mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-18 23:25:17 +08:00
@ -307,6 +307,7 @@ enum ElementType
|
||||
|
||||
typeStyleFontFace,
|
||||
|
||||
typeSvgTitle,
|
||||
typeSvgDesc,
|
||||
typeSvgFontFaceUri,
|
||||
typeSvgFontFaceFormat,
|
||||
|
||||
@ -288,9 +288,16 @@ void docx_serialize_image_child(std::wostream & strm, _docx_drawing & val)
|
||||
{
|
||||
CP_XML_NODE(L"pic:cNvPr")
|
||||
{
|
||||
_CP_OPT(std::wstring) title, descr;
|
||||
GetProperty(val.additional, L"svg:title", title);
|
||||
GetProperty(val.additional, L"svg:desc", descr);
|
||||
|
||||
//CP_XML_ATTR(L"desc text",L"");
|
||||
CP_XML_ATTR(L"id", val.id + 1);
|
||||
CP_XML_ATTR(L"name", val.name);
|
||||
|
||||
CP_XML_ATTR_OPT(L"title", title);
|
||||
CP_XML_ATTR_OPT(L"descr", descr);
|
||||
|
||||
//oox_serialize_action(CP_XML_STREAM(), val.action);
|
||||
}
|
||||
@ -399,8 +406,15 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
|
||||
{
|
||||
CP_XML_NODE(L"wp:docPr")
|
||||
{
|
||||
_CP_OPT(std::wstring) title, descr;
|
||||
GetProperty(val.additional, L"svg:title", title);
|
||||
GetProperty(val.additional, L"svg:desc", descr);
|
||||
|
||||
CP_XML_ATTR(L"name", val.name);
|
||||
CP_XML_ATTR(L"id", 0xf000 + val.id + 1);
|
||||
|
||||
CP_XML_ATTR_OPT(L"title", title);
|
||||
CP_XML_ATTR_OPT(L"descr", descr);
|
||||
|
||||
oox_serialize_action(CP_XML_STREAM(), val.action);
|
||||
}
|
||||
|
||||
@ -299,6 +299,14 @@ void draw_frame::add_child_element( xml::sax * Reader, const std::wstring & Ns,
|
||||
{
|
||||
CP_CREATE_ELEMENT(draw_contour_);
|
||||
}
|
||||
else if (CP_CHECK_NAME(L"svg", L"title"))
|
||||
{
|
||||
CP_CREATE_ELEMENT(svg_title_);
|
||||
}
|
||||
else if (CP_CHECK_NAME(L"svg", L"desc"))
|
||||
{
|
||||
CP_CREATE_ELEMENT(svg_desc_);
|
||||
}
|
||||
else
|
||||
{
|
||||
CP_NOT_APPLICABLE_ELM();
|
||||
|
||||
@ -177,6 +177,9 @@ public:
|
||||
|
||||
office_element_ptr draw_contour_; // draw-contour-polygon or draw-contour-path
|
||||
|
||||
office_element_ptr svg_title_;
|
||||
office_element_ptr svg_desc_;
|
||||
|
||||
friend class odf_document;
|
||||
friend class draw_image;
|
||||
friend class draw_chart;
|
||||
|
||||
@ -1578,6 +1578,11 @@ void draw_frame::docx_convert(oox::docx_conversion_context & Context)
|
||||
drawing->id = Context.get_drawing_context().get_current_frame_id();
|
||||
drawing->name = Context.get_drawing_context().get_current_object_name();
|
||||
drawing->inGroup = Context.get_drawing_context().in_group();
|
||||
|
||||
if (svg_title_)
|
||||
svg_title_->docx_convert(Context);
|
||||
if(svg_desc_)
|
||||
svg_desc_->docx_convert(Context);
|
||||
|
||||
common_draw_docx_convert(Context, common_draw_attlists_, drawing);
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -32,15 +32,59 @@
|
||||
|
||||
#include "font_face.h"
|
||||
|
||||
#include "draw_frame.h"
|
||||
|
||||
#include <xml/xmlchar.h>
|
||||
#include "serialize_elements.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_reader {
|
||||
|
||||
// svg:title
|
||||
//---------------------------------------------------------------------------------------
|
||||
const wchar_t* svg_title::ns = L"svg";
|
||||
const wchar_t* svg_title::name = L"title";
|
||||
|
||||
void svg_title::docx_convert(oox::docx_conversion_context& Context)
|
||||
{
|
||||
odf_reader::draw_frame* current_frame = Context.get_drawing_context().get_current_frame();
|
||||
|
||||
if (current_frame && current_frame->oox_drawing_)
|
||||
{
|
||||
current_frame->oox_drawing_->additional.push_back(odf_reader::_property(L"svg:title", text_));
|
||||
}
|
||||
}
|
||||
|
||||
std::wostream& svg_title::text_to_stream(std::wostream& _Wostream, bool bXmlEncode) const
|
||||
{
|
||||
_Wostream << text_;
|
||||
return _Wostream;
|
||||
}
|
||||
|
||||
void svg_title::add_text(const std::wstring& Text)
|
||||
{
|
||||
text_ += Text;
|
||||
}
|
||||
void svg_title::add_space(const std::wstring& Text)
|
||||
{
|
||||
text_ += Text;
|
||||
}
|
||||
// svg:desc
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
const wchar_t * svg_desc::ns = L"svg";
|
||||
const wchar_t * svg_desc::name = L"desc";
|
||||
|
||||
void svg_desc::docx_convert(oox::docx_conversion_context& Context)
|
||||
{
|
||||
odf_reader::draw_frame* current_frame = Context.get_drawing_context().get_current_frame();
|
||||
|
||||
if (current_frame && current_frame->oox_drawing_)
|
||||
{
|
||||
current_frame->oox_drawing_->additional.push_back(odf_reader::_property(L"svg:desc", text_));
|
||||
}
|
||||
}
|
||||
|
||||
std::wostream & svg_desc::text_to_stream(std::wostream & _Wostream, bool bXmlEncode) const
|
||||
{
|
||||
_Wostream << text_ ;
|
||||
|
||||
@ -78,6 +78,31 @@ private:
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(svg_font_face_uri);
|
||||
|
||||
// svg:title
|
||||
class svg_title : public office_element_impl<svg_title>
|
||||
{
|
||||
public:
|
||||
static const wchar_t* ns;
|
||||
static const wchar_t* name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeSvgTitle;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
void docx_convert(oox::docx_conversion_context& Context);
|
||||
|
||||
virtual std::wostream& text_to_stream(std::wostream& _Wostream, bool bXmlEncode = true) const;
|
||||
|
||||
std::wstring text_;
|
||||
|
||||
private:
|
||||
virtual void add_attributes(const xml::attributes_wc_ptr& Attributes) {}
|
||||
virtual void add_child_element(xml::sax* Reader, const std::wstring& Ns, const std::wstring& Name) {}
|
||||
virtual void add_text(const std::wstring& Text);
|
||||
virtual void add_space(const std::wstring& Text);
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(svg_title);
|
||||
|
||||
// svg:desc
|
||||
class svg_desc : public office_element_impl<svg_desc>
|
||||
{
|
||||
@ -89,6 +114,8 @@ public:
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
void docx_convert(oox::docx_conversion_context& Context);
|
||||
|
||||
virtual std::wostream & text_to_stream(std::wostream & _Wostream, bool bXmlEncode = true) const;
|
||||
|
||||
std::wstring text_;
|
||||
|
||||
Reference in New Issue
Block a user