mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
new odf math semantic
This commit is contained in:
@ -199,11 +199,6 @@ namespace Oox2Odf
|
||||
}
|
||||
bool bStart = odf_context()->start_math(base_font_size, base_font_color);
|
||||
|
||||
for (size_t i = 0; i < oox_math->m_arrItems.size(); ++i)
|
||||
{
|
||||
convert(oox_math->m_arrItems[i]);
|
||||
}
|
||||
|
||||
if (bStart)
|
||||
{
|
||||
StarMath::COOXml2Odf starMathConverter;
|
||||
@ -212,20 +207,23 @@ namespace Oox2Odf
|
||||
|
||||
std::wstring annotation_text = starMathConverter.GetAnnotation();
|
||||
|
||||
if (false == annotation_text.empty())
|
||||
if (annotation_text.empty())
|
||||
{
|
||||
CREATE_MATH_TAG(L"annotation");
|
||||
typedef odf_writer::math_annotation* T;
|
||||
T tmp = dynamic_cast<T>(elm.get());
|
||||
if (tmp)
|
||||
for (size_t i = 0; i < oox_math->m_arrItems.size(); ++i)
|
||||
{
|
||||
tmp->encoding_ = L"StarMath 5.0";
|
||||
convert(oox_math->m_arrItems[i]);
|
||||
}
|
||||
elm->add_text(annotation_text);
|
||||
|
||||
OPEN_MATH_TAG(elm);
|
||||
CLOSE_MATH_TAG;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring content = starMathConverter.GetOdf();
|
||||
odf_context()->math_context()->add_content(content);
|
||||
|
||||
odf_context()->math_context()->symbol_counter = 30; // starMathConverter. ???
|
||||
odf_context()->math_context()->lvl_max = 20; // starMathConverter. ???
|
||||
odf_context()->math_context()->lvl_min = 0; // starMathConverter. ???
|
||||
}
|
||||
|
||||
odf_context()->end_math();
|
||||
}
|
||||
@ -286,10 +284,6 @@ namespace Oox2Odf
|
||||
}
|
||||
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)
|
||||
{
|
||||
convert(oox_math_para->m_arrItems[i]);
|
||||
}
|
||||
if (bStart)
|
||||
{
|
||||
StarMath::COOXml2Odf starMathConverter;
|
||||
@ -298,20 +292,24 @@ namespace Oox2Odf
|
||||
|
||||
std::wstring annotation_text = starMathConverter.GetAnnotation();
|
||||
|
||||
if (false == annotation_text.empty())
|
||||
if (annotation_text.empty())
|
||||
{
|
||||
CREATE_MATH_TAG(L"annotation");
|
||||
typedef odf_writer::math_annotation* T;
|
||||
T tmp = dynamic_cast<T>(elm.get());
|
||||
if (tmp)
|
||||
for (size_t i = 0; i < oox_math_para->m_arrItems.size(); ++i)
|
||||
{
|
||||
tmp->encoding_ = L"StarMath 5.0";
|
||||
convert(oox_math_para->m_arrItems[i]);
|
||||
}
|
||||
elm->add_text(annotation_text);
|
||||
|
||||
OPEN_MATH_TAG(elm);
|
||||
CLOSE_MATH_TAG;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring content = starMathConverter.GetOdf();
|
||||
odf_context()->math_context()->add_content(content);
|
||||
|
||||
odf_context()->math_context()->symbol_counter = 30; // starMathConverter. ? ? ? ?
|
||||
odf_context()->math_context()->lvl_max = 20; // starMathConverter. ? ? ? ?
|
||||
odf_context()->math_context()->lvl_min = 0; // starMathConverter. ? ? ? ?
|
||||
}
|
||||
|
||||
odf_context()->end_math();
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,13 +71,23 @@ void office_math::add_child_element(const office_element_ptr & child_element)
|
||||
|
||||
void office_math::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
if (false == content_.empty())
|
||||
{
|
||||
CP_XML_NODE_SIMPLE_NONS()
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns", L"http://www.w3.org/1998/Math/MathML");
|
||||
|
||||
semantics_->serialize(CP_XML_STREAM());
|
||||
_Wostream << content_;
|
||||
}
|
||||
else
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE_NONS()
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns", L"http://www.w3.org/1998/Math/MathML");
|
||||
|
||||
if (semantics_)
|
||||
{
|
||||
semantics_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,12 +75,13 @@ public:
|
||||
static const wchar_t * name;
|
||||
|
||||
static const ElementType type = typeMath;
|
||||
|
||||
|
||||
friend class odf_document;
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element(const office_element_ptr & child_element);
|
||||
|
||||
std::wstring content_;
|
||||
private:
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
|
||||
@ -420,7 +420,7 @@ void odf_conversion_context::end_math()
|
||||
_CP_OPT(double)height = convert_symbol_width(1.76 * h, true);
|
||||
|
||||
if (false == math_context_.in_text_box_)
|
||||
drawing_context()->set_size(width, height); // раскомиттить по завершению
|
||||
drawing_context()->set_size(width, height);
|
||||
|
||||
drawing_context()->end_object(!math_context_.in_text_box_);
|
||||
|
||||
|
||||
@ -134,12 +134,10 @@ namespace odf_writer
|
||||
lvl_down_counter = -1;
|
||||
lvl_max = 1;
|
||||
lvl_min = -1;
|
||||
//debug_stream.open(debug_fileName);
|
||||
}
|
||||
|
||||
odf_math_context::~odf_math_context()
|
||||
{
|
||||
//debug_stream.close();
|
||||
}
|
||||
|
||||
void odf_math_context::set_styles_context(odf_style_context_ptr style_context)
|
||||
@ -172,14 +170,21 @@ namespace odf_writer
|
||||
|
||||
size_t level = impl_->current_level_.size();
|
||||
|
||||
odf_math_level_state level_state = { NULL, NULL, root };
|
||||
odf_math_level_state level_state = { NULL, NULL, root };
|
||||
odf_element_state state(root, L"", office_element_ptr(), level);
|
||||
|
||||
impl_->current_level_.push_back(level_state);
|
||||
impl_->current_math_state_.elements_.push_back(state);
|
||||
style_flag = true;
|
||||
}
|
||||
void odf_math_context::end_math()
|
||||
{
|
||||
if (impl_->current_math_state_.elements_.empty()) return;
|
||||
|
||||
end_element();
|
||||
|
||||
impl_->clear_current();
|
||||
}
|
||||
bool odf_math_context::start_element(office_element_ptr & elm)
|
||||
{
|
||||
if (!elm)
|
||||
@ -198,19 +203,18 @@ namespace odf_writer
|
||||
|
||||
void odf_math_context::end_element()
|
||||
{
|
||||
if (impl_->current_level_.empty()) return;
|
||||
|
||||
impl_->current_level_.pop_back();
|
||||
}
|
||||
bool odf_math_context::isEmpty()
|
||||
{
|
||||
return impl_->current_level_.empty();
|
||||
}
|
||||
void odf_math_context::end_math()
|
||||
void odf_math_context::add_content(const std::wstring& content)
|
||||
{
|
||||
if (impl_->current_math_state_.elements_.empty()) return;
|
||||
|
||||
end_element();
|
||||
|
||||
impl_->clear_current();
|
||||
if (!impl_->root_element_) return;
|
||||
impl_->root_element_->content_ = content;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -106,9 +106,11 @@ namespace cpdoccore {
|
||||
odf_text_context* text_context();
|
||||
|
||||
void start_math(office_element_ptr& root);
|
||||
void end_math();
|
||||
|
||||
bool start_element(office_element_ptr& elm); // office_math_element TODO
|
||||
void add_content(const std::wstring& content);
|
||||
|
||||
bool start_element(office_element_ptr& elm);
|
||||
void end_element();
|
||||
|
||||
std::vector<std::vector<std::wstring>> brackets;
|
||||
@ -132,10 +134,6 @@ namespace cpdoccore {
|
||||
std::set<wchar_t> mo;
|
||||
std::map<std::wstring, std::wstring> diak_symbols;
|
||||
|
||||
void end_math();
|
||||
|
||||
std::wofstream debug_stream;
|
||||
std::string debug_fileName = "debugLog.txt";
|
||||
bool isEmpty();
|
||||
std::vector<bool> tagFlag;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user