Commit 54b78e8e authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - convert math elements in sheets & slides

parent a50fdbe6
...@@ -75,7 +75,7 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD ...@@ -75,7 +75,7 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
delayed_converting_ (false), delayed_converting_ (false),
process_headers_footers_(false), process_headers_footers_(false),
process_comment_ (false), process_comment_ (false),
process_math_formula_ (false), math_context_ (false),
odf_document_ (OdfDocument) odf_document_ (OdfDocument)
{ {
streams_man_ = streams_man::create(temp_stream_); streams_man_ = streams_man::create(temp_stream_);
...@@ -187,15 +187,17 @@ void docx_conversion_context::finish_run() ...@@ -187,15 +187,17 @@ void docx_conversion_context::finish_run()
} }
void docx_conversion_context::start_math_formula() void docx_conversion_context::start_math_formula()
{ {
process_math_formula_ = true; math_context_.start();
output_stream() << L"<m:oMath>";
} }
void docx_conversion_context::end_math_formula() void docx_conversion_context::end_math_formula()
{ {
output_stream() << L"</m:oMath>"; std::wstring math_content = math_context_.end();
process_math_formula_ = false;
if (!math_content.empty())
{
output_stream() << L"<m:oMath>" << math_content << L"</m:oMath>";
}
} }
void docx_conversion_context::start_chart(std::wstring name) void docx_conversion_context::start_chart(std::wstring name)
......
...@@ -56,22 +56,21 @@ namespace cpdoccore { ...@@ -56,22 +56,21 @@ namespace cpdoccore {
class style_ref; class style_ref;
class length_or_percent; class length_or_percent;
} }
namespace odf_reader namespace odf_reader
{ {
class style_instance; class style_instance;
class odf_document; class odf_document;
class style_text_properties; class style_text_properties;
class draw_frame; class draw_frame;
class draw_shape; class draw_shape;
typedef boost::shared_ptr<style_text_properties> style_text_properties_ptr; class office_element;
class office_element; class style_columns;
class style_columns;
namespace text
{
namespace text{ class note_citation;
class note_citation; }
} }
}
namespace oox { namespace oox {
...@@ -571,7 +570,8 @@ public: ...@@ -571,7 +570,8 @@ public:
void push_text_properties(const odf_reader::style_text_properties * TextProperties); void push_text_properties(const odf_reader::style_text_properties * TextProperties);
void pop_text_properties(); void pop_text_properties();
odf_reader::style_text_properties_ptr current_text_properties();
odf_reader::style_text_properties_ptr current_text_properties();
void set_page_break_after(bool val); void set_page_break_after(bool val);
bool get_page_break_after(); bool get_page_break_after();
...@@ -606,9 +606,9 @@ public: ...@@ -606,9 +606,9 @@ public:
std::wstring find_list_rename(const std::wstring & ListStyleName) const; std::wstring find_list_rename(const std::wstring & ListStyleName) const;
drawing_context & get_drawing_context() { return drawing_context_; } drawing_context & get_drawing_context() { return drawing_context_; }
comments_context & get_comments_context() { return comments_context_; }
comments_context & get_comments_context() {return comments_context_;} math_context & get_math_context() { return math_context_; }
void docx_convert_delayed(); void docx_convert_delayed();
void add_delayed_element(odf_reader::office_element * Elm); void add_delayed_element(odf_reader::office_element * Elm);
...@@ -646,8 +646,7 @@ public: ...@@ -646,8 +646,7 @@ public:
void start_math_formula(); void start_math_formula();
void end_math_formula(); void end_math_formula();
bool process_math_formula_;
void set_process_headers_footers(bool Val) { process_headers_footers_ = Val; } void set_process_headers_footers(bool Val) { process_headers_footers_ = Val; }
headers_footers & get_headers_footers() { return headers_footers_; } headers_footers & get_headers_footers() { return headers_footers_; }
header_footer_context & get_header_footer_context() { return header_footer_context_; } header_footer_context & get_header_footer_context() { return header_footer_context_; }
...@@ -682,7 +681,8 @@ private: ...@@ -682,7 +681,8 @@ private:
hyperlinks hyperlinks_; hyperlinks hyperlinks_;
mediaitems mediaitems_; mediaitems mediaitems_;
styles_context styles_context_; styles_context styles_context_;
math_context math_context_;
std::wstring automatic_parent_style_; std::wstring automatic_parent_style_;
......
...@@ -49,7 +49,7 @@ struct _rect ...@@ -49,7 +49,7 @@ struct _rect
struct drawing_object_description struct drawing_object_description
{ {
oox::RelsType type_; oox::RelsType type_;
std::wstring name_; std::wstring name_;
_CP_OPT(_rect) svg_rect_; _CP_OPT(_rect) svg_rect_;
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <cpdoccore/xml/simple_xml_writer.h> #include <cpdoccore/xml/simple_xml_writer.h>
#include "../odf/odfcontext.h" #include "../odf/odfcontext.h"
#include "../odf/style_text_properties.h"
namespace cpdoccore { namespace cpdoccore {
...@@ -78,11 +79,6 @@ std::wstringstream & styles_context::text_style() ...@@ -78,11 +79,6 @@ std::wstringstream & styles_context::text_style()
return text_style_; return text_style_;
} }
std::wstringstream & styles_context::math_text_style()
{
return math_text_style_;
}
std::wstringstream & styles_context::paragraph_nodes() std::wstringstream & styles_context::paragraph_nodes()
{ {
return paragraph_nodes_; return paragraph_nodes_;
...@@ -135,5 +131,32 @@ void styles_context::docx_serialize_table_style(std::wostream & strm) ...@@ -135,5 +131,32 @@ void styles_context::docx_serialize_table_style(std::wostream & strm)
} }
} }
} }
namespace oox
{
math_context::math_context(bool graphic) : base_font_size_(12)
{
graphRPR_ = graphic;
if (graphRPR_) nsRPr_ = L"a:rPr";
else nsRPr_ = L"w:rPr";
}
void math_context::start()
{
text_properties_ = odf_reader::style_text_properties_ptr(new odf_reader::style_text_properties());
text_properties_->content().style_font_name_ = L"Cambria Math";
text_properties_->content().fo_font_size_ = odf_types::length(base_font_size_, odf_types::length::pt);
}
std::wstring math_context::end()
{
std::wstring math = math_stream_.str();
math_stream_.str( std::wstring() );
math_stream_.clear();
return math;
}
}
} }
\ No newline at end of file
...@@ -40,8 +40,11 @@ ...@@ -40,8 +40,11 @@
namespace cpdoccore { namespace cpdoccore {
namespace odf_reader{ namespace odf_reader
class style_instance; {
class style_instance;
class style_text_properties;
typedef boost::shared_ptr<style_text_properties> style_text_properties_ptr;
}; };
class styles_context : boost::noncopyable class styles_context : boost::noncopyable
...@@ -54,7 +57,6 @@ public: ...@@ -54,7 +57,6 @@ public:
std::wstringstream & paragraph_attr(); std::wstringstream & paragraph_attr();
std::wstringstream & table_style(); std::wstringstream & table_style();
std::wstringstream & list_style(); std::wstringstream & list_style();
std::wstringstream & math_text_style();
void docx_serialize_text_style(std::wostream & strm, std::wstring parenStyleId); void docx_serialize_text_style(std::wostream & strm, std::wstring parenStyleId);
void docx_serialize_table_style(std::wostream & strm); void docx_serialize_table_style(std::wostream & strm);
...@@ -65,7 +67,8 @@ public: ...@@ -65,7 +67,8 @@ public:
std::wstring & hlinkClick(){return hlinkClick_;} std::wstring & hlinkClick(){return hlinkClick_;}
const odf_reader::style_instance * get_current_processed_style() const { return current_processed_style_; } const odf_reader::style_instance * get_current_processed_style() const { return current_processed_style_; }
void start_process_style(const odf_reader::style_instance * Instance);
void start_process_style(const odf_reader::style_instance * Instance);
void end_process_style(); void end_process_style();
private: private:
...@@ -79,12 +82,32 @@ private: ...@@ -79,12 +82,32 @@ private:
std::wstringstream paragraph_nodes_; std::wstringstream paragraph_nodes_;
std::wstringstream paragraph_attr_; std::wstringstream paragraph_attr_;
std::wstringstream table_style_; std::wstringstream table_style_;
std::wstringstream math_text_style_;
}; };
namespace oox { namespace oox {
class math_context : boost::noncopyable
{
public:
math_context(bool graphic = false);
void start();
std::wstring end();
std::wostream & output_stream() { return math_stream_; }
std::wstringstream & math_style_stream() { return math_style_stream_; }
int base_font_size_;
odf_reader::style_text_properties_ptr text_properties_;
std::wstring nsRPr_;
bool graphRPR_;
private:
std::wstringstream math_stream_;
std::wstringstream math_style_stream_;
};
} }
} }
......
...@@ -68,6 +68,7 @@ pptx_conversion_context::pptx_conversion_context( odf_reader::odf_document * odf ...@@ -68,6 +68,7 @@ pptx_conversion_context::pptx_conversion_context( odf_reader::odf_document * odf
,pptx_table_context_(*this) ,pptx_table_context_(*this)
,pptx_comments_context_(comments_context_handle_) ,pptx_comments_context_(comments_context_handle_)
,pptx_slide_context_(*this/*, pptx_text_context_*/) ,pptx_slide_context_(*this/*, pptx_text_context_*/)
,math_context_(true)
,last_idx_placeHolder(1) ,last_idx_placeHolder(1)
,last_uniq_big_id(1) ,last_uniq_big_id(1)
{ {
......
...@@ -113,10 +113,11 @@ public: ...@@ -113,10 +113,11 @@ public:
pptx_xml_theme & current_theme(); pptx_xml_theme & current_theme();
pptx_xml_presentation & current_presentation();//собственно она одна pptx_xml_presentation & current_presentation();//собственно она одна
oox_chart_context & current_chart(); oox_chart_context & current_chart();
pptx_text_context & get_text_context() { return pptx_text_context_; } math_context & get_math_context() { return math_context_; }
pptx_text_context & get_text_context() { return pptx_text_context_; }
pptx_table_context & get_table_context(){return pptx_table_context_;} pptx_table_context & get_table_context() { return pptx_table_context_; }
mediaitems & get_mediaitems() { return pptx_slide_context_.get_mediaitems(); } mediaitems & get_mediaitems() { return pptx_slide_context_.get_mediaitems(); }
...@@ -146,6 +147,7 @@ private: ...@@ -146,6 +147,7 @@ private:
pptx_text_context pptx_text_context_; pptx_text_context pptx_text_context_;
pptx_table_context pptx_table_context_; pptx_table_context pptx_table_context_;
pptx_comments_context pptx_comments_context_; pptx_comments_context pptx_comments_context_;
math_context math_context_;
std::vector<oox_chart_context_ptr> charts_; std::vector<oox_chart_context_ptr> charts_;
......
...@@ -565,7 +565,7 @@ void pptx_slide_context::process_shapes() ...@@ -565,7 +565,7 @@ void pptx_slide_context::process_shapes()
if (iPlaceHolderIdx) drawing.place_holder_idx_ = *iPlaceHolderIdx; if (iPlaceHolderIdx) drawing.place_holder_idx_ = *iPlaceHolderIdx;
} }
drawing.sub_type = pic.type_; drawing.sub_type = pic.shape_type_;
impl_->add_drawing(drawing, isMediaInternal, rId, ref, typeShape); impl_->add_drawing(drawing, isMediaInternal, rId, ref, typeShape);
} }
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "xlsx_drawings.h" #include "xlsx_drawings.h"
#include "xlsx_drawing.h" #include "xlsx_drawing.h"
#include <boost/foreach.hpp>
#include <vector> #include <vector>
#include <cpdoccore/xml/simple_xml_writer.h> #include <cpdoccore/xml/simple_xml_writer.h>
...@@ -51,26 +50,26 @@ public: ...@@ -51,26 +50,26 @@ public:
xlsx_drawings_.push_back(d); xlsx_drawings_.push_back(d);
bool present = false; bool present = false;
BOOST_FOREACH(_rel const & r, xlsx_drawing_rels_) for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
{ {
if (r.rid == rid && r.ref == ref) if (xlsx_drawing_rels_[i].rid == rid && xlsx_drawing_rels_[i].ref == ref)
present = true; present = true;
} }
if (!present) if (!present)
{ {
xlsx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type)); xlsx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
} }
BOOST_FOREACH(_hlink_desc h, d.hlinks) for (int i = 0 ; i < d.hlinks.size(); i++)
{ {
xlsx_drawing_rels_.push_back(_rel(false, h.hId, h.hRef, typeHyperlink)); xlsx_drawing_rels_.push_back(_rel(false, d.hlinks[i].hId, d.hlinks[i].hRef, typeHyperlink));
} }
} }
void add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type) void add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type)
{ {
bool present = false; bool present = false;
BOOST_FOREACH(_rel const & r, xlsx_drawing_rels_) for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
{ {
if (r.rid == rid && r.ref == ref) if (xlsx_drawing_rels_[i].rid == rid && xlsx_drawing_rels_[i].ref == ref)
present = true; present = true;
} }
if (!present) if (!present)
...@@ -85,9 +84,9 @@ public: ...@@ -85,9 +84,9 @@ public:
{ {
if (inGroup) if (inGroup)
{ {
BOOST_FOREACH(_xlsx_drawing & d, xlsx_drawings_) for (int i = 0 ; i < xlsx_drawings_.size(); i++)
{ {
xlsx_serialize(strm, d); xlsx_serialize(strm, xlsx_drawings_[i]);
} }
} }
else else
...@@ -100,9 +99,9 @@ public: ...@@ -100,9 +99,9 @@ public:
CP_XML_ATTR(L"xmlns:a" , L"http://schemas.openxmlformats.org/drawingml/2006/main"); CP_XML_ATTR(L"xmlns:a" , L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:r" , L"http://schemas.openxmlformats.org/officeDocument/2006/relationships"); CP_XML_ATTR(L"xmlns:r" , L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
BOOST_FOREACH(_xlsx_drawing & d, xlsx_drawings_) for (int i = 0 ; i < xlsx_drawings_.size(); i++)
{ {
xlsx_serialize(CP_XML_STREAM(), d); xlsx_serialize(CP_XML_STREAM(), xlsx_drawings_[i]);
} }
} }
} }
...@@ -116,34 +115,34 @@ public: ...@@ -116,34 +115,34 @@ public:
void dump_rels(rels & Rels) void dump_rels(rels & Rels)
{ {
BOOST_FOREACH(_rel const & r, xlsx_drawing_rels_) for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
{ {
if (r.type == typeChart) if (xlsx_drawing_rels_[i].type == typeChart)
{ {
Rels.add(relationship( Rels.add(relationship(
r.rid, xlsx_drawing_rels_[i].rid,
utils::media::get_rel_type(r.type), utils::media::get_rel_type(xlsx_drawing_rels_[i].type),
(r.is_internal ? std::wstring(L"../") + r.ref : r.ref), (xlsx_drawing_rels_[i].is_internal ? std::wstring(L"../") + xlsx_drawing_rels_[i].ref : xlsx_drawing_rels_[i].ref),
(r.is_internal ? L"" : L"External") (xlsx_drawing_rels_[i].is_internal ? L"" : L"External")
) )
); );
} }
else if (r.type == typeImage) else if (xlsx_drawing_rels_[i].type == typeImage)
{ {
Rels.add(relationship( Rels.add(relationship(
r.rid, xlsx_drawing_rels_[i].rid,
utils::media::get_rel_type(r.type), utils::media::get_rel_type(xlsx_drawing_rels_[i].type),
r.is_internal ? std::wstring(L"../") + r.ref : r.ref, xlsx_drawing_rels_[i].is_internal ? std::wstring(L"../") + xlsx_drawing_rels_[i].ref : xlsx_drawing_rels_[i].ref,
(r.is_internal ? L"" : L"External") (xlsx_drawing_rels_[i].is_internal ? L"" : L"External")
) )
); );
} }
else if (r.type == typeHyperlink) else if (xlsx_drawing_rels_[i].type == typeHyperlink)
{ {
Rels.add(relationship( Rels.add(relationship(
r.rid, xlsx_drawing_rels_[i].rid,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
r.ref, xlsx_drawing_rels_[i].ref,
L"External") L"External")
); );
} }
......
...@@ -66,6 +66,7 @@ xlsx_conversion_context::xlsx_conversion_context(odf_reader::odf_document * odfD ...@@ -66,6 +66,7 @@ xlsx_conversion_context::xlsx_conversion_context(odf_reader::odf_document * odfD
num_format_context_ (odf_document_->odf_context()), num_format_context_ (odf_document_->odf_context()),
xlsx_text_context_ (odf_document_->odf_context().styleContainer()), xlsx_text_context_ (odf_document_->odf_context().styleContainer()),
xlsx_table_context_ (this, xlsx_text_context_), xlsx_table_context_ (this, xlsx_text_context_),
math_context_ (true),
xlsx_style_ (this), xlsx_style_ (this),
maxDigitSize_ (std::pair<float,float>(-1.0, -1.0) ), maxDigitSize_ (std::pair<float,float>(-1.0, -1.0) ),
...@@ -100,13 +101,10 @@ void xlsx_conversion_context::start_chart(std::wstring name) ...@@ -100,13 +101,10 @@ void xlsx_conversion_context::start_chart(std::wstring name)
//добавляем новую форму для диаграммы //добавляем новую форму для диаграммы
//в ней будет информационная часть - и она пишется каждый раз в свою xml (их - по числу диаграмм) //в ней будет информационная часть - и она пишется каждый раз в свою xml (их - по числу диаграмм)
//этот контекст нужно передавать в файл //этот контекст нужно передавать в файл
} }
void xlsx_conversion_context::end_chart() void xlsx_conversion_context::end_chart()
{ {
//current_chart().set_drawing_link(current_sheet().get_drawing_link());
//излишняя инфа
} }
void xlsx_conversion_context::start_document() void xlsx_conversion_context::start_document()
...@@ -117,7 +115,7 @@ void xlsx_conversion_context::start_document() ...@@ -117,7 +115,7 @@ void xlsx_conversion_context::start_document()
instances.push_back(odfContext.styleContainer().style_default_by_type(odf_types::style_family::TableCell)); instances.push_back(odfContext.styleContainer().style_default_by_type(odf_types::style_family::TableCell));
instances.push_back(odfContext.styleContainer().style_by_name(L"Default",odf_types::style_family::TableCell,false)); instances.push_back(odfContext.styleContainer().style_by_name(L"Default",odf_types::style_family::TableCell,false));
odf_reader::text_format_properties_content textFormatProperties = calc_text_properties_content(instances); odf_reader::text_format_properties_content textFormatProperties = calc_text_properties_content(instances);
odf_reader::paragraph_format_properties parFormatProperties = calc_paragraph_properties_content(instances); odf_reader::paragraph_format_properties parFormatProperties = calc_paragraph_properties_content(instances);
odf_reader::style_table_cell_properties_attlist cellFormatProperties = calc_table_cell_properties(instances); odf_reader::style_table_cell_properties_attlist cellFormatProperties = calc_table_cell_properties(instances);
......
...@@ -83,7 +83,7 @@ public: ...@@ -83,7 +83,7 @@ public:
void start_chart(std::wstring name); void start_chart(std::wstring name);
void end_chart(); void end_chart();
void start_body(); void start_body();
void end_body(); void end_body();
...@@ -164,6 +164,7 @@ public: ...@@ -164,6 +164,7 @@ public:
xlsx_xml_worksheet & current_sheet(); xlsx_xml_worksheet & current_sheet();
oox_chart_context & current_chart(); oox_chart_context & current_chart();
math_context & get_math_context() { return math_context_; }
num_format_context & get_num_format_context() { return num_format_context_; } num_format_context & get_num_format_context() { return num_format_context_; }
size_t get_default_cell_style() const { return default_style_; } size_t get_default_cell_style() const { return default_style_; }
xlsx_defined_names & get_xlsx_defined_names() { return xlsx_defined_names_; } xlsx_defined_names & get_xlsx_defined_names() { return xlsx_defined_names_; }
...@@ -197,6 +198,7 @@ private: ...@@ -197,6 +198,7 @@ private:
xlsx_defined_names xlsx_defined_names_; xlsx_defined_names xlsx_defined_names_;
xlsx_table_context xlsx_table_context_; xlsx_table_context xlsx_table_context_;
xlsx_text_context xlsx_text_context_; xlsx_text_context xlsx_text_context_;
math_context math_context_;
xlsx_drawing_context_handle xlsx_drawing_context_handle_; xlsx_drawing_context_handle xlsx_drawing_context_handle_;
xlsx_comments_context_handle xlsx_comments_context_handle_; xlsx_comments_context_handle xlsx_comments_context_handle_;
......
...@@ -43,6 +43,11 @@ ...@@ -43,6 +43,11 @@
#include "office_binary_data.h" #include "office_binary_data.h"
#include "math_elements.h" #include "math_elements.h"
#include "math_elementaries.h"
#include "math_token_elements.h"
#include "math_table_elements.h"
#include "math_limit_elements.h"
#include "math_layout_elements.h"]
#include "text_elements.h" #include "text_elements.h"
#include "list.h" #include "list.h"
......
...@@ -78,28 +78,28 @@ typedef shared_ptr<const office_element>::Type office_element_ptr_const; ...@@ -78,28 +78,28 @@ typedef shared_ptr<const office_element>::Type office_element_ptr_const;
// Класс для конструирования чартов // Класс для конструирования чартов
using namespace chart; using namespace chart;
void chart_build::set_width(double valPt) void object_odf_context::set_width(double valPt)
{ {
width_pt_ = valPt; width_pt_ = valPt;
} }
void chart_build::set_height(double valPt) void object_odf_context::set_height(double valPt)
{ {
height_pt_ = valPt; height_pt_ = valPt;
} }
void chart_build::set_class(std::wstring const & val) void object_odf_context::set_class(std::wstring const & val)
{ {
str_class_ = val; str_class_ = val;
class_= get_series_class_type(val); class_= get_series_class_type(val);
} }
void chart_build::set_style_name(std::wstring const & val) void object_odf_context::set_style_name(std::wstring const & val)
{ {
style_name_ = val; style_name_ = val;
} }
void chart_build::start_axis(std::wstring const & dimensionName, std::wstring const & name, std::wstring const & styleName) void object_odf_context::start_axis(std::wstring const & dimensionName, std::wstring const & name, std::wstring const & styleName)
{ {
in_axis_ = true; in_axis_ = true;
...@@ -111,17 +111,17 @@ void chart_build::start_axis(std::wstring const & dimensionName, std::wstring co ...@@ -111,17 +111,17 @@ void chart_build::start_axis(std::wstring const & dimensionName, std::wstring co
axises_.push_back(ax); axises_.push_back(ax);
} }
void chart_build::end_axis() void object_odf_context::end_axis()
{ {
in_axis_ = false; in_axis_ = false;
} }
void chart_build::add_categories(std::wstring const & cellRange) void object_odf_context::add_categories(std::wstring const & cellRange)
{ {
categories_.push_back(cellRange); categories_.push_back(cellRange);
} }
void chart_build::add_grid(std::wstring const & className, std::wstring const & styleName) void object_odf_context::add_grid(std::wstring const & className, std::wstring const & styleName)
{ {
if (!axises_.empty()) if (!axises_.empty())
{ {
...@@ -137,7 +137,7 @@ void chart_build::add_grid(std::wstring const & className, std::wstring const & ...@@ -137,7 +137,7 @@ void chart_build::add_grid(std::wstring const & className, std::wstring const &
_CP_LOG << "[warning] unexpected chart:grid" << std::endl; _CP_LOG << "[warning] unexpected chart:grid" << std::endl;
} }
} }
void chart_build::add_series(std::wstring const & cellRangeAddress, void object_odf_context::add_series(std::wstring const & cellRangeAddress,
std::wstring const & labelCell, std::wstring const & labelCell,
class_type classType, class_type classType,
std::wstring const & attachedAxis, std::wstring const & attachedAxis,
...@@ -149,7 +149,7 @@ void chart_build::add_series(std::wstring const & cellRangeAddress, ...@@ -149,7 +149,7 @@ void chart_build::add_series(std::wstring const & cellRangeAddress,
series_.push_back(series(cellRangeAddress,labelCell, classType, attachedAxis, styleName)); series_.push_back(series(cellRangeAddress,labelCell, classType, attachedAxis, styleName));
} }
void chart_build::add_point(unsigned int rep) void object_odf_context::add_point(unsigned int rep)
{ {
if (!series_.empty()) if (!series_.empty())
{ {
...@@ -162,7 +162,7 @@ void chart_build::add_point(unsigned int rep) ...@@ -162,7 +162,7 @@ void chart_build::add_point(unsigned int rep)
} }
void chart_build::xlsx_convert(oox::xlsx_conversion_context & Context) void object_odf_context::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
if (object_type_ == 1) if (object_type_ == 1)
{ {
...@@ -179,10 +179,12 @@ void chart_build::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -179,10 +179,12 @@ void chart_build::xlsx_convert(oox::xlsx_conversion_context & Context)
} }
else if (object_type_ == 3 && office_math_) else if (object_type_ == 3 && office_math_)
{ {
office_math_->xlsx_convert(Context); Context.get_math_context().base_font_size_ = baseFontHeight_;
Context.get_math_context().start();
office_math_->oox_convert(Context.get_math_context());
} }
} }
void chart_build::docx_convert(oox::docx_conversion_context & Context) void object_odf_context::docx_convert(oox::docx_conversion_context & Context)
{ {
if (object_type_ == 1) if (object_type_ == 1)
{ {
...@@ -212,14 +214,10 @@ void chart_build::docx_convert(oox::docx_conversion_context & Context) ...@@ -212,14 +214,10 @@ void chart_build::docx_convert(oox::docx_conversion_context & Context)
bool pState = Context.get_paragraph_state(); bool pState = Context.get_paragraph_state();
Context.set_paragraph_state(false); Context.set_paragraph_state(false);
style_text_properties textProperty; Context.start_math_formula();
textProperty.content().style_font_name_ = L"Cambria Math"; Context.get_math_context().base_font_size_ = baseFontHeight_;
textProperty.content().fo_font_size_ = odf_types::length(baseFontHeight_, odf_types::length::pt); office_math_->oox_convert(Context.get_math_context());
Context.push_text_properties(&textProperty); Context.end_math_formula();
office_math_->docx_convert(Context);
Context.pop_text_properties();
Context.get_drawing_context().get_text_stream_frame() = temp_stream.str(); Context.get_drawing_context().get_text_stream_frame() = temp_stream.str();
...@@ -228,7 +226,7 @@ void chart_build::docx_convert(oox::docx_conversion_context & Context) ...@@ -228,7 +226,7 @@ void chart_build::docx_convert(oox::docx_conversion_context & Context)
Context.set_paragraph_state (pState); Context.set_paragraph_state (pState);
} }
} }
void chart_build::pptx_convert(oox::pptx_conversion_context & Context) void object_odf_context::pptx_convert(oox::pptx_conversion_context & Context)
{ {
if (object_type_ == 1) if (object_type_ == 1)
{ {
...@@ -246,10 +244,12 @@ void chart_build::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -246,10 +244,12 @@ void chart_build::pptx_convert(oox::pptx_conversion_context & Context)
} }
else if (object_type_ == 3 && office_math_) else if (object_type_ == 3 && office_math_)
{ {
office_math_->pptx_convert(Context); Context.get_math_context().base_font_size_ = baseFontHeight_;
Context.get_math_context().start();
office_math_->oox_convert(Context.get_math_context());
} }
} }
void chart_build::calc_cache_series(std::wstring adress, std::vector<std::wstring> & cash) void object_odf_context::calc_cache_series(std::wstring adress, std::vector<std::wstring> & cash)
{ {
if (adress.empty()) return; if (adress.empty()) return;
...@@ -282,7 +282,7 @@ struct axises_sort ...@@ -282,7 +282,7 @@ struct axises_sort
} }
}; };
void chart_build::oox_convert(oox::oox_chart_context & chart_context) void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
{ {
chart_context.set_title (title_); chart_context.set_title (title_);
chart_context.set_wall (wall_); chart_context.set_wall (wall_);
...@@ -438,9 +438,9 @@ void chart_build::oox_convert(oox::oox_chart_context & chart_context) ...@@ -438,9 +438,9 @@ void chart_build::oox_convert(oox::oox_chart_context & chart_context)
} }
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
process_build_chart::process_build_chart(chart_build & chartBuild, odf_read_context & context) : process_build_object::process_build_object(object_odf_context & object_odf, odf_read_context & context) :
stop_ (false) stop_ (false)
,chart_build_ (chartBuild) ,object_odf_context_(object_odf)
,styles_ (context.styleContainer()) ,styles_ (context.styleContainer())
,settings_ (context.Settings()) ,settings_ (context.Settings())
,draw_styles_ (context.drawStyles()) ,draw_styles_ (context.drawStyles())
...@@ -453,14 +453,14 @@ process_build_chart::process_build_chart(chart_build & chartBuild, odf_read_cont ...@@ -453,14 +453,14 @@ process_build_chart::process_build_chart(chart_build & chartBuild, odf_read_cont
{ {
try try
{ {
chart_build_.baseFontHeight_ = boost::lexical_cast<int>(sett->content_); object_odf_context_.baseFontHeight_ = boost::lexical_cast<int>(sett->content_);
} }
catch(...) catch(...)
{ {
} }
} }
} }
void process_build_chart::ApplyChartProperties(std::wstring style, std::vector<_property> & propertiesOut) void process_build_object::ApplyChartProperties(std::wstring style, std::vector<_property> & propertiesOut)
{ {
style_instance* styleInst = styles_.style_by_name(style, odf_types::style_family::Chart, false); style_instance* styleInst = styles_.style_by_name(style, odf_types::style_family::Chart, false);
if(styleInst) if(styleInst)
...@@ -496,7 +496,7 @@ void process_build_chart::ApplyChartProperties(std::wstring style, std::vector<_ ...@@ -496,7 +496,7 @@ void process_build_chart::ApplyChartProperties(std::wstring style, std::vector<_
} }
} }
} }
void process_build_chart::ApplyTextProperties(std::wstring style, std::vector<_property> & propertiesOut) void process_build_object::ApplyTextProperties(std::wstring style, std::vector<_property> & propertiesOut)
{ {
style_instance* styleInst = styles_.style_by_name(style, odf_types::style_family::Chart, false/*Context.process_headers_footers_*/); style_instance* styleInst = styles_.style_by_name(style, odf_types::style_family::Chart, false/*Context.process_headers_footers_*/);
if(styleInst) if(styleInst)
...@@ -505,7 +505,7 @@ void process_build_chart::ApplyTextProperties(std::wstring style, std::vector<_p ...@@ -505,7 +505,7 @@ void process_build_chart::ApplyTextProperties(std::wstring style, std::vector<_p
properties.apply_to(propertiesOut); properties.apply_to(propertiesOut);
} }
} }
void process_build_chart::ApplyGraphicProperties(std::wstring style, std::vector<_property> & propertiesOut, oox::_oox_fill & fill) void process_build_object::ApplyGraphicProperties(std::wstring style, std::vector<_property> & propertiesOut, oox::_oox_fill & fill)
{ {
style_instance* styleInst = styles_.style_by_name(style, odf_types::style_family::Chart, false/*Context.process_headers_footers_*/); style_instance* styleInst = styles_.style_by_name(style, odf_types::style_family::Chart, false/*Context.process_headers_footers_*/);
if(styleInst) if(styleInst)
...@@ -516,90 +516,90 @@ void process_build_chart::ApplyGraphicProperties(std::wstring style, std::vector ...@@ -516,90 +516,90 @@ void process_build_chart::ApplyGraphicProperties(std::wstring style, std::vector
if (fill.bitmap) if (fill.bitmap)
{ {
fill.bitmap->xlink_href_ = chart_build_.baseRef_ + FILE_SEPARATOR_STR + fill.bitmap->xlink_href_; fill.bitmap->xlink_href_ = object_odf_context_.baseRef_ + FILE_SEPARATOR_STR + fill.bitmap->xlink_href_;
} }
properties.apply_to(propertiesOut); properties.apply_to(propertiesOut);
} }
} }
/////////////////////////////////////// ///////////////////////////////////////
bool process_build_chart::visit_table(std::wstring const & name) bool process_build_object::visit_table(std::wstring const & name)
{ {
chart_build_.table_name_ = name; object_odf_context_.table_name_ = name;
return true; return true;
} }
void process_build_chart::visit_column(unsigned int repeated) void process_build_object::visit_column(unsigned int repeated)
{ {
chart_build_.columns_count_ += repeated; object_odf_context_.columns_count_ += repeated;
chart_build_.columns_.push_back(repeated); object_odf_context_.columns_.push_back(repeated);
} }
bool process_build_chart::visit_rows(unsigned int repeated) bool process_build_object::visit_rows(unsigned int repeated)
{ {
chart_build_.current_table_column_ = 0; object_odf_context_.current_table_column_ = 0;
chart_build_.current_table_row_ += repeated; object_odf_context_.current_table_row_ += repeated;
return true; return true;
} }
////////////////////////////////////////////////// //////////////////////////////////////////////////
void process_build_chart::on_not_impl(std::string const & message) void process_build_object::on_not_impl(std::string const & message)
{ {
_CP_LOG << L"[process_draw_chart visitor] : not impliment for \"" << utf8_to_utf16(message) << L"\"" << std::endl; _CP_LOG << L"[process_draw_chart visitor] : not impliment for \"" << utf8_to_utf16(message) << L"\"" << std::endl;
} }
////////////////////////////////////////////////// //////////////////////////////////////////////////
void process_build_chart::visit(const office_document_content& val) void process_build_object::visit(const office_document_content& val)
{ {
if (val.office_body_) if (val.office_body_)
val.office_body_->accept(*this); val.office_body_->accept(*this);
} }
void process_build_chart::visit(office_document_content& val) void process_build_object::visit(office_document_content& val)
{ {
if (val.office_body_) if (val.office_body_)
val.office_body_->accept(*this); val.office_body_->accept(*this);
} }
void process_build_chart::visit(office_body& val) void process_build_object::visit(office_body& val)
{ {
if (val.content_) if (val.content_)
val.content_->accept(*this); val.content_->accept(*this);
} }
void process_build_chart::visit(office_chart& val) void process_build_object::visit(office_chart& val)
{ {
ACCEPT_ALL_CONTENT_CONST(val.content_); ACCEPT_ALL_CONTENT_CONST(val.content_);
} }
void process_build_chart::visit(office_text& val) void process_build_object::visit(office_text& val)
{ {
chart_build_.object_type_ = 2; object_odf_context_.object_type_ = 2;
chart_build_.office_text_ = &val;//конвертация будет уровнем выше object_odf_context_.office_text_ = &val;//конвертация будет уровнем выше
} }
void process_build_chart::visit(office_math& val) void process_build_object::visit(office_math& val)
{ {
chart_build_.object_type_ = 3; //0;//временно замещающая картинка object_odf_context_.object_type_ = 3; //0;//временно замещающая картинка
chart_build_.office_math_ = &val;//конвертация будет уровнем выше object_odf_context_.office_math_ = &val;//конвертация будет уровнем выше
} }
void process_build_chart::visit(const chart_chart& val) void process_build_object::visit(const chart_chart& val)
{ {
chart_build_.object_type_ = 1; object_odf_context_.object_type_ = 1;
if (val.chart_chart_attlist_.common_draw_size_attlist_.svg_width_) if (val.chart_chart_attlist_.common_draw_size_attlist_.svg_width_)
{ {
chart_build_.set_width(val.chart_chart_attlist_.common_draw_size_attlist_.svg_width_->get_value_unit(length::pt)); object_odf_context_.set_width(val.chart_chart_attlist_.common_draw_size_attlist_.svg_width_->get_value_unit(length::pt));
} }
if (val.chart_chart_attlist_.common_draw_size_attlist_.svg_height_) if (val.chart_chart_attlist_.common_draw_size_attlist_.svg_height_)
{ {
chart_build_.set_height(val.chart_chart_attlist_.common_draw_size_attlist_.svg_height_->get_value_unit(length::pt)); object_odf_context_.set_height(val.chart_chart_attlist_.common_draw_size_attlist_.svg_height_->get_value_unit(length::pt));
} }
ApplyGraphicProperties (val.chart_chart_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.chart_graphic_properties_, chart_build_.chart_fill_); ApplyGraphicProperties (val.chart_chart_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.chart_graphic_properties_, object_odf_context_.chart_fill_);
chart_build_.set_class(val.chart_chart_attlist_.chart_class_); object_odf_context_.set_class(val.chart_chart_attlist_.chart_class_);
ACCEPT_ALL_CONTENT_CONST(val.content_); ACCEPT_ALL_CONTENT_CONST(val.content_);
} }
void process_build_chart::visit(const chart_title& val) void process_build_object::visit(const chart_title& val)
{ {
title t; title t;
...@@ -619,14 +619,14 @@ void process_build_chart::visit(const chart_title& val) ...@@ -619,14 +619,14 @@ void process_build_chart::visit(const chart_title& val)
} }
t.bEnabled = true; t.bEnabled = true;
if (chart_build_.in_axis_) if (object_odf_context_.in_axis_)
chart_build_.axises_.back().title_ = t; object_odf_context_.axises_.back().title_ = t;
else else
chart_build_.title_ = t; object_odf_context_.title_ = t;
} }
void process_build_chart::visit(const chart_subtitle & val) void process_build_object::visit(const chart_subtitle & val)
{ {
title t; title t;
std::wstringstream v; std::wstringstream v;
...@@ -639,42 +639,42 @@ void process_build_chart::visit(const chart_subtitle & val) ...@@ -639,42 +639,42 @@ void process_build_chart::visit(const chart_subtitle & val)
t.pos_y = val.chart_title_attlist_.common_draw_position_attlist_.svg_y_->get_value_unit(length::pt); t.pos_y = val.chart_title_attlist_.common_draw_position_attlist_.svg_y_->get_value_unit(length::pt);
} }
t.bEnabled = true; t.bEnabled = true;
chart_build_.sub_title_ = t; object_odf_context_.sub_title_ = t;
} }
void process_build_chart::visit(const chart_footer& val) void process_build_object::visit(const chart_footer& val)
{ {
chart_build_.footer_.bEnabled = true; object_odf_context_.footer_.bEnabled = true;
ApplyChartProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.footer_.properties_); ApplyChartProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.footer_.properties_);
ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.footer_.graphic_properties_, chart_build_.footer_.fill_); ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.footer_.graphic_properties_, object_odf_context_.footer_.fill_);
ApplyTextProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.footer_.text_properties_); ApplyTextProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.footer_.text_properties_);
} }
void process_build_chart::visit(const chart_legend& val) void process_build_object::visit(const chart_legend& val)
{ {
chart_build_.legend_.bEnabled = true; object_odf_context_.legend_.bEnabled = true;
ApplyChartProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.legend_.properties_); ApplyChartProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.legend_.properties_);
ApplyGraphicProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.legend_.graphic_properties_,chart_build_.legend_.fill_); ApplyGraphicProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.legend_.graphic_properties_,object_odf_context_.legend_.fill_);
ApplyTextProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.legend_.text_properties_); ApplyTextProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.legend_.text_properties_);
} }
void process_build_chart::visit(const chart_plot_area& val) void process_build_object::visit(const chart_plot_area& val)
{ {
ACCEPT_ALL_CONTENT_CONST(val.content_); ACCEPT_ALL_CONTENT_CONST(val.content_);
chart_build_.plot_area_.cell_range_address_ = val.chart_plot_area_attlist_.table_cell_range_address_.get_value_or(L""); object_odf_context_.plot_area_.cell_range_address_ = val.chart_plot_area_attlist_.table_cell_range_address_.get_value_or(L"");
ApplyChartProperties (val.chart_plot_area_attlist_.common_attlist_.chart_style_name_.get_value_or(L""),chart_build_.plot_area_.properties_); ApplyChartProperties (val.chart_plot_area_attlist_.common_attlist_.chart_style_name_.get_value_or(L""),object_odf_context_.plot_area_.properties_);
ApplyGraphicProperties (val.chart_plot_area_attlist_.common_attlist_.chart_style_name_.get_value_or(L""),chart_build_.plot_area_.graphic_properties_, chart_build_.plot_area_.fill_); ApplyGraphicProperties (val.chart_plot_area_attlist_.common_attlist_.chart_style_name_.get_value_or(L""),object_odf_context_.plot_area_.graphic_properties_, object_odf_context_.plot_area_.fill_);
ApplyTextProperties (val.chart_plot_area_attlist_.common_attlist_.chart_style_name_.get_value_or(L""),chart_build_.plot_area_.text_properties_); ApplyTextProperties (val.chart_plot_area_attlist_.common_attlist_.chart_style_name_.get_value_or(L""),object_odf_context_.plot_area_.text_properties_);
} }
void process_build_chart::visit(const chart_axis& val) void process_build_object::visit(const chart_axis& val)
{ {
chart_build_.start_axis(val.chart_axis_attlist_.chart_dimension_.get_value_or(L""), object_odf_context_.start_axis(val.chart_axis_attlist_.chart_dimension_.get_value_or(L""),
val.chart_axis_attlist_.chart_name_.get_value_or(L""), val.chart_axis_attlist_.chart_name_.get_value_or(L""),
val.chart_axis_attlist_.common_attlist_.chart_style_name_.get_value_or(L"")); val.chart_axis_attlist_.common_attlist_.chart_style_name_.get_value_or(L""));
...@@ -682,20 +682,20 @@ void process_build_chart::visit(const chart_axis& val) ...@@ -682,20 +682,20 @@ void process_build_chart::visit(const chart_axis& val)
std::wstring style_name = val.chart_axis_attlist_.common_attlist_.chart_style_name_.get_value_or(L""); std::wstring style_name = val.chart_axis_attlist_.common_attlist_.chart_style_name_.get_value_or(L"");
ApplyChartProperties (style_name, chart_build_.axises_.back().properties_); ApplyChartProperties (style_name, object_odf_context_.axises_.back().properties_);
ApplyGraphicProperties (style_name, chart_build_.axises_.back().graphic_properties_, chart_build_.axises_.back().fill_); ApplyGraphicProperties (style_name, object_odf_context_.axises_.back().graphic_properties_, object_odf_context_.axises_.back().fill_);
ApplyTextProperties (style_name, chart_build_.axises_.back().text_properties_); ApplyTextProperties (style_name, object_odf_context_.axises_.back().text_properties_);
chart_build_.end_axis(); object_odf_context_.end_axis();
} }
void process_build_chart::visit(const chart_series& val) void process_build_object::visit(const chart_series& val)
{ {
const chart_series_attlist & att = val.chart_series_attlist_; const chart_series_attlist & att = val.chart_series_attlist_;
chart::class_type chartClass = get_series_class_type(att.chart_class_.get_value_or(chart_build_.str_class_)); chart::class_type chartClass = get_series_class_type(att.chart_class_.get_value_or(object_odf_context_.str_class_));
chart_build_.add_series( object_odf_context_.add_series(
att.chart_values_cell_range_address_.get_value_or(L""), att.chart_values_cell_range_address_.get_value_or(L""),
att.chart_label_cell_address_.get_value_or(L""), att.chart_label_cell_address_.get_value_or(L""),
chartClass, chartClass,
...@@ -705,144 +705,144 @@ void process_build_chart::visit(const chart_series& val) ...@@ -705,144 +705,144 @@ void process_build_chart::visit(const chart_series& val)
ACCEPT_ALL_CONTENT_CONST(val.content_); ACCEPT_ALL_CONTENT_CONST(val.content_);
ApplyChartProperties (att.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.series_.back().properties_); ApplyChartProperties (att.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().properties_);
ApplyGraphicProperties (att.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.series_.back().graphic_properties_,chart_build_.series_.back().fill_); ApplyGraphicProperties (att.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().graphic_properties_,object_odf_context_.series_.back().fill_);
ApplyTextProperties (att.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.series_.back().text_properties_); ApplyTextProperties (att.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().text_properties_);
} }
void process_build_chart::visit(const chart_domain& val) void process_build_object::visit(const chart_domain& val)
{ {
if (chart_build_.domain_cell_range_adress_.empty()) if (object_odf_context_.domain_cell_range_adress_.empty())
chart_build_.domain_cell_range_adress_ = val.table_cell_range_address_.get_value_or(L""); object_odf_context_.domain_cell_range_adress_ = val.table_cell_range_address_.get_value_or(L"");
else else
chart_build_.domain_cell_range_adress2_ = val.table_cell_range_address_.get_value_or(L""); object_odf_context_.domain_cell_range_adress2_ = val.table_cell_range_address_.get_value_or(L"");
} }
void process_build_chart::visit(const chart_grid& val) void process_build_object::visit(const chart_grid& val)
{ {
chart_build_.add_grid(val.chart_grid_attlist_.chart_class_.get_value_or(L""), object_odf_context_.add_grid(val.chart_grid_attlist_.chart_class_.get_value_or(L""),
val.chart_grid_attlist_.common_attlist_.chart_style_name_.get_value_or(L"") ); val.chart_grid_attlist_.common_attlist_.chart_style_name_.get_value_or(L"") );
oox::_oox_fill fill; oox::_oox_fill fill;
ApplyGraphicProperties (val.chart_grid_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), (chart_build_.axises_.back()).grids_.back().graphic_properties_, fill); ApplyGraphicProperties (val.chart_grid_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), (object_odf_context_.axises_.back()).grids_.back().graphic_properties_, fill);
} }
void process_build_chart::visit(const chart_wall& val) void process_build_object::visit(const chart_wall& val)
{ {
chart_build_.wall_.bEnabled = true; object_odf_context_.wall_.bEnabled = true;
ApplyChartProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.wall_.properties_); ApplyChartProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.wall_.properties_);
ApplyGraphicProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.wall_.graphic_properties_,chart_build_.wall_.fill_); ApplyGraphicProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.wall_.graphic_properties_,object_odf_context_.wall_.fill_);
ApplyTextProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.wall_.text_properties_); ApplyTextProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.wall_.text_properties_);
} }
void process_build_chart::visit(const chart_floor& val) void process_build_object::visit(const chart_floor& val)
{ {
chart_build_.floor_.bEnabled = true; object_odf_context_.floor_.bEnabled = true;
ApplyChartProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.floor_.properties_); ApplyChartProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.floor_.properties_);
ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.floor_.graphic_properties_,chart_build_.floor_.fill_); ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.floor_.graphic_properties_,object_odf_context_.floor_.fill_);
ApplyTextProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.floor_.text_properties_); ApplyTextProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.floor_.text_properties_);
} }
void process_build_chart::visit(const chart_data_point & val) void process_build_object::visit(const chart_data_point & val)
{ {
chart_build_.add_point( val.chart_data_point_attlist_.chart_repeated_.get_value_or(1)); object_odf_context_.add_point( val.chart_data_point_attlist_.chart_repeated_.get_value_or(1));
if (val.chart_data_point_attlist_.common_attlist_.chart_style_name_) if (val.chart_data_point_attlist_.common_attlist_.chart_style_name_)
{ {
chart_build_.series_.back().points_.back().bEnabled = true; object_odf_context_.series_.back().points_.back().bEnabled = true;
std::wstring style_name = val.chart_data_point_attlist_.common_attlist_.chart_style_name_.get_value_or(L""); std::wstring style_name = val.chart_data_point_attlist_.common_attlist_.chart_style_name_.get_value_or(L"");
ApplyGraphicProperties (style_name, chart_build_.series_.back().points_.back().graphic_properties_, ApplyGraphicProperties (style_name, object_odf_context_.series_.back().points_.back().graphic_properties_,
chart_build_.series_.back().points_.back().fill_); object_odf_context_.series_.back().points_.back().fill_);
ApplyTextProperties (style_name, chart_build_.series_.back().points_.back().text_properties_); ApplyTextProperties (style_name, object_odf_context_.series_.back().points_.back().text_properties_);
} }
} }
void process_build_chart::visit(const chart_mean_value & val) void process_build_object::visit(const chart_mean_value & val)
{ {
ApplyChartProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.series_.back().mean_value_.properties_); ApplyChartProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().mean_value_.properties_);
ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.series_.back().mean_value_.graphic_properties_, chart_build_.series_.back().mean_value_.fill_); ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().mean_value_.graphic_properties_, object_odf_context_.series_.back().mean_value_.fill_);
} }
void process_build_chart::visit(const chart_error_indicator & val) void process_build_object::visit(const chart_error_indicator & val)
{ {
ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.series_.back().error_indicator_.graphic_properties_,chart_build_.series_.back().error_indicator_.fill_ ); ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().error_indicator_.graphic_properties_,object_odf_context_.series_.back().error_indicator_.fill_ );
} }
void process_build_chart::visit(const chart_regression_curve & val) void process_build_object::visit(const chart_regression_curve & val)
{ {
oox::_oox_fill fill; oox::_oox_fill fill;
ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.series_.back().regression_curve_.line_properties_, fill); ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().regression_curve_.line_properties_, fill);
if (val.chart_equation_) if (val.chart_equation_)
{ {
chart_build_.series_.back().regression_curve_.bEquation = true; object_odf_context_.series_.back().regression_curve_.bEquation = true;
val.chart_equation_->accept(*this); val.chart_equation_->accept(*this);
} }
} }
void process_build_chart::visit(const chart_equation & val) void process_build_object::visit(const chart_equation & val)
{ {
if (chart_build_.series_.back().regression_curve_.bEquation == false)return; if (object_odf_context_.series_.back().regression_curve_.bEquation == false)return;
if (val.display_r_square_) if (val.display_r_square_)
chart_build_.series_.back().regression_curve_.bREquation = val.display_r_square_.get(); object_odf_context_.series_.back().regression_curve_.bREquation = val.display_r_square_.get();
ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.series_.back().regression_curve_.equation_properties_.graphic_properties_,chart_build_.series_.back().regression_curve_.equation_properties_.fill_); ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().regression_curve_.equation_properties_.graphic_properties_,object_odf_context_.series_.back().regression_curve_.equation_properties_.fill_);
ApplyTextProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), chart_build_.series_.back().regression_curve_.equation_properties_.text_properties_); ApplyTextProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().regression_curve_.equation_properties_.text_properties_);
} }
void process_build_chart::visit(const chart_categories& val) void process_build_object::visit(const chart_categories& val)
{ {
if (chart_build_.in_axis_) if (object_odf_context_.in_axis_)
{ {
chart_build_.axises_.back().type_ = 1; object_odf_context_.axises_.back().type_ = 1;
chart_build_.axises_.back().bCategories_ = true; object_odf_context_.axises_.back().bCategories_ = true;
} }
if (val.table_cell_range_address_) if (val.table_cell_range_address_)
chart_build_.add_categories(*val.table_cell_range_address_); object_odf_context_.add_categories(*val.table_cell_range_address_);
} }
void process_build_chart::visit(const table_table& val) void process_build_object::visit(const table_table& val)
{ {
ACCEPT_ALL_CONTENT_CONST(val.table_columns_and_groups_.content_); ACCEPT_ALL_CONTENT_CONST(val.table_columns_and_groups_.content_);
ACCEPT_ALL_CONTENT_CONST(val.table_rows_and_groups_.content_); ACCEPT_ALL_CONTENT_CONST(val.table_rows_and_groups_.content_);
} }
void process_build_chart::visit(const table_table_rows& val) void process_build_object::visit(const table_table_rows& val)
{ {
ACCEPT_ALL_CONTENT_CONST(val.table_table_row_); ACCEPT_ALL_CONTENT_CONST(val.table_table_row_);
} }
void process_build_chart::visit(table_table_rows& val) void process_build_object::visit(table_table_rows& val)
{ {
ACCEPT_ALL_CONTENT_CONST(val.table_table_row_); ACCEPT_ALL_CONTENT_CONST(val.table_table_row_);
} }
void process_build_chart::visit(const table_table_row & val) void process_build_object::visit(const table_table_row & val)
{ {
unsigned int repeated = val.table_table_row_attlist_.table_number_rows_repeated_; unsigned int repeated = val.table_table_row_attlist_.table_number_rows_repeated_;
ACCEPT_ALL_CONTENT_CONST(val.content_); ACCEPT_ALL_CONTENT_CONST(val.content_);
visit_rows(repeated); visit_rows(repeated);
} }
void process_build_chart::visit(const table_table_column& val) void process_build_object::visit(const table_table_column& val)
{ {
const unsigned int columnsRepeated = val.table_table_column_attlist_.table_number_columns_repeated_; const unsigned int columnsRepeated = val.table_table_column_attlist_.table_number_columns_repeated_;
visit_column(columnsRepeated); visit_column(columnsRepeated);
} }
void process_build_chart::visit(const table_table_row_group& val) void process_build_object::visit(const table_table_row_group& val)
{ {
ACCEPT_ALL_CONTENT_CONST(val.table_rows_and_groups_.content_); ACCEPT_ALL_CONTENT_CONST(val.table_rows_and_groups_.content_);
} }
void process_build_chart::visit(const table_table_column_group& val) void process_build_object::visit(const table_table_column_group& val)
{ {
ACCEPT_ALL_CONTENT_CONST(val.table_columns_and_groups_.content_); ACCEPT_ALL_CONTENT_CONST(val.table_columns_and_groups_.content_);
} }
void process_build_chart::visit(table_table_columns& val) void process_build_object::visit(table_table_columns& val)
{ {
ACCEPT_ALL_CONTENT_CONST(val.table_table_column_); ACCEPT_ALL_CONTENT_CONST(val.table_table_column_);
} }
void process_build_chart::visit(const table_columns_no_group& val) void process_build_object::visit(const table_columns_no_group& val)
{ {
if (val.table_columns_1_.table_table_columns_) if (val.table_columns_1_.table_table_columns_)
val.table_columns_1_.table_table_columns_->accept(*this); val.table_columns_1_.table_table_columns_->accept(*this);
...@@ -857,7 +857,7 @@ void process_build_chart::visit(const table_columns_no_group& val) ...@@ -857,7 +857,7 @@ void process_build_chart::visit(const table_columns_no_group& val)
ACCEPT_ALL_CONTENT_CONST(val.table_columns_2_.table_table_column_); ACCEPT_ALL_CONTENT_CONST(val.table_columns_2_.table_table_column_);
} }
void process_build_chart::visit(const table_rows_no_group& val) void process_build_object::visit(const table_rows_no_group& val)
{ {
if (val.table_rows_1_.table_table_rows_) if (val.table_rows_1_.table_table_rows_)
val.table_rows_1_.table_table_rows_->accept(*this); val.table_rows_1_.table_table_rows_->accept(*this);
...@@ -872,7 +872,7 @@ void process_build_chart::visit(const table_rows_no_group& val) ...@@ -872,7 +872,7 @@ void process_build_chart::visit(const table_rows_no_group& val)
else else
ACCEPT_ALL_CONTENT_CONST(val.table_rows_2_.table_table_row_); ACCEPT_ALL_CONTENT_CONST(val.table_rows_2_.table_table_row_);
} }
void process_build_chart::visit(const table_table_cell& val) void process_build_object::visit(const table_table_cell& val)
{ {
const table_table_cell_attlist & attlist = val.table_table_cell_attlist_; const table_table_cell_attlist & attlist = val.table_table_cell_attlist_;
...@@ -895,28 +895,28 @@ void process_build_chart::visit(const table_table_cell& val) ...@@ -895,28 +895,28 @@ void process_build_chart::visit(const table_table_cell& val)
if (cell_cash.empty()) if (cell_cash.empty())
cell_cash = cell_val; cell_cash = cell_val;
chart_build::_cell cell_={chart_build_.current_table_column_, chart_build_.current_table_row_, cell_cash}; object_odf_context::_cell cell_={object_odf_context_.current_table_column_, object_odf_context_.current_table_row_, cell_cash};
chart_build_.cash_values.push_back(cell_); object_odf_context_.cash_values.push_back(cell_);
chart_build_.current_table_column_+=repeated; object_odf_context_.current_table_column_+=repeated;
} }
void process_build_chart::visit(const table_covered_table_cell& val) void process_build_object::visit(const table_covered_table_cell& val)
{ {
unsigned int repeated = val.table_table_cell_attlist_.table_number_columns_repeated_; unsigned int repeated = val.table_table_cell_attlist_.table_number_columns_repeated_;
if ( repeated <2) if ( repeated <2)
return; return;
} }
void process_build_chart::visit(table_table_header_columns& val) void process_build_object::visit(table_table_header_columns& val)
{ {
ACCEPT_ALL_CONTENT_CONST(val.table_table_column_); ACCEPT_ALL_CONTENT_CONST(val.table_table_column_);
} }
void process_build_chart::visit(const table_table_header_rows& val) void process_build_object::visit(const table_table_header_rows& val)
{ {
ACCEPT_ALL_CONTENT_CONST(val.table_table_row_); ACCEPT_ALL_CONTENT_CONST(val.table_table_row_);
} }
void process_build_chart::visit(table_table_header_rows& val) void process_build_object::visit(table_table_header_rows& val)
{ {
ACCEPT_ALL_CONTENT_CONST(val.table_table_row_); ACCEPT_ALL_CONTENT_CONST(val.table_table_row_);
} }
......
...@@ -96,7 +96,7 @@ chart::class_type static get_series_class_type(std::wstring const & str) ...@@ -96,7 +96,7 @@ chart::class_type static get_series_class_type(std::wstring const & str)
} }
class chart_build class object_odf_context
{ {
public: public:
struct _cell struct _cell
...@@ -106,20 +106,20 @@ public: ...@@ -106,20 +106,20 @@ public:
std::wstring val; std::wstring val;
}; };
chart_build(std::wstring ref) : object_odf_context(std::wstring ref)
width_pt_(0), :
height_pt_(0), width_pt_ (0),
in_axis_(false), height_pt_ (0),
current_table_column_(0), in_axis_ (false),
current_table_row_(0), current_table_column_ (0),
columns_spanned_num_(0), current_table_row_ (0),
//target_table_(0/*targetTable*/), columns_spanned_num_ (0),
columns_count_(0), columns_count_ (0),
object_type_(0), object_type_ (0),
office_text_(NULL), office_text_ (NULL),
office_math_(NULL), office_math_ (NULL),
baseRef_(ref), baseRef_ (ref),
baseFontHeight_(12) baseFontHeight_ (12)
{ {
} }
...@@ -150,23 +150,23 @@ public: ...@@ -150,23 +150,23 @@ public:
void xlsx_convert (oox::xlsx_conversion_context & Context); void xlsx_convert (oox::xlsx_conversion_context & Context);
void docx_convert (oox::docx_conversion_context & Context); void docx_convert (oox::docx_conversion_context & Context);
void oox_convert (oox::oox_chart_context & chart);
void pptx_convert (oox::pptx_conversion_context & Context); void pptx_convert (oox::pptx_conversion_context & Context);
void oox_convert (oox::oox_chart_context & chart);
double width_pt_; double width_pt_;
double height_pt_; double height_pt_;
int object_type_; int object_type_;
office_text *office_text_; office_text *office_text_;
office_math *office_math_; office_math *office_math_;
int baseFontHeight_; int baseFontHeight_;
std::wstring baseRef_; std::wstring baseRef_;
//--------------------------------------------------------------- //---------------------------------------------------------------
std::wstring str_class_; std::wstring str_class_;
chart::class_type class_; chart::class_type class_;
std::wstring style_name_; std::wstring style_name_;
std::wstring name_; std::wstring name_;
bool in_axis_; bool in_axis_;
std::vector<chart::axis> axises_; std::vector<chart::axis> axises_;
...@@ -192,7 +192,7 @@ public: ...@@ -192,7 +192,7 @@ public:
std::vector<_property> chart_graphic_properties_; std::vector<_property> chart_graphic_properties_;
oox::_oox_fill chart_fill_; oox::_oox_fill chart_fill_;
std::vector<_cell> cash_values; std::vector<_cell> cash_values;
//--------------------------------------- //---------------------------------------
std::wstring target_table_; std::wstring target_table_;
...@@ -213,61 +213,62 @@ public: ...@@ -213,61 +213,62 @@ public:
}; };
// Класс для обхода всех элеменов office:object для построения диаграммы // Класс для обхода всех элеменов office:object для построения диаграммы
class process_build_chart : public base_visitor, class process_build_object
public const_visitor<office_document_content>, : public base_visitor,
public visitor<office_document_content>, public const_visitor<office_document_content>,
public visitor<office_document_content>,
public visitor<office_body>,
public visitor<office_chart>, public visitor<office_body>,
public visitor<office_text>, public visitor<office_chart>,
public visitor<office_math>, public visitor<office_text>,
public visitor<office_math>,
public const_visitor<chart_chart>,
public const_visitor<chart_chart>,
public const_visitor<chart_title>,
public const_visitor<chart_subtitle>, public const_visitor<chart_title>,
public const_visitor<chart_footer>, public const_visitor<chart_subtitle>,
public const_visitor<chart_legend>, public const_visitor<chart_footer>,
public const_visitor<chart_legend>,
public const_visitor<chart_plot_area>,
public const_visitor<chart_plot_area>,
public const_visitor<chart_axis>,
public const_visitor<chart_categories>, public const_visitor<chart_axis>,
public const_visitor<chart_grid>, public const_visitor<chart_categories>,
public const_visitor<chart_grid>,
public const_visitor<chart_series>,
public const_visitor<chart_domain>, public const_visitor<chart_series>,
public const_visitor<chart_data_point>, public const_visitor<chart_domain>,
public const_visitor<chart_mean_value>, public const_visitor<chart_data_point>,
public const_visitor<chart_regression_curve>, public const_visitor<chart_mean_value>,
public const_visitor<chart_equation>, public const_visitor<chart_regression_curve>,
public const_visitor<chart_error_indicator>, public const_visitor<chart_equation>,
public const_visitor<chart_wall>, public const_visitor<chart_error_indicator>,
public const_visitor<chart_floor>, public const_visitor<chart_wall>,
public const_visitor<chart_floor>,
public const_visitor<table_table>,
public const_visitor<table_table>,
public const_visitor<table_table_row_group>,
public const_visitor<table_rows_no_group>, public const_visitor<table_table_row_group>,
public const_visitor<table_table_header_rows>, public const_visitor<table_rows_no_group>,
public const_visitor<table_table_rows>, public const_visitor<table_table_header_rows>,
public const_visitor<table_table_row>, public const_visitor<table_table_rows>,
public const_visitor<table_table_row>,
public visitor<table_table_rows>,
public visitor<table_table_header_rows>, public visitor<table_table_rows>,
public visitor<table_table_header_rows>,
public const_visitor<table_table_cell>,
public const_visitor<table_covered_table_cell>, public const_visitor<table_table_cell>,
public const_visitor<table_covered_table_cell>,
public const_visitor<table_table_column_group>,
public visitor<table_table_header_columns>, public const_visitor<table_table_column_group>,
public visitor<table_table_columns>, public visitor<table_table_header_columns>,
public const_visitor<table_table_column>, public visitor<table_table_columns>,
public const_visitor<table_columns_no_group> public const_visitor<table_table_column>,
public const_visitor<table_columns_no_group>
{ {
public: public:
process_build_chart(chart_build & chartBuild, odf_read_context & context); process_build_object(object_odf_context & object_context, odf_read_context & context);
private: private:
void ApplyChartProperties(std::wstring style,std::vector<_property> & propertiesOut); void ApplyChartProperties(std::wstring style,std::vector<_property> & propertiesOut);
...@@ -331,7 +332,7 @@ public: ...@@ -331,7 +332,7 @@ public:
private: private:
bool stop_; bool stop_;
chart_build & chart_build_; object_odf_context & object_odf_context_;
styles_container & styles_; styles_container & styles_;
......
...@@ -1421,14 +1421,14 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context) ...@@ -1421,14 +1421,14 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
//функциональная часть //функциональная часть
office_element *contentSubDoc = objectSubDoc.get_impl()->get_content(); office_element *contentSubDoc = objectSubDoc.get_impl()->get_content();
draw_frame *frame = NULL; draw_frame *frame = NULL;
chart_build objectBuild(href); object_odf_context objectBuild(href);
//if (!contentSubDoc)//Diagramma.odt - кривые ссылки на объекты //if (!contentSubDoc)//Diagramma.odt - кривые ссылки на объекты
// return; // return;
if (contentSubDoc) if (contentSubDoc)
{ {
process_build_chart process_build_object_(objectBuild, objectSubDoc.odf_context()); process_build_object process_build_object_(objectBuild, objectSubDoc.odf_context());
contentSubDoc->accept(process_build_object_); contentSubDoc->accept(process_build_object_);
objectBuild.docx_convert(Context); objectBuild.docx_convert(Context);
...@@ -1491,6 +1491,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context) ...@@ -1491,6 +1491,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
if (in_frame) if (in_frame)
{ {
drawing.additional.push_back(_property(L"fit-to-size", true));
drawing.additional.push_back(_property(L"text-content", std::wstring(L"<w:p><m:oMathPara><m:oMathParaPr/>") + drawing.additional.push_back(_property(L"text-content", std::wstring(L"<w:p><m:oMathPara><m:oMathParaPr/>") +
content + std::wstring(L"</m:oMathPara></w:p>"))); content + std::wstring(L"</m:oMathPara></w:p>")));
Context.set_run_state(false); Context.set_run_state(false);
......
...@@ -291,7 +291,7 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -291,7 +291,7 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
//пример RemanejamentoOrcamentario.ods //пример RemanejamentoOrcamentario.ods
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
//функциональная часть //функциональная часть
const office_element *contentSubDoc = objectSubDoc.get_impl()->get_content(); office_element *contentSubDoc = objectSubDoc.get_impl()->get_content();
if (!contentSubDoc) if (!contentSubDoc)
{ {
//здесь другой формат xml (не Open Office) //здесь другой формат xml (не Open Office)
...@@ -301,9 +301,9 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -301,9 +301,9 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
} }
chart_build objectBuild(href); object_odf_context objectBuild(href);
process_build_chart process_build_object_(objectBuild, objectSubDoc.odf_context()); process_build_object process_build_object_(objectBuild, objectSubDoc.odf_context());
contentSubDoc->accept(process_build_object_); contentSubDoc->accept(process_build_object_);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -336,6 +336,28 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -336,6 +336,28 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
} }
Context.get_slide_context().end_shape(); Context.get_slide_context().end_shape();
} }
else if (objectBuild.object_type_ == 3) //мат формулы
{
Context.get_slide_context().start_shape(2);
objectBuild.pptx_convert(Context);
std::wstring math_content = Context.get_math_context().end();
if (!math_content.empty())
{
std::wstring text_content = L"<a:p><a14:m xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\">";
text_content += L"<m:oMathPara xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\">";
text_content += L"<m:oMathParaPr/>";
text_content += L"<m:oMath xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\">";
text_content += math_content;
text_content += L"</m:oMath></m:oMathPara></a14:m></a:p>";
Context.get_slide_context().set_property(_property(L"fit-to-size", true));
Context.get_slide_context().set_property(_property(L"text-content", text_content));
}
Context.get_slide_context().end_shape();
}
else else
{ {
//временно - замещающая картинка(если она конечно присутствует) //временно - замещающая картинка(если она конечно присутствует)
......
...@@ -253,7 +253,7 @@ void draw_text_box::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -253,7 +253,7 @@ void draw_text_box::xlsx_convert(oox::xlsx_conversion_context & Context)
void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
try { try {
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L""); const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
odf_reader::odf_document * odf_reader = Context.root(); odf_reader::odf_document * odf_reader = Context.root();
...@@ -268,18 +268,18 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -268,18 +268,18 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
//в отдельных embd объектах чаще всего диаграммы... но МОГУТ быть и обычные объекты подтипа frame!!! пример RemanejamentoOrcamentario.ods //в отдельных embd объектах чаще всего диаграммы... но МОГУТ быть и обычные объекты подтипа frame!!! пример RemanejamentoOrcamentario.ods
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
//функциональная часть //функциональная часть
const office_element *contentSubDoc = objectSubDoc.get_impl()->get_content(); office_element *contentSubDoc = objectSubDoc.get_impl()->get_content();
chart_build objectBuild(href); object_odf_context objectBuild(href);
if (contentSubDoc) if (contentSubDoc)
{ {
process_build_chart process_build_object_(objectBuild, objectSubDoc.odf_context()); process_build_object process_build_object_(objectBuild, objectSubDoc.odf_context());
contentSubDoc->accept(process_build_object_); contentSubDoc->accept(process_build_object_);
} }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//отображательная часть //отображательная часть
if (objectBuild.object_type_ == 1)//диаграмма if (objectBuild.object_type_ == 1) //диаграмма
{ {
const std::wstring href_draw = common_xlink_attlist_.href_.get_value_or(L""); const std::wstring href_draw = common_xlink_attlist_.href_.get_value_or(L"");
objectBuild.xlsx_convert(Context); objectBuild.xlsx_convert(Context);
...@@ -287,7 +287,7 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -287,7 +287,7 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
Context.get_drawing_context().start_chart(href_draw); // в рисовательной части только место объекта, рамочки ... и релсы Context.get_drawing_context().start_chart(href_draw); // в рисовательной части только место объекта, рамочки ... и релсы
Context.get_drawing_context().end_chart(); Context.get_drawing_context().end_chart();
} }
else if (objectBuild.object_type_ == 2)//текст (odt text) else if (objectBuild.object_type_ == 2) //текст (odt text)
{ {
Context.get_drawing_context().start_shape(2); Context.get_drawing_context().start_shape(2);
Context.get_text_context().start_drawing_content(); Context.get_text_context().start_drawing_content();
...@@ -297,15 +297,37 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -297,15 +297,37 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
objectBuild.xlsx_convert(Context); objectBuild.xlsx_convert(Context);
std::wstring text_content_ = Context.get_text_context().end_drawing_content(); std::wstring text_content = Context.get_text_context().end_drawing_content();
Context.get_text_context().set_local_styles_container(NULL);//вытираем вручную ... Context.get_text_context().set_local_styles_container(NULL);//вытираем вручную ...
if (text_content_.length()>0) if (!text_content.empty())
{ {
Context.get_drawing_context().set_property(_property(L"text-content",text_content_)); Context.get_drawing_context().set_property(_property(L"text-content", text_content));
} }
Context.get_drawing_context().end_shape(); Context.get_drawing_context().end_shape();
} }
else if (objectBuild.object_type_ == 3) //мат формулы
{
Context.get_drawing_context().start_shape(2);
objectBuild.xlsx_convert(Context);
std::wstring math_content = Context.get_math_context().end();
if (!math_content.empty())
{
std::wstring text_content = L"<a:p><a14:m xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\">";
text_content += L"<m:oMathPara xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\">";
text_content += L"<m:oMathParaPr/>";
text_content += L"<m:oMath xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\">";
text_content += math_content;
text_content += L"</m:oMath></m:oMathPara></a14:m></a:p>";
Context.get_drawing_context().set_property(_property(L"fit-to-size", true));
Context.get_drawing_context().set_property(_property(L"text-content", text_content));
}
Context.get_drawing_context().end_shape();
}
else else
{ {
//временно - замещающая картинка(если она конечно присутствует) //временно - замещающая картинка(если она конечно присутствует)
......
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void docx_convert(oox::docx_conversion_context & Context) ; virtual void docx_convert(oox::docx_conversion_context & Context) ;
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) {} virtual void xlsx_convert(oox::xlsx_conversion_context & Context) {}
...@@ -378,7 +378,7 @@ public: ...@@ -378,7 +378,7 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
draw_equation_attlist draw_equation_attlist_; draw_equation_attlist draw_equation_attlist_;
}; };
...@@ -421,7 +421,7 @@ public: ...@@ -421,7 +421,7 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
draw_handle_attlist draw_handle_attlist_; draw_handle_attlist draw_handle_attlist_;
...@@ -451,7 +451,7 @@ public: ...@@ -451,7 +451,7 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context); virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context); virtual void docx_convert(oox::docx_conversion_context & Context);
......
...@@ -53,12 +53,12 @@ void math_mstack::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -53,12 +53,12 @@ void math_mstack::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mstack::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mstack::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mstack::docx_convert(oox::docx_conversion_context & Context) void math_mstack::oox_convert(oox::math_context & Context)
{//0* elements {//0* elements
} }
...@@ -72,12 +72,12 @@ void math_msrow::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -72,12 +72,12 @@ void math_msrow::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_msrow::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_msrow::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_msrow::docx_convert(oox::docx_conversion_context & Context) void math_msrow::oox_convert(oox::math_context & Context)
{ {
} }
...@@ -91,12 +91,12 @@ void math_msline::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -91,12 +91,12 @@ void math_msline::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_msline::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_msline::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_msline::docx_convert(oox::docx_conversion_context & Context) void math_msline::oox_convert(oox::math_context & Context)
{ {
} }
...@@ -110,12 +110,12 @@ void math_msgroup::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -110,12 +110,12 @@ void math_msgroup::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_msgroup::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_msgroup::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_msgroup::docx_convert(oox::docx_conversion_context & Context) void math_msgroup::oox_convert(oox::math_context & Context)
{//0* elements {//0* elements
} }
...@@ -129,12 +129,12 @@ void math_mlongdiv::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -129,12 +129,12 @@ void math_mlongdiv::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mlongdiv::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mlongdiv::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mlongdiv::docx_convert(oox::docx_conversion_context & Context) void math_mlongdiv::oox_convert(oox::math_context & Context)
{//3* elements {//3* elements
} }
...@@ -148,12 +148,12 @@ void math_mscarry::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -148,12 +148,12 @@ void math_mscarry::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mscarry::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mscarry::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mscarry::docx_convert(oox::docx_conversion_context & Context) void math_mscarry::oox_convert(oox::math_context & Context)
{ {
} }
...@@ -167,12 +167,12 @@ void math_mscarries::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -167,12 +167,12 @@ void math_mscarries::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mscarries::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mscarries::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mscarries::docx_convert(oox::docx_conversion_context & Context) void math_mscarries::oox_convert(oox::math_context & Context)
{//0* elements {//0* elements
} }
......
...@@ -31,17 +31,12 @@ ...@@ -31,17 +31,12 @@
*/ */
#pragma once #pragma once
#include <iosfwd> #include "math_elements.h"
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/xml/nodetype.h>
#include "office_elements_create.h"
namespace cpdoccore { namespace cpdoccore {
namespace odf_reader { namespace odf_reader {
class math_mstack : public office_element_impl<math_mstack> class math_mstack : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -49,15 +44,11 @@ public: ...@@ -49,15 +44,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMStack; static const ElementType type = typeMStack;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -67,7 +58,7 @@ CP_REGISTER_OFFICE_ELEMENT3(math_mstack); ...@@ -67,7 +58,7 @@ CP_REGISTER_OFFICE_ELEMENT3(math_mstack);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_msrow : public office_element_impl<math_msrow> class math_msrow : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -75,15 +66,11 @@ public: ...@@ -75,15 +66,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMSRow; static const ElementType type = typeMSRow;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -93,7 +80,7 @@ CP_REGISTER_OFFICE_ELEMENT3(math_msrow); ...@@ -93,7 +80,7 @@ CP_REGISTER_OFFICE_ELEMENT3(math_msrow);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_msline : public office_element_impl<math_msline> class math_msline : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -103,15 +90,13 @@ public: ...@@ -103,15 +90,13 @@ public:
CPDOCCORE_DEFINE_VISITABLE(); CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context); virtual void oox_convert(oox::math_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
CP_REGISTER_OFFICE_ELEMENT2(math_msline); CP_REGISTER_OFFICE_ELEMENT2(math_msline);
...@@ -119,7 +104,7 @@ CP_REGISTER_OFFICE_ELEMENT3(math_msline); ...@@ -119,7 +104,7 @@ CP_REGISTER_OFFICE_ELEMENT3(math_msline);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_mlongdiv : public office_element_impl<math_mlongdiv> class math_mlongdiv : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -127,15 +112,11 @@ public: ...@@ -127,15 +112,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMSLongDiv; static const ElementType type = typeMSLongDiv;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -145,7 +126,7 @@ CP_REGISTER_OFFICE_ELEMENT3(math_mlongdiv); ...@@ -145,7 +126,7 @@ CP_REGISTER_OFFICE_ELEMENT3(math_mlongdiv);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_mscarries : public office_element_impl<math_mscarries> class math_mscarries : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -153,15 +134,11 @@ public: ...@@ -153,15 +134,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMSCarries; static const ElementType type = typeMSCarries;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -170,7 +147,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mscarries); ...@@ -170,7 +147,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mscarries);
CP_REGISTER_OFFICE_ELEMENT3(math_mscarries); CP_REGISTER_OFFICE_ELEMENT3(math_mscarries);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_msgroup : public office_element_impl<math_msgroup> class math_msgroup : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -178,15 +155,11 @@ public: ...@@ -178,15 +155,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMSGroup; static const ElementType type = typeMSGroup;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -196,7 +169,7 @@ CP_REGISTER_OFFICE_ELEMENT3(math_msgroup); ...@@ -196,7 +169,7 @@ CP_REGISTER_OFFICE_ELEMENT3(math_msgroup);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_mscarry : public office_element_impl<math_mscarry> class math_mscarry : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -204,15 +177,11 @@ public: ...@@ -204,15 +177,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMSCarry; static const ElementType type = typeMSCarry;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
......
...@@ -44,6 +44,9 @@ namespace cpdoccore { ...@@ -44,6 +44,9 @@ namespace cpdoccore {
namespace odf_reader { namespace odf_reader {
//---------------------------------------------------------------
const wchar_t * office_math_element::ns = L"math";
const wchar_t * office_math_element::name = L"math-element";
//--------------------------------------------------------------- //---------------------------------------------------------------
const wchar_t * office_math::ns = L"math"; const wchar_t * office_math::ns = L"math";
const wchar_t * office_math::name = L"math"; const wchar_t * office_math::name = L"math";
...@@ -55,7 +58,7 @@ void office_math::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -55,7 +58,7 @@ void office_math::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void office_math::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void office_math::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
if CP_CHECK_NAME1(L"semantics") if CP_CHECK_NAME1(L"semantics")
{ {
...@@ -64,10 +67,13 @@ void office_math::add_child_element( xml::sax * Reader, const ::std::wstring & N ...@@ -64,10 +67,13 @@ void office_math::add_child_element( xml::sax * Reader, const ::std::wstring & N
} }
void office_math::docx_convert(oox::docx_conversion_context & Context) void office_math::oox_convert(oox::math_context & Context)
{ {
if (semantics_) if (semantics_)
semantics_->docx_convert(Context); {
office_math_element* math_element = dynamic_cast<office_math_element*>(semantics_.get());
math_element->oox_convert(Context);
}
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
...@@ -79,7 +85,7 @@ void math_semantics::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -79,7 +85,7 @@ void math_semantics::add_attributes( const xml::attributes_wc_ptr & Attributes )
{ {
} }
void math_semantics::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_semantics::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
if CP_CHECK_NAME1(L"annotation") if CP_CHECK_NAME1(L"annotation")
{ {
...@@ -91,16 +97,13 @@ void math_semantics::add_child_element( xml::sax * Reader, const ::std::wstring ...@@ -91,16 +97,13 @@ void math_semantics::add_child_element( xml::sax * Reader, const ::std::wstring
} }
void math_semantics::docx_convert(oox::docx_conversion_context & Context) void math_semantics::oox_convert(oox::math_context & Context)
{ {
Context.start_math_formula(); for (int i = 0 ; i < content_.size(); i++)
BOOST_FOREACH(const office_element_ptr & elm, content_)
{ {
elm->docx_convert(Context); office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
} }
Context.end_math_formula();
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
...@@ -118,7 +121,7 @@ void math_annotation::add_attributes( const xml::attributes_wc_ptr & Attributes ...@@ -118,7 +121,7 @@ void math_annotation::add_attributes( const xml::attributes_wc_ptr & Attributes
} }
void math_annotation::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_annotation::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
...@@ -129,7 +132,7 @@ void math_annotation::add_text(const std::wstring & Text) ...@@ -129,7 +132,7 @@ void math_annotation::add_text(const std::wstring & Text)
text_ = Text; text_ = Text;
} }
void math_annotation::docx_convert(oox::docx_conversion_context & Context) void math_annotation::oox_convert(oox::math_context & Context)
{ {
} }
...@@ -149,7 +152,7 @@ void math_annotation_xml::add_attributes( const xml::attributes_wc_ptr & Attribu ...@@ -149,7 +152,7 @@ void math_annotation_xml::add_attributes( const xml::attributes_wc_ptr & Attribu
} }
void math_annotation_xml::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_annotation_xml::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
...@@ -160,7 +163,7 @@ void math_annotation_xml::add_text(const std::wstring & Text) ...@@ -160,7 +163,7 @@ void math_annotation_xml::add_text(const std::wstring & Text)
text_ = Text; text_ = Text;
} }
void math_annotation_xml::docx_convert(oox::docx_conversion_context & Context) void math_annotation_xml::oox_convert(oox::math_context & Context)
{ {
} }
......
...@@ -31,12 +31,6 @@ ...@@ -31,12 +31,6 @@
*/ */
#pragma once #pragma once
#include "math_elementaries.h"
#include "math_token_elements.h"
#include "math_table_elements.h"
#include "math_limit_elements.h"
#include "math_layout_elements.h"
#include <iosfwd> #include <iosfwd>
#include <cpdoccore/CPOptional.h> #include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/xmlelement.h> #include <cpdoccore/xml/xmlelement.h>
...@@ -47,6 +41,29 @@ ...@@ -47,6 +41,29 @@
namespace cpdoccore { namespace cpdoccore {
namespace odf_reader { namespace odf_reader {
class office_math_element : public office_element_impl<office_math_element>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeMathElement;
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 docx_convert (oox::docx_conversion_context & Context) {}
virtual void xlsx_convert (oox::xlsx_conversion_context & Context) {}
virtual void pptx_convert (oox::pptx_conversion_context & Context) {}
virtual void oox_convert (oox::math_context & Context) = 0;
CPDOCCORE_DEFINE_VISITABLE();
friend class odf_document;
};
//-------------------------------------------------------------------------------------------------------------------
class office_math : public office_element_impl<office_math> class office_math : public office_element_impl<office_math>
{ {
public: public:
...@@ -55,15 +72,18 @@ public: ...@@ -55,15 +72,18 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMath; static const ElementType type = typeMath;
CPDOCCORE_DEFINE_VISITABLE(); virtual void docx_convert (oox::docx_conversion_context & Context){}
virtual void xlsx_convert (oox::xlsx_conversion_context & Context){}
virtual void pptx_convert (oox::pptx_conversion_context & Context){}
virtual void docx_convert(oox::docx_conversion_context & Context); void oox_convert (oox::math_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
CPDOCCORE_DEFINE_VISITABLE();
friend class odf_document;
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr semantics_; office_element_ptr semantics_;
}; };
...@@ -72,7 +92,7 @@ CP_REGISTER_OFFICE_ELEMENT2(office_math); ...@@ -72,7 +92,7 @@ CP_REGISTER_OFFICE_ELEMENT2(office_math);
CP_REGISTER_OFFICE_ELEMENT3(office_math); CP_REGISTER_OFFICE_ELEMENT3(office_math);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_semantics : public office_element_impl<math_semantics> class math_semantics : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -80,17 +100,13 @@ public: ...@@ -80,17 +100,13 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMathSemantics; static const ElementType type = typeMathSemantics;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
office_element_ptr annotation_; office_element_ptr annotation_;
}; };
...@@ -98,7 +114,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_semantics); ...@@ -98,7 +114,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_semantics);
CP_REGISTER_OFFICE_ELEMENT3(math_semantics); CP_REGISTER_OFFICE_ELEMENT3(math_semantics);
//------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------
class math_annotation : public office_element_impl<math_annotation> class math_annotation : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -106,27 +122,22 @@ public: ...@@ -106,27 +122,22 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMathAnnotation; static const ElementType type = typeMathAnnotation;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text); virtual void add_text(const std::wstring & Text);
office_element_ptr_array content_; office_element_ptr_array content_;
_CP_OPT(std::wstring) text_; _CP_OPT(std::wstring) text_;
_CP_OPT(std::wstring) encoding_; _CP_OPT(std::wstring) encoding_;
}; };
CP_REGISTER_OFFICE_ELEMENT2(math_annotation); CP_REGISTER_OFFICE_ELEMENT2(math_annotation);
CP_REGISTER_OFFICE_ELEMENT3(math_annotation); CP_REGISTER_OFFICE_ELEMENT3(math_annotation);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_annotation_xml : public office_element_impl<math_annotation_xml> class math_annotation_xml : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -134,20 +145,15 @@ public: ...@@ -134,20 +145,15 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMathAnnotationXml; static const ElementType type = typeMathAnnotationXml;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text); virtual void add_text(const std::wstring & Text);
office_element_ptr_array content_; office_element_ptr_array content_;
_CP_OPT(std::wstring) text_; _CP_OPT(std::wstring) text_;
_CP_OPT(std::wstring) encoding_; _CP_OPT(std::wstring) encoding_;
}; };
......
...@@ -59,7 +59,7 @@ void math_mrow::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -59,7 +59,7 @@ void math_mrow::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mrow::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mrow::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{//0* elements {//0* elements
if (next_element_to_prev_) if (next_element_to_prev_)
{ {
...@@ -75,7 +75,7 @@ void math_mrow::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, ...@@ -75,7 +75,7 @@ void math_mrow::add_child_element( xml::sax * Reader, const ::std::wstring & Ns,
next_element_to_prev_ = true; next_element_to_prev_ = true;
} }
void math_mrow::docx_convert(oox::docx_conversion_context & Context) void math_mrow::oox_convert(oox::math_context & Context)
{ {
if (content_.size() < 1) return; if (content_.size() < 1) return;
...@@ -114,14 +114,15 @@ void math_mrow::docx_convert(oox::docx_conversion_context & Context) ...@@ -114,14 +114,15 @@ void math_mrow::docx_convert(oox::docx_conversion_context & Context)
mo_test_last->text_to_stream(Context.output_stream()); mo_test_last->text_to_stream(Context.output_stream());
Context.output_stream() << L"\"/>"; Context.output_stream() << L"\"/>";
} }
Context.output_stream() << Context.get_styles_context().math_text_style().str(); Context.output_stream() << Context.math_style_stream().str();
Context.output_stream() << L"</m:dPr>"; Context.output_stream() << L"</m:dPr>";
Context.output_stream() << L"<m:e>"; Context.output_stream() << L"<m:e>";
} }
for (int i = i_start; i < i_end ; i++) for (int i = i_start; i < i_end ; i++)
{ {
content_[i]->docx_convert(Context); office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
} }
if (bDPr) if (bDPr)
...@@ -139,24 +140,28 @@ void math_mfrac::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -139,24 +140,28 @@ void math_mfrac::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mfrac::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mfrac::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mfrac::docx_convert(oox::docx_conversion_context & Context) void math_mfrac::oox_convert(oox::math_context & Context)
{//2 elements {//2 elements
if (content_.size() != 2) if (content_.size() != 2)
{ {
return; return;
} }
office_math_element* math_element = NULL;
Context.output_stream() << L"<m:f>"; Context.output_stream() << L"<m:f>";
Context.output_stream() << L"<m:num>"; Context.output_stream() << L"<m:num>";
content_[0]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
Context.output_stream() << L"</m:num>"; Context.output_stream() << L"</m:num>";
Context.output_stream() << L"<m:den>"; Context.output_stream() << L"<m:den>";
content_[1]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[1].get());
math_element->oox_convert(Context);
Context.output_stream() << L"</m:den>"; Context.output_stream() << L"</m:den>";
Context.output_stream() << L"</m:f>"; Context.output_stream() << L"</m:f>";
...@@ -170,27 +175,28 @@ void math_msqrt::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -170,27 +175,28 @@ void math_msqrt::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_msqrt::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_msqrt::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_msqrt::docx_convert(oox::docx_conversion_context & Context) void math_msqrt::oox_convert(oox::math_context & Context)
{//1* elements {//1* elements
std::wostream & strm = Context.output_stream(); std::wostream & strm = Context.output_stream();
strm << L"<m:rad>"; strm << L"<m:rad>";
strm << L"<m:radPr>"; strm << L"<m:radPr>";
strm << L"<m:degHide m:val=\"1\"/>"; strm << L"<m:degHide m:val=\"1\"/>";
strm << Context.get_styles_context().math_text_style().str(); strm << Context.math_style_stream().str();
strm << L"</m:radPr>"; strm << L"</m:radPr>";
strm << L"<m:deg/>"; strm << L"<m:deg/>";
strm << L"<m:e>"; strm << L"<m:e>";
BOOST_FOREACH(const office_element_ptr & elm, content_) for (int i = 0 ; i < content_.size(); i++)
{ {
elm->docx_convert(Context); office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
} }
strm << L"</m:e>"; strm << L"</m:e>";
strm << L"</m:rad>"; strm << L"</m:rad>";
...@@ -204,27 +210,30 @@ void math_mroot::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -204,27 +210,30 @@ void math_mroot::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mroot::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mroot::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mroot::docx_convert(oox::docx_conversion_context & Context) void math_mroot::oox_convert(oox::math_context & Context)
{//2 elements {//2 elements
std::wostream & strm = Context.output_stream(); std::wostream & strm = Context.output_stream();
strm << L"<m:rad>"; strm << L"<m:rad>";
office_math_element* math_element = NULL;
strm << L"<m:radPr>"; strm << L"<m:radPr>";
strm << Context.get_styles_context().math_text_style().str(); strm << Context.math_style_stream().str();
strm << L"</m:radPr>"; strm << L"</m:radPr>";
strm << L"<m:deg>"; strm << L"<m:deg>";
content_[1]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[1].get());
math_element->oox_convert(Context);
strm << L"</m:deg>"; strm << L"</m:deg>";
strm << L"<m:e>"; strm << L"<m:e>";
content_[0]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
strm << L"</m:e>"; strm << L"</m:e>";
strm << L"</m:rad>"; strm << L"</m:rad>";
...@@ -242,36 +251,40 @@ void math_mstyle::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -242,36 +251,40 @@ void math_mstyle::add_attributes( const xml::attributes_wc_ptr & Attributes )
CP_APPLY_ATTR(L"math:color", color_); CP_APPLY_ATTR(L"math:color", color_);
// ver 3 // ver 3
if (!fontweight_) CP_APPLY_ATTR( L"fontweight", fontweight_); if (!fontweight_) CP_APPLY_ATTR( L"fontweight", fontweight_);
if (!mathsize_) CP_APPLY_ATTR(L"mathsize", mathsize_); if (!mathsize_) CP_APPLY_ATTR(L"mathsize", mathsize_);
if (!color_) CP_APPLY_ATTR(L"color", color_); if (!color_) CP_APPLY_ATTR(L"color", color_);
} }
void math_mstyle::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mstyle::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mstyle::docx_convert(oox::docx_conversion_context & Context) void math_mstyle::oox_convert(oox::math_context & Context)
{ {
style_text_properties textProperty; Context.text_properties_ = odf_reader::style_text_properties_ptr(new odf_reader::style_text_properties());
Context.text_properties_->content().style_font_name_ = L"Cambria Math";
Context.text_properties_->content().fo_font_size_ = odf_types::length(Context.base_font_size_, odf_types::length::pt);
if (mathsize_) if (mathsize_)
textProperty.content().fo_font_size_ = mathsize_; Context.text_properties_->content().fo_font_size_ = mathsize_;
if (color_) if (color_)
textProperty.content().fo_color_ = color_; Context.text_properties_->content().fo_color_ = color_;
if (common_attlist_.mathvariant_) if (common_attlist_.mathvariant_)
{ {
if (common_attlist_.mathvariant_->style_.bold) if (common_attlist_.mathvariant_->style_.bold)
textProperty.content().fo_font_weight_ = odf_types::font_weight(odf_types::font_weight::WBold); Context.text_properties_->content().fo_font_weight_ = odf_types::font_weight(odf_types::font_weight::WBold);
if (common_attlist_.mathvariant_->style_.italic) if (common_attlist_.mathvariant_->style_.italic)
textProperty.content().fo_font_style_ = odf_types::font_style(odf_types::font_style::Italic); Context.text_properties_->content().fo_font_style_ = odf_types::font_style(odf_types::font_style::Italic);
} }
Context.push_text_properties(&textProperty);
//-------------------------------------------------- //--------------------------------------------------
{ {
std::wstringstream & strm = Context.get_styles_context().math_text_style(); std::wstringstream & strm = Context.math_style_stream();
strm.str( std::wstring() ); strm.str( std::wstring() );
strm.clear(); strm.clear();
...@@ -279,28 +292,24 @@ void math_mstyle::docx_convert(oox::docx_conversion_context & Context) ...@@ -279,28 +292,24 @@ void math_mstyle::docx_convert(oox::docx_conversion_context & Context)
{ {
CP_XML_NODE(L"m:ctrlPr") CP_XML_NODE(L"m:ctrlPr")
{ {
Context.get_styles_context().start(); Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
Context.current_text_properties()->docx_convert(Context);
CP_XML_NODE(L"w:rPr")
{
CP_XML_STREAM() << Context.get_styles_context().text_style().str();
}
} }
} }
} }
BOOST_FOREACH(const office_element_ptr & elm, content_) for (int i = 0; i < content_.size(); i++)
{ {
elm->docx_convert(Context); office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
} }
//reset to default math text props
Context.text_properties_ = odf_reader::style_text_properties_ptr(new odf_reader::style_text_properties());
Context.pop_text_properties(); Context.text_properties_->content().style_font_name_ = L"Cambria Math";
Context.text_properties_->content().fo_font_size_ = odf_types::length(Context.base_font_size_, odf_types::length::pt);
// reset style ... todooo вынести отдельно..
{ {
std::wstringstream & strm = Context.get_styles_context().math_text_style(); std::wstringstream & strm = Context.math_style_stream();
strm.str( std::wstring() ); strm.str( std::wstring() );
strm.clear(); strm.clear();
...@@ -308,13 +317,7 @@ void math_mstyle::docx_convert(oox::docx_conversion_context & Context) ...@@ -308,13 +317,7 @@ void math_mstyle::docx_convert(oox::docx_conversion_context & Context)
{ {
CP_XML_NODE(L"m:ctrlPr") CP_XML_NODE(L"m:ctrlPr")
{ {
Context.get_styles_context().start(); Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
Context.current_text_properties()->docx_convert(Context);
CP_XML_NODE(L"w:rPr")
{
CP_XML_STREAM() << Context.get_styles_context().text_style().str();
}
} }
} }
} }
...@@ -332,16 +335,17 @@ void math_menclose::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -332,16 +335,17 @@ void math_menclose::add_attributes( const xml::attributes_wc_ptr & Attributes )
// if (!fontweight_) CP_APPLY_ATTR( L"fontweight", fontweight_); // if (!fontweight_) CP_APPLY_ATTR( L"fontweight", fontweight_);
} }
void math_menclose::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_menclose::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_menclose::docx_convert(oox::docx_conversion_context & Context) void math_menclose::oox_convert(oox::math_context & Context)
{//0* elements {//0* elements
//BOOST_FOREACH(const office_element_ptr & elm, content_) //BOOST_FOREACH(const office_element_ptr & elm, content_)
//{ //{
// elm->docx_convert(Context); //office_math_element* math_element = dynamic_cast<office_math_element*>(elm.get());
//math_element->oox_convert(Context);
//} //}
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
...@@ -357,16 +361,17 @@ void math_mfenced::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -357,16 +361,17 @@ void math_mfenced::add_attributes( const xml::attributes_wc_ptr & Attributes )
// if (!fontweight_) CP_APPLY_ATTR( L"fontweight", fontweight_); // if (!fontweight_) CP_APPLY_ATTR( L"fontweight", fontweight_);
} }
void math_mfenced::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mfenced::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mfenced::docx_convert(oox::docx_conversion_context & Context) void math_mfenced::oox_convert(oox::math_context & Context)
{//0* elements {//0* elements
//BOOST_FOREACH(const office_element_ptr & elm, content_) //BOOST_FOREACH(const office_element_ptr & elm, content_)
//{ //{
// elm->docx_convert(Context); //office_math_element* math_element = dynamic_cast<office_math_element*>(elm.get());
//math_element->oox_convert(Context);
//} //}
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
...@@ -382,12 +387,12 @@ void math_mpadded::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -382,12 +387,12 @@ void math_mpadded::add_attributes( const xml::attributes_wc_ptr & Attributes )
// if (!fontweight_) CP_APPLY_ATTR( L"fontweight", fontweight_); // if (!fontweight_) CP_APPLY_ATTR( L"fontweight", fontweight_);
} }
void math_mpadded::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mpadded::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mpadded::docx_convert(oox::docx_conversion_context & Context) void math_mpadded::oox_convert(oox::math_context & Context)
{//1* elements {//1* elements
} }
......
...@@ -31,12 +31,7 @@ ...@@ -31,12 +31,7 @@
*/ */
#pragma once #pragma once
#include <iosfwd> #include "math_elements.h"
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/xml/nodetype.h>
#include "office_elements_create.h"
#include "datatypes/common_attlists.h" #include "datatypes/common_attlists.h"
#include "datatypes/fontstyle.h" #include "datatypes/fontstyle.h"
...@@ -49,7 +44,7 @@ namespace cpdoccore { ...@@ -49,7 +44,7 @@ namespace cpdoccore {
namespace odf_reader { namespace odf_reader {
class math_mrow : public office_element_impl<math_mrow> class math_mrow : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -58,15 +53,11 @@ public: ...@@ -58,15 +53,11 @@ public:
static const ElementType type = typeMRow; static const ElementType type = typeMRow;
math_mrow(); math_mrow();
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
bool next_element_to_prev_; bool next_element_to_prev_;
...@@ -75,7 +66,7 @@ private: ...@@ -75,7 +66,7 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(math_mrow); CP_REGISTER_OFFICE_ELEMENT2(math_mrow);
CP_REGISTER_OFFICE_ELEMENT3(math_mrow); CP_REGISTER_OFFICE_ELEMENT3(math_mrow);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
class math_mfrac : public office_element_impl<math_mfrac> class math_mfrac : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -83,15 +74,11 @@ public: ...@@ -83,15 +74,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMFrac; static const ElementType type = typeMFrac;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; //2 elements office_element_ptr_array content_; //2 elements
...@@ -104,7 +91,7 @@ private: ...@@ -104,7 +91,7 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(math_mfrac); CP_REGISTER_OFFICE_ELEMENT2(math_mfrac);
CP_REGISTER_OFFICE_ELEMENT3(math_mfrac); CP_REGISTER_OFFICE_ELEMENT3(math_mfrac);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
class math_msqrt : public office_element_impl<math_msqrt> class math_msqrt : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -112,15 +99,11 @@ public: ...@@ -112,15 +99,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMSqrt; static const ElementType type = typeMSqrt;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -128,7 +111,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_msqrt); ...@@ -128,7 +111,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_msqrt);
CP_REGISTER_OFFICE_ELEMENT3(math_msqrt); CP_REGISTER_OFFICE_ELEMENT3(math_msqrt);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
class math_mroot : public office_element_impl<math_mroot> class math_mroot : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -136,15 +119,11 @@ public: ...@@ -136,15 +119,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMRoot; static const ElementType type = typeMRoot;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -152,7 +131,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mroot); ...@@ -152,7 +131,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mroot);
CP_REGISTER_OFFICE_ELEMENT3(math_mroot); CP_REGISTER_OFFICE_ELEMENT3(math_mroot);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
class math_mstyle : public office_element_impl<math_mstyle> class math_mstyle : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -160,15 +139,11 @@ public: ...@@ -160,15 +139,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMStyle; static const ElementType type = typeMStyle;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
...@@ -181,7 +156,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mstyle); ...@@ -181,7 +156,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mstyle);
CP_REGISTER_OFFICE_ELEMENT3(math_mstyle); CP_REGISTER_OFFICE_ELEMENT3(math_mstyle);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
class math_menclose : public office_element_impl<math_menclose> class math_menclose : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -189,15 +164,11 @@ public: ...@@ -189,15 +164,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMEnClose; static const ElementType type = typeMEnClose;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -205,7 +176,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_menclose); ...@@ -205,7 +176,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_menclose);
CP_REGISTER_OFFICE_ELEMENT3(math_menclose); CP_REGISTER_OFFICE_ELEMENT3(math_menclose);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
class math_mfenced : public office_element_impl<math_mfenced> class math_mfenced : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -213,15 +184,11 @@ public: ...@@ -213,15 +184,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMFenced; static const ElementType type = typeMFenced;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -229,7 +196,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mfenced); ...@@ -229,7 +196,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mfenced);
CP_REGISTER_OFFICE_ELEMENT3(math_mfenced); CP_REGISTER_OFFICE_ELEMENT3(math_mfenced);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
class math_mpadded : public office_element_impl<math_mpadded> class math_mpadded : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -237,15 +204,11 @@ public: ...@@ -237,15 +204,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMPadded; static const ElementType type = typeMPadded;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
......
...@@ -54,14 +54,14 @@ void math_msub::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -54,14 +54,14 @@ void math_msub::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_msub::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_msub::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
//<msub> base subscript </msub> //<msub> base subscript </msub>
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_msub::docx_convert(oox::docx_conversion_context & Context) void math_msub::oox_convert(oox::math_context & Context)
{//2 elements {//2 elements
if (content_.size() != 2) if (content_.size() != 2)
{ {
...@@ -69,14 +69,18 @@ void math_msub::docx_convert(oox::docx_conversion_context & Context) ...@@ -69,14 +69,18 @@ void math_msub::docx_convert(oox::docx_conversion_context & Context)
} }
std::wostream & strm = Context.output_stream(); std::wostream & strm = Context.output_stream();
office_math_element* math_element = NULL;
strm << L"<m:sSub>"; strm << L"<m:sSub>";
strm << L"<m:e>"; strm << L"<m:e>";
content_[0]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
strm << L"</m:e>"; strm << L"</m:e>";
strm << L"<m:sub>"; strm << L"<m:sub>";
content_[1]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[1].get());
math_element->oox_convert(Context);
strm << L"</m:sub>"; strm << L"</m:sub>";
strm << L"</m:sSub>"; strm << L"</m:sSub>";
...@@ -90,12 +94,12 @@ void math_msup::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -90,12 +94,12 @@ void math_msup::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_msup::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_msup::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_msup::docx_convert(oox::docx_conversion_context & Context) void math_msup::oox_convert(oox::math_context & Context)
{//2 elements {//2 elements
if (content_.size() != 2) if (content_.size() != 2)
{ {
...@@ -103,14 +107,18 @@ void math_msup::docx_convert(oox::docx_conversion_context & Context) ...@@ -103,14 +107,18 @@ void math_msup::docx_convert(oox::docx_conversion_context & Context)
} }
std::wostream & strm = Context.output_stream(); std::wostream & strm = Context.output_stream();
office_math_element* math_element = NULL;
strm << L"<m:sSup>"; strm << L"<m:sSup>";
strm << L"<m:e>"; strm << L"<m:e>";
content_[0]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
strm << L"</m:e>"; strm << L"</m:e>";
strm << L"<m:sup>"; strm << L"<m:sup>";
content_[1]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[1].get());
math_element->oox_convert(Context);
strm << L"</m:sup>"; strm << L"</m:sup>";
strm << L"</m:sSup>"; strm << L"</m:sSup>";
...@@ -125,27 +133,32 @@ void math_msubsup::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -125,27 +133,32 @@ void math_msubsup::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_msubsup::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_msubsup::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_msubsup::docx_convert(oox::docx_conversion_context & Context) void math_msubsup::oox_convert(oox::math_context & Context)
{//3 elements {//3 elements
std::wostream & strm = Context.output_stream(); std::wostream & strm = Context.output_stream();
office_math_element* math_element = NULL;
strm << L"<m:sSubSup>"; strm << L"<m:sSubSup>";
strm << L"<m:e>"; strm << L"<m:e>";
content_[0]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
strm << L"</m:e>"; strm << L"</m:e>";
strm << L"<m:sub>"; strm << L"<m:sub>";
content_[1]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[1].get());
math_element->oox_convert(Context);
strm << L"</m:sub>"; strm << L"</m:sub>";
strm << L"<m:sup>"; strm << L"<m:sup>";
content_[2]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[2].get());
math_element->oox_convert(Context);
strm << L"</m:sup>"; strm << L"</m:sup>";
strm << L"</m:sSubSup>"; strm << L"</m:sSubSup>";
...@@ -159,12 +172,12 @@ void math_none::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -159,12 +172,12 @@ void math_none::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_none::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_none::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_none::docx_convert(oox::docx_conversion_context & Context) void math_none::oox_convert(oox::math_context & Context)
{ {
} }
...@@ -178,12 +191,12 @@ void math_mprescripts::add_attributes( const xml::attributes_wc_ptr & Attributes ...@@ -178,12 +191,12 @@ void math_mprescripts::add_attributes( const xml::attributes_wc_ptr & Attributes
} }
void math_mprescripts::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mprescripts::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mprescripts::docx_convert(oox::docx_conversion_context & Context) void math_mprescripts::oox_convert(oox::math_context & Context)
{ {
} }
...@@ -196,12 +209,12 @@ void math_mmultiscripts::add_attributes( const xml::attributes_wc_ptr & Attribut ...@@ -196,12 +209,12 @@ void math_mmultiscripts::add_attributes( const xml::attributes_wc_ptr & Attribut
} }
void math_mmultiscripts::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mmultiscripts::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mmultiscripts::docx_convert(oox::docx_conversion_context & Context) void math_mmultiscripts::oox_convert(oox::math_context & Context)
{//1* elements {//1* elements
} }
...@@ -214,12 +227,12 @@ void math_munderover::add_attributes( const xml::attributes_wc_ptr & Attributes ...@@ -214,12 +227,12 @@ void math_munderover::add_attributes( const xml::attributes_wc_ptr & Attributes
} }
void math_munderover::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_munderover::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_munderover::docx_convert(oox::docx_conversion_context & Context) void math_munderover::oox_convert(oox::math_context & Context)
{//3 elements (+1) {//3 elements (+1)
if (content_.size() < 4) if (content_.size() < 4)
{ {
...@@ -233,6 +246,8 @@ void math_munderover::docx_convert(oox::docx_conversion_context & Context) ...@@ -233,6 +246,8 @@ void math_munderover::docx_convert(oox::docx_conversion_context & Context)
std::wostream & strm = Context.output_stream(); std::wostream & strm = Context.output_stream();
office_math_element* math_element = NULL;
if (sBase.size() < 3) if (sBase.size() < 3)
{ {
strm << L"<m:nary>"; strm << L"<m:nary>";
...@@ -246,19 +261,22 @@ void math_munderover::docx_convert(oox::docx_conversion_context & Context) ...@@ -246,19 +261,22 @@ void math_munderover::docx_convert(oox::docx_conversion_context & Context)
strm << L"</m:naryPr>"; strm << L"</m:naryPr>";
strm << L"<m:sub>"; strm << L"<m:sub>";
{ {
content_[2]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[2].get());
math_element->oox_convert(Context);
} }
strm << L"</m:sub>"; strm << L"</m:sub>";
strm << L"<m:sup>"; strm << L"<m:sup>";
{ {
content_[1]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[1].get());
math_element->oox_convert(Context);
} }
strm << L"</m:sup>"; strm << L"</m:sup>";
strm << L"<m:e>"; strm << L"<m:e>";
{ {
content_[3]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[3].get());
math_element->oox_convert(Context);
} }
strm << L"</m:e>"; strm << L"</m:e>";
strm << L"</m:nary>"; strm << L"</m:nary>";
...@@ -271,19 +289,23 @@ void math_munderover::docx_convert(oox::docx_conversion_context & Context) ...@@ -271,19 +289,23 @@ void math_munderover::docx_convert(oox::docx_conversion_context & Context)
strm << L"<m:limLow>"; strm << L"<m:limLow>";
strm << L"<m:limLowPr/>"; strm << L"<m:limLowPr/>";
strm << L"<m:e>"; strm << L"<m:e>";
content_[0]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
strm << L"</m:e>"; strm << L"</m:e>";
strm << L"<m:lim>"; strm << L"<m:lim>";
content_[1]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[1].get());
math_element->oox_convert(Context);
strm << L"</m:lim>"; strm << L"</m:lim>";
strm << L"</m:limLow>"; strm << L"</m:limLow>";
strm << L"</m:e>"; strm << L"</m:e>";
strm << L"<m:lim>"; strm << L"<m:lim>";
content_[2]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[2].get());
math_element->oox_convert(Context);
strm << L"</m:lim>"; strm << L"</m:lim>";
strm << L"</m:limUpp>"; strm << L"</m:limUpp>";
content_[3]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[3].get());
math_element->oox_convert(Context);
} }
} }
//--------------------------------------------------------------- //---------------------------------------------------------------
...@@ -295,22 +317,26 @@ void math_mover::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -295,22 +317,26 @@ void math_mover::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mover::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mover::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mover::docx_convert(oox::docx_conversion_context & Context) void math_mover::oox_convert(oox::math_context & Context)
{//2 elements {//2 elements
std::wostream & strm = Context.output_stream(); std::wostream & strm = Context.output_stream();
office_math_element* math_element = NULL;
strm << L"<m:limUpp>"; strm << L"<m:limUpp>";
strm << L"<m:limUppPr/>"; strm << L"<m:limUppPr/>";
strm << L"<m:e>"; strm << L"<m:e>";
content_[0]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
strm << L"</m:e>"; strm << L"</m:e>";
strm << L"<m:lim>"; strm << L"<m:lim>";
content_[1]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[1].get());
math_element->oox_convert(Context);
strm << L"</m:lim>"; strm << L"</m:lim>";
strm << L"</m:limUpp>"; strm << L"</m:limUpp>";
} }
...@@ -323,22 +349,25 @@ void math_munder::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -323,22 +349,25 @@ void math_munder::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_munder::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_munder::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_munder::docx_convert(oox::docx_conversion_context & Context) void math_munder::oox_convert(oox::math_context & Context)
{//2 elements {//2 elements
std::wostream & strm = Context.output_stream(); std::wostream & strm = Context.output_stream();
office_math_element* math_element = NULL;
strm << L"<m:limLow>"; strm << L"<m:limLow>";
strm << L"<m:limLowPr/>"; strm << L"<m:limLowPr/>";
strm << L"<m:e>"; strm << L"<m:e>";
content_[0]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
strm << L"</m:e>"; strm << L"</m:e>";
strm << L"<m:lim>"; strm << L"<m:lim>";
content_[1]->docx_convert(Context); math_element = dynamic_cast<office_math_element*>(content_[1].get());
math_element->oox_convert(Context);
strm << L"</m:lim>"; strm << L"</m:lim>";
strm << L"</m:limLow>"; strm << L"</m:limLow>";
} }
......
...@@ -31,17 +31,12 @@ ...@@ -31,17 +31,12 @@
*/ */
#pragma once #pragma once
#include <iosfwd> #include "math_elements.h"
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/xml/nodetype.h>
#include "office_elements_create.h"
namespace cpdoccore { namespace cpdoccore {
namespace odf_reader { namespace odf_reader {
class math_msub : public office_element_impl<math_msub> class math_msub : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -49,15 +44,11 @@ public: ...@@ -49,15 +44,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMSub; static const ElementType type = typeMSub;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -65,7 +56,7 @@ private: ...@@ -65,7 +56,7 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(math_msub); CP_REGISTER_OFFICE_ELEMENT2(math_msub);
CP_REGISTER_OFFICE_ELEMENT3(math_msub); CP_REGISTER_OFFICE_ELEMENT3(math_msub);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_msup : public office_element_impl<math_msup> class math_msup : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -73,15 +64,11 @@ public: ...@@ -73,15 +64,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMSup; static const ElementType type = typeMSup;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -90,7 +77,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_msup); ...@@ -90,7 +77,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_msup);
CP_REGISTER_OFFICE_ELEMENT3(math_msup); CP_REGISTER_OFFICE_ELEMENT3(math_msup);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_msubsup : public office_element_impl<math_msubsup> class math_msubsup : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -98,15 +85,11 @@ public: ...@@ -98,15 +85,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMSubSup; static const ElementType type = typeMSubSup;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -115,7 +98,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_msubsup); ...@@ -115,7 +98,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_msubsup);
CP_REGISTER_OFFICE_ELEMENT3(math_msubsup); CP_REGISTER_OFFICE_ELEMENT3(math_msubsup);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_none : public office_element_impl<math_none> class math_none : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -123,15 +106,11 @@ public: ...@@ -123,15 +106,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMNone; static const ElementType type = typeMNone;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -140,7 +119,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_none); ...@@ -140,7 +119,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_none);
CP_REGISTER_OFFICE_ELEMENT3(math_none); CP_REGISTER_OFFICE_ELEMENT3(math_none);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_mprescripts : public office_element_impl<math_mprescripts> class math_mprescripts : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -148,15 +127,11 @@ public: ...@@ -148,15 +127,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMPreScripts; static const ElementType type = typeMPreScripts;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -165,7 +140,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mprescripts); ...@@ -165,7 +140,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mprescripts);
CP_REGISTER_OFFICE_ELEMENT3(math_mprescripts); CP_REGISTER_OFFICE_ELEMENT3(math_mprescripts);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_mmultiscripts : public office_element_impl<math_mmultiscripts> class math_mmultiscripts : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -173,15 +148,11 @@ public: ...@@ -173,15 +148,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMMultiScripts; static const ElementType type = typeMMultiScripts;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -190,7 +161,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mmultiscripts); ...@@ -190,7 +161,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mmultiscripts);
CP_REGISTER_OFFICE_ELEMENT3(math_mmultiscripts); CP_REGISTER_OFFICE_ELEMENT3(math_mmultiscripts);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_munderover : public office_element_impl<math_munderover> class math_munderover : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -198,15 +169,11 @@ public: ...@@ -198,15 +169,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMUnderOver; static const ElementType type = typeMUnderOver;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; //3 exact - base, under, over office_element_ptr_array content_; //3 exact - base, under, over
}; };
...@@ -215,7 +182,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_munderover); ...@@ -215,7 +182,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_munderover);
CP_REGISTER_OFFICE_ELEMENT3(math_munderover); CP_REGISTER_OFFICE_ELEMENT3(math_munderover);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_mover : public office_element_impl<math_mover> class math_mover : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -223,15 +190,11 @@ public: ...@@ -223,15 +190,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMOver; static const ElementType type = typeMOver;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -240,7 +203,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mover); ...@@ -240,7 +203,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mover);
CP_REGISTER_OFFICE_ELEMENT3(math_mover); CP_REGISTER_OFFICE_ELEMENT3(math_mover);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_munder : public office_element_impl<math_munder> class math_munder : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -248,15 +211,11 @@ public: ...@@ -248,15 +211,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMUnder; static const ElementType type = typeMUnder;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
......
...@@ -54,19 +54,20 @@ void math_mtable::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -54,19 +54,20 @@ void math_mtable::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mtable::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mtable::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mtable::docx_convert(oox::docx_conversion_context & Context) void math_mtable::oox_convert(oox::math_context & Context)
{//0* elements {//0* elements
std::wostream & strm = Context.output_stream(); std::wostream & strm = Context.output_stream();
strm << L"<m:m>"; strm << L"<m:m>";
BOOST_FOREACH(const office_element_ptr & elm, content_) for (int i = 0; i < content_.size(); i++)
{ {
elm->docx_convert(Context); office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
} }
strm << L"</m:m>"; strm << L"</m:m>";
} }
...@@ -81,19 +82,20 @@ void math_mtr::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -81,19 +82,20 @@ void math_mtr::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mtr::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mtr::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mtr::docx_convert(oox::docx_conversion_context & Context) void math_mtr::oox_convert(oox::math_context & Context)
{//0* elements {//0* elements
std::wostream & strm = Context.output_stream(); std::wostream & strm = Context.output_stream();
strm << L"<m:mr>"; strm << L"<m:mr>";
BOOST_FOREACH(const office_element_ptr & elm, content_) for (int i = 0; i < content_.size(); i++)
{ {
elm->docx_convert(Context); office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
} }
strm << L"</m:mr>"; strm << L"</m:mr>";
} }
...@@ -108,12 +110,12 @@ void math_mlabeledtr::add_attributes( const xml::attributes_wc_ptr & Attributes ...@@ -108,12 +110,12 @@ void math_mlabeledtr::add_attributes( const xml::attributes_wc_ptr & Attributes
} }
void math_mlabeledtr::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mlabeledtr::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mlabeledtr::docx_convert(oox::docx_conversion_context & Context) void math_mlabeledtr::oox_convert(oox::math_context & Context)
{ {
} }
...@@ -128,19 +130,20 @@ void math_mtd::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -128,19 +130,20 @@ void math_mtd::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mtd::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mtd::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_mtd::docx_convert(oox::docx_conversion_context & Context) void math_mtd::oox_convert(oox::math_context & Context)
{ {
std::wostream & strm = Context.output_stream(); std::wostream & strm = Context.output_stream();
strm << L"<m:e>"; strm << L"<m:e>";
BOOST_FOREACH(const office_element_ptr & elm, content_) for (int i = 0; i < content_.size(); i++)
{ {
elm->docx_convert(Context); office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
} }
strm << L"</m:e>"; strm << L"</m:e>";
} }
...@@ -155,12 +158,12 @@ void math_maligngroup::add_attributes( const xml::attributes_wc_ptr & Attributes ...@@ -155,12 +158,12 @@ void math_maligngroup::add_attributes( const xml::attributes_wc_ptr & Attributes
} }
void math_maligngroup::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_maligngroup::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_maligngroup::docx_convert(oox::docx_conversion_context & Context) void math_maligngroup::oox_convert(oox::math_context & Context)
{ {
} }
...@@ -175,12 +178,12 @@ void math_malignmark::add_attributes( const xml::attributes_wc_ptr & Attributes ...@@ -175,12 +178,12 @@ void math_malignmark::add_attributes( const xml::attributes_wc_ptr & Attributes
} }
void math_malignmark::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_malignmark::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
void math_malignmark::docx_convert(oox::docx_conversion_context & Context) void math_malignmark::oox_convert(oox::math_context & Context)
{ {
} }
......
...@@ -31,17 +31,12 @@ ...@@ -31,17 +31,12 @@
*/ */
#pragma once #pragma once
#include <iosfwd> #include "math_elements.h"
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/xml/nodetype.h>
#include "office_elements_create.h"
namespace cpdoccore { namespace cpdoccore {
namespace odf_reader { namespace odf_reader {
class math_mtable : public office_element_impl<math_mtable> class math_mtable : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -49,15 +44,11 @@ public: ...@@ -49,15 +44,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMTable; static const ElementType type = typeMTable;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -66,7 +57,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mtable); ...@@ -66,7 +57,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mtable);
CP_REGISTER_OFFICE_ELEMENT3(math_mtable); CP_REGISTER_OFFICE_ELEMENT3(math_mtable);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_malignmark : public office_element_impl<math_malignmark> class math_malignmark : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -74,15 +65,11 @@ public: ...@@ -74,15 +65,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMAlignMark; static const ElementType type = typeMAlignMark;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -91,7 +78,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_malignmark); ...@@ -91,7 +78,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_malignmark);
CP_REGISTER_OFFICE_ELEMENT3(math_malignmark); CP_REGISTER_OFFICE_ELEMENT3(math_malignmark);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_maligngroup : public office_element_impl<math_maligngroup> class math_maligngroup : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -99,15 +86,11 @@ public: ...@@ -99,15 +86,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMAlignGroup; static const ElementType type = typeMAlignGroup;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -116,7 +99,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_maligngroup); ...@@ -116,7 +99,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_maligngroup);
CP_REGISTER_OFFICE_ELEMENT3(math_maligngroup); CP_REGISTER_OFFICE_ELEMENT3(math_maligngroup);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_mtd : public office_element_impl<math_mtd> class math_mtd : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -124,15 +107,11 @@ public: ...@@ -124,15 +107,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMTd; static const ElementType type = typeMTd;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -141,7 +120,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mtd); ...@@ -141,7 +120,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mtd);
CP_REGISTER_OFFICE_ELEMENT3(math_mtd); CP_REGISTER_OFFICE_ELEMENT3(math_mtd);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_mlabeledtr : public office_element_impl<math_mlabeledtr> class math_mlabeledtr : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -149,15 +128,11 @@ public: ...@@ -149,15 +128,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMLabelEdTr; static const ElementType type = typeMLabelEdTr;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -166,7 +141,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mlabeledtr); ...@@ -166,7 +141,7 @@ CP_REGISTER_OFFICE_ELEMENT2(math_mlabeledtr);
CP_REGISTER_OFFICE_ELEMENT3(math_mlabeledtr); CP_REGISTER_OFFICE_ELEMENT3(math_mlabeledtr);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_mtr : public office_element_impl<math_mtr> class math_mtr : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -174,15 +149,11 @@ public: ...@@ -174,15 +149,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMTr; static const ElementType type = typeMTr;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
......
...@@ -57,7 +57,7 @@ void math_mi::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -57,7 +57,7 @@ void math_mi::add_attributes( const xml::attributes_wc_ptr & Attributes )
common_attlist_.add_attributes(Attributes); common_attlist_.add_attributes(Attributes);
} }
void math_mi::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mi::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
...@@ -67,26 +67,21 @@ void math_mi::add_text(const std::wstring & Text) ...@@ -67,26 +67,21 @@ void math_mi::add_text(const std::wstring & Text)
text_ = Text; text_ = Text;
} }
std::wostream & math_mi::text_to_stream(::std::wostream & _strm) const std::wostream & math_mi::text_to_stream(std::wostream & _strm) const
{ {
if (text_) if (text_)
_strm << *text_; _strm << *text_;
return _strm; return _strm;
} }
void math_mi::docx_convert(oox::docx_conversion_context & Context) void math_mi::oox_convert(oox::math_context & Context)
{ {
if (!text_) return; if (!text_) return;
CP_XML_WRITER(Context.output_stream()) CP_XML_WRITER(Context.output_stream())
{ {
CP_XML_NODE(L"m:r") CP_XML_NODE(L"m:r")
{ {
Context.get_styles_context().start();
Context.current_text_properties()->docx_convert(Context);
if (common_attlist_.mathvariant_) if (common_attlist_.mathvariant_)
{ {
std::wstring m_sty_val; std::wstring m_sty_val;
...@@ -119,11 +114,8 @@ void math_mi::docx_convert(oox::docx_conversion_context & Context) ...@@ -119,11 +114,8 @@ void math_mi::docx_convert(oox::docx_conversion_context & Context)
} }
} }
CP_XML_NODE(L"w:rPr") Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
{
CP_XML_STREAM() << Context.get_styles_context().text_style().str();
}
CP_XML_NODE(L"m:t") CP_XML_NODE(L"m:t")
{ {
//CP_XML_ATTR(L"xml:space", L"preserve"); //CP_XML_ATTR(L"xml:space", L"preserve");
...@@ -143,7 +135,7 @@ void math_mo::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -143,7 +135,7 @@ void math_mo::add_attributes( const xml::attributes_wc_ptr & Attributes )
CP_APPLY_ATTR(L"fence", fence_); CP_APPLY_ATTR(L"fence", fence_);
} }
void math_mo::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mo::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
...@@ -153,14 +145,14 @@ void math_mo::add_text(const std::wstring & Text) ...@@ -153,14 +145,14 @@ void math_mo::add_text(const std::wstring & Text)
text_ = Text; text_ = Text;
} }
std::wostream & math_mo::text_to_stream(::std::wostream & _strm) const std::wostream & math_mo::text_to_stream(std::wostream & _strm) const
{ {
if (text_) if (text_)
_strm << *text_; _strm << *text_;
return _strm; return _strm;
} }
void math_mo::docx_convert(oox::docx_conversion_context & Context) void math_mo::oox_convert(oox::math_context & Context)
{ {
if (!text_) return; if (!text_) return;
...@@ -169,13 +161,9 @@ void math_mo::docx_convert(oox::docx_conversion_context & Context) ...@@ -169,13 +161,9 @@ void math_mo::docx_convert(oox::docx_conversion_context & Context)
CP_XML_NODE(L"m:r") CP_XML_NODE(L"m:r")
{ {
// + доп стили текста ... todoooo // + доп стили текста ... todoooo
Context.get_styles_context().start();
Context.current_text_properties()->docx_convert(Context);
CP_XML_NODE(L"w:rPr") Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
{
CP_XML_STREAM() << Context.get_styles_context().text_style().str();
}
CP_XML_NODE(L"m:t") CP_XML_NODE(L"m:t")
{ {
//CP_XML_ATTR(L"xml:space", L"preserve"); //CP_XML_ATTR(L"xml:space", L"preserve");
...@@ -194,7 +182,7 @@ void math_mn::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -194,7 +182,7 @@ void math_mn::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mn::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mn::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
...@@ -205,7 +193,7 @@ void math_mn::add_text(const std::wstring & Text) ...@@ -205,7 +193,7 @@ void math_mn::add_text(const std::wstring & Text)
} }
void math_mn::docx_convert(oox::docx_conversion_context & Context) void math_mn::oox_convert(oox::math_context & Context)
{ {
if (!text_) return; if (!text_) return;
...@@ -214,13 +202,9 @@ void math_mn::docx_convert(oox::docx_conversion_context & Context) ...@@ -214,13 +202,9 @@ void math_mn::docx_convert(oox::docx_conversion_context & Context)
CP_XML_NODE(L"m:r") CP_XML_NODE(L"m:r")
{ {
// + доп стили текста ... todoooo // + доп стили текста ... todoooo
Context.get_styles_context().start();
Context.current_text_properties()->docx_convert(Context);
CP_XML_NODE(L"w:rPr") Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
{
CP_XML_STREAM() << Context.get_styles_context().text_style().str();
}
CP_XML_NODE(L"m:t") CP_XML_NODE(L"m:t")
{ {
//CP_XML_ATTR(L"xml:space", L"preserve"); //CP_XML_ATTR(L"xml:space", L"preserve");
...@@ -239,7 +223,7 @@ void math_ms::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -239,7 +223,7 @@ void math_ms::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_ms::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_ms::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
...@@ -250,7 +234,7 @@ void math_ms::add_text(const std::wstring & Text) ...@@ -250,7 +234,7 @@ void math_ms::add_text(const std::wstring & Text)
} }
void math_ms::docx_convert(oox::docx_conversion_context & Context) void math_ms::oox_convert(oox::math_context & Context)
{ {
} }
...@@ -263,7 +247,7 @@ void math_mspace::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -263,7 +247,7 @@ void math_mspace::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mspace::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mspace::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
...@@ -274,7 +258,7 @@ void math_mspace::add_text(const std::wstring & Text) ...@@ -274,7 +258,7 @@ void math_mspace::add_text(const std::wstring & Text)
} }
void math_mspace::docx_convert(oox::docx_conversion_context & Context) void math_mspace::oox_convert(oox::math_context & Context)
{ {
} }
...@@ -288,7 +272,7 @@ void math_mtext::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -288,7 +272,7 @@ void math_mtext::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mtext::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mtext::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
...@@ -299,7 +283,7 @@ void math_mtext::add_text(const std::wstring & Text) ...@@ -299,7 +283,7 @@ void math_mtext::add_text(const std::wstring & Text)
} }
void math_mtext::docx_convert(oox::docx_conversion_context & Context) void math_mtext::oox_convert(oox::math_context & Context)
{ {
} }
...@@ -313,7 +297,7 @@ void math_mglyph::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -313,7 +297,7 @@ void math_mglyph::add_attributes( const xml::attributes_wc_ptr & Attributes )
} }
void math_mglyph::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void math_mglyph::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
...@@ -324,7 +308,7 @@ void math_mglyph::add_text(const std::wstring & Text) ...@@ -324,7 +308,7 @@ void math_mglyph::add_text(const std::wstring & Text)
} }
void math_mglyph::docx_convert(oox::docx_conversion_context & Context) void math_mglyph::oox_convert(oox::math_context & Context)
{ {
} }
......
...@@ -31,19 +31,14 @@ ...@@ -31,19 +31,14 @@
*/ */
#pragma once #pragma once
#include <iosfwd> #include "math_elements.h"
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/xml/nodetype.h>
#include "office_elements_create.h"
#include "datatypes/common_attlists.h" #include "datatypes/common_attlists.h"
namespace cpdoccore { namespace cpdoccore {
namespace odf_reader { namespace odf_reader {
class math_mi : public office_element_impl<math_mi> class math_mi : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -51,16 +46,12 @@ public: ...@@ -51,16 +46,12 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMI; static const ElementType type = typeMI;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
virtual std::wostream & text_to_stream(::std::wostream & _Wostream) const; virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private: private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes ); 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_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text (const std::wstring & Text); virtual void add_text (const std::wstring & Text);
odf_types::common_math_style_attlist common_attlist_; odf_types::common_math_style_attlist common_attlist_;
...@@ -72,7 +63,7 @@ private: ...@@ -72,7 +63,7 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(math_mi); CP_REGISTER_OFFICE_ELEMENT2(math_mi);
CP_REGISTER_OFFICE_ELEMENT3(math_mi); CP_REGISTER_OFFICE_ELEMENT3(math_mi);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_mo : public office_element_impl<math_mo> class math_mo : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -80,19 +71,15 @@ public: ...@@ -80,19 +71,15 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMO; static const ElementType type = typeMO;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context); virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
virtual std::wostream & text_to_stream(::std::wostream & _Wostream) const;
_CP_OPT(bool) fence_; _CP_OPT(bool) fence_;
_CP_OPT(bool) stretchy_; _CP_OPT(bool) stretchy_;
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text); virtual void add_text(const std::wstring & Text);
odf_types::common_math_style_attlist common_attlist_; odf_types::common_math_style_attlist common_attlist_;
...@@ -104,7 +91,7 @@ private: ...@@ -104,7 +91,7 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(math_mo); CP_REGISTER_OFFICE_ELEMENT2(math_mo);
CP_REGISTER_OFFICE_ELEMENT3(math_mo); CP_REGISTER_OFFICE_ELEMENT3(math_mo);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_mn : public office_element_impl<math_mn> class math_mn : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -112,15 +99,11 @@ public: ...@@ -112,15 +99,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMN; static const ElementType type = typeMN;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text); virtual void add_text(const std::wstring & Text);
odf_types::common_math_style_attlist common_attlist_; odf_types::common_math_style_attlist common_attlist_;
...@@ -132,7 +115,7 @@ private: ...@@ -132,7 +115,7 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(math_mn); CP_REGISTER_OFFICE_ELEMENT2(math_mn);
CP_REGISTER_OFFICE_ELEMENT3(math_mn); CP_REGISTER_OFFICE_ELEMENT3(math_mn);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_mtext : public office_element_impl<math_mtext> class math_mtext : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -140,15 +123,11 @@ public: ...@@ -140,15 +123,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMText; static const ElementType type = typeMText;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text); virtual void add_text(const std::wstring & Text);
odf_types::common_math_style_attlist common_attlist_; odf_types::common_math_style_attlist common_attlist_;
...@@ -160,7 +139,7 @@ private: ...@@ -160,7 +139,7 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(math_mtext); CP_REGISTER_OFFICE_ELEMENT2(math_mtext);
CP_REGISTER_OFFICE_ELEMENT3(math_mtext); CP_REGISTER_OFFICE_ELEMENT3(math_mtext);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_mspace : public office_element_impl<math_mspace> class math_mspace : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -168,15 +147,11 @@ public: ...@@ -168,15 +147,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMSpace; static const ElementType type = typeMSpace;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text); virtual void add_text(const std::wstring & Text);
odf_types::common_math_style_attlist common_attlist_; odf_types::common_math_style_attlist common_attlist_;
...@@ -188,7 +163,7 @@ private: ...@@ -188,7 +163,7 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(math_mspace); CP_REGISTER_OFFICE_ELEMENT2(math_mspace);
CP_REGISTER_OFFICE_ELEMENT3(math_mspace); CP_REGISTER_OFFICE_ELEMENT3(math_mspace);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_ms : public office_element_impl<math_ms> class math_ms : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -196,15 +171,11 @@ public: ...@@ -196,15 +171,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMS; static const ElementType type = typeMS;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text); virtual void add_text(const std::wstring & Text);
odf_types::common_math_style_attlist common_attlist_; odf_types::common_math_style_attlist common_attlist_;
...@@ -216,7 +187,7 @@ private: ...@@ -216,7 +187,7 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(math_ms); CP_REGISTER_OFFICE_ELEMENT2(math_ms);
CP_REGISTER_OFFICE_ELEMENT3(math_ms); CP_REGISTER_OFFICE_ELEMENT3(math_ms);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
class math_mglyph : public office_element_impl<math_mglyph> class math_mglyph : public office_math_element
{ {
public: public:
static const wchar_t * ns; static const wchar_t * ns;
...@@ -224,15 +195,11 @@ public: ...@@ -224,15 +195,11 @@ public:
static const xml::NodeType xml_type = xml::typeElement; static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMGlyph; static const ElementType type = typeMGlyph;
CPDOCCORE_DEFINE_VISITABLE(); virtual void oox_convert(oox::math_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text); virtual void add_text(const std::wstring & Text);
odf_types::common_math_style_attlist common_attlist_; odf_types::common_math_style_attlist common_attlist_;
......
...@@ -64,6 +64,11 @@ ...@@ -64,6 +64,11 @@
#include "templates.h" #include "templates.h"
#include "math_elements.h" #include "math_elements.h"
#include "math_elementaries.h"
#include "math_token_elements.h"
#include "math_table_elements.h"
#include "math_limit_elements.h"
#include "math_layout_elements.h"
#include "paragraph_elements.h" #include "paragraph_elements.h"
#include "text_elements.h" #include "text_elements.h"
......
...@@ -56,9 +56,9 @@ namespace odf_reader { ...@@ -56,9 +56,9 @@ namespace odf_reader {
class document_context; class document_context;
class office_element; class office_element;
typedef shared_ptr<office_element>::Type office_element_ptr; typedef shared_ptr<office_element>::Type office_element_ptr;
typedef weak_ptr<office_element>::Type office_element_weak_ptr; typedef weak_ptr<office_element>::Type office_element_weak_ptr;
typedef ::std::vector<office_element_ptr> office_element_ptr_array; typedef std::vector<office_element_ptr> office_element_ptr_array;
class office_element : public xml::element<wchar_t>, class office_element : public xml::element<wchar_t>,
public common::read_doc_element, public common::read_doc_element,
...@@ -81,13 +81,13 @@ public: ...@@ -81,13 +81,13 @@ public:
void setContext(document_context * Context) { context_ = Context; } void setContext(document_context * Context) { context_ = Context; }
public: public:
virtual ::std::wostream & text_to_stream(::std::wostream & _Wostream) const virtual std::wostream & text_to_stream(std::wostream & _Wostream) const
{ {
_CP_LOG << L"[warning] use base text_to_stream\n"; _CP_LOG << L"[warning] use base text_to_stream\n";
return _Wostream; return _Wostream;
} }
virtual ::std::wostream & xml_to_stream(::std::wostream & _Wostream) const virtual std::wostream & xml_to_stream(std::wostream & _Wostream) const
{ {
_CP_LOG << L"[warning] use base xml_to_stream\n"; _CP_LOG << L"[warning] use base xml_to_stream\n";
return _Wostream; return _Wostream;
......
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
bool register_element(const std::wstring &ns, const std::wstring & name, CreateFuncImpl f); bool register_element(const std::wstring &ns, const std::wstring & name, CreateFuncImpl f);
// Создать элемент по имени // Создать элемент по имени
office_element_ptr create(const ::std::wstring & ns, const ::std::wstring & name, document_context * Context = NULL, bool isRoot = false) const; office_element_ptr create(const std::wstring & ns, const std::wstring & name, document_context * Context = NULL, bool isRoot = false) const;
private: private:
typedef std::map<std::wstring, CreateFuncImpl> MapType; typedef std::map<std::wstring, CreateFuncImpl> MapType;
...@@ -134,16 +134,16 @@ template<class T> int RegisterElement<T>::class_registered_1_ = 0; //without nam ...@@ -134,16 +134,16 @@ template<class T> int RegisterElement<T>::class_registered_1_ = 0; //without nam
// Создать элемент и в случае успеха прочитать его содержимое из SAX, поместить в shared_ptr // Создать элемент и в случае успеха прочитать его содержимое из SAX, поместить в shared_ptr
bool create_element_and_read(xml::sax * Reader, bool create_element_and_read(xml::sax * Reader,
const ::std::wstring & Ns, const std::wstring & Ns,
const ::std::wstring & Name, const std::wstring & Name,
office_element_ptr & _Element, office_element_ptr & _Element,
document_context * Context, document_context * Context,
bool isRoot = false); bool isRoot = false);
// Создать элемент и в случае успеха прочитать его содержимое из SAX, поместить в array // Создать элемент и в случае успеха прочитать его содержимое из SAX, поместить в array
bool create_element_and_read(xml::sax * Reader, bool create_element_and_read(xml::sax * Reader,
const ::std::wstring & Ns, const std::wstring & Ns,
const ::std::wstring & Name, const std::wstring & Name,
office_element_ptr_array & _Elements, office_element_ptr_array & _Elements,
document_context * Context, document_context * Context,
bool isRoot = false); bool isRoot = false);
......
...@@ -204,6 +204,7 @@ enum ElementType ...@@ -204,6 +204,7 @@ enum ElementType
typeOfficeDocumentMeta, typeOfficeDocumentMeta,
typeOfficeDocumentSettings, typeOfficeDocumentSettings,
typeMathElement,
typeMath, typeMath,
typeMathSemantics, typeMathSemantics,
typeMathAnnotation, typeMathAnnotation,
......
...@@ -72,180 +72,88 @@ std::wstring delete_apostroph_in_name(std::wstring value) ...@@ -72,180 +72,88 @@ std::wstring delete_apostroph_in_name(std::wstring value)
void text_format_properties_content::add_attributes( const xml::attributes_wc_ptr & Attributes ) void text_format_properties_content::add_attributes( const xml::attributes_wc_ptr & Attributes )
{ {
// 15.4.1 CP_APPLY_ATTR(L"fo:font-variant", fo_font_variant_);
CP_APPLY_ATTR(L"fo:font-variant", fo_font_variant_); CP_APPLY_ATTR(L"fo:text-transform", fo_text_transform_);
CP_APPLY_ATTR(L"fo:color", fo_color_);
// 15.4.2 CP_APPLY_ATTR(L"fo:font-family", fo_font_family_);
CP_APPLY_ATTR(L"fo:text-transform", fo_text_transform_); CP_APPLY_ATTR(L"fo:font-size", fo_font_size_);
CP_APPLY_ATTR(L"fo:letter-spacing", fo_letter_spacing_);
// 15.4.3 CP_APPLY_ATTR(L"fo:language", fo_language_);
CP_APPLY_ATTR(L"fo:color", fo_color_); CP_APPLY_ATTR(L"fo:country", fo_country_);
CP_APPLY_ATTR(L"fo:font-style", fo_font_style_);
// 15.4.4 CP_APPLY_ATTR(L"fo:text-shadow", fo_text_shadow_);
CP_APPLY_ATTR(L"style:use-window-font-color", style_use_window_font_color_); CP_APPLY_ATTR(L"fo:font-weight", fo_font_weight_);
CP_APPLY_ATTR(L"fo:background-color", fo_background_color_);
// 15.4.5 CP_APPLY_ATTR(L"fo:hyphenate", fo_hyphenate_);
CP_APPLY_ATTR(L"style:text-outline", style_text_outline_); CP_APPLY_ATTR(L"fo:hyphenation-remain-char-count", fo_hyphenation_remain_char_count_);
CP_APPLY_ATTR(L"fo:hyphenation-push-char-count", fo_hyphenation_push_char_count_);
// 15.4.6
CP_APPLY_ATTR(L"style:text-line-through-type", style_text_line_through_type_); CP_APPLY_ATTR(L"style:use-window-font-color", style_use_window_font_color_);
CP_APPLY_ATTR(L"style:text-outline", style_text_outline_);
// 15.4.7 CP_APPLY_ATTR(L"style:text-line-through-type", style_text_line_through_type_);
CP_APPLY_ATTR(L"style:text-line-through-style", style_text_line_through_style_); CP_APPLY_ATTR(L"style:text-line-through-style", style_text_line_through_style_);
CP_APPLY_ATTR(L"style:text-line-through-width", style_text_line_through_width_);
// 15.4.8 CP_APPLY_ATTR(L"style:text-line-through-color", style_text_line_through_color_);
CP_APPLY_ATTR(L"style:text-line-through-width", style_text_line_through_width_); CP_APPLY_ATTR(L"style:text-line-through-text", style_text_line_through_text_);
// 15.4.9
CP_APPLY_ATTR(L"style:text-line-through-color", style_text_line_through_color_);
// 15.4.10
CP_APPLY_ATTR(L"style:text-line-through-text", style_text_line_through_text_);
// 15.4.11
CP_APPLY_ATTR(L"style:text-line-through-text-style", style_text_line_through_text_style_); CP_APPLY_ATTR(L"style:text-line-through-text-style", style_text_line_through_text_style_);
CP_APPLY_ATTR(L"style:text-position", style_text_position_);
// 15.4.12 CP_APPLY_ATTR(L"style:font-name", style_font_name_);
CP_APPLY_ATTR(L"style:text-position", style_text_position_); CP_APPLY_ATTR(L"style:font-name-asian", style_font_name_asian_);
CP_APPLY_ATTR(L"style:font-name-complex", style_font_name_complex_);
// 15.4.13 CP_APPLY_ATTR(L"style:font-family-asian", style_font_family_asian_);
CP_APPLY_ATTR(L"style:font-name", style_font_name_); CP_APPLY_ATTR(L"style:font-family-complex", style_font_family_complex_);
CP_APPLY_ATTR(L"style:font-name-asian", style_font_name_asian_); CP_APPLY_ATTR(L"style:font-family-generic", style_font_family_generic_);
CP_APPLY_ATTR(L"style:font-name-complex", style_font_name_complex_); CP_APPLY_ATTR(L"style:font-family-generic-asian", style_font_family_generic_asian_);
// 15.4.14
CP_APPLY_ATTR(L"fo:font-family", fo_font_family_);
CP_APPLY_ATTR(L"style:font-family-asian", style_font_family_asian_);
CP_APPLY_ATTR(L"style:font-family-complex", style_font_family_complex_);
// 15.4.15
CP_APPLY_ATTR(L"style:font-family-generic", style_font_family_generic_);
CP_APPLY_ATTR(L"style:font-family-generic-asian", style_font_family_generic_asian_);
CP_APPLY_ATTR(L"style:font-family-generic-complex", style_font_family_generic_complex_); CP_APPLY_ATTR(L"style:font-family-generic-complex", style_font_family_generic_complex_);
CP_APPLY_ATTR(L"style:font-style-name", style_font_style_name_);
// 15.4.16 CP_APPLY_ATTR(L"style:font-style-name-asian", style_font_style_name_asian_);
CP_APPLY_ATTR(L"style:font-style-name", style_font_style_name_); CP_APPLY_ATTR(L"style:font-style-name-complex", style_font_style_name_complex_);
CP_APPLY_ATTR(L"style:font-style-name-asian", style_font_style_name_asian_); CP_APPLY_ATTR(L"style:font-pitch", style_font_pitch_);
CP_APPLY_ATTR(L"style:font-style-name-complex", style_font_style_name_complex_); CP_APPLY_ATTR(L"style:font-pitch", style_font_pitch_asian_);
CP_APPLY_ATTR(L"style:font-pitch-complex", style_font_pitch_complex_);
// 15.4.17 CP_APPLY_ATTR(L"style:font-charset", style_font_charset_);
CP_APPLY_ATTR(L"style:font-pitch", style_font_pitch_); CP_APPLY_ATTR(L"style:font-charset-asian", style_font_charset_asian_);
CP_APPLY_ATTR(L"style:font-pitch", style_font_pitch_asian_); CP_APPLY_ATTR(L"style:font-charset-complex", style_font_charset_complex_);
CP_APPLY_ATTR(L"style:font-pitch-complex", style_font_pitch_complex_); CP_APPLY_ATTR(L"style:font-size-asian", style_font_size_asian_);
CP_APPLY_ATTR(L"style:font-size-complex", style_font_size_complex_);
// 15.4.18 CP_APPLY_ATTR(L"style:font-size-rel", style_font_size_rel_);
CP_APPLY_ATTR(L"style:font-charset", style_font_charset_); CP_APPLY_ATTR(L"style:font-size-rel-asian", style_font_size_rel_asian_);
CP_APPLY_ATTR(L"style:font-charset-asian", style_font_charset_asian_); CP_APPLY_ATTR(L"style:font-size-rel-complex", style_font_size_rel_complex_);
CP_APPLY_ATTR(L"style:font-charset-complex", style_font_charset_complex_); CP_APPLY_ATTR(L"style:script-type", style_script_type_);
CP_APPLY_ATTR(L"style:language-asian", style_language_asian_);
// 15.4.19 CP_APPLY_ATTR(L"style:language-complex", style_language_complex_);
CP_APPLY_ATTR(L"fo:font-size", fo_font_size_); CP_APPLY_ATTR(L"style:country-asian", style_country_asian_);
CP_APPLY_ATTR(L"style:font-size-asian", style_font_size_asian_); CP_APPLY_ATTR(L"style:country-complex", style_country_complex_);
CP_APPLY_ATTR(L"style:font-size-complex", style_font_size_complex_); CP_APPLY_ATTR(L"style:font-style-asian", style_font_style_asian_);
CP_APPLY_ATTR(L"style:font-style-complex", style_font_style_complex_);
// 15.4.20 CP_APPLY_ATTR(L"style:font-relief", style_font_relief_);
CP_APPLY_ATTR(L"style:font-size-rel", style_font_size_rel_); CP_APPLY_ATTR(L"style:text-underline-type", style_text_underline_type_);
CP_APPLY_ATTR(L"style:font-size-rel-asian", style_font_size_rel_asian_); CP_APPLY_ATTR(L"style:text-underline-style", style_text_underline_style_);
CP_APPLY_ATTR(L"style:font-size-rel-complex", style_font_size_rel_complex_); CP_APPLY_ATTR(L"style:text-underline-width", style_text_underline_width_);
CP_APPLY_ATTR(L"style:text-underline-color", style_text_underline_color_);
// 15.4.21 CP_APPLY_ATTR(L"style:font-weight-asian", style_font_weight_asian_);
CP_APPLY_ATTR(L"style:script-type", style_script_type_); CP_APPLY_ATTR(L"style:font-weight-complex", style_font_weight_complex_);
CP_APPLY_ATTR(L"style:text-underline-mode", style_text_underline_mode_);
// 15.4.22 CP_APPLY_ATTR(L"style:text-line-through-mode", style_text_line_through_mode_);
CP_APPLY_ATTR(L"fo:letter-spacing", fo_letter_spacing_); CP_APPLY_ATTR(L"style:letter-kerning", style_letter_kerning_);
CP_APPLY_ATTR(L"style:text-blinking", style_text_blinking_);
// 15.4.23 CP_APPLY_ATTR(L"style:text-combine", style_text_combine_);
CP_APPLY_ATTR(L"fo:language", fo_language_); CP_APPLY_ATTR(L"style:text-combine-start-char", style_text_combine_start_char_);
CP_APPLY_ATTR(L"style:language-asian", style_language_asian_); CP_APPLY_ATTR(L"style:text-combine-end-char", style_text_combine_end_char_);
CP_APPLY_ATTR(L"style:language-complex", style_language_complex_); CP_APPLY_ATTR(L"style:text-emphasize", style_text_emphasize_);
CP_APPLY_ATTR(L"style:text-scale", style_text_scale_);
// 15.4.24 CP_APPLY_ATTR(L"style:text-rotation-angle", style_text_rotation_angle_);
CP_APPLY_ATTR(L"fo:country", fo_country_); CP_APPLY_ATTR(L"style:text-rotation-scale", style_text_rotation_scale_);
CP_APPLY_ATTR(L"style:country-asian", style_country_asian_); CP_APPLY_ATTR(L"style:text-overline-color", style_text_overline_color_);
CP_APPLY_ATTR(L"style:country-complex", style_country_complex_); CP_APPLY_ATTR(L"style:text-overline-mode", style_text_overline_mode_);
CP_APPLY_ATTR(L"style:text-overline-style", style_text_overline_style_);
// 15.4.25
CP_APPLY_ATTR(L"fo:font-style", fo_font_style_); CP_APPLY_ATTR(L"text:display", text_display_);
CP_APPLY_ATTR(L"style:font-style-asian", style_font_style_asian_); CP_APPLY_ATTR(L"text:condition", text_condition_);
CP_APPLY_ATTR(L"style:font-style-complex", style_font_style_complex_);
// 15.4.26
CP_APPLY_ATTR(L"style:font-relief", style_font_relief_);
// 15.4.27
CP_APPLY_ATTR(L"fo:text-shadow", fo_text_shadow_);
// 15.4.28
CP_APPLY_ATTR(L"style:text-underline-type", style_text_underline_type_);
// 15.4.29
CP_APPLY_ATTR(L"style:text-underline-style", style_text_underline_style_);
// 15.4.30
CP_APPLY_ATTR(L"style:text-underline-width", style_text_underline_width_);
// 15.4.31
CP_APPLY_ATTR(L"style:text-underline-color", style_text_underline_color_);
// 15.4.32
CP_APPLY_ATTR(L"fo:font-weight", fo_font_weight_);
CP_APPLY_ATTR(L"style:font-weight-asian", style_font_weight_asian_);
CP_APPLY_ATTR(L"style:font-weight-complex", style_font_weight_complex_);
// 15.4.33
CP_APPLY_ATTR(L"style:text-underline-mode", style_text_underline_mode_);
// 15.4.34
CP_APPLY_ATTR(L"style:text-line-through-mode", style_text_line_through_mode_);
// 15.4.35
CP_APPLY_ATTR(L"style:letter-kerning", style_letter_kerning_);
// 15.4.36
CP_APPLY_ATTR(L"style:text-blinking", style_text_blinking_);
// 15.4.37
CP_APPLY_ATTR(L"fo:background-color", fo_background_color_);
// 15.4.38
CP_APPLY_ATTR(L"style:text-combine", style_text_combine_);
// 15.4.39
CP_APPLY_ATTR(L"style:text-combine-start-char", style_text_combine_start_char_);
CP_APPLY_ATTR(L"style:text-combine-end-char", style_text_combine_end_char_);
// 15.4.40
CP_APPLY_ATTR(L"style:text-emphasize", style_text_emphasize_);
// 15.4.41
CP_APPLY_ATTR(L"style:text-scale", style_text_scale_);
// 15.4.42
CP_APPLY_ATTR(L"style:text-rotation-angle", style_text_rotation_angle_);
// 15.4.43
CP_APPLY_ATTR(L"style:text-rotation-scale", style_text_rotation_scale_);
// 15.4.44
CP_APPLY_ATTR(L"fo:hyphenate", fo_hyphenate_);
// 15.4.45
CP_APPLY_ATTR(L"fo:hyphenation-remain-char-count", fo_hyphenation_remain_char_count_);
// 15.4.46
CP_APPLY_ATTR(L"fo:hyphenation-push-char-count", fo_hyphenation_push_char_count_);
// 15.4.47
CP_APPLY_ATTR(L"text:display", text_display_);
CP_APPLY_ATTR(L"text:condition", text_condition_);
CP_APPLY_ATTR(L"style:text-overline-color", style_text_overline_color_);
CP_APPLY_ATTR(L"style:text-overline-mode", style_text_overline_mode_);
CP_APPLY_ATTR(L"style:text-overline-style", style_text_overline_style_);
} }
int text_format_properties_content::process_font_size(const _CP_OPT(font_size) & FontSize, const style_instance * currnetStyle, bool Complex, double Mul) int text_format_properties_content::process_font_size(const _CP_OPT(font_size) & FontSize, const style_instance * currnetStyle, bool Complex, double Mul)
{ {
if (FontSize) if (FontSize)
...@@ -293,7 +201,7 @@ double text_format_properties_content::process_font_size_impl(const _CP_OPT(font ...@@ -293,7 +201,7 @@ double text_format_properties_content::process_font_size_impl(const _CP_OPT(font
return -1.0; return -1.0;
} }
int text_format_properties_content::process_font_weight(const optional<font_weight>::Type & FontWeight) int text_format_properties_content::process_font_weight(const _CP_OPT(font_weight) & FontWeight)
{ {
if (FontWeight) if (FontWeight)
{ {
...@@ -305,7 +213,7 @@ int text_format_properties_content::process_font_weight(const optional<font_weig ...@@ -305,7 +213,7 @@ int text_format_properties_content::process_font_weight(const optional<font_weig
return 0; //not set return 0; //not set
} }
int text_format_properties_content::process_font_style(const optional<font_style>::Type & FontStyle) int text_format_properties_content::process_font_style(const _CP_OPT(font_style) & FontStyle)
{ {
if (FontStyle) if (FontStyle)
{ {
...@@ -587,6 +495,7 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context & ...@@ -587,6 +495,7 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
} }
} }
void text_format_properties_content::docx_convert(oox::docx_conversion_context & Context) void text_format_properties_content::docx_convert(oox::docx_conversion_context & Context)
{ {
std::wostream & _pPr = Context.get_styles_context().paragraph_nodes(); std::wostream & _pPr = Context.get_styles_context().paragraph_nodes();
...@@ -599,9 +508,10 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context & ...@@ -599,9 +508,10 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
else else
_pPr << L"<w:suppressAutoHyphens w:val=\"true\" />"; _pPr << L"<w:suppressAutoHyphens w:val=\"true\" />";
} }
std::wostream & _rPr = Context.get_styles_context().text_style(); std::wostream & _rPr = Context.get_styles_context().text_style();
if (Context.rtl())
if (Context.rtl())
{ {
_rPr << L"<w:rtl/>";/* w:val=\"true\" */ _rPr << L"<w:rtl/>";/* w:val=\"true\" */
} }
...@@ -961,42 +871,6 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context & ...@@ -961,42 +871,6 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
std::wstring w_cs; std::wstring w_cs;
std::wstring w_ascii = w_hAnsi = w_cs = (style_font_name_ ? *style_font_name_: L""); std::wstring w_ascii = w_hAnsi = w_cs = (style_font_name_ ? *style_font_name_: L"");
if ( !Context.process_math_formula_ )
{
if (style_font_name_asian_)
w_eastAsia = *style_font_name_asian_;
if (style_font_name_complex_)
w_cs = *style_font_name_complex_;
fonts_container & fonts = Context.root()->odf_context().fontContainer();
font_instance * font = fonts.font_by_style_name(w_ascii);
if (font)
w_ascii = font->name();
font = fonts.font_by_style_name(w_hAnsi);
if (font)
w_hAnsi = font->name();
if (w_ascii.empty() && fo_font_family_)
{
w_ascii = fo_font_family_.get();
}
if (w_hAnsi.empty() && fo_font_family_)
{
w_hAnsi = fo_font_family_.get();
}
font = fonts.font_by_style_name(w_eastAsia);
if (font)
w_eastAsia = font->name();
font = fonts.font_by_style_name(w_cs);
if (font)
w_cs = font->name();
}
_rPr << L"<w:rFonts "; _rPr << L"<w:rFonts ";
if (!w_ascii.empty()) if (!w_ascii.empty())
_rPr << L"w:ascii=\"" << w_ascii <<"\" "; _rPr << L"w:ascii=\"" << w_ascii <<"\" ";
...@@ -1113,6 +987,447 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context & ...@@ -1113,6 +987,447 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
} }
} }
void text_format_properties_content::oox_convert (std::wostream & _rPr, bool graphic)
{
const int W = process_font_weight (fo_font_weight_);
const int fontStyle = process_font_style (fo_font_style_);
const int WCs = process_font_weight (style_font_weight_complex_);
if (graphic)
{
_rPr << L"<a:rPr";
int fontSize = process_font_size(fo_font_size_, NULL) / 2 * 100;
if (fontSize > 0)
{
_rPr << L" sz=\"" << fontSize << L"\"";
}
if (W)
{
if (W > 0) _rPr << L" b=\"1\"";
else _rPr << L" b=\"0\"";
}
if (fontStyle)
{
if (fontStyle > 0) _rPr << L" i=\"1\"";
else _rPr << L" i=\"0\"";
}
_rPr << L">";
_CP_OPT(color) color_text = fo_color_;
if (color_text)
{
_rPr << L"<a:solidFill><a:srgbClr val=\"" << color_text->get_hex_value() << "\"/></a:solidFill>";
}
//else if (style_use_window_font_color_ && *style_use_window_font_color_)
//{
// _rPr << L"<w:color w:val=\"auto\" />";
//}
//if (fo_background_color_)
//{
// std::wstring w_fill;
// if (fo_background_color_->get_type() == background_color::Transparent)
// w_fill = L"auto";
// else
// w_fill = fo_background_color_->get_color().get_hex_value();
// _rPr << L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"" << w_fill << "\" />";
//}
if (style_font_name_)
{
_rPr << L"<a:latin typeface=\"" << style_font_name_.get() << "\"/>";
}
_rPr << L"</a:rPr>";
}
else
{
_rPr << L"<w:rPr>";
if (r_style_)
{
_rPr << L"<w:rStyle w:val=\"" << *r_style_ << L"\" />";
}
const int W = process_font_weight(fo_font_weight_);
if (W)
{
if (W > 0)
_rPr << L"<w:b/>";
else
_rPr << L"<w:b w:val=\"false\" />";
}
if (WCs)
{
if (WCs > 0)
_rPr << L"<w:bCs/>";
else
_rPr << L"<w:bCs w:val=\"false\" />";
}
if (fo_text_transform_)
{
_rPr << (fo_text_transform_->get_type() == text_transform::Uppercase ? L"<w:caps w:val=\"true\" />" : L"<w:caps w:val=\"false\" />");
}
if (fontStyle)
{
if (fontStyle > 0)
_rPr << L"<w:i />";
else
_rPr << L"<w:i w:val=\"false\" />";
}
const int fontStyleComplex = process_font_style(style_font_style_complex_);
if (fontStyleComplex)
{
if (fontStyleComplex > 0)
_rPr << L"<w:iCs />";
else
_rPr << L"<w:iCs w:val=\"false\" />";
}
if (fo_font_variant_)
{
_rPr << (fo_font_variant_->get_type() == font_variant::SmallCaps ? L"<w:smallCaps w:val=\"true\" />" : L"<w:smallCaps w:val=\"true\" />" );
}
if (style_font_relief_)
{
if (style_font_relief_->get_type() == font_relief::Embossed)
_rPr << L"<w:emboss w:val=\"true\" />";
else if (style_font_relief_->get_type() == font_relief::Engraved)
_rPr << L"<w:imprint w:val=\"true\" />";
else
{
_rPr << L"<w:emboss w:val=\"false\" />";
_rPr << L"<w:imprint w:val=\"false\" />";
}
}
if (style_text_outline_)
{
_rPr << ((*style_text_outline_ == true) ? L"<w:outline w:val=\"true\" />" : L"<w:outline w:val=\"false\" />" );
}
if (fo_text_shadow_)
{
_rPr << ((fo_text_shadow_->get_type() == shadow_type::Enable) ? L"<w:shadow w:val=\"true\" />" : L"<w:shadow w:val=\"false\" />" );
}
if (text_display_)
{
if (text_display_->get_type() == text_display::None)
_rPr << L"<w:vanish />";
}
// underline
{
line_width under = style_text_underline_width_.get_value_or(line_width::Auto);
bool underlineBold = under.get_type() == line_width::Bold ||
under.get_type() == line_width::Thick;
std::wstring underline = L"";
if ( style_text_underline_type_ && style_text_underline_type_->get_type() == line_type::Non ||
style_text_underline_style_ && style_text_underline_style_->get_type() == line_style::None
)
{
// подчеркивание выключено
underline = L"none";
}
else if (style_text_underline_type_ &&
(!style_text_underline_style_ || style_text_underline_style_ && style_text_underline_style_->get_type() == line_style::Solid) )
{
if (underlineBold)
underline = L"thick";
switch (style_text_underline_type_->get_type())
{
case line_type::Single:
underline = L"single";
break;
case line_type::Double:
underline = L"double";
break;
}
}
else if (style_text_underline_style_)
{
switch (style_text_underline_style_->get_type())
{
case line_style::Solid:
if (underlineBold)
underline = L"thick";
else
underline = L"single";
break;
case line_style::Dotted:
if (underlineBold)
underline = L"dottedHeavy";
else
underline = L"dotted";
break;
case line_style::Dash:
if (underlineBold)
underline = L"dashedHeavy";
else
underline = L"dash";
break;
case line_style::LongDash:if (underlineBold)
underline = L"dashLongHeavy";
else
underline = L"dashLong";
break;
case line_style::DotDash:
if (underlineBold)
underline = L"dashDotHeavy";
else
underline = L"dotDash";
break;
case line_style::DotDotDash:
if (underlineBold)
underline = L"dashDotDotHeavy";
else
underline = L"dotDotDash";
break;
case line_style::Wave:
if (underlineBold)
underline = L"wavyHeavy";
else if (style_text_underline_type_.get_value_or( line_type(line_type::Single) ).get_type() == line_type::Double)
underline = L"wavyDouble";
else
underline = L"wave";
break;
}
}
std::wstring color = L"";
if (style_text_underline_color_ &&
style_text_underline_color_->get_type() == underline_color::Enabled)
{
color = style_text_underline_color_->get_color().get_color();
}
if (!underline.empty())
{
_rPr << L"<w:u w:val=\"" << underline << "\" ";
if (!color.empty())
_rPr << L"w:color=\"" << color << L"\" ";
_rPr << L"/>";
}
}
if (style_text_line_through_type_ && style_text_line_through_type_->get_type() == line_type::Non ||
style_text_line_through_style_ && style_text_line_through_style_->get_type() == line_style::None
)
{
_rPr << L"<w:dstrike w:val=\"false\" />";
_rPr << L"<w:strike w:val=\"false\" />";
}
else if (style_text_line_through_type_)
{
if (style_text_line_through_type_->get_type() == line_type::Single)
_rPr << L"<w:strike w:val=\"true\" />";
else if (style_text_line_through_type_->get_type() == line_type::Double)
_rPr << L"<w:dstrike w:val=\"true\" />";
}
else if (style_text_line_through_style_ && style_text_line_through_style_->get_type() != line_style::None)
{
_rPr << L"<w:strike w:val=\"true\" />";
}
bool needProcessFontSize = true;
if (style_text_position_)
{
bool noNeedSize = false;
if (style_text_position_->get_type() == text_position::Sub)
{
_rPr << L"<w:vertAlign w:val=\"subscript\" />";
noNeedSize = true;
}
if (style_text_position_->get_type() == text_position::Super)
{
_rPr << L"<w:vertAlign w:val=\"superscript\" />";
noNeedSize = true;
}
double fontSizeVal = (fo_font_size_) ? process_font_size_impl(fo_font_size_, NULL) :
process_font_size_impl(font_size(percent(100.0)), NULL);
if (style_text_position_->get_type() == text_position::Percent)
{
const double mul = style_text_position_->get_position().get_value() / 100.0;
if (fontSizeVal > 0)
{
const std::wstring position = boost::lexical_cast<std::wstring>( (int)(fontSizeVal * mul + 0.5));
if (!position.empty())
{
_rPr << L"<w:position w:val=\"" << position << "\" />";
}
}
}
if (style_text_position_->has_font_size() && !noNeedSize)
{
const double mul = style_text_position_->font_size().get_value() / 100.0;
if (fontSizeVal > 0 && mul > 0)
{
const std::wstring fontSize = boost::lexical_cast<std::wstring>((int)(fontSizeVal * mul + 0.5));
if (!fontSize.empty())
{
needProcessFontSize = false;
_rPr << L"<w:sz w:val=\"" << fontSize << "\" />";
}
}
}
}
if (style_text_rotation_angle_)
{
unsigned int value = (std::abs)(*style_text_rotation_angle_);
if (90 == value || 270 == value)
_rPr << L"<w:eastAsianLayout w:vert=\"true\" />";
}
if (style_text_scale_)
{
_rPr << L"<w:w w:val=\"" << style_text_scale_->get_value() << "\" />";
}
if (needProcessFontSize)
{
int fontSize = process_font_size(fo_font_size_, NULL);
if (fontSize > 0)
{
_rPr << L"<w:sz w:val=\"" << fontSize << "\" />";
}
}
int fontSizeComplex = process_font_size(style_font_size_complex_, NULL, true);
if (fontSizeComplex > 0)
_rPr << L"<w:szCs w:val=\"" << fontSizeComplex << "\" />";
if (fo_letter_spacing_)
{
if (fo_letter_spacing_->get_type() == letter_spacing::Normal)
_rPr << L"<w:spacing w:val=\"0\" />";
else
_rPr << L"<w:spacing w:val=\"" <<
(int)(20.0 * fo_letter_spacing_->get_length().get_value_unit(length::pt))
<< "\" />";
}
if (style_text_emphasize_)
{
std::wstring em = L"";
switch(style_text_emphasize_->get_type())
{
case text_emphasize::None:
em = L"none";
break;
case text_emphasize::Accent:
em = L"comma";
break;
case text_emphasize::Dot:
if (style_text_emphasize_->get_type_2() == text_emphasize::Above)
em = L"dot";
else
em = L"underDot";
break;
case text_emphasize::Circle:
em = L"circle";
break;
case text_emphasize::Disc:
em = L"dot"; // ?
break;
}
_rPr << L"<w:em w:val=\"" << em << "\" />";
}
if (style_font_name_ || style_font_name_asian_ || style_font_name_complex_ || fo_font_family_)
{
std::wstring w_eastAsia;
std::wstring w_hAnsi;
std::wstring w_cs;
std::wstring w_ascii = w_hAnsi = w_cs = (style_font_name_ ? *style_font_name_: L"");
_rPr << L"<w:rFonts ";
if (!w_ascii.empty())
_rPr << L"w:ascii=\"" << w_ascii <<"\" ";
if (!w_hAnsi.empty())
_rPr << L"w:hAnsi=\"" << w_hAnsi <<"\" ";
if (!w_eastAsia.empty())
_rPr << L"w:eastAsia=\"" << w_eastAsia <<"\" ";
if (!w_cs.empty())
_rPr << L"w:cs=\"" << w_cs <<"\" ";
_rPr << L" />";
}
_CP_OPT(color) color_text = fo_color_;
if (color_text)
{
_rPr << L"<w:color w:val=\"" << color_text->get_hex_value() << "\" />";
}
else if (style_use_window_font_color_ && *style_use_window_font_color_)
{
_rPr << L"<w:color w:val=\"auto\" />";
}
if (fo_background_color_)
{
std::wstring w_fill;
if (fo_background_color_->get_type() == background_color::Transparent)
w_fill = L"auto";
else
w_fill = fo_background_color_->get_color().get_hex_value();
_rPr << L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"" << w_fill << "\" />";
}
if (fo_language_ || style_language_asian_ || style_language_complex_)
{
std::wstring w_val;
if (fo_language_)
{
w_val = *fo_language_;
if (fo_country_)
w_val += L"-" + *fo_country_;
}
std::wstring w_eastAsia;
if (style_language_asian_)
{
w_eastAsia = *style_language_asian_;
if (style_country_asian_)
w_eastAsia += L"-" + *style_country_asian_;
}
std::wstring w_bidi;
if (style_language_complex_)
{
w_bidi = *style_language_complex_;
if (style_country_complex_)
w_bidi += L"-" + *style_country_complex_;
}
_rPr << L"<w:lang ";
if (!w_val.empty())
_rPr << L"w:val=\"" << w_val << "\" ";
if (!w_eastAsia.empty())
_rPr << L"w:eastAsia=\"" << w_eastAsia << "\" ";
if (!w_bidi.empty())
_rPr << L"w:bidi=\"" << w_bidi << "\" ";
_rPr << L"/>";
}
if (style_text_blinking_)
{
std::wstring w_val = L"none";
if (*style_text_blinking_)
w_val = L"blinkBackground";
_rPr << L"<w:effect w:val=\"" << w_val << "\" />";
}
_rPr << L"</w:rPr>";
}
}
void apply_font_size(optional<font_size>::Type & A, const optional<font_size>::Type & B) void apply_font_size(optional<font_size>::Type & A, const optional<font_size>::Type & B)
{ {
if (B && if (B &&
...@@ -1160,12 +1475,12 @@ void text_format_properties_content::apply_from(const text_format_properties_con ...@@ -1160,12 +1475,12 @@ void text_format_properties_content::apply_from(const text_format_properties_con
_CP_APPLY_PROP(style_font_style_name_asian_, Other.style_font_style_name_asian_); _CP_APPLY_PROP(style_font_style_name_asian_, Other.style_font_style_name_asian_);
_CP_APPLY_PROP(style_font_style_name_complex_, Other.style_font_style_name_complex_); _CP_APPLY_PROP(style_font_style_name_complex_, Other.style_font_style_name_complex_);
_CP_APPLY_PROP(style_font_pitch_, Other.style_font_pitch_); _CP_APPLY_PROP(style_font_pitch_, Other.style_font_pitch_);
_CP_APPLY_PROP(style_font_pitch_asian_, Other.style_font_pitch_asian_); _CP_APPLY_PROP(style_font_pitch_asian_, Other.style_font_pitch_asian_);
_CP_APPLY_PROP(style_font_pitch_complex_, Other.style_font_pitch_complex_); _CP_APPLY_PROP(style_font_pitch_complex_, Other.style_font_pitch_complex_);
_CP_APPLY_PROP(style_font_charset_, Other.style_font_charset_); _CP_APPLY_PROP(style_font_charset_, Other.style_font_charset_);
_CP_APPLY_PROP(style_font_charset_asian_, Other.style_font_charset_asian_); _CP_APPLY_PROP(style_font_charset_asian_, Other.style_font_charset_asian_);
_CP_APPLY_PROP(style_font_charset_complex_, Other.style_font_charset_complex_); _CP_APPLY_PROP(style_font_charset_complex_, Other.style_font_charset_complex_);
apply_font_size(fo_font_size_, Other.fo_font_size_); apply_font_size(fo_font_size_, Other.fo_font_size_);
......
...@@ -76,19 +76,21 @@ class text_format_properties_content : public oox::conversion_element ...@@ -76,19 +76,21 @@ class text_format_properties_content : public oox::conversion_element
public: public:
void add_attributes( const xml::attributes_wc_ptr & Attributes ); void add_attributes( const xml::attributes_wc_ptr & Attributes );
void docx_convert(oox::docx_conversion_context & Context); void docx_convert (oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context); void pptx_convert (oox::pptx_conversion_context & Context);
void pptx_convert_as_list(oox::pptx_conversion_context & Context); void pptx_convert_as_list (oox::pptx_conversion_context & Context);
void oox_convert (std::wostream & stream, bool graphic);
void apply_from(const text_format_properties_content & Other); void apply_from (const text_format_properties_content & Other);
void apply_to(std::vector<_property> & properties); void apply_to (std::vector<_property> & properties);
void set_r_style(const std::wstring & rStyle) { r_style_ = rStyle; } void set_r_style (const std::wstring & rStyle) { r_style_ = rStyle; }
int process_font_size(const optional<odf_types::font_size>::Type & FontSize, const style_instance * currnetStyle, bool Complex = false, double Mul = 1.0);
int process_font_size (const _CP_OPT(odf_types::font_size) & FontSize, const style_instance * currnetStyle, bool Complex = false, double Mul = 1.0);
private: private:
static double process_font_size_impl(const _CP_OPT(odf_types::font_size) & FontSize, const style_instance * currnetStyle, bool Complex = false, double Mul = 1.0); static double process_font_size_impl (const _CP_OPT(odf_types::font_size) & FontSize, const style_instance * currnetStyle, bool Complex = false, double Mul = 1.0);
static int process_font_weight(const optional<odf_types::font_weight>::Type & FontWeight); static int process_font_weight (const _CP_OPT(odf_types::font_weight) & FontWeight);
static int process_font_style(const optional<odf_types::font_style>::Type & FontStyle); static int process_font_style (const _CP_OPT(odf_types::font_style) & FontStyle);
public: public:
_CP_OPT(std::wstring) r_style_; _CP_OPT(std::wstring) r_style_;
...@@ -314,21 +316,20 @@ public: ...@@ -314,21 +316,20 @@ public:
CPDOCCORE_DEFINE_VISITABLE(); CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context); void docx_convert (oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context); void pptx_convert (oox::pptx_conversion_context & Context);
const text_format_properties_content & content() const { return text_format_properties_content_; } ; const text_format_properties_content & content() const { return text_format_properties_content_; } ;
text_format_properties_content & content() { return text_format_properties_content_; } ; text_format_properties_content & content() { return text_format_properties_content_; } ;
public:
style_text_properties(){}; style_text_properties(){};
style_text_properties(const std::wstring & rStyle){ text_format_properties_content_.set_r_style(rStyle); }; style_text_properties(const std::wstring & rStyle) { text_format_properties_content_.set_r_style(rStyle); };
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); 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_child_element ( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
private: text_format_properties_content text_format_properties_content_;
text_format_properties_content text_format_properties_content_;
}; };
CP_REGISTER_OFFICE_ELEMENT2(style_text_properties); CP_REGISTER_OFFICE_ELEMENT2(style_text_properties);
......
...@@ -1940,6 +1940,10 @@ ...@@ -1940,6 +1940,10 @@
RelativePath="..\.\PPTXFormat\Logic\Runs\Fld.h" RelativePath="..\.\PPTXFormat\Logic\Runs\Fld.h"
> >
</File> </File>
<File
RelativePath="..\PPTXFormat\Logic\Runs\MathParaWrapper.cpp"
>
</File>
<File <File
RelativePath="..\.\PPTXFormat\Logic\Runs\Run.h" RelativePath="..\.\PPTXFormat\Logic\Runs\Run.h"
> >
......
...@@ -222,7 +222,7 @@ void CSvmFile::PlayMetaFile() ...@@ -222,7 +222,7 @@ void CSvmFile::PlayMetaFile()
m_oStream.Skip(need_skip); m_oStream.Skip(need_skip);
#ifdef _DEBUG #ifdef _DEBUG
if (/*100 <= actionType &&*/ actionType <= META_LAST_ACTION && /*need_skip > 0 &&*/ !m_pOutput) if (100 <= actionType && actionType <= META_LAST_ACTION && need_skip > 0 && !m_pOutput)
{ {
std::wstring name = actionNames[actionType - 99].actionName; std::wstring name = actionNames[actionType - 99].actionName;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment