From b942e79de802ef503efd6d18f256b60cc7558826 Mon Sep 17 00:00:00 2001 From: "Elen.Subbotina" Date: Mon, 16 Dec 2013 13:21:04 +0000 Subject: [PATCH] =?UTF-8?q?(1.0.0.149):=20ASCOfficeOdfFile=20ods=20&=20odp?= =?UTF-8?q?=20-=20=D0=BF=D0=B0=D1=82=D1=82=D0=B5=D1=80=D0=BD=D1=8B=D0=B9?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=BB=D0=B8=D0=B2=D0=BA=D0=B8=20=D1=81=D0=B2?= =?UTF-8?q?=D0=BE=D0=B9=D1=81=D1=82=D0=B2=D0=BE=20=D0=BD=D0=B0=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D0=B5=20(xmlOptions)=20-?= =?UTF-8?q?=20presentationOnly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@53157 954022d7-b5bf-4e40-9824-e11837661b57 --- .../ASCOfficeOdfFile/ConvertOO2OOX.cpp | 5 +- .../ASCOfficeOdfFile/ConvertOO2OOX.h | 2 +- .../ASCOfficeOdfFile/OfficeOdfFile.cpp | 27 ++++++- .../ASCOfficeOdfFile/OfficeOdfFile.h | 2 + ASCOfficeODFFile/ASCOfficeOdfFile/version.h | 6 +- ASCOfficeODFFile/cpodf.vcproj | 8 ++ ASCOfficeODFFile/src/docx/measuredigits.cpp | 12 ++- ASCOfficeODFFile/src/docx/oox_drawing.cpp | 4 +- .../src/docx/oox_drawing_fills.cpp | 19 +++-- ASCOfficeODFFile/src/docx/oox_drawing_fills.h | 6 ++ ASCOfficeODFFile/src/docx/pptx_drawing.cpp | 31 ++----- .../src/docx/pptx_slide_context.cpp | 1 + .../src/docx/pptx_text_context.cpp | 81 +++++++++---------- ASCOfficeODFFile/src/docx/xlsx_drawing.cpp | 13 +-- .../src/docx/xlsx_drawing_context.cpp | 1 + ASCOfficeODFFile/src/odf/draw_common.cpp | 55 ++++++++++++- ASCOfficeODFFile/src/odf/hatchstyle.cpp | 28 +++++++ ASCOfficeODFFile/src/odf/hatchstyle.h | 43 ++++++++++ .../src/odf/odf_document_impl.cpp | 16 ++-- .../src/odf/style_graphic_properties.cpp | 3 + ASCOfficeODFFile/src/odf/styles.cpp | 18 +++++ ASCOfficeODFFile/src/odf/styles.h | 30 +++++++ 22 files changed, 312 insertions(+), 99 deletions(-) create mode 100644 ASCOfficeODFFile/src/odf/hatchstyle.cpp create mode 100644 ASCOfficeODFFile/src/odf/hatchstyle.h diff --git a/ASCOfficeODFFile/ASCOfficeOdfFile/ConvertOO2OOX.cpp b/ASCOfficeODFFile/ASCOfficeOdfFile/ConvertOO2OOX.cpp index f216b95a53..64267aef5c 100644 --- a/ASCOfficeODFFile/ASCOfficeOdfFile/ConvertOO2OOX.cpp +++ b/ASCOfficeODFFile/ASCOfficeOdfFile/ConvertOO2OOX.cpp @@ -39,7 +39,7 @@ HRESULT ConvertOdp2Pptx(cpdoccore::odf::odf_document & inputDoc, const std::wstr return S_OK; } -HRESULT ConvertOO2OOX(const std::wstring &ext, const std::wstring & srcPath, const std::wstring & dstPath) +HRESULT ConvertOO2OOX(const std::wstring &ext, const std::wstring & srcPath, const std::wstring & dstPath, bool bOnlyPresentation) { HRESULT hr = S_OK; @@ -56,6 +56,9 @@ HRESULT ConvertOO2OOX(const std::wstring &ext, const std::wstring & srcPath, con if (ext == L".odp")type = 3; } + + if (bOnlyPresentation && type != 3)return E_FAIL; + switch (type) { case 1: diff --git a/ASCOfficeODFFile/ASCOfficeOdfFile/ConvertOO2OOX.h b/ASCOfficeODFFile/ASCOfficeOdfFile/ConvertOO2OOX.h index 44ae90067d..7ad0696c24 100644 --- a/ASCOfficeODFFile/ASCOfficeOdfFile/ConvertOO2OOX.h +++ b/ASCOfficeODFFile/ASCOfficeOdfFile/ConvertOO2OOX.h @@ -1,4 +1,4 @@ #include #include -HRESULT ConvertOO2OOX(const std::wstring &ext, const std::wstring & srcPath, const std::wstring & dstPath); \ No newline at end of file +HRESULT ConvertOO2OOX(const std::wstring &ext, const std::wstring & srcPath, const std::wstring & dstPath, bool bOnlyPresentation); \ No newline at end of file diff --git a/ASCOfficeODFFile/ASCOfficeOdfFile/OfficeOdfFile.cpp b/ASCOfficeODFFile/ASCOfficeOdfFile/OfficeOdfFile.cpp index 9e31d09972..28849a7ccb 100644 --- a/ASCOfficeODFFile/ASCOfficeOdfFile/OfficeOdfFile.cpp +++ b/ASCOfficeODFFile/ASCOfficeOdfFile/OfficeOdfFile.cpp @@ -19,6 +19,8 @@ #include "ConvertOO2OOX.h" +#include "..\..\..\..\Common\XmlUtils.h" + #pragma comment(lib, "cpformulasconvert-static.lib") #pragma comment(lib, "cpxml-static.lib") @@ -40,6 +42,7 @@ COfficeOdfFile::COfficeOdfFile() { + bOnlyPresentation = false; office_utils_.CoCreateInstance(__uuidof(ASCOfficeUtils::COfficeUtils)); } @@ -66,6 +69,26 @@ boost::filesystem::wpath MakeTempDirectoryName(BSTR Dst) } +bool COfficeOdfFile::loadOptionFromXML(CString parametr,BSTR sXMLOptions) +{ + bool result = false; + XmlUtils::CXmlReader oXmlReader; + if( TRUE == oXmlReader.OpenFromXmlString( sXMLOptions ) ) + { + if( TRUE == oXmlReader.ReadRootNode( _T("Options") ) ) + { + if( TRUE == oXmlReader.ReadNode( parametr ) ) + { + result = true; + } + } + } + + return result; + +} + + HRESULT COfficeOdfFile::LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXMLOptions) { HRESULT hr; @@ -98,6 +121,8 @@ HRESULT COfficeOdfFile::LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXML boost::filesystem::wpath dstTempPath = outputDir.string(); #endif + bOnlyPresentation = loadOptionFromXML(L"onlyPresentation", sXMLOptions); + try { boost::filesystem::create_directory(srcTempPath); @@ -161,7 +186,7 @@ HRESULT COfficeOdfFile::LoadFromFileImpl(const std::wstring & srcFileName, return hr; - hr = ConvertOO2OOX(ext,srcTempPath, dstTempPath); + hr = ConvertOO2OOX(ext,srcTempPath, dstTempPath,bOnlyPresentation); if FAILED(hr) diff --git a/ASCOfficeODFFile/ASCOfficeOdfFile/OfficeOdfFile.h b/ASCOfficeODFFile/ASCOfficeOdfFile/OfficeOdfFile.h index f9ea1839f6..b79b01e75e 100644 --- a/ASCOfficeODFFile/ASCOfficeOdfFile/OfficeOdfFile.h +++ b/ASCOfficeODFFile/ASCOfficeOdfFile/OfficeOdfFile.h @@ -92,6 +92,8 @@ private: ATL::CComPtr< ASCOfficeUtils::IOfficeUtils > office_utils_; private: + bool bOnlyPresentation; + bool loadOptionFromXML(CString parametr,BSTR sXMLOptions); bool initialized(); HRESULT LoadFromFileImpl(const std::wstring & srcFileName, const std::wstring & srcTempPath, diff --git a/ASCOfficeODFFile/ASCOfficeOdfFile/version.h b/ASCOfficeODFFile/ASCOfficeOdfFile/version.h index e875fb53c5..55372cc97f 100644 --- a/ASCOfficeODFFile/ASCOfficeOdfFile/version.h +++ b/ASCOfficeODFFile/ASCOfficeOdfFile/version.h @@ -2,6 +2,6 @@ //1 //0 //0 -//145 -#define INTVER 1,0,0,145 -#define STRVER "1,0,0,145\0" +//149 +#define INTVER 1,0,0,149 +#define STRVER "1,0,0,149\0" diff --git a/ASCOfficeODFFile/cpodf.vcproj b/ASCOfficeODFFile/cpodf.vcproj index a673eff733..f3f95a7544 100644 --- a/ASCOfficeODFFile/cpodf.vcproj +++ b/ASCOfficeODFFile/cpodf.vcproj @@ -585,6 +585,14 @@ RelativePath=".\src\odf\gradientstyle.h" > + + + + diff --git a/ASCOfficeODFFile/src/docx/measuredigits.cpp b/ASCOfficeODFFile/src/docx/measuredigits.cpp index bec201cbca..abdf1b3f89 100644 --- a/ASCOfficeODFFile/src/docx/measuredigits.cpp +++ b/ASCOfficeODFFile/src/docx/measuredigits.cpp @@ -49,11 +49,17 @@ std::pair GetMaxDigitSizePixelsImpl(const wchar_t * fontName, float for (int i = 0; i <= 9; ++i) { if (S_OK != (hr = fontMan->LoadString2( boost::lexical_cast(i).c_str(), 0, 0))) - throw MeasureError(); + return std::pair(7,8); float x, y, width, height; - if (S_OK != (hr = fontMan->MeasureString(&x, &y, &width, &height))) - throw MeasureError(); + try + { + hr = fontMan->MeasureString(&x, &y, &width, &height); + }catch(...) + { + return std::pair(7,8); + } + if (width> maxWidth) maxWidth = width; diff --git a/ASCOfficeODFFile/src/docx/oox_drawing.cpp b/ASCOfficeODFFile/src/docx/oox_drawing.cpp index 43cb08cd61..caa0340d75 100644 --- a/ASCOfficeODFFile/src/docx/oox_drawing.cpp +++ b/ASCOfficeODFFile/src/docx/oox_drawing.cpp @@ -181,8 +181,6 @@ void oox_serialize_bodyPr(std::wostream & strm, const std::vectorpreset); + if (val.hatch->color_back_ref) + { + CP_XML_NODE(L"a:bgClr") + { + oox_serialize_srgb(CP_XML_STREAM(),*val.hatch->color_back_ref,val.opacity); + } + } + CP_XML_NODE(L"a:fgClr") + { + oox_serialize_srgb(CP_XML_STREAM(),val.hatch->color_ref,val.opacity); + } } - } } void oox_serialize_fill(std::wostream & strm, const _oox_fill & val) diff --git a/ASCOfficeODFFile/src/docx/oox_drawing_fills.h b/ASCOfficeODFFile/src/docx/oox_drawing_fills.h index ba8f127e87..1f0f588869 100644 --- a/ASCOfficeODFFile/src/docx/oox_drawing_fills.h +++ b/ASCOfficeODFFile/src/docx/oox_drawing_fills.h @@ -52,6 +52,11 @@ namespace oox { public: oox_hatch_fill(){} static oox_hatch_fill_ptr create(); + + std::wstring color_ref; + _CP_OPT(std::wstring) color_back_ref; + + std::wstring preset; }; //////////////////////////////////////////////////////////// class oox_gradient_fill; @@ -76,6 +81,7 @@ namespace oox { double rect[4]; double angle; + std::vector<_color_position> colors; }; ////////////////////////////////////////////////////////////////////////////// diff --git a/ASCOfficeODFFile/src/docx/pptx_drawing.cpp b/ASCOfficeODFFile/src/docx/pptx_drawing.cpp index 8d8d2d3905..243b3d8e65 100644 --- a/ASCOfficeODFFile/src/docx/pptx_drawing.cpp +++ b/ASCOfficeODFFile/src/docx/pptx_drawing.cpp @@ -26,18 +26,22 @@ void pptx_serialize_text(std::wostream & strm, const std::vector _CP_OPT(std::wstring) strTextContent; odf::GetProperty(properties,L"text-content",strTextContent); - if (!strTextContent)return; - CP_XML_WRITER(strm) { CP_XML_NODE(L"p:txBody") { oox_serialize_bodyPr(CP_XML_STREAM(),properties); - if (strTextContent) { CP_XML_STREAM() << strTextContent.get(); } + else + { + CP_XML_NODE(L"a:p")//empty a:p + { + CP_XML_NODE(L"a:endParaRPr"); + } + } } } } @@ -87,27 +91,6 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing const & val) void pptx_serialize_shape(std::wostream & strm, _pptx_drawing const & val) { - //std::wstring shapeType; - // - //if (val.sub_type<9 && val.sub_type>=0) - //{ - // shapeType = _ooxShapeType[val.sub_type]; - //} - //if (val.sub_type == 7)//custom - //{ - // _CP_OPT(int) iVal; - // odf::GetProperty(val.additional,L"draw-type-index",iVal); - // if (iVal)shapeType = _OO_OOX_custom_shapes[*iVal].oox; - //} - //else if (val.sub_type<9 && val.sub_type>=0) - //{ - // shapeType = _ooxShapeType[val.sub_type]; - //} - - //if ((val.place_holder_type_.length()>0) && - // !(val.place_holder_type_== L"body" || val.place_holder_type_== L"title" || val.place_holder_type_== L"subTitle"))return; - - CP_XML_WRITER(strm) { CP_XML_NODE(L"p:sp") diff --git a/ASCOfficeODFFile/src/docx/pptx_slide_context.cpp b/ASCOfficeODFFile/src/docx/pptx_slide_context.cpp index 97da41b7fc..3a72fe854a 100644 --- a/ASCOfficeODFFile/src/docx/pptx_slide_context.cpp +++ b/ASCOfficeODFFile/src/docx/pptx_slide_context.cpp @@ -269,6 +269,7 @@ void pptx_slide_context::process_images() std::wstring fileName = BOOST_STRING_PATH(wpath(impl_->odfPacket_) / pic.xlink_href_); drawing.fill.bitmap->bCrop = odf::parse_clipping(pic.clipping_string_,fileName,drawing.fill.bitmap->cropRect); + drawing.fill.bitmap->bStretch = true; /////////////////////////////////////////////////////////////////////////////////////////////////// std::wstring ref;/// это ссылка на выходной внешний объект diff --git a/ASCOfficeODFFile/src/docx/pptx_text_context.cpp b/ASCOfficeODFFile/src/docx/pptx_text_context.cpp index d42fd22551..788be2a1c7 100644 --- a/ASCOfficeODFFile/src/docx/pptx_text_context.cpp +++ b/ASCOfficeODFFile/src/docx/pptx_text_context.cpp @@ -231,45 +231,45 @@ void pptx_text_context::Impl::ApplyParagraphProperties(std::wstring style,odf::p void pptx_text_context::Impl::write_pPr(std::wostream & strm) { get_styles_context().start(); - //CP_XML_WRITER(strm) - //{ - // CP_XML_NODE(L"a:pPr") - // { + + int level = list_style_stack_.size()-1; + + odf::paragraph_format_properties paragraph_format_properties_; + ApplyParagraphProperties (styles_paragraph_, paragraph_format_properties_,odf::style_family::Paragraph); + + paragraph_format_properties_.pptx_convert(pptx_context_); + + const std::wstring & paragraphAttr = get_styles_context().paragraph_attr().str(); + const std::wstring & paragraphNodes = get_styles_context().paragraph_nodes().str(); + + if (level < 0 && paragraphAttr.length() <1 && paragraphNodes.length()<1) return; + strm << L"=0) - strm << L"lvl=\"" << level << L"\" "; + if (level>=0) + strm << L"lvl=\"" << level << L"\" "; - odf::paragraph_format_properties paragraph_format_properties_; - ApplyParagraphProperties (styles_paragraph_, paragraph_format_properties_,odf::style_family::Paragraph); - - paragraph_format_properties_.pptx_convert(pptx_context_); - - strm << get_styles_context().paragraph_attr().str(); + strm << paragraphAttr; strm << ">"; - strm << get_styles_context().paragraph_nodes().str(); + strm << paragraphNodes; - odf::list_style_container & list_styles = odf_context_.listStyleContainer(); + odf::list_style_container & list_styles = odf_context_.listStyleContainer(); - if (!list_styles.empty() && level>=0) - { - odf::text_list_style * s = list_styles.list_style_by_name(list_style_stack_.back()); - if (s) - { - odf::office_element_ptr elm = s->get_content()[level]; - if (elm) - { - elm->pptx_convert(pptx_context_); - } - strm << get_styles_context().list_style().str(); + if (!list_styles.empty() && level>=0) + { + odf::text_list_style * s = list_styles.list_style_by_name(list_style_stack_.back()); + if (s) + { + odf::office_element_ptr elm = s->get_content()[level]; + if (elm) + { + elm->pptx_convert(pptx_context_); } + strm << get_styles_context().list_style().str(); } + } strm << L""; - - // } - //} } void pptx_text_context::Impl::write_rPr(std::wostream & strm) @@ -311,7 +311,8 @@ std::wstring pptx_text_context::Impl::dump_paragraph() CP_XML_STREAM() << run_.str(); - //CP_XML_NODE(L"a:endParaRPr") //- сохранение/не сохранение стиля на последующие параграфы + CP_XML_NODE(L"a:endParaRPr"); + //- сохранение/не сохранение стиля на последующие параграфы //{ // CP_XML_ATTR(L"dirty", 0); //} @@ -338,7 +339,7 @@ void pptx_text_context::Impl::dump_run() CP_XML_NODE(L"a:t") { - //CP_XML_ATTR(L"xml:space", L"preserve"); временно уберу ... + CP_XML_ATTR(L"xml:space", L"preserve"); CP_XML_STREAM() << content; } } @@ -458,20 +459,16 @@ void pptx_text_context::Impl::write_list_properties(std::wostream & strm) { if (!list_style_stack_.empty()) { - //if (first_element_list_item_) - { - const int id = odf_context_.listStyleContainer().id_by_name( current_list_style() ); - //const int id = list_context_.id_by_name( current_list_style() ); - CP_XML_WRITER(strm) + const int id = odf_context_.listStyleContainer().id_by_name( current_list_style() ); + CP_XML_WRITER(strm) + { + CP_XML_NODE(L"a:buAutoNum") { - CP_XML_NODE(L"a:buAutoNum") - { - CP_XML_ATTR(L"type",L"arabicPeriod"); - CP_XML_ATTR(L"startAt",id);// - } - first_element_list_item_ = false; + CP_XML_ATTR(L"type",L"arabicPeriod"); + CP_XML_ATTR(L"startAt",id);// } } + first_element_list_item_ = false; } } void pptx_text_context::Impl::write_list_styles(std::wostream & strm)//defaults style paragraph & lists diff --git a/ASCOfficeODFFile/src/docx/xlsx_drawing.cpp b/ASCOfficeODFFile/src/docx/xlsx_drawing.cpp index b6f748c486..1e03635735 100644 --- a/ASCOfficeODFFile/src/docx/xlsx_drawing.cpp +++ b/ASCOfficeODFFile/src/docx/xlsx_drawing.cpp @@ -27,12 +27,13 @@ void xlsx_serialize_text(std::wostream & strm, const std::vector { _CP_OPT(std::wstring) strTextContent; odf::GetProperty(properties,L"text-content",strTextContent); - if (strTextContent) - { - CP_XML_NODE(L"xdr:txBody") - { - oox_serialize_bodyPr(CP_XML_STREAM(),properties); - CP_XML_NODE(L"a:lstStyle"); + + CP_XML_NODE(L"xdr:txBody") + { + oox_serialize_bodyPr(CP_XML_STREAM(),properties); + CP_XML_NODE(L"a:lstStyle"); + if (strTextContent) + { CP_XML_NODE(L"a:p") { CP_XML_STREAM() << strTextContent.get(); diff --git a/ASCOfficeODFFile/src/docx/xlsx_drawing_context.cpp b/ASCOfficeODFFile/src/docx/xlsx_drawing_context.cpp index 4b2c2ef226..c9d3a45955 100644 --- a/ASCOfficeODFFile/src/docx/xlsx_drawing_context.cpp +++ b/ASCOfficeODFFile/src/docx/xlsx_drawing_context.cpp @@ -321,6 +321,7 @@ void xlsx_drawing_context::process_images(xlsx_table_metrics & table_metrics) std::wstring fileName = BOOST_STRING_PATH(wpath(odf_packet_path_) / pic.xlink_href_); drawing.fill.bitmap->bCrop = odf::parse_clipping(pic.clipping_string_,fileName,drawing.fill.bitmap->cropRect); + drawing.fill.bitmap->bStretch = true; drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, drawing.type, isMediaInternal, ref); impl_->add_drawing(drawing, isMediaInternal, drawing.fill.bitmap->rId , ref, drawing.type); diff --git a/ASCOfficeODFFile/src/odf/draw_common.cpp b/ASCOfficeODFFile/src/odf/draw_common.cpp index b56184805e..dfd2ffb412 100644 --- a/ASCOfficeODFFile/src/odf/draw_common.cpp +++ b/ASCOfficeODFFile/src/odf/draw_common.cpp @@ -184,6 +184,40 @@ int Compute_BorderWidth(const graphic_format_properties & graphicProperties, Bor return get_value_emu(lengthValue); } +void Compute_HatchFill(draw_hatch * image_style,oox::oox_hatch_fill_ptr fill) +{ + int style =0; + if (image_style->draw_style_)style = image_style->draw_style_->get_type(); + + int angle = *image_style->draw_rotation_/10.; + + if (image_style->draw_color_)fill->color_ref = image_style->draw_color_->get_hex_value(); + + double size =0; + if (image_style->draw_distance_)size = (image_style->draw_distance_->get_value_unit(length::cm)); + + switch(style) + { + case hatch_style::single: + if (angle == 0 || angle == 180) fill->preset = L"dkHorz"; + else if (angle == 90 || angle == 270) fill->preset = L"dkVert"; + else if ((angle>180 && angle <270) + || (angle>0 && angle <90)) fill->preset = L"dkUpDiag"; + else fill->preset = L"dkDnDiag"; + break; + case hatch_style::doublee: + if (angle ==0 || angle == 90 || angle== 180 || angle == 270) + { + if (size > 0.2) fill->preset = L"lgGrid"; + else fill->preset = L"smGrid"; + } + else fill->preset = L"openDmnd"; + break; + case hatch_style::triple: + fill->preset = L"pkt5"; + break; + } +} void Compute_GradientFill(draw_gradient * image_style,oox::oox_gradient_fill_ptr fill) { int style =0; @@ -276,9 +310,9 @@ void Compute_GradientFill(draw_gradient * image_style,oox::oox_gradient_fill_ptr } }break; } - } + void Compute_GraphicFill(graphic_format_properties & props, styles_lite_container &styles, oox::_oox_fill & fill) { fill.type = 0; @@ -340,10 +374,27 @@ void Compute_GraphicFill(graphic_format_properties & props, styles_lite_containe fill.gradient = oox::oox_gradient_fill::create(); Compute_GradientFill(image_style, fill.gradient); - } } } + if (props.draw_fill_hatch_name_) + { + const std::wstring style_name = L"hatch:" + *props.draw_fill_hatch_name_; + if (office_element_ptr style = styles.find_by_style_name(style_name)) + { + if (draw_hatch * image_style = dynamic_cast(style.get())) + { + fill.hatch = oox::oox_hatch_fill::create(); + + Compute_HatchFill(image_style, fill.hatch); + } + } + if ((fill.hatch) && (props.draw_fill_color_)) + { + fill.hatch->color_back_ref = props.draw_fill_color_->get_hex_value(); + } + } + } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/ASCOfficeODFFile/src/odf/hatchstyle.cpp b/ASCOfficeODFFile/src/odf/hatchstyle.cpp new file mode 100644 index 0000000000..b416aa2cf3 --- /dev/null +++ b/ASCOfficeODFFile/src/odf/hatchstyle.cpp @@ -0,0 +1,28 @@ +#include "precompiled_cpodf.h" +#include "hatchstyle.h" + +#include + +namespace cpdoccore { +namespace odf { + +hatch_style hatch_style::parse(const std::wstring & Str) +{ + std::wstring tmp = Str; + boost::algorithm::to_lower(tmp); + + if (tmp == L"single") + return hatch_style( single ); + else if (tmp == L"double") + return hatch_style( doublee ); + else if (tmp == L"triple") + return hatch_style(triple ); + + else + { + BOOST_THROW_EXCEPTION( errors::invalid_attribute() ); + return hatch_style(single); + } +} +} +} diff --git a/ASCOfficeODFFile/src/odf/hatchstyle.h b/ASCOfficeODFFile/src/odf/hatchstyle.h new file mode 100644 index 0000000000..8773fb6a52 --- /dev/null +++ b/ASCOfficeODFFile/src/odf/hatchstyle.h @@ -0,0 +1,43 @@ +#pragma once + +#include +#include +#include "odfattributes.h" + + +namespace cpdoccore { +namespace odf { + +class hatch_style +{ +public: + enum type + { + single, + doublee, + triple + }; + + hatch_style() {} + + hatch_style(type _Type) : type_(_Type) + {} + + type get_type() const + { + return type_; + }; + static hatch_style parse(const std::wstring & Str); + +private: + type type_; + +}; + +std::wostream & operator << (std::wostream & _Wostream, const hatch_style & _Val); + +} + +APPLY_PARSE_XML_ATTRIBUTES(odf::hatch_style); + +} diff --git a/ASCOfficeODFFile/src/odf/odf_document_impl.cpp b/ASCOfficeODFFile/src/odf/odf_document_impl.cpp index 3d1db860d9..0fa133cddc 100644 --- a/ASCOfficeODFFile/src/odf/odf_document_impl.cpp +++ b/ASCOfficeODFFile/src/odf/odf_document_impl.cpp @@ -428,7 +428,7 @@ void odf_document::Impl::parse_styles() context_->drawStyles().add(L"bitmap:" + style->get_style_name(), elm); } - BOOST_FOREACH(const office_element_ptr & elm, docStyles->draw_styles_.draw_opacity_) + BOOST_FOREACH(const office_element_ptr & elm, docStyles->draw_styles_.draw_opacity_) { draw_opacity * style = dynamic_cast(elm.get()); @@ -437,15 +437,15 @@ void odf_document::Impl::parse_styles() context_->drawStyles().add(L"opacity:" + style->get_style_name(), elm); } - // BOOST_FOREACH(const office_element_ptr & elm, docStyles->draw_styles_.draw_hatch_) - // { - // const draw_hatch_image * style = dynamic_cast(elm.get()); + BOOST_FOREACH(const office_element_ptr & elm, docStyles->draw_styles_.draw_hatch_) + { + draw_hatch * style = dynamic_cast(elm.get()); - // if (!style) - // continue; + if (!style) + continue; - //context_->drawStyles().add(L"hatch:" + style->get_style_name(), elm); - // } + context_->drawStyles().add(L"hatch:" + style->get_style_name(), elm); + } } while(0); // end parse styles } diff --git a/ASCOfficeODFFile/src/odf/style_graphic_properties.cpp b/ASCOfficeODFFile/src/odf/style_graphic_properties.cpp index a4712b4468..92f1597b81 100644 --- a/ASCOfficeODFFile/src/odf/style_graphic_properties.cpp +++ b/ASCOfficeODFFile/src/odf/style_graphic_properties.cpp @@ -28,6 +28,8 @@ void graphic_format_properties::add_attributes( const xml::attributes_wc_ptr & A CP_APPLY_ATTR(L"draw:wrap-influence-on-position", draw_wrap_influence_on_position_); CP_APPLY_ATTR(L"draw:textarea-horizontal-align", draw_textarea_horizontal_align_); CP_APPLY_ATTR(L"draw:textarea-vertical-align", draw_textarea_vertical_align_); + + CP_APPLY_ATTR(L"draw:fill-hatch-solid", draw_fill_hatch_solid_); CP_APPLY_ATTR(L"draw:stroke", draw_stroke_); CP_APPLY_ATTR(L"draw:stroke-dash", draw_stroke_dash_); @@ -106,6 +108,7 @@ void graphic_format_properties::apply_from(const graphic_format_properties & Oth _CP_APPLY_PROP2(draw_marker_end_); _CP_APPLY_PROP2(draw_opacity_); _CP_APPLY_PROP2(draw_image_opacity_); + _CP_APPLY_PROP2(draw_fill_hatch_solid_); _CP_APPLY_PROP2(draw_textarea_horizontal_align_); _CP_APPLY_PROP2(draw_textarea_vertical_align_); diff --git a/ASCOfficeODFFile/src/odf/styles.cpp b/ASCOfficeODFFile/src/odf/styles.cpp index 7e7be8c813..168aa5ab77 100644 --- a/ASCOfficeODFFile/src/odf/styles.cpp +++ b/ASCOfficeODFFile/src/odf/styles.cpp @@ -241,6 +241,24 @@ void draw_gradient::add_child_element( xml::sax * Reader, const ::std::wstring & CP_NOT_APPLICABLE_ELM(); } ////////////////////////////////////////////////////////////////////////////////////////////////// +const wchar_t * draw_hatch::ns = L"draw"; +const wchar_t * draw_hatch::name = L"hatch"; + +void draw_hatch::add_attributes( const xml::attributes_wc_ptr & Attributes ) +{ + CP_APPLY_ATTR(L"draw:name", draw_name_); + CP_APPLY_ATTR(L"draw:display-name", draw_display_name_); + CP_APPLY_ATTR(L"draw:style", draw_style_); + CP_APPLY_ATTR(L"draw:color", draw_color_); + CP_APPLY_ATTR(L"draw:distance", draw_distance_); + CP_APPLY_ATTR(L"draw:rotation", draw_rotation_); +} + +void draw_hatch::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) +{ + CP_NOT_APPLICABLE_ELM(); +} +////////////////////////////////////////////////////////////////////////////////////////////////// const wchar_t * draw_opacity::ns = L"draw"; const wchar_t * draw_opacity::name = L"opacity"; diff --git a/ASCOfficeODFFile/src/odf/styles.h b/ASCOfficeODFFile/src/odf/styles.h index 770a530aa5..f20c0d9082 100644 --- a/ASCOfficeODFFile/src/odf/styles.h +++ b/ASCOfficeODFFile/src/odf/styles.h @@ -31,6 +31,7 @@ #include "common_attlists.h" #include "noteclass.h" #include "gradientstyle.h" +#include "hatchstyle.h" #include "styles_list.h" @@ -153,6 +154,35 @@ private: }; CP_REGISTER_OFFICE_ELEMENT2(draw_gradient); ///////////////////////////////////////////////////////////////////////////////////////////////// +/// \class style_draw_hatch +class draw_hatch : public office_element_impl +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + static const xml::NodeType xml_type = xml::typeElement; + static const ElementType type = typeStyleDrawHatch; + + CPDOCCORE_DEFINE_VISITABLE(); + + std::wstring get_style_name(){return draw_name_.get_value_or(L"");} + + _CP_OPT(hatch_style) draw_style_; + _CP_OPT(int) draw_rotation_; + _CP_OPT(length) draw_distance_; + _CP_OPT(color) draw_color_; + +private: + _CP_OPT(std::wstring) draw_name_; + _CP_OPT(std::wstring) draw_display_name_; + + virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); + virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name); + + friend class odf_document; +}; +CP_REGISTER_OFFICE_ELEMENT2(draw_hatch); +///////////////////////////////////////////////////////////////////////////////////////////////// /// \class style_draw_gradient class draw_opacity : public office_element_impl {