mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-20 07:41:12 +08:00
РИСОВАНИЕ в OOX формате НЕ РЕАЛИЗОВАНО !!!!
git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@55426 954022d7-b5bf-4e40-9824-e11837661b57
This commit is contained in:
committed by
Alexander Trofimov
parent
67d45b5e82
commit
19e8fa19bb
@ -1760,7 +1760,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\odf\custom_shape_types_convert.h"
|
||||
RelativePath=".\src\odf\datatypes\custom_shape_types_convert.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
||||
@ -449,11 +449,9 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring& expr)
|
||||
|
||||
const std::wstring res = boost::regex_replace(
|
||||
workstr,
|
||||
//boost::wregex(L"(?:(?=\\()([^\\}]*?)(?=\\)))|(\".*?\")|('.*?')"),//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ( <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ) .. <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>???
|
||||
boost::wregex(L"(?:(?=[()])(.*?)(?=[)]))|(\".*?\")|('.*?')"),
|
||||
&oox2odf_converter::Impl::replace_arguments,
|
||||
boost::match_default | boost::format_all);
|
||||
//workstr = replace_arguments(workstr);
|
||||
|
||||
return std::wstring(L"of:=") + res;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#include "precompiled_cpodf.h"
|
||||
#include "docx_drawing.h"
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
#include "../odf/custom_shape_types_convert.h"
|
||||
#include "custom_shape_types_convert.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -886,6 +886,22 @@
|
||||
<Filter
|
||||
Name="elements"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\OdfFormat\draw_frame.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OdfFormat\draw_frame.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OdfFormat\draw_shapes.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OdfFormat\draw_shapes.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OdfFormat\list.cpp"
|
||||
>
|
||||
@ -982,6 +998,14 @@
|
||||
<Filter
|
||||
Name="xml_common"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\OdfFormat\svg_creator.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OdfFormat\svg_creator.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\ASCOfficeOdfFile\src\xml\utils.cpp"
|
||||
>
|
||||
|
||||
326
ASCOfficeOdfFileW/source/OdfFormat/draw_frame.cpp
Normal file
326
ASCOfficeOdfFileW/source/OdfFormat/draw_frame.cpp
Normal file
@ -0,0 +1,326 @@
|
||||
#include "precompiled_cpodf.h"
|
||||
#include "draw_frame.h"
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost_string.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include <cpdoccore/xml/xmlchar.h>
|
||||
#include <cpdoccore/xml/serialize.h>
|
||||
#include <cpdoccore/xml/attributes.h>
|
||||
|
||||
#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") ||//<2F><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>.. <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CP_CHECK_NAME(L"draw", L"object") ||//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
228
ASCOfficeOdfFileW/source/OdfFormat/draw_frame.h
Normal file
228
ASCOfficeOdfFileW/source/OdfFormat/draw_frame.h
Normal file
@ -0,0 +1,228 @@
|
||||
#pragma once
|
||||
|
||||
#include <iosfwd>
|
||||
#include <cpdoccore/CPOptional.h>
|
||||
#include <cpdoccore/xml/xmlelement.h>
|
||||
#include <cpdoccore/xml/nodetype.h>
|
||||
#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<draw_image>
|
||||
{
|
||||
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);
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> .. <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||
class draw_chart : public office_element_impl<draw_chart>
|
||||
{
|
||||
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<draw_frame>
|
||||
{
|
||||
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_; // <20> content <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
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<draw_g>
|
||||
{
|
||||
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<draw_text_box>
|
||||
{
|
||||
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<draw_object>
|
||||
{
|
||||
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<draw_object>
|
||||
{
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
583
ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.cpp
Normal file
583
ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.cpp
Normal file
@ -0,0 +1,583 @@
|
||||
#include "precompiled_cpodf.h"
|
||||
#include "draw_shapes.h"
|
||||
#include "custom_shape_types_convert.h"
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost_string.h>
|
||||
#include <regex.h>
|
||||
|
||||
#include <cpdoccore/xml/xmlchar.h>
|
||||
#include <cpdoccore/xml/serialize.h>
|
||||
#include <cpdoccore/xml/attributes.h>
|
||||
|
||||
#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 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
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 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
if (draw_path_attlist_.svg_d_)
|
||||
{
|
||||
std::vector<svg_path::_polyline> o_Polyline_pt;
|
||||
std::vector<svg_path::_polyline> 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;i<poly.points.size();i++)
|
||||
{
|
||||
if (poly.points[i].x)
|
||||
{
|
||||
poly.points[i].x = length(poly.points[i].x.get()/1000.,length::cm).get_value_unit(length::emu);
|
||||
}
|
||||
if (poly.points[i].y)
|
||||
{
|
||||
poly.points[i].y = length(poly.points[i].y.get()/1000.,length::cm).get_value_unit(length::emu);
|
||||
}
|
||||
}
|
||||
o_Polyline_pt.push_back(poly);
|
||||
}
|
||||
if (o_Polyline_pt.size()>0)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> xml-oox <20><><EFBFBD><EFBFBD><EFBFBD> ... <20> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> drawing .. <20><><EFBFBD><EFBFBD> <20> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>..
|
||||
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<svg_path::_polyline> o_Polyline_pt;
|
||||
std::vector<svg_path::_polyline> 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;i<poly.points.size();i++)
|
||||
{
|
||||
if (poly.points[i].x)
|
||||
{
|
||||
poly.points[i].x = length(poly.points[i].x.get()/1000.,length::cm).get_value_unit(length::emu);
|
||||
}
|
||||
if (poly.points[i].y)
|
||||
{
|
||||
poly.points[i].y = length(poly.points[i].y.get()/1000.,length::cm).get_value_unit(length::emu);
|
||||
}
|
||||
}
|
||||
o_Polyline_pt.push_back(poly);
|
||||
}
|
||||
if (o_Polyline_pt.size()>0)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> xml-oox <20><><EFBFBD><EFBFBD><EFBFBD> ... <20> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> drawing .. <20><><EFBFBD><EFBFBD> <20> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>..
|
||||
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<int>(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> 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<draw_handle *>(parElement.get());
|
||||
//
|
||||
// int min = -1;
|
||||
// int max = -1;
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// min = parsing(handle->draw_handle_attlist_.draw_handle_range_y_minimum_);//<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> .. <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// 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; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) - <20><> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
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<svg_path::_polyline> o_Polyline_pt;
|
||||
std::vector<svg_path::_polyline> 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;i<poly.points.size();i++)
|
||||
{
|
||||
if (poly.points[i].x)
|
||||
{
|
||||
poly.points[i].x = length(poly.points[i].x.get()/1000.,length::cm).get_value_unit(length::emu)-x1;
|
||||
}
|
||||
if (poly.points[i].y)
|
||||
{
|
||||
poly.points[i].y = length(poly.points[i].y.get()/1000.,length::cm).get_value_unit(length::emu)-y1;
|
||||
}
|
||||
}
|
||||
o_Polyline_pt.push_back(poly);
|
||||
}
|
||||
if (o_Polyline_pt.size()>0)
|
||||
{
|
||||
sub_type_ = 6;
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> xml-oox <20><><EFBFBD><EFBFBD><EFBFBD> ... <20> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> drawing .. <20><><EFBFBD><EFBFBD> <20> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>..
|
||||
std::wstringstream output_;
|
||||
svg_path::oox_serialize(output_, o_Polyline_pt);
|
||||
additional_.push_back(odf::_property(L"custom_path",output_.str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
396
ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.h
Normal file
396
ASCOfficeOdfFileW/source/OdfFormat/draw_shapes.h
Normal file
@ -0,0 +1,396 @@
|
||||
#pragma once
|
||||
|
||||
#include <iosfwd>
|
||||
#include <cpdoccore/CPOptional.h>
|
||||
#include <cpdoccore/xml/xmlelement.h>
|
||||
#include <cpdoccore/xml/nodetype.h>
|
||||
|
||||
#include "office_elements.h"
|
||||
#include "office_elements_create.h"
|
||||
|
||||
#include "common_attlists.h"
|
||||
|
||||
|
||||
namespace cpdoccore
|
||||
{
|
||||
|
||||
namespace odf {
|
||||
|
||||
|
||||
class draw_shape : public office_element_impl<draw_shape>
|
||||
{
|
||||
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_;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
office_element_ptr_array content_;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
int sub_type_;
|
||||
std::vector<odf::_property> 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();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> svg - <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
};
|
||||
|
||||
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//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ... <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD> 378 <20><><EFBFBD><EFBFBD><EFBFBD> !!!!!!!!!!!
|
||||
{
|
||||
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<draw_equation>
|
||||
{
|
||||
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//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ... <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD> 378 <20><><EFBFBD><EFBFBD><EFBFBD> !!!!!!!!!!!
|
||||
{
|
||||
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<draw_handle>
|
||||
{
|
||||
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<draw_enhanced_geometry>
|
||||
{
|
||||
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<std::wstring,std::wstring> pair_string_value;
|
||||
|
||||
std::vector<draw_handle_geometry> draw_handle_geometry_; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
std::vector<pair_string_value>draw_equation_array_;
|
||||
|
||||
office_element_ptr_array draw_handle_;
|
||||
office_element_ptr_array draw_equation_;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> draw_handle - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
static int parsing(_CP_OPT(std::wstring) val);//todoooo <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
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);
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
}
|
||||
25
ASCOfficeOdfFileW/source/OdfFormat/svg_creator.cpp
Normal file
25
ASCOfficeOdfFileW/source/OdfFormat/svg_creator.cpp
Normal file
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
51
ASCOfficeOdfFileW/source/OdfFormat/svg_creator.h
Normal file
51
ASCOfficeOdfFileW/source/OdfFormat/svg_creator.h
Normal file
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost_string.h>
|
||||
#include <regex.h>
|
||||
#include <cpdoccore/CPOptional.h>
|
||||
|
||||
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; //<2F><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
friend void oox_serialize(std::wostream & _Wostream, _polyline const & val);
|
||||
friend void oox_serialize(std::wostream & _Wostream, std::vector<svg_path::_polyline> & 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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
#include <cpdoccore/xml/xmlchar.h>
|
||||
#include <cpdoccore/xml/attributes.h>
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
#include <cpdoccore/odf/odf_document.h>
|
||||
|
||||
#include "common_attlists.h"
|
||||
|
||||
|
||||
@ -10,8 +10,6 @@
|
||||
#include "paragraph_elements.h"
|
||||
#include "list.h"
|
||||
|
||||
#include <cpdoccore/odf/odf_document.h>
|
||||
|
||||
#include "odf_conversion_context.h"
|
||||
#include "odf_text_context.h"
|
||||
|
||||
|
||||
@ -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()));
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//m_oDrawing
|
||||
|
||||
if (oox_sheet->m_oDrawing.IsInit() && oox_sheet->m_oDrawing->m_oId.IsInit())
|
||||
{
|
||||
smart_ptr<OOX::File> 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]);
|
||||
//}
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//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())
|
||||
{
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
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
|
||||
@ -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);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user