Commit 6ed698c4 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWriter - extending convert content (styles, elements, ...)

parent e1e58466
......@@ -82,7 +82,8 @@ void draw_shape::serialize_attlist(CP_ATTR_NODE)
void draw_rect_attlist::serialize(CP_ATTR_NODE)
{
CP_XML_ATTR_OPT(L"draw:filter-name", draw_filter_name_);
CP_XML_ATTR_OPT(L"draw:filter-name", draw_filter_name_);
CP_XML_ATTR_OPT(L"draw:corner-radius", draw_corner_radius_);
}
const wchar_t * draw_rect::ns = L"draw";
......
......@@ -70,10 +70,10 @@ class draw_rect_attlist
{
public:
_CP_OPT(std::wstring) draw_filter_name_;
_CP_OPT(odf_types::length) draw_corner_radius_;
_CP_OPT(std::wstring) draw_filter_name_;
void serialize(CP_ATTR_NODE);
};
class draw_rect : public draw_shape
......
......@@ -252,16 +252,16 @@ public:
bool is_footer_;
bool is_header_;
void create_draw_base(int type);
office_element_ptr create_draw_element(int type);
void create_draw_base(int type);
office_element_ptr create_draw_element(int type);
style_graphic_properties *current_graphic_properties;
style_paragraph_properties *current_paragraph_properties;
style_text_properties *current_text_properties;
anchor_settings anchor_settings_;
anchor_settings anchor_settings_;
graphic_format_properties preset_graphic_format_properties;
graphic_format_properties preset_graphic_format_properties;
odf_group_state_ptr current_group_;
......@@ -270,7 +270,7 @@ public:
std::vector<office_element_ptr> tops_elements_;
office_element_ptr root_element_;
office_element_ptr root_element_;
double x;
double y;
......@@ -1354,9 +1354,16 @@ void odf_drawing_context::set_horizontal_pos(double offset_pt)
impl_->anchor_settings_.style_horizontal_pos_svg_x_ = length(length(offset_pt,length::pt).get_value_unit(length::cm),length::cm);
impl_->x = offset_pt;
}
void odf_drawing_context::set_default_wrap_style()
{
if (impl_->is_header_ || impl_->is_footer_ )
{
impl_->anchor_settings_.style_wrap_ = style_wrap::RunThrough;
}
}
void odf_drawing_context::set_wrap_style(style_wrap::type type)
{
impl_->anchor_settings_.style_wrap_ = style_wrap(type);
}
void odf_drawing_context::set_overlap (bool val)
......@@ -1612,6 +1619,20 @@ void odf_drawing_context::set_line_head(int type, int len, int width)
impl_->current_graphic_properties->content().draw_marker_start_width_ = length(0.2,length::cm); break;
}
}
void odf_drawing_context::set_corner_radius (odf_types::length corner)
{
if (impl_->current_level_.empty())return;
draw_rect* draw = dynamic_cast<draw_rect*>(impl_->current_level_.back().get());
if (draw)
{
draw->draw_rect_attlist_.draw_corner_radius_ = corner;
}
}
std::wstring odf_drawing_context::add_marker_style(int type)
{
if (type == 2) return L"";
......
......@@ -39,6 +39,7 @@
#include "office_elements_create.h"
#include "length.h"
#include "anchortype.h"
#include "stylewrap.h"
#include "gradientstyle.h"
......@@ -86,6 +87,7 @@ public:
void set_horizontal_pos (int align);
void set_horizontal_pos (double offset_pt);
void set_default_wrap_style();
void set_wrap_style (odf_types::style_wrap::type style);
void set_overlap (bool val);
......@@ -108,6 +110,8 @@ public:
void set_group_scale (double cx, double cy);
void set_group_shift (double x, double y);
void set_corner_radius (odf_types::length corner);
void end_group();
void start_shape (int type);
......
......@@ -101,13 +101,6 @@ void odf_text_context::set_single_object(bool bSingle, style_paragraph_propertie
single_paragraph_ = bSingle;
paragraph_properties_ = para_props;
text_properties_ = text_props;
//if (paragraph_properties_)//??? а могут ли быть разрывы после-до диаграммы???
//{
// paragraph_properties_->content().fo_break_before_ = need_break_;
// need_break_ = boost::none;
//}
}
void odf_text_context::add_text_content(const std::wstring & text)
......@@ -605,7 +598,8 @@ bool odf_text_context::set_master_page_name (std::wstring & master_page_name)
style *style_ = dynamic_cast<style*>(current_level_.back().style_elm.get());
if (!style_) return false;
if (!style_)
return false;
style_->style_master_page_name_ = master_page_name;
return true;
......
......@@ -287,7 +287,7 @@ void odt_conversion_context::add_page_break()
office_element_ptr elm;
create_element(L"text", L"soft-page-break", elm, this);
if (current_root_elements_.size() > 0/* && text_context()->is_need_break()*/)
if (current_root_elements_.size() > 0)
{
text_p* para = NULL;
style * style_ = NULL;
......@@ -303,6 +303,7 @@ void odt_conversion_context::add_page_break()
{
//тут получается что разрыв будет прописан внутри элемента (не параграфа) - так что вручную свойство запишем
//в случае разрыва параграфов оно запишется при старте после-разрывного параграфа
text_context()->set_type_break(1, 0);
text_context()->save_property_break();
}
text_context()->start_element(elm);
......@@ -311,7 +312,7 @@ void odt_conversion_context::add_page_break()
if (para)
{
styles_context()->create_style(L"",odf_types::style_family::Paragraph, true, false, -1);
styles_context()->create_style(L"", odf_types::style_family::Paragraph, true, false, -1);
//styles_context()->last_state().apply_from(style_);
if (style_ )
{
......@@ -332,15 +333,15 @@ void odt_conversion_context::add_page_break()
void odt_conversion_context::start_hyperlink(std::wstring ref)
{
office_element_ptr hyperlink_elm;
create_element(L"text", L"a",hyperlink_elm,this);
create_element(L"text", L"a", hyperlink_elm, this);
text_a* hyperlink = dynamic_cast<text_a*>(hyperlink_elm.get());
if (!hyperlink)return;
////////////////////////////
hyperlink->common_xlink_attlist_.href_ = ref;
hyperlink->common_xlink_attlist_.type_= xlink_type::Simple;
hyperlink->common_xlink_attlist_.href_ = ref;
hyperlink->common_xlink_attlist_.type_ = xlink_type::Simple;
//current_level_.back()->add_child_element(hyperlink_elm);
//current_level_.push_back(hyperlink_elm);
......
......@@ -51,7 +51,7 @@ namespace odf_writer {
using xml::xml_char_wc;
// style:tab-stop
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_tab_stop::ns = L"style";
const wchar_t * style_tab_stop::name = L"tab-stop";
......@@ -75,7 +75,6 @@ void style_tab_stop::serialize(std::wostream & strm)
}
}
}
// style:tab-stop
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_tab_stops::ns = L"style";
const wchar_t * style_tab_stops::name = L"tab-stops";
......@@ -97,7 +96,7 @@ void style_tab_stops::add_child_element( const office_element_ptr & child_elemen
{
style_tab_stops_.push_back(child_element);
}
// style:drop-cap
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_drop_cap::ns = L"style";
const wchar_t * style_drop_cap::name = L"drop-cap";
......@@ -116,7 +115,7 @@ void style_drop_cap::serialize(std::wostream & strm)
}
}
// style:background-image
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_background_image::ns = L"style";
const wchar_t * style_background_image::name = L"background-image";
......@@ -287,41 +286,40 @@ void paragraph_format_properties::clear()
fo_hyphenation_keep_ = boost::none;
fo_hyphenation_ladder_count_= boost::none;
style_register_true_ = boost::none;
fo_margin_left_ = boost::none;
fo_margin_right_ = boost::none;
fo_margin_left_ = boost::none;
fo_margin_right_ = boost::none;
//fo_text_indent_ = boost::none;//заточено под буквицу
style_auto_text_indent_ = boost::none;
fo_margin_top_ = boost::none;
fo_margin_bottom_ = boost::none;
fo_margin_ = boost::none;
fo_break_before_ = boost::none;
fo_break_after_ = boost::none;
fo_background_color_ = boost::none;
fo_padding_ = boost::none;
fo_padding_top_ = boost::none;
fo_padding_bottom_ = boost::none;
fo_padding_left_ = boost::none;
fo_padding_right_ = boost::none;
outline_level_ = boost::none;
style_page_number_ = boost::none;
style_snap_to_layout_grid_= boost::none;
style_join_border_ = boost::none;
style_text_autospace_ = boost::none;
fo_keep_with_next_ = boost::none;
fo_background_color_ = boost::none;
style_vertical_align_ = boost::none;
style_writing_mode_ = boost::none;
style_auto_text_indent_ = boost::none;
fo_margin_top_ = boost::none;
fo_margin_bottom_ = boost::none;
fo_margin_ = boost::none;
fo_break_before_ = boost::none;
fo_break_after_ = boost::none;
fo_background_color_ = boost::none;
fo_padding_ = boost::none;
fo_padding_top_ = boost::none;
fo_padding_bottom_ = boost::none;
fo_padding_left_ = boost::none;
fo_padding_right_ = boost::none;
outline_level_ = boost::none;
style_page_number_ = boost::none;
style_snap_to_layout_grid_ = boost::none;
style_join_border_ = boost::none;
style_text_autospace_ = boost::none;
fo_keep_with_next_ = boost::none;
fo_background_color_ = boost::none;
style_vertical_align_ = boost::none;
style_writing_mode_ = boost::none;
style_writing_mode_automatic_= boost::none;
style_line_break_ = boost::none;
style_line_break_ = boost::none;
style_background_transparency_= boost::none;
style_text_autospace_= boost::none;
text_line_number_ = boost::none;
style_line_break_ = boost::none;
text_number_lines_ = boost::none;
style_shadow_ = boost::none;
style_text_autospace_ = boost::none;
text_line_number_ = boost::none;
style_line_break_ = boost::none;
text_number_lines_ = boost::none;
style_shadow_ = boost::none;
//todo borders !!!
//todooo borders
}
void paragraph_format_properties::apply_from(paragraph_format_properties & Other)
......
......@@ -76,7 +76,6 @@ namespace oox{
namespace odf_writer {
/// \class style_tab_stop
class style_tab_stop : public office_element_impl<style_tab_stop>
{
public:
......@@ -108,7 +107,6 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(style_tab_stop)
/// \class style_tab_stops
class style_tab_stops : public office_element_impl<style_tab_stops>
{
public:
......@@ -131,7 +129,7 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(style_tab_stops)
/// \class style_drop_cap
class style_drop_cap : public office_element_impl<style_drop_cap>
{
public:
......@@ -157,8 +155,6 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(style_drop_cap)
/// \class style_background_image
/// style:background-image
class style_background_image : public office_element_impl<style_background_image>
{
public:
......@@ -186,7 +182,6 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(style_background_image)
/// \class paragraph_format_properties
class paragraph_format_properties
{
public:
......@@ -265,7 +260,6 @@ public:
};
/// \class style_paragraph_properties
class style_paragraph_properties : public office_element_impl<style_paragraph_properties>
{
public:
......
......@@ -69,7 +69,6 @@ namespace cpdoccore {
namespace odf_writer {
// 15.4
class text_format_properties_content
{
public:
......@@ -79,13 +78,11 @@ public:
void set_r_style(const std::wstring & rStyle) { r_style_ = rStyle; }
private:
//static double process_font_size_impl(const _CP_OPT(font_size) & FontSize, const style_instance * currnetStyle, bool Complex = false, double Mul = 1.0);
//static int process_font_weight(const optional<font_weight>::Type & FontWeight);
//static int process_font_style(const optional<font_style>::Type & FontStyle);
void clear();
public:
_CP_OPT(std::wstring) r_style_;
_CP_OPT(std::wstring) r_style_;
_CP_OPT(odf_types::font_variant) fo_font_variant_;
_CP_OPT(odf_types::text_transform) fo_text_transform_;
_CP_OPT(odf_types::color) fo_color_;
......@@ -97,44 +94,44 @@ public:
_CP_OPT(odf_types::line_style) style_text_line_through_style_;
_CP_OPT(odf_types::line_width) style_text_line_through_width_;
_CP_OPT(odf_types::color) style_text_line_through_color_;
_CP_OPT(std::wstring) style_text_line_through_text_;
_CP_OPT(std::wstring) style_text_line_through_text_;
_CP_OPT(odf_types::style_ref) style_text_line_through_text_style_;
_CP_OPT(odf_types::text_position) style_text_position_;
_CP_OPT(std::wstring) style_font_name_;
_CP_OPT(std::wstring) style_font_name_asian_;
_CP_OPT(std::wstring) style_font_name_complex_;
_CP_OPT(std::wstring) style_font_name_;
_CP_OPT(std::wstring) style_font_name_asian_;
_CP_OPT(std::wstring) style_font_name_complex_;
_CP_OPT(std::wstring) fo_font_family_;
_CP_OPT(std::wstring) style_font_family_asian_;
_CP_OPT(std::wstring) style_font_family_complex_;
_CP_OPT(std::wstring) fo_font_family_;
_CP_OPT(std::wstring) style_font_family_asian_;
_CP_OPT(std::wstring) style_font_family_complex_;
_CP_OPT(odf_types::font_family_generic) style_font_family_generic_;
_CP_OPT(odf_types::font_family_generic) style_font_family_generic_asian_;
_CP_OPT(odf_types::font_family_generic) style_font_family_generic_complex_;
_CP_OPT(std::wstring) style_font_style_name_;
_CP_OPT(std::wstring) style_font_style_name_asian_;
_CP_OPT(std::wstring) style_font_style_name_complex_;
_CP_OPT(std::wstring) style_font_style_name_;
_CP_OPT(std::wstring) style_font_style_name_asian_;
_CP_OPT(std::wstring) style_font_style_name_complex_;
_CP_OPT(odf_types::font_pitch) style_font_pitch_;
_CP_OPT(odf_types::font_pitch) style_font_pitch_asian_;
_CP_OPT(odf_types::font_pitch) style_font_pitch_complex_;
_CP_OPT(odf_types::font_pitch) style_font_pitch_;
_CP_OPT(odf_types::font_pitch) style_font_pitch_asian_;
_CP_OPT(odf_types::font_pitch) style_font_pitch_complex_;
_CP_OPT(std::wstring) style_font_charset_;
_CP_OPT(std::wstring) style_font_charset_asian_;
_CP_OPT(std::wstring) style_font_charset_complex_;
_CP_OPT(std::wstring) style_font_charset_;
_CP_OPT(std::wstring) style_font_charset_asian_;
_CP_OPT(std::wstring) style_font_charset_complex_;
_CP_OPT(odf_types::font_size) fo_font_size_;
_CP_OPT(odf_types::font_size) style_font_size_asian_;
_CP_OPT(odf_types::font_size) style_font_size_complex_;
_CP_OPT(odf_types::font_size) fo_font_size_;
_CP_OPT(odf_types::font_size) style_font_size_asian_;
_CP_OPT(odf_types::font_size) style_font_size_complex_;
_CP_OPT(odf_types::length) style_font_size_rel_;
_CP_OPT(odf_types::length) style_font_size_rel_asian_;
_CP_OPT(odf_types::length) style_font_size_rel_complex_;
_CP_OPT(odf_types::length) style_font_size_rel_;
_CP_OPT(odf_types::length) style_font_size_rel_asian_;
_CP_OPT(odf_types::length) style_font_size_rel_complex_;
_CP_OPT(odf_types::script_type) style_script_type_;
_CP_OPT(odf_types::script_type) style_script_type_;
_CP_OPT(odf_types::letter_spacing) fo_letter_spacing_;
......@@ -172,28 +169,28 @@ public:
_CP_OPT(odf_types::background_color) fo_background_color_;
_CP_OPT(odf_types::text_combine) style_text_combine_;
_CP_OPT(odf_types::text_combine) style_text_combine_;
_CP_OPT(wchar_t) style_text_combine_start_char_;
_CP_OPT(wchar_t) style_text_combine_end_char_;
_CP_OPT(wchar_t) style_text_combine_start_char_;
_CP_OPT(wchar_t) style_text_combine_end_char_;
_CP_OPT(odf_types::text_emphasize) style_text_emphasize_;
_CP_OPT(odf_types::percent) style_text_scale_;
_CP_OPT(int) style_text_rotation_angle_;
_CP_OPT(odf_types::text_emphasize) style_text_emphasize_;
_CP_OPT(odf_types::percent) style_text_scale_;
_CP_OPT(int) style_text_rotation_angle_;
_CP_OPT(odf_types::text_rotation_scale) style_text_rotation_scale_;
_CP_OPT(odf_types::Bool) fo_hyphenate_;
_CP_OPT(unsigned int) fo_hyphenation_remain_char_count_;
_CP_OPT(unsigned int) fo_hyphenation_push_char_count_;
_CP_OPT(odf_types::Bool) fo_hyphenate_;
_CP_OPT(unsigned int) fo_hyphenation_remain_char_count_;
_CP_OPT(unsigned int) fo_hyphenation_push_char_count_;
_CP_OPT(odf_types::text_display) text_display_;
_CP_OPT(odf_types::text_display) text_display_;
_CP_OPT(std::wstring) text_condition_;
_CP_OPT(std::wstring) text_condition_;
_CP_OPT(std::wstring) style_text_overline_color_;
_CP_OPT(std::wstring) style_text_overline_mode_;
_CP_OPT(std::wstring) style_text_overline_style_;
_CP_OPT(std::wstring) style_text_overline_color_;
_CP_OPT(std::wstring) style_text_overline_mode_;
_CP_OPT(std::wstring) style_text_overline_style_;
odf_types::common_border_attlist common_border_attlist_;
......@@ -202,8 +199,6 @@ public:
class style_text_properties;
typedef shared_ptr<style_text_properties>::Type style_text_properties_ptr;
/// \class style_text_properties
/// style:text-properties
class style_text_properties : public office_element_impl<style_text_properties>
{
public:
......@@ -221,8 +216,8 @@ public:
virtual void serialize(std::wostream & strm);
const text_format_properties_content & content() const { return text_format_properties_content_; } ;
text_format_properties_content & content() { return text_format_properties_content_; } ;
const text_format_properties_content & content() const { return text_format_properties_content_; } ;
text_format_properties_content & content() { return text_format_properties_content_; } ;
style_text_properties(){};
style_text_properties(const std::wstring & rStyle){ text_format_properties_content_.set_r_style(rStyle); };
......
......@@ -413,17 +413,17 @@ void style::serialize(std::wostream & strm)
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"style:default-outline-level", style_default_outline_level_);
CP_XML_ATTR_OPT(L"style:parent-style-name", style_parent_style_name_);
CP_XML_ATTR_OPT(L"style:next-style-name", style_next_style_name_);
CP_XML_ATTR_OPT(L"style:list-style-name", style_list_style_name_);
CP_XML_ATTR_OPT(L"style:auto-update", style_auto_update_);
CP_XML_ATTR_OPT(L"style:data-style-name", style_data_style_name_);
CP_XML_ATTR_OPT(L"style:class", style_class_);
CP_XML_ATTR_OPT(L"style:master-page-name", style_master_page_name_);
CP_XML_ATTR_OPT(L"style:display-name", style_display_name_);
CP_XML_ATTR(L"style:family", style_family_);
CP_XML_ATTR(L"style:name", style_name_);
CP_XML_ATTR_OPT(L"style:default-outline-level", style_default_outline_level_);
CP_XML_ATTR_OPT(L"style:parent-style-name", style_parent_style_name_);
CP_XML_ATTR_OPT(L"style:next-style-name", style_next_style_name_);
CP_XML_ATTR_OPT(L"style:list-style-name", style_list_style_name_);
CP_XML_ATTR_OPT(L"style:auto-update", style_auto_update_);
CP_XML_ATTR_OPT(L"style:data-style-name", style_data_style_name_);
CP_XML_ATTR_OPT(L"style:class", style_class_);
CP_XML_ATTR_OPT(L"style:master-page-name", style_master_page_name_);
CP_XML_ATTR_OPT(L"style:display-name", style_display_name_);
CP_XML_ATTR(L"style:family", style_family_);
CP_XML_ATTR(L"style:name", style_name_);
style_content_.serialize(CP_XML_STREAM());
}
......
......@@ -142,6 +142,16 @@ void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style, bool group)
{
switch(vml_style->m_arrProperties[i]->get_Value().eMsoPosHorRel)
{
case SimpleTypes::Vml::cssmsoposhorrelRightMargin:
{
anchor_type_x = 2;
odf_context()->drawing_context()->set_horizontal_rel(5);
}break;
case SimpleTypes::Vml::cssmsoposhorrelLeftMargin:
{
anchor_type_x = 2;
odf_context()->drawing_context()->set_horizontal_rel(4);
}break;
case SimpleTypes::Vml::cssmsoposhorrelMargin:
{
anchor_type_x = 2;
......@@ -175,6 +185,13 @@ void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style, bool group)
{
switch(vml_style->m_arrProperties[i]->get_Value().eMsoPosVerRel)
{
case SimpleTypes::Vml::cssmsoposverrelBottomMargin:
{
anchor_type_y = 2;
odf_context()->drawing_context()->set_vertical_pos(0);
odf_context()->drawing_context()->set_vertical_rel(3);
}break;
case SimpleTypes::Vml::cssmsoposverrelTopMargin:
case SimpleTypes::Vml::cssmsoposverrelMargin:
{
anchor_type_y = 2;
......@@ -673,6 +690,8 @@ void OoxConverter::convert(OOX::VmlWord::CWrap *vml_wrap)
{
if (vml_wrap == NULL) return;
odf_context()->drawing_context()->set_default_wrap_style();
if (vml_wrap->m_oType.IsInit())
{
switch(vml_wrap->m_oType->GetValue())
......@@ -709,6 +728,7 @@ void OoxConverter::convert(OOX::VmlWord::CWrap *vml_wrap)
}break;
}
}
bool anchor_page_x = false;
if (vml_wrap->m_oAnchorX.IsInit())
{
......@@ -747,6 +767,7 @@ void OoxConverter::convert(OOX::VmlWord::CWrap *vml_wrap)
odf_context()->drawing_context()->set_vertical_rel(2);//Line
}
}
}
void OoxConverter::convert(OOX::Vml::CVmlCommonElements *vml_common)
{
......
......@@ -408,8 +408,14 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
{
if (oox_paragraph == NULL) return;
bool bStyled = false;
if (current_section_properties)
{
if (odt_context->text_context()->get_KeepNextParagraph())
odt_context->end_paragraph();
odt_context->text_context()->set_KeepNextParagraph(false);
}
bool bStyled = false;
bool bStartNewParagraph = !odt_context->text_context()->get_KeepNextParagraph();
bool list_present = false;
......@@ -425,7 +431,7 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
std::wstring style_name = string2std_string(*oox_paragraph->m_oParagraphProperty->m_oPStyle->m_sVal);
odf_writer::odf_style_state_ptr style_state;
if (odt_context->styles_context()->find_odf_style_state(style_name,odf_types::style_family::Paragraph, style_state) && style_state)
if (odt_context->styles_context()->find_odf_style_state(style_name, odf_types::style_family::Paragraph, style_state) && style_state)
{
list_present = style_state->get_list_style_exist();
list_level = style_state->get_list_style_level();
......@@ -451,27 +457,38 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
}
if (oox_paragraph->m_oParagraphProperty || odt_context->is_empty_section() || current_section_properties)
{
bStyled = true;
odf_writer::style_paragraph_properties *paragraph_properties = NULL;
bStyled = true;
bool bRunPara = oox_paragraph->m_oParagraphProperty ? (oox_paragraph->m_oParagraphProperty->m_oRPr.IsInit() ? true : false) : false;
odf_writer::style_paragraph_properties *paragraph_properties = NULL;
odf_writer::style_text_properties *text_properties = NULL;
if (odt_context->text_context()->get_KeepNextParagraph())
{
odf_writer::odf_style_state_ptr state = odt_context->styles_context()->last_state(odf_types::style_family::Paragraph);
if (state)
{
paragraph_properties = state->get_paragraph_properties();
paragraph_properties = state->get_paragraph_properties();
if (bRunPara)
text_properties = state->get_text_properties();
if (oox_paragraph->m_oParagraphProperty && oox_paragraph->m_oParagraphProperty->m_oPStyle.IsInit() && oox_paragraph->m_oParagraphProperty->m_oPStyle->m_sVal.IsInit())
{
//перезатираем все свойства ... наложение не катит -- ваще то надо чистить после буквицы (Nadpis.docx) .. проверить надобность с остальными случами
paragraph_properties->content().clear();
if (text_properties)
text_properties->content().clear();
}
}
}
else
{
odt_context->styles_context()->create_style(L"",odf_types::style_family::Paragraph, true, false, -1);
paragraph_properties = odt_context->styles_context()->last_state()->get_paragraph_properties();
odt_context->styles_context()->create_style(L"", odf_types::style_family::Paragraph, true, false, -1);
paragraph_properties = odt_context->styles_context()->last_state()->get_paragraph_properties();
if (bRunPara)
text_properties = odt_context->styles_context()->last_state()->get_text_properties();
if(list_present && list_style_id >= 0)
{
......@@ -480,7 +497,9 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
}
}
convert(oox_paragraph->m_oParagraphProperty, paragraph_properties);
if (text_properties && oox_paragraph->m_oParagraphProperty)
convert(oox_paragraph->m_oParagraphProperty->m_oRPr.GetPointer(), text_properties);
}
else
{
......@@ -495,6 +514,21 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
if ((list_present = odt_context->text_context()->get_list_item_state()) == false) odt_context->set_no_list();
if (oox_paragraph->m_arrItems.size() < 2 && odt_context->text_context()->get_KeepNextParagraph())
{//rapcomnat12.docx - стр 185
bool empty_para = true;
for (unsigned int nIndex = 0; empty_para && nIndex < oox_paragraph->m_arrItems.size(); nIndex++ )
{
switch(oox_paragraph->m_arrItems[nIndex]->getType())
{
case OOX::et_w_pPr: break;
default:
empty_para = false;
}
}
if (empty_para) return;
}
if (bStartNewParagraph)
{
odt_context->start_paragraph(bStyled);
......@@ -579,12 +613,20 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
}break;
case OOX::et_w_lastRenderedPageBreak:
{
//odt_context->text_context()->add_page_break(); выше
//odt_context->add_page_break();
}break;
case OOX::et_w_br:
{
OOX::Logic::CBr* pBr= static_cast<OOX::Logic::CBr*>(oox_run->m_arrItems[i]);
if (pBr)odt_context->text_context()->set_type_break(pBr->m_oType.GetValue(), pBr->m_oClear.GetValue());
if (pBr)
{
int type = pBr->m_oType.GetValue();
if (type == 1)
odt_context->add_page_break();
else
odt_context->text_context()->set_type_break(type, pBr->m_oClear.GetValue());
}
}break;
case OOX::et_w_t:
{
......@@ -924,25 +966,36 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
odt_context->text_context()->set_type_break(1, 0); //page, clear_all
}
if (oox_paragraph_pr->m_oKeepNext.IsInit() && odt_context->table_context()->empty()/* && !oox_paragraph_pr->m_oFramePr.IsInit()*/)
if (oox_paragraph_pr->m_oKeepNext.IsInit() && odt_context->table_context()->empty() && !current_section_properties)
{
odt_context->text_context()->set_KeepNextParagraph(true);
}
convert(oox_paragraph_pr->m_oFramePr.GetPointer(), paragraph_properties); //буквица или фрейм
if (current_section_properties)
if (current_section_properties)
{
if ((current_section_properties->props) && (current_section_properties->props->m_oPgNumType.IsInit()) && (current_section_properties->props->m_oPgNumType->m_oStart.IsInit()))
{
paragraph_properties->content().style_page_number_ = current_section_properties->props->m_oPgNumType->m_oStart->GetValue();
}
convert(current_section_properties->props, current_section_properties->root);
//odf_writer::odf_style_state_ptr state = odt_context->styles_context()->last_state(odf_types::style_family::Paragraph);
//if (odt_context->is_paragraph_in_current_section_ && state)
//{
// odf_writer::style *style_ = dynamic_cast<odf_writer::style*>(state->get_office_element().get());
// if (style_)
// {
// odt_context->is_paragraph_in_current_section_ = false;
// style_->style_master_page_name_ = odt_context->page_layout_context()->last_master() ?
// odt_context->page_layout_context()->last_master()->get_name() : L"";
// }
//}
}
//if (oox_paragraph_pr->m_oSectPr.IsInit())
//{
// convert(oox_paragraph_pr->m_oSectPr.GetPointer()); перенесено выше
//}
if (oox_paragraph_pr->m_oTabs.IsInit())
{
......@@ -2093,7 +2146,10 @@ void DocxConverter::convert(OOX::Logic::CPicture* oox_pic)
else if (oox_pic->m_oShapeRoundRect.IsInit())
{
odf_context()->drawing_context()->set_name(L"RoundRect");
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeRoundRect);
odf_context()->drawing_context()->start_shape(SimpleTypes::shapetypeRect);
odf_types::length corner = odf_types::length(0.5, odf_types::length::cm);
odf_context()->drawing_context()->set_corner_radius(corner);
OoxConverter::convert(oox_pic->m_oShape.GetPointer());
OoxConverter::convert(oox_pic->m_oShapeRoundRect.GetPointer());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment