mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Improved pars of the OFD format structure
This commit is contained in:
@ -28,8 +28,10 @@ HEADERS += \
|
|||||||
src/Document.h \
|
src/Document.h \
|
||||||
src/Page.h \
|
src/Page.h \
|
||||||
src/PublicRes.h \
|
src/PublicRes.h \
|
||||||
|
src/Types/Color.h \
|
||||||
src/Utils/Types.h \
|
src/Utils/Types.h \
|
||||||
src/Utils/Utils.h
|
src/Utils/Utils.h \
|
||||||
|
src/Utils/XmlReader.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
OFDFile.cpp \
|
OFDFile.cpp \
|
||||||
@ -41,7 +43,6 @@ SOURCES += \
|
|||||||
src/Document.cpp \
|
src/Document.cpp \
|
||||||
src/Page.cpp \
|
src/Page.cpp \
|
||||||
src/PublicRes.cpp \
|
src/PublicRes.cpp \
|
||||||
src/Utils/Types.cpp
|
src/Types/Color.cpp \
|
||||||
|
src/Utils/Types.cpp \
|
||||||
HEADERS += $$CORE_ROOT_DIR/OOXML/Base/Unit.h
|
src/Utils/XmlReader.cpp
|
||||||
SOURCES += $$CORE_ROOT_DIR/OOXML/Base/Unit.cpp
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ CDocInfo::CDocInfo()
|
|||||||
: m_eDocUsage(EDocUsege::Normal)
|
: m_eDocUsage(EDocUsege::Normal)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool CDocInfo::Read(XmlUtils::CXmlLiteReader& oLiteReader)
|
bool CDocInfo::Read(CXmlReader& oLiteReader)
|
||||||
{
|
{
|
||||||
if (L"ofd:DocInfo" != oLiteReader.GetName())
|
if (L"ofd:DocInfo" != oLiteReader.GetName())
|
||||||
return false;
|
return false;
|
||||||
@ -61,7 +61,7 @@ CDocBody::CDocBody()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CDocBody* CDocBody::Read(XmlUtils::CXmlLiteReader& oLiteReader, IFolder* pFolder)
|
CDocBody* CDocBody::Read(CXmlReader& oLiteReader, IFolder* pFolder)
|
||||||
{
|
{
|
||||||
if (L"ofd:DocBody" != oLiteReader.GetName())
|
if (L"ofd:DocBody" != oLiteReader.GetName())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -114,7 +114,7 @@ bool CBase::Read(IFolder* pFolder)
|
|||||||
if (nullptr == pFolder || !pFolder->existsXml(L"OFD.xml"))
|
if (nullptr == pFolder || !pFolder->existsXml(L"OFD.xml"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
XmlUtils::CXmlLiteReader oLiteReader;
|
CXmlReader oLiteReader;
|
||||||
if (!oLiteReader.FromFile(pFolder->getFullFilePath(L"OFD.xml")) || !oLiteReader.ReadNextNode() || L"ofd:OFD" != oLiteReader.GetName())
|
if (!oLiteReader.FromFile(pFolder->getFullFilePath(L"OFD.xml")) || !oLiteReader.ReadNextNode() || L"ofd:OFD" != oLiteReader.GetName())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class CDocInfo
|
|||||||
std::vector<std::wstring> m_arCustomData;
|
std::vector<std::wstring> m_arCustomData;
|
||||||
public:
|
public:
|
||||||
CDocInfo();
|
CDocInfo();
|
||||||
bool Read(XmlUtils::CXmlLiteReader& oLiteReader);
|
bool Read(CXmlReader& oLiteReader);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDocBody
|
class CDocBody
|
||||||
@ -48,7 +48,7 @@ class CDocBody
|
|||||||
std::wstring m_wsSignature;
|
std::wstring m_wsSignature;
|
||||||
public:
|
public:
|
||||||
CDocBody();
|
CDocBody();
|
||||||
static CDocBody* Read(XmlUtils::CXmlLiteReader& oLiteReader, IFolder* pFolder);
|
static CDocBody* Read(CXmlReader& oLiteReader, IFolder* pFolder);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -61,12 +61,12 @@ public:
|
|||||||
|
|
||||||
bool Read(IFolder* pFolder);
|
bool Read(IFolder* pFolder);
|
||||||
|
|
||||||
std::wstring GetDocId() const;
|
// std::wstring GetDocId() const;
|
||||||
std::wstring GetCreationDate() const;
|
// std::wstring GetCreationDate() const;
|
||||||
std::wstring GetCreator() const;
|
// std::wstring GetCreator() const;
|
||||||
std::wstring GetCreatorVersion() const;
|
// std::wstring GetCreatorVersion() const;
|
||||||
|
|
||||||
std::wstring GetpathToDocRoot() const;
|
// std::wstring GetPathToDocRoot() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,9 +3,7 @@
|
|||||||
namespace OFD
|
namespace OFD
|
||||||
{
|
{
|
||||||
CContent::CContent()
|
CContent::CContent()
|
||||||
{
|
{}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
CContent::~CContent()
|
CContent::~CContent()
|
||||||
{
|
{
|
||||||
@ -13,7 +11,7 @@ CContent::~CContent()
|
|||||||
delete pLayer;
|
delete pLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CContent::Read(XmlUtils::CXmlLiteReader& oLiteReader)
|
bool CContent::Read(CXmlReader& oLiteReader)
|
||||||
{
|
{
|
||||||
if (L"ofd:Content" != oLiteReader.GetName())
|
if (L"ofd:Content" != oLiteReader.GetName())
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -12,7 +12,7 @@ public:
|
|||||||
CContent();
|
CContent();
|
||||||
~CContent();
|
~CContent();
|
||||||
|
|
||||||
bool Read(XmlUtils::CXmlLiteReader& oLiteReader);
|
bool Read(CXmlReader& oLiteReader);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
namespace OFD
|
namespace OFD
|
||||||
{
|
{
|
||||||
CGraphicUnit::CGraphicUnit(XmlUtils::CXmlLiteReader& oLiteReader)
|
CGraphicUnit::CGraphicUnit(CXmlReader& oLiteReader)
|
||||||
: m_bVisible(true), m_dLineWidth(0.353), m_eCap(ECap::Butt),
|
: m_bVisible(true), m_dLineWidth(0.353), m_eCap(ECap::Butt),
|
||||||
m_eJoin(EJoin::Miter), m_dMiterLimit(4.234), m_dDashOffset(0.),
|
m_eJoin(EJoin::Miter), m_dMiterLimit(4.234), m_dDashOffset(0.),
|
||||||
m_uchAlpha(255)
|
m_uchAlpha(255)
|
||||||
{
|
{
|
||||||
if (0 == oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
if (0 == oLiteReader.GetAttributesCount() || !oLiteReader.MoveToFirstAttribute())
|
||||||
return;
|
return;
|
||||||
@ -18,17 +18,17 @@ CGraphicUnit::CGraphicUnit(XmlUtils::CXmlLiteReader& oLiteReader)
|
|||||||
wsAttributeName = oLiteReader.GetName();
|
wsAttributeName = oLiteReader.GetName();
|
||||||
|
|
||||||
if (L"Boundary" == wsAttributeName)
|
if (L"Boundary" == wsAttributeName)
|
||||||
m_oBoundary.Read(oLiteReader.GetText());
|
m_oBoundary.Read(oLiteReader.GetTextA());
|
||||||
else if (L"Name" == wsAttributeName)
|
else if (L"Name" == wsAttributeName)
|
||||||
m_wsName = oLiteReader.GetText();
|
m_wsName = oLiteReader.GetText();
|
||||||
else if (L"Visible" == wsAttributeName)
|
else if (L"Visible" == wsAttributeName)
|
||||||
m_bVisible = XmlUtils::GetBoolean(oLiteReader.GetText());
|
m_bVisible = oLiteReader.GetBoolean(true);
|
||||||
else if (L"CTM" == wsAttributeName)
|
else if (L"CTM" == wsAttributeName)
|
||||||
m_oCTM.Read(oLiteReader.GetText());
|
m_oCTM.Read(oLiteReader.GetTextA());
|
||||||
else if (L"DrawParam" == wsAttributeName)
|
else if (L"DrawParam" == wsAttributeName)
|
||||||
m_unDrawParam = XmlUtils::GetUInteger(oLiteReader.GetText());
|
m_unDrawParam = oLiteReader.GetUInteger(true);
|
||||||
else if (L"LineWidth" == wsAttributeName)
|
else if (L"LineWidth" == wsAttributeName)
|
||||||
m_dLineWidth = XmlUtils::GetDouble(oLiteReader.GetText());
|
m_dLineWidth = oLiteReader.GetDouble(true);
|
||||||
else if (L"Cap" == wsAttributeName)
|
else if (L"Cap" == wsAttributeName)
|
||||||
{
|
{
|
||||||
const std::wstring wsValue{oLiteReader.GetText()};
|
const std::wstring wsValue{oLiteReader.GetText()};
|
||||||
@ -52,11 +52,11 @@ CGraphicUnit::CGraphicUnit(XmlUtils::CXmlLiteReader& oLiteReader)
|
|||||||
m_eJoin = EJoin::Bevel;
|
m_eJoin = EJoin::Bevel;
|
||||||
}
|
}
|
||||||
else if (L"MiterLimit" == wsAttributeName)
|
else if (L"MiterLimit" == wsAttributeName)
|
||||||
m_dMiterLimit = XmlUtils::GetDouble(oLiteReader.GetText());
|
m_dMiterLimit = oLiteReader.GetDouble(true);
|
||||||
else if (L"DashOffset" == wsAttributeName)
|
else if (L"DashOffset" == wsAttributeName)
|
||||||
m_dDashOffset = XmlUtils::GetDouble(oLiteReader.GetText());
|
m_dDashOffset = oLiteReader.GetDouble(true);
|
||||||
else if (L"Alpha" == wsAttributeName)
|
else if (L"Alpha" == wsAttributeName)
|
||||||
m_uchAlpha = XmlUtils::GetUInteger(oLiteReader.GetText());
|
m_uchAlpha = oLiteReader.GetUInteger(true);
|
||||||
} while (oLiteReader.MoveToNextAttribute());
|
} while (oLiteReader.MoveToNextAttribute());
|
||||||
|
|
||||||
oLiteReader.MoveToElement();
|
oLiteReader.MoveToElement();
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#ifndef GRAPHICUNIT_H
|
#ifndef GRAPHICUNIT_H
|
||||||
#define GRAPHICUNIT_H
|
#define GRAPHICUNIT_H
|
||||||
|
|
||||||
#include "../../../DesktopEditor/xml/include/xmlutils.h"
|
#include "../Utils/XmlReader.h"
|
||||||
#include "../Utils/Types.h"
|
#include "../Utils/Types.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ class CGraphicUnit
|
|||||||
std::vector<double> m_arDashPattern;
|
std::vector<double> m_arDashPattern;
|
||||||
unsigned char m_uchAlpha;
|
unsigned char m_uchAlpha;
|
||||||
public:
|
public:
|
||||||
CGraphicUnit(XmlUtils::CXmlLiteReader& oLiteReader);
|
CGraphicUnit(CXmlReader& oLiteReader);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#ifndef IPAGEBLOCK_H
|
#ifndef IPAGEBLOCK_H
|
||||||
#define IPAGEBLOCK_H
|
#define IPAGEBLOCK_H
|
||||||
|
|
||||||
#include "../../../DesktopEditor/xml/include/xmlutils.h"
|
#include "../Utils/XmlReader.h"
|
||||||
|
|
||||||
namespace OFD
|
namespace OFD
|
||||||
{
|
{
|
||||||
@ -11,7 +11,7 @@ class IPageBlock
|
|||||||
public:
|
public:
|
||||||
IPageBlock(){};
|
IPageBlock(){};
|
||||||
virtual ~IPageBlock(){};
|
virtual ~IPageBlock(){};
|
||||||
virtual bool Read(XmlUtils::CXmlLiteReader& oLiteReader) = 0;
|
virtual bool Read(CXmlReader& oLiteReader) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
namespace OFD
|
namespace OFD
|
||||||
{
|
{
|
||||||
CLayer::CLayer(XmlUtils::CXmlLiteReader& oLiteReader)
|
CLayer::CLayer(CXmlReader& oLiteReader)
|
||||||
: m_eType(EType::Body)
|
: m_eType(EType::Body)
|
||||||
{
|
{
|
||||||
Read(oLiteReader);
|
Read(oLiteReader);
|
||||||
@ -18,7 +18,7 @@ CLayer::~CLayer()
|
|||||||
delete pPageBlock;
|
delete pPageBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CLayer::Read(XmlUtils::CXmlLiteReader& oLiteReader)
|
bool CLayer::Read(CXmlReader& oLiteReader)
|
||||||
{
|
{
|
||||||
if (L"ofd:Layer" != oLiteReader.GetName())
|
if (L"ofd:Layer" != oLiteReader.GetName())
|
||||||
return false;
|
return false;
|
||||||
@ -28,7 +28,7 @@ bool CLayer::Read(XmlUtils::CXmlLiteReader& oLiteReader)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (L"ID" == oLiteReader.GetName())
|
if (L"ID" == oLiteReader.GetName())
|
||||||
m_unID = XmlUtils::GetUInteger(oLiteReader.GetText());
|
m_unID = oLiteReader.GetUInteger(true);
|
||||||
} while (oLiteReader.MoveToNextAttribute());
|
} while (oLiteReader.MoveToNextAttribute());
|
||||||
|
|
||||||
oLiteReader.MoveToElement();
|
oLiteReader.MoveToElement();
|
||||||
|
|||||||
@ -17,10 +17,10 @@ class CLayer
|
|||||||
unsigned int m_unID;
|
unsigned int m_unID;
|
||||||
std::vector<IPageBlock*> m_arPageBlocks;
|
std::vector<IPageBlock*> m_arPageBlocks;
|
||||||
public:
|
public:
|
||||||
CLayer(XmlUtils::CXmlLiteReader& oLiteReader);
|
CLayer(CXmlReader& oLiteReader);
|
||||||
~CLayer();
|
~CLayer();
|
||||||
|
|
||||||
bool Read(XmlUtils::CXmlLiteReader& oLiteReader);
|
bool Read(CXmlReader& oLiteReader);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,10 @@
|
|||||||
#include "TextObject.h"
|
#include "TextObject.h"
|
||||||
|
|
||||||
#include "../Utils/Utils.h"
|
|
||||||
|
|
||||||
namespace OFD
|
namespace OFD
|
||||||
{
|
{
|
||||||
CTextCode::CTextCode(XmlUtils::CXmlLiteReader& oLiteReader)
|
CTextCode::CTextCode(CXmlReader& oLiteReader)
|
||||||
{
|
{
|
||||||
if (NO_VALID_NODE(oLiteReader, L"ofd:TextCode"))
|
if (L"ofd:TextCode" != oLiteReader.GetName() || oLiteReader.IsEmptyElement() || !oLiteReader.IsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (0 != oLiteReader.GetAttributesCount() && oLiteReader.MoveToFirstAttribute())
|
if (0 != oLiteReader.GetAttributesCount() && oLiteReader.MoveToFirstAttribute())
|
||||||
@ -18,13 +16,13 @@ CTextCode::CTextCode(XmlUtils::CXmlLiteReader& oLiteReader)
|
|||||||
wsAttributeName = oLiteReader.GetName();
|
wsAttributeName = oLiteReader.GetName();
|
||||||
|
|
||||||
if (L"X" == wsAttributeName)
|
if (L"X" == wsAttributeName)
|
||||||
m_dX = XmlUtils::GetDouble(oLiteReader.GetText());
|
m_dX = oLiteReader.GetDouble(true);
|
||||||
else if (L"Y" == wsAttributeName)
|
else if (L"Y" == wsAttributeName)
|
||||||
m_dY = XmlUtils::GetDouble(oLiteReader.GetText());
|
m_dY = oLiteReader.GetDouble(true);
|
||||||
else if (L"DeltaX" == wsAttributeName)
|
else if (L"DeltaX" == wsAttributeName)
|
||||||
m_arDeltaX = GetDoubleValues(oLiteReader.GetText());
|
m_arDeltaX = oLiteReader.GetArrayDoubles(true);
|
||||||
else if (L"DeltaY" == wsAttributeName)
|
else if (L"DeltaY" == wsAttributeName)
|
||||||
m_arDeltaY = GetDoubleValues(oLiteReader.GetText());
|
m_arDeltaY = oLiteReader.GetArrayDoubles(true);
|
||||||
} while (oLiteReader.MoveToNextAttribute());
|
} while (oLiteReader.MoveToNextAttribute());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,12 +31,12 @@ CTextCode::CTextCode(XmlUtils::CXmlLiteReader& oLiteReader)
|
|||||||
m_wsText = oLiteReader.GetText2();
|
m_wsText = oLiteReader.GetText2();
|
||||||
}
|
}
|
||||||
|
|
||||||
CTextObject::CTextObject(XmlUtils::CXmlLiteReader& oLiteReader)
|
CTextObject::CTextObject(CXmlReader& oLiteReader)
|
||||||
: CGraphicUnit(oLiteReader),
|
: CGraphicUnit(oLiteReader),
|
||||||
m_bStroke(false), m_bFill(false), m_dHScale(1.),
|
m_bStroke(false), m_bFill(false), m_dHScale(1.),
|
||||||
m_unReadDirection(0), m_unCharDirection(0), m_unWeight(400),
|
m_unReadDirection(0), m_unCharDirection(0), m_unWeight(400),
|
||||||
m_bItalic(false),
|
m_bItalic(false),
|
||||||
m_pFillColor(nullptr), m_pStrokeColor(nullptr)
|
m_pFillColor(nullptr), m_pStrokeColor(nullptr)
|
||||||
{
|
{
|
||||||
CTextObject::Read(oLiteReader);
|
CTextObject::Read(oLiteReader);
|
||||||
}
|
}
|
||||||
@ -55,9 +53,9 @@ CTextObject::~CTextObject()
|
|||||||
delete pTextCode;
|
delete pTextCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTextObject::Read(XmlUtils::CXmlLiteReader& oLiteReader)
|
bool CTextObject::Read(CXmlReader& oLiteReader)
|
||||||
{
|
{
|
||||||
if (NO_VALID_NODE(oLiteReader, L"ofd:TextObject"))
|
if (L"ofd:TextObject" != oLiteReader.GetName() || oLiteReader.IsEmptyElement() || !oLiteReader.IsValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (0 != oLiteReader.GetAttributesCount() && oLiteReader.MoveToFirstAttribute())
|
if (0 != oLiteReader.GetAttributesCount() && oLiteReader.MoveToFirstAttribute())
|
||||||
@ -69,25 +67,23 @@ bool CTextObject::Read(XmlUtils::CXmlLiteReader& oLiteReader)
|
|||||||
wsAttributeName = oLiteReader.GetName();
|
wsAttributeName = oLiteReader.GetName();
|
||||||
|
|
||||||
if (L"Font" == wsAttributeName)
|
if (L"Font" == wsAttributeName)
|
||||||
{
|
m_unFont = oLiteReader.GetUInteger(true);
|
||||||
m_unFont = XmlUtils::GetUInteger(oLiteReader.GetText());
|
|
||||||
}
|
|
||||||
else if (L"Size" == wsAttributeName)
|
else if (L"Size" == wsAttributeName)
|
||||||
m_dSize = XmlUtils::GetDouble(oLiteReader.GetText());
|
m_dSize = oLiteReader.GetDouble(true);
|
||||||
else if (L"Stroke" == wsAttributeName)
|
else if (L"Stroke" == wsAttributeName)
|
||||||
m_bStroke = XmlUtils::GetBoolean(oLiteReader.GetText());
|
m_bStroke = oLiteReader.GetBoolean(true);
|
||||||
else if (L"Fill" == wsAttributeName)
|
else if (L"Fill" == wsAttributeName)
|
||||||
m_bFill = XmlUtils::GetBoolean(oLiteReader.GetText());
|
m_bFill = oLiteReader.GetBoolean(true);
|
||||||
else if (L"HScale" == wsAttributeName)
|
else if (L"HScale" == wsAttributeName)
|
||||||
m_dHScale = XmlUtils::GetDouble(oLiteReader.GetText());
|
m_dHScale = oLiteReader.GetDouble(true);
|
||||||
else if (L"ReadDirection" == wsAttributeName)
|
else if (L"ReadDirection" == wsAttributeName)
|
||||||
m_unReadDirection = XmlUtils::GetUInteger(oLiteReader.GetText());
|
m_unReadDirection = oLiteReader.GetUInteger(true);
|
||||||
else if (L"CharDirection" == wsAttributeName)
|
else if (L"CharDirection" == wsAttributeName)
|
||||||
m_unCharDirection = XmlUtils::GetUInteger(oLiteReader.GetText());
|
m_unCharDirection =oLiteReader.GetUInteger(true);
|
||||||
else if (L"Weight" == wsAttributeName)
|
else if (L"Weight" == wsAttributeName)
|
||||||
m_unWeight = XmlUtils::GetUInteger(oLiteReader.GetText());
|
m_unWeight = oLiteReader.GetUInteger(true);
|
||||||
else if (L"Italic" == wsAttributeName)
|
else if (L"Italic" == wsAttributeName)
|
||||||
m_bItalic = XmlUtils::GetBoolean(oLiteReader.GetText());
|
m_bItalic = oLiteReader.GetBoolean(true);
|
||||||
} while (oLiteReader.MoveToNextAttribute());
|
} while (oLiteReader.MoveToNextAttribute());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,14 +101,14 @@ bool CTextObject::Read(XmlUtils::CXmlLiteReader& oLiteReader)
|
|||||||
if (nullptr != m_pFillColor)
|
if (nullptr != m_pFillColor)
|
||||||
delete m_pFillColor;
|
delete m_pFillColor;
|
||||||
|
|
||||||
m_pFillColor = new TColor(oLiteReader);
|
m_pFillColor = new CColor(oLiteReader);
|
||||||
}
|
}
|
||||||
else if (L"ofd:StrokeColor" == wsNodeName && m_bStroke)
|
else if (L"ofd:StrokeColor" == wsNodeName && m_bStroke)
|
||||||
{
|
{
|
||||||
if (nullptr != m_pStrokeColor)
|
if (nullptr != m_pStrokeColor)
|
||||||
delete m_pStrokeColor;
|
delete m_pStrokeColor;
|
||||||
|
|
||||||
m_pStrokeColor = new TColor(oLiteReader);
|
m_pStrokeColor = new CColor(oLiteReader);
|
||||||
}
|
}
|
||||||
else if (L"ofd:TextCode" == wsNodeName)
|
else if (L"ofd:TextCode" == wsNodeName)
|
||||||
m_arTextCodes.push_back(new CTextCode(oLiteReader));
|
m_arTextCodes.push_back(new CTextCode(oLiteReader));
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
#include "IPageBlock.h"
|
#include "IPageBlock.h"
|
||||||
#include "GraphicUnit.h"
|
#include "GraphicUnit.h"
|
||||||
|
|
||||||
|
#include "../Types/Color.h"
|
||||||
|
|
||||||
namespace OFD
|
namespace OFD
|
||||||
{
|
{
|
||||||
class CTextCode
|
class CTextCode
|
||||||
@ -16,7 +18,7 @@ class CTextCode
|
|||||||
|
|
||||||
std::wstring m_wsText;
|
std::wstring m_wsText;
|
||||||
public:
|
public:
|
||||||
CTextCode(XmlUtils::CXmlLiteReader& oLiteReader);
|
CTextCode(CXmlReader& oLiteReader);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CTextObject : public IPageBlock, public CGraphicUnit
|
class CTextObject : public IPageBlock, public CGraphicUnit
|
||||||
@ -31,15 +33,15 @@ class CTextObject : public IPageBlock, public CGraphicUnit
|
|||||||
unsigned int m_unWeight;
|
unsigned int m_unWeight;
|
||||||
bool m_bItalic;
|
bool m_bItalic;
|
||||||
|
|
||||||
TColor* m_pFillColor;
|
CColor* m_pFillColor;
|
||||||
TColor* m_pStrokeColor;
|
CColor* m_pStrokeColor;
|
||||||
|
|
||||||
std::vector<CTextCode*> m_arTextCodes;
|
std::vector<CTextCode*> m_arTextCodes;
|
||||||
public:
|
public:
|
||||||
CTextObject(XmlUtils::CXmlLiteReader& oLiteReader);
|
CTextObject(CXmlReader& oLiteReader);
|
||||||
~CTextObject();
|
~CTextObject();
|
||||||
|
|
||||||
virtual bool Read(XmlUtils::CXmlLiteReader& oLiteReader) override;
|
virtual bool Read(CXmlReader& oLiteReader) override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,11 @@
|
|||||||
#include "Document.h"
|
#include "Document.h"
|
||||||
|
|
||||||
#include "../../OOXML/Base/Unit.h"
|
|
||||||
|
|
||||||
namespace OFD
|
namespace OFD
|
||||||
{
|
{
|
||||||
CPageArea::CPageArea()
|
CPageArea::CPageArea()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool CPageArea::Read(XmlUtils::CXmlLiteReader& oLiteReader)
|
bool CPageArea::Read(CXmlReader& oLiteReader)
|
||||||
{
|
{
|
||||||
if (L"ofd:PageArea" != oLiteReader.GetName())
|
if (L"ofd:PageArea" != oLiteReader.GetName())
|
||||||
return false;
|
return false;
|
||||||
@ -20,13 +18,13 @@ bool CPageArea::Read(XmlUtils::CXmlLiteReader& oLiteReader)
|
|||||||
wsNodeName = oLiteReader.GetName();
|
wsNodeName = oLiteReader.GetName();
|
||||||
|
|
||||||
if (L"ofd:PhysicalBox" == wsNodeName)
|
if (L"ofd:PhysicalBox" == wsNodeName)
|
||||||
m_oPhysicalBox.Read(oLiteReader.GetText2());
|
m_oPhysicalBox.Read(oLiteReader.GetText2A());
|
||||||
else if (L"ofd:ApplicationBox" == wsNodeName)
|
else if (L"ofd:ApplicationBox" == wsNodeName)
|
||||||
m_oApplicationBox.Read(oLiteReader.GetText2());
|
m_oApplicationBox.Read(oLiteReader.GetText2A());
|
||||||
else if (L"ofd:ContentBox" == wsNodeName)
|
else if (L"ofd:ContentBox" == wsNodeName)
|
||||||
m_oContentBox.Read(oLiteReader.GetText2());
|
m_oContentBox.Read(oLiteReader.GetText2A());
|
||||||
else if (L"ofd:BleedBox" == wsNodeName)
|
else if (L"ofd:BleedBox" == wsNodeName)
|
||||||
m_oBleedBox.Read(oLiteReader.GetText2());
|
m_oBleedBox.Read(oLiteReader.GetText2A());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -36,7 +34,7 @@ CCommonData::CCommonData()
|
|||||||
: m_unMaxUnitID(0)
|
: m_unMaxUnitID(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool CCommonData::Read(XmlUtils::CXmlLiteReader& oLiteReader)
|
bool CCommonData::Read(CXmlReader& oLiteReader)
|
||||||
{
|
{
|
||||||
if (L"ofd:CommonData" != oLiteReader.GetName())
|
if (L"ofd:CommonData" != oLiteReader.GetName())
|
||||||
return false;
|
return false;
|
||||||
@ -55,7 +53,7 @@ bool CCommonData::Read(XmlUtils::CXmlLiteReader& oLiteReader)
|
|||||||
// m_oPublicRes.Read();
|
// m_oPublicRes.Read();
|
||||||
}
|
}
|
||||||
else if (L"ofd:MaxUnitID" == wsNodeName)
|
else if (L"ofd:MaxUnitID" == wsNodeName)
|
||||||
m_unMaxUnitID = XmlUtils::GetUInteger(oLiteReader.GetText2());
|
m_unMaxUnitID = oLiteReader.GetUInteger();
|
||||||
// else if (L"ofd:DocumentRes" == wsNodeName)
|
// else if (L"ofd:DocumentRes" == wsNodeName)
|
||||||
// else if (L"ofd:TemplatePage" == wsNodeName)
|
// else if (L"ofd:TemplatePage" == wsNodeName)
|
||||||
// else if (L"ofd:DefaultCS" == wsNodeName)
|
// else if (L"ofd:DefaultCS" == wsNodeName)
|
||||||
@ -64,6 +62,30 @@ bool CCommonData::Read(XmlUtils::CXmlLiteReader& oLiteReader)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CPermission::CPermission()
|
||||||
|
: m_bEdit(true), m_bAnnot(true), m_bExport(true),
|
||||||
|
m_bSignature(true), m_bWatermark(true), m_bPrintScreen(true)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool CPermission::Read(CXmlReader& oLiteReader)
|
||||||
|
{
|
||||||
|
if (L"ofd:Permission" != oLiteReader.GetName())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const int nDepth = oLiteReader.GetDepth();
|
||||||
|
std::wstring wsNodeName;
|
||||||
|
|
||||||
|
while (oLiteReader.ReadNextSiblingNode(nDepth))
|
||||||
|
{
|
||||||
|
wsNodeName = oLiteReader.GetName();
|
||||||
|
|
||||||
|
if (L"ofd:Edit" == wsNodeName)
|
||||||
|
m_bEdit = oLiteReader.GetBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
CDocument::CDocument()
|
CDocument::CDocument()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -83,7 +105,7 @@ bool CDocument::Read(const std::wstring& wsFilePath)
|
|||||||
if (wsFilePath.empty())
|
if (wsFilePath.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
XmlUtils::CXmlLiteReader oLiteReader;
|
CXmlReader oLiteReader;
|
||||||
if (!oLiteReader.FromFile(wsFilePath) || !oLiteReader.ReadNextNode() || L"ofd:Document" != oLiteReader.GetName())
|
if (!oLiteReader.FromFile(wsFilePath) || !oLiteReader.ReadNextNode() || L"ofd:Document" != oLiteReader.GetName())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -111,7 +133,7 @@ bool CDocument::Read(const std::wstring& wsFilePath)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (L"ID" == oLiteReader.GetName())
|
if (L"ID" == oLiteReader.GetName())
|
||||||
nID = XmlUtils::GetUInteger(oLiteReader.GetText());
|
nID = oLiteReader.GetInteger(true);
|
||||||
else if (L"BaseLoc" == oLiteReader.GetName())
|
else if (L"BaseLoc" == oLiteReader.GetName())
|
||||||
wsBaseLoc = oLiteReader.GetText();
|
wsBaseLoc = oLiteReader.GetText();
|
||||||
}while (oLiteReader.MoveToNextAttribute());
|
}while (oLiteReader.MoveToNextAttribute());
|
||||||
|
|||||||
@ -17,7 +17,7 @@ class CPageArea
|
|||||||
public:
|
public:
|
||||||
CPageArea();
|
CPageArea();
|
||||||
|
|
||||||
bool Read(XmlUtils::CXmlLiteReader& oLiteReader);
|
bool Read(CXmlReader& oLiteReader);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CCommonData
|
class CCommonData
|
||||||
@ -28,7 +28,21 @@ class CCommonData
|
|||||||
public:
|
public:
|
||||||
CCommonData();
|
CCommonData();
|
||||||
|
|
||||||
bool Read(XmlUtils::CXmlLiteReader& oLiteReader);
|
bool Read(CXmlReader& oLiteReader);
|
||||||
|
};
|
||||||
|
|
||||||
|
class CPermission
|
||||||
|
{
|
||||||
|
bool m_bEdit;
|
||||||
|
bool m_bAnnot;
|
||||||
|
bool m_bExport;
|
||||||
|
bool m_bSignature;
|
||||||
|
bool m_bWatermark;
|
||||||
|
bool m_bPrintScreen;
|
||||||
|
public:
|
||||||
|
CPermission();
|
||||||
|
|
||||||
|
bool Read(CXmlReader& oLiteReader);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDocument
|
class CDocument
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
#include "Page.h"
|
#include "Page.h"
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include "../../DesktopEditor/common/File.h"
|
#include "../../DesktopEditor/common/File.h"
|
||||||
#include "../../DesktopEditor/common/Path.h"
|
#include "../../DesktopEditor/common/Path.h"
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ CPage* CPage::Read(const std::wstring& wsFilePath)
|
|||||||
wsNormalizedPath = NSSystemPath::Combine(wsNormalizedPath, L"Content.xml");
|
wsNormalizedPath = NSSystemPath::Combine(wsNormalizedPath, L"Content.xml");
|
||||||
|
|
||||||
|
|
||||||
XmlUtils::CXmlLiteReader oLiteReader;
|
CXmlReader oLiteReader;
|
||||||
if (!oLiteReader.FromFile(wsNormalizedPath) || !oLiteReader.ReadNextNode() || L"ofd:Page" != oLiteReader.GetName())
|
if (!oLiteReader.FromFile(wsNormalizedPath) || !oLiteReader.ReadNextNode() || L"ofd:Page" != oLiteReader.GetName())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|||||||
15
OFDFile/src/Types/Color.cpp
Normal file
15
OFDFile/src/Types/Color.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "Color.h"
|
||||||
|
|
||||||
|
namespace OFD
|
||||||
|
{
|
||||||
|
CColor::CColor(CXmlReader& oXmlReader)
|
||||||
|
{
|
||||||
|
Read(oXmlReader);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CColor::Read(CXmlReader& oXmlReader)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
32
OFDFile/src/Types/Color.h
Normal file
32
OFDFile/src/Types/Color.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#ifndef COLOR_H
|
||||||
|
#define COLOR_H
|
||||||
|
|
||||||
|
#include "../Utils/XmlReader.h"
|
||||||
|
|
||||||
|
namespace OFD
|
||||||
|
{
|
||||||
|
class CColor
|
||||||
|
{
|
||||||
|
struct TColorChannels
|
||||||
|
{
|
||||||
|
unsigned char m_chRed;
|
||||||
|
BYTE m_chGreen;
|
||||||
|
BYTE m_chBlue;
|
||||||
|
} m_oValue;
|
||||||
|
|
||||||
|
int m_nIndex;
|
||||||
|
unsigned int m_unColorSpace;
|
||||||
|
BYTE m_chAlpha;
|
||||||
|
// Pattern
|
||||||
|
// AxialShd
|
||||||
|
// RadialShd
|
||||||
|
// GouraudShd
|
||||||
|
// LaGouraudhd
|
||||||
|
public:
|
||||||
|
CColor(CXmlReader& oXmlReader);
|
||||||
|
|
||||||
|
bool Read(CXmlReader& oXmlReader);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // COLOR_H
|
||||||
@ -1,8 +1,6 @@
|
|||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
|
|
||||||
#include <vector>
|
#include "Utils.h"
|
||||||
#include "../../../DesktopEditor/common/StringExt.h"
|
|
||||||
#include "../../../OOXML/Base/Unit.h"
|
|
||||||
|
|
||||||
namespace OFD
|
namespace OFD
|
||||||
{
|
{
|
||||||
@ -15,35 +13,19 @@ bool TBox::Empty() const
|
|||||||
return m_dWidth < OFD_EPSILON || m_dHeight < OFD_EPSILON;
|
return m_dWidth < OFD_EPSILON || m_dHeight < OFD_EPSILON;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TBox::Read(const std::wstring& wsValue)
|
bool TBox::Read(const std::string& sValue)
|
||||||
{
|
{
|
||||||
const std::vector<std::wstring> arValues{NSStringExt::Split(wsValue, L' ')};
|
const std::vector<std::string> arValues{Split(sValue, ' ')};
|
||||||
|
|
||||||
if (4 > arValues.size())
|
if (4 > arValues.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_dX = XmlUtils::GetDouble(arValues[0]);
|
if (!StringToDouble(arValues[0], m_dX) ||
|
||||||
m_dY = XmlUtils::GetDouble(arValues[1]);
|
!StringToDouble(arValues[1], m_dY) ||
|
||||||
m_dWidth = XmlUtils::GetDouble(arValues[2]);
|
!StringToDouble(arValues[2], m_dWidth) ||
|
||||||
m_dHeight = XmlUtils::GetDouble(arValues[3]);
|
!StringToDouble(arValues[3], m_dHeight))
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TColor::TColor()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
TColor::TColor(XmlUtils::CXmlLiteReader& oLiteReader)
|
|
||||||
{
|
|
||||||
Read(oLiteReader);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TColor::Read(XmlUtils::CXmlLiteReader& oLiteReader)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,13 +2,10 @@
|
|||||||
#define TYPES_H
|
#define TYPES_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../../../DesktopEditor/xml/include/xmlutils.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace OFD
|
namespace OFD
|
||||||
{
|
{
|
||||||
#define OFD_EPSILON 0.0001
|
#define OFD_EPSILON 0.0001
|
||||||
|
|
||||||
struct TBox
|
struct TBox
|
||||||
{
|
{
|
||||||
double m_dX;
|
double m_dX;
|
||||||
@ -19,15 +16,7 @@ struct TBox
|
|||||||
TBox();
|
TBox();
|
||||||
|
|
||||||
bool Empty() const;
|
bool Empty() const;
|
||||||
bool Read(const std::wstring& wsValue);
|
bool Read(const std::string& wsValue);
|
||||||
};
|
|
||||||
|
|
||||||
struct TColor
|
|
||||||
{
|
|
||||||
TColor();
|
|
||||||
TColor(XmlUtils::CXmlLiteReader& oLiteReader);
|
|
||||||
|
|
||||||
bool Read(XmlUtils::CXmlLiteReader& oLiteReader);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,49 +1,96 @@
|
|||||||
#ifndef UTILS_H
|
#ifndef UTILS_H
|
||||||
#define UTILS_H
|
#define UTILS_H
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../../../OOXML/Base/Unit.h"
|
#include <vector>
|
||||||
#include "../../../DesktopEditor/common/StringExt.h"
|
#include <sstream>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
bool GetBoolean(const std::wstring& wsValue)
|
namespace OFD
|
||||||
{
|
{
|
||||||
return false;
|
inline std::vector<std::string> Split(const std::string& sValue, char chDelim)
|
||||||
|
{
|
||||||
|
if (sValue.empty())
|
||||||
|
return std::vector<std::string>();
|
||||||
|
|
||||||
|
std::vector<std::string> arValues;
|
||||||
|
std::stringstream oStringStream(sValue);
|
||||||
|
std::string sItem;
|
||||||
|
|
||||||
|
while (std::getline(oStringStream, sItem, chDelim))
|
||||||
|
arValues.push_back(sItem);
|
||||||
|
|
||||||
|
return arValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetInt(const std::wstring& wsValue)
|
inline bool StringToBoolean(const std::string& sValue, bool& bValue)
|
||||||
{
|
{
|
||||||
return 0;
|
//TODO:: скорректировать метод, если возможно чтение не стандартных значений с плавающей запятой
|
||||||
|
if (sValue.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
size_t unStart = sValue.find_first_not_of(" \t\n\r\f\v");
|
||||||
|
|
||||||
|
if (std::string::npos == unStart)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
size_t unEnd = sValue.find_last_not_of(" \t\n\r\f\v");
|
||||||
|
|
||||||
|
std::string sTrimmed = sValue.substr(unStart, unEnd - unStart + 1);
|
||||||
|
|
||||||
|
std::transform(sTrimmed.begin(), sTrimmed.end(), sTrimmed.begin(),
|
||||||
|
[](unsigned char c){ return std::tolower(c); });
|
||||||
|
|
||||||
|
return "true" == sTrimmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GetUInt(const std::wstring& wsValue)
|
inline bool StringToInteger(const std::string& sValue, int& nValue)
|
||||||
{
|
{
|
||||||
return 0;
|
//TODO:: скорректировать метод, если возможно чтение не стандартных значений с плавающей запятой
|
||||||
|
if (sValue.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char* pEnd = nullptr;
|
||||||
|
|
||||||
|
nValue = std::strtol(sValue.c_str(), &pEnd, 10);
|
||||||
|
|
||||||
|
if (pEnd == sValue.c_str() || '\0' != *pEnd)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
double GetDouble(const std::wstring& wsValue)
|
inline bool StringToUInteger(const std::string& sValue, unsigned int& unValue)
|
||||||
{
|
{
|
||||||
return 0.;
|
//TODO:: скорректировать метод, если возможно чтение не стандартных значений с плавающей запятой
|
||||||
|
if (sValue.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char* pEnd = nullptr;
|
||||||
|
|
||||||
|
unValue = std::strtoul(sValue.c_str(), &pEnd, 10);
|
||||||
|
|
||||||
|
if (pEnd == sValue.c_str() || '\0' != *pEnd)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool StringToDouble(const std::string& sValue, double& dValue)
|
||||||
|
|
||||||
std::vector<double> GetDoubleValues(const std::wstring& wsValue)
|
|
||||||
{
|
{
|
||||||
const std::vector<std::wstring> arValues{NSStringExt::Split(wsValue, L' ')};
|
//TODO:: скорректировать метод, если возможно чтение не стандартных значений с плавающей запятой
|
||||||
|
if (sValue.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
if(arValues.empty())
|
char* pEnd = nullptr;
|
||||||
return std::vector<double>();
|
|
||||||
|
|
||||||
std::vector<double> arDoubleValues(arValues.size());
|
dValue = std::strtod(sValue.c_str(), &pEnd);
|
||||||
|
|
||||||
for (unsigned int unIndex = 0; unIndex < arValues.size(); ++unIndex)
|
if (pEnd == sValue.c_str() || '\0' != *pEnd)
|
||||||
arDoubleValues[unIndex] = XmlUtils::GetDouble(arValues[unIndex]);
|
return false;
|
||||||
|
|
||||||
return arDoubleValues;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NO_VALID_NODE(lite_reader, node_name) node_name != oLiteReader.GetName() || oLiteReader.IsEmptyElement() || !oLiteReader.IsValid()
|
|
||||||
|
|
||||||
#endif // UTILS_H
|
#endif // UTILS_H
|
||||||
|
|||||||
63
OFDFile/src/Utils/XmlReader.cpp
Normal file
63
OFDFile/src/Utils/XmlReader.cpp
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#include "XmlReader.h"
|
||||||
|
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
|
namespace OFD
|
||||||
|
{
|
||||||
|
CXmlReader::CXmlReader()
|
||||||
|
{}
|
||||||
|
|
||||||
|
std::wstring CXmlReader::GetTextValue(bool bIsAttribute)
|
||||||
|
{
|
||||||
|
return (bIsAttribute) ? XmlUtils::CXmlLiteReader::GetText() : XmlUtils::CXmlLiteReader::GetText2();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CXmlReader::GetTextValueA(bool bIsAttribute)
|
||||||
|
{
|
||||||
|
return (bIsAttribute) ? XmlUtils::CXmlLiteReader::GetTextA() : XmlUtils::CXmlLiteReader::GetText2A();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CXmlReader::GetBoolean(bool bIsAttribute)
|
||||||
|
{
|
||||||
|
bool bValue = false;
|
||||||
|
StringToBoolean(GetTextValueA(bIsAttribute), bValue);
|
||||||
|
return bValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CXmlReader::GetInteger(bool bIsAttribute)
|
||||||
|
{
|
||||||
|
int nValue = 0;
|
||||||
|
StringToInteger(GetTextValueA(bIsAttribute), nValue);
|
||||||
|
return nValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CXmlReader::GetUInteger(bool bIsAttribute)
|
||||||
|
{
|
||||||
|
unsigned int unValue = 0;
|
||||||
|
StringToUInteger(GetTextValueA(bIsAttribute), unValue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double CXmlReader::GetDouble(bool bIsAttribute)
|
||||||
|
{
|
||||||
|
double dValue = 0.;
|
||||||
|
StringToDouble(GetTextValueA(bIsAttribute), dValue);
|
||||||
|
return dValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<double> CXmlReader::GetArrayDoubles(bool bIsAttribute)
|
||||||
|
{
|
||||||
|
const std::vector<std::string> arValues{Split(GetTextValueA(bIsAttribute), ' ')};
|
||||||
|
|
||||||
|
if(arValues.empty())
|
||||||
|
return std::vector<double>();
|
||||||
|
|
||||||
|
std::vector<double> arDoubleValues(arValues.size());
|
||||||
|
|
||||||
|
for (unsigned int unIndex = 0; unIndex < arValues.size(); ++unIndex)
|
||||||
|
if (!StringToDouble(arValues[unIndex], arDoubleValues[unIndex]))
|
||||||
|
return std::vector<double>();
|
||||||
|
|
||||||
|
return arDoubleValues;
|
||||||
|
}
|
||||||
|
}
|
||||||
25
OFDFile/src/Utils/XmlReader.h
Normal file
25
OFDFile/src/Utils/XmlReader.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef XMLREADER_H
|
||||||
|
#define XMLREADER_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include "../../../DesktopEditor/xml/include/xmlutils.h"
|
||||||
|
|
||||||
|
namespace OFD
|
||||||
|
{
|
||||||
|
class CXmlReader : public XmlUtils::CXmlLiteReader
|
||||||
|
{
|
||||||
|
std::wstring GetTextValue(bool bIsAttribute = false);
|
||||||
|
std::string GetTextValueA(bool bIsAttribute = false);
|
||||||
|
public:
|
||||||
|
CXmlReader();
|
||||||
|
|
||||||
|
bool GetBoolean(bool bIsAttribute = false);
|
||||||
|
int GetInteger(bool bIsAttribute = false);
|
||||||
|
unsigned int GetUInteger(bool bIsAttribute = false);
|
||||||
|
double GetDouble(bool bIsAttribute = false);
|
||||||
|
std::vector<double> GetArrayDoubles(bool bIsAttribute = false);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // XMLREADER_H
|
||||||
Reference in New Issue
Block a user