/* * Copyright (C) Ascensio System SIA, 2009-2026 * * 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, together with the * additional terms provided in the LICENSE file. * * 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: https://www.gnu.org/licenses/agpl-3.0.html * * You can contact Ascensio System SIA by email at info@onlyoffice.com * or by postal mail at 20A-6 Ernesta Birznieka-Upisha Street, Riga, * LV-1050, Latvia, European Union. * * The interactive user interfaces in modified versions of the Program * are required to display Appropriate Legal Notices in accordance with * Section 5 of the GNU AGPL version 3. * * No trademark rights are granted under this License. * * All non-code elements of the Product, including illustrations, * icon sets, and technical writing content, are licensed under the * Creative Commons Attribution-ShareAlike 4.0 International License: * https://creativecommons.org/licenses/by-sa/4.0/legalcode * * This license applies only to such non-code elements and does not * modify or replace the licensing terms applicable to the Program's * source code, which remains licensed under the GNU Affero General * Public License v3. * * SPDX-License-Identifier: AGPL-3.0-only */ #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