diff --git a/ASCOfficeOdfFile/OdfFileTest/OdfFileTest.cpp b/ASCOfficeOdfFile/OdfFileTest/OdfFileTest.cpp index ea3e14d23c..cdb1474b4f 100644 --- a/ASCOfficeOdfFile/OdfFileTest/OdfFileTest.cpp +++ b/ASCOfficeOdfFile/OdfFileTest/OdfFileTest.cpp @@ -55,7 +55,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.pptx"; //xlsx pptx + std::wstring dstPath = argc > 2 ? argv[2] : srcFileName + L"-my.docx"; //xlsx pptx std::wstring outputDir = NSDirectory::GetFolderPath(dstPath); diff --git a/ASCOfficeOdfFile/src/docx/docx_drawing.cpp b/ASCOfficeOdfFile/src/docx/docx_drawing.cpp index a8a971cfc0..b763ea3cb9 100644 --- a/ASCOfficeOdfFile/src/docx/docx_drawing.cpp +++ b/ASCOfficeOdfFile/src/docx/docx_drawing.cpp @@ -531,8 +531,8 @@ mso-position-vertical-relative:text;"; strStyle += L"height:" + boost::lexical_cast(val.cy / 12700.) + L"pt;"; strStyle += L"z-index:" + boost::lexical_cast(0xF000800 - val.id); - CP_XML_ATTR(L"id", L"Rect" + boost::lexical_cast(val.id)); - CP_XML_ATTR(L"o:spid", L"_x0000_s" + boost::lexical_cast(1024 + val.id)); + CP_XML_ATTR(L"id", L"Rect" + std::to_wstring(val.id)); + CP_XML_ATTR(L"o:spid", L"_x0000_s" + std::to_wstring(1024 + val.id)); CP_XML_ATTR(L"style", strStyle); CP_XML_ATTR(L"fillcolor", L"#4f81bd [3204]"); CP_XML_ATTR(L"strokecolor", L"#243f60 [1604]"); diff --git a/ASCOfficeOdfFile/src/docx/oox_drawing_fills.cpp b/ASCOfficeOdfFile/src/docx/oox_drawing_fills.cpp index b42dcd798e..c85490d80c 100644 --- a/ASCOfficeOdfFile/src/docx/oox_drawing_fills.cpp +++ b/ASCOfficeOdfFile/src/docx/oox_drawing_fills.cpp @@ -66,7 +66,7 @@ void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(double) { CP_XML_NODE(L"a:srgbClr") { - CP_XML_ATTR(L"val",color); + CP_XML_ATTR(L"val", color); if (opacity) { CP_XML_NODE(L"a:alpha") @@ -101,11 +101,56 @@ void oox_serialize_solid_fill(std::wostream & strm, const _oox_fill & val) { CP_XML_NODE(L"a:solidFill") { - oox_serialize_srgb(CP_XML_STREAM(),val.solid->color,val.opacity); + oox_serialize_srgb(CP_XML_STREAM(), val.solid->color, val.opacity); } } } +void vml_serialize_solid_fill(std::wostream & strm, const _oox_fill & val) +{ + if (!val.solid)return; + CP_XML_WRITER(strm) + { + CP_XML_NODE(L"v:fill") + { + oox_serialize_srgb(CP_XML_STREAM(), val.solid->color, val.opacity); + CP_XML_ATTR(L"v:fill", val.solid->color); + if (val.opacity) + { + CP_XML_ATTR(L"v:opacity", *val.opacity); + } + } + + } +} +void vml_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val) +{ + if (!val.bitmap) return; + if (!val.bitmap->isInternal) return; + + CP_XML_WRITER(strm) + { + CP_XML_NODE(L"v:fill") + { + CP_XML_ATTR(L"r:id", val.bitmap->rId ); + + if (val.opacity) + { + CP_XML_ATTR(L"opacity",(int)(*val.opacity)); + } + + if (val.bitmap->bTile) + { + CP_XML_ATTR(L"type", L"pattern"); + } + else + { + CP_XML_ATTR(L"type", L"frame"); + } + CP_XML_ATTR(L"recolor", L"t"); + } + } +} void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val) { if (!val.bitmap) return; @@ -164,20 +209,69 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val) { CP_XML_NODE(L"a:fillRect"); } - } } - } + } +} +void vml_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val) +{ + if (!val.gradient) return; + + CP_XML_WRITER(strm) + { + CP_XML_NODE(L"v:fill") + { + if (!val.gradient->colors.empty()) + { + CP_XML_ATTR(L"color2", val.gradient->colors[val.gradient->colors.size() - 1].color_ref); + std::wstring colors_value; + for (size_t i = 0; i < val.gradient->colors.size(); i++) + { + colors_value += std::to_wstring(val.gradient->colors[i].pos) + L"% #" + + val.gradient->colors[i].color_ref + L","; + } + + if (!colors_value.empty()) + { + CP_XML_ATTR(L"colors", colors_value.substr(0, colors_value.length() - 1)); + } + } + double angle =/*360 - */val.gradient->angle/* * 180./3.14159265358979323846*/; + + CP_XML_ATTR(L"focus", L"100%"); + switch(val.gradient->style) + { + case 0: + CP_XML_ATTR(L"type", L"gradient"); + CP_XML_ATTR(L"method", L"linear"); + CP_XML_ATTR(L"angle", angle); + break; + case 1: + //CP_XML_ATTR(L"type", L"gradientRadial"); + //break; + case 2: + //CP_XML_ATTR(L"type", L"gradientCenter"); + //break; + case 3: + //CP_XML_ATTR(L"type", L"gradientUnscaled"); + //break; + CP_XML_ATTR(L"type", L"gradientRadial"); + } + if (val.gradient->style > 0) + { + double focus_x = ((val.gradient->rect[2] - val.gradient->rect[0]) /2. + val.gradient->rect[0]) / 100.; + double focus_y = ((val.gradient->rect[3] - val.gradient->rect[1]) /2. + val.gradient->rect[1]) / 100.; + + CP_XML_ATTR(L"focusposition", XmlUtils::DoubleToString(focus_x, L"%.2f") + L"," + XmlUtils::DoubleToString(focus_y, L"%.2f")); + } + } } } void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val) { - if (!val.gradient) - { - return; - } + if (!val.gradient) return; CP_XML_WRITER(strm) { @@ -233,6 +327,7 @@ void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val) void oox_serialize_hatch_fill(std::wostream & strm, const _oox_fill & val) { if (!val.hatch)return; + CP_XML_WRITER(strm) { CP_XML_NODE(L"a:pattFill") @@ -253,7 +348,38 @@ void oox_serialize_hatch_fill(std::wostream & strm, const _oox_fill & val) } } } -void oox_serialize_fill(std::wostream & strm, const _oox_fill & val) + +void vml_serialize_background (std::wostream & strm, const _oox_fill & val, const std::wstring & color, int id) +{ + if (val.type == 0) return; + CP_XML_WRITER(strm) + { + CP_XML_NODE(L"v:background") + { + CP_XML_ATTR(L"id", L"_x0000_s" + std::to_wstring(1024 + id)); + CP_XML_ATTR(L"o:bwmode", L"white"); + CP_XML_ATTR(L"fillcolor", L"#" + color); + CP_XML_ATTR(L"o:targetscreensize", L"1024,768"); + switch (val.type) + { + case 1: + vml_serialize_solid_fill(CP_XML_STREAM(), val); + break; + case 2: + vml_serialize_bitmap_fill(CP_XML_STREAM(), val); + break; + case 3: + vml_serialize_gradient_fill(CP_XML_STREAM(), val); + break; + case 4: + //vml_serialize_hatch_fill(CP_XML_STREAM(), val); + break; + } + } + } +} + +void oox_serialize_fill (std::wostream & strm, const _oox_fill & val) { switch (val.type) { diff --git a/ASCOfficeOdfFile/src/docx/oox_drawing_fills.h b/ASCOfficeOdfFile/src/docx/oox_drawing_fills.h index dad53d666c..02c3ff8e00 100644 --- a/ASCOfficeOdfFile/src/docx/oox_drawing_fills.h +++ b/ASCOfficeOdfFile/src/docx/oox_drawing_fills.h @@ -143,9 +143,10 @@ namespace oox { } }; - void oox_serialize_fill(std::wostream & strm, const _oox_fill & val); - void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(double) opacity); - void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf_types::percent) opacity); + void vml_serialize_background (std::wostream & strm, const _oox_fill & val, const std::wstring & color, int id); + void oox_serialize_fill (std::wostream & strm, const _oox_fill & val); + void oox_serialize_srgb (std::wostream & strm,std::wstring color,_CP_OPT(double) opacity); + void oox_serialize_srgb (std::wostream & strm,std::wstring color,_CP_OPT(odf_types::percent) opacity); } } diff --git a/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.cpp b/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.cpp index eb3251bcb2..c5029f468d 100644 --- a/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.cpp +++ b/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.cpp @@ -109,11 +109,11 @@ void common_draw_fill_attlist::add_attributes( const xml::attributes_wc_ptr & At } void common_draw_fill_attlist::serialize(CP_ATTR_NODE) { - CP_XML_ATTR_OPT(L"draw:fill-color", draw_fill_color_); - CP_XML_ATTR_OPT(L"draw:fill", draw_fill_); + CP_XML_ATTR_OPT(L"draw:fill-color", draw_fill_color_); + CP_XML_ATTR_OPT(L"draw:fill", draw_fill_); - CP_XML_ATTR_OPT(L"draw:opacity", draw_opacity_); - CP_XML_ATTR_OPT(L"draw:image-opacity", draw_image_opacity_); + CP_XML_ATTR_OPT(L"draw:opacity", draw_opacity_); + CP_XML_ATTR_OPT(L"draw:image-opacity", draw_image_opacity_); CP_XML_ATTR_OPT(L"draw:fill-image-name", draw_fill_image_name_); CP_XML_ATTR_OPT(L"draw:fill-gradient-name", draw_fill_gradient_name_); diff --git a/ASCOfficeOdfFile/src/odf/draw_common.cpp b/ASCOfficeOdfFile/src/odf/draw_common.cpp index 7f2830e778..c56b4038dc 100644 --- a/ASCOfficeOdfFile/src/odf/draw_common.cpp +++ b/ASCOfficeOdfFile/src/odf/draw_common.cpp @@ -216,10 +216,10 @@ int Compute_BorderWidth(const graphic_format_properties & graphicProperties, Bor switch(borderSide) { - case sideTop: borderValue = graphicProperties.common_border_attlist_.fo_border_top_; break; - case sideBottom: borderValue = graphicProperties.common_border_attlist_.fo_border_bottom_; break; - case sideLeft: borderValue = graphicProperties.common_border_attlist_.fo_border_left_; break; - case sideRight: borderValue = graphicProperties.common_border_attlist_.fo_border_right_; break; + case sideTop: borderValue = graphicProperties.common_border_attlist_.fo_border_top_; break; + case sideBottom: borderValue = graphicProperties.common_border_attlist_.fo_border_bottom_; break; + case sideLeft: borderValue = graphicProperties.common_border_attlist_.fo_border_left_; break; + case sideRight: borderValue = graphicProperties.common_border_attlist_.fo_border_right_; break; } if (!borderValue) @@ -281,14 +281,14 @@ void Compute_GradientFill(draw_gradient * image_style,oox::oox_gradient_fill_ptr fill->style = 0; point.pos = 0; - if (image_style->draw_start_color_)point.color_ref = image_style->draw_start_color_->get_hex_value(); - if (image_style->draw_start_intensity_)point.opacity = image_style->draw_start_intensity_->get_value(); + if (image_style->draw_start_color_) point.color_ref = image_style->draw_start_color_->get_hex_value(); + if (image_style->draw_start_intensity_) point.opacity = image_style->draw_start_intensity_->get_value(); fill->colors.push_back(point); point.pos = 100; - if (image_style->draw_end_color_)point.color_ref = image_style->draw_end_color_->get_hex_value(); - if (image_style->draw_end_intensity_)point.opacity = image_style->draw_end_intensity_->get_value(); + if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value(); + if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value(); fill->colors.push_back(point); }break; @@ -297,20 +297,20 @@ void Compute_GradientFill(draw_gradient * image_style,oox::oox_gradient_fill_ptr fill->style = 0; point.pos = 0; - if (image_style->draw_end_color_)point.color_ref = image_style->draw_end_color_->get_hex_value(); - if (image_style->draw_end_intensity_)point.opacity = image_style->draw_end_intensity_->get_value(); + if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value(); + if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value(); fill->colors.push_back(point); point.pos = 50; - if (image_style->draw_start_color_)point.color_ref = image_style->draw_start_color_->get_hex_value(); - if (image_style->draw_start_intensity_)point.opacity = image_style->draw_start_intensity_->get_value(); + if (image_style->draw_start_color_) point.color_ref = image_style->draw_start_color_->get_hex_value(); + if (image_style->draw_start_intensity_) point.opacity = image_style->draw_start_intensity_->get_value(); fill->colors.push_back(point); point.pos = 100; - if (image_style->draw_end_color_)point.color_ref = image_style->draw_end_color_->get_hex_value(); - if (image_style->draw_end_intensity_)point.opacity = image_style->draw_end_intensity_->get_value(); + if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value(); + if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value(); fill->colors.push_back(point); }break; @@ -319,41 +319,35 @@ void Compute_GradientFill(draw_gradient * image_style,oox::oox_gradient_fill_ptr case gradient_style::square: case gradient_style::rectangular: { - if (style == gradient_style::radial || style == gradient_style::ellipsoid) fill->style = 2; + if (style == gradient_style::radial || + style == gradient_style::ellipsoid) fill->style = 2; if (style == gradient_style::square ) fill->style = 1; if (style == gradient_style::rectangular) fill->style = 3; point.pos = 0; - if (image_style->draw_end_color_)point.color_ref = image_style->draw_end_color_->get_hex_value(); - if (image_style->draw_end_intensity_)point.opacity = image_style->draw_end_intensity_->get_value(); - - fill->colors.push_back(point); - - point.pos = 100; - if (image_style->draw_start_color_)point.color_ref = image_style->draw_start_color_->get_hex_value(); - if (image_style->draw_start_intensity_)point.opacity = image_style->draw_start_intensity_->get_value(); + if (image_style->draw_start_color_) point.color_ref = image_style->draw_start_color_->get_hex_value(); + if (image_style->draw_start_intensity_) point.opacity = image_style->draw_start_intensity_->get_value(); fill->colors.push_back(point); - if (image_style->draw_cx_)//хохма - у мс в конвертилке из open-office перепутаны l & r !!! + point.pos = 100; + if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value(); + if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value(); + + fill->colors.push_back(point); + + fill->rect[0] = fill->rect[1] = 0; + fill->rect[2] = fill->rect[3] = 100; + + if (image_style->draw_cx_) { - fill->rect[0]=image_style->draw_cx_->get_value(); - fill->rect[2]=100-image_style->draw_cx_->get_value(); - } - else - { - fill->rect[0]=0; - fill->rect[2]=100; + fill->rect[0] = 100 - image_style->draw_cx_->get_value(); + fill->rect[2] = image_style->draw_cx_->get_value(); } if (image_style->draw_cy_) { - fill->rect[1]=image_style->draw_cy_->get_value(); - fill->rect[3]=100-image_style->draw_cy_->get_value(); - } - else - { - fill->rect[1]=0; - fill->rect[3]=100; + fill->rect[1] = 100 - image_style->draw_cy_->get_value(); + fill->rect[3] = image_style->draw_cy_->get_value(); } }break; } @@ -427,8 +421,14 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el { switch(image->style_repeat_->get_type()) { - case style_repeat::Repeat : fill.bitmap->bTile = true; break; - case style_repeat::Stretch : fill.bitmap->bStretch = true; break; + case style_repeat::Repeat : + fill.bitmap->bTile = true; + fill.bitmap->bStretch = false; + break; + case style_repeat::Stretch : + fill.bitmap->bStretch = true; + fill.bitmap->bTile = false; //?? для background точно выключать + break; } } if (image->draw_opacity_) @@ -445,8 +445,14 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el { switch(props.style_repeat_->get_type()) { - case style_repeat::Repeat : fill.bitmap->bTile = true; break; - case style_repeat::Stretch : fill.bitmap->bStretch = true; break; + case style_repeat::Repeat : + fill.bitmap->bTile = true; + fill.bitmap->bStretch = false; + break; + case style_repeat::Stretch : + fill.bitmap->bStretch = true; + fill.bitmap->bTile = false; + break; } } else diff --git a/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp b/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp index 90515523d1..734e861aa5 100644 --- a/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp +++ b/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp @@ -893,17 +893,17 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio Compute_GraphicFill(graphicProperties.common_draw_fill_attlist_, graphicProperties.style_background_image_, Context.root()->odf_context().drawStyles() ,drawing->fill, bTxbx); - if ((drawing->fill.bitmap) && (drawing->fill.bitmap->rId.length() < 1)) + if ((drawing->fill.bitmap) && (drawing->fill.bitmap->rId.empty())) { std::wstring href = drawing->fill.bitmap->xlink_href_; drawing->fill.bitmap->rId = Context.add_mediaitem(href, oox::typeImage, drawing->fill.bitmap->isInternal, href); } //////////////////////////////////////////////////// - drawing->additional.push_back(odf_reader::_property(L"border_width_left", Compute_BorderWidth(graphicProperties, sideLeft))); + drawing->additional.push_back(odf_reader::_property(L"border_width_left", Compute_BorderWidth(graphicProperties, sideLeft))); drawing->additional.push_back(odf_reader::_property(L"border_width_top", Compute_BorderWidth(graphicProperties, sideTop))); - drawing->additional.push_back(odf_reader::_property(L"border_width_right", Compute_BorderWidth(graphicProperties, sideRight))); - drawing->additional.push_back(odf_reader::_property(L"border_width_bottom", Compute_BorderWidth(graphicProperties, sideBottom))); + drawing->additional.push_back(odf_reader::_property(L"border_width_right", Compute_BorderWidth(graphicProperties, sideRight))); + drawing->additional.push_back(odf_reader::_property(L"border_width_bottom", Compute_BorderWidth(graphicProperties, sideBottom))); if (graphicProperties.common_border_attlist_.fo_border_) { diff --git a/ASCOfficeOdfFile/src/odf/draw_frame_xlsx.cpp b/ASCOfficeOdfFile/src/odf/draw_frame_xlsx.cpp index 2407974ed4..9e4df72aae 100644 --- a/ASCOfficeOdfFile/src/odf/draw_frame_xlsx.cpp +++ b/ASCOfficeOdfFile/src/odf/draw_frame_xlsx.cpp @@ -178,10 +178,10 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context) //////////////////////////////////////////////////////////////////// properties.apply_to(Context.get_drawing_context().get_properties()); - Context.get_drawing_context().set_property(odf_reader::_property(L"border_width_left", Compute_BorderWidth(properties, sideLeft))); - Context.get_drawing_context().set_property(odf_reader::_property(L"border_width_top", Compute_BorderWidth(properties, sideTop))); - Context.get_drawing_context().set_property(odf_reader::_property(L"border_width_right",Compute_BorderWidth(properties, sideRight))); - Context.get_drawing_context().set_property(odf_reader::_property(L"border_width_bottom", Compute_BorderWidth(properties, sideBottom))); + Context.get_drawing_context().set_property(odf_reader::_property(L"border_width_left", Compute_BorderWidth(properties, sideLeft))); + Context.get_drawing_context().set_property(odf_reader::_property(L"border_width_top", Compute_BorderWidth(properties, sideTop))); + Context.get_drawing_context().set_property(odf_reader::_property(L"border_width_right", Compute_BorderWidth(properties, sideRight))); + Context.get_drawing_context().set_property(odf_reader::_property(L"border_width_bottom", Compute_BorderWidth(properties, sideBottom))); if (properties.fo_clip_) { diff --git a/ASCOfficeOdfFile/src/odf/office_body.cpp b/ASCOfficeOdfFile/src/odf/office_body.cpp index b2392f0160..7ccbe7845c 100644 --- a/ASCOfficeOdfFile/src/odf/office_body.cpp +++ b/ASCOfficeOdfFile/src/odf/office_body.cpp @@ -41,7 +41,9 @@ #include #include + #include "odfcontext.h" +#include "draw_common.h" namespace cpdoccore { @@ -111,14 +113,29 @@ void office_body::docx_convert(oox::docx_conversion_context & Context) Context.add_page_properties(L""); // Context.add_page_properties(L""); } -//backcolor (for all pages) +//background (for all pages) if (page_layout_instance * firtsPageLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_by_name(Context.get_page_properties())) { if (style_page_layout_properties * prop = firtsPageLayout->properties()) { - if (prop->docx_back_serialize(Context.output_stream(), Context)) + oox::_oox_fill fill; + + Compute_GraphicFill(prop->style_page_layout_properties_attlist_.common_draw_fill_attlist_, + prop->style_page_layout_properties_elements_.style_background_image_, + Context.root()->odf_context().drawStyles(), fill); + + if (prop->style_page_layout_properties_attlist_.common_background_color_attlist_.fo_background_color_ || fill.type != 0) { - Context.set_settings_property(odf_reader::_property(L"displayBackgroundShape",true)); + if ((fill.bitmap) && (fill.bitmap->rId.empty())) + { + std::wstring href = fill.bitmap->xlink_href_; + fill.bitmap->rId = Context.add_mediaitem(href, oox::typeImage, fill.bitmap->isInternal, href); + } + int id = Context.get_drawing_context().get_current_shape_id(); + if (prop->docx_background_serialize(Context.output_stream(), Context, fill, id)) + { + Context.set_settings_property(odf_reader::_property(L"displayBackgroundShape", true)); + } } } } diff --git a/ASCOfficeOdfFile/src/odf/style_graphic_properties.h b/ASCOfficeOdfFile/src/odf/style_graphic_properties.h index 663020310a..b33e84b085 100644 --- a/ASCOfficeOdfFile/src/odf/style_graphic_properties.h +++ b/ASCOfficeOdfFile/src/odf/style_graphic_properties.h @@ -73,11 +73,11 @@ public: public: - _CP_OPT(odf_types::length_or_percent) fo_min_width_; - _CP_OPT(odf_types::length_or_percent) fo_min_height_; + _CP_OPT(odf_types::length_or_percent) fo_min_width_; + _CP_OPT(odf_types::length_or_percent) fo_min_height_; - _CP_OPT(odf_types::length_or_percent) fo_max_width_; - _CP_OPT(odf_types::length_or_percent) fo_max_height_; + _CP_OPT(odf_types::length_or_percent) fo_max_width_; + _CP_OPT(odf_types::length_or_percent) fo_max_height_; /////////////////////////////// _CP_OPT(odf_types::color) svg_stroke_color_; diff --git a/ASCOfficeOdfFile/src/odf/style_paragraph_properties.h b/ASCOfficeOdfFile/src/odf/style_paragraph_properties.h index 5df3795042..8b24e83d12 100644 --- a/ASCOfficeOdfFile/src/odf/style_paragraph_properties.h +++ b/ASCOfficeOdfFile/src/odf/style_paragraph_properties.h @@ -98,17 +98,17 @@ private: virtual void add_text(const std::wstring & Text); private: - odf_types::length style_position_; - _CP_OPT(odf_types::style_type) style_type_; - _CP_OPT(wchar_t) style_char_; + odf_types::length style_position_; + _CP_OPT(odf_types::style_type) style_type_; + _CP_OPT(wchar_t) style_char_; - _CP_OPT(odf_types::line_type) style_leader_type_; - _CP_OPT(odf_types::line_style) style_leader_style_; - _CP_OPT(odf_types::line_width) style_leader_width_; - _CP_OPT(odf_types::style_leader_color) style_leader_color_; + _CP_OPT(odf_types::line_type) style_leader_type_; + _CP_OPT(odf_types::line_style) style_leader_style_; + _CP_OPT(odf_types::line_width) style_leader_width_; + _CP_OPT(odf_types::style_leader_color) style_leader_color_; - _CP_OPT( std::wstring ) style_leader_text_; - _CP_OPT( odf_types::style_ref ) style_leader_text_style_; + _CP_OPT( std::wstring ) style_leader_text_; + _CP_OPT( odf_types::style_ref ) style_leader_text_style_; }; diff --git a/ASCOfficeOdfFile/src/odf/styles.cpp b/ASCOfficeOdfFile/src/odf/styles.cpp index 605078f74a..9ca8cfe028 100644 --- a/ASCOfficeOdfFile/src/odf/styles.cpp +++ b/ASCOfficeOdfFile/src/odf/styles.cpp @@ -54,7 +54,6 @@ #include "serialize_elements.h" #include "odfcontext.h" - #include "draw_common.h" namespace cpdoccore { @@ -904,12 +903,12 @@ void style_page_layout::add_child_element( xml::sax * Reader, const std::wstring // style-page-layout-properties-attlist void style_page_layout_properties_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes ) { - CP_APPLY_ATTR(L"fo:page-width", fo_page_width_); - CP_APPLY_ATTR(L"fo:page-height", fo_page_height_); + CP_APPLY_ATTR(L"fo:page-width", fo_page_width_); + CP_APPLY_ATTR(L"fo:page-height", fo_page_height_); common_num_format_attlist_.add_attributes(Attributes); common_num_format_prefix_suffix_attlist_.add_attributes(Attributes); - CP_APPLY_ATTR(L"style:paper-tray-name", style_paper_tray_name_); - CP_APPLY_ATTR(L"style:print-orientation", style_print_orientation_); + CP_APPLY_ATTR(L"style:paper-tray-name", style_paper_tray_name_); + CP_APPLY_ATTR(L"style:print-orientation", style_print_orientation_); common_horizontal_margin_attlist_.add_attributes(Attributes); common_vertical_margin_attlist_.add_attributes(Attributes); @@ -919,7 +918,8 @@ void style_page_layout_properties_attlist::add_attributes( const xml::attributes common_padding_attlist_.add_attributes(Attributes); common_shadow_attlist_.add_attributes(Attributes); common_background_color_attlist_.add_attributes(Attributes); - + common_draw_fill_attlist_.add_attributes(Attributes); + CP_APPLY_ATTR(L"style:register-truth-ref-style-name", style_register_truth_ref_style_name_); CP_APPLY_ATTR(L"style:print", style_print_); CP_APPLY_ATTR(L"style:print-page-order", style_print_page_order_); @@ -1260,18 +1260,26 @@ void style_page_layout_properties::add_child_element( xml::sax * Reader, const s { style_page_layout_properties_elements_.add_child_element(Reader, Ns, Name, getContext()); } -bool style_page_layout_properties::docx_back_serialize(std::wostream & strm, oox::docx_conversion_context & Context) -{ - if (!style_page_layout_properties_attlist_.common_background_color_attlist_.fo_background_color_)return false; - if (style_page_layout_properties_attlist_.common_background_color_attlist_.fo_background_color_->get_type() == background_color::Transparent) return true; +bool style_page_layout_properties::docx_background_serialize(std::wostream & strm, oox::docx_conversion_context & Context, oox::_oox_fill & fill, int id) +{ + if (style_page_layout_properties_attlist_.common_background_color_attlist_.fo_background_color_ && + style_page_layout_properties_attlist_.common_background_color_attlist_.fo_background_color_->get_type() == background_color::Transparent) + return true; //?? //прозрачный фон + CP_XML_WRITER(strm) { CP_XML_NODE(L"w:background") { - std::wstring color = style_page_layout_properties_attlist_.common_background_color_attlist_.fo_background_color_->get_color().get_hex_value(); - CP_XML_ATTR(L"w:color",color); + std::wstring color = L"ffffff"; + + if (style_page_layout_properties_attlist_.common_background_color_attlist_.fo_background_color_) + color = style_page_layout_properties_attlist_.common_background_color_attlist_.fo_background_color_->get_color().get_hex_value(); + + CP_XML_ATTR(L"w:color", color); + + oox::vml_serialize_background(CP_XML_STREAM(), fill, color, id); } } return true; diff --git a/ASCOfficeOdfFile/src/odf/styles.h b/ASCOfficeOdfFile/src/odf/styles.h index 4514109a63..cb5d0e8a49 100644 --- a/ASCOfficeOdfFile/src/odf/styles.h +++ b/ASCOfficeOdfFile/src/odf/styles.h @@ -892,54 +892,26 @@ public: odf_types::common_padding_attlist common_padding_attlist_; odf_types::common_shadow_attlist common_shadow_attlist_; - // 15.2.10 - odf_types::common_background_color_attlist common_background_color_attlist_; - // 15.2.12 - _CP_OPT(odf_types::style_ref) style_register_truth_ref_style_name_; - // 15.2.13 TODO - _CP_OPT(std::wstring) style_print_; - - // 15.2.14 - _CP_OPT(odf_types::direction) style_print_page_order_; - - // 15.2.15 TODO - _CP_OPT(std::wstring) style_first_page_number_; - - // 15.2.16 - _CP_OPT(odf_types::percent) style_scale_to_; - _CP_OPT(unsigned int) style_scale_to_pages_; - - // 15.2.17 - _CP_OPT(odf_types::table_centering) style_table_centering_; - // 15.2.18 - _CP_OPT(odf_types::length) style_footnote_max_height_; - - // 15.2.19 - odf_types::common_writing_mode_attlist common_writing_mode_attlist_; - - // 15.2.21 - _CP_OPT(odf_types::layout_grid_mode) style_layout_grid_mode_; - - // 15.2.22 - _CP_OPT(odf_types::length) style_layout_grid_base_height_; - - // 15.2.23 - _CP_OPT(odf_types::length) style_layout_grid_ruby_height_; - - // 15.2.24 - _CP_OPT(unsigned int) style_layout_grid_lines_; - - // 15.2.25 - _CP_OPT(odf_types::color) style_layout_grid_color_; - - // 15.2.26 - _CP_OPT(bool) style_layout_grid_ruby_below_; - - // 15.2.27 - _CP_OPT(bool) style_layout_grid_print_; - - // 15.2.28 - _CP_OPT(bool) style_layout_grid_display_; + odf_types::common_background_color_attlist common_background_color_attlist_; + odf_types::common_draw_fill_attlist common_draw_fill_attlist_; + + _CP_OPT(odf_types::style_ref) style_register_truth_ref_style_name_; + _CP_OPT(std::wstring) style_print_; + _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_; + odf_types::common_writing_mode_attlist common_writing_mode_attlist_; + _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(bool) style_layout_grid_ruby_below_; + _CP_OPT(bool) style_layout_grid_print_; + _CP_OPT(bool) style_layout_grid_display_; }; @@ -992,7 +964,7 @@ public: }; -// style:page-layout-properties +// style:page-layout-properties class style_page_layout_properties : public office_element_impl { public: @@ -1005,7 +977,7 @@ public: void docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context); void pptx_convert(oox::pptx_conversion_context & Context); - bool docx_back_serialize(std::wostream & strm, oox::docx_conversion_context & Context); + bool docx_background_serialize(std::wostream & strm, oox::docx_conversion_context & Context, oox::_oox_fill & fill, int id); style_page_layout_properties() { } @@ -1020,7 +992,7 @@ private: CP_REGISTER_OFFICE_ELEMENT2(style_page_layout_properties); -// text:notes-configuration +// text:notes-configuration class text_notes_configuration : public office_element_impl { public: diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp index 73dac8ea8c..837cff6933 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp @@ -55,8 +55,7 @@ #include "style_text_properties.h" #include "style_paragraph_properties.h" #include "style_graphic_properties.h" - - +#include "style_page_layout_properties.h" namespace cpdoccore { @@ -175,6 +174,7 @@ struct odf_drawing_state svg_y_ = boost::none; svg_height_ = boost::none; svg_width_ = boost::none; + fill_color_ = boost::none; name_ = L""; description_ = L""; @@ -208,7 +208,8 @@ struct odf_drawing_state int z_order_; bool hidden_; - _CP_OPT(double) rotateAngle; + _CP_OPT(double) rotateAngle; + _CP_OPT(unsigned int) fill_color_; bool flipH; bool flipV; @@ -238,8 +239,9 @@ public: width = height = x = y = 0; - is_header_ = false; - is_footer_ = false; + is_header_ = false; + is_footer_ = false; + is_background_ = false; //некоторые свойства для объектов графики не поддерживаюися в редакторах Liber && OpenOffice.net //в MS Office и в нашем - проблем таких нет. } @@ -254,6 +256,7 @@ public: bool is_footer_; bool is_header_; + bool is_background_; void create_draw_base(int type); office_element_ptr create_draw_element(int type); @@ -309,10 +312,18 @@ void odf_drawing_context::set_header_state(bool Val) { impl_->is_header_ = Val; } + +void odf_drawing_context::set_background_state(bool Val) +{ + impl_->is_background_ = Val; + + impl_->current_graphic_properties = new style_graphic_properties(); +} + void odf_drawing_context::check_anchor() { return; - if ((impl_->is_footer_ || impl_->is_header_) && (impl_->anchor_settings_.run_through_) && (impl_->anchor_settings_.run_through_->get_type() == run_through::Background)) + if ((impl_->is_footer_ || impl_->is_header_ || impl_->is_background_) && (impl_->anchor_settings_.run_through_) && (impl_->anchor_settings_.run_through_->get_type() == run_through::Background)) { set_anchor(anchor_type::Char); //подозрительно на подложку страницы @@ -444,7 +455,18 @@ void odf_drawing_context::start_drawing() } void odf_drawing_context::end_drawing() { - if (impl_->current_drawing_state_.elements_.empty()) return; + if (impl_->current_drawing_state_.elements_.empty()) + { + if (impl_->is_background_ && impl_->current_graphic_properties) + { + style_page_layout_properties * current_layout_properties = impl_->odf_context_->page_layout_context()->last_layout()->get_properties(); + current_layout_properties->style_page_layout_properties_attlist_.common_draw_fill_attlist_.apply_from(impl_->current_graphic_properties->content().common_draw_fill_attlist_); + delete impl_->current_graphic_properties; + impl_->current_graphic_properties = NULL; + impl_->current_drawing_state_.clear(); + } + return; + } draw_base* draw = dynamic_cast(impl_->current_drawing_state_.elements_[0].elm.get()); @@ -570,12 +592,13 @@ void odf_drawing_context::end_drawing() { impl_->tops_elements_.push_back(impl_->current_drawing_state_.elements_[0].elm); } + /////////////// impl_->current_drawing_state_.clear(); + impl_->current_graphic_properties = NULL; impl_->current_paragraph_properties = NULL; impl_->current_text_properties = NULL; - } //////////////////////////////////////////////////////////////////////////// @@ -629,7 +652,7 @@ void odf_drawing_context::Impl::create_draw_base(int type) draw_base* draw = dynamic_cast(draw_elm.get()); if (draw == NULL)return; ////////// - styles_context_->create_style(L"",style_family::Graphic, true, false, -1); + styles_context_->create_style(L"", style_family::Graphic, true, false, -1); office_element_ptr & style_shape_elm = styles_context_->last_state()->get_office_element(); std::wstring style_name; @@ -1068,7 +1091,7 @@ void odf_drawing_context::set_no_fill() switch(impl_->current_drawing_part_) { case Area: - if ((impl_->is_footer_ || impl_->is_header_) && + if ((impl_->is_footer_ || impl_->is_header_ || impl_->is_background_) && (impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_) && (impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_->get_type() == draw_fill::bitmap)) { @@ -1088,6 +1111,17 @@ void odf_drawing_context::set_type_fill(int type) impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_ = (draw_fill::type)type; } + +void odf_drawing_context::set_fill_color(unsigned int Color) +{ + impl_->current_drawing_state_.fill_color_ = Color; +} + +_CP_OPT(unsigned int) odf_drawing_context::get_fill_color() +{ + return impl_->current_drawing_state_.fill_color_; +} + void odf_drawing_context::set_solid_fill(std::wstring hexColor) { if (!impl_->current_graphic_properties)return; @@ -1097,28 +1131,29 @@ void odf_drawing_context::set_solid_fill(std::wstring hexColor) switch(impl_->current_drawing_part_) { - case Area: - impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_color_ = hexColor; - impl_->current_graphic_properties->content().common_background_color_attlist_.fo_background_color_ = color(hexColor); - //последнее нужно - что если будут вводить текст - под текстом будет цвет фона (или он поменяется в полях текста) - - if ((impl_->is_footer_ || impl_->is_header_) && - (impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_) && - (impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_->get_type() == draw_fill::bitmap)) - { - } - else - impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_ = draw_fill::solid; - break; - case Line: - impl_->current_graphic_properties->content().svg_stroke_color_ = hexColor; - if (!impl_->current_graphic_properties->content().draw_stroke_) - impl_->current_graphic_properties->content().draw_stroke_=line_style(line_style::Solid);//default - if (!impl_->current_graphic_properties->content().svg_stroke_width_) - impl_->current_graphic_properties->content().svg_stroke_width_ = length(length(1,length::pt).get_value_unit(length::cm),length::cm);//default - break; + case Area: + impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_color_ = hexColor; + impl_->current_graphic_properties->content().common_background_color_attlist_.fo_background_color_ = color(hexColor); + //последнее нужно - что если будут вводить текст - под текстом будет цвет фона (или он поменяется в полях текста) + + if ((impl_->is_footer_ || impl_->is_header_ || impl_->is_background_) && + (impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_) && + (impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_->get_type() == draw_fill::bitmap)) + { + } + else + impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_ = draw_fill::solid; + break; + case Line: + impl_->current_graphic_properties->content().svg_stroke_color_ = hexColor; + if (!impl_->current_graphic_properties->content().draw_stroke_) + impl_->current_graphic_properties->content().draw_stroke_=line_style(line_style::Solid);//default + if (!impl_->current_graphic_properties->content().svg_stroke_width_) + impl_->current_graphic_properties->content().svg_stroke_width_ = length(length(1,length::pt).get_value_unit(length::cm),length::cm);//default + break; } } + void odf_drawing_context::set_z_order(int id) { if (id < 0) @@ -1243,7 +1278,7 @@ void odf_drawing_context::set_object_foreground(bool Val) { if (Val) { - if (impl_->is_footer_|| impl_->is_header_) + if (impl_->is_footer_|| impl_->is_header_ || impl_->is_background_) { impl_->anchor_settings_.run_through_ = run_through(run_through::Background); } @@ -1273,7 +1308,7 @@ void odf_drawing_context::set_margin_bottom (double valPt) } void odf_drawing_context::set_anchor(int type) { - if ((impl_->is_footer_|| impl_->is_header_) && type == anchor_type::Page) + if ((impl_->is_footer_|| impl_->is_header_ || impl_->is_background_) && type == anchor_type::Page) { type = anchor_type::Paragraph; } @@ -1369,7 +1404,7 @@ void odf_drawing_context::set_horizontal_pos(double offset_pt) } void odf_drawing_context::set_default_wrap_style() { - if (impl_->is_header_ || impl_->is_footer_ ) + if (impl_->is_header_ || impl_->is_footer_ || impl_->is_background_) { impl_->anchor_settings_.style_wrap_ = style_wrap::RunThrough; } @@ -1879,7 +1914,7 @@ void odf_drawing_context::set_textarea_padding(_CP_OPT(double) & left, _CP_OPT(d //вложенные элементы void odf_drawing_context::start_image(std::wstring odf_path) { - if (impl_->is_footer_ || impl_->is_header_) + if (impl_->is_footer_ || impl_->is_header_ || impl_->is_background_) { start_shape(142/*SimpleTypes::shapetypeRect*/); start_bitmap_style(); @@ -2011,7 +2046,7 @@ void odf_drawing_context::set_text_box_parent_style(std::wstring style_name) void odf_drawing_context::end_image() { - if (impl_->is_footer_ || impl_->is_header_) + if (impl_->is_footer_ || impl_->is_header_ || impl_->is_background_) { end_bitmap_style(); end_shape(); @@ -2179,9 +2214,11 @@ void odf_drawing_context::start_gradient_style() gradient->draw_start_color_ = impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_color_; if (gradient->draw_start_color_) gradient->draw_start_intensity_ = 100.; + gradient->draw_border_ = 0; impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_gradient_name_ = gradient->draw_name_; impl_->current_graphic_properties->content().common_draw_fill_attlist_.draw_fill_ = draw_fill(draw_fill::gradient); + } void odf_drawing_context::set_gradient_type(gradient_style::type style) { @@ -2198,7 +2235,7 @@ void odf_drawing_context::set_gradient_start(std::wstring hexColor, _CP_OPT(doub int res = 0; if ((res = hexColor.find(L"#")) < 0) hexColor = std::wstring(L"#") + hexColor; - gradient->draw_start_color_ = hexColor; + gradient->draw_start_color_ = hexColor; gradient->draw_start_intensity_ = 100.; } void odf_drawing_context::set_gradient_end (std::wstring hexColor, _CP_OPT(double) & intensiv) @@ -2209,15 +2246,15 @@ void odf_drawing_context::set_gradient_end (std::wstring hexColor, _CP_OPT(doub int res = 0; if ((res = hexColor.find(L"#")) < 0) hexColor = std::wstring(L"#") + hexColor; - gradient->draw_end_color_ = hexColor; - gradient->draw_end_intensity_ = 100.; + gradient->draw_end_color_ = hexColor; + gradient->draw_end_intensity_ = 100.; } void odf_drawing_context::set_gradient_angle(double angle) { draw_gradient * gradient = dynamic_cast(impl_->styles_context_->last_state(style_family::Gradient)->get_office_element().get()); if (!gradient) return; - gradient->draw_angle_ = (270-angle)*10;//(int)((360 - angle)/180. * 3.14159265358979323846); + gradient->draw_angle_ = (270- angle) * 10;//(int)((360 - angle)/180. * 3.14159265358979323846); } void odf_drawing_context::set_gradient_rect(double l, double t, double r,double b) { @@ -2721,7 +2758,7 @@ void odf_drawing_context::set_image_client_rect_inch(double l, double t, double void odf_drawing_context::set_bitmap_link(std::wstring file_path) { std::wstring odf_ref_name ; - impl_->odf_context_->mediaitems()->add_or_find(file_path,_mediaitems::typeImage,odf_ref_name); + impl_->odf_context_->mediaitems()->add_or_find(file_path, _mediaitems::typeImage, odf_ref_name); if (impl_->current_drawing_state_.oox_shape_preset == 3000) { diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.h b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.h index 566ec50239..f66d9a43eb 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.h @@ -64,8 +64,10 @@ public: void clear (); void set_styles_context (odf_style_context* styles_context);//для embedded - void set_header_state (bool Val); - void set_footer_state (bool Val); + void set_header_state (bool Val); + void set_footer_state (bool Val); + void set_background_state (bool Val); + void check_anchor (); void set_margin_left (double valPt); @@ -173,6 +175,7 @@ public: void set_type_fill (int type);//for area - temp for objects void set_solid_fill (std::wstring hexColor); void set_opacity (double percent); + ////////////////////////////////////////////////////////////// void start_area_properties(); void end_area_properties(); @@ -187,6 +190,8 @@ public: std::wstring add_marker_style(int type); void end_line_properties (); + _CP_OPT(unsigned int) get_fill_color (); + void set_fill_color (unsigned int color); //void start_shadow_properties(); //void end_shadow_properties(); // пока одной функией .. diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.h b/ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.h index 904f1a2014..d9371a7a88 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.h @@ -170,6 +170,7 @@ private: bool is_header_; bool is_footer_; + bool is_background_; std::vector drawing_context_; std::vector text_context_; //for embedded diff --git a/ASCOfficeOdfFileW/source/OdfFormat/style_page_layout_properties.cpp b/ASCOfficeOdfFileW/source/OdfFormat/style_page_layout_properties.cpp index 571294706e..ce346e2158 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/style_page_layout_properties.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/style_page_layout_properties.cpp @@ -122,42 +122,47 @@ 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_); - 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_); + CP_XML_ATTR_OPT (L"fo:page-width", fo_page_width_); + CP_XML_ATTR_OPT (L"fo:page-height", fo_page_height_); - 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()); - common_border_line_width_attlist_.serialize(CP_GET_XML_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()); + 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: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: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()); + common_border_line_width_attlist_.serialize (CP_GET_XML_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()); + common_draw_fill_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_); + + 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_); } -const wchar_t * style_page_layout_properties::ns = L"style"; -const wchar_t * style_page_layout_properties::name = L"page-layout-properties"; +const wchar_t * style_page_layout_properties::ns = L"style"; +const wchar_t * style_page_layout_properties::name = L"page-layout-properties"; void style_page_layout_properties::create_child_element( const std::wstring & Ns, const std::wstring & Name) { diff --git a/ASCOfficeOdfFileW/source/OdfFormat/style_page_layout_properties.h b/ASCOfficeOdfFileW/source/OdfFormat/style_page_layout_properties.h index 0c611cddae..db83c49571 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/style_page_layout_properties.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/style_page_layout_properties.h @@ -62,6 +62,7 @@ public: _CP_OPT(odf_types::length) fo_page_width_; _CP_OPT(odf_types::length) fo_page_height_; + odf_types::common_draw_fill_attlist common_draw_fill_attlist_; odf_types::common_num_format_attlist common_num_format_attlist_; odf_types::common_num_format_prefix_suffix_attlist common_num_format_prefix_suffix_attlist_; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/styles.h b/ASCOfficeOdfFileW/source/OdfFormat/styles.h index fc33fa0288..ce647ba351 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/styles.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/styles.h @@ -159,8 +159,8 @@ public: std::wstring get_style_name(){return draw_name_.get_value_or(L"");} - _CP_OPT(odf_types::color) draw_start_color_; - _CP_OPT(odf_types::color) draw_end_color_; + _CP_OPT(odf_types::color) draw_start_color_; + _CP_OPT(odf_types::color) draw_end_color_; _CP_OPT(odf_types::percent) draw_end_intensity_; _CP_OPT(odf_types::percent) draw_start_intensity_; @@ -169,11 +169,11 @@ public: _CP_OPT(odf_types::percent) draw_cx_; _CP_OPT(odf_types::percent) draw_border_; - _CP_OPT(int) draw_angle_; - _CP_OPT(odf_types::gradient_style) draw_style_; + _CP_OPT(int) draw_angle_; + _CP_OPT(odf_types::gradient_style) draw_style_; - _CP_OPT(std::wstring) draw_name_; - _CP_OPT(std::wstring) draw_display_name_; + _CP_OPT(std::wstring) draw_name_; + _CP_OPT(std::wstring) draw_display_name_; virtual void create_child_element( const std::wstring & Ns, const std::wstring & Name); virtual void serialize(std::wostream & strm); diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDiagram.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDiagram.cpp index d5e5ca4c8d..5c1ad25960 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDiagram.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDiagram.cpp @@ -48,8 +48,6 @@ #include "../OdfFormat/style_text_properties.h" #include "../OdfFormat/style_paragraph_properties.h" -#define ARGB(a, r, g, b) ((unsigned int)( ( (unsigned char)(a) )| ( ( (unsigned char)(r) ) << 8 ) | ( ( (unsigned char)(g) ) << 16 ) | ( (unsigned char)(b) << 24 ) ) ) - using namespace cpdoccore; namespace Oox2Odf diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertVml.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertVml.cpp index ff0cf6e05f..6d98c57bc6 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertVml.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertVml.cpp @@ -44,6 +44,7 @@ #include "../OdfFormat/style_paragraph_properties.h" #include "../../../Common/DocxFormat/Source/DocxFormat/Logic/Vml.h" +#include "../../../DesktopEditor/raster/BgraFrame.h" #include "VmlShapeTypes2Oox.h" @@ -386,6 +387,9 @@ void OoxConverter::convert(OOX::Vml::CArc *vml_arc) void OoxConverter::convert(OOX::Vml::CBackground *vml_background) { if (vml_background == NULL) return; + + OOX::Vml::CVmlCommonElements *vml_common = static_cast(vml_background); + convert(vml_common); } void OoxConverter::convert(OOX::Vml::CFill *vml_fill) @@ -394,6 +398,28 @@ void OoxConverter::convert(OOX::Vml::CFill *vml_fill) odf_context()->drawing_context()->start_area_properties(); + std::wstring sImagePath; + + _CP_OPT(unsigned int) nRgbColor1, nRgbColor2; + _CP_OPT(std::wstring) sRgbColor1, sRgbColor2; + + if (vml_fill->m_oColor.IsInit()) + { + nRgbColor1 = ((unsigned int)(((BYTE)(vml_fill->m_oColor->Get_B()) + | ((unsigned int)((BYTE)(vml_fill->m_oColor->Get_G()))<<8)) + | (((unsigned int)(BYTE)(vml_fill->m_oColor->Get_R()))<<16))); + + sRgbColor1 = XmlUtils::IntToString(*nRgbColor1, L"%06X"); + } + + if (vml_fill->m_oColor2.IsInit()) + { + nRgbColor2 = ((unsigned int)(((BYTE)(vml_fill->m_oColor2->Get_B()) + | ((unsigned int)((BYTE)(vml_fill->m_oColor2->Get_G()))<<8)) + | (((unsigned int)(BYTE)(vml_fill->m_oColor2->Get_R()))<<16))); + sRgbColor2 = XmlUtils::IntToString(*nRgbColor2, L"%06X"); + } + if (vml_fill->m_rId.IsInit()) { //bitmap fill @@ -401,37 +427,37 @@ void OoxConverter::convert(OOX::Vml::CFill *vml_fill) { double Width=0, Height = 0; std::wstring sID = vml_fill->m_rId->GetValue(); - std::wstring pathImage = find_link_by_id(sID,1); + + sImagePath = find_link_by_id(sID, 1); - if (!pathImage.empty()) + if (!sImagePath.empty()) { - odf_context()->drawing_context()->set_bitmap_link(pathImage); - _graphics_utils_::GetResolution(pathImage.c_str(), Width, Height); + odf_context()->drawing_context()->set_bitmap_link( sImagePath ); + _graphics_utils_::GetResolution( sImagePath.c_str(), Width, Height ); } odf_context()->drawing_context()->set_image_style_repeat(1); } odf_context()->drawing_context()->end_bitmap_style(); } - else + + switch (vml_fill->m_oType.GetValue()) { - switch (vml_fill->m_oType.GetValue()) - { case SimpleTypes::filltypeGradient : case SimpleTypes::filltypeGradientCenter : case SimpleTypes::filltypeGradientRadial : case SimpleTypes::filltypeGradientUnscaled: { odf_context()->drawing_context()->start_gradient_style(); - if (SimpleTypes::filltypeGradient == vml_fill->m_oType.GetValue()) odf_context()->drawing_context()->set_gradient_type(odf_types::gradient_style::linear); - if (SimpleTypes::filltypeGradientRadial == vml_fill->m_oType.GetValue()) odf_context()->drawing_context()->set_gradient_type(odf_types::gradient_style::radial); - if (SimpleTypes::filltypeGradientCenter == vml_fill->m_oType.GetValue()) odf_context()->drawing_context()->set_gradient_type(odf_types::gradient_style::axial); - if (SimpleTypes::filltypeGradientUnscaled == vml_fill->m_oType.GetValue()) odf_context()->drawing_context()->set_gradient_type(odf_types::gradient_style::square); + if (SimpleTypes::filltypeGradient == vml_fill->m_oType.GetValue()) odf_context()->drawing_context()->set_gradient_type(odf_types::gradient_style::linear); + if (SimpleTypes::filltypeGradientRadial == vml_fill->m_oType.GetValue()) odf_context()->drawing_context()->set_gradient_type(odf_types::gradient_style::radial); + if (SimpleTypes::filltypeGradientCenter == vml_fill->m_oType.GetValue()) odf_context()->drawing_context()->set_gradient_type(odf_types::gradient_style::axial); + if (SimpleTypes::filltypeGradientUnscaled == vml_fill->m_oType.GetValue()) odf_context()->drawing_context()->set_gradient_type(odf_types::gradient_style::square); _CP_OPT(double) no_set; - if (vml_fill->m_oColor.IsInit()) - odf_context()->drawing_context()->set_gradient_start(vml_fill->m_oColor->ToString(), no_set); - if (vml_fill->m_oColor2.IsInit()) - odf_context()->drawing_context()->set_gradient_end(vml_fill->m_oColor2->ToString(), no_set); + if (sRgbColor1) + odf_context()->drawing_context()->set_gradient_start(*sRgbColor1, no_set); + if (sRgbColor2) + odf_context()->drawing_context()->set_gradient_end(*sRgbColor2, no_set); if (vml_fill->m_oFocusPosition.IsInit()) odf_context()->drawing_context()->set_gradient_center(vml_fill->m_oFocusPosition->GetX(), vml_fill->m_oFocusPosition->GetY()); @@ -440,23 +466,35 @@ void OoxConverter::convert(OOX::Vml::CFill *vml_fill) }break; case SimpleTypes::filltypePattern: { + if (!sImagePath.empty()) + { + odf_context()->drawing_context()->set_image_style_repeat(2); + + if (!nRgbColor1) + nRgbColor1 = odf_context()->drawing_context()->get_fill_color(); + + CBgraFrame bgraFrame; + + bgraFrame.ReColorPatternImage(sImagePath, nRgbColor1.get_value_or(0xffffff), nRgbColor2.get_value_or(0x000000)); + } + else + { odf_context()->drawing_context()->start_hatch_style(); - if (vml_fill->m_oColor2.IsInit()) - odf_context()->drawing_context()->set_hatch_line_color(vml_fill->m_oColor2->ToString()); - if (vml_fill->m_oColor.IsInit()) - odf_context()->drawing_context()->set_hatch_area_color(vml_fill->m_oColor->ToString()); + if (sRgbColor2) + odf_context()->drawing_context()->set_hatch_line_color(*sRgbColor2); + if (sRgbColor1) + odf_context()->drawing_context()->set_hatch_area_color(*sRgbColor1); else odf_context()->drawing_context()->set_hatch_area_color(L"#ffffff"); odf_context()->drawing_context()->end_hatch_style(); - + } }break; case SimpleTypes::filltypeSolid: default: - if (vml_fill->m_oColor.IsInit()) - odf_context()->drawing_context()->set_solid_fill(vml_fill->m_oColor->ToString()); + if (sImagePath.empty() && sRgbColor1) + odf_context()->drawing_context()->set_solid_fill(*sRgbColor1); break; - } } //-------------------------------------------------------------------------------------------------------------------- if (vml_fill->m_oOpacity.IsInit() && vml_fill->m_oOpacity2.IsInit() ) @@ -588,7 +626,7 @@ void OoxConverter::convert(OOX::Vml::CStroke *vml_stroke) if (vml_stroke->m_oColor.IsInit()) { std::wstring hexColor = vml_stroke->m_oColor->ToString(); - if (hexColor.length() < 1)hexColor = L"000000"; + if (hexColor.empty()) hexColor = L"000000"; odf_context()->drawing_context()->set_solid_fill(hexColor); } @@ -818,9 +856,16 @@ void OoxConverter::convert(OOX::Vml::CVmlCommonElements *vml_common) if (oRgbColor) { - odf_context()->drawing_context()->start_area_properties(); + unsigned int nRgbColor = ((unsigned int)(((BYTE)( oRgbColor->Get_B()) + | ((unsigned int)((BYTE)( oRgbColor->Get_G()))<<8)) + | (((unsigned int)(BYTE)( oRgbColor->Get_R()))<<16))); + + odf_context()->drawing_context()->set_fill_color(nRgbColor); + + odf_context()->drawing_context()->start_area_properties(); odf_context()->drawing_context()->set_solid_fill(oRgbColor->ToString().substr(2));//.Right(6)); odf_context()->drawing_context()->end_area_properties(); + delete oRgbColor; } } diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp index 6ac4bdac0a..21e38a5b80 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp @@ -215,11 +215,11 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown) OOX::Vml::CTextbox *vml = static_cast(oox_unknown); convert(vml); }break; - //case OOX::et_v_background: - //{ - // OOX::Vml::CBackground *vml = static_cast(oox_unknown); - // convert(vml); - //}break; + case OOX::et_v_background: + { + OOX::Vml::CBackground *vml = static_cast(oox_unknown); + convert(vml); + }break; case OOX::et_v_path: { OOX::Vml::CPath *vml = static_cast(oox_unknown); diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp index 22db787526..b76e46f758 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp @@ -1684,6 +1684,10 @@ void DocxConverter::convert(OOX::Logic::CBackground *oox_background, int type) odt_context->set_background(color, type); + odt_context->start_drawings(); + odt_context->drawing_context()->set_background_state(true); + odt_context->drawing_context()->start_drawing(); + if (oox_background->m_oDrawing.IsInit()) { convert(oox_background->m_oDrawing.GetPointer()); @@ -1692,6 +1696,8 @@ void DocxConverter::convert(OOX::Logic::CBackground *oox_background, int type) { convert(oox_background->m_oBackground.GetPointer()); } + odt_context->drawing_context()->end_drawing(); + odt_context->end_drawings(); } void DocxConverter::convert(ComplexTypes::Word::CFramePr *oox_frame_pr, odf_writer::style_paragraph_properties * paragraph_properties) diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.cpp index f729936caf..8b2c76002d 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/DestinationCommand.cpp @@ -1930,13 +1930,13 @@ void RtfShapeReader::ShapePropertyReader::ShapePropertyValueReader::PopState( Rt else if ( L"fLine" == m_sPropName ) m_oShape.m_bLine = ( 0 == nValue ? false : true ); else if ( L"lineStartArrowhead" == m_sPropName ) m_oShape.m_nLineStartArrow = nValue; else if ( L"lineColor" == m_sPropName ) m_oShape.m_nLineColor = nValue; - else if ( L"lineStartArrowWidth" == m_sPropName ) m_oShape.m_nLineStartArrowWidth= nValue; + else if ( L"lineStartArrowWidth" == m_sPropName ) m_oShape.m_nLineStartArrowWidth = nValue; else if ( L"lineStartArrowLength" == m_sPropName ) m_oShape.m_nLineStartArrowLength = nValue; - else if ( L"lineEndArrowhead" == m_sPropName ) m_oShape.m_nLineEndArrow = nValue; + else if ( L"lineEndArrowhead" == m_sPropName ) m_oShape.m_nLineEndArrow = nValue; else if ( L"lineEndArrowWidth" == m_sPropName ) m_oShape.m_nLineEndArrowWidth = nValue; else if ( L"lineEndArrowLength" == m_sPropName ) m_oShape.m_nLineEndArrowLength = nValue; else if ( L"lineWidth" == m_sPropName ) m_oShape.m_nLineWidth = nValue; - else if ( L"lineDashing" == m_sPropName ) m_oShape.m_nLineDashing = nValue; + else if ( L"lineDashing" == m_sPropName ) m_oShape.m_nLineDashing = nValue; else if (L"cxstyle" == m_sPropName ) m_oShape.m_nConnectorStyle = nValue; else if (L"cxk" == m_sPropName ) m_oShape.m_nConnectionType = nValue; else diff --git a/ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_drawing_context.cpp b/ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_drawing_context.cpp index c1e672c4bb..9cd3f2eaa8 100644 --- a/ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_drawing_context.cpp +++ b/ASCOfficeXlsFile2/source/XlsXlsxConverter/xlsx_drawing_context.cpp @@ -2417,44 +2417,12 @@ bool xlsx_drawing_context::ChangeBlack2ColorImage(std::wstring sRgbColor1, std:: std::wstring image_path = context_.get_mediaitems().media_path() + drawing_state->fill.texture_target.substr(6); - int rgbColor1 = STR::hex_str2int(sRgbColor1); - int rgbColor2 = STR::hex_str2int(sRgbColor2); + size_t rgbColor1 = STR::hex_str2int(sRgbColor1); + size_t rgbColor2 = STR::hex_str2int(sRgbColor2); CBgraFrame bgraFrame; - if (bgraFrame.OpenFile(image_path)) - { - int smpl = abs(bgraFrame.get_Stride() / bgraFrame.get_Width()); - - BYTE * rgb = bgraFrame.get_Data(); - - BYTE R1 = (BYTE)(rgbColor1); - BYTE G1 = (BYTE)(rgbColor1 >> 8); - BYTE B1 = (BYTE)(rgbColor1 >> 16); - - BYTE R2 = (BYTE)(rgbColor2); - BYTE G2 = (BYTE)(rgbColor2 >> 8); - BYTE B2 = (BYTE)(rgbColor2 >> 16); - - for (int i = 0 ; i < bgraFrame.get_Width() * bgraFrame.get_Height(); i++) - { - if (rgb[i * smpl + 0 ] == 0x00 && rgb[i * smpl + 1 ] == 0x00 && rgb[i * smpl + 2 ] == 0x00) - { - rgb[i * smpl + 0 ] = R1; - rgb[i * smpl + 1 ] = G1; - rgb[i * smpl + 2 ] = B1; - } - else - { - rgb[i * smpl + 0 ] = R2; - rgb[i * smpl + 1 ] = G2; - rgb[i * smpl + 2 ] = B2; - } - } - bgraFrame.SaveFile(image_path, 1); - return true; - } - return false; + return bgraFrame.ReColorPatternImage(image_path, rgbColor1, rgbColor2); } void xlsx_drawing_context::serialize_vml_HF(std::wostream & strm) diff --git a/Common/DocxFormat/Source/Common/SimpleTypes_Vml.h b/Common/DocxFormat/Source/Common/SimpleTypes_Vml.h index 2bfb923a44..c6b0466a14 100644 --- a/Common/DocxFormat/Source/Common/SimpleTypes_Vml.h +++ b/Common/DocxFormat/Source/Common/SimpleTypes_Vml.h @@ -283,31 +283,31 @@ namespace SimpleTypes { if ( 0 == nType ) { - switch (this->m_eValue) + switch (this->m_eValue) { - case filltypeFrame : return _T("frame"); - case filltypeGradient : return _T("gradient"); - case filltypeGradientRadial : return _T("gradientRadial"); - case filltypePattern : return _T("pattern"); - case filltypeSolid : return _T("solid"); - case filltypeTile : return _T("tile"); - default : return _T("solid"); + case filltypeFrame : return _T("frame"); + case filltypeGradient : return _T("gradient"); + case filltypeGradientRadial : return _T("gradientRadial"); + case filltypePattern : return _T("pattern"); + case filltypeSolid : return _T("solid"); + case filltypeTile : return _T("tile"); + default : return _T("solid"); } } else { - switch (this->m_eValue) + switch (this->m_eValue) { - case filltypeBackground : return _T("background"); - case filltypeFrame : return _T("frame"); - case filltypeGradient : return _T("gradient"); - case filltypeGradientCenter : return _T("gradientCenter"); - case filltypeGradientRadial : return _T("gradientRadial"); - case filltypeGradientUnscaled : return _T("gradientUnscaled"); - case filltypePattern : return _T("pattern"); - case filltypeSolid : return _T("solid"); - case filltypeTile : return _T("tile"); - default : return _T("solid"); + case filltypeBackground : return _T("background"); + case filltypeFrame : return _T("frame"); + case filltypeGradient : return _T("gradient"); + case filltypeGradientCenter : return _T("gradientCenter"); + case filltypeGradientRadial : return _T("gradientRadial"); + case filltypeGradientUnscaled : return _T("gradientUnscaled"); + case filltypePattern : return _T("pattern"); + case filltypeSolid : return _T("solid"); + case filltypeTile : return _T("tile"); + default : return _T("solid"); } } } @@ -438,13 +438,13 @@ namespace SimpleTypes switch ( wChar ) { case 'l': - if ( _T("long") == sValue ) this->m_eValue = strokearrowlengthLong; + if ( _T("long") == sValue ) this->m_eValue = strokearrowlengthLong; break; case 'm': - if ( _T("medium") == sValue ) this->m_eValue = strokearrowlengthMedium; + if ( _T("medium") == sValue ) this->m_eValue = strokearrowlengthMedium; break; case 's': - if ( _T("short") == sValue ) this->m_eValue = strokearrowlengthShort; + if ( _T("short") == sValue ) this->m_eValue = strokearrowlengthShort; break; } @@ -455,10 +455,10 @@ namespace SimpleTypes { switch(this->m_eValue) { - case strokearrowlengthLong : return _T("long"); - case strokearrowlengthMedium : return _T("medium"); - case strokearrowlengthShort : return _T("short"); - default : return _T("medium"); + case strokearrowlengthLong : return _T("long"); + case strokearrowlengthMedium : return _T("medium"); + case strokearrowlengthShort : return _T("short"); + default : return _T("medium"); } } @@ -563,13 +563,13 @@ namespace SimpleTypes switch ( wChar ) { case 'm': - if ( _T("medium") == sValue ) this->m_eValue = strokearrowwidthMedium; + if ( _T("medium") == sValue ) this->m_eValue = strokearrowwidthMedium; break; case 'n': - if ( _T("narrow") == sValue ) this->m_eValue = strokearrowwidthNarrow; + if ( _T("narrow") == sValue ) this->m_eValue = strokearrowwidthNarrow; break; case 'w': - if ( _T("wide") == sValue ) this->m_eValue = strokearrowwidthWide; + if ( _T("wide") == sValue ) this->m_eValue = strokearrowwidthWide; break; } @@ -580,10 +580,10 @@ namespace SimpleTypes { switch(this->m_eValue) { - case strokearrowwidthMedium : return _T("medium"); - case strokearrowwidthNarrow : return _T("narrow"); - case strokearrowwidthWide : return _T("wide"); - default : return _T("medium"); + case strokearrowwidthMedium : return _T("medium"); + case strokearrowwidthNarrow : return _T("narrow"); + case strokearrowwidthWide : return _T("wide"); + default : return _T("medium"); } } @@ -619,13 +619,13 @@ namespace SimpleTypes switch ( wChar ) { case 'f': - if ( _T("flat") == sValue ) this->m_eValue = strokeendcapFlat; + if ( _T("flat") == sValue ) this->m_eValue = strokeendcapFlat; break; case 'r': - if ( _T("round") == sValue ) this->m_eValue = strokeendcapRound; + if ( _T("round") == sValue ) this->m_eValue = strokeendcapRound; break; case 's': - if ( _T("square") == sValue ) this->m_eValue = strokeendcapSqaure; + if ( _T("square") == sValue ) this->m_eValue = strokeendcapSqaure; break; } @@ -777,10 +777,10 @@ namespace SimpleTypes switch ( wChar ) { case 'o': - if ( _T("officeopenxmlmath") == sValue ) this->m_eValue = alternatemathcontenttypeOfficeOpenXmlMath; + if ( _T("officeopenxmlmath") == sValue ) this->m_eValue = alternatemathcontenttypeOfficeOpenXmlMath; break; case 'm': - if ( _T("mathml") == sValue ) this->m_eValue = alternatemathcontenttypeMathMl; + if ( _T("mathml") == sValue ) this->m_eValue = alternatemathcontenttypeMathMl; break; } @@ -1033,10 +1033,10 @@ namespace SimpleTypes switch ( wChar ) { case 'a': - if ( _T("auto") == sValue ) this->m_eValue = colormodeAuto; + if ( _T("auto") == sValue ) this->m_eValue = colormodeAuto; break; case 'c': - if ( _T("custom") == sValue ) this->m_eValue = colormodeCustom; + if ( _T("custom") == sValue ) this->m_eValue = colormodeCustom; break; } @@ -1086,16 +1086,16 @@ namespace SimpleTypes switch ( wChar ) { case 'c': - if ( _T("curved") == sValue ) this->m_eValue = connectortypeCurved; + if ( _T("curved") == sValue ) this->m_eValue = connectortypeCurved; break; case 'e': - if ( _T("elbow") == sValue ) this->m_eValue = connectortypeElbow; + if ( _T("elbow") == sValue ) this->m_eValue = connectortypeElbow; break; case 'n': - if ( _T("none") == sValue ) this->m_eValue = connectortypeNone; + if ( _T("none") == sValue ) this->m_eValue = connectortypeNone; break; case 's': - if ( _T("straight") == sValue ) this->m_eValue = connectortypeStraight; + if ( _T("straight") == sValue ) this->m_eValue = connectortypeStraight; break; } @@ -1106,11 +1106,11 @@ namespace SimpleTypes { switch(this->m_eValue) { - case connectortypeCurved : return _T("curved"); - case connectortypeElbow : return _T("elbow"); - case connectortypeNone : return _T("none"); - case connectortypeStraight: return _T("straight"); - default : return _T("none"); + case connectortypeCurved : return _T("curved"); + case connectortypeElbow : return _T("elbow"); + case connectortypeNone : return _T("none"); + case connectortypeStraight: return _T("straight"); + default : return _T("none"); } } @@ -1147,16 +1147,16 @@ namespace SimpleTypes switch ( wChar ) { case 'c': - if ( _T("custom") == sValue ) this->m_eValue = connecttypeCustom; + if ( _T("custom") == sValue ) this->m_eValue = connecttypeCustom; break; case 'n': - if ( _T("none") == sValue ) this->m_eValue = connecttypeNone; + if ( _T("none") == sValue ) this->m_eValue = connecttypeNone; break; case 'r': - if ( _T("rect") == sValue ) this->m_eValue = connecttypeRect; + if ( _T("rect") == sValue ) this->m_eValue = connecttypeRect; break; case 's': - if ( _T("segments") == sValue ) this->m_eValue = connecttypeSegments; + if ( _T("segments") == sValue ) this->m_eValue = connecttypeSegments; break; } @@ -1167,11 +1167,11 @@ namespace SimpleTypes { switch(this->m_eValue) { - case connecttypeCustom : return _T("custom"); - case connecttypeNone : return _T("none"); - case connecttypeRect : return _T("rect"); - case connecttypeSegments: return _T("segments"); - default : return _T("none"); + case connecttypeCustom : return _T("custom"); + case connecttypeNone : return _T("none"); + case connecttypeRect : return _T("rect"); + case connecttypeSegments: return _T("segments"); + default : return _T("none"); } } @@ -1247,16 +1247,16 @@ namespace SimpleTypes switch ( wChar ) { case '0': - if ( _T("0") == sValue ) this->m_eValue = diagramlayout0; + if ( _T("0") == sValue ) this->m_eValue = diagramlayout0; break; case '1': - if ( _T("1") == sValue ) this->m_eValue = diagramlayout1; + if ( _T("1") == sValue ) this->m_eValue = diagramlayout1; break; case '2': - if ( _T("2") == sValue ) this->m_eValue = diagramlayout2; + if ( _T("2") == sValue ) this->m_eValue = diagramlayout2; break; case '3': - if ( _T("3") == sValue ) this->m_eValue = diagramlayout3; + if ( _T("3") == sValue ) this->m_eValue = diagramlayout3; break; } @@ -1267,11 +1267,11 @@ namespace SimpleTypes { switch(this->m_eValue) { - case diagramlayout0 : return _T("0"); - case diagramlayout1 : return _T("1"); - case diagramlayout2 : return _T("2"); - case diagramlayout3 : return _T("3"); - default : return _T("0"); + case diagramlayout0 : return _T("0"); + case diagramlayout1 : return _T("1"); + case diagramlayout2 : return _T("2"); + case diagramlayout3 : return _T("3"); + default : return _T("0"); } } @@ -1307,22 +1307,22 @@ namespace SimpleTypes switch ( wChar ) { case 'X': - if ( _T("XY") == sValue ) this->m_eValue = extrusionplaneXY; + if ( _T("XY") == sValue ) this->m_eValue = extrusionplaneXY; break; case 'Y': - if ( _T("YZ") == sValue ) this->m_eValue = extrusionplaneYZ; + if ( _T("YZ") == sValue ) this->m_eValue = extrusionplaneYZ; break; case 'Z': - if ( _T("ZX") == sValue ) this->m_eValue = extrusionplaneZX; + if ( _T("ZX") == sValue ) this->m_eValue = extrusionplaneZX; break; case 'x': - if ( _T("xy") == sValue ) this->m_eValue = extrusionplaneXY; + if ( _T("xy") == sValue ) this->m_eValue = extrusionplaneXY; break; case 'y': - if ( _T("yz") == sValue ) this->m_eValue = extrusionplaneYZ; + if ( _T("yz") == sValue ) this->m_eValue = extrusionplaneYZ; break; case 'z': - if ( _T("zx") == sValue ) this->m_eValue = extrusionplaneZX; + if ( _T("zx") == sValue ) this->m_eValue = extrusionplaneZX; break; } @@ -1372,13 +1372,13 @@ namespace SimpleTypes switch ( wChar ) { case 'b': - if ( _T("boundingCube") == sValue ) this->m_eValue = extrusionrenderBoundingCube; + if ( _T("boundingCube") == sValue ) this->m_eValue = extrusionrenderBoundingCube; break; case 's': - if ( _T("solid") == sValue ) this->m_eValue = extrusionrenderSolid; + if ( _T("solid") == sValue ) this->m_eValue = extrusionrenderSolid; break; case 'w': - if ( _T("wireFrame") == sValue ) this->m_eValue = extrusionrenderWireFrame; + if ( _T("wireFrame") == sValue ) this->m_eValue = extrusionrenderWireFrame; break; } @@ -1389,10 +1389,10 @@ namespace SimpleTypes { switch(this->m_eValue) { - case extrusionrenderBoundingCube: return _T("boundingCube"); - case extrusionrenderSolid: return _T("solid"); - case extrusionrenderWireFrame: return _T("wireFrame"); - default : return _T("solid"); + case extrusionrenderBoundingCube: return _T("boundingCube"); + case extrusionrenderSolid: return _T("solid"); + case extrusionrenderWireFrame: return _T("wireFrame"); + default : return _T("solid"); } } @@ -1467,22 +1467,22 @@ namespace SimpleTypes switch ( wChar ) { case 'b': - if ( _T("bottom") == sValue ) this->m_eValue = howBottom; + if ( _T("bottom") == sValue ) this->m_eValue = howBottom; break; case 'c': - if ( _T("center") == sValue ) this->m_eValue = howCenter; + if ( _T("center") == sValue ) this->m_eValue = howCenter; break; case 'l': - if ( _T("left") == sValue ) this->m_eValue = howLeft; + if ( _T("left") == sValue ) this->m_eValue = howLeft; break; case 'm': - if ( _T("middle") == sValue ) this->m_eValue = howMiddle; + if ( _T("middle") == sValue ) this->m_eValue = howMiddle; break; case 'r': - if ( _T("right") == sValue ) this->m_eValue = howRight; + if ( _T("right") == sValue ) this->m_eValue = howRight; break; case 't': - if ( _T("top") == sValue ) this->m_eValue = howTop; + if ( _T("top") == sValue ) this->m_eValue = howTop; break; } @@ -1493,13 +1493,13 @@ namespace SimpleTypes { switch(this->m_eValue) { - case howBottom: return _T("bottom"); - case howCenter: return _T("center"); - case howLeft : return _T("left"); - case howMiddle: return _T("middle"); - case howRight : return _T("right"); - case howTop : return _T("top"); - default : return _T("top"); + case howBottom: return _T("bottom"); + case howCenter: return _T("center"); + case howLeft : return _T("left"); + case howMiddle: return _T("middle"); + case howRight : return _T("right"); + case howTop : return _T("top"); + default : return _T("top"); } } @@ -1535,13 +1535,13 @@ namespace SimpleTypes switch ( wChar ) { case 'c': - if ( _T("center") == sValue ) this->m_eValue = hralignCenter; + if ( _T("center") == sValue ) this->m_eValue = hralignCenter; break; case 'l': - if ( _T("left") == sValue ) this->m_eValue = hralignLeft; + if ( _T("left") == sValue ) this->m_eValue = hralignLeft; break; case 'r': - if ( _T("right") == sValue ) this->m_eValue = hralignRight; + if ( _T("right") == sValue ) this->m_eValue = hralignRight; break; } @@ -1552,10 +1552,10 @@ namespace SimpleTypes { switch(this->m_eValue) { - case hralignCenter: return _T("center"); - case hralignLeft : return _T("left"); - case hralignRight : return _T("right"); - default : return _T("left"); + case hralignCenter: return _T("center"); + case hralignLeft : return _T("left"); + case hralignRight : return _T("right"); + default : return _T("left"); } } @@ -1590,10 +1590,10 @@ namespace SimpleTypes switch ( wChar ) { case 'a': - if ( _T("auto") == sValue ) this->m_eValue = insetmodeAuto; + if ( _T("auto") == sValue ) this->m_eValue = insetmodeAuto; break; case 'c': - if ( _T("custom") == sValue ) this->m_eValue = insetmodeCustom; + if ( _T("custom") == sValue ) this->m_eValue = insetmodeCustom; break; } @@ -1604,9 +1604,9 @@ namespace SimpleTypes { switch(this->m_eValue) { - case insetmodeAuto : return _T("auto"); - case insetmodeCustom : return _T("custom"); - default : return _T("auto"); + case insetmodeAuto : return _T("auto"); + case insetmodeCustom : return _T("custom"); + default : return _T("auto"); } } @@ -1642,9 +1642,9 @@ namespace SimpleTypes { switch (this->m_eValue) { - case oledrawaspectContent : return _T("Content"); - case oledrawaspectIcon : return _T("Icon"); - default : return _T("Content"); + case oledrawaspectContent : return _T("Content"); + case oledrawaspectIcon : return _T("Icon"); + default : return _T("Content"); } } @@ -1702,12 +1702,12 @@ namespace SimpleTypes { switch(this->m_eValue) { - case olelinktypeBitmap: return _T("Bitmap"); - case olelinktypeEmf: return _T("EnhancedMetaFile"); - case olelinktypeJpeg: return _T("Jpeg"); - case olelinktypePicture: return _T("Picture"); - case olelinktypePng: return _T("Png"); - default : return _T("Bitmap"); + case olelinktypeBitmap: return _T("Bitmap"); + case olelinktypeEmf: return _T("EnhancedMetaFile"); + case olelinktypeJpeg: return _T("Jpeg"); + case olelinktypePicture: return _T("Picture"); + case olelinktypePng: return _T("Png"); + default : return _T("Bitmap"); } } @@ -1944,10 +1944,10 @@ namespace SimpleTypes switch ( wChar ) { case 'f': - if ( _T("f") == sValue || _T("false") == sValue ) this->m_eValue = bordershadowFalse; + if ( _T("f") == sValue || _T("false") == sValue ) this->m_eValue = bordershadowFalse; break; case 't': - if ( _T("t") == sValue || _T("true") == sValue ) this->m_eValue = bordershadowTrue; + if ( _T("t") == sValue || _T("true") == sValue ) this->m_eValue = bordershadowTrue; break; } @@ -2074,34 +2074,34 @@ namespace SimpleTypes { switch(this->m_eValue) { - case bordertypeDash: return _T("dash"); - case bordertypeDashDotDot: return _T("dashDotDot"); - case bordertypeDashDotStroked: return _T("dashDotStroked"); - case bordertypeDashedSmall: return _T("dashedSmall"); - case bordertypeDot: return _T("dot"); - case bordertypeDotDash: return _T("dotDash"); - case bordertypeDouble: return _T("double"); - case bordertypeDoubleWave: return _T("doubleWave"); - case bordertypeHairline: return _T("hairline"); - case bordertypeHTMLInset: return _T("HTMLInset"); - case bordertypeHTMLOutset: return _T("HTMLOutset"); - case bordertypeNone: return _T("none"); - case bordertypeSingle: return _T("single"); - case bordertypeThick: return _T("thick"); - case bordertypeThickBetweenThin: return _T("thickBetweenThin"); - case bordertypeThickBetweenThinLarge: return _T("thickBetweenThinLarge"); - case bordertypeThickBetweenThinSmall: return _T("thickBetweenThinSmall"); - case bordertypeThickThin: return _T("thickThin"); - case bordertypeThickThinLarge: return _T("thickThinLarge"); - case bordertypeThickThinSmall: return _T("thickThinSmall"); - case bordertypeThinThick: return _T("thinThick"); - case bordertypeThinThickLarge: return _T("thinThickLarge"); - case bordertypeThinThickSmall: return _T("thinThickSmall"); - case bordertypeThreeDEmboss: return _T("threeDEmboss"); - case bordertypeThreeDEngrave: return _T("threeDEngrave"); - case bordertypeTriple: return _T("triple"); - case bordertypeWave: return _T("wave"); - default : return _T("none"); + case bordertypeDash: return _T("dash"); + case bordertypeDashDotDot: return _T("dashDotDot"); + case bordertypeDashDotStroked: return _T("dashDotStroked"); + case bordertypeDashedSmall: return _T("dashedSmall"); + case bordertypeDot: return _T("dot"); + case bordertypeDotDash: return _T("dotDash"); + case bordertypeDouble: return _T("double"); + case bordertypeDoubleWave: return _T("doubleWave"); + case bordertypeHairline: return _T("hairline"); + case bordertypeHTMLInset: return _T("HTMLInset"); + case bordertypeHTMLOutset: return _T("HTMLOutset"); + case bordertypeNone: return _T("none"); + case bordertypeSingle: return _T("single"); + case bordertypeThick: return _T("thick"); + case bordertypeThickBetweenThin: return _T("thickBetweenThin"); + case bordertypeThickBetweenThinLarge: return _T("thickBetweenThinLarge"); + case bordertypeThickBetweenThinSmall: return _T("thickBetweenThinSmall"); + case bordertypeThickThin: return _T("thickThin"); + case bordertypeThickThinLarge: return _T("thickThinLarge"); + case bordertypeThickThinSmall: return _T("thickThinSmall"); + case bordertypeThinThick: return _T("thinThick"); + case bordertypeThinThickLarge: return _T("thinThickLarge"); + case bordertypeThinThickSmall: return _T("thinThickSmall"); + case bordertypeThreeDEmboss: return _T("threeDEmboss"); + case bordertypeThreeDEngrave: return _T("threeDEngrave"); + case bordertypeTriple: return _T("triple"); + case bordertypeWave: return _T("wave"); + default : return _T("none"); } } @@ -2138,18 +2138,18 @@ namespace SimpleTypes switch ( wChar ) { case 'c': - if ( _T("char") == sValue ) this->m_eValue = horizontalanchorChar; + if ( _T("char") == sValue ) this->m_eValue = horizontalanchorChar; break; case 'm': - if ( _T("margin") == sValue ) this->m_eValue = horizontalanchorMargin; + if ( _T("margin") == sValue ) this->m_eValue = horizontalanchorMargin; break; case 'p': - if ( _T("page") == sValue ) this->m_eValue = horizontalanchorPage; + if ( _T("page") == sValue ) this->m_eValue = horizontalanchorPage; break; case 't': - if ( _T("text") == sValue ) this->m_eValue = horizontalanchorText; + if ( _T("text") == sValue ) this->m_eValue = horizontalanchorText; break; } @@ -2160,11 +2160,11 @@ namespace SimpleTypes { switch(this->m_eValue) { - case horizontalanchorChar: return _T("char"); - case horizontalanchorMargin: return _T("margin"); - case horizontalanchorPage: return _T("page"); - case horizontalanchorText: return _T("text"); - default : return _T("char"); + case horizontalanchorChar: return _T("char"); + case horizontalanchorMargin: return _T("margin"); + case horizontalanchorPage: return _T("page"); + case horizontalanchorText: return _T("text"); + default : return _T("char"); } } @@ -2201,18 +2201,18 @@ namespace SimpleTypes switch ( wChar ) { case 'l': - if ( _T("line") == sValue ) this->m_eValue = verticalanchorLine; + if ( _T("line") == sValue ) this->m_eValue = verticalanchorLine; break; case 'm': - if ( _T("margin") == sValue ) this->m_eValue = verticalanchorMargin; + if ( _T("margin") == sValue ) this->m_eValue = verticalanchorMargin; break; case 'p': - if ( _T("page") == sValue ) this->m_eValue = verticalanchorPage; + if ( _T("page") == sValue ) this->m_eValue = verticalanchorPage; break; case 't': - if ( _T("text") == sValue ) this->m_eValue = verticalanchorText; + if ( _T("text") == sValue ) this->m_eValue = verticalanchorText; break; } @@ -2223,11 +2223,11 @@ namespace SimpleTypes { switch(this->m_eValue) { - case verticalanchorLine: return _T("line"); - case verticalanchorMargin: return _T("margin"); - case verticalanchorPage: return _T("page"); - case verticalanchorText: return _T("text"); - default : return _T("line"); + case verticalanchorLine: return _T("line"); + case verticalanchorMargin: return _T("margin"); + case verticalanchorPage: return _T("page"); + case verticalanchorText: return _T("text"); + default : return _T("line"); } } @@ -2284,11 +2284,11 @@ namespace SimpleTypes { switch(this->m_eValue) { - case wrapsideBoth: return _T("both"); - case wrapsideLargest: return _T("largest"); - case wrapsideLeft: return _T("left"); - case wrapsideRight: return _T("right"); - default : return _T("both"); + case wrapsideBoth: return _T("both"); + case wrapsideLargest: return _T("largest"); + case wrapsideLeft: return _T("left"); + case wrapsideRight: return _T("right"); + default : return _T("both"); } } @@ -2347,12 +2347,12 @@ namespace SimpleTypes { switch(this->m_eValue) { - case wraptypeNone: return _T("none"); - case wraptypeSquare: return _T("square"); - case wraptypeThrough: return _T("through"); - case wraptypeTight: return _T("tight"); - case wraptypeTopAndBottom: return _T("topAndBottom"); - default : return _T("none"); + case wraptypeNone: return _T("none"); + case wraptypeSquare: return _T("square"); + case wraptypeThrough: return _T("through"); + case wraptypeTight: return _T("tight"); + case wraptypeTopAndBottom: return _T("topAndBottom"); + default : return _T("none"); } } @@ -2370,25 +2370,25 @@ namespace SimpleTypes { enum EVmlClientDataObjectType { - vmlclientdataobjecttypeButton = 0, - vmlclientdataobjecttypeCheckbox = 1, - vmlclientdataobjecttypeDialog = 2, - vmlclientdataobjecttypeDrop = 3, - vmlclientdataobjecttypeEdit = 4, - vmlclientdataobjecttypeGBox = 5, - vmlclientdataobjecttypeGroup = 6, - vmlclientdataobjecttypeLabel = 7, - vmlclientdataobjecttypeLineA = 8, - vmlclientdataobjecttypeList = 9, - vmlclientdataobjecttypeMovie = 10, - vmlclientdataobjecttypeNote = 11, - vmlclientdataobjecttypePict = 12, - vmlclientdataobjecttypeRadio = 13, - vmlclientdataobjecttypeRect = 14, - vmlclientdataobjecttypeRectA = 15, - vmlclientdataobjecttypeScroll = 16, - vmlclientdataobjecttypeShape = 17, - vmlclientdataobjecttypeSpin = 18 + vmlclientdataobjecttypeButton = 0, + vmlclientdataobjecttypeCheckbox = 1, + vmlclientdataobjecttypeDialog = 2, + vmlclientdataobjecttypeDrop = 3, + vmlclientdataobjecttypeEdit = 4, + vmlclientdataobjecttypeGBox = 5, + vmlclientdataobjecttypeGroup = 6, + vmlclientdataobjecttypeLabel = 7, + vmlclientdataobjecttypeLineA = 8, + vmlclientdataobjecttypeList = 9, + vmlclientdataobjecttypeMovie = 10, + vmlclientdataobjecttypeNote = 11, + vmlclientdataobjecttypePict = 12, + vmlclientdataobjecttypeRadio = 13, + vmlclientdataobjecttypeRect = 14, + vmlclientdataobjecttypeRectA = 15, + vmlclientdataobjecttypeScroll = 16, + vmlclientdataobjecttypeShape = 17, + vmlclientdataobjecttypeSpin = 18 }; template class CVmlClientDataObjectType : public CSimpleType @@ -2427,28 +2427,28 @@ namespace SimpleTypes virtual std::wstring ToString () const { - switch(this->m_eValue) + switch(this->m_eValue) { - case vmlclientdataobjecttypeButton: return _T("Button"); - case vmlclientdataobjecttypeCheckbox: return _T("Checkbox"); - case vmlclientdataobjecttypeDialog: return _T("Dialog"); - case vmlclientdataobjecttypeDrop: return _T("Drop"); - case vmlclientdataobjecttypeEdit: return _T("Edit"); - case vmlclientdataobjecttypeGBox: return _T("GBox"); - case vmlclientdataobjecttypeGroup: return _T("Group"); - case vmlclientdataobjecttypeLabel: return _T("Label"); - case vmlclientdataobjecttypeLineA: return _T("LineA"); - case vmlclientdataobjecttypeList: return _T("List"); - case vmlclientdataobjecttypeMovie: return _T("Movie"); - case vmlclientdataobjecttypeNote: return _T("Note"); - case vmlclientdataobjecttypePict: return _T("Pict"); - case vmlclientdataobjecttypeRadio: return _T("Radio"); - case vmlclientdataobjecttypeRect: return _T("Rect"); - case vmlclientdataobjecttypeRectA: return _T("RectA"); - case vmlclientdataobjecttypeScroll: return _T("Scroll"); - case vmlclientdataobjecttypeShape: return _T("Shape"); - case vmlclientdataobjecttypeSpin: return _T("Spin"); - default : return _T("Button"); + case vmlclientdataobjecttypeButton: return _T("Button"); + case vmlclientdataobjecttypeCheckbox: return _T("Checkbox"); + case vmlclientdataobjecttypeDialog: return _T("Dialog"); + case vmlclientdataobjecttypeDrop: return _T("Drop"); + case vmlclientdataobjecttypeEdit: return _T("Edit"); + case vmlclientdataobjecttypeGBox: return _T("GBox"); + case vmlclientdataobjecttypeGroup: return _T("Group"); + case vmlclientdataobjecttypeLabel: return _T("Label"); + case vmlclientdataobjecttypeLineA: return _T("LineA"); + case vmlclientdataobjecttypeList: return _T("List"); + case vmlclientdataobjecttypeMovie: return _T("Movie"); + case vmlclientdataobjecttypeNote: return _T("Note"); + case vmlclientdataobjecttypePict: return _T("Pict"); + case vmlclientdataobjecttypeRadio: return _T("Radio"); + case vmlclientdataobjecttypeRect: return _T("Rect"); + case vmlclientdataobjecttypeRectA: return _T("RectA"); + case vmlclientdataobjecttypeScroll: return _T("Scroll"); + case vmlclientdataobjecttypeShape: return _T("Shape"); + case vmlclientdataobjecttypeSpin: return _T("Spin"); + default : return _T("Button"); } } @@ -2499,13 +2499,13 @@ namespace SimpleTypes virtual std::wstring ToString () const { - switch(this->m_eValue) + switch(this->m_eValue) { - case vmlcallouttypeRectangle: return _T("rectangle"); - case vmlcallouttypeRoundRectangle: return _T("roundedrectangle"); - case vmlcallouttypeOval: return _T("oval"); - case vmlcallouttypeCloud: return _T("cloud"); - default : return _T("rectangle"); + case vmlcallouttypeRectangle: return _T("rectangle"); + case vmlcallouttypeRoundRectangle: return _T("roundedrectangle"); + case vmlcallouttypeOval: return _T("oval"); + case vmlcallouttypeCloud: return _T("cloud"); + default : return _T("rectangle"); } } @@ -2526,7 +2526,7 @@ namespace SimpleTypes return m_sValue; } - void SetValue(std::wstring &sValue) + void SetValue(std::wstring &sValue) { m_sValue = sValue; } @@ -2707,12 +2707,12 @@ namespace SimpleTypes return m_dValue; } - void SetValue(double dValue) + void SetValue(double dValue) { m_dValue = (std::max)( 0.0, (std::min)( 1.0, dValue) ); } - void SetValue(int nValue) + void SetValue(int nValue) { m_dValue = (std::max)( 0.0, (std::min)( 65536.0, (double) nValue) ) / 65536.0; } diff --git a/DesktopEditor/raster/BgraFrame.cpp b/DesktopEditor/raster/BgraFrame.cpp index 3d29c8cf42..f0be94be4f 100644 --- a/DesktopEditor/raster/BgraFrame.cpp +++ b/DesktopEditor/raster/BgraFrame.cpp @@ -39,6 +39,8 @@ bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileType) { + m_nFileType = nFileType; + if (CXIMAGE_FORMAT_JP2 == nFileType) { Jpeg2000::CJ2kFile oJ2; @@ -49,7 +51,7 @@ bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileTyp if (nFileType == 0) { CImageFileFormatChecker checker(strFileName); - nFileType = checker.eFileType; + m_nFileType = checker.eFileType; } NSFile::CFileBinary oFile; if (!oFile.OpenFile(strFileName)) @@ -57,7 +59,7 @@ bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileTyp CxImage img; - if (!img.Decode(oFile.GetFileNative(), nFileType)) + if (!img.Decode(oFile.GetFileNative(), m_nFileType)) return false; CxImageToMediaFrame(img); @@ -116,7 +118,44 @@ bool CBgraFrame::Resize(const long& nNewWidth, const long& nNewHeight, bool bDes CxImageToMediaFrame( imgDst ); return true; } +bool CBgraFrame::ReColorPatternImage(const std::wstring& strFileName, unsigned int rgbColorBack, unsigned int rgbColorFore) +{ + if (OpenFile(strFileName)) + { + int smpl = abs(get_Stride() / get_Width()); + BYTE * rgb = get_Data(); + + BYTE R1 = (BYTE)(rgbColorBack); + BYTE G1 = (BYTE)(rgbColorBack >> 8); + BYTE B1 = (BYTE)(rgbColorBack >> 16); + + BYTE R2 = (BYTE)(rgbColorFore); + BYTE G2 = (BYTE)(rgbColorFore >> 8); + BYTE B2 = (BYTE)(rgbColorFore >> 16); + + for (int i = 0 ; i < get_Width() * get_Height(); i++) + { + if (rgb[i * smpl + 0 ] == 0x00 && rgb[i * smpl + 1 ] == 0x00 && rgb[i * smpl + 2 ] == 0x00) + { + rgb[i * smpl + 0 ] = R1; + rgb[i * smpl + 1 ] = G1; + rgb[i * smpl + 2 ] = B1; + } + else + { + rgb[i * smpl + 0 ] = R2; + rgb[i * smpl + 1 ] = G2; + rgb[i * smpl + 2 ] = B2; + } + } + if (m_nFileType == 0) m_nFileType = 1; + + SaveFile(strFileName, m_nFileType); + return true; + } + return false; +} void CBgraFrame::CxImageToMediaFrame( CxImage& img ) { if( !img.IsValid() ) diff --git a/DesktopEditor/raster/BgraFrame.h b/DesktopEditor/raster/BgraFrame.h index c29596ff48..245df10544 100644 --- a/DesktopEditor/raster/BgraFrame.h +++ b/DesktopEditor/raster/BgraFrame.h @@ -39,6 +39,8 @@ class CxImage; class CBgraFrame { private: + int m_nFileType; + int m_lWidth; int m_lHeight; int m_lStride; @@ -67,6 +69,7 @@ private: } inline void Clear() { + m_nFileType = 0; m_lWidth = 0; m_lHeight = 0; m_lStride = 0; @@ -120,7 +123,10 @@ public: public: bool OpenFile(const std::wstring& strFileName, unsigned int nFileType = 0); //0 - detect bool SaveFile(const std::wstring& strFileName, unsigned int nFileType); - bool Resize(const long& nNewWidth, const long& nNewHeight, bool bDestroyData = true); + + bool Resize(const long& nNewWidth, const long& nNewHeight, bool bDestroyData = true); + + bool ReColorPatternImage(const std::wstring& strFileName, unsigned int rgbColorBack, unsigned int rgbColorFore); private: void CxImageToMediaFrame( CxImage& img );