Compare commits

...

5 Commits

17 changed files with 110 additions and 28 deletions

View File

@ -795,6 +795,11 @@ namespace StarMath
stTempPr->m_enStyle = SimpleTypes::EStyle::styleItalic;
bRpr = true;
}
else if(pRPr->m_oU.GetPointer() != nullptr && pRPr->m_oU->m_oVal.GetPointer() != nullptr)
{
stTempPr->m_enUnderLine = pRPr->m_oU->m_oVal->GetValue();
bRpr = true;
}
if(bRpr == true)
return stTempPr;
else
@ -1417,8 +1422,13 @@ namespace StarMath
void COOXml2Odf::StyleClosing(const StStyleMenClose &stStyle, XmlUtils::CXmlWriter *pXmlWrite)
{
if(stStyle.m_bMenClose)
{
pXmlWrite->WriteNodeEnd(L"menclose",false,false);
if(stStyle.m_bUnderlineClose)
{
pXmlWrite->WriteNodeBegin(L"mo",false);
pXmlWrite->WriteString(L"\u0332");
pXmlWrite->WriteNodeEnd(L"mo",false,false);
pXmlWrite->WriteNodeEnd(L"munder",false,false);
}
if(stStyle.m_iStyle != 0)
{
@ -1733,6 +1743,14 @@ namespace StarMath
wsAnnotation += L"overstrike ";
stStyle.m_bMenClose = true;
}
if(pAttribute->m_enUnderLine == SimpleTypes::EUnderline::underlineSingle)
{
pXmlWrite->WriteNodeBegin(L"munder",true);
pXmlWrite->WriteAttribute(L"accentunder",L"true");
pXmlWrite->WriteNodeEnd(L"w",true,false);
wsAnnotation += L"underline ";
stStyle.m_bUnderlineClose = true;
}
if(!bDelimiter)
pAttribute->Release();
}

View File

@ -18,7 +18,7 @@ namespace StarMath
{
struct StValuePr
{
StValuePr():m_wsTypeName(L""),m_wsBegBracket(L""),m_wsEndBracket(L""),m_wsChr(L""),m_wsColor(L""),m_bSupHide(false),m_bSubHide(false),m_enStyle(SimpleTypes::EStyle::stylePlain),m_iSize(0),m_enPos(SimpleTypes::ETopBot::tbBot),m_enVert(SimpleTypes::ETopBot::tbBot),m_enFont(StarMath::TypeFont::empty),m_iCount(0),m_bStrike(false)
StValuePr():m_wsTypeName(L""),m_wsChr(L""),m_wsBegBracket(L""),m_wsEndBracket(L""),m_wsColor(L""),m_bSupHide(false),m_bSubHide(false),m_enStyle(SimpleTypes::EStyle::stylePlain),m_iSize(0),m_enPos(SimpleTypes::ETopBot::tbBot),m_enVert(SimpleTypes::ETopBot::tbBot),m_enFont(StarMath::TypeFont::empty),m_iCount(0),m_bStrike(false),m_enUnderLine(SimpleTypes::EUnderline::underlineNone)
{
AddRef();
}
@ -32,6 +32,7 @@ namespace StarMath
StarMath::TypeFont m_enFont;
int m_iCount;
bool m_bStrike;
SimpleTypes::EUnderline m_enUnderLine;
void AddRef()
{
m_iCount++;
@ -45,10 +46,11 @@ namespace StarMath
};
struct StStyleMenClose
{
StStyleMenClose():m_iStyle(0),m_bMenClose(false)
StStyleMenClose():m_iStyle(0),m_bMenClose(false),m_bUnderlineClose(false)
{}
unsigned int m_iStyle;
bool m_bMenClose;
bool m_bUnderlineClose;
};
class COneElement;
class COOXml2Odf

View File

@ -916,7 +916,11 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
odf_context()->start_text_context();
//docx_converter->convert(oox_shape->oTextBoxShape.GetPointer());
convert(oox_shape->oTextBoxBodyPr.GetPointer());
if (oox_shape->style.IsInit())
convert(&oox_shape->style->fontRef);
for (size_t i = 0; i < oox_shape->oTextBoxShape->m_arrItems.size(); i++)
{
docx_converter->convert(oox_shape->oTextBoxShape->m_arrItems[i]);

View File

@ -484,6 +484,8 @@ public:
bool encrypt_document (const std::wstring &password, const std::wstring & srcPath, const std::wstring & dstPath);
bool encrypt_file (const std::wstring &password, const std::wstring & srcPath, const std::wstring & dstPath, std::wstring &encrypt_info, int &size);
std::vector<double> current_font_size;
//.......................................................................................................................
virtual OOX::IFileContainer *current_document() = 0;

View File

@ -87,8 +87,6 @@
using namespace cpdoccore;
std::vector<double> current_font_size;
namespace Oox2Odf
{

View File

@ -44,6 +44,7 @@
#include "../Format/math_layout_elements.h"
#include "../Format/math_limit_elements.h"
#include "../Format/math_token_elements.h"
#include "../Format/style_text_properties.h"
#include <set>
#include <vector>
@ -173,7 +174,20 @@ namespace Oox2Odf
brackets().resize(1);
bool bStart = odf_context()->start_math();
int base_font_size = current_font_size.empty() ? 12 : current_font_size.back();
std::wstring base_font_color;
if (odf_context()->is_child_text_context())
{
if (odf_context()->drawing_context()->get_text_properties())
{
if (odf_context()->drawing_context()->get_text_properties()->fo_color_)
{
base_font_color = odf_context()->drawing_context()->get_text_properties()->fo_color_->get_hex_value();
}
}
}
bool bStart = odf_context()->start_math(base_font_size, base_font_color);
for (size_t i = 0; i < oox_math->m_arrItems.size(); ++i)
{
@ -236,7 +250,21 @@ namespace Oox2Odf
{
if (!oox_math_para) return;
bool bStart = odf_context()->start_math();
int base_font_size = current_font_size.empty() ? 12 : current_font_size.back();
std::wstring base_font_color;
if (odf_context()->is_child_text_context())
{
if (odf_context()->drawing_context()->get_text_properties())
{
if (odf_context()->drawing_context()->get_text_properties()->fo_color_)
{
base_font_color = odf_context()->drawing_context()->get_text_properties()->fo_color_->get_hex_value();
}
}
}
bool bStart = odf_context()->start_math(base_font_size, base_font_color);
for (size_t i = 0; i < oox_math_para->m_arrItems.size(); ++i)
{
@ -1260,16 +1288,18 @@ namespace Oox2Odf
odf_context()->settings_context()->start_view();
if (oox_r_pr->m_oSz.IsInit() && oox_r_pr->m_oSz->m_oVal.IsInit())
{
odf_context()->math_context()->size = oox_r_pr->m_oSz->m_oVal->GetValue();
odf_context()->math_context()->font_size = oox_r_pr->m_oSz->m_oVal->GetValue();
}
else
odf_context()->settings_context()->add_config_content_item(L"BaseFontHeight", L"short", std::to_wstring((int)odf_context()->math_context()->font_size));
if (!odf_context()->math_context()->font_color.empty())
{
odf_context()->math_context()->size = 12;
odf_context()->settings_context()->add_config_content_item(L"BaseFontColor", L"string", L"#" + odf_context()->math_context()->font_color);
}
odf_context()->settings_context()->add_config_content_item(L"BaseFontHeight", L"short", std::to_wstring(odf_context()->math_context()->size));
if (oox_r_pr->m_oRFonts.IsInit() && oox_r_pr->m_oRFonts->m_sAscii.IsInit())
{
odf_context()->math_context()->font = *oox_r_pr->m_oRFonts->m_sAscii;
odf_context()->math_context()->font_name = *oox_r_pr->m_oRFonts->m_sAscii;
odf_context()->settings_context()->add_config_content_item(L"FontNameFunctions", L"string", *oox_r_pr->m_oRFonts->m_sAscii);
odf_context()->settings_context()->add_config_content_item(L"FontNameNumbers", L"string", *oox_r_pr->m_oRFonts->m_sAscii);

View File

@ -383,7 +383,7 @@ void odf_conversion_context::end_drawing_context()
drawing_context_.pop_back();
}
bool odf_conversion_context::start_math()
bool odf_conversion_context::start_math(int base_font_size, const std::wstring& base_font_color)
{
if (false == math_context_.isEmpty()) return false;
@ -401,6 +401,8 @@ bool odf_conversion_context::start_math()
math_context_.set_styles_context(odf_conversion_context::styles_context());
math_context_.start_math(get_current_object_element());
math_context_.font_size = base_font_size;
math_context_.font_color = base_font_color;
return true;
}
void odf_conversion_context::end_math()
@ -409,7 +411,7 @@ void odf_conversion_context::end_math()
end_object();
calculate_font_metrix(math_context_.font, math_context_.size, false, false, true); // смотреть по формуле - перевычислять только если есть изменения это шрифт и кегль
calculate_font_metrix(math_context_.font_name, math_context_.font_size, false, false, true); // смотреть по формуле - перевычислять только если есть изменения это шрифт и кегль
double h = math_context_.lvl_max - math_context_.lvl_min;
if (math_context_.lvl_min < 0) h += 1;

View File

@ -121,6 +121,8 @@ public:
virtual odf_text_context * text_context() = 0;
virtual odf_controls_context * controls_context() = 0;
virtual bool is_child_text_context() = 0;
std::wstring add_image (const std::wstring & image_file_name, bool bExternal = false);
std::wstring add_media (const std::wstring & file_name, bool bExternal = false);
std::wstring add_oleobject (const std::wstring & ole_file_name, bool bExternal = false);
@ -144,7 +146,7 @@ public:
void start_chart();
void end_chart();
virtual bool start_math();
virtual bool start_math(int base_font_size, const std::wstring & base_font_color);
virtual void end_math();
void start_spreadsheet();

View File

@ -2652,10 +2652,14 @@ graphic_format_properties* odf_drawing_context::get_graphic_properties()
{
return impl_->current_graphic_properties;
}
text_format_properties* odf_drawing_context::get_text_properties()
{
return impl_->current_text_properties;
}
void odf_drawing_context::set_textarea_vertical_align(int align)
{
if (!impl_->current_graphic_properties)return;
if (!impl_->current_graphic_properties) return;
switch(align)
{
case 0://SimpleTypes::textanchoringtypeB:

View File

@ -156,6 +156,7 @@ public:
bool placeholder_replacing();
graphic_format_properties* get_graphic_properties();
text_format_properties* get_text_properties();
void set_graphic_properties (style_graphic_properties *graphic_properties);
void set_graphic_properties (graphic_format_properties* graphic_properties);

View File

@ -124,8 +124,11 @@ namespace cpdoccore {
double lvl_down_counter = 0;
double lvl_max = 0;
double lvl_min = 0;
std::wstring font;
double size = 0;
std::wstring font_name;
double font_size = 0;
std::wstring font_color;
std::set<wchar_t> mo;
std::map<std::wstring, std::wstring> diak_symbols;

View File

@ -58,6 +58,11 @@ odp_conversion_context::odp_conversion_context(package::odf_document * outputDoc
: odf_conversion_context (PresentationDocument, outputDocument), root_presentation_(NULL), slide_context_(*this), rId_(1)
{
}
bool odp_conversion_context::is_child_text_context()
{
return (false == text_context_.empty());
}
odf_text_context* odp_conversion_context::text_context()
{
if (false == text_context_.empty())

View File

@ -73,6 +73,7 @@ public:
odp_page_state & current_slide() { return slide_context_.state();}
/////////////////////////////////////////////////////
virtual bool is_child_text_context();
virtual odf_drawing_context * drawing_context();
virtual odf_controls_context * controls_context();

View File

@ -693,6 +693,10 @@ odf_text_context* ods_conversion_context::text_context()
return NULL;
}
}
bool ods_conversion_context::is_child_text_context()
{
return (false == text_context_.empty());
}
void ods_conversion_context::add_text(const std::wstring &text)
{
office_element_ptr paragr_elm;

View File

@ -101,6 +101,7 @@ public:
//-----------------------------------------------------------------------
ods_table_state_ptr & current_table() { return table_context_.state();}
//-----------------------------------------------------------------------
virtual bool is_child_text_context();
virtual odf_drawing_context * drawing_context();
virtual odf_text_context * text_context();

View File

@ -210,16 +210,19 @@ odf_notes_context* odt_conversion_context::notes_context()
odf_text_context* odt_conversion_context::text_context()
{
if (text_context_.size() > 0)
{
return text_context_.back().get();
}
else
if (text_context_.empty())
{
return main_text_context_;
}
else
{
return text_context_.back().get();
}
}
bool odt_conversion_context::is_child_text_context()
{
return (false == text_context_.empty());
}
void odt_conversion_context::add_text_content(const std::wstring & text)
{
if (drop_cap_state_.enabled)
@ -260,12 +263,12 @@ void odt_conversion_context::start_drawing_context()
drawing_context()->set_footer_state(is_footer_);
drawing_context()->set_header_state(is_header_);
}
bool odt_conversion_context::start_math()
bool odt_conversion_context::start_math(int base_font_size, const std::wstring& base_font_color)
{
if (false == math_context()->isEmpty()) return false;
start_drawing_context();
return odf_conversion_context::start_math();
return odf_conversion_context::start_math(base_font_size, base_font_color);
}
void odt_conversion_context::end_math()
{

View File

@ -65,6 +65,8 @@ public:
virtual void start_document();
virtual void end_document();
virtual bool is_child_text_context();
virtual odf_drawing_context * drawing_context();
virtual odf_text_context * text_context();
virtual odf_controls_context * controls_context();
@ -79,7 +81,7 @@ public:
virtual void start_drawing_context();
virtual void end_drawing_context();
virtual bool start_math();
virtual bool start_math(int base_font_size, const std::wstring& base_font_color);
virtual void end_math();
void add_text_content (const std::wstring & text);