diff --git a/OdfFile/Projects/Linux/OdfFormatLib.pro b/OdfFile/Projects/Linux/OdfFormatLib.pro index 45e696350e..d3e81ad1de 100644 --- a/OdfFile/Projects/Linux/OdfFormatLib.pro +++ b/OdfFile/Projects/Linux/OdfFormatLib.pro @@ -19,6 +19,8 @@ include(../../../Common/base.pri) #BOOST include($$PWD/../../../Common/3dParty/boost/boost.pri) +include($$PWD/../../Reader/Converter/StarMath2OOXML/StarMath2OOXML.pri) + DEFINES += UNICODE \ _UNICODE \ DONT_WRITE_EMBEDDED_FONTS diff --git a/OdfFile/Projects/Windows/cpodf.vcxproj b/OdfFile/Projects/Windows/cpodf.vcxproj index 9261997573..05f9ae9ddd 100644 --- a/OdfFile/Projects/Windows/cpodf.vcxproj +++ b/OdfFile/Projects/Windows/cpodf.vcxproj @@ -282,6 +282,8 @@ /bigobj %(AdditionalOptions) + + /bigobj %(AdditionalOptions) @@ -675,6 +677,9 @@ + + + diff --git a/OdfFile/Projects/Windows/cpodf.vcxproj.filters b/OdfFile/Projects/Windows/cpodf.vcxproj.filters index 7ab9701d63..9fca4cac95 100644 --- a/OdfFile/Projects/Windows/cpodf.vcxproj.filters +++ b/OdfFile/Projects/Windows/cpodf.vcxproj.filters @@ -25,6 +25,9 @@ {67b2bf43-5673-4a6f-82cb-fe4be01aee5f} + + {7d3e34d2-a224-4d68-9144-4889bbcc3698} + @@ -481,6 +484,12 @@ oox\pptx + + starmath + + + starmath + @@ -934,5 +943,14 @@ oox\pptx + + starmath + + + starmath + + + starmath + \ No newline at end of file diff --git a/OdfFile/Reader/Converter/StarMath2OOXML/cconversionsmtoooxml.cpp b/OdfFile/Reader/Converter/StarMath2OOXML/cconversionsmtoooxml.cpp index cbf8962794..e7bd859a2c 100644 --- a/OdfFile/Reader/Converter/StarMath2OOXML/cconversionsmtoooxml.cpp +++ b/OdfFile/Reader/Converter/StarMath2OOXML/cconversionsmtoooxml.cpp @@ -1,3 +1,34 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2023 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ #include "cconversionsmtoooxml.h" #include "../../../../DesktopEditor/common/File.h" #include @@ -16,15 +47,13 @@ namespace StarMath { oTempElement->ConversionToOOXML(m_pXmlWrite); } EndConversion(); - NSFile::CFileBinary oFile; - oFile.CreateFileW(L"Test.txt"); - oFile.WriteStringUTF8(m_pXmlWrite->GetXmlString()); - oFile.CloseFile(); } void CConversionSMtoOOXML::StandartProperties(XmlUtils::CXmlWriter* pXmlWrite,CAttribute* pAttribute) { if(pAttribute == nullptr) { + //тут должны быть базовые свойства шрифта, задаваемые выше + pXmlWrite->WriteNodeBegin(L"w:rPr",false); pXmlWrite->WriteNodeBegin(L"w:rFonts",true); pXmlWrite->WriteAttribute(L"w:hAnsi",L"Cambria Math"); @@ -47,6 +76,7 @@ namespace StarMath { pXmlWrite->WriteNodeEnd(L"w",true,true); if(pAttribute->GetSize() == 0) { + //тут должны быть базовые свойства шрифта, задаваемые выше - далее везде где не задано - аналогично pXmlWrite->WriteNodeBegin(L"w:sz",true); pXmlWrite->WriteAttribute(L"w:val",L"40"); pXmlWrite->WriteNodeEnd(L"w",true,true); diff --git a/OdfFile/Reader/Converter/StarMath2OOXML/cconversionsmtoooxml.h b/OdfFile/Reader/Converter/StarMath2OOXML/cconversionsmtoooxml.h index 7656f54f25..5581cc4742 100644 --- a/OdfFile/Reader/Converter/StarMath2OOXML/cconversionsmtoooxml.h +++ b/OdfFile/Reader/Converter/StarMath2OOXML/cconversionsmtoooxml.h @@ -1,10 +1,40 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2023 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + #ifndef CCONVERSIONSMTOOOXML_H #define CCONVERSIONSMTOOOXML_H #include "cstarmathpars.h" #include "../../../../DesktopEditor/xml/include/xmlwriter.h" - - namespace StarMath { //delete XmlWrite class CConversionSMtoOOXML diff --git a/OdfFile/Reader/Converter/StarMath2OOXML/cstarmathpars.cpp b/OdfFile/Reader/Converter/StarMath2OOXML/cstarmathpars.cpp index d35669edb3..46fad8c507 100644 --- a/OdfFile/Reader/Converter/StarMath2OOXML/cstarmathpars.cpp +++ b/OdfFile/Reader/Converter/StarMath2OOXML/cstarmathpars.cpp @@ -1,3 +1,35 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2023 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + #include "cstarmathpars.h" #include "cconversionsmtoooxml.h" namespace StarMath diff --git a/OdfFile/Reader/Converter/StarMath2OOXML/cstarmathpars.h b/OdfFile/Reader/Converter/StarMath2OOXML/cstarmathpars.h index 2304e4a77e..30afb326a2 100644 --- a/OdfFile/Reader/Converter/StarMath2OOXML/cstarmathpars.h +++ b/OdfFile/Reader/Converter/StarMath2OOXML/cstarmathpars.h @@ -1,3 +1,35 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2023 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + #ifndef CSTARMATHPARS_H #define CSTARMATHPARS_H #include "typeselements.h" diff --git a/OdfFile/Reader/Converter/StarMath2OOXML/typeselements.h b/OdfFile/Reader/Converter/StarMath2OOXML/typeselements.h index b59de24931..3ed61afb42 100644 --- a/OdfFile/Reader/Converter/StarMath2OOXML/typeselements.h +++ b/OdfFile/Reader/Converter/StarMath2OOXML/typeselements.h @@ -1,5 +1,38 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2023 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + #ifndef TYPESELEMENTS_H #define TYPESELEMENTS_H + namespace StarMath { enum class TypeElement{ diff --git a/OdfFile/Reader/Format/math_elements.cpp b/OdfFile/Reader/Format/math_elements.cpp index 7e68a62abf..aa46882f15 100644 --- a/OdfFile/Reader/Format/math_elements.cpp +++ b/OdfFile/Reader/Format/math_elements.cpp @@ -31,6 +31,7 @@ */ #include "math_elements.h" +#include "../Converter/StarMath2OOXML/cconversionsmtoooxml.h" namespace cpdoccore { @@ -93,10 +94,39 @@ void math_semantics::add_child_element( xml::sax * Reader, const std::wstring & void math_semantics::oox_convert(oox::math_context & Context) { - for (size_t i = 0 ; i < content_.size(); i++) + math_annotation* annotation = dynamic_cast(annotation_.get()); + math_annotation_xml* annotation_xml = dynamic_cast(annotation_.get()); + + std::wstring annotation_text; + if ((annotation) && (annotation->text_)) annotation_text = *annotation->text_; + else if ((annotation_xml) && (annotation_xml->text_)) annotation_text = *annotation_xml->text_; + + bool result = false; + if (!annotation_text.empty()) { - office_math_element* math_element = dynamic_cast(content_[i].get()); - math_element->oox_convert(Context); + result = true; + StarMath::CParserStarMathString parser; + StarMath::CConversionSMtoOOXML converter; + + // базовые свойства шрифта для математики + /*parser.set*/ /*?*/ /*converter.set*/ Context.base_font_name_; + /*parser.set*/ /*?*/ /*converter.set*/ Context.base_font_size_; + /*parser.set*/ /*?*/ /*converter.set*/ Context.base_alignment_; + /*parser.set*/ /*?*/ /*converter.set*/ Context.base_font_italic_; + /*parser.set*/ /*?*/ /*converter.set*/ Context.base_font_bold_; + + /*result = */converter.StartConversion(parser.Parse(annotation_text)); + + Context.output_stream() << converter.GetOOXML(); + } + + if (!result) + { + for (size_t i = 0; i < content_.size(); i++) + { + office_math_element* math_element = dynamic_cast(content_[i].get()); + math_element->oox_convert(Context); + } } } @@ -126,11 +156,6 @@ void math_annotation::add_text(const std::wstring & Text) text_ = Text; } -void math_annotation::oox_convert(oox::math_context & Context) -{ - -} - //---------------------------------------------------------------------------------------------------- const wchar_t * math_annotation_xml::ns = L"math"; const wchar_t * math_annotation_xml::name = L"annotation-xml"; @@ -157,10 +182,6 @@ void math_annotation_xml::add_text(const std::wstring & Text) text_ = Text; } -void math_annotation_xml::oox_convert(oox::math_context & Context) -{ - -} //---------------------------------------------------------------------------------------------------- } diff --git a/OdfFile/Reader/Format/math_elements.h b/OdfFile/Reader/Format/math_elements.h index e7691fa0d5..0c8e49dbec 100644 --- a/OdfFile/Reader/Format/math_elements.h +++ b/OdfFile/Reader/Format/math_elements.h @@ -119,16 +119,16 @@ public: static const xml::NodeType xml_type = xml::typeElement; static const ElementType type = typeMathAnnotation; - virtual void oox_convert(oox::math_context & Context); + virtual void oox_convert(oox::math_context& Context) {} + _CP_OPT(std::wstring) text_; 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); - office_element_ptr_array content_; - _CP_OPT(std::wstring) text_; - _CP_OPT(std::wstring) encoding_; + office_element_ptr_array content_; + _CP_OPT(std::wstring) encoding_; }; CP_REGISTER_OFFICE_ELEMENT2(math_annotation); @@ -142,15 +142,15 @@ public: static const xml::NodeType xml_type = xml::typeElement; static const ElementType type = typeMathAnnotationXml; - virtual void oox_convert(oox::math_context & Context); + virtual void oox_convert(oox::math_context& Context) {} + _CP_OPT(std::wstring) text_; 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); office_element_ptr_array content_; - _CP_OPT(std::wstring) text_; _CP_OPT(std::wstring) encoding_; };