Commit 7a27150d authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - fix math after testing

parent 2197fddb
......@@ -144,7 +144,7 @@ void styles_context::docx_serialize_table_style(std::wostream & strm, std::wstri
namespace oox
{
math_context::math_context(odf_reader::fonts_container & fonts, bool graphic) :
base_font_size_(12), fonts_container_(fonts)
base_font_size_(12), fonts_container_(fonts), is_need_e_(false)
{
graphRPR_ = graphic;
......
......@@ -106,6 +106,8 @@ namespace oox {
std::wstring nsRPr_;
bool graphRPR_;
bool is_need_e_;
private:
std::wstringstream math_stream_;
std::wstringstream math_style_stream_;
......
......@@ -753,10 +753,10 @@ void pptx_slide_context::serialize_animations(std::wostream & strm)
{
CP_XML_ATTR(L"spd",impl_->transition_.Speed.get());
}
if (impl_->transition_.Time)
/* if (impl_->transition_.Time)
{
CP_XML_ATTR(L"p14:dur", impl_->transition_.Time.get());
}
}*/
if (impl_->transition_.PageTime)
{
CP_XML_ATTR(L"advTm", impl_->transition_.PageTime.get());
......
......@@ -96,6 +96,7 @@ void math_mrow::oox_convert(oox::math_context & Context)
bDPr = true;
}
bool need_e_old = Context.is_need_e_, need_e = false;
if (bDPr)
{
Context.output_stream() << L"<m:d>";
......@@ -115,20 +116,31 @@ void math_mrow::oox_convert(oox::math_context & Context)
}
Context.output_stream() << Context.math_style_stream().str();
Context.output_stream() << L"</m:dPr>";
Context.output_stream() << L"<m:e>";
need_e = true;
}
else need_e = Context.is_need_e_;
Context.is_need_e_ = false;
if (need_e)
{
Context.output_stream() << L"<m:e>";
}
for (int i = i_start; i < i_end ; i++)
{
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
}
if (need_e)
{
Context.output_stream() << L"</m:e>";
}
if (bDPr)
{
Context.output_stream() << L"</m:e>";
Context.output_stream() << L"</m:d>";
}
Context.is_need_e_ = need_e_old;
}
//---------------------------------------------------------------
const wchar_t * math_mfrac::ns = L"math";
......@@ -150,13 +162,23 @@ void math_mfrac::oox_convert(oox::math_context & Context)
{
return;
}
bool need_e = Context.is_need_e_;
if (need_e)
{
Context.output_stream() << L"<m:e>";
}
Context.is_need_e_ = false;
office_math_element* math_element = NULL;
Context.output_stream() << L"<m:f>";
Context.output_stream() << L"<m:num>";
math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
Context.output_stream() << L"</m:num>";
Context.is_need_e_ = false;
Context.output_stream() << L"<m:den>";
math_element = dynamic_cast<office_math_element*>(content_[1].get());
......@@ -164,6 +186,12 @@ void math_mfrac::oox_convert(oox::math_context & Context)
Context.output_stream() << L"</m:den>";
Context.output_stream() << L"</m:f>";
if (need_e)
{
Context.output_stream() << L"</m:e>";
}
Context.is_need_e_ = need_e;
}
//---------------------------------------------------------------
const wchar_t * math_msqrt::ns = L"math";
......@@ -192,6 +220,8 @@ void math_msqrt::oox_convert(oox::math_context & Context)
strm << L"<m:deg/>";
strm << L"<m:e>";
Context.is_need_e_ = false;
for (size_t i = 0 ; i < content_.size(); i++)
{
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
......@@ -230,6 +260,9 @@ void math_mroot::oox_convert(oox::math_context & Context)
math_element = dynamic_cast<office_math_element*>(content_[1].get());
math_element->oox_convert(Context);
strm << L"</m:deg>";
Context.is_need_e_ = false;
strm << L"<m:e>";
math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
......@@ -295,21 +328,23 @@ void math_mstyle::oox_convert(oox::math_context & Context)
}
}
}
bool need_e_old = Context.is_need_e_;
Context.is_need_e_ = content_.size() > 1 ? true : need_e_old;
for (size_t i = 0; i < content_.size(); i++)
{
math_munder* munder_test = dynamic_cast<math_munder*>(content_[i].get());
math_mfrac* frac_test = dynamic_cast<math_mfrac*>(content_[i].get());
math_mrow* row_test = dynamic_cast<math_mrow*>(content_[i].get());
//math_munder* munder_test = dynamic_cast<math_munder*>(content_[i].get());
//math_mfrac* frac_test = dynamic_cast<math_mfrac*>(content_[i].get());
//math_mrow* row_test = dynamic_cast<math_mrow*>(content_[i].get());
if (row_test || munder_test || frac_test)
Context.output_stream() << L"<m:e>";
//if (row_test || munder_test || frac_test)
// Context.output_stream() << L"<m:e>";
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
if (row_test || munder_test || frac_test)
Context.output_stream() << L"</m:e>";
//if (row_test || munder_test || frac_test)
// Context.output_stream() << L"</m:e>";
//office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
//math_element->oox_convert(Context);
......@@ -320,6 +355,7 @@ void math_mstyle::oox_convert(oox::math_context & Context)
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);
Context.is_need_e_ = need_e_old;
{
std::wstringstream & strm = Context.math_style_stream();
strm.str( std::wstring() );
......
......@@ -71,11 +71,15 @@ void math_msub::oox_convert(oox::math_context & Context)
strm << L"<m:sSub>";
strm << L"<m:e>";
Context.is_need_e_ = false;
math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
strm << L"</m:e>";
strm << L"<m:sub>";
Context.is_need_e_ = false; //??
math_element = dynamic_cast<office_math_element*>(content_[1].get());
math_element->oox_convert(Context);
strm << L"</m:sub>";
......@@ -109,6 +113,8 @@ void math_msup::oox_convert(oox::math_context & Context)
strm << L"<m:sSup>";
strm << L"<m:e>";
Context.is_need_e_ = false;
math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
strm << L"</m:e>";
......@@ -142,6 +148,8 @@ void math_msubsup::oox_convert(oox::math_context & Context)
office_math_element* math_element = NULL;
strm << L"<m:sSubSup>";
Context.is_need_e_ = false;
strm << L"<m:e>";
math_element = dynamic_cast<office_math_element*>(content_[0].get());
......@@ -328,6 +336,9 @@ void math_mover::oox_convert(oox::math_context & Context)
strm << L"<m:limUpp>";
strm << L"<m:limUppPr/>";
strm << L"<m:e>";
Context.is_need_e_ = false;
math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
strm << L"</m:e>";
......@@ -355,6 +366,13 @@ void math_munder::oox_convert(oox::math_context & Context)
{//2 elements
std::wostream & strm = Context.output_stream();
bool need_e = Context.is_need_e_;
if (need_e)
{
Context.output_stream() << L"<m:e>";
}
Context.is_need_e_ = false;
office_math_element* math_element = NULL;
strm << L"<m:limLow>";
strm << L"<m:limLowPr/>";
......@@ -367,6 +385,12 @@ void math_munder::oox_convert(oox::math_context & Context)
math_element->oox_convert(Context);
strm << L"</m:lim>";
strm << L"</m:limLow>";
if (need_e)
{
Context.output_stream() << L"</m:e>";
}
Context.is_need_e_ = need_e;
}
}
}
......@@ -92,23 +92,30 @@ void math_mtr::oox_convert(oox::math_context & Context)
std::wostream & strm = Context.output_stream();
strm << L"<m:mr>";
for (size_t i = 0; i < content_.size(); i++)
{
math_mrow* row_test = dynamic_cast<math_mrow*>(content_[i].get());
math_munder* munder_test = dynamic_cast<math_munder*>(content_[i].get());
math_mfrac* frac_test = dynamic_cast<math_mfrac*>(content_[i].get());
if (row_test || munder_test || frac_test)
Context.output_stream() << L"<m:e>";// EqArray записался в числитель вместо знаменателя.docx - дублирование
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
if (row_test || munder_test || frac_test)
strm << L"</m:e>";
}
bool need_e_old = Context.is_need_e_;
for (size_t i = 0; i < content_.size(); i++)
{
//Context.is_need_e_ = content_.size() > 1 ? true : false;
Context.is_need_e_ = true;
//math_mrow* row_test = dynamic_cast<math_mrow*>(content_[i].get());
//math_munder* munder_test = dynamic_cast<math_munder*>(content_[i].get());
//math_mfrac* frac_test = dynamic_cast<math_mfrac*>(content_[i].get());
//
//if (row_test || munder_test || frac_test)
// Context.output_stream() << L"<m:e>";// EqArray записался в числитель вместо знаменателя.docx - дублирование
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
//if (row_test || munder_test || frac_test)
// strm << L"</m:e>";
}
strm << L"</m:mr>";
Context.is_need_e_ = need_e_old;
}
//----------------------------------------------------------------------------------------------------
......@@ -151,6 +158,7 @@ void math_mtd::oox_convert(oox::math_context & Context)
std::wostream & strm = Context.output_stream();
strm << L"<m:e>";
Context.is_need_e_ = false;
for (size_t i = 0; i < content_.size(); i++)
{
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
......
......@@ -286,7 +286,7 @@ void math_mtext::oox_convert(oox::math_context & Context)
if (text_)
{
Context.output_stream() << L"<m:r><m:rPr><m:nor/></m:rPr><m:t>";
Context.output_stream() << *text_;
Context.output_stream() << XmlUtils::EncodeXmlString(*text_);
Context.output_stream() << L"</m:t></m:r>";
}
}
......
......@@ -407,7 +407,7 @@ void text_format_properties_content::drawing_serialize(std::wostream & strm, std
switch (style_text_underline_style_->get_type())
{
case line_style::Solid:
if (underlineBold) underline = L"thick";
if (underlineBold) underline = L"heavy";
else underline = L"sng";
break;
case line_style::Dotted:
......
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