From 19e8fa19bb60bb4177cd41dbd4ea2fa31556789b Mon Sep 17 00:00:00 2001 From: "Elen.Subbotina" Date: Thu, 10 Apr 2014 16:00:57 +0000 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=98=D0=A1=D0=9E=D0=92=D0=90=D0=9D?= =?UTF-8?q?=D0=98=D0=95=20=D0=B2=20OOX=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=20=D0=9D=D0=95=20=D0=A0=D0=95=D0=90=D0=9B=D0=98?= =?UTF-8?q?=D0=97=D0=9E=D0=92=D0=90=D0=9D=D0=9E=20!!!!?= 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@55426 954022d7-b5bf-4e40-9824-e11837661b57 --- ASCOfficeOdfFile/cpodf.vcproj | 2 +- .../src/formulasconvert_oox.cpp | 2 - ASCOfficeOdfFile/src/docx/docx_drawing.cpp | 2 +- .../src/odf/datatypes/common_attlists.cpp | 6 + .../src/odf/datatypes/common_attlists.h | 2 + ASCOfficeOdfFileW/source/OdfFormat.vcproj | 24 + .../source/OdfFormat/draw_frame.cpp | 326 ++++++++++ .../source/OdfFormat/draw_frame.h | 228 +++++++ .../source/OdfFormat/draw_shapes.cpp | 583 ++++++++++++++++++ .../source/OdfFormat/draw_shapes.h | 396 ++++++++++++ .../source/OdfFormat/svg_creator.cpp | 25 + .../source/OdfFormat/svg_creator.h | 51 ++ ASCOfficeOdfFileW/source/OdfFormat/table.cpp | 1 - .../source/OdfFormat/text_elements.cpp | 2 - .../source/Oox2OdfConverter/XlsxConverter.cpp | 64 +- .../source/Oox2OdfConverter/XlsxConverter.h | 4 + 16 files changed, 1709 insertions(+), 9 deletions(-) create mode 100644 ASCOfficeOdfFileW/source/OdfFormat/draw_frame.cpp create mode 100644 ASCOfficeOdfFileW/source/OdfFormat/draw_frame.h create mode 100644 ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.cpp create mode 100644 ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.h create mode 100644 ASCOfficeOdfFileW/source/OdfFormat/svg_creator.cpp create mode 100644 ASCOfficeOdfFileW/source/OdfFormat/svg_creator.h diff --git a/ASCOfficeOdfFile/cpodf.vcproj b/ASCOfficeOdfFile/cpodf.vcproj index 29f1abe8d1..904381c3d6 100644 --- a/ASCOfficeOdfFile/cpodf.vcproj +++ b/ASCOfficeOdfFile/cpodf.vcproj @@ -1760,7 +1760,7 @@ > -#include "../odf/custom_shape_types_convert.h" +#include "custom_shape_types_convert.h" namespace cpdoccore { diff --git a/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.cpp b/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.cpp index 29916fc7ab..3600de6177 100644 --- a/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.cpp +++ b/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.cpp @@ -895,6 +895,12 @@ void common_anim_smil_attlist::apply_from(const common_anim_smil_attlist & Other //_CP_APPLY_PROP(smil_type_, Other.smil_type_); // _CP_APPLY_PROP(smil_dur_, Other.smil_dur_); } +void union_common_draw_attlists::serialize(CP_ATTR_NODE) +{ + shape_with_text_and_styles_.serialize(CP_GET_XML_NODE()); + position_.serialize(CP_GET_XML_NODE()); + rel_size_.serialize(CP_GET_XML_NODE()); +} } } diff --git a/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.h b/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.h index 686bbd43c9..f80f08d713 100644 --- a/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.h +++ b/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.h @@ -670,6 +670,8 @@ struct union_common_draw_attlists common_draw_shape_with_text_and_styles_attlist shape_with_text_and_styles_; common_draw_position_attlist position_; common_draw_rel_size_attlist rel_size_; + + void serialize(CP_ATTR_NODE); }; diff --git a/ASCOfficeOdfFileW/source/OdfFormat.vcproj b/ASCOfficeOdfFileW/source/OdfFormat.vcproj index baaf024f1a..c95a752984 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat.vcproj +++ b/ASCOfficeOdfFileW/source/OdfFormat.vcproj @@ -886,6 +886,22 @@ + + + + + + + + @@ -982,6 +998,14 @@ + + + + diff --git a/ASCOfficeOdfFileW/source/OdfFormat/draw_frame.cpp b/ASCOfficeOdfFileW/source/OdfFormat/draw_frame.cpp new file mode 100644 index 0000000000..be5efadd52 --- /dev/null +++ b/ASCOfficeOdfFileW/source/OdfFormat/draw_frame.cpp @@ -0,0 +1,326 @@ +#include "precompiled_cpodf.h" +#include "draw_frame.h" + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "style_graphic_properties.h" +#include "length.h" +#include "borderstyle.h" + +#include "odf_conversion_context.h" + +namespace cpdoccore { +namespace odf { + +using xml::xml_char_wc; + +void draw_image_attlist::serialize(CP_ATTR_NODE) +{ + CP_XML_ATTR_OPT(L"draw:filter-name", draw_filter_name_); +} + +void draw_frame_attlist::serialize(CP_ATTR_NODE) +{ + CP_XML_ATTR_OPT(L"draw:copy-of", draw_copy_of_); +} + +void draw_chart_attlist::serialize(CP_ATTR_NODE) +{ + //CP_XML_ATTR_OPT(L"draw:filter-name", draw_filter_name_); +} + +// draw:image +////////////////////////////////////////////////////////////////////////////////////////////////// +const wchar_t * draw_image::ns = L"draw"; +const wchar_t * draw_image::name = L"image"; + +void draw_image::serialize(std::wostream & _Wostream) +{ + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_image_attlist_.serialize(CP_GET_XML_NODE()); + common_xlink_attlist_.serialize(CP_GET_XML_NODE()); + + if (office_binary_data_)office_binary_data_->serialize(CP_XML_STREAM()); + + BOOST_FOREACH(const office_element_ptr & elm, content_) + { + elm->serialize(CP_XML_STREAM()); + } + } + } +} + +void draw_image::create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name) +{ + if CP_CHECK_NAME(L"office", L"binary-data") + { + CP_CREATE_ELEMENT(office_binary_data_); + } + else + { + CP_CREATE_ELEMENT(content_); + //CP_NOT_APPLICABLE_ELM(); + } +} +void draw_image::add_child_element(office_element_ptr & child_element) +{ + ElementType type = child_element->get_type(); + + if (type == typeOfficeBinaryData) + { + office_binary_data_ = child_element; + } + else + content_.push_back(child_element); +} +// draw:chart +//////////////////////////////////////////////////////////////////////////////////////////////////// +const wchar_t * draw_chart::ns = L"draw"; +const wchar_t * draw_chart::name = L"chart"; + + +void draw_chart::serialize(std::wostream & _Wostream) +{ + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_chart_attlist_.serialize(CP_GET_XML_NODE()); + common_xlink_attlist_.serialize(CP_GET_XML_NODE()); + + BOOST_FOREACH(const office_element_ptr & elm, content_) + { + elm->serialize(CP_XML_STREAM()); + } + } + } +} + + +void draw_chart::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name) +{ + CP_CREATE_ELEMENT(content_); +} + +void draw_chart::add_child_element(office_element_ptr & child_element) +{ + content_.push_back(child_element); +} + +// draw:g +////////////////////////////////////////////////////////////////////////////////////////////////// +const wchar_t * draw_g::ns = L"draw"; +const wchar_t * draw_g::name = L"g"; + +void draw_g::serialize(std::wostream & _Wostream) +{ + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + common_draw_attlists_.serialize(CP_GET_XML_NODE()); + + BOOST_FOREACH(const office_element_ptr & elm, content_) + { + elm->serialize(CP_XML_STREAM()); + } + } + } +} +void draw_g::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name) +{ + CP_CREATE_ELEMENT(content_); +} +void draw_g::add_child_element(office_element_ptr & child_element) +{ + content_.push_back(child_element); +} +// draw:frame +////////////////////////////////////////////////////////////////////////////////////////////////// +const wchar_t * draw_frame::ns = L"draw"; +const wchar_t * draw_frame::name = L"frame"; + +void draw_frame::serialize(std::wostream & _Wostream) +{ + // idx_in_owner = -1; + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_frame_attlist_.serialize(CP_GET_XML_NODE()); + common_draw_attlists_.serialize(CP_GET_XML_NODE()); + common_presentation_attlist_.serialize(CP_GET_XML_NODE()); + + if (office_event_listeners_)office_event_listeners_->serialize(CP_XML_STREAM()); + + BOOST_FOREACH(const office_element_ptr & elm, content_) + { + elm->serialize(CP_XML_STREAM()); + } + } + } +} + +void draw_frame::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name) +{ + if (CP_CHECK_NAME(L"draw", L"text-box") || + CP_CHECK_NAME(L"draw", L"image") ||//копия чарта в виде картинки ну.. или просто картинка + CP_CHECK_NAME(L"draw", L"object") ||//месторасположение чарта + CP_CHECK_NAME(L"draw", L"object-ole") || + CP_CHECK_NAME(L"draw", L"applet") || + CP_CHECK_NAME(L"draw", L"floating-frame") || + CP_CHECK_NAME(L"draw", L"plugin") || + CP_CHECK_NAME(L"table", L"table") + ) + { + CP_CREATE_ELEMENT(content_); + } + else if CP_CHECK_NAME(L"office", L"event-listeners") + { + CP_CREATE_ELEMENT(office_event_listeners_); + } + else if CP_CHECK_NAME(L"draw", L"glue-point") + { + CP_CREATE_ELEMENT(draw_glue_point_); + } + else if CP_CHECK_NAME(L"draw", L"image-map") + { + CP_CREATE_ELEMENT(draw_image_map_); + } + else if ( CP_CHECK_NAME(L"draw", L"contour-polygon") || + CP_CHECK_NAME(L"draw", L"contour-path") ) + { + CP_CREATE_ELEMENT(draw_contour_); + } + else + { + CP_NOT_APPLICABLE_ELM(); + } +} +void draw_frame::add_child_element(office_element_ptr & child_element) +{ + ElementType type = child_element->get_type(); + + if (type == typeDrawImage || type == typeDrawTextBox || type == typeDrawObject || type == typeDrawObjectOle || type == typeTableTable) + { + content_.push_back(child_element); + } + else if (type == typeOfficeEventListeners) + { + office_event_listeners_ = child_element; + } + else + { + //CP_NOT_APPLICABLE_ELM(); + } + +} + +/////////////////////// + +void draw_text_box_attlist::serialize(CP_ATTR_NODE) +{ + CP_XML_ATTR_OPT(L"draw:chain-next-name", draw_chain_next_name_); + CP_XML_ATTR_OPT(L"draw:corner-radius", draw_corner_radius_); + CP_XML_ATTR_OPT(L"fo:min-width", fo_min_width_); + CP_XML_ATTR_OPT(L"fo:min-height", fo_min_height_); + CP_XML_ATTR_OPT(L"fo:max-width", fo_max_width_); + CP_XML_ATTR_OPT(L"fo:max-height", fo_max_height_); +} + +// draw:text-box +////////////////////////////////////////////////////////////////////////////////////////////////// +const wchar_t * draw_text_box::ns = L"draw"; +const wchar_t * draw_text_box::name = L"text-box"; + + +void draw_text_box::serialize(std::wostream & _Wostream) +{ + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_text_box_attlist_.serialize(CP_GET_XML_NODE()); + + BOOST_FOREACH(const office_element_ptr & elm, content_) + { + elm->serialize(CP_XML_STREAM()); + } + } + } +} + +void draw_text_box::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name) +{ + CP_CREATE_ELEMENT(content_); +} +void draw_text_box::add_child_element( office_element_ptr & child_element) +{ + content_.push_back(child_element); +} + +// draw:object +////////////////////////////////////////////////////////////////////////////////////////////////// +const wchar_t * draw_object::ns = L"draw"; +const wchar_t * draw_object::name = L"object"; + +void draw_object::serialize(std::wostream & _Wostream) +{ + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + //draw_object_attlist_.serialize(CP_GET_XML_NODE()); + common_xlink_attlist_.serialize(CP_GET_XML_NODE()); + } + } +} + +void draw_object::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name) +{ + CP_NOT_APPLICABLE_ELM(); // TODO +} +void draw_object::add_child_element(office_element_ptr & child_element) +{ + //CP_NOT_APPLICABLE_ELM(); +} +// draw:object +////////////////////////////////////////////////////////////////////////////////////////////////// +const wchar_t * draw_object_ole::ns = L"draw"; +const wchar_t * draw_object_ole::name = L"object-ole"; + +void draw_object_ole::serialize(std::wostream & _Wostream) +{ + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + CP_XML_ATTR_OPT(L"draw:class-id", draw_class_id_); + common_xlink_attlist_.serialize(CP_GET_XML_NODE()); + } + } +} + +void draw_object_ole::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name) +{ + CP_NOT_APPLICABLE_ELM(); +} +void draw_object_ole::add_child_element(office_element_ptr & child_element) +{ + //CP_NOT_APPLICABLE_ELM(); +} +} +} diff --git a/ASCOfficeOdfFileW/source/OdfFormat/draw_frame.h b/ASCOfficeOdfFileW/source/OdfFormat/draw_frame.h new file mode 100644 index 0000000000..b1cad3970f --- /dev/null +++ b/ASCOfficeOdfFileW/source/OdfFormat/draw_frame.h @@ -0,0 +1,228 @@ +#pragma once + +#include +#include +#include +#include +#include "office_elements.h" +#include "office_elements_create.h" +#include "common_attlists.h" +//#include "../docx/xlsxconversioncontext.h" + +namespace cpdoccore { +namespace odf { + +/// draw-image-attlist +class draw_image_attlist +{ +public: + _CP_OPT(std::wstring) draw_filter_name_; + + void serialize(CP_ATTR_NODE); +}; + //draw-frame-attlist +class draw_frame_attlist +{ +public: + _CP_OPT(std::wstring) draw_copy_of_; + + void serialize(CP_ATTR_NODE); +}; + //draw-chart-attlist +class draw_chart_attlist +{ +public: + + //_CP_OPT(std::wstring) draw_filter_name_; + void serialize(CP_ATTR_NODE); + +}; +///////////////////////////////////////////////////////////////////////////////////////// +class draw_image : 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 = typeDrawImage; + CPDOCCORE_DEFINE_VISITABLE(); + + virtual void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name); + virtual void add_child_element( office_element_ptr & child_element); + + virtual void serialize(std::wostream & _Wostream); + + draw_image_attlist draw_image_attlist_; + common_xlink_attlist common_xlink_attlist_; + + office_element_ptr office_binary_data_; + office_element_ptr_array content_; + +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_image); +////////////////////////////////////////////////////////////////////////////////////////////////////////// + + //объект рисования не нужен .. нужно только место для фрэйма - сам чарт в другом месте +class draw_chart : 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 = typeDrawChart; + CPDOCCORE_DEFINE_VISITABLE(); + + virtual void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name); + virtual void add_child_element( office_element_ptr & child_element); + + virtual void serialize(std::wostream & _Wostream); + + draw_chart_attlist draw_chart_attlist_; + common_xlink_attlist common_xlink_attlist_; + + //office_element_ptr title_; + office_element_ptr_array content_; + +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_chart); +/////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +class draw_frame : 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 = typeDrawFrame; + CPDOCCORE_DEFINE_VISITABLE(); + + virtual void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name); + virtual void add_child_element( office_element_ptr & child_element); + + virtual void serialize(std::wostream & _Wostream); + + int idx_in_owner ; + common_presentation_attlist common_presentation_attlist_; + union_common_draw_attlists common_draw_attlists_; + + + presentation_shape_attlist presentation_shape_attlist_; + draw_frame_attlist draw_frame_attlist_; + + // draw-text-box, draw-image, draw-object, draw-object-ole, draw-applet, draw-floating-frame, draw-plugin + office_element_ptr_array content_; + + office_element_ptr office_event_listeners_; // в content перенести нельзя - иначе событи будет добавляться не к этому объекту а следующему + office_element_ptr draw_glue_point_; + office_element_ptr draw_image_map_; + //office_element_ptr draw_chart_map_; + + office_element_ptr draw_contour_; // draw-contour-polygon or draw-contour-path + + friend class draw_image; + friend class draw_chart; +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_frame); +//////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class draw_g : 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 = typeDrawG; + CPDOCCORE_DEFINE_VISITABLE(); + + virtual void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name); + virtual void add_child_element( office_element_ptr & child_element); + + virtual void serialize(std::wostream & _Wostream); + + union_common_draw_attlists common_draw_attlists_; + + office_element_ptr_array content_; +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_g); +// draw-text-box-attlist +class draw_text_box_attlist +{ +public: + _CP_OPT(std::wstring) draw_chain_next_name_; + _CP_OPT(length) draw_corner_radius_; + _CP_OPT(length_or_percent) fo_min_width_; + _CP_OPT(length_or_percent) fo_min_height_; + _CP_OPT(length_or_percent) fo_max_width_; + _CP_OPT(length_or_percent) fo_max_height_; + + void serialize(CP_ATTR_NODE); +}; + + +class draw_text_box : 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 = typeDrawTextBox; + CPDOCCORE_DEFINE_VISITABLE(); + + virtual void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name); + virtual void add_child_element( office_element_ptr & child_element); + + virtual void serialize(std::wostream & _Wostream); + + draw_text_box_attlist draw_text_box_attlist_; + office_element_ptr_array content_; +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_text_box); +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// draw:object +class draw_object : 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 = typeDrawObject; + CPDOCCORE_DEFINE_VISITABLE(); + + virtual void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name); + virtual void add_child_element( office_element_ptr & child_element); + + virtual void serialize(std::wostream & _Wostream); + + common_xlink_attlist common_xlink_attlist_; +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_object); + +// draw:object-ole +class draw_object_ole : 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 = typeDrawObjectOle; + CPDOCCORE_DEFINE_VISITABLE(); + + virtual void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name); + virtual void add_child_element( office_element_ptr & child_element); + + virtual void serialize(std::wostream & _Wostream); + + common_xlink_attlist common_xlink_attlist_; + _CP_OPT(std::wstring) draw_class_id_; +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_object_ole); + +} +} diff --git a/ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.cpp b/ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.cpp new file mode 100644 index 0000000000..983d73aaaf --- /dev/null +++ b/ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.cpp @@ -0,0 +1,583 @@ +#include "precompiled_cpodf.h" +#include "draw_shapes.h" +#include "custom_shape_types_convert.h" + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "style_graphic_properties.h" +#include "length.h" +#include "borderstyle.h" + +#include "odf_conversion_context.h" + +#include "svg_creator.h" + +namespace cpdoccore { +namespace odf { + +using xml::xml_char_wc; + + +const wchar_t * draw_shape::ns = L"draw"; +const wchar_t * draw_shape::name = L"shape"; +///////////////////////////////////////////////////////////////////////////////////////////////////////// + +void draw_shape::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name) +{ + CP_CREATE_ELEMENT(content_); +} + +void draw_shape::add_child_element( office_element_ptr & child_element) +{ + content_.push_back(child_element); +} +void draw_shape::serialize(std::wostream & _Wostream) +{ + BOOST_FOREACH(const office_element_ptr & elm, content_) + { + elm->serialize(_Wostream); + } +} +void draw_shape::serialize_attlist(CP_ATTR_NODE) +{ + common_draw_attlists_.serialize(CP_GET_XML_NODE()); + common_presentation_attlist_.serialize(CP_GET_XML_NODE()); + common_xlink_attlist_.serialize(CP_GET_XML_NODE()); + + CP_XML_ATTR_OPT(L"draw:id", draw_id_); +} + +void draw_rect_attlist::serialize(CP_ATTR_NODE) +{ + CP_XML_ATTR_OPT(L"draw:filter-name", draw_filter_name_); +} + +const wchar_t * draw_rect::ns = L"draw"; +const wchar_t * draw_rect::name = L"rect"; + +void draw_rect::serialize(std::wostream & _Wostream) +{ + sub_type_ = 2;//todooo перекинуть + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_shape::serialize_attlist(CP_GET_XML_NODE()); + + draw_rect_attlist_.serialize(CP_GET_XML_NODE()); + + draw_shape::serialize(CP_XML_STREAM()); + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// draw-ellipse-attlist + +void draw_ellipse_attlist::serialize(CP_ATTR_NODE) +{ + CP_XML_ATTR_OPT(L"draw:filter-name", draw_filter_name_); +} + +/// draw:ellipse +const wchar_t * draw_ellipse::ns = L"draw"; +const wchar_t * draw_ellipse::name = L"ellipse"; + + +void draw_ellipse::serialize(std::wostream & _Wostream) +{ + sub_type_ = 3; + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_shape::serialize_attlist(CP_GET_XML_NODE()); + + draw_ellipse_attlist_.serialize(CP_GET_XML_NODE()); + + draw_shape::serialize(CP_XML_STREAM()); + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// draw:circle +const wchar_t * draw_circle::ns = L"draw"; +const wchar_t * draw_circle::name = L"circle"; + +void draw_circle::serialize(std::wostream & _Wostream) +{ + sub_type_ = 4; + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_shape::serialize_attlist(CP_GET_XML_NODE()); + + draw_shape::serialize(CP_XML_STREAM()); + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// draw-line-attlist +void draw_line_attlist::serialize(CP_ATTR_NODE) +{ + CP_XML_ATTR_OPT(L"svg:x1", svg_x1_); + CP_XML_ATTR_OPT(L"svg:x2", svg_x2_); + CP_XML_ATTR_OPT(L"svg:y1", svg_y1_); + CP_XML_ATTR_OPT(L"svg:y2", svg_y2_); +} +// draw:line +const wchar_t * draw_line::ns = L"draw"; +const wchar_t * draw_line::name = L"line"; + +void draw_line::serialize(std::wostream & _Wostream) +{ + sub_type_ = 5; + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_shape::serialize_attlist(CP_GET_XML_NODE()); + + draw_line_attlist_.serialize(CP_GET_XML_NODE()); + + draw_shape::serialize(CP_XML_STREAM()); + } + } +} +void draw_line::reset_svg_attributes() +{ + double x1=draw_line_attlist_.svg_x1_.get_value_or(length(0)).get_value_unit(length::pt); + double y1=draw_line_attlist_.svg_y1_.get_value_or(length(0)).get_value_unit(length::pt); + double x2=draw_line_attlist_.svg_x2_.get_value_or(length(0)).get_value_unit(length::pt); + double y2=draw_line_attlist_.svg_y2_.get_value_or(length(0)).get_value_unit(length::pt); + + if (x1 > x2) + { + common_draw_attlists_.position_.svg_x_ = draw_line_attlist_.svg_x2_; + common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ = length(x1-x2, length::pt); + + additional_.push_back(_property(L"flipH",true)); + }else + { + common_draw_attlists_.position_.svg_x_ = draw_line_attlist_.svg_x1_; + common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ = length(x2-x1, length::pt); + } + if (y1 > y2) + { + common_draw_attlists_.position_.svg_y_ = draw_line_attlist_.svg_y2_; + common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_ = length(y1-y2, length::pt); + + additional_.push_back(_property(L"flipV",true)); + }else + { + common_draw_attlists_.position_.svg_y_ = draw_line_attlist_.svg_y1_; + common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_ = length(y2-y1, length::pt); + } +} +//////////////////////////////////////////////////////////////////////////////////////////////////// +// draw:custom_shape +const wchar_t * draw_custom_shape::ns = L"draw"; +const wchar_t * draw_custom_shape::name = L"custom-shape"; + +void draw_custom_shape::serialize(std::wostream & _Wostream) +{ + sub_type_ = 7; + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_shape::serialize_attlist(CP_GET_XML_NODE()); + + draw_shape::serialize(CP_XML_STREAM()); + } + } +} +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// draw-path-attlist +void draw_path_attlist::serialize(CP_ATTR_NODE) +{ + CP_XML_ATTR_OPT(L"svg:d", svg_d_); + CP_XML_ATTR_OPT(L"svg:viewBox", svg_viewbox_); + +} +// draw:path +const wchar_t * draw_path::ns = L"draw"; +const wchar_t * draw_path::name = L"path"; + +void draw_path::serialize(std::wostream & _Wostream) +{ + sub_type_ = 6; + reset_svg_path(); + + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_shape::serialize_attlist(CP_GET_XML_NODE()); + + draw_path_attlist_.serialize(CP_GET_XML_NODE()); + + draw_shape::serialize(CP_XML_STREAM()); + } + } +} +void draw_path::reset_svg_path()//todooo наоборот +{ + if (draw_path_attlist_.svg_d_) + { + std::vector o_Polyline_pt; + std::vector o_Polyline_cm; + + bool res = svg_path::createSvgD(o_Polyline_cm,draw_path_attlist_.svg_d_.get(),false); + + BOOST_FOREACH(svg_path::_polyline & poly, o_Polyline_cm) + { + for (long i=0;i0) + { + //сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво.. + std::wstringstream output_; + svg_path::oox_serialize(output_, o_Polyline_pt); + additional_.push_back(odf::_property(L"custom_path",output_.str())); + } + } +} +/////////////////////////////////////// +void draw_polygon_attlist::serialize(CP_ATTR_NODE) +{ + CP_XML_ATTR_OPT(L"draw:points", draw_points_); + CP_XML_ATTR_OPT(L"svg:viewBox", svg_viewbox_); + +} +// draw:polygon +const wchar_t * draw_polygon::ns = L"draw"; +const wchar_t * draw_polygon::name = L"polygon"; + +void draw_polygon::serialize(std::wostream & _Wostream) +{ + sub_type_ = 8; + reset_polygon_path(); + + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_shape::serialize_attlist(CP_GET_XML_NODE()); + + draw_polygon_attlist_.serialize(CP_GET_XML_NODE()); + + draw_shape::serialize(CP_XML_STREAM()); + } + } +} +void draw_polygon::reset_polygon_path() +{ + if (draw_polygon_attlist_.draw_points_) + { + std::vector o_Polyline_pt; + std::vector o_Polyline_cm; + + bool res = svg_path::createPolygon(o_Polyline_cm,draw_polygon_attlist_.draw_points_.get(),false); + + BOOST_FOREACH(svg_path::_polyline & poly, o_Polyline_cm) + { + for (long i=0;i0) + { + //сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво.. + std::wstringstream output_; + svg_path::oox_serialize(output_, o_Polyline_pt); + additional_.push_back(odf::_property(L"custom_path",output_.str())); + } + } +} +//////////////////////////////////////////////////////////////////////////////////////////////////// +void draw_equation_attlist::serialize(CP_ATTR_NODE) +{ + CP_XML_ATTR_OPT(L"draw:name", draw_name_); + CP_XML_ATTR_OPT(L"draw:formula", draw_formula_); +} +void draw_handle_attlist::serialize(CP_ATTR_NODE) +{ + CP_XML_ATTR_OPT(L"draw:handle-position", draw_handle_position_); + + CP_XML_ATTR_OPT(L"draw:handle-range-y-maximum", draw_handle_range_y_maximum_); + CP_XML_ATTR_OPT(L"draw:handle-range-y-minimum", draw_handle_range_y_minimum_); + + CP_XML_ATTR_OPT(L"draw:handle-range-x-maximum", draw_handle_range_x_maximum_); + CP_XML_ATTR_OPT(L"draw:handle-range-x-minimum", draw_handle_range_x_minimum_); + + CP_XML_ATTR_OPT(L"draw:handle-radius-range-maximum", draw_handle_radius_range_maximum_); + CP_XML_ATTR_OPT(L"draw:handle-radius-range-minimum", draw_handle_radius_range_minimum_); + + CP_XML_ATTR_OPT(L"draw:handle-polar", draw_handle_polar_); +} +// draw:path +const wchar_t * draw_handle::ns = L"draw"; +const wchar_t * draw_handle::name = L"handle"; + +void draw_handle::serialize(std::wostream & _Wostream) +{ + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_handle_attlist_.serialize(CP_GET_XML_NODE()); + } + } +} +const wchar_t * draw_equation::ns = L"draw"; +const wchar_t * draw_equation::name = L"equation"; + +void draw_equation::serialize(std::wostream & _Wostream) +{ + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_equation_attlist_.serialize(CP_GET_XML_NODE()); + } + } +} +int draw_enhanced_geometry::parsing(_CP_OPT(std::wstring) val) +{ + int pos=0, res=-1; + if (!val)return res; + + BOOST_FOREACH(wchar_t c, val.get()) + { + if (c < L'0' && c > L'9') + return res; + } + + if ((pos = val->find(L"$"))>=0)return res; + res = boost::lexical_cast(val.get()); + return res; +} + + +/// draw-enhanced_geometry_attlist +void draw_enhanced_geometry_attlist::serialize(CP_ATTR_NODE) +{ + CP_XML_ATTR_OPT(L"draw:type", draw_type_); + CP_XML_ATTR_OPT(L"draw:modifiers", draw_modifiers_); +} +// draw:enhanced_geometry +const wchar_t * draw_enhanced_geometry::ns = L"draw"; +const wchar_t * draw_enhanced_geometry::name = L"enhanced-geometry"; + +void draw_enhanced_geometry::serialize(std::wostream & _Wostream) +{ + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_enhanced_geometry_attlist_.serialize(CP_GET_XML_NODE()); + CP_XML_ATTR_OPT(L"svg:viewBox", svg_viewbox_); + //draw_shape::serialize_attlist(CP_GET_XML_NODE()); + + //draw_polygon_attlist_.serialize(CP_GET_XML_NODE()); + + //draw_shape::serialize(CP_XML_STREAM()); + } + } +} + +typedef shared_ptr draw_handle_ptr; + +void draw_enhanced_geometry::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name) +{ + if CP_CHECK_NAME(L"draw", L"handle") + { + CP_CREATE_ELEMENT(draw_handle_); + } + else if CP_CHECK_NAME(L"draw", L"equation") + { + CP_CREATE_ELEMENT(draw_equation_); + } + else + { + //not_applicable_element(L"draw_enhanced_geometry", Reader, Ns, Name); + } + +} +void draw_enhanced_geometry::find_draw_type_odf(std::wstring & oox_type) +{ + for (long i=0; i<_OO_OOX_custom_shapes_count;i++) + { + if (_OO_OOX_custom_shapes[i].oox == oox_type) + { + draw_type_odf_index_ = i; + draw_enhanced_geometry_attlist_.draw_type_ = _OO_OOX_custom_shapes[i].odf; + break; + } + + } + //if ((draw_type_oox_index_) && (*draw_type_oox_index_== 179))//L"textBox" + //{ + // sub_type_ = 1;//textBox + //} + //std::wstringstream str; + + + // BOOST_FOREACH(const office_element_ptr & parElement, draw_handle_) + // { + // draw_handle * handle = dynamic_cast(parElement.get()); + // + // int min = -1; + // int max = -1; + // + // try + // { + // min = parsing(handle->draw_handle_attlist_.draw_handle_range_y_minimum_);//пока статик .. и выдается только цыфровое значение + // if (min<0)min =parsing(handle->draw_handle_attlist_.draw_handle_range_x_minimum_); + // if (min<0)min = parsing(handle->draw_handle_attlist_.draw_handle_radius_range_minimum_); + // } + // catch(...) + // { + // } + // if (min<0)min=0; + + // try + // { + // max = parsing(handle->draw_handle_attlist_.draw_handle_range_y_maximum_); + // if (max<0)max = parsing(handle->draw_handle_attlist_.draw_handle_range_x_maximum_); + // if (max<0)max = parsing(handle->draw_handle_attlist_.draw_handle_radius_range_maximum_); + // } + // catch(...) + // { + // } + // draw_handle_geometry elm={min, max}; + // draw_handle_geometry_.push_back(elm); + // } +} +//////////////////////////////////////////////////////////////////////////////////////////////////// +// draw:caption +////////////////////////////////////////////////////////////////////////////////////////////////// +const wchar_t * draw_caption::ns = L"draw"; +const wchar_t * draw_caption::name = L"caption"; + +void draw_caption::serialize(std::wostream & _Wostream) +{ + sub_type_ = 1; + + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_shape::serialize_attlist(CP_GET_XML_NODE()); + + draw_shape::serialize(CP_XML_STREAM()); + } + } +} +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// draw-connector-attlist +void draw_connector_attlist::serialize(CP_ATTR_NODE) +{ + CP_XML_ATTR_OPT(L"svg:d", svg_d_); + CP_XML_ATTR_OPT(L"svg:viewBox", svg_viewbox_); + CP_XML_ATTR_OPT(L"draw:type",draw_type_); + +} +// draw:connector +const wchar_t * draw_connector::ns = L"draw"; +const wchar_t * draw_connector::name = L"connector"; + +void draw_connector::serialize(std::wostream & _Wostream) +{ + sub_type_ = 5; //коннектор - линия, если ломаная (ниже определяется) - то путь + + reset_svg_path(); + + CP_XML_WRITER(_Wostream) + { + CP_XML_NODE_SIMPLE() + { + draw_shape::serialize_attlist(CP_GET_XML_NODE()); + + draw_connector_attlist_.serialize(CP_GET_XML_NODE()); + draw_line_attlist_.serialize(CP_GET_XML_NODE()); + + draw_shape::serialize(CP_XML_STREAM()); + } + } +} +void draw_connector::reset_svg_path() +{ + if (draw_connector_attlist_.svg_d_) + { + std::vector o_Polyline_pt; + std::vector o_Polyline_cm; + + bool res = svg_path::createSvgD(o_Polyline_cm,draw_connector_attlist_.svg_d_.get(),false); + + double x1=common_draw_attlists_.position_.svg_x_.get_value_or(length(0)).get_value_unit(length::emu); + double y1=common_draw_attlists_.position_.svg_y_.get_value_or(length(0)).get_value_unit(length::emu); + + BOOST_FOREACH(svg_path::_polyline & poly, o_Polyline_cm) + { + for (long i=0;i0) + { + sub_type_ = 6; + //сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво.. + std::wstringstream output_; + svg_path::oox_serialize(output_, o_Polyline_pt); + additional_.push_back(odf::_property(L"custom_path",output_.str())); + } + } +} +/////////////////////////////////////// + +} +} \ No newline at end of file diff --git a/ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.h b/ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.h new file mode 100644 index 0000000000..277817f6d3 --- /dev/null +++ b/ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.h @@ -0,0 +1,396 @@ +#pragma once + +#include +#include +#include +#include + +#include "office_elements.h" +#include "office_elements_create.h" + +#include "common_attlists.h" + + +namespace cpdoccore +{ + +namespace odf { + + +class draw_shape : public office_element_impl +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + + static const ElementType type = typeDrawShape; + static const xml::NodeType xml_type = xml::typeElement; + + 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); + + virtual void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name); + virtual void add_child_element( office_element_ptr & child_element); + + virtual void serialize(std::wostream & _Wostream); + virtual void serialize_attlist(CP_ATTR_NODE); + + common_xlink_attlist common_xlink_attlist_; + common_presentation_attlist common_presentation_attlist_; + union_common_draw_attlists common_draw_attlists_; + + _CP_OPT(std::wstring) draw_id_;//используется для анимашек + + office_element_ptr_array content_; + + CPDOCCORE_DEFINE_VISITABLE(); + + int sub_type_; + std::vector additional_; + + +}; + +////////////////////////////////////////////////////////////////////////////////////////////////////////// +class draw_rect_attlist +{ +public: + + _CP_OPT(std::wstring) draw_filter_name_; + void serialize(CP_ATTR_NODE); + + +}; + +class draw_rect : public draw_shape +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + + static const ElementType type = typeDrawRect; + static const xml::NodeType xml_type = xml::typeElement; + + virtual void serialize(std::wostream & _Wostream); + + draw_rect_attlist draw_rect_attlist_; + +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_rect); + +////////////////////////////////////////////////////////////////////////////////////////////////////////// +class draw_ellipse_attlist +{ +public: + _CP_OPT(std::wstring) draw_filter_name_; + void serialize(CP_ATTR_NODE); + +}; + +class draw_ellipse : public draw_shape +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + + static const ElementType type = typeDrawEllipse; + static const xml::NodeType xml_type = xml::typeElement; + + virtual void serialize(std::wostream & _Wostream); + + draw_ellipse_attlist draw_ellipse_attlist_; +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_ellipse); +////////////////////////////////////////////////////////////////////////////////////////////////////////// +class draw_circle : public draw_shape +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + + static const ElementType type = typeDrawCircle; + static const xml::NodeType xml_type = xml::typeElement; + + virtual void serialize(std::wostream & _Wostream); +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_circle); +////////////////////////////////////////////////////////////////////////////////////////////////////////// +class draw_line_attlist +{ +public: + virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); + + _CP_OPT(length) svg_x1_; + _CP_OPT(length) svg_y1_; + + _CP_OPT(length) svg_x2_; + _CP_OPT(length) svg_y2_; + + void serialize(CP_ATTR_NODE); +}; +///////////////////////////////////////////////////////////////////////// +class draw_line : public draw_shape +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + + static const ElementType type = typeDrawLine; + static const xml::NodeType xml_type = xml::typeElement; + + virtual void serialize(std::wostream & _Wostream); + + draw_line_attlist draw_line_attlist_; + + void reset_svg_attributes(); +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_line); +////////////////////////////////////////////////////////////////////////////////////////////////////////// +class draw_path_attlist +{ +public: + _CP_OPT(std::wstring) svg_d_; + _CP_OPT(std::wstring) svg_viewbox_; + + void serialize(CP_ATTR_NODE); +}; +///////////////////////////////////////////////////////////////////////// +class draw_path : public draw_shape +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + + static const ElementType type = typeDrawPath; + static const xml::NodeType xml_type = xml::typeElement; + + virtual void serialize(std::wostream & _Wostream); + + draw_path_attlist draw_path_attlist_; + + void reset_svg_path(); +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_path); +////////////////////////////////////////////////////////////////////////////////////////////////////////// +class draw_polygon_attlist +{ +public: + _CP_OPT(std::wstring) draw_points_; + _CP_OPT(std::wstring) svg_viewbox_; + + void serialize(CP_ATTR_NODE); +}; +///////////////////////////////////////////////////////////////////////// +class draw_polygon : public draw_shape +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + + static const ElementType type = typeDrawPolygon; + static const xml::NodeType xml_type = xml::typeElement; + + virtual void serialize(std::wostream & _Wostream); + + draw_polygon_attlist draw_polygon_attlist_; + + void reset_polygon_path();//частный случай svg - все точки соединены прямыми +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_polygon); +////////////////////////////////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////// +class draw_custom_shape : public draw_shape +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + + static const ElementType type = typeDrawCustomShape; + static const xml::NodeType xml_type = xml::typeElement; + + virtual void serialize(std::wostream & _Wostream); +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_custom_shape); +//draw:enhanced-geometry +////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////// +class draw_equation_attlist//убрать стринги ... сделать парсинг см стр 378 оазис !!!!!!!!!!! +{ +public: + _CP_OPT(std::wstring) draw_name_; + _CP_OPT(std::wstring) draw_formula_; + + void serialize(CP_ATTR_NODE); +}; +///////////////////////////////////////////////////////////////// +class draw_equation : public office_element_impl +{ +public: + + static const wchar_t * ns; + static const wchar_t * name; + + static const ElementType type = typeDrawEquation; + static const xml::NodeType xml_type = xml::typeElement; + CPDOCCORE_DEFINE_VISITABLE(); + + virtual void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name){} + virtual void add_child_element( office_element_ptr & child_element){} + + virtual void serialize(std::wostream & _Wostream); + + draw_equation_attlist draw_equation_attlist_; +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_equation); +//////////////// +struct draw_handle_geometry +{ + int min; + int max; +}; +////////////////////////////////////////////////////// +class draw_handle_attlist//убрать стринги ... сделать парсинг см стр 378 оазис !!!!!!!!!!! +{ +public: + _CP_OPT(std::wstring) draw_handle_position_; + + _CP_OPT(std::wstring) draw_handle_range_y_maximum_; + _CP_OPT(std::wstring) draw_handle_range_y_minimum_; + + _CP_OPT(std::wstring) draw_handle_range_x_maximum_; + _CP_OPT(std::wstring) draw_handle_range_x_minimum_; + + _CP_OPT(std::wstring) draw_handle_radius_range_maximum_; + _CP_OPT(std::wstring) draw_handle_radius_range_minimum_; + + _CP_OPT(std::wstring) draw_handle_polar_; + + void serialize(CP_ATTR_NODE); +}; + +class draw_handle : public office_element_impl +{ +public: + + static const wchar_t * ns; + static const wchar_t * name; + + static const ElementType type = typeDrawHandle; + static const xml::NodeType xml_type = xml::typeElement; + CPDOCCORE_DEFINE_VISITABLE(); + + virtual void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name){} + virtual void add_child_element( office_element_ptr & child_element){} + + virtual void serialize(std::wostream & _Wostream); + + draw_handle_attlist draw_handle_attlist_; + +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_handle); +///////////////// +class draw_enhanced_geometry_attlist +{ +public: + _CP_OPT(std::wstring) draw_type_; + _CP_OPT(std::wstring) draw_modifiers_; + + void serialize(CP_ATTR_NODE); +}; +///////////////////////////////////////////////////////////////////////// +class draw_enhanced_geometry : public office_element_impl +{ +public: + + static const wchar_t * ns; + static const wchar_t * name; + + static const ElementType type = typeDrawCustomShape; + static const xml::NodeType xml_type = xml::typeElement; + + virtual void create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name); + virtual void add_child_element( office_element_ptr & child_element); + + virtual void serialize(std::wostream & _Wostream); + + void find_draw_type_odf(std::wstring & oox_type); + + draw_enhanced_geometry_attlist draw_enhanced_geometry_attlist_; + + _CP_OPT(int) sub_type_; + _CP_OPT(int) draw_type_odf_index_; + _CP_OPT(std::wstring) svg_viewbox_; + + typedef std::pair pair_string_value; + + std::vector draw_handle_geometry_; //параметры в удобноваримом виде + std::vectordraw_equation_array_; + + office_element_ptr_array draw_handle_; + office_element_ptr_array draw_equation_;//некоторые заданные параметры отрисовки которые используются в draw_handle - автозамена общих частей + + static int parsing(_CP_OPT(std::wstring) val);//todoooo наоборот + + CPDOCCORE_DEFINE_VISITABLE(); +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_enhanced_geometry); + +/////////////////////////////////////////////////////////////////////////////////////////////////////////// + +class draw_caption : public draw_shape +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + + static const ElementType type = typeDrawCaption; + static const xml::NodeType xml_type = xml::typeElement; + + virtual void serialize(std::wostream & _Wostream); +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_caption); +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class draw_connector_attlist +{ +public: + _CP_OPT(std::wstring) svg_d_; + _CP_OPT(std::wstring) svg_viewbox_; + _CP_OPT(std::wstring) draw_type_; + + void serialize(CP_ATTR_NODE); +}; +///////////////////////////////////////////////////////////////////////// +class draw_connector : public draw_shape +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + + static const ElementType type = typeDrawConnector; + static const xml::NodeType xml_type = xml::typeElement; + + virtual void serialize(std::wostream & _Wostream); + + draw_connector_attlist draw_connector_attlist_; + draw_line_attlist draw_line_attlist_; + + void reset_svg_path(); + void reset_svg_attributes(); +}; + +CP_REGISTER_OFFICE_ELEMENT2(draw_connector); +////////////////////////////////////////////////////////////////////////////////////////////////////////// +} +} \ No newline at end of file diff --git a/ASCOfficeOdfFileW/source/OdfFormat/svg_creator.cpp b/ASCOfficeOdfFileW/source/OdfFormat/svg_creator.cpp new file mode 100644 index 0000000000..2ded4340ce --- /dev/null +++ b/ASCOfficeOdfFileW/source/OdfFormat/svg_creator.cpp @@ -0,0 +1,25 @@ +#pragma once +#include "precompiled_cpodf.h" +#include "svg_creator.h" + + +namespace cpdoccore +{ +namespace svg_path +{ + bool createSvgD(std::vector<_polyline> & Polyline, const std::wstring & rSvgDStatement, bool bWrongPositionAfterZ) + { + + return true; + } + + bool createPolygon(std::vector<_polyline> & Polyline, const std::wstring & rPolygonStatement, bool bWrongPositionAfterZ) + { + + return true; + } + + +} +} + diff --git a/ASCOfficeOdfFileW/source/OdfFormat/svg_creator.h b/ASCOfficeOdfFileW/source/OdfFormat/svg_creator.h new file mode 100644 index 0000000000..3a56e81ded --- /dev/null +++ b/ASCOfficeOdfFileW/source/OdfFormat/svg_creator.h @@ -0,0 +1,51 @@ +#pragma once + +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace cpdoccore +{ + +namespace svg_path +{ + struct _point + { + _point(double _x,double _y){x=_x; y=_y;} + + _CP_OPT(double) x; + _CP_OPT(double) y; + + friend void oox_serialize(std::wostream & _Wostream, _point const & val); + }; + struct _polyline + { + std::wstring command; + std::vector<_point> points; //будем бить строку пути по количеству точек в буковках + + friend void oox_serialize(std::wostream & _Wostream, _polyline const & val); + friend void oox_serialize(std::wostream & _Wostream, std::vector & path); + }; + //m - 1 point + //c - 3 point + //s - 2 point + //l - 1 point + //z - finish + //h - 0.5 point :) + //v - 0.5 point + //q - 2 point + //t - 1 point + //a - [[[[ + + bool createSvgD(std::vector<_polyline> & Polyline, const std::wstring & rSvgDStatement, bool bWrongPositionAfterZ); + bool createPolygon(std::vector<_polyline> & Polyline, const std::wstring & rPolygonStatement, bool bWrongPositionAfterZ); + +} +} + diff --git a/ASCOfficeOdfFileW/source/OdfFormat/table.cpp b/ASCOfficeOdfFileW/source/OdfFormat/table.cpp index 41d604084b..0080058879 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/table.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/table.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include "common_attlists.h" diff --git a/ASCOfficeOdfFileW/source/OdfFormat/text_elements.cpp b/ASCOfficeOdfFileW/source/OdfFormat/text_elements.cpp index f43d1b8790..6da830ac81 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/text_elements.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/text_elements.cpp @@ -10,8 +10,6 @@ #include "paragraph_elements.h" #include "list.h" -#include - #include "odf_conversion_context.h" #include "odf_text_context.h" diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp index 8b2aaf6954..36f05dedd0 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp @@ -133,9 +133,23 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet) if (oox_sheet->m_oMergeCells->m_arrItems[mrg]->m_oRef.IsInit()) ods_context->add_merge_cells(string2std_string(oox_sheet->m_oMergeCells->m_arrItems[mrg]->m_oRef.get())); } - //рисование - //m_oDrawing + + if (oox_sheet->m_oDrawing.IsInit() && oox_sheet->m_oDrawing->m_oId.IsInit()) + { + smart_ptr oFile = oox_sheet->Find(oox_sheet->m_oDrawing->m_oId->GetValue()); + if (oFile.IsInit() && OOX::Spreadsheet::FileTypes::Drawings == oFile->type()) + { + OOX::Spreadsheet::CDrawing* pDrawing = (OOX::Spreadsheet::CDrawing*)oFile.operator->(); + + convert(pDrawing); + } + } + //for (long dr =0; oox_sheet->m_oDrawing.IsInit() && dr < oox_sheet->m_oDrawing->m_arrItems.GetSize(); dr++) + //{ + // convert(oox_sheet->m_oDrawing->m_arrItems[dr]); + //} + //комментарии //m_mapComments @@ -934,4 +948,50 @@ void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool } +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void XlsxConverter::convert(OOX::Spreadsheet::CCellAnchor *oox_anchor) +{ + //SimpleTypes::Spreadsheet::CCellAnchorType<> m_oAnchorType; + std::wstring ref_from, ref_to; + int col_from, col_to, row_from, row_to; +////////////////// + if (oox_anchor->m_oFrom.IsInit()) + convert(oox_anchor->m_oFrom.GetPointer(),ref_from, col_from, row_from); + + if (oox_anchor->m_oTo.IsInit()) + convert(oox_anchor->m_oTo.GetPointer(),ref_to,col_to,row_to); +////////////// + if (oox_anchor->m_oPos.IsInit()) + { + } + + if (oox_anchor->m_oExt.IsInit()) + { + } +//собственно + if (oox_anchor->m_oGraphicFrame.IsInit()) + { + //m_oChartGraphic + } + if (oox_anchor->m_oXml.IsInit()) + { + //m_oXml + } +} + +void XlsxConverter::convert(OOX::Spreadsheet::CDrawing *oox_drawing) +{ + if (!oox_drawing)return; + + for (long dr = 0 ; dr < oox_drawing->m_arrItems.GetSize(); dr++) + { + convert(oox_drawing->m_arrItems[dr]); + } +} + + +void XlsxConverter::convert(OOX::Spreadsheet::CFromTo* oox_from_to, std::wstring & odf_ref, int & col, int & row) +{ +} + } // namespace Docx2Odt \ No newline at end of file diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.h b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.h index 92f4411668..edbe785757 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.h +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.h @@ -96,6 +96,10 @@ namespace Oox2Odf void convert(OOX::Spreadsheet::CCellStyle *cell_style, int oox_id); void convert(OOX::Spreadsheet::CNumFmt *numFmt); + void convert(OOX::Spreadsheet::CCellAnchor *oox_anchor); + void convert(OOX::Spreadsheet::CDrawing *oox_drawing); + void convert_sharing_string(int number); + void convert(OOX::Spreadsheet::CFromTo* oox_from_to, std::wstring & odf_ref, int & col, int & row); }; } \ No newline at end of file