Commit 9db24f8e authored by ElenaSubbotina's avatar ElenaSubbotina Committed by Alexander Trofimov

OdfFormatReader - конвертация стилевых настроек математических формул

parent 62e0c06c
......@@ -91,24 +91,24 @@ void docx_conversion_context::add_element_to_run(std::wstring parenStyleId)
if (!current_run_)
{
current_run_ = true;
output_stream() << L"<w:r>";
output_stream() << L"<w:r>";
if (!text_properties_stack_.empty() || parenStyleId.length() > 0)
{
if (!text_properties_stack_.empty())
if (!text_properties_stack_.empty() || parenStyleId.length() > 0)
{
odf_reader::style_text_properties_ptr textProp = this->current_text_properties();
get_styles_context().start();
if (!text_properties_stack_.empty())
{
odf_reader::style_text_properties_ptr textProp = this->current_text_properties();
get_styles_context().start();
if(( textProp) && (textProp->content().r_style_))parenStyleId = _T("");
textProp->content().docx_convert(*this);
if(( textProp) && (textProp->content().r_style_))parenStyleId = _T("");
textProp->content().docx_convert(*this);
}
get_styles_context().docx_serialize_text_style( output_stream(), parenStyleId);
}
get_styles_context().docx_serialize_text_style( output_stream(), parenStyleId);
}
}
}
}
void docx_conversion_context::start_paragraph()
......
......@@ -430,9 +430,9 @@ public:
std::wstring add_mediaitem(const std::wstring & uri, mediaitems::Type type, bool & isInternal, std::wstring & ref);
void dump_mediaitems(rels & Rels);
void dump_headers_footers(rels & Rels) const;
void dump_notes(rels & Rels) const;
void dump_mediaitems (rels & Rels);
void dump_headers_footers (rels & Rels) const;
void dump_notes (rels & Rels) const;
bool next_dump_page_properties_;
bool next_dump_section_;
......@@ -556,8 +556,8 @@ public:
bool process_math_formula_;
void set_process_headers_footers(bool Val) { process_headers_footers_ = Val; }
headers_footers & get_headers_footers() { return headers_footers_; }
header_footer_context & get_header_footer_context() { return header_footer_context_; }
headers_footers & get_headers_footers() { return headers_footers_; }
header_footer_context & get_header_footer_context() { return header_footer_context_; }
bool process_headers_footers_;
drop_cap_context & get_drop_cap_context(){return drop_cap_context_;}
......
......@@ -47,6 +47,11 @@ std::wstringstream & styles_context::text_style()
return text_style_;
}
std::wstringstream & styles_context::math_text_style()
{
return math_text_style_;
}
std::wstringstream & styles_context::paragraph_nodes()
{
return paragraph_nodes_;
......
......@@ -23,6 +23,7 @@ public:
std::wstringstream & paragraph_attr();
std::wstringstream & table_style();
std::wstringstream & list_style();
std::wstringstream & math_text_style();
void docx_serialize_text_style(std::wostream & strm, std::wstring parenStyleId);
void docx_serialize_table_style(std::wostream & strm);
......@@ -38,6 +39,7 @@ public:
private:
const odf_reader::style_instance * current_processed_style_;
std::wstring extern_node_;
std::wstring hlinkClick_;
......@@ -46,6 +48,7 @@ private:
std::wstringstream paragraph_nodes_;
std::wstringstream paragraph_attr_;
std::wstringstream table_style_;
std::wstringstream math_text_style_;
};
......
......@@ -11,7 +11,7 @@
#include "style_chart_properties.h"
#include "style_text_properties.h"
#include "odfcontext.h"
#include "office_settings.h"
#include "draw_common.h"
......@@ -174,20 +174,27 @@ void chart_build::docx_convert(oox::docx_conversion_context & Context)
std::wstringstream temp_stream(Context.get_drawing_context().get_text_stream_frame());
Context.set_stream_man( boost::shared_ptr<oox::streams_man>( new oox::streams_man(temp_stream) ));
bool runState = Context.get_run_state();
Context.set_run_state(false);
bool pState = Context.get_paragraph_state();
Context.set_paragraph_state(false);
bool graphic_parent=false;
style_text_properties textProperty;
textProperty.content().style_font_name_ = L"Cambria Math";
textProperty.content().fo_font_size_ = odf_types::length(baseFontHeight_, odf_types::length::pt);
Context.push_text_properties(&textProperty);
office_math_->docx_convert(Context);
Context.pop_text_properties();
Context.get_drawing_context().get_text_stream_frame() = temp_stream.str();
Context.set_stream_man(prev);
Context.set_run_state(runState);
Context.set_paragraph_state(pState);
Context.set_stream_man (prev);
Context.set_run_state (runState);
Context.set_paragraph_state (pState);
}
}
void chart_build::pptx_convert(oox::pptx_conversion_context & Context)
......@@ -364,6 +371,27 @@ void chart_build::oox_convert(oox::oox_chart_context & chart)
chart.set_content_axis(a);
}
}
//----------------------------------------------------------------------------------------
process_build_chart::process_build_chart(chart_build & chartBuild, odf_read_context & context) :
stop_ (false)
,chart_build_ (chartBuild)
,styles_ (context.styleContainer())
,settings_ (context.Settings())
,draw_styles_ (context.drawStyles())
{
office_element_ptr sett_elm = settings_.find_by_style_name(L"BaseFontHeight");
settings_config_item* sett = dynamic_cast<settings_config_item*>(sett_elm.get());
if (sett)
{
try
{
chart_build_.baseFontHeight_ = boost::lexical_cast<int>(sett->content_);
}
catch(...)
{
}
}
}
void process_build_chart::ApplyChartProperties(std::wstring style,std::vector<_property> & propertiesOut)
{
style_instance* styleInst = styles_.style_by_name(style, odf_types::style_family::Chart,false);
......
......@@ -23,6 +23,7 @@
#include "office_text.h"
#include "math_elements.h"
#include "table.h"
#include "odfcontext.h"
namespace cpdoccore {
......@@ -82,7 +83,8 @@ public:
columns_count_(0),
object_type_(0),
office_text_(NULL),
office_math_(NULL)
office_math_(NULL),
baseFontHeight_(12)
{
}
......@@ -122,11 +124,14 @@ public:
int object_type_;
office_text *office_text_;
office_math *office_math_;
int baseFontHeight_;
std::wstring str_class_;
chart::class_type class_;
std::wstring style_name_;
std::wstring name_;
//---------------------------------------------------------------
std::wstring str_class_;
chart::class_type class_;
std::wstring style_name_;
std::wstring name_;
bool in_axis_;
std::vector<chart::axis> axises_;
......@@ -135,13 +140,12 @@ public:
std::wstring domain_cell_range_adress_;
chart::title title_;
office_element_ptr_array title_odf_context_;
chart::title sub_title_;
chart::simple legend_;
chart::title title_;
office_element_ptr_array title_odf_context_;
chart::plot_area plot_area_;
chart::title sub_title_;
chart::simple legend_;
chart::plot_area plot_area_;
chart::simple wall_;
chart::simple floor_;
......@@ -226,13 +230,7 @@ class process_build_chart : public base_visitor,
{
public:
process_build_chart(chart_build & chartBuild, styles_container & styles, styles_lite_container & draw_styles):
stop_(false)
,chart_build_(chartBuild)
,styles_(styles)
,draw_styles_(draw_styles)
{
}
process_build_chart(chart_build & chartBuild, odf_read_context & context);
private:
void ApplyChartProperties(std::wstring style,std::vector<_property> & propertiesOut);
......@@ -297,7 +295,9 @@ private:
bool stop_;
chart_build & chart_build_;
styles_container & styles_;
styles_lite_container & settings_;
styles_lite_container & draw_styles_;
......
......@@ -19,8 +19,32 @@ bool operator== (const color & c1, const color & c2)
if (c1.get_hex_value() == c2.get_hex_value())return true;
else return false;
}
std::wstring html4_colors[16][2] =
{ {L"aqua" , L"#00ffff"},
{L"black" , L"#000000"},
{L"blue" , L"#0000ff"},
{L"fuchsia" , L"#ff00ff"},
{L"gray" , L"#808080"},
{L"green" , L"#008000"},
{L"lime" , L"#00ff00"},
{L"maroon" , L"#800000"},
{L"navy" , L"#000080"},
{L"olive" , L"#808000"},
{L"purple" , L"#800080"},
{L"red" , L"#ff0000"},
{L"silver" , L"#c0c0c0"},
{L"teal" , L"#008080"},
{L"white" , L"#FFFFFF"},
{L"yellow" , L"#ffff00"}
};
color color::parse(const std::wstring & Str)
{
for (int i = 0 ; i < 16; i++)
{
if (Str == html4_colors[i][0])
return color(html4_colors[i][1]);
}
return color(Str);
}
......
......@@ -175,6 +175,22 @@ void common_margin_attlist::apply_from(const common_margin_attlist & Other)
// TODO
_CP_APPLY_PROP(fo_margin_, Other.fo_margin_);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
void common_math_style_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"math:mathvariant", mathvariant_);
if (!mathvariant_) CP_APPLY_ATTR(L"mathvariant", mathvariant_);
}
void common_math_style_attlist::serialize(CP_ATTR_NODE)
{
CP_XML_ATTR_OPT(L"mathvariant", mathvariant_);
}
void common_math_style_attlist::apply_from(const common_math_style_attlist & Other)
{
// TODO
_CP_APPLY_PROP(mathvariant_, Other.mathvariant_);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
void common_break_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
......
......@@ -30,6 +30,7 @@
#include "officevaluetype.h"
#include "fillimagerefpoint.h"
#include "borderstyle.h"
#include "mathvariant.h"
#define _CP_APPLY_PROP(A, B) \
if (B) \
......@@ -117,6 +118,20 @@ public:
friend class style_page_layout_properties_attlist;
};
// common-math_style_attlist
class common_math_style_attlist
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
void apply_from(const common_math_style_attlist & Other);
void serialize(CP_ATTR_NODE);
public:
_CP_OPT(math_variant) mathvariant_;
};
// common-break-attlist
class common_break_attlist
{
......
#include <boost/algorithm/string.hpp>
#include "mathvariant.h"
#include <vector>
namespace cpdoccore { namespace odf_types {
std::wostream & operator << (std::wostream & _Wostream, const math_variant & math_variant_)
{
if (math_variant_.is_none())
{
return _Wostream;
}
//.....
return _Wostream;
}
bool operator == (math_variant & _b1, math_variant & _b2)
{
if (_b1.is_none() && _b2.is_none()) return true;
if (_b1.is_none() || _b2.is_none()) return false;
if ( _b1.style_.bold == _b2.style_.bold &&
_b1.style_.italic == _b2.style_.italic &&
_b1.style_.type == _b2.style_.type) return true;
return false;
}
math_variant::math_variant(const math_variant & Value)
{
style_ = Value.style_;
none_ = Value.is_none();
}
math_variant& math_variant::operator =(const math_variant& Value)
{
style_ = Value.style_;
none_ = Value.is_none();
return *this;
}
math_variant::math_variant(const std::wstring & Value) : none_(true)
{
std::wstring tmp = boost::algorithm::trim_copy(Value);
if (tmp.length() < 1) return;
boost::algorithm::to_lower(tmp);
std::vector< std::wstring > splitted;
boost::algorithm::split(splitted, Value, boost::algorithm::is_any_of(L" \t"), boost::algorithm::token_compress_on);
for (int i = 0 ; i < splitted.size(); i++)
{
if (splitted[i] == L"bold")
{
style_.bold = true;
}
else if (splitted[i] == L"italic")
{
style_.italic = true;
}
else if (splitted[i] == L"bold-italic")
{
style_.bold = true;
style_.italic = true;
}
else if (splitted[i] == L"double-struck")
{
style_.type = 1;
}
else if (splitted[i] == L"bold-fraktur")
{
style_.type = 2;
style_.bold = true;
}
else if (splitted[i] == L"fraktur")
{
style_.type = 2;
}
else if (splitted[i] == L"script")
{
style_.type = 3;
}
else if (splitted[i] == L"bold-script")
{
style_.type = 3;
style_.bold = true;
}
else if (splitted[i] == L"sans-serif-italic")
{
style_.type = 4;
style_.italic = true;
}
else if (splitted[i] == L"bold-sans-serif")
{
style_.type = 4;
style_.bold = true;
}
else if (splitted[i] == L"sans-serif-bold-italic")
{
style_.type = 4;
style_.italic = true;
style_.bold = true;
}
else if (splitted[i] == L"monospace")
{
style_.type = 5;
}
else if (splitted[i] == L"stretched")
{
//style_.stretched = true;
}
else if (splitted[i] == L"tailed")
{
//style_.type = 7;
}
else if (splitted[i] == L"looped")
{
//style_.type = 8;
}
else if (splitted[i] == L"initial")
{
//style_.type = 9;
}
}
none_ = false;
}
math_variant math_variant::parse( const std::wstring & Value)
{
return math_variant(Value);
}
}
}
#pragma once
#include <string>
#include <cpdoccore/CPOptional.h>
#include "odfattributes.h"
namespace cpdoccore { namespace odf_types {
class math_variant
{
public:
math_variant(){}
math_variant(const std::wstring & Value);
math_variant(const math_variant & Value);
static math_variant parse(const std::wstring & Str);
math_variant& operator=(const math_variant& d);
bool is_none() const { return none_; }
struct _style
{
_style() : italic(false), bold(false), type(0) {}
bool italic;
bool bold;
int type;
}style_;
private:
bool none_;
};
std::wostream & operator << (std::wostream & _Wostream, const math_variant & _Val);
bool operator == (math_variant & _b1, math_variant & _b2);
}
APPLY_PARSE_XML_ATTRIBUTES(odf_types::math_variant);
}
......@@ -1251,7 +1251,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
if (contentSubDoc)//Diagramma.odt -
{
process_build_chart process_build_object_(objectBuild, objectSubDoc.odf_context().styleContainer(), objectSubDoc.odf_context().drawStyles());
process_build_chart process_build_object_(objectBuild, objectSubDoc.odf_context());
contentSubDoc->accept(process_build_object_);
objectBuild.docx_convert(Context);
......
......@@ -272,7 +272,7 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
chart_build objectBuild;
process_build_chart process_build_object_(objectBuild, objectSubDoc.odf_context().styleContainer(), objectSubDoc.odf_context().drawStyles());
process_build_chart process_build_object_(objectBuild, objectSubDoc.odf_context());
contentSubDoc->accept(process_build_object_);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -232,7 +232,7 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
if (contentSubDoc)
{
process_build_chart process_build_object_(objectBuild, objectSubDoc.odf_context().styleContainer(), objectSubDoc.odf_context().drawStyles() );
process_build_chart process_build_object_(objectBuild, objectSubDoc.odf_context());
contentSubDoc->accept(process_build_object_);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
#include "math_layout_elements.h"
#include "math_token_elements.h"
#include "style_text_properties.h"
#include <boost/foreach.hpp>
......@@ -82,14 +83,15 @@ void math_mrow::docx_convert(oox::docx_conversion_context & Context)
mo_test_last->text_to_stream(Context.output_stream());
Context.output_stream() << L"\"/>";
}
Context.output_stream() << Context.get_styles_context().math_text_style().str();
Context.output_stream() << L"</m:dPr>";
Context.output_stream() << L"<m:e>";
}
for (int i = i_start; i < i_end ; i++)
{
content_[i]->docx_convert(Context);
}
for (int i = i_start; i < i_end ; i++)
{
content_[i]->docx_convert(Context);
}
if (bDPr)
{
......@@ -149,6 +151,7 @@ void math_msqrt::docx_convert(oox::docx_conversion_context & Context)
strm << L"<m:rad>";
strm << L"<m:radPr>";
strm << L"<m:degHide m:val=\"1\"/>";
strm << Context.get_styles_context().math_text_style().str();
strm << L"</m:radPr>";
strm << L"<m:deg/>";
......@@ -181,7 +184,9 @@ void math_mroot::docx_convert(oox::docx_conversion_context & Context)
strm << L"<m:rad>";
strm << L"<m:radPr/>";
strm << L"<m:radPr>";
strm << Context.get_styles_context().math_text_style().str();
strm << L"</m:radPr>";
strm << L"<m:deg>";
content_[1]->docx_convert(Context);
......@@ -199,11 +204,16 @@ const wchar_t * math_mstyle::name = L"mstyle";
//----------------------------------------------------------------------------------------------------
void math_mstyle::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
common_attlist_.add_attributes(Attributes);
// ver 2
CP_APPLY_ATTR(L"math:fontweight", fontweight_);
CP_APPLY_ATTR(L"math:mathsize", mathsize_);
CP_APPLY_ATTR(L"math:color", color_);
// 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 (!color_) CP_APPLY_ATTR(L"color", color_);
}
void math_mstyle::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
......@@ -213,10 +223,70 @@ void math_mstyle::add_child_element( xml::sax * Reader, const ::std::wstring & N
void math_mstyle::docx_convert(oox::docx_conversion_context & Context)
{
style_text_properties textProperty;
if (mathsize_)
textProperty.content().fo_font_size_ = mathsize_;
if (color_)
textProperty.content().fo_color_ = color_;
if (common_attlist_.mathvariant_)
{
if (common_attlist_.mathvariant_->style_.bold)
textProperty.content().fo_font_weight_ = odf_types::font_weight(odf_types::font_weight::WBold);
if (common_attlist_.mathvariant_->style_.italic)
textProperty.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();
strm.str( std::wstring() );
strm.clear();
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"m:ctrlPr")
{
Context.get_styles_context().start();
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_)
{
elm->docx_convert(Context);
}
Context.pop_text_properties();
// reset style ... todooo ..
{
std::wstringstream & strm = Context.get_styles_context().math_text_style();
strm.str( std::wstring() );
strm.clear();
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"m:ctrlPr")
{
Context.get_styles_context().start();
Context.current_text_properties()->docx_convert(Context);
CP_XML_NODE(L"w:rPr")
{
CP_XML_STREAM() << Context.get_styles_context().text_style().str();
}
}
}
}
}
//---------------------------------------------------------------
const wchar_t * math_menclose::ns = L"math";
......
......@@ -10,6 +10,7 @@
#include "datatypes/common_attlists.h"
#include "datatypes/fontstyle.h"
#include "datatypes/fontweight.h"
#include "datatypes/fontsize.h"
namespace cpdoccore {
......@@ -140,6 +141,9 @@ private:
office_element_ptr_array content_;
common_math_style_attlist common_attlist_;
_CP_OPT(font_size) mathsize_;
_CP_OPT(color) color_;
_CP_OPT(font_weight) fontweight_;
};
CP_REGISTER_OFFICE_ELEMENT2(math_mstyle);
......
#include "math_token_elements.h"
#include "style_text_properties.h"
#include <boost/foreach.hpp>
#include <cpdoccore/odf/odf_document.h>
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/simple_xml_writer.h>
......@@ -20,7 +23,7 @@ const wchar_t * math_mi::name = L"mi";
//----------------------------------------------------------------------------------------------------
void math_mi::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
common_attlist_.add_attributes(Attributes);
}
void math_mi::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
......@@ -44,20 +47,52 @@ void math_mi::docx_convert(oox::docx_conversion_context & Context)
{
if (!text_) return;
std::wostream & strm = Context.output_stream();
CP_XML_WRITER(strm)
CP_XML_WRITER(Context.output_stream())
{
CP_XML_NODE(L"m:r")
{
CP_XML_NODE(L"w:rPr")
Context.get_styles_context().start();
Context.current_text_properties()->docx_convert(Context);
if (common_attlist_.mathvariant_)
{
CP_XML_NODE(L"w:rFonts")
std::wstring m_sty_val;
if (common_attlist_.mathvariant_->style_.bold) m_sty_val += L"b";
if (common_attlist_.mathvariant_->style_.italic)m_sty_val += L"i";
CP_XML_NODE(L"m:rPr")
{
CP_XML_ATTR(L"w:hAnsi", L"Cambria Math");
CP_XML_ATTR(L"w:ascii", L"Cambria Math");
if (!m_sty_val.empty())
{
CP_XML_NODE(L"m:sty")
{
CP_XML_ATTR(L"m:val", m_sty_val);
}
}
if (common_attlist_.mathvariant_->style_.type > 0)
{
CP_XML_NODE(L"m:scr")
{
switch(common_attlist_.mathvariant_->style_.type)
{
case 1: CP_XML_ATTR(L"m:val", L"double-struck"); break;
case 2: CP_XML_ATTR(L"m:val", L"fraktur"); break;
case 3: CP_XML_ATTR(L"m:val", L"script"); break;
case 4: CP_XML_ATTR(L"m:val", L"sans-serif"); break;
case 5: CP_XML_ATTR(L"m:val", L"monospace"); break;
}
}
}
}
}
CP_XML_NODE(L"w:rPr")
{
CP_XML_STREAM() << Context.get_styles_context().text_style().str();
}
CP_XML_NODE(L"m:t")
{
//CP_XML_ATTR(L"xml:space", L"preserve");
......@@ -72,6 +107,7 @@ const wchar_t * math_mo::name = L"mo";
//----------------------------------------------------------------------------------------------------
void math_mo::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
common_attlist_.add_attributes(Attributes);
CP_APPLY_ATTR(L"stretchy", stretchy_);
CP_APPLY_ATTR(L"fence", fence_);
}
......@@ -96,20 +132,18 @@ std::wostream & math_mo::text_to_stream(::std::wostream & _strm) const
void math_mo::docx_convert(oox::docx_conversion_context & Context)
{
if (!text_) return;
std::wostream & strm = Context.output_stream();
CP_XML_WRITER(strm)
CP_XML_WRITER(Context.output_stream())
{
CP_XML_NODE(L"m:r")
{
// + ... todoooo
Context.get_styles_context().start();
Context.current_text_properties()->docx_convert(Context);
CP_XML_NODE(L"w:rPr")
{
CP_XML_NODE(L"w:rFonts")
{
CP_XML_ATTR(L"w:hAnsi", L"Cambria Math");
CP_XML_ATTR(L"w:ascii", L"Cambria Math");
}
CP_XML_STREAM() << Context.get_styles_context().text_style().str();
}
CP_XML_NODE(L"m:t")
{
......@@ -125,6 +159,7 @@ const wchar_t * math_mn::name = L"mn";
//----------------------------------------------------------------------------------------------------
void math_mn::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
common_attlist_.add_attributes(Attributes);
}
......@@ -143,20 +178,18 @@ void math_mn::docx_convert(oox::docx_conversion_context & Context)
{
if (!text_) return;
std::wostream & strm = Context.output_stream();
CP_XML_WRITER(strm)
CP_XML_WRITER(Context.output_stream())
{
CP_XML_NODE(L"m:r")
{
// + ... todoooo
Context.get_styles_context().start();
Context.current_text_properties()->docx_convert(Context);
CP_XML_NODE(L"w:rPr")
{
CP_XML_NODE(L"w:rFonts")
{
CP_XML_ATTR(L"w:hAnsi", L"Cambria Math");
CP_XML_ATTR(L"w:ascii", L"Cambria Math");
}
}
CP_XML_STREAM() << Context.get_styles_context().text_style().str();
}
CP_XML_NODE(L"m:t")
{
//CP_XML_ATTR(L"xml:space", L"preserve");
......@@ -171,6 +204,7 @@ const wchar_t * math_ms::name = L"ms";
//----------------------------------------------------------------------------------------------------
void math_ms::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
common_attlist_.add_attributes(Attributes);
}
......@@ -219,6 +253,7 @@ const wchar_t * math_mtext::name = L"mtext";
//----------------------------------------------------------------------------------------------------
void math_mtext::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
common_attlist_.add_attributes(Attributes);
}
......@@ -243,6 +278,7 @@ const wchar_t * math_mglyph::name = L"mglyph";
//----------------------------------------------------------------------------------------------------
void math_mglyph::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
common_attlist_.add_attributes(Attributes);
}
......
......@@ -7,6 +7,8 @@
#include "office_elements_create.h"
#include "datatypes/common_attlists.h"
namespace cpdoccore {
namespace odf_reader {
......@@ -26,11 +28,13 @@ public:
virtual std::wostream & text_to_stream(::std::wostream & _Wostream) const;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text);
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text (const std::wstring & Text);
office_element_ptr_array content_;
odf_types::common_math_style_attlist common_attlist_;
office_element_ptr_array content_;
_CP_OPT(std::wstring) text_;
};
......@@ -60,7 +64,9 @@ private:
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text);
office_element_ptr_array content_;
odf_types::common_math_style_attlist common_attlist_;
office_element_ptr_array content_;
_CP_OPT(std::wstring) text_;
};
......@@ -86,7 +92,9 @@ private:
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text);
office_element_ptr_array content_;
odf_types::common_math_style_attlist common_attlist_;
office_element_ptr_array content_;
_CP_OPT(std::wstring) text_;
};
......@@ -112,7 +120,9 @@ private:
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text);
office_element_ptr_array content_;
odf_types::common_math_style_attlist common_attlist_;
office_element_ptr_array content_;
_CP_OPT(std::wstring) text_;
};
......@@ -138,7 +148,9 @@ private:
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text);
office_element_ptr_array content_;
odf_types::common_math_style_attlist common_attlist_;
office_element_ptr_array content_;
_CP_OPT(std::wstring) text_;
};
......@@ -164,7 +176,9 @@ private:
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text);
office_element_ptr_array content_;
odf_types::common_math_style_attlist common_attlist_;
office_element_ptr_array content_;
_CP_OPT(std::wstring) text_;
};
......@@ -190,7 +204,9 @@ private:
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text);
office_element_ptr_array content_;
odf_types::common_math_style_attlist common_attlist_;
office_element_ptr_array content_;
_CP_OPT(std::wstring) text_;
};
......
......@@ -105,6 +105,9 @@ odf_document::Impl::Impl(const std::wstring & folderPath, const ProgressCallback
_CP_LOG << L"[info] parse manifest" << std::endl;
parse_manifests();
_CP_LOG << L"[info] parse settings" << std::endl;
parse_settings();
UpdateProgress(400000);
}
bool odf_document::Impl::UpdateProgress(long nComplete)
......@@ -198,7 +201,8 @@ void odf_document::Impl::parse_manifests()
if (!manifest_xml_)return;
office_document_base * document = dynamic_cast<office_document_base *>( manifest_xml_->get_content() );
if (!document)return;
if (!document)return;
int res =-1;
BOOST_FOREACH(office_element_ptr & elm, document->manifests_)
......@@ -229,6 +233,34 @@ void odf_document::Impl::parse_manifests()
}
}
void odf_document::Impl::parse_settings()
{
if (!settings_xml_)return;
office_document_base * document = dynamic_cast<office_document_base *>( settings_xml_->get_content() );
if (!document) return;
office_settings * settings = dynamic_cast<office_settings*>(document->office_settings_.get());
if (!settings) return;
BOOST_FOREACH(office_element_ptr & elm, settings->content_)
{
settings_config_item_set * item_set = dynamic_cast<settings_config_item_set *>(elm.get());
if (!item_set)continue;
if (item_set->config_name_ == L"ooo:configuration-settings")
{
BOOST_FOREACH(office_element_ptr & elm_sett, item_set->content_)
{
settings_config_item * sett = dynamic_cast<settings_config_item *>(elm_sett.get());
if (!sett)continue;
context_->Settings().add(sett->config_name_, elm_sett);
}
}
}
}
void odf_document::Impl::parse_styles()
{
do
......@@ -683,5 +715,6 @@ office_element * odf_document::Impl::get_content()
{
return content_xml_->get_content();
}
}
}
......@@ -46,9 +46,11 @@ private:
short bUserStopConvert;
odf_read_context_ptr context_;
void parse_styles();
void parse_styles();
void parse_fonts();
void parse_manifests();
void parse_settings();
private:
content_xml_t_ptr content_xml_;
......
......@@ -332,6 +332,7 @@ public:
styles_lite_container & numberStyles() { return number_style_container_; }
styles_lite_container & drawStyles() { return draw_style_container_; }
styles_lite_container & Templates() { return template_container_; }
styles_lite_container & Settings() { return settings_container_; }
private:
styles_container major_style_container_;
......@@ -343,6 +344,8 @@ private:
styles_lite_container number_style_container_;
styles_lite_container draw_style_container_;
styles_lite_container template_container_;
styles_lite_container settings_container_;
};
......
......@@ -33,6 +33,7 @@ const wchar_t * settings_config_item_set::name = L"config-item-set";
void settings_config_item_set::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"config:name", config_name_, std::wstring(L""));
}
void settings_config_item_set::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
......@@ -46,11 +47,13 @@ const wchar_t * settings_config_item::name = L"config-item";
void settings_config_item::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"config:name", config_name_, std::wstring(L""));
CP_APPLY_ATTR(L"config:type", config_type_, std::wstring(L""));
}
void settings_config_item::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
//CP_CREATE_ELEMENT(content_);
}
// config_item_map_indexed
//////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -21,14 +21,12 @@ public:
static const ElementType type = typeOfficeSettings;
CPDOCCORE_DEFINE_VISITABLE();
office_element_ptr_array content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text){}
private:
office_element_ptr_array content_;
virtual void add_text(const std::wstring & Text){}
};
CP_REGISTER_OFFICE_ELEMENT2(office_settings);
......@@ -44,15 +42,14 @@ public:
static const ElementType type = typeOfficeSettingsConfigItemSet;
CPDOCCORE_DEFINE_VISITABLE();
std::wstring config_name_;
office_element_ptr_array content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text){}
private:
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(settings_config_item_set);
......@@ -67,15 +64,13 @@ public:
static const ElementType type = typeOfficeSettingsConfigItem;
CPDOCCORE_DEFINE_VISITABLE();
std::wstring config_name_;
std::wstring config_type_;
std::wstring content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text){}
private:
office_element_ptr_array content_;
virtual void add_text(const std::wstring & Text){ content_ = Text; }
};
CP_REGISTER_OFFICE_ELEMENT2(settings_config_item);
......
......@@ -673,6 +673,14 @@
RelativePath="..\src\odf\datatypes\markerstyle.h"
>
</File>
<File
RelativePath="..\src\odf\datatypes\mathvariant.cpp"
>
</File>
<File
RelativePath="..\src\odf\datatypes\mathvariant.h"
>
</File>
<File
RelativePath="..\src\odf\datatypes\noteclass.cpp"
>
......
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