diff --git a/OOXML/PPTXFormat/Logic/ContentPart.cpp b/OOXML/PPTXFormat/Logic/Ah.cpp similarity index 92% rename from OOXML/PPTXFormat/Logic/ContentPart.cpp rename to OOXML/PPTXFormat/Logic/Ah.cpp index 7aedbea561..90e11b9601 100644 --- a/OOXML/PPTXFormat/Logic/ContentPart.cpp +++ b/OOXML/PPTXFormat/Logic/Ah.cpp @@ -1,4 +1,4 @@ -/* +/* * (c) Copyright Ascensio System SIA 2010-2019 * * This program is a free software product. You can redistribute it and/or @@ -29,3 +29,14 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ + +#include "Ah.h" + +namespace PPTX +{ + namespace Logic + { + Ah::Ah() {} + Ah::~Ah() {} + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Ah.h b/OOXML/PPTXFormat/Logic/Ah.h index 57c48bcf5f..68fd09304d 100644 --- a/OOXML/PPTXFormat/Logic/Ah.h +++ b/OOXML/PPTXFormat/Logic/Ah.h @@ -42,11 +42,12 @@ namespace PPTX class Ah : public WrapperWritingElement { public: - Ah(){} - virtual ~Ah(){} + Ah(); + virtual ~Ah(); + virtual std::wstring GetODString()const = 0; }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_AH_INCLUDE_H_ \ No newline at end of file +#endif // PPTX_LOGIC_AH_INCLUDE_H_ diff --git a/OOXML/PPTXFormat/Logic/AhBase.cpp b/OOXML/PPTXFormat/Logic/AhBase.cpp new file mode 100644 index 0000000000..9f21ffb961 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/AhBase.cpp @@ -0,0 +1,110 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "AhBase.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType AhBase::getType() const + { + if (ah.IsInit()) + return ah->getType(); + return OOX::et_Unknown; + } + void AhBase::fromXML(XmlUtils::CXmlNode& node) + { + std::wstring name = XmlUtils::GetNameNoNS(node.GetName()); + + if (name == _T("ahXY")) + ah.reset(new Logic::AhXY(node)); + else if (name == _T("ahPolar")) + ah.reset(new Logic::AhPolar(node)); + else ah.reset(); + } + void AhBase::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (sName == L"ahXY") + ah.reset(new Logic::AhXY(oReader)); + else if(sName == L"ahPolar") + ah.reset(new Logic::AhPolar(oReader)); + else ah.reset(); + } + void AhBase::GetAdjustHandleFrom(XmlUtils::CXmlNode& element) + { + XmlUtils::CXmlNode oNode; + if (element.GetNode(_T("a:ahXY"), oNode)) + ah.reset(new Logic::AhXY(oNode)); + else if(element.GetNode(_T("a:ahPolar"), oNode)) + ah.reset(new Logic::AhPolar(oNode)); + else ah.reset(); + } + std::wstring AhBase::toXML() const + { + if (ah.is_init()) + return ah->toXML(); + + return _T(""); + } + void AhBase::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + if (ah.is_init()) + ah->toPPTY(pWriter); + } + void AhBase::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + if (ah.is_init()) + ah->toXmlWriter(pWriter); + } + bool AhBase::is_init() const + { + return (ah.is_init()); + } + void AhBase::FillParentPointersForChilds() + { + } + void AhBase::SetParentPointer(const WrapperWritingElement* pParent) + { + if(is_init()) + ah->SetParentPointer(pParent); + } + std::wstring AhBase::GetODString()const + { + if (!ah.IsInit()) + return _T(""); + return ah->GetODString(); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/AhBase.h b/OOXML/PPTXFormat/Logic/AhBase.h index 900286a4ab..4b0f047471 100644 --- a/OOXML/PPTXFormat/Logic/AhBase.h +++ b/OOXML/PPTXFormat/Logic/AhBase.h @@ -48,86 +48,34 @@ namespace PPTX WritingElement_AdditionConstructors(AhBase) PPTX_LOGIC_BASE2(AhBase) - virtual OOX::EElementType getType() const - { - if (ah.IsInit()) - return ah->getType(); - return OOX::et_Unknown; - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - std::wstring name = XmlUtils::GetNameNoNS(node.GetName()); + virtual OOX::EElementType getType() const; - if (name == _T("ahXY")) - ah.reset(new Logic::AhXY(node)); - else if (name == _T("ahPolar")) - ah.reset(new Logic::AhPolar(node)); - else ah.reset(); - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - if (sName == L"ahXY") - ah.reset(new Logic::AhXY(oReader)); - else if(sName == L"ahPolar") - ah.reset(new Logic::AhPolar(oReader)); - else ah.reset(); - } - virtual void GetAdjustHandleFrom(XmlUtils::CXmlNode& element) - { - XmlUtils::CXmlNode oNode; - if (element.GetNode(_T("a:ahXY"), oNode)) - ah.reset(new Logic::AhXY(oNode)); - else if(element.GetNode(_T("a:ahPolar"), oNode)) - ah.reset(new Logic::AhPolar(oNode)); - else ah.reset(); - } + virtual void GetAdjustHandleFrom(XmlUtils::CXmlNode& element); - virtual std::wstring toXML() const - { - if (ah.is_init()) - return ah->toXML(); - - return _T(""); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - if (ah.is_init()) - ah->toPPTY(pWriter); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - if (ah.is_init()) - ah->toXmlWriter(pWriter); - } + virtual std::wstring toXML() const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; template const bool is() const { return (!ah.IsInit())?false:(typeid(*ah) == typeid(T));} template T& as() {return static_cast(*ah);} template const T& as() const {return static_cast(*ah);} - virtual bool is_init()const{return (ah.is_init());}; + virtual bool is_init()const; public: smart_ptr ah; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); + public: - virtual void SetParentPointer(const WrapperWritingElement* pParent) - { - if(is_init()) - ah->SetParentPointer(pParent); - } - - std::wstring GetODString()const - { - if (!ah.IsInit()) - return _T(""); - return ah->GetODString(); - } + virtual void SetParentPointer(const WrapperWritingElement* pParent); + std::wstring GetODString() const; }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_AHBASE_INCLUDE_H_ \ No newline at end of file +#endif // PPTX_LOGIC_AHBASE_INCLUDE_H_ diff --git a/OOXML/PPTXFormat/Logic/AhPolar.cpp b/OOXML/PPTXFormat/Logic/AhPolar.cpp new file mode 100644 index 0000000000..b93506236b --- /dev/null +++ b/OOXML/PPTXFormat/Logic/AhPolar.cpp @@ -0,0 +1,169 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "AhPolar.h" + +namespace PPTX +{ + namespace Logic + { + void AhPolar::fromXML(XmlUtils::CXmlNode& node) + { + XmlUtils::CXmlNode oPos = node.ReadNode(_T("a:pos")); + + x = oPos.GetAttributeBase(L"x"); + y = oPos.GetAttributeBase(L"y"); + + XmlMacroReadAttributeBase(node, L"gdRefAng", gdRefAng); + XmlMacroReadAttributeBase(node, L"gdRefR", gdRefR); + XmlMacroReadAttributeBase(node, L"maxAng", maxAng); + XmlMacroReadAttributeBase(node, L"maxR", maxR); + XmlMacroReadAttributeBase(node, L"minAng", minAng); + XmlMacroReadAttributeBase(node, L"minR", minR); + } + OOX::EElementType AhPolar::getType() const + { + return OOX::et_a_ahPolar; + } + void AhPolar::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring sName = oReader.GetName(); + + if (sName == L"a:pos") + { + ReadAttributes2(oReader); + } + } + } + void AhPolar::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("gdRefR"), gdRefR ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("minR"), minR ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("maxR"), maxR ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("gdRefAng"), gdRefAng ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("minAng"), minAng ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("maxAng"), maxAng ) + WritingElement_ReadAttributes_End( oReader ) + } + void AhPolar::ReadAttributes2(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y ) + WritingElement_ReadAttributes_End( oReader ) + } + std::wstring AhPolar::toXML() const + { + XmlUtils::CAttribute oAttr1; + oAttr1.Write(_T("gdRefR"), gdRefR); + oAttr1.Write(_T("minR"), minR); + oAttr1.Write(_T("maxR"), maxR); + oAttr1.Write(_T("gdRefAng"), gdRefAng); + oAttr1.Write(_T("minAng"), minAng); + oAttr1.Write(_T("maxAng"), maxAng); + + XmlUtils::CAttribute oAttr2; + oAttr2.Write(_T("x"), x); + oAttr2.Write(_T("y"), y); + + return XmlUtils::CreateNode(_T("a:ahPolar"), oAttr1, XmlUtils::CreateNode(_T("a:pos"), oAttr2)); + } + void AhPolar::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:ahPolar")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("gdRefR"), gdRefR); + pWriter->WriteAttribute(_T("minR"), minR); + pWriter->WriteAttribute(_T("maxR"), maxR); + pWriter->WriteAttribute(_T("gdRefAng"), gdRefAng); + pWriter->WriteAttribute(_T("minAng"), minAng); + pWriter->WriteAttribute(_T("maxAng"), maxAng); + pWriter->EndAttributes(); + + pWriter->StartNode(_T("a:pos")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("x"), x); + pWriter->WriteAttribute(_T("y"), y); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:pos")); + + pWriter->EndNode(_T("a:ahPolar")); + } + void AhPolar::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->StartRecord(GEOMETRY_TYPE_AH_POLAR); + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteString1(0, x); + pWriter->WriteString1(1, y); + + pWriter->WriteString2(2, gdRefAng); + pWriter->WriteString2(3, gdRefR); + pWriter->WriteString2(4, maxAng); + pWriter->WriteString2(5, maxR); + pWriter->WriteString2(6, minAng); + pWriter->WriteString2(7, minR); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->EndRecord(); + } + void AhPolar::FillParentPointersForChilds() + { + } + std::wstring AhPolar::GetODString() const + { + XmlUtils::CAttribute oAttr1; + oAttr1.Write(_T("gdRefR"), gdRefR); + oAttr1.Write(_T("minR"), minR); + oAttr1.Write(_T("maxR"), maxR); + oAttr1.Write(_T("gdRefAng"), gdRefAng); + oAttr1.Write(_T("minAng"), minAng); + oAttr1.Write(_T("maxAng"), maxAng); + + XmlUtils::CAttribute oAttr2; + oAttr2.Write(_T("x"), x); + oAttr2.Write(_T("y"), y); + + return XmlUtils::CreateNode(_T("ahPolar"), oAttr1, XmlUtils::CreateNode(_T("pos"), oAttr2)); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/AhPolar.h b/OOXML/PPTXFormat/Logic/AhPolar.h index 8d7e79aa6f..676a057daa 100644 --- a/OOXML/PPTXFormat/Logic/AhPolar.h +++ b/OOXML/PPTXFormat/Logic/AhPolar.h @@ -39,125 +39,22 @@ namespace PPTX { namespace Logic { - class AhPolar : public Ah { public: WritingElement_AdditionConstructors(AhPolar) PPTX_LOGIC_BASE2(AhPolar) - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlUtils::CXmlNode oPos = node.ReadNode(_T("a:pos")); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual OOX::EElementType getType() const; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - x = oPos.GetAttributeBase(L"x"); - y = oPos.GetAttributeBase(L"y"); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader); - XmlMacroReadAttributeBase(node, L"gdRefAng", gdRefAng); - XmlMacroReadAttributeBase(node, L"gdRefR", gdRefR); - XmlMacroReadAttributeBase(node, L"maxAng", maxAng); - XmlMacroReadAttributeBase(node, L"maxR", maxR); - XmlMacroReadAttributeBase(node, L"minAng", minAng); - XmlMacroReadAttributeBase(node, L"minR", minR); - } - virtual OOX::EElementType getType() const - { - return OOX::et_a_ahPolar; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); - - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring sName = oReader.GetName(); - - if (sName == L"a:pos") - { - ReadAttributes2(oReader); - } - } - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("gdRefR"), gdRefR ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("minR"), minR ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("maxR"), maxR ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("gdRefAng"), gdRefAng ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("minAng"), minAng ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("maxAng"), maxAng ) - WritingElement_ReadAttributes_End( oReader ) - } - void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y ) - WritingElement_ReadAttributes_End( oReader ) - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr1; - oAttr1.Write(_T("gdRefR"), gdRefR); - oAttr1.Write(_T("minR"), minR); - oAttr1.Write(_T("maxR"), maxR); - oAttr1.Write(_T("gdRefAng"), gdRefAng); - oAttr1.Write(_T("minAng"), minAng); - oAttr1.Write(_T("maxAng"), maxAng); - - XmlUtils::CAttribute oAttr2; - oAttr2.Write(_T("x"), x); - oAttr2.Write(_T("y"), y); - - return XmlUtils::CreateNode(_T("a:ahPolar"), oAttr1, XmlUtils::CreateNode(_T("a:pos"), oAttr2)); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:ahPolar")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("gdRefR"), gdRefR); - pWriter->WriteAttribute(_T("minR"), minR); - pWriter->WriteAttribute(_T("maxR"), maxR); - pWriter->WriteAttribute(_T("gdRefAng"), gdRefAng); - pWriter->WriteAttribute(_T("minAng"), minAng); - pWriter->WriteAttribute(_T("maxAng"), maxAng); - pWriter->EndAttributes(); - - pWriter->StartNode(_T("a:pos")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("x"), x); - pWriter->WriteAttribute(_T("y"), y); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:pos")); - - pWriter->EndNode(_T("a:ahPolar")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->StartRecord(GEOMETRY_TYPE_AH_POLAR); - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteString1(0, x); - pWriter->WriteString1(1, y); - - pWriter->WriteString2(2, gdRefAng); - pWriter->WriteString2(3, gdRefR); - pWriter->WriteString2(4, maxAng); - pWriter->WriteString2(5, maxR); - pWriter->WriteString2(6, minAng); - pWriter->WriteString2(7, minR); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->EndRecord(); - } + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; public: std::wstring x; @@ -169,25 +66,12 @@ namespace PPTX nullable_string maxR; nullable_string minAng; nullable_string minR; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); + public: - std::wstring GetODString()const - { - XmlUtils::CAttribute oAttr1; - oAttr1.Write(_T("gdRefR"), gdRefR); - oAttr1.Write(_T("minR"), minR); - oAttr1.Write(_T("maxR"), maxR); - oAttr1.Write(_T("gdRefAng"), gdRefAng); - oAttr1.Write(_T("minAng"), minAng); - oAttr1.Write(_T("maxAng"), maxAng); - - XmlUtils::CAttribute oAttr2; - oAttr2.Write(_T("x"), x); - oAttr2.Write(_T("y"), y); - - return XmlUtils::CreateNode(_T("ahPolar"), oAttr1, XmlUtils::CreateNode(_T("pos"), oAttr2)); - } + std::wstring GetODString() const; }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/AhXY.cpp b/OOXML/PPTXFormat/Logic/AhXY.cpp new file mode 100644 index 0000000000..860d730cc0 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/AhXY.cpp @@ -0,0 +1,169 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "AhXY.h" + +namespace PPTX +{ + namespace Logic + { + void AhXY::fromXML(XmlUtils::CXmlNode& node) + { + XmlUtils::CXmlNode oPos = node.ReadNode(_T("a:pos")); + + x = oPos.ReadAttributeBase(L"x"); + y = oPos.ReadAttributeBase(L"y"); + + XmlMacroReadAttributeBase(node, L"gdRefX", gdRefX); + XmlMacroReadAttributeBase(node, L"gdRefY", gdRefY); + XmlMacroReadAttributeBase(node, L"maxX", maxX); + XmlMacroReadAttributeBase(node, L"maxY", maxY); + XmlMacroReadAttributeBase(node, L"minX", minX); + XmlMacroReadAttributeBase(node, L"minY", minY); + } + OOX::EElementType AhXY::getType() const + { + return OOX::et_a_ahXY; + } + void AhXY::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring sName = oReader.GetName(); + + if (sName == L"a:pos") + { + ReadAttributes2(oReader); + } + } + } + void AhXY::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("gdRefX"), gdRefX ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("minX"), minX ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("maxX"), maxX ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("gdRefY"), gdRefY ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("minY"), minY ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("maxY"), maxY ) + WritingElement_ReadAttributes_End( oReader ) + } + void AhXY::ReadAttributes2(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y ) + WritingElement_ReadAttributes_End( oReader ) + } + std::wstring AhXY::toXML() const + { + XmlUtils::CAttribute oAttr1; + oAttr1.Write(_T("gdRefX"), gdRefX); + oAttr1.Write(_T("minX"), minX); + oAttr1.Write(_T("maxX"), maxX); + oAttr1.Write(_T("gdRefY"), gdRefY); + oAttr1.Write(_T("minY"), minY); + oAttr1.Write(_T("maxY"), maxY); + + XmlUtils::CAttribute oAttr2; + oAttr2.Write(_T("x"), x); + oAttr2.Write(_T("y"), y); + + return XmlUtils::CreateNode(_T("a:ahXY"), oAttr1, XmlUtils::CreateNode(_T("a:pos"), oAttr2)); + } + void AhXY::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:ahXY")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("gdRefX"), gdRefX); + pWriter->WriteAttribute(_T("minX"), minX); + pWriter->WriteAttribute(_T("maxX"), maxX); + pWriter->WriteAttribute(_T("gdRefY"), gdRefY); + pWriter->WriteAttribute(_T("minY"), minY); + pWriter->WriteAttribute(_T("maxY"), maxY); + pWriter->EndAttributes(); + + pWriter->StartNode(_T("a:pos")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("x"), x); + pWriter->WriteAttribute(_T("y"), y); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:pos")); + + pWriter->EndNode(_T("a:ahXY")); + } + void AhXY::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->StartRecord(GEOMETRY_TYPE_AH_XY); + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteString1(0, x); + pWriter->WriteString1(1, y); + + pWriter->WriteString2(2, gdRefX); + pWriter->WriteString2(3, gdRefY); + pWriter->WriteString2(4, maxX); + pWriter->WriteString2(5, maxY); + pWriter->WriteString2(6, minX); + pWriter->WriteString2(7, minY); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->EndRecord(); + } + void AhXY::FillParentPointersForChilds() + { + } + std::wstring AhXY::GetODString()const + { + XmlUtils::CAttribute oAttr1; + oAttr1.Write(_T("gdRefX"), gdRefX); + oAttr1.Write(_T("minX"), minX); + oAttr1.Write(_T("maxX"), maxX); + oAttr1.Write(_T("gdRefY"), gdRefY); + oAttr1.Write(_T("minY"), minY); + oAttr1.Write(_T("maxY"), maxY); + + XmlUtils::CAttribute oAttr2; + oAttr2.Write(_T("x"), x); + oAttr2.Write(_T("y"), y); + + return XmlUtils::CreateNode(_T("ahXY"), oAttr1, XmlUtils::CreateNode(_T("pos"), oAttr2)); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/AhXY.h b/OOXML/PPTXFormat/Logic/AhXY.h index 51d1b58ce3..65fc76ec36 100644 --- a/OOXML/PPTXFormat/Logic/AhXY.h +++ b/OOXML/PPTXFormat/Logic/AhXY.h @@ -39,125 +39,23 @@ namespace PPTX { namespace Logic { - class AhXY : public Ah { public: WritingElement_AdditionConstructors(AhXY) PPTX_LOGIC_BASE2(AhXY) - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlUtils::CXmlNode oPos = node.ReadNode(_T("a:pos")); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual OOX::EElementType getType() const; - x = oPos.ReadAttributeBase(L"x"); - y = oPos.ReadAttributeBase(L"y"); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - XmlMacroReadAttributeBase(node, L"gdRefX", gdRefX); - XmlMacroReadAttributeBase(node, L"gdRefY", gdRefY); - XmlMacroReadAttributeBase(node, L"maxX", maxX); - XmlMacroReadAttributeBase(node, L"maxY", maxY); - XmlMacroReadAttributeBase(node, L"minX", minX); - XmlMacroReadAttributeBase(node, L"minY", minY); - } - virtual OOX::EElementType getType() const - { - return OOX::et_a_ahXY; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader); - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring sName = oReader.GetName(); - - if (sName == L"a:pos") - { - ReadAttributes2(oReader); - } - } - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("gdRefX"), gdRefX ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("minX"), minX ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("maxX"), maxX ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("gdRefY"), gdRefY ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("minY"), minY ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("maxY"), maxY ) - WritingElement_ReadAttributes_End( oReader ) - } - void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y ) - WritingElement_ReadAttributes_End( oReader ) - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr1; - oAttr1.Write(_T("gdRefX"), gdRefX); - oAttr1.Write(_T("minX"), minX); - oAttr1.Write(_T("maxX"), maxX); - oAttr1.Write(_T("gdRefY"), gdRefY); - oAttr1.Write(_T("minY"), minY); - oAttr1.Write(_T("maxY"), maxY); - - XmlUtils::CAttribute oAttr2; - oAttr2.Write(_T("x"), x); - oAttr2.Write(_T("y"), y); - - return XmlUtils::CreateNode(_T("a:ahXY"), oAttr1, XmlUtils::CreateNode(_T("a:pos"), oAttr2)); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:ahXY")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("gdRefX"), gdRefX); - pWriter->WriteAttribute(_T("minX"), minX); - pWriter->WriteAttribute(_T("maxX"), maxX); - pWriter->WriteAttribute(_T("gdRefY"), gdRefY); - pWriter->WriteAttribute(_T("minY"), minY); - pWriter->WriteAttribute(_T("maxY"), maxY); - pWriter->EndAttributes(); - - pWriter->StartNode(_T("a:pos")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("x"), x); - pWriter->WriteAttribute(_T("y"), y); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:pos")); - - pWriter->EndNode(_T("a:ahXY")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->StartRecord(GEOMETRY_TYPE_AH_XY); - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteString1(0, x); - pWriter->WriteString1(1, y); - - pWriter->WriteString2(2, gdRefX); - pWriter->WriteString2(3, gdRefY); - pWriter->WriteString2(4, maxX); - pWriter->WriteString2(5, maxY); - pWriter->WriteString2(6, minX); - pWriter->WriteString2(7, minY); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->EndRecord(); - } + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; public: std::wstring x; @@ -169,26 +67,12 @@ namespace PPTX nullable_string maxY; nullable_string minX; nullable_string minY; + protected: - virtual void FillParentPointersForChilds(){}; - public: - - std::wstring GetODString()const - { - XmlUtils::CAttribute oAttr1; - oAttr1.Write(_T("gdRefX"), gdRefX); - oAttr1.Write(_T("minX"), minX); - oAttr1.Write(_T("maxX"), maxX); - oAttr1.Write(_T("gdRefY"), gdRefY); - oAttr1.Write(_T("minY"), minY); - oAttr1.Write(_T("maxY"), maxY); + virtual void FillParentPointersForChilds(); - XmlUtils::CAttribute oAttr2; - oAttr2.Write(_T("x"), x); - oAttr2.Write(_T("y"), y); - - return XmlUtils::CreateNode(_T("ahXY"), oAttr1, XmlUtils::CreateNode(_T("pos"), oAttr2)); - } + public: + std::wstring GetODString() const; }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Backdrop.cpp b/OOXML/PPTXFormat/Logic/Backdrop.cpp new file mode 100644 index 0000000000..376cba3056 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Backdrop.cpp @@ -0,0 +1,207 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Backdrop.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType Backdrop::getType() const + { + return OOX::et_a_backdrop; + } + void Backdrop::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + std::wstring strName = oReader.GetName(); + nullable_int x, y, z; + + if (strName == L"a:anchor") + { + ReadAttributes(oReader, x, y, z); + anchorX = x.get_value_or(0); + anchorY = y.get_value_or(0); + anchorZ = z.get_value_or(0); + } + else if (strName == L"a:norm") + { + ReadAttributes(oReader, x, y, z); + normX = x.get_value_or(0); + normY = y.get_value_or(0); + normZ = z.get_value_or(0); + } + else if (strName == L"a:up") + { + ReadAttributes(oReader, x, y, z); + + upX = x.get_value_or(0); + upY = y.get_value_or(0); + upZ = z.get_value_or(0); + } + } + FillParentPointersForChilds(); + } + void Backdrop::ReadAttributes(XmlUtils::CXmlLiteReader& oReader, nullable_int & x, nullable_int & y, nullable_int & z ) + { + WritingElement_ReadAttributes_Start_No_NS( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("z"), z) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("dx"), x) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("dy"), y) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("dz"), z) + WritingElement_ReadAttributes_End_No_NS( oReader ) + } + void Backdrop::fromXML(XmlUtils::CXmlNode& node) + { + XmlUtils::CXmlNode oNodeA = node.ReadNode(_T("a:anchor")); + XmlUtils::CXmlNode oNodeN = node.ReadNode(_T("a:norm")); + XmlUtils::CXmlNode oNodeU = node.ReadNode(_T("a:up")); + + anchorX = oNodeA.ReadAttributeInt(L"x"); + anchorY = oNodeA.ReadAttributeInt(L"y"); + anchorZ = oNodeA.ReadAttributeInt(L"z"); + + normX = oNodeN.ReadAttributeInt(L"dx"); + normY = oNodeN.ReadAttributeInt(L"dy"); + normZ = oNodeN.ReadAttributeInt(L"dz"); + + upX = oNodeU.ReadAttributeInt(L"dx"); + upY = oNodeU.ReadAttributeInt(L"dy"); + upZ = oNodeU.ReadAttributeInt(L"dz"); + } + std::wstring Backdrop::toXML() const + { + std::wstring str1 = L""; + + std::wstring str2 = L""; + + std::wstring str3 = L""; + + return _T("") + str1 + str2 + str3 + _T(""); + } + void Backdrop::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring sNodeNamespace; + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + sNodeNamespace = L"w14:"; + sAttrNamespace = sNodeNamespace; + } + else + sNodeNamespace = L"a:"; + + pWriter->StartNode(sNodeNamespace + L"backdrop"); + pWriter->EndAttributes(); + + pWriter->StartNode(sNodeNamespace + L"anchor"); + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + L"x", anchorX); + pWriter->WriteAttribute(sAttrNamespace + L"y", anchorY); + pWriter->WriteAttribute(sAttrNamespace + L"z", anchorZ); + pWriter->EndAttributes(); + pWriter->EndNode(sNodeNamespace + L"anchor"); + pWriter->StartNode(sNodeNamespace + L"norm"); + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + L"dx", normX); + pWriter->WriteAttribute(sAttrNamespace + L"dy", normY); + pWriter->WriteAttribute(sAttrNamespace + L"dz", normZ); + pWriter->EndAttributes(); + pWriter->EndNode(sNodeNamespace + L"norm"); + pWriter->StartNode(sNodeNamespace + L"up"); + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + L"dx", upX); + pWriter->WriteAttribute(sAttrNamespace + L"dy", upY); + pWriter->WriteAttribute(sAttrNamespace + L"dz", upZ); + pWriter->EndAttributes(); + pWriter->EndNode(sNodeNamespace + L"up"); + pWriter->EndNode(sNodeNamespace + L"backdrop"); + } + void Backdrop::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteInt1(0, anchorX); + pWriter->WriteInt1(1, anchorY); + pWriter->WriteInt1(2, anchorZ); + + pWriter->WriteInt1(3, normX); + pWriter->WriteInt1(4, normY); + pWriter->WriteInt1(5, normZ); + + pWriter->WriteInt1(6, upX); + pWriter->WriteInt1(7, upY); + pWriter->WriteInt1(8, upZ); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void Backdrop::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) anchorX = pReader->GetLong(); + else if (1 == _at) anchorY = pReader->GetLong(); + else if (2 == _at) anchorZ = pReader->GetLong(); + else if (3 == _at) normX = pReader->GetLong(); + else if (4 == _at) normY = pReader->GetLong(); + else if (5 == _at) normZ = pReader->GetLong(); + else if (6 == _at) upX = pReader->GetLong(); + else if (7 == _at) upY = pReader->GetLong(); + else if (8 == _at) upZ = pReader->GetLong(); + + else + break; + } + + pReader->Seek(_end_rec); + } + void Backdrop::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX + + + diff --git a/OOXML/PPTXFormat/Logic/Backdrop.h b/OOXML/PPTXFormat/Logic/Backdrop.h index d5adda0415..462a7d2f69 100644 --- a/OOXML/PPTXFormat/Logic/Backdrop.h +++ b/OOXML/PPTXFormat/Logic/Backdrop.h @@ -45,168 +45,18 @@ namespace PPTX WritingElement_AdditionConstructors(Backdrop) PPTX_LOGIC_BASE2(Backdrop) - virtual OOX::EElementType getType() const - { - return OOX::et_a_backdrop; - } - void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - if ( oReader.IsEmptyNode() ) - return; + virtual OOX::EElementType getType() const; + void fromXML(XmlUtils::CXmlLiteReader& oReader); - int nCurDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - std::wstring strName = oReader.GetName(); - nullable_int x, y, z; + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader, nullable_int & x, nullable_int & y, nullable_int & z ); - if (strName == L"a:anchor") - { - ReadAttributes(oReader, x, y, z); - anchorX = x.get_value_or(0); - anchorY = y.get_value_or(0); - anchorZ = z.get_value_or(0); - } - else if (strName == L"a:norm") - { - ReadAttributes(oReader, x, y, z); - normX = x.get_value_or(0); - normY = y.get_value_or(0); - normZ = z.get_value_or(0); - } - else if (strName == L"a:up") - { - ReadAttributes(oReader, x, y, z); - - upX = x.get_value_or(0); - upY = y.get_value_or(0); - upZ = z.get_value_or(0); - } - } - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader, nullable_int & x, nullable_int & y, nullable_int & z ) - { - WritingElement_ReadAttributes_Start_No_NS( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("z"), z) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("dx"), x) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("dy"), y) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("dz"), z) - WritingElement_ReadAttributes_End_No_NS( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlUtils::CXmlNode oNodeA = node.ReadNode(_T("a:anchor")); - XmlUtils::CXmlNode oNodeN = node.ReadNode(_T("a:norm")); - XmlUtils::CXmlNode oNodeU = node.ReadNode(_T("a:up")); - - anchorX = oNodeA.ReadAttributeInt(L"x"); - anchorY = oNodeA.ReadAttributeInt(L"y"); - anchorZ = oNodeA.ReadAttributeInt(L"z"); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - normX = oNodeN.ReadAttributeInt(L"dx"); - normY = oNodeN.ReadAttributeInt(L"dy"); - normZ = oNodeN.ReadAttributeInt(L"dz"); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - upX = oNodeU.ReadAttributeInt(L"dx"); - upY = oNodeU.ReadAttributeInt(L"dy"); - upZ = oNodeU.ReadAttributeInt(L"dz"); - } - virtual std::wstring toXML() const - { - std::wstring str1 = L""; - - std::wstring str2 = L""; - - std::wstring str3 = L""; - - return _T("") + str1 + str2 + str3 + _T(""); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring sNodeNamespace; - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - sNodeNamespace = L"w14:"; - sAttrNamespace = sNodeNamespace; - } - else - sNodeNamespace = L"a:"; - - pWriter->StartNode(sNodeNamespace + L"backdrop"); - pWriter->EndAttributes(); - - pWriter->StartNode(sNodeNamespace + L"anchor"); - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + L"x", anchorX); - pWriter->WriteAttribute(sAttrNamespace + L"y", anchorY); - pWriter->WriteAttribute(sAttrNamespace + L"z", anchorZ); - pWriter->EndAttributes(); - pWriter->EndNode(sNodeNamespace + L"anchor"); - pWriter->StartNode(sNodeNamespace + L"norm"); - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + L"dx", normX); - pWriter->WriteAttribute(sAttrNamespace + L"dy", normY); - pWriter->WriteAttribute(sAttrNamespace + L"dz", normZ); - pWriter->EndAttributes(); - pWriter->EndNode(sNodeNamespace + L"norm"); - pWriter->StartNode(sNodeNamespace + L"up"); - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + L"dx", upX); - pWriter->WriteAttribute(sAttrNamespace + L"dy", upY); - pWriter->WriteAttribute(sAttrNamespace + L"dz", upZ); - pWriter->EndAttributes(); - pWriter->EndNode(sNodeNamespace + L"up"); - pWriter->EndNode(sNodeNamespace + L"backdrop"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteInt1(0, anchorX); - pWriter->WriteInt1(1, anchorY); - pWriter->WriteInt1(2, anchorZ); - - pWriter->WriteInt1(3, normX); - pWriter->WriteInt1(4, normY); - pWriter->WriteInt1(5, normZ); - - pWriter->WriteInt1(6, upX); - pWriter->WriteInt1(7, upY); - pWriter->WriteInt1(8, upZ); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) anchorX = pReader->GetLong(); - else if (1 == _at) anchorY = pReader->GetLong(); - else if (2 == _at) anchorZ = pReader->GetLong(); - else if (3 == _at) normX = pReader->GetLong(); - else if (4 == _at) normY = pReader->GetLong(); - else if (5 == _at) normZ = pReader->GetLong(); - else if (6 == _at) upX = pReader->GetLong(); - else if (7 == _at) upY = pReader->GetLong(); - else if (8 == _at) upZ = pReader->GetLong(); - - else - break; - } - - pReader->Seek(_end_rec); - } int anchorX; int anchorY; int anchorZ; @@ -218,8 +68,9 @@ namespace PPTX int upX; int upY; int upZ; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Bevel.cpp b/OOXML/PPTXFormat/Logic/Bevel.cpp new file mode 100644 index 0000000000..8dfedf7d80 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Bevel.cpp @@ -0,0 +1,146 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Bevel.h" + +namespace PPTX +{ + namespace Logic + { + Bevel::Bevel(const std::wstring name) + { + m_name = name; + } + Bevel::~Bevel() {} + Bevel::Bevel(const Bevel& oSrc) { *this = oSrc; } + OOX::EElementType Bevel::getType() const + { + return OOX::et_a_bevel; + } + void Bevel::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_name = XmlUtils::GetNameNoNS(oReader.GetName()); + + ReadAttributes( oReader ); + } + void Bevel::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start_No_NS( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("w"), w) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("h"), h) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("prst"), prst) + WritingElement_ReadAttributes_End_No_NS( oReader ) + } + void Bevel::fromXML(XmlUtils::CXmlNode& node) + { + m_name = XmlUtils::GetNameNoNS(node.GetName()); + + XmlMacroReadAttributeBase(node, L"w", w); + XmlMacroReadAttributeBase(node, L"h", h); + XmlMacroReadAttributeBase(node, L"prst", prst); + } + std::wstring Bevel::toXML() const + { + std::wstring namespace_ = XmlUtils::GetNamespace(m_name); + if (namespace_ == L"w14") + { + namespace_ + L"w14:"; + } + else namespace_.clear(); + + XmlUtils::CAttribute oAttr; + oAttr.Write(namespace_ + L"w", w); + oAttr.Write(namespace_ + L"h", h); + oAttr.WriteLimitNullable(namespace_ + L"prst", prst); + + return XmlUtils::CreateNode(m_name, oAttr); + } + void Bevel::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring sNodeNamespace; + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + sNodeNamespace = _T("w14:"); + sAttrNamespace = sNodeNamespace; + } + else + sNodeNamespace = _T("a:"); + + + pWriter->StartNode(sNodeNamespace + m_name); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + L"w", w); + pWriter->WriteAttribute(sAttrNamespace + L"h", h); + if (prst.IsInit()) + { + pWriter->WriteAttribute(sAttrNamespace + L"prst", prst->get()); + } + pWriter->EndAttributes(); + + pWriter->EndNode(sNodeNamespace + m_name); + } + void Bevel::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteInt2(0, w); + pWriter->WriteInt2(1, h); + pWriter->WriteLimit2(2, prst); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void Bevel::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) w = pReader->GetLong(); + else if (1 == _at) h = pReader->GetLong(); + else if (2 == _at) prst = pReader->GetUChar(); + else + break; + } + + pReader->Seek(_end_rec); + } + void Bevel::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Bevel.h b/OOXML/PPTXFormat/Logic/Bevel.h index 3d25d53b3a..ab318fc072 100644 --- a/OOXML/PPTXFormat/Logic/Bevel.h +++ b/OOXML/PPTXFormat/Logic/Bevel.h @@ -40,127 +40,36 @@ namespace PPTX { namespace Logic { - class Bevel : public WrapperWritingElement { public: WritingElement_AdditionConstructors(Bevel) - - Bevel(const std::wstring name = L"a:bevel") - { - m_name = name; - } - virtual ~Bevel() {} - Bevel(const Bevel& oSrc) { *this = oSrc; } - virtual OOX::EElementType getType() const - { - return OOX::et_a_bevel; - } - void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = XmlUtils::GetNameNoNS(oReader.GetName()); + Bevel(const std::wstring name = L"a:bevel"); + virtual ~Bevel(); + Bevel(const Bevel& oSrc); - ReadAttributes( oReader ); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("w"), w) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("h"), h) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("prst"), prst) - WritingElement_ReadAttributes_End_No_NS( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = XmlUtils::GetNameNoNS(node.GetName()); - - XmlMacroReadAttributeBase(node, L"w", w); - XmlMacroReadAttributeBase(node, L"h", h); - XmlMacroReadAttributeBase(node, L"prst", prst); - } + virtual OOX::EElementType getType() const; - virtual std::wstring toXML() const - { - std::wstring namespace_ = XmlUtils::GetNamespace(m_name); - if (namespace_ == L"w14") - { - namespace_ + L"w14:"; - } - else namespace_.clear(); + void fromXML(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - XmlUtils::CAttribute oAttr; - oAttr.Write(namespace_ + L"w", w); - oAttr.Write(namespace_ + L"h", h); - oAttr.WriteLimitNullable(namespace_ + L"prst", prst); - - return XmlUtils::CreateNode(m_name, oAttr); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring sNodeNamespace; - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - sNodeNamespace = _T("w14:"); - sAttrNamespace = sNodeNamespace; - } - else - sNodeNamespace = _T("a:"); + virtual std::wstring toXML() const; - - pWriter->StartNode(sNodeNamespace + m_name); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + L"w", w); - pWriter->WriteAttribute(sAttrNamespace + L"h", h); - if (prst.IsInit()) - { - pWriter->WriteAttribute(sAttrNamespace + L"prst", prst->get()); - } - pWriter->EndAttributes(); - - pWriter->EndNode(sNodeNamespace + m_name); - } - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteInt2(0, w); - pWriter->WriteInt2(1, h); - pWriter->WriteLimit2(2, prst); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) w = pReader->GetLong(); - else if (1 == _at) h = pReader->GetLong(); - else if (2 == _at) prst = pReader->GetUChar(); - else - break; - } - - pReader->Seek(_end_rec); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); nullable_int w; nullable_int h; nullable_limit prst; std::wstring m_name; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX - #endif // PPTX_LOGIC_BEVEL_INCLUDE_H_ diff --git a/OOXML/PPTXFormat/Logic/Bg.cpp b/OOXML/PPTXFormat/Logic/Bg.cpp index 724c4ea654..70197b8830 100644 --- a/OOXML/PPTXFormat/Logic/Bg.cpp +++ b/OOXML/PPTXFormat/Logic/Bg.cpp @@ -40,30 +40,21 @@ namespace PPTX { namespace Logic { - Bg::Bg() { } - - Bg::~Bg() { } - - Bg::Bg(XmlUtils::CXmlNode& node) { fromXML(node); } - - const Bg& Bg::operator =(XmlUtils::CXmlNode& node) { fromXML(node); return *this; } - - void Bg::fromXML(XmlUtils::CXmlNode& node) { XmlMacroReadAttributeBase(node, L"bwMode", bwMode); @@ -72,8 +63,6 @@ namespace PPTX FillParentPointersForChilds(); } - - std::wstring Bg::toXML() const { XmlUtils::CAttribute oAttr; @@ -85,7 +74,6 @@ namespace PPTX return XmlUtils::CreateNode(_T("p:bg"), oAttr, oValue); } - void Bg::FillParentPointersForChilds() { //if(background != 0) @@ -95,7 +83,6 @@ namespace PPTX if(bgRef.IsInit()) bgRef->SetParentPointer(this); } - void Bg::GetBackground(Logic::BgPr& bg, DWORD& ARGB)const { if(bgPr.IsInit()) @@ -111,6 +98,72 @@ namespace PPTX parentFileAs().theme->themeElements.fmtScheme.GetFillStyle(bgRef->idx.get_value_or(0), bg.Fill); } } + void Bg::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("p:bg")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("bwMode"), bwMode); + pWriter->EndAttributes(); + + pWriter->Write(bgPr); + pWriter->Write(bgRef); + + pWriter->EndNode(_T("p:bg")); + } + void Bg::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit2(0, bwMode); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, bgPr); + pWriter->WriteRecord2(1, bgRef); + } + void Bg::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) + { + bwMode = pReader->GetUChar(); + } + else + break; + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + bgPr = new BgPr(); + bgPr->fromPPTY(pReader); + break; + } + case 1: + { + bgRef = new StyleRef(); + bgRef->m_name = _T("p:bgRef"); + bgRef->fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Bg.h b/OOXML/PPTXFormat/Logic/Bg.h index cca3668ac1..f480bfbc28 100644 --- a/OOXML/PPTXFormat/Logic/Bg.h +++ b/OOXML/PPTXFormat/Logic/Bg.h @@ -40,7 +40,6 @@ namespace PPTX { namespace Logic { - class Bg : public WrapperWritingElement { public: @@ -53,82 +52,17 @@ namespace PPTX virtual void fromXML(XmlUtils::CXmlNode& node); virtual std::wstring toXML() const; - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("p:bg")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("bwMode"), bwMode); - pWriter->EndAttributes(); - - pWriter->Write(bgPr); - pWriter->Write(bgRef); - - pWriter->EndNode(_T("p:bg")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit2(0, bwMode); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, bgPr); - pWriter->WriteRecord2(1, bgRef); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) - { - bwMode = pReader->GetUChar(); - } - else - break; - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - bgPr = new BgPr(); - bgPr->fromPPTY(pReader); - break; - } - case 1: - { - bgRef = new StyleRef(); - bgRef->m_name = _T("p:bgRef"); - bgRef->fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: nullable_limit bwMode; nullable bgPr; nullable bgRef; - virtual void GetBackground(Logic::BgPr& bg, DWORD& ARGB)const; + virtual void GetBackground(Logic::BgPr& bg, DWORD& ARGB) const; + protected: virtual void FillParentPointersForChilds(); }; diff --git a/OOXML/PPTXFormat/Logic/BgPr.cpp b/OOXML/PPTXFormat/Logic/BgPr.cpp new file mode 100644 index 0000000000..a1e7081c66 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/BgPr.cpp @@ -0,0 +1,126 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "BgPr.h" + +namespace PPTX +{ + namespace Logic + { + void BgPr::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"shadeToTitle", shadeToTitle); + Fill.GetFillFrom(node); + EffectList.GetEffectListFrom(node); + + FillParentPointersForChilds(); + } + std::wstring BgPr::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("shadeToTitle"), shadeToTitle); + + XmlUtils::CNodeValue oValue; + oValue.Write(Fill); + oValue.Write(EffectList); + + return XmlUtils::CreateNode(_T("p:bgPr"), oAttr, oValue); + } + void BgPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("p:bgPr")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("shadeToTitle"), shadeToTitle); + pWriter->EndAttributes(); + + Fill.toXmlWriter(pWriter); + EffectList.toXmlWriter(pWriter); + + pWriter->EndNode(_T("p:bgPr")); + } + void BgPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteBool2(0, shadeToTitle); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord1(0, Fill); + pWriter->WriteRecord1(1, EffectList); + } + void BgPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) + shadeToTitle = pReader->GetBool(); + else + break; + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + Fill.fromPPTY(pReader); + break; + } + case 1: + { + EffectList.fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void BgPr::FillParentPointersForChilds() + { + Fill.SetParentPointer(this); + EffectList.SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/BgPr.h b/OOXML/PPTXFormat/Logic/BgPr.h index 415812db53..5e8431d2ee 100644 --- a/OOXML/PPTXFormat/Logic/BgPr.h +++ b/OOXML/PPTXFormat/Logic/BgPr.h @@ -42,109 +42,26 @@ namespace PPTX { namespace Logic { - class BgPr : public WrapperWritingElement { public: PPTX_LOGIC_BASE(BgPr) public: - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"shadeToTitle", shadeToTitle); - Fill.GetFillFrom(node); - EffectList.GetEffectListFrom(node); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - FillParentPointersForChilds(); - } - - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("shadeToTitle"), shadeToTitle); - - XmlUtils::CNodeValue oValue; - oValue.Write(Fill); - oValue.Write(EffectList); - - return XmlUtils::CreateNode(_T("p:bgPr"), oAttr, oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("p:bgPr")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("shadeToTitle"), shadeToTitle); - pWriter->EndAttributes(); - - Fill.toXmlWriter(pWriter); - EffectList.toXmlWriter(pWriter); - - pWriter->EndNode(_T("p:bgPr")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteBool2(0, shadeToTitle); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord1(0, Fill); - pWriter->WriteRecord1(1, EffectList); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) - shadeToTitle = pReader->GetBool(); - else - break; - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - Fill.fromPPTY(pReader); - break; - } - case 1: - { - EffectList.fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: UniFill Fill; - EffectProperties EffectList; - + EffectProperties EffectList; nullable_bool shadeToTitle; + protected: - virtual void FillParentPointersForChilds() - { - Fill.SetParentPointer(this); - EffectList.SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/BodyPr.cpp b/OOXML/PPTXFormat/Logic/BodyPr.cpp new file mode 100644 index 0000000000..9c0fba285a --- /dev/null +++ b/OOXML/PPTXFormat/Logic/BodyPr.cpp @@ -0,0 +1,581 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "BodyPr.h" + +namespace PPTX +{ + namespace Logic + { + BodyPr::BodyPr(std::wstring ns) + { + m_namespace = ns; + } + void BodyPr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + std::wstring strName = oReader.GetName(); + + if (L"a:prstTxWarp" == strName) + prstTxWarp = oReader; + else if (L"a:scene3d" == strName) + scene3d = oReader; + else if (L"a:sp3d" == strName) + sp3d = oReader; + else if (strName == L"a:noAutofit" || strName == L"a:spAutoFit" || strName == L"a:normAutofit") + Fit.fromXML(oReader); + else if (L"a:flatTx" == strName) + { + //oNode.ReadAttributeBase(L"z", flatTx); + } + + } + FillParentPointersForChilds(); + } + void BodyPr::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start ( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("anchor"), anchor ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("anchorCtr"), anchorCtr ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("bIns"), bIns ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("compatLnSpc"), compatLnSpc ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("forceAA"), forceAA ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("fromWordArt"), fromWordArt ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("horzOverflow"), horzOverflow ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("lIns"), lIns ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("numCol"), numCol ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("rIns"), rIns ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("rot"), rot ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("rtlCol"), rtlCol ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("spcCol"), spcCol ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("spcFirstLastPara"), spcFirstLastPara ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("tIns"), tIns ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("upright"), upright ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("vert"), vert ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("vertOverflow"), vertOverflow ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("wrap"), wrap ) + WritingElement_ReadAttributes_End ( oReader ) + + Normalize(); + } + void BodyPr::fromXML(XmlUtils::CXmlNode& node) + { + m_namespace = XmlUtils::GetNamespace(node.GetName()); + + XmlMacroReadAttributeBase(node, L"anchor", anchor); + XmlMacroReadAttributeBase(node, L"anchorCtr", anchorCtr); + XmlMacroReadAttributeBase(node, L"bIns", bIns); + XmlMacroReadAttributeBase(node, L"compatLnSpc", compatLnSpc); + XmlMacroReadAttributeBase(node, L"forceAA", forceAA); + XmlMacroReadAttributeBase(node, L"fromWordArt", fromWordArt); + XmlMacroReadAttributeBase(node, L"horzOverflow", horzOverflow); + XmlMacroReadAttributeBase(node, L"lIns", lIns); + XmlMacroReadAttributeBase(node, L"numCol", numCol); + XmlMacroReadAttributeBase(node, L"rIns", rIns); + XmlMacroReadAttributeBase(node, L"rot", rot); + XmlMacroReadAttributeBase(node, L"rtlCol", rtlCol); + XmlMacroReadAttributeBase(node, L"spcCol", spcCol); + XmlMacroReadAttributeBase(node, L"spcFirstLastPara", spcFirstLastPara); + XmlMacroReadAttributeBase(node, L"tIns", tIns); + XmlMacroReadAttributeBase(node, L"upright", upright); + XmlMacroReadAttributeBase(node, L"vert", vert); + XmlMacroReadAttributeBase(node, L"vertOverflow", vertOverflow); + XmlMacroReadAttributeBase(node, L"wrap", wrap); + + Fit.GetTextFitFrom(node); + prstTxWarp = node.ReadNode(_T("a:prstTxWarp")); + scene3d = node.ReadNode(_T("a:scene3d")); + + XmlUtils::CXmlNode oNode = node.ReadNodeNoNS(_T("flatTx")); + XmlMacroReadAttributeBase(oNode, L"z", flatTx); + + sp3d = node.ReadNode(_T("a:sp3d")); + + Normalize(); + FillParentPointersForChilds(); + } + std::wstring BodyPr::toXML() const + { + if (m_namespace.empty()) m_namespace = L"a"; + + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("rot"), rot); + oAttr.Write(_T("spcFirstLastPara"), spcFirstLastPara); + oAttr.WriteLimitNullable(_T("vertOverflow"), vertOverflow); + oAttr.WriteLimitNullable(_T("horzOverflow"), horzOverflow); + oAttr.WriteLimitNullable(_T("vert"), vert); + oAttr.WriteLimitNullable(_T("wrap"), wrap); + oAttr.Write(_T("lIns"), lIns); + oAttr.Write(_T("tIns"), tIns); + oAttr.Write(_T("rIns"), rIns); + oAttr.Write(_T("bIns"), bIns); + oAttr.Write(_T("numCol"), numCol); + oAttr.Write(_T("spcCol"), spcCol); + oAttr.Write(_T("rtlCol"), rtlCol); + oAttr.Write(_T("fromWordArt"), fromWordArt); + oAttr.WriteLimitNullable(_T("anchor"), anchor); + oAttr.Write(_T("anchorCtr"), anchorCtr); + oAttr.Write(_T("forceAA"), forceAA); + oAttr.Write(_T("upright"), upright); + oAttr.Write(_T("compatLnSpc"), compatLnSpc); + + XmlUtils::CNodeValue oValue; + oValue.WriteNullable(prstTxWarp); + oValue.Write(Fit); + oValue.WriteNullable(scene3d); + oValue.WriteNullable(sp3d); + if (flatTx.IsInit()) + { + XmlUtils::CAttribute oAttr2; + oAttr2.Write(_T("z"), flatTx); + + oValue.m_strValue += XmlUtils::CreateNode(m_namespace + _T(":flatTx"), oAttr2); + } + + return XmlUtils::CreateNode(m_namespace + _T(":bodyPr"), oAttr, oValue); + } + void BodyPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + if (m_namespace.empty()) m_namespace = L"a"; + + pWriter->StartNode(m_namespace + _T(":bodyPr")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("rot"), rot); + pWriter->WriteAttribute(_T("spcFirstLastPara"), spcFirstLastPara); + pWriter->WriteAttribute(_T("vertOverflow"), vertOverflow); + pWriter->WriteAttribute(_T("horzOverflow"), horzOverflow); + pWriter->WriteAttribute(_T("vert"), vert); + pWriter->WriteAttribute(_T("wrap"), wrap); + pWriter->WriteAttribute(_T("lIns"), lIns); + pWriter->WriteAttribute(_T("tIns"), tIns); + pWriter->WriteAttribute(_T("rIns"), rIns); + pWriter->WriteAttribute(_T("bIns"), bIns); + pWriter->WriteAttribute(_T("numCol"), numCol); + pWriter->WriteAttribute(_T("spcCol"), spcCol); + pWriter->WriteAttribute(_T("rtlCol"), rtlCol); + pWriter->WriteAttribute(_T("fromWordArt"), fromWordArt); + pWriter->WriteAttribute(_T("anchor"), anchor); + pWriter->WriteAttribute(_T("anchorCtr"), anchorCtr); + pWriter->WriteAttribute(_T("forceAA"), forceAA); + pWriter->WriteAttribute(_T("upright"), upright); + pWriter->WriteAttribute(_T("compatLnSpc"), compatLnSpc); + pWriter->EndAttributes(); + + pWriter->Write(prstTxWarp); + Fit.toXmlWriter(pWriter); + pWriter->Write(scene3d); + pWriter->Write(sp3d); + if (flatTx.IsInit()) + { + pWriter->StartNode(m_namespace + _T(":flatTx")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("z"), flatTx); + pWriter->EndAttributes(); + pWriter->EndNode(m_namespace + _T(":flatTx")); + } + + pWriter->EndNode(m_namespace + _T(":bodyPr")); + } + void BodyPr::Merge(nullable& bodyPr)const + { + if (!bodyPr.IsInit()) + { + bodyPr = new PPTX::Logic::BodyPr(); + } + + if(Fit.type != TextFit::FitEmpty) + Fit.Merge(bodyPr->Fit); + /* + nullable_property prstTxWarp; + nullable_property scene3d; + nullable_property flatTx; + nullable_property sp3d; + */ + if(anchor.IsInit()) + bodyPr->anchor = *anchor; + if(anchorCtr.IsInit()) + bodyPr->anchorCtr = *anchorCtr; + if(bIns.IsInit()) + bodyPr->bIns = *bIns; + if(compatLnSpc.IsInit()) + bodyPr->compatLnSpc = *compatLnSpc; + if(forceAA.IsInit()) + bodyPr->forceAA = *forceAA; + if(fromWordArt.IsInit()) + bodyPr->fromWordArt = *fromWordArt; + if(horzOverflow.IsInit()) + bodyPr->horzOverflow = *horzOverflow; + if(lIns.IsInit()) + bodyPr->lIns = *lIns; + if(numCol.IsInit()) + bodyPr->numCol = *numCol; + if(rIns.IsInit()) + bodyPr->rIns = *rIns; + if(rot.IsInit()) + bodyPr->rot = *rot; + if(rtlCol.IsInit()) + bodyPr->rtlCol = *rtlCol; + if(spcCol.IsInit()) + bodyPr->spcCol = *spcCol; + if(spcFirstLastPara.IsInit()) + bodyPr->spcFirstLastPara = *spcFirstLastPara; + if(tIns.IsInit()) + bodyPr->tIns = *tIns; + if(upright.IsInit()) + bodyPr->upright = *upright; + if(vert.IsInit()) + bodyPr->vert = *vert; + if(vertOverflow.IsInit()) + bodyPr->vertOverflow = *vertOverflow; + if(wrap.IsInit()) + bodyPr->wrap = *wrap; + } + void BodyPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteInt2(0, flatTx); + pWriter->WriteLimit2(1, anchor); + pWriter->WriteBool2(2, anchorCtr); + pWriter->WriteInt2(3, bIns); + pWriter->WriteBool2(4, compatLnSpc); + pWriter->WriteBool2(5, forceAA); + pWriter->WriteBool2(6, fromWordArt); + pWriter->WriteLimit2(7, horzOverflow); + pWriter->WriteInt2(8, lIns); + pWriter->WriteInt2(9, numCol); + pWriter->WriteInt2(10, rIns); + pWriter->WriteInt2(11, rot); + pWriter->WriteBool2(12, rtlCol); + pWriter->WriteInt2(13, spcCol); + pWriter->WriteBool2(14, spcFirstLastPara); + pWriter->WriteInt2(15, tIns); + pWriter->WriteBool2(16, upright); + pWriter->WriteLimit2(17, vert); + pWriter->WriteLimit2(18, vertOverflow); + pWriter->WriteLimit2(19, wrap); + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, prstTxWarp); + pWriter->WriteRecord1(1, Fit); + pWriter->WriteRecord2(2, scene3d); + pWriter->WriteRecord2(3, sp3d); + } + void BodyPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + pReader->Skip(1); // start attributes + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + flatTx = pReader->GetLong(); + break; + } + case 1: + { + anchor = pReader->GetUChar(); + break; + } + case 2: + { + anchorCtr = pReader->GetBool(); + break; + } + case 3: + { + bIns = pReader->GetLong(); + break; + } + case 4: + { + compatLnSpc = pReader->GetBool(); + break; + } + case 5: + { + forceAA = pReader->GetBool(); + break; + } + case 6: + { + fromWordArt = pReader->GetBool(); + break; + } + case 7: + { + horzOverflow = pReader->GetUChar(); + break; + } + case 8: + { + lIns = pReader->GetLong(); + break; + } + case 9: + { + numCol = pReader->GetLong(); + break; + } + case 10: + { + rIns = pReader->GetLong(); + break; + } + case 11: + { + rot = pReader->GetLong(); + break; + } + case 12: + { + rtlCol = pReader->GetBool(); + break; + } + case 13: + { + spcCol = pReader->GetLong(); + break; + } + case 14: + { + spcFirstLastPara = pReader->GetBool(); + break; + } + case 15: + { + tIns = pReader->GetLong(); + break; + } + case 16: + { + upright = pReader->GetBool(); + break; + } + case 17: + { + vert = pReader->GetUChar(); + break; + } + case 18: + { + vertOverflow = pReader->GetUChar(); + break; + } + case 19: + { + wrap = pReader->GetUChar(); + break; + } + default: + break; + } + } + + while (pReader->GetPos() < _end_rec) + { + BYTE rec = pReader->GetUChar(); + + switch (rec) + { + case 0: + { + prstTxWarp = new PPTX::Logic::PrstTxWarp(); + prstTxWarp->fromPPTY(pReader); + break; + } + case 1: + { + Fit.fromPPTY(pReader); + break; + } + case 2: + { + scene3d = new PPTX::Logic::Scene3d(); + scene3d->fromPPTY(pReader); + break; + } + case 3: + { + sp3d = new PPTX::Logic::Sp3d(); + sp3d->fromPPTY(pReader); + break; + } + default: + { + // пока никаких настроек градиента нет + pReader->SkipRecord(); + } + } + } + pReader->Seek(_end_rec); + } + void BodyPr::FillParentPointersForChilds() + { + if(prstTxWarp.IsInit()) + prstTxWarp->SetParentPointer(this); + Fit.SetParentPointer(this); + if(scene3d.IsInit()) + scene3d->SetParentPointer(this); + } + + LinkedTxbx::LinkedTxbx(std::wstring ns) + { + m_namespace = ns; + } + void LinkedTxbx::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + ReadAttributes(oReader); + + if (oReader.IsEmptyNode()) + return; + + int nCurDepth = oReader.GetDepth(); + while (oReader.ReadNextSiblingNode(nCurDepth)) + { + std::wstring strName = oReader.GetName(); + + if (L"a:extLst" == strName) + { + if (oReader.IsEmptyNode()) + continue; + + int nParentDepth1 = oReader.GetDepth(); + while (oReader.ReadNextSiblingNode(nParentDepth1)) + { + Ext element; + element.fromXML(oReader); + extLst.push_back(element); + } + } + } + FillParentPointersForChilds(); + } + void LinkedTxbx::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start(oReader) + WritingElement_ReadAttributes_Read_if(oReader, L"id", id) + WritingElement_ReadAttributes_Read_else_if(oReader, L"seq", seq) + WritingElement_ReadAttributes_End(oReader) + Normalize(); + } + void LinkedTxbx::fromXML(XmlUtils::CXmlNode& node) + { + m_namespace = XmlUtils::GetNamespace(node.GetName()); + + XmlMacroReadAttributeBase(node, L"id", id); + XmlMacroReadAttributeBase(node, L"seq", seq); + + Normalize(); + FillParentPointersForChilds(); + } + std::wstring LinkedTxbx::toXML() const + { + if (m_namespace.empty()) m_namespace = L"a"; + + XmlUtils::CAttribute oAttr; + oAttr.Write(L"id", id); + oAttr.Write(L"seq", seq); + return XmlUtils::CreateNode(m_namespace + L":linkedTxbx", oAttr); + } + void LinkedTxbx::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + if (m_namespace.empty()) m_namespace = L"a"; + + pWriter->StartNode(m_namespace + L":linkedTxbx"); + + pWriter->StartAttributes(); + pWriter->WriteAttribute2(L"id", id); + pWriter->WriteAttribute2(L"seq", seq); + pWriter->EndAttributes(); + + pWriter->EndNode(m_namespace + L":linkedTxbx"); + } + void LinkedTxbx::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteUInt2(0, id); + pWriter->WriteUInt2(1, seq); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void LinkedTxbx::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + pReader->Skip(1); // start attributes + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + id = pReader->GetULong(); + break; + } + case 1: + { + seq = pReader->GetULong(); + break; + } + default: + break; + } + } + pReader->Seek(_end_rec); + } + void LinkedTxbx::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX + diff --git a/OOXML/PPTXFormat/Logic/BodyPr.h b/OOXML/PPTXFormat/Logic/BodyPr.h index 587e9f8012..99271126c5 100644 --- a/OOXML/PPTXFormat/Logic/BodyPr.h +++ b/OOXML/PPTXFormat/Logic/BodyPr.h @@ -52,432 +52,21 @@ namespace PPTX public: WritingElement_AdditionConstructors(BodyPr) - BodyPr(std::wstring ns = L"a") - { - m_namespace = ns; - } + BodyPr(std::wstring ns = L"a"); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - ReadAttributes( oReader ); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - if ( oReader.IsEmptyNode() ) - return; + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - int nCurDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - std::wstring strName = oReader.GetName(); - - if (L"a:prstTxWarp" == strName) - prstTxWarp = oReader; - else if (L"a:scene3d" == strName) - scene3d = oReader; - else if (L"a:sp3d" == strName) - sp3d = oReader; - else if (strName == L"a:noAutofit" || strName == L"a:spAutoFit" || strName == L"a:normAutofit") - Fit.fromXML(oReader); - else if (L"a:flatTx" == strName) - { - //oNode.ReadAttributeBase(L"z", flatTx); - } - - } - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start ( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("anchor"), anchor ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("anchorCtr"), anchorCtr ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("bIns"), bIns ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("compatLnSpc"), compatLnSpc ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("forceAA"), forceAA ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("fromWordArt"), fromWordArt ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("horzOverflow"), horzOverflow ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("lIns"), lIns ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("numCol"), numCol ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("rIns"), rIns ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("rot"), rot ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("rtlCol"), rtlCol ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("spcCol"), spcCol ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("spcFirstLastPara"), spcFirstLastPara ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("tIns"), tIns ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("upright"), upright ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("vert"), vert ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("vertOverflow"), vertOverflow ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("wrap"), wrap ) - WritingElement_ReadAttributes_End ( oReader ) + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - Normalize(); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_namespace = XmlUtils::GetNamespace(node.GetName()); - - XmlMacroReadAttributeBase(node, L"anchor", anchor); - XmlMacroReadAttributeBase(node, L"anchorCtr", anchorCtr); - XmlMacroReadAttributeBase(node, L"bIns", bIns); - XmlMacroReadAttributeBase(node, L"compatLnSpc", compatLnSpc); - XmlMacroReadAttributeBase(node, L"forceAA", forceAA); - XmlMacroReadAttributeBase(node, L"fromWordArt", fromWordArt); - XmlMacroReadAttributeBase(node, L"horzOverflow", horzOverflow); - XmlMacroReadAttributeBase(node, L"lIns", lIns); - XmlMacroReadAttributeBase(node, L"numCol", numCol); - XmlMacroReadAttributeBase(node, L"rIns", rIns); - XmlMacroReadAttributeBase(node, L"rot", rot); - XmlMacroReadAttributeBase(node, L"rtlCol", rtlCol); - XmlMacroReadAttributeBase(node, L"spcCol", spcCol); - XmlMacroReadAttributeBase(node, L"spcFirstLastPara", spcFirstLastPara); - XmlMacroReadAttributeBase(node, L"tIns", tIns); - XmlMacroReadAttributeBase(node, L"upright", upright); - XmlMacroReadAttributeBase(node, L"vert", vert); - XmlMacroReadAttributeBase(node, L"vertOverflow", vertOverflow); - XmlMacroReadAttributeBase(node, L"wrap", wrap); - - Fit.GetTextFitFrom(node); - prstTxWarp = node.ReadNode(_T("a:prstTxWarp")); - scene3d = node.ReadNode(_T("a:scene3d")); - - XmlUtils::CXmlNode oNode = node.ReadNodeNoNS(_T("flatTx")); - XmlMacroReadAttributeBase(oNode, L"z", flatTx); - - sp3d = node.ReadNode(_T("a:sp3d")); - - Normalize(); - FillParentPointersForChilds(); - } - - virtual std::wstring toXML() const - { - if (m_namespace.empty()) m_namespace = L"a"; - - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("rot"), rot); - oAttr.Write(_T("spcFirstLastPara"), spcFirstLastPara); - oAttr.WriteLimitNullable(_T("vertOverflow"), vertOverflow); - oAttr.WriteLimitNullable(_T("horzOverflow"), horzOverflow); - oAttr.WriteLimitNullable(_T("vert"), vert); - oAttr.WriteLimitNullable(_T("wrap"), wrap); - oAttr.Write(_T("lIns"), lIns); - oAttr.Write(_T("tIns"), tIns); - oAttr.Write(_T("rIns"), rIns); - oAttr.Write(_T("bIns"), bIns); - oAttr.Write(_T("numCol"), numCol); - oAttr.Write(_T("spcCol"), spcCol); - oAttr.Write(_T("rtlCol"), rtlCol); - oAttr.Write(_T("fromWordArt"), fromWordArt); - oAttr.WriteLimitNullable(_T("anchor"), anchor); - oAttr.Write(_T("anchorCtr"), anchorCtr); - oAttr.Write(_T("forceAA"), forceAA); - oAttr.Write(_T("upright"), upright); - oAttr.Write(_T("compatLnSpc"), compatLnSpc); - - XmlUtils::CNodeValue oValue; - oValue.WriteNullable(prstTxWarp); - oValue.Write(Fit); - oValue.WriteNullable(scene3d); - oValue.WriteNullable(sp3d); - if (flatTx.IsInit()) - { - XmlUtils::CAttribute oAttr2; - oAttr2.Write(_T("z"), flatTx); - - oValue.m_strValue += XmlUtils::CreateNode(m_namespace + _T(":flatTx"), oAttr2); - } - - return XmlUtils::CreateNode(m_namespace + _T(":bodyPr"), oAttr, oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - if (m_namespace.empty()) m_namespace = L"a"; - - pWriter->StartNode(m_namespace + _T(":bodyPr")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("rot"), rot); - pWriter->WriteAttribute(_T("spcFirstLastPara"), spcFirstLastPara); - pWriter->WriteAttribute(_T("vertOverflow"), vertOverflow); - pWriter->WriteAttribute(_T("horzOverflow"), horzOverflow); - pWriter->WriteAttribute(_T("vert"), vert); - pWriter->WriteAttribute(_T("wrap"), wrap); - pWriter->WriteAttribute(_T("lIns"), lIns); - pWriter->WriteAttribute(_T("tIns"), tIns); - pWriter->WriteAttribute(_T("rIns"), rIns); - pWriter->WriteAttribute(_T("bIns"), bIns); - pWriter->WriteAttribute(_T("numCol"), numCol); - pWriter->WriteAttribute(_T("spcCol"), spcCol); - pWriter->WriteAttribute(_T("rtlCol"), rtlCol); - pWriter->WriteAttribute(_T("fromWordArt"), fromWordArt); - pWriter->WriteAttribute(_T("anchor"), anchor); - pWriter->WriteAttribute(_T("anchorCtr"), anchorCtr); - pWriter->WriteAttribute(_T("forceAA"), forceAA); - pWriter->WriteAttribute(_T("upright"), upright); - pWriter->WriteAttribute(_T("compatLnSpc"), compatLnSpc); - pWriter->EndAttributes(); - - pWriter->Write(prstTxWarp); - Fit.toXmlWriter(pWriter); - pWriter->Write(scene3d); - pWriter->Write(sp3d); - if (flatTx.IsInit()) - { - pWriter->StartNode(m_namespace + _T(":flatTx")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("z"), flatTx); - pWriter->EndAttributes(); - pWriter->EndNode(m_namespace + _T(":flatTx")); - } - - pWriter->EndNode(m_namespace + _T(":bodyPr")); - } - - - void Merge(nullable& bodyPr)const - { - if (!bodyPr.IsInit()) - { - bodyPr = new PPTX::Logic::BodyPr(); - } - - if(Fit.type != TextFit::FitEmpty) - Fit.Merge(bodyPr->Fit); - /* - nullable_property prstTxWarp; - nullable_property scene3d; - nullable_property flatTx; - nullable_property sp3d; - */ - if(anchor.IsInit()) - bodyPr->anchor = *anchor; - if(anchorCtr.IsInit()) - bodyPr->anchorCtr = *anchorCtr; - if(bIns.IsInit()) - bodyPr->bIns = *bIns; - if(compatLnSpc.IsInit()) - bodyPr->compatLnSpc = *compatLnSpc; - if(forceAA.IsInit()) - bodyPr->forceAA = *forceAA; - if(fromWordArt.IsInit()) - bodyPr->fromWordArt = *fromWordArt; - if(horzOverflow.IsInit()) - bodyPr->horzOverflow = *horzOverflow; - if(lIns.IsInit()) - bodyPr->lIns = *lIns; - if(numCol.IsInit()) - bodyPr->numCol = *numCol; - if(rIns.IsInit()) - bodyPr->rIns = *rIns; - if(rot.IsInit()) - bodyPr->rot = *rot; - if(rtlCol.IsInit()) - bodyPr->rtlCol = *rtlCol; - if(spcCol.IsInit()) - bodyPr->spcCol = *spcCol; - if(spcFirstLastPara.IsInit()) - bodyPr->spcFirstLastPara = *spcFirstLastPara; - if(tIns.IsInit()) - bodyPr->tIns = *tIns; - if(upright.IsInit()) - bodyPr->upright = *upright; - if(vert.IsInit()) - bodyPr->vert = *vert; - if(vertOverflow.IsInit()) - bodyPr->vertOverflow = *vertOverflow; - if(wrap.IsInit()) - bodyPr->wrap = *wrap; - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteInt2(0, flatTx); - pWriter->WriteLimit2(1, anchor); - pWriter->WriteBool2(2, anchorCtr); - pWriter->WriteInt2(3, bIns); - pWriter->WriteBool2(4, compatLnSpc); - pWriter->WriteBool2(5, forceAA); - pWriter->WriteBool2(6, fromWordArt); - pWriter->WriteLimit2(7, horzOverflow); - pWriter->WriteInt2(8, lIns); - pWriter->WriteInt2(9, numCol); - pWriter->WriteInt2(10, rIns); - pWriter->WriteInt2(11, rot); - pWriter->WriteBool2(12, rtlCol); - pWriter->WriteInt2(13, spcCol); - pWriter->WriteBool2(14, spcFirstLastPara); - pWriter->WriteInt2(15, tIns); - pWriter->WriteBool2(16, upright); - pWriter->WriteLimit2(17, vert); - pWriter->WriteLimit2(18, vertOverflow); - pWriter->WriteLimit2(19, wrap); - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, prstTxWarp); - pWriter->WriteRecord1(1, Fit); - pWriter->WriteRecord2(2, scene3d); - pWriter->WriteRecord2(3, sp3d); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - pReader->Skip(1); // start attributes - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - flatTx = pReader->GetLong(); - break; - } - case 1: - { - anchor = pReader->GetUChar(); - break; - } - case 2: - { - anchorCtr = pReader->GetBool(); - break; - } - case 3: - { - bIns = pReader->GetLong(); - break; - } - case 4: - { - compatLnSpc = pReader->GetBool(); - break; - } - case 5: - { - forceAA = pReader->GetBool(); - break; - } - case 6: - { - fromWordArt = pReader->GetBool(); - break; - } - case 7: - { - horzOverflow = pReader->GetUChar(); - break; - } - case 8: - { - lIns = pReader->GetLong(); - break; - } - case 9: - { - numCol = pReader->GetLong(); - break; - } - case 10: - { - rIns = pReader->GetLong(); - break; - } - case 11: - { - rot = pReader->GetLong(); - break; - } - case 12: - { - rtlCol = pReader->GetBool(); - break; - } - case 13: - { - spcCol = pReader->GetLong(); - break; - } - case 14: - { - spcFirstLastPara = pReader->GetBool(); - break; - } - case 15: - { - tIns = pReader->GetLong(); - break; - } - case 16: - { - upright = pReader->GetBool(); - break; - } - case 17: - { - vert = pReader->GetUChar(); - break; - } - case 18: - { - vertOverflow = pReader->GetUChar(); - break; - } - case 19: - { - wrap = pReader->GetUChar(); - break; - } - default: - break; - } - } - - while (pReader->GetPos() < _end_rec) - { - BYTE rec = pReader->GetUChar(); - - switch (rec) - { - case 0: - { - prstTxWarp = new PPTX::Logic::PrstTxWarp(); - prstTxWarp->fromPPTY(pReader); - break; - } - case 1: - { - Fit.fromPPTY(pReader); - break; - } - case 2: - { - scene3d = new PPTX::Logic::Scene3d(); - scene3d->fromPPTY(pReader); - break; - } - case 3: - { - sp3d = new PPTX::Logic::Sp3d(); - sp3d->fromPPTY(pReader); - break; - } - default: - { - // пока никаких настроек градиента нет - pReader->SkipRecord(); - } - } - } - pReader->Seek(_end_rec); - } + void Merge(nullable& bodyPr) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); nullable prstTxWarp; TextFit Fit; @@ -506,15 +95,9 @@ namespace PPTX nullable_limit wrap; mutable std::wstring m_namespace; + protected: - virtual void FillParentPointersForChilds() - { - if(prstTxWarp.IsInit()) - prstTxWarp->SetParentPointer(this); - Fit.SetParentPointer(this); - if(scene3d.IsInit()) - scene3d->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); AVSINLINE void Normalize() { @@ -528,129 +111,30 @@ namespace PPTX public: WritingElement_AdditionConstructors(LinkedTxbx) - LinkedTxbx(std::wstring ns = L"a") - { - m_namespace = ns; - } + LinkedTxbx(std::wstring ns = L"a"); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - ReadAttributes(oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - if (oReader.IsEmptyNode()) - return; + virtual void fromXML(XmlUtils::CXmlNode& node); - int nCurDepth = oReader.GetDepth(); - while (oReader.ReadNextSiblingNode(nCurDepth)) - { - std::wstring strName = oReader.GetName(); + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - if (L"a:extLst" == strName) - { - if (oReader.IsEmptyNode()) - continue; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - int nParentDepth1 = oReader.GetDepth(); - while (oReader.ReadNextSiblingNode(nParentDepth1)) - { - Ext element; - element.fromXML(oReader); - extLst.push_back(element); - } - } - } - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start(oReader) - WritingElement_ReadAttributes_Read_if(oReader, L"id", id) - WritingElement_ReadAttributes_Read_else_if(oReader, L"seq", seq) - WritingElement_ReadAttributes_End(oReader) - Normalize(); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_namespace = XmlUtils::GetNamespace(node.GetName()); - - XmlMacroReadAttributeBase(node, L"id", id); - XmlMacroReadAttributeBase(node, L"seq", seq); - - Normalize(); - FillParentPointersForChilds(); - } - - virtual std::wstring toXML() const - { - if (m_namespace.empty()) m_namespace = L"a"; - - XmlUtils::CAttribute oAttr; - oAttr.Write(L"id", id); - oAttr.Write(L"seq", seq); - return XmlUtils::CreateNode(m_namespace + L":linkedTxbx", oAttr); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - if (m_namespace.empty()) m_namespace = L"a"; - - pWriter->StartNode(m_namespace + L":linkedTxbx"); - - pWriter->StartAttributes(); - pWriter->WriteAttribute2(L"id", id); - pWriter->WriteAttribute2(L"seq", seq); - pWriter->EndAttributes(); - - pWriter->EndNode(m_namespace + L":linkedTxbx"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteUInt2(0, id); - pWriter->WriteUInt2(1, seq); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - pReader->Skip(1); // start attributes - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - id = pReader->GetULong(); - break; - } - case 1: - { - seq = pReader->GetULong(); - break; - } - default: - break; - } - } - pReader->Seek(_end_rec); - } nullable_uint id; nullable_uint seq; std::vector extLst; mutable std::wstring m_namespace; + protected: - virtual void FillParentPointersForChilds() - { - } + virtual void FillParentPointersForChilds(); + AVSINLINE void Normalize() { } diff --git a/OOXML/PPTXFormat/Logic/CNvCxnSpPr.cpp b/OOXML/PPTXFormat/Logic/CNvCxnSpPr.cpp new file mode 100644 index 0000000000..3711c272dc --- /dev/null +++ b/OOXML/PPTXFormat/Logic/CNvCxnSpPr.cpp @@ -0,0 +1,344 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "CNvCxnSpPr.h" + +namespace PPTX +{ + namespace Logic + { + CNvCxnSpPr::CNvCxnSpPr(std::wstring ns) + { + m_namespace = ns; + } + CNvCxnSpPr& CNvCxnSpPr::operator=(const CNvCxnSpPr& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + noAdjustHandles = oSrc.noAdjustHandles; + noChangeArrowheads = oSrc.noChangeArrowheads; + noChangeAspect = oSrc.noChangeAspect; + noChangeShapeType = oSrc.noChangeShapeType; + noEditPoints = oSrc.noEditPoints; + noGrp = oSrc.noGrp; + noMove = oSrc.noMove; + noResize = oSrc.noResize; + noRot = oSrc.noRot; + noSelect = oSrc.noSelect; + + stCxn_id = oSrc.stCxn_id; + stCxn_idx = oSrc.stCxn_idx; + endCxn_id = oSrc.endCxn_id; + endCxn_idx = oSrc.endCxn_idx; + + return *this; + } + void CNvCxnSpPr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring strName = oReader.GetName(); + + if (strName == L"a:cxnSpLocks") + { + ReadAttributesLocks(oReader); + } + else if (strName == L"a:stCxn") + { + ReadAttributes(oReader, stCxn_id, stCxn_idx); + } + else if (strName == L"a:endCxn") + { + ReadAttributes(oReader, endCxn_id, endCxn_idx); + } + } + } + void CNvCxnSpPr::ReadAttributes(XmlUtils::CXmlLiteReader& oReader, nullable_int & id, nullable_int & idx ) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("id"), id) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("idx"), idx) + WritingElement_ReadAttributes_End( oReader ) + } + void CNvCxnSpPr::ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("noAdjustHandles"), noAdjustHandles) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeArrowheads"), noChangeArrowheads) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeAspect"), noChangeAspect) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeShapeType"), noChangeShapeType) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noEditPoints"), noEditPoints) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noGrp"), noGrp) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noMove"), noMove) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noResize"), noResize) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noRot"), noRot) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noSelect"), noSelect) + WritingElement_ReadAttributes_End( oReader ) + } + void CNvCxnSpPr::fromXML(XmlUtils::CXmlNode& node) + { + m_namespace = XmlUtils::GetNamespace(node.GetName()); + + XmlUtils::CXmlNode l_Locks; + if (node.GetNode(_T("a:cxnSpLocks"), l_Locks)) + { + XmlMacroReadAttributeBase(l_Locks, L"noAdjustHandles", noAdjustHandles); + XmlMacroReadAttributeBase(l_Locks, L"noChangeArrowheads", noChangeArrowheads); + XmlMacroReadAttributeBase(l_Locks, L"noChangeAspect", noChangeAspect); + XmlMacroReadAttributeBase(l_Locks, L"noChangeShapeType", noChangeShapeType); + XmlMacroReadAttributeBase(l_Locks, L"noEditPoints", noEditPoints); + XmlMacroReadAttributeBase(l_Locks, L"noGrp", noGrp); + XmlMacroReadAttributeBase(l_Locks, L"noMove", noMove); + XmlMacroReadAttributeBase(l_Locks, L"noResize", noResize); + XmlMacroReadAttributeBase(l_Locks, L"noRot", noRot); + XmlMacroReadAttributeBase(l_Locks, L"noSelect", noSelect); + } + + XmlUtils::CXmlNode l_Cxn; + if (node.GetNode(_T("a:stCxn"), l_Cxn)) + { + XmlMacroReadAttributeBase(l_Cxn, L"id", stCxn_id); + XmlMacroReadAttributeBase(l_Cxn, L"idx", stCxn_idx); + } + + XmlUtils::CXmlNode l_endCxn; + if (node.GetNode(_T("a:endCxn"), l_endCxn)) + { + XmlMacroReadAttributeBase(l_endCxn, L"id", endCxn_id); + XmlMacroReadAttributeBase(l_endCxn, L"idx", endCxn_idx); + } + } + std::wstring CNvCxnSpPr::toXML() const + { + XmlUtils::CAttribute oAttr1; + oAttr1.Write(_T("noAdjustHandles"), noAdjustHandles); + oAttr1.Write(_T("noChangeArrowheads"), noChangeArrowheads); + oAttr1.Write(_T("noChangeAspect"), noChangeAspect); + oAttr1.Write(_T("noChangeShapeType"), noChangeShapeType); + oAttr1.Write(_T("noEditPoints"), noEditPoints); + oAttr1.Write(_T("noGrp"), noGrp); + oAttr1.Write(_T("noMove"), noMove); + oAttr1.Write(_T("noResize"), noResize); + oAttr1.Write(_T("noRot"), noRot); + oAttr1.Write(_T("noSelect"), noSelect); + + XmlUtils::CAttribute oAttr2; + oAttr2.Write(_T("id"), stCxn_id); + oAttr2.Write(_T("idx"), stCxn_idx); + + XmlUtils::CAttribute oAttr3; + oAttr3.Write(_T("id"), endCxn_id); + oAttr3.Write(_T("idx"), endCxn_idx); + + XmlUtils::CNodeValue oValue; + oValue.m_strValue += XmlUtils::CreateNode(_T("a:cxnSpLocks"), oAttr1); + + if (_T("") != oAttr2.m_strValue) + oValue.m_strValue += XmlUtils::CreateNode(_T("a:stCxn"), oAttr2); + if (_T("") != oAttr3.m_strValue) + oValue.m_strValue += XmlUtils::CreateNode(_T("a:endCxn"), oAttr3); + + return XmlUtils::CreateNode(m_namespace + L":cNvCxnSpPr", oValue); + } + void CNvCxnSpPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring namespace_ = m_namespace; + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"wps"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; + + pWriter->StartNode(namespace_ + L":cNvCxnSpPr"); + + pWriter->EndAttributes(); + + pWriter->StartNode(_T("a:cxnSpLocks")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("noAdjustHandles"), noAdjustHandles); + pWriter->WriteAttribute(_T("noChangeArrowheads"), noChangeArrowheads); + pWriter->WriteAttribute(_T("noChangeAspect"), noChangeAspect); + pWriter->WriteAttribute(_T("noChangeShapeType"), noChangeShapeType); + pWriter->WriteAttribute(_T("noEditPoints"), noEditPoints); + pWriter->WriteAttribute(_T("noGrp"), noGrp); + pWriter->WriteAttribute(_T("noMove"), noMove); + pWriter->WriteAttribute(_T("noResize"), noResize); + pWriter->WriteAttribute(_T("noRot"), noRot); + pWriter->WriteAttribute(_T("noSelect"), noSelect); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:cxnSpLocks")); + + if (stCxn_id.is_init() || stCxn_idx.is_init()) + { + pWriter->StartNode(_T("a:stCxn")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("id"), stCxn_id); + pWriter->WriteAttribute(_T("idx"), stCxn_idx); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:stCxn")); + } + + if (endCxn_id.is_init() || endCxn_idx.is_init()) + { + pWriter->StartNode(_T("a:endCxn")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("id"), endCxn_id); + pWriter->WriteAttribute(_T("idx"), endCxn_idx); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:endCxn")); + } + + pWriter->EndNode(namespace_ + L":cNvCxnSpPr"); + } + void CNvCxnSpPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteBool2(0, noAdjustHandles); + pWriter->WriteBool2(1, noChangeArrowheads); + pWriter->WriteBool2(2, noChangeAspect); + pWriter->WriteBool2(3, noChangeShapeType); + pWriter->WriteBool2(4, noEditPoints); + pWriter->WriteBool2(5, noGrp); + pWriter->WriteBool2(6, noMove); + pWriter->WriteBool2(7, noResize); + pWriter->WriteBool2(8, noRot); + pWriter->WriteBool2(9, noSelect); + + pWriter->WriteInt2(10, stCxn_id); + pWriter->WriteInt2(11, stCxn_idx); + pWriter->WriteInt2(12, endCxn_id); + pWriter->WriteInt2(13, endCxn_idx); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void CNvCxnSpPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + noAdjustHandles = pReader->GetBool(); + break; + } + case 1: + { + noChangeArrowheads = pReader->GetBool(); + break; + } + case 2: + { + noChangeAspect = pReader->GetBool(); + break; + } + case 3: + { + noChangeShapeType = pReader->GetBool(); + break; + } + case 4: + { + noEditPoints = pReader->GetBool(); + break; + } + case 5: + { + noGrp = pReader->GetBool(); + break; + } + case 6: + { + noMove = pReader->GetBool(); + break; + } + case 7: + { + noResize = pReader->GetBool(); + break; + } + case 8: + { + noRot = pReader->GetBool(); + break; + } + case 9: + { + noSelect = pReader->GetBool(); + break; + } + case 10: + { + stCxn_id = pReader->GetLong(); + break; + } + case 11: + { + stCxn_idx = pReader->GetLong(); + break; + } + case 12: + { + endCxn_id = pReader->GetLong(); + break; + } + case 13: + { + endCxn_idx = pReader->GetLong(); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void CNvCxnSpPr::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/CNvCxnSpPr.h b/OOXML/PPTXFormat/Logic/CNvCxnSpPr.h index ff03da2778..ebbfd29bc7 100644 --- a/OOXML/PPTXFormat/Logic/CNvCxnSpPr.h +++ b/OOXML/PPTXFormat/Logic/CNvCxnSpPr.h @@ -44,313 +44,20 @@ namespace PPTX public: WritingElement_AdditionConstructors(CNvCxnSpPr) - CNvCxnSpPr(std::wstring ns = L"p") - { - m_namespace = ns; - } + CNvCxnSpPr(std::wstring ns = L"p"); + CNvCxnSpPr& operator=(const CNvCxnSpPr& oSrc); - CNvCxnSpPr& operator=(const CNvCxnSpPr& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - noAdjustHandles = oSrc.noAdjustHandles; - noChangeArrowheads = oSrc.noChangeArrowheads; - noChangeAspect = oSrc.noChangeAspect; - noChangeShapeType = oSrc.noChangeShapeType; - noEditPoints = oSrc.noEditPoints; - noGrp = oSrc.noGrp; - noMove = oSrc.noMove; - noResize = oSrc.noResize; - noRot = oSrc.noRot; - noSelect = oSrc.noSelect; + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader, nullable_int & id, nullable_int & idx ); + void ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader); - stCxn_id = oSrc.stCxn_id; - stCxn_idx = oSrc.stCxn_idx; - endCxn_id = oSrc.endCxn_id; - endCxn_idx = oSrc.endCxn_idx; + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - return *this; - } - - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); - - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring strName = oReader.GetName(); - - if (strName == L"a:cxnSpLocks") - { - ReadAttributesLocks(oReader); - } - else if (strName == L"a:stCxn") - { - ReadAttributes(oReader, stCxn_id, stCxn_idx); - } - else if (strName == L"a:endCxn") - { - ReadAttributes(oReader, endCxn_id, endCxn_idx); - } - } - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader, nullable_int & id, nullable_int & idx ) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("id"), id) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("idx"), idx) - WritingElement_ReadAttributes_End( oReader ) - } - void ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("noAdjustHandles"), noAdjustHandles) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeArrowheads"), noChangeArrowheads) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeAspect"), noChangeAspect) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeShapeType"), noChangeShapeType) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noEditPoints"), noEditPoints) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noGrp"), noGrp) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noMove"), noMove) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noResize"), noResize) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noRot"), noRot) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noSelect"), noSelect) - WritingElement_ReadAttributes_End( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_namespace = XmlUtils::GetNamespace(node.GetName()); - - XmlUtils::CXmlNode l_Locks; - if (node.GetNode(_T("a:cxnSpLocks"), l_Locks)) - { - XmlMacroReadAttributeBase(l_Locks, L"noAdjustHandles", noAdjustHandles); - XmlMacroReadAttributeBase(l_Locks, L"noChangeArrowheads", noChangeArrowheads); - XmlMacroReadAttributeBase(l_Locks, L"noChangeAspect", noChangeAspect); - XmlMacroReadAttributeBase(l_Locks, L"noChangeShapeType", noChangeShapeType); - XmlMacroReadAttributeBase(l_Locks, L"noEditPoints", noEditPoints); - XmlMacroReadAttributeBase(l_Locks, L"noGrp", noGrp); - XmlMacroReadAttributeBase(l_Locks, L"noMove", noMove); - XmlMacroReadAttributeBase(l_Locks, L"noResize", noResize); - XmlMacroReadAttributeBase(l_Locks, L"noRot", noRot); - XmlMacroReadAttributeBase(l_Locks, L"noSelect", noSelect); - } - - XmlUtils::CXmlNode l_Cxn; - if (node.GetNode(_T("a:stCxn"), l_Cxn)) - { - XmlMacroReadAttributeBase(l_Cxn, L"id", stCxn_id); - XmlMacroReadAttributeBase(l_Cxn, L"idx", stCxn_idx); - } - - XmlUtils::CXmlNode l_endCxn; - if (node.GetNode(_T("a:endCxn"), l_endCxn)) - { - XmlMacroReadAttributeBase(l_endCxn, L"id", endCxn_id); - XmlMacroReadAttributeBase(l_endCxn, L"idx", endCxn_idx); - } - } - - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr1; - oAttr1.Write(_T("noAdjustHandles"), noAdjustHandles); - oAttr1.Write(_T("noChangeArrowheads"), noChangeArrowheads); - oAttr1.Write(_T("noChangeAspect"), noChangeAspect); - oAttr1.Write(_T("noChangeShapeType"), noChangeShapeType); - oAttr1.Write(_T("noEditPoints"), noEditPoints); - oAttr1.Write(_T("noGrp"), noGrp); - oAttr1.Write(_T("noMove"), noMove); - oAttr1.Write(_T("noResize"), noResize); - oAttr1.Write(_T("noRot"), noRot); - oAttr1.Write(_T("noSelect"), noSelect); - - XmlUtils::CAttribute oAttr2; - oAttr2.Write(_T("id"), stCxn_id); - oAttr2.Write(_T("idx"), stCxn_idx); - - XmlUtils::CAttribute oAttr3; - oAttr3.Write(_T("id"), endCxn_id); - oAttr3.Write(_T("idx"), endCxn_idx); - - XmlUtils::CNodeValue oValue; - oValue.m_strValue += XmlUtils::CreateNode(_T("a:cxnSpLocks"), oAttr1); - - if (_T("") != oAttr2.m_strValue) - oValue.m_strValue += XmlUtils::CreateNode(_T("a:stCxn"), oAttr2); - if (_T("") != oAttr3.m_strValue) - oValue.m_strValue += XmlUtils::CreateNode(_T("a:endCxn"), oAttr3); - - return XmlUtils::CreateNode(m_namespace + L":cNvCxnSpPr", oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring namespace_ = m_namespace; - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"wps"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; - - pWriter->StartNode(namespace_ + L":cNvCxnSpPr"); - - pWriter->EndAttributes(); - - pWriter->StartNode(_T("a:cxnSpLocks")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("noAdjustHandles"), noAdjustHandles); - pWriter->WriteAttribute(_T("noChangeArrowheads"), noChangeArrowheads); - pWriter->WriteAttribute(_T("noChangeAspect"), noChangeAspect); - pWriter->WriteAttribute(_T("noChangeShapeType"), noChangeShapeType); - pWriter->WriteAttribute(_T("noEditPoints"), noEditPoints); - pWriter->WriteAttribute(_T("noGrp"), noGrp); - pWriter->WriteAttribute(_T("noMove"), noMove); - pWriter->WriteAttribute(_T("noResize"), noResize); - pWriter->WriteAttribute(_T("noRot"), noRot); - pWriter->WriteAttribute(_T("noSelect"), noSelect); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:cxnSpLocks")); - - if (stCxn_id.is_init() || stCxn_idx.is_init()) - { - pWriter->StartNode(_T("a:stCxn")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("id"), stCxn_id); - pWriter->WriteAttribute(_T("idx"), stCxn_idx); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:stCxn")); - } - - if (endCxn_id.is_init() || endCxn_idx.is_init()) - { - pWriter->StartNode(_T("a:endCxn")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("id"), endCxn_id); - pWriter->WriteAttribute(_T("idx"), endCxn_idx); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:endCxn")); - } - - pWriter->EndNode(namespace_ + L":cNvCxnSpPr"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteBool2(0, noAdjustHandles); - pWriter->WriteBool2(1, noChangeArrowheads); - pWriter->WriteBool2(2, noChangeAspect); - pWriter->WriteBool2(3, noChangeShapeType); - pWriter->WriteBool2(4, noEditPoints); - pWriter->WriteBool2(5, noGrp); - pWriter->WriteBool2(6, noMove); - pWriter->WriteBool2(7, noResize); - pWriter->WriteBool2(8, noRot); - pWriter->WriteBool2(9, noSelect); - - pWriter->WriteInt2(10, stCxn_id); - pWriter->WriteInt2(11, stCxn_idx); - pWriter->WriteInt2(12, endCxn_id); - pWriter->WriteInt2(13, endCxn_idx); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - noAdjustHandles = pReader->GetBool(); - break; - } - case 1: - { - noChangeArrowheads = pReader->GetBool(); - break; - } - case 2: - { - noChangeAspect = pReader->GetBool(); - break; - } - case 3: - { - noChangeShapeType = pReader->GetBool(); - break; - } - case 4: - { - noEditPoints = pReader->GetBool(); - break; - } - case 5: - { - noGrp = pReader->GetBool(); - break; - } - case 6: - { - noMove = pReader->GetBool(); - break; - } - case 7: - { - noResize = pReader->GetBool(); - break; - } - case 8: - { - noRot = pReader->GetBool(); - break; - } - case 9: - { - noSelect = pReader->GetBool(); - break; - } - case 10: - { - stCxn_id = pReader->GetLong(); - break; - } - case 11: - { - stCxn_idx = pReader->GetLong(); - break; - } - case 12: - { - endCxn_id = pReader->GetLong(); - break; - } - case 13: - { - endCxn_idx = pReader->GetLong(); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); std::wstring m_namespace; @@ -371,7 +78,8 @@ namespace PPTX nullable_int endCxn_idx; protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); + AVSINLINE void Normalize() { stCxn_id.normalize_positive(); diff --git a/OOXML/PPTXFormat/Logic/CNvGraphicFramePr.cpp b/OOXML/PPTXFormat/Logic/CNvGraphicFramePr.cpp new file mode 100644 index 0000000000..fdf1ec67d7 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/CNvGraphicFramePr.cpp @@ -0,0 +1,227 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "CNvGraphicFramePr.h" + +namespace PPTX +{ + namespace Logic + { + CNvGraphicFramePr::CNvGraphicFramePr(std::wstring ns) + { + m_namespace = ns; + } + CNvGraphicFramePr& CNvGraphicFramePr::operator=(const CNvGraphicFramePr& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + noChangeAspect = oSrc.noChangeAspect; + noDrilldown = oSrc.noDrilldown; + noGrp = oSrc.noGrp; + noMove = oSrc.noMove; + noResize = oSrc.noResize; + noSelect = oSrc.noSelect; + + m_namespace = oSrc.m_namespace; + + return *this; + } + void CNvGraphicFramePr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (strName == L"graphicFrameLocks") + { + ReadAttributesLocks(oReader); + } + } + } + void CNvGraphicFramePr::ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("noChangeAspect"), noChangeAspect) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noGrp"), noGrp) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noMove"), noMove) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noResize"), noResize) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noDrilldown"), noDrilldown) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noSelect"), noSelect) + WritingElement_ReadAttributes_End( oReader ) + } + void CNvGraphicFramePr::fromXML(XmlUtils::CXmlNode& node) + { + m_namespace = XmlUtils::GetNamespace(node.GetName()); + + XmlUtils::CXmlNode oNode = node.ReadNodeNoNS(L"graphicFrameLocks"); + if (oNode.IsValid()) + { + XmlMacroReadAttributeBase(oNode, L"noChangeAspect", noChangeAspect); + XmlMacroReadAttributeBase(oNode, L"noDrilldown", noDrilldown); + XmlMacroReadAttributeBase(oNode, L"noGrp", noGrp); + XmlMacroReadAttributeBase(oNode, L"noMove", noMove); + XmlMacroReadAttributeBase(oNode, L"noResize", noResize); + XmlMacroReadAttributeBase(oNode, L"noSelect", noSelect); + } + } + std::wstring CNvGraphicFramePr::toXML() const + { + std::wstring namespaceLocks = L"a"; + std::wstring namespaceLocksLink = PPTX::g_Namespaces.a.m_strLink; + //if (m_namespace == L"wp") namespaceLocks = L"wp"; + + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("noChangeAspect"), noChangeAspect); + oAttr.Write(_T("noDrilldown"), noDrilldown); + oAttr.Write(_T("noGrp"), noGrp); + oAttr.Write(_T("noMove"), noMove); + oAttr.Write(_T("noResize"), noResize); + oAttr.Write(_T("noSelect"), noSelect); + + bool isAttrEmpty = oAttr.m_strValue.empty(); + oAttr.Write(_T("xmlns:") + namespaceLocks, namespaceLocksLink); + + return XmlUtils::CreateNode(m_namespace + L":cNvGraphicFramePr", isAttrEmpty ? L"" : XmlUtils::CreateNode(namespaceLocks + L":graphicFrameLocks", oAttr)); + } + void CNvGraphicFramePr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring namespace_ = m_namespace; + std::wstring namespaceLock_ = L"a"; + std::wstring namespaceLockLink_ = PPTX::g_Namespaces.a.m_strLink; + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) + { + namespaceLock_ = L"a"; + namespaceLockLink_ = PPTX::g_Namespaces.a.m_strLink; + namespace_ = L"wp"; + } + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; + + pWriter->StartNode(namespace_ + L":cNvGraphicFramePr"); + + pWriter->EndAttributes(); + + pWriter->StartNode(namespaceLock_ + L":graphicFrameLocks"); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("xmlns:") + namespaceLock_, namespaceLockLink_); + pWriter->WriteAttribute(_T("noChangeAspect"), noChangeAspect); + pWriter->WriteAttribute(_T("noDrilldown"), noDrilldown); + pWriter->WriteAttribute(_T("noGrp"), noGrp); + pWriter->WriteAttribute(_T("noMove"), noMove); + pWriter->WriteAttribute(_T("noResize"), noResize); + pWriter->WriteAttribute(_T("noSelect"), noSelect); + + pWriter->EndAttributes(); + + pWriter->EndNode(namespaceLock_ + L":graphicFrameLocks"); + + pWriter->EndNode(namespace_ + L":cNvGraphicFramePr"); + } + void CNvGraphicFramePr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteBool2(0, noChangeAspect); + pWriter->WriteBool2(1, noDrilldown); + pWriter->WriteBool2(2, noGrp); + pWriter->WriteBool2(3, noMove); + pWriter->WriteBool2(4, noResize); + pWriter->WriteBool2(5, noSelect); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void CNvGraphicFramePr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + noChangeAspect = pReader->GetBool(); + break; + } + case 1: + { + noDrilldown = pReader->GetBool(); + break; + } + case 2: + { + noGrp = pReader->GetBool(); + break; + } + case 3: + { + noMove = pReader->GetBool(); + break; + } + case 4: + { + noResize = pReader->GetBool(); + break; + } + case 5: + { + noSelect = pReader->GetBool(); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void CNvGraphicFramePr::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/CNvGraphicFramePr.h b/OOXML/PPTXFormat/Logic/CNvGraphicFramePr.h index 9da1477000..8cc8a0e085 100644 --- a/OOXML/PPTXFormat/Logic/CNvGraphicFramePr.h +++ b/OOXML/PPTXFormat/Logic/CNvGraphicFramePr.h @@ -44,195 +44,20 @@ namespace PPTX public: WritingElement_AdditionConstructors(CNvGraphicFramePr) - CNvGraphicFramePr(std::wstring ns = L"p") - { - m_namespace = ns; - } + CNvGraphicFramePr(std::wstring ns = L"p"); + CNvGraphicFramePr& operator=(const CNvGraphicFramePr& oSrc); - CNvGraphicFramePr& operator=(const CNvGraphicFramePr& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + void fromXML(XmlUtils::CXmlLiteReader& oReader); - noChangeAspect = oSrc.noChangeAspect; - noDrilldown = oSrc.noDrilldown; - noGrp = oSrc.noGrp; - noMove = oSrc.noMove; - noResize = oSrc.noResize; - noSelect = oSrc.noSelect; + void ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader); - m_namespace = oSrc.m_namespace; + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - return *this; - } - void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); - - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - if (strName == L"graphicFrameLocks") - { - ReadAttributesLocks(oReader); - } - } - } - void ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("noChangeAspect"), noChangeAspect) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noGrp"), noGrp) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noMove"), noMove) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noResize"), noResize) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noDrilldown"), noDrilldown) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noSelect"), noSelect) - WritingElement_ReadAttributes_End( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_namespace = XmlUtils::GetNamespace(node.GetName()); - - XmlUtils::CXmlNode oNode = node.ReadNodeNoNS(L"graphicFrameLocks"); - if (oNode.IsValid()) - { - XmlMacroReadAttributeBase(oNode, L"noChangeAspect", noChangeAspect); - XmlMacroReadAttributeBase(oNode, L"noDrilldown", noDrilldown); - XmlMacroReadAttributeBase(oNode, L"noGrp", noGrp); - XmlMacroReadAttributeBase(oNode, L"noMove", noMove); - XmlMacroReadAttributeBase(oNode, L"noResize", noResize); - XmlMacroReadAttributeBase(oNode, L"noSelect", noSelect); - } - } - - virtual std::wstring toXML() const - { - std::wstring namespaceLocks = L"a"; - std::wstring namespaceLocksLink = PPTX::g_Namespaces.a.m_strLink; - //if (m_namespace == L"wp") namespaceLocks = L"wp"; - - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("noChangeAspect"), noChangeAspect); - oAttr.Write(_T("noDrilldown"), noDrilldown); - oAttr.Write(_T("noGrp"), noGrp); - oAttr.Write(_T("noMove"), noMove); - oAttr.Write(_T("noResize"), noResize); - oAttr.Write(_T("noSelect"), noSelect); - - bool isAttrEmpty = oAttr.m_strValue.empty(); - oAttr.Write(_T("xmlns:") + namespaceLocks, namespaceLocksLink); - - return XmlUtils::CreateNode(m_namespace + L":cNvGraphicFramePr", isAttrEmpty ? L"" : XmlUtils::CreateNode(namespaceLocks + L":graphicFrameLocks", oAttr)); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring namespace_ = m_namespace; - std::wstring namespaceLock_ = L"a"; - std::wstring namespaceLockLink_ = PPTX::g_Namespaces.a.m_strLink; - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) - { - namespaceLock_ = L"a"; - namespaceLockLink_ = PPTX::g_Namespaces.a.m_strLink; - namespace_ = L"wp"; - } - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; - - pWriter->StartNode(namespace_ + L":cNvGraphicFramePr"); - - pWriter->EndAttributes(); - - pWriter->StartNode(namespaceLock_ + L":graphicFrameLocks"); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("xmlns:") + namespaceLock_, namespaceLockLink_); - pWriter->WriteAttribute(_T("noChangeAspect"), noChangeAspect); - pWriter->WriteAttribute(_T("noDrilldown"), noDrilldown); - pWriter->WriteAttribute(_T("noGrp"), noGrp); - pWriter->WriteAttribute(_T("noMove"), noMove); - pWriter->WriteAttribute(_T("noResize"), noResize); - pWriter->WriteAttribute(_T("noSelect"), noSelect); - - pWriter->EndAttributes(); - - pWriter->EndNode(namespaceLock_ + L":graphicFrameLocks"); - - pWriter->EndNode(namespace_ + L":cNvGraphicFramePr"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteBool2(0, noChangeAspect); - pWriter->WriteBool2(1, noDrilldown); - pWriter->WriteBool2(2, noGrp); - pWriter->WriteBool2(3, noMove); - pWriter->WriteBool2(4, noResize); - pWriter->WriteBool2(5, noSelect); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - noChangeAspect = pReader->GetBool(); - break; - } - case 1: - { - noDrilldown = pReader->GetBool(); - break; - } - case 2: - { - noGrp = pReader->GetBool(); - break; - } - case 3: - { - noMove = pReader->GetBool(); - break; - } - case 4: - { - noResize = pReader->GetBool(); - break; - } - case 5: - { - noSelect = pReader->GetBool(); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } std::wstring m_namespace; nullable_bool noChangeAspect; @@ -241,8 +66,9 @@ namespace PPTX nullable_bool noMove; nullable_bool noResize; nullable_bool noSelect; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/CNvGrpSpPr.cpp b/OOXML/PPTXFormat/Logic/CNvGrpSpPr.cpp index 993d3fbfd3..875be562a1 100644 --- a/OOXML/PPTXFormat/Logic/CNvGrpSpPr.cpp +++ b/OOXML/PPTXFormat/Logic/CNvGrpSpPr.cpp @@ -35,7 +35,7 @@ namespace PPTX { namespace Logic { - CNvGrpSpPr& CNvGrpSpPr::operator=(const CNvGrpSpPr& oSrc) + CNvGrpSpPr& CNvGrpSpPr::operator=(const CNvGrpSpPr& oSrc) { parentFile = oSrc.parentFile; parentElement = oSrc.parentElement; diff --git a/OOXML/PPTXFormat/Logic/CNvPicPr.cpp b/OOXML/PPTXFormat/Logic/CNvPicPr.cpp new file mode 100644 index 0000000000..793f7d7ab2 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/CNvPicPr.cpp @@ -0,0 +1,300 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "CNvPicPr.h" + +namespace PPTX +{ + namespace Logic + { + CNvPicPr::CNvPicPr(std::wstring ns) + { + m_namespace = ns; + } + CNvPicPr& CNvPicPr::operator=(const CNvPicPr& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + preferRelativeResize = oSrc.preferRelativeResize; + + noAdjustHandles = oSrc.noAdjustHandles; + noChangeArrowheads = oSrc.noChangeArrowheads; + noChangeAspect = oSrc.noChangeAspect; + noChangeShapeType = oSrc.noChangeShapeType; + noCrop = oSrc.noCrop; + noEditPoints = oSrc.noEditPoints; + noGrp = oSrc.noGrp; + noMove = oSrc.noMove; + noResize = oSrc.noResize; + noRot = oSrc.noRot; + noSelect = oSrc.noSelect; + + m_namespace = oSrc.m_namespace; + + return *this; + } + void CNvPicPr::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start ( oReader ) + WritingElement_ReadAttributes_ReadSingle( oReader, _T("preferRelativeResize"), preferRelativeResize ) + WritingElement_ReadAttributes_End ( oReader ) + } + void CNvPicPr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (_T("picLocks") == strName) + { + ReadAttributesLocks(oReader); + } + } + } + void CNvPicPr::ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("noAdjustHandles"), noAdjustHandles) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeArrowheads"), noChangeArrowheads) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeAspect"), noChangeAspect) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeShapeType"), noChangeShapeType) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noCrop"), noCrop) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noEditPoints"), noEditPoints) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noGrp"), noGrp) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noMove"), noMove) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noResize"), noResize) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noRot"), noRot) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noSelect"), noSelect) + WritingElement_ReadAttributes_End( oReader ) + } + void CNvPicPr::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"preferRelativeResize", preferRelativeResize); + + XmlUtils::CXmlNode oNode; + if (node.GetNode(_T("a:picLocks"), oNode)) + { + XmlMacroReadAttributeBase(oNode, L"noAdjustHandles", noAdjustHandles); + XmlMacroReadAttributeBase(oNode, L"noChangeArrowheads", noChangeArrowheads); + XmlMacroReadAttributeBase(oNode, L"noChangeAspect", noChangeAspect); + XmlMacroReadAttributeBase(oNode, L"noChangeShapeType", noChangeShapeType); + XmlMacroReadAttributeBase(oNode, L"noCrop", noCrop); + XmlMacroReadAttributeBase(oNode, L"noEditPoints", noEditPoints); + XmlMacroReadAttributeBase(oNode, L"noGrp", noGrp); + XmlMacroReadAttributeBase(oNode, L"noMove", noMove); + XmlMacroReadAttributeBase(oNode, L"noResize", noResize); + XmlMacroReadAttributeBase(oNode, L"noRot", noRot); + XmlMacroReadAttributeBase(oNode, L"noSelect", noSelect); + } + } + std::wstring CNvPicPr::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("noAdjustHandles"), noAdjustHandles); + oAttr.Write(_T("noChangeAspect"), noChangeAspect); + oAttr.Write(_T("noChangeArrowheads"), noChangeArrowheads); + oAttr.Write(_T("noChangeShapeType"), noChangeShapeType); + oAttr.Write(_T("noEditPoints"), noEditPoints); + oAttr.Write(_T("noGrp"), noGrp); + oAttr.Write(_T("noMove"), noMove); + oAttr.Write(_T("noResize"), noResize); + oAttr.Write(_T("noRot"), noRot); + oAttr.Write(_T("noSelect"), noSelect); + oAttr.Write(_T("noCrop"), noCrop); + + XmlUtils::CAttribute oAttr2; + oAttr2.Write(_T("preferRelativeResize"), preferRelativeResize); + + if (_T("") == oAttr.m_strValue) + { + return XmlUtils::CreateNode(_T("p:cNvPicPr"), oAttr2); + } + + return XmlUtils::CreateNode(_T("p:cNvPicPr"), oAttr2, XmlUtils::CreateNode(_T("a:picLocks"), oAttr)); + } + void CNvPicPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring namespace_ = m_namespace; + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"pic"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; + + pWriter->StartNode(namespace_ + L":cNvPicPr"); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("preferRelativeResize"), preferRelativeResize); + pWriter->EndAttributes(); + + if (noAdjustHandles.is_init() || + noChangeAspect.is_init() || + noChangeArrowheads.is_init() || + noChangeShapeType.is_init() || + noEditPoints.is_init() || + noGrp.is_init() || + noMove.is_init() || + noResize.is_init() || + noRot.is_init() || + noSelect.is_init() || + noCrop.is_init()) + { + pWriter->StartNode(_T("a:picLocks")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("noAdjustHandles"), noAdjustHandles); + pWriter->WriteAttribute(_T("noChangeAspect"), noChangeAspect); + pWriter->WriteAttribute(_T("noChangeArrowheads"), noChangeArrowheads); + pWriter->WriteAttribute(_T("noChangeShapeType"), noChangeShapeType); + pWriter->WriteAttribute(_T("noEditPoints"), noEditPoints); + pWriter->WriteAttribute(_T("noGrp"), noGrp); + pWriter->WriteAttribute(_T("noMove"), noMove); + pWriter->WriteAttribute(_T("noResize"), noResize); + pWriter->WriteAttribute(_T("noRot"), noRot); + pWriter->WriteAttribute(_T("noSelect"), noSelect); + pWriter->WriteAttribute(_T("noCrop"), noCrop); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:picLocks")); + } + pWriter->EndNode(namespace_ + L":cNvPicPr"); + } + void CNvPicPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteBool2(0, preferRelativeResize); + pWriter->WriteBool2(1, noAdjustHandles); + pWriter->WriteBool2(2, noChangeArrowheads); + pWriter->WriteBool2(3, noChangeAspect); + pWriter->WriteBool2(4, noChangeShapeType); + pWriter->WriteBool2(5, noCrop); + pWriter->WriteBool2(6, noEditPoints); + pWriter->WriteBool2(7, noGrp); + pWriter->WriteBool2(8, noMove); + pWriter->WriteBool2(9, noResize); + pWriter->WriteBool2(10, noRot); + pWriter->WriteBool2(11, noSelect); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void CNvPicPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + preferRelativeResize = pReader->GetBool(); + break; + } + case 1: + { + noAdjustHandles = pReader->GetBool(); + break; + } + case 2: + { + noChangeArrowheads = pReader->GetBool(); + break; + } + case 3: + { + noChangeAspect = pReader->GetBool(); + break; + } + case 4: + { + noChangeShapeType = pReader->GetBool(); + break; + } + case 5: + { + noCrop = pReader->GetBool(); + break; + } + case 6: + { + noEditPoints = pReader->GetBool(); + break; + } + case 7: + { + noGrp = pReader->GetBool(); + break; + } + case 8: + { + noMove = pReader->GetBool(); + break; + } + case 9: + { + noResize = pReader->GetBool(); + break; + } + case 10: + { + noRot = pReader->GetBool(); + break; + } + case 11: + { + noSelect = pReader->GetBool(); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void CNvPicPr::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/CNvPicPr.h b/OOXML/PPTXFormat/Logic/CNvPicPr.h index 11e5eff3bb..74697bac68 100644 --- a/OOXML/PPTXFormat/Logic/CNvPicPr.h +++ b/OOXML/PPTXFormat/Logic/CNvPicPr.h @@ -46,268 +46,20 @@ namespace PPTX WritingElement_AdditionConstructors(CNvPicPr) - CNvPicPr(std::wstring ns = L"p") - { - m_namespace = ns; - } + CNvPicPr(std::wstring ns = L"p"); + CNvPicPr& operator=(const CNvPicPr& oSrc); - CNvPicPr& operator=(const CNvPicPr& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader); - preferRelativeResize = oSrc.preferRelativeResize; + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - noAdjustHandles = oSrc.noAdjustHandles; - noChangeArrowheads = oSrc.noChangeArrowheads; - noChangeAspect = oSrc.noChangeAspect; - noChangeShapeType = oSrc.noChangeShapeType; - noCrop = oSrc.noCrop; - noEditPoints = oSrc.noEditPoints; - noGrp = oSrc.noGrp; - noMove = oSrc.noMove; - noResize = oSrc.noResize; - noRot = oSrc.noRot; - noSelect = oSrc.noSelect; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - m_namespace = oSrc.m_namespace; - - return *this; - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start ( oReader ) - WritingElement_ReadAttributes_ReadSingle( oReader, _T("preferRelativeResize"), preferRelativeResize ) - WritingElement_ReadAttributes_End ( oReader ) - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); - - ReadAttributes( oReader ); - - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); - - if (_T("picLocks") == strName) - { - ReadAttributesLocks(oReader); - } - } - } - void ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("noAdjustHandles"), noAdjustHandles) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeArrowheads"), noChangeArrowheads) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeAspect"), noChangeAspect) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeShapeType"), noChangeShapeType) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noCrop"), noCrop) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noEditPoints"), noEditPoints) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noGrp"), noGrp) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noMove"), noMove) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noResize"), noResize) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noRot"), noRot) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noSelect"), noSelect) - WritingElement_ReadAttributes_End( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"preferRelativeResize", preferRelativeResize); - - XmlUtils::CXmlNode oNode; - if (node.GetNode(_T("a:picLocks"), oNode)) - { - XmlMacroReadAttributeBase(oNode, L"noAdjustHandles", noAdjustHandles); - XmlMacroReadAttributeBase(oNode, L"noChangeArrowheads", noChangeArrowheads); - XmlMacroReadAttributeBase(oNode, L"noChangeAspect", noChangeAspect); - XmlMacroReadAttributeBase(oNode, L"noChangeShapeType", noChangeShapeType); - XmlMacroReadAttributeBase(oNode, L"noCrop", noCrop); - XmlMacroReadAttributeBase(oNode, L"noEditPoints", noEditPoints); - XmlMacroReadAttributeBase(oNode, L"noGrp", noGrp); - XmlMacroReadAttributeBase(oNode, L"noMove", noMove); - XmlMacroReadAttributeBase(oNode, L"noResize", noResize); - XmlMacroReadAttributeBase(oNode, L"noRot", noRot); - XmlMacroReadAttributeBase(oNode, L"noSelect", noSelect); - } - } - - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("noAdjustHandles"), noAdjustHandles); - oAttr.Write(_T("noChangeAspect"), noChangeAspect); - oAttr.Write(_T("noChangeArrowheads"), noChangeArrowheads); - oAttr.Write(_T("noChangeShapeType"), noChangeShapeType); - oAttr.Write(_T("noEditPoints"), noEditPoints); - oAttr.Write(_T("noGrp"), noGrp); - oAttr.Write(_T("noMove"), noMove); - oAttr.Write(_T("noResize"), noResize); - oAttr.Write(_T("noRot"), noRot); - oAttr.Write(_T("noSelect"), noSelect); - oAttr.Write(_T("noCrop"), noCrop); - - XmlUtils::CAttribute oAttr2; - oAttr2.Write(_T("preferRelativeResize"), preferRelativeResize); - - if (_T("") == oAttr.m_strValue) - { - return XmlUtils::CreateNode(_T("p:cNvPicPr"), oAttr2); - } - - return XmlUtils::CreateNode(_T("p:cNvPicPr"), oAttr2, XmlUtils::CreateNode(_T("a:picLocks"), oAttr)); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring namespace_ = m_namespace; - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"pic"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; - - pWriter->StartNode(namespace_ + L":cNvPicPr"); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("preferRelativeResize"), preferRelativeResize); - pWriter->EndAttributes(); - - if (noAdjustHandles.is_init() || - noChangeAspect.is_init() || - noChangeArrowheads.is_init() || - noChangeShapeType.is_init() || - noEditPoints.is_init() || - noGrp.is_init() || - noMove.is_init() || - noResize.is_init() || - noRot.is_init() || - noSelect.is_init() || - noCrop.is_init()) - { - pWriter->StartNode(_T("a:picLocks")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("noAdjustHandles"), noAdjustHandles); - pWriter->WriteAttribute(_T("noChangeAspect"), noChangeAspect); - pWriter->WriteAttribute(_T("noChangeArrowheads"), noChangeArrowheads); - pWriter->WriteAttribute(_T("noChangeShapeType"), noChangeShapeType); - pWriter->WriteAttribute(_T("noEditPoints"), noEditPoints); - pWriter->WriteAttribute(_T("noGrp"), noGrp); - pWriter->WriteAttribute(_T("noMove"), noMove); - pWriter->WriteAttribute(_T("noResize"), noResize); - pWriter->WriteAttribute(_T("noRot"), noRot); - pWriter->WriteAttribute(_T("noSelect"), noSelect); - pWriter->WriteAttribute(_T("noCrop"), noCrop); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:picLocks")); - } - pWriter->EndNode(namespace_ + L":cNvPicPr"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteBool2(0, preferRelativeResize); - pWriter->WriteBool2(1, noAdjustHandles); - pWriter->WriteBool2(2, noChangeArrowheads); - pWriter->WriteBool2(3, noChangeAspect); - pWriter->WriteBool2(4, noChangeShapeType); - pWriter->WriteBool2(5, noCrop); - pWriter->WriteBool2(6, noEditPoints); - pWriter->WriteBool2(7, noGrp); - pWriter->WriteBool2(8, noMove); - pWriter->WriteBool2(9, noResize); - pWriter->WriteBool2(10, noRot); - pWriter->WriteBool2(11, noSelect); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - preferRelativeResize = pReader->GetBool(); - break; - } - case 1: - { - noAdjustHandles = pReader->GetBool(); - break; - } - case 2: - { - noChangeArrowheads = pReader->GetBool(); - break; - } - case 3: - { - noChangeAspect = pReader->GetBool(); - break; - } - case 4: - { - noChangeShapeType = pReader->GetBool(); - break; - } - case 5: - { - noCrop = pReader->GetBool(); - break; - } - case 6: - { - noEditPoints = pReader->GetBool(); - break; - } - case 7: - { - noGrp = pReader->GetBool(); - break; - } - case 8: - { - noMove = pReader->GetBool(); - break; - } - case 9: - { - noResize = pReader->GetBool(); - break; - } - case 10: - { - noRot = pReader->GetBool(); - break; - } - case 11: - { - noSelect = pReader->GetBool(); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } std::wstring m_namespace; nullable_bool preferRelativeResize; @@ -323,8 +75,9 @@ namespace PPTX nullable_bool noResize; nullable_bool noRot; nullable_bool noSelect; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/CNvPr.cpp b/OOXML/PPTXFormat/Logic/CNvPr.cpp new file mode 100644 index 0000000000..0940d02a3f --- /dev/null +++ b/OOXML/PPTXFormat/Logic/CNvPr.cpp @@ -0,0 +1,311 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "CNvPr.h" + +namespace PPTX +{ + namespace Logic + { + CNvPr::CNvPr(std::wstring ns) + { + m_namespace = ns; + } + OOX::EElementType CNvPr::getType () const + { + return OOX::et_p_cNvPr; + } + void CNvPr::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + nullable_int id_; + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, L"id", id_) + WritingElement_ReadAttributes_Read_else_if ( oReader, L"name", name) + WritingElement_ReadAttributes_Read_else_if ( oReader, L"descr", descr) + WritingElement_ReadAttributes_Read_else_if ( oReader, L"hidden", hidden) + WritingElement_ReadAttributes_Read_else_if ( oReader, L"title", title) + WritingElement_ReadAttributes_Read_else_if (oReader, L"form", form) + WritingElement_ReadAttributes_End( oReader ) + + id = id_.get_value_or(0); + Normalize(); + } + void CNvPr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + if (strName == L"hlinkClick") + hlinkClick = oReader; + else if (strName == L"hlinkHover") + hlinkHover = oReader; + else if (strName == L"extLst") + { + if ( oReader.IsEmptyNode() ) + continue; + + int nParentDepth1 = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) + { + Ext ext; + ext.fromXML(oReader); + if (ext.spid.IsInit()) + { + vmlSpid = ext.spid; + break; + } + } + } + + } + } + void CNvPr::fromXML(XmlUtils::CXmlNode& node) + { + m_namespace = XmlUtils::GetNamespace(node.GetName()); + + id = node.ReadAttributeInt(L"id"); + name = node.GetAttribute(L"name"); + + XmlMacroReadAttributeBase(node, L"descr", descr); + XmlMacroReadAttributeBase(node, L"hidden", hidden); + XmlMacroReadAttributeBase(node, L"title", title); + + hlinkClick = node.ReadNode(L"a:hlinkClick"); + hlinkHover = node.ReadNode(L"a:hlinkHover"); + + XmlUtils::CXmlNode list = node.ReadNodeNoNS(L"extLst"); + if (list.IsValid()) + { + XmlUtils::CXmlNodes oNodes; + if (list.GetNodes(L"*", oNodes)) + { + int nCount = oNodes.GetCount(); + for (int i = 0; i < nCount; ++i) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(i, oNode); + + Ext ext; + ext.fromXML(oNode); + if (ext.spid.IsInit()) + { + vmlSpid = ext.spid; + break; + } + } + } + } + + Normalize(); + } + std::wstring CNvPr::toXML2(std::wstring node_name) const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(L"id", id); + oAttr.Write(L"name", XmlUtils::EncodeXmlString(name)); + if (descr.IsInit()) + { + std::wstring d = XmlUtils::EncodeXmlString(descr.get()); + XmlUtils::replace_all(d, L"\n", L" "); + + oAttr.Write(L"descr", d); + } + oAttr.Write(L"hidden", hidden); + if (title.IsInit()) oAttr.Write(L"title", XmlUtils::EncodeXmlString(title.get())); + oAttr.Write(L"form", form); + + XmlUtils::CNodeValue oValue; + oValue.WriteNullable(hlinkClick); + oValue.WriteNullable(hlinkHover); + + return XmlUtils::CreateNode(node_name.empty() ? (m_namespace + L":cNvPr") : node_name, oAttr, oValue); + } + std::wstring CNvPr::toXML() const + { + return toXML2(L""); + } + void CNvPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring namespace_ = m_namespace; + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_= L"pic"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_= L"xdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_= L"a"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; + + toXmlWriter2(namespace_, pWriter); + + } + void CNvPr::toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(strNS + L":cNvPr"); + + int _id = id; + if (_id < 0) + { + _id = pWriter->m_lObjectId; + ++pWriter->m_lObjectId; + } + else + { + if (pWriter->m_lObjectId <= (unsigned int)_id) + { + pWriter->m_lObjectId = _id + 1; + } + } + + pWriter->StartAttributes(); + pWriter->WriteAttribute (L"id", _id); + pWriter->WriteAttribute (L"name", XmlUtils::EncodeXmlString(name)); + if (descr.IsInit()) + { + std::wstring d = XmlUtils::EncodeXmlString(descr.get()); + XmlUtils::replace_all(d, L"\n", L" "); + + pWriter->WriteAttribute (L"descr", d); + } + pWriter->WriteAttribute (L"hidden", hidden); + if (title.IsInit()) pWriter->WriteAttribute (L"title", XmlUtils::EncodeXmlString(title.get())); + pWriter->WriteAttribute (L"form", form); + + pWriter->EndAttributes(); + + pWriter->Write(hlinkClick); + pWriter->Write(hlinkHover); + + pWriter->EndNode(strNS + L":cNvPr"); + } + void CNvPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteInt1(0, id); + pWriter->WriteString1(1, name); + pWriter->WriteBool2(2, hidden); + pWriter->WriteString2(3, title); + pWriter->WriteString2(4, descr); + pWriter->WriteBool2(5, form); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, hlinkClick); + pWriter->WriteRecord2(1, hlinkHover); + } + void CNvPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + id = 1; + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + id = pReader->GetLong(); + }break; + case 1: + { + name = pReader->GetString2(); + }break; + case 2: + { + hidden = pReader->GetBool(); + }break; + case 3: + { + title = pReader->GetString2(); + }break; + case 4: + { + descr = pReader->GetString2(); + }break; + case 5: + { + form = pReader->GetBool(); + }break; + default: + break; + } + } + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + hlinkClick = new PPTX::Logic::Hyperlink(L"hlinkClick"); + hlinkClick->fromPPTY(pReader); + break; + } + case 1: + { + hlinkHover = new PPTX::Logic::Hyperlink(L"hlinkHover"); + hlinkHover->fromPPTY(pReader); + break; + } + default: + { + break; + } + } + } + + pReader->Seek(_end_rec); + } + void CNvPr::FillParentPointersForChilds() + { + if(hlinkClick.IsInit()) + hlinkClick->SetParentPointer(this); + if(hlinkHover.IsInit()) + hlinkHover->SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX + diff --git a/OOXML/PPTXFormat/Logic/CNvPr.h b/OOXML/PPTXFormat/Logic/CNvPr.h index 93e6c4964b..29a0eb7d3b 100644 --- a/OOXML/PPTXFormat/Logic/CNvPr.h +++ b/OOXML/PPTXFormat/Logic/CNvPr.h @@ -45,275 +45,23 @@ namespace PPTX public: WritingElement_AdditionConstructors(CNvPr) - CNvPr(std::wstring ns = L"p") - { - m_namespace = ns; - } + CNvPr(std::wstring ns = L"p"); - virtual OOX::EElementType getType () const - { - return OOX::et_p_cNvPr; - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - nullable_int id_; - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, L"id", id_) - WritingElement_ReadAttributes_Read_else_if ( oReader, L"name", name) - WritingElement_ReadAttributes_Read_else_if ( oReader, L"descr", descr) - WritingElement_ReadAttributes_Read_else_if ( oReader, L"hidden", hidden) - WritingElement_ReadAttributes_Read_else_if ( oReader, L"title", title) - WritingElement_ReadAttributes_Read_else_if (oReader, L"form", form) - WritingElement_ReadAttributes_End( oReader ) - - id = id_.get_value_or(0); - Normalize(); - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + virtual OOX::EElementType getType () const; - ReadAttributes( oReader ); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); - if (strName == L"hlinkClick") - hlinkClick = oReader; - else if (strName == L"hlinkHover") - hlinkHover = oReader; - else if (strName == L"extLst") - { - if ( oReader.IsEmptyNode() ) - continue; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - int nParentDepth1 = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) - { - Ext ext; - ext.fromXML(oReader); - if (ext.spid.IsInit()) - { - vmlSpid = ext.spid; - break; - } - } - } + std::wstring toXML2(std::wstring node_name) const; + virtual std::wstring toXML() const; - } - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_namespace = XmlUtils::GetNamespace(node.GetName()); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + void toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const; - id = node.ReadAttributeInt(L"id"); - name = node.GetAttribute(L"name"); - - XmlMacroReadAttributeBase(node, L"descr", descr); - XmlMacroReadAttributeBase(node, L"hidden", hidden); - XmlMacroReadAttributeBase(node, L"title", title); - - hlinkClick = node.ReadNode(L"a:hlinkClick"); - hlinkHover = node.ReadNode(L"a:hlinkHover"); - - XmlUtils::CXmlNode list = node.ReadNodeNoNS(L"extLst"); - if (list.IsValid()) - { - XmlUtils::CXmlNodes oNodes; - if (list.GetNodes(L"*", oNodes)) - { - int nCount = oNodes.GetCount(); - for (int i = 0; i < nCount; ++i) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(i, oNode); - - Ext ext; - ext.fromXML(oNode); - if (ext.spid.IsInit()) - { - vmlSpid = ext.spid; - break; - } - } - } - } - - Normalize(); - } - - - std::wstring toXML2(std::wstring node_name) const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(L"id", id); - oAttr.Write(L"name", XmlUtils::EncodeXmlString(name)); - if (descr.IsInit()) - { - std::wstring d = XmlUtils::EncodeXmlString(descr.get()); - XmlUtils::replace_all(d, L"\n", L" "); - - oAttr.Write(L"descr", d); - } - oAttr.Write(L"hidden", hidden); - if (title.IsInit()) oAttr.Write(L"title", XmlUtils::EncodeXmlString(title.get())); - oAttr.Write(L"form", form); - - XmlUtils::CNodeValue oValue; - oValue.WriteNullable(hlinkClick); - oValue.WriteNullable(hlinkHover); - - return XmlUtils::CreateNode(node_name.empty() ? (m_namespace + L":cNvPr") : node_name, oAttr, oValue); - } - virtual std::wstring toXML() const - { - return toXML2(L""); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring namespace_ = m_namespace; - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_= L"pic"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_= L"xdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_= L"a"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; - - toXmlWriter2(namespace_, pWriter); - - } - void toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(strNS + L":cNvPr"); - - int _id = id; - if (_id < 0) - { - _id = pWriter->m_lObjectId; - ++pWriter->m_lObjectId; - } - else - { - if (pWriter->m_lObjectId <= (unsigned int)_id) - { - pWriter->m_lObjectId = _id + 1; - } - } - - pWriter->StartAttributes(); - pWriter->WriteAttribute (L"id", _id); - pWriter->WriteAttribute (L"name", XmlUtils::EncodeXmlString(name)); - if (descr.IsInit()) - { - std::wstring d = XmlUtils::EncodeXmlString(descr.get()); - XmlUtils::replace_all(d, L"\n", L" "); - - pWriter->WriteAttribute (L"descr", d); - } - pWriter->WriteAttribute (L"hidden", hidden); - if (title.IsInit()) pWriter->WriteAttribute (L"title", XmlUtils::EncodeXmlString(title.get())); - pWriter->WriteAttribute (L"form", form); - - pWriter->EndAttributes(); - - pWriter->Write(hlinkClick); - pWriter->Write(hlinkHover); - - pWriter->EndNode(strNS + L":cNvPr"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteInt1(0, id); - pWriter->WriteString1(1, name); - pWriter->WriteBool2(2, hidden); - pWriter->WriteString2(3, title); - pWriter->WriteString2(4, descr); - pWriter->WriteBool2(5, form); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, hlinkClick); - pWriter->WriteRecord2(1, hlinkHover); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - id = 1; - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - id = pReader->GetLong(); - }break; - case 1: - { - name = pReader->GetString2(); - }break; - case 2: - { - hidden = pReader->GetBool(); - }break; - case 3: - { - title = pReader->GetString2(); - }break; - case 4: - { - descr = pReader->GetString2(); - }break; - case 5: - { - form = pReader->GetBool(); - }break; - default: - break; - } - } - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - hlinkClick = new PPTX::Logic::Hyperlink(L"hlinkClick"); - hlinkClick->fromPPTY(pReader); - break; - } - case 1: - { - hlinkHover = new PPTX::Logic::Hyperlink(L"hlinkHover"); - hlinkHover->fromPPTY(pReader); - break; - } - default: - { - break; - } - } - } - - pReader->Seek(_end_rec); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); std::wstring m_namespace; @@ -328,14 +76,9 @@ namespace PPTX //std::vector extLst; nullable_string vmlSpid; + protected: - virtual void FillParentPointersForChilds() - { - if(hlinkClick.IsInit()) - hlinkClick->SetParentPointer(this); - if(hlinkHover.IsInit()) - hlinkHover->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); AVSINLINE void Normalize() { diff --git a/OOXML/PPTXFormat/Logic/CNvSpPr.cpp b/OOXML/PPTXFormat/Logic/CNvSpPr.cpp new file mode 100644 index 0000000000..b0687522c1 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/CNvSpPr.cpp @@ -0,0 +1,341 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "CNvSpPr.h" + +namespace PPTX +{ + namespace Logic + { + CNvSpPr::CNvSpPr(std::wstring ns) + { + m_namespace = ns; + } + CNvSpPr& CNvSpPr::operator=(const CNvSpPr& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + txBox = oSrc.txBox; + noAdjustHandles = oSrc.noAdjustHandles; + noChangeArrowheads = oSrc.noChangeArrowheads; + noChangeAspect = oSrc.noChangeAspect; + noChangeShapeType = oSrc.noChangeShapeType; + noEditPoints = oSrc.noEditPoints; + noGrp = oSrc.noGrp; + noMove = oSrc.noMove; + noResize = oSrc.noResize; + noRot = oSrc.noRot; + noSelect = oSrc.noSelect; + noTextEdit = oSrc.noTextEdit; + + return *this; + } + void CNvSpPr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + ReadAttributes(oReader); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring strName = oReader.GetName(); + + if (strName == L"a:spLocks") + { + ReadAttributesLocks(oReader); + } + } + } + void CNvSpPr::ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("noAdjustHandles"), noAdjustHandles) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noGrp"), noGrp) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noMove"), noMove) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noRot"), noRot) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noResize"), noResize) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noTextEdit"), noTextEdit) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noSelect"), noSelect) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeArrowheads"), noChangeArrowheads) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeShapeType"), noChangeShapeType) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeAspect"), noChangeAspect) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noEditPoints"), noEditPoints) + WritingElement_ReadAttributes_End( oReader ) + } + void CNvSpPr::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_ReadSingle( oReader, _T("txBox"), txBox) + WritingElement_ReadAttributes_End( oReader ) + } + void CNvSpPr::fromXML(XmlUtils::CXmlNode& node) + { + m_namespace = XmlUtils::GetNamespace(node.GetName()); + + XmlMacroReadAttributeBase(node, L"txBox", txBox); + + XmlUtils::CXmlNode l_Locks; + if (node.GetNode(_T("a:spLocks"), l_Locks)) + { + XmlMacroReadAttributeBase(l_Locks, L"noAdjustHandles", noAdjustHandles); + XmlMacroReadAttributeBase(l_Locks, L"noChangeArrowheads", noChangeArrowheads); + XmlMacroReadAttributeBase(l_Locks, L"noChangeAspect", noChangeAspect); + XmlMacroReadAttributeBase(l_Locks, L"noChangeShapeType", noChangeShapeType); + XmlMacroReadAttributeBase(l_Locks, L"noEditPoints", noEditPoints); + XmlMacroReadAttributeBase(l_Locks, L"noGrp", noGrp); + XmlMacroReadAttributeBase(l_Locks, L"noMove", noMove); + XmlMacroReadAttributeBase(l_Locks, L"noResize", noResize); + XmlMacroReadAttributeBase(l_Locks, L"noRot", noRot); + XmlMacroReadAttributeBase(l_Locks, L"noSelect", noSelect); + XmlMacroReadAttributeBase(l_Locks, L"noTextEdit", noTextEdit); + } + } + std::wstring CNvSpPr::toXML() const + { + XmlUtils::CAttribute oAttr1; + oAttr1.Write(_T("txBox"), txBox); + + XmlUtils::CAttribute oAttr2; + oAttr2.Write(_T("noAdjustHandles"), noAdjustHandles); + oAttr2.Write(_T("noChangeArrowheads"), noChangeArrowheads); + oAttr2.Write(_T("noChangeAspect"), noChangeAspect); + oAttr2.Write(_T("noChangeShapeType"), noChangeShapeType); + oAttr2.Write(_T("noEditPoints"), noEditPoints); + oAttr2.Write(_T("noGrp"), noGrp); + oAttr2.Write(_T("noMove"), noMove); + oAttr2.Write(_T("noResize"), noResize); + oAttr2.Write(_T("noRot"), noRot); + oAttr2.Write(_T("noSelect"), noSelect); + oAttr2.Write(_T("noTextEdit"), noTextEdit); + + if (_T("") == oAttr2.m_strValue) + return XmlUtils::CreateNode(m_namespace + L":cNvSpPr", oAttr1); + + return XmlUtils::CreateNode(m_namespace + L":cNvSpPr", oAttr1, XmlUtils::CreateNode(_T("a:spLocks"), oAttr2)); + } + void CNvSpPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring namespace_ = m_namespace; + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"wps"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; + + pWriter->StartNode(namespace_ + L":cNvSpPr"); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("txBox"), txBox); + pWriter->EndAttributes(); + + if (noAdjustHandles.is_init() || + noChangeArrowheads.is_init() || + noChangeAspect.is_init() || + noChangeShapeType.is_init() || + noEditPoints.is_init() || + noGrp.is_init() || + noMove.is_init() || + noResize.is_init() || + noRot.is_init() || + noSelect.is_init() || + noTextEdit.is_init()) + { + pWriter->StartNode(_T("a:spLocks")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("noAdjustHandles"), noAdjustHandles); + pWriter->WriteAttribute(_T("noChangeArrowheads"), noChangeArrowheads); + pWriter->WriteAttribute(_T("noChangeAspect"), noChangeAspect); + pWriter->WriteAttribute(_T("noChangeShapeType"), noChangeShapeType); + pWriter->WriteAttribute(_T("noEditPoints"), noEditPoints); + pWriter->WriteAttribute(_T("noGrp"), noGrp); + pWriter->WriteAttribute(_T("noMove"), noMove); + pWriter->WriteAttribute(_T("noResize"), noResize); + pWriter->WriteAttribute(_T("noRot"), noRot); + pWriter->WriteAttribute(_T("noSelect"), noSelect); + pWriter->WriteAttribute(_T("noTextEdit"), noTextEdit); + pWriter->EndAttributes(); + + pWriter->EndNode(_T("a:spLocks")); + } + + pWriter->EndNode(namespace_ + L":cNvSpPr"); + } + void CNvSpPr::toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(strNS + _T(":cNvSpPr")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("txBox"), txBox); + pWriter->EndAttributes(); + + if (noAdjustHandles.is_init() || + noChangeArrowheads.is_init() || + noChangeAspect.is_init() || + noChangeShapeType.is_init() || + noEditPoints.is_init() || + noGrp.is_init() || + noMove.is_init() || + noResize.is_init() || + noRot.is_init() || + noSelect.is_init() || + noTextEdit.is_init()) + { + pWriter->StartNode(_T("a:spLocks")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("noAdjustHandles"), noAdjustHandles); + pWriter->WriteAttribute(_T("noChangeArrowheads"), noChangeArrowheads); + pWriter->WriteAttribute(_T("noChangeAspect"), noChangeAspect); + pWriter->WriteAttribute(_T("noChangeShapeType"), noChangeShapeType); + pWriter->WriteAttribute(_T("noEditPoints"), noEditPoints); + pWriter->WriteAttribute(_T("noGrp"), noGrp); + pWriter->WriteAttribute(_T("noMove"), noMove); + pWriter->WriteAttribute(_T("noResize"), noResize); + pWriter->WriteAttribute(_T("noRot"), noRot); + pWriter->WriteAttribute(_T("noSelect"), noSelect); + pWriter->WriteAttribute(_T("noTextEdit"), noTextEdit); + pWriter->EndAttributes(); + + pWriter->EndNode(_T("a:spLocks")); + } + + pWriter->EndNode(strNS + _T(":cNvSpPr")); + } + void CNvSpPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteBool2(0, txBox); + pWriter->WriteBool2(1, noAdjustHandles); + pWriter->WriteBool2(2, noChangeArrowheads); + pWriter->WriteBool2(3, noChangeAspect); + pWriter->WriteBool2(4, noChangeShapeType); + pWriter->WriteBool2(5, noEditPoints); + pWriter->WriteBool2(6, noGrp); + pWriter->WriteBool2(7, noMove); + pWriter->WriteBool2(8, noResize); + pWriter->WriteBool2(9, noRot); + pWriter->WriteBool2(10, noSelect); + pWriter->WriteBool2(11, noTextEdit); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void CNvSpPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + txBox = pReader->GetBool(); + break; + } + case 1: + { + noAdjustHandles = pReader->GetBool(); + break; + } + case 2: + { + noChangeArrowheads = pReader->GetBool(); + break; + } + case 3: + { + noChangeAspect = pReader->GetBool(); + break; + } + case 4: + { + noChangeShapeType = pReader->GetBool(); + break; + } + case 5: + { + noEditPoints = pReader->GetBool(); + break; + } + case 6: + { + noGrp = pReader->GetBool(); + break; + } + case 7: + { + noMove = pReader->GetBool(); + break; + } + case 8: + { + noResize = pReader->GetBool(); + break; + } + case 9: + { + noRot = pReader->GetBool(); + break; + } + case 10: + { + noSelect = pReader->GetBool(); + break; + } + case 11: + { + noTextEdit = pReader->GetBool(); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void CNvSpPr::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/CNvSpPr.h b/OOXML/PPTXFormat/Logic/CNvSpPr.h index 2ba4aad32d..ce396a1f87 100644 --- a/OOXML/PPTXFormat/Logic/CNvSpPr.h +++ b/OOXML/PPTXFormat/Logic/CNvSpPr.h @@ -44,309 +44,22 @@ namespace PPTX public: WritingElement_AdditionConstructors(CNvSpPr) - CNvSpPr(std::wstring ns = L"p") - { - m_namespace = ns; - } + CNvSpPr(std::wstring ns = L"p"); + CNvSpPr& operator=(const CNvSpPr& oSrc); - CNvSpPr& operator=(const CNvSpPr& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - txBox = oSrc.txBox; - noAdjustHandles = oSrc.noAdjustHandles; - noChangeArrowheads = oSrc.noChangeArrowheads; - noChangeAspect = oSrc.noChangeAspect; - noChangeShapeType = oSrc.noChangeShapeType; - noEditPoints = oSrc.noEditPoints; - noGrp = oSrc.noGrp; - noMove = oSrc.noMove; - noResize = oSrc.noResize; - noRot = oSrc.noRot; - noSelect = oSrc.noSelect; - noTextEdit = oSrc.noTextEdit; + void ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - return *this; - } + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); - - ReadAttributes(oReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + void toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const; - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring strName = oReader.GetName(); - - if (strName == L"a:spLocks") - { - ReadAttributesLocks(oReader); - } - } - } - void ReadAttributesLocks(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("noAdjustHandles"), noAdjustHandles) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noGrp"), noGrp) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noMove"), noMove) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noRot"), noRot) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noResize"), noResize) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noTextEdit"), noTextEdit) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noSelect"), noSelect) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeArrowheads"), noChangeArrowheads) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeShapeType"), noChangeShapeType) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noChangeAspect"), noChangeAspect) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("noEditPoints"), noEditPoints) - WritingElement_ReadAttributes_End( oReader ) - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_ReadSingle( oReader, _T("txBox"), txBox) - WritingElement_ReadAttributes_End( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_namespace = XmlUtils::GetNamespace(node.GetName()); - - XmlMacroReadAttributeBase(node, L"txBox", txBox); - - XmlUtils::CXmlNode l_Locks; - if (node.GetNode(_T("a:spLocks"), l_Locks)) - { - XmlMacroReadAttributeBase(l_Locks, L"noAdjustHandles", noAdjustHandles); - XmlMacroReadAttributeBase(l_Locks, L"noChangeArrowheads", noChangeArrowheads); - XmlMacroReadAttributeBase(l_Locks, L"noChangeAspect", noChangeAspect); - XmlMacroReadAttributeBase(l_Locks, L"noChangeShapeType", noChangeShapeType); - XmlMacroReadAttributeBase(l_Locks, L"noEditPoints", noEditPoints); - XmlMacroReadAttributeBase(l_Locks, L"noGrp", noGrp); - XmlMacroReadAttributeBase(l_Locks, L"noMove", noMove); - XmlMacroReadAttributeBase(l_Locks, L"noResize", noResize); - XmlMacroReadAttributeBase(l_Locks, L"noRot", noRot); - XmlMacroReadAttributeBase(l_Locks, L"noSelect", noSelect); - XmlMacroReadAttributeBase(l_Locks, L"noTextEdit", noTextEdit); - } - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr1; - oAttr1.Write(_T("txBox"), txBox); - - XmlUtils::CAttribute oAttr2; - oAttr2.Write(_T("noAdjustHandles"), noAdjustHandles); - oAttr2.Write(_T("noChangeArrowheads"), noChangeArrowheads); - oAttr2.Write(_T("noChangeAspect"), noChangeAspect); - oAttr2.Write(_T("noChangeShapeType"), noChangeShapeType); - oAttr2.Write(_T("noEditPoints"), noEditPoints); - oAttr2.Write(_T("noGrp"), noGrp); - oAttr2.Write(_T("noMove"), noMove); - oAttr2.Write(_T("noResize"), noResize); - oAttr2.Write(_T("noRot"), noRot); - oAttr2.Write(_T("noSelect"), noSelect); - oAttr2.Write(_T("noTextEdit"), noTextEdit); - - if (_T("") == oAttr2.m_strValue) - return XmlUtils::CreateNode(m_namespace + L":cNvSpPr", oAttr1); - - return XmlUtils::CreateNode(m_namespace + L":cNvSpPr", oAttr1, XmlUtils::CreateNode(_T("a:spLocks"), oAttr2)); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring namespace_ = m_namespace; - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"wps"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; - - pWriter->StartNode(namespace_ + L":cNvSpPr"); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("txBox"), txBox); - pWriter->EndAttributes(); - - if (noAdjustHandles.is_init() || - noChangeArrowheads.is_init() || - noChangeAspect.is_init() || - noChangeShapeType.is_init() || - noEditPoints.is_init() || - noGrp.is_init() || - noMove.is_init() || - noResize.is_init() || - noRot.is_init() || - noSelect.is_init() || - noTextEdit.is_init()) - { - pWriter->StartNode(_T("a:spLocks")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("noAdjustHandles"), noAdjustHandles); - pWriter->WriteAttribute(_T("noChangeArrowheads"), noChangeArrowheads); - pWriter->WriteAttribute(_T("noChangeAspect"), noChangeAspect); - pWriter->WriteAttribute(_T("noChangeShapeType"), noChangeShapeType); - pWriter->WriteAttribute(_T("noEditPoints"), noEditPoints); - pWriter->WriteAttribute(_T("noGrp"), noGrp); - pWriter->WriteAttribute(_T("noMove"), noMove); - pWriter->WriteAttribute(_T("noResize"), noResize); - pWriter->WriteAttribute(_T("noRot"), noRot); - pWriter->WriteAttribute(_T("noSelect"), noSelect); - pWriter->WriteAttribute(_T("noTextEdit"), noTextEdit); - pWriter->EndAttributes(); - - pWriter->EndNode(_T("a:spLocks")); - } - - pWriter->EndNode(namespace_ + L":cNvSpPr"); - } - - void toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(strNS + _T(":cNvSpPr")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("txBox"), txBox); - pWriter->EndAttributes(); - - if (noAdjustHandles.is_init() || - noChangeArrowheads.is_init() || - noChangeAspect.is_init() || - noChangeShapeType.is_init() || - noEditPoints.is_init() || - noGrp.is_init() || - noMove.is_init() || - noResize.is_init() || - noRot.is_init() || - noSelect.is_init() || - noTextEdit.is_init()) - { - pWriter->StartNode(_T("a:spLocks")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("noAdjustHandles"), noAdjustHandles); - pWriter->WriteAttribute(_T("noChangeArrowheads"), noChangeArrowheads); - pWriter->WriteAttribute(_T("noChangeAspect"), noChangeAspect); - pWriter->WriteAttribute(_T("noChangeShapeType"), noChangeShapeType); - pWriter->WriteAttribute(_T("noEditPoints"), noEditPoints); - pWriter->WriteAttribute(_T("noGrp"), noGrp); - pWriter->WriteAttribute(_T("noMove"), noMove); - pWriter->WriteAttribute(_T("noResize"), noResize); - pWriter->WriteAttribute(_T("noRot"), noRot); - pWriter->WriteAttribute(_T("noSelect"), noSelect); - pWriter->WriteAttribute(_T("noTextEdit"), noTextEdit); - pWriter->EndAttributes(); - - pWriter->EndNode(_T("a:spLocks")); - } - - pWriter->EndNode(strNS + _T(":cNvSpPr")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteBool2(0, txBox); - pWriter->WriteBool2(1, noAdjustHandles); - pWriter->WriteBool2(2, noChangeArrowheads); - pWriter->WriteBool2(3, noChangeAspect); - pWriter->WriteBool2(4, noChangeShapeType); - pWriter->WriteBool2(5, noEditPoints); - pWriter->WriteBool2(6, noGrp); - pWriter->WriteBool2(7, noMove); - pWriter->WriteBool2(8, noResize); - pWriter->WriteBool2(9, noRot); - pWriter->WriteBool2(10, noSelect); - pWriter->WriteBool2(11, noTextEdit); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - txBox = pReader->GetBool(); - break; - } - case 1: - { - noAdjustHandles = pReader->GetBool(); - break; - } - case 2: - { - noChangeArrowheads = pReader->GetBool(); - break; - } - case 3: - { - noChangeAspect = pReader->GetBool(); - break; - } - case 4: - { - noChangeShapeType = pReader->GetBool(); - break; - } - case 5: - { - noEditPoints = pReader->GetBool(); - break; - } - case 6: - { - noGrp = pReader->GetBool(); - break; - } - case 7: - { - noMove = pReader->GetBool(); - break; - } - case 8: - { - noResize = pReader->GetBool(); - break; - } - case 9: - { - noRot = pReader->GetBool(); - break; - } - case 10: - { - noSelect = pReader->GetBool(); - break; - } - case 11: - { - noTextEdit = pReader->GetBool(); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); std::wstring m_namespace; @@ -362,8 +75,9 @@ namespace PPTX nullable_bool noRot; nullable_bool noSelect; nullable_bool noTextEdit; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/CSld.cpp b/OOXML/PPTXFormat/Logic/CSld.cpp new file mode 100644 index 0000000000..1dc439ad1c --- /dev/null +++ b/OOXML/PPTXFormat/Logic/CSld.cpp @@ -0,0 +1,163 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "CSld.h" + +namespace PPTX +{ + namespace Logic + { + CSld::CSld(OOX::Document *pMain) : WrapperWritingElement(pMain), spTree(L"p") + { + } + void CSld::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + } + void CSld::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"name", attrName); + + bg = node.ReadNode(L"p:bg"); + spTree = node.ReadNodeNoNS(L"spTree"); + controls = node.ReadNode(L"p:controls"); + + FillParentPointersForChilds(); + } + std::wstring CSld::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(L"name", attrName); + + XmlUtils::CNodeValue oValue; + oValue.WriteNullable(bg); + oValue.Write(spTree); + oValue.WriteNullable(controls); + + return XmlUtils::CreateNode(L"p:cSld", oAttr, oValue); + } + void CSld::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(L"p:cSld"); + + pWriter->StartAttributes(); + pWriter->WriteAttribute2(L"name", attrName); + pWriter->EndAttributes(); + + pWriter->Write(bg); + spTree.toXmlWriter(pWriter); + pWriter->Write(controls); + + pWriter->EndNode(L"p:cSld"); + } + void CSld::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteString2(0, attrName); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, bg); + + pWriter->StartRecord(1); + pWriter->StartRecord(SPTREE_TYPE_SPTREE); + pWriter->WriteRecord1(0, spTree.nvGrpSpPr); + pWriter->WriteRecord1(1, spTree.grpSpPr); + + pWriter->StartRecord(2); + pWriter->WriteULONG((_UINT32)spTree.SpTreeElems.size()); + for (size_t i = 0; i < spTree.SpTreeElems.size(); i++) + { + pWriter->WriteRecord1(0, spTree.SpTreeElems[i]); + } + pWriter->EndRecord(); + pWriter->EndRecord(); + pWriter->EndRecord(); + + pWriter->WriteRecord2(2, controls); + } + void CSld::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) + attrName = pReader->GetString2(); + else + break; + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + bg = new Bg(); + bg->fromPPTY(pReader); + break; + } + case 1: + { + spTree.fromPPTY(pReader); + break; + } + case 2: + { + controls = new Controls(m_pMainDocument); + controls->fromPPTY(pReader); + break; + } + default: + { + pReader->Seek(_end_rec); + return; + } + } + } + + pReader->Seek(_end_rec); + } + void CSld::FillParentPointersForChilds() + { + spTree.SetParentPointer(this); + if(bg.IsInit()) bg->SetParentPointer(this); + if(controls.IsInit()) controls->SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/CSld.h b/OOXML/PPTXFormat/Logic/CSld.h index afbc92e43b..19ca4d98d2 100644 --- a/OOXML/PPTXFormat/Logic/CSld.h +++ b/OOXML/PPTXFormat/Logic/CSld.h @@ -47,126 +47,16 @@ namespace PPTX public: WritingElement_AdditionConstructors(CSld) - CSld(OOX::Document *pMain = NULL) : WrapperWritingElement(pMain), spTree(L"p") - { - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"name", attrName); - - bg = node.ReadNode(L"p:bg"); - spTree = node.ReadNodeNoNS(L"spTree"); - controls = node.ReadNode(L"p:controls"); - - FillParentPointersForChilds(); - } + CSld(OOX::Document *pMain = NULL); - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(L"name", attrName); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - XmlUtils::CNodeValue oValue; - oValue.WriteNullable(bg); - oValue.Write(spTree); - oValue.WriteNullable(controls); + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - return XmlUtils::CreateNode(L"p:cSld", oAttr, oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(L"p:cSld"); - - pWriter->StartAttributes(); - pWriter->WriteAttribute2(L"name", attrName); - pWriter->EndAttributes(); - - pWriter->Write(bg); - spTree.toXmlWriter(pWriter); - pWriter->Write(controls); - - pWriter->EndNode(L"p:cSld"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteString2(0, attrName); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, bg); - - pWriter->StartRecord(1); - pWriter->StartRecord(SPTREE_TYPE_SPTREE); - pWriter->WriteRecord1(0, spTree.nvGrpSpPr); - pWriter->WriteRecord1(1, spTree.grpSpPr); - - pWriter->StartRecord(2); - pWriter->WriteULONG((_UINT32)spTree.SpTreeElems.size()); - for (size_t i = 0; i < spTree.SpTreeElems.size(); i++) - { - pWriter->WriteRecord1(0, spTree.SpTreeElems[i]); - } - pWriter->EndRecord(); - pWriter->EndRecord(); - pWriter->EndRecord(); - - pWriter->WriteRecord2(2, controls); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) - attrName = pReader->GetString2(); - else - break; - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - bg = new Bg(); - bg->fromPPTY(pReader); - break; - } - case 1: - { - spTree.fromPPTY(pReader); - break; - } - case 2: - { - controls = new Controls(m_pMainDocument); - controls->fromPPTY(pReader); - break; - } - default: - { - pReader->Seek(_end_rec); - return; - } - } - } - - pReader->Seek(_end_rec); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); nullable_string attrName; @@ -175,13 +65,9 @@ namespace PPTX nullable controls; //custDataLst //controls + protected: - virtual void FillParentPointersForChilds() - { - spTree.SetParentPointer(this); - if(bg.IsInit()) bg->SetParentPointer(this); - if(controls.IsInit()) controls->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Camera.cpp b/OOXML/PPTXFormat/Logic/Camera.cpp new file mode 100644 index 0000000000..27713421e3 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Camera.cpp @@ -0,0 +1,170 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Camera.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType Camera::getType() const + { + return OOX::et_a_camera; + } + void Camera::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + std::wstring strName = oReader.GetName(); + + if (strName == L"a:rot") + { + rot = oReader; + break; + } + } + FillParentPointersForChilds(); + } + void Camera::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start_No_NS( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("prst"), prst) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("fov"), fov) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("zoom"), zoom) + WritingElement_ReadAttributes_End_No_NS( oReader ) + } + void Camera::fromXML(XmlUtils::CXmlNode& node) + { + prst = node.GetAttribute(_T("prst")); + XmlMacroReadAttributeBase(node, L"fov", fov); + XmlMacroReadAttributeBase(node, L"zoom", zoom); + + std::wstring sRotNodeName = _T("a:rot"); + rot = node.ReadNode(sRotNodeName); + FillParentPointersForChilds(); + } + std::wstring Camera::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("prst"), prst.get()); + oAttr.Write(_T("fov"), fov); + oAttr.Write(_T("zoom"), zoom); + + XmlUtils::CNodeValue oValue; + oValue.WriteNullable(rot); + + return XmlUtils::CreateNode(_T("a:camera"), oAttr, oValue); + } + void Camera::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring sNodeNamespace; + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + sNodeNamespace = L"w14:"; + sAttrNamespace = sNodeNamespace; + } + else + sNodeNamespace = L"a:"; + + pWriter->StartNode(sNodeNamespace + L"camera"); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + L"prst", prst.get()); + pWriter->WriteAttribute(sAttrNamespace + L"fov", fov); + pWriter->WriteAttribute(sAttrNamespace + L"zoom", zoom); + pWriter->EndAttributes(); + + pWriter->Write(rot); + + pWriter->EndNode(sNodeNamespace + L"camera"); + } + void Camera::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit1(0, prst); + pWriter->WriteInt2(1, fov); + pWriter->WriteInt2(2, zoom); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, rot); + } + void Camera::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) prst.SetBYTECode(pReader->GetUChar()); + else if (1 == _at) fov = pReader->GetLong(); + else if (2 == _at) zoom = pReader->GetLong(); + else + break; + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + rot = new Logic::Rot(); + rot->fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void Camera::FillParentPointersForChilds() + { + if(rot.IsInit()) + rot->SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Camera.h b/OOXML/PPTXFormat/Logic/Camera.h index cc13207efa..e21e36eb84 100644 --- a/OOXML/PPTXFormat/Logic/Camera.h +++ b/OOXML/PPTXFormat/Logic/Camera.h @@ -41,152 +41,33 @@ namespace PPTX { namespace Logic { - class Camera : public WrapperWritingElement { public: WritingElement_AdditionConstructors(Camera) PPTX_LOGIC_BASE2(Camera) - virtual OOX::EElementType getType() const - { - return OOX::et_a_camera; - } - void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); + virtual OOX::EElementType getType() const; - if ( oReader.IsEmptyNode() ) - return; + void fromXML(XmlUtils::CXmlLiteReader& oReader); - int nCurDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - std::wstring strName = oReader.GetName(); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - if (strName == L"a:rot") - { - rot = oReader; - break; - } - } - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("prst"), prst) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("fov"), fov) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("zoom"), zoom) - WritingElement_ReadAttributes_End_No_NS( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - prst = node.GetAttribute(_T("prst")); - XmlMacroReadAttributeBase(node, L"fov", fov); - XmlMacroReadAttributeBase(node, L"zoom", zoom); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - std::wstring sRotNodeName = _T("a:rot"); - rot = node.ReadNode(sRotNodeName); - FillParentPointersForChilds(); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("prst"), prst.get()); - oAttr.Write(_T("fov"), fov); - oAttr.Write(_T("zoom"), zoom); - - XmlUtils::CNodeValue oValue; - oValue.WriteNullable(rot); - - return XmlUtils::CreateNode(_T("a:camera"), oAttr, oValue); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring sNodeNamespace; - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - sNodeNamespace = L"w14:"; - sAttrNamespace = sNodeNamespace; - } - else - sNodeNamespace = L"a:"; - - pWriter->StartNode(sNodeNamespace + L"camera"); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + L"prst", prst.get()); - pWriter->WriteAttribute(sAttrNamespace + L"fov", fov); - pWriter->WriteAttribute(sAttrNamespace + L"zoom", zoom); - pWriter->EndAttributes(); - - pWriter->Write(rot); - - pWriter->EndNode(sNodeNamespace + L"camera"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit1(0, prst); - pWriter->WriteInt2(1, fov); - pWriter->WriteInt2(2, zoom); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, rot); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) prst.SetBYTECode(pReader->GetUChar()); - else if (1 == _at) fov = pReader->GetLong(); - else if (2 == _at) zoom = pReader->GetLong(); - else - break; - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - rot = new Logic::Rot(); - rot->fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } - nullable rot; Limit::CameraType prst; nullable_int fov; nullable_int zoom; + protected: - virtual void FillParentPointersForChilds() - { - if(rot.IsInit()) - rot->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); AVSINLINE void Normalize() { diff --git a/OOXML/PPTXFormat/Logic/Cell3D.cpp b/OOXML/PPTXFormat/Logic/Cell3D.cpp new file mode 100644 index 0000000000..6e77051f17 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Cell3D.cpp @@ -0,0 +1,104 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Cell3D.h" + +namespace PPTX +{ + namespace Logic + { + Cell3D::Cell3D() + { + } + void Cell3D::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (_T("bevel") == strName) + bevel = oReader; + else if (_T("lightRig") == strName) + lightRig = oReader; + } + FillParentPointersForChilds(); + } + void Cell3D::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start ( oReader ) + WritingElement_ReadAttributes_ReadSingle ( oReader, _T("prstMaterial"), prstMaterial ) + WritingElement_ReadAttributes_End ( oReader ) + } + void Cell3D::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"prstMaterial", prstMaterial); + + bevel = node.ReadNodeNoNS(_T("bevel")); + lightRig = node.ReadNodeNoNS(_T("lightRig")); + + FillParentPointersForChilds(); + } + std::wstring Cell3D::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.WriteLimitNullable(_T("prstMaterial"), prstMaterial); + + XmlUtils::CNodeValue oValue; + oValue.WriteNullable(bevel); + oValue.WriteNullable(lightRig); + + return XmlUtils::CreateNode(_T("a:cell3D"), oAttr, oValue); + } + void Cell3D::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + // TODO: + } + void Cell3D::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + // TODO: + } + void Cell3D::FillParentPointersForChilds() + { + if(bevel.IsInit()) + bevel->SetParentPointer(this); + if(lightRig.IsInit()) + lightRig->SetParentPointer(this); + } + + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Cell3D.h b/OOXML/PPTXFormat/Logic/Cell3D.h index 459572a90e..d80d57a310 100644 --- a/OOXML/PPTXFormat/Logic/Cell3D.h +++ b/OOXML/PPTXFormat/Logic/Cell3D.h @@ -47,79 +47,26 @@ namespace PPTX public: WritingElement_AdditionConstructors(Cell3D) - Cell3D() - { - } + Cell3D(); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - if (_T("bevel") == strName) - bevel = oReader; - else if (_T("lightRig") == strName) - lightRig = oReader; - } - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start ( oReader ) - WritingElement_ReadAttributes_ReadSingle ( oReader, _T("prstMaterial"), prstMaterial ) - WritingElement_ReadAttributes_End ( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"prstMaterial", prstMaterial); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - bevel = node.ReadNodeNoNS(_T("bevel")); - lightRig = node.ReadNodeNoNS(_T("lightRig")); - - FillParentPointersForChilds(); - } - - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.WriteLimitNullable(_T("prstMaterial"), prstMaterial); - - XmlUtils::CNodeValue oValue; - oValue.WriteNullable(bevel); - oValue.WriteNullable(lightRig); - - return XmlUtils::CreateNode(_T("a:cell3D"), oAttr, oValue); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - // TODO: - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - // TODO: - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; public: nullable_limit prstMaterial; nullable bevel; nullable lightRig; + protected: - virtual void FillParentPointersForChilds() - { - if(bevel.IsInit()) - bevel->SetParentPointer(this); - if(lightRig.IsInit()) - lightRig->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/ClrMap.cpp b/OOXML/PPTXFormat/Logic/ClrMap.cpp new file mode 100644 index 0000000000..41150fb559 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/ClrMap.cpp @@ -0,0 +1,290 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "ClrMap.h" + +namespace PPTX +{ + namespace Logic + { + ClrMap::ClrMap(std::wstring name) + { + m_name = name; + SetMap(); + } + OOX::EElementType ClrMap::getType() const + { + return OOX::et_a_clrMap; + } + ClrMap& ClrMap::operator=(const ClrMap& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + m_name = oSrc.m_name; + + m_arColorMap = oSrc.m_arColorMap; + + return *this; + } + void ClrMap::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_name = oReader.GetName(); + SetMap(); + + m_arColorMap.clear(); + + ReadAttributes(oReader); + } + void ClrMap::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + Limit::ColorSchemeIndex lColorIndex_accent1; + Limit::ColorSchemeIndex lColorIndex_accent2; + Limit::ColorSchemeIndex lColorIndex_accent3; + Limit::ColorSchemeIndex lColorIndex_accent4; + Limit::ColorSchemeIndex lColorIndex_accent5; + Limit::ColorSchemeIndex lColorIndex_accent6; + Limit::ColorSchemeIndex lColorIndex_bg1; + Limit::ColorSchemeIndex lColorIndex_bg2; + Limit::ColorSchemeIndex lColorIndex_tx1; + Limit::ColorSchemeIndex lColorIndex_tx2; + Limit::ColorSchemeIndex lColorIndex_folHlink; + Limit::ColorSchemeIndex lColorIndex_hlink; + + WritingElement_ReadAttributes_Start_No_NS( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, L"accent1", lColorIndex_accent1) + WritingElement_ReadAttributes_Read_else_if( oReader, L"accent2", lColorIndex_accent2 ) + WritingElement_ReadAttributes_Read_else_if( oReader, L"accent3", lColorIndex_accent3 ) + WritingElement_ReadAttributes_Read_else_if( oReader, L"accent4", lColorIndex_accent4 ) + WritingElement_ReadAttributes_Read_else_if( oReader, L"accent5", lColorIndex_accent5 ) + WritingElement_ReadAttributes_Read_else_if( oReader, L"accent6", lColorIndex_accent6 ) + WritingElement_ReadAttributes_Read_else_if( oReader, L"bg1", lColorIndex_bg1 ) + WritingElement_ReadAttributes_Read_else_if( oReader, L"bg2", lColorIndex_bg2 ) + WritingElement_ReadAttributes_Read_else_if( oReader, L"tx1", lColorIndex_tx1 ) + WritingElement_ReadAttributes_Read_else_if( oReader, L"tx2", lColorIndex_tx2 ) + WritingElement_ReadAttributes_Read_else_if( oReader, L"folHlink", lColorIndex_folHlink ) + WritingElement_ReadAttributes_Read_else_if( oReader, L"hlink", lColorIndex_hlink ) + + WritingElement_ReadAttributes_Read_else_if( oReader, L"t1", lColorIndex_tx1 ) + WritingElement_ReadAttributes_Read_else_if( oReader, L"t2", lColorIndex_tx2 ) + WritingElement_ReadAttributes_Read_else_if( oReader, L"followedHyperlink", lColorIndex_folHlink ) + WritingElement_ReadAttributes_Read_else_if( oReader, L"hyperlink", lColorIndex_hlink ) + WritingElement_ReadAttributes_End_No_NS( oReader ) + + m_arColorMap.push_back(std::make_pair(L"bg1", lColorIndex_bg1)); + m_arColorMap.push_back(std::make_pair(L"tx1", lColorIndex_tx1)); + m_arColorMap.push_back(std::make_pair(L"bg2", lColorIndex_bg2)); + m_arColorMap.push_back(std::make_pair(L"tx2", lColorIndex_tx2)); + m_arColorMap.push_back(std::make_pair(L"accent1", lColorIndex_accent1)); + m_arColorMap.push_back(std::make_pair(L"accent2", lColorIndex_accent2)); + m_arColorMap.push_back(std::make_pair(L"accent3", lColorIndex_accent3)); + m_arColorMap.push_back(std::make_pair(L"accent4", lColorIndex_accent4)); + m_arColorMap.push_back(std::make_pair(L"accent5", lColorIndex_accent5)); + m_arColorMap.push_back(std::make_pair(L"accent6", lColorIndex_accent6)); + m_arColorMap.push_back(std::make_pair(L"folHlink", lColorIndex_folHlink)); + m_arColorMap.push_back(std::make_pair(L"hlink", lColorIndex_hlink)); + } + void ClrMap::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + SetMap(); + + m_arColorMap.clear(); + + Limit::ColorSchemeIndex lColorIndex; + + if (m_name == L"w:clrSchemeMapping") + { + lColorIndex._set(node.GetAttribute(L"w:bg1")); m_arColorMap.push_back(std::make_pair(L"bg1", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"w:t1")); m_arColorMap.push_back(std::make_pair(L"tx1", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"w:bg2")); m_arColorMap.push_back(std::make_pair(L"bg2", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"w:t2")); m_arColorMap.push_back(std::make_pair(L"tx2", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"w:accent1")); m_arColorMap.push_back(std::make_pair(L"accent1", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"w:accent2")); m_arColorMap.push_back(std::make_pair(L"accent2", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"w:accent3")); m_arColorMap.push_back(std::make_pair(L"accent3", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"w:accent4")); m_arColorMap.push_back(std::make_pair(L"accent4", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"w:accent5")); m_arColorMap.push_back(std::make_pair(L"accent5", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"w:accent6")); m_arColorMap.push_back(std::make_pair(L"accent6", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"w:hyperlink")); m_arColorMap.push_back(std::make_pair(L"hlink", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"w:followedHyperlink"));m_arColorMap.push_back(std::make_pair(L"folHlink", lColorIndex)); + } + else + { + lColorIndex._set(node.GetAttribute(L"bg1")); m_arColorMap.push_back(std::make_pair(L"bg1", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"tx1")); m_arColorMap.push_back(std::make_pair(L"tx1", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"bg2")); m_arColorMap.push_back(std::make_pair(L"bg2", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"tx2")); m_arColorMap.push_back(std::make_pair(L"tx2", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"accent1")); m_arColorMap.push_back(std::make_pair(L"accent1", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"accent2")); m_arColorMap.push_back(std::make_pair(L"accent2", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"accent3")); m_arColorMap.push_back(std::make_pair(L"accent3", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"accent4")); m_arColorMap.push_back(std::make_pair(L"accent4", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"accent5")); m_arColorMap.push_back(std::make_pair(L"accent5", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"accent6")); m_arColorMap.push_back(std::make_pair(L"accent6", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"hlink")); m_arColorMap.push_back(std::make_pair(L"hlink", lColorIndex)); + lColorIndex._set(node.GetAttribute(L"folHlink")); m_arColorMap.push_back(std::make_pair(L"folHlink", lColorIndex)); + } + } + std::wstring ClrMap::toXML() const + { + XmlUtils::CAttribute oAttr; + + if (m_name == L"w:clrSchemeMapping") + { + for (size_t i = 0; i < m_arColorMap.size(); ++i) + { + std::wstring att_name, att_val; + + if (m_arColorMap[i].first == L"tx1") att_name = L"w:t1"; + else if (m_arColorMap[i].first == L"tx2") att_name = L"w:t2"; + else if (m_arColorMap[i].first == L"hlink") att_name = L"w:hyperlink"; + else if (m_arColorMap[i].first == L"folHlink") att_name = L"w:followedHyperlink"; + else att_name = L"w:" + m_arColorMap[i].first; + + if (m_arColorMap[i].second.get() == L"lt1") att_val = L"light1"; + else if (m_arColorMap[i].second.get() == L"lt2") att_val = L"light2"; + else if (m_arColorMap[i].second.get() == L"dk1") att_val = L"dark1"; + else if (m_arColorMap[i].second.get() == L"dk2") att_val = L"dark2"; + else if (m_arColorMap[i].second.get() == L"hlink") att_val = L"hyperlink"; + else if (m_arColorMap[i].second.get() == L"folHlink")att_val = L"followedHyperlink"; + else att_val = m_arColorMap[i].second.get(); + + oAttr.Write(att_name, att_val); + } + } + else + { + for (size_t i = 0; i < m_arColorMap.size(); ++i) + { + oAttr.Write(m_arColorMap[i].first, m_arColorMap[i].second.get()); + } + } + + return XmlUtils::CreateNode(m_name, oAttr); + } + void ClrMap::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + + pWriter->StartAttributes(); + for (size_t i = 0; i < m_arColorMap.size(); ++i) + { + pWriter->WriteAttribute(m_arColorMap[i].first, m_arColorMap[i].second.get()); + } + pWriter->EndAttributes(); + + pWriter->EndNode(m_name); + } + std::wstring ClrMap::GetColorSchemeIndex(const std::wstring& str)const + { + std::map::const_iterator pPair = m_mapColorMap.find(str); + if (m_mapColorMap.end() != pPair) + { + return m_arColorMap[pPair->second].second.get(); + } + return L""; + } + void ClrMap::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + + for (size_t i = 0; i < m_arColorMap.size(); ++i) + { + pWriter->WriteLimit1(SchemeClr_GetBYTECode(m_arColorMap[i].first), m_arColorMap[i].second); + } + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void ClrMap::Insert(const std::wstring& prop, const Limit::ColorSchemeIndex& val) + { + std::map::iterator pPair = m_mapColorMap.find(prop); + + if (m_mapColorMap.end() != pPair) + { + if (pPair->second >= (int)m_arColorMap.size()) + m_arColorMap.resize(12); + m_arColorMap[pPair->second] = std::make_pair(prop, val); + } + } + bool ClrMap::Find(const std::wstring& prop, Limit::ColorSchemeIndex& val) const + { + std::map::const_iterator pPair = m_mapColorMap.find(prop); + if (m_mapColorMap.end() != pPair) + { + val = m_arColorMap[pPair->second].second; + return true; + } + else + { + return false; + } + } + void ClrMap::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start sttribute + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + BYTE ind = pReader->GetUChar(); + Limit::ColorSchemeIndex _index; + _index.SetBYTECode(ind); + + Insert(SchemeClr_GetStringCode(_at), _index); + } + + pReader->Seek(_e); + } + void ClrMap::FillParentPointersForChilds(){}; + void ClrMap::SetMap() + { + if (false == m_mapColorMap.empty()) return; + + m_mapColorMap.insert(std::make_pair(L"bg1", 0)); + m_mapColorMap.insert(std::make_pair(L"tx1", 1)); + m_mapColorMap.insert(std::make_pair(L"bg2", 2)); + m_mapColorMap.insert(std::make_pair(L"tx2", 3)); + m_mapColorMap.insert(std::make_pair(L"accent1", 4)); + m_mapColorMap.insert(std::make_pair(L"accent2", 5)); + m_mapColorMap.insert(std::make_pair(L"accent3", 6)); + m_mapColorMap.insert(std::make_pair(L"accent4", 7)); + m_mapColorMap.insert(std::make_pair(L"accent5", 8)); + m_mapColorMap.insert(std::make_pair(L"accent6", 9)); + m_mapColorMap.insert(std::make_pair(L"hlink", 10)); + m_mapColorMap.insert(std::make_pair(L"folHlink", 11)); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/ClrMap.h b/OOXML/PPTXFormat/Logic/ClrMap.h index 203459bd92..f346beb756 100644 --- a/OOXML/PPTXFormat/Logic/ClrMap.h +++ b/OOXML/PPTXFormat/Logic/ClrMap.h @@ -43,268 +43,39 @@ namespace PPTX public: WritingElement_AdditionConstructors(ClrMap) - ClrMap(std::wstring name = L"p:clrMap") - { - m_name = name; - SetMap(); - } + ClrMap(std::wstring name = L"p:clrMap"); - virtual OOX::EElementType getType() const - { - return OOX::et_a_clrMap; - } - ClrMap& operator=(const ClrMap& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + virtual OOX::EElementType getType() const; + ClrMap& operator=(const ClrMap& oSrc); - m_name = oSrc.m_name; - - m_arColorMap = oSrc.m_arColorMap; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - return *this; - } + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = oReader.GetName(); - SetMap(); + virtual void fromXML(XmlUtils::CXmlNode& node); - m_arColorMap.clear(); + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - ReadAttributes(oReader); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - Limit::ColorSchemeIndex lColorIndex_accent1; - Limit::ColorSchemeIndex lColorIndex_accent2; - Limit::ColorSchemeIndex lColorIndex_accent3; - Limit::ColorSchemeIndex lColorIndex_accent4; - Limit::ColorSchemeIndex lColorIndex_accent5; - Limit::ColorSchemeIndex lColorIndex_accent6; - Limit::ColorSchemeIndex lColorIndex_bg1; - Limit::ColorSchemeIndex lColorIndex_bg2; - Limit::ColorSchemeIndex lColorIndex_tx1; - Limit::ColorSchemeIndex lColorIndex_tx2; - Limit::ColorSchemeIndex lColorIndex_folHlink; - Limit::ColorSchemeIndex lColorIndex_hlink; - - WritingElement_ReadAttributes_Start_No_NS( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, L"accent1", lColorIndex_accent1) - WritingElement_ReadAttributes_Read_else_if( oReader, L"accent2", lColorIndex_accent2 ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"accent3", lColorIndex_accent3 ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"accent4", lColorIndex_accent4 ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"accent5", lColorIndex_accent5 ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"accent6", lColorIndex_accent6 ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"bg1", lColorIndex_bg1 ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"bg2", lColorIndex_bg2 ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"tx1", lColorIndex_tx1 ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"tx2", lColorIndex_tx2 ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"folHlink", lColorIndex_folHlink ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"hlink", lColorIndex_hlink ) - - WritingElement_ReadAttributes_Read_else_if( oReader, L"t1", lColorIndex_tx1 ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"t2", lColorIndex_tx2 ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"followedHyperlink", lColorIndex_folHlink ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"hyperlink", lColorIndex_hlink ) - WritingElement_ReadAttributes_End_No_NS( oReader ) - - m_arColorMap.push_back(std::make_pair(L"bg1", lColorIndex_bg1)); - m_arColorMap.push_back(std::make_pair(L"tx1", lColorIndex_tx1)); - m_arColorMap.push_back(std::make_pair(L"bg2", lColorIndex_bg2)); - m_arColorMap.push_back(std::make_pair(L"tx2", lColorIndex_tx2)); - m_arColorMap.push_back(std::make_pair(L"accent1", lColorIndex_accent1)); - m_arColorMap.push_back(std::make_pair(L"accent2", lColorIndex_accent2)); - m_arColorMap.push_back(std::make_pair(L"accent3", lColorIndex_accent3)); - m_arColorMap.push_back(std::make_pair(L"accent4", lColorIndex_accent4)); - m_arColorMap.push_back(std::make_pair(L"accent5", lColorIndex_accent5)); - m_arColorMap.push_back(std::make_pair(L"accent6", lColorIndex_accent6)); - m_arColorMap.push_back(std::make_pair(L"folHlink", lColorIndex_folHlink)); - m_arColorMap.push_back(std::make_pair(L"hlink", lColorIndex_hlink)); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); - SetMap(); + virtual std::wstring GetColorSchemeIndex(const std::wstring& str) const; - m_arColorMap.clear(); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; - Limit::ColorSchemeIndex lColorIndex; + void Insert(const std::wstring& prop, const Limit::ColorSchemeIndex& val); + bool Find(const std::wstring& prop, Limit::ColorSchemeIndex& val) const; - if (m_name == L"w:clrSchemeMapping") - { - lColorIndex._set(node.GetAttribute(L"w:bg1")); m_arColorMap.push_back(std::make_pair(L"bg1", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"w:t1")); m_arColorMap.push_back(std::make_pair(L"tx1", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"w:bg2")); m_arColorMap.push_back(std::make_pair(L"bg2", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"w:t2")); m_arColorMap.push_back(std::make_pair(L"tx2", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"w:accent1")); m_arColorMap.push_back(std::make_pair(L"accent1", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"w:accent2")); m_arColorMap.push_back(std::make_pair(L"accent2", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"w:accent3")); m_arColorMap.push_back(std::make_pair(L"accent3", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"w:accent4")); m_arColorMap.push_back(std::make_pair(L"accent4", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"w:accent5")); m_arColorMap.push_back(std::make_pair(L"accent5", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"w:accent6")); m_arColorMap.push_back(std::make_pair(L"accent6", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"w:hyperlink")); m_arColorMap.push_back(std::make_pair(L"hlink", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"w:followedHyperlink"));m_arColorMap.push_back(std::make_pair(L"folHlink", lColorIndex)); - } - else - { - lColorIndex._set(node.GetAttribute(L"bg1")); m_arColorMap.push_back(std::make_pair(L"bg1", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"tx1")); m_arColorMap.push_back(std::make_pair(L"tx1", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"bg2")); m_arColorMap.push_back(std::make_pair(L"bg2", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"tx2")); m_arColorMap.push_back(std::make_pair(L"tx2", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"accent1")); m_arColorMap.push_back(std::make_pair(L"accent1", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"accent2")); m_arColorMap.push_back(std::make_pair(L"accent2", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"accent3")); m_arColorMap.push_back(std::make_pair(L"accent3", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"accent4")); m_arColorMap.push_back(std::make_pair(L"accent4", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"accent5")); m_arColorMap.push_back(std::make_pair(L"accent5", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"accent6")); m_arColorMap.push_back(std::make_pair(L"accent6", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"hlink")); m_arColorMap.push_back(std::make_pair(L"hlink", lColorIndex)); - lColorIndex._set(node.GetAttribute(L"folHlink")); m_arColorMap.push_back(std::make_pair(L"folHlink", lColorIndex)); - } - } + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - - if (m_name == L"w:clrSchemeMapping") - { - for (size_t i = 0; i < m_arColorMap.size(); ++i) - { - std::wstring att_name, att_val; - - if (m_arColorMap[i].first == L"tx1") att_name = L"w:t1"; - else if (m_arColorMap[i].first == L"tx2") att_name = L"w:t2"; - else if (m_arColorMap[i].first == L"hlink") att_name = L"w:hyperlink"; - else if (m_arColorMap[i].first == L"folHlink") att_name = L"w:followedHyperlink"; - else att_name = L"w:" + m_arColorMap[i].first; - - if (m_arColorMap[i].second.get() == L"lt1") att_val = L"light1"; - else if (m_arColorMap[i].second.get() == L"lt2") att_val = L"light2"; - else if (m_arColorMap[i].second.get() == L"dk1") att_val = L"dark1"; - else if (m_arColorMap[i].second.get() == L"dk2") att_val = L"dark2"; - else if (m_arColorMap[i].second.get() == L"hlink") att_val = L"hyperlink"; - else if (m_arColorMap[i].second.get() == L"folHlink")att_val = L"followedHyperlink"; - else att_val = m_arColorMap[i].second.get(); - - oAttr.Write(att_name, att_val); - } - } - else - { - for (size_t i = 0; i < m_arColorMap.size(); ++i) - { - oAttr.Write(m_arColorMap[i].first, m_arColorMap[i].second.get()); - } - } - - return XmlUtils::CreateNode(m_name, oAttr); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - - pWriter->StartAttributes(); - for (size_t i = 0; i < m_arColorMap.size(); ++i) - { - pWriter->WriteAttribute(m_arColorMap[i].first, m_arColorMap[i].second.get()); - } - pWriter->EndAttributes(); - - pWriter->EndNode(m_name); - } - - virtual std::wstring GetColorSchemeIndex(const std::wstring& str)const - { - std::map::const_iterator pPair = m_mapColorMap.find(str); - if (m_mapColorMap.end() != pPair) - { - return m_arColorMap[pPair->second].second.get(); - } - return L""; - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - - for (size_t i = 0; i < m_arColorMap.size(); ++i) - { - pWriter->WriteLimit1(SchemeClr_GetBYTECode(m_arColorMap[i].first), m_arColorMap[i].second); - } - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - void Insert(const std::wstring& prop, const Limit::ColorSchemeIndex& val) - { - std::map::iterator pPair = m_mapColorMap.find(prop); - - if (m_mapColorMap.end() != pPair) - { - if (pPair->second >= (int)m_arColorMap.size()) - m_arColorMap.resize(12); - m_arColorMap[pPair->second] = std::make_pair(prop, val); - } - } - bool Find(const std::wstring& prop, Limit::ColorSchemeIndex& val) const - { - std::map::const_iterator pPair = m_mapColorMap.find(prop); - if (m_mapColorMap.end() != pPair) - { - val = m_arColorMap[pPair->second].second; - return true; - } - else - { - return false; - } - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start sttribute - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - BYTE ind = pReader->GetUChar(); - Limit::ColorSchemeIndex _index; - _index.SetBYTECode(ind); - - Insert(SchemeClr_GetStringCode(_at), _index); - } - - pReader->Seek(_e); - } std::vector> m_arColorMap; std::wstring m_name; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); std::map m_mapColorMap; - void SetMap() - { - if (false == m_mapColorMap.empty()) return; - - m_mapColorMap.insert(std::make_pair(L"bg1", 0)); - m_mapColorMap.insert(std::make_pair(L"tx1", 1)); - m_mapColorMap.insert(std::make_pair(L"bg2", 2)); - m_mapColorMap.insert(std::make_pair(L"tx2", 3)); - m_mapColorMap.insert(std::make_pair(L"accent1", 4)); - m_mapColorMap.insert(std::make_pair(L"accent2", 5)); - m_mapColorMap.insert(std::make_pair(L"accent3", 6)); - m_mapColorMap.insert(std::make_pair(L"accent4", 7)); - m_mapColorMap.insert(std::make_pair(L"accent5", 8)); - m_mapColorMap.insert(std::make_pair(L"accent6", 9)); - m_mapColorMap.insert(std::make_pair(L"hlink", 10)); - m_mapColorMap.insert(std::make_pair(L"folHlink", 11)); - } + void SetMap(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/ClrMapOvr.cpp b/OOXML/PPTXFormat/Logic/ClrMapOvr.cpp new file mode 100644 index 0000000000..c499bd49d4 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/ClrMapOvr.cpp @@ -0,0 +1,114 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "ClrMapOvr.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType ClrMapOvr::getType() const + { + return OOX::et_a_clrMapOvr; + } + void ClrMapOvr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if ( L"overrideClrMapping" == sName) + { + overrideClrMapping = oReader; + break; + } + } + if (overrideClrMapping.is_init()) + overrideClrMapping->m_name = _T("a:overrideClrMapping"); + + FillParentPointersForChilds(); + } + void ClrMapOvr::fromXML(XmlUtils::CXmlNode& node) + { + overrideClrMapping = node.ReadNodeNoNS(_T("overrideClrMapping")); + if (overrideClrMapping.is_init()) + overrideClrMapping->m_name = _T("a:overrideClrMapping"); + FillParentPointersForChilds(); + } + std::wstring ClrMapOvr::toXML() const + { + if (overrideClrMapping.IsInit()) + return _T("") + overrideClrMapping->toXML() + _T(""); + return _T(""); + } + void ClrMapOvr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord2(0, overrideClrMapping); + } + void ClrMapOvr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + if (overrideClrMapping.is_init()) + { + pWriter->WriteString(_T("")); + overrideClrMapping->m_name = _T("a:overrideClrMapping"); + overrideClrMapping->toXmlWriter(pWriter); + pWriter->WriteString(_T("")); + } + else + { + pWriter->WriteString(_T("")); + } + } + void ClrMapOvr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4; + + if (pReader->GetPos() < _e) + { + pReader->Skip(1); // "0"-rectype + overrideClrMapping = new Logic::ClrMap(); + overrideClrMapping->fromPPTY(pReader); + } + + pReader->Seek(_e); + } + void ClrMapOvr::FillParentPointersForChilds() + { + if(overrideClrMapping.IsInit()) + overrideClrMapping->SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/ClrMapOvr.h b/OOXML/PPTXFormat/Logic/ClrMapOvr.h index 8bc9f07634..cc1cbc9733 100644 --- a/OOXML/PPTXFormat/Logic/ClrMapOvr.h +++ b/OOXML/PPTXFormat/Logic/ClrMapOvr.h @@ -46,89 +46,23 @@ namespace PPTX WritingElement_AdditionConstructors(ClrMapOvr) PPTX_LOGIC_BASE2(ClrMapOvr) - virtual OOX::EElementType getType() const - { - return OOX::et_a_clrMapOvr; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); + virtual OOX::EElementType getType() const; - if ( L"overrideClrMapping" == sName) - { - overrideClrMapping = oReader; - break; - } - } - if (overrideClrMapping.is_init()) - overrideClrMapping->m_name = _T("a:overrideClrMapping"); - - FillParentPointersForChilds(); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - overrideClrMapping = node.ReadNodeNoNS(_T("overrideClrMapping")); - if (overrideClrMapping.is_init()) - overrideClrMapping->m_name = _T("a:overrideClrMapping"); - FillParentPointersForChilds(); - } + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - virtual std::wstring toXML() const - { - if (overrideClrMapping.IsInit()) - return _T("") + overrideClrMapping->toXML() + _T(""); - return _T(""); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord2(0, overrideClrMapping); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - if (overrideClrMapping.is_init()) - { - pWriter->WriteString(_T("")); - overrideClrMapping->m_name = _T("a:overrideClrMapping"); - overrideClrMapping->toXmlWriter(pWriter); - pWriter->WriteString(_T("")); - } - else - { - pWriter->WriteString(_T("")); - } - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4; - - if (pReader->GetPos() < _e) - { - pReader->Skip(1); // "0"-rectype - overrideClrMapping = new Logic::ClrMap(); - overrideClrMapping->fromPPTY(pReader); - } - - pReader->Seek(_e); - } + virtual std::wstring toXML() const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: nullable overrideClrMapping; + protected: - virtual void FillParentPointersForChilds() - { - if(overrideClrMapping.IsInit()) - overrideClrMapping->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_SLIDES_CLRMAPOVR_INCLUDE_H_ \ No newline at end of file +#endif // PPTX_SLIDES_CLRMAPOVR_INCLUDE_H_ diff --git a/OOXML/PPTXFormat/Logic/CustGeom.cpp b/OOXML/PPTXFormat/Logic/CustGeom.cpp new file mode 100644 index 0000000000..a3371f5fa8 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/CustGeom.cpp @@ -0,0 +1,323 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "CustGeom.h" + +namespace PPTX +{ + namespace Logic + { + CustGeom& CustGeom::operator=(const CustGeom& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + avLst = oSrc.avLst; + gdLst = oSrc.gdLst; + ahLst = oSrc.ahLst; + cxnLst = oSrc.cxnLst; + pathLst = oSrc.pathLst; + + rect = oSrc.rect; + + return *this; + } + OOX::EElementType CustGeom::getType() const + { + return OOX::et_a_custGeom; + } + void CustGeom::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring sName = oReader.GetName(); + + if (sName == L"a:avLst") + { + if ( oReader.IsEmptyNode() ) + continue; + + int nParentDepth1 = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) + { + std::wstring sName1 = oReader.GetName(); + + if (sName1 == L"a:gd") + { + Gd gd; + avLst.push_back(gd); + avLst.back().fromXML(oReader); + } + } + } + else if (sName == L"a:gdLst") + { + if ( oReader.IsEmptyNode() ) + continue; + + int nParentDepth1 = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) + { + std::wstring sName1 = oReader.GetName(); + + if (sName1 == L"a:gd") + { + Gd gd; + gdLst.push_back(gd); + gdLst.back().fromXML(oReader); + } + } + } + else if (sName == L"a:rect") + rect = oReader; + else if (sName == L"a:pathLst") + { + if ( oReader.IsEmptyNode() ) + continue; + + int nParentDepth1 = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) + { + std::wstring sName1 = oReader.GetName(); + + if (sName1 == L"a:path") + { + Path2D gd; + pathLst.push_back(gd); + pathLst.back().fromXML(oReader); + } + } + } + else if (sName == L"a:ahLst") + { + if ( oReader.IsEmptyNode() ) + continue; + + int nParentDepth1 = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) + { + std::wstring sName1 = oReader.GetName(); + + if (sName1 == L"a:ahPolar") + { + AhBase gd; + ahLst.push_back(gd); + ahLst.back().fromXML(oReader); + } + else if (sName1 == L"a:ahXY") + { + AhBase gd; + ahLst.push_back(gd); + ahLst.back().fromXML(oReader); + } + } + } + else if (sName == L"a:cxnLst") + { + if ( oReader.IsEmptyNode() ) + continue; + + int nParentDepth1 = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) + { + std::wstring sName1 = oReader.GetName(); + + if (sName1 == L"a:cxn") + { + Cxn gd; + cxnLst.push_back(gd); + cxnLst.back().fromXML(oReader); + } + } + } + } + FillParentPointersForChilds(); + } + void CustGeom::fromXML(XmlUtils::CXmlNode& node) + { + XmlUtils::CXmlNode oNode; + if (node.GetNode(_T("a:avLst"), oNode)) + XmlMacroLoadArray(oNode, _T("a:gd"), avLst, Gd); + if (node.GetNode(_T("a:gdLst"), oNode)) + XmlMacroLoadArray(oNode, _T("a:gd"), gdLst, Gd); + + if (node.GetNode(_T("a:ahLst"), oNode)) + { + XmlMacroLoadArray(oNode, _T("a:ahPolar"), ahLst, AhBase); + XmlMacroLoadArray(oNode, _T("a:ahXY"), ahLst, AhBase); + } + + if (node.GetNode(_T("a:cxnLst"), oNode)) + XmlMacroLoadArray(oNode, _T("a:cxn"), cxnLst, Cxn); + + if (node.GetNode(_T("a:pathLst"), oNode)) + XmlMacroLoadArray(oNode, _T("a:path"), pathLst, Path2D); + + rect = node.ReadNodeNoNS(_T("rect")); + + FillParentPointersForChilds(); + } + std::wstring CustGeom::toXML() const + { + XmlUtils::CNodeValue oValue; + oValue.WriteArray(_T("a:avLst"), avLst); + oValue.WriteArray(_T("a:gdLst"), gdLst); + oValue.WriteArray(_T("a:ahLst"), ahLst); + oValue.WriteArray(_T("a:cxnLst"), cxnLst); + oValue.WriteNullable(rect); + oValue.WriteArray(_T("a:pathLst"), pathLst); + + return XmlUtils::CreateNode(_T("a:custGeom"), oValue); + } + void CustGeom::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:custGeom")); + pWriter->EndAttributes(); + + if (avLst.size() == 0) + pWriter->WriteString(_T("")); + else + pWriter->WriteArray(_T("a:avLst"), avLst); + + if (gdLst.size() == 0) + pWriter->WriteString(_T("")); + else + pWriter->WriteArray(_T("a:gdLst"), gdLst); + + if (ahLst.size() == 0) + pWriter->WriteString(_T("")); + else + pWriter->WriteArray(_T("a:ahLst"), ahLst); + + if (cxnLst.size() == 0) + pWriter->WriteString(_T("")); + else + pWriter->WriteArray(_T("a:cxnLst"), cxnLst); + + if (rect.is_init()) + pWriter->Write(rect); + else + pWriter->WriteString(_T("")); + if (pathLst.size() == 0) + pWriter->WriteString(_T("")); + else + pWriter->WriteArray(_T("a:pathLst"), pathLst); + + pWriter->EndNode(_T("a:custGeom")); + } + void CustGeom::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->StartRecord(GEOMETRY_TYPE_CUSTOM); + + pWriter->WriteRecordArray(0, 1, avLst); + pWriter->WriteRecordArray(1, 1, gdLst); + pWriter->WriteRecordArray(2, 1, ahLst); + pWriter->WriteRecordArray(3, 1, cxnLst); + pWriter->WriteRecordArray(4, 1, pathLst); + pWriter->WriteRecord2(5, rect); + + pWriter->EndRecord(); + } + void CustGeom::FillParentPointersForChilds() + { + size_t count = 0; + + count = avLst.size(); + for (size_t i = 0; i < count; ++i) + avLst[i].SetParentPointer(this); + + count = gdLst.size(); + for (size_t i = 0; i < count; ++i) + gdLst[i].SetParentPointer(this); + + count = ahLst.size(); + for (size_t i = 0; i < count; ++i) + ahLst[i].SetParentPointer(this); + + count = cxnLst.size(); + for (size_t i = 0; i < count; ++i) + cxnLst[i].SetParentPointer(this); + + count = pathLst.size(); + for (size_t i = 0; i < count; ++i) + pathLst[i].SetParentPointer(this); + + if (rect.IsInit()) + rect->SetParentPointer(this); + } + std::wstring CustGeom::GetODString() const + { + std::wstring strXml = _T(""); + + size_t nCount = 0; + + strXml += _T(""); + nCount = avLst.size(); + for (size_t i = 0; i < nCount; ++i) + strXml += avLst[i].GetODString(); + strXml += _T(""); + + strXml += _T(""); + nCount = gdLst.size(); + for (size_t i = 0; i < nCount; ++i) + strXml += gdLst[i].GetODString(); + strXml += _T(""); + + strXml += _T(""); + nCount = ahLst.size(); + for (size_t i = 0; i < nCount; ++i) + strXml += ahLst[i].GetODString(); + strXml += _T(""); + + strXml += _T(""); + nCount = cxnLst.size(); + for (size_t i = 0; i < nCount; ++i) + strXml += cxnLst[i].GetODString(); + strXml += _T(""); + + strXml += _T(""); + nCount = pathLst.size(); + for (size_t i = 0; i < nCount; ++i) + strXml += pathLst[i].GetODString(); + strXml += _T(""); + + if (rect.IsInit()) + strXml += rect->GetODString(); + + return XmlUtils::CreateNode(_T("ooxml-shape"), strXml); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/CustGeom.h b/OOXML/PPTXFormat/Logic/CustGeom.h index c58651f42e..2649218e3e 100644 --- a/OOXML/PPTXFormat/Logic/CustGeom.h +++ b/OOXML/PPTXFormat/Logic/CustGeom.h @@ -50,302 +50,28 @@ namespace PPTX WritingElement_AdditionConstructors(CustGeom) PPTX_LOGIC_BASE2(CustGeom) - CustGeom& operator=(const CustGeom& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + CustGeom& operator=(const CustGeom& oSrc); + virtual OOX::EElementType getType() const; - avLst = oSrc.avLst; - gdLst = oSrc.gdLst; - ahLst = oSrc.ahLst; - cxnLst = oSrc.cxnLst; - pathLst = oSrc.pathLst; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - rect = oSrc.rect; + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; - return *this; - } - - virtual OOX::EElementType getType() const - { - return OOX::et_a_custGeom; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring sName = oReader.GetName(); - - if (sName == L"a:avLst") - { - if ( oReader.IsEmptyNode() ) - continue; - - int nParentDepth1 = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) - { - std::wstring sName1 = oReader.GetName(); - - if (sName1 == L"a:gd") - { - Gd gd; - avLst.push_back(gd); - avLst.back().fromXML(oReader); - } - } - } - else if (sName == L"a:gdLst") - { - if ( oReader.IsEmptyNode() ) - continue; - - int nParentDepth1 = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) - { - std::wstring sName1 = oReader.GetName(); - - if (sName1 == L"a:gd") - { - Gd gd; - gdLst.push_back(gd); - gdLst.back().fromXML(oReader); - } - } - } - else if (sName == L"a:rect") - rect = oReader; - else if (sName == L"a:pathLst") - { - if ( oReader.IsEmptyNode() ) - continue; - - int nParentDepth1 = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) - { - std::wstring sName1 = oReader.GetName(); - - if (sName1 == L"a:path") - { - Path2D gd; - pathLst.push_back(gd); - pathLst.back().fromXML(oReader); - } - } - } - else if (sName == L"a:ahLst") - { - if ( oReader.IsEmptyNode() ) - continue; - - int nParentDepth1 = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) - { - std::wstring sName1 = oReader.GetName(); - - if (sName1 == L"a:ahPolar") - { - AhBase gd; - ahLst.push_back(gd); - ahLst.back().fromXML(oReader); - } - else if (sName1 == L"a:ahXY") - { - AhBase gd; - ahLst.push_back(gd); - ahLst.back().fromXML(oReader); - } - } - } - else if (sName == L"a:cxnLst") - { - if ( oReader.IsEmptyNode() ) - continue; - - int nParentDepth1 = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) - { - std::wstring sName1 = oReader.GetName(); - - if (sName1 == L"a:cxn") - { - Cxn gd; - cxnLst.push_back(gd); - cxnLst.back().fromXML(oReader); - } - } - } - } - FillParentPointersForChilds(); - } - - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlUtils::CXmlNode oNode; - if (node.GetNode(_T("a:avLst"), oNode)) - XmlMacroLoadArray(oNode, _T("a:gd"), avLst, Gd); - if (node.GetNode(_T("a:gdLst"), oNode)) - XmlMacroLoadArray(oNode, _T("a:gd"), gdLst, Gd); - - if (node.GetNode(_T("a:ahLst"), oNode)) - { - XmlMacroLoadArray(oNode, _T("a:ahPolar"), ahLst, AhBase); - XmlMacroLoadArray(oNode, _T("a:ahXY"), ahLst, AhBase); - } - - if (node.GetNode(_T("a:cxnLst"), oNode)) - XmlMacroLoadArray(oNode, _T("a:cxn"), cxnLst, Cxn); - - if (node.GetNode(_T("a:pathLst"), oNode)) - XmlMacroLoadArray(oNode, _T("a:path"), pathLst, Path2D); - - rect = node.ReadNodeNoNS(_T("rect")); - - FillParentPointersForChilds(); - } - - virtual std::wstring toXML() const - { - XmlUtils::CNodeValue oValue; - oValue.WriteArray(_T("a:avLst"), avLst); - oValue.WriteArray(_T("a:gdLst"), gdLst); - oValue.WriteArray(_T("a:ahLst"), ahLst); - oValue.WriteArray(_T("a:cxnLst"), cxnLst); - oValue.WriteNullable(rect); - oValue.WriteArray(_T("a:pathLst"), pathLst); - - return XmlUtils::CreateNode(_T("a:custGeom"), oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:custGeom")); - pWriter->EndAttributes(); - - if (avLst.size() == 0) - pWriter->WriteString(_T("")); - else - pWriter->WriteArray(_T("a:avLst"), avLst); - - if (gdLst.size() == 0) - pWriter->WriteString(_T("")); - else - pWriter->WriteArray(_T("a:gdLst"), gdLst); - - if (ahLst.size() == 0) - pWriter->WriteString(_T("")); - else - pWriter->WriteArray(_T("a:ahLst"), ahLst); - - if (cxnLst.size() == 0) - pWriter->WriteString(_T("")); - else - pWriter->WriteArray(_T("a:cxnLst"), cxnLst); - - if (rect.is_init()) - pWriter->Write(rect); - else - pWriter->WriteString(_T("")); - if (pathLst.size() == 0) - pWriter->WriteString(_T("")); - else - pWriter->WriteArray(_T("a:pathLst"), pathLst); - - pWriter->EndNode(_T("a:custGeom")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->StartRecord(GEOMETRY_TYPE_CUSTOM); - - pWriter->WriteRecordArray(0, 1, avLst); - pWriter->WriteRecordArray(1, 1, gdLst); - pWriter->WriteRecordArray(2, 1, ahLst); - pWriter->WriteRecordArray(3, 1, cxnLst); - pWriter->WriteRecordArray(4, 1, pathLst); - pWriter->WriteRecord2(5, rect); - - pWriter->EndRecord(); - } std::vector avLst; std::vector gdLst; std::vector ahLst; std::vector cxnLst; nullable rect; std::vector pathLst; + protected: - virtual void FillParentPointersForChilds() - { - size_t count = 0; + virtual void FillParentPointersForChilds(); - count = avLst.size(); - for (size_t i = 0; i < count; ++i) - avLst[i].SetParentPointer(this); - - count = gdLst.size(); - for (size_t i = 0; i < count; ++i) - gdLst[i].SetParentPointer(this); - - count = ahLst.size(); - for (size_t i = 0; i < count; ++i) - ahLst[i].SetParentPointer(this); - - count = cxnLst.size(); - for (size_t i = 0; i < count; ++i) - cxnLst[i].SetParentPointer(this); - - count = pathLst.size(); - for (size_t i = 0; i < count; ++i) - pathLst[i].SetParentPointer(this); - - if (rect.IsInit()) - rect->SetParentPointer(this); - } public: - virtual std::wstring GetODString() const - { - std::wstring strXml = _T(""); - - size_t nCount = 0; - - strXml += _T(""); - nCount = avLst.size(); - for (size_t i = 0; i < nCount; ++i) - strXml += avLst[i].GetODString(); - strXml += _T(""); - - strXml += _T(""); - nCount = gdLst.size(); - for (size_t i = 0; i < nCount; ++i) - strXml += gdLst[i].GetODString(); - strXml += _T(""); - - strXml += _T(""); - nCount = ahLst.size(); - for (size_t i = 0; i < nCount; ++i) - strXml += ahLst[i].GetODString(); - strXml += _T(""); - - strXml += _T(""); - nCount = cxnLst.size(); - for (size_t i = 0; i < nCount; ++i) - strXml += cxnLst[i].GetODString(); - strXml += _T(""); - - strXml += _T(""); - nCount = pathLst.size(); - for (size_t i = 0; i < nCount; ++i) - strXml += pathLst[i].GetODString(); - strXml += _T(""); - - if (rect.IsInit()) - strXml += rect->GetODString(); - - return XmlUtils::CreateNode(_T("ooxml-shape"), strXml); - } + virtual std::wstring GetODString() const; }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Cxn.cpp b/OOXML/PPTXFormat/Logic/Cxn.cpp new file mode 100644 index 0000000000..ae9009b746 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Cxn.cpp @@ -0,0 +1,132 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Cxn.h" + +namespace PPTX +{ + namespace Logic + { + Cxn& Cxn::operator=(const Cxn& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + x = oSrc.x; + y = oSrc.y; + ang = oSrc.ang; + return *this; + } + OOX::EElementType Cxn::getType() const + { + return OOX::et_a_cxn; + } + void Cxn::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring sName = oReader.GetName(); + + if (sName == L"a:pos") + { + ReadAttributes2(oReader); + } + } + } + void Cxn::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_ReadSingle( oReader, _T("ang"), ang ) + WritingElement_ReadAttributes_End( oReader ) + } + void Cxn::ReadAttributes2(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y ) + WritingElement_ReadAttributes_End( oReader ) + } + void Cxn::fromXML(XmlUtils::CXmlNode& node) + { + ang = node.GetAttribute(_T("ang")); + + XmlUtils::CXmlNode oPos; + if (node.GetNode(_T("a:pos"), oPos)) + { + x = oPos.GetAttribute(_T("x")); + y = oPos.GetAttribute(_T("y")); + } + } + std::wstring Cxn::toXML() const + { + return _T(""); + } + void Cxn::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:cxn")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("ang"), ang); + pWriter->EndAttributes(); + + pWriter->StartNode(_T("a:pos")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("x"), x); + pWriter->WriteAttribute(_T("y"), y); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:pos")); + + pWriter->EndNode(_T("a:cxn")); + } + void Cxn::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteString1(0, x); + pWriter->WriteString1(1, y); + pWriter->WriteString1(2, ang); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void Cxn::FillParentPointersForChilds() + { + } + std::wstring Cxn::GetODString()const + { + return _T(""); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Cxn.h b/OOXML/PPTXFormat/Logic/Cxn.h index 5520c79c84..80538251d1 100644 --- a/OOXML/PPTXFormat/Logic/Cxn.h +++ b/OOXML/PPTXFormat/Logic/Cxn.h @@ -43,106 +43,30 @@ namespace PPTX WritingElement_AdditionConstructors(Cxn) PPTX_LOGIC_BASE2(Cxn) - Cxn& operator=(const Cxn& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + Cxn& operator=(const Cxn& oSrc); + virtual OOX::EElementType getType() const; - x = oSrc.x; - y = oSrc.y; - ang = oSrc.ang; - return *this; - } - virtual OOX::EElementType getType() const - { - return OOX::et_a_cxn; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring sName = oReader.GetName(); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader); - if (sName == L"a:pos") - { - ReadAttributes2(oReader); - } - } - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_ReadSingle( oReader, _T("ang"), ang ) - WritingElement_ReadAttributes_End( oReader ) - } - void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y ) - WritingElement_ReadAttributes_End( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - ang = node.GetAttribute(_T("ang")); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - XmlUtils::CXmlNode oPos; - if (node.GetNode(_T("a:pos"), oPos)) - { - x = oPos.GetAttribute(_T("x")); - y = oPos.GetAttribute(_T("y")); - } - } - - virtual std::wstring toXML() const - { - return _T(""); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:cxn")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("ang"), ang); - pWriter->EndAttributes(); - - pWriter->StartNode(_T("a:pos")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("x"), x); - pWriter->WriteAttribute(_T("y"), y); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:pos")); - - pWriter->EndNode(_T("a:cxn")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteString1(0, x); - pWriter->WriteString1(1, y); - pWriter->WriteString1(2, ang); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; public: std::wstring x; std::wstring y; std::wstring ang; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); + public: - std::wstring GetODString()const - { - return _T(""); - } + std::wstring GetODString() const; }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/DefaultShapeDefinition.cpp b/OOXML/PPTXFormat/Logic/DefaultShapeDefinition.cpp new file mode 100644 index 0000000000..d903f4a0ec --- /dev/null +++ b/OOXML/PPTXFormat/Logic/DefaultShapeDefinition.cpp @@ -0,0 +1,190 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "DefaultShapeDefinition.h" + +namespace PPTX +{ + namespace Logic + { + DefaultShapeDefinition::DefaultShapeDefinition() + { + } + DefaultShapeDefinition& DefaultShapeDefinition::operator=(const DefaultShapeDefinition& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + spPr = oSrc.spPr; + bodyPr = oSrc.bodyPr; + lstStyle = oSrc.lstStyle; + style = oSrc.style; + m_name = oSrc.m_name; + + return *this; + } + void DefaultShapeDefinition::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_name = XmlUtils::GetNameNoNS(oReader.GetName()); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (_T("spPr") == strName) + spPr.fromXML(oReader); + else if (_T("bodyPr") == strName) + bodyPr = oReader; + else if (_T("lstStyle") == strName) + lstStyle.fromXML(oReader); + else if (_T("style") == strName) + style = oReader; + } + } + void DefaultShapeDefinition::fromXML(XmlUtils::CXmlNode& node) + { + m_name = XmlUtils::GetNameNoNS(node.GetName()); + + XmlUtils::CXmlNodes oNodes; + if (node.GetNodes(_T("*"), oNodes)) + { + int count = oNodes.GetCount(); + for (int i = 0; i < count; ++i) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(i, oNode); + + std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); + + if (_T("spPr") == strName) + spPr = oNode; + else if (_T("bodyPr") == strName) + bodyPr = oNode; + else if (_T("lstStyle") == strName) + lstStyle = oNode; + else if (_T("style") == strName) + style = oNode; + } + } + + FillParentPointersForChilds(); + } + std::wstring DefaultShapeDefinition::toXML() const + { + XmlUtils::CNodeValue oValue; + oValue.Write(spPr); + oValue.WriteNullable(bodyPr); + oValue.Write(lstStyle); + oValue.WriteNullable(style); + + return XmlUtils::CreateNode(_T("a:") + m_name, oValue); + } + void DefaultShapeDefinition::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord1(0, spPr); + pWriter->WriteRecord2(1, bodyPr); + pWriter->WriteRecord1(2, lstStyle); + pWriter->WriteRecord2(3, style); + } + void DefaultShapeDefinition::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + spPr.m_namespace = _T("a"); + spPr.fromPPTY(pReader); + break; + } + case 1: + { + bodyPr = BodyPr(L"a"); + bodyPr->fromPPTY(pReader); + break; + } + case 2: + { + lstStyle.m_name = _T("a:lstStyle"); + lstStyle.fromPPTY(pReader); + break; + } + case 3: + { + style = new ShapeStyle(L"a"); + style->fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void DefaultShapeDefinition::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:") + m_name); + pWriter->EndAttributes(); + + pWriter->m_lFlag = 0x04; + spPr.toXmlWriter(pWriter); + pWriter->m_lFlag = 0; + + if (bodyPr.IsInit()) + bodyPr->toXmlWriter(pWriter); + lstStyle.toXmlWriter(pWriter); + pWriter->Write(style); + + pWriter->EndNode(_T("a:") + m_name); + } + void DefaultShapeDefinition::FillParentPointersForChilds() + { + spPr.SetParentPointer(this); + + if (bodyPr.IsInit()) + bodyPr->SetParentPointer(this); + + lstStyle.SetParentPointer(this); + if(style.IsInit()) + style->SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/DefaultShapeDefinition.h b/OOXML/PPTXFormat/Logic/DefaultShapeDefinition.h index 7c6c7809f4..6b57a2cd6a 100644 --- a/OOXML/PPTXFormat/Logic/DefaultShapeDefinition.h +++ b/OOXML/PPTXFormat/Logic/DefaultShapeDefinition.h @@ -48,150 +48,16 @@ namespace PPTX public: WritingElement_AdditionConstructors(DefaultShapeDefinition) - DefaultShapeDefinition() - { - } + DefaultShapeDefinition(); + DefaultShapeDefinition& operator=(const DefaultShapeDefinition& oSrc); - DefaultShapeDefinition& operator=(const DefaultShapeDefinition& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - spPr = oSrc.spPr; - bodyPr = oSrc.bodyPr; - lstStyle = oSrc.lstStyle; - style = oSrc.style; - m_name = oSrc.m_name; - - return *this; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = XmlUtils::GetNameNoNS(oReader.GetName()); - - if ( oReader.IsEmptyNode() ) - return; - - int nCurDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); - - if (_T("spPr") == strName) - spPr.fromXML(oReader); - else if (_T("bodyPr") == strName) - bodyPr = oReader; - else if (_T("lstStyle") == strName) - lstStyle.fromXML(oReader); - else if (_T("style") == strName) - style = oReader; - } - } - - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = XmlUtils::GetNameNoNS(node.GetName()); - - XmlUtils::CXmlNodes oNodes; - if (node.GetNodes(_T("*"), oNodes)) - { - int count = oNodes.GetCount(); - for (int i = 0; i < count; ++i) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(i, oNode); - - std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); - - if (_T("spPr") == strName) - spPr = oNode; - else if (_T("bodyPr") == strName) - bodyPr = oNode; - else if (_T("lstStyle") == strName) - lstStyle = oNode; - else if (_T("style") == strName) - style = oNode; - } - } - - FillParentPointersForChilds(); - } - virtual std::wstring toXML() const - { - XmlUtils::CNodeValue oValue; - oValue.Write(spPr); - oValue.WriteNullable(bodyPr); - oValue.Write(lstStyle); - oValue.WriteNullable(style); - - return XmlUtils::CreateNode(_T("a:") + m_name, oValue); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord1(0, spPr); - pWriter->WriteRecord2(1, bodyPr); - pWriter->WriteRecord1(2, lstStyle); - pWriter->WriteRecord2(3, style); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - spPr.m_namespace = _T("a"); - spPr.fromPPTY(pReader); - break; - } - case 1: - { - bodyPr = BodyPr(L"a"); - bodyPr->fromPPTY(pReader); - break; - } - case 2: - { - lstStyle.m_name = _T("a:lstStyle"); - lstStyle.fromPPTY(pReader); - break; - } - case 3: - { - style = new ShapeStyle(L"a"); - style->fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:") + m_name); - pWriter->EndAttributes(); - - pWriter->m_lFlag = 0x04; - spPr.toXmlWriter(pWriter); - pWriter->m_lFlag = 0; - - if (bodyPr.IsInit()) - bodyPr->toXmlWriter(pWriter); - lstStyle.toXmlWriter(pWriter); - pWriter->Write(style); - - pWriter->EndNode(_T("a:") + m_name); - } + virtual std::wstring toXML() const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; public: SpPr spPr; @@ -200,20 +66,11 @@ namespace PPTX nullable style; std::wstring m_name; + protected: - virtual void FillParentPointersForChilds() - { - spPr.SetParentPointer(this); - - if (bodyPr.IsInit()) - bodyPr->SetParentPointer(this); - - lstStyle.SetParentPointer(this); - if(style.IsInit()) - style->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_DEFAULTSHAPEDEFINITION_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_DEFAULTSHAPEDEFINITION_INCLUDE_H diff --git a/OOXML/PPTXFormat/Logic/ExtP.cpp b/OOXML/PPTXFormat/Logic/ExtP.cpp new file mode 100644 index 0000000000..68e2d74a8f --- /dev/null +++ b/OOXML/PPTXFormat/Logic/ExtP.cpp @@ -0,0 +1,198 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "ExtP.h" + +namespace PPTX +{ + namespace Logic + { + Ext::Ext() + { + } + void Ext::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes(oReader); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (strName == L"media") + { + ReadAttributes1(oReader); + if ( oReader.IsEmptyNode() ) + continue; + + int nParentDepth1 = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) + { + std::wstring strName1 = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (strName1 == L"trim") + { + ReadAttributes2(oReader); + } + } + } + else if (strName == L"compatExt") + { + ReadAttributes3(oReader); + } + } + } + void Ext::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_ReadSingle ( oReader, L"uri", uri) + WritingElement_ReadAttributes_End( oReader ) + } + void Ext::ReadAttributes1(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_ReadSingle( oReader, L"r:embed", link) + WritingElement_ReadAttributes_End( oReader ) + } + void Ext::ReadAttributes2(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, L"st", st) + WritingElement_ReadAttributes_Read_else_if ( oReader, L"end", end) + WritingElement_ReadAttributes_End( oReader ) + } + void Ext::ReadAttributes3(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ); + WritingElement_ReadAttributes_ReadSingle ( oReader, L"spid", spid) + WritingElement_ReadAttributes_End( oReader ) + } + void Ext::fromXML(XmlUtils::CXmlNode& node) + { + XmlUtils::CXmlNodes oNodes; + if (node.GetNodes(L"*", oNodes)) + { + int nCount = oNodes.GetCount(); + for (int i = 0; i < nCount; ++i) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(i, oNode); + + std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); + + if (L"media" == strName) + { + link = oNode.GetAttribute(L"r:embed"); + + XmlUtils::CXmlNode trim = oNode.ReadNodeNoNS(L"trim"); + if (trim.IsValid()) + { + XmlMacroReadAttributeBase(trim, L"st", st); + XmlMacroReadAttributeBase(trim, L"end", end); + } + } + else if (L"compatExt" == strName) + { + spid = oNode.GetAttribute(L"spid"); + } + else if (L"sectionLst" == strName) + { + sectionLst = oNode; + } + } + } + } + std::wstring Ext::toXML() const + { + XmlUtils::CAttribute oAttr; + XmlUtils::CNodeValue oValue; + + return XmlUtils::CreateNode(L"p:ext", oValue); + } + void Ext::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring namespace_ext = L"p"; + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ext= L"a"; + + if (link.IsInit()) + { + std::wstring namespace_link = L"p14"; + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_link= L"wp15"; + + pWriter->StartNode(namespace_ext + L":ext"); + pWriter->StartAttributes(); + pWriter->WriteAttribute(L"uri", std::wstring(L"{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}")); + pWriter->EndAttributes(); + + pWriter->StartNode(namespace_link + L":media"); + pWriter->StartAttributes(); + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) + pWriter->WriteAttribute(L"xmlns:wp15", std::wstring(L"http://schemas.microsoft.com/office/word/2012/wordprocessingDrawing")); + else + pWriter->WriteAttribute(L"xmlns:p14", std::wstring(L"http://schemas.microsoft.com/office/powerpoint/2010/main")); + pWriter->WriteAttribute(L"r:embed", link->get()); + pWriter->EndAttributes(); + pWriter->EndNode(namespace_link + L":media"); + pWriter->EndNode(namespace_ext + L":ext"); + } + if (sectionLst.IsInit()) + { + pWriter->StartNode(namespace_ext + L":ext"); + pWriter->StartAttributes(); + pWriter->WriteAttribute(L"uri", std::wstring(L"{521415D9-36F7-43E2-AB2F-B90AF26B5E84}")); + pWriter->EndAttributes(); + + sectionLst->toXmlWriter(pWriter); + pWriter->EndNode(namespace_ext + L":ext"); + } + } + void Ext::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + if (link.IsInit()) + link->toPPTY(0, pWriter); + pWriter->WriteDouble2(1, st); + pWriter->WriteDouble2(2, end); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void Ext::FillParentPointersForChilds() + { + } + } +} diff --git a/OOXML/PPTXFormat/Logic/ExtP.h b/OOXML/PPTXFormat/Logic/ExtP.h index ce26b09c93..dc5927f590 100644 --- a/OOXML/PPTXFormat/Logic/ExtP.h +++ b/OOXML/PPTXFormat/Logic/ExtP.h @@ -29,6 +29,9 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ + +#pragma once + #ifndef PPTX_LOGIC_EXTP_PROPERTIES_INCLUDE_H_ #define PPTX_LOGIC_EXTP_PROPERTIES_INCLUDE_H_ @@ -98,165 +101,20 @@ namespace PPTX public: WritingElement_AdditionConstructors(Ext) - Ext() - { - } + Ext(); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes(oReader); - - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - if (strName == L"media") - { - ReadAttributes1(oReader); - if ( oReader.IsEmptyNode() ) - continue; + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes1(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes3(XmlUtils::CXmlLiteReader& oReader); - int nParentDepth1 = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) - { - std::wstring strName1 = XmlUtils::GetNameNoNS(oReader.GetName()); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; - if (strName1 == L"trim") - { - ReadAttributes2(oReader); - } - } - } - else if (strName == L"compatExt") - { - ReadAttributes3(oReader); - } - } - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_ReadSingle ( oReader, L"uri", uri) - WritingElement_ReadAttributes_End( oReader ) - } - void ReadAttributes1(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_ReadSingle( oReader, L"r:embed", link) - WritingElement_ReadAttributes_End( oReader ) - } - void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, L"st", st) - WritingElement_ReadAttributes_Read_else_if ( oReader, L"end", end) - WritingElement_ReadAttributes_End( oReader ) - } - void ReadAttributes3(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ); - WritingElement_ReadAttributes_ReadSingle ( oReader, L"spid", spid) - WritingElement_ReadAttributes_End( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlUtils::CXmlNodes oNodes; - if (node.GetNodes(L"*", oNodes)) - { - int nCount = oNodes.GetCount(); - for (int i = 0; i < nCount; ++i) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(i, oNode); - - std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); - - if (L"media" == strName) - { - link = oNode.GetAttribute(L"r:embed"); - - XmlUtils::CXmlNode trim = oNode.ReadNodeNoNS(L"trim"); - if (trim.IsValid()) - { - XmlMacroReadAttributeBase(trim, L"st", st); - XmlMacroReadAttributeBase(trim, L"end", end); - } - } - else if (L"compatExt" == strName) - { - spid = oNode.GetAttribute(L"spid"); - } - else if (L"sectionLst" == strName) - { - sectionLst = oNode; - } - } - } - } - - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - XmlUtils::CNodeValue oValue; - - return XmlUtils::CreateNode(L"p:ext", oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring namespace_ext = L"p"; - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ext= L"a"; - - if (link.IsInit()) - { - std::wstring namespace_link = L"p14"; - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_link= L"wp15"; - - pWriter->StartNode(namespace_ext + L":ext"); - pWriter->StartAttributes(); - pWriter->WriteAttribute(L"uri", std::wstring(L"{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}")); - pWriter->EndAttributes(); - - pWriter->StartNode(namespace_link + L":media"); - pWriter->StartAttributes(); - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) - pWriter->WriteAttribute(L"xmlns:wp15", std::wstring(L"http://schemas.microsoft.com/office/word/2012/wordprocessingDrawing")); - else - pWriter->WriteAttribute(L"xmlns:p14", std::wstring(L"http://schemas.microsoft.com/office/powerpoint/2010/main")); - pWriter->WriteAttribute(L"r:embed", link->get()); - pWriter->EndAttributes(); - pWriter->EndNode(namespace_link + L":media"); - pWriter->EndNode(namespace_ext + L":ext"); - } - if (sectionLst.IsInit()) - { - pWriter->StartNode(namespace_ext + L":ext"); - pWriter->StartAttributes(); - pWriter->WriteAttribute(L"uri", std::wstring(L"{521415D9-36F7-43E2-AB2F-B90AF26B5E84}")); - pWriter->EndAttributes(); - - sectionLst->toXmlWriter(pWriter); - pWriter->EndNode(namespace_ext + L":ext"); - } - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - if (link.IsInit()) - link->toPPTY(0, pWriter); - pWriter->WriteDouble2(1, st); - pWriter->WriteDouble2(2, end); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } //------------------------------------------------------- nullable_string uri; //media @@ -271,10 +129,7 @@ namespace PPTX //table //sparklineGroups protected: - virtual void FillParentPointersForChilds() - { - - } + virtual void FillParentPointersForChilds(); }; } } diff --git a/OOXML/PPTXFormat/Logic/FillStyle.cpp b/OOXML/PPTXFormat/Logic/FillStyle.cpp new file mode 100644 index 0000000000..3daac2c3eb --- /dev/null +++ b/OOXML/PPTXFormat/Logic/FillStyle.cpp @@ -0,0 +1,87 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "FillStyle.h" + +namespace PPTX +{ + namespace Logic + { + void FillStyle::fromXML(XmlUtils::CXmlNode& node) + { + Fill.GetFillFrom(node); + FillParentPointersForChilds(); + } + std::wstring FillStyle::toXML() const + { + return _T("") + Fill.toXML() + _T(""); + } + void FillStyle::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:fill")); + pWriter->EndAttributes(); + + Fill.toXmlWriter(pWriter); + + pWriter->EndNode(_T("a:fill")); + } + void FillStyle::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord1(0, Fill); + } + void FillStyle::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + Fill.fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void FillStyle::FillParentPointersForChilds() + { + Fill.SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/FillStyle.h b/OOXML/PPTXFormat/Logic/FillStyle.h index d1db10042f..e9e935d4e3 100644 --- a/OOXML/PPTXFormat/Logic/FillStyle.h +++ b/OOXML/PPTXFormat/Logic/FillStyle.h @@ -46,64 +46,21 @@ namespace PPTX PPTX_LOGIC_BASE(FillStyle) public: - virtual void fromXML(XmlUtils::CXmlNode& node) - { - Fill.GetFillFrom(node); - FillParentPointersForChilds(); - } + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - virtual std::wstring toXML() const - { - return _T("") + Fill.toXML() + _T(""); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:fill")); - pWriter->EndAttributes(); - - Fill.toXmlWriter(pWriter); - - pWriter->EndNode(_T("a:fill")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord1(0, Fill); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - Fill.fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: UniFill Fill; + protected: - virtual void FillParentPointersForChilds() - { - Fill.SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_FILLSTYLE_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_FILLSTYLE_INCLUDE_H diff --git a/OOXML/PPTXFormat/Logic/FontCollection.cpp b/OOXML/PPTXFormat/Logic/FontCollection.cpp new file mode 100644 index 0000000000..b72d16bfae --- /dev/null +++ b/OOXML/PPTXFormat/Logic/FontCollection.cpp @@ -0,0 +1,176 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "FontCollection.h" + +namespace PPTX +{ + namespace Logic + { + FontCollection& FontCollection::operator=(const FontCollection& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + latin = oSrc.latin; + ea = oSrc.ea; + cs = oSrc.cs; + + for (size_t i=0; i < oSrc.Fonts.size(); i++) + Fonts.push_back(oSrc.Fonts[i]); + + m_name = oSrc.m_name; + + return *this; + } + void FontCollection::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + XmlUtils::CXmlNodes oNodes; + if (node.GetNodes(_T("*"), oNodes)) + { + int nCount = oNodes.GetCount(); + for (int i = 0; i < nCount; ++i) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(i, oNode); + + std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); + + if (_T("latin") == strName) + latin = oNode; + else if (_T("ea") == strName) + ea = oNode; + else if (_T("cs") == strName) + cs = oNode; + else if (_T("font") == strName) + Fonts.push_back(SupplementalFont(oNode)); + } + } + + FillParentPointersForChilds(); + } + std::wstring FontCollection::toXML() const + { + XmlUtils::CNodeValue oValue; + oValue.Write(latin); + oValue.Write(ea); + oValue.Write(cs); + oValue.WriteArray(Fonts); + + return XmlUtils::CreateNode(m_name, oValue); + } + void FontCollection::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + pWriter->EndAttributes(); + + latin.toXmlWriter(pWriter); + ea.toXmlWriter(pWriter); + cs.toXmlWriter(pWriter); + + size_t nCount = Fonts.size(); + for (size_t i = 0; i < nCount; ++i) + Fonts[i].toXmlWriter(pWriter); + + pWriter->EndNode(m_name); + } + void FontCollection::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord1(0, latin); + pWriter->WriteRecord1(1, ea); + pWriter->WriteRecord1(2, cs); + pWriter->WriteRecordArray(3, 0, Fonts); + } + void FontCollection::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + latin.fromPPTY(pReader); + latin.m_name = _T("a:latin"); + break; + } + case 1: + { + ea.fromPPTY(pReader); + ea.m_name = _T("a:ea"); + break; + } + case 2: + { + cs.fromPPTY(pReader); + cs.m_name = _T("a:cs"); + break; + } + case 3: + { + pReader->Skip(4); + ULONG _c = pReader->GetULong(); + for (ULONG i = 0; i < _c; ++i) + { + pReader->Skip(1); // type + + SupplementalFont elm; + Fonts.push_back(elm); + + Fonts[i].m_name = _T("a:font"); + Fonts[i].fromPPTY(pReader); + } + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void FontCollection::FillParentPointersForChilds() + { + latin.SetParentPointer(this); + ea.SetParentPointer(this); + cs.SetParentPointer(this); + + size_t count = Fonts.size(); + for (size_t i = 0; i < count; ++i) + Fonts[i].SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/FontCollection.h b/OOXML/PPTXFormat/Logic/FontCollection.h index 71cbab9d86..1ea8619401 100644 --- a/OOXML/PPTXFormat/Logic/FontCollection.h +++ b/OOXML/PPTXFormat/Logic/FontCollection.h @@ -41,165 +41,34 @@ namespace PPTX { namespace Logic { - class FontCollection : public WrapperWritingElement { public: PPTX_LOGIC_BASE(FontCollection) - FontCollection& operator=(const FontCollection& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; - - latin = oSrc.latin; - ea = oSrc.ea; - cs = oSrc.cs; - - for (size_t i=0; i < oSrc.Fonts.size(); i++) - Fonts.push_back(oSrc.Fonts[i]); - - m_name = oSrc.m_name; - - return *this; - } + FontCollection& operator=(const FontCollection& oSrc); public: - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - XmlUtils::CXmlNodes oNodes; - if (node.GetNodes(_T("*"), oNodes)) - { - int nCount = oNodes.GetCount(); - for (int i = 0; i < nCount; ++i) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(i, oNode); - - std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); - - if (_T("latin") == strName) - latin = oNode; - else if (_T("ea") == strName) - ea = oNode; - else if (_T("cs") == strName) - cs = oNode; - else if (_T("font") == strName) - Fonts.push_back(SupplementalFont(oNode)); - } - } - - FillParentPointersForChilds(); - } - virtual std::wstring toXML() const - { - XmlUtils::CNodeValue oValue; - oValue.Write(latin); - oValue.Write(ea); - oValue.Write(cs); - oValue.WriteArray(Fonts); - - return XmlUtils::CreateNode(m_name, oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - pWriter->EndAttributes(); - - latin.toXmlWriter(pWriter); - ea.toXmlWriter(pWriter); - cs.toXmlWriter(pWriter); - - size_t nCount = Fonts.size(); - for (size_t i = 0; i < nCount; ++i) - Fonts[i].toXmlWriter(pWriter); - - pWriter->EndNode(m_name); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord1(0, latin); - pWriter->WriteRecord1(1, ea); - pWriter->WriteRecord1(2, cs); - pWriter->WriteRecordArray(3, 0, Fonts); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - latin.fromPPTY(pReader); - latin.m_name = _T("a:latin"); - break; - } - case 1: - { - ea.fromPPTY(pReader); - ea.m_name = _T("a:ea"); - break; - } - case 2: - { - cs.fromPPTY(pReader); - cs.m_name = _T("a:cs"); - break; - } - case 3: - { - pReader->Skip(4); - ULONG _c = pReader->GetULong(); - for (ULONG i = 0; i < _c; ++i) - { - pReader->Skip(1); // type - - SupplementalFont elm; - Fonts.push_back(elm); - - Fonts[i].m_name = _T("a:font"); - Fonts[i].fromPPTY(pReader); - } - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: TextFont latin; TextFont ea; TextFont cs; std::vector Fonts; - //private: + public: std::wstring m_name; - protected: - virtual void FillParentPointersForChilds() - { - latin.SetParentPointer(this); - ea.SetParentPointer(this); - cs.SetParentPointer(this); - size_t count = Fonts.size(); - for (size_t i = 0; i < count; ++i) - Fonts[i].SetParentPointer(this); - } + protected: + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_FONTCOLLECTION_INCLUDE_H_ \ No newline at end of file +#endif // PPTX_LOGIC_FONTCOLLECTION_INCLUDE_H_ diff --git a/OOXML/PPTXFormat/Logic/FontRef.cpp b/OOXML/PPTXFormat/Logic/FontRef.cpp new file mode 100644 index 0000000000..8acb1603de --- /dev/null +++ b/OOXML/PPTXFormat/Logic/FontRef.cpp @@ -0,0 +1,133 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "FontRef.h" + +namespace PPTX +{ + namespace Logic + { + FontRef::FontRef() + { + } + OOX::EElementType FontRef::getType () const + { + return OOX::et_Unknown; + } + void FontRef::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_name = oReader.GetName(); + + ReadAttributes( oReader ); + + Color.fromXMLParent(oReader); + + FillParentPointersForChilds(); + } + void FontRef::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start ( oReader ) + WritingElement_ReadAttributes_ReadSingle( oReader, _T("idx"), idx ) + WritingElement_ReadAttributes_End ( oReader ) + } + void FontRef::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + XmlMacroReadAttributeBase(node, L"idx", idx); + Color.GetColorFrom(node); + + FillParentPointersForChilds(); + } + void FontRef::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("idx"), idx); + pWriter->EndAttributes(); + + Color.toXmlWriter(pWriter); + + pWriter->EndNode(m_name); + } + void FontRef::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit2(0, idx); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord1(0, Color); + } + void FontRef::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) + { + idx = pReader->GetUChar(); + } + else + break; + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + Color.fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void FontRef::FillParentPointersForChilds() + { + Color.SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/FontRef.h b/OOXML/PPTXFormat/Logic/FontRef.h index fbedd1ec5b..5081c2976f 100644 --- a/OOXML/PPTXFormat/Logic/FontRef.h +++ b/OOXML/PPTXFormat/Logic/FontRef.h @@ -46,109 +46,25 @@ namespace PPTX public: WritingElement_AdditionConstructors(FontRef) - FontRef() - { - } - virtual OOX::EElementType getType () const - { - return OOX::et_Unknown; - } + FontRef(); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = oReader.GetName(); + virtual OOX::EElementType getType () const; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - ReadAttributes( oReader ); - - Color.fromXMLParent(oReader); - - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start ( oReader ) - WritingElement_ReadAttributes_ReadSingle( oReader, _T("idx"), idx ) - WritingElement_ReadAttributes_End ( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - XmlMacroReadAttributeBase(node, L"idx", idx); - Color.GetColorFrom(node); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - FillParentPointersForChilds(); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("idx"), idx); - pWriter->EndAttributes(); - - Color.toXmlWriter(pWriter); - - pWriter->EndNode(m_name); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit2(0, idx); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord1(0, Color); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) - { - idx = pReader->GetUChar(); - } - else - break; - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - Color.fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } - UniColor Color; nullable_limit idx; std::wstring m_name; + protected: - virtual void FillParentPointersForChilds() - { - Color.SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Gd.cpp b/OOXML/PPTXFormat/Logic/Gd.cpp new file mode 100644 index 0000000000..894cbae6cc --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Gd.cpp @@ -0,0 +1,275 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Gd.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType Gd::getType () const + { + return OOX::et_a_gd; + } + void Gd::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + } + void Gd::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start ( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("name"), name ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("fmla"), fmla ) + WritingElement_ReadAttributes_End ( oReader ) + } + void Gd::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"name", name); + XmlMacroReadAttributeBase(node, L"fmla", fmla); + } + std::wstring Gd::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("name"), name); + oAttr.Write(_T("fmla"), fmla); + + return XmlUtils::CreateNode(_T("a:gd"), oAttr); + } + void Gd::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:gd")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute2(_T("name"), name); + pWriter->WriteAttribute(_T("fmla"), fmla); +// pWriter->EndAttributes(); + pWriter->WriteNodeEnd(_T(""), true, true); + +// pWriter->EndNode(_T("a:gd")); + } + void Gd::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + + if (name.is_init() && fmla.is_init()) + { + pWriter->WriteString2(0, name); + + size_t nStart = 0; + size_t nCurrent = 0; + + const wchar_t* pData = fmla->c_str(); + size_t nLen = fmla->length(); + + int nFound = 0; + while (nCurrent < nLen) + { + if (pData[nCurrent] == (WCHAR)' ') + { + if (nStart < nCurrent) + { + if (0 == nFound) + { + if ((nCurrent - nStart) > 1) + { + pWriter->WriteInt1(1, GetFormulaType2(pData[nStart], pData[nStart + 1])); + } + else + { + pWriter->WriteInt1(1, 0); + } + } + else + { + pWriter->WriteString1Data(nFound + 1, pData + nStart, (ULONG)(nCurrent - nStart)); + } + nStart = nCurrent + 1; + ++nFound; + } + } + ++nCurrent; + } + if (nStart < nCurrent) + { + if (0 == nFound) + { + if ((nCurrent - nStart) > 1) + { + pWriter->WriteInt1(1, GetFormulaType2(pData[nStart], pData[nStart + 1])); + } + else + { + pWriter->WriteInt1(1, 0); + } + } + else + { + pWriter->WriteString1Data(nFound + 1, pData + nStart, (ULONG)(nCurrent - nStart)); + } + } + } + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void Gd::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + pReader->Skip(5); // len + start attributes + + std::wstring _fmla = _T(""); + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) + name = pReader->GetString2(); + else if (1 == _at) + { + _fmla = GetFormulaName(pReader->GetLong()); + } + else + { + if (1 < _at) + _fmla += _T(" "); + _fmla += pReader->GetString2(); + } + } + if (_T("") != _fmla) + fmla = _fmla; + } + int Gd::GetFormulaType(const std::wstring& str) const + { + if (_T("*/") == str) + return 0; + if (_T("+-") == str) + return 1; + if (_T("+/") == str) + return 2; + if (_T("?:") == str) + return 3; + if (_T("abs") == str) + return 4; + if (_T("at2") == str) + return 5; + if (_T("cat2") == str) + return 6; + if (_T("cos") == str) + return 7; + if (_T("max") == str) + return 8; + if (_T("min") == str) + return 16; + if (_T("mod") == str) + return 9; + if (_T("pin") == str) + return 10; + if (_T("sat2") == str) + return 11; + if (_T("sin") == str) + return 12; + if (_T("sqrt") == str) + return 13; + if (_T("tan") == str) + return 14; + if (_T("val") == str) + return 15; + return 0; + } + AVSINLINE int Gd::GetFormulaType2(const WCHAR& c1, const WCHAR& c2) const + { + switch (c1) + { + case (WCHAR)'*': + return 0; + case (WCHAR)'+': + return ((WCHAR)'-' == c2) ? 1 : 2; + case (WCHAR)'?': + return 3; + case (WCHAR)'a': + return ((WCHAR)'b' == c2) ? 4 : 5; + case (WCHAR)'c': + return ((WCHAR)'a' == c2) ? 6 : 7; + case (WCHAR)'m': + return ((WCHAR)'a' == c2) ? 8 : (((WCHAR)'i' == c2) ? 16 : 9); + case (WCHAR)'p': + return 10; + case (WCHAR)'s': + return ((WCHAR)'a' == c2) ? 11 : (((WCHAR)'i' == c2) ? 12 : 13); + case (WCHAR)'t': + return 14; + case (WCHAR)'v': + return 15; + default: + break; + } + return 0; + } + std::wstring Gd::GetFormulaName(const int& val) + { + switch (val) + { + case 0: return _T("*/"); + case 1: return _T("+-"); + case 2: return _T("+/"); + case 3: return _T("?:"); + case 4: return _T("abs"); + case 5: return _T("at2"); + case 6: return _T("cat2"); + case 7: return _T("cos"); + case 8: return _T("max"); + case 16: return _T("min"); + case 9: return _T("mod"); + case 10: return _T("pin"); + case 11: return _T("sat2"); + case 12: return _T("sin"); + case 13: return _T("sqrt"); + case 14: return _T("tan"); + case 15: return _T("val"); + default: + return _T("*/"); + } + } + void Gd::FillParentPointersForChilds() + { + } + std::wstring Gd::GetODString() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("name"), name); + oAttr.Write(_T("fmla"), fmla); + + return XmlUtils::CreateNode(_T("gd"), oAttr); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Gd.h b/OOXML/PPTXFormat/Logic/Gd.h index a254529928..3819c67d6e 100644 --- a/OOXML/PPTXFormat/Logic/Gd.h +++ b/OOXML/PPTXFormat/Logic/Gd.h @@ -45,252 +45,32 @@ namespace PPTX WritingElement_AdditionConstructors(Gd) PPTX_LOGIC_BASE2(Gd) - virtual OOX::EElementType getType () const - { - return OOX::et_a_gd; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); + virtual OOX::EElementType getType () const; - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start ( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("name"), name ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("fmla"), fmla ) - WritingElement_ReadAttributes_End ( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"name", name); - XmlMacroReadAttributeBase(node, L"fmla", fmla); - } + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("name"), name); - oAttr.Write(_T("fmla"), fmla); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - return XmlUtils::CreateNode(_T("a:gd"), oAttr); - } + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:gd")); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - pWriter->StartAttributes(); - pWriter->WriteAttribute2(_T("name"), name); - pWriter->WriteAttribute(_T("fmla"), fmla); -// pWriter->EndAttributes(); - pWriter->WriteNodeEnd(_T(""), true, true); - -// pWriter->EndNode(_T("a:gd")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - - if (name.is_init() && fmla.is_init()) - { - pWriter->WriteString2(0, name); - - size_t nStart = 0; - size_t nCurrent = 0; - - const wchar_t* pData = fmla->c_str(); - size_t nLen = fmla->length(); - - int nFound = 0; - while (nCurrent < nLen) - { - if (pData[nCurrent] == (WCHAR)' ') - { - if (nStart < nCurrent) - { - if (0 == nFound) - { - if ((nCurrent - nStart) > 1) - { - pWriter->WriteInt1(1, GetFormulaType2(pData[nStart], pData[nStart + 1])); - } - else - { - pWriter->WriteInt1(1, 0); - } - } - else - { - pWriter->WriteString1Data(nFound + 1, pData + nStart, (ULONG)(nCurrent - nStart)); - } - nStart = nCurrent + 1; - ++nFound; - } - } - ++nCurrent; - } - if (nStart < nCurrent) - { - if (0 == nFound) - { - if ((nCurrent - nStart) > 1) - { - pWriter->WriteInt1(1, GetFormulaType2(pData[nStart], pData[nStart + 1])); - } - else - { - pWriter->WriteInt1(1, 0); - } - } - else - { - pWriter->WriteString1Data(nFound + 1, pData + nStart, (ULONG)(nCurrent - nStart)); - } - } - } - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - pReader->Skip(5); // len + start attributes - - std::wstring _fmla = _T(""); - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) - name = pReader->GetString2(); - else if (1 == _at) - { - _fmla = GetFormulaName(pReader->GetLong()); - } - else - { - if (1 < _at) - _fmla += _T(" "); - _fmla += pReader->GetString2(); - } - } - if (_T("") != _fmla) - fmla = _fmla; - } - - int GetFormulaType(const std::wstring& str) const - { - if (_T("*/") == str) - return 0; - if (_T("+-") == str) - return 1; - if (_T("+/") == str) - return 2; - if (_T("?:") == str) - return 3; - if (_T("abs") == str) - return 4; - if (_T("at2") == str) - return 5; - if (_T("cat2") == str) - return 6; - if (_T("cos") == str) - return 7; - if (_T("max") == str) - return 8; - if (_T("min") == str) - return 16; - if (_T("mod") == str) - return 9; - if (_T("pin") == str) - return 10; - if (_T("sat2") == str) - return 11; - if (_T("sin") == str) - return 12; - if (_T("sqrt") == str) - return 13; - if (_T("tan") == str) - return 14; - if (_T("val") == str) - return 15; - return 0; - } - - AVSINLINE int GetFormulaType2(const WCHAR& c1, const WCHAR& c2) const - { - switch (c1) - { - case (WCHAR)'*': - return 0; - case (WCHAR)'+': - return ((WCHAR)'-' == c2) ? 1 : 2; - case (WCHAR)'?': - return 3; - case (WCHAR)'a': - return ((WCHAR)'b' == c2) ? 4 : 5; - case (WCHAR)'c': - return ((WCHAR)'a' == c2) ? 6 : 7; - case (WCHAR)'m': - return ((WCHAR)'a' == c2) ? 8 : (((WCHAR)'i' == c2) ? 16 : 9); - case (WCHAR)'p': - return 10; - case (WCHAR)'s': - return ((WCHAR)'a' == c2) ? 11 : (((WCHAR)'i' == c2) ? 12 : 13); - case (WCHAR)'t': - return 14; - case (WCHAR)'v': - return 15; - default: - break; - } - return 0; - } - - static std::wstring GetFormulaName(const int& val) - { - switch (val) - { - case 0: return _T("*/"); - case 1: return _T("+-"); - case 2: return _T("+/"); - case 3: return _T("?:"); - case 4: return _T("abs"); - case 5: return _T("at2"); - case 6: return _T("cat2"); - case 7: return _T("cos"); - case 8: return _T("max"); - case 16: return _T("min"); - case 9: return _T("mod"); - case 10: return _T("pin"); - case 11: return _T("sat2"); - case 12: return _T("sin"); - case 13: return _T("sqrt"); - case 14: return _T("tan"); - case 15: return _T("val"); - default: - return _T("*/"); - } - } + int GetFormulaType(const std::wstring& str) const; + int GetFormulaType2(const WCHAR& c1, const WCHAR& c2) const; + static std::wstring GetFormulaName(const int& val); public: nullable_string name; nullable_string fmla; - protected: - virtual void FillParentPointersForChilds(){}; - public: - virtual std::wstring GetODString()const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("name"), name); - oAttr.Write(_T("fmla"), fmla); - return XmlUtils::CreateNode(_T("gd"), oAttr); - } + protected: + virtual void FillParentPointersForChilds(); + + public: + virtual std::wstring GetODString() const; }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Geometry.cpp b/OOXML/PPTXFormat/Logic/Geometry.cpp index 314943c345..e153765570 100644 --- a/OOXML/PPTXFormat/Logic/Geometry.cpp +++ b/OOXML/PPTXFormat/Logic/Geometry.cpp @@ -132,6 +132,340 @@ namespace PPTX if (lpShapeElement) delete lpShapeElement; } + + Geometry::Geometry() + { + } + OOX::EElementType Geometry::getType() const + { + if (m_geometry.IsInit()) + return m_geometry->getType(); + return OOX::et_Unknown; + } + void Geometry::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (strName == _T("prstGeom")) + m_geometry.reset(new Logic::PrstGeom(oReader)); + else if (strName == _T("custGeom")) + m_geometry.reset(new Logic::CustGeom(oReader)); + else + m_geometry.reset(); + } + void Geometry::fromXML(XmlUtils::CXmlNode& node) + { + std::wstring strName = XmlUtils::GetNameNoNS(node.GetName()); + + if (strName == _T("prstGeom")) + m_geometry.reset(new Logic::PrstGeom(node)); + else if (strName == _T("custGeom")) + m_geometry.reset(new Logic::CustGeom(node)); + else m_geometry.reset(); + } + void Geometry::GetGeometryFrom(XmlUtils::CXmlNode& element) + { + XmlUtils::CXmlNode oNode; + if (element.GetNode(_T("a:prstGeom"), oNode)) + m_geometry.reset(new Logic::PrstGeom(oNode)); + else if (element.GetNode(_T("a:custGeom"), oNode)) + m_geometry.reset(new Logic::CustGeom(oNode)); + else m_geometry.reset(); + } + std::wstring Geometry::toXML() const + { + if (m_geometry.IsInit()) + return m_geometry->toXML(); + return _T(""); + } + void Geometry::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + if (m_geometry.is_init()) + m_geometry->toXmlWriter(pWriter); + } + void Geometry::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + if (m_geometry.is_init()) + m_geometry->toPPTY(pWriter); + } + void Geometry::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + if (pReader->GetPos() < _end_rec) + { + BYTE _t = pReader->GetUChar(); + + if (GEOMETRY_TYPE_PRST == _t) + { + // preset shape + LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4; + pReader->Skip(1); // start attributes + + Logic::PrstGeom* pGeom = new Logic::PrstGeom(); + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) + pGeom->prst.set(pReader->GetString2()); + else + break; + } + + while (pReader->GetPos() < _e) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; + ULONG _c = pReader->GetULong(); + + for (ULONG i = 0; i < _c; ++i) + { + pReader->Skip(1); + pGeom->avLst.push_back(Gd()); + pGeom->avLst[i].fromPPTY(pReader); + } + + pReader->Seek(_end_rec2); + break; + } + default: + break; + } + } + + m_geometry.reset(pGeom); + } + else if (GEOMETRY_TYPE_CUSTOM == _t) + { + LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4; + + Logic::CustGeom* pGeom = new Logic::CustGeom(); + while (pReader->GetPos() < _e) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; + ULONG _c = pReader->GetULong(); + + for (ULONG i = 0; i < _c; ++i) + { + pReader->Skip(1); + pGeom->avLst.push_back(Gd()); + pGeom->avLst[i].fromPPTY(pReader); + } + + pReader->Seek(_end_rec2); + break; + } + case 1: + { + LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; + ULONG _c = pReader->GetULong(); + + for (ULONG i = 0; i < _c; ++i) + { + pReader->Skip(1); + pGeom->gdLst.push_back(Gd()); + pGeom->gdLst[i].fromPPTY(pReader); + } + + pReader->Seek(_end_rec2); + break; + } + case 2: + { + LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; + ULONG _c = pReader->GetULong(); + + for (ULONG i = 0; i < _c; ++i) + { + BYTE _type1 = pReader->GetUChar(); + pReader->Skip(4); // len + BYTE _type = pReader->GetUChar(); + pReader->Skip(5); // len + start attributes + + if (1 == _type) + { + Logic::AhPolar* p = new Logic::AhPolar(); + while (true) + { + BYTE _at2 = pReader->GetUChar_TypeNode(); + if (_at2 == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at2) + { + case 0: p->x = pReader->GetString2(); break; + case 1: p->y = pReader->GetString2(); break; + case 2: p->gdRefAng = pReader->GetString2(); break; + case 3: p->gdRefR = pReader->GetString2(); break; + case 4: p->maxAng = pReader->GetString2(); break; + case 5: p->maxR = pReader->GetString2(); break; + case 6: p->minAng = pReader->GetString2(); break; + case 7: p->minR = pReader->GetString2(); break; + default: + break; + } + } + pGeom->ahLst.push_back(AhBase()); + pGeom->ahLst[i].ah.reset(p); + } + else + { + Logic::AhXY* p = new Logic::AhXY(); + while (true) + { + BYTE _at2 = pReader->GetUChar_TypeNode(); + if (_at2 == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at2) + { + case 0: p->x = pReader->GetString2(); break; + case 1: p->y = pReader->GetString2(); break; + case 2: p->gdRefX = pReader->GetString2(); break; + case 3: p->gdRefY = pReader->GetString2(); break; + case 4: p->maxX = pReader->GetString2(); break; + case 5: p->maxY = pReader->GetString2(); break; + case 6: p->minX = pReader->GetString2(); break; + case 7: p->minY = pReader->GetString2(); break; + default: + break; + } + } + pGeom->ahLst.push_back(AhBase()); + pGeom->ahLst[i].ah.reset(p); + } + } + + pReader->Seek(_end_rec2); + break; + } + case 3: + { + LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; + + ULONG _c = pReader->GetULong(); + + for (ULONG i = 0; i < _c; ++i) + { + BYTE _type = pReader->GetUChar(); + pReader->Skip(5); // len + start attributes + + pGeom->cxnLst.push_back(Cxn()); + while (true) + { + BYTE _at2 = pReader->GetUChar_TypeNode(); + if (_at2 == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at2) + { + case 0: + pGeom->cxnLst[i].x = pReader->GetString2(); + break; + case 1: + pGeom->cxnLst[i].y = pReader->GetString2(); + break; + case 2: + pGeom->cxnLst[i].ang = pReader->GetString2(); + break; + default: + break; + } + } + } + + pReader->Seek(_end_rec2); + break; + } + case 4: + { + LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; + ULONG _c = pReader->GetULong(); + + for (ULONG i = 0; i < _c; ++i) + { + BYTE _type = pReader->GetUChar(); + pGeom->pathLst.push_back(Path2D()); + pGeom->pathLst[i].fromPPTY(pReader); + } + + pReader->Seek(_end_rec2); + break; + } + case 5: + { + LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + pGeom->rect = new Logic::Rect(); + pGeom->rect->m_name = _T("a:rect"); + pGeom->rect->l = _T("l"); + pGeom->rect->t = _T("t"); + pGeom->rect->r = _T("r"); + pGeom->rect->b = _T("b"); + while (true) + { + BYTE _at2 = pReader->GetUChar_TypeNode(); + if (_at2 == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at2) + { + case 0: + pGeom->rect->l = pReader->GetString2(); + break; + case 1: + pGeom->rect->t = pReader->GetString2(); + break; + case 2: + pGeom->rect->r = pReader->GetString2(); + break; + case 3: + pGeom->rect->b = pReader->GetString2(); + break; + default: + break; + } + } + + pReader->Seek(_end_rec2); + break; + } + default: + break; + } + } + + m_geometry.reset(pGeom); + } + } + + pReader->Seek(_end_rec); + } + bool Geometry::is_init() const + { + return (m_geometry.IsInit()); + } + void Geometry::FillParentPointersForChilds() {} + void Geometry::SetParentPointer(const WrapperWritingElement* pParent) + { + if(is_init()) + m_geometry->SetParentPointer(pParent); + } } } diff --git a/OOXML/PPTXFormat/Logic/Geometry.h b/OOXML/PPTXFormat/Logic/Geometry.h index 117497eceb..ea71acbfe5 100644 --- a/OOXML/PPTXFormat/Logic/Geometry.h +++ b/OOXML/PPTXFormat/Logic/Geometry.h @@ -41,354 +41,39 @@ namespace PPTX { namespace Logic { - class Geometry : public WrapperWritingElement { public: WritingElement_AdditionConstructors(Geometry) - Geometry() - { - } - virtual OOX::EElementType getType() const - { - if (m_geometry.IsInit()) - return m_geometry->getType(); - return OOX::et_Unknown; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); - - if (strName == _T("prstGeom")) - m_geometry.reset(new Logic::PrstGeom(oReader)); - else if (strName == _T("custGeom")) - m_geometry.reset(new Logic::CustGeom(oReader)); - else - m_geometry.reset(); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - std::wstring strName = XmlUtils::GetNameNoNS(node.GetName()); - - if (strName == _T("prstGeom")) - m_geometry.reset(new Logic::PrstGeom(node)); - else if (strName == _T("custGeom")) - m_geometry.reset(new Logic::CustGeom(node)); - else m_geometry.reset(); - } + Geometry(); - virtual void GetGeometryFrom(XmlUtils::CXmlNode& element) - { - XmlUtils::CXmlNode oNode; - if (element.GetNode(_T("a:prstGeom"), oNode)) - m_geometry.reset(new Logic::PrstGeom(oNode)); - else if (element.GetNode(_T("a:custGeom"), oNode)) - m_geometry.reset(new Logic::CustGeom(oNode)); - else m_geometry.reset(); - } - virtual std::wstring toXML() const - { - if (m_geometry.IsInit()) - return m_geometry->toXML(); - return _T(""); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - if (m_geometry.is_init()) - m_geometry->toXmlWriter(pWriter); - } + virtual OOX::EElementType getType() const; - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - if (m_geometry.is_init()) - m_geometry->toPPTY(pWriter); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - if (pReader->GetPos() < _end_rec) - { - BYTE _t = pReader->GetUChar(); + virtual void GetGeometryFrom(XmlUtils::CXmlNode& element); - if (GEOMETRY_TYPE_PRST == _t) - { - // preset shape - LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4; - pReader->Skip(1); // start attributes + virtual std::wstring toXML() const; - Logic::PrstGeom* pGeom = new Logic::PrstGeom(); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) - pGeom->prst.set(pReader->GetString2()); - else - break; - } - - while (pReader->GetPos() < _e) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; - ULONG _c = pReader->GetULong(); - - for (ULONG i = 0; i < _c; ++i) - { - pReader->Skip(1); - pGeom->avLst.push_back(Gd()); - pGeom->avLst[i].fromPPTY(pReader); - } - - pReader->Seek(_end_rec2); - break; - } - default: - break; - } - } - - m_geometry.reset(pGeom); - } - else if (GEOMETRY_TYPE_CUSTOM == _t) - { - LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4; - - Logic::CustGeom* pGeom = new Logic::CustGeom(); - while (pReader->GetPos() < _e) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; - ULONG _c = pReader->GetULong(); - - for (ULONG i = 0; i < _c; ++i) - { - pReader->Skip(1); - pGeom->avLst.push_back(Gd()); - pGeom->avLst[i].fromPPTY(pReader); - } - - pReader->Seek(_end_rec2); - break; - } - case 1: - { - LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; - ULONG _c = pReader->GetULong(); - - for (ULONG i = 0; i < _c; ++i) - { - pReader->Skip(1); - pGeom->gdLst.push_back(Gd()); - pGeom->gdLst[i].fromPPTY(pReader); - } - - pReader->Seek(_end_rec2); - break; - } - case 2: - { - LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; - ULONG _c = pReader->GetULong(); - - for (ULONG i = 0; i < _c; ++i) - { - BYTE _type1 = pReader->GetUChar(); - pReader->Skip(4); // len - BYTE _type = pReader->GetUChar(); - pReader->Skip(5); // len + start attributes - - if (1 == _type) - { - Logic::AhPolar* p = new Logic::AhPolar(); - while (true) - { - BYTE _at2 = pReader->GetUChar_TypeNode(); - if (_at2 == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at2) - { - case 0: p->x = pReader->GetString2(); break; - case 1: p->y = pReader->GetString2(); break; - case 2: p->gdRefAng = pReader->GetString2(); break; - case 3: p->gdRefR = pReader->GetString2(); break; - case 4: p->maxAng = pReader->GetString2(); break; - case 5: p->maxR = pReader->GetString2(); break; - case 6: p->minAng = pReader->GetString2(); break; - case 7: p->minR = pReader->GetString2(); break; - default: - break; - } - } - pGeom->ahLst.push_back(AhBase()); - pGeom->ahLst[i].ah.reset(p); - } - else - { - Logic::AhXY* p = new Logic::AhXY(); - while (true) - { - BYTE _at2 = pReader->GetUChar_TypeNode(); - if (_at2 == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at2) - { - case 0: p->x = pReader->GetString2(); break; - case 1: p->y = pReader->GetString2(); break; - case 2: p->gdRefX = pReader->GetString2(); break; - case 3: p->gdRefY = pReader->GetString2(); break; - case 4: p->maxX = pReader->GetString2(); break; - case 5: p->maxY = pReader->GetString2(); break; - case 6: p->minX = pReader->GetString2(); break; - case 7: p->minY = pReader->GetString2(); break; - default: - break; - } - } - pGeom->ahLst.push_back(AhBase()); - pGeom->ahLst[i].ah.reset(p); - } - } - - pReader->Seek(_end_rec2); - break; - } - case 3: - { - LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; - - ULONG _c = pReader->GetULong(); - - for (ULONG i = 0; i < _c; ++i) - { - BYTE _type = pReader->GetUChar(); - pReader->Skip(5); // len + start attributes - - pGeom->cxnLst.push_back(Cxn()); - while (true) - { - BYTE _at2 = pReader->GetUChar_TypeNode(); - if (_at2 == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at2) - { - case 0: - pGeom->cxnLst[i].x = pReader->GetString2(); - break; - case 1: - pGeom->cxnLst[i].y = pReader->GetString2(); - break; - case 2: - pGeom->cxnLst[i].ang = pReader->GetString2(); - break; - default: - break; - } - } - } - - pReader->Seek(_end_rec2); - break; - } - case 4: - { - LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; - ULONG _c = pReader->GetULong(); - - for (ULONG i = 0; i < _c; ++i) - { - BYTE _type = pReader->GetUChar(); - pGeom->pathLst.push_back(Path2D()); - pGeom->pathLst[i].fromPPTY(pReader); - } - - pReader->Seek(_end_rec2); - break; - } - case 5: - { - LONG _end_rec2 = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - pGeom->rect = new Logic::Rect(); - pGeom->rect->m_name = _T("a:rect"); - pGeom->rect->l = _T("l"); - pGeom->rect->t = _T("t"); - pGeom->rect->r = _T("r"); - pGeom->rect->b = _T("b"); - while (true) - { - BYTE _at2 = pReader->GetUChar_TypeNode(); - if (_at2 == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at2) - { - case 0: - pGeom->rect->l = pReader->GetString2(); - break; - case 1: - pGeom->rect->t = pReader->GetString2(); - break; - case 2: - pGeom->rect->r = pReader->GetString2(); - break; - case 3: - pGeom->rect->b = pReader->GetString2(); - break; - default: - break; - } - } - - pReader->Seek(_end_rec2); - break; - } - default: - break; - } - } - - m_geometry.reset(pGeom); - } - } - - pReader->Seek(_end_rec); - } - - virtual bool is_init() const {return (m_geometry.IsInit());}; + virtual bool is_init() const; template AVSINLINE const bool is() const { return m_geometry.is(); } template AVSINLINE T& as() { return m_geometry.as(); } template AVSINLINE const T& as() const { return m_geometry.as(); } smart_ptr m_geometry; - protected: - virtual void FillParentPointersForChilds(){}; - public: - virtual void SetParentPointer(const WrapperWritingElement* pParent) - { - if(is_init()) - m_geometry->SetParentPointer(pParent); - }; + protected: + virtual void FillParentPointersForChilds(); + + public: + virtual void SetParentPointer(const WrapperWritingElement* pParent); void ConvertToCustomVML(IRenderer* punkRenderer, std::wstring& strPath, std::wstring& strRect, LONG& lWidth, LONG& lHeight); }; } // namespace Logic diff --git a/OOXML/PPTXFormat/Logic/GrpSpPr.cpp b/OOXML/PPTXFormat/Logic/GrpSpPr.cpp index ca85c6143d..4df619e9f7 100644 --- a/OOXML/PPTXFormat/Logic/GrpSpPr.cpp +++ b/OOXML/PPTXFormat/Logic/GrpSpPr.cpp @@ -29,13 +29,231 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ + #include "GrpSpPr.h" namespace PPTX { namespace Logic { - + GrpSpPr::GrpSpPr(std::wstring ns) + { + m_namespace = ns; + } + GrpSpPr& GrpSpPr::operator=(const GrpSpPr& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + xfrm = oSrc.xfrm; + Fill = oSrc.Fill; + EffectList = oSrc.EffectList; + scene3d = oSrc.scene3d; + bwMode = oSrc.bwMode; + return *this; + } + OOX::EElementType GrpSpPr::getType () const + { + return OOX::et_p_groupSpPr; + } + void GrpSpPr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if ( L"xfrm" == sName) + xfrm = oReader; + else if ( L"blipFill" == sName || + L"gradFill" == sName || + L"grpFill" == sName || + L"noFill" == sName || + L"pattFill" == sName || + L"solidFill" == sName ) + { + Fill.fromXML(oReader); + } + else if ( L"effectDag" == sName || + L"effectLst" == sName) + { + EffectList.fromXML(oReader); + } + else if ( L"extLst" == sName ) + { + if ( oReader.IsEmptyNode() ) + continue; + + int nParentDepth1 = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) + { + Ext element; + element.fromXML(oReader); + extLst.push_back (element); + } + } + } + FillParentPointersForChilds(); + } + void GrpSpPr::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_ReadSingle( oReader, _T("bwMode"), bwMode ) + WritingElement_ReadAttributes_End( oReader ) + } + void GrpSpPr::fromXML(XmlUtils::CXmlNode& node) + { + m_namespace = XmlUtils::GetNamespace(node.GetName()); + + XmlMacroReadAttributeBase(node, L"bwMode", bwMode); + + XmlUtils::CXmlNodes oNodes; + if (node.GetNodes(_T("*"), oNodes)) + { + int count = oNodes.GetCount(); + for (int i = 0; i < count; ++i) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(i, oNode); + + std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); + if (_T("xfrm") == strName) + { + if (!xfrm.IsInit()) + xfrm = oNode; + } + else if (_T("scene3d") == strName) + { + if (!scene3d.IsInit()) + scene3d = oNode; + } + } + } + + Fill.GetFillFrom(node); + EffectList.GetEffectListFrom(node); + + FillParentPointersForChilds(); + } + std::wstring GrpSpPr::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.WriteLimitNullable(_T("bwMode"), bwMode); + + XmlUtils::CNodeValue oValue; + oValue.WriteNullable(xfrm); + oValue.Write(Fill); + oValue.Write(EffectList); + oValue.WriteNullable(scene3d); + + return XmlUtils::CreateNode(m_namespace + L":grpSpPr", oAttr, oValue); + } + void GrpSpPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring namespace_ = m_namespace; + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"wpg"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; + + pWriter->StartNode(namespace_ + L":grpSpPr"); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("bwMode"), bwMode); + pWriter->EndAttributes(); + + pWriter->Write(xfrm); + Fill.toXmlWriter(pWriter); + EffectList.toXmlWriter(pWriter); + pWriter->Write(scene3d); + + pWriter->EndNode(namespace_ + L":grpSpPr"); + } + void GrpSpPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit2(0, bwMode); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, xfrm); + pWriter->WriteRecord1(1, Fill); + pWriter->WriteRecord1(2, EffectList); + pWriter->WriteRecord2(3, scene3d); + } + void GrpSpPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) + { + bwMode = pReader->GetUChar(); + } + else + break; + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + if (xfrm.is_init() == false) + { + xfrm = new Xfrm(); + } + xfrm->fromPPTY(pReader); + break; + } + case 1: + { + Fill.fromPPTY(pReader); + break; + } + case 2: + { + EffectList.fromPPTY(pReader); + break; + } + case 3: + { + scene3d = new PPTX::Logic::Scene3d(); + scene3d->fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void GrpSpPr::FillParentPointersForChilds() + { + Fill.SetParentPointer(this); + EffectList.SetParentPointer(this); + + if(xfrm.IsInit()) xfrm->SetParentPointer(this); + if(scene3d.IsInit()) scene3d->SetParentPointer(this); + } } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/GrpSpPr.h b/OOXML/PPTXFormat/Logic/GrpSpPr.h index 417feb5f0f..c6d8c03929 100644 --- a/OOXML/PPTXFormat/Logic/GrpSpPr.h +++ b/OOXML/PPTXFormat/Logic/GrpSpPr.h @@ -51,222 +51,20 @@ namespace PPTX public: WritingElement_AdditionConstructors(GrpSpPr) - GrpSpPr(std::wstring ns = L"p") - { - m_namespace = ns; - } - GrpSpPr& operator=(const GrpSpPr& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + GrpSpPr(std::wstring ns = L"p"); + GrpSpPr& operator=(const GrpSpPr& oSrc); - xfrm = oSrc.xfrm; - Fill = oSrc.Fill; - EffectList = oSrc.EffectList; - scene3d = oSrc.scene3d; - bwMode = oSrc.bwMode; - return *this; - } - virtual OOX::EElementType getType () const - { - return OOX::et_p_groupSpPr; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + virtual OOX::EElementType getType () const; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - ReadAttributes( oReader ); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - if ( L"xfrm" == sName) - xfrm = oReader; - else if ( L"blipFill" == sName || - L"gradFill" == sName || - L"grpFill" == sName || - L"noFill" == sName || - L"pattFill" == sName || - L"solidFill" == sName ) - { - Fill.fromXML(oReader); - } - else if ( L"effectDag" == sName || - L"effectLst" == sName) - { - EffectList.fromXML(oReader); - } - else if ( L"extLst" == sName ) - { - if ( oReader.IsEmptyNode() ) - continue; - - int nParentDepth1 = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) - { - Ext element; - element.fromXML(oReader); - extLst.push_back (element); - } - } - } - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_ReadSingle( oReader, _T("bwMode"), bwMode ) - WritingElement_ReadAttributes_End( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_namespace = XmlUtils::GetNamespace(node.GetName()); - - XmlMacroReadAttributeBase(node, L"bwMode", bwMode); - - XmlUtils::CXmlNodes oNodes; - if (node.GetNodes(_T("*"), oNodes)) - { - int count = oNodes.GetCount(); - for (int i = 0; i < count; ++i) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(i, oNode); - - std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); - if (_T("xfrm") == strName) - { - if (!xfrm.IsInit()) - xfrm = oNode; - } - else if (_T("scene3d") == strName) - { - if (!scene3d.IsInit()) - scene3d = oNode; - } - } - } - - Fill.GetFillFrom(node); - EffectList.GetEffectListFrom(node); - - FillParentPointersForChilds(); - } - - - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.WriteLimitNullable(_T("bwMode"), bwMode); - - XmlUtils::CNodeValue oValue; - oValue.WriteNullable(xfrm); - oValue.Write(Fill); - oValue.Write(EffectList); - oValue.WriteNullable(scene3d); - - return XmlUtils::CreateNode(m_namespace + L":grpSpPr", oAttr, oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring namespace_ = m_namespace; - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"wpg"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; - - pWriter->StartNode(namespace_ + L":grpSpPr"); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("bwMode"), bwMode); - pWriter->EndAttributes(); - - pWriter->Write(xfrm); - Fill.toXmlWriter(pWriter); - EffectList.toXmlWriter(pWriter); - pWriter->Write(scene3d); - - pWriter->EndNode(namespace_ + L":grpSpPr"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit2(0, bwMode); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, xfrm); - pWriter->WriteRecord1(1, Fill); - pWriter->WriteRecord1(2, EffectList); - pWriter->WriteRecord2(3, scene3d); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) - { - bwMode = pReader->GetUChar(); - } - else - break; - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - if (xfrm.is_init() == false) - { - xfrm = new Xfrm(); - } - xfrm->fromPPTY(pReader); - break; - } - case 1: - { - Fill.fromPPTY(pReader); - break; - } - case 2: - { - EffectList.fromPPTY(pReader); - break; - } - case 3: - { - scene3d = new PPTX::Logic::Scene3d(); - scene3d->fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); std::wstring m_namespace; @@ -278,15 +76,9 @@ namespace PPTX std::vector extLst; nullable_limit bwMode; + protected: - virtual void FillParentPointersForChilds() - { - Fill.SetParentPointer(this); - EffectList.SetParentPointer(this); - - if(xfrm.IsInit()) xfrm->SetParentPointer(this); - if(scene3d.IsInit()) scene3d->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Gs.cpp b/OOXML/PPTXFormat/Logic/Gs.cpp new file mode 100644 index 0000000000..9c00ef459c --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Gs.cpp @@ -0,0 +1,125 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Gs.h" + +namespace PPTX +{ + namespace Logic + { + Gs& Gs::operator=(const Gs& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + color = oSrc.color; + pos = oSrc.pos; + + return *this; + } + OOX::EElementType Gs::getType () const + { + return OOX::et_a_gs; + } + void Gs::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + color.fromXML(oReader); + break; + } + FillParentPointersForChilds(); + } + void Gs::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + nullable_int tmp; + WritingElement_ReadAttributes_Start_No_NS ( oReader ) + WritingElement_ReadAttributes_ReadSingle ( oReader, _T("pos"), tmp) + WritingElement_ReadAttributes_End_No_NS( oReader ) + + pos = tmp.get_value_or(0); + } + void Gs::fromXML(XmlUtils::CXmlNode& node) + { + pos = node.ReadAttributeInt(L"pos"); + color.GetColorFrom(node); + + FillParentPointersForChilds(); + } + std::wstring Gs::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("pos"), pos); + + return XmlUtils::CreateNode(_T("a:gs"), oAttr, color.toXML()); + } + void Gs::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring sNodeNamespace; + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + sNodeNamespace = _T("w14:"); + sAttrNamespace = sNodeNamespace; + } + else + sNodeNamespace = _T("a:"); + pWriter->StartNode(sNodeNamespace + _T("gs")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + _T("pos"), pos); + pWriter->EndAttributes(); + + color.toXmlWriter(pWriter); + + pWriter->EndNode(sNodeNamespace + _T("gs")); + } + void Gs::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteInt1(0, pos); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord1(0, color); + } + void Gs::FillParentPointersForChilds() + { + color.SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Gs.h b/OOXML/PPTXFormat/Logic/Gs.h index 478a5c05c6..41b1232dbf 100644 --- a/OOXML/PPTXFormat/Logic/Gs.h +++ b/OOXML/PPTXFormat/Logic/Gs.h @@ -44,98 +44,23 @@ namespace PPTX WritingElement_AdditionConstructors(Gs) PPTX_LOGIC_BASE2(Gs) - Gs& operator=(const Gs& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + Gs& operator=(const Gs& oSrc); - color = oSrc.color; - pos = oSrc.pos; - - return *this; - } - virtual OOX::EElementType getType () const - { - return OOX::et_a_gs; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); + virtual OOX::EElementType getType () const; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - if ( oReader.IsEmptyNode() ) - return; - - int nCurDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - color.fromXML(oReader); - break; - } - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - nullable_int tmp; - WritingElement_ReadAttributes_Start_No_NS ( oReader ) - WritingElement_ReadAttributes_ReadSingle ( oReader, _T("pos"), tmp) - WritingElement_ReadAttributes_End_No_NS( oReader ) - - pos = tmp.get_value_or(0); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - pos = node.ReadAttributeInt(L"pos"); - color.GetColorFrom(node); - - FillParentPointersForChilds(); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("pos"), pos); - - return XmlUtils::CreateNode(_T("a:gs"), oAttr, color.toXML()); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring sNodeNamespace; - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - sNodeNamespace = _T("w14:"); - sAttrNamespace = sNodeNamespace; - } - else - sNodeNamespace = _T("a:"); - pWriter->StartNode(sNodeNamespace + _T("gs")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + _T("pos"), pos); - pWriter->EndAttributes(); - - color.toXmlWriter(pWriter); - - pWriter->EndNode(sNodeNamespace + _T("gs")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteInt1(0, pos); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord1(0, color); - } + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; public: UniColor color; int pos; + protected: - virtual void FillParentPointersForChilds() - { - color.SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/HeadingVariant.cpp b/OOXML/PPTXFormat/Logic/HeadingVariant.cpp index fff76fac44..6e2ed6eccb 100644 --- a/OOXML/PPTXFormat/Logic/HeadingVariant.cpp +++ b/OOXML/PPTXFormat/Logic/HeadingVariant.cpp @@ -37,6 +37,46 @@ namespace PPTX { namespace Logic { + void HeadingVariant::fromXML(XmlUtils::CXmlNode& node) + { + XmlUtils::CXmlNode oNode = node.ReadNodeNoNS(_T("i4")); + if (oNode.IsValid()) + { + m_type = L"i4"; + m_iContent = oNode.GetTextExt(); + } + else + { + m_type = L"lpstr"; + m_strContent = node.ReadNodeNoNS(_T("lpstr")).GetTextExt(); + } + } + std::wstring HeadingVariant::toXML() const + { + if (m_type.IsInit() && (m_type->get() == _T("i4"))) + { + return _T("") + std::to_wstring(*m_iContent) + _T(""); + } + return _T("") + *m_strContent + _T(""); + } + void HeadingVariant::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("vt:variant")); + pWriter->EndAttributes(); + + if (m_type.IsInit() && (m_type->get() == _T("i4"))) + { + pWriter->WriteNodeValue(_T("vt:i4"), *m_iContent); + } + else + { + pWriter->WriteNodeValue(_T("vt:lpstr"), *m_strContent); + } + + pWriter->EndNode(_T("vt:variant")); + } + void HeadingVariant::FillParentPointersForChilds() {} + void CVariantVStream::fromXML(XmlUtils::CXmlNode& node) { XmlMacroReadAttributeBase(node, _T("version"), m_strVersion); @@ -607,7 +647,6 @@ namespace PPTX return m_eBaseType.IsInit() ? m_eBaseType.get() : vtEmpty; } - void CustomProperty::fromXML(XmlUtils::CXmlNode& node) { XmlMacroReadAttributeBase(node, _T("fmtid"), m_strFmtid); diff --git a/OOXML/PPTXFormat/Logic/HeadingVariant.h b/OOXML/PPTXFormat/Logic/HeadingVariant.h index 7ea0c2299e..38be0b1cdf 100644 --- a/OOXML/PPTXFormat/Logic/HeadingVariant.h +++ b/OOXML/PPTXFormat/Logic/HeadingVariant.h @@ -53,52 +53,19 @@ namespace PPTX PPTX_LOGIC_BASE(HeadingVariant) public: - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlUtils::CXmlNode oNode = node.ReadNodeNoNS(_T("i4")); - if (oNode.IsValid()) - { - m_type = L"i4"; - m_iContent = oNode.GetTextExt(); - } - else - { - m_type = L"lpstr"; - m_strContent = node.ReadNodeNoNS(_T("lpstr")).GetTextExt(); - } - } - virtual std::wstring toXML() const - { - if (m_type.IsInit() && (m_type->get() == _T("i4"))) - { - return _T("") + std::to_wstring(*m_iContent) + _T(""); - } - return _T("") + *m_strContent + _T(""); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("vt:variant")); - pWriter->EndAttributes(); - - if (m_type.IsInit() && (m_type->get() == _T("i4"))) - { - pWriter->WriteNodeValue(_T("vt:i4"), *m_iContent); - } - else - { - pWriter->WriteNodeValue(_T("vt:lpstr"), *m_strContent); - } - - pWriter->EndNode(_T("vt:variant")); - } + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; public: nullable_limit m_type; nullable_string m_strContent; nullable_int m_iContent; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; + class CVariantVStream : public WrapperWritingElement { public: @@ -117,6 +84,7 @@ namespace PPTX protected: virtual void FillParentPointersForChilds(){}; }; + class CVariant : public WrapperWritingElement { public: @@ -146,6 +114,7 @@ namespace PPTX protected: virtual void FillParentPointersForChilds(){}; }; + class CVariantVector : public WrapperWritingElement { public: @@ -166,6 +135,7 @@ namespace PPTX protected: virtual void FillParentPointersForChilds(){}; }; + class CVariantArray : public WrapperWritingElement { public: diff --git a/OOXML/PPTXFormat/Logic/Hf.cpp b/OOXML/PPTXFormat/Logic/Hf.cpp new file mode 100644 index 0000000000..b76d3c8369 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Hf.cpp @@ -0,0 +1,105 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "HF.h" + +namespace PPTX +{ + namespace Logic + { + void HF::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"dt", dt); + XmlMacroReadAttributeBase(node, L"ftr", ftr); + XmlMacroReadAttributeBase(node, L"hdr", hdr); + XmlMacroReadAttributeBase(node, L"sldNum", sldNum); + } + std::wstring HF::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(L"dt", dt); + oAttr.Write(L"ftr", ftr); + oAttr.Write(L"hdr", hdr); + oAttr.Write(L"sldNum", sldNum); + + return XmlUtils::CreateNode(L"p:hf", oAttr); + } + void HF::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteBool2(0, dt); + pWriter->WriteBool2(1, ftr); + pWriter->WriteBool2(2, hdr); + pWriter->WriteBool2(3, sldNum); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void HF::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(L"p:hf"); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(L"dt", dt); + pWriter->WriteAttribute(L"ftr", ftr); + pWriter->WriteAttribute(L"hdr", hdr); + pWriter->WriteAttribute(L"sldNum", sldNum); + pWriter->EndAttributes(); + + pWriter->EndNode(L"p:hf"); + } + void HF::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // attribute start + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) + dt = pReader->GetBool(); + else if (1 == _at) + ftr = pReader->GetBool(); + else if (2 == _at) + hdr = pReader->GetBool(); + else if (3 == _at) + sldNum = pReader->GetBool(); + } + + pReader->Seek(_e); + } + void HF::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Hf.h b/OOXML/PPTXFormat/Logic/Hf.h index e80bfe160f..028c68a33a 100644 --- a/OOXML/PPTXFormat/Logic/Hf.h +++ b/OOXML/PPTXFormat/Logic/Hf.h @@ -44,76 +44,20 @@ namespace PPTX public: PPTX_LOGIC_BASE(HF) - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"dt", dt); - XmlMacroReadAttributeBase(node, L"ftr", ftr); - XmlMacroReadAttributeBase(node, L"hdr", hdr); - XmlMacroReadAttributeBase(node, L"sldNum", sldNum); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(L"dt", dt); - oAttr.Write(L"ftr", ftr); - oAttr.Write(L"hdr", hdr); - oAttr.Write(L"sldNum", sldNum); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - return XmlUtils::CreateNode(L"p:hf", oAttr); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteBool2(0, dt); - pWriter->WriteBool2(1, ftr); - pWriter->WriteBool2(2, hdr); - pWriter->WriteBool2(3, sldNum); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(L"p:hf"); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(L"dt", dt); - pWriter->WriteAttribute(L"ftr", ftr); - pWriter->WriteAttribute(L"hdr", hdr); - pWriter->WriteAttribute(L"sldNum", sldNum); - pWriter->EndAttributes(); - - pWriter->EndNode(L"p:hf"); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // attribute start - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) - dt = pReader->GetBool(); - else if (1 == _at) - ftr = pReader->GetBool(); - else if (2 == _at) - hdr = pReader->GetBool(); - else if (3 == _at) - sldNum = pReader->GetBool(); - } - - pReader->Seek(_e); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); nullable_bool dt; nullable_bool ftr; nullable_bool hdr; nullable_bool sldNum; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Hyperlink.cpp b/OOXML/PPTXFormat/Logic/Hyperlink.cpp index 0d40b0bb14..ea95b47e79 100644 --- a/OOXML/PPTXFormat/Logic/Hyperlink.cpp +++ b/OOXML/PPTXFormat/Logic/Hyperlink.cpp @@ -30,7 +30,6 @@ * */ - #include "Hyperlink.h" #include "../Slide.h" @@ -43,6 +42,97 @@ namespace PPTX { namespace Logic { + Hyperlink::Hyperlink(const std::wstring& name) + { + m_name = name; + } + OOX::EElementType Hyperlink::getType () const + { + return OOX::et_a_hyperlink; + } + void Hyperlink::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_name = XmlUtils::GetNameNoNS(oReader.GetName()); + + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); + if (sName == L"snd") + { + snd = oReader; + break; + } + + } + } + void Hyperlink::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start ( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, (L"r:id"), id ) + WritingElement_ReadAttributes_Read_else_if( oReader, (L"relationships:id"), id ) + WritingElement_ReadAttributes_Read_else_if( oReader, (L"invalidUrl"), invalidUrl ) + WritingElement_ReadAttributes_Read_else_if( oReader, (L"action"), action ) + WritingElement_ReadAttributes_Read_else_if( oReader, (L"tgtFrame"), tgtFrame ) + WritingElement_ReadAttributes_Read_else_if( oReader, (L"tooltip"), tooltip ) + WritingElement_ReadAttributes_Read_else_if( oReader, (L"history"), history) + WritingElement_ReadAttributes_Read_else_if( oReader, (L"highlightClick"), highlightClick ) + WritingElement_ReadAttributes_Read_else_if( oReader, (L"endSnd"), endSnd ) + WritingElement_ReadAttributes_End ( oReader ) + } + void Hyperlink::fromXML(XmlUtils::CXmlNode& node) + { + m_name = XmlUtils::GetNameNoNS(node.GetName()); + + std::wstring sSndNodeName = (L"snd"); + snd = node.ReadNodeNoNS(sSndNodeName); + + XmlMacroReadAttributeBase(node, L"r:id", id); + XmlMacroReadAttributeBase(node, L"invalidUrl", invalidUrl); + XmlMacroReadAttributeBase(node, L"action", action); + XmlMacroReadAttributeBase(node, L"tgtFrame", tgtFrame); + XmlMacroReadAttributeBase(node, L"tooltip", tooltip); + XmlMacroReadAttributeBase(node, L"history", history); + XmlMacroReadAttributeBase(node, L"highlightClick", highlightClick); + XmlMacroReadAttributeBase(node, L"endSnd", endSnd); + + if (false == id.IsInit()) + { + XmlMacroReadAttributeBase( node, L"relationships:id", id ); + } + } + void Hyperlink::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(L"a:" + m_name); + + pWriter->StartAttributes(); + pWriter->WriteAttribute (L"r:id", id); + pWriter->WriteAttribute2(L"invalidUrl", invalidUrl); + pWriter->WriteAttribute2(L"action", action); + pWriter->WriteAttribute2(L"tgtFrame", tgtFrame); + + if (tooltip.IsInit()) + pWriter->WriteAttribute(L"tooltip", XmlUtils::EncodeXmlString(*tooltip)); + + pWriter->WriteAttribute(L"history", history); + pWriter->WriteAttribute(L"highlightClick", highlightClick); + pWriter->WriteAttribute(L"endSnd", endSnd); + pWriter->EndAttributes(); + + pWriter->Write(snd); + + pWriter->EndNode(L"a:" + m_name); + } + void Hyperlink::FillParentPointersForChilds() + { + if(snd.IsInit()) + snd->SetParentPointer(this); + } std::wstring Hyperlink::GetPathFromId(OOX::IFileContainer* pRels, const std::wstring & rId)const { if (rId.empty()) return L""; @@ -71,7 +161,6 @@ namespace PPTX return sLink; } - void Hyperlink::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const { OOX::IFileContainer* pRels = pWriter->GetRels().GetPointer(); @@ -96,7 +185,6 @@ namespace PPTX pWriter->WriteRecord2(0, snd); } - void Hyperlink::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) { LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; diff --git a/OOXML/PPTXFormat/Logic/Hyperlink.h b/OOXML/PPTXFormat/Logic/Hyperlink.h index e3daec3602..50d7f13f01 100644 --- a/OOXML/PPTXFormat/Logic/Hyperlink.h +++ b/OOXML/PPTXFormat/Logic/Hyperlink.h @@ -41,103 +41,22 @@ namespace PPTX { namespace Logic { - class Hyperlink : public WrapperWritingElement { public: WritingElement_AdditionConstructors(Hyperlink) - Hyperlink(const std::wstring & name = L"hlinkClick") - { - m_name = name; - } + Hyperlink(const std::wstring & name = L"hlinkClick"); + virtual OOX::EElementType getType () const; - virtual OOX::EElementType getType () const - { - return OOX::et_a_hyperlink; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = XmlUtils::GetNameNoNS(oReader.GetName()); - - ReadAttributes( oReader ); - - if ( oReader.IsEmptyNode() ) - return; - - int nCurDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); - if (sName == L"snd") - { - snd = oReader; - break; - } - - } - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start ( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, (L"r:id"), id ) - WritingElement_ReadAttributes_Read_else_if( oReader, (L"relationships:id"), id ) - WritingElement_ReadAttributes_Read_else_if( oReader, (L"invalidUrl"), invalidUrl ) - WritingElement_ReadAttributes_Read_else_if( oReader, (L"action"), action ) - WritingElement_ReadAttributes_Read_else_if( oReader, (L"tgtFrame"), tgtFrame ) - WritingElement_ReadAttributes_Read_else_if( oReader, (L"tooltip"), tooltip ) - WritingElement_ReadAttributes_Read_else_if( oReader, (L"history"), history) - WritingElement_ReadAttributes_Read_else_if( oReader, (L"highlightClick"), highlightClick ) - WritingElement_ReadAttributes_Read_else_if( oReader, (L"endSnd"), endSnd ) - WritingElement_ReadAttributes_End ( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = XmlUtils::GetNameNoNS(node.GetName()); - - std::wstring sSndNodeName = (L"snd"); - snd = node.ReadNodeNoNS(sSndNodeName); - - XmlMacroReadAttributeBase(node, L"r:id", id); - XmlMacroReadAttributeBase(node, L"invalidUrl", invalidUrl); - XmlMacroReadAttributeBase(node, L"action", action); - XmlMacroReadAttributeBase(node, L"tgtFrame", tgtFrame); - XmlMacroReadAttributeBase(node, L"tooltip", tooltip); - XmlMacroReadAttributeBase(node, L"history", history); - XmlMacroReadAttributeBase(node, L"highlightClick", highlightClick); - XmlMacroReadAttributeBase(node, L"endSnd", endSnd); - - if (false == id.IsInit()) - { - XmlMacroReadAttributeBase( node, L"relationships:id", id ); - } - } + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(L"a:" + m_name); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - pWriter->StartAttributes(); - pWriter->WriteAttribute (L"r:id", id); - pWriter->WriteAttribute2(L"invalidUrl", invalidUrl); - pWriter->WriteAttribute2(L"action", action); - pWriter->WriteAttribute2(L"tgtFrame", tgtFrame); - - if (tooltip.IsInit()) - pWriter->WriteAttribute(L"tooltip", XmlUtils::EncodeXmlString(*tooltip)); - - pWriter->WriteAttribute(L"history", history); - pWriter->WriteAttribute(L"highlightClick", highlightClick); - pWriter->WriteAttribute(L"endSnd", endSnd); - pWriter->EndAttributes(); - - pWriter->Write(snd); - - pWriter->EndNode(L"a:" + m_name); - } - nullable snd; nullable_string id; // id;// @@ -150,14 +69,10 @@ namespace PPTX nullable_bool endSnd; //default="false" std::wstring m_name; - protected: - virtual void FillParentPointersForChilds() - { - if(snd.IsInit()) - snd->SetParentPointer(this); - } - virtual std::wstring GetPathFromId(OOX::IFileContainer* pRels, const std::wstring &rId)const; + protected: + virtual void FillParentPointersForChilds(); + virtual std::wstring GetPathFromId(OOX::IFileContainer* pRels, const std::wstring &rId) const; }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/LightRig.cpp b/OOXML/PPTXFormat/Logic/LightRig.cpp new file mode 100644 index 0000000000..385ca60246 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/LightRig.cpp @@ -0,0 +1,163 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "LightRig.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType LightRig::getType() const + { + return OOX::et_a_lightRig; + } + void LightRig::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + std::wstring strName = oReader.GetName(); + + if (strName == L"a:rot") + { + rot = oReader; + break; + } + } + FillParentPointersForChilds(); + } + void LightRig::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start_No_NS( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("dir"), dir) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("rig"), rig) + WritingElement_ReadAttributes_End_No_NS( oReader ) + } + void LightRig::fromXML(XmlUtils::CXmlNode& node) + { + dir = node.GetAttribute(L"dir"); + rig = node.GetAttribute(L"rig"); + + rot = node.ReadNode(L"a:rot"); + FillParentPointersForChilds(); + } + std::wstring LightRig::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("rig"), rig.get()); + oAttr.Write(_T("dir"), dir.get()); + + XmlUtils::CNodeValue oValue; + oValue.WriteNullable(rot); + + return XmlUtils::CreateNode(_T("a:lightRig"), oAttr, oValue); + } + void LightRig::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring sNodeNamespace; + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + sNodeNamespace = L"w14:"; + sAttrNamespace = sNodeNamespace; + } + else + sNodeNamespace = L"a:"; + + pWriter->StartNode(sNodeNamespace + L"lightRig"); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + L"rig", rig.get()); + pWriter->WriteAttribute(sAttrNamespace + L"dir", dir.get()); + pWriter->EndAttributes(); + + pWriter->Write(rot); + + pWriter->EndNode(sNodeNamespace + L"lightRig"); + } + void LightRig::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit1(0, dir); + pWriter->WriteLimit1(1, rig); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, rot); + } + void LightRig::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) dir.SetBYTECode(pReader->GetUChar()); + else if (1 == _at) rig.SetBYTECode(pReader->GetUChar()); + else + break; + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + rot = new Logic::Rot(); + rot->fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void LightRig::FillParentPointersForChilds() + { + if(rot.IsInit()) + rot->SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/LightRig.h b/OOXML/PPTXFormat/Logic/LightRig.h index 95b108283f..0634b65ad1 100644 --- a/OOXML/PPTXFormat/Logic/LightRig.h +++ b/OOXML/PPTXFormat/Logic/LightRig.h @@ -42,141 +42,30 @@ namespace PPTX { namespace Logic { - class LightRig : public WrapperWritingElement { public: WritingElement_AdditionConstructors(LightRig) PPTX_LOGIC_BASE2(LightRig) - virtual OOX::EElementType getType() const - { - return OOX::et_a_lightRig; - } - void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); + virtual OOX::EElementType getType() const; - if ( oReader.IsEmptyNode() ) - return; + void fromXML(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - int nCurDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - std::wstring strName = oReader.GetName(); + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - if (strName == L"a:rot") - { - rot = oReader; - break; - } - } - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("dir"), dir) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("rig"), rig) - WritingElement_ReadAttributes_End_No_NS( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - dir = node.GetAttribute(L"dir"); - rig = node.GetAttribute(L"rig"); - - rot = node.ReadNode(L"a:rot"); - FillParentPointersForChilds(); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("rig"), rig.get()); - oAttr.Write(_T("dir"), dir.get()); - - XmlUtils::CNodeValue oValue; - oValue.WriteNullable(rot); - - return XmlUtils::CreateNode(_T("a:lightRig"), oAttr, oValue); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring sNodeNamespace; - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - sNodeNamespace = L"w14:"; - sAttrNamespace = sNodeNamespace; - } - else - sNodeNamespace = L"a:"; - - pWriter->StartNode(sNodeNamespace + L"lightRig"); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + L"rig", rig.get()); - pWriter->WriteAttribute(sAttrNamespace + L"dir", dir.get()); - pWriter->EndAttributes(); - - pWriter->Write(rot); - - pWriter->EndNode(sNodeNamespace + L"lightRig"); - } - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit1(0, dir); - pWriter->WriteLimit1(1, rig); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, rot); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) dir.SetBYTECode(pReader->GetUChar()); - else if (1 == _at) rig.SetBYTECode(pReader->GetUChar()); - else - break; - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - rot = new Logic::Rot(); - rot->fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } nullable rot; Limit::RectAlign dir; Limit::LightRigType rig; + protected: - virtual void FillParentPointersForChilds() - { - if(rot.IsInit()) - rot->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Lin.cpp b/OOXML/PPTXFormat/Logic/Lin.cpp new file mode 100644 index 0000000000..8f65fcd890 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Lin.cpp @@ -0,0 +1,124 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Lin.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType Lin::getType () const + { + return OOX::et_a_lin; + } + void Lin::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + } + void Lin::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start_No_NS ( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("ang"), ang) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("scaled"), scaled) + WritingElement_ReadAttributes_End_No_NS( oReader ) + + Normalize(); + } + void Lin::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"ang", ang); + XmlMacroReadAttributeBase(node, L"scaled", scaled); + + Normalize(); + } + std::wstring Lin::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("ang"), ang); + oAttr.Write(_T("scaled"), scaled); + + return XmlUtils::CreateNode(_T("a:lin"), oAttr); + } + void Lin::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteInt2(0, ang); + pWriter->WriteBool2(1, scaled); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void Lin::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) + ang = pReader->GetLong(); + else if (1 == _at) + scaled = pReader->GetBool(); + } + + pReader->Seek(_end_rec); + } + void Lin::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring sNodeNamespace; + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + sNodeNamespace = _T("w14:"); + sAttrNamespace = sNodeNamespace; + } + else + sNodeNamespace = _T("a:"); + pWriter->StartNode(sNodeNamespace + _T("lin")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + _T("ang"), ang); + pWriter->WriteAttribute(sAttrNamespace + _T("scaled"), scaled); + pWriter->EndAttributes(); + + pWriter->EndNode(sNodeNamespace + _T("lin")); + } + void Lin::FillParentPointersForChilds() {} + AVSINLINE void Lin::Normalize() + { + ang.normalize(0, 21600000); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Lin.h b/OOXML/PPTXFormat/Logic/Lin.h index 72cb362bc2..1e1b2637cb 100644 --- a/OOXML/PPTXFormat/Logic/Lin.h +++ b/OOXML/PPTXFormat/Logic/Lin.h @@ -39,106 +39,30 @@ namespace PPTX { namespace Logic { - class Lin : public WrapperWritingElement { public: WritingElement_AdditionConstructors(Lin) PPTX_LOGIC_BASE2(Lin) - virtual OOX::EElementType getType () const - { - return OOX::et_a_lin; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS ( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("ang"), ang) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("scaled"), scaled) - WritingElement_ReadAttributes_End_No_NS( oReader ) - - Normalize(); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"ang", ang); - XmlMacroReadAttributeBase(node, L"scaled", scaled); + virtual OOX::EElementType getType () const; - Normalize(); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("ang"), ang); - oAttr.Write(_T("scaled"), scaled); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - return XmlUtils::CreateNode(_T("a:lin"), oAttr); - } + virtual std::wstring toXML() const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteInt2(0, ang); - pWriter->WriteBool2(1, scaled); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) - ang = pReader->GetLong(); - else if (1 == _at) - scaled = pReader->GetBool(); - } - - pReader->Seek(_end_rec); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring sNodeNamespace; - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - sNodeNamespace = _T("w14:"); - sAttrNamespace = sNodeNamespace; - } - else - sNodeNamespace = _T("a:"); - pWriter->StartNode(sNodeNamespace + _T("lin")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + _T("ang"), ang); - pWriter->WriteAttribute(sAttrNamespace + _T("scaled"), scaled); - pWriter->EndAttributes(); - - pWriter->EndNode(sNodeNamespace + _T("lin")); - } - public: nullable_int ang; nullable_bool scaled; - protected: - virtual void FillParentPointersForChilds(){}; - AVSINLINE void Normalize() - { - ang.normalize(0, 21600000); - } + protected: + virtual void FillParentPointersForChilds(); + void Normalize(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/LineEnd.cpp b/OOXML/PPTXFormat/Logic/LineEnd.cpp new file mode 100644 index 0000000000..e37ef844d3 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/LineEnd.cpp @@ -0,0 +1,145 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "LineEnd.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType LineEnd::getType() const + { + return OOX::et_a_buSzPts; + } + void LineEnd::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_name = oReader.GetName(); + + ReadAttributes( oReader ); + } + void LineEnd::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + // Читаем атрибуты + WritingElement_ReadAttributes_Start_No_NS( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("w"), w ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("type"), type ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("len"), len ) + WritingElement_ReadAttributes_End_No_NS( oReader ) + } + void LineEnd::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + XmlMacroReadAttributeBase(node, L"type", type); + XmlMacroReadAttributeBase(node, L"w", w); + XmlMacroReadAttributeBase(node, L"len", len); + } + std::wstring LineEnd::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.WriteLimitNullable(_T("type"), type); + oAttr.WriteLimitNullable(_T("w"), w); + oAttr.WriteLimitNullable(_T("len"), len); + + return XmlUtils::CreateNode(m_name, oAttr); + } + void LineEnd::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("type"), type); + pWriter->WriteAttribute(_T("w"), w); + pWriter->WriteAttribute(_T("len"), len); + pWriter->EndAttributes(); + + pWriter->EndNode(m_name); + } + void LineEnd::Merge(nullable& line)const + { + if(!line.IsInit()) + line = LineEnd(); + if(type.IsInit()) + line->type = *type; + if(w.IsInit()) + line->w = *w; + if(len.IsInit()) + line->len = *len; + } + void LineEnd::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + type = pReader->GetUChar(); + break; + } + case 1: + { + w = pReader->GetUChar(); + break; + } + case 2: + { + len = pReader->GetUChar(); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void LineEnd::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit2(0, type); + pWriter->WriteLimit2(1, w); + pWriter->WriteLimit2(2, len); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void LineEnd::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/LineEnd.h b/OOXML/PPTXFormat/Logic/LineEnd.h index bceccfef65..9939a78a7c 100644 --- a/OOXML/PPTXFormat/Logic/LineEnd.h +++ b/OOXML/PPTXFormat/Logic/LineEnd.h @@ -47,122 +47,28 @@ namespace PPTX WritingElement_AdditionConstructors(LineEnd) PPTX_LOGIC_BASE2(LineEnd) - virtual OOX::EElementType getType() const - { - return OOX::et_a_buSzPts; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = oReader.GetName(); - - ReadAttributes( oReader ); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - // Читаем атрибуты - WritingElement_ReadAttributes_Start_No_NS( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("w"), w ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("type"), type ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("len"), len ) - WritingElement_ReadAttributes_End_No_NS( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); - - XmlMacroReadAttributeBase(node, L"type", type); - XmlMacroReadAttributeBase(node, L"w", w); - XmlMacroReadAttributeBase(node, L"len", len); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.WriteLimitNullable(_T("type"), type); - oAttr.WriteLimitNullable(_T("w"), w); - oAttr.WriteLimitNullable(_T("len"), len); + virtual OOX::EElementType getType() const; - return XmlUtils::CreateNode(m_name, oAttr); - } + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("type"), type); - pWriter->WriteAttribute(_T("w"), w); - pWriter->WriteAttribute(_T("len"), len); - pWriter->EndAttributes(); - - pWriter->EndNode(m_name); - } - - virtual void Merge(nullable& line)const - { - if(!line.IsInit()) - line = LineEnd(); - if(type.IsInit()) - line->type = *type; - if(w.IsInit()) - line->w = *w; - if(len.IsInit()) - line->len = *len; - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - type = pReader->GetUChar(); - break; - } - case 1: - { - w = pReader->GetUChar(); - break; - } - case 2: - { - len = pReader->GetUChar(); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit2(0, type); - pWriter->WriteLimit2(1, w); - pWriter->WriteLimit2(2, len); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void Merge(nullable& line) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; public: nullable_limit type; nullable_limit w; nullable_limit len; - //private: + public: std::wstring m_name; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/LineJoin.cpp b/OOXML/PPTXFormat/Logic/LineJoin.cpp new file mode 100644 index 0000000000..c5b337a2c2 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/LineJoin.cpp @@ -0,0 +1,208 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "LineJoin.h" + +namespace PPTX +{ + namespace Logic + { + bool LineJoin::is_init() const + { + return (type==JoinEmpty); + } + void LineJoin::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + std::wstring name = XmlUtils::GetNameNoNS(oReader.GetName()); + + type = JoinEmpty; + + if (name == _T("round")) + type = JoinRound; + else if (name == _T("bevel")) + type = JoinBevel; + else if (name == _T("miter")) + { + type = JoinMiter; + ReadAttributes(oReader); + } + + Normalize(); + } + OOX::EElementType LineJoin::getType () const + { + if(type == JoinRound) + return OOX::et_a_round; + else if(type == JoinBevel) + return OOX::et_a_bevel; + else if(type == JoinMiter) + return OOX::et_a_miter; + else + return OOX::et_Unknown; + } + void LineJoin::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start_No_NS ( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("lim"), lim ) + WritingElement_ReadAttributes_End_No_NS ( oReader ) + } + void LineJoin::GetJoinFrom(XmlUtils::CXmlNode& element) + { + type = JoinEmpty; + XmlUtils::CXmlNode oNode = element.ReadNodeNoNS(_T("round")); + if (oNode.IsValid()) + type = JoinRound; + else + { + oNode = element.ReadNodeNoNS(_T("bevel")); + if (oNode.IsValid()) + type = JoinBevel; + else + { + oNode = element.ReadNodeNoNS(_T("miter")); + if (oNode.IsValid()) + { + type = JoinMiter; + XmlMacroReadAttributeBase(oNode, L"lim", lim); + } + } + } + + Normalize(); + } + void LineJoin::fromXML(XmlUtils::CXmlNode& node) + { + std::wstring name = XmlUtils::GetNameNoNS(node.GetName()); + + type = JoinEmpty; + + if (name == _T("round")) + type = JoinRound; + else if (name == _T("bevel")) + type = JoinBevel; + else if (name == _T("miter")) + { + type = JoinMiter; + XmlMacroReadAttributeBase(node, L"lim", lim); + } + + Normalize(); + } + std::wstring LineJoin::toXML() const + { + if(type == JoinRound) + return _T(""); + else if(type == JoinBevel) + return _T(""); + else if(type == JoinMiter) + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("lim"), lim); + + return XmlUtils::CreateNode(_T("a:miter"), oAttr); + } + return _T(""); + } + void LineJoin::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring sNodeNamespace; + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + sNodeNamespace = _T("w14:"); + sAttrNamespace = sNodeNamespace; + } + else + sNodeNamespace = _T("a:"); + if (type == JoinRound) + { + pWriter->WriteString(_T("<") + sNodeNamespace + _T("round/>")); + } + else if (type == JoinBevel) + { + pWriter->WriteString(_T("<") + sNodeNamespace + _T("bevel/>")); + } + else if (type == JoinMiter) + { + pWriter->StartNode(sNodeNamespace + _T("miter")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + _T("lim"), lim); + pWriter->EndAttributes(); + pWriter->EndNode(sNodeNamespace + _T("miter")); + } + } + void LineJoin::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + int bb = (int)type; + pWriter->WriteInt1(0, bb); + pWriter->WriteInt2(1, lim); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void LineJoin::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + type = (eJoin)pReader->GetLong(); + break; + } + case 1: + { + lim = pReader->GetLong(); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void LineJoin::FillParentPointersForChilds() {} + AVSINLINE void LineJoin::Normalize() + { + lim.normalize_positive(); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/LineJoin.h b/OOXML/PPTXFormat/Logic/LineJoin.h index a66b2200b9..846266d902 100644 --- a/OOXML/PPTXFormat/Logic/LineJoin.h +++ b/OOXML/PPTXFormat/Logic/LineJoin.h @@ -47,182 +47,28 @@ namespace PPTX WritingElement_AdditionConstructors(LineJoin) PPTX_LOGIC_BASE2(LineJoin) - virtual bool is_init()const{return (type==JoinEmpty);}; + virtual bool is_init() const; - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - std::wstring name = XmlUtils::GetNameNoNS(oReader.GetName()); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual OOX::EElementType getType () const; - type = JoinEmpty; + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + virtual void GetJoinFrom(XmlUtils::CXmlNode& element); - if (name == _T("round")) - type = JoinRound; - else if (name == _T("bevel")) - type = JoinBevel; - else if (name == _T("miter")) - { - type = JoinMiter; - ReadAttributes(oReader); - } + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - Normalize(); - } - virtual OOX::EElementType getType () const - { - if(type == JoinRound) - return OOX::et_a_round; - else if(type == JoinBevel) - return OOX::et_a_bevel; - else if(type == JoinMiter) - return OOX::et_a_miter; - else - return OOX::et_Unknown; - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS ( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("lim"), lim ) - WritingElement_ReadAttributes_End_No_NS ( oReader ) - } - - virtual void GetJoinFrom(XmlUtils::CXmlNode& element) - { - type = JoinEmpty; - XmlUtils::CXmlNode oNode = element.ReadNodeNoNS(_T("round")); - if (oNode.IsValid()) - type = JoinRound; - else - { - oNode = element.ReadNodeNoNS(_T("bevel")); - if (oNode.IsValid()) - type = JoinBevel; - else - { - oNode = element.ReadNodeNoNS(_T("miter")); - if (oNode.IsValid()) - { - type = JoinMiter; - XmlMacroReadAttributeBase(oNode, L"lim", lim); - } - } - } - - Normalize(); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - std::wstring name = XmlUtils::GetNameNoNS(node.GetName()); - - type = JoinEmpty; - - if (name == _T("round")) - type = JoinRound; - else if (name == _T("bevel")) - type = JoinBevel; - else if (name == _T("miter")) - { - type = JoinMiter; - XmlMacroReadAttributeBase(node, L"lim", lim); - } - - Normalize(); - } - virtual std::wstring toXML() const - { - if(type == JoinRound) - return _T(""); - else if(type == JoinBevel) - return _T(""); - else if(type == JoinMiter) - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("lim"), lim); - - return XmlUtils::CreateNode(_T("a:miter"), oAttr); - } - return _T(""); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring sNodeNamespace; - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - sNodeNamespace = _T("w14:"); - sAttrNamespace = sNodeNamespace; - } - else - sNodeNamespace = _T("a:"); - if (type == JoinRound) - { - pWriter->WriteString(_T("<") + sNodeNamespace + _T("round/>")); - } - else if (type == JoinBevel) - { - pWriter->WriteString(_T("<") + sNodeNamespace + _T("bevel/>")); - } - else if (type == JoinMiter) - { - pWriter->StartNode(sNodeNamespace + _T("miter")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + _T("lim"), lim); - pWriter->EndAttributes(); - pWriter->EndNode(sNodeNamespace + _T("miter")); - } - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - int bb = (int)type; - pWriter->WriteInt1(0, bb); - pWriter->WriteInt2(1, lim); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - type = (eJoin)pReader->GetLong(); - break; - } - case 1: - { - lim = pReader->GetLong(); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: eJoin type; nullable_int lim; - protected: - virtual void FillParentPointersForChilds(){}; - AVSINLINE void Normalize() - { - lim.normalize_positive(); - } + protected: + virtual void FillParentPointersForChilds(); + void Normalize(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/LineStyle.cpp b/OOXML/PPTXFormat/Logic/LineStyle.cpp new file mode 100644 index 0000000000..42e4e6f683 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/LineStyle.cpp @@ -0,0 +1,112 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "LineStyle.h" + +namespace PPTX +{ + namespace Logic + { + void LineStyle::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + ln = node.ReadNodeNoNS(_T("ln")); + lnRef = node.ReadNodeNoNS(_T("lnRef")); + + FillParentPointersForChilds(); + } + std::wstring LineStyle::toXML() const + { + XmlUtils::CNodeValue oValue; + if (ln.IsInit()) + oValue.WriteNullable(ln); + else + oValue.WriteNullable(lnRef); + + return XmlUtils::CreateNode(m_name, oValue); + } + void LineStyle::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + pWriter->EndAttributes(); + + if (ln.IsInit()) + pWriter->Write(ln); + else + pWriter->Write(lnRef); + + pWriter->EndNode(m_name); + } + void LineStyle::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord2(0, ln); + pWriter->WriteRecord2(1, lnRef); + } + void LineStyle::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + ln = new Ln(); + ln->fromPPTY(pReader); + break; + } + case 1: + { + lnRef = new StyleRef(); + lnRef->fromPPTY(pReader); + lnRef->m_name = _T("a:lnRef"); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void LineStyle::FillParentPointersForChilds() + { + if(ln.IsInit()) + ln->SetParentPointer(this); + if(lnRef.IsInit()) + lnRef->SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/LineStyle.h b/OOXML/PPTXFormat/Logic/LineStyle.h index 634a185e5a..bbf497c05e 100644 --- a/OOXML/PPTXFormat/Logic/LineStyle.h +++ b/OOXML/PPTXFormat/Logic/LineStyle.h @@ -47,90 +47,24 @@ namespace PPTX PPTX_LOGIC_BASE(LineStyle) public: - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - ln = node.ReadNodeNoNS(_T("ln")); - lnRef = node.ReadNodeNoNS(_T("lnRef")); - - FillParentPointersForChilds(); - } - virtual std::wstring toXML() const - { - XmlUtils::CNodeValue oValue; - if (ln.IsInit()) - oValue.WriteNullable(ln); - else - oValue.WriteNullable(lnRef); - - return XmlUtils::CreateNode(m_name, oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - pWriter->EndAttributes(); - - if (ln.IsInit()) - pWriter->Write(ln); - else - pWriter->Write(lnRef); - - pWriter->EndNode(m_name); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord2(0, ln); - pWriter->WriteRecord2(1, lnRef); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - ln = new Ln(); - ln->fromPPTY(pReader); - break; - } - case 1: - { - lnRef = new StyleRef(); - lnRef->fromPPTY(pReader); - lnRef->m_name = _T("a:lnRef"); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: nullable ln; nullable lnRef; + public: std::wstring m_name; + protected: - virtual void FillParentPointersForChilds() - { - if(ln.IsInit()) - ln->SetParentPointer(this); - if(lnRef.IsInit()) - lnRef->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_LINESTYLE_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_LINESTYLE_INCLUDE_H diff --git a/OOXML/PPTXFormat/Logic/Ln.cpp b/OOXML/PPTXFormat/Logic/Ln.cpp new file mode 100644 index 0000000000..61289e4fad --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Ln.cpp @@ -0,0 +1,350 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Ln.h" + +namespace PPTX +{ + namespace Logic + { + Ln::Ln() + { + } + void Ln::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + //m_eDashType = OOX::Drawing::linedashtypeUnknown; + + m_name = oReader.GetName(); + + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while ( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); + if (_T("bevel") == sName || + _T("miter") == sName || + _T("round") == sName ) + { + Join.fromXML(oReader); + } + else if ( _T("tailEnd") == sName ) + tailEnd = oReader; + else if ( _T("headEnd") == sName ) + headEnd = oReader; + + else if ( _T("gradFill") == sName || + _T("noFill") == sName || + _T("pattFill") == sName || + _T("solidFill") == sName ) + { + Fill.fromXML(oReader); + } + else if ( _T("custDash") == sName ) + { + //custDash = oReader; + //m_eDashType = OOX::Drawing::linedashtypeCustom; + } + else if ( _T("prstDash") == sName ) + { + prstDash = oReader; + //m_eDashType = OOX::Drawing::linedashtypePreset; + } + else if ( L"effectDag" == sName || + L"effectLst" == sName) + { + Effects.fromXML(oReader); + } + else if ( L"extLst" == sName ) + { + if ( oReader.IsEmptyNode() ) + continue; + + int nParentDepth1 = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) + { + Ext element; + element.fromXML(oReader); + extLst.push_back (element); + } + } + } + FillParentPointersForChilds(); + } + void Ln::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + XmlMacroReadAttributeBase(node, L"algn", algn); + XmlMacroReadAttributeBase(node, L"cap", cap); + XmlMacroReadAttributeBase(node, L"cmpd", cmpd); + XmlMacroReadAttributeBase(node, L"w", w); + + Fill.GetFillFrom(node); + prstDash = node.ReadNodeNoNS(_T("prstDash")); + Join.GetJoinFrom(node); + headEnd = node.ReadNodeNoNS(_T("headEnd")); + tailEnd = node.ReadNodeNoNS(_T("tailEnd")); + + FillParentPointersForChilds(); + } + void Ln::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start_No_NS( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("algn"), algn ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("cap"), cap ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("cmpd"), cmpd ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("w"), w ) + WritingElement_ReadAttributes_End_No_NS( oReader ) + + Normalize(); + } + std::wstring Ln::toXML() const + { + std::wstring _name = m_name; + if (_name.empty()) + _name = _T("a:ln"); + + std::wstring sAttrNamespace; + + if (_name == L"w14:textOutline") + sAttrNamespace = _T("w14:"); + + XmlUtils::CAttribute oAttr; + oAttr.Write (sAttrNamespace + _T("w"), w); + oAttr.WriteLimitNullable(sAttrNamespace + _T("cap"), cap); + oAttr.WriteLimitNullable(sAttrNamespace + _T("cmpd"), cmpd); + oAttr.WriteLimitNullable(sAttrNamespace + _T("algn"), algn); + + XmlUtils::CNodeValue oValue; + oValue.Write(Fill); + oValue.WriteNullable(prstDash); + oValue.Write(Join); + oValue.WriteNullable(headEnd); + oValue.WriteNullable(tailEnd); + + return XmlUtils::CreateNode(_name, oAttr, oValue); + } + void Ln::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring _name = m_name; + if (_name.empty()) + _name = _T("a:ln"); + + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + _name = _T("w14:textOutline"); + sAttrNamespace = _T("w14:"); + } + + pWriter->StartNode(_name); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + _T("w"), w); + pWriter->WriteAttribute(sAttrNamespace + _T("cap"), cap); + pWriter->WriteAttribute(sAttrNamespace + _T("cmpd"), cmpd); + pWriter->WriteAttribute(sAttrNamespace + _T("algn"), algn); + pWriter->EndAttributes(); + + Fill.toXmlWriter(pWriter); + pWriter->Write(prstDash); + Join.toXmlWriter(pWriter); + pWriter->Write(headEnd); + pWriter->Write(tailEnd); + + pWriter->EndNode(_name); + } + void Ln::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit2(0, algn); + pWriter->WriteLimit2(1, cap); + pWriter->WriteLimit2(2, cmpd); + pWriter->WriteInt2(3, w); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord1(0, Fill); + pWriter->WriteRecord2(1, prstDash); + pWriter->WriteRecord1(2, Join); + pWriter->WriteRecord2(3, headEnd); + pWriter->WriteRecord2(4, tailEnd); + } + void Ln::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + m_name = _T("a:ln"); + + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + algn = pReader->GetUChar(); + break; + } + case 1: + { + cap = pReader->GetUChar(); + break; + } + case 2: + { + cmpd = pReader->GetUChar(); + break; + } + case 3: + { + w = pReader->GetLong(); + break; + } + default: + break; + } + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + Fill.fromPPTY(pReader); + break; + } + case 1: + { + prstDash = new Logic::PrstDash(); + prstDash->fromPPTY(pReader); + break; + } + case 2: + { + Join.fromPPTY(pReader); + break; + } + case 3: + { + headEnd = new Logic::LineEnd(); + headEnd->m_name = _T("a:headEnd"); + headEnd->fromPPTY(pReader); + break; + } + case 4: + { + tailEnd = new Logic::LineEnd(); + tailEnd->m_name = _T("a:tailEnd"); + tailEnd->fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void Ln::Merge(nullable& line)const + { + if(!line.IsInit()) + line = Ln(); + + if(Fill.is_init()) + line->Fill = Fill;//.fromXML(Fill.toXML()); + if(prstDash.is_init()) + line->prstDash = *prstDash; + if(Join.is_init()) + line->Join = Join; + if(headEnd.is_init()) + headEnd->Merge(line->headEnd); + if(tailEnd.is_init()) + tailEnd->Merge(line->tailEnd); + + if(algn.is_init()) + line->algn = *algn; + if(cap.is_init()) + line->cap = *cap; + if(cmpd.is_init()) + line->cmpd = *cmpd; + if(w.is_init()) + line->w = *w; + } + void Ln::Merge(Ln& line)const + { + if(Fill.is_init()) + line.Fill = Fill;//.fromXML(Fill.toXML()); + if(prstDash.is_init()) + line.prstDash = *prstDash; + if(Join.is_init()) + line.Join = Join; + if(headEnd.is_init()) + headEnd->Merge(line.headEnd); + if(tailEnd.is_init()) + tailEnd->Merge(line.tailEnd); + + if(algn.is_init()) + line.algn = *algn; + if(cap.is_init()) + line.cap = *cap; + if(cmpd.is_init()) + line.cmpd = *cmpd; + if(w.is_init()) + line.w = *w; + } + void Ln::FillParentPointersForChilds() + { + Fill.SetParentPointer(this); + Join.SetParentPointer(this); + if(prstDash.IsInit()) + prstDash->SetParentPointer(this); + if(headEnd.IsInit()) + headEnd->SetParentPointer(this); + if(tailEnd.IsInit()) + tailEnd->SetParentPointer(this); + } + AVSINLINE void Ln::Normalize() + { + w.normalize(0, 20116800); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Ln.h b/OOXML/PPTXFormat/Logic/Ln.h index cbb4142d18..8d176c4e89 100644 --- a/OOXML/PPTXFormat/Logic/Ln.h +++ b/OOXML/PPTXFormat/Logic/Ln.h @@ -53,308 +53,21 @@ namespace PPTX { public: WritingElement_AdditionConstructors(Ln) - Ln() - { - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - //m_eDashType = OOX::Drawing::linedashtypeUnknown; + Ln(); - m_name = oReader.GetName(); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - ReadAttributes( oReader ); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - if ( oReader.IsEmptyNode() ) - return; + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - int nCurDepth = oReader.GetDepth(); - while ( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); - if (_T("bevel") == sName || - _T("miter") == sName || - _T("round") == sName ) - { - Join.fromXML(oReader); - } - else if ( _T("tailEnd") == sName ) - tailEnd = oReader; - else if ( _T("headEnd") == sName ) - headEnd = oReader; - - else if ( _T("gradFill") == sName || - _T("noFill") == sName || - _T("pattFill") == sName || - _T("solidFill") == sName ) - { - Fill.fromXML(oReader); - } - else if ( _T("custDash") == sName ) - { - //custDash = oReader; - //m_eDashType = OOX::Drawing::linedashtypeCustom; - } - else if ( _T("prstDash") == sName ) - { - prstDash = oReader; - //m_eDashType = OOX::Drawing::linedashtypePreset; - } - else if ( L"effectDag" == sName || - L"effectLst" == sName) - { - Effects.fromXML(oReader); - } - else if ( L"extLst" == sName ) - { - if ( oReader.IsEmptyNode() ) - continue; - - int nParentDepth1 = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) - { - Ext element; - element.fromXML(oReader); - extLst.push_back (element); - } - } - } - FillParentPointersForChilds(); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); - - XmlMacroReadAttributeBase(node, L"algn", algn); - XmlMacroReadAttributeBase(node, L"cap", cap); - XmlMacroReadAttributeBase(node, L"cmpd", cmpd); - XmlMacroReadAttributeBase(node, L"w", w); - - Fill.GetFillFrom(node); - prstDash = node.ReadNodeNoNS(_T("prstDash")); - Join.GetJoinFrom(node); - headEnd = node.ReadNodeNoNS(_T("headEnd")); - tailEnd = node.ReadNodeNoNS(_T("tailEnd")); - - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("algn"), algn ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("cap"), cap ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("cmpd"), cmpd ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("w"), w ) - WritingElement_ReadAttributes_End_No_NS( oReader ) - - Normalize(); - } - virtual std::wstring toXML() const - { - std::wstring _name = m_name; - if (_name.empty()) - _name = _T("a:ln"); - - std::wstring sAttrNamespace; - - if (_name == L"w14:textOutline") - sAttrNamespace = _T("w14:"); - - XmlUtils::CAttribute oAttr; - oAttr.Write (sAttrNamespace + _T("w"), w); - oAttr.WriteLimitNullable(sAttrNamespace + _T("cap"), cap); - oAttr.WriteLimitNullable(sAttrNamespace + _T("cmpd"), cmpd); - oAttr.WriteLimitNullable(sAttrNamespace + _T("algn"), algn); - - XmlUtils::CNodeValue oValue; - oValue.Write(Fill); - oValue.WriteNullable(prstDash); - oValue.Write(Join); - oValue.WriteNullable(headEnd); - oValue.WriteNullable(tailEnd); - - return XmlUtils::CreateNode(_name, oAttr, oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring _name = m_name; - if (_name.empty()) - _name = _T("a:ln"); - - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - _name = _T("w14:textOutline"); - sAttrNamespace = _T("w14:"); - } - - pWriter->StartNode(_name); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + _T("w"), w); - pWriter->WriteAttribute(sAttrNamespace + _T("cap"), cap); - pWriter->WriteAttribute(sAttrNamespace + _T("cmpd"), cmpd); - pWriter->WriteAttribute(sAttrNamespace + _T("algn"), algn); - pWriter->EndAttributes(); - - Fill.toXmlWriter(pWriter); - pWriter->Write(prstDash); - Join.toXmlWriter(pWriter); - pWriter->Write(headEnd); - pWriter->Write(tailEnd); - - pWriter->EndNode(_name); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit2(0, algn); - pWriter->WriteLimit2(1, cap); - pWriter->WriteLimit2(2, cmpd); - pWriter->WriteInt2(3, w); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord1(0, Fill); - pWriter->WriteRecord2(1, prstDash); - pWriter->WriteRecord1(2, Join); - pWriter->WriteRecord2(3, headEnd); - pWriter->WriteRecord2(4, tailEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - m_name = _T("a:ln"); - - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - algn = pReader->GetUChar(); - break; - } - case 1: - { - cap = pReader->GetUChar(); - break; - } - case 2: - { - cmpd = pReader->GetUChar(); - break; - } - case 3: - { - w = pReader->GetLong(); - break; - } - default: - break; - } - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - Fill.fromPPTY(pReader); - break; - } - case 1: - { - prstDash = new Logic::PrstDash(); - prstDash->fromPPTY(pReader); - break; - } - case 2: - { - Join.fromPPTY(pReader); - break; - } - case 3: - { - headEnd = new Logic::LineEnd(); - headEnd->m_name = _T("a:headEnd"); - headEnd->fromPPTY(pReader); - break; - } - case 4: - { - tailEnd = new Logic::LineEnd(); - tailEnd->m_name = _T("a:tailEnd"); - tailEnd->fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } - - // merge - virtual void Merge(nullable& line)const - { - if(!line.IsInit()) - line = Ln(); - - if(Fill.is_init()) - line->Fill = Fill;//.fromXML(Fill.toXML()); - if(prstDash.is_init()) - line->prstDash = *prstDash; - if(Join.is_init()) - line->Join = Join; - if(headEnd.is_init()) - headEnd->Merge(line->headEnd); - if(tailEnd.is_init()) - tailEnd->Merge(line->tailEnd); - - if(algn.is_init()) - line->algn = *algn; - if(cap.is_init()) - line->cap = *cap; - if(cmpd.is_init()) - line->cmpd = *cmpd; - if(w.is_init()) - line->w = *w; - } - - virtual void Merge(Ln& line)const - { - if(Fill.is_init()) - line.Fill = Fill;//.fromXML(Fill.toXML()); - if(prstDash.is_init()) - line.prstDash = *prstDash; - if(Join.is_init()) - line.Join = Join; - if(headEnd.is_init()) - headEnd->Merge(line.headEnd); - if(tailEnd.is_init()) - tailEnd->Merge(line.tailEnd); - - if(algn.is_init()) - line.algn = *algn; - if(cap.is_init()) - line.cap = *cap; - if(cmpd.is_init()) - line.cmpd = *cmpd; - if(w.is_init()) - line.w = *w; - } + virtual void Merge(nullable& line) const; + virtual void Merge(Ln& line) const; public: // OOX::Drawing::ELineDashType m_eDashType; // Тип штриха @@ -376,23 +89,10 @@ namespace PPTX nullable_int w; std::wstring m_name; - protected: - virtual void FillParentPointersForChilds() - { - Fill.SetParentPointer(this); - Join.SetParentPointer(this); - if(prstDash.IsInit()) - prstDash->SetParentPointer(this); - if(headEnd.IsInit()) - headEnd->SetParentPointer(this); - if(tailEnd.IsInit()) - tailEnd->SetParentPointer(this); - } - AVSINLINE void Normalize() - { - w.normalize(0, 20116800); - } + protected: + virtual void FillParentPointersForChilds(); + void Normalize(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/NvCxnSpPr.cpp b/OOXML/PPTXFormat/Logic/NvCxnSpPr.cpp new file mode 100644 index 0000000000..6d45aa7fe9 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/NvCxnSpPr.cpp @@ -0,0 +1,167 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "NvCxnSpPr.h" + +namespace PPTX +{ + namespace Logic + { + NvCxnSpPr::NvCxnSpPr(std::wstring ns) + { + m_namespace = ns; + } + NvCxnSpPr& NvCxnSpPr::operator=(const NvCxnSpPr& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + cNvPr = oSrc.cNvPr; + cNvCxnSpPr = oSrc.cNvCxnSpPr; + nvPr = oSrc.nvPr; + + return *this; + } + void NvCxnSpPr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (strName == L"cNvPr") + cNvPr = oReader; + else if(strName == L"cNvCxnSpPr") + cNvCxnSpPr = oReader; + else if(strName == L"nvPr") + nvPr = oReader; + } + } + void NvCxnSpPr::fromXML(XmlUtils::CXmlNode& node) + { + m_namespace = XmlUtils::GetNamespace(node.GetName()); + + cNvPr = node.ReadNodeNoNS(_T("cNvPr")); + cNvCxnSpPr = node.ReadNodeNoNS(_T("cNvCxnSpPr")); + nvPr = node.ReadNodeNoNS(_T("nvPr")); + + FillParentPointersForChilds(); + } + std::wstring NvCxnSpPr::toXML() const + { + XmlUtils::CNodeValue oValue; + oValue.Write(cNvPr); + oValue.Write(cNvCxnSpPr); + + if (m_namespace != L"xdr" && m_namespace != L"cdr") + { + oValue.Write(nvPr); + } + + return XmlUtils::CreateNode(m_namespace + L":nvCxnSpPr", oValue); + } + void NvCxnSpPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring namespace_ = m_namespace; + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"wps"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; + + pWriter->StartNode(namespace_ + L":nvCxnSpPr"); + + pWriter->EndAttributes(); + + cNvPr.toXmlWriter2(namespace_ , pWriter); + cNvCxnSpPr.toXmlWriter(pWriter); + + if (pWriter->m_lDocType != XMLWRITER_DOC_TYPE_GRAPHICS && + pWriter->m_lDocType != XMLWRITER_DOC_TYPE_CHART_DRAWING) + { + nvPr.toXmlWriter2(namespace_, pWriter); + } + + pWriter->EndNode(namespace_ + L":nvCxnSpPr"); + } + void NvCxnSpPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord1(0, cNvPr); + pWriter->WriteRecord1(1, cNvCxnSpPr); + pWriter->WriteRecord1(2, nvPr); + } + void NvCxnSpPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + cNvPr.fromPPTY(pReader); + break; + } + case 1: + { + cNvCxnSpPr.fromPPTY(pReader); + break; + } + case 2: + { + nvPr.fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void NvCxnSpPr::FillParentPointersForChilds() + { + cNvPr.SetParentPointer(this); + cNvCxnSpPr.SetParentPointer(this); + nvPr.SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/NvCxnSpPr.h b/OOXML/PPTXFormat/Logic/NvCxnSpPr.h index b307ce9091..64e9937920 100644 --- a/OOXML/PPTXFormat/Logic/NvCxnSpPr.h +++ b/OOXML/PPTXFormat/Logic/NvCxnSpPr.h @@ -48,145 +48,26 @@ namespace PPTX public: WritingElement_AdditionConstructors(NvCxnSpPr) - NvCxnSpPr(std::wstring ns = L"p") - { - m_namespace = ns; - } + NvCxnSpPr(std::wstring ns = L"p"); - NvCxnSpPr& operator=(const NvCxnSpPr& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + NvCxnSpPr& operator=(const NvCxnSpPr& oSrc); - cNvPr = oSrc.cNvPr; - cNvCxnSpPr = oSrc.cNvCxnSpPr; - nvPr = oSrc.nvPr; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - return *this; - } - - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); - - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); - - if (strName == L"cNvPr") - cNvPr = oReader; - else if(strName == L"cNvCxnSpPr") - cNvCxnSpPr = oReader; - else if(strName == L"nvPr") - nvPr = oReader; - } - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_namespace = XmlUtils::GetNamespace(node.GetName()); - - cNvPr = node.ReadNodeNoNS(_T("cNvPr")); - cNvCxnSpPr = node.ReadNodeNoNS(_T("cNvCxnSpPr")); - nvPr = node.ReadNodeNoNS(_T("nvPr")); - - FillParentPointersForChilds(); - } - - virtual std::wstring toXML() const - { - XmlUtils::CNodeValue oValue; - oValue.Write(cNvPr); - oValue.Write(cNvCxnSpPr); - - if (m_namespace != L"xdr" && m_namespace != L"cdr") - { - oValue.Write(nvPr); - } - - return XmlUtils::CreateNode(m_namespace + L":nvCxnSpPr", oValue); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring namespace_ = m_namespace; - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"wps"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; - - pWriter->StartNode(namespace_ + L":nvCxnSpPr"); - - pWriter->EndAttributes(); - - cNvPr.toXmlWriter2(namespace_ , pWriter); - cNvCxnSpPr.toXmlWriter(pWriter); - - if (pWriter->m_lDocType != XMLWRITER_DOC_TYPE_GRAPHICS && - pWriter->m_lDocType != XMLWRITER_DOC_TYPE_CHART_DRAWING) - { - nvPr.toXmlWriter2(namespace_, pWriter); - } - - pWriter->EndNode(namespace_ + L":nvCxnSpPr"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord1(0, cNvPr); - pWriter->WriteRecord1(1, cNvCxnSpPr); - pWriter->WriteRecord1(2, nvPr); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - cNvPr.fromPPTY(pReader); - break; - } - case 1: - { - cNvCxnSpPr.fromPPTY(pReader); - break; - } - case 2: - { - nvPr.fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); std::wstring m_namespace; CNvPr cNvPr; CNvCxnSpPr cNvCxnSpPr; NvPr nvPr; + protected: - virtual void FillParentPointersForChilds() - { - cNvPr.SetParentPointer(this); - cNvCxnSpPr.SetParentPointer(this); - nvPr.SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/NvGraphicFramePr.cpp b/OOXML/PPTXFormat/Logic/NvGraphicFramePr.cpp index c2c14ed76f..3e2bd393bb 100644 --- a/OOXML/PPTXFormat/Logic/NvGraphicFramePr.cpp +++ b/OOXML/PPTXFormat/Logic/NvGraphicFramePr.cpp @@ -29,11 +29,149 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ + #include "NvGraphicFramePr.h" namespace PPTX { namespace Logic { + NvGraphicFramePr::NvGraphicFramePr(std::wstring ns) : cNvPr(ns), cNvGraphicFramePr(ns), nvPr(ns) + { + m_namespace = ns; + } + NvGraphicFramePr& NvGraphicFramePr::operator=(const NvGraphicFramePr& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + cNvPr = oSrc.cNvPr; + cNvGraphicFramePr = oSrc.cNvGraphicFramePr; + nvPr = oSrc.nvPr; + + m_namespace = oSrc.m_namespace; + + return *this; + } + void NvGraphicFramePr::fromXML(XmlUtils::CXmlNode& node) + { + m_namespace = XmlUtils::GetNamespace(node.GetName()); + + cNvPr = node.ReadNodeNoNS(_T("cNvPr")); + cNvGraphicFramePr = node.ReadNodeNoNS(_T("cNvGraphicFramePr")); + nvPr = node.ReadNodeNoNS(_T("nvPr")); + + FillParentPointersForChilds(); + } + void NvGraphicFramePr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (sName == L"cNvPr") + cNvPr.fromXML( oReader); + else if (sName == L"cNvGraphicFramePr") + cNvGraphicFramePr.fromXML( oReader); + else if (sName == L"nvPr") + nvPr.fromXML( oReader); + } + FillParentPointersForChilds(); + } + std::wstring NvGraphicFramePr::toXML() const + { + XmlUtils::CNodeValue oValue; + oValue.Write(cNvPr); + oValue.Write(cNvGraphicFramePr); + oValue.Write(nvPr); + + return XmlUtils::CreateNode(m_namespace + L":nvGraphicFramePr", oValue); + } + void NvGraphicFramePr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + if ((pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) && pWriter->m_lGroupIndex >= 0) + { + cNvPr.toXmlWriter2(_T("wpg"), pWriter); + pWriter->WriteString(_T("")); + return; + } + + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX && pWriter->m_lGroupIndex >= 0) + { + pWriter->StartNode(_T("xdr:nvGraphicFramePr")); + pWriter->EndAttributes(); + + cNvPr.toXmlWriter(pWriter); + cNvGraphicFramePr.toXmlWriter(pWriter); + + pWriter->EndNode(_T("xdr:nvGraphicFramePr")); + return; + } + std::wstring namespace_ = m_namespace; + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; + + pWriter->StartNode(namespace_ + L":nvGraphicFramePr"); + pWriter->EndAttributes(); + + cNvPr.toXmlWriter(pWriter); + cNvGraphicFramePr.toXmlWriter(pWriter); + nvPr.toXmlWriter(pWriter); + + pWriter->EndNode(namespace_ + L":nvGraphicFramePr"); + } + void NvGraphicFramePr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord1(0, cNvPr); + pWriter->WriteRecord1(1, cNvGraphicFramePr); + pWriter->WriteRecord1(2, nvPr); + } + void NvGraphicFramePr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + cNvPr.fromPPTY(pReader); + break; + } + case 1: + { + cNvGraphicFramePr.fromPPTY(pReader); + break; + } + case 2: + { + nvPr.fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void NvGraphicFramePr::FillParentPointersForChilds() + { + cNvPr.SetParentPointer(this); + cNvGraphicFramePr.SetParentPointer(this); + nvPr.SetParentPointer(this); + } } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/NvGraphicFramePr.h b/OOXML/PPTXFormat/Logic/NvGraphicFramePr.h index d0d2330de5..f0cec6353c 100644 --- a/OOXML/PPTXFormat/Logic/NvGraphicFramePr.h +++ b/OOXML/PPTXFormat/Logic/NvGraphicFramePr.h @@ -48,158 +48,30 @@ namespace PPTX public: WritingElement_AdditionConstructors(NvGraphicFramePr) - NvGraphicFramePr(std::wstring ns = L"p") : cNvPr(ns), cNvGraphicFramePr(ns), nvPr(ns) - { - m_namespace = ns; - } - NvGraphicFramePr& operator=(const NvGraphicFramePr& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + NvGraphicFramePr(std::wstring ns = L"p"); - cNvPr = oSrc.cNvPr; - cNvGraphicFramePr = oSrc.cNvGraphicFramePr; - nvPr = oSrc.nvPr; + NvGraphicFramePr& operator=(const NvGraphicFramePr& oSrc); - m_namespace = oSrc.m_namespace; + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - return *this; - } + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_namespace = XmlUtils::GetNamespace(node.GetName()); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - cNvPr = node.ReadNodeNoNS(_T("cNvPr")); - cNvGraphicFramePr = node.ReadNodeNoNS(_T("cNvGraphicFramePr")); - nvPr = node.ReadNodeNoNS(_T("nvPr")); - - FillParentPointersForChilds(); - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); - - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); - - if (sName == L"cNvPr") - cNvPr.fromXML( oReader); - else if (sName == L"cNvGraphicFramePr") - cNvGraphicFramePr.fromXML( oReader); - else if (sName == L"nvPr") - nvPr.fromXML( oReader); - } - FillParentPointersForChilds(); - } - - virtual std::wstring toXML() const - { - XmlUtils::CNodeValue oValue; - oValue.Write(cNvPr); - oValue.Write(cNvGraphicFramePr); - oValue.Write(nvPr); - - return XmlUtils::CreateNode(m_namespace + L":nvGraphicFramePr", oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - if ((pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) && pWriter->m_lGroupIndex >= 0) - { - cNvPr.toXmlWriter2(_T("wpg"), pWriter); - pWriter->WriteString(_T("")); - return; - } - - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX && pWriter->m_lGroupIndex >= 0) - { - pWriter->StartNode(_T("xdr:nvGraphicFramePr")); - pWriter->EndAttributes(); - - cNvPr.toXmlWriter(pWriter); - cNvGraphicFramePr.toXmlWriter(pWriter); - - pWriter->EndNode(_T("xdr:nvGraphicFramePr")); - return; - } - std::wstring namespace_ = m_namespace; - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; - - pWriter->StartNode(namespace_ + L":nvGraphicFramePr"); - pWriter->EndAttributes(); - - cNvPr.toXmlWriter(pWriter); - cNvGraphicFramePr.toXmlWriter(pWriter); - nvPr.toXmlWriter(pWriter); - - pWriter->EndNode(namespace_ + L":nvGraphicFramePr"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord1(0, cNvPr); - pWriter->WriteRecord1(1, cNvGraphicFramePr); - pWriter->WriteRecord1(2, nvPr); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - cNvPr.fromPPTY(pReader); - break; - } - case 1: - { - cNvGraphicFramePr.fromPPTY(pReader); - break; - } - case 2: - { - nvPr.fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } - - std::wstring m_namespace; CNvPr cNvPr; CNvGraphicFramePr cNvGraphicFramePr; NvPr nvPr; + protected: - virtual void FillParentPointersForChilds() - { - cNvPr.SetParentPointer(this); - cNvGraphicFramePr.SetParentPointer(this); - nvPr.SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); + }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_NVGRAPHICFRAMEPR_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_NVGRAPHICFRAMEPR_INCLUDE_H diff --git a/OOXML/PPTXFormat/Logic/NvGrpSpPr.cpp b/OOXML/PPTXFormat/Logic/NvGrpSpPr.cpp index 5f73ab3578..1cc0b747e3 100644 --- a/OOXML/PPTXFormat/Logic/NvGrpSpPr.cpp +++ b/OOXML/PPTXFormat/Logic/NvGrpSpPr.cpp @@ -35,7 +35,87 @@ namespace PPTX { namespace Logic { + NvGrpSpPr::NvGrpSpPr(std::wstring ns) + { + m_namespace = ns; + } + NvGrpSpPr& NvGrpSpPr::operator=(const NvGrpSpPr& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + cNvPr = oSrc.cNvPr; + cNvGrpSpPr = oSrc.cNvGrpSpPr; + nvPr = oSrc.nvPr; + return *this; + } + OOX::EElementType NvGrpSpPr::getType () const + { + return OOX::et_p_NvGrpSpPr; + } + void NvGrpSpPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring namespace_ = m_namespace; + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"wpg"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; + + pWriter->StartNode(namespace_ + L":nvGrpSpPr"); + + pWriter->EndAttributes(); + + cNvPr.toXmlWriter(pWriter); + cNvGrpSpPr.toXmlWriter(pWriter); + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_PPTX) + { + nvPr.toXmlWriter(pWriter); + } + + pWriter->EndNode(namespace_ + L":nvGrpSpPr"); + } + void NvGrpSpPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord1(0, cNvPr); + pWriter->WriteRecord1(1, cNvGrpSpPr); + pWriter->WriteRecord1(2, nvPr); + } + void NvGrpSpPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + cNvPr.fromPPTY(pReader); + break; + } + case 1: + { + cNvGrpSpPr.fromPPTY(pReader); + break; + } + case 2: + { + nvPr.fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } void NvGrpSpPr::fromXML(XmlUtils::CXmlNode& node) { m_namespace = XmlUtils::GetNamespace(node.GetName()); @@ -78,13 +158,11 @@ namespace PPTX return XmlUtils::CreateNode(m_namespace + L":nvGrpSpPr", oValue); } - void NvGrpSpPr::FillParentPointersForChilds() { cNvPr.SetParentPointer(this); cNvGrpSpPr.SetParentPointer(this); nvPr.SetParentPointer(this); } - } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/NvGrpSpPr.h b/OOXML/PPTXFormat/Logic/NvGrpSpPr.h index e587b8132b..03695d7b19 100644 --- a/OOXML/PPTXFormat/Logic/NvGrpSpPr.h +++ b/OOXML/PPTXFormat/Logic/NvGrpSpPr.h @@ -42,111 +42,34 @@ namespace PPTX { namespace Logic { - class NvGrpSpPr : public WrapperWritingElement { public: WritingElement_AdditionConstructors(NvGrpSpPr) - NvGrpSpPr(std::wstring ns = L"p") - { - m_namespace = ns; - } + NvGrpSpPr(std::wstring ns = L"p"); - NvGrpSpPr& operator=(const NvGrpSpPr& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + NvGrpSpPr& operator=(const NvGrpSpPr& oSrc); - cNvPr = oSrc.cNvPr; - cNvGrpSpPr = oSrc.cNvGrpSpPr; - nvPr = oSrc.nvPr; - return *this; - } - virtual OOX::EElementType getType () const - { - return OOX::et_p_NvGrpSpPr; - } + virtual OOX::EElementType getType () const; virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); virtual void fromXML(XmlUtils::CXmlNode& node); virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring namespace_ = m_namespace; - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"wpg"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; - - pWriter->StartNode(namespace_ + L":nvGrpSpPr"); - - pWriter->EndAttributes(); - - cNvPr.toXmlWriter(pWriter); - cNvGrpSpPr.toXmlWriter(pWriter); - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_PPTX) - { - nvPr.toXmlWriter(pWriter); - } - - pWriter->EndNode(namespace_ + L":nvGrpSpPr"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord1(0, cNvPr); - pWriter->WriteRecord1(1, cNvGrpSpPr); - pWriter->WriteRecord1(2, nvPr); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - cNvPr.fromPPTY(pReader); - break; - } - case 1: - { - cNvGrpSpPr.fromPPTY(pReader); - break; - } - case 2: - { - nvPr.fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); std::wstring m_namespace; CNvPr cNvPr; CNvGrpSpPr cNvGrpSpPr; NvPr nvPr; + protected: virtual void FillParentPointersForChilds(); - }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/NvPicPr.cpp b/OOXML/PPTXFormat/Logic/NvPicPr.cpp new file mode 100644 index 0000000000..912aecfbdd --- /dev/null +++ b/OOXML/PPTXFormat/Logic/NvPicPr.cpp @@ -0,0 +1,181 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "NvPicPr.h" + +namespace PPTX +{ + namespace Logic + { + NvPicPr::NvPicPr(std::wstring ns) + { + m_namespace = ns; + } + NvPicPr& NvPicPr::operator=(const NvPicPr& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + cNvPr = oSrc.cNvPr; + cNvPicPr = oSrc.cNvPicPr; + nvPr = oSrc.nvPr; + + m_namespace = oSrc.m_namespace; + + return *this; + } + void NvPicPr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (_T("cNvPr") == strName) + cNvPr.fromXML( oReader); + else if (_T("cNvPicPr") == strName) + cNvPicPr.fromXML( oReader); + else if (_T("nvPr") == strName) + nvPr.fromXML( oReader); + } + } + void NvPicPr::fromXML(XmlUtils::CXmlNode& node) + { + m_namespace = XmlUtils::GetNamespace(node.GetName()); + + XmlUtils::CXmlNodes oNodes; + if (node.GetNodes(_T("*"), oNodes)) + { + int nCount = oNodes.GetCount(); + for (int i = 0; i < nCount; ++i) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(i, oNode); + + std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); + + if (_T("cNvPr") == strName) + cNvPr = oNode; + else if (_T("cNvPicPr") == strName) + cNvPicPr = oNode; + else if (_T("nvPr") == strName) + nvPr = oNode; + } + } + + FillParentPointersForChilds(); + } + std::wstring NvPicPr::toXML() const + { + XmlUtils::CNodeValue oValue; + oValue.Write(cNvPr); + oValue.Write(cNvPicPr); + oValue.Write(nvPr); + + return XmlUtils::CreateNode(m_namespace + L":nvPicPr", oValue); + } + void NvPicPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring namespace_ = m_namespace; + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"pic"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; + + pWriter->StartNode(namespace_ + L":nvPicPr"); + + pWriter->EndAttributes(); + + cNvPr.toXmlWriter(pWriter); + cNvPicPr.toXmlWriter(pWriter); + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_PPTX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) + nvPr.toXmlWriter(pWriter); + + pWriter->EndNode(namespace_ + L":nvPicPr"); + } + void NvPicPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord1(0, cNvPr); + pWriter->WriteRecord1(1, cNvPicPr); + pWriter->WriteRecord1(2, nvPr); + } + void NvPicPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + cNvPr.fromPPTY(pReader); + break; + } + case 1: + { + cNvPicPr.fromPPTY(pReader); + break; + } + case 2: + { + nvPr.fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void NvPicPr::FillParentPointersForChilds() + { + cNvPr.SetParentPointer(this); + cNvPicPr.SetParentPointer(this); + nvPr.SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/NvPicPr.h b/OOXML/PPTXFormat/Logic/NvPicPr.h index e6e3d0e08d..32c90608e9 100644 --- a/OOXML/PPTXFormat/Logic/NvPicPr.h +++ b/OOXML/PPTXFormat/Logic/NvPicPr.h @@ -48,160 +48,29 @@ namespace PPTX public: WritingElement_AdditionConstructors(NvPicPr) - NvPicPr(std::wstring ns = L"p") - { - m_namespace = ns; - } - NvPicPr& operator=(const NvPicPr& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + NvPicPr(std::wstring ns = L"p"); - cNvPr = oSrc.cNvPr; - cNvPicPr = oSrc.cNvPicPr; - nvPr = oSrc.nvPr; + NvPicPr& operator=(const NvPicPr& oSrc); - m_namespace = oSrc.m_namespace; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - return *this; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - if (_T("cNvPr") == strName) - cNvPr.fromXML( oReader); - else if (_T("cNvPicPr") == strName) - cNvPicPr.fromXML( oReader); - else if (_T("nvPr") == strName) - nvPr.fromXML( oReader); - } - } - - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_namespace = XmlUtils::GetNamespace(node.GetName()); - - XmlUtils::CXmlNodes oNodes; - if (node.GetNodes(_T("*"), oNodes)) - { - int nCount = oNodes.GetCount(); - for (int i = 0; i < nCount; ++i) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(i, oNode); - - std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); - - if (_T("cNvPr") == strName) - cNvPr = oNode; - else if (_T("cNvPicPr") == strName) - cNvPicPr = oNode; - else if (_T("nvPr") == strName) - nvPr = oNode; - } - } - - FillParentPointersForChilds(); - } - - virtual std::wstring toXML() const - { - XmlUtils::CNodeValue oValue; - oValue.Write(cNvPr); - oValue.Write(cNvPicPr); - oValue.Write(nvPr); - - return XmlUtils::CreateNode(m_namespace + L":nvPicPr", oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring namespace_ = m_namespace; - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"pic"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; - - pWriter->StartNode(namespace_ + L":nvPicPr"); - - pWriter->EndAttributes(); - - cNvPr.toXmlWriter(pWriter); - cNvPicPr.toXmlWriter(pWriter); - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_PPTX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) - nvPr.toXmlWriter(pWriter); - - pWriter->EndNode(namespace_ + L":nvPicPr"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord1(0, cNvPr); - pWriter->WriteRecord1(1, cNvPicPr); - pWriter->WriteRecord1(2, nvPr); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - cNvPr.fromPPTY(pReader); - break; - } - case 1: - { - cNvPicPr.fromPPTY(pReader); - break; - } - case 2: - { - nvPr.fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } std::wstring m_namespace; CNvPr cNvPr; CNvPicPr cNvPicPr; NvPr nvPr; + protected: - virtual void FillParentPointersForChilds() - { - cNvPr.SetParentPointer(this); - cNvPicPr.SetParentPointer(this); - nvPr.SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_NVPICPR_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_NVPICPR_INCLUDE_H diff --git a/OOXML/PPTXFormat/Logic/NvPr.cpp b/OOXML/PPTXFormat/Logic/NvPr.cpp new file mode 100644 index 0000000000..4c4a82170d --- /dev/null +++ b/OOXML/PPTXFormat/Logic/NvPr.cpp @@ -0,0 +1,235 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "NvPr.h" + +namespace PPTX +{ + namespace Logic + { + NvPr::NvPr(std::wstring ns) + { + m_namespace = ns; + } + NvPr& NvPr::operator=(const NvPr& oSrc) + { + isPhoto = oSrc.isPhoto; + userDrawn = oSrc.userDrawn; + media = oSrc.media; + ph = oSrc.ph; + + for (size_t i=0; i < oSrc.extLst.size(); i++) + extLst.push_back(oSrc.extLst[i]); + + return *this; + } + void NvPr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + ReadAttributes(oReader); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (strName == L"ph") + ph = oReader; + else if (strName == L"extLst") + { + if ( oReader.IsEmptyNode() ) + continue; + + int nParentDepth1 = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) + { + Ext element(oReader); + extLst.push_back(element); + } + } + else + { + media.fromXML(oReader); + } + } + } + void NvPr::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, L"isPhoto", isPhoto) + WritingElement_ReadAttributes_Read_else_if ( oReader, L"userDrawn", userDrawn) + WritingElement_ReadAttributes_End( oReader ) + } + void NvPr::fromXML(XmlUtils::CXmlNode& node) + { + m_namespace = XmlUtils::GetNamespace(node.GetName()); + + XmlMacroReadAttributeBase(node, L"isPhoto", isPhoto); + XmlMacroReadAttributeBase(node, L"userDrawn", userDrawn); + + ph = node.ReadNodeNoNS(L"ph"); + media.GetMediaFrom(node); + + XmlUtils::CXmlNode list = node.ReadNodeNoNS(L"extLst"); + if (list.IsValid()) + { + XmlUtils::CXmlNodes oNodes; + if (list.GetNodes(_T("*"), oNodes)) + { + int nCount = oNodes.GetCount(); + for (int i = 0; i < nCount; ++i) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(i, oNode); + + Ext element; + element.fromXML(oNode); + extLst.push_back (element); + } + } + } + } + std::wstring NvPr::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(L"isPhoto", isPhoto); + oAttr.Write(L"userDrawn", userDrawn); + + XmlUtils::CNodeValue oValue; + oValue.WriteNullable(ph); + oValue.Write(media); + + return XmlUtils::CreateNode(L"p:nvPr", oAttr, oValue); + + } + void NvPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring namespace_ = m_namespace; + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_= L"pic"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_= L"xdr"; + + toXmlWriter2(namespace_, pWriter); + } + void NvPr::toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(strNS + L":nvPr"); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(L"isPhoto", isPhoto); + pWriter->WriteAttribute(L"userDrawn", userDrawn); + pWriter->EndAttributes(); + + pWriter->Write(ph); + media.toXmlWriter(pWriter); + + std::wstring namespace_extLst = L"a"; + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_PPTX) namespace_extLst = L"p"; + + pWriter->WriteArray(namespace_extLst + L":extLst", extLst); + + pWriter->EndNode(strNS + L":nvPr"); + } + void NvPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteBool2(0, isPhoto); + pWriter->WriteBool2(1, userDrawn); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, ph); + pWriter->WriteRecord1(1, media); + pWriter->WriteRecordArray(2, 0, extLst); + } + void NvPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + isPhoto = pReader->GetBool(); + break; + } + case 1: + { + userDrawn = pReader->GetBool(); + break; + } + default: + break; + } + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + ph = new Ph(); + ph->fromPPTY(pReader); + break; + } + default: + { + pReader->SkipRecord(); + break; + } + } + } + + pReader->Seek(_end_rec); + } + void NvPr::FillParentPointersForChilds() + { + if(ph.IsInit()) + ph->SetParentPointer(this); + if(media.is_init()) + media.SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/NvPr.h b/OOXML/PPTXFormat/Logic/NvPr.h index 0e9542f7f5..921d5562c8 100644 --- a/OOXML/PPTXFormat/Logic/NvPr.h +++ b/OOXML/PPTXFormat/Logic/NvPr.h @@ -46,196 +46,21 @@ namespace PPTX public: WritingElement_AdditionConstructors(NvPr) - NvPr(std::wstring ns = L"p") - { - m_namespace = ns; - } - NvPr& operator=(const NvPr& oSrc) - { - isPhoto = oSrc.isPhoto; - userDrawn = oSrc.userDrawn; - media = oSrc.media; - ph = oSrc.ph; + NvPr(std::wstring ns = L"p"); - for (size_t i=0; i < oSrc.extLst.size(); i++) - extLst.push_back(oSrc.extLst[i]); - - return *this; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); - - ReadAttributes(oReader); + NvPr& operator=(const NvPr& oSrc); - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - if (strName == L"ph") - ph = oReader; - else if (strName == L"extLst") - { - if ( oReader.IsEmptyNode() ) - continue; + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + void toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const; - int nParentDepth1 = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) - { - Ext element(oReader); - extLst.push_back(element); - } - } - else - { - media.fromXML(oReader); - } - } - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, L"isPhoto", isPhoto) - WritingElement_ReadAttributes_Read_else_if ( oReader, L"userDrawn", userDrawn) - WritingElement_ReadAttributes_End( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_namespace = XmlUtils::GetNamespace(node.GetName()); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - XmlMacroReadAttributeBase(node, L"isPhoto", isPhoto); - XmlMacroReadAttributeBase(node, L"userDrawn", userDrawn); - - ph = node.ReadNodeNoNS(L"ph"); - media.GetMediaFrom(node); - - XmlUtils::CXmlNode list = node.ReadNodeNoNS(L"extLst"); - if (list.IsValid()) - { - XmlUtils::CXmlNodes oNodes; - if (list.GetNodes(_T("*"), oNodes)) - { - int nCount = oNodes.GetCount(); - for (int i = 0; i < nCount; ++i) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(i, oNode); - - Ext element; - element.fromXML(oNode); - extLst.push_back (element); - } - } - } - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(L"isPhoto", isPhoto); - oAttr.Write(L"userDrawn", userDrawn); - - XmlUtils::CNodeValue oValue; - oValue.WriteNullable(ph); - oValue.Write(media); - - return XmlUtils::CreateNode(L"p:nvPr", oAttr, oValue); - - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring namespace_ = m_namespace; - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_= L"pic"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_= L"xdr"; - - toXmlWriter2(namespace_, pWriter); - } - void toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(strNS + L":nvPr"); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(L"isPhoto", isPhoto); - pWriter->WriteAttribute(L"userDrawn", userDrawn); - pWriter->EndAttributes(); - - pWriter->Write(ph); - media.toXmlWriter(pWriter); - - std::wstring namespace_extLst = L"a"; - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_PPTX) namespace_extLst = L"p"; - - pWriter->WriteArray(namespace_extLst + L":extLst", extLst); - - pWriter->EndNode(strNS + L":nvPr"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteBool2(0, isPhoto); - pWriter->WriteBool2(1, userDrawn); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, ph); - pWriter->WriteRecord1(1, media); - pWriter->WriteRecordArray(2, 0, extLst); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - isPhoto = pReader->GetBool(); - break; - } - case 1: - { - userDrawn = pReader->GetBool(); - break; - } - default: - break; - } - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - ph = new Ph(); - ph->fromPPTY(pReader); - break; - } - default: - { - pReader->SkipRecord(); - break; - } - } - } - - pReader->Seek(_end_rec); - } std::wstring m_namespace; // Attributes nullable_bool isPhoto; @@ -246,14 +71,9 @@ namespace PPTX UniMedia media; //custDataLst std::vector extLst; + protected: - virtual void FillParentPointersForChilds() - { - if(ph.IsInit()) - ph->SetParentPointer(this); - if(media.is_init()) - media.SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/NvSpPr.cpp b/OOXML/PPTXFormat/Logic/NvSpPr.cpp new file mode 100644 index 0000000000..415bd16599 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/NvSpPr.cpp @@ -0,0 +1,178 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "NvSpPr.h" + +namespace PPTX +{ + namespace Logic + { + NvSpPr::NvSpPr(std::wstring ns) + { + m_namespace = ns; + } + NvSpPr& NvSpPr::operator=(const NvSpPr& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + cNvPr = oSrc.cNvPr; + cNvSpPr = oSrc.cNvSpPr; + nvPr = oSrc.nvPr; + return *this; + } + void NvSpPr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (_T("cNvPr") == strName) + cNvPr = oReader; + else if (_T("cNvSpPr") == strName) + cNvSpPr = oReader; + else if (_T("nvPr") == strName) + nvPr = oReader; + } + + FillParentPointersForChilds(); + } + void NvSpPr::fromXML(XmlUtils::CXmlNode& node) + { + m_namespace = XmlUtils::GetNamespace(node.GetName()); + + XmlUtils::CXmlNodes oNodes; + if (node.GetNodes(_T("*"), oNodes)) + { + int nCount = oNodes.GetCount(); + for (int i = 0; i < nCount; ++i) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(i, oNode); + + std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); + + if (_T("cNvPr") == strName) + cNvPr = oNode; + else if (_T("cNvSpPr") == strName) + cNvSpPr = oNode; + else if (_T("nvPr") == strName) + nvPr = oNode; + } + } + + FillParentPointersForChilds(); + } + std::wstring NvSpPr::toXML() const + { + XmlUtils::CNodeValue oValue; + oValue.Write(cNvPr); + oValue.Write(cNvSpPr); + oValue.Write(nvPr); + + return XmlUtils::CreateNode(m_namespace + L":nvSpPr", oValue); + } + void NvSpPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring namespace_ = m_namespace; + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"wps"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; + + pWriter->StartNode( namespace_ + L":nvSpPr"); + + pWriter->EndAttributes(); + + cNvPr.toXmlWriter(pWriter); + cNvSpPr.toXmlWriter(pWriter); + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_PPTX) + nvPr.toXmlWriter(pWriter); + + pWriter->EndNode( namespace_ + L":nvSpPr"); + } + void NvSpPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord1(0, cNvPr); + pWriter->WriteRecord1(1, cNvSpPr); + pWriter->WriteRecord1(2, nvPr); + } + void NvSpPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + cNvPr.fromPPTY(pReader); + break; + } + case 1: + { + cNvSpPr.fromPPTY(pReader); + break; + } + case 2: + { + nvPr.fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void NvSpPr::FillParentPointersForChilds() + { + cNvPr.SetParentPointer(this); + cNvSpPr.SetParentPointer(this); + nvPr.SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/NvSpPr.h b/OOXML/PPTXFormat/Logic/NvSpPr.h index 7502ca377c..ae90f9edd7 100644 --- a/OOXML/PPTXFormat/Logic/NvSpPr.h +++ b/OOXML/PPTXFormat/Logic/NvSpPr.h @@ -48,157 +48,28 @@ namespace PPTX public: WritingElement_AdditionConstructors(NvSpPr) - NvSpPr(std::wstring ns = L"p") - { - m_namespace = ns; - } + NvSpPr(std::wstring ns = L"p"); + NvSpPr& operator=(const NvSpPr& oSrc); - NvSpPr& operator=(const NvSpPr& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - cNvPr = oSrc.cNvPr; - cNvSpPr = oSrc.cNvSpPr; - nvPr = oSrc.nvPr; - return *this; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); - - if (_T("cNvPr") == strName) - cNvPr = oReader; - else if (_T("cNvSpPr") == strName) - cNvSpPr = oReader; - else if (_T("nvPr") == strName) - nvPr = oReader; - } - - FillParentPointersForChilds(); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_namespace = XmlUtils::GetNamespace(node.GetName()); - - XmlUtils::CXmlNodes oNodes; - if (node.GetNodes(_T("*"), oNodes)) - { - int nCount = oNodes.GetCount(); - for (int i = 0; i < nCount; ++i) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(i, oNode); - - std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); - - if (_T("cNvPr") == strName) - cNvPr = oNode; - else if (_T("cNvSpPr") == strName) - cNvSpPr = oNode; - else if (_T("nvPr") == strName) - nvPr = oNode; - } - } - - FillParentPointersForChilds(); - } - virtual std::wstring toXML() const - { - XmlUtils::CNodeValue oValue; - oValue.Write(cNvPr); - oValue.Write(cNvSpPr); - oValue.Write(nvPr); - - return XmlUtils::CreateNode(m_namespace + L":nvSpPr", oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring namespace_ = m_namespace; - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = L"wps"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = L"a"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = L"cdr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = L"dgm"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = L"dsp"; - - pWriter->StartNode( namespace_ + L":nvSpPr"); - - pWriter->EndAttributes(); - - cNvPr.toXmlWriter(pWriter); - cNvSpPr.toXmlWriter(pWriter); - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_PPTX) - nvPr.toXmlWriter(pWriter); - - pWriter->EndNode( namespace_ + L":nvSpPr"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord1(0, cNvPr); - pWriter->WriteRecord1(1, cNvSpPr); - pWriter->WriteRecord1(2, nvPr); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - cNvPr.fromPPTY(pReader); - break; - } - case 1: - { - cNvSpPr.fromPPTY(pReader); - break; - } - case 2: - { - nvPr.fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); std::wstring m_namespace; CNvPr cNvPr; CNvSpPr cNvSpPr; NvPr nvPr; + protected: - virtual void FillParentPointersForChilds() - { - cNvPr.SetParentPointer(this); - cNvSpPr.SetParentPointer(this); - nvPr.SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_NVSPPR_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_NVSPPR_INCLUDE_H diff --git a/OOXML/PPTXFormat/Logic/Paragraph.cpp b/OOXML/PPTXFormat/Logic/Paragraph.cpp new file mode 100644 index 0000000000..c88eaa2b40 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Paragraph.cpp @@ -0,0 +1,392 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Paragraph.h" + +namespace PPTX +{ + namespace Logic + { + Paragraph& Paragraph::operator=(const Paragraph& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + pPr = oSrc.pPr; + endParaRPr = oSrc.endParaRPr; + + for (size_t i=0 ; i < oSrc.RunElems.size(); i++) + { + RunElems.push_back(oSrc.RunElems[i]); + } + + return *this; + } + void Paragraph::fromXML2(XmlUtils::CXmlNode& node, bool bClear) + { + if (bClear) + { + RunElems.clear(); + } + + XmlUtils::CXmlNodes oNodes; + if (node.GetNodes(_T("*"), oNodes)) + { + int nCount = oNodes.GetCount(); + for (int i = 0; i < nCount; ++i) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(i, oNode); + + std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); + + if (_T("pPr") == strName) + pPr = oNode; + else if (_T("endParaRPr") == strName) + endParaRPr = oNode; + else if ((_T("r") == strName) || (_T("fld") == strName) || (_T("br") == strName) || (_T("m") == strName)) + RunElems.push_back(RunElem(oNode)); + else if (_T("AlternateContent") == strName) + { + //code as in SpTreeElem.cpp + XmlUtils::CXmlNode oNodeChoice; + if (oNode.GetNode(_T("mc:Choice"), oNodeChoice)) + { + XmlUtils::CXmlNode oNodeFall; + std::wstring sRequires; + //todo better check (a14 can be math, slicer) + if(oNodeChoice.GetAttributeIfExist(L"Requires", sRequires) && L"a14" == sRequires) + { + fromXML2(oNodeChoice, false); + } + else if (oNode.GetNode(_T("mc:Fallback"), oNodeFall)) + { + fromXML2(oNodeFall, false); + } + } + } + } + } + + FillParentPointersForChilds(); + } + void Paragraph::fromXML2(XmlUtils::CXmlLiteReader& oReader, bool bClear) + { + if (bClear) + { + RunElems.clear(); + } + + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (_T("pPr") == strName) + pPr = oReader; + else if (_T("endParaRPr") == strName) + endParaRPr = oReader; + else if ((_T("r") == strName) || (_T("fld") == strName) || (_T("br") == strName) || (_T("m") == strName)) + RunElems.push_back(RunElem(oReader)); + else if (_T("AlternateContent") == strName) + { + if ( oReader.IsEmptyNode() ) + continue; + + int nParentDepth1 = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) + { + std::wstring strName1 = oReader.GetName(); + if (_T("mc:Choice") == strName1) + {//GetAttributeIfExist(L"Requires", sRequires) && L"a14" == sRequires) + fromXML2(oReader, false); + break; + } + else if (_T("mc:Fallback") == strName1) + { + fromXML2(oReader, false); + } + + } + } + } + } + void Paragraph::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start ( oReader ) + WritingElement_ReadAttributes_End ( oReader ) + } + void Paragraph::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + fromXML2(oReader, true); + } + OOX::EElementType Paragraph::getType() const + { + return OOX::et_a_p; + } + void Paragraph::fromXML(XmlUtils::CXmlNode& node) + { + fromXML2(node, true); + } + void Paragraph::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:p")); + pWriter->EndAttributes(); + + if (pPr.is_init()) + pPr->m_name = _T("a:pPr"); + pWriter->Write(pPr); + + size_t nCount = RunElems.size(); + for (size_t i = 0; i < nCount; ++i) + RunElems[i].toXmlWriter(pWriter); + + pWriter->Write(endParaRPr); + + pWriter->EndNode(_T("a:p")); + } + void Paragraph::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord2(0, pPr); + pWriter->WriteRecord2(1, endParaRPr); + pWriter->WriteRecordArray(2, 0, RunElems); + } + void Paragraph::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + pPr = new Logic::TextParagraphPr(); + pPr->fromPPTY(pReader); + break; + } + case 1: + { + endParaRPr = new Logic::RunProperties(); + endParaRPr->m_name = _T("a:endParaRPr"); + endParaRPr->fromPPTY(pReader); + break; + } + case 2: + { + pReader->Skip(4); + + ULONG _c = pReader->GetULong(); + for (ULONG i = 0; i < _c; ++i) + { + pReader->Skip(5); // type (0) + len + BYTE _type = pReader->GetUChar(); + + switch (_type) + { + case PARRUN_TYPE_RUN: + { + LONG _end = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attr + + Logic::Run* pRun = new Logic::Run(); + + while (true) + { + BYTE _at2 = pReader->GetUChar_TypeNode(); + + if (_at2 == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at2) + pRun->SetText(pReader->GetString2()); + } + + while (pReader->GetPos() < _end) + { + BYTE _rec = pReader->GetUChar(); + + if (0 == _rec) + { + pRun->rPr = new Logic::RunProperties(); + pRun->rPr->m_name = _T("a:rPr"); + pRun->rPr->fromPPTY(pReader); + } + else + pReader->SkipRecord(); + } + + RunElem elm; + RunElems.push_back(elm); + RunElems.back().InitRun(pRun); + + pReader->Seek(_end); + }break; + case PARRUN_TYPE_FLD: + { + LONG _end = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attr + + Logic::Fld* pRun = new Logic::Fld(); + + while (true) + { + BYTE _at2 = pReader->GetUChar_TypeNode(); + if (_at2 == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at2) + pRun->id = pReader->GetString2(); + else if (1 == _at2) + pRun->type = pReader->GetString2(); + else if (2 == _at2) + pRun->SetText(pReader->GetString2()); + } + + while (pReader->GetPos() < _end) + { + BYTE _rec = pReader->GetUChar(); + + if (0 == _rec) + { + pRun->rPr = new Logic::RunProperties(); + pRun->rPr->m_name = _T("a:rPr"); + pRun->rPr->fromPPTY(pReader); + } + else if (1 == _rec) + { + pRun->pPr = new Logic::TextParagraphPr(); + pRun->pPr->m_name = _T("a:pPr"); + pRun->pPr->fromPPTY(pReader); + } + else + pReader->SkipRecord(); + } + RunElem elm; + RunElems.push_back(elm); + RunElems.back().InitRun(pRun); + + pReader->Seek(_end); + }break; + case PARRUN_TYPE_BR: + { + LONG _end = pReader->GetPos() + pReader->GetRecordSize() + 4; + + Logic::Br* pRun = new Logic::Br(); + while (pReader->GetPos() < _end) + { + BYTE _rec = pReader->GetUChar(); + + if (0 == _rec) + { + pRun->rPr = new Logic::RunProperties(); + pRun->rPr->m_name = _T("a:rPr"); + pRun->rPr->fromPPTY(pReader); + } + else + pReader->SkipRecord(); + } + + RunElem elm; + RunElems.push_back(elm); + RunElems.back().InitRun(pRun); + + pReader->Seek(_end); + }break; + case PARRUN_TYPE_MATH: + { + Logic::MathParaWrapper* pRun = new Logic::MathParaWrapper(); + pRun->fromPPTY(_type, pReader); + + RunElem elm; + RunElems.push_back(elm); + RunElems.back().InitRun(pRun); + }break; + case PARRUN_TYPE_MATHPARA: + { + Logic::MathParaWrapper* pRun = new Logic::MathParaWrapper(); + pRun->fromPPTY(_type, pReader); + + RunElem elm; + RunElems.push_back(elm); + RunElems.back().InitRun(pRun); + }break; + default: + break; + } + } + break; + } + default: + { + break; + } + } + } + pReader->Seek(_end_rec); + } + std::wstring Paragraph::GetText(bool bParagraphSeparator) const + { + std::wstring result = _T(""); + + for (size_t i = 0; i < RunElems.size(); ++i) + { + result += RunElems[i].GetText(); + } + + if (bParagraphSeparator) + { + result = result + _T("\n"); + } + return result; + } + void Paragraph::FillParentPointersForChilds() + { + if(pPr.IsInit()) + pPr->SetParentPointer(this); + if(endParaRPr.IsInit()) + endParaRPr->SetParentPointer(this); + + size_t count = RunElems.size(); + for (size_t i = 0; i < count; ++i) + RunElems[i].SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Paragraph.h b/OOXML/PPTXFormat/Logic/Paragraph.h index 796a0b19ab..b56f6f5d7f 100644 --- a/OOXML/PPTXFormat/Logic/Paragraph.h +++ b/OOXML/PPTXFormat/Logic/Paragraph.h @@ -48,371 +48,33 @@ namespace PPTX WritingElement_AdditionConstructors(Paragraph) PPTX_LOGIC_BASE2(Paragraph) - Paragraph& operator=(const Paragraph& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + Paragraph& operator=(const Paragraph& oSrc); - pPr = oSrc.pPr; - endParaRPr = oSrc.endParaRPr; - - for (size_t i=0 ; i < oSrc.RunElems.size(); i++) - { - RunElems.push_back(oSrc.RunElems[i]); - } - - return *this; - } private: - virtual void fromXML2(XmlUtils::CXmlNode& node, bool bClear) - { - if (bClear) - { - RunElems.clear(); - } + virtual void fromXML2(XmlUtils::CXmlNode& node, bool bClear); + virtual void fromXML2(XmlUtils::CXmlLiteReader& oReader, bool bClear); - XmlUtils::CXmlNodes oNodes; - if (node.GetNodes(_T("*"), oNodes)) - { - int nCount = oNodes.GetCount(); - for (int i = 0; i < nCount; ++i) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(i, oNode); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); - - if (_T("pPr") == strName) - pPr = oNode; - else if (_T("endParaRPr") == strName) - endParaRPr = oNode; - else if ((_T("r") == strName) || (_T("fld") == strName) || (_T("br") == strName) || (_T("m") == strName)) - RunElems.push_back(RunElem(oNode)); - else if (_T("AlternateContent") == strName) - { - //code as in SpTreeElem.cpp - XmlUtils::CXmlNode oNodeChoice; - if (oNode.GetNode(_T("mc:Choice"), oNodeChoice)) - { - XmlUtils::CXmlNode oNodeFall; - std::wstring sRequires; - //todo better check (a14 can be math, slicer) - if(oNodeChoice.GetAttributeIfExist(L"Requires", sRequires) && L"a14" == sRequires) - { - fromXML2(oNodeChoice, false); - } - else if (oNode.GetNode(_T("mc:Fallback"), oNodeFall)) - { - fromXML2(oNodeFall, false); - } - } - } - } - } - - FillParentPointersForChilds(); - } - virtual void fromXML2(XmlUtils::CXmlLiteReader& oReader, bool bClear) - { - if (bClear) - { - RunElems.clear(); - } - - ReadAttributes( oReader ); - - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); - - if (_T("pPr") == strName) - pPr = oReader; - else if (_T("endParaRPr") == strName) - endParaRPr = oReader; - else if ((_T("r") == strName) || (_T("fld") == strName) || (_T("br") == strName) || (_T("m") == strName)) - RunElems.push_back(RunElem(oReader)); - else if (_T("AlternateContent") == strName) - { - if ( oReader.IsEmptyNode() ) - continue; - - int nParentDepth1 = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) - { - std::wstring strName1 = oReader.GetName(); - if (_T("mc:Choice") == strName1) - {//GetAttributeIfExist(L"Requires", sRequires) && L"a14" == sRequires) - fromXML2(oReader, false); - break; - } - else if (_T("mc:Fallback") == strName1) - { - fromXML2(oReader, false); - } - - } - } - } - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start ( oReader ) - WritingElement_ReadAttributes_End ( oReader ) - } public: - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - fromXML2(oReader, true); - } - virtual OOX::EElementType getType() const - { - return OOX::et_a_p; - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - fromXML2(node, true); - } + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual OOX::EElementType getType() const; - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:p")); - pWriter->EndAttributes(); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - if (pPr.is_init()) - pPr->m_name = _T("a:pPr"); - pWriter->Write(pPr); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - size_t nCount = RunElems.size(); - for (size_t i = 0; i < nCount; ++i) - RunElems[i].toXmlWriter(pWriter); - - pWriter->Write(endParaRPr); - - pWriter->EndNode(_T("a:p")); - } - - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord2(0, pPr); - pWriter->WriteRecord2(1, endParaRPr); - pWriter->WriteRecordArray(2, 0, RunElems); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - pPr = new Logic::TextParagraphPr(); - pPr->fromPPTY(pReader); - break; - } - case 1: - { - endParaRPr = new Logic::RunProperties(); - endParaRPr->m_name = _T("a:endParaRPr"); - endParaRPr->fromPPTY(pReader); - break; - } - case 2: - { - pReader->Skip(4); - - ULONG _c = pReader->GetULong(); - for (ULONG i = 0; i < _c; ++i) - { - pReader->Skip(5); // type (0) + len - BYTE _type = pReader->GetUChar(); - - switch (_type) - { - case PARRUN_TYPE_RUN: - { - LONG _end = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attr - - Logic::Run* pRun = new Logic::Run(); - - while (true) - { - BYTE _at2 = pReader->GetUChar_TypeNode(); - - if (_at2 == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at2) - pRun->SetText(pReader->GetString2()); - } - - while (pReader->GetPos() < _end) - { - BYTE _rec = pReader->GetUChar(); - - if (0 == _rec) - { - pRun->rPr = new Logic::RunProperties(); - pRun->rPr->m_name = _T("a:rPr"); - pRun->rPr->fromPPTY(pReader); - } - else - pReader->SkipRecord(); - } - - RunElem elm; - RunElems.push_back(elm); - RunElems.back().InitRun(pRun); - - pReader->Seek(_end); - }break; - case PARRUN_TYPE_FLD: - { - LONG _end = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attr - - Logic::Fld* pRun = new Logic::Fld(); - - while (true) - { - BYTE _at2 = pReader->GetUChar_TypeNode(); - if (_at2 == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at2) - pRun->id = pReader->GetString2(); - else if (1 == _at2) - pRun->type = pReader->GetString2(); - else if (2 == _at2) - pRun->SetText(pReader->GetString2()); - } - - while (pReader->GetPos() < _end) - { - BYTE _rec = pReader->GetUChar(); - - if (0 == _rec) - { - pRun->rPr = new Logic::RunProperties(); - pRun->rPr->m_name = _T("a:rPr"); - pRun->rPr->fromPPTY(pReader); - } - else if (1 == _rec) - { - pRun->pPr = new Logic::TextParagraphPr(); - pRun->pPr->m_name = _T("a:pPr"); - pRun->pPr->fromPPTY(pReader); - } - else - pReader->SkipRecord(); - } - RunElem elm; - RunElems.push_back(elm); - RunElems.back().InitRun(pRun); - - pReader->Seek(_end); - }break; - case PARRUN_TYPE_BR: - { - LONG _end = pReader->GetPos() + pReader->GetRecordSize() + 4; - - Logic::Br* pRun = new Logic::Br(); - while (pReader->GetPos() < _end) - { - BYTE _rec = pReader->GetUChar(); - - if (0 == _rec) - { - pRun->rPr = new Logic::RunProperties(); - pRun->rPr->m_name = _T("a:rPr"); - pRun->rPr->fromPPTY(pReader); - } - else - pReader->SkipRecord(); - } - - RunElem elm; - RunElems.push_back(elm); - RunElems.back().InitRun(pRun); - - pReader->Seek(_end); - }break; - case PARRUN_TYPE_MATH: - { - Logic::MathParaWrapper* pRun = new Logic::MathParaWrapper(); - pRun->fromPPTY(_type, pReader); - - RunElem elm; - RunElems.push_back(elm); - RunElems.back().InitRun(pRun); - }break; - case PARRUN_TYPE_MATHPARA: - { - Logic::MathParaWrapper* pRun = new Logic::MathParaWrapper(); - pRun->fromPPTY(_type, pReader); - - RunElem elm; - RunElems.push_back(elm); - RunElems.back().InitRun(pRun); - }break; - default: - break; - } - } - break; - } - default: - { - break; - } - } - } - pReader->Seek(_end_rec); - } - - std::wstring GetText(bool bParagraphSeparator = true)const - { - std::wstring result = _T(""); - - for (size_t i = 0; i < RunElems.size(); ++i) - { - result += RunElems[i].GetText(); - } - - if (bParagraphSeparator) - { - result = result + _T("\n"); - } - return result; - } + std::wstring GetText(bool bParagraphSeparator = true) const; public: nullable pPr; std::vector RunElems; nullable endParaRPr; - protected: - virtual void FillParentPointersForChilds() - { - if(pPr.IsInit()) - pPr->SetParentPointer(this); - if(endParaRPr.IsInit()) - endParaRPr->SetParentPointer(this); - size_t count = RunElems.size(); - for (size_t i = 0; i < count; ++i) - RunElems[i].SetParentPointer(this); - } + protected: + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/ContentPart.h b/OOXML/PPTXFormat/Logic/PartTitle.cpp similarity index 75% rename from OOXML/PPTXFormat/Logic/ContentPart.h rename to OOXML/PPTXFormat/Logic/PartTitle.cpp index 7aedbea561..a1cd194753 100644 --- a/OOXML/PPTXFormat/Logic/ContentPart.h +++ b/OOXML/PPTXFormat/Logic/PartTitle.cpp @@ -1,4 +1,4 @@ -/* +/* * (c) Copyright Ascensio System SIA 2010-2019 * * This program is a free software product. You can redistribute it and/or @@ -29,3 +29,27 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ + +#include "PartTitle.h" + +namespace PPTX +{ + namespace Logic + { + void PartTitle::fromXML(XmlUtils::CXmlNode& node) + { + m_title = node.GetTextExt(); + } + std::wstring PartTitle::toXML() const + { + return _T("") + m_title + _T(""); + } + void PartTitle::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->WriteNodeValue(_T("vt:lpstr"), m_title); + } + void PartTitle::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/PartTitle.h b/OOXML/PPTXFormat/Logic/PartTitle.h index e140aaf154..dc3e5be5ad 100644 --- a/OOXML/PPTXFormat/Logic/PartTitle.h +++ b/OOXML/PPTXFormat/Logic/PartTitle.h @@ -45,25 +45,17 @@ namespace PPTX PPTX_LOGIC_BASE(PartTitle) public: - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_title = node.GetTextExt(); - } - virtual std::wstring toXML() const - { - return _T("") + m_title + _T(""); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->WriteNodeValue(_T("vt:lpstr"), m_title); - } + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; public: std::wstring m_title; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_PART_TITLE_INCLUDE_H_ \ No newline at end of file +#endif // PPTX_LOGIC_PART_TITLE_INCLUDE_H_ diff --git a/OOXML/PPTXFormat/Logic/Path.cpp b/OOXML/PPTXFormat/Logic/Path.cpp new file mode 100644 index 0000000000..fc3bd03ab8 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Path.cpp @@ -0,0 +1,157 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Path.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType Path::getType () const + { + return OOX::et_a_path; + } + void Path::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (_T("fillToRect") == strName) + rect = oReader; + } + FillParentPointersForChilds(); + } + void Path::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start ( oReader ) + WritingElement_ReadAttributes_ReadSingle ( oReader, _T("path"), path ) + WritingElement_ReadAttributes_End ( oReader ) + } + void Path::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"path", path); + rect = node.ReadNodeNoNS(_T("fillToRect")); + + FillParentPointersForChilds(); + } + std::wstring Path::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.WriteLimitNullable(_T("path"), path); + + XmlUtils::CNodeValue oValue; + oValue.WriteNullable(rect); + + return XmlUtils::CreateNode(_T("a:path"), oAttr, oValue); + } + void Path::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit2(0, path); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, rect); + } + void Path::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) + { + path = pReader->GetUChar(); + } + else + break; + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + rect = new Logic::Rect(); + rect->fromPPTY(pReader); + rect->m_name = _T("a:fillToRect"); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void Path::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring sNodeNamespace; + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + sNodeNamespace = _T("w14:"); + sAttrNamespace = sNodeNamespace; + } + else + sNodeNamespace = _T("a:"); + pWriter->StartNode(sNodeNamespace + _T("path")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + _T("path"), path); + pWriter->EndAttributes(); + + pWriter->Write(rect); + + pWriter->EndNode(sNodeNamespace + _T("path")); + } + void Path::FillParentPointersForChilds() + { + if(rect.IsInit()) + rect->SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Path.h b/OOXML/PPTXFormat/Logic/Path.h index 0a3e00d539..7b195148df 100644 --- a/OOXML/PPTXFormat/Logic/Path.h +++ b/OOXML/PPTXFormat/Logic/Path.h @@ -39,138 +39,31 @@ namespace PPTX { namespace Logic { - class Path : public WrapperWritingElement { public: WritingElement_AdditionConstructors(Path) PPTX_LOGIC_BASE2(Path) - virtual OOX::EElementType getType () const - { - return OOX::et_a_path; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); + virtual OOX::EElementType getType () const; - if ( oReader.IsEmptyNode() ) - return; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - int nCurDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); - - if (_T("fillToRect") == strName) - rect = oReader; - } - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start ( oReader ) - WritingElement_ReadAttributes_ReadSingle ( oReader, _T("path"), path ) - WritingElement_ReadAttributes_End ( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"path", path); - rect = node.ReadNodeNoNS(_T("fillToRect")); - - FillParentPointersForChilds(); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.WriteLimitNullable(_T("path"), path); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - XmlUtils::CNodeValue oValue; - oValue.WriteNullable(rect); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - return XmlUtils::CreateNode(_T("a:path"), oAttr, oValue); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit2(0, path); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, rect); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) - { - path = pReader->GetUChar(); - } - else - break; - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - rect = new Logic::Rect(); - rect->fromPPTY(pReader); - rect->m_name = _T("a:fillToRect"); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring sNodeNamespace; - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - sNodeNamespace = _T("w14:"); - sAttrNamespace = sNodeNamespace; - } - else - sNodeNamespace = _T("a:"); - pWriter->StartNode(sNodeNamespace + _T("path")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + _T("path"), path); - pWriter->EndAttributes(); - - pWriter->Write(rect); - - pWriter->EndNode(sNodeNamespace + _T("path")); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; public: nullable rect; nullable_limit path; + protected: - virtual void FillParentPointersForChilds() - { - if(rect.IsInit()) - rect->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Path2D.cpp b/OOXML/PPTXFormat/Logic/Path2D.cpp new file mode 100644 index 0000000000..f05c5de64a --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Path2D.cpp @@ -0,0 +1,319 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Path2D.h" + +namespace PPTX +{ + namespace Logic + { + Path2D& Path2D::operator=(const Path2D& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + extrusionOk = oSrc.extrusionOk; + fill = oSrc.fill; + h = oSrc.h; + stroke = oSrc.stroke; + w = oSrc.w; + + Paths = oSrc.Paths; + + return *this; + } + OOX::EElementType Path2D::getType() const + { + return OOX::et_a_path; + } + void Path2D::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + Paths.clear(); + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring sName = oReader.GetName(); + + UniPath2D p; + Paths.push_back(p); + Paths.back().fromXML(oReader); + } + + FillParentPointersForChilds(); + } + void Path2D::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("extrusionOk"), extrusionOk) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("fill"), fill ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("h"), h ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("stroke"), stroke ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("w"), w ) + WritingElement_ReadAttributes_End( oReader ) + } + void Path2D::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"extrusionOk", extrusionOk); + XmlMacroReadAttributeBase(node, L"fill", fill); + XmlMacroReadAttributeBase(node, L"h", h); + XmlMacroReadAttributeBase(node, L"stroke", stroke); + XmlMacroReadAttributeBase(node, L"w", w); + + Paths.clear(); + XmlMacroLoadArray(node, _T("*"), Paths, UniPath2D); + + FillParentPointersForChilds(); + } + std::wstring Path2D::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("w"), w); + oAttr.Write(_T("h"), h); + oAttr.WriteLimitNullable(_T("fill"), fill); + oAttr.Write(_T("stroke"), stroke); + oAttr.Write(_T("extrusionOk"), extrusionOk); + + XmlUtils::CNodeValue oValue; + oValue.WriteArray(Paths); + + return XmlUtils::CreateNode(_T("a:path"), oAttr, oValue); + } + void Path2D::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:path")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("w"), w); + pWriter->WriteAttribute(_T("h"), h); + pWriter->WriteAttribute(_T("fill"), fill); + pWriter->WriteAttribute(_T("stroke"), stroke); + pWriter->WriteAttribute(_T("extrusionOk"), extrusionOk); + pWriter->EndAttributes(); + + size_t nCount = Paths.size(); + for (size_t i = 0; i < nCount; ++i) + Paths[i].toXmlWriter(pWriter); + + pWriter->EndNode(_T("a:path")); + } + void Path2D::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteBool2(0, extrusionOk); + pWriter->WriteLimit2(1, fill); + pWriter->WriteInt2(2, h); + pWriter->WriteBool2(3, stroke); + pWriter->WriteInt2(4, w); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecordArray(0, 1, Paths); + } + void Path2D::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4; + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + extrusionOk = pReader->GetBool(); + break; + } + case 1: + { + fill = pReader->GetUChar(); + break; + } + case 2: + { + h = pReader->GetLong(); + break; + } + case 3: + { + stroke = pReader->GetBool(); + break; + } + case 4: + { + w = pReader->GetLong(); + break; + } + default: + break; + } + } + + while (pReader->GetPos() < _e) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + pReader->Skip(4); // len + + ULONG _c = pReader->GetULong(); + + for (ULONG j = 0; j < _c; ++j) + { + pReader->Skip(5); // type + len + + BYTE _type = pReader->GetUChar(); + LONG _end = pReader->GetPos() + pReader->GetRecordSize() + 4; + + Paths.push_back(UniPath2D()); + UniPath2D& oPath = Paths[j]; + + if (_type == GEOMETRY_TYPE_PATH_CLOZE) + { + Logic::Close* p = new Logic::Close(); + oPath.Path2D.reset(p); + pReader->Seek(_end); + continue; + } + + pReader->Skip(1); + + std::wstring arr[6]; + + while (true) + { + BYTE _at2 = pReader->GetUChar_TypeNode(); + if (_at2 == NSBinPptxRW::g_nodeAttributeEnd) + break; + + arr[_at2] = pReader->GetString2(); + } + + switch (_type) + { + case GEOMETRY_TYPE_PATH_MOVETO: + { + Logic::MoveTo* p = new Logic::MoveTo(); + p->x = arr[0]; + p->y = arr[1]; + oPath.Path2D.reset(p); + break; + } + case GEOMETRY_TYPE_PATH_LINETO: + { + Logic::LineTo* p = new Logic::LineTo(); + p->x = arr[0]; + p->y = arr[1]; + oPath.Path2D.reset(p); + break; + } + case GEOMETRY_TYPE_PATH_CUBICBEZTO: + { + Logic::CubicBezTo* p = new Logic::CubicBezTo(); + p->x[0] = arr[0]; + p->y[0] = arr[1]; + p->x[1] = arr[2]; + p->y[1] = arr[3]; + p->x[2] = arr[4]; + p->y[2] = arr[5]; + oPath.Path2D.reset(p); + break; + } + case GEOMETRY_TYPE_PATH_ARCTO: + { + Logic::ArcTo* p = new Logic::ArcTo(); + p->wR = arr[0]; + p->hR = arr[1]; + p->stAng = arr[2]; + p->swAng = arr[3]; + oPath.Path2D.reset(p); + break; + } + case GEOMETRY_TYPE_PATH_QUADBEZTO: + { + Logic::QuadBezTo* p = new Logic::QuadBezTo(); + p->x[0] = arr[0]; + p->y[0] = arr[1]; + p->x[1] = arr[2]; + p->y[1] = arr[3]; + oPath.Path2D.reset(p); + break; + } + default: + break; + } + + pReader->Seek(_end); + } + + break; + } + default: + break; + } + } + + pReader->Seek(_e); + } + void Path2D::FillParentPointersForChilds() + { + size_t count = Paths.size(); + for (size_t i = 0; i < count; ++i) + Paths[i].SetParentPointer(this); + } + std::wstring Path2D::GetODString()const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("w"), w); + oAttr.Write(_T("h"), h); + oAttr.WriteLimitNullable(_T("fill"), fill); + oAttr.Write(_T("stroke"), stroke); + oAttr.Write(_T("extrusionOk"), extrusionOk); + + std::wstring strXml = _T(""); + size_t nCount = Paths.size(); + for (size_t i = 0; i < nCount; ++i) + strXml += Paths[i].GetODString(); + + return XmlUtils::CreateNode(_T("path"), oAttr, strXml); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Path2D.h b/OOXML/PPTXFormat/Logic/Path2D.h index 47aa1980d1..3b5357337d 100644 --- a/OOXML/PPTXFormat/Logic/Path2D.h +++ b/OOXML/PPTXFormat/Logic/Path2D.h @@ -48,265 +48,20 @@ namespace PPTX WritingElement_AdditionConstructors(Path2D) PPTX_LOGIC_BASE2(Path2D) - Path2D& operator=(const Path2D& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + Path2D& operator=(const Path2D& oSrc); - extrusionOk = oSrc.extrusionOk; - fill = oSrc.fill; - h = oSrc.h; - stroke = oSrc.stroke; - w = oSrc.w; + virtual OOX::EElementType getType() const; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - Paths = oSrc.Paths; + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - return *this; - } - virtual OOX::EElementType getType() const - { - return OOX::et_a_path; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - Paths.clear(); - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring sName = oReader.GetName(); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - UniPath2D p; - Paths.push_back(p); - Paths.back().fromXML(oReader); - } - - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("extrusionOk"), extrusionOk) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("fill"), fill ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("h"), h ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("stroke"), stroke ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("w"), w ) - WritingElement_ReadAttributes_End( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"extrusionOk", extrusionOk); - XmlMacroReadAttributeBase(node, L"fill", fill); - XmlMacroReadAttributeBase(node, L"h", h); - XmlMacroReadAttributeBase(node, L"stroke", stroke); - XmlMacroReadAttributeBase(node, L"w", w); - - Paths.clear(); - XmlMacroLoadArray(node, _T("*"), Paths, UniPath2D); - - FillParentPointersForChilds(); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("w"), w); - oAttr.Write(_T("h"), h); - oAttr.WriteLimitNullable(_T("fill"), fill); - oAttr.Write(_T("stroke"), stroke); - oAttr.Write(_T("extrusionOk"), extrusionOk); - - XmlUtils::CNodeValue oValue; - oValue.WriteArray(Paths); - - return XmlUtils::CreateNode(_T("a:path"), oAttr, oValue); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:path")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("w"), w); - pWriter->WriteAttribute(_T("h"), h); - pWriter->WriteAttribute(_T("fill"), fill); - pWriter->WriteAttribute(_T("stroke"), stroke); - pWriter->WriteAttribute(_T("extrusionOk"), extrusionOk); - pWriter->EndAttributes(); - - size_t nCount = Paths.size(); - for (size_t i = 0; i < nCount; ++i) - Paths[i].toXmlWriter(pWriter); - - pWriter->EndNode(_T("a:path")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteBool2(0, extrusionOk); - pWriter->WriteLimit2(1, fill); - pWriter->WriteInt2(2, h); - pWriter->WriteBool2(3, stroke); - pWriter->WriteInt2(4, w); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecordArray(0, 1, Paths); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _e = pReader->GetPos() + pReader->GetRecordSize() + 4; - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - extrusionOk = pReader->GetBool(); - break; - } - case 1: - { - fill = pReader->GetUChar(); - break; - } - case 2: - { - h = pReader->GetLong(); - break; - } - case 3: - { - stroke = pReader->GetBool(); - break; - } - case 4: - { - w = pReader->GetLong(); - break; - } - default: - break; - } - } - - while (pReader->GetPos() < _e) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - pReader->Skip(4); // len - - ULONG _c = pReader->GetULong(); - - for (ULONG j = 0; j < _c; ++j) - { - pReader->Skip(5); // type + len - - BYTE _type = pReader->GetUChar(); - LONG _end = pReader->GetPos() + pReader->GetRecordSize() + 4; - - Paths.push_back(UniPath2D()); - UniPath2D& oPath = Paths[j]; - - if (_type == GEOMETRY_TYPE_PATH_CLOZE) - { - Logic::Close* p = new Logic::Close(); - oPath.Path2D.reset(p); - pReader->Seek(_end); - continue; - } - - pReader->Skip(1); - - std::wstring arr[6]; - - while (true) - { - BYTE _at2 = pReader->GetUChar_TypeNode(); - if (_at2 == NSBinPptxRW::g_nodeAttributeEnd) - break; - - arr[_at2] = pReader->GetString2(); - } - - switch (_type) - { - case GEOMETRY_TYPE_PATH_MOVETO: - { - Logic::MoveTo* p = new Logic::MoveTo(); - p->x = arr[0]; - p->y = arr[1]; - oPath.Path2D.reset(p); - break; - } - case GEOMETRY_TYPE_PATH_LINETO: - { - Logic::LineTo* p = new Logic::LineTo(); - p->x = arr[0]; - p->y = arr[1]; - oPath.Path2D.reset(p); - break; - } - case GEOMETRY_TYPE_PATH_CUBICBEZTO: - { - Logic::CubicBezTo* p = new Logic::CubicBezTo(); - p->x[0] = arr[0]; - p->y[0] = arr[1]; - p->x[1] = arr[2]; - p->y[1] = arr[3]; - p->x[2] = arr[4]; - p->y[2] = arr[5]; - oPath.Path2D.reset(p); - break; - } - case GEOMETRY_TYPE_PATH_ARCTO: - { - Logic::ArcTo* p = new Logic::ArcTo(); - p->wR = arr[0]; - p->hR = arr[1]; - p->stAng = arr[2]; - p->swAng = arr[3]; - oPath.Path2D.reset(p); - break; - } - case GEOMETRY_TYPE_PATH_QUADBEZTO: - { - Logic::QuadBezTo* p = new Logic::QuadBezTo(); - p->x[0] = arr[0]; - p->y[0] = arr[1]; - p->x[1] = arr[2]; - p->y[1] = arr[3]; - oPath.Path2D.reset(p); - break; - } - default: - break; - } - - pReader->Seek(_end); - } - - break; - } - default: - break; - } - } - - pReader->Seek(_e); - } - public: nullable_bool extrusionOk; nullable_limit fill; @@ -315,30 +70,12 @@ namespace PPTX nullable_int w; std::vector Paths; + protected: - virtual void FillParentPointersForChilds() - { - size_t count = Paths.size(); - for (size_t i = 0; i < count; ++i) - Paths[i].SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); + public: - virtual std::wstring GetODString()const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("w"), w); - oAttr.Write(_T("h"), h); - oAttr.WriteLimitNullable(_T("fill"), fill); - oAttr.Write(_T("stroke"), stroke); - oAttr.Write(_T("extrusionOk"), extrusionOk); - - std::wstring strXml = _T(""); - size_t nCount = Paths.size(); - for (size_t i = 0; i < nCount; ++i) - strXml += Paths[i].GetODString(); - - return XmlUtils::CreateNode(_T("path"), oAttr, strXml); - } + virtual std::wstring GetODString() const; }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Ph.cpp b/OOXML/PPTXFormat/Logic/Ph.cpp new file mode 100644 index 0000000000..7b0e1c1a7c --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Ph.cpp @@ -0,0 +1,149 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Ph.h" + +namespace PPTX +{ + namespace Logic + { + Ph::Ph() + { + } + void Ph::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes(oReader); + } + void Ph::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("hasCustomPrompt"), hasCustomPrompt) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("idx"), idx) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("orient"), orient) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("sz"), sz) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("type"), type) + WritingElement_ReadAttributes_End( oReader ) + } + void Ph::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"hasCustomPrompt", hasCustomPrompt); + XmlMacroReadAttributeBase(node, L"idx", idx); + XmlMacroReadAttributeBase(node, L"orient", orient); + XmlMacroReadAttributeBase(node, L"sz", sz); + XmlMacroReadAttributeBase(node, L"type", type); + } + std::wstring Ph::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.WriteLimitNullable(_T("type"), type); + oAttr.WriteLimitNullable(_T("orient"), orient); + oAttr.WriteLimitNullable(_T("sz"), sz); + oAttr.Write(_T("idx"), idx); + oAttr.Write(_T("hasCustomPrompt"), hasCustomPrompt); + + return XmlUtils::CreateNode(_T("p:ph"), oAttr); + } + void Ph::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("p:ph")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("type"), type); + pWriter->WriteAttribute(_T("orient"), orient); + pWriter->WriteAttribute(_T("sz"), sz); + pWriter->WriteAttribute(_T("idx"), idx); + pWriter->WriteAttribute(_T("hasCustomPrompt"), hasCustomPrompt); + pWriter->EndAttributes(); + + pWriter->EndNode(_T("p:ph")); + } + void Ph::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteBool2(0, hasCustomPrompt); + pWriter->WriteString2(1, idx); + pWriter->WriteLimit2(2, orient); + pWriter->WriteLimit2(3, sz); + pWriter->WriteLimit2(4, type); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void Ph::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + hasCustomPrompt = pReader->GetBool(); + break; + } + case 1: + { + idx = pReader->GetString2(); + break; + } + case 2: + { + orient = pReader->GetUChar(); + break; + } + case 3: + { + sz = pReader->GetUChar(); + break; + } + case 4: + { + type = pReader->GetUChar(); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void Ph::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Ph.h b/OOXML/PPTXFormat/Logic/Ph.h index a1f1386f10..1aa4880041 100644 --- a/OOXML/PPTXFormat/Logic/Ph.h +++ b/OOXML/PPTXFormat/Logic/Ph.h @@ -46,116 +46,16 @@ namespace PPTX public: WritingElement_AdditionConstructors(Ph) - Ph() - { - } + Ph(); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes(oReader); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("hasCustomPrompt"), hasCustomPrompt) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("idx"), idx) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("orient"), orient) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("sz"), sz) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("type"), type) - WritingElement_ReadAttributes_End( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"hasCustomPrompt", hasCustomPrompt); - XmlMacroReadAttributeBase(node, L"idx", idx); - XmlMacroReadAttributeBase(node, L"orient", orient); - XmlMacroReadAttributeBase(node, L"sz", sz); - XmlMacroReadAttributeBase(node, L"type", type); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.WriteLimitNullable(_T("type"), type); - oAttr.WriteLimitNullable(_T("orient"), orient); - oAttr.WriteLimitNullable(_T("sz"), sz); - oAttr.Write(_T("idx"), idx); - oAttr.Write(_T("hasCustomPrompt"), hasCustomPrompt); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - return XmlUtils::CreateNode(_T("p:ph"), oAttr); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("p:ph")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("type"), type); - pWriter->WriteAttribute(_T("orient"), orient); - pWriter->WriteAttribute(_T("sz"), sz); - pWriter->WriteAttribute(_T("idx"), idx); - pWriter->WriteAttribute(_T("hasCustomPrompt"), hasCustomPrompt); - pWriter->EndAttributes(); - - pWriter->EndNode(_T("p:ph")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteBool2(0, hasCustomPrompt); - pWriter->WriteString2(1, idx); - pWriter->WriteLimit2(2, orient); - pWriter->WriteLimit2(3, sz); - pWriter->WriteLimit2(4, type); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - hasCustomPrompt = pReader->GetBool(); - break; - } - case 1: - { - idx = pReader->GetString2(); - break; - } - case 2: - { - orient = pReader->GetUChar(); - break; - } - case 3: - { - sz = pReader->GetUChar(); - break; - } - case 4: - { - type = pReader->GetUChar(); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: nullable_bool hasCustomPrompt; @@ -163,8 +63,9 @@ namespace PPTX nullable_limit orient; nullable_limit sz; nullable_limit type; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Pic.h b/OOXML/PPTXFormat/Logic/Pic.h index 5b2decd238..8d664faebf 100644 --- a/OOXML/PPTXFormat/Logic/Pic.h +++ b/OOXML/PPTXFormat/Logic/Pic.h @@ -88,6 +88,7 @@ namespace PPTX } } }; + class OLEType : public BaseLimit { public: @@ -131,6 +132,7 @@ namespace PPTX } } }; + class OLEUpdateMode : public BaseLimit { public: diff --git a/OOXML/PPTXFormat/Logic/PrstDash.cpp b/OOXML/PPTXFormat/Logic/PrstDash.cpp new file mode 100644 index 0000000000..4e6f740df0 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/PrstDash.cpp @@ -0,0 +1,118 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "PrstDash.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType PrstDash::getType() const + { + return OOX::et_a_prstDash; + } + void PrstDash::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + } + void PrstDash::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start_No_NS( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), val ) + WritingElement_ReadAttributes_End_No_NS( oReader ) + } + void PrstDash::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"val", val); + } + std::wstring PrstDash::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.WriteLimitNullable(_T("val"), val); + + return XmlUtils::CreateNode(_T("a:prstDash"), oAttr); + } + void PrstDash::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit2(0, val); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void PrstDash::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + val = pReader->GetUChar(); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void PrstDash::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring sNodeNamespace; + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + sNodeNamespace = _T("w14:"); + sAttrNamespace = sNodeNamespace; + } + else + sNodeNamespace = _T("a:"); + pWriter->StartNode(sNodeNamespace + _T("prstDash")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + _T("val"), val); + pWriter->EndAttributes(); + + pWriter->EndNode(sNodeNamespace + _T("prstDash")); + } + void PrstDash::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/PrstDash.h b/OOXML/PPTXFormat/Logic/PrstDash.h index 1dc4a58c73..70c82757d5 100644 --- a/OOXML/PPTXFormat/Logic/PrstDash.h +++ b/OOXML/PPTXFormat/Logic/PrstDash.h @@ -47,88 +47,22 @@ namespace PPTX WritingElement_AdditionConstructors(PrstDash) PPTX_LOGIC_BASE2(PrstDash) - virtual OOX::EElementType getType() const - { - return OOX::et_a_prstDash; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), val ) - WritingElement_ReadAttributes_End_No_NS( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"val", val); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.WriteLimitNullable(_T("val"), val); + virtual OOX::EElementType getType() const; - return XmlUtils::CreateNode(_T("a:prstDash"), oAttr); - } + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit2(0, val); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - val = pReader->GetUChar(); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring sNodeNamespace; - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - sNodeNamespace = _T("w14:"); - sAttrNamespace = sNodeNamespace; - } - else - sNodeNamespace = _T("a:"); - pWriter->StartNode(sNodeNamespace + _T("prstDash")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + _T("val"), val); - pWriter->EndAttributes(); - - pWriter->EndNode(sNodeNamespace + _T("prstDash")); - } + virtual std::wstring toXML() const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; public: nullable_limit val; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/PrstGeom.cpp b/OOXML/PPTXFormat/Logic/PrstGeom.cpp new file mode 100644 index 0000000000..391c0783ab --- /dev/null +++ b/OOXML/PPTXFormat/Logic/PrstGeom.cpp @@ -0,0 +1,158 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "PrstGeom.h" + +namespace PPTX +{ + namespace Logic + { + PrstGeom& PrstGeom::operator=(const PrstGeom& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + prst = oSrc.prst; + avLst = oSrc.avLst; + + return *this; + } + OOX::EElementType PrstGeom::getType() const + { + return OOX::et_a_prstGeom; + } + void PrstGeom::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring sName = oReader.GetName(); + + if (sName == L"a:avLst") + { + if ( oReader.IsEmptyNode() ) + continue; + + int nParentDepth1 = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) + { + std::wstring sName1 = oReader.GetName(); + + if (sName1 == L"a:gd") + { + Gd gd; + avLst.push_back(gd); + avLst.back().fromXML(oReader); + } + } + } + } + + FillParentPointersForChilds(); + } + void PrstGeom::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_ReadSingle( oReader, _T("prst"), prst) + WritingElement_ReadAttributes_End( oReader ) + } + void PrstGeom::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"prst", prst); + + XmlUtils::CXmlNode nodeList = node.ReadNode(_T("a:avLst")); + XmlMacroLoadArray(nodeList, _T("a:gd"), avLst, Gd); + + FillParentPointersForChilds(); + } + std::wstring PrstGeom::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("prst"), prst.get()); + + XmlUtils::CNodeValue oValue; + oValue.WriteArray(_T("a:avLst"), avLst); + + return XmlUtils::CreateNode(_T("a:prstGeom"), oAttr, oValue); + } + void PrstGeom::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:prstGeom")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("prst"), prst.get()); + pWriter->EndAttributes(); + + if (avLst.size() == 0) + pWriter->WriteString(_T("")); + else + pWriter->WriteArray(_T("a:avLst"), avLst); + + pWriter->EndNode(_T("a:prstGeom")); + } + void PrstGeom::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->StartRecord(GEOMETRY_TYPE_PRST); + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteString1(0, prst.get()); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecordArray(0, 1, avLst); + + pWriter->EndRecord(); + } + void PrstGeom::FillParentPointersForChilds() + { + size_t count = avLst.size(); + for (size_t i = 0; i < count; ++i) + avLst[i].SetParentPointer(this); + } + std::wstring PrstGeom::GetODString()const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("prst"), prst.get()); + + std::wstring strXml = _T(""); + size_t nCount = avLst.size(); + for (size_t i = 0; i < nCount; ++i) + strXml += avLst[i].GetODString(); + + return XmlUtils::CreateNode(_T("prstGeom"), oAttr, strXml); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/PrstGeom.h b/OOXML/PPTXFormat/Logic/PrstGeom.h index c341422054..7f66fd5a7d 100644 --- a/OOXML/PPTXFormat/Logic/PrstGeom.h +++ b/OOXML/PPTXFormat/Logic/PrstGeom.h @@ -47,132 +47,26 @@ namespace PPTX WritingElement_AdditionConstructors(PrstGeom) PPTX_LOGIC_BASE2(PrstGeom) - PrstGeom& operator=(const PrstGeom& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + PrstGeom& operator=(const PrstGeom& oSrc); + virtual OOX::EElementType getType() const; - prst = oSrc.prst; - avLst = oSrc.avLst; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - return *this; - } - virtual OOX::EElementType getType() const - { - return OOX::et_a_prstGeom; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); - - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring sName = oReader.GetName(); - - if (sName == L"a:avLst") - { - if ( oReader.IsEmptyNode() ) - continue; - - int nParentDepth1 = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) - { - std::wstring sName1 = oReader.GetName(); - - if (sName1 == L"a:gd") - { - Gd gd; - avLst.push_back(gd); - avLst.back().fromXML(oReader); - } - } - } - } - - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_ReadSingle( oReader, _T("prst"), prst) - WritingElement_ReadAttributes_End( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"prst", prst); - - XmlUtils::CXmlNode nodeList = node.ReadNode(_T("a:avLst")); - XmlMacroLoadArray(nodeList, _T("a:gd"), avLst, Gd); - - FillParentPointersForChilds(); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("prst"), prst.get()); - - XmlUtils::CNodeValue oValue; - oValue.WriteArray(_T("a:avLst"), avLst); - - return XmlUtils::CreateNode(_T("a:prstGeom"), oAttr, oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:prstGeom")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("prst"), prst.get()); - pWriter->EndAttributes(); - - if (avLst.size() == 0) - pWriter->WriteString(_T("")); - else - pWriter->WriteArray(_T("a:avLst"), avLst); - - pWriter->EndNode(_T("a:prstGeom")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->StartRecord(GEOMETRY_TYPE_PRST); - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteString1(0, prst.get()); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecordArray(0, 1, avLst); - - pWriter->EndRecord(); - } + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; public: Limit::ShapeType prst; std::vector avLst; + protected: - virtual void FillParentPointersForChilds() - { - size_t count = avLst.size(); - for (size_t i = 0; i < count; ++i) - avLst[i].SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); + public: - virtual std::wstring GetODString()const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("prst"), prst.get()); - - std::wstring strXml = _T(""); - size_t nCount = avLst.size(); - for (size_t i = 0; i < nCount; ++i) - strXml += avLst[i].GetODString(); - - return XmlUtils::CreateNode(_T("prstGeom"), oAttr, strXml); - } + virtual std::wstring GetODString()const; }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/PrstTxWarp.cpp b/OOXML/PPTXFormat/Logic/PrstTxWarp.cpp new file mode 100644 index 0000000000..340f263ea0 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/PrstTxWarp.cpp @@ -0,0 +1,184 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "PrstTxWarp.h" + +namespace PPTX +{ + namespace Logic + { + PrstTxWarp& PrstTxWarp::operator=(const PrstTxWarp& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + avLst = oSrc.avLst; + prst = oSrc.prst; + + return *this; + } + OOX::EElementType PrstTxWarp::getType () const + { + return OOX::et_a_prstTxWarp; + } + void PrstTxWarp::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + std::wstring strName = oReader.GetName(); + + if (_T("a:avLst") == strName) + { + if ( oReader.IsEmptyNode() ) + continue; + + int nCurDepth1 = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth1 ) ) + { + std::wstring strName1 = oReader.GetName(); + + if (_T("a:gd") == strName1) + { + Gd gd; + avLst.push_back(gd); + avLst.back().fromXML(oReader); + } + } + } + } + } + void PrstTxWarp::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start ( oReader ) + WritingElement_ReadAttributes_ReadSingle ( oReader, _T("prst"), prst ) + WritingElement_ReadAttributes_End ( oReader ) + } + void PrstTxWarp::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"prst", prst); + + XmlUtils::CXmlNode nodeList = node.ReadNode(_T("a:avLst")); + XmlMacroLoadArray(nodeList, _T("a:gd"), avLst, Gd); + + FillParentPointersForChilds(); + } + std::wstring PrstTxWarp::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("prst"), prst.get()); + + XmlUtils::CNodeValue oValue; + oValue.WriteArray(_T("a:avLst"), avLst); + + return XmlUtils::CreateNode(_T("a:prstTxWarp"), oAttr, oValue); + } + void PrstTxWarp::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:prstTxWarp")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("prst"), prst.get()); + pWriter->EndAttributes(); + + pWriter->WriteArray(_T("a:avLst"), avLst); + + pWriter->EndNode(_T("a:prstTxWarp")); + } + void PrstTxWarp::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit1(0, prst); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecordArray(0, 1, avLst); + } + void PrstTxWarp::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + prst.SetBYTECode(pReader->GetUChar()); + break; + } + default: + break; + } + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + pReader->Skip(4); + LONG len = pReader->GetLong(); + for (LONG i = 0; i < len; ++i) + { + pReader->Skip(1); + avLst.push_back(Gd()); + avLst[i].fromPPTY(pReader); + } + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void PrstTxWarp::FillParentPointersForChilds() + { + size_t count = avLst.size(); + for (size_t i = 0; i < count; ++i) + avLst[i].SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/PrstTxWarp.h b/OOXML/PPTXFormat/Logic/PrstTxWarp.h index 76cc35ace2..fa71893571 100644 --- a/OOXML/PPTXFormat/Logic/PrstTxWarp.h +++ b/OOXML/PPTXFormat/Logic/PrstTxWarp.h @@ -47,156 +47,25 @@ namespace PPTX WritingElement_AdditionConstructors(PrstTxWarp) PPTX_LOGIC_BASE2(PrstTxWarp) - PrstTxWarp& operator=(const PrstTxWarp& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + PrstTxWarp& operator=(const PrstTxWarp& oSrc); - avLst = oSrc.avLst; - prst = oSrc.prst; + virtual OOX::EElementType getType () const; - return *this; - } - virtual OOX::EElementType getType () const - { - return OOX::et_a_prstTxWarp; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - if ( oReader.IsEmptyNode() ) - return; + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - int nCurDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - std::wstring strName = oReader.GetName(); - - if (_T("a:avLst") == strName) - { - if ( oReader.IsEmptyNode() ) - continue; - - int nCurDepth1 = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth1 ) ) - { - std::wstring strName1 = oReader.GetName(); - - if (_T("a:gd") == strName1) - { - Gd gd; - avLst.push_back(gd); - avLst.back().fromXML(oReader); - } - } - } - } - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start ( oReader ) - WritingElement_ReadAttributes_ReadSingle ( oReader, _T("prst"), prst ) - WritingElement_ReadAttributes_End ( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"prst", prst); - - XmlUtils::CXmlNode nodeList = node.ReadNode(_T("a:avLst")); - XmlMacroLoadArray(nodeList, _T("a:gd"), avLst, Gd); - - FillParentPointersForChilds(); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("prst"), prst.get()); - - XmlUtils::CNodeValue oValue; - oValue.WriteArray(_T("a:avLst"), avLst); - - return XmlUtils::CreateNode(_T("a:prstTxWarp"), oAttr, oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:prstTxWarp")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("prst"), prst.get()); - pWriter->EndAttributes(); - - pWriter->WriteArray(_T("a:avLst"), avLst); - - pWriter->EndNode(_T("a:prstTxWarp")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit1(0, prst); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecordArray(0, 1, avLst); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - prst.SetBYTECode(pReader->GetUChar()); - break; - } - default: - break; - } - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - pReader->Skip(4); - LONG len = pReader->GetLong(); - for (LONG i = 0; i < len; ++i) - { - pReader->Skip(1); - avLst.push_back(Gd()); - avLst[i].fromPPTY(pReader); - } - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); Limit::TextShapeType prst; std::vector avLst; + protected: - virtual void FillParentPointersForChilds() - { - size_t count = avLst.size(); - for (size_t i = 0; i < count; ++i) - avLst[i].SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Rect.cpp b/OOXML/PPTXFormat/Logic/Rect.cpp new file mode 100644 index 0000000000..ad20c149a2 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Rect.cpp @@ -0,0 +1,161 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Rect.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType Rect::getType() const + { + return OOX::et_a_rect; + } + void Rect::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_name = oReader.GetName(); + + ReadAttributes( oReader ); + } + void Rect::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start_No_NS( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("t"), t ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("l"), l ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("r"), r ) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("b"), b ) + WritingElement_ReadAttributes_End_No_NS( oReader ) + } + void Rect::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + XmlMacroReadAttributeBase(node, L"t", t); + XmlMacroReadAttributeBase(node, L"b", b); + XmlMacroReadAttributeBase(node, L"l", l); + XmlMacroReadAttributeBase(node, L"r", r); + } + std::wstring Rect::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("l"), l); + oAttr.Write(_T("t"), t); + oAttr.Write(_T("r"), r); + oAttr.Write(_T("b"), b); + + return XmlUtils::CreateNode(m_name, oAttr); + } + void Rect::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring _name; + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + _name = _T("w14:") + XmlUtils::GetNameNoNS(m_name); + sAttrNamespace = _T("w14:"); + } + else + _name = m_name; + pWriter->StartNode(_name); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + _T("l"), l); + pWriter->WriteAttribute(sAttrNamespace + _T("t"), t); + pWriter->WriteAttribute(sAttrNamespace + _T("r"), r); + pWriter->WriteAttribute(sAttrNamespace + _T("b"), b); + pWriter->EndAttributes(); + + pWriter->EndNode(_name); + } + void Rect::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteString2(0, l); + pWriter->WriteString2(1, t); + pWriter->WriteString2(2, r); + pWriter->WriteString2(3, b); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void Rect::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + l = pReader->GetString2(); + break; + } + case 1: + { + t = pReader->GetString2(); + break; + } + case 2: + { + r = pReader->GetString2(); + break; + } + case 3: + { + b = pReader->GetString2(); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void Rect::FillParentPointersForChilds() {} + std::wstring Rect::GetODString() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("l"), l); + oAttr.Write(_T("t"), t); + oAttr.Write(_T("r"), r); + oAttr.Write(_T("b"), b); + + return XmlUtils::CreateNode(XmlUtils::GetNameNoNS(m_name), oAttr); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Rect.h b/OOXML/PPTXFormat/Logic/Rect.h index 0b24d454be..11a451b5ab 100644 --- a/OOXML/PPTXFormat/Logic/Rect.h +++ b/OOXML/PPTXFormat/Logic/Rect.h @@ -46,138 +46,30 @@ namespace PPTX WritingElement_AdditionConstructors(Rect) PPTX_LOGIC_BASE2(Rect) - virtual OOX::EElementType getType() const - { - return OOX::et_a_rect; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = oReader.GetName(); + virtual OOX::EElementType getType() const; - ReadAttributes( oReader ); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("t"), t ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("l"), l ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("r"), r ) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("b"), b ) - WritingElement_ReadAttributes_End_No_NS( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - XmlMacroReadAttributeBase(node, L"t", t); - XmlMacroReadAttributeBase(node, L"b", b); - XmlMacroReadAttributeBase(node, L"l", l); - XmlMacroReadAttributeBase(node, L"r", r); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("l"), l); - oAttr.Write(_T("t"), t); - oAttr.Write(_T("r"), r); - oAttr.Write(_T("b"), b); - - return XmlUtils::CreateNode(m_name, oAttr); - } + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring _name; - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - _name = _T("w14:") + XmlUtils::GetNameNoNS(m_name); - sAttrNamespace = _T("w14:"); - } - else - _name = m_name; - pWriter->StartNode(_name); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + _T("l"), l); - pWriter->WriteAttribute(sAttrNamespace + _T("t"), t); - pWriter->WriteAttribute(sAttrNamespace + _T("r"), r); - pWriter->WriteAttribute(sAttrNamespace + _T("b"), b); - pWriter->EndAttributes(); - - pWriter->EndNode(_name); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteString2(0, l); - pWriter->WriteString2(1, t); - pWriter->WriteString2(2, r); - pWriter->WriteString2(3, b); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - l = pReader->GetString2(); - break; - } - case 1: - { - t = pReader->GetString2(); - break; - } - case 2: - { - r = pReader->GetString2(); - break; - } - case 3: - { - b = pReader->GetString2(); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } nullable_string t; nullable_string b; nullable_string l; nullable_string r; std::wstring m_name; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); + public: - virtual std::wstring GetODString()const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("l"), l); - oAttr.Write(_T("t"), t); - oAttr.Write(_T("r"), r); - oAttr.Write(_T("b"), b); - - return XmlUtils::CreateNode(XmlUtils::GetNameNoNS(m_name), oAttr); - } + virtual std::wstring GetODString() const; }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Rot.cpp b/OOXML/PPTXFormat/Logic/Rot.cpp new file mode 100644 index 0000000000..fca871891e --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Rot.cpp @@ -0,0 +1,124 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Rot.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType Rot::getType() const + { + return OOX::et_a_rot; + } + void Rot::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + } + void Rot::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start_No_NS( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, L"lat", lat) + WritingElement_ReadAttributes_Read_else_if ( oReader, L"lon", lon) + WritingElement_ReadAttributes_Read_else_if ( oReader, L"rev", rev) + WritingElement_ReadAttributes_End_No_NS( oReader ) + } + void Rot::fromXML(XmlUtils::CXmlNode& node) + { + lat = node.GetAttribute(L"lat"); + lon = node.GetAttribute(L"lon"); + rev = node.GetAttribute(L"rev"); + } + std::wstring Rot::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(L"lat", lat); + oAttr.Write(L"lon", lon); + oAttr.Write(L"rev", rev); + + return XmlUtils::CreateNode(L"a:rot", oAttr); + } + void Rot::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring sNodeNamespace; + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + sNodeNamespace = L"w14:"; + sAttrNamespace = sNodeNamespace; + } + else + sNodeNamespace = L"a:"; + + pWriter->StartNode(sNodeNamespace + L"rot"); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + L"lat", lat); + pWriter->WriteAttribute(sAttrNamespace + L"lon", lon); + pWriter->WriteAttribute(sAttrNamespace + L"rev", rev); + pWriter->EndAttributes(); + + pWriter->EndNode(sNodeNamespace + L"rot"); + } + void Rot::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteInt2(0, lat); + pWriter->WriteInt2(1, lon); + pWriter->WriteInt2(2, rev); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void Rot::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) lat = pReader->GetLong(); + else if (1 == _at) lon = pReader->GetLong(); + else if (2 == _at) rev = pReader->GetLong(); + else + break; + } + pReader->Seek(_end_rec); + } + void Rot::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Rot.h b/OOXML/PPTXFormat/Logic/Rot.h index b64240f714..2b803bbdcf 100644 --- a/OOXML/PPTXFormat/Logic/Rot.h +++ b/OOXML/PPTXFormat/Logic/Rot.h @@ -46,95 +46,26 @@ namespace PPTX WritingElement_AdditionConstructors(Rot) PPTX_LOGIC_BASE2(Rot) - virtual OOX::EElementType getType() const - { - return OOX::et_a_rot; - } - void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, L"lat", lat) - WritingElement_ReadAttributes_Read_else_if ( oReader, L"lon", lon) - WritingElement_ReadAttributes_Read_else_if ( oReader, L"rev", rev) - WritingElement_ReadAttributes_End_No_NS( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - lat = node.GetAttribute(L"lat"); - lon = node.GetAttribute(L"lon"); - rev = node.GetAttribute(L"rev"); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(L"lat", lat); - oAttr.Write(L"lon", lon); - oAttr.Write(L"rev", rev); + virtual OOX::EElementType getType() const; + void fromXML(XmlUtils::CXmlLiteReader& oReader); - return XmlUtils::CreateNode(L"a:rot", oAttr); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring sNodeNamespace; - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - sNodeNamespace = L"w14:"; - sAttrNamespace = sNodeNamespace; - } - else - sNodeNamespace = L"a:"; + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - pWriter->StartNode(sNodeNamespace + L"rot"); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + L"lat", lat); - pWriter->WriteAttribute(sAttrNamespace + L"lon", lon); - pWriter->WriteAttribute(sAttrNamespace + L"rev", rev); - pWriter->EndAttributes(); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - pWriter->EndNode(sNodeNamespace + L"rot"); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteInt2(0, lat); - pWriter->WriteInt2(1, lon); - pWriter->WriteInt2(2, rev); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) lat = pReader->GetLong(); - else if (1 == _at) lon = pReader->GetLong(); - else if (2 == _at) rev = pReader->GetLong(); - else - break; - } - pReader->Seek(_end_rec); - } nullable_int lat; nullable_int lon; nullable_int rev; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_ROT_INCLUDE_H_ \ No newline at end of file +#endif // PPTX_LOGIC_ROT_INCLUDE_H_ diff --git a/OOXML/PPTXFormat/Logic/RunElem.cpp b/OOXML/PPTXFormat/Logic/RunElem.cpp new file mode 100644 index 0000000000..e1c5e2b615 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/RunElem.cpp @@ -0,0 +1,117 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "RunElem.h" + +namespace PPTX +{ + namespace Logic + { + RunElem::RunElem() {} + OOX::EElementType RunElem::getType () const + { + if (Elem.IsInit()) + return Elem->getType(); + return OOX::et_Unknown; + } + void RunElem::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + std::wstring name = XmlUtils::GetNameNoNS(oReader.GetName()); + + if(name == _T("r")) + Elem.reset(new Logic::Run(oReader)); + else if(name == _T("fld")) + Elem.reset(new Logic::Fld(oReader)); + else if(name == _T("br")) + Elem.reset(new Logic::Br(oReader)); + else if(name == _T("m")) + Elem.reset(new Logic::MathParaWrapper(oReader)); + else + Elem.reset(); + } + void RunElem::fromXML(XmlUtils::CXmlNode& node) + { + std::wstring name = XmlUtils::GetNameNoNS(node.GetName()); + + if(name == _T("r")) + Elem.reset(new Logic::Run(node)); + else if(name == _T("fld")) + Elem.reset(new Logic::Fld(node)); + else if(name == _T("br")) + Elem.reset(new Logic::Br(node)); + else if(name == _T("m")) + Elem.reset(new Logic::MathParaWrapper(node)); + else + Elem.reset(); + } + std::wstring RunElem::toXML() const + { + if (is_init()) + return Elem->toXML(); + return _T(""); + } + void RunElem::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + if (is_init()) + Elem->toXmlWriter(pWriter); + } + void RunElem::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + if (Elem.is_init()) + Elem->toPPTY(pWriter); + } + void RunElem::InitRun(RunBase* pRun) + { + Elem.reset(pRun); + } + bool RunElem::is_init() const + { + return (Elem.IsInit()); + } + std::wstring RunElem::GetText() const + { + return Elem->GetText(); + } + smart_ptr RunElem::GetElem() + { + return Elem; + } + void RunElem::FillParentPointersForChilds() + { + } + void RunElem::SetParentPointer(const WrapperWritingElement* pParent) + { + if(is_init()) + Elem->SetParentPointer(pParent); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/RunElem.h b/OOXML/PPTXFormat/Logic/RunElem.h index 30ed74720e..f2ccf6b5f5 100644 --- a/OOXML/PPTXFormat/Logic/RunElem.h +++ b/OOXML/PPTXFormat/Logic/RunElem.h @@ -49,84 +49,36 @@ namespace PPTX public: WritingElement_AdditionConstructors(RunElem) - RunElem() {} + RunElem(); - virtual OOX::EElementType getType () const - { - if (Elem.IsInit()) - return Elem->getType(); - return OOX::et_Unknown; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - std::wstring name = XmlUtils::GetNameNoNS(oReader.GetName()); + virtual OOX::EElementType getType () const; - if(name == _T("r")) - Elem.reset(new Logic::Run(oReader)); - else if(name == _T("fld")) - Elem.reset(new Logic::Fld(oReader)); - else if(name == _T("br")) - Elem.reset(new Logic::Br(oReader)); - else if(name == _T("m")) - Elem.reset(new Logic::MathParaWrapper(oReader)); - else - Elem.reset(); - } + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - virtual void fromXML(XmlUtils::CXmlNode& node) - { - std::wstring name = XmlUtils::GetNameNoNS(node.GetName()); + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; - if(name == _T("r")) - Elem.reset(new Logic::Run(node)); - else if(name == _T("fld")) - Elem.reset(new Logic::Fld(node)); - else if(name == _T("br")) - Elem.reset(new Logic::Br(node)); - else if(name == _T("m")) - Elem.reset(new Logic::MathParaWrapper(node)); - else - Elem.reset(); - } - virtual std::wstring toXML() const - { - if (is_init()) - return Elem->toXML(); - return _T(""); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - if (is_init()) - Elem->toXmlWriter(pWriter); - } + void InitRun(RunBase* pRun); - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - if (Elem.is_init()) - Elem->toPPTY(pWriter); - } + virtual bool is_init() const; + virtual std::wstring GetText() const; - void InitRun(RunBase* pRun) - { - Elem.reset(pRun); - } + smart_ptr GetElem(); - virtual bool is_init() const {return (Elem.IsInit());}; - virtual std::wstring GetText() const{return Elem->GetText();} - smart_ptr GetElem() - { - return Elem; - } template AVSINLINE const bool is() const { return Elem.is(); } template AVSINLINE T& as() { return Elem.as(); } template AVSINLINE const T& as() const { return Elem.as(); } private: smart_ptr Elem; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); + public: - virtual void SetParentPointer(const WrapperWritingElement* pParent){if(is_init()) Elem->SetParentPointer(pParent);} + virtual void SetParentPointer(const WrapperWritingElement* pParent); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/RunProperties.cpp b/OOXML/PPTXFormat/Logic/RunProperties.cpp new file mode 100644 index 0000000000..c3147ef394 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/RunProperties.cpp @@ -0,0 +1,765 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "RunProperties.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType Rtl::getType () const + { + return OOX::et_a_rtl; + } + void Rtl::fromXML(XmlUtils::CXmlNode& node) + { + } + void Rtl::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + + } + void Rtl::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void Rtl::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + pReader->Seek(_end_rec); + } + void Rtl::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->WriteString(L""); + } + void Rtl::FillParentPointersForChilds() {} + + UFillTx::UFillTx(std::wstring name) + { + m_name = name; + } + OOX::EElementType UFillTx::getType () const + { + return OOX::et_a_uFillTx; + } + void UFillTx::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + Fill.GetFillFrom(node); + FillParentPointersForChilds(); + } + void UFillTx::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_name = oReader.GetName(); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); + + Fill.fromXML(oReader); + } + + FillParentPointersForChilds(); + } + void UFillTx::Merge(nullable& uFillTx)const + { + if(!uFillTx.is_init()) + uFillTx = UFillTx(); + + uFillTx->m_name = m_name; + + if(Fill.is_init()) + uFillTx->Fill = Fill; + } + void UFillTx::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord1(0, Fill); + } + void UFillTx::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + } + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + Fill.fromPPTY(pReader); + }break; + default: + { + }break; + } + } + pReader->Seek(_end_rec); + } + void UFillTx::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + pWriter->EndAttributes(); + Fill.toXmlWriter(pWriter); + pWriter->EndNode(m_name); + } + void UFillTx::FillParentPointersForChilds() + { + Fill.SetParentPointer(this); + } + + Highlight::Highlight() + { + } + OOX::EElementType Highlight::getType () const + { + return OOX::et_a_highlight; + } + void Highlight::fromXML(XmlUtils::CXmlNode& node) + { + Color.GetColorFrom(node); + FillParentPointersForChilds(); + } + void Highlight::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); + + Color.fromXML(oReader); + } + + FillParentPointersForChilds(); + } + void Highlight::Merge(nullable& highlight)const + { + if(!highlight.is_init()) + highlight = Highlight(); + + if(Color.is_init()) + highlight->Color = Color; + } + void Highlight::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord1(0, Color); + } + void Highlight::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + } + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + Color.fromPPTY(pReader); + }break; + default: + { + }break; + } + } + pReader->Seek(_end_rec); + } + void Highlight::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(L"a:highlight"); + pWriter->EndAttributes(); + Color.toXmlWriter(pWriter); + pWriter->EndNode(L"a:highlight"); + } + void Highlight::FillParentPointersForChilds() + { + Color.SetParentPointer(this); + } + + RunProperties::RunProperties() + { + m_name = L"a:rPr"; + } + OOX::EElementType RunProperties::getType () const + { + return OOX::et_a_rPr; + } + void RunProperties::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_name = oReader.GetName(); + + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (L"blipFill" == sName || + L"gradFill" == sName || + L"grpFill" == sName || + L"noFill" == sName || + L"pattFill" == sName || + L"solidFill" == sName ) + { + Fill.fromXML(oReader); + } + else if ( L"ln" == sName ) + ln = oReader; + else if ( L"cs" == sName ) + cs = oReader; + else if ( L"ea" == sName ) + ea = oReader; + else if ( L"latin" == sName ) + latin = oReader; + else if ( L"sym" == sName ) + sym = oReader; + else if ( L"uFill" == sName ) + uFill = oReader; + else if ( L"uFillTx" == sName ) + uFillTx = oReader; + else if ( L"hlinkClick" == sName ) + hlinkClick = oReader; + else if (L"hlinkMouseOver" == sName) + hlinkMouseOver = oReader; + else if ( L"rtl" == sName ) + rtl = oReader; + else if (L"highlight" == sName) + highlight = oReader; + else if ( L"effectDag" == sName || + L"effectLst" == sName) + { + EffectList.fromXML(oReader); + } + else if ( L"a:extLst" == sName ) + { + if ( oReader.IsEmptyNode() ) + continue; + + int nParentDepth1 = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) + { + Ext element; + element.fromXML(oReader); + extLst.push_back (element); + } + } + } + FillParentPointersForChilds(); + } + void RunProperties::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + XmlMacroReadAttributeBase(node, L"altLang", altLang); + XmlMacroReadAttributeBase(node, L"b", b); + XmlMacroReadAttributeBase(node, L"bmk", bmk); + XmlMacroReadAttributeBase(node, L"cap", cap); + XmlMacroReadAttributeBase(node, L"dirty", dirty); + XmlMacroReadAttributeBase(node, L"err", err); + XmlMacroReadAttributeBase(node, L"i", i); + XmlMacroReadAttributeBase(node, L"kern", kern); + XmlMacroReadAttributeBase(node, L"kumimoji", kumimoji); + XmlMacroReadAttributeBase(node, L"lang", lang); + XmlMacroReadAttributeBase(node, L"noProof", noProof); + XmlMacroReadAttributeBase(node, L"normalizeH", normalizeH); + XmlMacroReadAttributeBase(node, L"smtClean", smtClean); + XmlMacroReadAttributeBase(node, L"smtId", altLang); + XmlMacroReadAttributeBase(node, L"strike", strike); + XmlMacroReadAttributeBase(node, L"sz", sz); + XmlMacroReadAttributeBase(node, L"u", u); + XmlMacroReadAttributeBase(node, L"baseline", baseline); + XmlMacroReadAttributeBase(node, L"spc", spc); + + XmlUtils::CXmlNodes oNodes; + if (node.GetNodes(L"*", oNodes)) + { + int nCount = oNodes.GetCount(); + for (int j = 0; j < nCount; ++j) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(j, oNode); + + std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); + + if (L"ln" == strName) + ln = oNode; + else if (L"latin" == strName) + latin = oNode; + else if (L"ea" == strName) + ea = oNode; + else if (L"cs" == strName) + cs = oNode; + else if (L"sym" == strName) + sym = oNode; + else if (L"hlinkClick" == strName) + hlinkClick = oNode; + else if (L"hlinkMouseOver" == strName) + hlinkMouseOver = oNode; + else if (L"rtl" == strName) + rtl = oNode; + else if (L"uFill" == strName) + uFill = oNode; + else if (L"uFillTx" == strName) + uFillTx = oNode; + else if (L"highlight" == strName) + highlight = oNode; + } + } + + Fill.GetFillFrom(node); + EffectList.GetEffectListFrom(node); + + Normalize(); + + FillParentPointersForChilds(); + } + void RunProperties::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start ( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, L"altLang", altLang) + WritingElement_ReadAttributes_Read_else_if( oReader, L"b", b) + WritingElement_ReadAttributes_Read_else_if( oReader, L"bmk", bmk) + WritingElement_ReadAttributes_Read_else_if( oReader, L"cap", cap) + WritingElement_ReadAttributes_Read_else_if( oReader, L"dirty", dirty) + WritingElement_ReadAttributes_Read_else_if( oReader, L"err", err) + WritingElement_ReadAttributes_Read_else_if( oReader, L"i", i) + WritingElement_ReadAttributes_Read_else_if( oReader, L"kern", kern) + WritingElement_ReadAttributes_Read_else_if( oReader, L"kumimoji", kumimoji) + WritingElement_ReadAttributes_Read_else_if( oReader, L"lang", lang) + WritingElement_ReadAttributes_Read_else_if( oReader, L"noProof", noProof) + WritingElement_ReadAttributes_Read_else_if( oReader, L"normalizeH", normalizeH) + WritingElement_ReadAttributes_Read_else_if( oReader, L"smtClean", smtClean) + WritingElement_ReadAttributes_Read_else_if( oReader, L"smtId", smtId) + WritingElement_ReadAttributes_Read_else_if( oReader, L"strike", strike) + WritingElement_ReadAttributes_Read_else_if( oReader, L"sz", sz) + WritingElement_ReadAttributes_Read_else_if( oReader, L"u", u) + WritingElement_ReadAttributes_Read_else_if( oReader, L"baseline", baseline) + WritingElement_ReadAttributes_Read_else_if( oReader, L"spc", spc) + WritingElement_ReadAttributes_End ( oReader ) + + Normalize(); + } + void RunProperties::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + + pWriter->StartAttributes(); + + pWriter->WriteAttribute(L"kumimoji", kumimoji); + pWriter->WriteAttribute(L"lang", lang); + pWriter->WriteAttribute(L"altLang", altLang); + pWriter->WriteAttribute(L"sz", sz); + pWriter->WriteAttribute(L"b", b); + pWriter->WriteAttribute(L"i", i); + pWriter->WriteAttribute(L"u", u); + pWriter->WriteAttribute(L"strike", strike); + pWriter->WriteAttribute(L"kern", kern); + pWriter->WriteAttribute(L"cap", cap); + pWriter->WriteAttribute(L"spc", spc); + pWriter->WriteAttribute(L"normalizeH", normalizeH); + pWriter->WriteAttribute(L"baseline", baseline); + pWriter->WriteAttribute(L"noProof", noProof); + pWriter->WriteAttribute(L"dirty", dirty); + pWriter->WriteAttribute(L"err", err); + pWriter->WriteAttribute(L"smtClean", smtClean); + pWriter->WriteAttribute(L"smtId", smtId); + pWriter->WriteAttribute(L"bmk", bmk); + + pWriter->EndAttributes(); + + pWriter->Write(ln); + Fill.toXmlWriter(pWriter); + EffectList.toXmlWriter(pWriter); + pWriter->Write(highlight); + pWriter->Write(uFill); + pWriter->Write(uFillTx); + pWriter->Write(latin); + pWriter->Write(ea); + pWriter->Write(cs); + pWriter->Write(sym); + pWriter->Write(hlinkClick); + pWriter->Write(hlinkMouseOver); + pWriter->Write(rtl); + + pWriter->EndNode(m_name); + } + void RunProperties::Merge(nullable& props)const + { + if(!props.is_init()) + props = new RunProperties(); + + if(ln.is_init()) + ln->Merge(props->ln); + if(Fill.is_init()) + props->Fill = Fill; + if(uFill.is_init()) + uFill->Merge(props->uFill); + if(uFillTx.is_init()) + uFillTx->Merge(props->uFillTx); + if (highlight.is_init()) + highlight->Merge(props->highlight); + + // EffectProperties EffectList; + //uLn (Underline Stroke) §21.1.2.3.14 + //uLnTx (Underline Follows Text) §21.1.2.3.15 + + if(latin.is_init()) latin->Merge(props->latin); + if(ea.is_init()) ea->Merge(props->ea); + if(cs.is_init()) cs->Merge(props->cs); + if(sym.is_init()) sym->Merge(props->sym); + /* + nullable_property hlinkClick; + nullable_property hlinkMouseOver; + */ + if(rtl.is_init()) props->rtl = new Logic::Rtl(); + if(altLang.is_init()) props->altLang = *altLang; + if(b.is_init()) props->b = *b; + if(baseline.is_init()) props->baseline = *baseline; + if(bmk.is_init()) props->bmk = *bmk; + if(cap.is_init()) props->cap = *cap; + if(dirty.is_init()) props->dirty = *dirty; + if(err.is_init()) props->err = *err; + if(i.is_init()) props->i = *i; + if(kern.is_init()) props->kern = *kern; + if(kumimoji.is_init()) props->kumimoji = *kumimoji; + if(lang.is_init()) props->lang = *lang; + if(noProof.is_init()) props->noProof = *noProof; + if(normalizeH.is_init())props->normalizeH = *normalizeH; + if(smtClean.is_init()) props->smtClean = *smtClean; + if(smtId.is_init()) props->smtId = *smtId; + if(spc.is_init()) props->spc = *spc; + if(strike.is_init()) props->strike = *strike; + if(sz.is_init()) props->sz = *sz; + if(u.is_init()) props->u = *u; + } + void RunProperties::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + + pWriter->WriteString2(0, altLang); + pWriter->WriteBool2 (1, b); + pWriter->WriteInt2 (2, baseline); + pWriter->WriteString2(3, bmk); + pWriter->WriteLimit2(4, cap); + pWriter->WriteBool2 (5, dirty); + pWriter->WriteBool2 (6, err); + pWriter->WriteBool2 (7, i); + pWriter->WriteInt2 (8, kern); + pWriter->WriteBool2 (9, kumimoji); + pWriter->WriteString2(10, lang); + pWriter->WriteBool2 (11, noProof); + pWriter->WriteBool2 (12, normalizeH); + pWriter->WriteBool2 (13, smtClean); + pWriter->WriteInt2 (14, smtId); + pWriter->WriteInt2 (15, spc); + pWriter->WriteLimit2(16, strike); + pWriter->WriteInt2 (17, sz); + pWriter->WriteLimit2(18, u); + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, ln); + pWriter->WriteRecord1(1, Fill); + pWriter->WriteRecord1(2, EffectList); + + pWriter->WriteRecord2(3, latin); + pWriter->WriteRecord2(4, ea); + pWriter->WriteRecord2(5, cs); + pWriter->WriteRecord2(6, sym); + + pWriter->WriteRecord2(7, hlinkClick); + pWriter->WriteRecord2(8, hlinkMouseOver); + pWriter->WriteRecord2(9, rtl); + + pWriter->WriteRecord2(10, uFill); + pWriter->WriteRecord2(11, uFillTx); + + pWriter->WriteRecord2(12, highlight); + } + void RunProperties::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + altLang = pReader->GetString2(); + }break; + case 1: + { + b = pReader->GetBool(); + }break; + case 2: + { + baseline = pReader->GetLong(); + }break; + case 3: + { + bmk = pReader->GetString2(); + }break; + case 4: + { + cap = pReader->GetUChar(); + }break; + case 5: + { + dirty = pReader->GetBool(); + }break; + case 6: + { + err = pReader->GetBool(); + }break; + case 7: + { + i = pReader->GetBool(); + }break; + case 8: + { + kern = pReader->GetLong(); + }break; + case 9: + { + kumimoji = pReader->GetBool(); + }break; + case 10: + { + lang = pReader->GetString2(); + }break; + case 11: + { + noProof = pReader->GetBool(); // noproof + }break; + case 12: + { + normalizeH = pReader->GetBool(); + }break; + case 13: + { + smtClean = pReader->GetBool(); + }break; + case 14: + { + smtId = pReader->GetLong(); + }break; + case 15: + { + spc = pReader->GetLong(); + }break; + case 16: + { + strike = pReader->GetUChar(); + }break; + case 17: + { + sz = pReader->GetLong(); + }break; + case 18: + { + u = pReader->GetUChar(); + }break; + default: + break; + } + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + ln = new Logic::Ln(); + ln->fromPPTY(pReader); + }break; + case 1: + { + Fill.fromPPTY(pReader); + }break; + case 2: + { + EffectList.fromPPTY(pReader); + }break; + case 3: + { + latin = new Logic::TextFont(); + latin->m_name = L"a:latin"; + latin->fromPPTY(pReader); + }break; + case 4: + { + ea = new Logic::TextFont(); + ea->m_name = L"a:ea"; + ea->fromPPTY(pReader); + }break; + case 5: + { + cs = new Logic::TextFont(); + cs->m_name = L"a:cs"; + cs->fromPPTY(pReader); + }break; + case 6: + { + sym = new Logic::TextFont(); + sym->m_name = L"a:sym"; + sym->fromPPTY(pReader); + }break; + case 7: + { + hlinkClick = new Logic::Hyperlink(L"hlinkClick"); + hlinkClick->fromPPTY(pReader); + }break; + case 8: + { + hlinkMouseOver = new Logic::Hyperlink(L"hlinkMouseOver"); + hlinkMouseOver->fromPPTY(pReader); + }break; + case 9: + { + rtl = new Logic::Rtl(); + rtl->fromPPTY(pReader); + }break; + case 10: + { + uFill = new Logic::UFillTx(L"a:uFill"); + uFill->fromPPTY(pReader); + }break; + case 11: + { + uFillTx = new Logic::UFillTx(L"a:uFillTx"); + uFillTx->fromPPTY(pReader); + }break; + case 12: + { + highlight = new Logic::Highlight(); + highlight->fromPPTY(pReader); + }break; + default: + { + pReader->SkipRecord(); + } + } + } + + pReader->Seek(_end_rec); + } + void RunProperties::FillParentPointersForChilds() + { + if(ln.is_init()) + ln->SetParentPointer(this); + Fill.SetParentPointer(this); + EffectList.SetParentPointer(this); + if(latin.is_init()) + latin->SetParentPointer(this); + if(ea.is_init()) + ea->SetParentPointer(this); + if(cs.is_init()) + cs->SetParentPointer(this); + if(sym.is_init()) + sym->SetParentPointer(this); + if(hlinkClick.is_init()) + hlinkClick->SetParentPointer(this); + if(hlinkMouseOver.is_init()) + hlinkMouseOver->SetParentPointer(this); + if(rtl.is_init()) + rtl->SetParentPointer(this); + if(uFill.is_init()) + uFill->SetParentPointer(this); + if(uFillTx.is_init()) + uFillTx->SetParentPointer(this); + if (highlight.is_init()) + highlight->SetParentPointer(this); + } + AVSINLINE void RunProperties::Normalize() + { + kern.normalize(0, 400000); + smtId.normalize_positive(); + spc.normalize(-400000, 400000); + sz.normalize(10, 400000); + } + PPTX::Logic::UniColor RunProperties::GetColor() const + { + if (Fill.is()) + return Fill.as().Color; + if (Fill.is()) + return Fill.as().GetFrontColor(); + + UniColor oUniColor; + return oUniColor; + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/RunProperties.h b/OOXML/PPTXFormat/Logic/RunProperties.h index 4987226913..9b55c819ab 100644 --- a/OOXML/PPTXFormat/Logic/RunProperties.h +++ b/OOXML/PPTXFormat/Logic/RunProperties.h @@ -55,737 +55,92 @@ namespace PPTX WritingElement_AdditionConstructors(Rtl) PPTX_LOGIC_BASE2(Rtl) - virtual OOX::EElementType getType () const - { - return OOX::et_a_rtl; - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - } + virtual OOX::EElementType getType () const; - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - pReader->Seek(_end_rec); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->WriteString(L""); - } protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; class UFillTx : public WrapperWritingElement { public: WritingElement_AdditionConstructors(UFillTx) - - UFillTx(std::wstring name = L"a:uFillTx") - { - m_name = name; - } - virtual OOX::EElementType getType () const - { - return OOX::et_a_uFillTx; - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); - - Fill.GetFillFrom(node); - FillParentPointersForChilds(); - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = oReader.GetName(); - - if ( oReader.IsEmptyNode() ) - return; - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); - - Fill.fromXML(oReader); - } + UFillTx(std::wstring name = L"a:uFillTx"); - FillParentPointersForChilds(); - } + virtual OOX::EElementType getType () const; - void Merge(nullable& uFillTx)const - { - if(!uFillTx.is_init()) - uFillTx = UFillTx(); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - uFillTx->m_name = m_name; - - if(Fill.is_init()) - uFillTx->Fill = Fill; - } + void Merge(nullable& uFillTx) const; - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord1(0, Fill); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - } - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - Fill.fromPPTY(pReader); - }break; - default: - { - }break; - } - } - pReader->Seek(_end_rec); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - pWriter->EndAttributes(); - Fill.toXmlWriter(pWriter); - pWriter->EndNode(m_name); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; UniFill Fill; std::wstring m_name; + protected: - virtual void FillParentPointersForChilds() - { - Fill.SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; class Highlight : public WrapperWritingElement { public: WritingElement_AdditionConstructors(Highlight) - - Highlight() - { - } - virtual OOX::EElementType getType () const - { - return OOX::et_a_highlight; - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - Color.GetColorFrom(node); - FillParentPointersForChilds(); - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - if ( oReader.IsEmptyNode() ) - return; - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); - - Color.fromXML(oReader); - } + Highlight(); - FillParentPointersForChilds(); - } + virtual OOX::EElementType getType () const; - void Merge(nullable& highlight)const - { - if(!highlight.is_init()) - highlight = Highlight(); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - if(Color.is_init()) - highlight->Color = Color; - } + void Merge(nullable& highlight) const; - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord1(0, Color); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - } - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - Color.fromPPTY(pReader); - }break; - default: - { - }break; - } - } - pReader->Seek(_end_rec); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(L"a:highlight"); - pWriter->EndAttributes(); - Color.toXmlWriter(pWriter); - pWriter->EndNode(L"a:highlight"); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; UniColor Color; + protected: - virtual void FillParentPointersForChilds() - { - Color.SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; class RunProperties : public WrapperWritingElement { public: WritingElement_AdditionConstructors(RunProperties) - - RunProperties() - { - m_name = L"a:rPr"; - } - virtual OOX::EElementType getType () const - { - return OOX::et_a_rPr; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = oReader.GetName(); - ReadAttributes( oReader ); + RunProperties(); + virtual OOX::EElementType getType () const; - if ( oReader.IsEmptyNode() ) - return; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); - - if (L"blipFill" == sName || - L"gradFill" == sName || - L"grpFill" == sName || - L"noFill" == sName || - L"pattFill" == sName || - L"solidFill" == sName ) - { - Fill.fromXML(oReader); - } - else if ( L"ln" == sName ) - ln = oReader; - else if ( L"cs" == sName ) - cs = oReader; - else if ( L"ea" == sName ) - ea = oReader; - else if ( L"latin" == sName ) - latin = oReader; - else if ( L"sym" == sName ) - sym = oReader; - else if ( L"uFill" == sName ) - uFill = oReader; - else if ( L"uFillTx" == sName ) - uFillTx = oReader; - else if ( L"hlinkClick" == sName ) - hlinkClick = oReader; - else if (L"hlinkMouseOver" == sName) - hlinkMouseOver = oReader; - else if ( L"rtl" == sName ) - rtl = oReader; - else if (L"highlight" == sName) - highlight = oReader; - else if ( L"effectDag" == sName || - L"effectLst" == sName) - { - EffectList.fromXML(oReader); - } - else if ( L"a:extLst" == sName ) - { - if ( oReader.IsEmptyNode() ) - continue; + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + void Merge(nullable& props) const; - int nParentDepth1 = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth1 ) ) - { - Ext element; - element.fromXML(oReader); - extLst.push_back (element); - } - } - } - FillParentPointersForChilds(); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - XmlMacroReadAttributeBase(node, L"altLang", altLang); - XmlMacroReadAttributeBase(node, L"b", b); - XmlMacroReadAttributeBase(node, L"bmk", bmk); - XmlMacroReadAttributeBase(node, L"cap", cap); - XmlMacroReadAttributeBase(node, L"dirty", dirty); - XmlMacroReadAttributeBase(node, L"err", err); - XmlMacroReadAttributeBase(node, L"i", i); - XmlMacroReadAttributeBase(node, L"kern", kern); - XmlMacroReadAttributeBase(node, L"kumimoji", kumimoji); - XmlMacroReadAttributeBase(node, L"lang", lang); - XmlMacroReadAttributeBase(node, L"noProof", noProof); - XmlMacroReadAttributeBase(node, L"normalizeH", normalizeH); - XmlMacroReadAttributeBase(node, L"smtClean", smtClean); - XmlMacroReadAttributeBase(node, L"smtId", altLang); - XmlMacroReadAttributeBase(node, L"strike", strike); - XmlMacroReadAttributeBase(node, L"sz", sz); - XmlMacroReadAttributeBase(node, L"u", u); - XmlMacroReadAttributeBase(node, L"baseline", baseline); - XmlMacroReadAttributeBase(node, L"spc", spc); - - XmlUtils::CXmlNodes oNodes; - if (node.GetNodes(L"*", oNodes)) - { - int nCount = oNodes.GetCount(); - for (int j = 0; j < nCount; ++j) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(j, oNode); - - std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); - - if (L"ln" == strName) - ln = oNode; - else if (L"latin" == strName) - latin = oNode; - else if (L"ea" == strName) - ea = oNode; - else if (L"cs" == strName) - cs = oNode; - else if (L"sym" == strName) - sym = oNode; - else if (L"hlinkClick" == strName) - hlinkClick = oNode; - else if (L"hlinkMouseOver" == strName) - hlinkMouseOver = oNode; - else if (L"rtl" == strName) - rtl = oNode; - else if (L"uFill" == strName) - uFill = oNode; - else if (L"uFillTx" == strName) - uFillTx = oNode; - else if (L"highlight" == strName) - highlight = oNode; - } - } - - Fill.GetFillFrom(node); - EffectList.GetEffectListFrom(node); - - Normalize(); - - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start ( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, L"altLang", altLang) - WritingElement_ReadAttributes_Read_else_if( oReader, L"b", b) - WritingElement_ReadAttributes_Read_else_if( oReader, L"bmk", bmk) - WritingElement_ReadAttributes_Read_else_if( oReader, L"cap", cap) - WritingElement_ReadAttributes_Read_else_if( oReader, L"dirty", dirty) - WritingElement_ReadAttributes_Read_else_if( oReader, L"err", err) - WritingElement_ReadAttributes_Read_else_if( oReader, L"i", i) - WritingElement_ReadAttributes_Read_else_if( oReader, L"kern", kern) - WritingElement_ReadAttributes_Read_else_if( oReader, L"kumimoji", kumimoji) - WritingElement_ReadAttributes_Read_else_if( oReader, L"lang", lang) - WritingElement_ReadAttributes_Read_else_if( oReader, L"noProof", noProof) - WritingElement_ReadAttributes_Read_else_if( oReader, L"normalizeH", normalizeH) - WritingElement_ReadAttributes_Read_else_if( oReader, L"smtClean", smtClean) - WritingElement_ReadAttributes_Read_else_if( oReader, L"smtId", smtId) - WritingElement_ReadAttributes_Read_else_if( oReader, L"strike", strike) - WritingElement_ReadAttributes_Read_else_if( oReader, L"sz", sz) - WritingElement_ReadAttributes_Read_else_if( oReader, L"u", u) - WritingElement_ReadAttributes_Read_else_if( oReader, L"baseline", baseline) - WritingElement_ReadAttributes_Read_else_if( oReader, L"spc", spc) - WritingElement_ReadAttributes_End ( oReader ) - - Normalize(); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - - pWriter->StartAttributes(); - - pWriter->WriteAttribute(L"kumimoji", kumimoji); - pWriter->WriteAttribute(L"lang", lang); - pWriter->WriteAttribute(L"altLang", altLang); - pWriter->WriteAttribute(L"sz", sz); - pWriter->WriteAttribute(L"b", b); - pWriter->WriteAttribute(L"i", i); - pWriter->WriteAttribute(L"u", u); - pWriter->WriteAttribute(L"strike", strike); - pWriter->WriteAttribute(L"kern", kern); - pWriter->WriteAttribute(L"cap", cap); - pWriter->WriteAttribute(L"spc", spc); - pWriter->WriteAttribute(L"normalizeH", normalizeH); - pWriter->WriteAttribute(L"baseline", baseline); - pWriter->WriteAttribute(L"noProof", noProof); - pWriter->WriteAttribute(L"dirty", dirty); - pWriter->WriteAttribute(L"err", err); - pWriter->WriteAttribute(L"smtClean", smtClean); - pWriter->WriteAttribute(L"smtId", smtId); - pWriter->WriteAttribute(L"bmk", bmk); - - pWriter->EndAttributes(); - - pWriter->Write(ln); - Fill.toXmlWriter(pWriter); - EffectList.toXmlWriter(pWriter); - pWriter->Write(highlight); - pWriter->Write(uFill); - pWriter->Write(uFillTx); - pWriter->Write(latin); - pWriter->Write(ea); - pWriter->Write(cs); - pWriter->Write(sym); - pWriter->Write(hlinkClick); - pWriter->Write(hlinkMouseOver); - pWriter->Write(rtl); - - pWriter->EndNode(m_name); - } - - - void Merge(nullable& props)const - { - if(!props.is_init()) - props = new RunProperties(); - - if(ln.is_init()) - ln->Merge(props->ln); - if(Fill.is_init()) - props->Fill = Fill; - if(uFill.is_init()) - uFill->Merge(props->uFill); - if(uFillTx.is_init()) - uFillTx->Merge(props->uFillTx); - if (highlight.is_init()) - highlight->Merge(props->highlight); - - // EffectProperties EffectList; - //uLn (Underline Stroke) §21.1.2.3.14 - //uLnTx (Underline Follows Text) §21.1.2.3.15 - - if(latin.is_init()) latin->Merge(props->latin); - if(ea.is_init()) ea->Merge(props->ea); - if(cs.is_init()) cs->Merge(props->cs); - if(sym.is_init()) sym->Merge(props->sym); - /* - nullable_property hlinkClick; - nullable_property hlinkMouseOver; - */ - if(rtl.is_init()) props->rtl = new Logic::Rtl(); - if(altLang.is_init()) props->altLang = *altLang; - if(b.is_init()) props->b = *b; - if(baseline.is_init()) props->baseline = *baseline; - if(bmk.is_init()) props->bmk = *bmk; - if(cap.is_init()) props->cap = *cap; - if(dirty.is_init()) props->dirty = *dirty; - if(err.is_init()) props->err = *err; - if(i.is_init()) props->i = *i; - if(kern.is_init()) props->kern = *kern; - if(kumimoji.is_init()) props->kumimoji = *kumimoji; - if(lang.is_init()) props->lang = *lang; - if(noProof.is_init()) props->noProof = *noProof; - if(normalizeH.is_init())props->normalizeH = *normalizeH; - if(smtClean.is_init()) props->smtClean = *smtClean; - if(smtId.is_init()) props->smtId = *smtId; - if(spc.is_init()) props->spc = *spc; - if(strike.is_init()) props->strike = *strike; - if(sz.is_init()) props->sz = *sz; - if(u.is_init()) props->u = *u; - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - - pWriter->WriteString2(0, altLang); - pWriter->WriteBool2 (1, b); - pWriter->WriteInt2 (2, baseline); - pWriter->WriteString2(3, bmk); - pWriter->WriteLimit2(4, cap); - pWriter->WriteBool2 (5, dirty); - pWriter->WriteBool2 (6, err); - pWriter->WriteBool2 (7, i); - pWriter->WriteInt2 (8, kern); - pWriter->WriteBool2 (9, kumimoji); - pWriter->WriteString2(10, lang); - pWriter->WriteBool2 (11, noProof); - pWriter->WriteBool2 (12, normalizeH); - pWriter->WriteBool2 (13, smtClean); - pWriter->WriteInt2 (14, smtId); - pWriter->WriteInt2 (15, spc); - pWriter->WriteLimit2(16, strike); - pWriter->WriteInt2 (17, sz); - pWriter->WriteLimit2(18, u); - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, ln); - pWriter->WriteRecord1(1, Fill); - pWriter->WriteRecord1(2, EffectList); - - pWriter->WriteRecord2(3, latin); - pWriter->WriteRecord2(4, ea); - pWriter->WriteRecord2(5, cs); - pWriter->WriteRecord2(6, sym); - - pWriter->WriteRecord2(7, hlinkClick); - pWriter->WriteRecord2(8, hlinkMouseOver); - pWriter->WriteRecord2(9, rtl); - - pWriter->WriteRecord2(10, uFill); - pWriter->WriteRecord2(11, uFillTx); - - pWriter->WriteRecord2(12, highlight); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - altLang = pReader->GetString2(); - }break; - case 1: - { - b = pReader->GetBool(); - }break; - case 2: - { - baseline = pReader->GetLong(); - }break; - case 3: - { - bmk = pReader->GetString2(); - }break; - case 4: - { - cap = pReader->GetUChar(); - }break; - case 5: - { - dirty = pReader->GetBool(); - }break; - case 6: - { - err = pReader->GetBool(); - }break; - case 7: - { - i = pReader->GetBool(); - }break; - case 8: - { - kern = pReader->GetLong(); - }break; - case 9: - { - kumimoji = pReader->GetBool(); - }break; - case 10: - { - lang = pReader->GetString2(); - }break; - case 11: - { - noProof = pReader->GetBool(); // noproof - }break; - case 12: - { - normalizeH = pReader->GetBool(); - }break; - case 13: - { - smtClean = pReader->GetBool(); - }break; - case 14: - { - smtId = pReader->GetLong(); - }break; - case 15: - { - spc = pReader->GetLong(); - }break; - case 16: - { - strike = pReader->GetUChar(); - }break; - case 17: - { - sz = pReader->GetLong(); - }break; - case 18: - { - u = pReader->GetUChar(); - }break; - default: - break; - } - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - ln = new Logic::Ln(); - ln->fromPPTY(pReader); - }break; - case 1: - { - Fill.fromPPTY(pReader); - }break; - case 2: - { - EffectList.fromPPTY(pReader); - }break; - case 3: - { - latin = new Logic::TextFont(); - latin->m_name = L"a:latin"; - latin->fromPPTY(pReader); - }break; - case 4: - { - ea = new Logic::TextFont(); - ea->m_name = L"a:ea"; - ea->fromPPTY(pReader); - }break; - case 5: - { - cs = new Logic::TextFont(); - cs->m_name = L"a:cs"; - cs->fromPPTY(pReader); - }break; - case 6: - { - sym = new Logic::TextFont(); - sym->m_name = L"a:sym"; - sym->fromPPTY(pReader); - }break; - case 7: - { - hlinkClick = new Logic::Hyperlink(L"hlinkClick"); - hlinkClick->fromPPTY(pReader); - }break; - case 8: - { - hlinkMouseOver = new Logic::Hyperlink(L"hlinkMouseOver"); - hlinkMouseOver->fromPPTY(pReader); - }break; - case 9: - { - rtl = new Logic::Rtl(); - rtl->fromPPTY(pReader); - }break; - case 10: - { - uFill = new Logic::UFillTx(L"a:uFill"); - uFill->fromPPTY(pReader); - }break; - case 11: - { - uFillTx = new Logic::UFillTx(L"a:uFillTx"); - uFillTx->fromPPTY(pReader); - }break; - case 12: - { - highlight = new Logic::Highlight(); - highlight->fromPPTY(pReader); - }break; - default: - { - pReader->SkipRecord(); - } - } - } - - pReader->Seek(_end_rec); - } - - //uLn (Underline Stroke) §21.1.2.3.14 - //uLnTx (Underline Follows Text) §21.1.2.3.15 + //uLn (Underline Stroke) §21.1.2.3.14 + //uLnTx (Underline Follows Text) §21.1.2.3.15 nullable ln; UniFill Fill; EffectProperties EffectList; - + std::vector extLst; nullable highlight; @@ -820,54 +175,14 @@ namespace PPTX nullable_limit u; std::wstring m_name; - protected: - virtual void FillParentPointersForChilds() - { - if(ln.is_init()) - ln->SetParentPointer(this); - Fill.SetParentPointer(this); - EffectList.SetParentPointer(this); - if(latin.is_init()) - latin->SetParentPointer(this); - if(ea.is_init()) - ea->SetParentPointer(this); - if(cs.is_init()) - cs->SetParentPointer(this); - if(sym.is_init()) - sym->SetParentPointer(this); - if(hlinkClick.is_init()) - hlinkClick->SetParentPointer(this); - if(hlinkMouseOver.is_init()) - hlinkMouseOver->SetParentPointer(this); - if(rtl.is_init()) - rtl->SetParentPointer(this); - if(uFill.is_init()) - uFill->SetParentPointer(this); - if(uFillTx.is_init()) - uFillTx->SetParentPointer(this); - if (highlight.is_init()) - highlight->SetParentPointer(this); - } - AVSINLINE void Normalize() - { - kern.normalize(0, 400000); - smtId.normalize_positive(); - spc.normalize(-400000, 400000); - sz.normalize(10, 400000); - } + protected: + virtual void FillParentPointersForChilds(); + + void Normalize(); public: - PPTX::Logic::UniColor GetColor()const - { - if (Fill.is()) - return Fill.as().Color; - if (Fill.is()) - return Fill.as().GetFrontColor(); - - UniColor oUniColor; - return oUniColor; - } + PPTX::Logic::UniColor GetColor() const; }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Scene3d.cpp b/OOXML/PPTXFormat/Logic/Scene3d.cpp new file mode 100644 index 0000000000..e2aadda6e8 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Scene3d.cpp @@ -0,0 +1,167 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Scene3d.h" + +namespace PPTX +{ + namespace Logic + { + Scene3d::Scene3d() {} + OOX::EElementType Scene3d::getType() const + { + return OOX::et_a_scene3d; + } + void Scene3d::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + if ( oReader.IsEmptyNode() ) + return; + + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + std::wstring strName = oReader.GetName(); + + if (strName == L"a:camera") + camera = oReader; + if (strName == L"a:lightRig") + lightRig = oReader; + if (strName == L"a:backdrop") + backdrop = oReader; + } + FillParentPointersForChilds(); + } + void Scene3d::fromXML(XmlUtils::CXmlNode& node) + { + camera = node.ReadNode(L"a:camera"); + lightRig = node.ReadNode(L"a:lightRig"); + backdrop = node.ReadNode(L"a:backdrop"); + + FillParentPointersForChilds(); + } + std::wstring Scene3d::toXML() const + { + XmlUtils::CNodeValue oValue; + + oValue.WriteNullable(camera); + oValue.WriteNullable(lightRig); + oValue.WriteNullable(backdrop); + + return XmlUtils::CreateNode(L"a:scene3d", oValue); + } + void Scene3d::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, camera); + pWriter->WriteRecord2(1, lightRig); + pWriter->WriteRecord2(2, backdrop); + } + void Scene3d::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + break; + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + camera = new Logic::Camera(); + camera->fromPPTY(pReader); + }break; + case 1: + { + lightRig = new Logic::LightRig(); + lightRig->fromPPTY(pReader); + }break; + case 2: + { + backdrop = new Logic::Backdrop(); + backdrop->fromPPTY(pReader); + }break; + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void Scene3d::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring sNodeNamespace; + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + sNodeNamespace = L"w14:"; + sAttrNamespace = sNodeNamespace; + } + else + sNodeNamespace = m_namespace + L":"; + + pWriter->StartNode(sNodeNamespace + L"scene3d"); + + pWriter->StartAttributes(); + pWriter->EndAttributes(); + + pWriter->Write(camera); + pWriter->Write(lightRig); + pWriter->Write(backdrop); + + pWriter->EndNode(sNodeNamespace + L"scene3d"); + } + void Scene3d::FillParentPointersForChilds() + { + if(camera.IsInit()) + camera->SetParentPointer(this); + if(lightRig.IsInit()) + lightRig->SetParentPointer(this); + if(backdrop.IsInit()) + backdrop->SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Scene3d.h b/OOXML/PPTXFormat/Logic/Scene3d.h index 96f10db226..7c025c10d7 100644 --- a/OOXML/PPTXFormat/Logic/Scene3d.h +++ b/OOXML/PPTXFormat/Logic/Scene3d.h @@ -47,143 +47,28 @@ namespace PPTX { public: WritingElement_AdditionConstructors(Scene3d) - Scene3d() {} - virtual OOX::EElementType getType() const - { - return OOX::et_a_scene3d; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - if ( oReader.IsEmptyNode() ) - return; + Scene3d(); - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + virtual OOX::EElementType getType() const; - int nCurDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - std::wstring strName = oReader.GetName(); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - if (strName == L"a:camera") - camera = oReader; - if (strName == L"a:lightRig") - lightRig = oReader; - if (strName == L"a:backdrop") - backdrop = oReader; - } - FillParentPointersForChilds(); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - camera = node.ReadNode(L"a:camera"); - lightRig = node.ReadNode(L"a:lightRig"); - backdrop = node.ReadNode(L"a:backdrop"); - - FillParentPointersForChilds(); - } - virtual std::wstring toXML() const - { - XmlUtils::CNodeValue oValue; - - oValue.WriteNullable(camera); - oValue.WriteNullable(lightRig); - oValue.WriteNullable(backdrop); + virtual std::wstring toXML() const; - return XmlUtils::CreateNode(L"a:scene3d", oValue); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, camera); - pWriter->WriteRecord2(1, lightRig); - pWriter->WriteRecord2(2, backdrop); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - break; - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - camera = new Logic::Camera(); - camera->fromPPTY(pReader); - }break; - case 1: - { - lightRig = new Logic::LightRig(); - lightRig->fromPPTY(pReader); - }break; - case 2: - { - backdrop = new Logic::Backdrop(); - backdrop->fromPPTY(pReader); - }break; - default: - break; - } - } - - pReader->Seek(_end_rec); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring sNodeNamespace; - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - sNodeNamespace = L"w14:"; - sAttrNamespace = sNodeNamespace; - } - else - sNodeNamespace = m_namespace + L":"; - - pWriter->StartNode(sNodeNamespace + L"scene3d"); - - pWriter->StartAttributes(); - pWriter->EndAttributes(); - - pWriter->Write(camera); - pWriter->Write(lightRig); - pWriter->Write(backdrop); - - pWriter->EndNode(sNodeNamespace + L"scene3d"); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; nullable camera; nullable lightRig; nullable backdrop; std::wstring m_namespace = L"a"; + protected: - virtual void FillParentPointersForChilds() - { - if(camera.IsInit()) - camera->SetParentPointer(this); - if(lightRig.IsInit()) - lightRig->SetParentPointer(this); - if(backdrop.IsInit()) - backdrop->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/ShapeStyle.cpp b/OOXML/PPTXFormat/Logic/ShapeStyle.cpp new file mode 100644 index 0000000000..fe0e1c786a --- /dev/null +++ b/OOXML/PPTXFormat/Logic/ShapeStyle.cpp @@ -0,0 +1,200 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "ShapeStyle.h" + +namespace PPTX +{ + namespace Logic + { + ShapeStyle::ShapeStyle(std::wstring ns) + { + m_namespace = ns; + } + ShapeStyle& ShapeStyle::operator=(const ShapeStyle& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + lnRef = oSrc.lnRef; + fillRef = oSrc.fillRef; + effectRef = oSrc.effectRef; + fontRef = oSrc.fontRef; + + m_namespace = oSrc.m_namespace; + + return *this; + } + OOX::EElementType ShapeStyle::getType () const + { + return OOX::et_p_style; + } + void ShapeStyle::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (_T("lnRef") == strName) + lnRef.fromXML(oReader); + else if (_T("fillRef") == strName) + fillRef.fromXML(oReader); + else if (_T("effectRef") == strName) + effectRef.fromXML(oReader); + else if (_T("fontRef") == strName) + fontRef.fromXML(oReader); + } + FillParentPointersForChilds(); + } + void ShapeStyle::fromXML(XmlUtils::CXmlNode& node) + { + m_namespace = XmlUtils::GetNamespace(node.GetName()); + + XmlUtils::CXmlNodes oNodes; + if (node.GetNodes(_T("*"), oNodes)) + { + int nCount = oNodes.GetCount(); + for (int i = 0; i < nCount; ++i) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(i, oNode); + + std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); + + if (_T("lnRef") == strName) + lnRef = oNode; + else if (_T("fillRef") == strName) + fillRef = oNode; + else if (_T("effectRef") == strName) + effectRef = oNode; + else if (_T("fontRef") == strName) + fontRef = oNode; + } + } + + FillParentPointersForChilds(); + } + std::wstring ShapeStyle::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("xmlns:") + PPTX::g_Namespaces.p.m_strName, PPTX::g_Namespaces.p.m_strLink); + oAttr.Write(_T("xmlns:") + PPTX::g_Namespaces.a.m_strName, PPTX::g_Namespaces.a.m_strLink); + + XmlUtils::CNodeValue oValue; + oValue.Write(lnRef); + oValue.Write(fillRef); + oValue.Write(effectRef); + oValue.Write(fontRef); + + return XmlUtils::CreateNode(m_namespace + _T(":style"), oAttr, oValue); + } + void ShapeStyle::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring name_ = L"a:style"; + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) name_ = L"cdr:style"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) name_ = L"dgm:style"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) name_ = L"dsp:style"; + else name_ = m_namespace + L":style"; + + pWriter->StartNode(name_); + pWriter->EndAttributes(); + + lnRef.toXmlWriter(pWriter); + fillRef.toXmlWriter(pWriter); + effectRef.toXmlWriter(pWriter); + fontRef.toXmlWriter(pWriter); + + pWriter->EndNode(name_); + } + void ShapeStyle::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord1(0, lnRef); + pWriter->WriteRecord1(1, fillRef); + pWriter->WriteRecord1(2, effectRef); + pWriter->WriteRecord1(3, fontRef); + } + void ShapeStyle::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + lnRef.m_name = _T("a:lnRef"); + lnRef.fromPPTY(pReader); + break; + } + case 1: + { + fillRef.m_name = _T("a:fillRef"); + fillRef.fromPPTY(pReader); + break; + } + case 2: + { + effectRef.m_name = _T("a:effectRef"); + effectRef.fromPPTY(pReader); + break; + } + case 3: + { + fontRef.m_name = _T("a:fontRef"); + fontRef.fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void ShapeStyle::FillParentPointersForChilds() + { + lnRef.SetParentPointer(this); + fillRef.SetParentPointer(this); + effectRef.SetParentPointer(this); + fontRef.SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/ShapeStyle.h b/OOXML/PPTXFormat/Logic/ShapeStyle.h index f94fed0aff..6db8154693 100644 --- a/OOXML/PPTXFormat/Logic/ShapeStyle.h +++ b/OOXML/PPTXFormat/Logic/ShapeStyle.h @@ -46,164 +46,19 @@ namespace PPTX public: WritingElement_AdditionConstructors(ShapeStyle) - ShapeStyle(std::wstring ns = L"a") - { - m_namespace = ns; - } - ShapeStyle& operator=(const ShapeStyle& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + ShapeStyle(std::wstring ns = L"a"); + ShapeStyle& operator=(const ShapeStyle& oSrc); - lnRef = oSrc.lnRef; - fillRef = oSrc.fillRef; - effectRef = oSrc.effectRef; - fontRef = oSrc.fontRef; + virtual OOX::EElementType getType () const; - m_namespace = oSrc.m_namespace; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - return *this; - } - virtual OOX::EElementType getType () const - { - return OOX::et_p_style; - } - - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); + virtual std::wstring toXML() const; - if ( oReader.IsEmptyNode() ) - return; - - int nCurDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); - - if (_T("lnRef") == strName) - lnRef.fromXML(oReader); - else if (_T("fillRef") == strName) - fillRef.fromXML(oReader); - else if (_T("effectRef") == strName) - effectRef.fromXML(oReader); - else if (_T("fontRef") == strName) - fontRef.fromXML(oReader); - } - FillParentPointersForChilds(); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_namespace = XmlUtils::GetNamespace(node.GetName()); - - XmlUtils::CXmlNodes oNodes; - if (node.GetNodes(_T("*"), oNodes)) - { - int nCount = oNodes.GetCount(); - for (int i = 0; i < nCount; ++i) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(i, oNode); - - std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); - - if (_T("lnRef") == strName) - lnRef = oNode; - else if (_T("fillRef") == strName) - fillRef = oNode; - else if (_T("effectRef") == strName) - effectRef = oNode; - else if (_T("fontRef") == strName) - fontRef = oNode; - } - } - - FillParentPointersForChilds(); - } - - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("xmlns:") + PPTX::g_Namespaces.p.m_strName, PPTX::g_Namespaces.p.m_strLink); - oAttr.Write(_T("xmlns:") + PPTX::g_Namespaces.a.m_strName, PPTX::g_Namespaces.a.m_strLink); - - XmlUtils::CNodeValue oValue; - oValue.Write(lnRef); - oValue.Write(fillRef); - oValue.Write(effectRef); - oValue.Write(fontRef); - - return XmlUtils::CreateNode(m_namespace + _T(":style"), oAttr, oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring name_ = L"a:style"; - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) name_ = L"cdr:style"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) name_ = L"dgm:style"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) name_ = L"dsp:style"; - else name_ = m_namespace + L":style"; - - pWriter->StartNode(name_); - pWriter->EndAttributes(); - - lnRef.toXmlWriter(pWriter); - fillRef.toXmlWriter(pWriter); - effectRef.toXmlWriter(pWriter); - fontRef.toXmlWriter(pWriter); - - pWriter->EndNode(name_); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord1(0, lnRef); - pWriter->WriteRecord1(1, fillRef); - pWriter->WriteRecord1(2, effectRef); - pWriter->WriteRecord1(3, fontRef); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - lnRef.m_name = _T("a:lnRef"); - lnRef.fromPPTY(pReader); - break; - } - case 1: - { - fillRef.m_name = _T("a:fillRef"); - fillRef.fromPPTY(pReader); - break; - } - case 2: - { - effectRef.m_name = _T("a:effectRef"); - effectRef.fromPPTY(pReader); - break; - } - case 3: - { - fontRef.m_name = _T("a:fontRef"); - fontRef.fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: StyleRef lnRef; @@ -212,16 +67,11 @@ namespace PPTX FontRef fontRef; mutable std::wstring m_namespace; + protected: - virtual void FillParentPointersForChilds() - { - lnRef.SetParentPointer(this); - fillRef.SetParentPointer(this); - effectRef.SetParentPointer(this); - fontRef.SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_SHAPESTYLE_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_SHAPESTYLE_INCLUDE_H diff --git a/OOXML/PPTXFormat/Logic/SmartArt.cpp b/OOXML/PPTXFormat/Logic/SmartArt.cpp index 859c2d0e22..b8ea7fc143 100644 --- a/OOXML/PPTXFormat/Logic/SmartArt.cpp +++ b/OOXML/PPTXFormat/Logic/SmartArt.cpp @@ -56,6 +56,31 @@ namespace PPTX { namespace Logic { + SmartArt::SmartArt() + { + } + SmartArt& SmartArt::operator=(const SmartArt& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + return *this; + } + OOX::EElementType SmartArt::getType () const + { + return OOX::et_dgm_DiagrammParts; + } + void SmartArt::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + } + void SmartArt::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"r:dm", id_data); + XmlMacroReadAttributeBase(node, L"r:cs", id_color); + XmlMacroReadAttributeBase(node, L"r:lo", id_layout); + XmlMacroReadAttributeBase(node, L"r:qs", id_style); + } smart_ptr SmartArt::FindDiagramDrawing(OOX::CDiagramData* pDiagramData) const { if (!pDiagramData) return NULL; @@ -397,6 +422,67 @@ namespace PPTX { pWriter->WriteString(toXML()); } + void SmartArt::FillParentPointersForChilds() + { + } + void SmartArt::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start(oReader) + WritingElement_ReadAttributes_Read_if(oReader, (L"r:cs"), id_color) + WritingElement_ReadAttributes_Read_else_if(oReader, (L"r:dm"), id_data) + WritingElement_ReadAttributes_Read_else_if(oReader, (L"r:lo"), id_layout) + WritingElement_ReadAttributes_Read_else_if(oReader, (L"r:qs"), id_style) + WritingElement_ReadAttributes_End(oReader) + } + + ChartRec::ChartRec() + { + } + ChartRec::ChartRec(const ChartRec& oSrc) + { + *this = oSrc; + } + ChartRec& ChartRec::operator=(const ChartRec& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + return *this; + } + void ChartRec::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start_No_NS( oReader ) + WritingElement_ReadAttributes_ReadSingle ( oReader, L"id", id_data ) + WritingElement_ReadAttributes_End_No_NS ( oReader ) + } + void ChartRec::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + std::wstring ns = XmlUtils::GetNamespace(oReader.GetName()); + + m_bChartEx = false; + + ReadAttributes( oReader ); + FillParentPointersForChilds(); + + if (ns == L"cx") + { + m_bChartEx = true; + } + } + void ChartRec::fromXML(XmlUtils::CXmlNode& node) + { + m_bChartEx = false; + + std::wstring ns = XmlUtils::GetNamespace(node.GetName()); + + XmlMacroReadAttributeBase(node, L"r:id", id_data); + FillParentPointersForChilds(); + + if (ns == L"cx") + { + m_bChartEx = true; + } + } void ChartRec::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const { OOX::IFileContainer* pRels = pWriter->GetRels().GetPointer(); @@ -596,7 +682,6 @@ namespace PPTX { pWriter->WriteString(toXML()); } - void ChartRec::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) { ULONG lLen = pReader->GetLong(); @@ -649,5 +734,8 @@ namespace PPTX oDrawingConverter.m_pReader = pOldReader; oDrawingConverter.m_pImageManager = pOldImageManager; } + void ChartRec::FillParentPointersForChilds() + { + } } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/SmartArt.h b/OOXML/PPTXFormat/Logic/SmartArt.h index eaeee75aaf..4bfa402e10 100644 --- a/OOXML/PPTXFormat/Logic/SmartArt.h +++ b/OOXML/PPTXFormat/Logic/SmartArt.h @@ -47,33 +47,14 @@ namespace PPTX public: WritingElement_AdditionConstructors(SmartArt) - SmartArt() - { - } + SmartArt(); + SmartArt& operator=(const SmartArt& oSrc); - SmartArt& operator=(const SmartArt& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + virtual OOX::EElementType getType () const; - return *this; - } + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - virtual OOX::EElementType getType () const - { - return OOX::et_dgm_DiagrammParts; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"r:dm", id_data); - XmlMacroReadAttributeBase(node, L"r:cs", id_color); - XmlMacroReadAttributeBase(node, L"r:lo", id_layout); - XmlMacroReadAttributeBase(node, L"r:qs", id_style); - } virtual std::wstring toXML() const; virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; @@ -90,20 +71,12 @@ namespace PPTX nullable m_oDrawing; smart_ptr m_pDrawingContainer; + protected: - virtual void FillParentPointersForChilds() - { - } + virtual void FillParentPointersForChilds(); + private: - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start(oReader) - WritingElement_ReadAttributes_Read_if(oReader, (L"r:cs"), id_color) - WritingElement_ReadAttributes_Read_else_if(oReader, (L"r:dm"), id_data) - WritingElement_ReadAttributes_Read_else_if(oReader, (L"r:lo"), id_layout) - WritingElement_ReadAttributes_Read_else_if(oReader, (L"r:qs"), id_style) - WritingElement_ReadAttributes_End(oReader) - } + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); smart_ptr FindDiagramDrawing(OOX::CDiagramData* pDiagramData) const; }; @@ -112,55 +85,16 @@ namespace PPTX public: WritingElement_AdditionConstructors(ChartRec) - ChartRec() - { - } + ChartRec(); + ChartRec(const ChartRec& oSrc); - ChartRec(const ChartRec& oSrc) - { - *this = oSrc; - } - ChartRec& operator=(const ChartRec& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + ChartRec& operator=(const ChartRec& oSrc); - return *this; - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS( oReader ) - WritingElement_ReadAttributes_ReadSingle ( oReader, L"id", id_data ) - WritingElement_ReadAttributes_End_No_NS ( oReader ) - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - std::wstring ns = XmlUtils::GetNamespace(oReader.GetName()); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - m_bChartEx = false; - - ReadAttributes( oReader ); - FillParentPointersForChilds(); - - if (ns == L"cx") - { - m_bChartEx = true; - } - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_bChartEx = false; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - std::wstring ns = XmlUtils::GetNamespace(node.GetName()); - - XmlMacroReadAttributeBase(node, L"r:id", id_data); - FillParentPointersForChilds(); - - if (ns == L"cx") - { - m_bChartEx = true; - } - } virtual std::wstring toXML() const; virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; @@ -171,10 +105,9 @@ namespace PPTX bool m_bChartEx = false; int m_nCountCharts = 0; + protected: - virtual void FillParentPointersForChilds() - { - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Sp3d.cpp b/OOXML/PPTXFormat/Logic/Sp3d.cpp new file mode 100644 index 0000000000..3a5c271542 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Sp3d.cpp @@ -0,0 +1,275 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Sp3d.h" + +namespace PPTX +{ + namespace Logic + { + Sp3d::Sp3d() {} + Sp3d& Sp3d::operator=(const Sp3d& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + contourW = oSrc.contourW; + extrusionH = oSrc.extrusionH; + prstMaterial = oSrc.prstMaterial; + z = oSrc.z; + + bevelT = oSrc.bevelT; + bevelB = oSrc.bevelB; + extrusionClr = oSrc.extrusionClr; + contourClr = oSrc.contourClr; + + return *this; + } + OOX::EElementType Sp3d::getType() const + { + return OOX::et_a_prstClr; + } + void Sp3d::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_name = XmlUtils::GetNameNoNS(oReader.GetName()); + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (_T("bevelT") == strName) + bevelT = oReader; + else if (_T("bevelB") == strName) + bevelB = oReader; + else if (_T("extrusionClr") == strName) + { + extrusionClr.GetColorFrom(oReader); + } + else if (_T("contourClr") == strName) + { + contourClr.GetColorFrom(oReader); + } + } + } + void Sp3d::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"contourW", contourW); + XmlMacroReadAttributeBase(node, L"extrusionH", extrusionH); + XmlMacroReadAttributeBase(node, L"prstMaterial", prstMaterial); + XmlMacroReadAttributeBase(node, L"z", z); + XmlMacroReadAttributeBase(node, L"macro", macro); + + XmlUtils::CXmlNodes oNodes; + if (node.GetNodes(_T("*"), oNodes)) + { + int nCount = oNodes.GetCount(); + for (int i = 0; i < nCount; ++i) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(i, oNode); + + std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); + + if (_T("bevelT") == strName) + bevelT = oNode; + else if (_T("bevelB") == strName) + bevelB = oNode; + else if (_T("extrusionClr") == strName) + { + extrusionClr.GetColorFrom(oNode); + } + else if (_T("contourClr") == strName) + { + contourClr.GetColorFrom(oNode); + } + } + } + + FillParentPointersForChilds(); + } + void Sp3d::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start_No_NS(oReader) + WritingElement_ReadAttributes_Read_if ( oReader, _T("contourW"), contourW) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("extrusionH"), extrusionH) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("prstMaterial"), prstMaterial) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("z"), z) + WritingElement_ReadAttributes_Read_else_if (oReader, _T("macro"), macro) + WritingElement_ReadAttributes_End_No_NS(oReader) + } + void Sp3d::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring sNodeNamespace, sNodeChildNamespace; + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + sNodeNamespace = L"w14:"; + sNodeChildNamespace = sAttrNamespace = sNodeNamespace; + } + else + { + sNodeNamespace = m_namespace + L":"; + sNodeChildNamespace = L"a:"; + } + + + pWriter->StartNode(sNodeNamespace + m_name); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + L"macro", macro); + pWriter->WriteAttribute(sAttrNamespace + L"contourW", contourW); + pWriter->WriteAttribute(sAttrNamespace + L"extrusionH", extrusionH); + pWriter->WriteAttribute(sAttrNamespace + L"prstMaterial", prstMaterial); + pWriter->WriteAttribute(sAttrNamespace + L"z", z); + pWriter->EndAttributes(); + + pWriter->Write(bevelT); + pWriter->Write(bevelB); + + if (extrusionClr.is_init()) + { + pWriter->StartNode(sNodeChildNamespace + L"extrusionClr"); + pWriter->EndAttributes(); + extrusionClr.toXmlWriter(pWriter); + pWriter->EndNode(sNodeChildNamespace + L"extrusionClr"); + } + if (contourClr.is_init()) + { + pWriter->StartNode(sNodeChildNamespace + L"contourClr"); + pWriter->EndAttributes(); + contourClr.toXmlWriter(pWriter); + pWriter->EndNode(sNodeChildNamespace + L"contourClr"); + } + + pWriter->EndNode(sNodeNamespace + m_name); + } + void Sp3d::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteInt2(0, contourW); + pWriter->WriteInt2(1, extrusionH); + pWriter->WriteLimit2(2, prstMaterial); + pWriter->WriteInt2(3, z); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, bevelT); + pWriter->WriteRecord2(1, bevelB); + pWriter->WriteRecord1(2, extrusionClr); + pWriter->WriteRecord1(3, contourClr); + + if (macro.IsInit()) + { + pWriter->StartRecord(SPTREE_TYPE_MACRO); + pWriter->WriteString1(0, *macro); + pWriter->EndRecord(); + } + } + void Sp3d::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) contourW = pReader->GetLong(); + else if (1 == _at) extrusionH = pReader->GetLong(); + else if (2 == _at) prstMaterial = pReader->GetUChar(); + else if (3 == _at) z = pReader->GetLong(); + else + break; + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + bevelT = new Logic::Bevel(L"bevelT"); + bevelT->fromPPTY(pReader); + break; + } + case 1: + { + bevelB = new Logic::Bevel(L"bevelB"); + bevelB->fromPPTY(pReader); + break; + } + case 2: + { + extrusionClr.fromPPTY(pReader); + break; + } + case 3: + { + contourClr.fromPPTY(pReader); + break; + } + case SPTREE_TYPE_MACRO: + { + pReader->Skip(5); // type + size + macro = pReader->GetString2(); + }break; + default: + break; + } + } + pReader->Seek(_end_rec); + } + void Sp3d::FillParentPointersForChilds() + { + if(bevelT.IsInit()) + bevelT->SetParentPointer(this); + if(bevelB.IsInit()) + bevelB->SetParentPointer(this); + extrusionClr.SetParentPointer(this); + contourClr.SetParentPointer(this); + } + AVSINLINE void Sp3d::Normalize() + { + contourW.normalize_positive(); + extrusionH.normalize_positive(); + } + } // namespace Logic +} // namespace PPTX + diff --git a/OOXML/PPTXFormat/Logic/Sp3d.h b/OOXML/PPTXFormat/Logic/Sp3d.h index 35bc33bd2c..7a7fefa5ea 100644 --- a/OOXML/PPTXFormat/Logic/Sp3d.h +++ b/OOXML/PPTXFormat/Logic/Sp3d.h @@ -40,237 +40,25 @@ namespace PPTX { namespace Logic { - class Sp3d : public WrapperWritingElement { public: WritingElement_AdditionConstructors(Sp3d) - Sp3d() {} - Sp3d& operator=(const Sp3d& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + Sp3d(); - contourW = oSrc.contourW; - extrusionH = oSrc.extrusionH; - prstMaterial = oSrc.prstMaterial; - z = oSrc.z; + Sp3d& operator=(const Sp3d& oSrc); + virtual OOX::EElementType getType() const; - bevelT = oSrc.bevelT; - bevelB = oSrc.bevelB; - extrusionClr = oSrc.extrusionClr; - contourClr = oSrc.contourClr; + void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - return *this; - } + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - virtual OOX::EElementType getType() const - { - return OOX::et_a_prstClr; - } - void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = XmlUtils::GetNameNoNS(oReader.GetName()); - ReadAttributes( oReader ); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - if ( oReader.IsEmptyNode() ) - return; - - int nCurDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); - - if (_T("bevelT") == strName) - bevelT = oReader; - else if (_T("bevelB") == strName) - bevelB = oReader; - else if (_T("extrusionClr") == strName) - { - extrusionClr.GetColorFrom(oReader); - } - else if (_T("contourClr") == strName) - { - contourClr.GetColorFrom(oReader); - } - } - } - - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"contourW", contourW); - XmlMacroReadAttributeBase(node, L"extrusionH", extrusionH); - XmlMacroReadAttributeBase(node, L"prstMaterial", prstMaterial); - XmlMacroReadAttributeBase(node, L"z", z); - XmlMacroReadAttributeBase(node, L"macro", macro); - - XmlUtils::CXmlNodes oNodes; - if (node.GetNodes(_T("*"), oNodes)) - { - int nCount = oNodes.GetCount(); - for (int i = 0; i < nCount; ++i) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(i, oNode); - - std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); - - if (_T("bevelT") == strName) - bevelT = oNode; - else if (_T("bevelB") == strName) - bevelB = oNode; - else if (_T("extrusionClr") == strName) - { - extrusionClr.GetColorFrom(oNode); - } - else if (_T("contourClr") == strName) - { - contourClr.GetColorFrom(oNode); - } - } - } - - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS(oReader) - WritingElement_ReadAttributes_Read_if ( oReader, _T("contourW"), contourW) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("extrusionH"), extrusionH) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("prstMaterial"), prstMaterial) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("z"), z) - WritingElement_ReadAttributes_Read_else_if (oReader, _T("macro"), macro) - WritingElement_ReadAttributes_End_No_NS(oReader) - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring sNodeNamespace, sNodeChildNamespace; - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - sNodeNamespace = L"w14:"; - sNodeChildNamespace = sAttrNamespace = sNodeNamespace; - } - else - { - sNodeNamespace = m_namespace + L":"; - sNodeChildNamespace = L"a:"; - } - - - pWriter->StartNode(sNodeNamespace + m_name); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + L"macro", macro); - pWriter->WriteAttribute(sAttrNamespace + L"contourW", contourW); - pWriter->WriteAttribute(sAttrNamespace + L"extrusionH", extrusionH); - pWriter->WriteAttribute(sAttrNamespace + L"prstMaterial", prstMaterial); - pWriter->WriteAttribute(sAttrNamespace + L"z", z); - pWriter->EndAttributes(); - - pWriter->Write(bevelT); - pWriter->Write(bevelB); - - if (extrusionClr.is_init()) - { - pWriter->StartNode(sNodeChildNamespace + L"extrusionClr"); - pWriter->EndAttributes(); - extrusionClr.toXmlWriter(pWriter); - pWriter->EndNode(sNodeChildNamespace + L"extrusionClr"); - } - if (contourClr.is_init()) - { - pWriter->StartNode(sNodeChildNamespace + L"contourClr"); - pWriter->EndAttributes(); - contourClr.toXmlWriter(pWriter); - pWriter->EndNode(sNodeChildNamespace + L"contourClr"); - } - - pWriter->EndNode(sNodeNamespace + m_name); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteInt2(0, contourW); - pWriter->WriteInt2(1, extrusionH); - pWriter->WriteLimit2(2, prstMaterial); - pWriter->WriteInt2(3, z); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, bevelT); - pWriter->WriteRecord2(1, bevelB); - pWriter->WriteRecord1(2, extrusionClr); - pWriter->WriteRecord1(3, contourClr); - - if (macro.IsInit()) - { - pWriter->StartRecord(SPTREE_TYPE_MACRO); - pWriter->WriteString1(0, *macro); - pWriter->EndRecord(); - } - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) contourW = pReader->GetLong(); - else if (1 == _at) extrusionH = pReader->GetLong(); - else if (2 == _at) prstMaterial = pReader->GetUChar(); - else if (3 == _at) z = pReader->GetLong(); - else - break; - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - bevelT = new Logic::Bevel(L"bevelT"); - bevelT->fromPPTY(pReader); - break; - } - case 1: - { - bevelB = new Logic::Bevel(L"bevelB"); - bevelB->fromPPTY(pReader); - break; - } - case 2: - { - extrusionClr.fromPPTY(pReader); - break; - } - case 3: - { - contourClr.fromPPTY(pReader); - break; - } - case SPTREE_TYPE_MACRO: - { - pReader->Skip(5); // type + size - macro = pReader->GetString2(); - }break; - default: - break; - } - } - pReader->Seek(_end_rec); - } - nullable_string macro; nullable_int contourW; nullable_int extrusionH; @@ -284,22 +72,10 @@ namespace PPTX std::wstring m_name = L"sp3d"; std::wstring m_namespace = L"a"; - protected: - virtual void FillParentPointersForChilds() - { - if(bevelT.IsInit()) - bevelT->SetParentPointer(this); - if(bevelB.IsInit()) - bevelB->SetParentPointer(this); - extrusionClr.SetParentPointer(this); - contourClr.SetParentPointer(this); - } - AVSINLINE void Normalize() - { - contourW.normalize_positive(); - extrusionH.normalize_positive(); - } + protected: + virtual void FillParentPointersForChilds(); + void Normalize(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/SpPr.cpp b/OOXML/PPTXFormat/Logic/SpPr.cpp index bbf75795dc..09a417390a 100644 --- a/OOXML/PPTXFormat/Logic/SpPr.cpp +++ b/OOXML/PPTXFormat/Logic/SpPr.cpp @@ -55,7 +55,6 @@ namespace PPTX { fromXML(oReader); } - const SpPr& SpPr::operator =(XmlUtils::CXmlNode& node) { fromXML(node); @@ -157,7 +156,6 @@ namespace PPTX FillParentPointersForChilds(); } - std::wstring SpPr::toXML() const { XmlUtils::CAttribute oAttr; @@ -174,7 +172,6 @@ namespace PPTX return XmlUtils::CreateNode(m_namespace + L":spPr", oAttr, oValue); } - void SpPr::Merge(SpPr& spPr)const { if(xfrm.IsInit()) @@ -186,7 +183,6 @@ namespace PPTX if(ln.IsInit()) ln->Merge(spPr.ln); } - void SpPr::FillParentPointersForChilds() { if(xfrm.IsInit()) @@ -201,7 +197,6 @@ namespace PPTX if(sp3d.IsInit()) sp3d->SetParentPointer(this); } - void SpPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) { LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; @@ -273,5 +268,72 @@ namespace PPTX pReader->Seek(_end_rec); } + OOX::EElementType SpPr::getType () const + { + return OOX::et_a_spPr; + } + void SpPr::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_ReadSingle( oReader, _T("bwMode"), bwMode ) + WritingElement_ReadAttributes_End( oReader ) + } + void SpPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring name_ = L"a:spPr"; + + if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) + { + if (0 == (pWriter->m_lFlag & 0x01)) name_ = L"wps:spPr"; + else name_ = L"pic:spPr"; + } + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) name_ = L"xdr:spPr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) name_ = L"cdr:spPr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) name_ = L"dgm:spPr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) name_ = L"dsp:spPr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART) name_ = L"c:spPr"; + else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) name_ = L"a:spPr"; + else + {//theme + if (0 != (pWriter->m_lFlag & 0x04)) name_ = L"a:spPr"; + else name_ = L"p:spPr"; + } + pWriter->StartNode(name_); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("bwMode"), bwMode); + pWriter->EndAttributes(); + + pWriter->Write(xfrm); + Geometry.toXmlWriter(pWriter); + + if ((pWriter->m_lFlag & 0x02) != 0 && !Fill.is_init()) + { + pWriter->WriteString(_T("")); + } + Fill.toXmlWriter(pWriter); + + pWriter->Write(ln); + EffectList.toXmlWriter(pWriter); + pWriter->Write(scene3d); + pWriter->Write(sp3d); + + pWriter->EndNode(name_); + } + void SpPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit2(0, bwMode); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, xfrm); + pWriter->WriteRecord1(1, Geometry); + pWriter->WriteRecord1(2, Fill); + pWriter->WriteRecord2(3, ln); + pWriter->WriteRecord1(4, EffectList); + pWriter->WriteRecord2(5, scene3d); + pWriter->WriteRecord2(6, sp3d); + } } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/SpPr.h b/OOXML/PPTXFormat/Logic/SpPr.h index fb176f3f2e..83fa2c21b7 100644 --- a/OOXML/PPTXFormat/Logic/SpPr.h +++ b/OOXML/PPTXFormat/Logic/SpPr.h @@ -60,83 +60,19 @@ namespace PPTX explicit SpPr(XmlUtils::CXmlLiteReader& oReader); const SpPr& operator =(XmlUtils::CXmlLiteReader& oReader); - virtual OOX::EElementType getType () const - { - return OOX::et_a_spPr; - } + virtual OOX::EElementType getType () const; virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); virtual void fromXML(XmlUtils::CXmlNode& node); - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_ReadSingle( oReader, _T("bwMode"), bwMode ) - WritingElement_ReadAttributes_End( oReader ) - } - + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + virtual std::wstring toXML() const; - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring name_ = L"a:spPr"; - - if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) - { - if (0 == (pWriter->m_lFlag & 0x01)) name_ = L"wps:spPr"; - else name_ = L"pic:spPr"; - } - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) name_ = L"xdr:spPr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) name_ = L"cdr:spPr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DIAGRAM) name_ = L"dgm:spPr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DSP_DRAWING) name_ = L"dsp:spPr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART) name_ = L"c:spPr"; - else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) name_ = L"a:spPr"; - else - {//theme - if (0 != (pWriter->m_lFlag & 0x04)) name_ = L"a:spPr"; - else name_ = L"p:spPr"; - } - pWriter->StartNode(name_); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("bwMode"), bwMode); - pWriter->EndAttributes(); - - pWriter->Write(xfrm); - Geometry.toXmlWriter(pWriter); - - if ((pWriter->m_lFlag & 0x02) != 0 && !Fill.is_init()) - { - pWriter->WriteString(_T("")); - } - Fill.toXmlWriter(pWriter); - - pWriter->Write(ln); - EffectList.toXmlWriter(pWriter); - pWriter->Write(scene3d); - pWriter->Write(sp3d); - - pWriter->EndNode(name_); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit2(0, bwMode); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, xfrm); - pWriter->WriteRecord1(1, Geometry); - pWriter->WriteRecord1(2, Fill); - pWriter->WriteRecord2(3, ln); - pWriter->WriteRecord1(4, EffectList); - pWriter->WriteRecord2(5, scene3d); - pWriter->WriteRecord2(6, sp3d); - } - + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + void Merge(SpPr& spPr)const; nullable xfrm; @@ -152,6 +88,7 @@ namespace PPTX std::vector extLst; std::wstring m_namespace; + protected: virtual void FillParentPointersForChilds(); }; diff --git a/OOXML/PPTXFormat/Logic/SpTree.cpp b/OOXML/PPTXFormat/Logic/SpTree.cpp index da0d8971d2..44c3cacc33 100644 --- a/OOXML/PPTXFormat/Logic/SpTree.cpp +++ b/OOXML/PPTXFormat/Logic/SpTree.cpp @@ -30,7 +30,6 @@ * */ - #include "SpTree.h" #include "Shape.h" #include "Pic.h" @@ -41,6 +40,39 @@ namespace PPTX { namespace Logic { + SpTree::SpTree(std::wstring ns) : nvGrpSpPr(ns), grpSpPr(ns) + { + m_namespace = ns; + m_lGroupIndex = 0; + } + SpTree& SpTree::operator=(const SpTree& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + nvGrpSpPr = oSrc.nvGrpSpPr; + grpSpPr = oSrc.grpSpPr; + + for (size_t i=0; i < oSrc.SpTreeElems.size(); i++) + SpTreeElems.push_back(oSrc.SpTreeElems[i]); + + m_namespace = oSrc.m_namespace; + m_lGroupIndex = oSrc.m_lGroupIndex; + + return *this; + } + OOX::EElementType SpTree::getType () const + { + return OOX::et_p_ShapeTree; + } + void SpTree::FillParentPointersForChilds() + { + nvGrpSpPr.SetParentPointer(this); + grpSpPr.SetParentPointer(this); + + for (size_t i = 0; i < SpTreeElems.size(); ++i) + SpTreeElems[i].SetParentPointer(this); + } void SpTree::fromXML(XmlUtils::CXmlLiteReader& oReader) { m_namespace = XmlUtils::GetNamespace(oReader.GetName()); @@ -339,7 +371,6 @@ namespace PPTX pWriter->EndNode(name_); } - void SpTree::NormalizeRect(Aggplus::RECT& rect)const { if (grpSpPr.xfrm.IsInit()) @@ -359,7 +390,6 @@ namespace PPTX if (parentIs()) parentAs().NormalizeRect(rect); } - void SpTree::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const { if (getType() == OOX::et_lc_LockedCanvas) @@ -429,5 +459,151 @@ namespace PPTX } pReader->Seek(_end_rec); } + + LockedCanvas::LockedCanvas() : SpTree(L"a") + { + } + LockedCanvas& LockedCanvas::operator=(const LockedCanvas& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + nvGrpSpPr = oSrc.nvGrpSpPr; + grpSpPr = oSrc.grpSpPr; + + for (size_t i=0; i < oSrc.SpTreeElems.size(); i++) + SpTreeElems.push_back(oSrc.SpTreeElems[i]); + + m_lGroupIndex = oSrc.m_lGroupIndex; + + return *this; + } + OOX::EElementType LockedCanvas::getType () const + { + return OOX::et_lc_LockedCanvas; + } + void LockedCanvas::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + SpTree::fromXML(oReader); + } + void LockedCanvas::fromXML(XmlUtils::CXmlNode& node) + { + SpTree::fromXML(node); + } + std::wstring LockedCanvas::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(L"xmlns:lc", L"http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas"); + + XmlUtils::CNodeValue oValue; + oValue.Write(nvGrpSpPr); + oValue.Write(grpSpPr); + + oValue.WriteArray(SpTreeElems); + + return XmlUtils::CreateNode(L"lc:lockedCanvas", oAttr, oValue); + } + void LockedCanvas::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + BYTE lDocType = pWriter->m_lDocType; + pWriter->m_lDocType = XMLWRITER_DOC_TYPE_GRAPHICS; + + pWriter->StartNode(L"lc:lockedCanvas"); + pWriter->StartAttributes(); + pWriter->WriteAttribute(L"xmlns:lc", L"http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas"); + + pWriter->EndAttributes(); + + nvGrpSpPr.toXmlWriter(pWriter); + + grpSpPr.toXmlWriter(pWriter); + + pWriter->m_lGroupIndex++; + + for (size_t i = 0; i < SpTreeElems.size(); ++i) + { + SpTreeElems[i].toXmlWriter(pWriter); + } + + pWriter->m_lGroupIndex--; + + pWriter->EndNode(L"lc:lockedCanvas"); + + pWriter->m_lDocType = lDocType; + } + void LockedCanvas::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + BinDocxRW::CDocxSerializer* docx = pWriter->m_pMainDocument; + pWriter->m_pMainDocument = NULL; + + pWriter->StartRecord(SPTREE_TYPE_LOCKED_CANVAS); + + pWriter->WriteRecord1(0, nvGrpSpPr); + pWriter->WriteRecord1(1, grpSpPr); + pWriter->WriteRecordArray(2, 0, SpTreeElems); + + pWriter->EndRecord(); + pWriter->m_pMainDocument = docx; + } + void LockedCanvas::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(5); // type + len + + BinDocxRW::CDocxSerializer* docx = pReader->m_pMainDocument; + pReader->m_pMainDocument = NULL; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + nvGrpSpPr.fromPPTY(pReader); + break; + } + case 1: + { + grpSpPr.fromPPTY(pReader); + break; + } + case 2: + { + pReader->Skip(4); // len + ULONG _c = pReader->GetULong(); + + for (ULONG i = 0; i < _c; ++i) + { + pReader->Skip(1); // type (0) + LONG nElemLength = pReader->GetLong(); // len + //SpTreeElem::fromPPTY сразу делает GetChar, а toPPTY ничего не пишет если не инициализирован + if(nElemLength > 0) + { + SpTreeElem elm; + elm.fromPPTY(pReader); + + if (elm.is_init()) + { + if (elm.getType() == OOX::et_p_ShapeTree) + { + smart_ptr e = elm.GetElem().smart_dynamic_cast(); + e->m_lGroupIndex = m_lGroupIndex + 1; + } + SpTreeElems.push_back(elm); + } + } + } + } + default: + { + break; + } + } + } + pReader->Seek(_end_rec); + pReader->m_pMainDocument = docx; + } } } diff --git a/OOXML/PPTXFormat/Logic/SpTree.h b/OOXML/PPTXFormat/Logic/SpTree.h index 91e29d1bfb..9071a6ec96 100644 --- a/OOXML/PPTXFormat/Logic/SpTree.h +++ b/OOXML/PPTXFormat/Logic/SpTree.h @@ -47,32 +47,11 @@ namespace PPTX public: WritingElement_AdditionConstructors(SpTree) - SpTree(std::wstring ns = L"p") : nvGrpSpPr(ns), grpSpPr(ns) - { - m_namespace = ns; - m_lGroupIndex = 0; - } + SpTree(std::wstring ns = L"p"); - SpTree& operator=(const SpTree& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + SpTree& operator=(const SpTree& oSrc); + virtual OOX::EElementType getType () const; - nvGrpSpPr = oSrc.nvGrpSpPr; - grpSpPr = oSrc.grpSpPr; - - for (size_t i=0; i < oSrc.SpTreeElems.size(); i++) - SpTreeElems.push_back(oSrc.SpTreeElems[i]); - - m_namespace = oSrc.m_namespace; - m_lGroupIndex = oSrc.m_lGroupIndex; - - return *this; - } - virtual OOX::EElementType getType () const - { - return OOX::et_p_ShapeTree; - } virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); virtual void fromXML(XmlUtils::CXmlNode& node); virtual std::wstring toXML() const; @@ -93,171 +72,29 @@ namespace PPTX std::wstring m_namespace; int m_lGroupIndex; - protected: - virtual void FillParentPointersForChilds() - { - nvGrpSpPr.SetParentPointer(this); - grpSpPr.SetParentPointer(this); - for (size_t i = 0; i < SpTreeElems.size(); ++i) - SpTreeElems[i].SetParentPointer(this); - } + protected: + virtual void FillParentPointersForChilds(); }; + class LockedCanvas : public SpTree { public: WritingElement_AdditionConstructors(LockedCanvas) - LockedCanvas() : SpTree(L"a") - { - } + LockedCanvas(); - LockedCanvas& operator=(const LockedCanvas& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + LockedCanvas& operator=(const LockedCanvas& oSrc); - nvGrpSpPr = oSrc.nvGrpSpPr; - grpSpPr = oSrc.grpSpPr; + virtual OOX::EElementType getType () const; - for (size_t i=0; i < oSrc.SpTreeElems.size(); i++) - SpTreeElems.push_back(oSrc.SpTreeElems[i]); - - m_lGroupIndex = oSrc.m_lGroupIndex; - - return *this; - } - virtual OOX::EElementType getType () const - { - return OOX::et_lc_LockedCanvas; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - SpTree::fromXML(oReader); - } - - virtual void fromXML(XmlUtils::CXmlNode& node) - { - SpTree::fromXML(node); - } - - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(L"xmlns:lc", L"http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas"); - - XmlUtils::CNodeValue oValue; - oValue.Write(nvGrpSpPr); - oValue.Write(grpSpPr); - - oValue.WriteArray(SpTreeElems); - - return XmlUtils::CreateNode(L"lc:lockedCanvas", oAttr, oValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - BYTE lDocType = pWriter->m_lDocType; - pWriter->m_lDocType = XMLWRITER_DOC_TYPE_GRAPHICS; - - pWriter->StartNode(L"lc:lockedCanvas"); - pWriter->StartAttributes(); - pWriter->WriteAttribute(L"xmlns:lc", L"http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas"); - - pWriter->EndAttributes(); - - nvGrpSpPr.toXmlWriter(pWriter); - - grpSpPr.toXmlWriter(pWriter); - - pWriter->m_lGroupIndex++; - - for (size_t i = 0; i < SpTreeElems.size(); ++i) - { - SpTreeElems[i].toXmlWriter(pWriter); - } - - pWriter->m_lGroupIndex--; - - pWriter->EndNode(L"lc:lockedCanvas"); - - pWriter->m_lDocType = lDocType; - } - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - BinDocxRW::CDocxSerializer* docx = pWriter->m_pMainDocument; - pWriter->m_pMainDocument = NULL; - - pWriter->StartRecord(SPTREE_TYPE_LOCKED_CANVAS); - - pWriter->WriteRecord1(0, nvGrpSpPr); - pWriter->WriteRecord1(1, grpSpPr); - pWriter->WriteRecordArray(2, 0, SpTreeElems); - - pWriter->EndRecord(); - pWriter->m_pMainDocument = docx; - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(5); // type + len - - BinDocxRW::CDocxSerializer* docx = pReader->m_pMainDocument; - pReader->m_pMainDocument = NULL; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - nvGrpSpPr.fromPPTY(pReader); - break; - } - case 1: - { - grpSpPr.fromPPTY(pReader); - break; - } - case 2: - { - pReader->Skip(4); // len - ULONG _c = pReader->GetULong(); - - for (ULONG i = 0; i < _c; ++i) - { - pReader->Skip(1); // type (0) - LONG nElemLength = pReader->GetLong(); // len - //SpTreeElem::fromPPTY сразу делает GetChar, а toPPTY ничего не пишет если не инициализирован - if(nElemLength > 0) - { - SpTreeElem elm; - elm.fromPPTY(pReader); - - if (elm.is_init()) - { - if (elm.getType() == OOX::et_p_ShapeTree) - { - smart_ptr e = elm.GetElem().smart_dynamic_cast(); - e->m_lGroupIndex = m_lGroupIndex + 1; - } - SpTreeElems.push_back(elm); - } - } - } - } - default: - { - break; - } - } - } - pReader->Seek(_end_rec); - pReader->m_pMainDocument = docx; - } + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/StyleRef.cpp b/OOXML/PPTXFormat/Logic/StyleRef.cpp new file mode 100644 index 0000000000..2ef5f711c5 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/StyleRef.cpp @@ -0,0 +1,141 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "StyleRef.h" + +namespace PPTX +{ + namespace Logic + { + StyleRef::StyleRef() + { + } + OOX::EElementType StyleRef::getType () const + { + return OOX::et_Unknown; + } + void StyleRef::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_name = oReader.GetName(); + + ReadAttributes( oReader ); + + Color.fromXMLParent(oReader); + + FillParentPointersForChilds(); + } + void StyleRef::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start ( oReader ) + WritingElement_ReadAttributes_ReadSingle( oReader, _T("idx"), idx ) + WritingElement_ReadAttributes_End ( oReader ) + } + void StyleRef::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + XmlMacroReadAttributeBase(node, L"idx", idx); + Color.GetColorFrom(node); + FillParentPointersForChilds(); + } + std::wstring StyleRef::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("idx"), idx); + + return XmlUtils::CreateNode(m_name, oAttr, Color.toXML()); + } + void StyleRef::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("idx"), idx); + pWriter->EndAttributes(); + + Color.toXmlWriter(pWriter); + + pWriter->EndNode(m_name); + } + void StyleRef::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + if (0 == _at) + idx = pReader->GetLong(); + else + break; + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + Color.fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void StyleRef::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteInt2(0, idx); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord1(0, Color); + } + void StyleRef::FillParentPointersForChilds() + { + Color.SetParentPointer(this); + } + AVSINLINE void StyleRef::Nomalize() + { + idx.normalize_positive(); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/StyleRef.h b/OOXML/PPTXFormat/Logic/StyleRef.h index d59ee74bf9..ccf216f8c8 100644 --- a/OOXML/PPTXFormat/Logic/StyleRef.h +++ b/OOXML/PPTXFormat/Logic/StyleRef.h @@ -46,118 +46,27 @@ namespace PPTX public: WritingElement_AdditionConstructors(StyleRef) - StyleRef() - { - } + StyleRef(); - virtual OOX::EElementType getType () const - { - return OOX::et_Unknown; - } + virtual OOX::EElementType getType () const; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = oReader.GetName(); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - ReadAttributes( oReader ); - - Color.fromXMLParent(oReader); - - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start ( oReader ) - WritingElement_ReadAttributes_ReadSingle( oReader, _T("idx"), idx ) - WritingElement_ReadAttributes_End ( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - XmlMacroReadAttributeBase(node, L"idx", idx); - Color.GetColorFrom(node); - FillParentPointersForChilds(); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("idx"), idx); - - return XmlUtils::CreateNode(m_name, oAttr, Color.toXML()); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("idx"), idx); - pWriter->EndAttributes(); - - Color.toXmlWriter(pWriter); - - pWriter->EndNode(m_name); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - if (0 == _at) - idx = pReader->GetLong(); - else - break; - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - Color.fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteInt2(0, idx); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord1(0, Color); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; UniColor Color; nullable_int idx; std::wstring m_name; - protected: - virtual void FillParentPointersForChilds() - { - Color.SetParentPointer(this); - } - AVSINLINE void Nomalize() - { - idx.normalize_positive(); - } + protected: + virtual void FillParentPointersForChilds(); + AVSINLINE void Nomalize(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/SupplementalFont.cpp b/OOXML/PPTXFormat/Logic/SupplementalFont.cpp new file mode 100644 index 0000000000..5b3c63c277 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/SupplementalFont.cpp @@ -0,0 +1,99 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "SupplementalFont.h" + +namespace PPTX +{ + namespace Logic + { + void SupplementalFont::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + XmlMacroReadAttributeBase(node, L"script", script); + XmlMacroReadAttributeBase(node, L"typeface", typeface); + } + void SupplementalFont::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("script"), script); + pWriter->WriteAttribute(_T("typeface"), typeface); + pWriter->EndAttributes(); + + pWriter->EndNode(m_name); + } + void SupplementalFont::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteString1(0, script); + pWriter->WriteString1(1, typeface); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void SupplementalFont::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attr + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + script = pReader->GetString2(); + break; + } + case 1: + { + typeface = pReader->GetString2(); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void SupplementalFont::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/SupplementalFont.h b/OOXML/PPTXFormat/Logic/SupplementalFont.h index 8f212f985c..686f8a13c9 100644 --- a/OOXML/PPTXFormat/Logic/SupplementalFont.h +++ b/OOXML/PPTXFormat/Logic/SupplementalFont.h @@ -46,74 +46,21 @@ namespace PPTX PPTX_LOGIC_BASE(SupplementalFont) public: - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - XmlMacroReadAttributeBase(node, L"script", script); - XmlMacroReadAttributeBase(node, L"typeface", typeface); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("script"), script); - pWriter->WriteAttribute(_T("typeface"), typeface); - pWriter->EndAttributes(); - - pWriter->EndNode(m_name); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteString1(0, script); - pWriter->WriteString1(1, typeface); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attr - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - script = pReader->GetString2(); - break; - } - case 1: - { - typeface = pReader->GetString2(); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: std::wstring script; std::wstring typeface; - //private: + public: std::wstring m_name; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Tab.cpp b/OOXML/PPTXFormat/Logic/Tab.cpp new file mode 100644 index 0000000000..00439c744d --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Tab.cpp @@ -0,0 +1,86 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Tab.h" + +namespace PPTX +{ + namespace Logic + { + void Tab::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + } + OOX::EElementType Tab::getType () const + { + return OOX::et_a_tab; + } + void Tab::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start ( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("pos"), pos) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("algn"), algn) + WritingElement_ReadAttributes_End ( oReader ) + } + void Tab::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"pos", pos); + XmlMacroReadAttributeBase(node, L"algn", algn); + + FillParentPointersForChilds(); + } + void Tab::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit2(0, algn); + pWriter->WriteInt2(1, pos); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void Tab::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:tab")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("pos"), pos); + pWriter->WriteAttribute(_T("algn"), algn); + pWriter->EndAttributes(); + + pWriter->EndNode(_T("a:tab")); + } + void Tab::FillParentPointersForChilds() + { + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Tab.h b/OOXML/PPTXFormat/Logic/Tab.h index 344a372bb2..e39b3ff74d 100644 --- a/OOXML/PPTXFormat/Logic/Tab.h +++ b/OOXML/PPTXFormat/Logic/Tab.h @@ -45,57 +45,22 @@ namespace PPTX public: WritingElement_AdditionConstructors(Tab) PPTX_LOGIC_BASE2(Tab) - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes( oReader ); - if ( oReader.IsEmptyNode() ) - return; - } - virtual OOX::EElementType getType () const - { - return OOX::et_a_tab; - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start ( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("pos"), pos) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("algn"), algn) - WritingElement_ReadAttributes_End ( oReader ) - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"pos", pos); - XmlMacroReadAttributeBase(node, L"algn", algn); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual OOX::EElementType getType () const; - FillParentPointersForChilds(); - } + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit2(0, algn); - pWriter->WriteInt2(1, pos); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:tab")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("pos"), pos); - pWriter->WriteAttribute(_T("algn"), algn); - pWriter->EndAttributes(); - - pWriter->EndNode(_T("a:tab")); - } + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; public: nullable_int pos; nullable_limit algn; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TableBgStyle.cpp b/OOXML/PPTXFormat/Logic/TableBgStyle.cpp new file mode 100644 index 0000000000..aff86571e0 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/TableBgStyle.cpp @@ -0,0 +1,120 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "TableBgStyle.h" + +namespace PPTX +{ + namespace Logic + { + void TableBgStyle::fromXML(XmlUtils::CXmlNode& node) + { + fill = node.ReadNode(_T("a:fill")); + fillRef = node.ReadNodeNoNS(_T("fillRef")); + + FillParentPointersForChilds(); + } + void TableBgStyle::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:tblBg")); + pWriter->EndAttributes(); + + pWriter->Write(fill); + pWriter->Write(fillRef); + + pWriter->EndNode(_T("a:tblBg")); + } + void TableBgStyle::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord2(0, fill); + pWriter->WriteRecord2(1, fillRef); + } + void TableBgStyle::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + fill = new FillStyle(); + fill->fromPPTY(pReader); + break; + } + case 1: + { + fillRef = new StyleRef(); + fillRef->fromPPTY(pReader); + fillRef->m_name = _T("a:fillRef"); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + const UniFill TableBgStyle::GetFillStyle(UniColor& Color)const + { + UniFill result; + result.SetParentFilePointer(parentFile); + UniColor resColor; + resColor.SetParentFilePointer(parentFile); + Color = resColor; + + if(fill.IsInit()) + return fill->Fill; + if(fillRef.IsInit()) + { + m_Theme->GetFillStyle(fillRef->idx.get_value_or(0), result); + Color = fillRef->Color; + return result; + } + return result; + } + void TableBgStyle::FillParentPointersForChilds() + { + if(fill.IsInit()) + fill->SetParentPointer(this); + if(fillRef.IsInit()) + fillRef->SetParentPointer(this); + } + void TableBgStyle::SetTheme(const smart_ptr theme) + { + m_Theme = theme; + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TableBgStyle.h b/OOXML/PPTXFormat/Logic/TableBgStyle.h index 8b17f89fb6..ac47a6d778 100644 --- a/OOXML/PPTXFormat/Logic/TableBgStyle.h +++ b/OOXML/PPTXFormat/Logic/TableBgStyle.h @@ -49,60 +49,11 @@ namespace PPTX PPTX_LOGIC_BASE(TableBgStyle) public: - virtual void fromXML(XmlUtils::CXmlNode& node) - { - fill = node.ReadNode(_T("a:fill")); - fillRef = node.ReadNodeNoNS(_T("fillRef")); + virtual void fromXML(XmlUtils::CXmlNode& node); - FillParentPointersForChilds(); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:tblBg")); - pWriter->EndAttributes(); - - pWriter->Write(fill); - pWriter->Write(fillRef); - - pWriter->EndNode(_T("a:tblBg")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord2(0, fill); - pWriter->WriteRecord2(1, fillRef); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - fill = new FillStyle(); - fill->fromPPTY(pReader); - break; - } - case 1: - { - fillRef = new StyleRef(); - fillRef->fromPPTY(pReader); - fillRef->m_name = _T("a:fillRef"); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: // Childs @@ -111,42 +62,18 @@ namespace PPTX nullable fill; nullable fillRef; - const UniFill GetFillStyle(UniColor& Color)const - { - UniFill result; - result.SetParentFilePointer(parentFile); - UniColor resColor; - resColor.SetParentFilePointer(parentFile); - Color = resColor; + const UniFill GetFillStyle(UniColor& Color) const; - if(fill.IsInit()) - return fill->Fill; - if(fillRef.IsInit()) - { - m_Theme->GetFillStyle(fillRef->idx.get_value_or(0), result); - Color = fillRef->Color; - return result; - } - return result; - } protected: - virtual void FillParentPointersForChilds() - { - if(fill.IsInit()) - fill->SetParentPointer(this); - if(fillRef.IsInit()) - fillRef->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); public: - void SetTheme(const smart_ptr theme) - { - m_Theme = theme; - } + void SetTheme(const smart_ptr theme); + private: smart_ptr m_Theme; }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_TABLEBGSTYLE_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_TABLEBGSTYLE_INCLUDE_H diff --git a/OOXML/PPTXFormat/Logic/TablePartStyle.cpp b/OOXML/PPTXFormat/Logic/TablePartStyle.cpp new file mode 100644 index 0000000000..72ba7a7345 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/TablePartStyle.cpp @@ -0,0 +1,122 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "TablePartStyle.h" + +namespace PPTX +{ + namespace Logic + { + void TablePartStyle::fromXML(XmlUtils::CXmlNode& node) + { + m_name = XmlUtils::GetNameNoNS(node.GetName()); + + tcTxStyle = node.ReadNode(_T("a:tcTxStyle")); + tcStyle = node.ReadNode(_T("a:tcStyle")); + + FillParentPointersForChilds(); + } + void TablePartStyle::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + pWriter->EndAttributes(); + + pWriter->Write(tcTxStyle); + pWriter->Write(tcStyle); + + pWriter->EndNode(m_name); + } + void TablePartStyle::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord2(0, tcTxStyle); + pWriter->WriteRecord2(1, tcStyle); + } + void TablePartStyle::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + tcTxStyle = new TcTxStyle(); + tcTxStyle->fromPPTY(pReader); + break; + } + case 1: + { + tcStyle = new TcStyle(); + tcStyle->fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + const UniFill TablePartStyle::GetFillStyle(UniColor& Color) const + { + UniFill result; + result.SetParentFilePointer(parentFile); + UniColor resColor; + resColor.SetParentFilePointer(parentFile); + Color = resColor; + if(!tcStyle.IsInit()) + return result; + if(tcStyle->fill.IsInit()) + return tcStyle->fill->Fill; + if(tcStyle->fillRef.IsInit()) + { + m_Theme->GetFillStyle(tcStyle->fillRef->idx.get_value_or(0), result); + Color = tcStyle->fillRef->Color; + return result; + } + return result; + } + void TablePartStyle::SetTheme(const smart_ptr theme) + { + m_Theme = theme; + } + void TablePartStyle::FillParentPointersForChilds() + { + if(tcTxStyle.IsInit()) + tcTxStyle->SetParentPointer(this); + if(tcStyle.IsInit()) + tcStyle->SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TablePartStyle.h b/OOXML/PPTXFormat/Logic/TablePartStyle.h index 126762ff29..73b713acdb 100644 --- a/OOXML/PPTXFormat/Logic/TablePartStyle.h +++ b/OOXML/PPTXFormat/Logic/TablePartStyle.h @@ -49,97 +49,22 @@ namespace PPTX public: PPTX_LOGIC_BASE(TablePartStyle) - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = XmlUtils::GetNameNoNS(node.GetName()); + virtual void fromXML(XmlUtils::CXmlNode& node); - tcTxStyle = node.ReadNode(_T("a:tcTxStyle")); - tcStyle = node.ReadNode(_T("a:tcStyle")); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - FillParentPointersForChilds(); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - pWriter->EndAttributes(); - - pWriter->Write(tcTxStyle); - pWriter->Write(tcStyle); - - pWriter->EndNode(m_name); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord2(0, tcTxStyle); - pWriter->WriteRecord2(1, tcStyle); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - tcTxStyle = new TcTxStyle(); - tcTxStyle->fromPPTY(pReader); - break; - } - case 1: - { - tcStyle = new TcStyle(); - tcStyle->fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } nullable tcTxStyle; nullable tcStyle; - const UniFill GetFillStyle(UniColor& Color) const - { - UniFill result; - result.SetParentFilePointer(parentFile); - UniColor resColor; - resColor.SetParentFilePointer(parentFile); - Color = resColor; - if(!tcStyle.IsInit()) - return result; - if(tcStyle->fill.IsInit()) - return tcStyle->fill->Fill; - if(tcStyle->fillRef.IsInit()) - { - m_Theme->GetFillStyle(tcStyle->fillRef->idx.get_value_or(0), result); - Color = tcStyle->fillRef->Color; - return result; - } - return result; - } + const UniFill GetFillStyle(UniColor& Color) const; + void SetTheme(const smart_ptr theme); - void SetTheme(const smart_ptr theme) - { - m_Theme = theme; - } - std::wstring m_name; + protected: - virtual void FillParentPointersForChilds() - { - if(tcTxStyle.IsInit()) - tcTxStyle->SetParentPointer(this); - if(tcStyle.IsInit()) - tcStyle->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); private: smart_ptr m_Theme; @@ -147,4 +72,4 @@ namespace PPTX } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_TABLEPARTSTYLE_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_TABLEPARTSTYLE_INCLUDE_H diff --git a/OOXML/PPTXFormat/Logic/TableStyle.cpp b/OOXML/PPTXFormat/Logic/TableStyle.cpp new file mode 100644 index 0000000000..ff3beb5a23 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/TableStyle.cpp @@ -0,0 +1,318 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "TableStyle.h" + +namespace PPTX +{ + namespace Logic + { + void TableStyle::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + XmlMacroReadAttributeBase(node, L"styleId", styleId); + XmlMacroReadAttributeBase(node, L"styleName", styleName); + + tblBg = node.ReadNode(_T("a:tblBg")); + wholeTbl = node.ReadNode(_T("a:wholeTbl")); + band1H = node.ReadNode(_T("a:band1H")); + band2H = node.ReadNode(_T("a:band2H")); + band1V = node.ReadNode(_T("a:band1V")); + band2V = node.ReadNode(_T("a:band2V")); + lastCol = node.ReadNode(_T("a:lastCol")); + firstCol = node.ReadNode(_T("a:firstCol")); + lastRow = node.ReadNode(_T("a:lastRow")); + seCell = node.ReadNode(_T("a:seCell")); + swCell = node.ReadNode(_T("a:swCell")); + firstRow = node.ReadNode(_T("a:firstRow")); + neCell = node.ReadNode(_T("a:neCell")); + nwCell = node.ReadNode(_T("a:nwCell")); + + FillParentPointersForChilds(); + } + void TableStyle::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("styleId"), styleId); + pWriter->WriteAttribute(_T("styleName"), styleName); + pWriter->EndAttributes(); + + pWriter->Write(tblBg); + pWriter->Write(wholeTbl); + pWriter->Write(band1H); + pWriter->Write(band2H); + pWriter->Write(band1V); + pWriter->Write(band2V); + pWriter->Write(lastCol); + pWriter->Write(firstCol); + pWriter->Write(lastRow); + pWriter->Write(seCell); + pWriter->Write(swCell); + pWriter->Write(firstRow); + pWriter->Write(neCell); + pWriter->Write(nwCell); + + pWriter->EndNode(m_name); + } + void TableStyle::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteString1(0, styleId); + pWriter->WriteString1(1, styleName); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, tblBg); + pWriter->WriteRecord2(1, wholeTbl); + + pWriter->WriteRecord2(2, band1H); + pWriter->WriteRecord2(3, band2H); + + pWriter->WriteRecord2(4, band1V); + pWriter->WriteRecord2(5, band1V); + + pWriter->WriteRecord2(6, lastCol); + pWriter->WriteRecord2(7, firstCol); + + pWriter->WriteRecord2(8, firstRow); + pWriter->WriteRecord2(9, lastRow); + + pWriter->WriteRecord2(10, seCell); + pWriter->WriteRecord2(11, swCell); + + pWriter->WriteRecord2(12, neCell); + pWriter->WriteRecord2(13, nwCell); + } + void TableStyle::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + styleId = pReader->GetString2(); + break; + } + case 1: + { + styleName = pReader->GetString2(); + break; + } + default: + break; + } + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + tblBg = new TableBgStyle(); + tblBg->fromPPTY(pReader); + break; + } + case 1: + { + wholeTbl = new TablePartStyle(); + wholeTbl->fromPPTY(pReader); + wholeTbl->m_name = _T("a:wholeTbl"); + break; + } + case 2: + { + band1H = new TablePartStyle(); + band1H->fromPPTY(pReader); + band1H->m_name = _T("a:band1H"); + break; + } + case 3: + { + band2H = new TablePartStyle(); + band2H->fromPPTY(pReader); + band2H->m_name = _T("a:band2H"); + break; + } + case 4: + { + band1V = new TablePartStyle(); + band1V->fromPPTY(pReader); + band1V->m_name = _T("a:band1V"); + break; + } + case 5: + { + band2V = new TablePartStyle(); + band2V->fromPPTY(pReader); + band2V->m_name = _T("a:band2V"); + break; + } + case 6: + { + lastCol = new TablePartStyle(); + lastCol->fromPPTY(pReader); + lastCol->m_name = _T("a:lastCol"); + break; + } + case 7: + { + firstCol = new TablePartStyle(); + firstCol->fromPPTY(pReader); + firstCol->m_name = _T("a:firstCol"); + break; + } + case 8: + { + firstRow = new TablePartStyle(); + firstRow->fromPPTY(pReader); + firstRow->m_name = _T("a:firstRow"); + break; + } + case 9: + { + lastRow = new TablePartStyle(); + lastRow->fromPPTY(pReader); + lastRow->m_name = _T("a:lastRow"); + break; + } + case 10: + { + seCell = new TablePartStyle(); + seCell->fromPPTY(pReader); + seCell->m_name = _T("a:seCell"); + break; + } + case 11: + { + swCell = new TablePartStyle(); + swCell->fromPPTY(pReader); + swCell->m_name = _T("a:swCell"); + break; + } + case 12: + { + neCell = new TablePartStyle(); + neCell->fromPPTY(pReader); + neCell->m_name = _T("a:neCell"); + break; + } + case 13: + { + nwCell = new TablePartStyle(); + nwCell->fromPPTY(pReader); + nwCell->m_name = _T("a:nwCell"); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void TableStyle::FillParentPointersForChilds() + { + if(tblBg.IsInit()) + tblBg->SetParentPointer(this); + if(wholeTbl.IsInit()) + wholeTbl->SetParentPointer(this); + if(band1H.IsInit()) + band1H->SetParentPointer(this); + if(band2H.IsInit()) + band2H->SetParentPointer(this); + if(band1V.IsInit()) + band1V->SetParentPointer(this); + if(band2V.IsInit()) + band2V->SetParentPointer(this); + if(lastCol.IsInit()) + lastCol->SetParentPointer(this); + if(firstCol.IsInit()) + firstCol->SetParentPointer(this); + if(lastRow.IsInit()) + lastRow->SetParentPointer(this); + if(seCell.IsInit()) + seCell->SetParentPointer(this); + if(swCell.IsInit()) + swCell->SetParentPointer(this); + if(firstRow.IsInit()) + firstRow->SetParentPointer(this); + if(neCell.IsInit()) + neCell->SetParentPointer(this); + if(nwCell.IsInit()) + nwCell->SetParentPointer(this); + } + void TableStyle::SetTheme(const smart_ptr theme) + { + m_Theme = theme; + if(tblBg.IsInit()) + tblBg->SetTheme(m_Theme); + if(wholeTbl.IsInit()) + wholeTbl->SetTheme(m_Theme); + if(band1H.IsInit()) + band1H->SetTheme(m_Theme); + if(band2H.IsInit()) + band2H->SetTheme(m_Theme); + if(band1V.IsInit()) + band1V->SetTheme(m_Theme); + if(band2V.IsInit()) + band2V->SetTheme(m_Theme); + if(lastCol.IsInit()) + lastCol->SetTheme(m_Theme); + if(firstCol.IsInit()) + firstCol->SetTheme(m_Theme); + if(lastRow.IsInit()) + lastRow->SetTheme(m_Theme); + if(seCell.IsInit()) + seCell->SetTheme(m_Theme); + if(swCell.IsInit()) + swCell->SetTheme(m_Theme); + if(firstRow.IsInit()) + firstRow->SetTheme(m_Theme); + if(neCell.IsInit()) + neCell->SetTheme(m_Theme); + if(nwCell.IsInit()) + nwCell->SetTheme(m_Theme); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TableStyle.h b/OOXML/PPTXFormat/Logic/TableStyle.h index 1a76022ce4..58f65f4aa7 100644 --- a/OOXML/PPTXFormat/Logic/TableStyle.h +++ b/OOXML/PPTXFormat/Logic/TableStyle.h @@ -48,224 +48,11 @@ namespace PPTX PPTX_LOGIC_BASE(TableStyle) public: - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); + virtual void fromXML(XmlUtils::CXmlNode& node); - XmlMacroReadAttributeBase(node, L"styleId", styleId); - XmlMacroReadAttributeBase(node, L"styleName", styleName); - - tblBg = node.ReadNode(_T("a:tblBg")); - wholeTbl = node.ReadNode(_T("a:wholeTbl")); - band1H = node.ReadNode(_T("a:band1H")); - band2H = node.ReadNode(_T("a:band2H")); - band1V = node.ReadNode(_T("a:band1V")); - band2V = node.ReadNode(_T("a:band2V")); - lastCol = node.ReadNode(_T("a:lastCol")); - firstCol = node.ReadNode(_T("a:firstCol")); - lastRow = node.ReadNode(_T("a:lastRow")); - seCell = node.ReadNode(_T("a:seCell")); - swCell = node.ReadNode(_T("a:swCell")); - firstRow = node.ReadNode(_T("a:firstRow")); - neCell = node.ReadNode(_T("a:neCell")); - nwCell = node.ReadNode(_T("a:nwCell")); - - FillParentPointersForChilds(); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("styleId"), styleId); - pWriter->WriteAttribute(_T("styleName"), styleName); - pWriter->EndAttributes(); - - pWriter->Write(tblBg); - pWriter->Write(wholeTbl); - pWriter->Write(band1H); - pWriter->Write(band2H); - pWriter->Write(band1V); - pWriter->Write(band2V); - pWriter->Write(lastCol); - pWriter->Write(firstCol); - pWriter->Write(lastRow); - pWriter->Write(seCell); - pWriter->Write(swCell); - pWriter->Write(firstRow); - pWriter->Write(neCell); - pWriter->Write(nwCell); - - pWriter->EndNode(m_name); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteString1(0, styleId); - pWriter->WriteString1(1, styleName); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, tblBg); - pWriter->WriteRecord2(1, wholeTbl); - - pWriter->WriteRecord2(2, band1H); - pWriter->WriteRecord2(3, band2H); - - pWriter->WriteRecord2(4, band1V); - pWriter->WriteRecord2(5, band1V); - - pWriter->WriteRecord2(6, lastCol); - pWriter->WriteRecord2(7, firstCol); - - pWriter->WriteRecord2(8, firstRow); - pWriter->WriteRecord2(9, lastRow); - - pWriter->WriteRecord2(10, seCell); - pWriter->WriteRecord2(11, swCell); - - pWriter->WriteRecord2(12, neCell); - pWriter->WriteRecord2(13, nwCell); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - styleId = pReader->GetString2(); - break; - } - case 1: - { - styleName = pReader->GetString2(); - break; - } - default: - break; - } - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - tblBg = new TableBgStyle(); - tblBg->fromPPTY(pReader); - break; - } - case 1: - { - wholeTbl = new TablePartStyle(); - wholeTbl->fromPPTY(pReader); - wholeTbl->m_name = _T("a:wholeTbl"); - break; - } - case 2: - { - band1H = new TablePartStyle(); - band1H->fromPPTY(pReader); - band1H->m_name = _T("a:band1H"); - break; - } - case 3: - { - band2H = new TablePartStyle(); - band2H->fromPPTY(pReader); - band2H->m_name = _T("a:band2H"); - break; - } - case 4: - { - band1V = new TablePartStyle(); - band1V->fromPPTY(pReader); - band1V->m_name = _T("a:band1V"); - break; - } - case 5: - { - band2V = new TablePartStyle(); - band2V->fromPPTY(pReader); - band2V->m_name = _T("a:band2V"); - break; - } - case 6: - { - lastCol = new TablePartStyle(); - lastCol->fromPPTY(pReader); - lastCol->m_name = _T("a:lastCol"); - break; - } - case 7: - { - firstCol = new TablePartStyle(); - firstCol->fromPPTY(pReader); - firstCol->m_name = _T("a:firstCol"); - break; - } - case 8: - { - firstRow = new TablePartStyle(); - firstRow->fromPPTY(pReader); - firstRow->m_name = _T("a:firstRow"); - break; - } - case 9: - { - lastRow = new TablePartStyle(); - lastRow->fromPPTY(pReader); - lastRow->m_name = _T("a:lastRow"); - break; - } - case 10: - { - seCell = new TablePartStyle(); - seCell->fromPPTY(pReader); - seCell->m_name = _T("a:seCell"); - break; - } - case 11: - { - swCell = new TablePartStyle(); - swCell->fromPPTY(pReader); - swCell->m_name = _T("a:swCell"); - break; - } - case 12: - { - neCell = new TablePartStyle(); - neCell->fromPPTY(pReader); - neCell->m_name = _T("a:neCell"); - break; - } - case 13: - { - nwCell = new TablePartStyle(); - nwCell->fromPPTY(pReader); - nwCell->m_name = _T("a:nwCell"); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: std::wstring styleId; @@ -285,75 +72,16 @@ namespace PPTX nullable firstRow; nullable neCell; nullable nwCell; - //private: - public: - std::wstring m_name; - protected: - virtual void FillParentPointersForChilds() - { - if(tblBg.IsInit()) - tblBg->SetParentPointer(this); - if(wholeTbl.IsInit()) - wholeTbl->SetParentPointer(this); - if(band1H.IsInit()) - band1H->SetParentPointer(this); - if(band2H.IsInit()) - band2H->SetParentPointer(this); - if(band1V.IsInit()) - band1V->SetParentPointer(this); - if(band2V.IsInit()) - band2V->SetParentPointer(this); - if(lastCol.IsInit()) - lastCol->SetParentPointer(this); - if(firstCol.IsInit()) - firstCol->SetParentPointer(this); - if(lastRow.IsInit()) - lastRow->SetParentPointer(this); - if(seCell.IsInit()) - seCell->SetParentPointer(this); - if(swCell.IsInit()) - swCell->SetParentPointer(this); - if(firstRow.IsInit()) - firstRow->SetParentPointer(this); - if(neCell.IsInit()) - neCell->SetParentPointer(this); - if(nwCell.IsInit()) - nwCell->SetParentPointer(this); - } public: - void SetTheme(const smart_ptr theme) - { - m_Theme = theme; - if(tblBg.IsInit()) - tblBg->SetTheme(m_Theme); - if(wholeTbl.IsInit()) - wholeTbl->SetTheme(m_Theme); - if(band1H.IsInit()) - band1H->SetTheme(m_Theme); - if(band2H.IsInit()) - band2H->SetTheme(m_Theme); - if(band1V.IsInit()) - band1V->SetTheme(m_Theme); - if(band2V.IsInit()) - band2V->SetTheme(m_Theme); - if(lastCol.IsInit()) - lastCol->SetTheme(m_Theme); - if(firstCol.IsInit()) - firstCol->SetTheme(m_Theme); - if(lastRow.IsInit()) - lastRow->SetTheme(m_Theme); - if(seCell.IsInit()) - seCell->SetTheme(m_Theme); - if(swCell.IsInit()) - swCell->SetTheme(m_Theme); - if(firstRow.IsInit()) - firstRow->SetTheme(m_Theme); - if(neCell.IsInit()) - neCell->SetTheme(m_Theme); - if(nwCell.IsInit()) - nwCell->SetTheme(m_Theme); - } + std::wstring m_name; + + protected: + virtual void FillParentPointersForChilds(); + + public: + void SetTheme(const smart_ptr theme); + private: smart_ptr m_Theme; }; diff --git a/OOXML/PPTXFormat/Logic/TcBdr.cpp b/OOXML/PPTXFormat/Logic/TcBdr.cpp new file mode 100644 index 0000000000..76840d5f1a --- /dev/null +++ b/OOXML/PPTXFormat/Logic/TcBdr.cpp @@ -0,0 +1,193 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "TcBdr.h" + +namespace PPTX +{ + namespace Logic + { + void TcBdr::fromXML(XmlUtils::CXmlNode& node) + { + XmlUtils::CXmlNodes oNodes; + if (node.GetNodes(_T("*"), oNodes)) + { + int count = oNodes.GetCount(); + + for (int i = 0; i < count; ++i) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(i, oNode); + + std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); + + if (_T("left") == strName) + left = oNode; + else if (_T("right") == strName) + right = oNode; + else if (_T("top") == strName) + top = oNode; + else if (_T("bottom") == strName) + bottom = oNode; + else if (_T("insideH") == strName) + insideH = oNode; + else if (_T("insideV") == strName) + insideV = oNode; + else if (_T("tl2br") == strName) + tl2br = oNode; + else if (_T("tr2bl") == strName) + tr2bl = oNode; + } + } + + FillParentPointersForChilds(); + } + void TcBdr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:tcBdr")); + pWriter->EndAttributes(); + + pWriter->Write(left); + pWriter->Write(right); + pWriter->Write(top); + pWriter->Write(bottom); + pWriter->Write(insideH); + pWriter->Write(insideV); + pWriter->Write(tl2br); + pWriter->Write(tr2bl); + + pWriter->EndNode(_T("a:tcBdr")); + } + void TcBdr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord2(0, left); + pWriter->WriteRecord2(1, right); + pWriter->WriteRecord2(2, top); + pWriter->WriteRecord2(3, bottom); + pWriter->WriteRecord2(4, insideH); + pWriter->WriteRecord2(5, insideV); + pWriter->WriteRecord2(6, tl2br); + pWriter->WriteRecord2(7, tr2bl); + } + void TcBdr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + left = new LineStyle(); + left->fromPPTY(pReader); + left->m_name = _T("a:left"); + break; + } + case 1: + { + right = new LineStyle(); + right->fromPPTY(pReader); + right->m_name = _T("a:right"); + break; + } + case 2: + { + top = new LineStyle(); + top->fromPPTY(pReader); + top->m_name = _T("a:top"); + break; + } + case 3: + { + bottom = new LineStyle(); + bottom->fromPPTY(pReader); + bottom->m_name = _T("a:bottom"); + break; + } + case 4: + { + insideH = new LineStyle(); + insideH->fromPPTY(pReader); + insideH->m_name = _T("a:insideH"); + break; + } + case 5: + { + insideV = new LineStyle(); + insideV->fromPPTY(pReader); + insideV->m_name = _T("a:insideV"); + break; + } + case 6: + { + tl2br = new LineStyle(); + tl2br->fromPPTY(pReader); + tl2br->m_name = _T("a:tl2br"); + break; + } + case 7: + { + tr2bl = new LineStyle(); + tr2bl->fromPPTY(pReader); + tr2bl->m_name = _T("a:tr2bl"); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void TcBdr::FillParentPointersForChilds() + { + if(left.IsInit()) + left->SetParentPointer(this); + if(right.IsInit()) + right->SetParentPointer(this); + if(top.IsInit()) + top->SetParentPointer(this); + if(bottom.IsInit()) + bottom->SetParentPointer(this); + if(insideH.IsInit()) + insideH->SetParentPointer(this); + if(insideV.IsInit()) + insideV->SetParentPointer(this); + if(tl2br.IsInit()) + tl2br->SetParentPointer(this); + if(tr2bl.IsInit()) + tr2bl->SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TcBdr.h b/OOXML/PPTXFormat/Logic/TcBdr.h index 192c82eece..8e7f1d3401 100644 --- a/OOXML/PPTXFormat/Logic/TcBdr.h +++ b/OOXML/PPTXFormat/Logic/TcBdr.h @@ -46,143 +46,11 @@ namespace PPTX PPTX_LOGIC_BASE(TcBdr) public: - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlUtils::CXmlNodes oNodes; - if (node.GetNodes(_T("*"), oNodes)) - { - int count = oNodes.GetCount(); - - for (int i = 0; i < count; ++i) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(i, oNode); + virtual void fromXML(XmlUtils::CXmlNode& node); - std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); - - if (_T("left") == strName) - left = oNode; - else if (_T("right") == strName) - right = oNode; - else if (_T("top") == strName) - top = oNode; - else if (_T("bottom") == strName) - bottom = oNode; - else if (_T("insideH") == strName) - insideH = oNode; - else if (_T("insideV") == strName) - insideV = oNode; - else if (_T("tl2br") == strName) - tl2br = oNode; - else if (_T("tr2bl") == strName) - tr2bl = oNode; - } - } - - FillParentPointersForChilds(); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:tcBdr")); - pWriter->EndAttributes(); - - pWriter->Write(left); - pWriter->Write(right); - pWriter->Write(top); - pWriter->Write(bottom); - pWriter->Write(insideH); - pWriter->Write(insideV); - pWriter->Write(tl2br); - pWriter->Write(tr2bl); - - pWriter->EndNode(_T("a:tcBdr")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord2(0, left); - pWriter->WriteRecord2(1, right); - pWriter->WriteRecord2(2, top); - pWriter->WriteRecord2(3, bottom); - pWriter->WriteRecord2(4, insideH); - pWriter->WriteRecord2(5, insideV); - pWriter->WriteRecord2(6, tl2br); - pWriter->WriteRecord2(7, tr2bl); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - left = new LineStyle(); - left->fromPPTY(pReader); - left->m_name = _T("a:left"); - break; - } - case 1: - { - right = new LineStyle(); - right->fromPPTY(pReader); - right->m_name = _T("a:right"); - break; - } - case 2: - { - top = new LineStyle(); - top->fromPPTY(pReader); - top->m_name = _T("a:top"); - break; - } - case 3: - { - bottom = new LineStyle(); - bottom->fromPPTY(pReader); - bottom->m_name = _T("a:bottom"); - break; - } - case 4: - { - insideH = new LineStyle(); - insideH->fromPPTY(pReader); - insideH->m_name = _T("a:insideH"); - break; - } - case 5: - { - insideV = new LineStyle(); - insideV->fromPPTY(pReader); - insideV->m_name = _T("a:insideV"); - break; - } - case 6: - { - tl2br = new LineStyle(); - tl2br->fromPPTY(pReader); - tl2br->m_name = _T("a:tl2br"); - break; - } - case 7: - { - tr2bl = new LineStyle(); - tr2bl->fromPPTY(pReader); - tr2bl->m_name = _T("a:tr2bl"); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: nullable left; @@ -193,28 +61,11 @@ namespace PPTX nullable insideV; nullable tl2br; nullable tr2bl; + protected: - virtual void FillParentPointersForChilds() - { - if(left.IsInit()) - left->SetParentPointer(this); - if(right.IsInit()) - right->SetParentPointer(this); - if(top.IsInit()) - top->SetParentPointer(this); - if(bottom.IsInit()) - bottom->SetParentPointer(this); - if(insideH.IsInit()) - insideH->SetParentPointer(this); - if(insideV.IsInit()) - insideV->SetParentPointer(this); - if(tl2br.IsInit()) - tl2br->SetParentPointer(this); - if(tr2bl.IsInit()) - tr2bl->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_TCBDR_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_TCBDR_INCLUDE_H diff --git a/OOXML/PPTXFormat/Logic/TcStyle.cpp b/OOXML/PPTXFormat/Logic/TcStyle.cpp new file mode 100644 index 0000000000..74e1f36cc3 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/TcStyle.cpp @@ -0,0 +1,120 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "TcStyle.h" + +namespace PPTX +{ + namespace Logic + { + void TcStyle::fromXML(XmlUtils::CXmlNode& node) + { + tcBdr = node.ReadNode(_T("a:tcBdr")); + cell3D = node.ReadNode(_T("a:cell3D")); + fill = node.ReadNode(_T("a:fill")); + fillRef = node.ReadNodeNoNS(_T("fillRef")); + + FillParentPointersForChilds(); + } + void TcStyle::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:tcStyle")); + pWriter->EndAttributes(); + + pWriter->Write(tcBdr); + pWriter->Write(fillRef); + pWriter->Write(fill); + pWriter->Write(cell3D); + + pWriter->EndNode(_T("a:tcStyle")); + } + void TcStyle::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord2(0, tcBdr); + pWriter->WriteRecord2(1, fillRef); + pWriter->WriteRecord2(2, fill); + pWriter->WriteRecord2(3, cell3D); + } + void TcStyle::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + tcBdr = new TcBdr(); + tcBdr->fromPPTY(pReader); + break; + } + case 1: + { + fillRef = new StyleRef(); + fillRef->fromPPTY(pReader); + fillRef->m_name = _T("a:fillRef"); + break; + } + case 2: + { + fill = new FillStyle(); + fill->fromPPTY(pReader); + break; + } + case 3: + { + cell3D = new Cell3D(); + cell3D->fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void TcStyle::FillParentPointersForChilds() + { + if(tcBdr.IsInit()) + tcBdr->SetParentPointer(this); + if(fill.IsInit()) + fill->SetParentPointer(this); + if(fillRef.IsInit()) + fillRef->SetParentPointer(this); + if(cell3D.IsInit()) + cell3D->SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TcStyle.h b/OOXML/PPTXFormat/Logic/TcStyle.h index 508d009eed..d2635b07d4 100644 --- a/OOXML/PPTXFormat/Logic/TcStyle.h +++ b/OOXML/PPTXFormat/Logic/TcStyle.h @@ -49,79 +49,11 @@ namespace PPTX PPTX_LOGIC_BASE(TcStyle) public: - virtual void fromXML(XmlUtils::CXmlNode& node) - { - tcBdr = node.ReadNode(_T("a:tcBdr")); - cell3D = node.ReadNode(_T("a:cell3D")); - fill = node.ReadNode(_T("a:fill")); - fillRef = node.ReadNodeNoNS(_T("fillRef")); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - FillParentPointersForChilds(); - } - - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:tcStyle")); - pWriter->EndAttributes(); - - pWriter->Write(tcBdr); - pWriter->Write(fillRef); - pWriter->Write(fill); - pWriter->Write(cell3D); - - pWriter->EndNode(_T("a:tcStyle")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord2(0, tcBdr); - pWriter->WriteRecord2(1, fillRef); - pWriter->WriteRecord2(2, fill); - pWriter->WriteRecord2(3, cell3D); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - tcBdr = new TcBdr(); - tcBdr->fromPPTY(pReader); - break; - } - case 1: - { - fillRef = new StyleRef(); - fillRef->fromPPTY(pReader); - fillRef->m_name = _T("a:fillRef"); - break; - } - case 2: - { - fill = new FillStyle(); - fill->fromPPTY(pReader); - break; - } - case 3: - { - cell3D = new Cell3D(); - cell3D->fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: nullable tcBdr; @@ -129,21 +61,12 @@ namespace PPTX nullable fillRef; nullable fill; nullable cell3D; + protected: - virtual void FillParentPointersForChilds() - { - if(tcBdr.IsInit()) - tcBdr->SetParentPointer(this); - if(fill.IsInit()) - fill->SetParentPointer(this); - if(fillRef.IsInit()) - fillRef->SetParentPointer(this); - if(cell3D.IsInit()) - cell3D->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_TCSTYLE_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_TCSTYLE_INCLUDE_H diff --git a/OOXML/PPTXFormat/Logic/TcTxStyle.cpp b/OOXML/PPTXFormat/Logic/TcTxStyle.cpp new file mode 100644 index 0000000000..7c089bdc31 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/TcTxStyle.cpp @@ -0,0 +1,132 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "TcTxStyle.h" + +namespace PPTX +{ + namespace Logic + { + void TcTxStyle::fromXML(XmlUtils::CXmlNode& node) + { + XmlMacroReadAttributeBase(node, L"i", i); + XmlMacroReadAttributeBase(node, L"b", b); + + fontRef = node.ReadNodeNoNS(_T("fontRef")); + Color.GetColorFrom(node); + + FillParentPointersForChilds(); + } + void TcTxStyle::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("a:tcTxStyle")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("i"), i); + pWriter->WriteAttribute(_T("b"), b); + pWriter->EndAttributes(); + + pWriter->Write(fontRef); + Color.toXmlWriter(pWriter); + + pWriter->EndNode(_T("a:tcTxStyle")); + } + void TcTxStyle::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit2(0, i); + pWriter->WriteLimit2(1, b); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, fontRef); + pWriter->WriteRecord1(1, Color); + } + void TcTxStyle::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + i = pReader->GetUChar(); + break; + } + case 1: + { + b = pReader->GetUChar(); + break; + } + default: + break; + } + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + fontRef = new Logic::FontRef(); + fontRef->fromPPTY(pReader); + fontRef->m_name = _T("a:fontRef"); + break; + } + case 1: + { + Color.fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void TcTxStyle::FillParentPointersForChilds() + { + if(fontRef.IsInit()) + fontRef->SetParentPointer(this); + Color.SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TcTxStyle.h b/OOXML/PPTXFormat/Logic/TcTxStyle.h index b1c68d3cdd..c62b608d60 100644 --- a/OOXML/PPTXFormat/Logic/TcTxStyle.h +++ b/OOXML/PPTXFormat/Logic/TcTxStyle.h @@ -48,95 +48,11 @@ namespace PPTX PPTX_LOGIC_BASE(TcTxStyle) public: - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlMacroReadAttributeBase(node, L"i", i); - XmlMacroReadAttributeBase(node, L"b", b); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - fontRef = node.ReadNodeNoNS(_T("fontRef")); - Color.GetColorFrom(node); - - FillParentPointersForChilds(); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("a:tcTxStyle")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("i"), i); - pWriter->WriteAttribute(_T("b"), b); - pWriter->EndAttributes(); - - pWriter->Write(fontRef); - Color.toXmlWriter(pWriter); - - pWriter->EndNode(_T("a:tcTxStyle")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit2(0, i); - pWriter->WriteLimit2(1, b); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, fontRef); - pWriter->WriteRecord1(1, Color); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - i = pReader->GetUChar(); - break; - } - case 1: - { - b = pReader->GetUChar(); - break; - } - default: - break; - } - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - fontRef = new Logic::FontRef(); - fontRef->fromPPTY(pReader); - fontRef->m_name = _T("a:fontRef"); - break; - } - case 1: - { - Color.fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: nullable_limit i; @@ -148,13 +64,9 @@ font (Font) §20.1.4.2.13 */ nullable fontRef; UniColor Color; + protected: - virtual void FillParentPointersForChilds() - { - if(fontRef.IsInit()) - fontRef->SetParentPointer(this); - Color.SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; // class FontCollection: public WrapperWritingElement diff --git a/OOXML/PPTXFormat/Logic/TextFit.cpp b/OOXML/PPTXFormat/Logic/TextFit.cpp new file mode 100644 index 0000000000..bb7ce8b409 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/TextFit.cpp @@ -0,0 +1,270 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "TextFit.h" + +namespace PPTX +{ + namespace Logic + { + TextFit::TextFit() + { + type = FitEmpty; + } + bool TextFit::is_init() + { + return (type != FitEmpty); + } + void TextFit::GetTextFitFrom(XmlUtils::CXmlNode& element) + { + type = FitEmpty; + + XmlUtils::CXmlNode oNode; + if (element.GetNode(_T("a:noAutofit"), oNode)) + type = FitNo; + else if (element.GetNode(_T("a:spAutoFit"), oNode)) + type = FitSpAuto; + else if (element.GetNode(_T("a:normAutofit"), oNode)) + { + type = FitNormAuto; + + nullable_string sFontScale; + nullable_string sLnSpcRed; + + XmlMacroReadAttributeBase(oNode, L"fontScale", sFontScale); + XmlMacroReadAttributeBase(oNode, L"lnSpcReduction", sLnSpcRed); + + if (sFontScale.is_init()) + { + int nFound = (int)sFontScale->rfind(wchar_t('%')); + if (nFound < 0) + fontScale = *sFontScale; + else + { + std::wstring sRet = sFontScale->substr(0, nFound); + double dRet = XmlUtils::GetDouble(sRet); + int val = (int)(dRet * 1000); + fontScale = val; + } + } + + if (sLnSpcRed.is_init()) + { + int nFound = (int)sLnSpcRed->rfind(wchar_t('%')); + if (nFound < 0) + lnSpcReduction = *sLnSpcRed; + else + { + std::wstring sRet = sLnSpcRed->substr(0, nFound); + double dRet = XmlUtils::GetDouble(sRet); + int val = (int)(dRet * 1000); + lnSpcReduction = val; + } + } + } + } + OOX::EElementType TextFit::getType() const + { + return OOX::et_a_textFit; + } + void TextFit::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + std::wstring strName = oReader.GetName(); + + if (_T("a:noAutofit") == strName) + type = FitNo; + else if (_T("a:spAutoFit") == strName) + type = FitSpAuto; + else if (_T("a:normAutofit") == strName) + { + type = FitNormAuto; + + ReadAttributes(oReader); + } + } + void TextFit::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + nullable_string sFontScale; + nullable_string sLnSpcRed; + + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("fontScale"), sFontScale) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("lnSpcReduction"), sLnSpcRed) + WritingElement_ReadAttributes_End( oReader ) + + Normalize(sFontScale, sLnSpcRed); + } + void TextFit::fromXML(XmlUtils::CXmlNode& node) + { + type = FitEmpty; + + std::wstring strName = node.GetName(); + + if (_T("a:noAutofit") == strName) + type = FitNo; + else if (_T("a:spAutoFit") == strName) + type = FitSpAuto; + else if (_T("a:normAutofit") == strName) + { + type = FitNormAuto; + + nullable_string sFontScale; + nullable_string sLnSpcRed; + + XmlMacroReadAttributeBase(node, L"fontScale", sFontScale); + XmlMacroReadAttributeBase(node, L"lnSpcReduction", sLnSpcRed); + + Normalize(sFontScale, sLnSpcRed); + } + } + void TextFit::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + if (type == FitNo) + { + pWriter->WriteString(_T("")); + return; + } + + if (type == FitSpAuto) + { + pWriter->WriteString(_T("")); + return; + } + + if (type == FitNormAuto) + { + pWriter->StartNode(_T("a:normAutofit")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("fontScale"), fontScale); + pWriter->WriteAttribute(_T("lnSpcReduction"), lnSpcReduction); + pWriter->EndAttributes(); + + pWriter->EndNode(_T("a:normAutofit")); + } + } + void TextFit::Merge(TextFit& fit)const + { + if(type != FitEmpty) + { + if((type == FitNo) || (type == FitSpAuto)) + { + fit.type = type; + fit.fontScale.reset(); + fit.lnSpcReduction.reset(); + } + else if(type == FitNormAuto) + { + fit.type = type; + if(fontScale.is_init()) + fit.fontScale = *fontScale; + if(lnSpcReduction.is_init()) + fit.lnSpcReduction = *lnSpcReduction; + } + } + } + void TextFit::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteInt1(0, type); + pWriter->WriteInt2(1, fontScale); + pWriter->WriteInt2(2, lnSpcReduction); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void TextFit::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + type = (eFit)pReader->GetLong(); + break; + } + case 1: + { + fontScale = pReader->GetLong(); + break; + } + case 2: + { + lnSpcReduction = pReader->GetLong(); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void TextFit::FillParentPointersForChilds(){} + void TextFit::Normalize(nullable_string & sFontScale, nullable_string & sLnSpcRed) + { + if (sFontScale.is_init()) + { + int nFound = (int)sFontScale->rfind(wchar_t('%')); + if (nFound < 0) + fontScale = *sFontScale; + else + { + std::wstring sRet = sFontScale->substr(0, nFound); + double dRet = XmlUtils::GetDouble(sRet); + int val = (int)(dRet * 1000); + fontScale = val; + } + } + + if (sLnSpcRed.is_init()) + { + int nFound = (int)sLnSpcRed->rfind(wchar_t('%')); + if (nFound < 0) + lnSpcReduction = *sLnSpcRed; + else + { + std::wstring sRet = sLnSpcRed->substr(0, nFound); + double dRet = XmlUtils::GetDouble(sRet); + int val = (int)(dRet * 1000); + lnSpcReduction = val; + } + } + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TextFit.h b/OOXML/PPTXFormat/Logic/TextFit.h index 4fc815558e..0d71a4aae7 100644 --- a/OOXML/PPTXFormat/Logic/TextFit.h +++ b/OOXML/PPTXFormat/Logic/TextFit.h @@ -45,245 +45,33 @@ namespace PPTX enum eFit {FitEmpty = 0, FitNo = 1, FitSpAuto = 2, FitNormAuto = 3}; WritingElement_AdditionConstructors(TextFit) - TextFit() - { - type = FitEmpty; - } + + TextFit(); - virtual bool is_init(){return (type != FitEmpty);}; + virtual bool is_init(); + void GetTextFitFrom(XmlUtils::CXmlNode& element); + virtual OOX::EElementType getType() const; - void GetTextFitFrom(XmlUtils::CXmlNode& element) - { - type = FitEmpty; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - XmlUtils::CXmlNode oNode; - if (element.GetNode(_T("a:noAutofit"), oNode)) - type = FitNo; - else if (element.GetNode(_T("a:spAutoFit"), oNode)) - type = FitSpAuto; - else if (element.GetNode(_T("a:normAutofit"), oNode)) - { - type = FitNormAuto; + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - nullable_string sFontScale; - nullable_string sLnSpcRed; + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - XmlMacroReadAttributeBase(oNode, L"fontScale", sFontScale); - XmlMacroReadAttributeBase(oNode, L"lnSpcReduction", sLnSpcRed); + void Merge(TextFit& fit) const; - if (sFontScale.is_init()) - { - int nFound = (int)sFontScale->rfind(wchar_t('%')); - if (nFound < 0) - fontScale = *sFontScale; - else - { - std::wstring sRet = sFontScale->substr(0, nFound); - double dRet = XmlUtils::GetDouble(sRet); - int val = (int)(dRet * 1000); - fontScale = val; - } - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - if (sLnSpcRed.is_init()) - { - int nFound = (int)sLnSpcRed->rfind(wchar_t('%')); - if (nFound < 0) - lnSpcReduction = *sLnSpcRed; - else - { - std::wstring sRet = sLnSpcRed->substr(0, nFound); - double dRet = XmlUtils::GetDouble(sRet); - int val = (int)(dRet * 1000); - lnSpcReduction = val; - } - } - } - } - - virtual OOX::EElementType getType() const - { - return OOX::et_a_textFit; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - std::wstring strName = oReader.GetName(); - - if (_T("a:noAutofit") == strName) - type = FitNo; - else if (_T("a:spAutoFit") == strName) - type = FitSpAuto; - else if (_T("a:normAutofit") == strName) - { - type = FitNormAuto; - - ReadAttributes(oReader); - } - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - nullable_string sFontScale; - nullable_string sLnSpcRed; - - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("fontScale"), sFontScale) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("lnSpcReduction"), sLnSpcRed) - WritingElement_ReadAttributes_End( oReader ) - - Normalize(sFontScale, sLnSpcRed); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - type = FitEmpty; - - std::wstring strName = node.GetName(); - - if (_T("a:noAutofit") == strName) - type = FitNo; - else if (_T("a:spAutoFit") == strName) - type = FitSpAuto; - else if (_T("a:normAutofit") == strName) - { - type = FitNormAuto; - - nullable_string sFontScale; - nullable_string sLnSpcRed; - - XmlMacroReadAttributeBase(node, L"fontScale", sFontScale); - XmlMacroReadAttributeBase(node, L"lnSpcReduction", sLnSpcRed); - - Normalize(sFontScale, sLnSpcRed); - } - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - if (type == FitNo) - { - pWriter->WriteString(_T("")); - return; - } - - if (type == FitSpAuto) - { - pWriter->WriteString(_T("")); - return; - } - - if (type == FitNormAuto) - { - pWriter->StartNode(_T("a:normAutofit")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("fontScale"), fontScale); - pWriter->WriteAttribute(_T("lnSpcReduction"), lnSpcReduction); - pWriter->EndAttributes(); - - pWriter->EndNode(_T("a:normAutofit")); - } - } - - void Merge(TextFit& fit)const - { - if(type != FitEmpty) - { - if((type == FitNo) || (type == FitSpAuto)) - { - fit.type = type; - fit.fontScale.reset(); - fit.lnSpcReduction.reset(); - } - else if(type == FitNormAuto) - { - fit.type = type; - if(fontScale.is_init()) - fit.fontScale = *fontScale; - if(lnSpcReduction.is_init()) - fit.lnSpcReduction = *lnSpcReduction; - } - } - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteInt1(0, type); - pWriter->WriteInt2(1, fontScale); - pWriter->WriteInt2(2, lnSpcReduction); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - type = (eFit)pReader->GetLong(); - break; - } - case 1: - { - fontScale = pReader->GetLong(); - break; - } - case 2: - { - lnSpcReduction = pReader->GetLong(); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } public: eFit type; nullable_int fontScale; nullable_int lnSpcReduction; + protected: - virtual void FillParentPointersForChilds(){} - - void Normalize(nullable_string & sFontScale, nullable_string & sLnSpcRed) - { - if (sFontScale.is_init()) - { - int nFound = (int)sFontScale->rfind(wchar_t('%')); - if (nFound < 0) - fontScale = *sFontScale; - else - { - std::wstring sRet = sFontScale->substr(0, nFound); - double dRet = XmlUtils::GetDouble(sRet); - int val = (int)(dRet * 1000); - fontScale = val; - } - } - - if (sLnSpcRed.is_init()) - { - int nFound = (int)sLnSpcRed->rfind(wchar_t('%')); - if (nFound < 0) - lnSpcReduction = *sLnSpcRed; - else - { - std::wstring sRet = sLnSpcRed->substr(0, nFound); - double dRet = XmlUtils::GetDouble(sRet); - int val = (int)(dRet * 1000); - lnSpcReduction = val; - } - } - } + virtual void FillParentPointersForChilds(); + void Normalize(nullable_string & sFontScale, nullable_string & sLnSpcRed); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TextFont.cpp b/OOXML/PPTXFormat/Logic/TextFont.cpp new file mode 100644 index 0000000000..56b8a612c8 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/TextFont.cpp @@ -0,0 +1,231 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "TextFont.h" + +namespace PPTX +{ + namespace Logic + { + TextFont::TextFont() + { + m_eType = OOX::et_Unknown; + } + TextFont::~TextFont() {} + TextFont::TextFont(const TextFont& oSrc) { *this = oSrc; } + OOX::EElementType TextFont::getType () const + { + return m_eType; + } + void TextFont::fromXML(XmlUtils::CXmlNode& node) + { + m_eType = OOX::et_Unknown; + m_name = node.GetName(); + + if ( _T("a:cs") == m_name ) + m_eType = OOX::et_a_cs; + else if ( _T("a:ea") == m_name ) + m_eType = OOX::et_a_ea; + else if ( _T("a:latin") == m_name ) + m_eType = OOX::et_a_latin; + else if ( _T("a:sym") == m_name ) + m_eType = OOX::et_a_sym; + + XmlMacroReadAttributeBase(node, L"charset", charset); + XmlMacroReadAttributeBase(node, L"panose", panose); + XmlMacroReadAttributeBase(node, L"pitchFamily", pitchFamily); + + typeface = node.GetAttribute(_T("typeface")); + } + void TextFont::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_eType = OOX::et_Unknown; + m_name = oReader.GetName(); + + if ( _T("a:cs") == m_name ) + m_eType = OOX::et_a_cs; + else if ( _T("a:ea") == m_name ) + m_eType = OOX::et_a_ea; + else if ( _T("a:latin") == m_name ) + m_eType = OOX::et_a_latin; + else if ( _T("a:sym") == m_name ) + m_eType = OOX::et_a_sym; + + ReadAttributes( oReader ); + + if ( !oReader.IsEmptyNode() ) + oReader.ReadTillEnd(); + } + std::wstring TextFont::toXML() const + { + std::wstring name = m_name; + if (name.empty()) + { + switch ( m_eType ) + { + case OOX::et_a_cs: name = _T("a:cs"); break; + case OOX::et_a_ea: name = _T("a:ea"); break; + case OOX::et_a_latin: name = _T("a:latin"); break; + case OOX::et_a_sym: name = _T("a:sym"); break; + default: return _T(""); + } + } + + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("typeface"), typeface); + oAttr.Write(_T("pitchFamily"), pitchFamily); + oAttr.Write(_T("charset"), charset); + oAttr.Write(_T("panose"), panose); + + return XmlUtils::CreateNode(name, oAttr); + } + void TextFont::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + // Читаем атрибуты + if ( oReader.GetAttributesCount() <= 0 ) + return; + + if ( !oReader.MoveToFirstAttribute() ) + return; + + std::wstring wsName = oReader.GetName(); + while( !wsName.empty() ) + { + wchar_t wsChar0 = wsName[0]; + + switch ( wsChar0 ) + { + case 'c': + if ( _T("charset") == wsName ) charset = oReader.GetText(); + break; + + case 'p': + if ( _T("panose") == wsName ) panose = oReader.GetText(); + else if ( _T("pitchFamily") == wsName ) pitchFamily = oReader.GetText(); + break; + + case 't': + if ( _T("typeface") == wsName ) typeface = oReader.GetText(); + break; + } + + if ( !oReader.MoveToNextAttribute() ) + break; + + wsName = oReader.GetName(); + } + oReader.MoveToElement(); + } + void TextFont::Merge(nullable& font)const + { + if(!font.is_init()) + font = TextFont(); + + if(charset.is_init()) font->charset = *charset; + if(panose.is_init()) font->panose = *panose; + if(pitchFamily.is_init()) font->pitchFamily = *pitchFamily; + + font->typeface = typeface; + } + void TextFont::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteString2(0, charset); + pWriter->WriteString2(1, panose); + pWriter->WriteString2(2, pitchFamily); + + /* + pWriter->WriteString1(3, typeface); + */ + + std::wstring sPick = pWriter->m_pCommon->m_pNativePicker->GetTypefacePick(*this); + pWriter->WriteString1(3, sPick); + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void TextFont::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + charset = pReader->GetString2(); + break; + } + case 1: + { + panose = pReader->GetString2(); + break; + } + case 2: + { + pitchFamily = pReader->GetString2(); + break; + } + case 3: + { + typeface = pReader->GetString2(); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void TextFont::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("typeface"), XmlUtils::EncodeXmlString(typeface)); + pWriter->WriteAttribute(_T("pitchFamily"), pitchFamily); + pWriter->WriteAttribute(_T("charset"), charset); + pWriter->WriteAttribute(_T("panose"), panose); + pWriter->EndAttributes(); + + pWriter->EndNode(m_name); + } + void TextFont::FillParentPointersForChilds(){} + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TextFont.h b/OOXML/PPTXFormat/Logic/TextFont.h index 1fb8be937a..517e4f5096 100644 --- a/OOXML/PPTXFormat/Logic/TextFont.h +++ b/OOXML/PPTXFormat/Logic/TextFont.h @@ -43,203 +43,22 @@ namespace PPTX { public: WritingElement_AdditionConstructors(TextFont) - TextFont() - { - m_eType = OOX::et_Unknown; - } - virtual ~TextFont() {} - TextFont(const TextFont& oSrc) { *this = oSrc; } - virtual OOX::EElementType getType () const - { - return m_eType; - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_eType = OOX::et_Unknown; - m_name = node.GetName(); + TextFont(); + virtual ~TextFont(); + TextFont(const TextFont& oSrc); - if ( _T("a:cs") == m_name ) - m_eType = OOX::et_a_cs; - else if ( _T("a:ea") == m_name ) - m_eType = OOX::et_a_ea; - else if ( _T("a:latin") == m_name ) - m_eType = OOX::et_a_latin; - else if ( _T("a:sym") == m_name ) - m_eType = OOX::et_a_sym; + virtual OOX::EElementType getType () const; + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual std::wstring toXML() const; - XmlMacroReadAttributeBase(node, L"charset", charset); - XmlMacroReadAttributeBase(node, L"panose", panose); - XmlMacroReadAttributeBase(node, L"pitchFamily", pitchFamily); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + void Merge(nullable& font) const; - typeface = node.GetAttribute(_T("typeface")); - } - - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_eType = OOX::et_Unknown; - m_name = oReader.GetName(); - - if ( _T("a:cs") == m_name ) - m_eType = OOX::et_a_cs; - else if ( _T("a:ea") == m_name ) - m_eType = OOX::et_a_ea; - else if ( _T("a:latin") == m_name ) - m_eType = OOX::et_a_latin; - else if ( _T("a:sym") == m_name ) - m_eType = OOX::et_a_sym; - - ReadAttributes( oReader ); - - if ( !oReader.IsEmptyNode() ) - oReader.ReadTillEnd(); - } - virtual std::wstring toXML() const - { - std::wstring name = m_name; - if (name.empty()) - { - switch ( m_eType ) - { - case OOX::et_a_cs: name = _T("a:cs"); break; - case OOX::et_a_ea: name = _T("a:ea"); break; - case OOX::et_a_latin: name = _T("a:latin"); break; - case OOX::et_a_sym: name = _T("a:sym"); break; - default: return _T(""); - } - } - - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("typeface"), typeface); - oAttr.Write(_T("pitchFamily"), pitchFamily); - oAttr.Write(_T("charset"), charset); - oAttr.Write(_T("panose"), panose); - - return XmlUtils::CreateNode(name, oAttr); - } - - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - // Читаем атрибуты - if ( oReader.GetAttributesCount() <= 0 ) - return; - - if ( !oReader.MoveToFirstAttribute() ) - return; - - std::wstring wsName = oReader.GetName(); - while( !wsName.empty() ) - { - wchar_t wsChar0 = wsName[0]; - - switch ( wsChar0 ) - { - case 'c': - if ( _T("charset") == wsName ) charset = oReader.GetText(); - break; - - case 'p': - if ( _T("panose") == wsName ) panose = oReader.GetText(); - else if ( _T("pitchFamily") == wsName ) pitchFamily = oReader.GetText(); - break; - - case 't': - if ( _T("typeface") == wsName ) typeface = oReader.GetText(); - break; - } - - if ( !oReader.MoveToNextAttribute() ) - break; - - wsName = oReader.GetName(); - } - oReader.MoveToElement(); - } - - void Merge(nullable& font)const - { - if(!font.is_init()) - font = TextFont(); - - if(charset.is_init()) font->charset = *charset; - if(panose.is_init()) font->panose = *panose; - if(pitchFamily.is_init()) font->pitchFamily = *pitchFamily; - - font->typeface = typeface; - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteString2(0, charset); - pWriter->WriteString2(1, panose); - pWriter->WriteString2(2, pitchFamily); - - /* - pWriter->WriteString1(3, typeface); - */ - - std::wstring sPick = pWriter->m_pCommon->m_pNativePicker->GetTypefacePick(*this); - pWriter->WriteString1(3, sPick); - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - charset = pReader->GetString2(); - break; - } - case 1: - { - panose = pReader->GetString2(); - break; - } - case 2: - { - pitchFamily = pReader->GetString2(); - break; - } - case 3: - { - typeface = pReader->GetString2(); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("typeface"), XmlUtils::EncodeXmlString(typeface)); - pWriter->WriteAttribute(_T("pitchFamily"), pitchFamily); - pWriter->WriteAttribute(_T("charset"), charset); - pWriter->WriteAttribute(_T("panose"), panose); - pWriter->EndAttributes(); - - pWriter->EndNode(m_name); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; public: nullable_string charset; @@ -249,8 +68,9 @@ namespace PPTX std::wstring m_name; OOX::EElementType m_eType; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TextListStyle.cpp b/OOXML/PPTXFormat/Logic/TextListStyle.cpp new file mode 100644 index 0000000000..dbbf7c040c --- /dev/null +++ b/OOXML/PPTXFormat/Logic/TextListStyle.cpp @@ -0,0 +1,197 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "TextListStyle.h" + +namespace PPTX +{ + namespace Logic + { + TextListStyle::TextListStyle(std::wstring name) + { + m_name = name; + } + void TextListStyle::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + /*defPPr*/ levels[9] = node.ReadNode(_T("a:defPPr")); + /*lvl1pPr*/levels[0] = node.ReadNode(_T("a:lvl1pPr")); + /*lvl2pPr*/levels[1] = node.ReadNode(_T("a:lvl2pPr")); + /*lvl3pPr*/levels[2] = node.ReadNode(_T("a:lvl3pPr")); + /*lvl4pPr*/levels[3] = node.ReadNode(_T("a:lvl4pPr")); + /*lvl5pPr*/levels[4] = node.ReadNode(_T("a:lvl5pPr")); + /*lvl6pPr*/levels[5] = node.ReadNode(_T("a:lvl6pPr")); + /*lvl7pPr*/levels[6] = node.ReadNode(_T("a:lvl7pPr")); + /*lvl8pPr*/levels[7] = node.ReadNode(_T("a:lvl8pPr")); + /*lvl9pPr*/levels[8] = node.ReadNode(_T("a:lvl9pPr")); + + FillParentPointersForChilds(); + } + OOX::EElementType TextListStyle::getType () const + { + return OOX::et_Unknown;//a_bodyStyle; + } + void TextListStyle::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_name = oReader.GetName(); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (_T("defPPr") == strName) + levels[9] = oReader; + else if (_T("lvl1pPr") == strName) + levels[0] = oReader; + else if (_T("lvl2pPr") == strName) + levels[1] = oReader; + else if (_T("lvl3pPr") == strName) + levels[2] = oReader; + else if (_T("lvl4pPr") == strName) + levels[3] = oReader; + else if (_T("lvl5pPr") == strName) + levels[4] = oReader; + else if (_T("lvl6pPr") == strName) + levels[5] = oReader; + else if (_T("lvl7pPr") == strName) + levels[6] = oReader; + else if (_T("lvl8pPr") == strName) + levels[7] = oReader; + else if (_T("lvl9pPr") == strName) + levels[8] = oReader; + } + } + std::wstring TextListStyle::toXML() const + { + XmlUtils::CNodeValue oValue; + oValue.WriteNullable(/*defPPr*/ levels[9]); + oValue.WriteNullable(/*lvl1pPr*/ levels[0]); + oValue.WriteNullable(/*lvl2pPr*/ levels[1]); + oValue.WriteNullable(/*lvl3pPr*/ levels[2]); + oValue.WriteNullable(/*lvl4pPr*/ levels[3]); + oValue.WriteNullable(/*lvl5pPr*/ levels[4]); + oValue.WriteNullable(/*lvl6pPr*/ levels[5]); + oValue.WriteNullable(/*lvl7pPr*/ levels[6]); + oValue.WriteNullable(/*lvl8pPr*/ levels[7]); + oValue.WriteNullable(/*lvl9pPr*/ levels[8]); + + return XmlUtils::CreateNode(m_name, oValue); + } + void TextListStyle::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord2(0, levels[0]); + pWriter->WriteRecord2(1, levels[1]); + pWriter->WriteRecord2(2, levels[2]); + pWriter->WriteRecord2(3, levels[3]); + pWriter->WriteRecord2(4, levels[4]); + pWriter->WriteRecord2(5, levels[5]); + pWriter->WriteRecord2(6, levels[6]); + pWriter->WriteRecord2(7, levels[7]); + pWriter->WriteRecord2(8, levels[8]); + pWriter->WriteRecord2(9, levels[9]); + } + void TextListStyle::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + pWriter->EndAttributes(); + + pWriter->Write(/*defPPr*/ levels[9]); + pWriter->Write(/*lvl1pPr*/ levels[0]); + pWriter->Write(/*lvl2pPr*/ levels[1]); + pWriter->Write(/*lvl3pPr*/ levels[2]); + pWriter->Write(/*lvl4pPr*/ levels[3]); + pWriter->Write(/*lvl5pPr*/ levels[4]); + pWriter->Write(/*lvl6pPr*/ levels[5]); + pWriter->Write(/*lvl7pPr*/ levels[6]); + pWriter->Write(/*lvl8pPr*/ levels[7]); + pWriter->Write(/*lvl9pPr*/ levels[8]); + + pWriter->EndNode(m_name); + } + void TextListStyle::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + std::wstring arr_names[10] = {_T("a:lvl1pPr"), _T("a:lvl2pPr"), _T("a:lvl3pPr"), _T("a:lvl4pPr"), _T("a:lvl5pPr"), + _T("a:lvl6pPr"), _T("a:lvl7pPr"), _T("a:lvl8pPr"), _T("a:lvl9pPr"), _T("a:defPPr")}; + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + + if (_at < 0 || _at > 9) + break; + + levels[_at] = new TextParagraphPr(); + levels[_at]->m_name = arr_names[_at]; + levels[_at]->fromPPTY(pReader); + } + + pReader->Seek(_end_rec); + } + bool TextListStyle::IsListStyleEmpty() + { + for (int i = 0; i < 10; i++) + { + if (levels[i].IsInit()) + { + if (levels[i]->ParagraphBullet.is_init() == false) continue; + if (levels[i]->ParagraphBullet.is())continue; + + return false; + } + } + return true; + } + void TextListStyle::Merge(nullable& lstStyle)const + { + if(!lstStyle.is_init()) + lstStyle = TextListStyle(); + for(int i = 0; i < 10; i++) + if(levels[i].is_init()) + levels[i]->Merge(lstStyle->levels[i]); + } + void TextListStyle::FillParentPointersForChilds() + { + for(int i = 0; i < 10; i++) + { + if(levels[i].is_init()) + levels[i]->SetParentPointer(this); + } + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TextListStyle.h b/OOXML/PPTXFormat/Logic/TextListStyle.h index ec107ff71d..d56bb73e19 100644 --- a/OOXML/PPTXFormat/Logic/TextListStyle.h +++ b/OOXML/PPTXFormat/Logic/TextListStyle.h @@ -46,172 +46,28 @@ namespace PPTX public: WritingElement_AdditionConstructors(TextListStyle) - TextListStyle(std::wstring name = L"a:lstStyle") - { - m_name = name; - } + TextListStyle(std::wstring name = L"a:lstStyle"); - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual OOX::EElementType getType () const; - /*defPPr*/ levels[9] = node.ReadNode(_T("a:defPPr")); - /*lvl1pPr*/levels[0] = node.ReadNode(_T("a:lvl1pPr")); - /*lvl2pPr*/levels[1] = node.ReadNode(_T("a:lvl2pPr")); - /*lvl3pPr*/levels[2] = node.ReadNode(_T("a:lvl3pPr")); - /*lvl4pPr*/levels[3] = node.ReadNode(_T("a:lvl4pPr")); - /*lvl5pPr*/levels[4] = node.ReadNode(_T("a:lvl5pPr")); - /*lvl6pPr*/levels[5] = node.ReadNode(_T("a:lvl6pPr")); - /*lvl7pPr*/levels[6] = node.ReadNode(_T("a:lvl7pPr")); - /*lvl8pPr*/levels[7] = node.ReadNode(_T("a:lvl8pPr")); - /*lvl9pPr*/levels[8] = node.ReadNode(_T("a:lvl9pPr")); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual std::wstring toXML() const; - FillParentPointersForChilds(); - } - virtual OOX::EElementType getType () const - { - return OOX::et_Unknown;//a_bodyStyle; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = oReader.GetName(); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - if ( oReader.IsEmptyNode() ) - return; - - int nCurDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - std::wstring strName = XmlUtils::GetNameNoNS(oReader.GetName()); - - if (_T("defPPr") == strName) - levels[9] = oReader; - else if (_T("lvl1pPr") == strName) - levels[0] = oReader; - else if (_T("lvl2pPr") == strName) - levels[1] = oReader; - else if (_T("lvl3pPr") == strName) - levels[2] = oReader; - else if (_T("lvl4pPr") == strName) - levels[3] = oReader; - else if (_T("lvl5pPr") == strName) - levels[4] = oReader; - else if (_T("lvl6pPr") == strName) - levels[5] = oReader; - else if (_T("lvl7pPr") == strName) - levels[6] = oReader; - else if (_T("lvl8pPr") == strName) - levels[7] = oReader; - else if (_T("lvl9pPr") == strName) - levels[8] = oReader; - } - } - virtual std::wstring toXML() const - { - XmlUtils::CNodeValue oValue; - oValue.WriteNullable(/*defPPr*/ levels[9]); - oValue.WriteNullable(/*lvl1pPr*/ levels[0]); - oValue.WriteNullable(/*lvl2pPr*/ levels[1]); - oValue.WriteNullable(/*lvl3pPr*/ levels[2]); - oValue.WriteNullable(/*lvl4pPr*/ levels[3]); - oValue.WriteNullable(/*lvl5pPr*/ levels[4]); - oValue.WriteNullable(/*lvl6pPr*/ levels[5]); - oValue.WriteNullable(/*lvl7pPr*/ levels[6]); - oValue.WriteNullable(/*lvl8pPr*/ levels[7]); - oValue.WriteNullable(/*lvl9pPr*/ levels[8]); - - return XmlUtils::CreateNode(m_name, oValue); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord2(0, levels[0]); - pWriter->WriteRecord2(1, levels[1]); - pWriter->WriteRecord2(2, levels[2]); - pWriter->WriteRecord2(3, levels[3]); - pWriter->WriteRecord2(4, levels[4]); - pWriter->WriteRecord2(5, levels[5]); - pWriter->WriteRecord2(6, levels[6]); - pWriter->WriteRecord2(7, levels[7]); - pWriter->WriteRecord2(8, levels[8]); - pWriter->WriteRecord2(9, levels[9]); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - pWriter->EndAttributes(); - - pWriter->Write(/*defPPr*/ levels[9]); - pWriter->Write(/*lvl1pPr*/ levels[0]); - pWriter->Write(/*lvl2pPr*/ levels[1]); - pWriter->Write(/*lvl3pPr*/ levels[2]); - pWriter->Write(/*lvl4pPr*/ levels[3]); - pWriter->Write(/*lvl5pPr*/ levels[4]); - pWriter->Write(/*lvl6pPr*/ levels[5]); - pWriter->Write(/*lvl7pPr*/ levels[6]); - pWriter->Write(/*lvl8pPr*/ levels[7]); - pWriter->Write(/*lvl9pPr*/ levels[8]); - - pWriter->EndNode(m_name); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - std::wstring arr_names[10] = {_T("a:lvl1pPr"), _T("a:lvl2pPr"), _T("a:lvl3pPr"), _T("a:lvl4pPr"), _T("a:lvl5pPr"), - _T("a:lvl6pPr"), _T("a:lvl7pPr"), _T("a:lvl8pPr"), _T("a:lvl9pPr"), _T("a:defPPr")}; - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - - if (_at < 0 || _at > 9) - break; - - levels[_at] = new TextParagraphPr(); - levels[_at]->m_name = arr_names[_at]; - levels[_at]->fromPPTY(pReader); - } - - pReader->Seek(_end_rec); - } - bool IsListStyleEmpty() - { - for (int i = 0; i < 10; i++) - { - if (levels[i].IsInit()) - { - if (levels[i]->ParagraphBullet.is_init() == false) continue; - if (levels[i]->ParagraphBullet.is())continue; - - return false; - } - } - return true; - } - - void Merge(nullable& lstStyle)const - { - if(!lstStyle.is_init()) - lstStyle = TextListStyle(); - for(int i = 0; i < 10; i++) - if(levels[i].is_init()) - levels[i]->Merge(lstStyle->levels[i]); - } + bool IsListStyleEmpty(); + void Merge(nullable& lstStyle) const; nullable levels[10]; mutable std::wstring m_name; + protected: - virtual void FillParentPointersForChilds() - { - for(int i = 0; i < 10; i++) - { - if(levels[i].is_init()) - levels[i]->SetParentPointer(this); - } - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_TEXTSTYLE_INCLUDE_H_ \ No newline at end of file +#endif // PPTX_LOGIC_TEXTSTYLE_INCLUDE_H_ diff --git a/OOXML/PPTXFormat/Logic/TextParagraphPr.cpp b/OOXML/PPTXFormat/Logic/TextParagraphPr.cpp new file mode 100644 index 0000000000..83e7f31992 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/TextParagraphPr.cpp @@ -0,0 +1,499 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "TextParagraphPr.h" + +namespace PPTX +{ + namespace Logic + { + TextParagraphPr::TextParagraphPr() + { + m_name = L"a:pPr"; + } + TextParagraphPr& TextParagraphPr::operator=(const TextParagraphPr& oSrc) + { + parentFile = oSrc.parentFile; + parentElement = oSrc.parentElement; + + lnSpc = oSrc.lnSpc; + spcAft = oSrc.spcAft; + spcBef = oSrc.spcBef; + + buColor = oSrc.buColor; + buSize = oSrc.buSize; + buTypeface = oSrc.buTypeface; + ParagraphBullet = oSrc.ParagraphBullet; + + tabLst = oSrc.tabLst; + defRPr = oSrc.defRPr; + + algn = oSrc.algn; + defTabSz = oSrc.defTabSz; + eaLnBrk = oSrc.eaLnBrk; + fontAlgn = oSrc.fontAlgn; + hangingPunct = oSrc.hangingPunct; + indent = oSrc.indent; + latinLnBrk = oSrc.latinLnBrk; + lvl = oSrc.lvl; + marL = oSrc.marL; + marR = oSrc.marR; + rtl = oSrc.rtl; + + m_name = oSrc.m_name; + + return *this; + } + void TextParagraphPr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_name = oReader.GetName(); + ReadAttributes( oReader ); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring sName = oReader.GetName(); + + if ( _T("a:lnSpc") == sName ) + lnSpc = oReader; + else if ( _T("a:defRPr") == sName ) + defRPr = oReader; + else if ( _T("a:spcAft") == sName ) + spcAft = oReader; + else if ( _T("a:spcBef") == sName ) + spcBef = oReader; + else if ( _T("a:tabLst") == sName ) + { + if (false == oReader.IsEmptyNode()) + { + int nParentDepth1 = oReader.GetDepth(); + while (oReader.ReadNextSiblingNode(nParentDepth1)) + { + std::wstring sName1 = oReader.GetName(); + if (_T("a:tab") == sName1) + { + Tab tab(oReader); + tabLst.push_back(tab); + } + } + } + } + //else if ( _T("a:extLst") == sName ) + // extLst = oReader; + + else if ( _T("a:buBlip") == sName || _T("a:buChar") == sName || _T("a:buAutoNum") == sName || sName == _T("a:buNone")) + ParagraphBullet.fromXML(oReader); + else if ( _T("a:buClr") == sName || sName == _T("a:buClrTx")) + buColor.fromXML(oReader); + else if ( _T("a:buFont") == sName || _T("a:buFontTx") == sName ) + buTypeface.fromXML( oReader); + else if ( _T("a:buSzTx") == sName || sName == _T("a:buSzPct") || sName == _T("a:buSzPts")) + buSize.fromXML(oReader); + } + } + OOX::EElementType TextParagraphPr::getType() const + { + return OOX::et_a_pPr; + } + void TextParagraphPr::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + XmlMacroReadAttributeBase(node, L"algn", algn); + XmlMacroReadAttributeBase(node, L"defTabSz", defTabSz); + XmlMacroReadAttributeBase(node, L"eaLnBrk", eaLnBrk); + XmlMacroReadAttributeBase(node, L"fontAlgn", fontAlgn); + XmlMacroReadAttributeBase(node, L"hangingPunct", hangingPunct); + XmlMacroReadAttributeBase(node, L"indent", indent); + XmlMacroReadAttributeBase(node, L"latinLnBrk", latinLnBrk); + XmlMacroReadAttributeBase(node, L"lvl", lvl); + XmlMacroReadAttributeBase(node, L"marL", marL); + XmlMacroReadAttributeBase(node, L"marR", marR); + XmlMacroReadAttributeBase(node, L"rtl", rtl); + + XmlUtils::CXmlNodes oNodes; + if (node.GetNodes(_T("*"), oNodes)) + { + int nCount = oNodes.GetCount(); + for (int i = 0; i < nCount; ++i) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(i, oNode); + + std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); + + if (_T("lnSpc") == strName) + lnSpc = oNode; + else if (_T("spcAft") == strName) + spcAft = oNode; + else if (_T("spcBef") == strName) + spcBef = oNode; + else if (_T("defRPr") == strName) + defRPr = oNode; + else if (_T("tabLst") == strName) + XmlMacroLoadArray(oNode, _T("a:tab"), tabLst, Tab); + } + } + + + buColor.ReadBulletColorFrom(node); + buSize.ReadBulletSizeFrom(node); + buTypeface.ReadBulletTypefaceFrom(node); + ParagraphBullet.ReadBulletFrom(node); + + Normalize(); + + FillParentPointersForChilds(); + } + void TextParagraphPr::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start ( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("rtl"), rtl) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("lvl"), lvl) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("algn"), algn) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("fontAlgn"),fontAlgn) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("marL"), marL) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("marR"), marR) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("indent"), indent) + WritingElement_ReadAttributes_Read_else_if( oReader, _T("defTabSz"),defTabSz) + WritingElement_ReadAttributes_End ( oReader ) + } + void TextParagraphPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("marL"), marL); + pWriter->WriteAttribute(_T("marR"), marR); + pWriter->WriteAttribute(_T("lvl"), lvl); + pWriter->WriteAttribute(_T("indent"), indent); + pWriter->WriteAttribute(_T("algn"), algn); + pWriter->WriteAttribute(_T("defTabSz"), defTabSz); + pWriter->WriteAttribute(_T("rtl"), rtl); + pWriter->WriteAttribute(_T("eaLnBrk"), eaLnBrk); + pWriter->WriteAttribute(_T("fontAlgn"), fontAlgn); + pWriter->WriteAttribute(_T("latinLnBrk"), latinLnBrk); + pWriter->WriteAttribute(_T("hangingPunct"), hangingPunct); + pWriter->EndAttributes(); + + pWriter->Write(lnSpc); + pWriter->Write(spcBef); + pWriter->Write(spcAft); + buColor.toXmlWriter(pWriter); + buSize.toXmlWriter(pWriter); + buTypeface.toXmlWriter(pWriter); + ParagraphBullet.toXmlWriter(pWriter); + + pWriter->WriteArray(_T("a:tabLst"), tabLst); + + pWriter->Write(defRPr); + + pWriter->EndNode(m_name); + } + void TextParagraphPr::Merge(nullable& props) + { + if(!props.is_init()) + props = TextParagraphPr(); + + if(lnSpc.is_init()) + { + props->lnSpc = lnSpc; + } + if(spcAft.is_init()) + { + props->spcAft = spcAft; + } + if(spcBef.is_init()) + { + props->spcBef = spcBef; + } + + if(buColor.is_init()) + props->buColor = buColor; + if(buSize.is_init()) + props->buSize = buSize; + if(buTypeface.is_init()) + props->buTypeface = buTypeface; + if(ParagraphBullet.is_init()) + props->ParagraphBullet = ParagraphBullet; + + //property > tabLst;// (Tab List) + if(defRPr.is_init()) + defRPr->Merge(props->defRPr); + + // Attribs + if(algn.is_init()) props->algn = *algn; + if(defTabSz.is_init()) props->defTabSz = *defTabSz; + if(eaLnBrk.is_init()) props->eaLnBrk = *eaLnBrk; + if(fontAlgn.is_init()) props->fontAlgn = *fontAlgn; + if(hangingPunct.is_init()) props->hangingPunct = *hangingPunct; + if(indent.is_init()) props->indent = *indent; + if(latinLnBrk.is_init()) props->latinLnBrk = *latinLnBrk; + if(lvl.is_init()) props->lvl = *lvl; + if(marL.is_init()) props->marL = *marL; + if(marR.is_init()) props->marR = *marR; + if(rtl.is_init()) props->rtl = *rtl; + } + void TextParagraphPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit2(0, algn); + pWriter->WriteInt2(1, defTabSz); + pWriter->WriteBool2(2, eaLnBrk); + pWriter->WriteLimit2(3, fontAlgn); + pWriter->WriteBool2(4, hangingPunct); + pWriter->WriteInt2(5, indent); + pWriter->WriteBool2(6, latinLnBrk); + pWriter->WriteInt2(7, lvl); + pWriter->WriteInt2(8, marL); + pWriter->WriteInt2(9, marR); + pWriter->WriteBool2(10, rtl); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + pWriter->WriteRecord2(0, lnSpc); + pWriter->WriteRecord2(1, spcAft); + pWriter->WriteRecord2(2, spcBef); + + pWriter->WriteRecord1(3, buColor); + pWriter->WriteRecord1(4, buSize); + pWriter->WriteRecord1(5, buTypeface); + pWriter->WriteRecord1(6, ParagraphBullet); + + pWriter->WriteRecordArray(7, 0, tabLst); + + pWriter->WriteRecord2(8, defRPr); + } + void TextParagraphPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + algn = pReader->GetUChar(); + break; + } + case 1: + { + defTabSz = pReader->GetLong(); + break; + } + case 2: + { + eaLnBrk = pReader->GetBool(); + break; + } + case 3: + { + fontAlgn = pReader->GetUChar(); + break; + } + case 4: + { + hangingPunct = pReader->GetBool(); + break; + } + case 5: + { + indent = pReader->GetLong(); + break; + } + case 6: + { + latinLnBrk = pReader->GetBool(); + break; + } + case 7: + { + lvl = pReader->GetLong(); + break; + } + case 8: + { + marL = pReader->GetLong(); + break; + } + case 9: + { + marR = pReader->GetLong(); + break; + } + case 10: + { + rtl = pReader->GetBool(); + break; + } + default: + break; + } + } + + while (pReader->GetPos() < _end_rec) + { + BYTE _at = pReader->GetUChar(); + switch (_at) + { + case 0: + { + lnSpc = new TextSpacing(); + lnSpc->m_name = _T("a:lnSpc"); + lnSpc->fromPPTY(pReader); + break; + } + case 1: + { + spcAft = new TextSpacing(); + spcAft->m_name = _T("a:spcAft"); + spcAft->fromPPTY(pReader); + break; + } + case 2: + { + spcBef = new TextSpacing(); + spcBef->m_name = _T("a:spcBef"); + spcBef->fromPPTY(pReader); + break; + } + case 3: + { + buColor.fromPPTY(pReader); + break; + } + case 4: + { + buSize.fromPPTY(pReader); + break; + } + case 5: + { + buTypeface.fromPPTY(pReader); + break; + } + case 6: + { + ParagraphBullet.fromPPTY(pReader); + break; + } + case 7: + { + pReader->Skip(4); + ULONG _c = pReader->GetULong(); + + if (0 != _c) + { + tabLst.clear(); + for (ULONG i = 0; i < _c; i++) + { + pReader->Skip(6); // type, len, start attr + size_t nIndex = tabLst.size(); + tabLst.push_back(Tab()); + + while (true) + { + BYTE __at = pReader->GetUChar_TypeNode(); + if (__at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (__at) + { + case 0: + { + tabLst[nIndex].algn = pReader->GetUChar(); + break; + } + case 1: + { + tabLst[nIndex].pos = pReader->GetLong(); + break; + } + default: + break; + } + } + } + } + break; + } + case 8: + { + defRPr = new Logic::RunProperties(); + defRPr->m_name = _T("a:defRPr"); + defRPr->fromPPTY(pReader); + break; + } + default: + { + pReader->SkipRecord(); + } + } + } + + pReader->Seek(_end_rec); + } + void TextParagraphPr::FillParentPointersForChilds() + { + if(lnSpc.is_init()) + lnSpc->SetParentPointer(this); + if(spcAft.is_init()) + spcAft->SetParentPointer(this); + if(spcBef.is_init()) + spcBef->SetParentPointer(this); + + buColor.SetParentPointer(this); + buSize.SetParentPointer(this); + buTypeface.SetParentPointer(this); + ParagraphBullet.SetParentPointer(this); + + if(defRPr.is_init()) + defRPr->SetParentPointer(this); + } + AVSINLINE void TextParagraphPr::Normalize() + { + indent.normalize(-51206400, 51206400); + lvl.normalize(0, 8); + marL.normalize(0, 51206400); + marR.normalize(0, 51206400); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TextParagraphPr.h b/OOXML/PPTXFormat/Logic/TextParagraphPr.h index d9f4f5c5c3..4fd74a7d84 100644 --- a/OOXML/PPTXFormat/Logic/TextParagraphPr.h +++ b/OOXML/PPTXFormat/Logic/TextParagraphPr.h @@ -48,454 +48,25 @@ namespace PPTX { namespace Logic { - class TextParagraphPr : public WrapperWritingElement { public: WritingElement_AdditionConstructors(TextParagraphPr) - TextParagraphPr() - { - m_name = L"a:pPr"; - } - TextParagraphPr& operator=(const TextParagraphPr& oSrc) - { - parentFile = oSrc.parentFile; - parentElement = oSrc.parentElement; + TextParagraphPr(); + TextParagraphPr& operator=(const TextParagraphPr& oSrc); - lnSpc = oSrc.lnSpc; - spcAft = oSrc.spcAft; - spcBef = oSrc.spcBef; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual OOX::EElementType getType() const; + virtual void fromXML(XmlUtils::CXmlNode& node); - buColor = oSrc.buColor; - buSize = oSrc.buSize; - buTypeface = oSrc.buTypeface; - ParagraphBullet = oSrc.ParagraphBullet; + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - tabLst = oSrc.tabLst; - defRPr = oSrc.defRPr; + void Merge(nullable& props); - algn = oSrc.algn; - defTabSz = oSrc.defTabSz; - eaLnBrk = oSrc.eaLnBrk; - fontAlgn = oSrc.fontAlgn; - hangingPunct = oSrc.hangingPunct; - indent = oSrc.indent; - latinLnBrk = oSrc.latinLnBrk; - lvl = oSrc.lvl; - marL = oSrc.marL; - marR = oSrc.marR; - rtl = oSrc.rtl; - - m_name = oSrc.m_name; - - return *this; - } - - - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = oReader.GetName(); - ReadAttributes( oReader ); - - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring sName = oReader.GetName(); - - if ( _T("a:lnSpc") == sName ) - lnSpc = oReader; - else if ( _T("a:defRPr") == sName ) - defRPr = oReader; - else if ( _T("a:spcAft") == sName ) - spcAft = oReader; - else if ( _T("a:spcBef") == sName ) - spcBef = oReader; - else if ( _T("a:tabLst") == sName ) - { - if (false == oReader.IsEmptyNode()) - { - int nParentDepth1 = oReader.GetDepth(); - while (oReader.ReadNextSiblingNode(nParentDepth1)) - { - std::wstring sName1 = oReader.GetName(); - if (_T("a:tab") == sName1) - { - Tab tab(oReader); - tabLst.push_back(tab); - } - } - } - } - //else if ( _T("a:extLst") == sName ) - // extLst = oReader; - - else if ( _T("a:buBlip") == sName || _T("a:buChar") == sName || _T("a:buAutoNum") == sName || sName == _T("a:buNone")) - ParagraphBullet.fromXML(oReader); - else if ( _T("a:buClr") == sName || sName == _T("a:buClrTx")) - buColor.fromXML(oReader); - else if ( _T("a:buFont") == sName || _T("a:buFontTx") == sName ) - buTypeface.fromXML( oReader); - else if ( _T("a:buSzTx") == sName || sName == _T("a:buSzPct") || sName == _T("a:buSzPts")) - buSize.fromXML(oReader); - } - } - - virtual OOX::EElementType getType() const - { - return OOX::et_a_pPr; - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); - - XmlMacroReadAttributeBase(node, L"algn", algn); - XmlMacroReadAttributeBase(node, L"defTabSz", defTabSz); - XmlMacroReadAttributeBase(node, L"eaLnBrk", eaLnBrk); - XmlMacroReadAttributeBase(node, L"fontAlgn", fontAlgn); - XmlMacroReadAttributeBase(node, L"hangingPunct", hangingPunct); - XmlMacroReadAttributeBase(node, L"indent", indent); - XmlMacroReadAttributeBase(node, L"latinLnBrk", latinLnBrk); - XmlMacroReadAttributeBase(node, L"lvl", lvl); - XmlMacroReadAttributeBase(node, L"marL", marL); - XmlMacroReadAttributeBase(node, L"marR", marR); - XmlMacroReadAttributeBase(node, L"rtl", rtl); - - XmlUtils::CXmlNodes oNodes; - if (node.GetNodes(_T("*"), oNodes)) - { - int nCount = oNodes.GetCount(); - for (int i = 0; i < nCount; ++i) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(i, oNode); - - std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); - - if (_T("lnSpc") == strName) - lnSpc = oNode; - else if (_T("spcAft") == strName) - spcAft = oNode; - else if (_T("spcBef") == strName) - spcBef = oNode; - else if (_T("defRPr") == strName) - defRPr = oNode; - else if (_T("tabLst") == strName) - XmlMacroLoadArray(oNode, _T("a:tab"), tabLst, Tab); - } - } - - - buColor.ReadBulletColorFrom(node); - buSize.ReadBulletSizeFrom(node); - buTypeface.ReadBulletTypefaceFrom(node); - ParagraphBullet.ReadBulletFrom(node); - - Normalize(); - - FillParentPointersForChilds(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start ( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("rtl"), rtl) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("lvl"), lvl) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("algn"), algn) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("fontAlgn"),fontAlgn) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("marL"), marL) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("marR"), marR) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("indent"), indent) - WritingElement_ReadAttributes_Read_else_if( oReader, _T("defTabSz"),defTabSz) - WritingElement_ReadAttributes_End ( oReader ) - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("marL"), marL); - pWriter->WriteAttribute(_T("marR"), marR); - pWriter->WriteAttribute(_T("lvl"), lvl); - pWriter->WriteAttribute(_T("indent"), indent); - pWriter->WriteAttribute(_T("algn"), algn); - pWriter->WriteAttribute(_T("defTabSz"), defTabSz); - pWriter->WriteAttribute(_T("rtl"), rtl); - pWriter->WriteAttribute(_T("eaLnBrk"), eaLnBrk); - pWriter->WriteAttribute(_T("fontAlgn"), fontAlgn); - pWriter->WriteAttribute(_T("latinLnBrk"), latinLnBrk); - pWriter->WriteAttribute(_T("hangingPunct"), hangingPunct); - pWriter->EndAttributes(); - - pWriter->Write(lnSpc); - pWriter->Write(spcBef); - pWriter->Write(spcAft); - buColor.toXmlWriter(pWriter); - buSize.toXmlWriter(pWriter); - buTypeface.toXmlWriter(pWriter); - ParagraphBullet.toXmlWriter(pWriter); - - pWriter->WriteArray(_T("a:tabLst"), tabLst); - - pWriter->Write(defRPr); - - pWriter->EndNode(m_name); - } - - void Merge(nullable& props) - { - if(!props.is_init()) - props = TextParagraphPr(); - - if(lnSpc.is_init()) - { - props->lnSpc = lnSpc; - } - if(spcAft.is_init()) - { - props->spcAft = spcAft; - } - if(spcBef.is_init()) - { - props->spcBef = spcBef; - } - - if(buColor.is_init()) - props->buColor = buColor; - if(buSize.is_init()) - props->buSize = buSize; - if(buTypeface.is_init()) - props->buTypeface = buTypeface; - if(ParagraphBullet.is_init()) - props->ParagraphBullet = ParagraphBullet; - - //property > tabLst;// (Tab List) - if(defRPr.is_init()) - defRPr->Merge(props->defRPr); - - // Attribs - if(algn.is_init()) props->algn = *algn; - if(defTabSz.is_init()) props->defTabSz = *defTabSz; - if(eaLnBrk.is_init()) props->eaLnBrk = *eaLnBrk; - if(fontAlgn.is_init()) props->fontAlgn = *fontAlgn; - if(hangingPunct.is_init()) props->hangingPunct = *hangingPunct; - if(indent.is_init()) props->indent = *indent; - if(latinLnBrk.is_init()) props->latinLnBrk = *latinLnBrk; - if(lvl.is_init()) props->lvl = *lvl; - if(marL.is_init()) props->marL = *marL; - if(marR.is_init()) props->marR = *marR; - if(rtl.is_init()) props->rtl = *rtl; - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit2(0, algn); - pWriter->WriteInt2(1, defTabSz); - pWriter->WriteBool2(2, eaLnBrk); - pWriter->WriteLimit2(3, fontAlgn); - pWriter->WriteBool2(4, hangingPunct); - pWriter->WriteInt2(5, indent); - pWriter->WriteBool2(6, latinLnBrk); - pWriter->WriteInt2(7, lvl); - pWriter->WriteInt2(8, marL); - pWriter->WriteInt2(9, marR); - pWriter->WriteBool2(10, rtl); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - pWriter->WriteRecord2(0, lnSpc); - pWriter->WriteRecord2(1, spcAft); - pWriter->WriteRecord2(2, spcBef); - - pWriter->WriteRecord1(3, buColor); - pWriter->WriteRecord1(4, buSize); - pWriter->WriteRecord1(5, buTypeface); - pWriter->WriteRecord1(6, ParagraphBullet); - - pWriter->WriteRecordArray(7, 0, tabLst); - - pWriter->WriteRecord2(8, defRPr); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - algn = pReader->GetUChar(); - break; - } - case 1: - { - defTabSz = pReader->GetLong(); - break; - } - case 2: - { - eaLnBrk = pReader->GetBool(); - break; - } - case 3: - { - fontAlgn = pReader->GetUChar(); - break; - } - case 4: - { - hangingPunct = pReader->GetBool(); - break; - } - case 5: - { - indent = pReader->GetLong(); - break; - } - case 6: - { - latinLnBrk = pReader->GetBool(); - break; - } - case 7: - { - lvl = pReader->GetLong(); - break; - } - case 8: - { - marL = pReader->GetLong(); - break; - } - case 9: - { - marR = pReader->GetLong(); - break; - } - case 10: - { - rtl = pReader->GetBool(); - break; - } - default: - break; - } - } - - while (pReader->GetPos() < _end_rec) - { - BYTE _at = pReader->GetUChar(); - switch (_at) - { - case 0: - { - lnSpc = new TextSpacing(); - lnSpc->m_name = _T("a:lnSpc"); - lnSpc->fromPPTY(pReader); - break; - } - case 1: - { - spcAft = new TextSpacing(); - spcAft->m_name = _T("a:spcAft"); - spcAft->fromPPTY(pReader); - break; - } - case 2: - { - spcBef = new TextSpacing(); - spcBef->m_name = _T("a:spcBef"); - spcBef->fromPPTY(pReader); - break; - } - case 3: - { - buColor.fromPPTY(pReader); - break; - } - case 4: - { - buSize.fromPPTY(pReader); - break; - } - case 5: - { - buTypeface.fromPPTY(pReader); - break; - } - case 6: - { - ParagraphBullet.fromPPTY(pReader); - break; - } - case 7: - { - pReader->Skip(4); - ULONG _c = pReader->GetULong(); - - if (0 != _c) - { - tabLst.clear(); - for (ULONG i = 0; i < _c; i++) - { - pReader->Skip(6); // type, len, start attr - size_t nIndex = tabLst.size(); - tabLst.push_back(Tab()); - - while (true) - { - BYTE __at = pReader->GetUChar_TypeNode(); - if (__at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (__at) - { - case 0: - { - tabLst[nIndex].algn = pReader->GetUChar(); - break; - } - case 1: - { - tabLst[nIndex].pos = pReader->GetLong(); - break; - } - default: - break; - } - } - } - } - break; - } - case 8: - { - defRPr = new Logic::RunProperties(); - defRPr->m_name = _T("a:defRPr"); - defRPr->fromPPTY(pReader); - break; - } - default: - { - pReader->SkipRecord(); - } - } - } - - pReader->Seek(_end_rec); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: //Childs @@ -523,35 +94,13 @@ namespace PPTX nullable_int marL; // (Left Margin) nullable_int marR; // (Right Margin) nullable_bool rtl; // (Right To Left) - //private: + public: mutable std::wstring m_name; + protected: - virtual void FillParentPointersForChilds() - { - if(lnSpc.is_init()) - lnSpc->SetParentPointer(this); - if(spcAft.is_init()) - spcAft->SetParentPointer(this); - if(spcBef.is_init()) - spcBef->SetParentPointer(this); - - buColor.SetParentPointer(this); - buSize.SetParentPointer(this); - buTypeface.SetParentPointer(this); - ParagraphBullet.SetParentPointer(this); - - if(defRPr.is_init()) - defRPr->SetParentPointer(this); - } - - AVSINLINE void Normalize() - { - indent.normalize(-51206400, 51206400); - lvl.normalize(0, 8); - marL.normalize(0, 51206400); - marR.normalize(0, 51206400); - } + virtual void FillParentPointersForChilds(); + void Normalize(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TextSpacing.cpp b/OOXML/PPTXFormat/Logic/TextSpacing.cpp new file mode 100644 index 0000000000..5f5d0f1e24 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/TextSpacing.cpp @@ -0,0 +1,161 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "TextSpacing.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType TextSpacing::getType () const + { + return OOX::et_Unknown; + } + void TextSpacing::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + m_name = oReader.GetName(); + + if ( oReader.IsEmptyNode() ) + return; + + int nCurDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nCurDepth ) ) + { + std::wstring sName = oReader.GetName(); + nullable_int val; + if (sName == L"a:spcPct") + { + ReadAttributes(oReader, val); + spcPct = val; + } + if (sName == L"a:spcPts") + { + ReadAttributes(oReader, val); + spcPts = val; + } + } + Normalize(); + } + void TextSpacing::ReadAttributes(XmlUtils::CXmlLiteReader& oReader, nullable_int & val) + { + WritingElement_ReadAttributes_Start ( oReader ) + WritingElement_ReadAttributes_ReadSingle ( oReader, _T("val"), val) + WritingElement_ReadAttributes_End ( oReader ) + } + void TextSpacing::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + XmlUtils::CXmlNode node1 = node.ReadNode(_T("a:spcPct")); + XmlMacroReadAttributeBase(node1, L"val", spcPct); + + XmlUtils::CXmlNode node2 = node.ReadNode(_T("a:spcPts")); + XmlMacroReadAttributeBase(node2, L"val", spcPts); + + Normalize(); + } + void TextSpacing::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(m_name); + pWriter->EndAttributes(); + + if (spcPct.is_init()) + { + pWriter->StartNode(_T("a:spcPct")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("val"), *spcPct); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:spcPct")); + } + else + { + pWriter->StartNode(_T("a:spcPts")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("val"), spcPts.get_value_or(0)); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:spcPts")); + } + + pWriter->EndNode(m_name); + } + void TextSpacing::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteInt2(0, spcPct); + pWriter->WriteInt2(1, spcPts); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void TextSpacing::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + spcPct = pReader->GetLong(); + break; + } + case 1: + { + spcPts = pReader->GetLong(); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + int TextSpacing::GetVal()const + { + if(spcPts.is_init()) + return -spcPts.get(); + else + return spcPct.get_value_or(100000)/1000; + } + void TextSpacing::FillParentPointersForChilds(){} + AVSINLINE void TextSpacing::Normalize() + { + spcPts.normalize(0, 158400); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TextSpacing.h b/OOXML/PPTXFormat/Logic/TextSpacing.h index 4126d8ee5c..c564cd7ae6 100644 --- a/OOXML/PPTXFormat/Logic/TextSpacing.h +++ b/OOXML/PPTXFormat/Logic/TextSpacing.h @@ -46,141 +46,29 @@ namespace PPTX WritingElement_AdditionConstructors(TextSpacing) PPTX_LOGIC_BASE2(TextSpacing) - virtual OOX::EElementType getType () const - { - return OOX::et_Unknown; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = oReader.GetName(); - - if ( oReader.IsEmptyNode() ) - return; + virtual OOX::EElementType getType () const; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - int nCurDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nCurDepth ) ) - { - std::wstring sName = oReader.GetName(); - nullable_int val; - if (sName == L"a:spcPct") - { - ReadAttributes(oReader, val); - spcPct = val; - } - if (sName == L"a:spcPts") - { - ReadAttributes(oReader, val); - spcPts = val; - } - } - Normalize(); - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader, nullable_int & val) - { - WritingElement_ReadAttributes_Start ( oReader ) - WritingElement_ReadAttributes_ReadSingle ( oReader, _T("val"), val) - WritingElement_ReadAttributes_End ( oReader ) - } + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader, nullable_int & val); - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - XmlUtils::CXmlNode node1 = node.ReadNode(_T("a:spcPct")); - XmlMacroReadAttributeBase(node1, L"val", spcPct); - - XmlUtils::CXmlNode node2 = node.ReadNode(_T("a:spcPts")); - XmlMacroReadAttributeBase(node2, L"val", spcPts); - - Normalize(); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(m_name); - pWriter->EndAttributes(); - - if (spcPct.is_init()) - { - pWriter->StartNode(_T("a:spcPct")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("val"), *spcPct); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:spcPct")); - } - else - { - pWriter->StartNode(_T("a:spcPts")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("val"), spcPts.get_value_or(0)); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:spcPts")); - } - - pWriter->EndNode(m_name); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteInt2(0, spcPct); - pWriter->WriteInt2(1, spcPts); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - spcPct = pReader->GetLong(); - break; - } - case 1: - { - spcPts = pReader->GetLong(); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); public: nullable_int spcPct; nullable_int spcPts; - int GetVal()const - { - if(spcPts.is_init()) - return -spcPts.get(); - else - return spcPct.get_value_or(100000)/1000; - } - //private: + int GetVal() const; + public: std::wstring m_name; - protected: - virtual void FillParentPointersForChilds(){}; - AVSINLINE void Normalize() - { - spcPts.normalize(0, 158400); - } + protected: + virtual void FillParentPointersForChilds(); + void Normalize(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TxBody.cpp b/OOXML/PPTXFormat/Logic/TxBody.cpp index f1b977bdd9..f02202de32 100644 --- a/OOXML/PPTXFormat/Logic/TxBody.cpp +++ b/OOXML/PPTXFormat/Logic/TxBody.cpp @@ -29,7 +29,6 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ -#pragma once #include "TxBody.h" #include "ClrMap.h" diff --git a/OOXML/PPTXFormat/Logic/TxStyles.cpp b/OOXML/PPTXFormat/Logic/TxStyles.cpp new file mode 100644 index 0000000000..df29d2950f --- /dev/null +++ b/OOXML/PPTXFormat/Logic/TxStyles.cpp @@ -0,0 +1,137 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "TxStyles.h" + +namespace PPTX +{ + namespace Logic + { + void TxStyles::fromXML(XmlUtils::CXmlNode& node) + { + XmlUtils::CXmlNodes oNodes; + if (node.GetNodes(_T("*"), oNodes)) + { + int nCount = oNodes.GetCount(); + for (int i = 0; i < nCount; ++i) + { + XmlUtils::CXmlNode oNode; + oNodes.GetAt(i, oNode); + + std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); + + if (_T("titleStyle") == strName) + titleStyle = oNode; + else if (_T("bodyStyle") == strName) + bodyStyle = oNode; + else if (_T("otherStyle") == strName) + otherStyle = oNode; + } + } + + FillParentPointersForChilds(); + } + std::wstring TxStyles::toXML() const + { + XmlUtils::CNodeValue oValue; + oValue.WriteNullable(titleStyle); + oValue.WriteNullable(bodyStyle); + oValue.WriteNullable(otherStyle); + + return XmlUtils::CreateNode(_T("p:txStyles"), oValue); + } + void TxStyles::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteRecord2(0, titleStyle); + pWriter->WriteRecord2(1, bodyStyle); + pWriter->WriteRecord2(2, otherStyle); + } + void TxStyles::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG end = pReader->GetPos() + pReader->GetLong() + 4; + + while (pReader->GetPos() < end) + { + BYTE _rec = pReader->GetUChar(); + + switch (_rec) + { + case 0: + { + titleStyle = new TextListStyle(); + titleStyle->m_name = _T("p:titleStyle"); + titleStyle->fromPPTY(pReader); + break; + } + case 1: + { + bodyStyle = new TextListStyle(); + bodyStyle->m_name = _T("p:bodyStyle"); + bodyStyle->fromPPTY(pReader); + break; + } + case 2: + { + otherStyle = new TextListStyle(); + otherStyle->m_name = _T("p:otherStyle"); + otherStyle->fromPPTY(pReader); + break; + } + default: + break; + } + } + + pReader->Seek(end); + } + void TxStyles::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(_T("p:txStyles")); + pWriter->EndAttributes(); + + pWriter->Write(titleStyle); + pWriter->Write(bodyStyle); + pWriter->Write(otherStyle); + + pWriter->EndNode(_T("p:txStyles")); + } + void TxStyles::FillParentPointersForChilds() + { + if(titleStyle.is_init()) + titleStyle->SetParentPointer(this); + if(bodyStyle.is_init()) + bodyStyle->SetParentPointer(this); + if(otherStyle.is_init()) + otherStyle->SetParentPointer(this); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/TxStyles.h b/OOXML/PPTXFormat/Logic/TxStyles.h index dce140e31e..a9dd6360ea 100644 --- a/OOXML/PPTXFormat/Logic/TxStyles.h +++ b/OOXML/PPTXFormat/Logic/TxStyles.h @@ -47,112 +47,21 @@ namespace PPTX public: PPTX_LOGIC_BASE(TxStyles) - virtual void fromXML(XmlUtils::CXmlNode& node) - { - XmlUtils::CXmlNodes oNodes; - if (node.GetNodes(_T("*"), oNodes)) - { - int nCount = oNodes.GetCount(); - for (int i = 0; i < nCount; ++i) - { - XmlUtils::CXmlNode oNode; - oNodes.GetAt(i, oNode); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName()); - - if (_T("titleStyle") == strName) - titleStyle = oNode; - else if (_T("bodyStyle") == strName) - bodyStyle = oNode; - else if (_T("otherStyle") == strName) - otherStyle = oNode; - } - } - - FillParentPointersForChilds(); - } - virtual std::wstring toXML() const - { - XmlUtils::CNodeValue oValue; - oValue.WriteNullable(titleStyle); - oValue.WriteNullable(bodyStyle); - oValue.WriteNullable(otherStyle); - - return XmlUtils::CreateNode(_T("p:txStyles"), oValue); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteRecord2(0, titleStyle); - pWriter->WriteRecord2(1, bodyStyle); - pWriter->WriteRecord2(2, otherStyle); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG end = pReader->GetPos() + pReader->GetLong() + 4; - - while (pReader->GetPos() < end) - { - BYTE _rec = pReader->GetUChar(); - - switch (_rec) - { - case 0: - { - titleStyle = new TextListStyle(); - titleStyle->m_name = _T("p:titleStyle"); - titleStyle->fromPPTY(pReader); - break; - } - case 1: - { - bodyStyle = new TextListStyle(); - bodyStyle->m_name = _T("p:bodyStyle"); - bodyStyle->fromPPTY(pReader); - break; - } - case 2: - { - otherStyle = new TextListStyle(); - otherStyle->m_name = _T("p:otherStyle"); - otherStyle->fromPPTY(pReader); - break; - } - default: - break; - } - } - - pReader->Seek(end); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(_T("p:txStyles")); - pWriter->EndAttributes(); - - pWriter->Write(titleStyle); - pWriter->Write(bodyStyle); - pWriter->Write(otherStyle); - - pWriter->EndNode(_T("p:txStyles")); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; nullable titleStyle; nullable bodyStyle; nullable otherStyle; + protected: - virtual void FillParentPointersForChilds() - { - if(titleStyle.is_init()) - titleStyle->SetParentPointer(this); - if(bodyStyle.is_init()) - bodyStyle->SetParentPointer(this); - if(otherStyle.is_init()) - otherStyle->SetParentPointer(this); - } + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_TXSTYLES_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_TXSTYLES_INCLUDE_H diff --git a/OOXML/PPTXFormat/Logic/UniMedia.cpp b/OOXML/PPTXFormat/Logic/UniMedia.cpp new file mode 100644 index 0000000000..863c296e8d --- /dev/null +++ b/OOXML/PPTXFormat/Logic/UniMedia.cpp @@ -0,0 +1,114 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "UniMedia.h" + +namespace PPTX +{ + namespace Logic + { + UniMedia::UniMedia() + { + } + void UniMedia::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + std::wstring name = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (name == _T("audioCd")) + Media.reset(new Logic::AudioCD(oReader)); + else if (name == _T("wavAudioFile")) + Media.reset(new Logic::WavAudioFile(oReader)); + else if (name == _T("audioFile")) + Media.reset(new Logic::MediaFile(oReader)); + else if (name == _T("videoFile")) + Media.reset(new Logic::MediaFile(oReader)); + else if (name == _T("quickTimeFile")) + Media.reset(new Logic::MediaFile(oReader)); + else Media.reset(); + } + void UniMedia::fromXML(XmlUtils::CXmlNode& node) + { + std::wstring name = XmlUtils::GetNameNoNS(node.GetName()); + + if (name == _T("audioCd")) + Media.reset(new Logic::AudioCD(node)); + else if (name == _T("wavAudioFile")) + Media.reset(new Logic::WavAudioFile(node)); + else if (name == _T("audioFile")) + Media.reset(new Logic::MediaFile(node)); + else if (name == _T("videoFile")) + Media.reset(new Logic::MediaFile(node)); + else if (name == _T("quickTimeFile")) + Media.reset(new Logic::MediaFile(node)); + else Media.reset(); + } + void UniMedia::GetMediaFrom(XmlUtils::CXmlNode& element) + { + XmlUtils::CXmlNode oNode; + if (element.GetNode(_T("a:audioCd"), oNode)) + Media.reset(new Logic::AudioCD(oNode)); + else if (element.GetNode(_T("a:wavAudioFile"), oNode)) + Media.reset(new Logic::WavAudioFile(oNode)); + else if (element.GetNode(_T("a:audioFile"), oNode)) + Media.reset(new Logic::MediaFile(oNode)); + else if (element.GetNode(_T("a:videoFile"), oNode)) + Media.reset(new Logic::MediaFile(oNode)); + else if (element.GetNode(_T("a:quickTimeFile"), oNode)) + Media.reset(new Logic::MediaFile(oNode)); + else Media.reset(); + } + std::wstring UniMedia::toXML() const + { + if (Media.IsInit()) + return Media->toXML(); + return _T(""); + } + void UniMedia::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + } + void UniMedia::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + if (Media.is_init()) + Media->toXmlWriter(pWriter); + } + bool UniMedia::is_init() const + { + return (Media.IsInit()); + } + void UniMedia::FillParentPointersForChilds() {} + void UniMedia::SetParentPointer(const WrapperWritingElement* pParent) + { + if(is_init()) + Media->SetParentPointer(pParent); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/UniMedia.h b/OOXML/PPTXFormat/Logic/UniMedia.h index 99bc38eed3..eba633fa0b 100644 --- a/OOXML/PPTXFormat/Logic/UniMedia.h +++ b/OOXML/PPTXFormat/Logic/UniMedia.h @@ -47,94 +47,33 @@ namespace PPTX public: WritingElement_AdditionConstructors(UniMedia) + UniMedia(); - UniMedia() - { - } + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - std::wstring name = XmlUtils::GetNameNoNS(oReader.GetName()); + virtual void GetMediaFrom(XmlUtils::CXmlNode& element); - if (name == _T("audioCd")) - Media.reset(new Logic::AudioCD(oReader)); - else if (name == _T("wavAudioFile")) - Media.reset(new Logic::WavAudioFile(oReader)); - else if (name == _T("audioFile")) - Media.reset(new Logic::MediaFile(oReader)); - else if (name == _T("videoFile")) - Media.reset(new Logic::MediaFile(oReader)); - else if (name == _T("quickTimeFile")) - Media.reset(new Logic::MediaFile(oReader)); - else Media.reset(); - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - std::wstring name = XmlUtils::GetNameNoNS(node.GetName()); + virtual std::wstring toXML() const; - if (name == _T("audioCd")) - Media.reset(new Logic::AudioCD(node)); - else if (name == _T("wavAudioFile")) - Media.reset(new Logic::WavAudioFile(node)); - else if (name == _T("audioFile")) - Media.reset(new Logic::MediaFile(node)); - else if (name == _T("videoFile")) - Media.reset(new Logic::MediaFile(node)); - else if (name == _T("quickTimeFile")) - Media.reset(new Logic::MediaFile(node)); - else Media.reset(); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - virtual void GetMediaFrom(XmlUtils::CXmlNode& element) - { - XmlUtils::CXmlNode oNode; - if (element.GetNode(_T("a:audioCd"), oNode)) - Media.reset(new Logic::AudioCD(oNode)); - else if (element.GetNode(_T("a:wavAudioFile"), oNode)) - Media.reset(new Logic::WavAudioFile(oNode)); - else if (element.GetNode(_T("a:audioFile"), oNode)) - Media.reset(new Logic::MediaFile(oNode)); - else if (element.GetNode(_T("a:videoFile"), oNode)) - Media.reset(new Logic::MediaFile(oNode)); - else if (element.GetNode(_T("a:quickTimeFile"), oNode)) - Media.reset(new Logic::MediaFile(oNode)); - else Media.reset(); - } - - virtual std::wstring toXML() const - { - if (Media.IsInit()) - return Media->toXML(); - return _T(""); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - if (Media.is_init()) - Media->toXmlWriter(pWriter); - } - - virtual bool is_init()const{return (Media.IsInit());}; + virtual bool is_init() const; template AVSINLINE const bool is() const { return Media.is(); } template AVSINLINE T& as() { return Media.as(); } template AVSINLINE const T& as() const { return Media.as(); } smart_ptr Media; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); + public: - virtual void SetParentPointer(const WrapperWritingElement* pParent) - { - if(is_init()) - Media->SetParentPointer(pParent); - }; + virtual void SetParentPointer(const WrapperWritingElement* pParent); }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_UNIMEDIA_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_UNIMEDIA_INCLUDE_H diff --git a/OOXML/PPTXFormat/Logic/UniPath2D.cpp b/OOXML/PPTXFormat/Logic/UniPath2D.cpp new file mode 100644 index 0000000000..dae6277dc2 --- /dev/null +++ b/OOXML/PPTXFormat/Logic/UniPath2D.cpp @@ -0,0 +1,127 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "UniPath2D.h" + +namespace PPTX +{ + namespace Logic + { + OOX::EElementType UniPath2D::getType() const + { + if (Path2D.IsInit()) + return Path2D->getType(); + return OOX::et_Unknown; + } + void UniPath2D::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + std::wstring name = XmlUtils::GetNameNoNS(oReader.GetName()); + + if (name == _T("moveTo")) + Path2D.reset(new Logic::MoveTo(oReader)); + else if (name == _T("lnTo")) + Path2D.reset(new Logic::LineTo(oReader)); + else if (name == _T("cubicBezTo")) + Path2D.reset(new Logic::CubicBezTo(oReader)); + else if (name == _T("close")) + Path2D.reset(new Logic::Close(oReader)); + else if (name == _T("arcTo")) + Path2D.reset(new Logic::ArcTo(oReader)); + else if (name == _T("quadBezTo")) + Path2D.reset(new Logic::QuadBezTo(oReader)); + else Path2D.reset(); + } + void UniPath2D::fromXML(XmlUtils::CXmlNode& node) + { + std::wstring name = XmlUtils::GetNameNoNS(node.GetName()); + + if (name == _T("moveTo")) + Path2D.reset(new Logic::MoveTo(node)); + else if (name == _T("lnTo")) + Path2D.reset(new Logic::LineTo(node)); + else if (name == _T("cubicBezTo")) + Path2D.reset(new Logic::CubicBezTo(node)); + else if (name == _T("close")) + Path2D.reset(new Logic::Close(node)); + else if (name == _T("arcTo")) + Path2D.reset(new Logic::ArcTo(node)); + else if (name == _T("quadBezTo")) + Path2D.reset(new Logic::QuadBezTo(node)); + else Path2D.reset(); + } + void UniPath2D::GetPath2DFrom(XmlUtils::CXmlNode& element) + { + XmlUtils::CXmlNode oNode; + + if(element.GetNode(_T("a:moveTo"), oNode)) + Path2D.reset(new Logic::MoveTo(oNode)); + else if(element.GetNode(_T("a:lnTo"), oNode)) + Path2D.reset(new Logic::LineTo(oNode)); + else if(element.GetNode(_T("a:cubicBezTo"), oNode)) + Path2D.reset(new Logic::CubicBezTo(oNode)); + else if(element.GetNode(_T("a:close"), oNode)) + Path2D.reset(new Logic::Close(oNode)); + else if(element.GetNode(_T("a:arcTo"), oNode)) + Path2D.reset(new Logic::ArcTo(oNode)); + else if(element.GetNode(_T("a:quadBezTo"), oNode)) + Path2D.reset(new Logic::QuadBezTo(oNode)); + else Path2D.reset(); + } + std::wstring UniPath2D::toXML() const + { + if (Path2D.IsInit()) + return Path2D->toXML(); + return _T(""); + } + void UniPath2D::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + if (Path2D.is_init()) + Path2D->toPPTY(pWriter); + } + void UniPath2D::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + if (Path2D.is_init()) + Path2D->toXmlWriter(pWriter); + } + bool UniPath2D::is_init()const{return (Path2D.IsInit());}; + void UniPath2D::FillParentPointersForChilds(){} + void UniPath2D::SetParentPointer(const WrapperWritingElement* pParent) + { + if(is_init()) + Path2D->SetParentPointer(pParent); + } + std::wstring UniPath2D::GetODString() const + { + return Path2D->GetODString(); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/UniPath2D.h b/OOXML/PPTXFormat/Logic/UniPath2D.h index 260ee75c40..604ccb1c68 100644 --- a/OOXML/PPTXFormat/Logic/UniPath2D.h +++ b/OOXML/PPTXFormat/Logic/UniPath2D.h @@ -52,110 +52,34 @@ namespace PPTX WritingElement_AdditionConstructors(UniPath2D) PPTX_LOGIC_BASE2(UniPath2D) - virtual OOX::EElementType getType() const - { - if (Path2D.IsInit()) - return Path2D->getType(); - return OOX::et_Unknown; - } + virtual OOX::EElementType getType() const; - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - std::wstring name = XmlUtils::GetNameNoNS(oReader.GetName()); - - if (name == _T("moveTo")) - Path2D.reset(new Logic::MoveTo(oReader)); - else if (name == _T("lnTo")) - Path2D.reset(new Logic::LineTo(oReader)); - else if (name == _T("cubicBezTo")) - Path2D.reset(new Logic::CubicBezTo(oReader)); - else if (name == _T("close")) - Path2D.reset(new Logic::Close(oReader)); - else if (name == _T("arcTo")) - Path2D.reset(new Logic::ArcTo(oReader)); - else if (name == _T("quadBezTo")) - Path2D.reset(new Logic::QuadBezTo(oReader)); - else Path2D.reset(); - } - - virtual void fromXML(XmlUtils::CXmlNode& node) - { - std::wstring name = XmlUtils::GetNameNoNS(node.GetName()); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& node); - if (name == _T("moveTo")) - Path2D.reset(new Logic::MoveTo(node)); - else if (name == _T("lnTo")) - Path2D.reset(new Logic::LineTo(node)); - else if (name == _T("cubicBezTo")) - Path2D.reset(new Logic::CubicBezTo(node)); - else if (name == _T("close")) - Path2D.reset(new Logic::Close(node)); - else if (name == _T("arcTo")) - Path2D.reset(new Logic::ArcTo(node)); - else if (name == _T("quadBezTo")) - Path2D.reset(new Logic::QuadBezTo(node)); - else Path2D.reset(); - } + virtual void GetPath2DFrom(XmlUtils::CXmlNode& element); - virtual void GetPath2DFrom(XmlUtils::CXmlNode& element) - { - XmlUtils::CXmlNode oNode; - - if(element.GetNode(_T("a:moveTo"), oNode)) - Path2D.reset(new Logic::MoveTo(oNode)); - else if(element.GetNode(_T("a:lnTo"), oNode)) - Path2D.reset(new Logic::LineTo(oNode)); - else if(element.GetNode(_T("a:cubicBezTo"), oNode)) - Path2D.reset(new Logic::CubicBezTo(oNode)); - else if(element.GetNode(_T("a:close"), oNode)) - Path2D.reset(new Logic::Close(oNode)); - else if(element.GetNode(_T("a:arcTo"), oNode)) - Path2D.reset(new Logic::ArcTo(oNode)); - else if(element.GetNode(_T("a:quadBezTo"), oNode)) - Path2D.reset(new Logic::QuadBezTo(oNode)); - else Path2D.reset(); - } + virtual std::wstring toXML() const; - virtual std::wstring toXML() const - { - if (Path2D.IsInit()) - return Path2D->toXML(); - return _T(""); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - if (Path2D.is_init()) - Path2D->toPPTY(pWriter); - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - if (Path2D.is_init()) - Path2D->toXmlWriter(pWriter); - } - - virtual bool is_init()const{return (Path2D.IsInit());}; + virtual bool is_init() const; template const bool is() const { return (!Path2D.IsInit())?false:(typeid(*Path2D) == typeid(T));} template T& as() {return static_cast(*Path2D);} template const T& as() const {return static_cast(*Path2D);} smart_ptr Path2D; - protected: - virtual void FillParentPointersForChilds(){}; - public: - virtual void SetParentPointer(const WrapperWritingElement* pParent) - { - if(is_init()) - Path2D->SetParentPointer(pParent); - }; - std::wstring GetODString()const - { - return Path2D->GetODString(); - } + protected: + virtual void FillParentPointersForChilds(); + + public: + virtual void SetParentPointer(const WrapperWritingElement* pParent); + std::wstring GetODString() const; }; } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_UNIPATH2D_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_UNIPATH2D_INCLUDE_H diff --git a/OOXML/PPTXFormat/Logic/Xfrm.cpp b/OOXML/PPTXFormat/Logic/Xfrm.cpp new file mode 100644 index 0000000000..0b85654a6a --- /dev/null +++ b/OOXML/PPTXFormat/Logic/Xfrm.cpp @@ -0,0 +1,415 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "Xfrm.h" + +namespace PPTX +{ + namespace Logic + { + Xfrm::Xfrm() + { + node_name = L"a:xfrm"; + } + Xfrm::~Xfrm() {} + Xfrm::Xfrm(XmlUtils::CXmlNode& node) + { + fromXML(node); + } + Xfrm::Xfrm(XmlUtils::CXmlLiteReader& oReader) + { + fromXML(oReader); + } + const Xfrm& Xfrm::operator =(XmlUtils::CXmlNode& node) + { + fromXML(node); + return *this; + } + Xfrm::Xfrm(const Xfrm& oSrc) + { + *this = oSrc; + } + OOX::EElementType Xfrm::getType () const + { + return OOX::et_a_xfrm; + } + void Xfrm::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + node_name = oReader.GetName(); + + ReadAttributes(oReader); + + if ( oReader.IsEmptyNode() ) + return; + + int nParentDepth = oReader.GetDepth(); + while( oReader.ReadNextSiblingNode( nParentDepth ) ) + { + std::wstring sName = oReader.GetName(); + + if (sName == L"a:off") + ReadAttributes1(oReader, offX, offY); + else if (sName == L"a:ext") + ReadAttributes2(oReader, extX, extY); + else if (sName == L"a:chOff") + ReadAttributes1(oReader, chOffX, chOffY); + else if (sName == L"a:chExt") + ReadAttributes2(oReader, chExtX, chExtY); + } + } + void Xfrm::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("flipH"), flipH) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("flipV"), flipV ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("rot"), rot ) + WritingElement_ReadAttributes_End( oReader ) + } + void Xfrm::ReadAttributes1(XmlUtils::CXmlLiteReader& oReader, nullable_int & x, nullable_int & y) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y ) + WritingElement_ReadAttributes_End( oReader ) + } + void Xfrm::ReadAttributes2(XmlUtils::CXmlLiteReader& oReader, nullable_int & cx, nullable_int & cy) + { + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("cx"), cx ) + WritingElement_ReadAttributes_Read_else_if ( oReader, _T("cy"), cy ) + WritingElement_ReadAttributes_End( oReader ) + } + void Xfrm::fromXML(XmlUtils::CXmlNode& node) + { + node_name = node.GetName(); + + XmlMacroReadAttributeBase(node, L"flipH", flipH); + XmlMacroReadAttributeBase(node, L"flipV", flipV); + XmlMacroReadAttributeBase(node, L"rot", rot); + + XmlUtils::CXmlNode oNodeOff; + if(node.GetNode(_T("a:off"), oNodeOff)) + { + XmlMacroReadAttributeBase(oNodeOff, L"x", offX); + XmlMacroReadAttributeBase(oNodeOff, L"y", offY); + } + XmlUtils::CXmlNode oNodeExt; + if(node.GetNode(_T("a:ext"), oNodeExt)) + { + XmlMacroReadAttributeBase(oNodeExt, L"cx", extX); + XmlMacroReadAttributeBase(oNodeExt, L"cy", extY); + } + XmlUtils::CXmlNode oNodeChOff; + if(node.GetNode(_T("a:chOff"), oNodeChOff)) + { + XmlMacroReadAttributeBase(oNodeChOff, L"x", chOffX); + XmlMacroReadAttributeBase(oNodeChOff, L"y", chOffY); + } + XmlUtils::CXmlNode oNodeChExt; + if(node.GetNode(_T("a:chExt"), oNodeChExt)) + { + XmlMacroReadAttributeBase(oNodeChExt, L"cx", chExtX); + XmlMacroReadAttributeBase(oNodeChExt, L"cy", chExtY); + } + Normalize(); + } + std::wstring Xfrm::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(L"rot", rot); + oAttr.Write(L"flipH", flipH); + oAttr.Write(L"flipV", flipV); + + XmlUtils::CNodeValue oValue; + + XmlUtils::CAttribute oAttr1; + oAttr1.Write(L"x", offX); + oAttr1.Write(L"y", offY); + + XmlUtils::CAttribute oAttr2; + oAttr2.Write(_T("cx"), extX); + oAttr2.Write(_T("cy"), extY); + + XmlUtils::CAttribute oAttr3; + oAttr3.Write(_T("x"), chOffX); + oAttr3.Write(_T("y"), chOffY); + + XmlUtils::CAttribute oAttr4; + oAttr4.Write(_T("cx"), chExtX); + oAttr4.Write(_T("cy"), chExtY); + + std::wstring strValue = _T(""); + + if (_T("") != oAttr1.m_strValue) + strValue += XmlUtils::CreateNode(_T("a:off"), oAttr1); + if (_T("") != oAttr2.m_strValue) + strValue += XmlUtils::CreateNode(_T("a:ext"), oAttr2); + if (_T("") != oAttr3.m_strValue) + strValue += XmlUtils::CreateNode(_T("a:chOff"), oAttr3); + if (_T("") != oAttr4.m_strValue) + strValue += XmlUtils::CreateNode(_T("a:chExt"), oAttr4); + + return XmlUtils::CreateNode(node_name, oAttr, strValue); + } + void Xfrm::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(node_name); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("rot"), rot); + pWriter->WriteAttribute(_T("flipH"), flipH); + pWriter->WriteAttribute(_T("flipV"), flipV); + pWriter->EndAttributes(); + + if (offX.is_init() || offY.is_init()) + { + pWriter->StartNode(_T("a:off")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("x"), offX); + pWriter->WriteAttribute(_T("y"), offY); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:off")); + } + + if (extX.is_init() || extY.is_init()) + { + pWriter->StartNode(_T("a:ext")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("cx"), extX); + pWriter->WriteAttribute(_T("cy"), extY); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:ext")); + } + + if (chOffX.is_init() || chOffY.is_init()) + { + pWriter->StartNode(_T("a:chOff")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("x"), chOffX); + pWriter->WriteAttribute(_T("y"), chOffY); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:chOff")); + } + + if (chExtX.is_init() || chExtY.is_init()) + { + pWriter->StartNode(_T("a:chExt")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("cx"), chExtX); + pWriter->WriteAttribute(_T("cy"), chExtY); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:chExt")); + } + + pWriter->EndNode(node_name); + } + void Xfrm::toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode(strNS + L":xfrm"); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("rot"), rot); + pWriter->WriteAttribute(_T("flipH"), flipH); + pWriter->WriteAttribute(_T("flipV"), flipV); + pWriter->EndAttributes(); + + if (offX.is_init() || offY.is_init()) + { + pWriter->StartNode(_T("a:off")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("x"), offX); + pWriter->WriteAttribute(_T("y"), offY); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:off")); + } + + if (extX.is_init() || extY.is_init()) + { + pWriter->StartNode(_T("a:ext")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("cx"), extX); + pWriter->WriteAttribute(_T("cy"), extY); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:ext")); + } + + if (chOffX.is_init() || chOffY.is_init()) + { + pWriter->StartNode(_T("a:chOff")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("x"), chOffX); + pWriter->WriteAttribute(_T("y"), chOffY); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:chOff")); + } + + if (chExtX.is_init() || chExtY.is_init()) + { + pWriter->StartNode(_T("a:chExt")); + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("cx"), chExtX); + pWriter->WriteAttribute(_T("cy"), chExtY); + pWriter->EndAttributes(); + pWriter->EndNode(_T("a:chExt")); + } + + pWriter->EndNode(strNS + _T(":xfrm")); + } + void Xfrm::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteInt2(0, offX); + pWriter->WriteInt2(1, offY); + pWriter->WriteInt2(2, extX); + pWriter->WriteInt2(3, extY); + pWriter->WriteInt2(4, chOffX); + pWriter->WriteInt2(5, chOffY); + pWriter->WriteInt2(6, chExtX); + pWriter->WriteInt2(7, chExtY); + pWriter->WriteBool2(8, flipH); + pWriter->WriteBool2(9, flipV); + pWriter->WriteInt2(10, rot); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void Xfrm::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + { + offX = pReader->GetLong(); + break; + } + case 1: + { + offY = pReader->GetLong(); + break; + } + case 2: + { + extX = pReader->GetLong(); + break; + } + case 3: + { + extY = pReader->GetLong(); + break; + } + case 4: + { + chOffX = pReader->GetLong(); + break; + } + case 5: + { + chOffY = pReader->GetLong(); + break; + } + case 6: + { + chExtX = pReader->GetLong(); + break; + } + case 7: + { + chExtY = pReader->GetLong(); + break; + } + case 8: + { + flipH = pReader->GetBool(); + break; + } + case 9: + { + flipV = pReader->GetBool(); + break; + } + case 10: + { + rot = pReader->GetLong(); + break; + } + default: + break; + } + } + + pReader->Seek(_end_rec); + } + void Xfrm::Merge(nullable& xfrm)const + { + if(!xfrm.IsInit()) + xfrm = new Xfrm(); + if(offX.IsInit()) + xfrm->offX = *offX; + if(offY.IsInit()) + xfrm->offY = *offY; + if(extX.IsInit()) + xfrm->extX = *extX; + if(extY.IsInit()) + xfrm->extY = *extY; + if(chOffX.IsInit()) + xfrm->chOffX = *chOffX; + if(chOffY.IsInit()) + xfrm->chOffY = *chOffY; + if(chExtX.IsInit()) + xfrm->chExtX = *chExtX; + if(chExtY.IsInit()) + xfrm->chExtY = *chExtY; + if(flipH.IsInit()) + xfrm->flipH = *flipH; + if(flipV.IsInit()) + xfrm->flipV = *flipV; + if(rot.IsInit()) + xfrm->rot = *rot; + } + void Xfrm::FillParentPointersForChilds(){} + AVSINLINE void Xfrm::Normalize() + { + extX.normalize_positive(); + extY.normalize_positive(); + chExtX.normalize_positive(); + chExtY.normalize_positive(); + } + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/Xfrm.h b/OOXML/PPTXFormat/Logic/Xfrm.h index 569a9a188e..1ded283fc1 100644 --- a/OOXML/PPTXFormat/Logic/Xfrm.h +++ b/OOXML/PPTXFormat/Logic/Xfrm.h @@ -40,372 +40,32 @@ namespace PPTX class Xfrm : public WrapperWritingElement { public: - Xfrm() - { - node_name = L"a:xfrm"; - } - virtual ~Xfrm() {} - explicit Xfrm(XmlUtils::CXmlNode& node) { fromXML(node); } - explicit Xfrm(XmlUtils::CXmlLiteReader& oReader){ fromXML(oReader); } - const Xfrm& operator =(XmlUtils::CXmlNode& node) - { - fromXML(node); - return *this; - } - Xfrm(const Xfrm& oSrc) { *this = oSrc; } + Xfrm(); + virtual ~Xfrm(); + explicit Xfrm(XmlUtils::CXmlNode& node); + explicit Xfrm(XmlUtils::CXmlLiteReader& oReader); + + const Xfrm& operator =(XmlUtils::CXmlNode& node); + Xfrm(const Xfrm& oSrc); - virtual OOX::EElementType getType () const - { - return OOX::et_a_xfrm; - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - node_name = oReader.GetName(); - - ReadAttributes(oReader); + virtual OOX::EElementType getType () const; + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - if ( oReader.IsEmptyNode() ) - return; - - int nParentDepth = oReader.GetDepth(); - while( oReader.ReadNextSiblingNode( nParentDepth ) ) - { - std::wstring sName = oReader.GetName(); + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + void ReadAttributes1(XmlUtils::CXmlLiteReader& oReader, nullable_int & x, nullable_int & y); + void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader, nullable_int & cx, nullable_int & cy); - if (sName == L"a:off") - ReadAttributes1(oReader, offX, offY); - else if (sName == L"a:ext") - ReadAttributes2(oReader, extX, extY); - else if (sName == L"a:chOff") - ReadAttributes1(oReader, chOffX, chOffY); - else if (sName == L"a:chExt") - ReadAttributes2(oReader, chExtX, chExtY); - } - } + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("flipH"), flipH) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("flipV"), flipV ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("rot"), rot ) - WritingElement_ReadAttributes_End( oReader ) - } - void ReadAttributes1(XmlUtils::CXmlLiteReader& oReader, nullable_int & x, nullable_int & y) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("x"), x ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("y"), y ) - WritingElement_ReadAttributes_End( oReader ) - } - void ReadAttributes2(XmlUtils::CXmlLiteReader& oReader, nullable_int & cx, nullable_int & cy) - { - WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("cx"), cx ) - WritingElement_ReadAttributes_Read_else_if ( oReader, _T("cy"), cy ) - WritingElement_ReadAttributes_End( oReader ) - } + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + void toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const; - virtual void fromXML(XmlUtils::CXmlNode& node) - { - node_name = node.GetName(); + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); - XmlMacroReadAttributeBase(node, L"flipH", flipH); - XmlMacroReadAttributeBase(node, L"flipV", flipV); - XmlMacroReadAttributeBase(node, L"rot", rot); + void Merge(nullable& xfrm) const; - XmlUtils::CXmlNode oNodeOff; - if(node.GetNode(_T("a:off"), oNodeOff)) - { - XmlMacroReadAttributeBase(oNodeOff, L"x", offX); - XmlMacroReadAttributeBase(oNodeOff, L"y", offY); - } - XmlUtils::CXmlNode oNodeExt; - if(node.GetNode(_T("a:ext"), oNodeExt)) - { - XmlMacroReadAttributeBase(oNodeExt, L"cx", extX); - XmlMacroReadAttributeBase(oNodeExt, L"cy", extY); - } - XmlUtils::CXmlNode oNodeChOff; - if(node.GetNode(_T("a:chOff"), oNodeChOff)) - { - XmlMacroReadAttributeBase(oNodeChOff, L"x", chOffX); - XmlMacroReadAttributeBase(oNodeChOff, L"y", chOffY); - } - XmlUtils::CXmlNode oNodeChExt; - if(node.GetNode(_T("a:chExt"), oNodeChExt)) - { - XmlMacroReadAttributeBase(oNodeChExt, L"cx", chExtX); - XmlMacroReadAttributeBase(oNodeChExt, L"cy", chExtY); - } - Normalize(); - } - - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(L"rot", rot); - oAttr.Write(L"flipH", flipH); - oAttr.Write(L"flipV", flipV); - - XmlUtils::CNodeValue oValue; - - XmlUtils::CAttribute oAttr1; - oAttr1.Write(L"x", offX); - oAttr1.Write(L"y", offY); - - XmlUtils::CAttribute oAttr2; - oAttr2.Write(_T("cx"), extX); - oAttr2.Write(_T("cy"), extY); - - XmlUtils::CAttribute oAttr3; - oAttr3.Write(_T("x"), chOffX); - oAttr3.Write(_T("y"), chOffY); - - XmlUtils::CAttribute oAttr4; - oAttr4.Write(_T("cx"), chExtX); - oAttr4.Write(_T("cy"), chExtY); - - std::wstring strValue = _T(""); - - if (_T("") != oAttr1.m_strValue) - strValue += XmlUtils::CreateNode(_T("a:off"), oAttr1); - if (_T("") != oAttr2.m_strValue) - strValue += XmlUtils::CreateNode(_T("a:ext"), oAttr2); - if (_T("") != oAttr3.m_strValue) - strValue += XmlUtils::CreateNode(_T("a:chOff"), oAttr3); - if (_T("") != oAttr4.m_strValue) - strValue += XmlUtils::CreateNode(_T("a:chExt"), oAttr4); - - return XmlUtils::CreateNode(node_name, oAttr, strValue); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(node_name); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("rot"), rot); - pWriter->WriteAttribute(_T("flipH"), flipH); - pWriter->WriteAttribute(_T("flipV"), flipV); - pWriter->EndAttributes(); - - if (offX.is_init() || offY.is_init()) - { - pWriter->StartNode(_T("a:off")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("x"), offX); - pWriter->WriteAttribute(_T("y"), offY); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:off")); - } - - if (extX.is_init() || extY.is_init()) - { - pWriter->StartNode(_T("a:ext")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("cx"), extX); - pWriter->WriteAttribute(_T("cy"), extY); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:ext")); - } - - if (chOffX.is_init() || chOffY.is_init()) - { - pWriter->StartNode(_T("a:chOff")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("x"), chOffX); - pWriter->WriteAttribute(_T("y"), chOffY); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:chOff")); - } - - if (chExtX.is_init() || chExtY.is_init()) - { - pWriter->StartNode(_T("a:chExt")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("cx"), chExtX); - pWriter->WriteAttribute(_T("cy"), chExtY); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:chExt")); - } - - pWriter->EndNode(node_name); - } - - void toXmlWriter2(const std::wstring& strNS, NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(strNS + L":xfrm"); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("rot"), rot); - pWriter->WriteAttribute(_T("flipH"), flipH); - pWriter->WriteAttribute(_T("flipV"), flipV); - pWriter->EndAttributes(); - - if (offX.is_init() || offY.is_init()) - { - pWriter->StartNode(_T("a:off")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("x"), offX); - pWriter->WriteAttribute(_T("y"), offY); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:off")); - } - - if (extX.is_init() || extY.is_init()) - { - pWriter->StartNode(_T("a:ext")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("cx"), extX); - pWriter->WriteAttribute(_T("cy"), extY); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:ext")); - } - - if (chOffX.is_init() || chOffY.is_init()) - { - pWriter->StartNode(_T("a:chOff")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("x"), chOffX); - pWriter->WriteAttribute(_T("y"), chOffY); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:chOff")); - } - - if (chExtX.is_init() || chExtY.is_init()) - { - pWriter->StartNode(_T("a:chExt")); - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("cx"), chExtX); - pWriter->WriteAttribute(_T("cy"), chExtY); - pWriter->EndAttributes(); - pWriter->EndNode(_T("a:chExt")); - } - - pWriter->EndNode(strNS + _T(":xfrm")); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteInt2(0, offX); - pWriter->WriteInt2(1, offY); - pWriter->WriteInt2(2, extX); - pWriter->WriteInt2(3, extY); - pWriter->WriteInt2(4, chOffX); - pWriter->WriteInt2(5, chOffY); - pWriter->WriteInt2(6, chExtX); - pWriter->WriteInt2(7, chExtY); - pWriter->WriteBool2(8, flipH); - pWriter->WriteBool2(9, flipV); - pWriter->WriteInt2(10, rot); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - offX = pReader->GetLong(); - break; - } - case 1: - { - offY = pReader->GetLong(); - break; - } - case 2: - { - extX = pReader->GetLong(); - break; - } - case 3: - { - extY = pReader->GetLong(); - break; - } - case 4: - { - chOffX = pReader->GetLong(); - break; - } - case 5: - { - chOffY = pReader->GetLong(); - break; - } - case 6: - { - chExtX = pReader->GetLong(); - break; - } - case 7: - { - chExtY = pReader->GetLong(); - break; - } - case 8: - { - flipH = pReader->GetBool(); - break; - } - case 9: - { - flipV = pReader->GetBool(); - break; - } - case 10: - { - rot = pReader->GetLong(); - break; - } - default: - break; - } - } - - pReader->Seek(_end_rec); - } - void Merge(nullable& xfrm)const - { - if(!xfrm.IsInit()) - xfrm = new Xfrm(); - if(offX.IsInit()) - xfrm->offX = *offX; - if(offY.IsInit()) - xfrm->offY = *offY; - if(extX.IsInit()) - xfrm->extX = *extX; - if(extY.IsInit()) - xfrm->extY = *extY; - if(chOffX.IsInit()) - xfrm->chOffX = *chOffX; - if(chOffY.IsInit()) - xfrm->chOffY = *chOffY; - if(chExtX.IsInit()) - xfrm->chExtX = *chExtX; - if(chExtY.IsInit()) - xfrm->chExtY = *chExtY; - if(flipH.IsInit()) - xfrm->flipH = *flipH; - if(flipV.IsInit()) - xfrm->flipV = *flipV; - if(rot.IsInit()) - xfrm->rot = *rot; - } nullable_int offX; nullable_int offY; nullable_int extX; @@ -420,16 +80,10 @@ namespace PPTX nullable_int rot; std::wstring node_name; - protected: - virtual void FillParentPointersForChilds(){}; - AVSINLINE void Normalize() - { - extX.normalize_positive(); - extY.normalize_positive(); - chExtX.normalize_positive(); - chExtY.normalize_positive(); - } + protected: + virtual void FillParentPointersForChilds(); + void Normalize(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/XmlId.cpp b/OOXML/PPTXFormat/Logic/XmlId.cpp new file mode 100644 index 0000000000..0ea3be203a --- /dev/null +++ b/OOXML/PPTXFormat/Logic/XmlId.cpp @@ -0,0 +1,112 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * 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-12 Ernesta Birznieka-Upisha + * 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 "XmlId.h" + +namespace PPTX +{ + namespace Logic + { + XmlId::XmlId(std::wstring name) + { + m_name = name; + } + void XmlId::fromXML(XmlUtils::CXmlNode& node) + { + m_name = node.GetName(); + + XmlMacroReadAttributeBase(node, L"r:id", rid); + XmlMacroReadAttributeBase(node, L"id", id); + } + std::wstring XmlId::toXML() const + { + XmlUtils::CAttribute oAttr; + oAttr.Write(_T("r:id"), rid.ToString()); + oAttr.Write(_T("id"), id); + + return XmlUtils::CreateNode(m_name, oAttr); + } + void XmlId::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteString2(0, id); + + rid.toPPTY(1, pWriter); + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + } + void XmlId::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) + { + LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; + + pReader->Skip(1); // start attributes + + while (true) + { + BYTE _at = pReader->GetUChar_TypeNode(); + if (_at == NSBinPptxRW::g_nodeAttributeEnd) + break; + + switch (_at) + { + case 0: + id = pReader->GetString2(); + break; + case 1: + rid = pReader->GetString2(); + break; + default: + break; + } + } + pReader->Seek(_end_rec); + } + void XmlId::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + pWriter->StartNode( m_name ); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(_T("id"), id); + + std::wstring sRid = rid.ToString(); + if (sRid.empty() == false) + { + pWriter->WriteAttribute(_T("r:id"), sRid); + } + pWriter->EndAttributes(); + + pWriter->EndNode( m_name ); + } + void XmlId::FillParentPointersForChilds(){} + + } // namespace Logic +} // namespace PPTX diff --git a/OOXML/PPTXFormat/Logic/XmlId.h b/OOXML/PPTXFormat/Logic/XmlId.h index 849d7616c3..c6e2167365 100644 --- a/OOXML/PPTXFormat/Logic/XmlId.h +++ b/OOXML/PPTXFormat/Logic/XmlId.h @@ -45,84 +45,21 @@ namespace PPTX public: PPTX_LOGIC_BASE(XmlId) - XmlId(std::wstring name) - { - m_name = name; - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - m_name = node.GetName(); + XmlId(std::wstring name); - XmlMacroReadAttributeBase(node, L"r:id", rid); - XmlMacroReadAttributeBase(node, L"id", id); - } - virtual std::wstring toXML() const - { - XmlUtils::CAttribute oAttr; - oAttr.Write(_T("r:id"), rid.ToString()); - oAttr.Write(_T("id"), id); + virtual void fromXML(XmlUtils::CXmlNode& node); + virtual std::wstring toXML() const; - return XmlUtils::CreateNode(m_name, oAttr); - } - - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteString2(0, id); - - rid.toPPTY(1, pWriter); - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - id = pReader->GetString2(); - break; - case 1: - rid = pReader->GetString2(); - break; - default: - break; - } - } - pReader->Seek(_end_rec); - } - - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode( m_name ); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(_T("id"), id); - - std::wstring sRid = rid.ToString(); - if (sRid.empty() == false) - { - pWriter->WriteAttribute(_T("r:id"), sRid); - } - pWriter->EndAttributes(); - - pWriter->EndNode( m_name ); - } + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader); + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; nullable_string id; OOX::RId rid; std::wstring m_name; + protected: - virtual void FillParentPointersForChilds(){}; + virtual void FillParentPointersForChilds(); }; } // namespace Logic } // namespace PPTX diff --git a/OOXML/Projects/Linux/PPTXFormatLib/PPTXFormatLib.pro b/OOXML/Projects/Linux/PPTXFormatLib/PPTXFormatLib.pro index 2d30a4c3d6..ac32291a88 100644 --- a/OOXML/Projects/Linux/PPTXFormatLib/PPTXFormatLib.pro +++ b/OOXML/Projects/Linux/PPTXFormatLib/PPTXFormatLib.pro @@ -54,7 +54,6 @@ SOURCES += \ ../../../PPTXFormat/Logic/Transitions/TransitionBase.cpp \ ../../../PPTXFormat/Logic/Bg.cpp \ ../../../PPTXFormat/Logic/CNvGrpSpPr.cpp \ - ../../../PPTXFormat/Logic/ContentPart.cpp \ ../../../PPTXFormat/Logic/CxnSp.cpp \ ../../../PPTXFormat/Logic/EffectDag.cpp \ ../../../PPTXFormat/Logic/EffectLst.cpp \ @@ -79,6 +78,80 @@ SOURCES += \ ../../../PPTXFormat/Logic/UniEffect.cpp \ ../../../PPTXFormat/Logic/Runs/MathParaWrapper.cpp \ ../../../PPTXFormat/Logic/Controls.cpp \ + \ + ../../../PPTXFormat/Logic/Ah.cpp \ + ../../../PPTXFormat/Logic/AhBase.cpp \ + ../../../PPTXFormat/Logic/AhPolar.cpp \ + ../../../PPTXFormat/Logic/AhXY.cpp \ + ../../../PPTXFormat/Logic/Backdrop.cpp \ + ../../../PPTXFormat/Logic/Bevel.cpp \ + ../../../PPTXFormat/Logic/BgPr.cpp \ + ../../../PPTXFormat/Logic/BodyPr.cpp \ + ../../../PPTXFormat/Logic/Camera.cpp \ + ../../../PPTXFormat/Logic/Cell3D.cpp \ + ../../../PPTXFormat/Logic/ClrMap.cpp \ + ../../../PPTXFormat/Logic/ClrMapOvr.cpp \ + ../../../PPTXFormat/Logic/CNvCxnSpPr.cpp \ + ../../../PPTXFormat/Logic/CNvGraphicFramePr.cpp \ + ../../../PPTXFormat/Logic/CNvPicPr.cpp \ + ../../../PPTXFormat/Logic/CNvPr.cpp \ + ../../../PPTXFormat/Logic/CNvSpPr.cpp \ + ../../../PPTXFormat/Logic/CSld.cpp \ + ../../../PPTXFormat/Logic/CustGeom.cpp \ + ../../../PPTXFormat/Logic/Cxn.cpp \ + ../../../PPTXFormat/Logic/DefaultShapeDefinition.cpp \ + ../../../PPTXFormat/Logic/ExtP.cpp \ + ../../../PPTXFormat/Logic/FillStyle.cpp \ + ../../../PPTXFormat/Logic/FontCollection.cpp \ + ../../../PPTXFormat/Logic/FontRef.cpp \ + ../../../PPTXFormat/Logic/Gd.cpp \ + ../../../PPTXFormat/Logic/Gs.cpp \ + ../../../PPTXFormat/Logic/Hf.cpp \ + ../../../PPTXFormat/Logic/LightRig.cpp \ + ../../../PPTXFormat/Logic/Lin.cpp \ + ../../../PPTXFormat/Logic/LineEnd.cpp \ + ../../../PPTXFormat/Logic/LineJoin.cpp \ + ../../../PPTXFormat/Logic/LineStyle.cpp \ + ../../../PPTXFormat/Logic/Ln.cpp \ + ../../../PPTXFormat/Logic/NvCxnSpPr.cpp \ + ../../../PPTXFormat/Logic/NvPicPr.cpp \ + ../../../PPTXFormat/Logic/NvPr.cpp \ + ../../../PPTXFormat/Logic/NvSpPr.cpp \ + ../../../PPTXFormat/Logic/Paragraph.cpp \ + ../../../PPTXFormat/Logic/PartTitle.cpp \ + ../../../PPTXFormat/Logic/Path.cpp \ + ../../../PPTXFormat/Logic/Path2D.cpp \ + ../../../PPTXFormat/Logic/Ph.cpp \ + ../../../PPTXFormat/Logic/PrstDash.cpp \ + ../../../PPTXFormat/Logic/PrstGeom.cpp \ + ../../../PPTXFormat/Logic/PrstTxWarp.cpp \ + ../../../PPTXFormat/Logic/Rect.cpp \ + ../../../PPTXFormat/Logic/Rot.cpp \ + ../../../PPTXFormat/Logic/RunElem.cpp \ + ../../../PPTXFormat/Logic/RunProperties.cpp \ + ../../../PPTXFormat/Logic/Scene3d.cpp \ + ../../../PPTXFormat/Logic/ShapeStyle.cpp \ + ../../../PPTXFormat/Logic/Sp3d.cpp \ + ../../../PPTXFormat/Logic/StyleRef.cpp \ + ../../../PPTXFormat/Logic/SupplementalFont.cpp \ + ../../../PPTXFormat/Logic/Tab.cpp \ + ../../../PPTXFormat/Logic/TableBgStyle.cpp \ + ../../../PPTXFormat/Logic/TablePartStyle.cpp \ + ../../../PPTXFormat/Logic/TableStyle.cpp \ + ../../../PPTXFormat/Logic/TcBdr.cpp \ + ../../../PPTXFormat/Logic/TcStyle.cpp \ + ../../../PPTXFormat/Logic/TcTxStyle.cpp \ + ../../../PPTXFormat/Logic/TextFit.cpp \ + ../../../PPTXFormat/Logic/TextFont.cpp \ + ../../../PPTXFormat/Logic/TextListStyle.cpp \ + ../../../PPTXFormat/Logic/TextParagraphPr.cpp \ + ../../../PPTXFormat/Logic/TextSpacing.cpp \ + ../../../PPTXFormat/Logic/TxStyles.cpp \ + ../../../PPTXFormat/Logic/UniMedia.cpp \ + ../../../PPTXFormat/Logic/UniPath2D.cpp \ + ../../../PPTXFormat/Logic/Xfrm.cpp \ + ../../../PPTXFormat/Logic/XmlId.cpp \ + \ ../../../PPTXFormat/Presentation.cpp \ ../../../PPTXFormat/FileContainer.cpp \ ../../../PPTXFormat/FileTypes.cpp \ @@ -508,7 +581,6 @@ HEADERS += \ ../../../PPTXFormat/Logic/CNvPicPr.h \ ../../../PPTXFormat/Logic/CNvPr.h \ ../../../PPTXFormat/Logic/CNvSpPr.h \ - ../../../PPTXFormat/Logic/ContentPart.h \ ../../../PPTXFormat/Logic/CSld.h \ ../../../PPTXFormat/Logic/CustGeom.h \ ../../../PPTXFormat/Logic/Cxn.h \ diff --git a/OOXML/Projects/Linux/PPTXFormatLib/pptx_format_logic.cpp b/OOXML/Projects/Linux/PPTXFormatLib/pptx_format_logic.cpp index 70903a4196..681b1ec55e 100644 --- a/OOXML/Projects/Linux/PPTXFormatLib/pptx_format_logic.cpp +++ b/OOXML/Projects/Linux/PPTXFormatLib/pptx_format_logic.cpp @@ -39,7 +39,6 @@ #include "../../../PPTXFormat/Logic/Transitions/TransitionBase.cpp" #include "../../../PPTXFormat/Logic/Bg.cpp" #include "../../../PPTXFormat/Logic/CNvGrpSpPr.cpp" -#include "../../../PPTXFormat/Logic/ContentPart.cpp" #include "../../../PPTXFormat/Logic/CxnSp.cpp" #include "../../../PPTXFormat/Logic/EffectDag.cpp" #include "../../../PPTXFormat/Logic/EffectLst.cpp" @@ -64,6 +63,80 @@ #include "../../../PPTXFormat/Logic/UniFill.cpp" #include "../../../PPTXFormat/Logic/Runs/MathParaWrapper.cpp" #include "../../../PPTXFormat/Logic/Controls.cpp" + +#include "../../../PPTXFormat/Logic/Ah.cpp" +#include "../../../PPTXFormat/Logic/AhBase.cpp" +#include "../../../PPTXFormat/Logic/AhPolar.cpp" +#include "../../../PPTXFormat/Logic/AhXY.cpp" +#include "../../../PPTXFormat/Logic/Backdrop.cpp" +#include "../../../PPTXFormat/Logic/Bevel.cpp" +#include "../../../PPTXFormat/Logic/BgPr.cpp" +#include "../../../PPTXFormat/Logic/BodyPr.cpp" +#include "../../../PPTXFormat/Logic/Camera.cpp" +#include "../../../PPTXFormat/Logic/Cell3D.cpp" +#include "../../../PPTXFormat/Logic/ClrMap.cpp" +#include "../../../PPTXFormat/Logic/ClrMapOvr.cpp" +#include "../../../PPTXFormat/Logic/CNvCxnSpPr.cpp" +#include "../../../PPTXFormat/Logic/CNvGraphicFramePr.cpp" +#include "../../../PPTXFormat/Logic/CNvPicPr.cpp" +#include "../../../PPTXFormat/Logic/CNvPr.cpp" +#include "../../../PPTXFormat/Logic/CNvSpPr.cpp" +#include "../../../PPTXFormat/Logic/CSld.cpp" +#include "../../../PPTXFormat/Logic/CustGeom.cpp" +#include "../../../PPTXFormat/Logic/Cxn.cpp" +#include "../../../PPTXFormat/Logic/DefaultShapeDefinition.cpp" +#include "../../../PPTXFormat/Logic/ExtP.cpp" +#include "../../../PPTXFormat/Logic/FillStyle.cpp" +#include "../../../PPTXFormat/Logic/FontCollection.cpp" +#include "../../../PPTXFormat/Logic/FontRef.cpp" +#include "../../../PPTXFormat/Logic/Gd.cpp" +#include "../../../PPTXFormat/Logic/Gs.cpp" +#include "../../../PPTXFormat/Logic/Hf.cpp" +#include "../../../PPTXFormat/Logic/LightRig.cpp" +#include "../../../PPTXFormat/Logic/Lin.cpp" +#include "../../../PPTXFormat/Logic/LineEnd.cpp" +#include "../../../PPTXFormat/Logic/LineJoin.cpp" +#include "../../../PPTXFormat/Logic/LineStyle.cpp" +#include "../../../PPTXFormat/Logic/Ln.cpp" +#include "../../../PPTXFormat/Logic/NvCxnSpPr.cpp" +#include "../../../PPTXFormat/Logic/NvPicPr.cpp" +#include "../../../PPTXFormat/Logic/NvPr.cpp" +#include "../../../PPTXFormat/Logic/NvSpPr.cpp" +#include "../../../PPTXFormat/Logic/Paragraph.cpp" +#include "../../../PPTXFormat/Logic/PartTitle.cpp" +#include "../../../PPTXFormat/Logic/Path.cpp" +#include "../../../PPTXFormat/Logic/Path2D.cpp" +#include "../../../PPTXFormat/Logic/Ph.cpp" +#include "../../../PPTXFormat/Logic/PrstDash.cpp" +#include "../../../PPTXFormat/Logic/PrstGeom.cpp" +#include "../../../PPTXFormat/Logic/PrstTxWarp.cpp" +#include "../../../PPTXFormat/Logic/Rect.cpp" +#include "../../../PPTXFormat/Logic/Rot.cpp" +#include "../../../PPTXFormat/Logic/RunElem.cpp" +#include "../../../PPTXFormat/Logic/RunProperties.cpp" +#include "../../../PPTXFormat/Logic/Scene3d.cpp" +#include "../../../PPTXFormat/Logic/ShapeStyle.cpp" +#include "../../../PPTXFormat/Logic/Sp3d.cpp" +#include "../../../PPTXFormat/Logic/StyleRef.cpp" +#include "../../../PPTXFormat/Logic/SupplementalFont.cpp" +#include "../../../PPTXFormat/Logic/Tab.cpp" +#include "../../../PPTXFormat/Logic/TableBgStyle.cpp" +#include "../../../PPTXFormat/Logic/TablePartStyle.cpp" +#include "../../../PPTXFormat/Logic/TableStyle.cpp" +#include "../../../PPTXFormat/Logic/TcBdr.cpp" +#include "../../../PPTXFormat/Logic/TcStyle.cpp" +#include "../../../PPTXFormat/Logic/TcTxStyle.cpp" +#include "../../../PPTXFormat/Logic/TextFit.cpp" +#include "../../../PPTXFormat/Logic/TextFont.cpp" +#include "../../../PPTXFormat/Logic/TextListStyle.cpp" +#include "../../../PPTXFormat/Logic/TextParagraphPr.cpp" +#include "../../../PPTXFormat/Logic/TextSpacing.cpp" +#include "../../../PPTXFormat/Logic/TxStyles.cpp" +#include "../../../PPTXFormat/Logic/UniMedia.cpp" +#include "../../../PPTXFormat/Logic/UniPath2D.cpp" +#include "../../../PPTXFormat/Logic/Xfrm.cpp" +#include "../../../PPTXFormat/Logic/XmlId.cpp" + #include "../../../PPTXFormat/Presentation.cpp" #include "../../../PPTXFormat/FileContainer.cpp" #include "../../../PPTXFormat/FileTypes.cpp"