Files
core/HwpFile/HwpDoc/Paragraph/CtrlShapeOle.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

139 lines
4.0 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 "CtrlShapeOle.h"
namespace HWP
{
CCtrlShapeOle::CCtrlShapeOle()
{}
CCtrlShapeOle::CCtrlShapeOle(const HWP_STRING& sCtrlID)
: CCtrlGeneralShape(sCtrlID)
{}
CCtrlShapeOle::CCtrlShapeOle(const CCtrlGeneralShape& oShape)
: CCtrlGeneralShape(oShape)
{}
CCtrlShapeOle::CCtrlShapeOle(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
: CCtrlGeneralShape(sCtrlID, nSize, oBuffer, nOff, nVersion)
{}
CCtrlShapeOle::CCtrlShapeOle(const HWP_STRING& sCtrlID, CXMLReader& oReader, EHanType eType)
: CCtrlGeneralShape(sCtrlID, oReader, eType)
{
switch(eType)
{
case EHanType::HWPX: ReadFromHWPX (oReader); return;
case EHanType::HWPML: ReadFromHWPML(oReader); return;
default: break;
}
}
void CCtrlShapeOle::ReadFromHWPX(CXMLReader &oReader)
{
m_sBinDataID = oReader.GetAttribute("binaryItemIDRef");
WHILE_READ_NEXT_NODE(oReader)
{
if ("hc:extent" == oReader.GetName())
{
START_READ_ATTRIBUTES(oReader)
{
if ("x" == sAttributeName)
m_nExtentX = oReader.GetInt();
else if ("y" == sAttributeName)
m_nExtentY = oReader.GetInt();
}
END_READ_ATTRIBUTES(oReader)
}
else
CCtrlGeneralShape::ParseChildren(oReader, EHanType::HWPX);
}
END_WHILE
}
void CCtrlShapeOle::ReadFromHWPML(CXMLReader &oReader)
{
START_READ_ATTRIBUTES(oReader)
{
if ("ExtentX" == sAttributeName)
m_nExtentX = oReader.GetInt();
else if ("ExtentY" == sAttributeName)
m_nExtentY = oReader.GetInt();
else if ("BinItem" == sAttributeName)
m_sBinDataID = oReader.GetText();
}
END_READ_ATTRIBUTES(oReader)
WHILE_READ_NEXT_NODE(oReader)
CCtrlGeneralShape::ParseChildren(oReader, EHanType::HWPML);
END_WHILE
}
EShapeType CCtrlShapeOle::GetShapeType() const
{
return EShapeType::Ole;
}
HWP_STRING CCtrlShapeOle::GetBinDataID() const
{
return m_sBinDataID;
}
int CCtrlShapeOle::ParseElement(CCtrlShapeOle& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
{
oBuffer.SavePosition();
oBuffer.ReadInt(oObj.m_nAttr);
oBuffer.ReadInt(oObj.m_nExtentX);
oBuffer.ReadInt(oObj.m_nExtentY);
oObj.m_sBinDataID = std::to_wstring(oBuffer.ReadShort());
oBuffer.ReadColor(oObj.m_nBorderColor);
oBuffer.ReadInt(oObj.m_nBorderThick);
oBuffer.ReadInt(oObj.m_nBorderAttr);
oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos(true));
return nSize;
}
int CCtrlShapeOle::ParseCtrl(CCtrlShapeOle& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
{
return CCtrlObjElement::ParseCtrl(oObj, nSize, oBuffer, nOff, nVersion);
}
}