mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Merge branch 'fix/ofd' into fix/fb2-html-hwp
This commit is contained in:
@ -30,6 +30,7 @@ INCLUDEPATH += \
|
||||
|
||||
HEADERS += \
|
||||
OFDFile.h \
|
||||
src/Annotation.h \
|
||||
src/Content/ImageObject.h \
|
||||
src/Content/PageBlock.h \
|
||||
src/Content/PathObject.h \
|
||||
@ -52,6 +53,7 @@ HEADERS += \
|
||||
src/Types/Font.h \
|
||||
src/Types/MultiMedia.h \
|
||||
src/Types/PageArea.h \
|
||||
src/Types/PenSettings.h \
|
||||
src/Types/Signature.h \
|
||||
src/Types/TemplatePage.h \
|
||||
src/Utils/Types.h \
|
||||
@ -60,6 +62,7 @@ HEADERS += \
|
||||
|
||||
SOURCES += \
|
||||
OFDFile.cpp \
|
||||
src/Annotation.cpp \
|
||||
src/Content/ImageObject.cpp \
|
||||
src/Content/PageBlock.cpp \
|
||||
src/Content/PathObject.cpp \
|
||||
@ -80,6 +83,7 @@ SOURCES += \
|
||||
src/Types/Font.cpp \
|
||||
src/Types/MultiMedia.cpp \
|
||||
src/Types/PageArea.cpp \
|
||||
src/Types/PenSettings.cpp \
|
||||
src/Types/Signature.cpp \
|
||||
src/Types/TemplatePage.cpp \
|
||||
src/Utils/Types.cpp \
|
||||
|
||||
205
OFDFile/src/Annotation.cpp
Normal file
205
OFDFile/src/Annotation.cpp
Normal file
@ -0,0 +1,205 @@
|
||||
#include "Annotation.h"
|
||||
#include "Utils/Utils.h"
|
||||
|
||||
#include "../../../Common/File.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CParameter::CParameter(CXmlReader& oLiteReader)
|
||||
{
|
||||
if (oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
do
|
||||
{
|
||||
if ("Name" != oLiteReader.GetNameA())
|
||||
continue;
|
||||
|
||||
m_wsName = oLiteReader.GetText();
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
m_wsValue = oLiteReader.GetText2();
|
||||
}
|
||||
|
||||
CAnnot::CAnnot(CXmlReader& oLiteReader)
|
||||
: m_bVisible(true), m_bPrint(true), m_bNoZoom(false), m_bNoRotate(false), m_bReadOnly(true)
|
||||
{
|
||||
if (oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
std::string wsAttributeName;
|
||||
do
|
||||
{
|
||||
wsAttributeName = oLiteReader.GetNameA();
|
||||
|
||||
if ("Type" == wsAttributeName)
|
||||
{
|
||||
const std::string sValue{oLiteReader.GetTextA()};
|
||||
|
||||
if ("Link" == sValue)
|
||||
m_eType = EAnnotType::Link;
|
||||
else if ("Path" == sValue)
|
||||
m_eType = EAnnotType::Path;
|
||||
else if ("Highlight" == sValue)
|
||||
m_eType = EAnnotType::Highlight;
|
||||
else if ("Stamp" == sValue)
|
||||
m_eType = EAnnotType::Stamp;
|
||||
else if ("Watermark" == sValue)
|
||||
m_eType = EAnnotType::Watermark;
|
||||
}
|
||||
else if ("Visible" == wsAttributeName)
|
||||
{
|
||||
if ("false" == oLiteReader.GetTextA())
|
||||
m_bVisible = false;
|
||||
}
|
||||
else if ("Print" == wsAttributeName)
|
||||
{
|
||||
if ("false" == oLiteReader.GetTextA())
|
||||
m_bPrint = false;
|
||||
}
|
||||
else if ("NoZoom" == wsAttributeName)
|
||||
{
|
||||
if ("true" == oLiteReader.GetTextA())
|
||||
m_bNoZoom = true;
|
||||
}
|
||||
else if ("NoRotate" == wsAttributeName)
|
||||
{
|
||||
if ("true" == oLiteReader.GetTextA())
|
||||
m_bNoRotate = true;
|
||||
}
|
||||
else if ("ReadOnly" == wsAttributeName)
|
||||
{
|
||||
if ("true" == oLiteReader.GetTextA())
|
||||
m_bReadOnly = true;
|
||||
}
|
||||
}while(oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::string sNodeName;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
sNodeName = oLiteReader.GetNameA();
|
||||
|
||||
if ("ofd:Parameters" == sNodeName)
|
||||
{
|
||||
const int nChildDepth = oLiteReader.GetDepth();
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nChildDepth))
|
||||
{
|
||||
if ("ofd:Parameter" != oLiteReader.GetNameA())
|
||||
continue;
|
||||
|
||||
m_arParameters.push_back(new CParameter(oLiteReader));
|
||||
}
|
||||
}
|
||||
else if ("ofd:Appearance" == sNodeName)
|
||||
m_arAppearances.push_back(new CAppearance(oLiteReader));
|
||||
}
|
||||
}
|
||||
|
||||
CAnnot::~CAnnot()
|
||||
{
|
||||
ClearContainer(m_arParameters);
|
||||
ClearContainer(m_arAppearances);
|
||||
}
|
||||
|
||||
void CAnnot::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (!m_bPrint)
|
||||
return;
|
||||
|
||||
for (const CAppearance* pAppearance : m_arAppearances)
|
||||
pAppearance->Draw(pRenderer, oCommonData, ePageType);
|
||||
}
|
||||
|
||||
CPageAnnot::CPageAnnot()
|
||||
{}
|
||||
|
||||
CPageAnnot* CPageAnnot::Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath)
|
||||
{
|
||||
if (wsFilePath.empty() || !CanUseThisPath(wsFilePath, wsRootPath))
|
||||
return nullptr;
|
||||
|
||||
const std::wstring wsNormalizedPath = CombinePaths(wsRootPath, wsFilePath);
|
||||
|
||||
CXmlReader oLiteReader;
|
||||
if (!oLiteReader.FromFile(wsNormalizedPath) || !oLiteReader.ReadNextNode() || "ofd:PageAnnot" != oLiteReader.GetNameA())
|
||||
return nullptr;
|
||||
|
||||
CPageAnnot *pPageAnnot = new CPageAnnot();
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
if ("ofd:Annot" != oLiteReader.GetNameA())
|
||||
continue;
|
||||
|
||||
pPageAnnot->m_arAnnots.push_back(new CAnnot(oLiteReader));
|
||||
}
|
||||
|
||||
return pPageAnnot;
|
||||
}
|
||||
|
||||
void CPageAnnot::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
for (const CAnnot* pAnnot : m_arAnnots)
|
||||
pAnnot->Draw(pRenderer, oCommonData, ePageType);
|
||||
}
|
||||
|
||||
CAnnotation::CAnnotation()
|
||||
: m_pPageAnnot(nullptr)
|
||||
{}
|
||||
|
||||
CAnnotation::~CAnnotation()
|
||||
{
|
||||
if (nullptr != m_pPageAnnot)
|
||||
delete m_pPageAnnot;
|
||||
}
|
||||
|
||||
bool CAnnotation::Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath)
|
||||
{
|
||||
if (wsFilePath.empty() || !CanUseThisPath(wsFilePath, wsRootPath))
|
||||
return false;
|
||||
|
||||
std::wstring wsNormalizedPath = CombinePaths(wsRootPath, wsFilePath);
|
||||
|
||||
if (L"xml" != NSFile::GetFileExtention(wsNormalizedPath))
|
||||
wsNormalizedPath = CombinePaths(wsNormalizedPath, L"Annotations.xml");
|
||||
|
||||
CXmlReader oLiteReader;
|
||||
if (!oLiteReader.FromFile(wsNormalizedPath) || !oLiteReader.ReadNextNode() || L"ofd:Annotations" != oLiteReader.GetName())
|
||||
return false;
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
if (L"ofd:Page" != oLiteReader.GetName())
|
||||
continue;
|
||||
|
||||
const int nChildDepth = oLiteReader.GetDepth();
|
||||
while (oLiteReader.ReadNextSiblingNode(nChildDepth))
|
||||
{
|
||||
if (L"ofd:FileLoc" != oLiteReader.GetName())
|
||||
continue;
|
||||
|
||||
if (nullptr == m_pPageAnnot)
|
||||
m_pPageAnnot = CPageAnnot::Read(oLiteReader.GetText2(), NSSystemPath::GetDirectoryName(wsNormalizedPath));
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr != m_pPageAnnot;
|
||||
}
|
||||
|
||||
void CAnnotation::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr != m_pPageAnnot)
|
||||
m_pPageAnnot->Draw(pRenderer, oCommonData, ePageType);
|
||||
}
|
||||
}
|
||||
77
OFDFile/src/Annotation.h
Normal file
77
OFDFile/src/Annotation.h
Normal file
@ -0,0 +1,77 @@
|
||||
#ifndef ANNOTATION_H
|
||||
#define ANNOTATION_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Content/PageBlock.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CParameter
|
||||
{
|
||||
public:
|
||||
CParameter(CXmlReader& oLiteReader);
|
||||
private:
|
||||
std::wstring m_wsName;
|
||||
std::wstring m_wsValue;
|
||||
};
|
||||
|
||||
typedef CPageBlock CAppearance;
|
||||
|
||||
enum class EAnnotType
|
||||
{
|
||||
Link,
|
||||
Path,
|
||||
Highlight,
|
||||
Stamp,
|
||||
Watermark
|
||||
};
|
||||
|
||||
class CAnnot
|
||||
{
|
||||
public:
|
||||
CAnnot(CXmlReader& oLiteReader);
|
||||
~CAnnot();
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const;
|
||||
private:
|
||||
EAnnotType m_eType;
|
||||
bool m_bVisible;
|
||||
bool m_bPrint;
|
||||
bool m_bNoZoom;
|
||||
bool m_bNoRotate;
|
||||
bool m_bReadOnly;
|
||||
|
||||
std::vector<CParameter*> m_arParameters;
|
||||
std::vector<CAppearance*> m_arAppearances;
|
||||
};
|
||||
|
||||
class CPageAnnot
|
||||
{
|
||||
public:
|
||||
CPageAnnot();
|
||||
|
||||
static CPageAnnot* Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath);
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const;
|
||||
private:
|
||||
|
||||
std::vector<CAnnot*> m_arAnnots;
|
||||
};
|
||||
|
||||
class CAnnotation
|
||||
{
|
||||
public:
|
||||
CAnnotation();
|
||||
~CAnnotation();
|
||||
|
||||
bool Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath);
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const;
|
||||
private:
|
||||
CPageAnnot *m_pPageAnnot;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ANNOTATION_H
|
||||
@ -30,12 +30,12 @@ bool CContent::Read(CXmlReader& oLiteReader)
|
||||
return false;
|
||||
}
|
||||
|
||||
void CContent::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
void CContent::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
for (const CLayer* pLayer : m_arLayers)
|
||||
pLayer->Draw(pRenderer, oCommonData);
|
||||
pLayer->Draw(pRenderer, oCommonData, ePageType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ public:
|
||||
~CContent();
|
||||
|
||||
bool Read(CXmlReader& oLiteReader);
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const;
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -4,9 +4,7 @@
|
||||
namespace OFD
|
||||
{
|
||||
CGraphicUnit::CGraphicUnit(CXmlReader& oLiteReader)
|
||||
: m_bVisible(true), m_unDrawParam(0), m_dLineWidth(0.353),
|
||||
m_eCap(ECap::Butt), m_eJoin(EJoin::Miter), m_dMiterLimit(4.234),
|
||||
m_dDashOffset(0.), m_uchAlpha(255)
|
||||
: m_bVisible(true), m_unDrawParam(0), m_oPenSettings(oLiteReader)
|
||||
{
|
||||
if (0 == oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
||||
return;
|
||||
@ -27,36 +25,6 @@ CGraphicUnit::CGraphicUnit(CXmlReader& oLiteReader)
|
||||
m_oCTM.Read(oLiteReader.GetTextA());
|
||||
else if (L"DrawParam" == wsAttributeName)
|
||||
m_unDrawParam = oLiteReader.GetUInteger(true);
|
||||
else if (L"LineWidth" == wsAttributeName)
|
||||
m_dLineWidth = oLiteReader.GetDouble(true);
|
||||
else if (L"Cap" == wsAttributeName)
|
||||
{
|
||||
const std::wstring wsValue{oLiteReader.GetText()};
|
||||
|
||||
if (L"Butt" == wsValue)
|
||||
m_eCap = ECap::Butt;
|
||||
else if (L"Round" == wsValue)
|
||||
m_eCap = ECap::Round;
|
||||
else if (L"Square" == wsValue)
|
||||
m_eCap = ECap::Square;
|
||||
}
|
||||
else if (L"Join" == wsAttributeName)
|
||||
{
|
||||
const std::wstring wsValue{oLiteReader.GetText()};
|
||||
|
||||
if (L"Miter" == wsValue)
|
||||
m_eJoin = EJoin::Miter;
|
||||
else if (L"Round" == wsValue)
|
||||
m_eJoin = EJoin::Round;
|
||||
else if (L"Bevel" == wsValue)
|
||||
m_eJoin = EJoin::Bevel;
|
||||
}
|
||||
else if (L"MiterLimit" == wsAttributeName)
|
||||
m_dMiterLimit = oLiteReader.GetDouble(true);
|
||||
else if (L"DashOffset" == wsAttributeName)
|
||||
m_dDashOffset = oLiteReader.GetDouble(true);
|
||||
else if (L"Alpha" == wsAttributeName)
|
||||
m_uchAlpha = oLiteReader.GetUInteger(true);
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
@ -67,6 +35,8 @@ void CGraphicUnit::Apply(IRenderer* pRenderer, TMatrix& oOldTransform) const
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
m_oPenSettings.Apply(pRenderer);
|
||||
|
||||
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);
|
||||
|
||||
@ -1,13 +1,9 @@
|
||||
#ifndef GRAPHICUNIT_H
|
||||
#define GRAPHICUNIT_H
|
||||
|
||||
#include "../Utils/XmlReader.h"
|
||||
#include "../Types/PenSettings.h"
|
||||
#include "../Utils/Types.h"
|
||||
|
||||
#include "../../../DesktopEditor/graphics/IRenderer.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CGraphicUnit
|
||||
@ -17,28 +13,7 @@ class CGraphicUnit
|
||||
bool m_bVisible;
|
||||
TMatrix m_oCTM;
|
||||
unsigned int m_unDrawParam;
|
||||
double m_dLineWidth;
|
||||
|
||||
enum class ECap
|
||||
{
|
||||
Butt,
|
||||
Round,
|
||||
Square
|
||||
} m_eCap;
|
||||
|
||||
enum class EJoin
|
||||
{
|
||||
Miter,
|
||||
Round,
|
||||
Bevel
|
||||
} m_eJoin;
|
||||
|
||||
double m_dMiterLimit;
|
||||
double m_dDashOffset;
|
||||
std::vector<double> m_arDashPattern;
|
||||
unsigned char m_uchAlpha;
|
||||
|
||||
friend class CPathObject;
|
||||
CPenSettings m_oPenSettings;
|
||||
public:
|
||||
CGraphicUnit(CXmlReader& oLiteReader);
|
||||
|
||||
|
||||
@ -8,13 +8,20 @@
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
enum class EPageType
|
||||
{
|
||||
Page,
|
||||
TemplatePage,
|
||||
Anotation
|
||||
};
|
||||
|
||||
class IPageBlock : public IOFDElement
|
||||
{
|
||||
public:
|
||||
IPageBlock(CXmlReader& oLiteReader)
|
||||
: IOFDElement(oLiteReader){};
|
||||
virtual ~IPageBlock(){};
|
||||
virtual void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const = 0;
|
||||
virtual void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ CImageObject::CImageObject(CXmlReader& oLiteReader)
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
void CImageObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
void CImageObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr == pRenderer || nullptr == oCommonData.GetDocumentRes())
|
||||
return;
|
||||
|
||||
@ -12,7 +12,7 @@ class CImageObject : public IPageBlock, public CGraphicUnit
|
||||
public:
|
||||
CImageObject(CXmlReader& oLiteReader);
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -21,12 +21,12 @@ CLayer::~CLayer()
|
||||
delete pPageBlock;
|
||||
}
|
||||
|
||||
void CLayer::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
void CLayer::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
for (const IPageBlock* pPageBlock : m_arPageBlocks)
|
||||
pPageBlock->Draw(pRenderer, oCommonData);
|
||||
pPageBlock->Draw(pRenderer, oCommonData, ePageType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ public:
|
||||
CLayer(CXmlReader& oLiteReader);
|
||||
~CLayer();
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,20 @@ namespace OFD
|
||||
CPageBlock::CPageBlock(CXmlReader& oLiteReader)
|
||||
: IPageBlock(oLiteReader)
|
||||
{
|
||||
if ("ofd:PageBlock" != oLiteReader.GetNameA() || oLiteReader.IsEmptyNode())
|
||||
if (oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
do
|
||||
{
|
||||
if ("Boundary" != oLiteReader.GetNameA())
|
||||
continue;
|
||||
|
||||
m_oBoundary.Read(oLiteReader.GetTextA());
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
if (oLiteReader.IsEmptyNode())
|
||||
return;
|
||||
|
||||
CPageBlock::ReadIntoContainer(oLiteReader, m_arPageBlocks);
|
||||
@ -41,12 +54,19 @@ void CPageBlock::ReadIntoContainer(CXmlReader& oLiteReader, std::vector<IPageBlo
|
||||
}
|
||||
}
|
||||
|
||||
void CPageBlock::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
void CPageBlock::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
|
||||
double dM11, dM12, dM21, dM22, dDx, dDy;
|
||||
|
||||
pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy);
|
||||
pRenderer->SetTransform(dM11, dM12, dM21, dM22, dDx + m_oBoundary.m_dX, dDy + m_oBoundary.m_dY);
|
||||
|
||||
for (const IPageBlock* pPageBlock : m_arPageBlocks)
|
||||
pPageBlock->Draw(pRenderer, oCommonData);
|
||||
pPageBlock->Draw(pRenderer, oCommonData, ePageType);
|
||||
|
||||
pRenderer->SetTransform(dM11, dM12, dM21, dM22, dDx, dDy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,19 +2,20 @@
|
||||
#define PAGEBLOCK_H
|
||||
|
||||
#include "IPageBlock.h"
|
||||
#include "../Res.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CPageBlock : public IPageBlock
|
||||
{
|
||||
TBox m_oBoundary;
|
||||
|
||||
std::vector<IPageBlock*> m_arPageBlocks;
|
||||
public:
|
||||
CPageBlock(CXmlReader& oLiteReader);
|
||||
|
||||
static void ReadIntoContainer(CXmlReader& oLiteReader, std::vector<IPageBlock*>& arPageBlocks);
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#include "PathObject.h"
|
||||
|
||||
#include "src/Utils/Utils.h"
|
||||
#include "../Types/DrawParam.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
@ -132,7 +134,7 @@ void CPathObject::AddElement(const IPathElement* pElement)
|
||||
m_arElements.push_back(pElement);
|
||||
}
|
||||
|
||||
void CPathObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
void CPathObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr == pRenderer || m_arElements.empty())
|
||||
return;
|
||||
@ -168,38 +170,46 @@ void CPathObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) con
|
||||
}
|
||||
}
|
||||
|
||||
const CRes* pPublicRes{oCommonData.GetPublicRes()};
|
||||
std::vector<const CDrawParam*> arDrawParams{pPublicRes->GetDrawParams()};
|
||||
|
||||
if (m_bFill)
|
||||
{
|
||||
pRenderer->put_BrushType(c_BrushTypeSolid);
|
||||
|
||||
if (nullptr != m_pFillColor)
|
||||
{
|
||||
pRenderer->put_BrushColor1(m_pFillColor->ToInt(oCommonData.GetPublicRes()));
|
||||
pRenderer->put_BrushColor1(m_pFillColor->ToInt(pPublicRes));
|
||||
pRenderer->put_BrushAlpha1(m_pFillColor->GetAlpha());
|
||||
}
|
||||
else
|
||||
{
|
||||
pRenderer->put_BrushColor1(0);
|
||||
pRenderer->put_BrushAlpha1(0xff);
|
||||
|
||||
if (EPageType::TemplatePage == ePageType)
|
||||
for (const CDrawParam* pDrawParam : arDrawParams)
|
||||
if (pDrawParam->ApplyFillColor(pRenderer, pPublicRes))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
pRenderer->put_BrushType(c_BrushTypeNotSet);
|
||||
|
||||
|
||||
if(m_bStroke)
|
||||
{
|
||||
pRenderer->put_PenSize(m_dLineWidth);
|
||||
|
||||
if (nullptr != m_pStrokeColor)
|
||||
{
|
||||
pRenderer->put_PenColor(m_pStrokeColor->ToInt(oCommonData.GetPublicRes()));
|
||||
pRenderer->put_PenColor(m_pStrokeColor->ToInt(pPublicRes));
|
||||
pRenderer->put_PenAlpha(m_pStrokeColor->GetAlpha());
|
||||
}
|
||||
else
|
||||
{
|
||||
pRenderer->put_PenColor(0);
|
||||
pRenderer->put_PenAlpha(0xff);
|
||||
|
||||
if (EPageType::TemplatePage == ePageType)
|
||||
for (const CDrawParam* pDrawParam : arDrawParams)
|
||||
if (pDrawParam->ApplyStrokeColor(pRenderer, pPublicRes))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -117,7 +117,7 @@ public:
|
||||
CPathObject(CXmlReader& oLiteReader);
|
||||
~CPathObject();
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -178,12 +178,14 @@ CTextObject::~CTextObject()
|
||||
delete pTextCode;
|
||||
}
|
||||
|
||||
void CTextObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
void CTextObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr == pRenderer || m_arTextCodes.empty())
|
||||
return;
|
||||
|
||||
const CFont* pFont = oCommonData.GetPublicRes()->GetFont(m_unFontID);
|
||||
const CRes* pPublicRes{oCommonData.GetPublicRes()};
|
||||
|
||||
const CFont* pFont = pPublicRes->GetFont(m_unFontID);
|
||||
|
||||
if (nullptr == pFont)
|
||||
return;
|
||||
@ -193,19 +195,25 @@ void CTextObject::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) con
|
||||
TMatrix oOldTransform;
|
||||
CGraphicUnit::Apply(pRenderer, oOldTransform);
|
||||
|
||||
std::vector<const CDrawParam*> arDrawParams{pPublicRes->GetDrawParams()};
|
||||
|
||||
if (m_bFill)
|
||||
{
|
||||
pRenderer->put_BrushType(c_BrushTypeSolid);
|
||||
|
||||
if (nullptr != m_pFillColor)
|
||||
{
|
||||
pRenderer->put_BrushColor1(m_pFillColor->ToInt(oCommonData.GetPublicRes()));
|
||||
pRenderer->put_BrushColor1(m_pFillColor->ToInt(pPublicRes));
|
||||
pRenderer->put_BrushAlpha1(m_pFillColor->GetAlpha());
|
||||
}
|
||||
else
|
||||
{
|
||||
pRenderer->put_BrushColor1(0);
|
||||
pRenderer->put_BrushAlpha1(0xff);
|
||||
|
||||
if (EPageType::TemplatePage == ePageType)
|
||||
for (const CDrawParam* pDrawParam : arDrawParams)
|
||||
if (pDrawParam->ApplyFillColor(pRenderer, pPublicRes))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -248,15 +256,14 @@ TCGTransform TCGTransform::Read(CXmlReader& oLiteReader)
|
||||
oLiteReader.MoveToElement();
|
||||
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
unsigned int unCount = 0;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth) && unCount < oCGTransform.m_unGlyphCount)
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
if ("ofd:Glyphs" == oLiteReader.GetNameA())
|
||||
{
|
||||
oCGTransform.m_arGlyphs.push_back(oLiteReader.GetUInteger());
|
||||
++unCount;
|
||||
}
|
||||
if ("ofd:Glyphs" != oLiteReader.GetNameA())
|
||||
continue;
|
||||
|
||||
const std::vector<unsigned int> arValues{oLiteReader.GetArrayUInteger()};
|
||||
oCGTransform.m_arGlyphs.insert(oCGTransform.m_arGlyphs.end(), arValues.begin(), arValues.end());
|
||||
}
|
||||
|
||||
return oCGTransform;
|
||||
@ -264,10 +271,10 @@ TCGTransform TCGTransform::Read(CXmlReader& oLiteReader)
|
||||
|
||||
bool TCGTransform::Draw(IRenderer* pRenderer, const LONG& lUnicode, unsigned int& unIndex, double dX, double dY) const
|
||||
{
|
||||
if (m_unCodePosition != unIndex || 0 == m_unCodeCount || 0 == m_unGlyphCount)
|
||||
if (m_unCodePosition + m_arGlyphs.size() > unIndex || 0 == m_unCodeCount || m_arGlyphs.empty())
|
||||
return false;
|
||||
|
||||
for (unsigned int unGlyphCount = 0; unGlyphCount < m_unGlyphCount; ++unGlyphCount)
|
||||
for (unsigned int unGlyphCount = 0; unGlyphCount < m_arGlyphs.size(); ++unGlyphCount)
|
||||
pRenderer->CommandDrawTextExCHAR(lUnicode, m_arGlyphs[unGlyphCount], dX, dY, 0, 0);
|
||||
|
||||
unIndex += m_unCodeCount;
|
||||
|
||||
@ -58,7 +58,7 @@ public:
|
||||
CTextObject(CXmlReader& oLiteReader);
|
||||
~CTextObject();
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const override;
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -55,15 +55,15 @@ bool CDocument::Read(const std::wstring& wsFilePath, IFolder* pFolder)
|
||||
|
||||
const std::wstring wsCoreDirectory{pFolder->getFullFilePath(NSSystemPath::GetDirectoryName(wsFilePath))};
|
||||
const int nDepth = oLiteReader.GetDepth();
|
||||
std::wstring wsNodeName;
|
||||
std::string sNodeName;
|
||||
|
||||
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
wsNodeName = oLiteReader.GetName();
|
||||
sNodeName = oLiteReader.GetNameA();
|
||||
|
||||
if (L"ofd:CommonData" == wsNodeName)
|
||||
if ("ofd:CommonData" == sNodeName)
|
||||
m_oCommonData.Read(oLiteReader, wsCoreDirectory);
|
||||
else if (L"ofd:Pages" == wsNodeName)
|
||||
else if ("ofd:Pages" == sNodeName)
|
||||
{
|
||||
const int nPagesDepth = oLiteReader.GetDepth();
|
||||
|
||||
@ -99,8 +99,10 @@ bool CDocument::Read(const std::wstring& wsFilePath, IFolder* pFolder)
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
}
|
||||
else if (L"ofd:Permissions" == wsNodeName)
|
||||
else if ("ofd:Permissions" == sNodeName)
|
||||
m_oPermission.Read(oLiteReader);
|
||||
else if ("ofd:Annotations" == sNodeName)
|
||||
m_oAnnotation.Read(oLiteReader.GetText2(), wsCoreDirectory);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -116,7 +118,9 @@ bool CDocument::DrawPage(IRenderer* pRenderer, int nPageIndex) const
|
||||
if (itFound == m_mPages.cend())
|
||||
return false;
|
||||
|
||||
itFound->second->Draw(pRenderer, m_oCommonData);
|
||||
itFound->second->Draw(pRenderer, m_oCommonData, EPageType::Page);
|
||||
|
||||
m_oAnnotation.Draw(pRenderer, m_oCommonData, EPageType::Anotation);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define DOCUMENT_H
|
||||
|
||||
#include "Page.h"
|
||||
#include "Annotation.h"
|
||||
|
||||
#include "../../DesktopEditor/graphics/IRenderer.h"
|
||||
#include "../../OfficeUtils/src/ZipFolder.h"
|
||||
@ -26,6 +27,7 @@ class CDocument
|
||||
{
|
||||
CCommonData m_oCommonData;
|
||||
CPermission m_oPermission;
|
||||
CAnnotation m_oAnnotation;
|
||||
|
||||
std::map<unsigned int, CPage*> m_mPages;
|
||||
public:
|
||||
|
||||
@ -61,7 +61,7 @@ CPage* CPage::Read(const std::wstring& wsFilePath, const std::wstring& wsRootPat
|
||||
return pPage;
|
||||
}
|
||||
|
||||
void CPage::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
void CPage::Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const
|
||||
{
|
||||
if (nullptr == pRenderer)
|
||||
return;
|
||||
@ -73,10 +73,10 @@ void CPage::Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const
|
||||
const CTemplatePage *pTemplatePage = oCommonData.GetTemplatePage(m_parTemplatePage.first, m_parTemplatePage.second);
|
||||
|
||||
if (nullptr != pTemplatePage && EZOrder::Background == pTemplatePage->GetZOrder() && nullptr != pTemplatePage->GetPage())
|
||||
pTemplatePage->GetPage()->Draw(pRenderer, oCommonData);
|
||||
pTemplatePage->GetPage()->Draw(pRenderer, oCommonData, EPageType::TemplatePage);
|
||||
}
|
||||
|
||||
m_oContent.Draw(pRenderer, oCommonData);
|
||||
m_oContent.Draw(pRenderer, oCommonData, ePageType);
|
||||
|
||||
pRenderer->EndCommand(c_nImageType);
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ public:
|
||||
~CPage();
|
||||
|
||||
static CPage* Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath);
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData) const;
|
||||
void Draw(IRenderer* pRenderer, const CCommonData& oCommonData, EPageType ePageType) const;
|
||||
|
||||
void GetPageSize(double& dWidth, double& dHeight) const;
|
||||
};
|
||||
|
||||
@ -47,7 +47,7 @@ bool CRes::Read(const std::wstring& wsFilePath, const std::wstring& wsRootPath)
|
||||
if (!oLiteReader.FromFile(wsFullPath) || !oLiteReader.ReadNextNode() || L"ofd:Res" != oLiteReader.GetName() || oLiteReader.IsEmptyNode())
|
||||
return false;
|
||||
|
||||
std::wstring wsResRootPath;
|
||||
std::wstring wsResRootPath{wsRootPath};
|
||||
|
||||
if (0 != oLiteReader.GetAttributesCount() && oLiteReader.MoveToFirstAttribute())
|
||||
{
|
||||
@ -135,4 +135,14 @@ const CCompositeGraphicUnit* CRes::GetCompositeGraphicUnit(unsigned int unId) co
|
||||
{
|
||||
RETURN_ELEMENT_FROM_MAP(CCompositeGraphicUnit, m_mCCompositeGraphicUnits);
|
||||
}
|
||||
|
||||
std::vector<const CDrawParam*> CRes::GetDrawParams() const
|
||||
{
|
||||
std::vector<const CDrawParam*> arValues;
|
||||
|
||||
for (std::map<unsigned int, CDrawParam*>::const_iterator itBegin = m_mDrawParams.cbegin(); itBegin != m_mDrawParams.cend(); ++itBegin)
|
||||
arValues.push_back(itBegin->second);
|
||||
|
||||
return arValues;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,8 +9,6 @@
|
||||
#include "Types/MultiMedia.h"
|
||||
#include "Types/CompositeGraphicUnit.h"
|
||||
|
||||
#include "../../OfficeUtils/src/ZipFolder.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CRes
|
||||
@ -31,6 +29,8 @@ public:
|
||||
const CFont* GetFont(unsigned int unId) const;
|
||||
const CMultiMedia* GetMultiMedia(unsigned int unId) const;
|
||||
const CCompositeGraphicUnit* GetCompositeGraphicUnit(unsigned int unId) const;
|
||||
|
||||
std::vector<const CDrawParam*> GetDrawParams() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#include "Color.h"
|
||||
|
||||
#include "../Res.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CColor::CColor(CXmlReader& oXmlReader)
|
||||
|
||||
@ -2,10 +2,10 @@
|
||||
#define COLOR_H
|
||||
|
||||
#include "../Utils/XmlReader.h"
|
||||
#include "../Res.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CRes;
|
||||
class CColor
|
||||
{
|
||||
BYTE m_oValues[4];
|
||||
|
||||
@ -3,6 +3,63 @@
|
||||
namespace OFD
|
||||
{
|
||||
CDrawParam::CDrawParam(CXmlReader& oXmlReader)
|
||||
: IOFDElement(oXmlReader)
|
||||
{}
|
||||
: IOFDElement(oXmlReader), m_oPenSettings(oXmlReader),
|
||||
m_pStrokeColor(nullptr), m_pFillColor(nullptr)
|
||||
{
|
||||
std::string sName;
|
||||
const int nDepth = oXmlReader.GetDepth();
|
||||
|
||||
while (oXmlReader.ReadNextSiblingNode(nDepth))
|
||||
{
|
||||
sName = oXmlReader.GetNameA();
|
||||
|
||||
if ("ofd:FillColor" == sName)
|
||||
{
|
||||
if (nullptr != m_pFillColor)
|
||||
delete m_pFillColor;
|
||||
|
||||
m_pFillColor = new CColor(oXmlReader);
|
||||
}
|
||||
else if ("ofd:StrokeColor" == sName)
|
||||
{
|
||||
if (nullptr != m_pStrokeColor)
|
||||
delete m_pStrokeColor;
|
||||
|
||||
m_pStrokeColor = new CColor(oXmlReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CDrawParam::~CDrawParam()
|
||||
{
|
||||
if (nullptr != m_pStrokeColor)
|
||||
delete m_pStrokeColor;
|
||||
|
||||
if (nullptr != m_pFillColor)
|
||||
delete m_pFillColor;
|
||||
}
|
||||
|
||||
bool CDrawParam::ApplyStrokeColor(IRenderer* pRenderer, const CRes* pPublicRes) const
|
||||
{
|
||||
if (nullptr == pRenderer || nullptr == m_pStrokeColor)
|
||||
return false;
|
||||
|
||||
m_oPenSettings.Apply(pRenderer);
|
||||
|
||||
pRenderer->put_PenColor(m_pStrokeColor->ToInt(pPublicRes));
|
||||
pRenderer->put_PenAlpha(m_pStrokeColor->GetAlpha());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDrawParam::ApplyFillColor(IRenderer* pRenderer, const CRes* pPublicRes) const
|
||||
{
|
||||
if (nullptr == pRenderer || nullptr == m_pFillColor)
|
||||
return false;
|
||||
|
||||
pRenderer->put_BrushColor1(m_pFillColor->ToInt(pPublicRes));
|
||||
pRenderer->put_BrushAlpha1(m_pFillColor->GetAlpha());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,13 +2,23 @@
|
||||
#define DRAWPARAM_H
|
||||
|
||||
#include "../IOFDElement.h"
|
||||
#include "PenSettings.h"
|
||||
#include "Color.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CDrawParam : public IOFDElement
|
||||
{
|
||||
CPenSettings m_oPenSettings;
|
||||
|
||||
CColor *m_pStrokeColor;
|
||||
CColor *m_pFillColor;
|
||||
public:
|
||||
CDrawParam(CXmlReader& oXmlReader);
|
||||
~CDrawParam();
|
||||
|
||||
bool ApplyStrokeColor(IRenderer* pRenderer, const CRes* pPublicRes) const;
|
||||
bool ApplyFillColor(IRenderer* pRenderer, const CRes* pPublicRes) const;
|
||||
};
|
||||
}
|
||||
#endif // DRAWPARAM_H
|
||||
|
||||
87
OFDFile/src/Types/PenSettings.cpp
Normal file
87
OFDFile/src/Types/PenSettings.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
#include "PenSettings.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
CPenSettings::CPenSettings(CXmlReader& oLiteReader)
|
||||
: m_dLineWidth(0.353), m_eCap(ECap::Butt),
|
||||
m_eJoin(EJoin::Miter), m_dMiterLimit(4.234), m_dDashOffset(0.)
|
||||
{
|
||||
if (0 == oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
||||
return;
|
||||
|
||||
std::wstring wsAttributeName;
|
||||
|
||||
do
|
||||
{
|
||||
wsAttributeName = oLiteReader.GetName();
|
||||
|
||||
if (L"LineWidth" == wsAttributeName)
|
||||
m_dLineWidth = oLiteReader.GetDouble(true);
|
||||
else if (L"Cap" == wsAttributeName)
|
||||
{
|
||||
const std::wstring wsValue{oLiteReader.GetText()};
|
||||
|
||||
if (L"Butt" == wsValue)
|
||||
m_eCap = ECap::Butt;
|
||||
else if (L"Round" == wsValue)
|
||||
m_eCap = ECap::Round;
|
||||
else if (L"Square" == wsValue)
|
||||
m_eCap = ECap::Square;
|
||||
}
|
||||
else if (L"Join" == wsAttributeName)
|
||||
{
|
||||
const std::wstring wsValue{oLiteReader.GetText()};
|
||||
|
||||
if (L"Miter" == wsValue)
|
||||
m_eJoin = EJoin::Miter;
|
||||
else if (L"Round" == wsValue)
|
||||
m_eJoin = EJoin::Round;
|
||||
else if (L"Bevel" == wsValue)
|
||||
m_eJoin = EJoin::Bevel;
|
||||
}
|
||||
else if (L"MiterLimit" == wsAttributeName)
|
||||
m_dMiterLimit = oLiteReader.GetDouble(true);
|
||||
else if (L"DashOffset" == wsAttributeName)
|
||||
m_dDashOffset = oLiteReader.GetDouble(true);
|
||||
else if (L"Alpha" == wsAttributeName)
|
||||
m_uchAlpha = oLiteReader.GetUInteger(true);
|
||||
} while (oLiteReader.MoveToNextAttribute());
|
||||
|
||||
oLiteReader.MoveToElement();
|
||||
}
|
||||
|
||||
void CPenSettings::Apply(IRenderer* pRenderer) const
|
||||
{
|
||||
pRenderer->put_PenSize(m_dLineWidth);
|
||||
pRenderer->put_PenAlpha(m_uchAlpha);
|
||||
pRenderer->put_BrushAlpha1(m_uchAlpha);
|
||||
|
||||
BYTE nCapStyle = 0;
|
||||
switch (m_eCap)
|
||||
{
|
||||
case ECap::Butt: nCapStyle = Aggplus::LineCapFlat; break;
|
||||
case ECap::Round: nCapStyle = Aggplus::LineCapRound; break;
|
||||
case ECap::Square: nCapStyle = Aggplus::LineCapSquare; break;
|
||||
}
|
||||
|
||||
pRenderer->put_PenLineStartCap(nCapStyle);
|
||||
pRenderer->put_PenLineEndCap(nCapStyle);
|
||||
|
||||
BYTE nJoinStyle = 0;
|
||||
switch (m_eJoin)
|
||||
{
|
||||
case EJoin::Miter: nJoinStyle = Aggplus::LineJoinMiter; break;
|
||||
case EJoin::Round: nJoinStyle = Aggplus::LineJoinRound; break;
|
||||
case EJoin::Bevel: nJoinStyle = Aggplus::LineJoinBevel; break;
|
||||
}
|
||||
|
||||
pRenderer->put_PenLineJoin(nJoinStyle);
|
||||
|
||||
if (!m_arDashPattern.empty())
|
||||
{
|
||||
pRenderer->put_PenDashStyle(Aggplus::DashStyleCustom);
|
||||
pRenderer->put_PenDashOffset(m_dDashOffset);
|
||||
pRenderer->PenDashPattern((double*)m_arDashPattern.data(), m_arDashPattern.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
39
OFDFile/src/Types/PenSettings.h
Normal file
39
OFDFile/src/Types/PenSettings.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef PENSETTINGS_H
|
||||
#define PENSETTINGS_H
|
||||
|
||||
#include "../Utils/XmlReader.h"
|
||||
|
||||
#include "../../../DesktopEditor/graphics/IRenderer.h"
|
||||
|
||||
namespace OFD
|
||||
{
|
||||
class CPenSettings
|
||||
{
|
||||
double m_dLineWidth;
|
||||
|
||||
enum class ECap
|
||||
{
|
||||
Butt,
|
||||
Round,
|
||||
Square
|
||||
} m_eCap;
|
||||
|
||||
enum class EJoin
|
||||
{
|
||||
Miter,
|
||||
Round,
|
||||
Bevel
|
||||
} m_eJoin;
|
||||
|
||||
double m_dMiterLimit;
|
||||
double m_dDashOffset;
|
||||
std::vector<double> m_arDashPattern;
|
||||
unsigned char m_uchAlpha;
|
||||
public:
|
||||
CPenSettings(CXmlReader& oLiteReader);
|
||||
|
||||
void Apply(IRenderer* pRenderer) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PENSETTINGS_H
|
||||
@ -9,7 +9,7 @@ enum class EZOrder
|
||||
{
|
||||
Body,
|
||||
Background
|
||||
} ;
|
||||
};
|
||||
|
||||
EZOrder GetZOrderFromString(const std::string& sValue);
|
||||
|
||||
|
||||
@ -65,4 +65,20 @@ std::vector<double> CXmlReader::GetArrayDoubles(bool bIsAttribute)
|
||||
|
||||
return arDoubleValues;
|
||||
}
|
||||
|
||||
std::vector<unsigned int> CXmlReader::GetArrayUInteger(bool bIsAttribute)
|
||||
{
|
||||
const std::vector<std::string> arValues{Split(GetTextValueA(bIsAttribute), ' ')};
|
||||
|
||||
if(arValues.empty())
|
||||
return std::vector<unsigned int>();
|
||||
|
||||
std::vector<unsigned int> arUIntValues(arValues.size());
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < arValues.size(); ++unIndex)
|
||||
if (!StringToUInteger(arValues[unIndex], arUIntValues[unIndex]))
|
||||
return std::vector<unsigned int>();
|
||||
|
||||
return arUIntValues;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ public:
|
||||
double GetDouble(bool bIsAttribute = false);
|
||||
std::vector<std::string> GetArrayStrings(bool bIsAttribute = false);
|
||||
std::vector<double> GetArrayDoubles(bool bIsAttribute = false);
|
||||
std::vector<unsigned int> GetArrayUInteger(bool bIsAttribute = false);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user