Commit 8774035b authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - presentation table extended graphics properties

parent 8cec4ce8
......@@ -54,7 +54,7 @@ int _tmain(int argc, _TCHAR* argv[])
HRESULT hr = S_OK;
//////////////////////////////////////////////////////////////////////////
std::wstring srcFileName = argv[1];
std::wstring dstPath = argc > 2 ? argv[2] : srcFileName + L"-my.xlsx"; //xlsx pptx docx
std::wstring dstPath = argc > 2 ? argv[2] : srcFileName + L"-my.pptx"; //xlsx pptx docx
std::wstring outputDir = NSDirectory::GetFolderPath(dstPath);
......
......@@ -331,12 +331,12 @@
</References>
<Files>
<Filter
Name="Source Files"
Name="Common"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="OdfFileTest.cpp"
RelativePath="..\..\Common\3dParty\pole\pole.cpp"
>
<FileConfiguration
Name="Debug|Win32"
......@@ -348,7 +348,7 @@
</FileConfiguration>
</File>
<File
RelativePath="..\..\Common\3dParty\pole\pole.cpp"
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
>
<FileConfiguration
Name="Debug|Win32"
......@@ -360,7 +360,7 @@
</FileConfiguration>
</File>
<File
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
RelativePath="..\..\DesktopEditor\xml\src\xmldom.cpp"
>
<FileConfiguration
Name="Debug|Win32"
......@@ -372,7 +372,7 @@
</FileConfiguration>
</File>
<File
RelativePath="..\..\DesktopEditor\xml\src\xmldom.cpp"
RelativePath="..\..\DesktopEditor\xml\src\xmllight.cpp"
>
<FileConfiguration
Name="Debug|Win32"
......@@ -383,8 +383,9 @@
/>
</FileConfiguration>
</File>
</Filter>
<File
RelativePath="..\..\DesktopEditor\xml\src\xmllight.cpp"
RelativePath="OdfFileTest.cpp"
>
<FileConfiguration
Name="Debug|Win32"
......@@ -395,7 +396,6 @@
/>
</FileConfiguration>
</File>
</Filter>
</Files>
<Globals>
</Globals>
......
......@@ -79,24 +79,24 @@ text_format_properties_content calc_text_properties_content(const std::vector<co
}
//////////////
graphic_format_properties calc_graphic_properties_content(const std::vector<const style_graphic_properties*> & graphicProps)
graphic_format_properties calc_graphic_properties_content(const std::vector<const graphic_format_properties*> & graphicProps)
{
graphic_format_properties result;
BOOST_FOREACH(const style_graphic_properties* v, graphicProps)
BOOST_FOREACH(const graphic_format_properties* v, graphicProps)
{
if (v)
result.apply_from(v->content());
result.apply_from(v);
}
return result;
}
graphic_format_properties calc_graphic_properties_content(const style_instance * styleInstance)
{
std::vector<const style_graphic_properties*> graphicProps;
std::vector<const graphic_format_properties*> graphicProps;
while (styleInstance)
{
if (const style_content * content = styleInstance->content())
if (const style_graphic_properties * graphicProp = content->get_style_graphic_properties())
if (const graphic_format_properties * graphicProp = content->get_graphic_properties())
graphicProps.push_back(graphicProp);
styleInstance = styleInstance->parent();
......@@ -110,7 +110,8 @@ graphic_format_properties calc_graphic_properties_content(const std::vector<cons
graphic_format_properties result;
BOOST_FOREACH(const style_instance * inst, styleInstances)
{
result.apply_from(calc_graphic_properties_content(inst));
graphic_format_properties f = calc_graphic_properties_content(inst);
result.apply_from(&f);
}
return result;
}
......
......@@ -70,6 +70,10 @@
if (Other.A) \
A = Other.A;
#define _CP_APPLY_PROP3(A) \
if (Other->A) \
A = Other->A;
namespace cpdoccore {
namespace odf_types {
......
......@@ -1141,17 +1141,17 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
odf_reader::style_instance* styleInst = Context.root()->odf_context().styleContainer().style_by_name(styleName, odf_types::style_family::Graphic,Context.process_headers_footers_);
odf_reader::style_graphic_properties *properties = NULL;
if (styleInst) properties = styleInst->content()->get_style_graphic_properties();
odf_reader::graphic_format_properties *properties = NULL;
if (styleInst) properties = styleInst->content()->get_graphic_properties();
////////////////
if (properties)
{
if (properties->content().fo_clip_ && drawing->fill.bitmap)
if (properties->fo_clip_ && drawing->fill.bitmap)
{
std::wstring strRectClip = properties->content().fo_clip_.get();
strRectClip = strRectClip.substr(5,strRectClip.length()-6);
std::wstring strRectClip = properties->fo_clip_.get();
strRectClip = strRectClip.substr(5, strRectClip.length() - 6);
std::wstring fileName = Context.root()->get_folder() + FILE_SEPARATOR_STR+ href;
std::wstring fileName = Context.root()->get_folder() + FILE_SEPARATOR_STR + href;
drawing->fill.bitmap->bCrop = parse_clipping(strRectClip, fileName, drawing->fill.bitmap->cropRect, NULL/*Context.applicationFonts_*/);
}
......
......@@ -142,85 +142,104 @@ void graphic_format_properties::apply_to(std::vector<_property> & properties)
if (fo_wrap_option_)
properties.push_back(_property(L"text-wrap", (int)fo_wrap_option_->get_type()));
}
void graphic_format_properties::apply_from(const graphic_format_properties & Other)
void graphic_format_properties::apply_from(const graphic_format_properties * Other)
{
_CP_APPLY_PROP2(draw_stroke_);
_CP_APPLY_PROP2(draw_stroke_dash_);
_CP_APPLY_PROP2(draw_marker_start_);
_CP_APPLY_PROP2(draw_marker_end_);
_CP_APPLY_PROP2(draw_textarea_horizontal_align_);
_CP_APPLY_PROP2(draw_textarea_vertical_align_);
_CP_APPLY_PROP2(draw_auto_grow_height_);
_CP_APPLY_PROP2(draw_auto_grow_width_);
_CP_APPLY_PROP2(draw_fit_to_size_);
_CP_APPLY_PROP2(draw_fit_to_contour_);
_CP_APPLY_PROP2(svg_stroke_color_);
_CP_APPLY_PROP2(svg_stroke_width_);
_CP_APPLY_PROP2(svg_stroke_opacity_);
_CP_APPLY_PROP2(fo_min_width_);
_CP_APPLY_PROP2(fo_min_height_);
_CP_APPLY_PROP2(fo_max_width_);
_CP_APPLY_PROP2(fo_max_height_);
_CP_APPLY_PROP2(fo_wrap_option_);
_CP_APPLY_PROP2(style_print_content_);
_CP_APPLY_PROP2(style_protect_);
_CP_APPLY_PROP2(style_editable_);
_CP_APPLY_PROP2(style_wrap_);
_CP_APPLY_PROP2(style_wrap_dynamic_treshold_);
_CP_APPLY_PROP2(style_number_wrapped_paragraphs_);
_CP_APPLY_PROP2(style_wrap_contour_);
_CP_APPLY_PROP2(style_wrap_contour_mode_);
_CP_APPLY_PROP2(style_run_through_);
_CP_APPLY_PROP2(style_flow_with_text_);
_CP_APPLY_PROP2(style_overflow_behavior_);
_CP_APPLY_PROP2(style_mirror_);
_CP_APPLY_PROP2(fo_clip_);
_CP_APPLY_PROP2(draw_wrap_influence_on_position_);
common_draw_fill_attlist_.apply_from(Other.common_draw_fill_attlist_);
common_draw_rel_size_attlist_.apply_from(Other.common_draw_rel_size_attlist_);
common_horizontal_margin_attlist_.apply_from(Other.common_horizontal_margin_attlist_);
common_vertical_margin_attlist_.apply_from(Other.common_vertical_margin_attlist_);
common_margin_attlist_.apply_from(Other.common_margin_attlist_);
common_horizontal_pos_attlist_.apply_from(Other.common_horizontal_pos_attlist_);
common_horizontal_rel_attlist_.apply_from(Other.common_horizontal_rel_attlist_);
common_vertical_pos_attlist_.apply_from(Other.common_vertical_pos_attlist_);
common_vertical_rel_attlist_.apply_from(Other.common_vertical_rel_attlist_);
common_text_anchor_attlist_.apply_from(Other.common_text_anchor_attlist_);
common_border_attlist_.apply_from(Other.common_border_attlist_);
common_border_line_width_attlist_.apply_from(Other.common_border_line_width_attlist_);
common_padding_attlist_.apply_from(Other.common_padding_attlist_);
common_shadow_attlist_.apply_from(Other.common_shadow_attlist_);
common_background_color_attlist_.apply_from(Other.common_background_color_attlist_);
_CP_APPLY_PROP(style_background_image_, Other.style_background_image_);
if (Other == NULL) return;
_CP_APPLY_PROP3(draw_stroke_);
_CP_APPLY_PROP3(draw_stroke_dash_);
_CP_APPLY_PROP3(draw_marker_start_);
_CP_APPLY_PROP3(draw_marker_end_);
_CP_APPLY_PROP3(draw_textarea_horizontal_align_);
_CP_APPLY_PROP3(draw_textarea_vertical_align_);
_CP_APPLY_PROP3(draw_auto_grow_height_);
_CP_APPLY_PROP3(draw_auto_grow_width_);
_CP_APPLY_PROP3(draw_fit_to_size_);
_CP_APPLY_PROP3(draw_fit_to_contour_);
_CP_APPLY_PROP3(svg_stroke_color_);
_CP_APPLY_PROP3(svg_stroke_width_);
_CP_APPLY_PROP3(svg_stroke_opacity_);
_CP_APPLY_PROP3(fo_min_width_);
_CP_APPLY_PROP3(fo_min_height_);
_CP_APPLY_PROP3(fo_max_width_);
_CP_APPLY_PROP3(fo_max_height_);
_CP_APPLY_PROP3(fo_wrap_option_);
_CP_APPLY_PROP3(style_print_content_);
_CP_APPLY_PROP3(style_protect_);
_CP_APPLY_PROP3(style_editable_);
_CP_APPLY_PROP3(style_wrap_);
_CP_APPLY_PROP3(style_wrap_dynamic_treshold_);
_CP_APPLY_PROP3(style_number_wrapped_paragraphs_);
_CP_APPLY_PROP3(style_wrap_contour_);
_CP_APPLY_PROP3(style_wrap_contour_mode_);
_CP_APPLY_PROP3(style_run_through_);
_CP_APPLY_PROP3(style_flow_with_text_);
_CP_APPLY_PROP3(style_overflow_behavior_);
_CP_APPLY_PROP3(style_mirror_);
_CP_APPLY_PROP3(fo_clip_);
_CP_APPLY_PROP3(draw_wrap_influence_on_position_);
common_draw_fill_attlist_.apply_from (Other->common_draw_fill_attlist_);
common_draw_rel_size_attlist_.apply_from (Other->common_draw_rel_size_attlist_);
common_horizontal_margin_attlist_.apply_from(Other->common_horizontal_margin_attlist_);
common_vertical_margin_attlist_.apply_from (Other->common_vertical_margin_attlist_);
common_margin_attlist_.apply_from (Other->common_margin_attlist_);
common_horizontal_pos_attlist_.apply_from (Other->common_horizontal_pos_attlist_);
common_horizontal_rel_attlist_.apply_from (Other->common_horizontal_rel_attlist_);
common_vertical_pos_attlist_.apply_from (Other->common_vertical_pos_attlist_);
common_vertical_rel_attlist_.apply_from (Other->common_vertical_rel_attlist_);
common_text_anchor_attlist_.apply_from (Other->common_text_anchor_attlist_);
common_border_attlist_.apply_from (Other->common_border_attlist_);
common_border_line_width_attlist_.apply_from(Other->common_border_line_width_attlist_);
common_padding_attlist_.apply_from (Other->common_padding_attlist_);
common_shadow_attlist_.apply_from (Other->common_shadow_attlist_);
common_background_color_attlist_.apply_from (Other->common_background_color_attlist_);
_CP_APPLY_PROP(style_background_image_, Other->style_background_image_);
}
// style:graphic-properties
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_graphic_properties::ns = L"style";
const wchar_t * style_graphic_properties::name = L"graphic-properties";
void style_graphic_properties::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
graphic_format_properties_.add_attributes(Attributes);
content_.add_attributes(Attributes);
}
void style_graphic_properties::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if (L"style" == Ns && L"background-image" == Name)
{
CP_CREATE_ELEMENT(graphic_format_properties_.style_background_image_);
CP_CREATE_ELEMENT(content_.style_background_image_);
}
//if (CP_CHECK_NAME(L"text", L"list-style")
// styles_.add_child_element(Reader, Ns, Name, getContext()); он тут и не нужен по сути... описание есть и в другом сместе
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * loext_graphic_properties::ns = L"loext";
const wchar_t * loext_graphic_properties::name = L"graphic-properties";
void loext_graphic_properties::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
content_.add_attributes(Attributes);
}
void loext_graphic_properties::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if (L"style" == Ns && L"background-image" == Name)
{
CP_CREATE_ELEMENT(content_.style_background_image_);
}
//if (CP_CHECK_NAME(L"text", L"list-style")
// styles_.add_child_element(Reader, Ns, Name, getContext()); он тут и не нужен по сути... описание есть и в другом сместе
}
}
}
......@@ -68,10 +68,9 @@ class graphic_format_properties
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
void apply_from(const graphic_format_properties & Other);
void apply_to(std::vector<_property> & properties);
void apply_from(const graphic_format_properties * Other);
public:
void apply_to(std::vector<_property> & properties);
_CP_OPT(odf_types::length_or_percent) fo_min_width_;
_CP_OPT(odf_types::length_or_percent) fo_min_height_;
......@@ -138,7 +137,6 @@ public:
};
/// style:graphic-properties
class style_graphic_properties : public office_element_impl<style_graphic_properties>
{
public:
......@@ -149,20 +147,34 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
const graphic_format_properties & content() const { return graphic_format_properties_; }
graphic_format_properties content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
private:
graphic_format_properties graphic_format_properties_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_graphic_properties);
class loext_graphic_properties : public office_element_impl<style_graphic_properties>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeStyleGraphicPropertis;
CPDOCCORE_DEFINE_VISITABLE();
graphic_format_properties content_;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(loext_graphic_properties);
}
}
......
......@@ -142,7 +142,6 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(style_tab_stops);
// style_drop_cap
class style_drop_cap : public office_element_impl<style_drop_cap>
{
public:
......@@ -171,7 +170,6 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(style_drop_cap);
/// style:background-image
class style_background_image : public office_element_impl<style_background_image>
{
public:
......@@ -214,85 +212,32 @@ public:
void xlsx_convert(std::wostream & strm, bool in_draw);
// 15.5.1 fo:line-height
_CP_OPT(odf_types::line_width) fo_line_height_; // +
// 15.5.2 style:line-height-at-least
_CP_OPT(odf_types::length) style_line_height_at_least_; // +
// 15.5.3 style:line-spacing
_CP_OPT(odf_types::length) style_line_spacing_; // +
// 15.5.4 style:font-independent-line-spacing
_CP_OPT(bool) style_font_independent_line_spacing_; // ???
// 15.5.5 fo:text-align
_CP_OPT(odf_types::text_align) fo_text_align_; // +
// 15.5.6 fo:text-align-last
_CP_OPT(odf_types::text_align) fo_text_align_last_;
// 15.5.7 style:justify-single-word
_CP_OPT(bool) style_justify_single_word_;
// 15.5.8 fo:keep-together
_CP_OPT(odf_types::keep_together) fo_keep_together_; // +
// 15.5.9 fo:widows
_CP_OPT(unsigned int) fo_widows_; // +
// 15.5.10 fo:orphans
_CP_OPT(unsigned int) fo_orphans_;
// 15.5.11 <style:tab-stops>
office_element_ptr style_tab_stops_; // +
// 15.5.12 style:tab-stop-distance
_CP_OPT(odf_types::length) style_tab_stop_distance_;
// 15.5.13 fo:hyphenation-keep
_CP_OPT(odf_types::hyphenation_keep) fo_hyphenation_keep_;
// 15.5.14 fo:hyphenation-ladder-count
_CP_OPT(odf_types::integer_or_nolimit) fo_hyphenation_ladder_count_;
// 15.5.15 <style:drop-cap>
office_element_ptr style_drop_cap_;
// 15.5.16 style:register-true
_CP_OPT(bool) style_register_true_;
// 15.5.17 fo:margin-left
_CP_OPT(odf_types::length_or_percent) fo_margin_left_; // +
// fo:margin-right
_CP_OPT(odf_types::length_or_percent) fo_margin_right_; // +
// 15.5.18 fo:text-indent
_CP_OPT(odf_types::length_or_percent) fo_text_indent_; // +
// 15.5.19 style:auto-text-indent
_CP_OPT(bool) style_auto_text_indent_; // ???
// 15.5.20 fo:margin-top
_CP_OPT(odf_types::length_or_percent) fo_margin_top_; // +
// fo:margin-bottom
_CP_OPT(odf_types::length_or_percent) fo_margin_bottom_; // +
// 15.5.21 fo:margin
_CP_OPT(odf_types::length_or_percent) fo_margin_;
// 15.5.22 fo:break-before
_CP_OPT(odf_types::fo_break) fo_break_before_; // +
// fo:break-after
_CP_OPT(odf_types::fo_break) fo_break_after_;
// 15.5.23 fo:background-color
_CP_OPT(odf_types::background_color) fo_background_color_;
// 15.5.24 <style:background-image>
office_element_ptr style_background_image_;
_CP_OPT(odf_types::border_style) fo_border_; // +
......@@ -301,7 +246,6 @@ public:
_CP_OPT(odf_types::border_style) fo_border_left_; // +
_CP_OPT(odf_types::border_style) fo_border_right_; // +
// 15.5.26
_CP_OPT( odf_types::border_widths ) style_border_line_width_; // +
_CP_OPT( odf_types::border_widths ) style_border_line_width_top_; // +
......@@ -327,14 +271,11 @@ public:
_CP_OPT(bool) style_snap_to_layout_grid_;
_CP_OPT(unsigned int) style_page_number_;
// 15.5.40 style:background-transparency
_CP_OPT(odf_types::percent) style_background_transparency_;
//
_CP_OPT(bool) style_join_border_;
};
// style_paragraph_properties
class style_paragraph_properties : public office_element_impl<style_paragraph_properties>
{
public:
......
......@@ -158,9 +158,15 @@ style_paragraph_properties * style_content::get_style_paragraph_properties() con
return dynamic_cast<style_paragraph_properties *>(style_paragraph_properties_.get());
}
style_graphic_properties * style_content::get_style_graphic_properties() const
graphic_format_properties * style_content::get_graphic_properties() const
{
return dynamic_cast<style_graphic_properties *>(style_graphic_properties_.get());
style_graphic_properties *style_ = dynamic_cast<style_graphic_properties *>(style_graphic_properties_.get());
loext_graphic_properties *loext_ = dynamic_cast<loext_graphic_properties *>(style_graphic_properties_.get());
if (style_) return &style_->content_;
if (loext_) return &loext_->content_;
return NULL;
}
style_table_properties * style_content::get_style_table_properties() const
{
......@@ -264,7 +270,7 @@ void style_content::add_child_element( xml::sax * Reader, const std::wstring & N
{
CP_CREATE_ELEMENT_SIMPLE(style_section_properties_);
}
else if CP_CHECK_NAME(L"style", L"graphic-properties")
else if (CP_CHECK_NAME(L"style", L"graphic-properties") || CP_CHECK_NAME(L"loext", L"graphic-properties"))
{
CP_CREATE_ELEMENT_SIMPLE(style_graphic_properties_);
}
......
......@@ -70,9 +70,10 @@
namespace cpdoccore { namespace odf_reader {
class graphic_format_properties;
class style_text_properties;
class style_paragraph_properties;
class style_graphic_properties;
class style_section_properties;
class style_table_cell_properties;
class style_table_row_properties;
......@@ -89,9 +90,10 @@ public:
void docx_convert(oox::docx_conversion_context & Context, bool in_styles = false);
void xlsx_convert(oox::xlsx_conversion_context & Context);
graphic_format_properties * get_graphic_properties() const;
style_text_properties * get_style_text_properties() const;
style_paragraph_properties * get_style_paragraph_properties() const;
style_graphic_properties * get_style_graphic_properties() const;
style_table_properties * get_style_table_properties() const;
style_section_properties * get_style_section_properties() const;
style_table_cell_properties * get_style_table_cell_properties() const;
......
......@@ -199,13 +199,14 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
if ((inst) && (inst->content()))
{
//table_properties
if (inst->content()->get_style_graphic_properties())
if (inst->content()->get_graphic_properties())
{
const graphic_format_properties & style_graphic = inst->content()->get_style_graphic_properties()->content();
oox::_oox_fill fill;
Compute_GraphicFill(style_graphic.common_draw_fill_attlist_, style_graphic.style_background_image_,
Context.root()->odf_context().drawStyles() ,fill);
graphic_format_properties * graphic_props = inst->content()->get_graphic_properties();
if (graphic_props)
Compute_GraphicFill(graphic_props->common_draw_fill_attlist_, graphic_props->style_background_image_,
Context.root()->odf_context().drawStyles(), fill);
if (fill.bitmap)
{
......@@ -231,9 +232,9 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
////////////////////////////////////////////////////////////////////////
std::wstring table_content_ = Context.get_table_context().tableData().str();
if (table_content_.length()>0)
if (!table_content_.empty())
{
Context.get_slide_context().set_property(_property(L"table-content",table_content_));
Context.get_slide_context().set_property(_property(L"table-content", table_content_));
}
Context.get_slide_context().end_table();
}
......
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