Files
core/OOXML/PPTXFormat/Logic/AhPolar.cpp
Alexander Trofimov 76ee07f61c [copyright] Update copyright header
Co-authored-by: Alexander Trofimov <alexander.trofimov@onlyoffice.com>
Co-committed-by: Alexander Trofimov <alexander.trofimov@onlyoffice.com>
2026-05-14 08:23:56 +00:00

173 lines
5.8 KiB
C++

/*
* 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 "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