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:
......
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