mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Improved rendering of text in OFD format and refactoring
This commit is contained in:
@ -52,6 +52,7 @@ HEADERS += \
|
||||
src/Types/Font.h \
|
||||
src/Types/MultiMedia.h \
|
||||
src/Types/PageArea.h \
|
||||
src/Types/Signature.h \
|
||||
src/Types/TemplatePage.h \
|
||||
src/Utils/Types.h \
|
||||
src/Utils/Utils.h \
|
||||
@ -79,6 +80,7 @@ SOURCES += \
|
||||
src/Types/Font.cpp \
|
||||
src/Types/MultiMedia.cpp \
|
||||
src/Types/PageArea.cpp \
|
||||
src/Types/Signature.cpp \
|
||||
src/Types/TemplatePage.cpp \
|
||||
src/Utils/Types.cpp \
|
||||
src/Utils/XmlReader.cpp
|
||||
|
||||
@ -1,14 +1,15 @@
|
||||
#include "Base.h"
|
||||
#include "Utils/Utils.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
#define IF_CHECK_NODE(node_name, varible_name)\
|
||||
if (node_name == wsNodeName)\
|
||||
if (node_name == sNodeName)\
|
||||
varible_name = oLiteReader.GetText2()
|
||||
|
||||
#define ELSE_IF_CHECK_NODE(node_name, varible_name)\
|
||||
else if (node_name == wsNodeName)\
|
||||
varible_name = oLiteReader.GetText2()
|
||||
else if (node_name == sNodeName)\
|
||||
varible_name = oLiteReader.GetText2()
|
||||
|
||||
EDocUsege GetDocUsage(const std::wstring& wsValue)
|
||||
{
|
||||
@ -33,32 +34,67 @@ bool CDocInfo::Read(CXmlReader& oLiteReader)
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
|
||||
std::wstring wsNodeName;
|
||||
std::string sNodeName;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
wsNodeName = oLiteReader.GetName();
|
||||
sNodeName = oLiteReader.GetNameA();
|
||||
|
||||
IF_CHECK_NODE(L"ofd:DocID", m_wsDocId);
|
||||
ELSE_IF_CHECK_NODE(L"ofd:Title", m_wsTitle);
|
||||
ELSE_IF_CHECK_NODE(L"ofd:Author", m_wsAuthor);
|
||||
ELSE_IF_CHECK_NODE(L"ofd:Subject", m_wsSubject);
|
||||
ELSE_IF_CHECK_NODE(L"ofd:Abstruct", m_wsAbstact);
|
||||
ELSE_IF_CHECK_NODE(L"ofd:CreationDate", m_wsCreationDate);
|
||||
ELSE_IF_CHECK_NODE(L"ofd:ModDate", m_wsModDate);
|
||||
ELSE_IF_CHECK_NODE(L"ofd:Cover", m_wsCover);
|
||||
ELSE_IF_CHECK_NODE(L"ofd:Creator", m_wsCreator);
|
||||
ELSE_IF_CHECK_NODE(L"ofd:CreatorVersion", m_wsCreatorVersion);
|
||||
else if (L"ofd:DocUsage" == wsNodeName)
|
||||
IF_CHECK_NODE("ofd:DocID", m_wsDocId);
|
||||
ELSE_IF_CHECK_NODE("ofd:Title", m_wsTitle);
|
||||
ELSE_IF_CHECK_NODE("ofd:Author", m_wsAuthor);
|
||||
ELSE_IF_CHECK_NODE("ofd:Subject", m_wsSubject);
|
||||
ELSE_IF_CHECK_NODE("ofd:Abstruct", m_wsAbstact);
|
||||
ELSE_IF_CHECK_NODE("ofd:CreationDate", m_wsCreationDate);
|
||||
ELSE_IF_CHECK_NODE("ofd:ModDate", m_wsModDate);
|
||||
ELSE_IF_CHECK_NODE("ofd:Cover", m_wsCover);
|
||||
ELSE_IF_CHECK_NODE("ofd:Creator", m_wsCreator);
|
||||
ELSE_IF_CHECK_NODE("ofd:CreatorVersion", m_wsCreatorVersion);
|
||||
else if ("ofd:DocUsage" == sNodeName)
|
||||
m_eDocUsage = GetDocUsage(oLiteReader.GetText2());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CDocBody::CDocBody()
|
||||
void CDocBody::ReadSignatures(const std::wstring& wsFilePath, const std::wstring& wsRootPath)
|
||||
{
|
||||
CXmlReader oLiteReader;
|
||||
if (!oLiteReader.FromFile(CombinePaths(wsRootPath, wsFilePath)) || !oLiteReader.ReadNextNode() || L"ofd:Signatures" != oLiteReader.GetName())
|
||||
return;
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::string sNodeName;
|
||||
unsigned int unMaxSignId = 0;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
sNodeName = oLiteReader.GetNameA();
|
||||
|
||||
if ("ofd:MaxSignId" == sNodeName)
|
||||
unMaxSignId = oLiteReader.GetUInteger();
|
||||
else if ("ofd:Signature" == sNodeName)
|
||||
{
|
||||
if (0 == oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
||||
continue;
|
||||
|
||||
do
|
||||
{
|
||||
if ("BaseLoc" == oLiteReader.GetNameA())
|
||||
AddToContainer(CSignature::Read(oLiteReader.GetText(), wsRootPath), m_arSignatures);
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CDocBody::CDocBody()
|
||||
{}
|
||||
|
||||
CDocBody::~CDocBody()
|
||||
{
|
||||
ClearContainer(m_arSignatures);
|
||||
}
|
||||
|
||||
CDocBody* CDocBody::Read(CXmlReader& oLiteReader, IFolder* pFolder)
|
||||
@ -67,7 +103,7 @@ CDocBody* CDocBody::Read(CXmlReader& oLiteReader, IFolder* pFolder)
|
||||
return nullptr;
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::wstring wsNodeName;
|
||||
std::string sNodeName;
|
||||
|
||||
CDocBody *pDocBody = new CDocBody();
|
||||
|
||||
@ -76,9 +112,9 @@ CDocBody* CDocBody::Read(CXmlReader& oLiteReader, IFolder* pFolder)
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
wsNodeName = oLiteReader.GetName();
|
||||
sNodeName = oLiteReader.GetNameA();
|
||||
|
||||
if (L"ofd:DocInfo" == wsNodeName)
|
||||
if ("ofd:DocInfo" == sNodeName)
|
||||
{
|
||||
if (!pDocBody->m_oDocInfo.Read(oLiteReader))
|
||||
{
|
||||
@ -86,14 +122,15 @@ CDocBody* CDocBody::Read(CXmlReader& oLiteReader, IFolder* pFolder)
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else if (L"ofd:DocRoot" == wsNodeName)
|
||||
else if ("ofd:DocRoot" == sNodeName)
|
||||
{
|
||||
const std::wstring wsPath = NSSystemPath::ShortenPath(oLiteReader.GetText2());
|
||||
|
||||
if (!wsPath.empty() && L'.' != wsPath.front())
|
||||
pDocBody->m_oDocument.Read(pFolder->getFullFilePath(wsPath));
|
||||
}
|
||||
ELSE_IF_CHECK_NODE(L"ofd:Signatures", pDocBody->m_wsSignature);
|
||||
else if ("ofd:Signatures" == sNodeName)
|
||||
pDocBody->ReadSignatures(oLiteReader.GetText2(), pFolder->getFullFilePath(L""));
|
||||
}
|
||||
|
||||
return pDocBody;
|
||||
@ -101,7 +138,13 @@ CDocBody* CDocBody::Read(CXmlReader& oLiteReader, IFolder* pFolder)
|
||||
|
||||
bool CDocBody::DrawPage(IRenderer* pRenderer, int nPageIndex) const
|
||||
{
|
||||
return m_oDocument.DrawPage(pRenderer, nPageIndex);
|
||||
const bool bResult = m_oDocument.DrawPage(pRenderer, nPageIndex);
|
||||
|
||||
for (const CSignature* pSignature : m_arSignatures)
|
||||
if (pSignature->Draw(pRenderer, nPageIndex, nullptr))
|
||||
break;
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
unsigned int CDocBody::GetPageCount() const
|
||||
|
||||
@ -2,10 +2,10 @@
|
||||
#define BASE_H
|
||||
|
||||
#include "../../DesktopEditor/graphics/IRenderer.h"
|
||||
#include "../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
#include "../../OfficeUtils/src/ZipFolder.h"
|
||||
|
||||
#include "Document.h"
|
||||
#include "Types/Signature.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
@ -47,9 +47,13 @@ class CDocBody
|
||||
CDocument m_oDocument;
|
||||
// std::wstring m_wsPathToDocRoot;
|
||||
// std::wstring m_wsVersions;
|
||||
std::wstring m_wsSignature;
|
||||
std::vector<CSignature*> m_arSignatures;
|
||||
|
||||
void ReadSignatures(const std::wstring& wsFilePath, const std::wstring& wsRootPath);
|
||||
public:
|
||||
CDocBody();
|
||||
~CDocBody();
|
||||
|
||||
static CDocBody* Read(CXmlReader& oLiteReader, IFolder* pFolder);
|
||||
|
||||
bool DrawPage(IRenderer* pRenderer, int nPageIndex) const;
|
||||
|
||||
@ -62,12 +62,17 @@ CGraphicUnit::CGraphicUnit(CXmlReader& oLiteReader)
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
void CGraphicUnit::Apply(IRenderer* pRenderer) const
|
||||
void CGraphicUnit::Apply(IRenderer* pRenderer, TMatrix& oOldTransform) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
pRenderer->ResetTransform();
|
||||
pRenderer->GetTransform(&oOldTransform.m_dM11, &oOldTransform.m_dM12, &oOldTransform.m_dM21, &oOldTransform.m_dM22, &oOldTransform.m_dDx, &oOldTransform.m_dDy);
|
||||
|
||||
Aggplus::CMatrix oTransform(oOldTransform.m_dM11, oOldTransform.m_dM12, oOldTransform.m_dM21, oOldTransform.m_dM22, oOldTransform.m_dDx, oOldTransform.m_dDy);
|
||||
const Aggplus::CMatrix oCurrentTransform(m_oCTM.m_dM11, m_oCTM.m_dM12, m_oCTM.m_dM21, m_oCTM.m_dM22, m_oBoundary.m_dX + m_oCTM.m_dDx, m_oBoundary.m_dY + m_oCTM.m_dDy);
|
||||
|
||||
oTransform.Multiply(&oCurrentTransform);
|
||||
|
||||
// Clipping
|
||||
// pRenderer->put_ClipMode(c_nClipRegionTypeWinding | c_nClipRegionIntersect);
|
||||
@ -86,7 +91,7 @@ void CGraphicUnit::Apply(IRenderer* pRenderer) const
|
||||
// pRenderer->EndCommand(c_nClipType);
|
||||
// pRenderer->PathCommandEnd();
|
||||
|
||||
pRenderer->SetTransform(m_oCTM.m_dM11, m_oCTM.m_dM12, m_oCTM.m_dM21, m_oCTM.m_dM22, m_oBoundary.m_dX + m_oCTM.m_dDx, m_oBoundary.m_dY + m_oCTM.m_dDy);
|
||||
pRenderer->SetTransform(oTransform.sx(), oTransform.shy(), oTransform.shx(), oTransform.sy(), oTransform.tx(), oTransform.ty());
|
||||
}
|
||||
|
||||
TBox CGraphicUnit::GetBoundary() const
|
||||
|
||||
@ -42,7 +42,7 @@ class CGraphicUnit
|
||||
public:
|
||||
CGraphicUnit(CXmlReader& oLiteReader);
|
||||
|
||||
void Apply(IRenderer* pRenderer) const;
|
||||
void Apply(IRenderer* pRenderer, TMatrix& oOldTransform) const;
|
||||
|
||||
TBox GetBoundary() const;
|
||||
};
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
#include "ImageObject.h"
|
||||
|
||||
#include "../../../DesktopEditor/graphics/Image.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CImageObject::CImageObject(CXmlReader& oLiteReader)
|
||||
@ -36,7 +34,8 @@ void CImageObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) co
|
||||
if (nullptr == pMultiMedia)
|
||||
return;
|
||||
|
||||
CGraphicUnit::Apply(pRenderer);
|
||||
TMatrix oOldTransform;
|
||||
CGraphicUnit::Apply(pRenderer, oOldTransform);
|
||||
|
||||
const std::wstring wsFilePath = pMultiMedia->GetFilePath();
|
||||
|
||||
@ -44,5 +43,7 @@ void CImageObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) co
|
||||
return;
|
||||
|
||||
pRenderer->DrawImageFromFile(wsFilePath, 0, 0, 1, 1);
|
||||
|
||||
pRenderer->SetTransform(oOldTransform.m_dM11, oOldTransform.m_dM12, oOldTransform.m_dM21, oOldTransform.m_dM22, oOldTransform.m_dDx, oOldTransform.m_dDy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,54 +60,56 @@ CPathObject::CPathObject(CXmlReader& oLiteReader)
|
||||
{
|
||||
std::vector<std::string> arValues{Split(oLiteReader.GetText2A(), ' ')};
|
||||
|
||||
std::vector<std::string>::const_iterator itElement = arValues.cbegin();
|
||||
|
||||
char chElementName;
|
||||
|
||||
while (!arValues.empty())
|
||||
while (arValues.cend() != itElement)
|
||||
{
|
||||
if (arValues.front().length() != 1)
|
||||
{
|
||||
arValues.erase(arValues.begin());
|
||||
++itElement;
|
||||
continue;
|
||||
}
|
||||
|
||||
chElementName = arValues[0][0];
|
||||
arValues.erase(arValues.begin());
|
||||
chElementName = (*itElement)[0];
|
||||
++itElement;
|
||||
|
||||
switch (chElementName)
|
||||
{
|
||||
case 'S':
|
||||
{
|
||||
AddElement(CStartElement::ReadFromArray(arValues));
|
||||
AddElement(CStartElement::ReadFromArray(itElement, arValues.cend()));
|
||||
break;
|
||||
}
|
||||
case 'M':
|
||||
{
|
||||
AddElement(CMoveElement::ReadFromArray(arValues));
|
||||
AddElement(CMoveElement::ReadFromArray(itElement, arValues.cend()));
|
||||
break;
|
||||
}
|
||||
case 'L':
|
||||
{
|
||||
AddElement(CLineElement::ReadFromArray(arValues));
|
||||
AddElement(CLineElement::ReadFromArray(itElement, arValues.cend()));
|
||||
break;
|
||||
}
|
||||
case 'Q':
|
||||
{
|
||||
AddElement(CBezierCurve2Element::ReadFromArray(arValues));
|
||||
AddElement(CBezierCurve2Element::ReadFromArray(itElement, arValues.cend()));
|
||||
break;
|
||||
}
|
||||
case 'B':
|
||||
{
|
||||
AddElement(CBezierCurveElement::ReadFromArray(arValues));
|
||||
AddElement(CBezierCurveElement::ReadFromArray(itElement, arValues.cend()));
|
||||
break;
|
||||
}
|
||||
case 'A':
|
||||
{
|
||||
AddElement(CArcElement::ReadFromArray(arValues));
|
||||
AddElement(CArcElement::ReadFromArray(itElement, arValues.cend()));
|
||||
break;
|
||||
}
|
||||
case 'C':
|
||||
{
|
||||
AddElement(CCloseElement::ReadFromArray(arValues));
|
||||
AddElement(new CCloseElement());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -135,7 +137,8 @@ void CPathObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) con
|
||||
if (nullptr == pRenderer || m_arElements.empty())
|
||||
return;
|
||||
|
||||
CGraphicUnit::Apply(pRenderer);
|
||||
TMatrix oOldTransform;
|
||||
CGraphicUnit::Apply(pRenderer, oOldTransform);
|
||||
|
||||
pRenderer->BeginCommand(c_nPathType);
|
||||
pRenderer->PathCommandStart();
|
||||
@ -207,14 +210,16 @@ void CPathObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) con
|
||||
|
||||
pRenderer->PathCommandEnd();
|
||||
pRenderer->EndCommand(c_nPathType);
|
||||
|
||||
pRenderer->SetTransform(oOldTransform.m_dM11, oOldTransform.m_dM12, oOldTransform.m_dM21, oOldTransform.m_dM22, oOldTransform.m_dDx, oOldTransform.m_dDy);
|
||||
}
|
||||
|
||||
CStartElement::CStartElement()
|
||||
{}
|
||||
|
||||
IPathElement* CStartElement::ReadFromArray(std::vector<std::string>& arValues)
|
||||
IPathElement* CStartElement::ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd)
|
||||
{
|
||||
if (arValues.size() < 2)
|
||||
if (itEnd - itBegin < 2)
|
||||
return nullptr;
|
||||
|
||||
CStartElement *pElement = new CStartElement();
|
||||
@ -222,12 +227,10 @@ IPathElement* CStartElement::ReadFromArray(std::vector<std::string>& arValues)
|
||||
if (nullptr == pElement)
|
||||
return nullptr;
|
||||
|
||||
if (StringToDouble(arValues[0], pElement->m_dX) && StringToDouble(arValues[1], pElement->m_dY))
|
||||
if (StringToDouble(*itBegin++, pElement->m_dX) && StringToDouble(*itBegin++, pElement->m_dY))
|
||||
return pElement;
|
||||
|
||||
if (nullptr != pElement)
|
||||
delete pElement;
|
||||
|
||||
delete pElement;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -240,9 +243,9 @@ void CStartElement::Draw(IRenderer* pRenderer) const
|
||||
CMoveElement::CMoveElement()
|
||||
{}
|
||||
|
||||
IPathElement* CMoveElement::ReadFromArray(std::vector<std::string>& arValues)
|
||||
IPathElement* CMoveElement::ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd)
|
||||
{
|
||||
if (arValues.size() < 2)
|
||||
if (itEnd - itBegin < 2)
|
||||
return nullptr;
|
||||
|
||||
CMoveElement *pElement = new CMoveElement();
|
||||
@ -250,8 +253,7 @@ IPathElement* CMoveElement::ReadFromArray(std::vector<std::string>& arValues)
|
||||
if (nullptr == pElement)
|
||||
return nullptr;
|
||||
|
||||
|
||||
if (StringToDouble(arValues[0], pElement->m_dX) && StringToDouble(arValues[1], pElement->m_dY))
|
||||
if (StringToDouble(*itBegin++, pElement->m_dX) && StringToDouble(*itBegin++, pElement->m_dY))
|
||||
return pElement;
|
||||
|
||||
delete pElement;
|
||||
@ -267,9 +269,9 @@ void CMoveElement::Draw(IRenderer* pRenderer) const
|
||||
CLineElement::CLineElement()
|
||||
{}
|
||||
|
||||
IPathElement* CLineElement::ReadFromArray(std::vector<std::string>& arValues)
|
||||
IPathElement* CLineElement::ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd)
|
||||
{
|
||||
if (arValues.size() < 2)
|
||||
if (itEnd - itBegin < 2)
|
||||
return nullptr;
|
||||
|
||||
CLineElement *pElement = new CLineElement();
|
||||
@ -277,7 +279,7 @@ IPathElement* CLineElement::ReadFromArray(std::vector<std::string>& arValues)
|
||||
if (nullptr == pElement)
|
||||
return nullptr;
|
||||
|
||||
if (StringToDouble(arValues[0], pElement->m_dX) && StringToDouble(arValues[1], pElement->m_dY))
|
||||
if (StringToDouble(*itBegin++, pElement->m_dX) && StringToDouble(*itBegin++, pElement->m_dY))
|
||||
return pElement;
|
||||
|
||||
delete pElement;
|
||||
@ -293,9 +295,9 @@ void CLineElement::Draw(IRenderer* pRenderer) const
|
||||
CBezierCurve2Element::CBezierCurve2Element()
|
||||
{}
|
||||
|
||||
IPathElement* CBezierCurve2Element::ReadFromArray(std::vector<std::string>& arValues)
|
||||
IPathElement* CBezierCurve2Element::ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd)
|
||||
{
|
||||
if (arValues.size() < 4)
|
||||
if (itEnd - itBegin < 4)
|
||||
return nullptr;
|
||||
|
||||
CBezierCurve2Element *pElement = new CBezierCurve2Element();
|
||||
@ -303,8 +305,8 @@ IPathElement* CBezierCurve2Element::ReadFromArray(std::vector<std::string>& arVa
|
||||
if (nullptr == pElement)
|
||||
return nullptr;
|
||||
|
||||
if (StringToDouble(arValues[0], pElement->m_dX1) && StringToDouble(arValues[1], pElement->m_dY1) &&
|
||||
StringToDouble(arValues[2], pElement->m_dX2) && StringToDouble(arValues[3], pElement->m_dY2))
|
||||
if (StringToDouble(*itBegin++, pElement->m_dX1) && StringToDouble(*itBegin++, pElement->m_dY1) &&
|
||||
StringToDouble(*itBegin++, pElement->m_dX2) && StringToDouble(*itBegin++, pElement->m_dY2))
|
||||
return pElement;
|
||||
|
||||
delete pElement;
|
||||
@ -313,16 +315,20 @@ IPathElement* CBezierCurve2Element::ReadFromArray(std::vector<std::string>& arVa
|
||||
|
||||
void CBezierCurve2Element::Draw(IRenderer* pRenderer) const
|
||||
{
|
||||
// if (nullptr != pRenderer)
|
||||
// pRenderer->PathCommandCurveTo()
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
double dX = 0, dY = 0;
|
||||
pRenderer->PathCommandGetCurrentPoint(&dX, &dY);
|
||||
pRenderer->PathCommandCurveTo(dX, dY, m_dX1, m_dY1, m_dX2, m_dY2);
|
||||
}
|
||||
|
||||
CBezierCurveElement::CBezierCurveElement()
|
||||
{}
|
||||
|
||||
IPathElement* CBezierCurveElement::ReadFromArray(std::vector<std::string>& arValues)
|
||||
IPathElement* CBezierCurveElement::ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd)
|
||||
{
|
||||
if (arValues.size() < 4)
|
||||
if (itEnd - itBegin < 6)
|
||||
return nullptr;
|
||||
|
||||
CBezierCurveElement *pElement = new CBezierCurveElement();
|
||||
@ -330,8 +336,9 @@ IPathElement* CBezierCurveElement::ReadFromArray(std::vector<std::string>& arVal
|
||||
if (nullptr == pElement)
|
||||
return nullptr;
|
||||
|
||||
if (StringToDouble(arValues[0], pElement->m_dX1) && StringToDouble(arValues[1], pElement->m_dY1) &&
|
||||
StringToDouble(arValues[2], pElement->m_dX2) && StringToDouble(arValues[3], pElement->m_dY2))
|
||||
if (StringToDouble(*itBegin++, pElement->m_dX1) && StringToDouble(*itBegin++, pElement->m_dY1) &&
|
||||
StringToDouble(*itBegin++, pElement->m_dX2) && StringToDouble(*itBegin++, pElement->m_dY2) &&
|
||||
StringToDouble(*itBegin++, pElement->m_dX3) && StringToDouble(*itBegin++, pElement->m_dY3))
|
||||
return pElement;
|
||||
|
||||
delete pElement;
|
||||
@ -347,9 +354,10 @@ void CBezierCurveElement::Draw(IRenderer* pRenderer) const
|
||||
CArcElement::CArcElement()
|
||||
{}
|
||||
|
||||
IPathElement* CArcElement::ReadFromArray(std::vector<std::string>& arValues)
|
||||
IPathElement* CArcElement::ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd)
|
||||
{
|
||||
if (arValues.size() < 7)
|
||||
|
||||
if (itEnd - itBegin < 7)
|
||||
return nullptr;
|
||||
|
||||
CArcElement *pElement = new CArcElement();
|
||||
@ -357,10 +365,10 @@ IPathElement* CArcElement::ReadFromArray(std::vector<std::string>& arValues)
|
||||
if (nullptr == pElement)
|
||||
return nullptr;
|
||||
|
||||
if (StringToDouble(arValues[0], pElement->m_dRadiusX) && StringToDouble(arValues[1], pElement->m_dRadiusY) &&
|
||||
StringToDouble(arValues[2], pElement->m_dAngle) && StringToBoolean(arValues[3], pElement->m_bLarge) &&
|
||||
StringToBoolean(arValues[4], pElement->m_bSweep) && StringToDouble(arValues[5], pElement->m_dX) &&
|
||||
StringToDouble(arValues[6], pElement->m_dY))
|
||||
if (StringToDouble (*itBegin++, pElement->m_dRadiusX) && StringToDouble (*itBegin++, pElement->m_dRadiusY) &&
|
||||
StringToDouble (*itBegin++, pElement->m_dAngle) && StringToBoolean(*itBegin++, pElement->m_bLarge) &&
|
||||
StringToBoolean(*itBegin++, pElement->m_bSweep) && StringToDouble (*itBegin++, pElement->m_dX) &&
|
||||
StringToDouble (*itBegin++, pElement->m_dY))
|
||||
return pElement;
|
||||
|
||||
delete pElement;
|
||||
@ -376,11 +384,6 @@ void CArcElement::Draw(IRenderer* pRenderer) const
|
||||
CCloseElement::CCloseElement()
|
||||
{}
|
||||
|
||||
IPathElement* CCloseElement::ReadFromArray(std::vector<std::string>& arValues)
|
||||
{
|
||||
return new CCloseElement();
|
||||
}
|
||||
|
||||
void CCloseElement::Draw(IRenderer* pRenderer) const
|
||||
{
|
||||
if (nullptr != pRenderer)
|
||||
|
||||
@ -24,7 +24,7 @@ class CStartElement : public IPathElement
|
||||
double m_dY;
|
||||
public:
|
||||
CStartElement();
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>& arValues);
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd);
|
||||
void Draw(IRenderer* pRenderer) const override;
|
||||
};
|
||||
|
||||
@ -34,7 +34,7 @@ class CMoveElement : public IPathElement
|
||||
double m_dY;
|
||||
public:
|
||||
CMoveElement();
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>& arValues);
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd);
|
||||
void Draw(IRenderer* pRenderer) const override;
|
||||
};
|
||||
|
||||
@ -44,7 +44,7 @@ class CLineElement : public IPathElement
|
||||
double m_dY;
|
||||
public:
|
||||
CLineElement();
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>& arValues);
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd);
|
||||
void Draw(IRenderer* pRenderer) const override;
|
||||
};
|
||||
|
||||
@ -56,7 +56,7 @@ class CBezierCurve2Element : public IPathElement
|
||||
double m_dY2;
|
||||
public:
|
||||
CBezierCurve2Element();
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>& arValues);
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd);
|
||||
void Draw(IRenderer* pRenderer) const override;
|
||||
};
|
||||
|
||||
@ -70,7 +70,7 @@ class CBezierCurveElement : public IPathElement
|
||||
double m_dY3;
|
||||
public:
|
||||
CBezierCurveElement();
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>& arValues);
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd);
|
||||
void Draw(IRenderer* pRenderer) const override;
|
||||
};
|
||||
|
||||
@ -85,7 +85,7 @@ class CArcElement : public IPathElement
|
||||
double m_dY;
|
||||
public:
|
||||
CArcElement();
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>& arValues);
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>::const_iterator& itBegin, const std::vector<std::string>::const_iterator& itEnd);
|
||||
void Draw(IRenderer* pRenderer) const override;
|
||||
};
|
||||
|
||||
@ -93,7 +93,6 @@ class CCloseElement : public IPathElement
|
||||
{
|
||||
public:
|
||||
CCloseElement();
|
||||
static IPathElement* ReadFromArray(std::vector<std::string>& arValues);
|
||||
void Draw(IRenderer* pRenderer) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ void CTextCode::Draw(IRenderer* pRenderer, unsigned int& unIndex, const std::vec
|
||||
if (nullptr == pRenderer || m_wsText.empty())
|
||||
return;
|
||||
|
||||
double dX = m_dX, dDelta = 0;
|
||||
double dX = m_dX, dY = m_dY, dDeltaX = 0, dDeltaY = 0;
|
||||
bool bDrawed = false;
|
||||
|
||||
for (unsigned int unGlyphIndex = 0; unGlyphIndex < m_wsText.length(); ++unGlyphIndex)
|
||||
@ -72,7 +72,7 @@ void CTextCode::Draw(IRenderer* pRenderer, unsigned int& unIndex, const std::vec
|
||||
{
|
||||
for (const TCGTransform& oCGTransform : arCGTransforms)
|
||||
{
|
||||
if (oCGTransform.Draw(pRenderer, unIndex, dX, m_dY))
|
||||
if (oCGTransform.Draw(pRenderer, unIndex, dX, dY))
|
||||
{
|
||||
bDrawed = true;
|
||||
break;
|
||||
@ -82,20 +82,24 @@ void CTextCode::Draw(IRenderer* pRenderer, unsigned int& unIndex, const std::vec
|
||||
|
||||
if (!bDrawed)
|
||||
{
|
||||
pRenderer->CommandDrawTextCHAR(m_wsText[unGlyphIndex], dX, m_dY, 0, 0);
|
||||
pRenderer->CommandDrawTextCHAR(m_wsText[unGlyphIndex], dX, dY, 0, 0);
|
||||
++unIndex;
|
||||
}
|
||||
|
||||
if (unGlyphIndex < m_arDeltaX.size())
|
||||
dDelta = m_arDeltaX[unGlyphIndex];
|
||||
dDeltaX = m_arDeltaX[unGlyphIndex];
|
||||
|
||||
dX += dDelta;
|
||||
if (unGlyphIndex < m_arDeltaY.size())
|
||||
dDeltaY = m_arDeltaY[unGlyphIndex];
|
||||
|
||||
dX += dDeltaX;
|
||||
dY += dDeltaY;
|
||||
}
|
||||
}
|
||||
|
||||
CTextObject::CTextObject(CXmlReader& oLiteReader)
|
||||
: IPageBlock(oLiteReader), CGraphicUnit(oLiteReader),
|
||||
m_bStroke(false), m_bFill(false), m_dHScale(1.),
|
||||
m_bStroke(false), m_bFill(true), m_dHScale(1.),
|
||||
m_unReadDirection(0), m_unCharDirection(0), m_unWeight(400),
|
||||
m_bItalic(false),
|
||||
m_pFillColor(nullptr), m_pStrokeColor(nullptr), m_unFontID(0)
|
||||
@ -179,7 +183,8 @@ void CTextObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) con
|
||||
if (nullptr == pRenderer || m_arTextCodes.empty())
|
||||
return;
|
||||
|
||||
CGraphicUnit::Apply(pRenderer);
|
||||
TMatrix oOldTransform;
|
||||
CGraphicUnit::Apply(pRenderer, oOldTransform);
|
||||
|
||||
const CFont* pFont = oCommonData.GetPublicRes()->GetFont(m_unFontID);
|
||||
|
||||
@ -210,6 +215,8 @@ void CTextObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) con
|
||||
|
||||
for (const CTextCode* pTextCode : m_arTextCodes)
|
||||
pTextCode->Draw(pRenderer, unGlyphsIndex, m_arCGTransforms);
|
||||
|
||||
pRenderer->SetTransform(oOldTransform.m_dM11, oOldTransform.m_dM12, oOldTransform.m_dM21, oOldTransform.m_dM22, oOldTransform.m_dDx, oOldTransform.m_dDy);
|
||||
}
|
||||
|
||||
TCGTransform TCGTransform::Read(CXmlReader& oLiteReader)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "OFDFile_Private.h"
|
||||
|
||||
#include "../../OfficeUtils/src/OfficeUtils.h"
|
||||
#include "Utils/Utils.h"
|
||||
|
||||
COFDFile_Private::COFDFile_Private(NSFonts::IApplicationFonts* pFonts)
|
||||
: m_pAppFonts(pFonts), m_pTempFolder(nullptr)
|
||||
@ -9,11 +10,11 @@ COFDFile_Private::COFDFile_Private(NSFonts::IApplicationFonts* pFonts)
|
||||
return;
|
||||
|
||||
// Создаем менеджер шрифтов с собственным кэшем
|
||||
m_pFontManager = m_pAppFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pMeasurerCache = NSFonts::NSFontCache::Create();
|
||||
pMeasurerCache->SetStreams(m_pAppFonts->GetStreams());
|
||||
m_pFontManager->SetOwnerCache(pMeasurerCache);
|
||||
pMeasurerCache->SetCacheSize(16);
|
||||
// m_pFontManager = m_pAppFonts->GenerateFontManager();
|
||||
// NSFonts::IFontsCache* pMeasurerCache = NSFonts::NSFontCache::Create();
|
||||
// pMeasurerCache->SetStreams(m_pAppFonts->GetStreams());
|
||||
// m_pFontManager->SetOwnerCache(pMeasurerCache);
|
||||
// pMeasurerCache->SetCacheSize(16);
|
||||
}
|
||||
|
||||
COFDFile_Private::~COFDFile_Private()
|
||||
@ -23,7 +24,7 @@ COFDFile_Private::~COFDFile_Private()
|
||||
if (nullptr != m_pTempFolder)
|
||||
delete m_pTempFolder;
|
||||
|
||||
RELEASEINTERFACE(m_pFontManager);
|
||||
// RELEASEINTERFACE(m_pFontManager);
|
||||
}
|
||||
|
||||
void COFDFile_Private::Close()
|
||||
@ -110,6 +111,33 @@ void COFDFile_Private::DrawPage(IRenderer* pRenderer, int nPageIndex)
|
||||
m_oBase.DrawPage(pRenderer, nPageIndex);
|
||||
}
|
||||
|
||||
void COFDFile_Private::DrawPage(IRenderer* pRenderer, int nPageIndex, const double& dX, const double& dY, const double& dWidth, const double& dHeight)
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
double dPageWidth = 0., dPageHeight = 0.;
|
||||
|
||||
GetPageSize(nPageIndex, dPageWidth, dPageHeight);
|
||||
|
||||
if (OFD::IsZeroValue(dPageWidth) || OFD::IsZeroValue(dPageHeight))
|
||||
return;
|
||||
|
||||
double dM11, dM12, dM21, dM22, dDx, dDy;
|
||||
pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy);
|
||||
|
||||
Aggplus::CMatrix oTransform(dM11, dM12, dM21, dM22, dDx, dDy);
|
||||
|
||||
oTransform.Scale(dWidth / dPageWidth, dHeight / dPageHeight);
|
||||
oTransform.Translate(dX, dY);
|
||||
|
||||
pRenderer->SetTransform(oTransform.sx(), oTransform.shy(), oTransform.shx(), oTransform.sy(), oTransform.tx(), oTransform.ty());
|
||||
|
||||
m_oBase.DrawPage(pRenderer, nPageIndex);
|
||||
|
||||
pRenderer->SetTransform(dM11, dM12, dM21, dM22, dDx, dDy);
|
||||
}
|
||||
|
||||
NSFonts::IApplicationFonts* COFDFile_Private::GetFonts()
|
||||
{
|
||||
return m_pAppFonts;
|
||||
|
||||
@ -33,6 +33,7 @@ public:
|
||||
void GetPageSize(int nPageIndex, double& dWidth, double& dHeight) const;
|
||||
|
||||
void DrawPage(IRenderer* pRenderer, int nPageIndex);
|
||||
void DrawPage(IRenderer* pRenderer, int nPageIndex, const double& dX, const double& dY, const double& dWidth, const double& dHeight);
|
||||
|
||||
NSFonts::IApplicationFonts* GetFonts();
|
||||
};
|
||||
|
||||
@ -39,10 +39,12 @@ int CColor::ToInt(const CRes* pPublicRes) const
|
||||
|
||||
const CColorSpace* pColorSpace = pPublicRes->GetColorSpace(m_unColodSpaceID);
|
||||
|
||||
if (nullptr == pColorSpace)
|
||||
return 0;
|
||||
CColorSpace::EType eColoSpaceType{CColorSpace::EType::RGB};
|
||||
|
||||
switch(pColorSpace->GetType())
|
||||
if (nullptr != pColorSpace)
|
||||
eColoSpaceType = pColorSpace->GetType();
|
||||
|
||||
switch(eColoSpaceType)
|
||||
{
|
||||
case CColorSpace::EType::GRAY:
|
||||
return (255 << 24) | (m_oValues[0] << 16) | (m_oValues[0] << 8) | (m_oValues[0] << 0);
|
||||
|
||||
@ -5,8 +5,6 @@
|
||||
#include "PageArea.h"
|
||||
#include "TemplatePage.h"
|
||||
|
||||
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CCommonData
|
||||
|
||||
186
OFDFile/src/Types/Signature.cpp
Normal file
186
OFDFile/src/Types/Signature.cpp
Normal file
@ -0,0 +1,186 @@
|
||||
#include "Signature.h"
|
||||
|
||||
#include "../Utils/Utils.h"
|
||||
|
||||
#include "../OFDFile_Private.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CSignature::CSignature()
|
||||
{}
|
||||
|
||||
CSignature* CSignature::Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath)
|
||||
{
|
||||
if (wsFilePath.empty())
|
||||
return nullptr;
|
||||
|
||||
CXmlReader oLiteReader;
|
||||
if (!oLiteReader.FromFile(CombinePaths(wsRootPath, wsFilePath)) || !oLiteReader.ReadNextNode() || L"ofd:Signature" != oLiteReader.GetName() || oLiteReader.IsEmptyNode())
|
||||
return nullptr;
|
||||
|
||||
CSignature *pSignature = new CSignature();
|
||||
|
||||
pSignature->m_wsRootPath = wsRootPath;
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
if ("ofd:SignedInfo" == oLiteReader.GetNameA())
|
||||
pSignature->m_oSignedInfo.Read(oLiteReader);
|
||||
else if ("ofd:SignedValue" == oLiteReader.GetNameA())
|
||||
pSignature->m_wsSignedValue = CombinePaths(wsRootPath, oLiteReader.GetText2());
|
||||
}
|
||||
|
||||
return pSignature;
|
||||
}
|
||||
|
||||
bool CSignature::Draw(IRenderer* pRenderer, unsigned int unPageIndex, NSFonts::IApplicationFonts* pFonts) const
|
||||
{
|
||||
if (nullptr == pRenderer || m_wsSignedValue.empty() ||
|
||||
m_oSignedInfo.m_oStampAnnot.m_unPageRef - 1 != unPageIndex ||
|
||||
m_oSignedInfo.m_oStampAnnot.m_oBoundary.Empty())
|
||||
return false;
|
||||
|
||||
COFDFile_Private oFile(pFonts);
|
||||
oFile.SetTempDir(m_wsRootPath);
|
||||
|
||||
oFile.LoadFromFile(m_wsSignedValue);
|
||||
|
||||
oFile.DrawPage(pRenderer, 0,
|
||||
m_oSignedInfo.m_oStampAnnot.m_oBoundary.m_dX,
|
||||
m_oSignedInfo.m_oStampAnnot.m_oBoundary.m_dY,
|
||||
m_oSignedInfo.m_oStampAnnot.m_oBoundary.m_dWidth,
|
||||
m_oSignedInfo.m_oStampAnnot.m_oBoundary.m_dHeight);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void TProvider::Read(CXmlReader& oLiteReader)
|
||||
{
|
||||
if (0 == oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
||||
return;
|
||||
|
||||
std::string sAttributeName;
|
||||
|
||||
do
|
||||
{
|
||||
sAttributeName = oLiteReader.GetNameA();
|
||||
|
||||
if ("ProviderName" == sAttributeName)
|
||||
m_wsProviderName = oLiteReader.GetText();
|
||||
else if ("Version" == sAttributeName)
|
||||
m_wsVersion = oLiteReader.GetText();
|
||||
else if ("Company" == sAttributeName)
|
||||
m_wsCompany = oLiteReader.GetText();
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
TReference* TReference::Read(CXmlReader& oLiteReader)
|
||||
{
|
||||
if ("ofd:Reference" != oLiteReader.GetNameA() || oLiteReader.IsEmptyElement() || 0 == oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
||||
return nullptr;
|
||||
|
||||
TReference* pElement = new TReference();
|
||||
|
||||
do
|
||||
{
|
||||
if ("FileRef" == oLiteReader.GetNameA())
|
||||
pElement->m_wsFileRef = oLiteReader.GetText();
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
if ("ofd:CheckValue" == oLiteReader.GetNameA())
|
||||
{
|
||||
pElement->m_wsCheckValue = oLiteReader.GetText2();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return pElement;
|
||||
}
|
||||
|
||||
TReferences::~TReferences()
|
||||
{
|
||||
ClearContainer(m_arValues);
|
||||
}
|
||||
|
||||
void TReferences::Read(CXmlReader& oLiteReader)
|
||||
{
|
||||
if (oLiteReader.IsEmptyElement() || 0 == oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
||||
return;
|
||||
|
||||
do
|
||||
{
|
||||
if ("CheckMethod" == oLiteReader.GetNameA())
|
||||
m_wsCheckMethod = oLiteReader.GetText();
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
AddToContainer(TReference::Read(oLiteReader), m_arValues);
|
||||
}
|
||||
|
||||
TStampAnnot::TStampAnnot()
|
||||
: m_unID(0), m_unPageRef(0)
|
||||
{}
|
||||
|
||||
void TStampAnnot::Read(CXmlReader& oLiteReader)
|
||||
{
|
||||
if (0 == oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
||||
return;
|
||||
|
||||
std::string sAttributeName;
|
||||
|
||||
do
|
||||
{
|
||||
sAttributeName = oLiteReader.GetNameA();
|
||||
|
||||
if ("ID" == sAttributeName)
|
||||
m_unID = oLiteReader.GetUInteger(true);
|
||||
else if ("PageRef" == sAttributeName)
|
||||
m_unPageRef = oLiteReader.GetUInteger(true);
|
||||
else if ("Boundary" == sAttributeName)
|
||||
m_oBoundary.Read(oLiteReader.GetTextA());
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
void TSignedInfo::Read(CXmlReader& oLiteReader)
|
||||
{
|
||||
if (oLiteReader.IsEmptyNode())
|
||||
return;
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
|
||||
std::string sNodeName;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
sNodeName = oLiteReader.GetNameA();
|
||||
|
||||
if ("ofd:Provider" == sNodeName)
|
||||
m_oProvider.Read(oLiteReader);
|
||||
else if ("ofd:SignatureMethod" == sNodeName)
|
||||
m_wsSignatureMethod = oLiteReader.GetText2();
|
||||
else if ("ofd:SignatureDateTime" == sNodeName)
|
||||
m_wsSignatureDateTime = oLiteReader.GetText2();
|
||||
else if ("ofd:References" == sNodeName)
|
||||
m_oReferences.Read(oLiteReader);
|
||||
else if ("ofd:StampAnnot" == sNodeName)
|
||||
m_oStampAnnot.Read(oLiteReader);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
75
OFDFile/src/Types/Signature.h
Normal file
75
OFDFile/src/Types/Signature.h
Normal file
@ -0,0 +1,75 @@
|
||||
#ifndef SIGNATURE_H
|
||||
#define SIGNATURE_H
|
||||
|
||||
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
#include "../../../DesktopEditor/graphics/IRenderer.h"
|
||||
#include "../Utils/XmlReader.h"
|
||||
#include "../Utils/Types.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
struct TProvider
|
||||
{
|
||||
std::wstring m_wsProviderName;
|
||||
std::wstring m_wsVersion;
|
||||
std::wstring m_wsCompany;
|
||||
|
||||
void Read(CXmlReader& oLiteReader);
|
||||
};
|
||||
|
||||
struct TReference
|
||||
{
|
||||
std::wstring m_wsFileRef;
|
||||
std::wstring m_wsCheckValue;
|
||||
|
||||
static TReference* Read(CXmlReader& oLiteReader);
|
||||
};
|
||||
|
||||
struct TReferences
|
||||
{
|
||||
std::wstring m_wsCheckMethod;
|
||||
std::vector<TReference*> m_arValues;
|
||||
|
||||
~TReferences();
|
||||
|
||||
void Read(CXmlReader& oLiteReader);
|
||||
};
|
||||
|
||||
struct TStampAnnot
|
||||
{
|
||||
unsigned int m_unID;
|
||||
unsigned int m_unPageRef;
|
||||
TBox m_oBoundary;
|
||||
|
||||
TStampAnnot();
|
||||
|
||||
void Read(CXmlReader& oLiteReader);
|
||||
};
|
||||
|
||||
struct TSignedInfo
|
||||
{
|
||||
TProvider m_oProvider;
|
||||
std::wstring m_wsSignatureMethod;
|
||||
std::wstring m_wsSignatureDateTime;
|
||||
TReferences m_oReferences;
|
||||
TStampAnnot m_oStampAnnot;
|
||||
|
||||
void Read(CXmlReader& oLiteReader);
|
||||
};
|
||||
|
||||
class CSignature
|
||||
{
|
||||
TSignedInfo m_oSignedInfo;
|
||||
std::wstring m_wsSignedValue;
|
||||
|
||||
std::wstring m_wsRootPath;
|
||||
public:
|
||||
CSignature();
|
||||
|
||||
static CSignature* Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath);
|
||||
|
||||
bool Draw(IRenderer* pRenderer, unsigned int unPageIndex, NSFonts::IApplicationFonts* pFonts) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SIGNATURE_H
|
||||
@ -2,7 +2,6 @@
|
||||
#define TEMPLATEPAGE_H
|
||||
|
||||
#include "../IOFDElement.h"
|
||||
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
|
||||
@ -103,6 +103,16 @@ inline void AddToContainer(T* pValue, std::vector<T*>& arValues)
|
||||
arValues.push_back(pValue);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void ClearContainer(std::vector<T*>& arValues)
|
||||
{
|
||||
for (T* pElement : arValues)
|
||||
if (nullptr != pElement)
|
||||
delete pElement;
|
||||
|
||||
arValues.clear();
|
||||
}
|
||||
|
||||
inline std::wstring CombinePaths(const std::wstring& wsFirstPath, const std::wstring& wsSecondPath)
|
||||
{
|
||||
if (wsFirstPath.empty())
|
||||
@ -128,5 +138,10 @@ inline std::wstring CombinePaths(const std::wstring& wsFirstPath, const std::wst
|
||||
|
||||
return NSSystemPath::Combine(wsFirstPath, wsNewSecondPath);
|
||||
}
|
||||
|
||||
inline bool IsZeroValue(const double& dValue)
|
||||
{
|
||||
return DBL_EPSILON > std::abs(dValue);
|
||||
}
|
||||
}
|
||||
#endif // UTILS_H
|
||||
|
||||
Reference in New Issue
Block a user