Files
core/OOXML/PPTXFormat/ShowPr/PresentationPr.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

300 lines
8.3 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 "PresentationPr.h"
#include "./Browse.h"
#include "./CustomShowId.h"
#include "./Kiosk.h"
#include "./Present.h"
#include "./SldAll.h"
#include "./SldRg.h"
namespace PPTX
{
namespace nsPresentation
{
void ShowPr::fromXML(XmlUtils::CXmlNode& node)
{
XmlMacroReadAttributeBase(node, L"loop", loop);
XmlMacroReadAttributeBase(node, L"showAnimation", showAnimation);
XmlMacroReadAttributeBase(node, L"showNarration", showNarration);
XmlMacroReadAttributeBase(node, L"useTimings", useTimings);
Browse = node.ReadNodeNoNS(L"browse");
CustomShowId = node.ReadNodeNoNS(L"custShow");
Kiosk = node.ReadNodeNoNS(L"kiosk");
XmlUtils::CXmlNode node1 = node.ReadNodeNoNS(L"penClr");
PenClr.GetColorFrom(node1);
Present = node.ReadNodeNoNS(L"present");
SldAll = node.ReadNodeNoNS(L"sldAll");
SldRg = node.ReadNodeNoNS(L"sldRg");
}
std::wstring ShowPr::toXML() const
{
XmlUtils::CAttribute oAttr;
oAttr.Write(L"loop", loop);
oAttr.Write(L"showAnimation", showAnimation);
oAttr.Write(L"showNarration", showNarration);
oAttr.Write(L"useTimings", useTimings);
XmlUtils::CNodeValue oValue;
oValue.WriteNullable(Present);
oValue.WriteNullable(Browse);
oValue.WriteNullable(Kiosk);
oValue.WriteNullable(SldAll);
oValue.WriteNullable(SldRg);
oValue.WriteNullable(CustomShowId);
oValue.Write(PenClr);
return XmlUtils::CreateNode(L"p:ShowPr", oAttr, oValue);
}
void ShowPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteBool2(0, loop);
pWriter->WriteBool2(1, showAnimation);
pWriter->WriteBool2(2, showNarration);
pWriter->WriteBool2(3, useTimings);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
pWriter->WriteRecord2(0, Browse);
pWriter->WriteRecord2(1, CustomShowId);
pWriter->WriteRecord2(2, Kiosk);
pWriter->WriteRecord1(3, PenClr);
pWriter->WriteRecord2(4, Present);
pWriter->WriteRecord2(5, SldAll);
pWriter->WriteRecord2(6, SldRg);
}
void ShowPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(L"p:showPr");
pWriter->StartAttributes();
pWriter->WriteAttribute(L"loop", loop);
pWriter->WriteAttribute(L"showAnimation", showAnimation);
pWriter->WriteAttribute(L"showNarration", showNarration);
pWriter->WriteAttribute(L"useTimings", useTimings);
pWriter->EndAttributes();
pWriter->Write(Present);
pWriter->Write(Browse);
pWriter->Write(Kiosk);
pWriter->Write(SldAll);
pWriter->Write(SldRg);
pWriter->Write(CustomShowId);
if(PenClr.is_init())
{
pWriter->WriteString(L"<p:penClr>");
PenClr.toXmlWriter(pWriter);
pWriter->WriteString(L"</p:penClr>");
}
pWriter->EndNode(L"p:showPr");
}
void ShowPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(1); // start attributes
while (true)
{
BYTE _at = pReader->GetUChar_TypeNode();
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
break;
if (0 == _at)
loop = pReader->GetBool();
else if (1 == _at)
showAnimation = pReader->GetBool();
else if (2 == _at)
showNarration = pReader->GetBool();
else if (3 == _at)
useTimings = pReader->GetBool();
else
break;
}
while (pReader->GetPos() < _end_rec)
{
BYTE _at = pReader->GetUChar();
switch (_at)
{
case 0:
{
Browse = new nsPresentation::Browse();
Browse->fromPPTY(pReader);
break;
}
case 1:
{
CustomShowId = new nsPresentation::CustomShowId();
CustomShowId->fromPPTY(pReader);
break;
}
case 2:
{
Kiosk = new nsPresentation::Kiosk();
Kiosk->fromPPTY(pReader);
break;
}
case 3:
{
PenClr.fromPPTY(pReader);
break;
}
case 4:
{
Present = new nsPresentation::Present();
pReader->SkipRecord();
break;
}
case 5:
{
SldAll = new nsPresentation::SldAll();
pReader->SkipRecord();
break;
}
case 6:
{
SldRg = new nsPresentation::SldRg();
SldRg->fromPPTY(pReader);
break;
}
default:
break;
}
}
pReader->Seek(_end_rec);
}
void ShowPr::FillParentPointersForChilds()
{
}
//--------------------------------------------------------------------------------------------------------
void PrintPr::fromXML(XmlUtils::CXmlNode& node)
{
XmlMacroReadAttributeBase(node, L"clrMode", clrMode);
XmlMacroReadAttributeBase(node, L"prnWhat", prnWhat);
XmlMacroReadAttributeBase(node, L"frameSlides", frameSlides);
XmlMacroReadAttributeBase(node, L"hiddenSlides", hiddenSlides);
XmlMacroReadAttributeBase(node, L"scaleToFitPaper", scaleToFitPaper);
XmlUtils::CXmlNode list = node.ReadNodeNoNS(L"extLst");
if (list.IsValid())
{
std::vector<XmlUtils::CXmlNode> oNodes;
if (list.GetNodes(L"*", oNodes))
{
size_t nCount = oNodes.size();
for (size_t i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode& oNode = oNodes[i];
Logic::Ext element;
element.fromXML(oNode);
ExtLst.push_back(element);
}
}
}
}
std::wstring PrintPr::toXML() const
{
XmlUtils::CAttribute oAttr;
oAttr.Write(L"frameSlides", frameSlides);
oAttr.Write(L"hiddenSlides", hiddenSlides);
oAttr.Write(L"scaleToFitPaper", scaleToFitPaper);
oAttr.WriteLimitNullable(L"clrMode", clrMode);
oAttr.WriteLimitNullable(L"prnWhat", prnWhat);
XmlUtils::CNodeValue oValue;
return XmlUtils::CreateNode(L"p:PrintPr", oAttr, oValue);
}
void PrintPr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteBool2(0, frameSlides);
pWriter->WriteBool2(1, hiddenSlides);
pWriter->WriteBool2(2, scaleToFitPaper);
pWriter->WriteLimit2(3, clrMode);
pWriter->WriteLimit2(4, prnWhat);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
}
void PrintPr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->WriteString(toXML());
}
void PrintPr::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(1); // start attributes
while (true)
{
BYTE _at = pReader->GetUChar_TypeNode();
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
break;
switch (_at)
{
case 0:
frameSlides = pReader->GetBool(); break;
case 1:
hiddenSlides = pReader->GetBool(); break;
case 2:
scaleToFitPaper = pReader->GetBool(); break;
case 3:
clrMode = pReader->GetUChar(); break;
case 4:
prnWhat = pReader->GetUChar(); break;
default:
break;
}
}
pReader->Seek(_end_rec);
}
void PrintPr::FillParentPointersForChilds()
{
}
} // namespace nsPresentation
} // namespace PPTX