Commit ed3c83cb authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWriter - odt - change page layouts, fix write anchor vml shapes

parent 39e3a29c
......@@ -1178,6 +1178,7 @@ void odf_drawing_context::set_flip_V(bool bVal)
void odf_drawing_context::set_rotate(double dVal)
{
if (dVal > 180) dVal = dVal - 360;
double dRotate = dVal / 180. * 3.14159265358979323846;
impl_->current_drawing_state_.rotateAngle = dRotate;
}
......@@ -1267,14 +1268,14 @@ void odf_drawing_context::set_vertical_rel(int from)
switch(from)
{
case 0: type = vertical_rel::Baseline; break;// relfromvBottomMargin ???
case 1: type = vertical_rel::PageContent; break;// relfromvInsideMargin ???
case 2: type = vertical_rel::Baseline; break;// relfromvLine
case 3: type = vertical_rel::Paragraph; set_anchor(anchor_type::Paragraph); break;// relfromvMargin
case 4: type = vertical_rel::Baseline; break;// relfromvOutsideMargin ???
case 5: type = vertical_rel::Page; set_anchor(anchor_type::Page); break;// relfromvPage
case 6: type = vertical_rel::Paragraph; set_anchor(anchor_type::Paragraph); break;// relfromvParagraph
case 7: type = vertical_rel::Baseline; break;// relfromvTopMargin ???
case 0: type = vertical_rel::Baseline; break;// relfromvBottomMargin ???
case 1: type = vertical_rel::PageContent; break;// relfromvInsideMargin ???
case 2: type = vertical_rel::Baseline; break;// relfromvLine
case 3: type = vertical_rel::Paragraph; break;// relfromvMargin
case 4: type = vertical_rel::Baseline; break;// relfromvOutsideMargin ???
case 5: type = vertical_rel::Page; break;// relfromvPage
case 6: type = vertical_rel::Paragraph; break;// relfromvParagraph
case 7: type = vertical_rel::Baseline; break;// relfromvTopMargin ???
}
impl_->anchor_settings_.style_vertical_rel_ = vertical_rel(type);
......@@ -1287,11 +1288,11 @@ void odf_drawing_context::set_vertical_pos(int align)
vertical_pos::type type;
switch(align)
{
case 0: type = vertical_pos::Bottom; break;//alignvBottom = 0,
case 1: type = vertical_pos::Middle; break;//alignvCenter = 1,
case 2: type = vertical_pos::FromTop; break;//alignvInside = 2, ???
case 3: type = vertical_pos::Below; break;//alignvOutside = 3, ???
case 4: type = vertical_pos::Top; break;//alignvTop = 4
case 0: type = vertical_pos::Bottom; break;//alignvBottom = 0,
case 1: type = vertical_pos::Middle; break;//alignvCenter = 1,
case 2: type = vertical_pos::FromTop; break;//alignvInside = 2, ???
case 3: type = vertical_pos::Below; break;//alignvOutside = 3, ???
case 4: type = vertical_pos::Top; break;//alignvTop = 4
}
impl_->anchor_settings_.style_vertical_pos_ = vertical_pos(type);
}
......@@ -1327,14 +1328,14 @@ void odf_drawing_context::set_horizontal_pos(int align)
switch(align)
{
case 0: type = horizontal_pos::Center; break;//alignhCenter = 0,
case 1: type = horizontal_pos::FromInside; break;//alignhInside = 1,
case 2: type = horizontal_pos::FromLeft; break;//alignhLeft = 2,
case 3: type = horizontal_pos::Outside; break;//alignhOutside = 3,
case 4: type = horizontal_pos::Right;
if (impl_->anchor_settings_.style_horizontal_rel_ && impl_->anchor_settings_.style_horizontal_rel_->get_type() == horizontal_rel::ParagraphStartMargin)
impl_->anchor_settings_.style_horizontal_rel_ = horizontal_rel::ParagraphEndMargin;
break;//alignhRight = 4
case 0: type = horizontal_pos::Center; break;//alignhCenter = 0,
case 1: type = horizontal_pos::FromInside; break;//alignhInside = 1,
case 2: type = horizontal_pos::FromLeft; break;//alignhLeft = 2,
case 3: type = horizontal_pos::Outside; break;//alignhOutside = 3,
case 4: type = horizontal_pos::Right;
if (impl_->anchor_settings_.style_horizontal_rel_ && impl_->anchor_settings_.style_horizontal_rel_->get_type() == horizontal_rel::ParagraphStartMargin)
impl_->anchor_settings_.style_horizontal_rel_ = horizontal_rel::ParagraphEndMargin;
break;//alignhRight = 4
}
impl_->anchor_settings_.style_horizontal_pos_ = horizontal_pos(type);
}
......
......@@ -428,93 +428,44 @@ bool odf_page_layout_context::add_header(int type)
return true;
}
void odf_page_layout_context::set_page_border_padding_bottom(int offset_type, int type, double length_pt)
void odf_page_layout_context::set_page_border_offset (int type)
{
if (type < 1) return;
style_page_layout_properties * props = get_properties();
if (!props)return;
length length_ = length(length(length_pt,length::pt).get_value_unit(length::cm),length::cm);
if (offset_type == 2 && props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_bottom_)
{
length new_margin = length_;
length_ = props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_bottom_->get_length() - length_;
props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_bottom_ = new_margin;
}
props->style_page_layout_properties_attlist_.common_padding_attlist_.fo_padding_bottom_ = length_;
}
void odf_page_layout_context::set_page_border_padding_top(int offset_type, int type, double length_pt)
{
if (type < 1) return;
style_page_layout_properties * props = get_properties();
if (!props)return;
length length_ = length(length(length_pt,length::pt).get_value_unit(length::cm),length::cm);
if (offset_type == 2 && props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_top_)
{
length new_margin = length_;
length_ = props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_top_->get_length() - length_;
props->style_page_layout_properties_attlist_.common_vertical_margin_attlist_.fo_margin_top_ = new_margin;
}
props->style_page_layout_properties_attlist_.common_padding_attlist_.fo_padding_top_ = length_;
props->style_page_layout_properties_attlist_.offset_page_border_ = type;
}
void odf_page_layout_context::set_page_border_padding_left(int offset_type, int type, double length_pt)
void odf_page_layout_context::set_page_border_padding(int border, double length_pt)
{
if (type < 1) return;
style_page_layout_properties * props = get_properties();
if (!props)return;
length length_ = length(length(length_pt,length::pt).get_value_unit(length::cm),length::cm);
if (offset_type == 2 && props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_left_)
{
length new_margin = length_;
length_ = props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_left_->get_length() - length_;
props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_left_ = new_margin;
}
props->style_page_layout_properties_attlist_.common_padding_attlist_.fo_padding_left_ = length_;
}
length length_ = length(length(length_pt, length::pt).get_value_unit(length::cm), length::cm);
void odf_page_layout_context::set_page_border_padding_right(int offset_type, int type, double length_pt)
{
if (type < 1) return;
style_page_layout_properties * props = get_properties();
if (!props)return;
length length_ = length(length(length_pt,length::pt).get_value_unit(length::cm),length::cm);
if (offset_type == 2 && props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_right_)
switch (border)
{
length new_margin = length_;
length_ = props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_right_->get_length() - length_;
props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_right_ = new_margin;
case 1:
props->style_page_layout_properties_attlist_.common_padding_attlist_.fo_padding_top_ = length_; break;
case 2:
props->style_page_layout_properties_attlist_.common_padding_attlist_.fo_padding_bottom_ = length_; break;
case 3:
props->style_page_layout_properties_attlist_.common_padding_attlist_.fo_padding_left_ = length_; break;
case 4:
props->style_page_layout_properties_attlist_.common_padding_attlist_.fo_padding_right_ = length_; break;
}
props->style_page_layout_properties_attlist_.common_padding_attlist_.fo_padding_right_ = length_;
}
void odf_page_layout_context::set_page_border_shadow(bool val)
void odf_page_layout_context::set_page_border_shadow (bool val)
{
style_page_layout_properties * props = get_properties();
if (!props)return;
props->style_page_layout_properties_attlist_.common_shadow_attlist_.style_shadow_ = shadow_type::parse(L"#000000 0.159cm 0.159cm");
}
void odf_page_layout_context::set_page_border(std::wstring top, std::wstring left, std::wstring bottom, std::wstring right)
void odf_page_layout_context::set_page_border (std::wstring top, std::wstring left, std::wstring bottom, std::wstring right)
{
style_page_layout_properties * props = get_properties();
if (!props)return;
......
......@@ -83,10 +83,8 @@ public:
void set_page_border (std::wstring top, std::wstring left, std::wstring bottom, std::wstring right);
void set_page_border_shadow (bool val);
void set_page_border_padding_bottom (int offset_type, int type, double length_pt);
void set_page_border_padding_top (int offset_type, int type, double length_pt);
void set_page_border_padding_left (int offset_type, int type, double length_pt);
void set_page_border_padding_right (int offset_type, int type, double length_pt);
void set_page_border_padding (int border, double length_pt);
void set_page_border_offset (int type);
void set_page_orientation (int type);
void set_page_size (_CP_OPT(odf_types::length) width, _CP_OPT(odf_types::length) height);
......
......@@ -48,17 +48,88 @@ namespace cpdoccore {
namespace odf_writer {
/// style:page-layout-properties
//////////////////////////////////////////////////////////////////////////////////////////////////
void style_page_layout_properties_attlist::serialize(CP_ATTR_NODE)
{
CP_XML_ATTR_OPT(L"fo:page-width", fo_page_width_);
CP_XML_ATTR_OPT(L"fo:page-height", fo_page_height_);
if (offset_page_border_ == 2)
{
//from page to from text
if (common_padding_attlist_.fo_padding_)
{
if (common_margin_attlist_.fo_margin_)
{
length new_margin = *common_padding_attlist_.fo_padding_ ;
length new_padding = common_margin_attlist_.fo_margin_->get_length() - *common_padding_attlist_.fo_padding_;
common_margin_attlist_.fo_margin_ = new_margin;
common_padding_attlist_.fo_padding_ = new_padding;
}
else
{
common_padding_attlist_.fo_padding_top_ = common_padding_attlist_.fo_padding_bottom_ =
common_padding_attlist_.fo_padding_left_ = common_padding_attlist_.fo_padding_right_ = common_padding_attlist_.fo_padding_;
common_padding_attlist_.fo_padding_ = boost::none;
}
}
if (common_padding_attlist_.fo_padding_top_ && (common_vertical_margin_attlist_.fo_margin_top_ || common_margin_attlist_.fo_margin_))
{
if (!common_vertical_margin_attlist_.fo_margin_top_ )
common_vertical_margin_attlist_.fo_margin_top_ = common_margin_attlist_.fo_margin_;
length new_margin = *common_padding_attlist_.fo_padding_top_ ;
length new_padding = common_vertical_margin_attlist_.fo_margin_top_->get_length() - *common_padding_attlist_.fo_padding_top_ ;
common_vertical_margin_attlist_.fo_margin_top_ = new_margin;
common_padding_attlist_.fo_padding_top_ = new_padding;
}
if (common_padding_attlist_.fo_padding_bottom_ && (common_vertical_margin_attlist_.fo_margin_bottom_ || common_margin_attlist_.fo_margin_))
{
if (!common_vertical_margin_attlist_.fo_margin_bottom_ )
common_vertical_margin_attlist_.fo_margin_bottom_ = common_margin_attlist_.fo_margin_;
length new_margin = *common_padding_attlist_.fo_padding_bottom_ ;
length new_padding = common_vertical_margin_attlist_.fo_margin_bottom_->get_length() - *common_padding_attlist_.fo_padding_bottom_ ;
common_vertical_margin_attlist_.fo_margin_bottom_ = new_margin;
common_padding_attlist_.fo_padding_bottom_ = new_padding;
}
if (common_padding_attlist_.fo_padding_left_ && (common_horizontal_margin_attlist_.fo_margin_left_ || common_margin_attlist_.fo_margin_))
{
if (!common_horizontal_margin_attlist_.fo_margin_left_)
common_horizontal_margin_attlist_.fo_margin_left_ = common_margin_attlist_.fo_margin_;
length new_margin = *common_padding_attlist_.fo_padding_left_ ;
length new_padding = common_horizontal_margin_attlist_.fo_margin_left_->get_length() - *common_padding_attlist_.fo_padding_top_ ;
common_horizontal_margin_attlist_.fo_margin_left_ = new_margin;
common_padding_attlist_.fo_padding_left_ = new_padding;
}
if (common_padding_attlist_.fo_padding_right_ && (common_horizontal_margin_attlist_.fo_margin_right_ || common_margin_attlist_.fo_margin_))
{
if (!common_horizontal_margin_attlist_.fo_margin_right_)
common_horizontal_margin_attlist_.fo_margin_right_ = common_margin_attlist_.fo_margin_;
length new_margin = *common_padding_attlist_.fo_padding_right_ ;
length new_padding = common_horizontal_margin_attlist_.fo_margin_right_->get_length() - *common_padding_attlist_.fo_padding_right_ ;
common_horizontal_margin_attlist_.fo_margin_right_ = new_margin;
common_padding_attlist_.fo_padding_right_ = new_padding;
}
}
CP_XML_ATTR_OPT (L"fo:page-width", fo_page_width_);
CP_XML_ATTR_OPT (L"fo:page-height", fo_page_height_);
common_num_format_attlist_.serialize(CP_GET_XML_NODE());
common_num_format_prefix_suffix_attlist_.serialize(CP_GET_XML_NODE());
CP_XML_ATTR_OPT(L"style:paper-tray-name", style_paper_tray_name_);
CP_XML_ATTR_OPT(L"style:print-orientation", style_print_orientation_);
common_horizontal_margin_attlist_.serialize(CP_GET_XML_NODE());
CP_XML_ATTR_OPT (L"style:paper-tray-name", style_paper_tray_name_);
CP_XML_ATTR_OPT (L"style:print-orientation", style_print_orientation_);
common_horizontal_margin_attlist_.serialize(CP_GET_XML_NODE());
common_vertical_margin_attlist_.serialize(CP_GET_XML_NODE());
common_margin_attlist_.serialize(CP_GET_XML_NODE());
common_border_attlist_.serialize(CP_GET_XML_NODE());
......@@ -66,23 +137,24 @@ void style_page_layout_properties_attlist::serialize(CP_ATTR_NODE)
common_padding_attlist_.serialize(CP_GET_XML_NODE());
common_shadow_attlist_.serialize(CP_GET_XML_NODE());
common_background_color_attlist_.serialize(CP_GET_XML_NODE());
CP_XML_ATTR_OPT(L"style:register-truth-ref-style-name", style_register_truth_ref_style_name_);
CP_XML_ATTR_OPT(L"style:print", style_print_);
CP_XML_ATTR_OPT(L"style:print-page-order", style_print_page_order_);
CP_XML_ATTR_OPT(L"style:first-page-number", style_first_page_number_);
CP_XML_ATTR_OPT(L"style:scale-to", style_scale_to_);
CP_XML_ATTR_OPT(L"style:scale-to_pages", style_scale_to_pages_);
CP_XML_ATTR_OPT(L"style:table-centering", style_table_centering_);
CP_XML_ATTR_OPT(L"style:footnote-max-height", style_footnote_max_height_);
CP_XML_ATTR_OPT (L"style:register-truth-ref-style-name", style_register_truth_ref_style_name_);
CP_XML_ATTR_OPT (L"style:print", style_print_);
CP_XML_ATTR_OPT (L"style:print-page-order", style_print_page_order_);
CP_XML_ATTR_OPT (L"style:first-page-number", style_first_page_number_);
CP_XML_ATTR_OPT (L"style:scale-to", style_scale_to_);
CP_XML_ATTR_OPT (L"style:scale-to_pages", style_scale_to_pages_);
CP_XML_ATTR_OPT (L"style:table-centering", style_table_centering_);
CP_XML_ATTR_OPT (L"style:footnote-max-height", style_footnote_max_height_);
common_writing_mode_attlist_.serialize(CP_GET_XML_NODE());
CP_XML_ATTR_OPT(L"style:layout-grid-mode", style_layout_grid_mode_);
CP_XML_ATTR_OPT(L"style:layout-grid-base-height", style_layout_grid_base_height_);
CP_XML_ATTR_OPT(L"style:layout-grid-ruby-height", style_layout_grid_ruby_height_);
CP_XML_ATTR_OPT(L"style:layout-grid-lines", style_layout_grid_lines_);
CP_XML_ATTR_OPT(L"style:layout-grid-color", style_layout_grid_color_);
CP_XML_ATTR_OPT(L"style:layout-grid-ruby-below", style_layout_grid_ruby_below_);
CP_XML_ATTR_OPT(L"style:layout-grid-print", style_layout_grid_print_);
CP_XML_ATTR_OPT(L"style:layout-grid-display", style_layout_grid_display_);
CP_XML_ATTR_OPT (L"style:layout-grid-mode", style_layout_grid_mode_);
CP_XML_ATTR_OPT (L"style:layout-grid-base-height", style_layout_grid_base_height_);
CP_XML_ATTR_OPT (L"style:layout-grid-ruby-height", style_layout_grid_ruby_height_);
CP_XML_ATTR_OPT (L"style:layout-grid-lines", style_layout_grid_lines_);
CP_XML_ATTR_OPT (L"style:layout-grid-color", style_layout_grid_color_);
CP_XML_ATTR_OPT (L"style:layout-grid-ruby-below", style_layout_grid_ruby_below_);
CP_XML_ATTR_OPT (L"style:layout-grid-print", style_layout_grid_print_);
CP_XML_ATTR_OPT (L"style:layout-grid-display", style_layout_grid_display_);
}
const wchar_t * style_page_layout_properties::ns = L"style";
const wchar_t * style_page_layout_properties::name = L"page-layout-properties";
......@@ -108,7 +180,7 @@ void style_page_layout_properties::serialize(std::wostream & strm)
}
}
}
// style-page-layout-properties-elements
//////////////////////////////////////////////////////////////////////////////////////////////////
void style_page_layout_properties_elements::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name, odf_conversion_context * Context )
{
......@@ -143,14 +215,20 @@ void style_page_layout_properties_elements::add_child_element( const office_elem
style_columns_ = child;
break;
case typeStyleFootnoteSep:
style_footnote_sep_ = child;
style_footnote_sep_ = child;
break;
}
}
void style_page_layout_properties_elements::serialize(std::wostream & strm)
{
if (style_background_image_) style_background_image_->serialize(strm);
if (style_columns_) style_columns_->serialize(strm);
if (style_footnote_sep_) style_footnote_sep_->serialize(strm);
if (style_background_image_)
style_background_image_->serialize(strm);
if (style_columns_)
style_columns_->serialize(strm);
if (style_footnote_sep_)
style_footnote_sep_->serialize(strm);
}
}
......
......@@ -53,53 +53,53 @@
namespace cpdoccore {
namespace odf_writer {
// style:page-layout-properties-attlist
class style_page_layout_properties_attlist
{
public:
style_page_layout_properties_attlist() : offset_page_border_(1) {}
void serialize(CP_ATTR_NODE);
_CP_OPT(odf_types::length) fo_page_width_;
_CP_OPT(odf_types::length) fo_page_height_;
_CP_OPT(odf_types::length) fo_page_width_;
_CP_OPT(odf_types::length) fo_page_height_;
odf_types::common_num_format_attlist common_num_format_attlist_;
odf_types::common_num_format_prefix_suffix_attlist common_num_format_prefix_suffix_attlist_;
odf_types::common_num_format_prefix_suffix_attlist common_num_format_prefix_suffix_attlist_;
odf_types::common_horizontal_margin_attlist common_horizontal_margin_attlist_;
odf_types::common_horizontal_margin_attlist common_horizontal_margin_attlist_;
odf_types::common_vertical_margin_attlist common_vertical_margin_attlist_;
odf_types::common_margin_attlist common_margin_attlist_;
odf_types::common_border_attlist common_border_attlist_;
odf_types::common_border_line_width_attlist common_border_line_width_attlist_;
odf_types::common_padding_attlist common_padding_attlist_;
odf_types::common_shadow_attlist common_shadow_attlist_;
odf_types::common_border_attlist common_border_attlist_;
odf_types::common_border_line_width_attlist common_border_line_width_attlist_;
odf_types::common_padding_attlist common_padding_attlist_;
odf_types::common_shadow_attlist common_shadow_attlist_;
odf_types::common_background_color_attlist common_background_color_attlist_;
odf_types::common_writing_mode_attlist common_writing_mode_attlist_;
odf_types::common_background_color_attlist common_background_color_attlist_;
odf_types::common_writing_mode_attlist common_writing_mode_attlist_;
_CP_OPT(odf_types::style_ref) style_register_truth_ref_style_name_;
_CP_OPT(std::wstring) style_print_;
_CP_OPT(std::wstring) style_paper_tray_name_;
_CP_OPT(std::wstring) style_print_orientation_;
_CP_OPT(odf_types::direction) style_print_page_order_;
_CP_OPT(std::wstring) style_first_page_number_;
_CP_OPT(odf_types::percent) style_scale_to_;
_CP_OPT(unsigned int) style_scale_to_pages_;
_CP_OPT(odf_types::table_centering) style_table_centering_;
_CP_OPT(odf_types::length) style_footnote_max_height_;
_CP_OPT(odf_types::layout_grid_mode) style_layout_grid_mode_;
_CP_OPT(odf_types::length) style_layout_grid_base_height_;
_CP_OPT(odf_types::length) style_layout_grid_ruby_height_;
_CP_OPT(unsigned int) style_layout_grid_lines_;
_CP_OPT(odf_types::color) style_layout_grid_color_;
_CP_OPT(odf_types::Bool) style_layout_grid_ruby_below_;
_CP_OPT(odf_types::Bool) style_layout_grid_print_;
_CP_OPT(odf_types::Bool) style_layout_grid_display_;
_CP_OPT(odf_types::style_ref) style_register_truth_ref_style_name_;
_CP_OPT(std::wstring) style_print_;
_CP_OPT(std::wstring) style_paper_tray_name_;
_CP_OPT(std::wstring) style_print_orientation_;
_CP_OPT(odf_types::direction) style_print_page_order_;
_CP_OPT(std::wstring) style_first_page_number_;
_CP_OPT(odf_types::percent) style_scale_to_;
_CP_OPT(unsigned int) style_scale_to_pages_;
_CP_OPT(odf_types::table_centering) style_table_centering_;
_CP_OPT(odf_types::length) style_footnote_max_height_;
_CP_OPT(odf_types::layout_grid_mode) style_layout_grid_mode_;
_CP_OPT(odf_types::length) style_layout_grid_base_height_;
_CP_OPT(odf_types::length) style_layout_grid_ruby_height_;
_CP_OPT(unsigned int) style_layout_grid_lines_;
_CP_OPT(odf_types::color) style_layout_grid_color_;
_CP_OPT(odf_types::Bool) style_layout_grid_ruby_below_;
_CP_OPT(odf_types::Bool) style_layout_grid_print_;
_CP_OPT(odf_types::Bool) style_layout_grid_display_;
int offset_page_border_;
};
// style:page-layout-properties-elements
class style_page_layout_properties_elements
{
public:
......@@ -107,15 +107,13 @@ public:
void add_child_element( const office_element_ptr & child);
void serialize(std::wostream & strm);
office_element_ptr style_background_image_;
office_element_ptr style_columns_;
office_element_ptr style_background_image_;
office_element_ptr style_columns_;
// 15.2.20
office_element_ptr style_footnote_sep_;
};
// style:page-layout-properties
class style_page_layout_properties : public office_element_impl<style_page_layout_properties>
{
public:
......
......@@ -91,9 +91,9 @@ void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style, bool group)
{
if (vml_style == NULL) return;
_CP_OPT(double) width_pt, height_pt, x, y;
_CP_OPT(double) width, height, x, y, x2, y2; // in pt
bool anchor_set = false;
_CP_OPT(int) anchor_type_x, anchor_type_y;
for (unsigned int i=0; i < vml_style->m_arrProperties.size(); i++)
{
......@@ -102,10 +102,10 @@ void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style, bool group)
switch(vml_style->m_arrProperties[i]->get_Type())
{
case SimpleTypes::Vml::cssptHeight:
height_pt = vml_style->m_arrProperties[i]->get_Value().oValue.dValue;
height = vml_style->m_arrProperties[i]->get_Value().oValue.dValue;
break;
case SimpleTypes::Vml::cssptWidth:
width_pt = vml_style->m_arrProperties[i]->get_Value().oValue.dValue;
width = vml_style->m_arrProperties[i]->get_Value().oValue.dValue;
break;
case SimpleTypes::Vml::cssptTop:
y = vml_style->m_arrProperties[i]->get_Value().oValue.dValue;
......@@ -114,63 +114,88 @@ void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style, bool group)
x = vml_style->m_arrProperties[i]->get_Value().oValue.dValue;
break;
case SimpleTypes::Vml::cssptMarginBottom:
//odf_context()->drawing_context()->set_margin_bottom(vml_style->m_arrProperties[i].get_Value().oValue.dValue);
//x = vml_style->m_arrProperties[i].get_Value().oValue.dValue;
y2 = vml_style->m_arrProperties[i]->get_Value().oValue.dValue;
break;
case SimpleTypes::Vml::cssptMarginLeft:
//odf_context()->drawing_context()->set_margin_left (vml_style->m_arrProperties[i].get_Value().oValue.dValue);
x = vml_style->m_arrProperties[i]->get_Value().oValue.dValue;
break;
case SimpleTypes::Vml::cssptMarginRight:
//odf_context()->drawing_context()->set_margin_right(vml_style->m_arrProperties[i].get_Value().oValue.dValue);
x2 = vml_style->m_arrProperties[i]->get_Value().oValue.dValue;
break;
case SimpleTypes::Vml::cssptMarginTop:
//odf_context()->drawing_context()->set_margin_top(vml_style->m_arrProperties[i].get_Value().oValue.dValue);
y = vml_style->m_arrProperties[i]->get_Value().oValue.dValue;
break;
////////////////////////////////////////////////////////////////
case SimpleTypes::Vml::cssptMsoPositionHorizontal:
{
switch(vml_style->m_arrProperties[i]->get_Value().eMsoPosHor)
{
case SimpleTypes::Vml::cssmsoposhorAbsolute: odf_context()->drawing_context()->set_horizontal_pos(2); break;
case SimpleTypes::Vml::cssmsoposhorLeft: odf_context()->drawing_context()->set_horizontal_pos(2); break;
case SimpleTypes::Vml::cssmsoposhorCenter: odf_context()->drawing_context()->set_horizontal_pos(0); break;
case SimpleTypes::Vml::cssmsoposhorRight: odf_context()->drawing_context()->set_horizontal_pos(4); break;
case SimpleTypes::Vml::cssmsoposhorInside: odf_context()->drawing_context()->set_horizontal_pos(1); break;
case SimpleTypes::Vml::cssmsoposhorOutside : odf_context()->drawing_context()->set_horizontal_pos(3); break;
case SimpleTypes::Vml::cssmsoposhorAbsolute: odf_context()->drawing_context()->set_horizontal_pos(2); break;
case SimpleTypes::Vml::cssmsoposhorLeft: odf_context()->drawing_context()->set_horizontal_pos(2); break;
case SimpleTypes::Vml::cssmsoposhorCenter: odf_context()->drawing_context()->set_horizontal_pos(0); break;
case SimpleTypes::Vml::cssmsoposhorRight: odf_context()->drawing_context()->set_horizontal_pos(4); break;
case SimpleTypes::Vml::cssmsoposhorInside: odf_context()->drawing_context()->set_horizontal_pos(1); break;
case SimpleTypes::Vml::cssmsoposhorOutside : odf_context()->drawing_context()->set_horizontal_pos(3); break;
}
break;
}break;
case SimpleTypes::Vml::cssptMsoPositionHorizontalRelative:
{
switch(vml_style->m_arrProperties[i]->get_Value().eMsoPosHorRel)
{
case SimpleTypes::Vml::cssmsoposhorrelMargin: odf_context()->drawing_context()->set_horizontal_rel(2); break;
case SimpleTypes::Vml::cssmsoposhorrelPage: odf_context()->drawing_context()->set_horizontal_rel(6); break;
case SimpleTypes::Vml::cssmsoposhorrelText: odf_context()->drawing_context()->set_horizontal_rel(1); break;
case SimpleTypes::Vml::cssmsoposhorrelChar: odf_context()->drawing_context()->set_horizontal_rel(0); break;
case SimpleTypes::Vml::cssmsoposhorrelMargin:
{
anchor_type_x = 2;
odf_context()->drawing_context()->set_horizontal_rel(2);
}break;
case SimpleTypes::Vml::cssmsoposhorrelPage:
{
anchor_type_x = 0;
odf_context()->drawing_context()->set_horizontal_rel(6);
}break;
case SimpleTypes::Vml::cssmsoposhorrelText:
case SimpleTypes::Vml::cssmsoposhorrelChar:
{
anchor_type_x = 4;
odf_context()->drawing_context()->set_horizontal_rel(0);
}break;
}
anchor_set = true;
break;
}break;
case SimpleTypes::Vml::cssptMsoPositionVertical:
switch(vml_style->m_arrProperties[i]->get_Value().eMsoPosVer)
{
case SimpleTypes::Vml::cssmsoposverAbsolute: odf_context()->drawing_context()->set_vertical_pos(2); break;
case SimpleTypes::Vml::cssmsoposverTop: odf_context()->drawing_context()->set_vertical_pos(4); break;
case SimpleTypes::Vml::cssmsoposverCenter: odf_context()->drawing_context()->set_vertical_pos(1); break;
case SimpleTypes::Vml::cssmsoposverBottom: odf_context()->drawing_context()->set_vertical_pos(0); break;
case SimpleTypes::Vml::cssmsoposverInside: odf_context()->drawing_context()->set_vertical_pos(2); break;//??
case SimpleTypes::Vml::cssmsoposverOutside: odf_context()->drawing_context()->set_vertical_pos(3); break;//??
case SimpleTypes::Vml::cssmsoposverAbsolute: odf_context()->drawing_context()->set_vertical_pos(2); break;
case SimpleTypes::Vml::cssmsoposverTop: odf_context()->drawing_context()->set_vertical_pos(4); break;
case SimpleTypes::Vml::cssmsoposverCenter: odf_context()->drawing_context()->set_vertical_pos(1); break;
case SimpleTypes::Vml::cssmsoposverBottom: odf_context()->drawing_context()->set_vertical_pos(0); break;
case SimpleTypes::Vml::cssmsoposverInside: odf_context()->drawing_context()->set_vertical_pos(2); break;//??
case SimpleTypes::Vml::cssmsoposverOutside: odf_context()->drawing_context()->set_vertical_pos(3); break;//??
}
break;
case SimpleTypes::Vml::cssptMsoPositionVerticalRelative:
{
switch(vml_style->m_arrProperties[i]->get_Value().eMsoPosVerRel)
{
case SimpleTypes::Vml::cssmsoposverrelMargin: odf_context()->drawing_context()->set_vertical_rel(3); break;//3 ???
case SimpleTypes::Vml::cssmsoposverrelPage: odf_context()->drawing_context()->set_vertical_rel(5); break;
case SimpleTypes::Vml::cssmsoposverrelText: odf_context()->drawing_context()->set_vertical_rel(6); break;
case SimpleTypes::Vml::cssmsoposverrelLine: odf_context()->drawing_context()->set_vertical_rel(2); break;
case SimpleTypes::Vml::cssmsoposverrelMargin:
{
anchor_type_y = 2;
odf_context()->drawing_context()->set_vertical_rel(3);
}break;
case SimpleTypes::Vml::cssmsoposverrelPage:
{
anchor_type_y = 0;
odf_context()->drawing_context()->set_vertical_rel(5);
}break;
case SimpleTypes::Vml::cssmsoposverrelText:
{
anchor_type_y = 4;
odf_context()->drawing_context()->set_vertical_rel(6);
}break;
case SimpleTypes::Vml::cssmsoposverrelLine:
{
odf_context()->drawing_context()->set_vertical_rel(2);
}break;
}
anchor_set= true;
break;
}break;
case SimpleTypes::Vml::cssptZIndex:
{
if (vml_style->m_arrProperties[i]->get_Value().oZIndex.eType == SimpleTypes::Vml::csszindextypeOrder)
......@@ -239,21 +264,30 @@ void OoxConverter::convert(SimpleTypes::Vml::CCssStyle *vml_style, bool group)
}break;
}
}
if (x2 && !x && width) x = *x2 - *width;
if (y2 && !y && height) y = *y2 - *height;
if (group)
{
_CP_OPT(double) not_set;
odf_context()->drawing_context()->set_group_size(width_pt, height_pt, width_pt, height_pt);//not_set ,not_set);
odf_context()->drawing_context()->set_group_size(width, height, width, height);//not_set ,not_set);
odf_context()->drawing_context()->set_group_position(x, y, x, y);//not_set , not_set );
}
else
{
odf_context()->drawing_context()->set_size (width_pt, height_pt);
odf_context()->drawing_context()->set_size (width, height);
odf_context()->drawing_context()->set_position (x, y);
if (x && y && !anchor_set)
if ( (anchor_type_x && anchor_type_y) && (*anchor_type_x == *anchor_type_y))
odf_context()->drawing_context()->set_anchor(*anchor_type_x);
else if (x && y)
odf_context()->drawing_context()->set_anchor(2);
//if (x && y && !anchor_set)
// odf_context()->drawing_context()->set_anchor(2);
}
//if (width_pt && height_pt)
......@@ -675,14 +709,18 @@ void OoxConverter::convert(OOX::VmlWord::CWrap *vml_wrap)
}break;
}
}
bool anchor_page_x = false;
if (vml_wrap->m_oAnchorX.IsInit())
{
switch(vml_wrap->m_oAnchorX->GetValue())
{
case SimpleTypes::horizontalanchorMargin:
odf_context()->drawing_context()->set_horizontal_rel(4); break;
case SimpleTypes::horizontalanchorPage:
odf_context()->drawing_context()->set_horizontal_rel(6); break;
case SimpleTypes::horizontalanchorPage:
{
anchor_page_x = true;
odf_context()->drawing_context()->set_horizontal_rel(6);
}break;
case SimpleTypes::horizontalanchorText:
odf_context()->drawing_context()->set_horizontal_rel(1); break;//???? paragraph ????
case SimpleTypes::horizontalanchorChar:
......@@ -697,8 +735,11 @@ void OoxConverter::convert(OOX::VmlWord::CWrap *vml_wrap)
case SimpleTypes::verticalanchorMargin:
odf_context()->drawing_context()->set_vertical_rel(0); break;
case SimpleTypes::verticalanchorPage:
odf_context()->drawing_context()->set_anchor(0); //page
odf_context()->drawing_context()->set_vertical_rel(5); break;
{
if (anchor_page_x)
odf_context()->drawing_context()->set_anchor(0); //page
odf_context()->drawing_context()->set_vertical_rel(5);
}break;
case SimpleTypes::verticalanchorText:
odf_context()->drawing_context()->set_vertical_rel(0); break;
case SimpleTypes::verticalanchorLine:
......
......@@ -1020,12 +1020,13 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
if (oox_section_pr->m_oPgMar.IsInit())
{
_CP_OPT(odf_types::length) top, left, right, bottom, other;
convert(oox_section_pr->m_oPgMar->m_oBottom.GetPointer(), bottom);
convert(oox_section_pr->m_oPgMar->m_oLeft.GetPointer() , left);
convert(oox_section_pr->m_oPgMar->m_oRight.GetPointer() , right);
convert(oox_section_pr->m_oPgMar->m_oTop.GetPointer() , top);
odt_context->page_layout_context()->set_page_margin(top,left,bottom, right);
odt_context->page_layout_context()->set_page_margin(top, left, bottom, right);
convert(oox_section_pr->m_oPgMar->m_oGutter.GetPointer(), other);
odt_context->page_layout_context()->set_page_gutter(other);
......@@ -1047,45 +1048,49 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
if (oox_section_pr->m_oPgBorders.IsInit())
{
std::wstring top, left, right, bottom;
convert(oox_section_pr->m_oPgBorders->m_oBottom.GetPointer(), bottom);
convert(oox_section_pr->m_oPgBorders->m_oLeft.GetPointer() , left);
convert(oox_section_pr->m_oPgBorders->m_oRight.GetPointer() , right);
convert(oox_section_pr->m_oPgBorders->m_oTop.GetPointer() , top);
odt_context->page_layout_context()->set_page_border(top,left,bottom, right);
odt_context->page_layout_context()->set_page_border(top, left, bottom, right);
int border_offset = 1;
if (oox_section_pr->m_oPgBorders->m_oOffsetFrom.IsInit() &&
(oox_section_pr->m_oPgBorders->m_oOffsetFrom->GetValue() == SimpleTypes::pageborderoffsetPage))border_offset = 2;
(oox_section_pr->m_oPgBorders->m_oOffsetFrom->GetValue() == SimpleTypes::pageborderoffsetPage))
{
odt_context->page_layout_context()->set_page_border_offset(2);
}
if (oox_section_pr->m_oPgBorders->m_oBottom.IsInit())
{
int type = (oox_section_pr->m_oPgBorders->m_oBottom->m_oVal.IsInit() ? oox_section_pr->m_oPgBorders->m_oBottom->m_oVal->GetValue() : SimpleTypes::bordervalueSingle);
if (oox_section_pr->m_oPgBorders->m_oBottom->m_oSpace.IsInit())
odt_context->page_layout_context()->set_page_border_padding_bottom(border_offset, type, oox_section_pr->m_oPgBorders->m_oBottom->m_oSpace->ToPoints());
odt_context->page_layout_context()->set_page_border_padding(2, oox_section_pr->m_oPgBorders->m_oBottom->m_oSpace->ToPoints());
}
if (oox_section_pr->m_oPgBorders->m_oTop.IsInit())
{
int type = (oox_section_pr->m_oPgBorders->m_oBottom->m_oVal.IsInit() ? oox_section_pr->m_oPgBorders->m_oTop->m_oVal->GetValue() : SimpleTypes::bordervalueSingle);
if (oox_section_pr->m_oPgBorders->m_oTop->m_oSpace.IsInit())
odt_context->page_layout_context()->set_page_border_padding_top(border_offset, type, oox_section_pr->m_oPgBorders->m_oTop->m_oSpace->ToPoints());
odt_context->page_layout_context()->set_page_border_padding(1, oox_section_pr->m_oPgBorders->m_oTop->m_oSpace->ToPoints());
}
if (oox_section_pr->m_oPgBorders->m_oLeft.IsInit())
{
int type = (oox_section_pr->m_oPgBorders->m_oBottom->m_oVal.IsInit() ? oox_section_pr->m_oPgBorders->m_oLeft->m_oVal->GetValue() : SimpleTypes::bordervalueSingle);
if (oox_section_pr->m_oPgBorders->m_oLeft->m_oSpace.IsInit())
odt_context->page_layout_context()->set_page_border_padding_left(border_offset, type, oox_section_pr->m_oPgBorders->m_oLeft->m_oSpace->ToPoints());
odt_context->page_layout_context()->set_page_border_padding(3, oox_section_pr->m_oPgBorders->m_oLeft->m_oSpace->ToPoints());
}
if (oox_section_pr->m_oPgBorders->m_oRight.IsInit())
{
int type = (oox_section_pr->m_oPgBorders->m_oBottom->m_oVal.IsInit() ? oox_section_pr->m_oPgBorders->m_oRight->m_oVal->GetValue() : SimpleTypes::bordervalueSingle);
if (oox_section_pr->m_oPgBorders->m_oRight->m_oSpace.IsInit())
odt_context->page_layout_context()->set_page_border_padding_right(border_offset, type, oox_section_pr->m_oPgBorders->m_oRight->m_oSpace->ToPoints());
odt_context->page_layout_context()->set_page_border_padding(4, oox_section_pr->m_oPgBorders->m_oRight->m_oSpace->ToPoints());
}
......@@ -1145,11 +1150,17 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
if (present_header && s->m_arrHeaderReference.size() <1 && last_section_properties)
s = last_section_properties;
bool present_title_page = s->m_oTitlePg.IsInit() ? true : false;
bool add_title_header = false, add_title_footer = false;
for (unsigned int i=0; i< s->m_arrHeaderReference.size(); i++)
{
if (s->m_arrHeaderReference[i] == NULL) continue;
int type =s->m_arrHeaderReference[i]->m_oType.IsInit() ? s->m_arrHeaderReference[i]->m_oType->GetValue() :0 ;
if (type == 2) add_title_header = true;
if (odt_context->start_header(type))
{
if (s->m_arrHeaderReference[i]->m_oId.IsInit())
......@@ -1161,6 +1172,15 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
odt_context->end_header_footer();
}
}
if (present_title_page && !add_title_header)
{
if (odt_context->start_header(2))
{
odt_context->start_paragraph(false);
odt_context->end_paragraph();
}
odt_context->end_header_footer();
}
s = oox_section_pr;
if (present_footer && s->m_arrFooterReference.size() < 1 && last_section_properties)
s = last_section_properties; // нужно хранить ссылки на ВСЕ !!!
......@@ -1170,6 +1190,9 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
if (s->m_arrFooterReference[i] == NULL) continue;
int type = s->m_arrFooterReference[i]->m_oType.IsInit() ? s->m_arrFooterReference[i]->m_oType->GetValue() :0 ;
if (type == 2) add_title_footer = true;
if (odt_context->start_footer(type))
{
if (s->m_arrFooterReference[i]->m_oId.IsInit())
......@@ -1181,7 +1204,16 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
odt_context->end_header_footer();
}
}
//--------------------------------------------------------------------------------------------------------------------------------------------
if (present_title_page && !add_title_footer)
{
if (odt_context->start_footer(2))
{
odt_context->start_paragraph(false);
odt_context->end_paragraph();
}
odt_context->end_header_footer();
}
//--------------------------------------------------------------------------------------------------------------------------------------------
if (!continuous)
odt_context->set_master_page_name(odt_context->page_layout_context()->last_master() ?
......@@ -1917,10 +1949,10 @@ void DocxConverter::convert(OOX::Logic::CPicture* oox_pic)
odt_context->start_drawings();
if (odt_context->table_context()->empty())
odf_context()->drawing_context()->set_anchor(odf_types::anchor_type::AsChar);//default
odf_context()->drawing_context()->set_anchor(anchor_type::AsChar);//default
else
{
odf_context()->drawing_context()->set_anchor(odf_types::anchor_type::Paragraph);
odf_context()->drawing_context()->set_anchor(anchor_type::Paragraph);
odf_context()->drawing_context()->set_object_background(true);
}
......@@ -2204,31 +2236,55 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
odt_context->drawing_context()->set_drawings_rect(x, y, width, height);
_CP_OPT(int) anchor_type_x, anchor_type_y;
if (oox_anchor->m_oPositionV.IsInit() && oox_anchor->m_oPositionV->m_oRelativeFrom.IsInit())
{
odt_context->drawing_context()->set_vertical_rel(oox_anchor->m_oPositionV->m_oRelativeFrom->GetValue());
int vert_rel = oox_anchor->m_oPositionV->m_oRelativeFrom->GetValue();
odt_context->drawing_context()->set_vertical_rel(vert_rel);
if ( oox_anchor->m_oPositionV->m_oAlign.IsInit())
odt_context->drawing_context()->set_vertical_pos(oox_anchor->m_oPositionV->m_oAlign->GetValue());
else if(oox_anchor->m_oPositionV->m_oPosOffset.IsInit())
{
switch(vert_rel)
{
case 3:
case 6: anchor_type_y = anchor_type::Paragraph; break;
case 5: anchor_type_y = anchor_type::Page; break;
}
odt_context->drawing_context()->set_vertical_pos(oox_anchor->m_oPositionV->m_oPosOffset->ToPoints());
}
else
odt_context->drawing_context()->set_vertical_pos(SimpleTypes::alignvTop);
}
if (oox_anchor->m_oPositionH.IsInit() && oox_anchor->m_oPositionH->m_oRelativeFrom.IsInit())
{
odt_context->drawing_context()->set_horizontal_rel(oox_anchor->m_oPositionH->m_oRelativeFrom->GetValue());
int horiz_rel = oox_anchor->m_oPositionH->m_oRelativeFrom->GetValue();
odt_context->drawing_context()->set_horizontal_rel(horiz_rel);
if (oox_anchor->m_oPositionH->m_oAlign.IsInit())
odt_context->drawing_context()->set_horizontal_pos(oox_anchor->m_oPositionH->m_oAlign->GetValue());
else if(oox_anchor->m_oPositionH->m_oPosOffset.IsInit())
{
odt_context->drawing_context()->set_horizontal_pos(oox_anchor->m_oPositionH->m_oPosOffset->ToPoints());
switch(horiz_rel)
{
case 1:
case 2: anchor_type_x = anchor_type::Paragraph; break;
case 6: anchor_type_x = anchor_type::Page; break;
}
}
else
odt_context->drawing_context()->set_horizontal_pos(SimpleTypes::alignhLeft);
}
if ( (anchor_type_x && anchor_type_y) && (*anchor_type_x == *anchor_type_y))
odt_context->drawing_context()->set_anchor(*anchor_type_x);
bool wrap_set = false;
if (oox_anchor->m_oWrapSquare.IsInit())
{
......@@ -3508,8 +3564,14 @@ void DocxConverter::convert(OOX::Logic::CTbl *oox_table)
{
switch(oox_table->m_oTableProperties->m_oTblpPr->m_oVertAnchor->GetValue())
{
case SimpleTypes::vanchorMargin: odt_context->drawing_context()->set_vertical_rel(6); break;//1???
case SimpleTypes::vanchorPage: odt_context->drawing_context()->set_vertical_rel(5); break;
case SimpleTypes::vanchorMargin:
{ odt_context->drawing_context()->set_anchor(anchor_type::Paragraph);
odt_context->drawing_context()->set_vertical_rel(6); //1???
}break;
case SimpleTypes::vanchorPage:
{ odt_context->drawing_context()->set_anchor(anchor_type::Page);
odt_context->drawing_context()->set_vertical_rel(5);
}break;
}
}
if (oox_table->m_oTableProperties->m_oTblpPr->m_oHorzAnchor.IsInit())
......
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