mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
30 Commits
v9.2.0.25
...
feature/te
| Author | SHA1 | Date | |
|---|---|---|---|
| a2fc927b39 | |||
| b6f024b73f | |||
| 3870d23511 | |||
| d2527e5707 | |||
| 81b4ba3493 | |||
| 44e217cf7c | |||
| b5f0b39258 | |||
| 3f6a800dd8 | |||
| 1c8ad7a5c4 | |||
| 8464d3aeb7 | |||
| ed939ebd1d | |||
| fe6c5614d4 | |||
| f0b266793f | |||
| 490281dda0 | |||
| b98b808cda | |||
| 6c77718f17 | |||
| 74a2b3b06f | |||
| 8f3e19a5db | |||
| 0019f589bc | |||
| 200c17ee40 | |||
| 4543bfa6cd | |||
| 16e78d87a4 | |||
| 051597a78a | |||
| 13e03328af | |||
| 04ccd4fe27 | |||
| 4b335fc796 | |||
| 5e177412e2 | |||
| dec13334db | |||
| c8ebcfac87 | |||
| 2931c4b53e |
@ -69,7 +69,6 @@ public:
|
||||
bool isOpenOfficeFormatFile(const std::wstring& fileName, std::wstring& documentID);
|
||||
bool isOnlyOfficeFormatFile(const std::wstring& fileName);
|
||||
bool isMacFormatFile(const std::wstring& fileName);
|
||||
bool isHwpxFile(const std::wstring& fileName);
|
||||
|
||||
bool isDocFormatFile(const std::wstring& fileName);
|
||||
bool isXlsFormatFile(const std::wstring& fileName);
|
||||
@ -100,7 +99,6 @@ public:
|
||||
bool isPdfFormatFile(unsigned char* pBuffer, int dwBytes, std::wstring& documentID);
|
||||
bool isPdfOformFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isOpenOfficeFlatFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isHwpmlFile(unsigned char* pBuffer, int dwBytes);
|
||||
|
||||
bool isBinaryDoctFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isBinaryXlstFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
|
||||
@ -467,18 +467,15 @@ bool COfficeFileFormatChecker::isHwpFile(POLE::Storage* storage)
|
||||
if (storage == NULL)
|
||||
return false;
|
||||
|
||||
unsigned char buffer[17];
|
||||
unsigned char buffer[10];
|
||||
|
||||
POLE::Stream stream(storage, L"FileHeader");
|
||||
|
||||
static constexpr const char* hwpFormatLine = "HWP Document File";
|
||||
|
||||
if (17 == stream.read(buffer, 17) && NULL != strstr((char*)buffer, hwpFormatLine))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
POLE::Stream stream(storage, L"BodyText/Section0");
|
||||
if (stream.read(buffer, 10) < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isXlsFormatFile(POLE::Storage *storage)
|
||||
{
|
||||
if (storage == NULL)
|
||||
@ -814,13 +811,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isHwpxFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
@ -900,10 +890,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT;
|
||||
}
|
||||
else if (isHwpmlFile(bufferDetect, sizeRead))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPML;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
file.CloseFile();
|
||||
}
|
||||
@ -973,8 +959,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
|
||||
else if (0 == sExt.compare(L".hwpx"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX;
|
||||
else if (0 == sExt.compare(L".hml"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPML;
|
||||
|
||||
if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN)
|
||||
return true;
|
||||
@ -1419,31 +1403,6 @@ bool COfficeFileFormatChecker::isMacFormatFile(const std::wstring& fileName)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isHwpxFile(const std::wstring &fileName)
|
||||
{
|
||||
COfficeUtils oOfficeUtils;
|
||||
|
||||
ULONG unSize = 0;
|
||||
BYTE* pBuffer = NULL;
|
||||
|
||||
HRESULT hresult = oOfficeUtils.LoadFileFromArchive(fileName, L"mimetype", &pBuffer, unSize);
|
||||
|
||||
if (hresult != S_OK || NULL == pBuffer)
|
||||
return false;
|
||||
|
||||
static constexpr const char* hwpxFormatLine = "application/hwp+zip";
|
||||
bool bResult = false;
|
||||
|
||||
if (19 <= unSize && NULL != strstr((char *)pBuffer, hwpxFormatLine))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX;
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
delete[] pBuffer;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring &fileName, std::wstring &documentID)
|
||||
{
|
||||
documentID.clear();
|
||||
@ -1609,28 +1568,6 @@ bool COfficeFileFormatChecker::isOpenOfficeFlatFormatFile(unsigned char *pBuffer
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isHwpmlFile(unsigned char *pBuffer, int dwBytes)
|
||||
{
|
||||
if (NULL == pBuffer || dwBytes < 8)
|
||||
return false;
|
||||
|
||||
for (unsigned int unPos = 0; unPos < dwBytes - 8; ++unPos)
|
||||
{
|
||||
if ('<' != pBuffer[unPos])
|
||||
continue;
|
||||
|
||||
if (dwBytes - unPos >= 15 && '!' == pBuffer[unPos + 1] &&
|
||||
0 == memcmp(&pBuffer[unPos], "<!DOCTYPE HWPML", 15))
|
||||
return true;
|
||||
|
||||
if (dwBytes - unPos >= 6 && 0 == memcmp(&pBuffer[unPos], "<HWPML", 6))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isOOXFlatFormatFile(unsigned char *pBuffer, int dwBytes)
|
||||
{
|
||||
if (dwBytes < 8)
|
||||
@ -1739,8 +1676,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".hwp";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX:
|
||||
return L".hwpx";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPML:
|
||||
return L".hml";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_MD:
|
||||
return L".md";
|
||||
|
||||
@ -1926,8 +1861,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
|
||||
if (L".hwpx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX;
|
||||
if (L".hml" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPML;
|
||||
if (L".md" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_MD;
|
||||
|
||||
|
||||
@ -59,8 +59,7 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0018
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0019
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001a
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPML AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001b
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_MD AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001c
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_MD AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001b
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_XML AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0030
|
||||
|
||||
|
||||
@ -45,7 +45,6 @@ win32 {
|
||||
}
|
||||
|
||||
DEFINES += COPYRIGHT_YEAR=$${CURRENT_YEAR}
|
||||
#DEFINES += _LOGOUT_ALWAYS
|
||||
|
||||
QMAKE_TARGET_COMPANY = $$PUBLISHER_NAME
|
||||
QMAKE_TARGET_COPYRIGHT = © $${PUBLISHER_NAME} $${CURRENT_YEAR}. All rights reserved.
|
||||
@ -216,8 +215,7 @@ core_linux {
|
||||
QMAKE_LINK = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
QMAKE_LINK_SHLIB = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
|
||||
QMAKE_CFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
QMAKE_CXXFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
QMAKE_CXXFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
QMAKE_LFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,11 +29,11 @@
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef _SYSTEMUTILS_H
|
||||
#define _SYSTEMUTILS_H
|
||||
|
||||
#include <string>
|
||||
#include "../../Common/kernel_config.h"
|
||||
#include "../../OdfFile/Common/logging.h"
|
||||
|
||||
#define VALUE_STRINGIFY(d) L##d
|
||||
#define VALUE_TO_STR(v) VALUE_STRINGIFY(v)
|
||||
@ -59,7 +59,7 @@ namespace NSSystemUtils
|
||||
static const wchar_t* gc_EnvLastModifiedBy = L"LAST_MODIFIED_BY";
|
||||
static const wchar_t* gc_EnvModified = L"MODIFIED";
|
||||
static const wchar_t* gc_EnvMemoryLimit = L"X2T_MEMORY_LIMIT";
|
||||
static const wchar_t* gc_EnvMemoryLimitDefault = L"4GiB";
|
||||
static const wchar_t* gc_EnvMemoryLimitDefault = L"3GiB";
|
||||
|
||||
KERNEL_DECL std::string GetEnvVariableA(const std::wstring& strName);
|
||||
KERNEL_DECL std::wstring GetEnvVariable(const std::wstring& strName);
|
||||
@ -76,3 +76,4 @@ namespace NSSystemUtils
|
||||
};
|
||||
KERNEL_DECL std::wstring GetSystemDirectory(const SystemDirectoryType& type);
|
||||
}
|
||||
#endif // _SYSTEMUTILS_H
|
||||
|
||||
@ -311,28 +311,6 @@ public:
|
||||
return ((CPdfFile*)m_pFile)->UnmergePages();
|
||||
return false;
|
||||
}
|
||||
bool RedactPage(int nPageIndex, double* arrRedactBox, int nLengthX8, BYTE* data, int size, bool bCopy = false)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
{
|
||||
// Память из CDrawingFileEmbed освобождается сразу после вызова функции, поэтому копируем
|
||||
if (bCopy)
|
||||
{
|
||||
BYTE* pCopy = (BYTE*)malloc(size);
|
||||
memcpy(pCopy, data, size);
|
||||
data = pCopy;
|
||||
}
|
||||
// Захватывает полученную память data
|
||||
return ((CPdfFile*)m_pFile)->RedactPage(nPageIndex, arrRedactBox, nLengthX8, data, size);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool UndoRedact()
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->UndoRedact();
|
||||
return false;
|
||||
}
|
||||
|
||||
BYTE* GetGlyphs(int nPageIndex)
|
||||
{
|
||||
|
||||
@ -207,40 +207,6 @@ JSSmart<CJSValue> CDrawingFileEmbed::UnmergePages()
|
||||
return CJSContext::createBool(m_pFile->UnmergePages());
|
||||
return CJSContext::createBool(false);
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::RedactPage(JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> arrRedactBox, JSSmart<CJSValue> dataFiller)
|
||||
{
|
||||
bool result = false;
|
||||
if (m_pFile)
|
||||
{
|
||||
int pageIndex = nPageIndex->toInt32();
|
||||
|
||||
JSSmart<CJSArray> arrBox = arrRedactBox->toArray();
|
||||
int nCountBox = arrBox->getCount();
|
||||
double* pBox = NULL;
|
||||
if (0 < nCountBox)
|
||||
pBox = new double[nCountBox];
|
||||
|
||||
for (int i = 0; i < nCountBox; i++)
|
||||
pBox[i] = arrBox->get(i)->toDouble();
|
||||
|
||||
JSSmart<CJSTypedArray> dataPtr = dataFiller->toTypedArray();
|
||||
CJSDataBuffer buffer = dataPtr->getData();
|
||||
|
||||
result = m_pFile->RedactPage(pageIndex, pBox, nCountBox / 8, buffer.Data, (int)buffer.Len, true);
|
||||
|
||||
if (pBox)
|
||||
delete[] pBox;
|
||||
if (buffer.IsExternalize)
|
||||
buffer.Free();
|
||||
}
|
||||
return CJSContext::createBool(result);
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::UndoRedact()
|
||||
{
|
||||
if (m_pFile)
|
||||
return CJSContext::createBool(m_pFile->UndoRedact());
|
||||
return CJSContext::createBool(false);
|
||||
}
|
||||
|
||||
bool EmbedDrawingFile(JSSmart<NSJSBase::CJSContext>& context, IOfficeDrawingFile* pFile)
|
||||
{
|
||||
|
||||
@ -54,8 +54,6 @@ public:
|
||||
JSSmart<CJSValue> SplitPages(JSSmart<CJSValue> arrPageIndexes, JSSmart<CJSValue> data);
|
||||
JSSmart<CJSValue> MergePages(JSSmart<CJSValue> data, JSSmart<CJSValue> nMaxID, JSSmart<CJSValue> sPrefixForm);
|
||||
JSSmart<CJSValue> UnmergePages();
|
||||
JSSmart<CJSValue> RedactPage(JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> arrRedactBox, JSSmart<CJSValue> dataFiller);
|
||||
JSSmart<CJSValue> UndoRedact();
|
||||
|
||||
DECLARE_EMBED_METHODS
|
||||
};
|
||||
|
||||
@ -33,8 +33,6 @@ namespace NSDrawingFileEmbed
|
||||
FUNCTION_WRAPPER_V8_2(_SplitPages, SplitPages)
|
||||
FUNCTION_WRAPPER_V8_3(_MergePages, MergePages)
|
||||
FUNCTION_WRAPPER_V8_0(_UnmergePages, UnmergePages)
|
||||
FUNCTION_WRAPPER_V8_3(_RedactPage, RedactPage)
|
||||
FUNCTION_WRAPPER_V8_0(_UndoRedact, UndoRedact)
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
@ -67,8 +65,6 @@ namespace NSDrawingFileEmbed
|
||||
NSV8Objects::Template_Set(result, "SplitPages", _SplitPages);
|
||||
NSV8Objects::Template_Set(result, "MergePages", _MergePages);
|
||||
NSV8Objects::Template_Set(result, "UnmergePages", _UnmergePages);
|
||||
NSV8Objects::Template_Set(result, "RedactPage", _RedactPage);
|
||||
NSV8Objects::Template_Set(result, "UndoRedact", _UndoRedact);
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
|
||||
@ -1046,28 +1046,6 @@ int CFontFile::GetGIDByUnicode(int code)
|
||||
return unGID;
|
||||
}
|
||||
|
||||
int CFontFile::GetUnicodeByGID(int gid)
|
||||
{
|
||||
if (!m_pFace)
|
||||
return 0;
|
||||
|
||||
FT_ULong charcode;
|
||||
FT_UInt gindex;
|
||||
|
||||
charcode = FT_Get_First_Char(m_pFace, &gindex);
|
||||
|
||||
while (gindex != 0)
|
||||
{
|
||||
if (gindex == gid)
|
||||
{
|
||||
return charcode;
|
||||
}
|
||||
charcode = FT_Get_Next_Char(m_pFace, charcode, &gindex);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
INT CFontFile::GetString(CGlyphString& oString)
|
||||
{
|
||||
int nCountGlyph = oString.GetLength();
|
||||
|
||||
@ -254,7 +254,6 @@ public:
|
||||
double GetCharWidth(int gid);
|
||||
|
||||
int GetGIDByUnicode(int code);
|
||||
int GetUnicodeByGID(int gid);
|
||||
|
||||
int GetKerning(FT_UInt unPrevGID, FT_UInt unGID);
|
||||
void SetStringGID(const INT& bGID);
|
||||
|
||||
@ -851,14 +851,6 @@ unsigned int CFontManager::GetGIDByUnicode(const unsigned int& unCode)
|
||||
|
||||
return m_pFont->GetGIDByUnicode(unCode);
|
||||
}
|
||||
int CFontManager::GetUnicodeByGID(const int& gid)
|
||||
{
|
||||
if (!m_pFont)
|
||||
return 0;
|
||||
|
||||
return m_pFont->GetUnicodeByGID(gid);
|
||||
}
|
||||
|
||||
void CFontManager::SetSubpixelRendering(const bool& hmul, const bool& vmul)
|
||||
{
|
||||
if (hmul)
|
||||
|
||||
@ -186,7 +186,6 @@ public:
|
||||
virtual std::wstring GetFontType();
|
||||
virtual unsigned int GetNameIndex(const std::wstring& wsName);
|
||||
virtual unsigned int GetGIDByUnicode(const unsigned int& unCode);
|
||||
virtual int GetUnicodeByGID(const int& gid);
|
||||
|
||||
virtual void SetSubpixelRendering(const bool& hmul, const bool& vmul);
|
||||
|
||||
|
||||
@ -758,36 +758,12 @@ CGraphicsPath&& CBooleanOperations::GetResult()
|
||||
return std::move(Result);
|
||||
}
|
||||
|
||||
bool CBooleanOperations::IsSelfInters(const CGraphicsPath& p)
|
||||
{
|
||||
PreparePath(p, 1, Segments1, Curves1);
|
||||
PreparePath(p, 2, Segments2, Curves2);
|
||||
|
||||
OriginCurves1 = Curves1;
|
||||
OriginCurves2 = Curves2;
|
||||
|
||||
GetIntersection();
|
||||
|
||||
if (Locations.empty())
|
||||
return false;
|
||||
else
|
||||
{
|
||||
for (const auto& l : Locations)
|
||||
{
|
||||
if (!isZero(l->Time) && !isZero(l->Time - 1.0) && l->C.Segment2.Index != l->Inters->C.Segment1.Index)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CBooleanOperations::TraceBoolean()
|
||||
{
|
||||
bool reverse = false;
|
||||
bool self = Path1 == Path2;
|
||||
if (((Op == Subtraction || Op == Exclusion) ^
|
||||
Path1.IsClockwise() ^
|
||||
Path2.IsClockwise()) && !self)
|
||||
if ((Op == Subtraction || Op == Exclusion) ^
|
||||
Path1.IsClockwise() ^
|
||||
Path2.IsClockwise())
|
||||
reverse = true;
|
||||
|
||||
PreparePath(Path1, 1, Segments1, Curves1);
|
||||
@ -798,32 +774,6 @@ void CBooleanOperations::TraceBoolean()
|
||||
|
||||
GetIntersection();
|
||||
|
||||
if (self)
|
||||
{
|
||||
if (Op == Subtraction)
|
||||
return;
|
||||
|
||||
std::vector<std::vector<int>> adj_matr(Locations.size());
|
||||
|
||||
for (size_t i = 0; i < Locations.size(); i++)
|
||||
{
|
||||
std::vector<int> adj_vec;
|
||||
|
||||
if (CheckLocation(Locations[i], true))
|
||||
adj_vec.push_back(Locations[i]->C.Segment1.Index);
|
||||
if (CheckLocation(Locations[i], false))
|
||||
adj_vec.push_back(Locations[i]->C.Segment2.Index);
|
||||
if (CheckLocation(Locations[i]->Inters, true))
|
||||
adj_vec.push_back(Locations[i]->Inters->C.Segment1.Index);
|
||||
if (CheckLocation(Locations[i]->Inters, false))
|
||||
adj_vec.push_back(Locations[i]->Inters->C.Segment2.Index);
|
||||
adj_matr[i] = adj_vec;
|
||||
}
|
||||
|
||||
CreateNewPath(adj_matr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Locations.empty())
|
||||
{
|
||||
int length = static_cast<int>(Locations.size());
|
||||
@ -852,16 +802,6 @@ void CBooleanOperations::TraceBoolean()
|
||||
TraceAllOverlap();
|
||||
return;
|
||||
}
|
||||
if (IsOneCurvePath(1))
|
||||
{
|
||||
TraceOneCurvePath1();
|
||||
return;
|
||||
}
|
||||
if (IsOneCurvePath(2))
|
||||
{
|
||||
TraceOneCurvePath2();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SetWinding();
|
||||
@ -1068,100 +1008,6 @@ void CBooleanOperations::TraceAllOverlap()
|
||||
}
|
||||
}
|
||||
|
||||
void CBooleanOperations::TraceOneCurvePath1()
|
||||
{
|
||||
if (Op == Intersection)
|
||||
{
|
||||
Result.StartFigure();
|
||||
for (const auto& s : Segments1)
|
||||
{
|
||||
if (s.Inters && Result.GetPointCount() == 0)
|
||||
{
|
||||
Result.MoveTo(s.P.X, s.P.Y);
|
||||
Segment s2 = GetNextSegment(s);
|
||||
if (s2.IsCurve)
|
||||
Result.CurveTo(s2.HI.X + s2.P.X, s2.HI.Y + s2.P.Y,
|
||||
s2.HO.X + s2.P.X, s2.HO.Y + s2.P.Y,
|
||||
s2.P.X, s2.P.Y);
|
||||
else
|
||||
Result.LineTo(s2.P.X, s2.P.Y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Op == Union)
|
||||
{
|
||||
Result.AddPath(Path2);
|
||||
for (size_t i = 0; i < Segments1.size(); i++)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
Result.MoveTo(Segments1[i].P.X, Segments1[i].P.Y);
|
||||
else if (Segments1[i].IsCurve)
|
||||
Result.CurveTo(Segments1[i].HI.X + Segments1[i].P.X, Segments1[i].HI.Y + Segments1[i].P.Y,
|
||||
Segments1[i].HO.X + Segments1[i].P.X, Segments1[i].HO.Y + Segments1[i].P.Y,
|
||||
Segments1[i].P.X, Segments1[i].P.Y);
|
||||
else
|
||||
Result.LineTo(Segments1[i].P.X, Segments1[i].P.Y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Result.StartFigure();
|
||||
|
||||
for (size_t i = 0; i < Segments1.size(); i++)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
Result.MoveTo(Segments1[i].P.X, Segments1[i].P.Y);
|
||||
else if (Segments1[i].IsCurve)
|
||||
Result.CurveTo(Segments1[i].HI.X + Segments1[i].P.X, Segments1[i].HI.Y + Segments1[i].P.Y,
|
||||
Segments1[i].HO.X + Segments1[i].P.X, Segments1[i].HO.Y + Segments1[i].P.Y,
|
||||
Segments1[i].P.X, Segments1[i].P.Y);
|
||||
else
|
||||
Result.LineTo(Segments1[i].P.X, Segments1[i].P.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CBooleanOperations::TraceOneCurvePath2()
|
||||
{
|
||||
if (Op == Intersection)
|
||||
{
|
||||
Result.StartFigure();
|
||||
for (const auto& s : Segments2)
|
||||
{
|
||||
if (s.Inters && Result.GetPointCount() == 0)
|
||||
{
|
||||
Result.MoveTo(s.P.X, s.P.Y);
|
||||
Segment s2 = GetNextSegment(s);
|
||||
if (s2.IsCurve)
|
||||
Result.CurveTo(s2.HI.X + s2.P.X, s2.HI.Y + s2.P.Y,
|
||||
s2.HO.X + s2.P.X, s2.HO.Y + s2.P.Y,
|
||||
s2.P.X, s2.P.Y);
|
||||
else
|
||||
Result.LineTo(s2.P.X, s2.P.Y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Op == Union)
|
||||
{
|
||||
Result.AddPath(Path1);
|
||||
for (size_t i = 0; i < Segments2.size(); i++)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
Result.MoveTo(Segments2[i].P.X, Segments2[i].P.Y);
|
||||
else if (Segments2[i].IsCurve)
|
||||
Result.CurveTo(Segments2[i].HI.X + Segments2[i].P.X, Segments2[i].HI.Y + Segments2[i].P.Y,
|
||||
Segments2[i].HO.X + Segments2[i].P.X, Segments2[i].HO.Y + Segments2[i].P.Y,
|
||||
Segments2[i].P.X, Segments2[i].P.Y);
|
||||
else
|
||||
Result.LineTo(Segments2[i].P.X, Segments2[i].P.Y);
|
||||
}
|
||||
}
|
||||
else
|
||||
Result = std::move(Path1);
|
||||
}
|
||||
|
||||
void CBooleanOperations::TracePaths()
|
||||
{
|
||||
size_t length = Segments1.size();
|
||||
@ -1198,10 +1044,7 @@ void CBooleanOperations::TracePaths()
|
||||
Segment tmp = GetNextSegment(prev.Inters->S);
|
||||
if (tmp.IsEmpty()) break;
|
||||
if (tmp.IsValid(Op))
|
||||
{
|
||||
s = tmp;
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid && prev.Inters)
|
||||
@ -1410,218 +1253,6 @@ void CBooleanOperations::SetVisited(const Segment& segment)
|
||||
Segments2[segment.Index].Visited = true;
|
||||
}
|
||||
|
||||
void CBooleanOperations::CreateNewPath(const std::vector<std::vector<int>>& adjMatr) noexcept
|
||||
{
|
||||
int* loc_visited = new int[Locations.size()];
|
||||
memset(loc_visited, false, Locations.size());
|
||||
bool* seg_visited = new bool[Segments1.size()];
|
||||
memset(seg_visited, false, Segments1.size());
|
||||
|
||||
Result.StartFigure();
|
||||
for (int i = 0; i < Locations.size(); i++)
|
||||
{
|
||||
auto loc = Locations[i];
|
||||
if (loc_visited[i] == 2)
|
||||
continue;
|
||||
|
||||
bool finish = true;
|
||||
for (size_t j = 0; j < Segments1.size(); j++)
|
||||
finish = finish && seg_visited[j];
|
||||
|
||||
if (finish)
|
||||
break;
|
||||
|
||||
auto add_seg = [&](int x, int prev_x) {
|
||||
for (int j = adjMatr[x].size() - 1; j >= 0; j--)
|
||||
{
|
||||
int ver = adjMatr[x][j];
|
||||
if (seg_visited[ver] || ver == prev_x)
|
||||
continue;
|
||||
|
||||
seg_visited[ver] = true;
|
||||
if (Segments1[ver].IsCurve)
|
||||
{
|
||||
Segment seg;
|
||||
auto curve = Curves1[ver];
|
||||
auto curve1 = Curves1[ver == 0 ? Curves1.size() - 1 : ver - 1];
|
||||
if (curve.Segment2.Index == Locations[x]->C.Segment2.Index)
|
||||
{
|
||||
auto new_curve = curve.DivideAtTime(Locations[x]->Time);
|
||||
seg = new_curve.Segment1;
|
||||
}
|
||||
if (curve.Segment2.Index == Locations[x]->Inters->C.Segment2.Index)
|
||||
{
|
||||
auto new_curve = curve.DivideAtTime(Locations[x]->Inters->Time);
|
||||
seg = new_curve.Segment1;
|
||||
}
|
||||
if (curve1.Segment2.Index == Locations[x]->C.Segment2.Index)
|
||||
{
|
||||
auto new_curve = curve1.DivideAtTime(Locations[x]->Time);
|
||||
seg = new_curve.Segment2;
|
||||
}
|
||||
if (curve1.Segment2.Index == Locations[x]->Inters->C.Segment2.Index)
|
||||
{
|
||||
auto new_curve = curve1.DivideAtTime(Locations[x]->Inters->Time);
|
||||
seg = new_curve.Segment2;
|
||||
}
|
||||
Result.CurveTo(seg.HI.X + seg.P.X, seg.HI.Y + seg.P.Y,
|
||||
seg.HO.X + seg.P.X, seg.HO.Y + seg.P.Y,
|
||||
seg.P.X, seg.P.Y);
|
||||
}
|
||||
else
|
||||
Result.LineTo(Segments1[ver].P.X, Segments1[ver].P.Y);
|
||||
|
||||
return ver;
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
|
||||
auto add_loc = [&](int x, int prev_x) {
|
||||
while (1)
|
||||
{
|
||||
for (int j = 0; j < adjMatr.size(); j++)
|
||||
{
|
||||
if (std::find(adjMatr[j].begin(), adjMatr[j].end(), x) != adjMatr[j].end())
|
||||
{
|
||||
if (loc_visited[j] == 2 || j == prev_x)
|
||||
continue;
|
||||
|
||||
if (j != i)
|
||||
loc_visited[j]++;
|
||||
auto ll = Locations[j];
|
||||
Curve curve;
|
||||
double t;
|
||||
if ((x == Curves1.size() - 1 ? 0 : x + 1) == ll->C.Segment2.Index)
|
||||
{
|
||||
curve = Curves1[x];
|
||||
t = ll->Time;
|
||||
}
|
||||
if ((x == Curves1.size() - 1 ? 0 : x + 1) == ll->Inters->C.Segment2.Index)
|
||||
{
|
||||
curve = Curves1[x];
|
||||
t = ll->Inters->Time;
|
||||
}
|
||||
if (x == ll->C.Segment2.Index)
|
||||
{
|
||||
curve = Curves1[x == 0 ? Curves1.size() - 1 : x - 1];
|
||||
t = ll->Time;
|
||||
}
|
||||
if (x == ll->Inters->C.Segment2.Index)
|
||||
{
|
||||
curve = Curves1[x == 0 ? Curves1.size() - 1 : x - 1];
|
||||
t = ll->Inters->Time;
|
||||
}
|
||||
if (curve.Segment2.IsCurve)
|
||||
{
|
||||
auto new_curve = curve.DivideAtTime(t);
|
||||
Result.CurveTo(new_curve.Segment1.HI.X + new_curve.Segment1.P.X, new_curve.Segment1.HI.Y + new_curve.Segment1.P.Y,
|
||||
new_curve.Segment1.HO.X + new_curve.Segment1.P.X, new_curve.Segment1.HO.Y + new_curve.Segment1.P.Y,
|
||||
new_curve.Segment1.P.X, new_curve.Segment1.P.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto pt = curve.GetPoint(t);
|
||||
Result.LineTo(pt.X, pt.Y);
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
}
|
||||
x = (x >= Curves1.size() - 1) ? 0 : x + 1;
|
||||
prev_x = -1;
|
||||
if (Curves1[x].Segment2.IsCurve)
|
||||
Result.CurveTo(Curves1[x].Segment2.HI.X + Curves1[x].Segment2.P.X, Curves1[x].Segment2.HI.Y + Curves1[x].Segment2.P.Y,
|
||||
Curves1[x].Segment2.HO.X + Curves1[x].Segment2.P.X, Curves1[x].Segment2.HO.Y + Curves1[x].Segment2.P.Y,
|
||||
Curves1[x].Segment2.P.X, Curves1[x].Segment2.P.Y);
|
||||
else
|
||||
Result.LineTo(Curves1[x].Segment2.P.X, Curves1[x].Segment2.P.Y);
|
||||
}
|
||||
|
||||
return -1;
|
||||
};
|
||||
|
||||
loc_visited[i]++;
|
||||
auto p = loc->C.GetPoint(loc->Time);
|
||||
Result.MoveTo(p.X, p.Y);
|
||||
int cur_seg = -1;
|
||||
int cur_loc = i;
|
||||
while (1)
|
||||
{
|
||||
cur_seg = add_seg(cur_loc, cur_seg);
|
||||
if (cur_seg == -1)
|
||||
break;
|
||||
cur_loc = add_loc(cur_seg, cur_loc);
|
||||
if (cur_loc == i || cur_loc == -1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < Locations.size(); i++)
|
||||
{
|
||||
if (loc_visited[i] != 2)
|
||||
{
|
||||
loc_visited[i]++;
|
||||
auto p = Locations[i]->C.GetPoint(Locations[i]->Time);
|
||||
Result.MoveTo(p.X, p.Y);
|
||||
auto prev_loc = Locations[i];
|
||||
|
||||
auto add_loc = [&](std::shared_ptr<Location> l1, std::shared_ptr<Location> l2) {
|
||||
auto add_pt = [&](std::shared_ptr<Location> lc, std::shared_ptr<Location> prev){
|
||||
if (prev->C.Segment2.IsCurve)
|
||||
{
|
||||
auto new_curve = prev->C;
|
||||
double t1 = prev->Time;
|
||||
double t2 = lc->Time;
|
||||
if (t2 < t1)
|
||||
{
|
||||
new_curve.Flip();
|
||||
t1 = 1.0 - t1;
|
||||
t2 = 1.0 - t2;
|
||||
}
|
||||
new_curve = new_curve.DivideAtTime(t1);
|
||||
new_curve = new_curve.DivideAtTime((t2 - t1) / (1.0 - t1));
|
||||
|
||||
Result.CurveTo(new_curve.Segment1.HI.X + new_curve.Segment1.P.X, new_curve.Segment1.HI.Y + new_curve.Segment1.P.Y,
|
||||
new_curve.Segment1.HO.X + new_curve.Segment1.P.X, new_curve.Segment1.HO.Y + new_curve.Segment1.P.Y,
|
||||
new_curve.Segment1.P.X, new_curve.Segment1.P.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto pt = lc->C.GetPoint(lc->Time);
|
||||
Result.LineTo(pt.X, pt.Y);
|
||||
}
|
||||
};
|
||||
|
||||
if (l1->C.Segment2.Index == l2->C.Segment2.Index)
|
||||
add_pt(l1, l2);
|
||||
else if (l1->C.Segment2.Index == l2->Inters->C.Segment2.Index)
|
||||
add_pt(l1, l2->Inters);
|
||||
else if (l1->Inters->C.Segment2.Index == l2->C.Segment2.Index)
|
||||
add_pt(l1->Inters, l2);
|
||||
else if (l1->Inters->C.Segment2.Index == l2->Inters->C.Segment2.Index)
|
||||
add_pt(l1->Inters, l2->Inters);
|
||||
};
|
||||
|
||||
for (int j = i + 1; j < Locations.size(); j++)
|
||||
{
|
||||
if (loc_visited[j] == 2)
|
||||
continue;
|
||||
|
||||
loc_visited[j]++;
|
||||
add_loc(Locations[j], prev_loc);
|
||||
prev_loc = Locations[j];
|
||||
}
|
||||
add_loc(Locations[i], prev_loc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Result.CloseFigure();
|
||||
|
||||
delete[] seg_visited;
|
||||
delete[] loc_visited;
|
||||
}
|
||||
|
||||
std::vector<std::vector<int>> CBooleanOperations::FindBoundsCollisions()
|
||||
{
|
||||
std::vector<std::vector<double>> allBounds, bounds2;
|
||||
@ -1665,14 +1296,13 @@ std::vector<std::vector<int>> CBooleanOperations::FindBoundsCollisions()
|
||||
|
||||
activeIndicesByPri2.erase(activeIndicesByPri2.begin(),
|
||||
activeIndicesByPri2.begin() + pruneCount);
|
||||
|
||||
for (int j = 0; j < static_cast<int>(activeIndicesByPri2.size()); j++)
|
||||
{
|
||||
bool isActive1 = activeIndicesByPri2[j] < length1,
|
||||
isActive2 = self || !isActive1,
|
||||
isActive1Or2 = (isCurrent1 && isActive2) || (isCurrent2 && isActive1),
|
||||
inRange1 = allBounds[allIdicesByPri1[i]][1] <= allBounds[activeIndicesByPri2[j]][3] + GEOMETRIC_EPSILON,
|
||||
inRange2 = allBounds[allIdicesByPri1[i]][3] >= allBounds[activeIndicesByPri2[j]][1] - GEOMETRIC_EPSILON;
|
||||
isActive2 = self || !isActive1,
|
||||
isActive1Or2 = (isCurrent1 && isActive2) || (isCurrent2 && isActive1),
|
||||
inRange1 = allBounds[allIdicesByPri1[i]][1] <= allBounds[activeIndicesByPri2[j]][3] + GEOMETRIC_EPSILON,
|
||||
inRange2 = allBounds[allIdicesByPri1[i]][3] >= allBounds[activeIndicesByPri2[j]][1] - GEOMETRIC_EPSILON;
|
||||
|
||||
if (isActive1Or2 && (inRange2 && inRange1))
|
||||
{
|
||||
@ -1684,7 +1314,10 @@ std::vector<std::vector<int>> CBooleanOperations::FindBoundsCollisions()
|
||||
}
|
||||
}
|
||||
if (isCurrent1)
|
||||
{
|
||||
if (self) curCollisions.push_back(allIdicesByPri1[i]);
|
||||
allCollisions[allIdicesByPri1[i]] = curCollisions;
|
||||
}
|
||||
if (activeIndicesByPri2.size() > 0)
|
||||
{
|
||||
int index = 1 + binarySearch(allBounds, activeIndicesByPri2, 2, allBounds[allIdicesByPri1[i]][2]);
|
||||
@ -1694,23 +1327,8 @@ std::vector<std::vector<int>> CBooleanOperations::FindBoundsCollisions()
|
||||
activeIndicesByPri2.push_back(allIdicesByPri1[i]);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
std::vector<std::vector<int>> erase_ver(length1);
|
||||
for (auto& c : allCollisions)
|
||||
{
|
||||
std::sort(c.begin(), c.end());
|
||||
if (self)
|
||||
{
|
||||
c.erase(std::remove(c.begin(), c.end(), index), c.end());
|
||||
c.erase(std::remove(c.begin(), c.end(), index == allLength - 1 ? 0 : index + 1), c.end());
|
||||
c.erase(std::remove(c.begin(), c.end(), index == 0 ? allLength - 1 : index - 1), c.end());
|
||||
for (const auto& ind : erase_ver[index])
|
||||
c.erase(std::remove(c.begin(), c.end(), ind), c.end());
|
||||
for (const auto& ind : c)
|
||||
erase_ver[ind].push_back(index);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
return allCollisions;
|
||||
}
|
||||
@ -2270,12 +1888,6 @@ bool CBooleanOperations::AllInters(const std::vector<Segment>& segments) const n
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBooleanOperations::IsOneCurvePath(int pathIndex) const noexcept
|
||||
{
|
||||
return Locations.size() == 4 && pathIndex == 1 ? (OriginCurves1.size() == 1 && OriginCurves2.size() != 1)
|
||||
: (OriginCurves2.size() == 1 && OriginCurves1.size() != 1);
|
||||
}
|
||||
|
||||
void CBooleanOperations::AddLocation(Curve curve1, Curve curve2, double t1,
|
||||
double t2, bool overlap, bool filter, bool ends)
|
||||
{
|
||||
@ -2316,29 +1928,6 @@ void CBooleanOperations::AddOffsets(std::vector<double>& offsets,
|
||||
offsets.push_back(count != 0 ? offset : offset / 32);
|
||||
}
|
||||
|
||||
bool CBooleanOperations::CheckLocation(std::shared_ptr<Location> loc, bool start) const noexcept
|
||||
{
|
||||
for (const auto& l : Locations)
|
||||
{
|
||||
if (start)
|
||||
{
|
||||
if (l->C.Segment1.Index == loc->C.Segment1.Index && l->Time != loc->Time)
|
||||
return loc->Time < l->Time;
|
||||
if (l->Inters->C.Segment1.Index == loc->C.Segment1.Index && l->Inters->Time != loc->Time)
|
||||
return loc->Time < l->Inters->Time;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (l->C.Segment2.Index == loc->C.Segment2.Index && l->Time != loc->Time)
|
||||
return loc->Time > l->Time;
|
||||
if (l->Inters->C.Segment2.Index == loc->C.Segment2.Index && l->Inters->Time != loc->Time)
|
||||
return loc->Time > l->Inters->Time;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
const CGraphicsPath& path2,
|
||||
BooleanOpType op,
|
||||
@ -2348,54 +1937,21 @@ CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
std::vector<CGraphicsPath> paths1 = path1.GetSubPaths(),
|
||||
paths2 = path2.GetSubPaths(),
|
||||
paths;
|
||||
int skip_end1 = -1;
|
||||
for (size_t i = 0; i < paths2.size(); i++)
|
||||
|
||||
for (const auto& p1 : paths1)
|
||||
{
|
||||
int skip_end2 = -1;
|
||||
CBooleanOperations o;
|
||||
if (i > skip_end2 && o.IsSelfInters(paths2[i]))
|
||||
for (const auto& p2 : paths2)
|
||||
{
|
||||
CBooleanOperations operation(paths2[i], paths2[i], Intersection, fillType, isLuminosity);
|
||||
CGraphicsPath p = std::move(operation.GetResult());
|
||||
|
||||
std::vector<CGraphicsPath> tmp_paths = p.GetSubPaths();
|
||||
paths2[i] = tmp_paths[0];
|
||||
skip_end2 = i + tmp_paths.size() - 1;
|
||||
for (size_t k = 1; k < tmp_paths.size(); k++)
|
||||
paths2.insert(paths2.begin() + i + k, tmp_paths[k]);
|
||||
}
|
||||
|
||||
for (size_t j = 0; j < paths1.size(); j++)
|
||||
{
|
||||
CBooleanOperations o2;
|
||||
if (j > skip_end1 && o2.IsSelfInters(paths1[j]))
|
||||
{
|
||||
CBooleanOperations operation(paths1[j], paths1[j], Intersection, fillType, isLuminosity);
|
||||
CGraphicsPath p = std::move(operation.GetResult());
|
||||
|
||||
std::vector<CGraphicsPath> tmp_paths = p.GetSubPaths();
|
||||
paths1[j] = tmp_paths[0];
|
||||
skip_end1 = j + tmp_paths.size() - 1;
|
||||
for (size_t k = 1; k < tmp_paths.size(); k++)
|
||||
paths1.insert(paths1.begin() + i + k, tmp_paths[k]);
|
||||
}
|
||||
|
||||
CBooleanOperations operation(paths1[j], paths2[i], op, fillType, isLuminosity);
|
||||
CBooleanOperations operation(p1, p2, op, fillType, isLuminosity);
|
||||
paths.push_back(operation.GetResult());
|
||||
}
|
||||
|
||||
if (op == Subtraction)
|
||||
{
|
||||
paths1 = CGraphicsPath(paths).GetSubPaths();
|
||||
paths.clear();
|
||||
}
|
||||
}
|
||||
|
||||
return op == Subtraction ? CGraphicsPath(paths1) : CGraphicsPath(paths);
|
||||
return CGraphicsPath(paths);
|
||||
}
|
||||
|
||||
// For Unit-tests
|
||||
bool CGraphicsPath::Equals(const CGraphicsPath& other) noexcept
|
||||
//For unit-tests
|
||||
bool CGraphicsPath::operator==(const CGraphicsPath& other) noexcept
|
||||
{
|
||||
unsigned pointsCount = GetPointCount(),
|
||||
otherPointsCount = other.GetPointCount();
|
||||
@ -2404,7 +1960,7 @@ bool CGraphicsPath::Equals(const CGraphicsPath& other) noexcept
|
||||
return false;
|
||||
|
||||
std::vector<PointD> points = GetPoints(0, pointsCount),
|
||||
otherPoints = other.GetPoints(0, otherPointsCount);
|
||||
otherPoints = other.GetPoints(0, otherPointsCount);
|
||||
|
||||
for (unsigned i = 0; i < pointsCount; i++)
|
||||
if (getDistance(points[i], otherPoints[i]) > POINT_EPSILON)
|
||||
|
||||
@ -107,19 +107,15 @@ namespace Aggplus
|
||||
class CBooleanOperations
|
||||
{
|
||||
public:
|
||||
CBooleanOperations() {};
|
||||
CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType, bool isLuminosity);
|
||||
~CBooleanOperations();
|
||||
CGraphicsPath&& GetResult();
|
||||
bool IsSelfInters(const CGraphicsPath& p);
|
||||
|
||||
// BooleanOp
|
||||
void TraceBoolean();
|
||||
void TraceOneInters();
|
||||
void TraceAllOverlap();
|
||||
void TracePaths();
|
||||
void TraceOneCurvePath1();
|
||||
void TraceOneCurvePath2();
|
||||
|
||||
// Path
|
||||
void PreparePath(const CGraphicsPath& path, int id, std::vector<Segment>& segments,
|
||||
@ -131,7 +127,6 @@ namespace Aggplus
|
||||
Segment GetPreviousSegment(const Segment& segment) const noexcept;
|
||||
Segment GetNextSegment(const Segment& segment) const noexcept;
|
||||
void SetVisited(const Segment& segment);
|
||||
void CreateNewPath(const std::vector<std::vector<int>>& adjMatr) noexcept;
|
||||
|
||||
// Bounds
|
||||
std::vector<std::vector<int>> FindBoundsCollisions();
|
||||
@ -156,9 +151,7 @@ namespace Aggplus
|
||||
void InsertLocation(std::shared_ptr<Location> loc, bool overlap);
|
||||
bool AllOverlap() const noexcept;
|
||||
bool AllInters(const std::vector<Segment>& segments) const noexcept;
|
||||
bool IsOneCurvePath(int pathIndex) const noexcept;
|
||||
void AddOffsets(std::vector<double>& offsets, const Curve& curve, bool end);
|
||||
bool CheckLocation(std::shared_ptr<Location> loc, bool start) const noexcept;
|
||||
|
||||
private:
|
||||
BooleanOpType Op = Intersection;
|
||||
@ -170,9 +163,9 @@ namespace Aggplus
|
||||
// c_nStroke, c_nWindingFillMode, c_nEvenOddFillMode
|
||||
long FillType = c_nWindingFillMode;
|
||||
|
||||
CGraphicsPath Path1{};
|
||||
CGraphicsPath Path2{};
|
||||
CGraphicsPath Result{};
|
||||
CGraphicsPath Path1;
|
||||
CGraphicsPath Path2;
|
||||
CGraphicsPath Result;
|
||||
|
||||
std::vector<Segment> Segments1;
|
||||
std::vector<Segment> Segments2;
|
||||
|
||||
@ -419,6 +419,7 @@ namespace Aggplus
|
||||
m_bReleaseImage = FALSE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_bIsScale = false;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(const std::wstring& strName, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
|
||||
@ -427,6 +428,7 @@ namespace Aggplus
|
||||
m_bReleaseImage = TRUE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_bIsScale = false;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(CImage *pImage, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
|
||||
@ -435,6 +437,7 @@ namespace Aggplus
|
||||
m_bReleaseImage = FALSE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_bIsScale = false;
|
||||
}
|
||||
|
||||
CBrushTexture::~CBrushTexture()
|
||||
|
||||
@ -205,6 +205,10 @@ public:
|
||||
bool m_bUseBounds;
|
||||
CDoubleRect m_oBounds;
|
||||
|
||||
bool m_bIsScale;
|
||||
double m_dScaleX;
|
||||
double m_dScaleY;
|
||||
|
||||
BYTE Alpha;
|
||||
};
|
||||
}
|
||||
|
||||
@ -847,6 +847,8 @@ namespace Aggplus
|
||||
double dScaleY = m_dDpiY / m_dDpiTile;
|
||||
|
||||
brushMatrix.Scale(dScaleX, dScaleY, Aggplus::MatrixOrderAppend);
|
||||
if (ptxBrush->m_bIsScale)
|
||||
brushMatrix.Scale(ptxBrush->m_dScaleX, ptxBrush->m_dScaleY, Aggplus::MatrixOrderAppend);
|
||||
}
|
||||
|
||||
brushMatrix.Translate(x, y, Aggplus::MatrixOrderAppend);
|
||||
|
||||
@ -76,7 +76,7 @@ namespace Aggplus
|
||||
j += 2;
|
||||
}
|
||||
}
|
||||
//if (p.Is_poly_closed()) CloseFigure();
|
||||
if (p.Is_poly_closed()) CloseFigure();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -262,25 +262,6 @@ namespace Aggplus
|
||||
m_internal->m_agg_ps.line_to(x + width, y);
|
||||
m_internal->m_agg_ps.line_to(x + width, y + height);
|
||||
m_internal->m_agg_ps.line_to(x, y + height);
|
||||
m_internal->m_agg_ps.line_to(x, y);
|
||||
m_internal->m_agg_ps.close_polygon();
|
||||
return Ok;
|
||||
}
|
||||
Status CGraphicsPath::AddRoundRectangle(double x, double y, double width, double height, double cx, double cy)
|
||||
{
|
||||
m_internal->m_agg_ps.move_to(x + cx, y);
|
||||
m_internal->m_agg_ps.line_to(x + width - cx, y);
|
||||
agg::bezier_arc arc1(x + width - cx, y + cy, cx, cy, -agg::pi / 2.0, agg::pi / 2.0);
|
||||
m_internal->m_agg_ps.join_path(arc1, 0);
|
||||
m_internal->m_agg_ps.line_to(x + width, y + height - cy);
|
||||
agg::bezier_arc arc2(x + width - cx, y + height - cy, cx, cy, 0.0, agg::pi / 2.0);
|
||||
m_internal->m_agg_ps.join_path(arc2, 0);
|
||||
m_internal->m_agg_ps.line_to(x + cx, y + height);
|
||||
agg::bezier_arc arc3(x + cx, y + height - cy, cx, cy, agg::pi / 2.0, agg::pi / 2.0);
|
||||
m_internal->m_agg_ps.join_path(arc3, 0);
|
||||
m_internal->m_agg_ps.line_to(x, y + cy);
|
||||
agg::bezier_arc arc4(x + cx, y + cy, cx, cy, agg::pi, agg::pi / 2.0);
|
||||
m_internal->m_agg_ps.join_path(arc4, 0);
|
||||
m_internal->m_agg_ps.close_polygon();
|
||||
return Ok;
|
||||
}
|
||||
@ -917,11 +898,14 @@ namespace Aggplus
|
||||
PointD firstPoint = subPath.GetPoints(0, 1)[0];
|
||||
double x, y;
|
||||
subPath.GetLastPoint(x, y);
|
||||
if ((abs(firstPoint.X - x) >= 1e-2 || abs(firstPoint.Y - y) >= 1e-2) ||
|
||||
if ((abs(firstPoint.X - x) <= 1e-2 && abs(firstPoint.Y - y) <= 1e-2) ||
|
||||
subPath.GetPointCount() == 1)
|
||||
subPath.LineTo(firstPoint.X, firstPoint.Y);
|
||||
{
|
||||
if (!firstPoint.Equals(PointD(x, y)) || subPath.GetPointCount() == 1)
|
||||
subPath.LineTo(firstPoint.X, firstPoint.Y);
|
||||
subPath.CloseFigure();
|
||||
}
|
||||
|
||||
subPath.CloseFigure();
|
||||
result.push_back(subPath);
|
||||
subPath.Reset();
|
||||
}
|
||||
@ -949,7 +933,7 @@ namespace Aggplus
|
||||
double x, y;
|
||||
subPath.GetLastPoint(x, y);
|
||||
|
||||
if ((abs(firstPoint.X - x) >= 1e-2 || abs(firstPoint.Y - y) >= 1e-2) || subPath.GetPointCount() == 1)
|
||||
if (!firstPoint.Equals(PointD(x, y)) || subPath.GetPointCount() == 1)
|
||||
subPath.LineTo(firstPoint.X, firstPoint.Y);
|
||||
|
||||
subPath.CloseFigure();
|
||||
@ -1003,24 +987,6 @@ namespace Aggplus
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CGraphicsPath::operator==(const CGraphicsPath& other) noexcept
|
||||
{
|
||||
unsigned pointsCount = GetPointCount(),
|
||||
otherPointsCount = other.GetPointCount();
|
||||
|
||||
if (pointsCount != otherPointsCount)
|
||||
return false;
|
||||
|
||||
std::vector<PointD> points = GetPoints(0, pointsCount),
|
||||
otherPoints = other.GetPoints(0, otherPointsCount);
|
||||
|
||||
for (unsigned i = 0; i < pointsCount; i++)
|
||||
if (!points[i].Equals(otherPoints[i]))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Aggplus
|
||||
@ -1549,3 +1515,31 @@ namespace Aggplus
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT IRenderer::AddPath(const Aggplus::CGraphicsPath& path)
|
||||
{
|
||||
if (path.GetPointCount() == 0)
|
||||
return S_FALSE;
|
||||
|
||||
size_t length = path.GetPointCount() + path.GetCloseCount();
|
||||
std::vector<Aggplus::PointD> points = path.GetPoints(0, length);
|
||||
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
if (path.IsCurvePoint(i))
|
||||
{
|
||||
PathCommandCurveTo(points[i].X, points[i].Y,
|
||||
points[i + 1].X, points[i + 1].Y,
|
||||
points[i + 2].X, points[i + 2].Y);
|
||||
i += 2;
|
||||
}
|
||||
else if (path.IsMovePoint(i))
|
||||
PathCommandMoveTo(points[i].X, points[i].Y);
|
||||
else if (path.IsLinePoint(i))
|
||||
PathCommandLineTo(points[i].X, points[i].Y);
|
||||
else
|
||||
PathCommandClose();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -72,7 +72,6 @@ namespace Aggplus
|
||||
Status AddCurve(double* pPoints, int nCount);
|
||||
Status AddEllipse(double x, double y, double width, double height);
|
||||
Status AddRectangle(double x, double y, double width, double height);
|
||||
Status AddRoundRectangle(double x, double y, double width, double height, double cx, double cy);
|
||||
Status AddPolygon(double* pPoints, int nCount);
|
||||
Status AddPath(const CGraphicsPath& oPath);
|
||||
Status AddArc(double x, double y, double width, double height, double startAngle, double sweepAngle);
|
||||
@ -117,7 +116,6 @@ namespace Aggplus
|
||||
std::vector<PointD> GetPoints(unsigned idx, unsigned count) const noexcept;
|
||||
std::vector<CGraphicsPath> GetSubPaths() const;
|
||||
|
||||
bool Equals(const CGraphicsPath& other) noexcept;
|
||||
CGraphicsPath& operator=(const CGraphicsPath& other) noexcept;
|
||||
CGraphicsPath& operator=(CGraphicsPath&& other) noexcept;
|
||||
bool operator==(const CGraphicsPath& other) noexcept;
|
||||
|
||||
@ -613,6 +613,32 @@ HRESULT CGraphicsRenderer::put_BrushTransform(const Aggplus::CMatrix& oMatrix)
|
||||
m_oBrush.Transform = oMatrix;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::get_BrushOffset(double& offsetX, double& offsetY) const
|
||||
{
|
||||
offsetX = m_oBrush.OffsetX;
|
||||
offsetY = m_oBrush.OffsetY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::put_BrushOffset(const double& offsetX, const double& offsetY)
|
||||
{
|
||||
m_oBrush.OffsetX = offsetX;
|
||||
m_oBrush.OffsetY = offsetY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const
|
||||
{
|
||||
isScale = m_oBrush.IsScale;
|
||||
scaleX = m_oBrush.ScaleX;
|
||||
scaleY = m_oBrush.ScaleY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::put_BrushScale(bool isScale, const double& scaleX, const double& scaleY)
|
||||
{
|
||||
m_oBrush.IsScale = isScale;
|
||||
m_oBrush.ScaleX = scaleX;
|
||||
m_oBrush.ScaleY = scaleY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height)
|
||||
{
|
||||
m_oBrush.Rectable = val;
|
||||
@ -946,11 +972,18 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
switch (m_oBrush.TextureMode)
|
||||
{
|
||||
case c_BrushTextureModeTile:
|
||||
oMode = Aggplus::WrapModeTile;
|
||||
break;
|
||||
case c_BrushTextureModeTileCenter:
|
||||
oMode = Aggplus::WrapModeTile;
|
||||
break;
|
||||
case c_BrushTextureModeTileFlipX:
|
||||
oMode = Aggplus::WrapModeTileFlipX;
|
||||
break;
|
||||
case c_BrushTextureModeTileFlipY:
|
||||
oMode = Aggplus::WrapModeTileFlipY;
|
||||
break;
|
||||
case c_BrushTextureModeTileFlipXY:
|
||||
oMode = Aggplus::WrapModeTileFlipXY;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1023,11 +1056,18 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
if (m_oBrush.Rectable == 1)
|
||||
{
|
||||
pTextureBrush->m_bUseBounds = true;
|
||||
pTextureBrush->m_oBounds.left = m_oBrush.Rect.X;
|
||||
pTextureBrush->m_oBounds.top = m_oBrush.Rect.Y;
|
||||
pTextureBrush->m_oBounds.left = m_oBrush.Rect.X + m_oBrush.OffsetX;
|
||||
pTextureBrush->m_oBounds.top = m_oBrush.Rect.Y + m_oBrush.OffsetY;
|
||||
pTextureBrush->m_oBounds.right = pTextureBrush->m_oBounds.left + m_oBrush.Rect.Width;
|
||||
pTextureBrush->m_oBounds.bottom = pTextureBrush->m_oBounds.top + m_oBrush.Rect.Height;
|
||||
}
|
||||
|
||||
if (m_oBrush.IsScale == 1)
|
||||
{
|
||||
pTextureBrush->m_bIsScale = true;
|
||||
pTextureBrush->m_dScaleX = m_oBrush.ScaleX;
|
||||
pTextureBrush->m_dScaleY = m_oBrush.ScaleY;
|
||||
}
|
||||
}
|
||||
|
||||
pBrush = pTextureBrush;
|
||||
|
||||
@ -189,6 +189,10 @@ public:
|
||||
virtual HRESULT put_BrushLinearAngle(const double& dAngle);
|
||||
virtual HRESULT get_BrushTransform(Aggplus::CMatrix& oMatrix);
|
||||
virtual HRESULT put_BrushTransform(const Aggplus::CMatrix& oMatrix);
|
||||
virtual HRESULT get_BrushOffset(double& offsetX, double& offsetY) const;
|
||||
virtual HRESULT put_BrushOffset(const double& offsetX, const double& offsetY);
|
||||
virtual HRESULT get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const;
|
||||
virtual HRESULT put_BrushScale(bool isScale, const double& scaleX, const double& scaleY);
|
||||
virtual HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height);
|
||||
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height);
|
||||
virtual HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount);
|
||||
|
||||
@ -156,7 +156,6 @@ public:
|
||||
PageClear = 9,
|
||||
PageRotate = 10,
|
||||
Headings = 11,
|
||||
Redact = 12,
|
||||
|
||||
Undefined = 255
|
||||
};
|
||||
@ -168,7 +167,10 @@ public:
|
||||
AdvancedCommandType GetCommandType() { return m_nCommandType; }
|
||||
};
|
||||
|
||||
namespace Aggplus { class CImage; }
|
||||
namespace Aggplus {
|
||||
class CImage;
|
||||
class CGraphicsPath;
|
||||
}
|
||||
|
||||
// IRenderer
|
||||
class IRenderer : public IGrObject
|
||||
@ -240,6 +242,32 @@ public:
|
||||
virtual HRESULT put_BrushTransform(const Aggplus::CMatrix& oMatrix) = 0;
|
||||
virtual HRESULT get_BrushLinearAngle(double* dAngle) = 0;
|
||||
virtual HRESULT put_BrushLinearAngle(const double& dAngle) = 0;
|
||||
virtual HRESULT get_BrushOffset(double& offsetX, double& offsetY) const
|
||||
{
|
||||
UNUSED_VARIABLE(offsetX);
|
||||
UNUSED_VARIABLE(offsetY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT put_BrushOffset(const double& offsetX, const double& offsetY)
|
||||
{
|
||||
UNUSED_VARIABLE(offsetX);
|
||||
UNUSED_VARIABLE(offsetY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const
|
||||
{
|
||||
UNUSED_VARIABLE(isScale);
|
||||
UNUSED_VARIABLE(scaleX);
|
||||
UNUSED_VARIABLE(scaleY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT put_BrushScale(bool isScale, const double& scaleX, const double& scaleY)
|
||||
{
|
||||
UNUSED_VARIABLE(isScale);
|
||||
UNUSED_VARIABLE(scaleX);
|
||||
UNUSED_VARIABLE(scaleY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height) = 0;
|
||||
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height) = 0;
|
||||
|
||||
@ -299,6 +327,8 @@ public:
|
||||
virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT PathCommandTextEx(const std::wstring& sText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
|
||||
HRESULT AddPath(const Aggplus::CGraphicsPath& path);
|
||||
|
||||
//-------- Функции для вывода изображений ---------------------------------------------------
|
||||
virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha = 255) = 0;
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#include "../fontengine/FontManager.h"
|
||||
#include "../raster/BgraFrame.h"
|
||||
#include "../common/StringExt.h"
|
||||
#include "../GraphicsPath.h"
|
||||
|
||||
// этот класс нужно переписать. должно работать как и в js
|
||||
// а не просто на каждом символе переключаться, если нужно
|
||||
@ -351,7 +352,13 @@ namespace NSOnlineOfficeBinToPdf
|
||||
bool bIsPathOpened = false;
|
||||
bool bIsEnableBrushRect = false;
|
||||
|
||||
double old_t1, old_t2, old_t3, old_t4, old_t5, old_t6;
|
||||
|
||||
CBufferReader oReader(pBuffer, lBufferLen);
|
||||
Aggplus::CGraphicsPath path;
|
||||
Aggplus::CMatrix transMatrRot;
|
||||
Aggplus::RectF_T<double> clipRect;
|
||||
bool isResetRot = false;
|
||||
while (oReader.Check())
|
||||
{
|
||||
eCommand = (CommandType)(oReader.ReadByte());
|
||||
@ -471,6 +478,16 @@ namespace NSOnlineOfficeBinToPdf
|
||||
double m2 = oReader.ReadDouble();
|
||||
double m3 = oReader.ReadDouble();
|
||||
double m4 = oReader.ReadDouble();
|
||||
|
||||
long type;
|
||||
pRenderer->get_BrushTextureMode(&type);
|
||||
if (type != c_BrushTextureModeStretch)
|
||||
{
|
||||
m1 = 0.0;
|
||||
m2 = 0.0;
|
||||
}
|
||||
|
||||
clipRect = Aggplus::RectF_T<double>(m1, m2, m3, m4);
|
||||
pRenderer->BrushRect(bIsEnableBrushRect ? 1 : 0, m1, m2, m3, m4);
|
||||
break;
|
||||
}
|
||||
@ -590,6 +607,16 @@ namespace NSOnlineOfficeBinToPdf
|
||||
pRenderer->put_BrushTextureAlpha(lAlpha);
|
||||
break;
|
||||
}
|
||||
case ctBrushResetRotation:
|
||||
{
|
||||
pRenderer->GetTransform(&old_t1, &old_t2, &old_t3, &old_t4, &old_t5, &old_t6);
|
||||
|
||||
Aggplus::CMatrix mtr(old_t1, old_t2, old_t3, old_t4, old_t5, old_t6);
|
||||
double rot = mtr.rotation();
|
||||
transMatrRot.Rotate(agg::rad2deg(rot));
|
||||
isResetRot = true;
|
||||
break;
|
||||
}
|
||||
case ctSetTransform:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
@ -611,6 +638,8 @@ namespace NSOnlineOfficeBinToPdf
|
||||
|
||||
pRenderer->BeginCommand(c_nPathType);
|
||||
pRenderer->PathCommandStart();
|
||||
path.Reset();
|
||||
path.StartFigure();
|
||||
|
||||
bIsPathOpened = true;
|
||||
break;
|
||||
@ -619,14 +648,14 @@ namespace NSOnlineOfficeBinToPdf
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
pRenderer->PathCommandMoveTo(m1, m2);
|
||||
path.MoveTo(m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandLineTo:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
pRenderer->PathCommandLineTo(m1, m2);
|
||||
path.LineTo(m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandCurveTo:
|
||||
@ -637,12 +666,12 @@ namespace NSOnlineOfficeBinToPdf
|
||||
double m4 = oReader.ReadDouble();
|
||||
double m5 = oReader.ReadDouble();
|
||||
double m6 = oReader.ReadDouble();
|
||||
pRenderer->PathCommandCurveTo(m1, m2, m3, m4, m5, m6);
|
||||
path.CurveTo(m1, m2, m3, m4, m5, m6);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandClose:
|
||||
{
|
||||
pRenderer->PathCommandClose();
|
||||
path.CloseFigure();
|
||||
break;
|
||||
}
|
||||
case ctPathCommandEnd:
|
||||
@ -655,9 +684,101 @@ namespace NSOnlineOfficeBinToPdf
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ctPathCommandOffset:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
|
||||
pRenderer->put_BrushOffset(m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandScale:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
|
||||
pRenderer->put_BrushScale(true, m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctDrawPath:
|
||||
{
|
||||
pRenderer->DrawPath(oReader.ReadInt());
|
||||
long fill = oReader.ReadInt();
|
||||
long type;
|
||||
pRenderer->get_BrushType(&type);
|
||||
|
||||
if (fill != c_nStroke && type == c_BrushTypeTexture)
|
||||
{
|
||||
Aggplus::CGraphicsPath clipPath;
|
||||
Aggplus::CGraphicsPath drawPath(path);
|
||||
|
||||
if (isResetRot)
|
||||
{
|
||||
pRenderer->get_BrushTextureMode(&type);
|
||||
bool isStretch = type == c_BrushTextureModeStretch;
|
||||
|
||||
double left, top, width, height;
|
||||
drawPath.GetBounds(left, top, width, height);
|
||||
|
||||
double rot = transMatrRot.rotation();
|
||||
double cX = left + width / 2.0;
|
||||
double cY = top + height / 2.0;
|
||||
|
||||
bool isZeroPt = clipRect.X < 0.1 && clipRect.X > -0.1 && clipRect.Y < 0.1 && clipRect.Y > -0.1;
|
||||
bool isZeroRot = rot < 1e-6 && rot > -1e-6;
|
||||
|
||||
transMatrRot.Reset();
|
||||
transMatrRot.RotateAt(agg::rad2deg(rot), cX, cY, Aggplus::MatrixOrderAppend);
|
||||
|
||||
double offX = old_t5 - transMatrRot.tx();
|
||||
double offY = old_t6 - transMatrRot.ty();
|
||||
|
||||
drawPath.Transform(&transMatrRot);
|
||||
pRenderer->SetTransform(1.0, 0.0, 0.0, 1.0, offX, offY);
|
||||
|
||||
if (isZeroPt && !isZeroRot && isStretch)
|
||||
drawPath.GetBounds(left, top, width, height);
|
||||
else
|
||||
{
|
||||
Aggplus::CGraphicsPath tmpPath;
|
||||
tmpPath.AddRectangle(left, top, width, height);
|
||||
tmpPath.Transform(&transMatrRot);
|
||||
tmpPath.GetBounds(left, top, width, height);
|
||||
}
|
||||
|
||||
if (isZeroPt || !isStretch)
|
||||
clipRect = Aggplus::RectF_T<double>(left, top, width, height);
|
||||
|
||||
if (isStretch)
|
||||
{
|
||||
if (!isZeroPt)
|
||||
clipRect.Offset(-offX, -offY);
|
||||
pRenderer->BrushRect(true, clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
double tileOffX, tileOffY;
|
||||
pRenderer->get_BrushOffset(tileOffX, tileOffY);
|
||||
pRenderer->put_BrushOffset(tileOffX - offX, tileOffY - offY);
|
||||
}
|
||||
}
|
||||
|
||||
clipPath.AddRectangle(clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height);
|
||||
path = Aggplus::CalcBooleanOperation(drawPath, clipPath, Aggplus::Intersection);
|
||||
clipRect = Aggplus::RectF_T<double>();
|
||||
}
|
||||
|
||||
pRenderer->AddPath(path);
|
||||
pRenderer->DrawPath(fill);
|
||||
|
||||
if (isResetRot)
|
||||
{
|
||||
pRenderer->SetTransform(old_t1, old_t2, old_t3, old_t4, old_t5, old_t6);
|
||||
transMatrRot.Reset();
|
||||
isResetRot = false;
|
||||
}
|
||||
|
||||
pRenderer->put_BrushScale(false, 1.0, 1.0);
|
||||
pRenderer->put_BrushOffset(0.0, 0.0);
|
||||
break;
|
||||
}
|
||||
case ctDrawImageFromFile:
|
||||
@ -921,7 +1042,6 @@ namespace NSOnlineOfficeBinToPdf
|
||||
case ctPageClear:
|
||||
case ctPageRotate:
|
||||
case ctHeadings:
|
||||
case ctRedact:
|
||||
{
|
||||
IAdvancedCommand::AdvancedCommandType eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::Undefined;
|
||||
switch (eCommand)
|
||||
@ -935,7 +1055,6 @@ namespace NSOnlineOfficeBinToPdf
|
||||
case ctPageClear: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::PageClear; break;
|
||||
case ctPageRotate: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::PageRotate; break;
|
||||
case ctHeadings: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::Headings; break;
|
||||
case ctRedact: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::Redact; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -946,7 +1065,7 @@ namespace NSOnlineOfficeBinToPdf
|
||||
if ((IAdvancedCommand::AdvancedCommandType::Undefined != eAdvancedCommandType) &&
|
||||
(S_OK == pRenderer->IsSupportAdvancedCommand(eAdvancedCommandType)))
|
||||
{
|
||||
IAdvancedCommand* pCommand = oReader.Read(eCommand, pCorrector, nLen);
|
||||
IAdvancedCommand* pCommand = oReader.Read(eCommand, pCorrector);
|
||||
if (pCommand)
|
||||
{
|
||||
pRenderer->AdvancedCommand(pCommand);
|
||||
@ -1132,6 +1251,10 @@ namespace NSOnlineOfficeBinToPdf
|
||||
oReader.Skip(1);
|
||||
break;
|
||||
}
|
||||
case ctBrushResetRotation:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case ctSetTransform:
|
||||
{
|
||||
oReader.SkipInt(6);
|
||||
@ -1164,6 +1287,16 @@ namespace NSOnlineOfficeBinToPdf
|
||||
{
|
||||
break;
|
||||
}
|
||||
case ctPathCommandOffset:
|
||||
{
|
||||
oReader.SkipInt(2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandScale:
|
||||
{
|
||||
oReader.SkipInt(2);
|
||||
break;
|
||||
}
|
||||
case ctDrawPath:
|
||||
{
|
||||
oReader.SkipInt();
|
||||
|
||||
@ -108,6 +108,7 @@ namespace NSOnlineOfficeBinToPdf
|
||||
ctBrushRectableEnabled = 30,
|
||||
ctBrushGradient = 31,
|
||||
ctBrushTexturePath = 32,
|
||||
ctBrushResetRotation = 33,
|
||||
|
||||
// font
|
||||
ctFontXML = 40,
|
||||
@ -153,6 +154,8 @@ namespace NSOnlineOfficeBinToPdf
|
||||
ctPathCommandGetCurrentPoint = 101,
|
||||
ctPathCommandText = 102,
|
||||
ctPathCommandTextEx = 103,
|
||||
ctPathCommandOffset = 104,
|
||||
ctPathCommandScale = 105,
|
||||
|
||||
// image
|
||||
ctDrawImage = 110,
|
||||
@ -185,7 +188,6 @@ namespace NSOnlineOfficeBinToPdf
|
||||
ctShapeStart = 167,
|
||||
ctShapeEnd = 168,
|
||||
ctHeadings = 169,
|
||||
ctRedact = 170,
|
||||
|
||||
ctPageWidth = 200,
|
||||
ctPageHeight = 201,
|
||||
|
||||
@ -46,16 +46,8 @@ namespace NSOnlineOfficeBinToPdf
|
||||
RELEASEOBJECT(command);
|
||||
return command;
|
||||
}
|
||||
template<typename T>
|
||||
inline IAdvancedCommand* Read_Command_Len(CBufferReader* pReader, IMetafileToRenderter* pCorrector, int nLen)
|
||||
{
|
||||
T* command = new T();
|
||||
if (!command->Read(pReader, pCorrector, nLen))
|
||||
RELEASEOBJECT(command);
|
||||
return command;
|
||||
}
|
||||
|
||||
IAdvancedCommand* CBufferReader::Read(int type, IMetafileToRenderter* pCorrector, int nLen)
|
||||
IAdvancedCommand* CBufferReader::Read(int type, IMetafileToRenderter* pCorrector)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@ -66,12 +58,11 @@ namespace NSOnlineOfficeBinToPdf
|
||||
case ctFormField: return Read_Command<CFormFieldInfo> (this, pCorrector);
|
||||
case ctAnnotFieldDelete: return Read_Command<CAnnotFieldDelete>(this, pCorrector);
|
||||
case ctWidgetsInfo: return Read_Command<CWidgetsInfo> (this, pCorrector);
|
||||
case ctShapeStart: return Read_Command_Len<CShapeStart> (this, pCorrector, nLen);
|
||||
case ctShapeStart: return Read_Command<CShapeStart> (this, pCorrector);
|
||||
case ctShapeEnd: return new CEmptyComand(IAdvancedCommand::AdvancedCommandType::ShapeEnd);
|
||||
case ctPageClear: return new CEmptyComand(IAdvancedCommand::AdvancedCommandType::PageClear);
|
||||
case ctPageRotate: return Read_Command<CPageRotate> (this, pCorrector);
|
||||
case ctHeadings: return Read_Command<CHeadings> (this, pCorrector);
|
||||
case ctRedact: return Read_Command<CRedact> (this, pCorrector);
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
@ -190,12 +190,8 @@ namespace NSOnlineOfficeBinToPdf
|
||||
int len = 2 * ReadUShort();
|
||||
SkipString16(len);
|
||||
}
|
||||
inline int Tell()
|
||||
{
|
||||
return (int)(m_cur - m_buffer);
|
||||
}
|
||||
|
||||
IAdvancedCommand* Read(int type, IMetafileToRenderter* pCorrector, int nLen = 0);
|
||||
IAdvancedCommand* Read(int type, IMetafileToRenderter* pCorrector);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -214,6 +214,19 @@ public:
|
||||
|
||||
inline bool IsPositive() { return Width > 0 && Height > 0; }
|
||||
|
||||
RectF_T& operator=(const RectF_T& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
X = other.X;
|
||||
Y = other.Y;
|
||||
Width = other.Width;
|
||||
Height = other.Height;
|
||||
|
||||
return *this;
|
||||
};
|
||||
|
||||
public:
|
||||
T X, Y, Width, Height;
|
||||
};
|
||||
|
||||
@ -76,7 +76,6 @@ CAnnotFieldInfo::CAnnotFieldInfo() : IAdvancedCommand(AdvancedCommandType::Annot
|
||||
m_pFreeTextPr = NULL;
|
||||
m_pCaretPr = NULL;
|
||||
m_pStampPr = NULL;
|
||||
m_pRedactPr = NULL;
|
||||
m_pWidgetPr = NULL;
|
||||
}
|
||||
CAnnotFieldInfo::~CAnnotFieldInfo()
|
||||
@ -92,7 +91,6 @@ CAnnotFieldInfo::~CAnnotFieldInfo()
|
||||
RELEASEOBJECT(m_pFreeTextPr);
|
||||
RELEASEOBJECT(m_pCaretPr);
|
||||
RELEASEOBJECT(m_pStampPr);
|
||||
RELEASEOBJECT(m_pRedactPr);
|
||||
RELEASEOBJECT(m_pWidgetPr);
|
||||
}
|
||||
|
||||
@ -180,13 +178,6 @@ void CAnnotFieldInfo::SetType(int nType)
|
||||
m_pPopupPr = new CAnnotFieldInfo::CPopupAnnotPr();
|
||||
break;
|
||||
}
|
||||
case EAnnotType::Redact:
|
||||
{
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pRedactPr);
|
||||
m_pRedactPr = new CAnnotFieldInfo::CRedactAnnotPr();
|
||||
break;
|
||||
}
|
||||
case EAnnotType::Widget:
|
||||
case EAnnotType::WidgetPushButton:
|
||||
case EAnnotType::WidgetRadioButton:
|
||||
@ -301,10 +292,6 @@ bool CAnnotFieldInfo::IsStamp() const
|
||||
{
|
||||
return (m_nType == 12);
|
||||
}
|
||||
bool CAnnotFieldInfo::IsRedact() const
|
||||
{
|
||||
return (m_nType == 25);
|
||||
}
|
||||
|
||||
CAnnotFieldInfo::CMarkupAnnotPr* CAnnotFieldInfo::GetMarkupAnnotPr() { return m_pMarkupPr; }
|
||||
CAnnotFieldInfo::CTextAnnotPr* CAnnotFieldInfo::GetTextAnnotPr() { return m_pTextPr; }
|
||||
@ -317,7 +304,6 @@ CAnnotFieldInfo::CPopupAnnotPr* CAnnotFieldInfo::GetPopupAnnotPr()
|
||||
CAnnotFieldInfo::CFreeTextAnnotPr* CAnnotFieldInfo::GetFreeTextAnnotPr() { return m_pFreeTextPr; }
|
||||
CAnnotFieldInfo::CCaretAnnotPr* CAnnotFieldInfo::GetCaretAnnotPr() { return m_pCaretPr; }
|
||||
CAnnotFieldInfo::CStampAnnotPr* CAnnotFieldInfo::GetStampAnnotPr() { return m_pStampPr; }
|
||||
CAnnotFieldInfo::CRedactAnnotPr* CAnnotFieldInfo::GetRedactAnnotPr() { return m_pRedactPr; }
|
||||
CAnnotFieldInfo::CWidgetAnnotPr* CAnnotFieldInfo::GetWidgetAnnotPr() { return m_pWidgetPr; }
|
||||
|
||||
bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
@ -405,8 +391,6 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
m_pCaretPr->Read(pReader, nFlags);
|
||||
else if (IsStamp())
|
||||
m_pStampPr->Read(pReader, nFlags);
|
||||
else if (IsRedact())
|
||||
m_pRedactPr->Read(pReader, nFlags);
|
||||
}
|
||||
else if (IsPopup())
|
||||
m_pPopupPr->Read(pReader);
|
||||
@ -681,46 +665,6 @@ void CAnnotFieldInfo::CStampAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader*
|
||||
m_dInRect[3] = pReader->ReadDouble();
|
||||
}
|
||||
|
||||
BYTE CAnnotFieldInfo::CRedactAnnotPr::GetQ() const { return m_nQ; }
|
||||
int CAnnotFieldInfo::CRedactAnnotPr::GetFontStyle() const { return m_nFontStyle; }
|
||||
double CAnnotFieldInfo::CRedactAnnotPr::GetFontSize() const { return m_dFS; }
|
||||
const std::wstring& CAnnotFieldInfo::CRedactAnnotPr::GetFontName() { return m_wsFN; }
|
||||
const std::wstring& CAnnotFieldInfo::CRedactAnnotPr::GetOverlayText() { return m_wsOverlayText; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CRedactAnnotPr::GetIC() { return m_arrIC; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CRedactAnnotPr::GetFontColor() { return m_arrFC; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CRedactAnnotPr::GetQuadPoints() { return m_arrQuadPoints; }
|
||||
void CAnnotFieldInfo::CRedactAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags)
|
||||
{
|
||||
if (nFlags & (1 << 15))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrQuadPoints.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
}
|
||||
if (nFlags & (1 << 16))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrIC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrIC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
if (nFlags & (1 << 17))
|
||||
m_wsOverlayText = pReader->ReadString();
|
||||
if (nFlags & (1 << 19))
|
||||
m_nQ = pReader->ReadByte();
|
||||
if (nFlags & (1 << 20))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrFC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrFC.push_back(pReader->ReadDouble());
|
||||
m_dFS = pReader->ReadDouble();
|
||||
m_wsFN = pReader->ReadString();
|
||||
m_nFontStyle = pReader->ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
bool CAnnotFieldInfo::CPopupAnnotPr::IsOpen() const { return m_bOpen; }
|
||||
int CAnnotFieldInfo::CPopupAnnotPr::GetFlag() const { return m_nFlag; }
|
||||
int CAnnotFieldInfo::CPopupAnnotPr::GetParentID() const { return m_nParentID; }
|
||||
@ -1222,46 +1166,3 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CRedact::CRedact() : IAdvancedCommand(AdvancedCommandType::Redact) {}
|
||||
CRedact::~CRedact()
|
||||
{
|
||||
for (int i = 0; i < m_arrRedact.size(); ++i)
|
||||
RELEASEOBJECT(m_arrRedact[i]);
|
||||
}
|
||||
const std::vector<CRedact::SRedact*>& CRedact::GetRedact() { return m_arrRedact; }
|
||||
bool CRedact::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrRedact.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
SRedact* pRedact = new SRedact();
|
||||
pRedact->sID = pReader->ReadString();
|
||||
int m = pReader->ReadInt();
|
||||
pRedact->arrQuadPoints.reserve(m * 8);
|
||||
for (int j = 0; j < m; ++j)
|
||||
{
|
||||
pRedact->arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
pRedact->arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
pRedact->arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
pRedact->arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
double x = pReader->ReadDouble();
|
||||
double y = pReader->ReadDouble();
|
||||
pRedact->arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
pRedact->arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
pRedact->arrQuadPoints.push_back(x);
|
||||
pRedact->arrQuadPoints.push_back(y);
|
||||
}
|
||||
pRedact->nFlag = pReader->ReadInt();
|
||||
if (pRedact->nFlag & (1 << 0))
|
||||
{
|
||||
pRedact->nRenderLen = pReader->ReadInt() - 4;
|
||||
pRedact->pRender = pReader->GetCurrentBuffer();
|
||||
pReader->Skip(pRedact->nRenderLen);
|
||||
}
|
||||
m_arrRedact.push_back(pRedact);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -59,7 +59,6 @@ public:
|
||||
Ink = 14,
|
||||
Popup = 15,
|
||||
FileAttachment = 16,
|
||||
Redact = 25,
|
||||
Widget = 26,
|
||||
WidgetPushButton = 27,
|
||||
WidgetRadioButton = 28,
|
||||
@ -453,31 +452,6 @@ public:
|
||||
double m_dInRect[4]{};
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CRedactAnnotPr
|
||||
{
|
||||
public:
|
||||
BYTE GetQ() const;
|
||||
int GetFontStyle() const;
|
||||
double GetFontSize() const;
|
||||
const std::wstring& GetFontName();
|
||||
const std::wstring& GetOverlayText();
|
||||
const std::vector<double>& GetIC();
|
||||
const std::vector<double>& GetFontColor();
|
||||
const std::vector<double>& GetQuadPoints();
|
||||
|
||||
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags);
|
||||
|
||||
private:
|
||||
BYTE m_nQ;
|
||||
int m_nFontStyle;
|
||||
double m_dFS;
|
||||
std::wstring m_wsFN;
|
||||
std::wstring m_wsOverlayText;
|
||||
std::vector<double> m_arrIC;
|
||||
std::vector<double> m_arrFC;
|
||||
std::vector<double> m_arrQuadPoints;
|
||||
};
|
||||
|
||||
CAnnotFieldInfo();
|
||||
virtual ~CAnnotFieldInfo();
|
||||
|
||||
@ -517,7 +491,6 @@ public:
|
||||
bool IsFreeText() const;
|
||||
bool IsCaret() const;
|
||||
bool IsStamp() const;
|
||||
bool IsRedact() const;
|
||||
|
||||
CMarkupAnnotPr* GetMarkupAnnotPr();
|
||||
CTextAnnotPr* GetTextAnnotPr();
|
||||
@ -530,7 +503,6 @@ public:
|
||||
CFreeTextAnnotPr* GetFreeTextAnnotPr();
|
||||
CCaretAnnotPr* GetCaretAnnotPr();
|
||||
CStampAnnotPr* GetStampAnnotPr();
|
||||
CRedactAnnotPr* GetRedactAnnotPr();
|
||||
CWidgetAnnotPr* GetWidgetAnnotPr();
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
@ -575,7 +547,6 @@ private:
|
||||
CFreeTextAnnotPr* m_pFreeTextPr;
|
||||
CCaretAnnotPr* m_pCaretPr;
|
||||
CStampAnnotPr* m_pStampPr;
|
||||
CRedactAnnotPr* m_pRedactPr;
|
||||
CWidgetAnnotPr* m_pWidgetPr;
|
||||
};
|
||||
|
||||
@ -631,27 +602,4 @@ private:
|
||||
std::vector<CParent*> m_arrParents;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CRedact : public IAdvancedCommand
|
||||
{
|
||||
public:
|
||||
struct SRedact
|
||||
{
|
||||
std::wstring sID;
|
||||
std::vector<double> arrQuadPoints;
|
||||
int nFlag;
|
||||
LONG nRenderLen;
|
||||
BYTE* pRender;
|
||||
};
|
||||
|
||||
CRedact();
|
||||
virtual ~CRedact();
|
||||
|
||||
const std::vector<SRedact*>& GetRedact();
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
|
||||
private:
|
||||
std::vector<SRedact*> m_arrRedact;
|
||||
};
|
||||
|
||||
#endif // _BUILD_ANNOTFIELD_H_
|
||||
|
||||
@ -147,20 +147,10 @@ void CShapeStart::SetShapeImage(BYTE* pImgData, int nWidth, int nHeight)
|
||||
}
|
||||
}
|
||||
std::string& CShapeStart::GetShapeXML() { return m_sShapeXML; }
|
||||
const std::vector<std::wstring>& CShapeStart::GetRedactID() { return m_arrRedactID; }
|
||||
Aggplus::CImage* CShapeStart::GetShapeImage() { return m_pImage; }
|
||||
bool CShapeStart::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector, int nLen)
|
||||
bool CShapeStart::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
{
|
||||
int nStart = pReader->Tell();
|
||||
m_sShapeXML = pReader->ReadStringA();
|
||||
int nEnd = pReader->Tell();
|
||||
if (nEnd - nStart < nLen)
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrRedactID.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrRedactID.push_back(pReader->ReadString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -139,17 +139,15 @@ public:
|
||||
~CShapeStart();
|
||||
|
||||
std::string& GetShapeXML();
|
||||
const std::vector<std::wstring>& GetRedactID();
|
||||
Aggplus::CImage* GetShapeImage();
|
||||
|
||||
void SetShapeXML(const std::string& sShapeXML);
|
||||
void SetShapeImage(BYTE* pImgData, int nWidth, int nHeight);
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector, int nLen);
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
|
||||
private:
|
||||
std::string m_sShapeXML;
|
||||
std::vector<std::wstring> m_arrRedactID;
|
||||
Aggplus::CImage* m_pImage;
|
||||
};
|
||||
|
||||
|
||||
@ -639,7 +639,6 @@ namespace NSFonts
|
||||
virtual double GetCharWidth(int gid) = 0;
|
||||
|
||||
virtual int GetGIDByUnicode(int code) = 0;
|
||||
virtual int GetUnicodeByGID(int gid) = 0;
|
||||
|
||||
virtual int GetEmbeddingLicenceType() = 0;
|
||||
virtual void FillFontSelectFormat(CFontSelectFormat& oFormat) = 0;
|
||||
@ -737,7 +736,6 @@ namespace NSFonts
|
||||
|
||||
virtual unsigned int GetNameIndex(const std::wstring& wsName) = 0;
|
||||
virtual unsigned int GetGIDByUnicode(const unsigned int& unCode) = 0;
|
||||
virtual int GetUnicodeByGID(const int& gid) = 0;
|
||||
|
||||
virtual void GetFace(double& d0, double& d1, double& d2) = 0;
|
||||
virtual void GetLimitsY(double& dMin, double& dMax) = 0;
|
||||
|
||||
@ -54,8 +54,6 @@
|
||||
"_SplitPages",
|
||||
"_MergePages",
|
||||
"_UnmergePages",
|
||||
"_RedactPage",
|
||||
"_UndoRedact",
|
||||
"_GetImageBase64",
|
||||
"_GetImageBase64Len",
|
||||
"_GetImageBase64Ptr",
|
||||
@ -97,7 +95,7 @@
|
||||
"compile_files_array": [
|
||||
{
|
||||
"folder": "../../../raster/",
|
||||
"files": ["BgraFrame.cpp", "ImageFileFormatChecker.cpp", "PICT/PICFile.cpp"]
|
||||
"files": ["BgraFrame.cpp", "ImageFileFormatChecker.cpp", "PICT/PICFile.cpp", "PICT/pic.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../cximage/CxImage/",
|
||||
@ -157,11 +155,11 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../agg-2.4/src/",
|
||||
"files": ["agg_arc.cpp", "agg_vcgen_stroke.cpp", "agg_vcgen_dash.cpp", "agg_trans_affine.cpp", "agg_curves.cpp", "agg_image_filters.cpp", "agg_bezier_arc.cpp"]
|
||||
"files": ["agg_arc.cpp", "agg_vcgen_stroke.cpp", "agg_vcgen_dash.cpp", "agg_trans_affine.cpp", "agg_curves.cpp", "agg_image_filters.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../common/",
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp", "Path.cpp", "SystemUtils.cpp", "StringUTF32.cpp", "StringBuilder.cpp"]
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp", "Path.cpp", "SystemUtils.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../Common/3dParty/icu/icu/source/common/",
|
||||
@ -197,7 +195,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/SrcWriter/",
|
||||
"files": ["AcroForm.cpp", "Annotation.cpp", "Catalog.cpp", "Destination.cpp", "Document.cpp", "Encrypt.cpp", "EncryptDictionary.cpp", "Field.cpp", "Font.cpp", "Font14.cpp", "FontCidTT.cpp", "FontOTWriter.cpp", "FontTT.cpp", "FontTTWriter.cpp", "GState.cpp", "Image.cpp", "Info.cpp", "Metadata.cpp", "Objects.cpp", "Outline.cpp", "Pages.cpp", "Pattern.cpp", "ResourcesDictionary.cpp", "Shading.cpp", "States.cpp", "Streams.cpp", "Utils.cpp", "RedactOutputDev.cpp"]
|
||||
"files": ["AcroForm.cpp", "Annotation.cpp", "Catalog.cpp", "Destination.cpp", "Document.cpp", "Encrypt.cpp", "EncryptDictionary.cpp", "Field.cpp", "Font.cpp", "Font14.cpp", "FontCidTT.cpp", "FontOTWriter.cpp", "FontTT.cpp", "FontTTWriter.cpp", "GState.cpp", "Image.cpp", "Info.cpp", "Metadata.cpp", "Objects.cpp", "Outline.cpp", "Pages.cpp", "Pattern.cpp", "ResourcesDictionary.cpp", "Shading.cpp", "States.cpp", "Streams.cpp", "Utils.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/Resources/",
|
||||
@ -252,8 +250,8 @@
|
||||
"files": ["BaseItem.cpp", "ContText.cpp", "Paragraph.cpp", "Shape.cpp", "TextLine.cpp", "Table.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../OdfFile/Common",
|
||||
"files": ["logging.cpp"]
|
||||
"folder": "../../../common",
|
||||
"files": ["StringUTF32.cpp", "StringBuilder.cpp"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -113,6 +113,7 @@ SOURCES += \
|
||||
../../../../raster/ImageFileFormatChecker.cpp \
|
||||
../../../../raster/Metafile/MetaFile.cpp \
|
||||
../../../../raster/PICT/PICFile.cpp \
|
||||
../../../../raster/PICT/pic.cpp \
|
||||
\
|
||||
../../../ArrowHead.cpp \
|
||||
../../../Brush.cpp \
|
||||
@ -700,8 +701,7 @@ HEADERS += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Utils.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Metadata.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/ICCProfile.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/RedactOutputDev.h
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.h
|
||||
|
||||
SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/AcroForm.cpp \
|
||||
@ -730,8 +730,7 @@ SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Streams.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Utils.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Metadata.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/RedactOutputDev.cpp
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.cpp
|
||||
|
||||
# PdfFile
|
||||
|
||||
|
||||
@ -145,9 +145,9 @@ CFile.prototype["isNeedPassword"] = function()
|
||||
{
|
||||
return this._isNeedPassword;
|
||||
};
|
||||
CFile.prototype["SplitPages"] = function(arrOriginIndex, arrayBufferChanges)
|
||||
CFile.prototype["SplitPages"] = function(arrPageIndex, arrayBufferChanges)
|
||||
{
|
||||
let ptr = this._SplitPages(arrOriginIndex, arrayBufferChanges);
|
||||
let ptr = this._SplitPages(arrPageIndex, arrayBufferChanges);
|
||||
let res = ptr.getMemory(true);
|
||||
ptr.free();
|
||||
return res;
|
||||
@ -160,14 +160,6 @@ CFile.prototype["UndoMergePages"] = function()
|
||||
{
|
||||
return this._UndoMergePages();
|
||||
};
|
||||
CFile.prototype["RedactPage"] = function(originIndex, arrRedactBox, arrayBufferFiller)
|
||||
{
|
||||
return this._RedactPage(originIndex, arrRedactBox, arrayBufferFiller);
|
||||
};
|
||||
CFile.prototype["UndoRedact"] = function()
|
||||
{
|
||||
return this._UndoRedact();
|
||||
};
|
||||
|
||||
// INFO DOCUMENT
|
||||
CFile.prototype.getInfo = function()
|
||||
@ -259,9 +251,9 @@ CFile.prototype["getStructure"] = function()
|
||||
return res;
|
||||
};
|
||||
|
||||
CFile.prototype["getLinks"] = function(originIndex)
|
||||
CFile.prototype["getLinks"] = function(pageIndex)
|
||||
{
|
||||
let ptr = this._getLinks(originIndex);
|
||||
let ptr = this._getLinks(pageIndex);
|
||||
let reader = ptr.getReader();
|
||||
|
||||
if (!reader) return [];
|
||||
@ -284,12 +276,11 @@ CFile.prototype["getLinks"] = function(originIndex)
|
||||
};
|
||||
|
||||
// TEXT
|
||||
CFile.prototype["getGlyphs"] = function(originIndex)
|
||||
CFile.prototype["getGlyphs"] = function(pageIndex)
|
||||
{
|
||||
let pageIndex = this.pages.findIndex(function(page) {
|
||||
return page.originIndex == originIndex;
|
||||
});
|
||||
let page = this.pages[pageIndex];
|
||||
if (page.originIndex == undefined)
|
||||
return [];
|
||||
if (page.fonts.length > 0)
|
||||
{
|
||||
// waiting fonts
|
||||
@ -297,7 +288,7 @@ CFile.prototype["getGlyphs"] = function(originIndex)
|
||||
}
|
||||
|
||||
this.lockPageNumForFontsLoader(pageIndex, UpdateFontsSource.Page);
|
||||
let res = this._getGlyphs(originIndex);
|
||||
let res = this._getGlyphs(page.originIndex);
|
||||
// there is no need to delete the result; this buffer is used as a text buffer
|
||||
// for text commands on other pages. After receiving ALL text pages,
|
||||
// you need to call destroyTextInfo()
|
||||
@ -621,7 +612,6 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
oFont["vertical"] = readDoubleFunc.call(reader);
|
||||
if (nFontFlag & (1 << 6))
|
||||
oFont["actual"] = readStringFunc.call(reader);
|
||||
oFont["rtl"] = (nFontFlag >> 7) & 1;
|
||||
oFont["size"] = readDoubleFunc.call(reader);
|
||||
oFont["color"] = [];
|
||||
oFont["color"].push(readDouble2Func.call(reader));
|
||||
@ -1409,7 +1399,7 @@ CFile.prototype["getInteractiveFormsInfo"] = function()
|
||||
// optional nWidget - rec["AP"]["i"]
|
||||
// optional sView - N/D/R
|
||||
// optional sButtonView - state pushbutton-annotation - Off/Yes(or rec["ExportValue"])
|
||||
CFile.prototype["getInteractiveFormsAP"] = function(originIndex, width, height, backgroundColor, nWidget, sView, sButtonView)
|
||||
CFile.prototype["getInteractiveFormsAP"] = function(pageIndex, width, height, backgroundColor, nWidget, sView, sButtonView)
|
||||
{
|
||||
let nView = -1;
|
||||
if (sView)
|
||||
@ -1425,11 +1415,8 @@ CFile.prototype["getInteractiveFormsAP"] = function(originIndex, width, height,
|
||||
if (sButtonView)
|
||||
nButtonView = (sButtonView == "Off" ? 0 : 1);
|
||||
|
||||
let pageIndex = this.pages.findIndex(function(page) {
|
||||
return page.originIndex == originIndex;
|
||||
});
|
||||
this.lockPageNumForFontsLoader(pageIndex, UpdateFontsSource.Forms);
|
||||
let ptr = this._getInteractiveFormsAP(width, height, backgroundColor, originIndex, nWidget, nView, nButtonView);
|
||||
let ptr = this._getInteractiveFormsAP(width, height, backgroundColor, pageIndex, nWidget, nView, nButtonView);
|
||||
let reader = ptr.getReader();
|
||||
this.unlockPageNumForFontsLoader();
|
||||
|
||||
@ -1514,13 +1501,13 @@ CFile.prototype["getButtonIcons"] = function(pageIndex, width, height, backgroun
|
||||
ptr.free();
|
||||
return res;
|
||||
};
|
||||
// optional originIndex - get annotations from specific page
|
||||
CFile.prototype["getAnnotationsInfo"] = function(originIndex)
|
||||
// optional pageIndex - get annotations from specific page
|
||||
CFile.prototype["getAnnotationsInfo"] = function(pageIndex)
|
||||
{
|
||||
if (!this.nativeFile)
|
||||
return [];
|
||||
|
||||
let ptr = this._getAnnotationsInfo(originIndex);
|
||||
let ptr = this._getAnnotationsInfo(pageIndex);
|
||||
let reader = ptr.getReader();
|
||||
|
||||
if (!reader) return [];
|
||||
@ -1552,7 +1539,7 @@ CFile.prototype["getAnnotationsInfo"] = function(originIndex)
|
||||
};
|
||||
// optional nAnnot ...
|
||||
// optional sView ...
|
||||
CFile.prototype["getAnnotationsAP"] = function(originIndex, width, height, backgroundColor, nAnnot, sView)
|
||||
CFile.prototype["getAnnotationsAP"] = function(pageIndex, width, height, backgroundColor, nAnnot, sView)
|
||||
{
|
||||
let nView = -1;
|
||||
if (sView)
|
||||
@ -1565,11 +1552,8 @@ CFile.prototype["getAnnotationsAP"] = function(originIndex, width, height, backg
|
||||
nView = 2;
|
||||
}
|
||||
|
||||
let pageIndex = this.pages.findIndex(function(page) {
|
||||
return page.originIndex == originIndex;
|
||||
});
|
||||
this.lockPageNumForFontsLoader(pageIndex, UpdateFontsSource.Annotation);
|
||||
let ptr = this._getAnnotationsAP(width, height, backgroundColor, originIndex, nAnnot, nView);
|
||||
let ptr = this._getAnnotationsAP(width, height, backgroundColor, pageIndex, nAnnot, nView);
|
||||
let reader = ptr.getReader();
|
||||
this.unlockPageNumForFontsLoader();
|
||||
|
||||
|
||||
@ -135,17 +135,6 @@ CFile.prototype._UndoMergePages = function()
|
||||
return g_native_drawing_file["UnmergePages"]();
|
||||
};
|
||||
|
||||
CFile.prototype._RedactPage = function(pageIndex, box, filler)
|
||||
{
|
||||
let dataFiller = (undefined !== filler.byteLength) ? new Uint8Array(filler) : filler;
|
||||
return g_native_drawing_file["RedactPage"](pageIndex, box, dataFiller);
|
||||
};
|
||||
|
||||
CFile.prototype._UndoRedact = function()
|
||||
{
|
||||
return g_native_drawing_file["UndoRedact"]();
|
||||
};
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
|
||||
@ -192,38 +192,6 @@ CFile.prototype._UndoMergePages = function()
|
||||
return Module["_UnmergePages"](this.nativeFile) == 1;
|
||||
};
|
||||
|
||||
CFile.prototype._RedactPage = function(pageIndex, arrRedactBox, arrayBufferFiller)
|
||||
{
|
||||
let changesPtr = 0;
|
||||
let changesLen = 0;
|
||||
if (arrayBufferFiller)
|
||||
{
|
||||
let changes = new Uint8Array(arrayBufferFiller);
|
||||
changesLen = changes.length;
|
||||
changesPtr = Module["_malloc"](changesLen);
|
||||
Module["HEAP8"].set(changes, changesPtr);
|
||||
}
|
||||
|
||||
let memoryBuffer = new Int32Array(arrRedactBox.length);
|
||||
for (let i = 0; i < arrRedactBox.length; i++)
|
||||
memoryBuffer[i] = Math.round(arrRedactBox[i] * 10000);
|
||||
|
||||
let pointer = Module["_malloc"](memoryBuffer.length * 4);
|
||||
Module["HEAP32"].set(memoryBuffer, pointer >> 2);
|
||||
|
||||
let bRes = Module["_RedactPage"](this.nativeFile, pageIndex, pointer, memoryBuffer.length / 8, changesPtr, changesLen);
|
||||
changesPtr = 0; // Success or not, changesPtr is either taken or freed
|
||||
|
||||
Module["_free"](pointer);
|
||||
|
||||
return bRes == 1;
|
||||
};
|
||||
|
||||
CFile.prototype._UndoRedact = function()
|
||||
{
|
||||
return Module["_UndoRedact"](this.nativeFile) == 1;
|
||||
};
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
|
||||
@ -178,19 +178,6 @@ WASM_EXPORT int UnmergePages(CDrawingFile* pFile)
|
||||
{
|
||||
return pFile->UnmergePages() ? 1 : 0;
|
||||
}
|
||||
WASM_EXPORT int RedactPage(CDrawingFile* pFile, int nPageIndex, int* arrRedactBox, int nLengthX8, BYTE* data, int size)
|
||||
{
|
||||
double* arrDRedactBox = new double[nLengthX8 * 8];
|
||||
for (int i = 0; i < nLengthX8 * 8; ++i)
|
||||
arrDRedactBox[i] = arrRedactBox[i] / 10000.0;
|
||||
int nRes = pFile->RedactPage(nPageIndex, arrDRedactBox, nLengthX8, data, size) ? 1 : 0;
|
||||
delete[] arrDRedactBox;
|
||||
return nRes;
|
||||
}
|
||||
WASM_EXPORT int UndoRedact(CDrawingFile* pFile)
|
||||
{
|
||||
return pFile->UndoRedact() ? 1 : 0;
|
||||
}
|
||||
|
||||
WASM_EXPORT void* GetImageBase64(CDrawingFile* pFile, int rId)
|
||||
{
|
||||
|
||||
@ -976,8 +976,6 @@ bool GetFromBase64(const std::wstring& sPath, BYTE** pBuffer, int* nBufferLen)
|
||||
if (!NSBase64::Base64Decode((const char*)pFileContent, dwFileSize, *pBuffer, nBufferLen))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
oFile.CloseFile();
|
||||
return true;
|
||||
}
|
||||
@ -1051,37 +1049,49 @@ int main(int argc, char* argv[])
|
||||
int nBufferLen = NULL;
|
||||
BYTE* pBuffer = NULL;
|
||||
|
||||
if (true && GetFromBase64(NSFile::GetProcessDirectory() + L"/split.txt", &pBuffer, &nBufferLen))
|
||||
if (GetFromBase64(NSFile::GetProcessDirectory() + L"/split1.txt", &pBuffer, &nBufferLen))
|
||||
{
|
||||
std::vector<int> arrPages = { 2 };
|
||||
std::vector<int> arrPages = { 0 };
|
||||
BYTE* pSplitPages = SplitPages(pGrFile, arrPages.data(), arrPages.size(), pBuffer, nBufferLen);
|
||||
int nLength = READ_INT(pSplitPages);
|
||||
|
||||
if (nLength > 4)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.CreateFileW(NSFile::GetProcessDirectory() + L"/split.pdf"))
|
||||
if (oFile.CreateFileW(NSFile::GetProcessDirectory() + L"/split1.pdf"))
|
||||
oFile.WriteFile(pSplitPages + 4, nLength - 4);
|
||||
oFile.CloseFile();
|
||||
|
||||
BYTE* pMallocData = (BYTE*)malloc(nLength - 4);
|
||||
memcpy(pMallocData, pSplitPages + 4, nLength - 4);
|
||||
|
||||
MergePages(pGrFile, pMallocData, nLength - 4, 0, "merge1");
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pSplitPages);
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
|
||||
if (true)
|
||||
if (GetFromBase64(NSFile::GetProcessDirectory() + L"/split2.txt", &pBuffer, &nBufferLen))
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.OpenFile(NSFile::GetProcessDirectory() + L"/split.pdf"))
|
||||
{
|
||||
DWORD dwFileSize = oFile.GetFileSize();
|
||||
BYTE* pFileContent = (BYTE*)malloc(dwFileSize);
|
||||
std::vector<int> arrPages = { 0 };
|
||||
BYTE* pSplitPages = SplitPages(pGrFile, arrPages.data(), arrPages.size(), pBuffer, nBufferLen);
|
||||
int nLength = READ_INT(pSplitPages);
|
||||
|
||||
DWORD dwReaded;
|
||||
if (oFile.ReadFile(pFileContent, dwFileSize, dwReaded))
|
||||
MergePages(pGrFile, pFileContent, dwReaded, 0, "merge1");
|
||||
if (nLength > 4)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.CreateFileW(NSFile::GetProcessDirectory() + L"/split2.pdf"))
|
||||
oFile.WriteFile(pSplitPages + 4, nLength - 4);
|
||||
oFile.CloseFile();
|
||||
|
||||
BYTE* pMallocData = (BYTE*)malloc(nLength - 4);
|
||||
memcpy(pMallocData, pSplitPages + 4, nLength - 4);
|
||||
|
||||
MergePages(pGrFile, pMallocData, nLength - 4, 0, "merge2");
|
||||
}
|
||||
oFile.CloseFile();
|
||||
RELEASEARRAYOBJECTS(pSplitPages);
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
}
|
||||
|
||||
// INFO
|
||||
@ -1125,15 +1135,6 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
BYTE* pColor = new BYTE[12] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
// REDACT
|
||||
if (false)
|
||||
{
|
||||
int pRect[8] = { 307499, 217499, 307499, 1124999, 1799999, 1124999, 1799999, 217499 };
|
||||
if (!RedactPage(pGrFile, nTestPage, pRect, 1, pColor, 12))
|
||||
std::cout << "Redact false" << std::endl;
|
||||
}
|
||||
|
||||
int i = nTestPage;
|
||||
//for (int i = 0; i < nPagesCount; ++i)
|
||||
{
|
||||
@ -1161,6 +1162,7 @@ int main(int argc, char* argv[])
|
||||
RELEASEARRAYOBJECTS(res);
|
||||
}
|
||||
}
|
||||
|
||||
free(pInfo);
|
||||
|
||||
// LINKS
|
||||
@ -1513,8 +1515,6 @@ int main(int argc, char* argv[])
|
||||
std::cout << "; font-actual:" << std::string((char*)(pAnnots + i), nPathLength) << "; ";
|
||||
i += nPathLength;
|
||||
}
|
||||
if (nFontFlag & (1 << 7))
|
||||
std::cout << "; dir:rtl; ";
|
||||
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
|
||||
@ -282,7 +282,8 @@ SOURCES += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/JBig2/source/JBig2File.cpp
|
||||
|
||||
SOURCES += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/PICT/PICFile.cpp
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/PICT/PICFile.cpp \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/PICT/pic.cpp
|
||||
|
||||
!build_xp {
|
||||
CONFIG += support_heif
|
||||
|
||||
@ -113,7 +113,10 @@ const long c_BrushTypeTensorCurveGradient = 6007;
|
||||
|
||||
const long c_BrushTextureModeStretch = 0;
|
||||
const long c_BrushTextureModeTile = 1;
|
||||
const long c_BrushTextureModeTileCenter = 2;
|
||||
const long c_BrushTextureModeTileFlipX = 2;
|
||||
const long c_BrushTextureModeTileFlipY = 3;
|
||||
const long c_BrushTextureModeTileFlipXY = 4;
|
||||
const long c_BrushTextureModeTileCenter = 5;
|
||||
// --------------------------------------------------------------
|
||||
|
||||
namespace Aggplus { class CImage; }
|
||||
@ -284,6 +287,13 @@ namespace NSStructures
|
||||
Aggplus::RectF Rect;
|
||||
Aggplus::CDoubleRect Bounds;
|
||||
|
||||
int IsScale;
|
||||
double ScaleX;
|
||||
double ScaleY;
|
||||
|
||||
double OffsetX;
|
||||
double OffsetY;
|
||||
|
||||
double LinearAngle;
|
||||
std::vector<TSubColor> m_arrSubColors;
|
||||
NSStructures::GradientInfo m_oGradientInfo;
|
||||
@ -415,6 +425,13 @@ namespace NSStructures
|
||||
Rect.Width = 0.0F;
|
||||
Rect.Height = 0.0F;
|
||||
|
||||
IsScale = FALSE;
|
||||
ScaleX = 1.0;
|
||||
ScaleY = 1.0;
|
||||
|
||||
OffsetX = 0.0;
|
||||
OffsetY = 0.0;
|
||||
|
||||
Bounds.left = 0;
|
||||
Bounds.top = 0;
|
||||
Bounds.right = 0;
|
||||
@ -454,6 +471,10 @@ namespace NSStructures
|
||||
Rect = other.Rect;
|
||||
Bounds = other.Bounds;
|
||||
|
||||
IsScale = other.IsScale;
|
||||
ScaleX = other.ScaleX;
|
||||
ScaleY = other.ScaleY;
|
||||
|
||||
LinearAngle = other.LinearAngle;
|
||||
m_arrSubColors = other.m_arrSubColors;
|
||||
m_oGradientInfo = other.m_oGradientInfo;
|
||||
|
||||
@ -50,9 +50,9 @@ TEST(BooleanOperations, NoIntersOutside)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, NoIntersInside)
|
||||
@ -105,9 +105,9 @@ TEST(BooleanOperations, NoIntersInside)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, OneIntersOutside)
|
||||
@ -154,9 +154,9 @@ TEST(BooleanOperations, OneIntersOutside)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, OneIntersInside)
|
||||
@ -206,9 +206,9 @@ TEST(BooleanOperations, OneIntersInside)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, OverlapOutside)
|
||||
@ -258,9 +258,9 @@ TEST(BooleanOperations, OverlapOutside)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, OverlapInside)
|
||||
@ -312,9 +312,9 @@ TEST(BooleanOperations, OverlapInside)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, LineIntersLine)
|
||||
@ -368,9 +368,9 @@ TEST(BooleanOperations, LineIntersLine)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, CurveIntersLine)
|
||||
@ -415,9 +415,9 @@ TEST(BooleanOperations, CurveIntersLine)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, CurveIntersCurve)
|
||||
@ -453,9 +453,9 @@ TEST(BooleanOperations, CurveIntersCurve)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, RectIntersRect)
|
||||
@ -508,9 +508,9 @@ TEST(BooleanOperations, RectIntersRect)
|
||||
resultSubtract.LineTo(55.0, 25.0);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, EllipseIntersEllipse)
|
||||
@ -550,9 +550,9 @@ TEST(BooleanOperations, EllipseIntersEllipse)
|
||||
resultSubtract.CurveTo(303.228, 82.0, 348.0, 126.772, 348.0, 182.0);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, EllipseIntersCross)
|
||||
@ -621,9 +621,9 @@ TEST(BooleanOperations, EllipseIntersCross)
|
||||
resultSubtract.CurveTo(188.228, 60, 233, 104.772, 233, 160);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, TriangleIntersEllipse)
|
||||
@ -665,9 +665,9 @@ TEST(BooleanOperations, TriangleIntersEllipse)
|
||||
resultSubtract.CurveTo(243.078, 286.812, 260.127, 260.386, 263.419, 229.839);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, TwoVerticesInters)
|
||||
@ -715,9 +715,9 @@ TEST(BooleanOperations, TwoVerticesInters)
|
||||
resultSubtract.LineTo(-300, -300);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, RectIntersEllipse)
|
||||
@ -773,9 +773,9 @@ TEST(BooleanOperations, RectIntersEllipse)
|
||||
resultSubtract.CurveTo(257.623, 242.785, 258.883, 240.478, 260, 238.092);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, RectIntersCross)
|
||||
@ -869,9 +869,9 @@ TEST(BooleanOperations, RectIntersCross)
|
||||
resultSubtract.LineTo(-89.5, 24);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, CrossIntersTriangle)
|
||||
@ -977,9 +977,9 @@ TEST(BooleanOperations, CrossIntersTriangle)
|
||||
resultSubtract.LineTo(-6, 3.5);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, CrossIntersCross)
|
||||
@ -1077,9 +1077,9 @@ TEST(BooleanOperations, CrossIntersCross)
|
||||
resultSubtract.LineTo(-72, -191);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, EllipseTouchEllipse)
|
||||
@ -1119,9 +1119,9 @@ TEST(BooleanOperations, EllipseTouchEllipse)
|
||||
resultSubtract.CurveTo(138.137, 237, 165, 210.137, 165, 177);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, TriangleOverlapTriangle)
|
||||
@ -1170,7 +1170,7 @@ TEST(BooleanOperations, TriangleOverlapTriangle)
|
||||
resultSubtract.LineTo(-200, -300);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
@ -450,15 +450,15 @@ bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileTyp
|
||||
#if CXIMAGE_SUPPORT_PIC
|
||||
if (CXIMAGE_FORMAR_PIC == m_nFileType)
|
||||
{
|
||||
CPictFile pict_file;
|
||||
return pict_file.Open(this, strFileName, m_bIsRGBA);
|
||||
PICT::CPictFile PIC;
|
||||
return PIC.Open(this, strFileName, !m_bIsRGBA);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
if (CXIMAGE_FORMAT_HEIF == m_nFileType)
|
||||
{
|
||||
return NSHeif::CHeifFile::Open(this, strFileName, m_bIsRGBA);
|
||||
return NSHeif::CHeifFile::Open(this, strFileName, m_bIsRGBA);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -540,8 +540,8 @@ bool CBgraFrame::Decode(BYTE* pBuffer, int nSize, unsigned int nFileType)
|
||||
#if CXIMAGE_SUPPORT_PIC
|
||||
if (CXIMAGE_FORMAR_PIC == m_nFileType)
|
||||
{
|
||||
CPictFile pict_file;
|
||||
return pict_file.Open(this, pBuffer, nSize, m_bIsRGBA);
|
||||
PICT::CPictFile PIC;
|
||||
return PIC.Open(this, pBuffer, nSize, !m_bIsRGBA);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -55,10 +55,7 @@ namespace SVG
|
||||
std::wstring wsImageData = m_wsHref.substr(unType + 8, m_wsHref.length() - unType - 8);
|
||||
ulSize = NSBase64::Base64DecodeGetRequiredLength(wsImageData.length());
|
||||
|
||||
pBuffer = new(std::nothrow) BYTE[ulSize];
|
||||
|
||||
if (NULL == pBuffer)
|
||||
return false;
|
||||
pBuffer = new BYTE[ulSize];
|
||||
|
||||
NSBase64::Base64Decode(wsImageData.c_str(), wsImageData.length(), pBuffer, &(int&)ulSize);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -32,250 +32,14 @@
|
||||
#ifndef PICFILE_H
|
||||
#define PICFILE_H
|
||||
|
||||
#include "../../graphics/pro/Graphics.h"
|
||||
#include "../BgraFrame.h"
|
||||
|
||||
enum PixelTrait
|
||||
{
|
||||
UndefinedPixelTrait = 0x000000,
|
||||
CopyPixelTrait = 0x000001,
|
||||
UpdatePixelTrait = 0x000002,
|
||||
BlendPixelTrait = 0x000004
|
||||
};
|
||||
|
||||
enum ClassType
|
||||
{
|
||||
UndefinedClass,
|
||||
DirectClass,
|
||||
PseudoClass
|
||||
};
|
||||
|
||||
enum PixelChannel
|
||||
{
|
||||
UndefinedPixelChannel = 0,
|
||||
RedPixelChannel = 0,
|
||||
CyanPixelChannel = 0,
|
||||
GrayPixelChannel = 0,
|
||||
LPixelChannel = 0,
|
||||
LabelPixelChannel = 0,
|
||||
YPixelChannel = 0,
|
||||
aPixelChannel = 1,
|
||||
GreenPixelChannel = 1,
|
||||
MagentaPixelChannel = 1,
|
||||
CbPixelChannel = 1,
|
||||
bPixelChannel = 2,
|
||||
BluePixelChannel = 2,
|
||||
YellowPixelChannel = 2,
|
||||
CrPixelChannel = 2,
|
||||
BlackPixelChannel = 3,
|
||||
AlphaPixelChannel = 4,
|
||||
IndexPixelChannel = 5,
|
||||
ReadMaskPixelChannel = 6,
|
||||
WriteMaskPixelChannel = 7,
|
||||
MetaPixelChannel = 8, /* deprecated */
|
||||
CompositeMaskPixelChannel = 9,
|
||||
MetaPixelChannels = 10,
|
||||
IntensityPixelChannel = 64, /* ???? */
|
||||
CompositePixelChannel = 64, /* ???? */
|
||||
SyncPixelChannel = 65 /* not a real channel */
|
||||
};
|
||||
|
||||
struct PixelChannelMap
|
||||
{
|
||||
PixelChannel channel{UndefinedPixelChannel};
|
||||
PixelTrait traits{UndefinedPixelTrait};
|
||||
size_t offset{0};
|
||||
};
|
||||
|
||||
struct PixelInfo
|
||||
{
|
||||
ClassType storage_class{DirectClass};
|
||||
|
||||
PixelTrait alpha_trait{UndefinedPixelTrait};
|
||||
|
||||
double red{0.0};
|
||||
double green{0.0};
|
||||
double blue{0.0};
|
||||
double alpha{0.0};
|
||||
double index{0.0};
|
||||
};
|
||||
|
||||
struct Image
|
||||
{
|
||||
ClassType m_eStorageClass{DirectClass};
|
||||
PixelTrait m_eAlphaTrait{UndefinedPixelTrait};
|
||||
|
||||
PixelInfo* m_pColormap{nullptr};
|
||||
PixelChannelMap* m_pChannelMap{nullptr};
|
||||
|
||||
size_t m_nColors{0};
|
||||
size_t m_nHeight{0};
|
||||
size_t m_nWidth{0};
|
||||
BYTE* m_pPixelData{nullptr};
|
||||
|
||||
Image()
|
||||
{
|
||||
m_pChannelMap = new PixelChannelMap[65];
|
||||
for (size_t i=0; i <= 64; i++)
|
||||
m_pChannelMap[i].channel=(PixelChannel) i;
|
||||
|
||||
m_pChannelMap[RedPixelChannel].offset = 0;
|
||||
m_pChannelMap[GreenPixelChannel].offset = 1;
|
||||
m_pChannelMap[BluePixelChannel].offset = 2;
|
||||
m_pChannelMap[AlphaPixelChannel].offset = 3;
|
||||
m_pChannelMap[IndexPixelChannel].offset = 5;
|
||||
}
|
||||
|
||||
Image(const Image& other) : Image()
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
~Image()
|
||||
{
|
||||
if (m_pChannelMap)
|
||||
delete[] m_pChannelMap;
|
||||
|
||||
if (m_pColormap)
|
||||
delete[] m_pColormap;
|
||||
|
||||
if (m_pPixelData)
|
||||
free(m_pPixelData);
|
||||
}
|
||||
|
||||
Image& operator=(const Image& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
m_eStorageClass = other.m_eStorageClass;
|
||||
m_eAlphaTrait = other.m_eAlphaTrait;
|
||||
|
||||
m_nColors = other.m_nColors;
|
||||
m_nWidth = other.m_nWidth;
|
||||
m_nHeight = other.m_nHeight;
|
||||
|
||||
if (other.m_pColormap)
|
||||
{
|
||||
m_pColormap = new PixelInfo[m_nColors + 1];
|
||||
memcpy(m_pColormap, other.m_pColormap, (m_nColors + 1) * sizeof(PixelInfo));
|
||||
}
|
||||
|
||||
memcpy(m_pChannelMap, other.m_pChannelMap, 65 * sizeof(PixelChannelMap));
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Realloc(const size_t& w, const size_t& h, const bool& isCopy = true)
|
||||
{
|
||||
size_t oldSize = 4 * m_nWidth * m_nHeight;
|
||||
size_t newSize = 4 * w * h;
|
||||
|
||||
m_nWidth = w;
|
||||
m_nHeight = h;
|
||||
|
||||
if (0 == newSize)
|
||||
{
|
||||
if (m_pPixelData)
|
||||
free(m_pPixelData);
|
||||
m_pPixelData = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldSize == newSize)
|
||||
return;
|
||||
|
||||
BYTE* oldPixels = m_pPixelData;
|
||||
if (oldSize > newSize || !m_pPixelData)
|
||||
{
|
||||
m_pPixelData = (BYTE*)malloc(newSize);
|
||||
if (isCopy && oldPixels)
|
||||
memcpy(m_pPixelData, oldPixels, newSize);
|
||||
|
||||
if (oldPixels)
|
||||
free(oldPixels);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pPixelData = (BYTE*)realloc(oldPixels, newSize);
|
||||
if (NULL == m_pPixelData)
|
||||
{
|
||||
m_pPixelData = (BYTE*)malloc(newSize);
|
||||
if (isCopy && oldPixels)
|
||||
memcpy(m_pPixelData, oldPixels, oldSize);
|
||||
|
||||
if (oldPixels)
|
||||
free(oldPixels);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class CPictFile
|
||||
{
|
||||
public:
|
||||
CPictFile();
|
||||
~CPictFile();
|
||||
|
||||
bool Open(CBgraFrame* frame, const std::wstring& fileName, bool isRGB);
|
||||
bool Open(CBgraFrame* frame, BYTE* buffer, const size_t& size, bool isRGB);
|
||||
private:
|
||||
bool Decode();
|
||||
bool DecodeHeader();
|
||||
bool DecodeData();
|
||||
|
||||
size_t GetFileSize() const;
|
||||
|
||||
size_t Read(const size_t& length, void* data);
|
||||
const void* ReadBlobStream(const size_t& length, void* data, size_t* count);
|
||||
unsigned short ReadShortValue();
|
||||
signed short ReadSignedShortValue();
|
||||
unsigned int ReadLongValue();
|
||||
bool ReadRectangle(Aggplus::Rect* rect);
|
||||
|
||||
void SetImageAlpha(Image* img, const BYTE alpha);
|
||||
BYTE* DecodeImage(const Image& img, size_t bytesPerLine, size_t bitsPerPixel, size_t* extent);
|
||||
const BYTE* UnpackScanline(const BYTE* pixels, const size_t& bitsPerPixel, BYTE* scanline, size_t* bytesPerLine);
|
||||
BYTE* GetPixels(const Image& image, const long long& x, const long long& y, const size_t& width, const size_t& height) const;
|
||||
void CompositeImage(const Image& composite,const long long& xOffset, const long long& yOffset);
|
||||
|
||||
void ReadPolygon();
|
||||
Aggplus::Rect ContractRect(const Aggplus::Rect& rect, bool isFrame);
|
||||
void DrawPolygon(bool isFrame);
|
||||
void DrawLine(const Aggplus::Point& p1, const Aggplus::Point& p2);
|
||||
void DrawRect(bool isFrame);
|
||||
void DrawRoundRect(bool isFrame);
|
||||
void DrawOval(bool isFrame);
|
||||
void DrawArc();
|
||||
void ReadAndDrawText(int x, int y);
|
||||
|
||||
void InitializeRenderer();
|
||||
|
||||
private:
|
||||
int m_nVersion{0};
|
||||
|
||||
FILE* m_pFile{nullptr};
|
||||
Image m_oImgData{};
|
||||
CBgraFrame m_oFrame{};
|
||||
BYTE* m_pFrameData{nullptr};
|
||||
|
||||
size_t m_nPenHeight{0};
|
||||
size_t m_nPenWidth{0};
|
||||
|
||||
int m_nFontStyle{0};
|
||||
int m_nFontSize{0};
|
||||
|
||||
std::wstring m_wsFontName{};
|
||||
|
||||
Aggplus::Point m_oPenPoint{0, 0};
|
||||
Aggplus::Point m_oTextPoint{0, 0};
|
||||
|
||||
Aggplus::Rect m_oLastRect{};
|
||||
Aggplus::Rect m_oLastRoundRect{};
|
||||
Aggplus::Rect m_oLastOval{};
|
||||
Aggplus::Rect m_oLastArc{};
|
||||
std::vector<Aggplus::Point> m_arLastPolygon{};
|
||||
|
||||
NSGraphics::IGraphicsRenderer* m_pRenderer{nullptr};
|
||||
NSFonts::IFontManager* m_pFontManager{nullptr};
|
||||
};
|
||||
namespace PICT {
|
||||
class GRAPHICS_DECL CPictFile {
|
||||
public:
|
||||
bool Open(CBgraFrame* pFrame, const std::wstring& strFileName, bool isRGBA);
|
||||
bool Open(CBgraFrame* pFrame, BYTE* pBuffer, int nSize, bool isRGBA);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PICFILE_H
|
||||
|
||||
3300
DesktopEditor/raster/PICT/pic.cpp
Normal file
3300
DesktopEditor/raster/PICT/pic.cpp
Normal file
File diff suppressed because it is too large
Load Diff
391
DesktopEditor/raster/PICT/pic.h
Normal file
391
DesktopEditor/raster/PICT/pic.h
Normal file
@ -0,0 +1,391 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PIC_H
|
||||
#define PIC_H
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <cstddef>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
UndefinedType,
|
||||
BilevelType,
|
||||
GrayscaleType,
|
||||
GrayscaleAlphaType,
|
||||
PaletteType,
|
||||
PaletteAlphaType,
|
||||
TrueColorType,
|
||||
TrueColorAlphaType,
|
||||
ColorSeparationType,
|
||||
ColorSeparationAlphaType,
|
||||
OptimizeType,
|
||||
PaletteBilevelAlphaType
|
||||
} ImageType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* path;
|
||||
unsigned char* datum;
|
||||
|
||||
size_t length;
|
||||
size_t signature;
|
||||
|
||||
char* name;
|
||||
} StringInfo;
|
||||
|
||||
typedef struct _NodeInfo
|
||||
{
|
||||
void* key;
|
||||
void* value;
|
||||
|
||||
struct _NodeInfo* left;
|
||||
struct _NodeInfo* right;
|
||||
} NodeInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
NodeInfo* root;
|
||||
|
||||
int (*compare)(const void*, const void*);
|
||||
|
||||
int balance;
|
||||
|
||||
void* key;
|
||||
void* next;
|
||||
|
||||
size_t nodes;
|
||||
|
||||
size_t signature;
|
||||
} SplayTreeInfo;
|
||||
|
||||
typedef struct _PrimaryInfo
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
} PrimaryInfo;
|
||||
|
||||
typedef struct _ChromaticityInfo
|
||||
{
|
||||
PrimaryInfo red_primary;
|
||||
PrimaryInfo green_primary;
|
||||
PrimaryInfo blue_primary;
|
||||
PrimaryInfo white_point;
|
||||
} ChromaticityInfo;
|
||||
|
||||
typedef struct _PICTCode
|
||||
{
|
||||
const char* name;
|
||||
long long length;
|
||||
|
||||
const char* description;
|
||||
} PICTCode;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short top;
|
||||
short left;
|
||||
short bottom;
|
||||
short right;
|
||||
} PICTrectangle;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short version;
|
||||
short pack_type;
|
||||
|
||||
size_t pack_size;
|
||||
size_t horizontal_resolution;
|
||||
size_t vertical_resolution;
|
||||
|
||||
short pixel_type;
|
||||
short bits_per_pixel;
|
||||
short component_count;
|
||||
short component_size;
|
||||
|
||||
size_t plane_bytes;
|
||||
size_t table;
|
||||
size_t reserved;
|
||||
} PICTPixmap;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t width;
|
||||
size_t height;
|
||||
|
||||
long long x;
|
||||
long long y;
|
||||
} RectangleInfo;
|
||||
|
||||
typedef struct _NexusInfo
|
||||
{
|
||||
RectangleInfo region;
|
||||
size_t length;
|
||||
unsigned char* pixels;
|
||||
int authentic_pixel_cache;
|
||||
size_t signature;
|
||||
struct _NexusInfo* virtual_nexus;
|
||||
} NexusInfo;
|
||||
|
||||
|
||||
typedef struct _GeometryInfo
|
||||
{
|
||||
double rho;
|
||||
double sigma;
|
||||
double xi;
|
||||
double psi;
|
||||
double chi;
|
||||
} GeometryInfo;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
UndefinedChannel = 0x0000,
|
||||
RedChannel = 0x0001,
|
||||
GrayChannel = 0x0001,
|
||||
CyanChannel = 0x0001,
|
||||
LChannel = 0x0001,
|
||||
GreenChannel = 0x0002,
|
||||
MagentaChannel = 0x0002,
|
||||
aChannel = 0x0002,
|
||||
BlueChannel = 0x0004,
|
||||
bChannel = 0x0002,
|
||||
YellowChannel = 0x0004,
|
||||
BlackChannel = 0x0008,
|
||||
AlphaChannel = 0x0010,
|
||||
OpacityChannel = 0x0010,
|
||||
IndexChannel = 0x0020, /* Color Index Table? */
|
||||
ReadMaskChannel = 0x0040, /* Pixel is Not Readable? */
|
||||
WriteMaskChannel = 0x0080, /* Pixel is Write Protected? */
|
||||
MetaChannel = 0x0100, /* not used */
|
||||
CompositeMaskChannel = 0x0200, /* SVG mask */
|
||||
CompositeChannels = 0x001F,
|
||||
AllChannels = 0X7FFFFFF,
|
||||
/*
|
||||
Special purpose channel types.
|
||||
FUTURE: are these needed any more - they are more like hacks
|
||||
SyncChannels for example is NOT a real channel but a 'flag'
|
||||
It really says -- "User has not defined channels"
|
||||
Though it does have extra meaning in the "-auto-level" operator
|
||||
*/
|
||||
TrueAlphaChannel = 0x0100, /* extract actual alpha channel from opacity */
|
||||
RGBChannels = 0x0200, /* set alpha from grayscale mask in RGB */
|
||||
GrayChannels = 0x0400,
|
||||
SyncChannels = 0x20000, /* channels modified as a single unit */
|
||||
DefaultChannels = AllChannels
|
||||
} ChannelType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ReadMode,
|
||||
WriteMode,
|
||||
IOMode,
|
||||
PersistMode
|
||||
} MapMode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
UndefinedClass,
|
||||
DirectClass,
|
||||
PseudoClass
|
||||
} ClassType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
UndefinedColorspace,
|
||||
CMYColorspace, /* negated linear RGB colorspace */
|
||||
CMYKColorspace, /* CMY with Black separation */
|
||||
GRAYColorspace, /* Single Channel greyscale (non-linear) image */
|
||||
HCLColorspace,
|
||||
HCLpColorspace,
|
||||
HSBColorspace,
|
||||
HSIColorspace,
|
||||
HSLColorspace,
|
||||
HSVColorspace, /* alias for HSB */
|
||||
HWBColorspace,
|
||||
LabColorspace,
|
||||
LCHColorspace, /* alias for LCHuv */
|
||||
LCHabColorspace, /* Cylindrical (Polar) Lab */
|
||||
LCHuvColorspace, /* Cylindrical (Polar) Luv */
|
||||
LogColorspace,
|
||||
LMSColorspace,
|
||||
LuvColorspace,
|
||||
OHTAColorspace,
|
||||
Rec601YCbCrColorspace,
|
||||
Rec709YCbCrColorspace,
|
||||
RGBColorspace, /* Linear RGB colorspace */
|
||||
scRGBColorspace, /* ??? */
|
||||
sRGBColorspace, /* Default: non-linear sRGB colorspace */
|
||||
TransparentColorspace,
|
||||
xyYColorspace,
|
||||
XYZColorspace, /* IEEE Color Reference colorspace */
|
||||
YCbCrColorspace,
|
||||
YCCColorspace,
|
||||
YDbDrColorspace,
|
||||
YIQColorspace,
|
||||
YPbPrColorspace,
|
||||
YUVColorspace,
|
||||
LinearGRAYColorspace, /* Single Channel greyscale (linear) image */
|
||||
JzazbzColorspace,
|
||||
DisplayP3Colorspace,
|
||||
Adobe98Colorspace,
|
||||
ProPhotoColorspace,
|
||||
OklabColorspace,
|
||||
OklchColorspace
|
||||
} ColorspaceType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
UndefinedPixelTrait = 0x000000,
|
||||
CopyPixelTrait = 0x000001,
|
||||
UpdatePixelTrait = 0x000002,
|
||||
BlendPixelTrait = 0x000004
|
||||
} PixelTrait;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
UndefinedPixelChannel = 0,
|
||||
RedPixelChannel = 0,
|
||||
CyanPixelChannel = 0,
|
||||
GrayPixelChannel = 0,
|
||||
LPixelChannel = 0,
|
||||
LabelPixelChannel = 0,
|
||||
YPixelChannel = 0,
|
||||
aPixelChannel = 1,
|
||||
GreenPixelChannel = 1,
|
||||
MagentaPixelChannel = 1,
|
||||
CbPixelChannel = 1,
|
||||
bPixelChannel = 2,
|
||||
BluePixelChannel = 2,
|
||||
YellowPixelChannel = 2,
|
||||
CrPixelChannel = 2,
|
||||
BlackPixelChannel = 3,
|
||||
AlphaPixelChannel = 4,
|
||||
IndexPixelChannel = 5,
|
||||
ReadMaskPixelChannel = 6,
|
||||
WriteMaskPixelChannel = 7,
|
||||
MetaPixelChannel = 8, /* deprecated */
|
||||
CompositeMaskPixelChannel = 9,
|
||||
MetaPixelChannels = 10,
|
||||
IntensityPixelChannel = 64, /* ???? */
|
||||
CompositePixelChannel = 64, /* ???? */
|
||||
SyncPixelChannel = 65 /* not a real channel */
|
||||
} PixelChannel;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PixelChannel channel;
|
||||
PixelTrait traits;
|
||||
long long offset;
|
||||
} PixelChannelMap;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ClassType storage_class;
|
||||
|
||||
ColorspaceType colorspace;
|
||||
|
||||
PixelTrait alpha_trait;
|
||||
|
||||
double fuzz;
|
||||
|
||||
size_t depth;
|
||||
size_t count;
|
||||
|
||||
double red;
|
||||
double green;
|
||||
double blue;
|
||||
double black;
|
||||
double alpha;
|
||||
double index;
|
||||
} PixelInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ClassType storage_class;
|
||||
ColorspaceType colorspace;
|
||||
ChromaticityInfo chromaticity;
|
||||
int m_pctVersion;
|
||||
|
||||
size_t m_nHeight;
|
||||
size_t m_nWidth;
|
||||
size_t m_ndepth;
|
||||
size_t m_nPixelsSize;
|
||||
size_t colors;
|
||||
|
||||
SplayTreeInfo* profiles;
|
||||
SplayTreeInfo* artifacts;
|
||||
|
||||
double fuzz;
|
||||
|
||||
unsigned char* ppixels;
|
||||
|
||||
double resolutionX;
|
||||
double resolutionY;
|
||||
double gamma;
|
||||
|
||||
ImageType type;
|
||||
|
||||
PixelInfo background_color;
|
||||
PixelInfo* colormap;
|
||||
|
||||
PixelTrait alpha_trait;
|
||||
|
||||
PixelChannelMap* channel_map;
|
||||
|
||||
PixelTrait mask_trait;
|
||||
|
||||
int taint;
|
||||
|
||||
void* cache;
|
||||
|
||||
size_t number_channels;
|
||||
|
||||
char error[256];
|
||||
}ImagePICT;
|
||||
|
||||
int DecodePICT(FILE* hFile, ImagePICT* image);
|
||||
void AquireImage(ImagePICT* image);
|
||||
ImagePICT* DestroyImage(ImagePICT* image);
|
||||
|
||||
#endif // PIC_H
|
||||
@ -21,10 +21,12 @@ namespace NSDocxRenderer
|
||||
}
|
||||
void CDocument::Clear()
|
||||
{
|
||||
m_oPageBuilder.Clear();
|
||||
NewPage();
|
||||
|
||||
m_arXmlString.clear();
|
||||
for(auto& val : m_mapXmlString)
|
||||
delete val.second;
|
||||
|
||||
m_mapXmlString.clear();
|
||||
m_lCurrentCommandType = 0;
|
||||
m_oImageManager.Clear();
|
||||
m_oFontStyleManager.Clear();
|
||||
@ -566,16 +568,11 @@ namespace NSDocxRenderer
|
||||
m_lCurrentCommandType = -1;
|
||||
m_oCurrentPage.m_lCurrentCommand = m_lCurrentCommandType;
|
||||
|
||||
if (0 == m_oPageBuilder.GetSize())
|
||||
m_oPageBuilder.AddSize(100000);
|
||||
m_oPageBuilder.ClearNoAttack();
|
||||
|
||||
auto pWriter = new NSStringUtils::CStringBuilder();
|
||||
pWriter->AddSize(100000);
|
||||
m_oCurrentPage.Analyze();
|
||||
m_oCurrentPage.Record(m_oPageBuilder, m_lPageNum >= m_lNumberPages - 1);
|
||||
m_arXmlString.push_back(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(m_oPageBuilder.GetBuffer(), (LONG)m_oPageBuilder.GetCurSize()));
|
||||
|
||||
if (m_oPageBuilder.GetCurSize() > 100000000/*100Mb*/)
|
||||
m_oPageBuilder.Clear();
|
||||
m_oCurrentPage.Record(*pWriter, m_lPageNum >= m_lNumberPages - 1);
|
||||
m_mapXmlString[m_lPageNum] = pWriter;
|
||||
}
|
||||
else
|
||||
m_oCurrentPage.EndCommand(lType);
|
||||
@ -870,9 +867,9 @@ namespace NSDocxRenderer
|
||||
mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14\">\
|
||||
<w:body>");
|
||||
|
||||
for (std::list<std::string>::const_iterator i = m_arXmlString.cbegin(); i != m_arXmlString.cend(); ++i)
|
||||
for (size_t i = 0; i < m_mapXmlString.size(); ++i)
|
||||
{
|
||||
oDocumentStream.WriteFile((const BYTE*)i->c_str(), (LONG)i->length());
|
||||
oDocumentStream.WriteStringUTF8(m_mapXmlString[i]->GetData());
|
||||
}
|
||||
|
||||
oDocumentStream.WriteStringUTF8(L"</w:body></w:document>");
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
#include "managers/ImageManager.h"
|
||||
#include "managers/FontStyleManager.h"
|
||||
#include "managers/ParagraphStyleManager.h"
|
||||
#include <list>
|
||||
|
||||
|
||||
namespace NSDocxRenderer
|
||||
@ -41,8 +40,7 @@ namespace NSDocxRenderer
|
||||
|
||||
bool m_bIsDisablePageCommand {false}; // disable commands inside draw function
|
||||
|
||||
NSStringUtils::CStringBuilder m_oPageBuilder;
|
||||
std::list<std::string> m_arXmlString;
|
||||
std::map<LONG, NSStringUtils::CStringBuilder*> m_mapXmlString;
|
||||
|
||||
public:
|
||||
CDocument(IRenderer* pRenderer, NSFonts::IApplicationFonts* pFonts);
|
||||
|
||||
@ -36,14 +36,6 @@ bool CHWPFile::OpenHWPX(const std::wstring& wsFilePath)
|
||||
return m_pInternal->Open(wsFilePath, HWP::EHanType::HWPX);
|
||||
}
|
||||
|
||||
bool CHWPFile::OpenHWPML(const std::wstring &wsFilePath)
|
||||
{
|
||||
if (nullptr == m_pInternal)
|
||||
return false;
|
||||
|
||||
return m_pInternal->Open(wsFilePath, HWP::EHanType::HWPML);
|
||||
}
|
||||
|
||||
void CHWPFile::Close()
|
||||
{
|
||||
if (nullptr != m_pInternal)
|
||||
@ -78,8 +70,3 @@ bool CHWPFile::IsHWPXFormat(const std::wstring& wsFilePath)
|
||||
{
|
||||
return HWP::EHanType::HWPX == HWP::CWriterContext::DetectHancom(wsFilePath);
|
||||
}
|
||||
|
||||
bool CHWPFile::IsHWPMLFormat(const std::wstring &wsFilePath)
|
||||
{
|
||||
return HWP::EHanType::HWPML == HWP::CWriterContext::DetectHancom(wsFilePath);
|
||||
}
|
||||
|
||||
@ -24,14 +24,12 @@ public:
|
||||
|
||||
bool OpenHWP(const std::wstring& wsFilePath);
|
||||
bool OpenHWPX(const std::wstring& wsFilePath);
|
||||
bool OpenHWPML(const std::wstring& wsFilePath);
|
||||
void Close();
|
||||
bool ConvertToOOXML(const std::wstring& wsFilePath);
|
||||
bool ConvertToOOXML_Dir(const std::wstring& wsDirectoryPath);
|
||||
|
||||
static bool IsHWPFormat(const std::wstring& wsFilePath);
|
||||
static bool IsHWPXFormat(const std::wstring& wsFilePath);
|
||||
static bool IsHWPMLFormat(const std::wstring& wsFilePath);
|
||||
};
|
||||
|
||||
#endif // HWPFILE_H
|
||||
|
||||
@ -49,7 +49,6 @@ SOURCES += \
|
||||
HwpDoc/HWPElements/HWPRecordStyle.cpp \
|
||||
HwpDoc/HWPElements/HwpRecordTabDef.cpp \
|
||||
HwpDoc/HWPFile.cpp \
|
||||
HwpDoc/HWPMLFile.cpp \
|
||||
HwpDoc/HWPSection.cpp \
|
||||
HwpDoc/HWPStream.cpp \
|
||||
HwpDoc/HWPXFile.cpp \
|
||||
@ -100,7 +99,6 @@ SOURCES += \
|
||||
HEADERS += \
|
||||
HWPFile.h \
|
||||
HwpDoc/Common/Common.h \
|
||||
HwpDoc/Common/NodeNames.h \
|
||||
HwpDoc/Common/WriterContext.h \
|
||||
HwpDoc/Common/XMLReader.h \
|
||||
HwpDoc/Conversion/ConversionState.h \
|
||||
@ -131,10 +129,10 @@ HEADERS += \
|
||||
HwpDoc/HWPElements/HWPRecordParaText.h \
|
||||
HwpDoc/HWPElements/HWPRecordStyle.h \
|
||||
HwpDoc/HWPElements/HWPTag.h \
|
||||
HwpDoc/HWPElements/HWPType.h \
|
||||
HwpDoc/HWPElements/HwpRecordTabDef.h \
|
||||
HwpDoc/HWPElements/HwpRecordTypes.h \
|
||||
HwpDoc/HWPFile.h \
|
||||
HwpDoc/HWPMLFile.h \
|
||||
HwpDoc/HWPSection.h \
|
||||
HwpDoc/HWPStream.h \
|
||||
HwpDoc/HWPXFile.h \
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
@ -27,19 +26,25 @@ typedef char HWP_BYTE;
|
||||
#define DEFAULT(value) case value: default: return value
|
||||
|
||||
#define MAKE_STR(value) #value
|
||||
#define STR(value) MAKE_STR(#value)
|
||||
#define MAKE_WSTR(value) L##value
|
||||
#define WSTR(value) MAKE_WSTR(#value)
|
||||
|
||||
#define IF_STRING_IN_ENUM(checked_value, value, enum_type)\
|
||||
if (WSTR(checked_value) == value)\
|
||||
return enum_type::checked_value
|
||||
#define ELSE_IF_STRING_IN_ENUM(checked_value, value, enum_type)\
|
||||
else if (WSTR(checked_value) == value)\
|
||||
return enum_type::checked_value
|
||||
#define ELSE_STRING_IN_ENUM(checked_value, enum_type)\
|
||||
else\
|
||||
return enum_type::checked_value
|
||||
|
||||
#define RETURN_VECTOR_CONST_PTR(type, array_values) \
|
||||
std::vector<const type*> arTempVector(array_values.size()); \
|
||||
for (unsigned int unIndex = 0; unIndex < array_values.size(); ++unIndex) \
|
||||
arTempVector[unIndex] = dynamic_cast<const type*>(array_values[unIndex]); \
|
||||
return arTempVector
|
||||
|
||||
#define TO_LOWER(value) std::transform(value.begin(), value.end(), value.begin(), tolower)
|
||||
#define TO_UPPER(value) std::transform(value.begin(), value.end(), value.begin(), toupper)
|
||||
|
||||
class IRef
|
||||
{
|
||||
unsigned long m_ulRef;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -13,45 +13,28 @@ CWriterContext::CWriterContext()
|
||||
|
||||
CWriterContext::~CWriterContext()
|
||||
{
|
||||
Clear();
|
||||
if (nullptr != m_pHWPFile)
|
||||
delete m_pHWPFile;
|
||||
|
||||
if (nullptr != m_pHWPXFile)
|
||||
delete m_pHWPXFile;
|
||||
}
|
||||
|
||||
void CWriterContext::Clear()
|
||||
{
|
||||
switch (m_eType)
|
||||
{
|
||||
case EHanType::HWP:
|
||||
{
|
||||
if (nullptr == m_pHWPFile)
|
||||
return;
|
||||
|
||||
delete m_pHWPFile;
|
||||
m_pHWPFile = nullptr;
|
||||
break;
|
||||
}
|
||||
case EHanType::HWPX:
|
||||
{
|
||||
if (nullptr == m_pHWPXFile)
|
||||
return;
|
||||
|
||||
delete m_pHWPXFile;
|
||||
m_pHWPXFile = nullptr;
|
||||
break;
|
||||
}
|
||||
case EHanType::HWPML:
|
||||
{
|
||||
if(nullptr == m_pHWPMLFile)
|
||||
return;
|
||||
|
||||
delete m_pHWPMLFile;
|
||||
m_pHWPMLFile = nullptr;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_eType = EHanType::NONE;
|
||||
|
||||
if (nullptr != m_pHWPFile)
|
||||
{
|
||||
delete m_pHWPFile;
|
||||
m_pHWPFile = nullptr;
|
||||
}
|
||||
|
||||
if (nullptr != m_pHWPXFile)
|
||||
{
|
||||
delete m_pHWPXFile;
|
||||
m_pHWPXFile = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
EHanType CWriterContext::GetType()
|
||||
@ -78,13 +61,6 @@ VECTOR<const CHWPSection*> CWriterContext::GetSections()
|
||||
|
||||
break;
|
||||
}
|
||||
case EHanType::HWPML:
|
||||
{
|
||||
if (nullptr != m_pHWPMLFile)
|
||||
return m_pHWPMLFile->GetSections();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return VECTOR<const CHWPSection*>();
|
||||
@ -94,35 +70,36 @@ EHanType CWriterContext::DetectHancom(const HWP_STRING& sPathToFile)
|
||||
{
|
||||
bool bDetected = false;
|
||||
|
||||
#define DETECT(hwp_class)\
|
||||
{\
|
||||
hwp_class* pTemp = new hwp_class(sPathToFile);\
|
||||
if (nullptr != pTemp)\
|
||||
{\
|
||||
if (pTemp->Detect())\
|
||||
{\
|
||||
bDetected = true;\
|
||||
pTemp->Close();\
|
||||
}\
|
||||
delete pTemp;\
|
||||
}\
|
||||
}
|
||||
CHWPFile* pHwpTemp = new CHWPFile(sPathToFile);
|
||||
if (nullptr != pHwpTemp)
|
||||
{
|
||||
if (pHwpTemp->Detect())
|
||||
{
|
||||
bDetected = true;
|
||||
pHwpTemp->Close();
|
||||
}
|
||||
|
||||
DETECT(CHWPFile)
|
||||
delete pHwpTemp;
|
||||
}
|
||||
|
||||
if (bDetected)
|
||||
return EHanType::HWP;
|
||||
|
||||
DETECT(CHWPXFile)
|
||||
CHWPXFile* pHwpxTemp = new CHWPXFile(sPathToFile);
|
||||
if (nullptr != pHwpxTemp)
|
||||
{
|
||||
if (pHwpxTemp->Detect())
|
||||
{
|
||||
bDetected = true;
|
||||
pHwpxTemp->Close();
|
||||
}
|
||||
|
||||
delete pHwpxTemp;
|
||||
}
|
||||
|
||||
if (bDetected)
|
||||
return EHanType::HWPX;
|
||||
|
||||
DETECT(CHWPMLFile)
|
||||
|
||||
if(bDetected)
|
||||
return EHanType::HWPML;
|
||||
|
||||
return EHanType::NONE;
|
||||
}
|
||||
|
||||
@ -131,11 +108,19 @@ bool CWriterContext::Detect()
|
||||
switch(m_eType)
|
||||
{
|
||||
case EHanType::HWP:
|
||||
return (nullptr != m_pHWPFile) ? m_pHWPFile->Detect() : false;
|
||||
{
|
||||
if (nullptr == m_pHWPFile)
|
||||
return false;
|
||||
|
||||
return m_pHWPFile->Detect();
|
||||
}
|
||||
case EHanType::HWPX:
|
||||
return (nullptr != m_pHWPXFile) ? m_pHWPXFile->Detect() : false;
|
||||
case EHanType::HWPML:
|
||||
return (nullptr != m_pHWPMLFile) ? m_pHWPMLFile->Detect() : false;
|
||||
{
|
||||
if (nullptr == m_pHWPXFile)
|
||||
return false;
|
||||
|
||||
return m_pHWPXFile->Detect();
|
||||
}
|
||||
case EHanType::NONE:
|
||||
return false;
|
||||
}
|
||||
@ -147,25 +132,25 @@ bool CWriterContext::Open(const HWP_STRING& sPathToFile, EHanType eHanType)
|
||||
|
||||
m_eType = eHanType;
|
||||
|
||||
#define OPEN(variable_name, class_name)\
|
||||
variable_name = new class_name(sPathToFile);\
|
||||
if (nullptr == variable_name)\
|
||||
return false;\
|
||||
return variable_name->Open()
|
||||
|
||||
switch (m_eType)
|
||||
{
|
||||
case EHanType::HWP:
|
||||
{
|
||||
OPEN(m_pHWPFile, CHWPFile);
|
||||
m_pHWPFile = new CHWPFile(sPathToFile);
|
||||
|
||||
if (nullptr == m_pHWPFile)
|
||||
return false;
|
||||
|
||||
return m_pHWPFile->Open();
|
||||
}
|
||||
case EHanType::HWPX:
|
||||
{
|
||||
OPEN(m_pHWPXFile, CHWPXFile);
|
||||
}
|
||||
case EHanType::HWPML:
|
||||
{
|
||||
OPEN(m_pHWPMLFile, CHWPMLFile);
|
||||
m_pHWPXFile = new CHWPXFile(sPathToFile);
|
||||
|
||||
if (nullptr == m_pHWPXFile)
|
||||
return false;
|
||||
|
||||
return m_pHWPXFile->Open();
|
||||
}
|
||||
case EHanType::NONE:
|
||||
break;
|
||||
@ -176,24 +161,19 @@ bool CWriterContext::Open(const HWP_STRING& sPathToFile, EHanType eHanType)
|
||||
|
||||
void CWriterContext::Close()
|
||||
{
|
||||
#define CLOSE(variable_name)\
|
||||
if (nullptr != variable_name)\
|
||||
variable_name->Close();\
|
||||
break
|
||||
|
||||
switch (m_eType)
|
||||
{
|
||||
case EHanType::HWP:
|
||||
{
|
||||
CLOSE(m_pHWPFile);
|
||||
if (nullptr != m_pHWPFile)
|
||||
m_pHWPFile->Close();
|
||||
break;
|
||||
}
|
||||
case EHanType::HWPX:
|
||||
{
|
||||
CLOSE(m_pHWPXFile);
|
||||
}
|
||||
case EHanType::HWPML:
|
||||
{
|
||||
CLOSE(m_pHWPMLFile);
|
||||
if (nullptr != m_pHWPXFile)
|
||||
m_pHWPXFile->Close();
|
||||
break;
|
||||
}
|
||||
case EHanType::NONE:
|
||||
break;
|
||||
@ -218,14 +198,7 @@ const CHWPDocInfo* CWriterContext::GetDocInfo()
|
||||
|
||||
return m_pHWPXFile->GetDocInfo();
|
||||
}
|
||||
case EHanType::HWPML:
|
||||
{
|
||||
if (nullptr == m_pHWPMLFile)
|
||||
return nullptr;
|
||||
|
||||
return m_pHWPMLFile->GetDocInfo();
|
||||
}
|
||||
default:
|
||||
case EHanType::NONE:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -336,11 +309,6 @@ bool CWriterContext::GetBinBytes(const HWP_STRING& sId, CHWPStream& oBuffer, HWP
|
||||
sFileName = NSFile::GetFileName(pBinData->GetPath());
|
||||
return m_pHWPXFile->GetChildStream(pBinData->GetPath(), oBuffer);
|
||||
}
|
||||
case EHanType::HWPML:
|
||||
{
|
||||
sFileName = pBinData->GetItemID() + L'.' + pBinData->GetFormat();
|
||||
return m_pHWPMLFile->GetBinData(pBinData->GetItemID(), oBuffer);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
#include "../HanType.h"
|
||||
#include "../HWPFile.h"
|
||||
#include "../HWPXFile.h"
|
||||
#include "../HWPMLFile.h"
|
||||
|
||||
#include "../HWPElements/HWPRecordParaShape.h"
|
||||
#include "../HWPElements/HWPRecordStyle.h"
|
||||
@ -17,10 +16,9 @@ namespace HWP
|
||||
{
|
||||
class CWriterContext
|
||||
{
|
||||
EHanType m_eType;
|
||||
CHWPFile* m_pHWPFile;
|
||||
CHWPXFile* m_pHWPXFile;
|
||||
CHWPMLFile* m_pHWPMLFile;
|
||||
EHanType m_eType;
|
||||
CHWPFile* m_pHWPFile;
|
||||
CHWPXFile* m_pHWPXFile;
|
||||
public:
|
||||
CWriterContext();
|
||||
~CWriterContext();
|
||||
|
||||
@ -31,47 +31,12 @@ bool CXMLReader::IsEmptyNode()
|
||||
|
||||
bool CXMLReader::GetBool()
|
||||
{
|
||||
return "1" == GetTextAValue(*this) || "true" == GetTextAValue(*this);
|
||||
}
|
||||
|
||||
int StringToInt(const std::string& sValue, const int& _default)
|
||||
{
|
||||
std::string::const_iterator itPos{sValue.cbegin()};
|
||||
|
||||
while (std::isspace(*itPos))
|
||||
++itPos;
|
||||
|
||||
if (sValue.cend() == itPos)
|
||||
return _default;
|
||||
|
||||
while (sValue.cend() != itPos && !std::isdigit(*itPos))
|
||||
++itPos;
|
||||
|
||||
if (sValue.cend() == itPos)
|
||||
return _default;
|
||||
|
||||
int nResult = 0;
|
||||
|
||||
while (itPos != sValue.cend() && std::isdigit(*itPos))
|
||||
{
|
||||
nResult = nResult * 10 + (*itPos - '0');
|
||||
++itPos;
|
||||
}
|
||||
|
||||
return ((nResult & 0xFF) << 16) | (((nResult >> 8) & 0xFF) << 8) | ((nResult >> 16) & 0xFF);
|
||||
return "1" == GetTextAValue(*this);
|
||||
}
|
||||
|
||||
int CXMLReader::GetColor(const int& nDefault)
|
||||
{
|
||||
const std::string sValue{GetTextAValue(*this)};
|
||||
|
||||
if (sValue.empty())
|
||||
return nDefault;
|
||||
|
||||
if ('#' == sValue[0])
|
||||
return ConvertHexToInt(sValue, nDefault);
|
||||
|
||||
return StringToInt(sValue, nDefault);
|
||||
return ConvertHexToInt(GetTextAValue(*this), nDefault);
|
||||
}
|
||||
|
||||
int CXMLReader::GetInt()
|
||||
@ -335,24 +300,24 @@ int ConvertWidthToHWP(const std::string& sValue)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ConvertHexToInt(const std::string& sValue, const int& _default)
|
||||
int ConvertHexToInt(const std::string& wsValue, const int& _default)
|
||||
{
|
||||
if (sValue.empty() || "none" == sValue)
|
||||
if (wsValue.empty() || "none" == wsValue)
|
||||
return _default;
|
||||
|
||||
std::string::const_iterator itStart = sValue.cbegin();
|
||||
std::string::const_iterator itStart = wsValue.cbegin();
|
||||
|
||||
if ('#' == *itStart)
|
||||
++itStart;
|
||||
|
||||
if (sValue.cend() - itStart != 6)
|
||||
if (wsValue.cend() - itStart < 6)
|
||||
return _default;
|
||||
|
||||
itStart = sValue.cend() - 6;
|
||||
itStart = wsValue.cend() - 6;
|
||||
|
||||
int nResult = 0;
|
||||
|
||||
while (itStart != sValue.cend())
|
||||
while (itStart != wsValue.cend())
|
||||
{
|
||||
if ('0' <= *itStart && *itStart <= '9')
|
||||
nResult = (nResult << 4) | (*itStart++ - '0');
|
||||
|
||||
@ -15,8 +15,6 @@
|
||||
#include "../Paragraph/CtrlShapeArc.h"
|
||||
#include "../Paragraph/CtrlShapePolygon.h"
|
||||
#include "../Paragraph/CtrlShapeCurve.h"
|
||||
#include "../Paragraph/CtrlShapeLine.h"
|
||||
#include "../Paragraph/CtrlShapeRect.h"
|
||||
|
||||
#include "../HWPElements/HWPRecordParaShape.h"
|
||||
#include "../HWPElements/HWPRecordCharShape.h"
|
||||
@ -334,7 +332,7 @@ void CConverter2OOXML::WriteCharacter(const CCtrlCharacter* pCharacter, short sh
|
||||
}
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WriteShape(const CCtrlGeneralShape* pShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CCtrlContainer *pContainer)
|
||||
void CConverter2OOXML::WriteShape(const CCtrlGeneralShape* pShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
{
|
||||
if (nullptr == pShape || oState.m_bInTextBox)
|
||||
return;
|
||||
@ -348,7 +346,7 @@ void CConverter2OOXML::WriteShape(const CCtrlGeneralShape* pShape, short shParaS
|
||||
case EShapeType::Polygon:
|
||||
case EShapeType::Curve:
|
||||
{
|
||||
WriteGeometryShape(pShape, shParaShapeID, shParaStyleID, oBuilder, oState, pContainer);
|
||||
WriteGeometryShape(pShape, shParaShapeID, shParaStyleID, oBuilder, oState);
|
||||
break;
|
||||
}
|
||||
case EShapeType::Pic:
|
||||
@ -598,8 +596,7 @@ void CConverter2OOXML::WriteParagraph(const CHWPPargraph* pParagraph, NSStringUt
|
||||
}
|
||||
case ECtrlObjectType::HeadFoot:
|
||||
{
|
||||
if (EHanType::HWPX == m_pContext->GetType() ||
|
||||
EHanType::HWPML == m_pContext->GetType())
|
||||
if (EHanType::HWPX == m_pContext->GetType())
|
||||
oState.m_arCtrlsHeadFoot.push_back((const CCtrlHeadFoot*)pCtrl);
|
||||
break;
|
||||
}
|
||||
@ -1004,7 +1001,7 @@ VECTOR<TPoint> ArcToBezier(const TPoint& oStart, const TPoint& oEnd, const TPoin
|
||||
return {oStart, oControl1, oControl2, oEnd};
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CCtrlContainer* pContainer)
|
||||
void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
{
|
||||
if (nullptr == pGeneralShape)
|
||||
return;
|
||||
@ -1020,8 +1017,8 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape
|
||||
|
||||
OpenParagraph(shParaShapeID, shParaStyleID, oBuilder, oState);
|
||||
|
||||
const int nWidth = Transform::HWPUINT2OOXML(pGeneralShape->GetFinalWidth());
|
||||
const int nHeight = Transform::HWPUINT2OOXML(pGeneralShape->GetFinalHeight());
|
||||
const int nWidth = Transform::HWPUINT2OOXML(pGeneralShape->GetWidth());
|
||||
const int nHeight = Transform::HWPUINT2OOXML(pGeneralShape->GetHeight());
|
||||
|
||||
const std::wstring wsWidth = std::to_wstring(nWidth);
|
||||
const std::wstring wsHeight = std::to_wstring(nHeight);
|
||||
@ -1029,7 +1026,7 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape
|
||||
oBuilder.WriteString(L"<w:r><w:rPr><w:noProof/></w:rPr>");
|
||||
oBuilder.WriteString(L"<mc:AlternateContent><mc:Choice Requires=\"wps\">");
|
||||
|
||||
OpenDrawingNode((nullptr != pContainer) ? pContainer : pGeneralShape, oBuilder);
|
||||
OpenDrawingNode(pGeneralShape, oBuilder);
|
||||
|
||||
oBuilder.WriteString(L"<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">");
|
||||
oBuilder.WriteString(L"<a:graphicData uri=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\">");
|
||||
@ -1043,20 +1040,9 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape
|
||||
case EShapeObjectType::Arc:
|
||||
{
|
||||
const CCtrlShapeArc *pShapeArc = (const CCtrlShapeArc*)pGeneralShape;
|
||||
|
||||
TPoint oStartPoint {pShapeArc->GetFirstPoint()},
|
||||
oEndPoint {pShapeArc->GetSecondPoint()},
|
||||
oCenterPoint{pShapeArc->GetCenterPoint()};
|
||||
|
||||
const TMatrix oMatrix{pGeneralShape->GetFinalMatrix()};
|
||||
|
||||
oMatrix.ApplyToPoint(oStartPoint .m_nX, oStartPoint .m_nY);
|
||||
oMatrix.ApplyToPoint(oEndPoint .m_nX, oEndPoint .m_nY);
|
||||
oMatrix.ApplyToPoint(oCenterPoint.m_nX, oCenterPoint.m_nY);
|
||||
|
||||
VECTOR<TPoint> arBezierPoints{ArcToBezier({Transform::HWPUINT2OOXML(oStartPoint .m_nX), Transform::HWPUINT2OOXML(oStartPoint .m_nY)},
|
||||
{Transform::HWPUINT2OOXML(oEndPoint .m_nX), Transform::HWPUINT2OOXML(oEndPoint .m_nY)},
|
||||
{Transform::HWPUINT2OOXML(oCenterPoint.m_nX), Transform::HWPUINT2OOXML(oCenterPoint.m_nY)})};
|
||||
VECTOR<TPoint> arBezierPoints{ArcToBezier({Transform::HWPUINT2OOXML(pShapeArc->GetFirstPoint() .m_nX), Transform::HWPUINT2OOXML(pShapeArc->GetFirstPoint() .m_nY)},
|
||||
{Transform::HWPUINT2OOXML(pShapeArc->GetSecondPoint().m_nX), Transform::HWPUINT2OOXML(pShapeArc->GetSecondPoint().m_nY)},
|
||||
{Transform::HWPUINT2OOXML(pShapeArc->GetCenterPoint().m_nX), Transform::HWPUINT2OOXML(pShapeArc->GetCenterPoint().m_nY)})};
|
||||
|
||||
oBuilder.WriteString(L"<a:custGeom><a:pathLst><a:path>");
|
||||
oBuilder.WriteString(L"<a:moveTo><a:pt x=\"" + std::to_wstring(arBezierPoints[0].m_nX) + L"\" y=\"" + std::to_wstring(arBezierPoints[0].m_nY) + L"\"/></a:moveTo>");
|
||||
@ -1078,55 +1064,13 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape
|
||||
}
|
||||
case EShapeObjectType::Line:
|
||||
{
|
||||
const CCtrlShapeLine *pShapeLine = (const CCtrlShapeLine*)pGeneralShape;
|
||||
|
||||
TPoint oStartPoint{pShapeLine->GetStartX(), pShapeLine->GetStartY()},
|
||||
oEndPoint {pShapeLine->GetEndX(), pShapeLine->GetEndY() };
|
||||
|
||||
const TMatrix oMatrix{pGeneralShape->GetFinalMatrix()};
|
||||
|
||||
oMatrix.ApplyToPoint(oStartPoint .m_nX, oStartPoint .m_nY);
|
||||
oMatrix.ApplyToPoint(oEndPoint .m_nX, oEndPoint .m_nY);
|
||||
|
||||
oBuilder.WriteString(L"<a:custGeom><a:pathLst><a:path>");
|
||||
|
||||
oBuilder.WriteString(L"<a:moveTo><a:pt x=\"" + std::to_wstring(Transform::HWPUINT2OOXML(oStartPoint.m_nX)) + L"\" y=\"" + std::to_wstring(Transform::HWPUINT2OOXML(oStartPoint.m_nY)) + L"\"/></a:moveTo>");
|
||||
oBuilder.WriteString(L"<a:lnTo><a:pt x=\"" + std::to_wstring(Transform::HWPUINT2OOXML(oEndPoint.m_nX)) + L"\" y=\"" + std::to_wstring(Transform::HWPUINT2OOXML(oEndPoint.m_nY)) + L"\"/></a:lnTo>");
|
||||
|
||||
oBuilder.WriteString(L"</a:path></a:pathLst></a:custGeom>");
|
||||
// oBuilder.WriteString(L"<a:prstGeom prst=\"line\"><a:avLst/></a:prstGeom>");
|
||||
oBuilder.WriteString(L"<a:prstGeom prst=\"line\"><a:avLst/></a:prstGeom>");
|
||||
break;
|
||||
}
|
||||
|
||||
case EShapeObjectType::Rectangle:
|
||||
{
|
||||
const CCtrlShapeRect* pShapeRect = (const CCtrlShapeRect*)pGeneralShape;
|
||||
|
||||
TPoint arPoints[4];
|
||||
|
||||
pShapeRect->GetPoints(arPoints);
|
||||
|
||||
const TMatrix oMatrix{pGeneralShape->GetFinalMatrix()};
|
||||
|
||||
for (TPoint& oPoint : arPoints)
|
||||
{
|
||||
oMatrix.ApplyToPoint(oPoint.m_nX, oPoint.m_nY);
|
||||
|
||||
oPoint.m_nX = Transform::HWPUINT2OOXML(oPoint.m_nX);
|
||||
oPoint.m_nY = Transform::HWPUINT2OOXML(oPoint.m_nY);
|
||||
}
|
||||
|
||||
oBuilder.WriteString(L"<a:custGeom><a:pathLst><a:path>");
|
||||
|
||||
oBuilder.WriteString(L"<a:moveTo><a:pt x=\"" + std::to_wstring(arPoints[0].m_nX) + L"\" y=\"" + std::to_wstring(arPoints[0].m_nY) + L"\"/></a:moveTo>");
|
||||
|
||||
for (unsigned short ushIndex = 1; ushIndex < 4; ++ushIndex)
|
||||
oBuilder.WriteString(L"<a:lnTo><a:pt x=\"" + std::to_wstring(arPoints[ushIndex].m_nX) + L"\" y=\"" + std::to_wstring(arPoints[ushIndex].m_nY) + L"\"/></a:lnTo>");
|
||||
|
||||
oBuilder.WriteString(L"<a:lnTo><a:pt x=\"" + std::to_wstring(arPoints[0].m_nX) + L"\" y=\"" + std::to_wstring(arPoints[0].m_nY) + L"\"/></a:lnTo>");
|
||||
|
||||
oBuilder.WriteString(L"</a:path></a:pathLst></a:custGeom>");
|
||||
// oBuilder.WriteString(L"<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>");
|
||||
oBuilder.WriteString(L"<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>");
|
||||
break;
|
||||
}
|
||||
case EShapeObjectType::Polygon:
|
||||
@ -1136,21 +1080,11 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape
|
||||
if (2 > arPoints.size())
|
||||
break;
|
||||
|
||||
const TMatrix oMatrix{pGeneralShape->GetFinalMatrix()};
|
||||
|
||||
for (TPoint& oPoint : arPoints)
|
||||
{
|
||||
oMatrix.ApplyToPoint(oPoint.m_nX, oPoint.m_nY);
|
||||
|
||||
oPoint.m_nX = Transform::HWPUINT2OOXML(oPoint.m_nX);
|
||||
oPoint.m_nY = Transform::HWPUINT2OOXML(oPoint.m_nY);
|
||||
}
|
||||
|
||||
oBuilder.WriteString(L"<a:custGeom><a:pathLst><a:path>");
|
||||
oBuilder.WriteString(L"<a:moveTo><a:pt x=\"" + std::to_wstring(arPoints[0].m_nX) + L"\" y=\"" + std::to_wstring(arPoints[0].m_nY) + L"\"/></a:moveTo>");
|
||||
oBuilder.WriteString(L"<a:moveTo><a:pt x=\"" + std::to_wstring(Transform::HWPUINT2OOXML(arPoints[0].m_nX)) + L"\" y=\"" + std::to_wstring(Transform::HWPUINT2OOXML(arPoints[0].m_nY)) + L"\"/></a:moveTo>");
|
||||
|
||||
for (unsigned short ushIndex = 1; ushIndex < arPoints.size(); ++ushIndex)
|
||||
oBuilder.WriteString(L"<a:lnTo><a:pt x=\"" + std::to_wstring(arPoints[ushIndex].m_nX) + L"\" y=\"" + std::to_wstring(arPoints[ushIndex].m_nY) + L"\"/></a:lnTo>");
|
||||
oBuilder.WriteString(L"<a:lnTo><a:pt x=\"" + std::to_wstring(Transform::HWPUINT2OOXML(arPoints[ushIndex].m_nX)) + L"\" y=\"" + std::to_wstring(Transform::HWPUINT2OOXML(arPoints[ushIndex].m_nY)) + L"\"/></a:lnTo>");
|
||||
|
||||
oBuilder.WriteString(L"</a:path></a:pathLst></a:custGeom>");
|
||||
break;
|
||||
@ -1162,34 +1096,23 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape
|
||||
if (2 > arPoints.size())
|
||||
break;
|
||||
|
||||
const TMatrix oMatrix{pGeneralShape->GetFinalMatrix()};
|
||||
|
||||
for (TPoint& oPoint : arPoints)
|
||||
{
|
||||
oPoint.m_nX = Transform::HWPUINT2OOXML(oPoint.m_nX);
|
||||
oPoint.m_nY = Transform::HWPUINT2OOXML(oPoint.m_nY);
|
||||
|
||||
oMatrix.ApplyToPoint(oPoint.m_nX, oPoint.m_nY);
|
||||
}
|
||||
|
||||
VECTOR<HWP_BYTE> arSegmentType{((const CCtrlShapeCurve*)pGeneralShape)->GetSegmentsType()};
|
||||
oBuilder.WriteString(L"<a:custGeom><a:pathLst><a:path>");
|
||||
|
||||
oBuilder.WriteString(L"<a:moveTo><a:pt x=\"" + std::to_wstring(arPoints[0].m_nX) + L"\" y=\"" + std::to_wstring(arPoints[0].m_nY) + L"\"/></a:moveTo>");
|
||||
oBuilder.WriteString(L"<a:moveTo><a:pt x=\"" + std::to_wstring(Transform::HWPUINT2OOXML(arPoints[0].m_nX)) + L"\" y=\"" + std::to_wstring(Transform::HWPUINT2OOXML(arPoints[0].m_nY)) + L"\"/></a:moveTo>");
|
||||
|
||||
for (unsigned short ushIndex = 0; ushIndex < arSegmentType.size(); ++ushIndex)
|
||||
{
|
||||
if (0x01 == arSegmentType[ushIndex])
|
||||
{
|
||||
oBuilder.WriteString(L"<a:cubicBezTo>");
|
||||
oBuilder.WriteString(L"<a:pt x=\"" + std::to_wstring(arPoints[ushIndex + 1].m_nX) + L"\" y=\"" + std::to_wstring(arPoints[ushIndex + 1].m_nY) + L"\"/>");
|
||||
oBuilder.WriteString(L"<a:pt x=\"" + std::to_wstring(arPoints[ushIndex + 2].m_nX) + L"\" y=\"" + std::to_wstring(arPoints[ushIndex + 2].m_nY) + L"\"/>");
|
||||
oBuilder.WriteString(L"<a:pt x=\"" + std::to_wstring(arPoints[ushIndex + 3].m_nX) + L"\" y=\"" + std::to_wstring(arPoints[ushIndex + 3].m_nY) + L"\"/>");
|
||||
oBuilder.WriteString(L"<a:pt x=\"" + std::to_wstring(Transform::HWPUINT2OOXML(arPoints[ushIndex + 1].m_nX)) + L"\" y=\"" + std::to_wstring(Transform::HWPUINT2OOXML(arPoints[ushIndex + 1].m_nY)) + L"\"/>");
|
||||
oBuilder.WriteString(L"<a:pt x=\"" + std::to_wstring(Transform::HWPUINT2OOXML(arPoints[ushIndex + 2].m_nX)) + L"\" y=\"" + std::to_wstring(Transform::HWPUINT2OOXML(arPoints[ushIndex + 2].m_nY)) + L"\"/>");
|
||||
oBuilder.WriteString(L"<a:pt x=\"" + std::to_wstring(Transform::HWPUINT2OOXML(arPoints[ushIndex + 3].m_nX)) + L"\" y=\"" + std::to_wstring(Transform::HWPUINT2OOXML(arPoints[ushIndex + 3].m_nY)) + L"\"/>");
|
||||
oBuilder.WriteString(L"</a:cubicBezTo>");
|
||||
ushIndex += 2;
|
||||
}
|
||||
else
|
||||
oBuilder.WriteString(L"<a:lnTo><a:pt x=\"" + std::to_wstring(arPoints[ushIndex + 1].m_nX) + L"\" y=\"" + std::to_wstring(arPoints[ushIndex + 1].m_nY) + L"\"/></a:lnTo>");
|
||||
oBuilder.WriteString(L"<a:lnTo><a:pt x=\"" + std::to_wstring(Transform::HWPUINT2OOXML(arPoints[ushIndex + 1].m_nX)) + L"\" y=\"" + std::to_wstring(Transform::HWPUINT2OOXML(arPoints[ushIndex + 1].m_nY)) + L"\"/></a:lnTo>");
|
||||
}
|
||||
|
||||
oBuilder.WriteString(L"</a:path></a:pathLst></a:custGeom>");
|
||||
@ -1311,7 +1234,7 @@ void CConverter2OOXML::WriteOleShape(const CCtrlShapeOle* pOleShape, short shPar
|
||||
void CConverter2OOXML::WriteContainer(const CCtrlContainer* pContainer, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
{
|
||||
for (const CCtrlGeneralShape* pGeneralShape : pContainer->GetShapes())
|
||||
WriteShape(pGeneralShape, shParaShapeID, shParaStyleID, oBuilder, oState, pContainer);
|
||||
WriteShape(pGeneralShape, shParaShapeID, shParaStyleID, oBuilder, oState);
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WriteSectionSettings(TConversionState& oState)
|
||||
@ -1322,22 +1245,12 @@ void CConverter2OOXML::WriteSectionSettings(TConversionState& oState)
|
||||
{
|
||||
std::vector<const CCtrlHeadFoot*> arCtrlsHeadFoot;
|
||||
|
||||
switch (m_pContext->GetType())
|
||||
if (EHanType::HWP == m_pContext->GetType())
|
||||
arCtrlsHeadFoot = oState.m_pSectionDef->GetHeaderFooters();
|
||||
else if (EHanType::HWPX == m_pContext->GetType())
|
||||
{
|
||||
case EHanType::HWP:
|
||||
{
|
||||
arCtrlsHeadFoot = oState.m_pSectionDef->GetHeaderFooters();
|
||||
break;
|
||||
}
|
||||
case EHanType::HWPX:
|
||||
case EHanType::HWPML:
|
||||
{
|
||||
arCtrlsHeadFoot = oState.m_arCtrlsHeadFoot;
|
||||
oState.m_arCtrlsHeadFoot.clear();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
arCtrlsHeadFoot = oState.m_arCtrlsHeadFoot;
|
||||
oState.m_arCtrlsHeadFoot.clear();
|
||||
}
|
||||
|
||||
#define WRITE_ID(id)\
|
||||
@ -1419,7 +1332,9 @@ void CConverter2OOXML::WritePicture(const CCtrlShapePic* pCtrlPic, short shParaS
|
||||
|
||||
oBuilder.WriteString(L"<w:r><w:rPr><w:noProof/></w:rPr>");
|
||||
|
||||
OpenDrawingNode(pCtrlPic, oBuilder);
|
||||
int nWidth{pCtrlPic->GetImageRectWidth()}, nHeight{pCtrlPic->GetIMageRectHeight()};
|
||||
|
||||
OpenDrawingNode(pCtrlPic, oBuilder, &nWidth, &nHeight);
|
||||
|
||||
oBuilder.WriteString(L"<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">");
|
||||
oBuilder.WriteString(L"<a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">");
|
||||
@ -1435,7 +1350,7 @@ void CConverter2OOXML::WritePicture(const CCtrlShapePic* pCtrlPic, short shParaS
|
||||
if (pCtrlPic->VertFlip())
|
||||
oBuilder.WriteString(L" flipV=\"1\"");
|
||||
|
||||
oBuilder.WriteString(L"><a:off x=\"0\" y=\"0\"/><a:ext cx=\"" + std::to_wstring(pCtrlPic->GetFinalWidth()) + L"\" cy=\"" + std::to_wstring(pCtrlPic->GetFinalHeight()) + L"\"/></a:xfrm>");
|
||||
oBuilder.WriteString(L"><a:off x=\"0\" y=\"0\"/><a:ext cx=\"" + std::to_wstring(nWidth) + L"\" cy=\"" + std::to_wstring(nHeight) + L"\"/></a:xfrm>");
|
||||
oBuilder.WriteString(L"<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom><a:noFill/>");
|
||||
WriteBorderSettings(pCtrlPic, oBuilder);
|
||||
oBuilder.WriteString(L"</pic:spPr></pic:pic></a:graphicData></a:graphic>");
|
||||
@ -1527,7 +1442,7 @@ bool CConverter2OOXML::SaveSVGFile(const HWP_STRING& sSVG, HWP_STRING& sFileName
|
||||
|
||||
HWP_STRING CConverter2OOXML::SavePicture(const HWP_STRING& sBinItemId, TConversionState& oState)
|
||||
{
|
||||
if (nullptr == m_pContext || sBinItemId.empty())
|
||||
if (nullptr == m_pContext)
|
||||
return HWP_STRING();
|
||||
|
||||
//TODO:: добавить поддержку устновки размеров изображения из свойств шейпа
|
||||
@ -1613,7 +1528,7 @@ void CConverter2OOXML::WriteTextBorderStyle(short shBorderFillId, NSStringUtils:
|
||||
WriteBorder(pBorderFill->GetLeftBorder(), L"bdr", oBuilder);
|
||||
}
|
||||
|
||||
void CConverter2OOXML::OpenDrawingNode(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder)
|
||||
void CConverter2OOXML::OpenDrawingNode(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder, int* pWidth, int* pHeight)
|
||||
{
|
||||
if (nullptr == pCtrlShape)
|
||||
return;
|
||||
@ -1628,7 +1543,7 @@ void CConverter2OOXML::OpenDrawingNode(const CCtrlObjElement* pCtrlShape, NSStri
|
||||
L"\" distR=\"" + std::to_wstring(Transform::HWPUINT2OOXML(pCtrlShape->GetRightOutMargin() / 10)) +
|
||||
L"\">");
|
||||
|
||||
WriteShapeExtent(pCtrlShape, oBuilder);
|
||||
WriteShapeExtent(pCtrlShape, oBuilder, pWidth, pHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1641,7 +1556,7 @@ void CConverter2OOXML::OpenDrawingNode(const CCtrlObjElement* pCtrlShape, NSStri
|
||||
L"\" simplePos=\"0\" locked=\"0\" layoutInCell=\"1\" allowOverlap=\"1\">");
|
||||
|
||||
WriteShapePosition(pCtrlShape, oBuilder);
|
||||
WriteShapeExtent(pCtrlShape, oBuilder);
|
||||
WriteShapeExtent(pCtrlShape, oBuilder, pWidth, pHeight);
|
||||
WriteShapeWrapMode(pCtrlShape, oBuilder);
|
||||
}
|
||||
|
||||
@ -1656,7 +1571,10 @@ void CConverter2OOXML::CloseDrawingNode(const CCtrlObjElement* pCtrlShape, NSStr
|
||||
if (pCtrlShape->GetTreatAsChar())
|
||||
oBuilder.WriteString(L"</wp:inline>");
|
||||
else
|
||||
{
|
||||
oBuilder.WriteString(L"<wp14:sizeRelH relativeFrom=\"page\"><wp14:pctWidth>0</wp14:pctWidth></wp14:sizeRelH><wp14:sizeRelV relativeFrom=\"page\"><wp14:pctHeight>0</wp14:pctHeight></wp14:sizeRelV>");
|
||||
oBuilder.WriteString(L"</wp:anchor>");
|
||||
}
|
||||
|
||||
oBuilder.WriteString(L"</w:drawing>");
|
||||
}
|
||||
@ -1683,7 +1601,7 @@ HWP_STRING GetHRelativeFrom(EHRelTo eRelTo)
|
||||
case EHRelTo::COLUMN:
|
||||
return L"column";
|
||||
case EHRelTo::PARA:
|
||||
return L"margin";
|
||||
return L"character";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1705,20 +1623,43 @@ void CConverter2OOXML::WriteShapePosition(const CCtrlCommon* pCtrlShape, NSStrin
|
||||
|
||||
oBuilder.WriteString(L"<wp:simplePos x=\"0\" y=\"0\"/>");
|
||||
|
||||
const int nHorzOffset = pCtrlShape->GetHorzOffset();
|
||||
const int nVertOffset = pCtrlShape->GetVertOffset();
|
||||
oBuilder.WriteString(L"<wp:positionH relativeFrom=\"");
|
||||
|
||||
oBuilder.WriteString(L"<wp:positionH relativeFrom=\"" + GetHRelativeFrom(pCtrlShape->GetHorzRelTo()) + L"\"><wp:posOffset>" + std::to_wstring(Transform::HWPUINT2OOXML(nHorzOffset)) + L"</wp:posOffset></wp:positionH>");
|
||||
oBuilder.WriteString(L"<wp:positionV relativeFrom=\"" + GetVRelativeFrom(pCtrlShape->GetVertRelTo()) + L"\"><wp:posOffset>" + std::to_wstring(Transform::HWPUINT2OOXML(nVertOffset)) + L"</wp:posOffset></wp:positionV>");
|
||||
if (0 == pCtrlShape->GetHorzOffset())
|
||||
{
|
||||
oBuilder.WriteString(L"margin\">");
|
||||
oBuilder.WriteString(L"<wp:align>left</wp:align>");
|
||||
}
|
||||
else
|
||||
{
|
||||
oBuilder.WriteString(GetHRelativeFrom(pCtrlShape->GetHorzRelTo()) + L"\">");
|
||||
oBuilder.WriteString(L"<wp:posOffset>" + std::to_wstring(Transform::HWPUINT2OOXML(pCtrlShape->GetHorzOffset())) + L"</wp:posOffset>");
|
||||
}
|
||||
|
||||
oBuilder.WriteString(L"</wp:positionH>");
|
||||
|
||||
oBuilder.WriteString(L"<wp:positionV relativeFrom=\"" + GetVRelativeFrom(pCtrlShape->GetVertRelTo()) + L"\"><wp:posOffset>" + std::to_wstring(Transform::HWPUINT2OOXML(pCtrlShape->GetVertOffset())) + L"</wp:posOffset></wp:positionV>");
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WriteShapeExtent(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder)
|
||||
void CConverter2OOXML::WriteShapeExtent(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder, int* pWidth, int* pHeight)
|
||||
{
|
||||
if (nullptr == pCtrlShape)
|
||||
return;
|
||||
|
||||
const int nFinalWidth = std::abs(pCtrlShape->GetFinalWidth());
|
||||
const int nFinalHeight = std::abs(pCtrlShape->GetFinalHeight());
|
||||
int nFinalWidth = std::abs(pCtrlShape->GetWidth());
|
||||
int nFinalHeight = std::abs(pCtrlShape->GetHeight());
|
||||
|
||||
if (0 == nFinalWidth || 0 == nFinalHeight)
|
||||
{
|
||||
nFinalWidth = pCtrlShape->GetCurWidth();
|
||||
nFinalHeight = pCtrlShape->GetCurHeight();
|
||||
}
|
||||
|
||||
if (nullptr != pWidth)
|
||||
*pWidth = Transform::HWPUINT2OOXML(nFinalWidth);
|
||||
|
||||
if (nullptr != pHeight)
|
||||
*pHeight = Transform::HWPUINT2OOXML(nFinalHeight);
|
||||
|
||||
oBuilder.WriteString(L"<wp:extent cx=\"" + std::to_wstring(Transform::HWPUINT2OOXML(nFinalWidth)) + L"\" cy=\"" + std::to_wstring(Transform::HWPUINT2OOXML(nFinalHeight)) + L"\"/>");
|
||||
oBuilder.WriteString(L"<wp:effectExtent l=\"0\" t=\"0\" r=\"0\" b=\"0\"/>");
|
||||
@ -1954,63 +1895,25 @@ void CConverter2OOXML::WriteLineSettings(const CCtrlGeneralShape* pCtrlGeneralSh
|
||||
if (nullptr == pCtrlGeneralShape)
|
||||
return;
|
||||
|
||||
WriteLineSettings({pCtrlGeneralShape->GetLineStyle(), pCtrlGeneralShape->GetLineColor(),
|
||||
pCtrlGeneralShape->GetLineThick(), 1,
|
||||
pCtrlGeneralShape->GetLineHeadStyle(), pCtrlGeneralShape->GetLineHeadSize(),
|
||||
pCtrlGeneralShape->GetLineTailStyle(), pCtrlGeneralShape->GetLineTailSize()}, oBuilder);
|
||||
|
||||
WriteLineSettings(pCtrlGeneralShape->GetLineStyle(), pCtrlGeneralShape->GetLineColor(), pCtrlGeneralShape->GetLineThick(), 1, oBuilder);
|
||||
}
|
||||
|
||||
void WriteLineArrowStyles(ELineArrowStyle eArrowStyle, ELineArrowSize eArrowSize, NSStringUtils::CStringBuilder& oBuilder)
|
||||
void CConverter2OOXML::WriteLineSettings(ELineStyle2 eLineStyle, int nColor, int nThick, HWP_BYTE nCompoundLineType, NSStringUtils::CStringBuilder& oBuilder)
|
||||
{
|
||||
switch (eArrowStyle)
|
||||
{
|
||||
case ELineArrowStyle::ARROW: oBuilder.WriteString(L" type=\"triangle\""); break;
|
||||
case ELineArrowStyle::SPEAR: oBuilder.WriteString(L" type=\"arrow\""); break;
|
||||
case ELineArrowStyle::CONCAVE_ARROW: oBuilder.WriteString(L" type=\"stealth\""); break;
|
||||
case ELineArrowStyle::DIAMOND:
|
||||
case ELineArrowStyle::EMPTY_DIAMOND:
|
||||
case ELineArrowStyle::BOX:
|
||||
case ELineArrowStyle::EMPTY_BOX: oBuilder.WriteString(L" type=\"diamond\""); break;
|
||||
case ELineArrowStyle::CIRCLE:
|
||||
case ELineArrowStyle::EMPTY_CIRCLE: oBuilder.WriteString(L" type=\"oval\""); break;
|
||||
case ELineArrowStyle::NORMAL:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (eArrowSize)
|
||||
{
|
||||
case ELineArrowSize::SMALL_SMALL: oBuilder.WriteString(L" w=\"sm\" len=\"sm\""); break;
|
||||
case ELineArrowSize::SMALL_MEDIUM: oBuilder.WriteString(L" w=\"sm\" len=\"med\""); break;
|
||||
case ELineArrowSize::SMALL_LARGE: oBuilder.WriteString(L" w=\"sm\" len=\"lg\""); break;
|
||||
case ELineArrowSize::MEDIUM_SMALL: oBuilder.WriteString(L" w=\"med\" len=\"sm\""); break;
|
||||
case ELineArrowSize::MEDIUM_MEDIUM: oBuilder.WriteString(L" w=\"med\" len=\"med\""); break;
|
||||
case ELineArrowSize::MEDIUM_LARGE: oBuilder.WriteString(L" w=\"med\" len=\"lg\""); break;
|
||||
case ELineArrowSize::LARGE_SMALL: oBuilder.WriteString(L" w=\"lg\" len=\"sm\""); break;
|
||||
case ELineArrowSize::LARGE_MEDIUM: oBuilder.WriteString(L" w=\"lg\" len=\"med\""); break;
|
||||
case ELineArrowSize::LARGE_LARGE: oBuilder.WriteString(L" w=\"lg\" len=\"lg\""); break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WriteLineSettings(const TLineData& oLineData, NSStringUtils::CStringBuilder& oBuilder)
|
||||
{
|
||||
if (ELineStyle2::NONE == oLineData.m_eStyle)
|
||||
if (ELineStyle2::NONE == eLineStyle)
|
||||
{
|
||||
oBuilder.WriteString(L"<a:ln><a:noFill/></a:ln>");
|
||||
return;
|
||||
}
|
||||
|
||||
int nThick{oLineData.m_nThick};
|
||||
|
||||
if (0 == oLineData.m_nThick)
|
||||
if (0 == nThick)
|
||||
nThick = 100;
|
||||
|
||||
oBuilder.WriteString(L"<a:ln");
|
||||
|
||||
oBuilder.WriteString(L" w=\"" + std::to_wstring(Transform::HWPUINT2OOXML(nThick)) + L"\" cap=\"sq\"");
|
||||
|
||||
switch (oLineData.m_eStyle)
|
||||
switch (eLineStyle)
|
||||
{
|
||||
case ELineStyle2::DOUBLE_SLIM:
|
||||
{
|
||||
@ -2038,9 +1941,9 @@ void CConverter2OOXML::WriteLineSettings(const TLineData& oLineData, NSStringUti
|
||||
|
||||
oBuilder.WriteString(L">");
|
||||
|
||||
oBuilder.WriteString(L"<a:solidFill><a:srgbClr val=\"" + Transform::IntColorToHEX(oLineData.m_nColor) + L"\"/></a:solidFill>");
|
||||
oBuilder.WriteString(L"<a:solidFill><a:srgbClr val=\"" + Transform::IntColorToHEX(nColor) + L"\"/></a:solidFill>");
|
||||
|
||||
switch (oLineData.m_eStyle)
|
||||
switch (eLineStyle)
|
||||
{
|
||||
case ELineStyle2::DASH:
|
||||
{
|
||||
@ -2076,21 +1979,7 @@ void CConverter2OOXML::WriteLineSettings(const TLineData& oLineData, NSStringUti
|
||||
break;
|
||||
}
|
||||
|
||||
if (ELineArrowStyle::NORMAL != oLineData.m_eHeadStyle)
|
||||
{
|
||||
oBuilder.WriteString(L"<a:headEnd");
|
||||
WriteLineArrowStyles(oLineData.m_eHeadStyle, oLineData.m_eHeadSize, oBuilder);
|
||||
oBuilder.WriteString(L"/>");
|
||||
}
|
||||
|
||||
if (ELineArrowStyle::NORMAL != oLineData.m_eTailStyle)
|
||||
{
|
||||
oBuilder.WriteString(L"<a:tailEnd ");
|
||||
WriteLineArrowStyles(oLineData.m_eTailStyle, oLineData.m_eTailSize, oBuilder);
|
||||
oBuilder.WriteString(L"/>");
|
||||
}
|
||||
|
||||
switch (oLineData.m_nCompoundLineType)
|
||||
switch (nCompoundLineType)
|
||||
{
|
||||
case 0x00:
|
||||
{
|
||||
@ -2113,13 +2002,9 @@ void CConverter2OOXML::WriteBorderSettings(const CCtrlShapePic* pCtrlPic, NSStri
|
||||
return;
|
||||
|
||||
if (EHanType::HWP == m_pContext->GetType())
|
||||
WriteLineSettings({pCtrlPic->GetBorderLineStyle(), pCtrlPic->GetBorderColor(),
|
||||
pCtrlPic->GetBorderThick(), pCtrlPic->GetBorderCompoundLineType()},
|
||||
oBuilder);
|
||||
else if (EHanType::HWPX == m_pContext->GetType() ||
|
||||
EHanType::HWPML == m_pContext->GetType())
|
||||
WriteLineSettings({pCtrlPic->GetLineStyle(), pCtrlPic->GetLineColor(),
|
||||
pCtrlPic->GetLineThick(), 1}, oBuilder);
|
||||
WriteLineSettings(pCtrlPic->GetBorderLineStyle(), pCtrlPic->GetBorderColor(), pCtrlPic->GetBorderThick(), pCtrlPic->GetBorderCompoundLineType(), oBuilder);
|
||||
else if (EHanType::HWPX == m_pContext->GetType())
|
||||
WriteLineSettings(pCtrlPic->GetLineStyle(), pCtrlPic->GetLineColor(), pCtrlPic->GetLineThick(), 1, oBuilder);
|
||||
}
|
||||
|
||||
void CConverter2OOXML::WriteAutoNumber(const CCtrlAutoNumber* pAutoNumber, short shParaShapeID, short shParaStyleID, short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
|
||||
@ -2296,23 +2181,4 @@ HWP_STRING CConverter2OOXML::GetTempDirectory() const
|
||||
{
|
||||
return m_sTempDirectory;
|
||||
}
|
||||
|
||||
TLineData::TLineData(ELineStyle2 eStyle, int nColor,
|
||||
int nThick, HWP_BYTE nCompoundLineType,
|
||||
ELineArrowStyle eHeadStyle, ELineArrowSize eHeadSize,
|
||||
ELineArrowStyle eTailStyle, ELineArrowSize eTailSize)
|
||||
:m_eStyle(eStyle), m_nColor(nColor),
|
||||
m_nThick(nThick), m_nCompoundLineType(nCompoundLineType),
|
||||
m_eHeadStyle(eHeadStyle), m_eHeadSize(eHeadSize),
|
||||
m_eTailStyle(eTailStyle), m_eTailSize(eTailSize)
|
||||
{}
|
||||
|
||||
TLineData::TLineData(ELineStyle2 eStyle, int nColor,
|
||||
int nThick, HWP_BYTE nCompoundLineType)
|
||||
:m_eStyle(eStyle), m_nColor(nColor),
|
||||
m_nThick(nThick), m_nCompoundLineType(nCompoundLineType),
|
||||
m_eHeadStyle(ELineArrowStyle::NORMAL), m_eHeadSize(ELineArrowSize::SMALL_SMALL),
|
||||
m_eTailStyle(ELineArrowStyle::NORMAL), m_eTailSize(ELineArrowSize::SMALL_SMALL)
|
||||
{}
|
||||
|
||||
}
|
||||
|
||||
@ -30,27 +30,6 @@ struct TContentType
|
||||
HWP_STRING m_wsType;
|
||||
};
|
||||
|
||||
struct TLineData
|
||||
{
|
||||
ELineStyle2 m_eStyle;
|
||||
int m_nColor;
|
||||
int m_nThick;
|
||||
HWP_BYTE m_nCompoundLineType;
|
||||
|
||||
ELineArrowStyle m_eHeadStyle;
|
||||
ELineArrowSize m_eHeadSize;
|
||||
ELineArrowStyle m_eTailStyle;
|
||||
ELineArrowSize m_eTailSize;
|
||||
|
||||
TLineData(ELineStyle2 eStyle, int nColor,
|
||||
int nThick, HWP_BYTE nCompoundLineType,
|
||||
ELineArrowStyle eHeadStyle, ELineArrowSize eHeadSize,
|
||||
ELineArrowStyle eTailStyle, ELineArrowSize eTailSize);
|
||||
|
||||
TLineData(ELineStyle2 eStyle, int nColor,
|
||||
int nThick, HWP_BYTE nCompoundLineType);
|
||||
};
|
||||
|
||||
enum class ECellCreator
|
||||
{
|
||||
FILE,
|
||||
@ -99,7 +78,7 @@ class CConverter2OOXML
|
||||
void WriteCellProperties(short shBorderFillID, NSStringUtils::CStringBuilder& oBuilder);
|
||||
void WriteBorder(const TBorder& oBorder, const HWP_STRING& sBorderName, NSStringUtils::CStringBuilder& oBuilder);
|
||||
|
||||
void WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CCtrlContainer *pContainer = nullptr);
|
||||
void WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteEqEditShape(const CCtrlEqEdit* pEqEditShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteOleShape(const CCtrlShapeOle* pOleShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
|
||||
@ -115,11 +94,11 @@ class CConverter2OOXML
|
||||
void WriteRunnerStyle(short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CRunnerStyle& sExternStyles = CRunnerStyle());
|
||||
void WriteTextBorderStyle(short shBorderFillId, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
|
||||
void OpenDrawingNode(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder);
|
||||
void OpenDrawingNode(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder, int* pWidth = nullptr, int *pHeight = nullptr);
|
||||
void CloseDrawingNode(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder);
|
||||
|
||||
void WriteShapePosition(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder);
|
||||
void WriteShapeExtent(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder);
|
||||
void WriteShapeExtent(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder, int* pWidth = nullptr, int *pHeight = nullptr);
|
||||
void WriteShapeWrapMode(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder);
|
||||
void WriteShapeProperty(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder);
|
||||
|
||||
@ -129,12 +108,12 @@ class CConverter2OOXML
|
||||
void WriteText(const CParaText* pParaText, const VECTOR<TRangeTag>& arRangeTags, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteText(const HWP_STRING& wsText, short shParaShapeID, short shParaStyleID, short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CRunnerStyle& oExternalStyle = CRunnerStyle());
|
||||
void WriteLineSettings(const CCtrlGeneralShape* pCtrlGeneralShape, NSStringUtils::CStringBuilder& oBuilder);
|
||||
void WriteLineSettings(const TLineData& oLineData, NSStringUtils::CStringBuilder& oBuilder);
|
||||
void WriteLineSettings(ELineStyle2 eLineStyle, int nColor, int nThick, HWP_BYTE nCompoundLineType, NSStringUtils::CStringBuilder& oBuilder);
|
||||
void WriteBorderSettings(const CCtrlShapePic* pCtrlPic, NSStringUtils::CStringBuilder& oBuilder);
|
||||
|
||||
void WriteAutoNumber(const CCtrlAutoNumber* pAutoNumber, short shParaShapeID, short shParaStyleID, short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteCharacter(const CCtrlCharacter* pCharacter, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
void WriteShape(const CCtrlGeneralShape* pShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CCtrlContainer* pContainer = nullptr);
|
||||
void WriteShape(const CCtrlGeneralShape* pShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
|
||||
void WriteNote(const CCtrlNote* pNote, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||
|
||||
|
||||
@ -24,9 +24,11 @@ namespace Transform
|
||||
|
||||
inline std::wstring IntColorToHEX(int nColor)
|
||||
{
|
||||
wchar_t buffer[7];
|
||||
std::swprintf(buffer, sizeof(buffer) / sizeof(wchar_t), L"%06X", nColor & 0xFFFFFF);
|
||||
return std::wstring(buffer);
|
||||
std::wstringstream oSStream;
|
||||
|
||||
oSStream << std::uppercase << std::hex << std::setw(6) << std::setfill(L'0') << nColor;
|
||||
|
||||
return oSStream.str();
|
||||
}
|
||||
|
||||
inline short LineWidth2Pt(short shHWPThick)
|
||||
|
||||
@ -47,7 +47,7 @@ namespace HWP
|
||||
|
||||
swprintf(arTemp, tempLen, L"%02X%02X%02X", m_uchRed, m_uchGreen, m_uchBlue);
|
||||
|
||||
return std::wstring(arTemp);
|
||||
return std::wstring(arTemp, 6);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -12,8 +12,6 @@
|
||||
#include "HWPElements/HWPRecordStyle.h"
|
||||
#include "HWPElements/HwpRecordTabDef.h"
|
||||
|
||||
#include "Common/NodeNames.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
ECompatDoc GetCompatDoc(int nValue)
|
||||
@ -40,10 +38,6 @@ CHWPDocInfo::CHWPDocInfo(CHWPFile* pHWPFile)
|
||||
: m_eHanType(EHanType::HWP), m_pParentHWP(pHWPFile), m_eCompatibleDoc(ECompatDoc::HWP)
|
||||
{}
|
||||
|
||||
CHWPDocInfo::CHWPDocInfo(CHWPMLFile* pHWPMLFile)
|
||||
: m_eHanType(EHanType::HWPML), m_pParentHWPML(pHWPMLFile), m_eCompatibleDoc(ECompatDoc::UNKNOWN)
|
||||
{}
|
||||
|
||||
CHWPDocInfo::~CHWPDocInfo()
|
||||
{
|
||||
#define REMOVE_LIST_DATA(array) \
|
||||
@ -188,40 +182,72 @@ bool CHWPDocInfo::Parse(CHWPStream& oBuffer, int nVersion)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHWPDocInfo::ParseHWPX(CXMLReader& oReader)
|
||||
bool CHWPDocInfo::Parse(CXMLReader& oReader, int nVersion)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if ("hh:beginNum" == sNodeName)
|
||||
m_arRecords.push_back(new CHWPRecordDocumentProperties(*this, oReader));
|
||||
m_arRecords.push_back(new CHWPRecordDocumentProperties(*this, oReader, nVersion));
|
||||
else if ("hh:refList" == sNodeName)
|
||||
ReadRefList(oReader);
|
||||
ReadRefList(oReader, nVersion);
|
||||
}
|
||||
END_WHILE
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHWPDocInfo::ParseHWPML(CXMLReader &oReader)
|
||||
bool CHWPDocInfo::ReadRefList(CXMLReader& oReader, int nVersion)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if ("MAPPINGTABLE" == sNodeName)
|
||||
if ("hh:fontfaces" == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_AND_NAME(oReader, Mapping)
|
||||
{
|
||||
if ("BINDATALIST" == sNodeMappingName)
|
||||
{
|
||||
CHWPRecordBinData *pRecordBinData = nullptr;
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, BinData, "BINITEM")
|
||||
pRecordBinData = new CHWPRecordBinData(oReader, EHanType::HWPML);
|
||||
m_mBinDatas.insert(std::make_pair<HWP_STRING, CHWPRecord*>(pRecordBinData->GetItemID(), (HWP::CHWPRecord*)pRecordBinData));
|
||||
END_WHILE
|
||||
}
|
||||
else
|
||||
ReadRefListElement(oReader, EHanType::HWPML);
|
||||
}
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, FontFace, "hh:fontface")
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Font, "hh:font")
|
||||
m_arFaseNames.push_back(new CHWPRecordFaceName(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
END_WHILE
|
||||
}
|
||||
else if ("hh:borderFills" == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, BorderFill, "hh:borderFill")
|
||||
m_arBorderFills.push_back(new CHWPRecordBorderFill(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
else if ("hh:charProperties" == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, CharPr, "hh:charPr")
|
||||
m_arCharShapes.push_back(new CHWPRecordCharShape(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
else if ("hh:tabProperties" == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, TabPr, "hh:tabPr")
|
||||
m_arTabDefs.push_back(new CHwpRecordTabDef(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
else if ("hh:numberings" == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Numbering, "hh:numbering")
|
||||
m_arNumberings.push_back(new CHWPRecordNumbering(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
else if ("hh:bullets" == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH(oReader, Bullet)
|
||||
m_arBullets.push_back(new CHWPRecordBullet(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
else if ("hh:paraProperties" == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, ParaPr, "hh:paraPr")
|
||||
m_arParaShapes.push_back(new CHWPRecordParaShape(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
else if ("hh:styles" == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Style, "hh:style")
|
||||
m_arStyles.push_back(new CHWPRecordStyle(*this, oReader, nVersion));
|
||||
END_WHILE
|
||||
}
|
||||
}
|
||||
@ -230,74 +256,7 @@ bool CHWPDocInfo::ParseHWPML(CXMLReader &oReader)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHWPDocInfo::ReadRefList(CXMLReader& oReader)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE(oReader)
|
||||
ReadRefListElement(oReader, EHanType::HWPX);
|
||||
END_WHILE
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHWPDocInfo::ReadRefListElement(CXMLReader &oReader, HWP::EHanType eType)
|
||||
{
|
||||
const std::string sNodeName{oReader.GetName()};
|
||||
|
||||
if (GetNodeName(ENode::FaceNameList, eType) == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, FontFace, GetNodeName(ENode::FontFace, eType))
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Font, GetNodeName(ENode::Font, eType))
|
||||
m_arFaseNames.push_back(new CHWPRecordFaceName(*this, oReader, eType));
|
||||
END_WHILE
|
||||
END_WHILE
|
||||
}
|
||||
else if (GetNodeName(ENode::BorderFillList, eType) == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, BorderFill, GetNodeName(ENode::BorderFill, eType))
|
||||
m_arBorderFills.push_back(new CHWPRecordBorderFill(*this, oReader, eType));
|
||||
END_WHILE
|
||||
}
|
||||
else if (GetNodeName(ENode::CharShapeList, eType) == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, CharPr, GetNodeName(ENode::CharShape, eType))
|
||||
m_arCharShapes.push_back(new CHWPRecordCharShape(*this, oReader, eType));
|
||||
END_WHILE
|
||||
}
|
||||
else if (GetNodeName(ENode::TabDefList, eType) == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, TabPr, GetNodeName(ENode::TabDef, eType))
|
||||
m_arTabDefs.push_back(new CHwpRecordTabDef(*this, oReader, eType));
|
||||
END_WHILE
|
||||
}
|
||||
else if (GetNodeName(ENode::NumberingList, eType) == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Numbering, GetNodeName(ENode::Numbering, eType))
|
||||
m_arNumberings.push_back(new CHWPRecordNumbering(*this, oReader, eType));
|
||||
END_WHILE
|
||||
}
|
||||
else if (GetNodeName(ENode::BulletList, eType) == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH(oReader, Bullet)
|
||||
m_arBullets.push_back(new CHWPRecordBullet(*this, oReader, eType));
|
||||
END_WHILE
|
||||
}
|
||||
else if (GetNodeName(ENode::ParaShapeList, eType) == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, ParaPr, GetNodeName(ENode::ParaShape, eType))
|
||||
m_arParaShapes.push_back(new CHWPRecordParaShape(*this, oReader, eType));
|
||||
END_WHILE
|
||||
}
|
||||
else if (GetNodeName(ENode::StyleList, eType) == sNodeName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Style, GetNodeName(ENode::Style, eType))
|
||||
m_arStyles.push_back(new CHWPRecordStyle(*this, oReader, eType));
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHWPDocInfo::ReadContentHpf(CXMLReader& oReader)
|
||||
bool CHWPDocInfo::ReadContentHpf(CXMLReader& oReader, int nVersion)
|
||||
{
|
||||
CHWPRecordBinData *pRecordBinData = nullptr;
|
||||
|
||||
@ -305,7 +264,7 @@ bool CHWPDocInfo::ReadContentHpf(CXMLReader& oReader)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Item, "opf:item")
|
||||
{
|
||||
pRecordBinData = new CHWPRecordBinData(oReader, EHanType::HWPX);
|
||||
pRecordBinData = new CHWPRecordBinData(oReader, nVersion);
|
||||
m_mBinDatas.insert(std::make_pair<HWP_STRING, CHWPRecord*>(pRecordBinData->GetItemID(), (HWP::CHWPRecord*)pRecordBinData));
|
||||
}
|
||||
END_WHILE
|
||||
@ -376,7 +335,6 @@ const CHWPRecord* CHWPDocInfo::GetBinData(const HWP_STRING& sID) const
|
||||
{
|
||||
case EHanType::HWP:
|
||||
case EHanType::HWPX:
|
||||
case EHanType::HWPML:
|
||||
{
|
||||
std::map<HWP_STRING, CHWPRecord*>::const_iterator itFound = m_mBinDatas.find(sID);
|
||||
|
||||
|
||||
@ -20,13 +20,11 @@ enum class ECompatDoc
|
||||
|
||||
class CHWPFile;
|
||||
class CHWPXFile;
|
||||
class CHWPMLFile;
|
||||
class CHWPDocInfo
|
||||
{
|
||||
EHanType m_eHanType;
|
||||
CHWPXFile *m_pParentHWPX;
|
||||
CHWPFile *m_pParentHWP;
|
||||
CHWPMLFile *m_pParentHWPML;
|
||||
EHanType m_eHanType;
|
||||
CHWPXFile *m_pParentHWPX;
|
||||
CHWPFile *m_pParentHWP;
|
||||
VECTOR<CHWPRecord*> m_arRecords;
|
||||
|
||||
std::map<HWP_STRING, CHWPRecord*> m_mBinDatas;
|
||||
@ -44,14 +42,12 @@ public:
|
||||
CHWPDocInfo(EHanType eHanType);
|
||||
CHWPDocInfo(CHWPXFile* pHWPXFile);
|
||||
CHWPDocInfo(CHWPFile* pHWPFile);
|
||||
CHWPDocInfo(CHWPMLFile* pHWPMLFile);
|
||||
|
||||
~CHWPDocInfo();
|
||||
|
||||
bool Parse(CHWPStream& oBuffer, int nVersion);
|
||||
bool ParseHWPX(CXMLReader& oReader);
|
||||
bool ParseHWPML(CXMLReader& oReader);
|
||||
bool ReadContentHpf(CXMLReader& oReader);
|
||||
bool Parse(CXMLReader& oReader, int nVersion);
|
||||
bool ReadContentHpf(CXMLReader& oReader, int nVersion);
|
||||
|
||||
const CHWPRecord* GetRecord(int nIndex) const;
|
||||
const CHWPRecord* GetFaceName(int nIndex) const;
|
||||
@ -69,8 +65,7 @@ public:
|
||||
EHanType GetHanType() const;
|
||||
ECompatDoc GetCompatibleDoc() const;
|
||||
private:
|
||||
bool ReadRefList(CXMLReader& oReader);
|
||||
bool ReadRefListElement(CXMLReader& oReader, EHanType eType);
|
||||
bool ReadRefList(CXMLReader& oReader, int nVersion);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#include "HWPRecordBinData.h"
|
||||
|
||||
#include "../HWPFile.h"
|
||||
#include "../Common/NodeNames.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <regex>
|
||||
@ -29,6 +28,7 @@ EType GetType(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EState GetState(int nValue)
|
||||
{
|
||||
SWITCH(EState, nValue)
|
||||
@ -74,40 +74,23 @@ CHWPRecordBinData::CHWPRecordBinData(CHWPDocInfo& oDocInfo, int nTagNum, int nLe
|
||||
oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos(true));
|
||||
}
|
||||
|
||||
CHWPRecordBinData::CHWPRecordBinData(CXMLReader& oReader, EHanType eType)
|
||||
CHWPRecordBinData::CHWPRecordBinData(CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_BIN_DATA, 0, 0)
|
||||
{
|
||||
std::string sType;
|
||||
HWP_STRING sSubPath;
|
||||
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::BinData, eType) == sAttributeName)
|
||||
if ("id" == sAttributeName)
|
||||
m_sItemID = oReader.GetText();
|
||||
else if (EHanType::HWPX == eType && "isEmbeded" == sAttributeName)
|
||||
{
|
||||
const std::string sType = oReader.GetTextA();
|
||||
|
||||
if ("0" == sType)
|
||||
m_eType = EType::LINK;
|
||||
else if ("1" == sType)
|
||||
m_eType = EType::EMBEDDING;
|
||||
}
|
||||
else if (EHanType::HWPML == eType && "Type" == sAttributeName)
|
||||
{
|
||||
const std::string sType = oReader.GetTextA();
|
||||
|
||||
if ("Link" == sType)
|
||||
m_eType = EType::LINK;
|
||||
else if ("Embedding" == sType)
|
||||
m_eType = EType::EMBEDDING;
|
||||
else if ("Storage" == sType)
|
||||
m_eType = EType::STORAGE;
|
||||
}
|
||||
else if (GetAttributeName(EAttribute::Href, eType) == sAttributeName)
|
||||
else if ("isEmbeded" == sAttributeName)
|
||||
sType = oReader.GetTextA();
|
||||
else if ("href" == sAttributeName)
|
||||
m_sAPath = oReader.GetText();
|
||||
else if (GetAttributeName(EAttribute::SubPath, eType) == sAttributeName)
|
||||
else if ("sub-path" == sAttributeName)
|
||||
sSubPath = oReader.GetText();
|
||||
else if (GetAttributeName(EAttribute::MediaType, eType) == sAttributeName)
|
||||
else if ("media-type" == sAttributeName)
|
||||
{
|
||||
m_sFormat = oReader.GetText();
|
||||
|
||||
@ -117,10 +100,15 @@ CHWPRecordBinData::CHWPRecordBinData(CXMLReader& oReader, EHanType eType)
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
if (EType::LINK != m_eType || sSubPath.empty())
|
||||
return;
|
||||
if ("0" == sType)
|
||||
{
|
||||
m_eType = EType::LINK;
|
||||
|
||||
m_sAPath = sSubPath;
|
||||
if (!sSubPath.empty())
|
||||
m_sAPath = sSubPath;
|
||||
}
|
||||
else if ("1" == sType)
|
||||
m_eType = EType::EMBEDDING;
|
||||
}
|
||||
|
||||
HWP_STRING CHWPRecordBinData::GetPath() const
|
||||
|
||||
@ -44,7 +44,7 @@ class CHWPRecordBinData : public CHWPRecord
|
||||
HWP_STRING m_sItemID;
|
||||
public:
|
||||
CHWPRecordBinData(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordBinData(CXMLReader& oReader, EHanType eType);
|
||||
CHWPRecordBinData(CXMLReader& oReader, int nVersion);
|
||||
|
||||
HWP_STRING GetPath() const;
|
||||
HWP_STRING GetItemID() const;
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
#include "HWPRecordBorderFill.h"
|
||||
|
||||
#include "../Common/NodeNames.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
EImageFillType GetImageFillType(int nType)
|
||||
@ -60,15 +58,15 @@ EColorFillPattern GetColorFillPattern(int nPattern)
|
||||
}
|
||||
}
|
||||
|
||||
void TBorder::Read(CXMLReader& oReader, EHanType eType)
|
||||
void TBorder::Read(CXMLReader& oReader)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::Type, eType) == sAttributeName)
|
||||
m_eStyle = GetLineStyle2(oReader.GetTextA(), eType);
|
||||
else if (GetAttributeName(EAttribute::Color, eType) == sAttributeName)
|
||||
if ("type" == sAttributeName)
|
||||
m_eStyle = GetLineStyle2(oReader.GetText());
|
||||
else if ("color" == sAttributeName)
|
||||
m_nColor = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::Width, eType) == sAttributeName)
|
||||
else if ("width" == sAttributeName)
|
||||
m_chWidth = (HWP_BYTE)ConvertWidthToHWP(oReader.GetTextA());
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
@ -156,112 +154,112 @@ CFill::CFill(CHWPStream& oBuffer, int nOff, int nSize)
|
||||
m_nSize = oBuffer.GetDistanceToLastPos(true);
|
||||
}
|
||||
|
||||
CFill::CFill(CXMLReader& oReader, EHanType eType)
|
||||
CFill::CFill(CXMLReader& oReader)
|
||||
: m_nFillType(0), m_eHatchStyle(EColorFillPattern::NONE), m_eMode(EImageFillType::NONE), m_chAlpha(0xff)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if (GetNodeName(ENode::WindowBrush, eType) == sNodeName)
|
||||
if ("hc:winBrush" == sNodeName)
|
||||
{
|
||||
ReadWinBrush(oReader, eType);
|
||||
ReadWinBrush(oReader);
|
||||
m_nFillType |= 0x01;
|
||||
}
|
||||
else if (GetNodeName(ENode::Gradation, eType) == sNodeName)
|
||||
else if ("hc:gradation" == sNodeName)
|
||||
{
|
||||
ReadGradation(oReader, eType);
|
||||
ReadGradation(oReader);
|
||||
m_nFillType |= 0x04;
|
||||
}
|
||||
else if (GetNodeName(ENode::ImageBrush, eType) == sNodeName)
|
||||
else if ("hc:imgBrush" == sNodeName)
|
||||
{
|
||||
ReadImgBrush(oReader, eType);
|
||||
ReadImgBrush(oReader);
|
||||
m_nFillType |= 0x02;
|
||||
}
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
void CFill::ReadWinBrush(CXMLReader& oReader, EHanType eType)
|
||||
void CFill::ReadWinBrush(CXMLReader& oReader)
|
||||
{
|
||||
m_eHatchStyle = EColorFillPattern::NONE;
|
||||
m_chAlpha = 0xff;
|
||||
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::FaceColor, eType) == sAttributeName)
|
||||
if ("faceColor" == sAttributeName)
|
||||
m_nFaceColor = oReader.GetColor(0xFFFFFFFF);
|
||||
else if (GetAttributeName(EAttribute::HatchColor, eType) == sAttributeName)
|
||||
else if ("hatchColor" == sAttributeName)
|
||||
m_nHatchColor = oReader.GetColor();
|
||||
else if (GetAttributeName(EAttribute::HatchStyle, eType) == sAttributeName)
|
||||
else if ("hatchStyle" == sAttributeName)
|
||||
m_eHatchStyle = GetColorFillPattern(oReader.GetInt());
|
||||
else if (GetAttributeName(EAttribute::Alpha, eType) == sAttributeName)
|
||||
else if ("alpha" == sAttributeName)
|
||||
m_chAlpha = (HWP_BYTE)oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
|
||||
void CFill::ReadGradation(CXMLReader& oReader, EHanType eType)
|
||||
void CFill::ReadGradation(CXMLReader& oReader)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::Type, eType) == sAttributeName)
|
||||
if ("type" == sAttributeName)
|
||||
m_eGradType = ::HWP::GetGradFillType(oReader.GetInt());
|
||||
else if (GetAttributeName(EAttribute::Angle, eType) == sAttributeName)
|
||||
else if ("angle" == sAttributeName)
|
||||
m_nAngle = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::CenterX, eType) == sAttributeName)
|
||||
else if ("centerX" == sAttributeName)
|
||||
m_nCenterX = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::CenterY, eType) == sAttributeName)
|
||||
else if ("centerY" == sAttributeName)
|
||||
m_nCenterY = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::Step, eType) == sAttributeName)
|
||||
else if ("step" == sAttributeName)
|
||||
m_nStep = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::ColorNum, eType) == sAttributeName)
|
||||
else if ("colorNum" == sAttributeName)
|
||||
m_nColorNum = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::StepCenter, eType) == sAttributeName)
|
||||
else if ("stepCenter" == sAttributeName)
|
||||
m_chStepCenter = (HWP_BYTE)oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::Alpha, eType) == sAttributeName)
|
||||
else if ("alpha" == sAttributeName)
|
||||
m_chAlpha = (HWP_BYTE)oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, GetNodeName(ENode::Color, eType))
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hc:color")
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::Value, eType) != sAttributeName)
|
||||
if ("value" != oReader.GetName())
|
||||
continue;
|
||||
|
||||
m_arColors.push_back(oReader.GetColor());
|
||||
m_arColors.push_back(oReader.GetColor(true));
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
void CFill::ReadImgBrush(CXMLReader& oReader, EHanType eType)
|
||||
void CFill::ReadImgBrush(CXMLReader& oReader)
|
||||
{
|
||||
m_eMode = GetImageFillType(oReader.GetAttributeInt(GetAttributeName(EAttribute::Mode, eType)));
|
||||
m_eMode = GetImageFillType(oReader.GetAttributeInt("mode"));
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, GetNodeName(ENode::Image, eType))
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hc:img")
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::Bright, eType) == sAttributeName)
|
||||
if ("bright" == sAttributeName)
|
||||
m_chBright = (HWP_BYTE)oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::Contrast, eType) == sAttributeName)
|
||||
else if ("contrast" == sAttributeName)
|
||||
m_chContrast = (HWP_BYTE)oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::Effect, eType) == sAttributeName)
|
||||
else if ("effect" == sAttributeName)
|
||||
{
|
||||
const std::string sEffect{oReader.GetTextA()};
|
||||
|
||||
if (GetValueName(EValue::RealPic, eType))
|
||||
if ("REAL_PIC" == sEffect)
|
||||
m_chEffect = 0;
|
||||
else if (GetValueName(EValue::GrayScale, eType))
|
||||
else if ("GRAY_SCALE" == sEffect)
|
||||
m_chEffect = 1;
|
||||
else if (GetValueName(EValue::BlackWhite, eType))
|
||||
else if ("BLACK_WHITE" == sEffect)
|
||||
m_chEffect = 2;
|
||||
}
|
||||
else if (GetAttributeName(EAttribute::BinItem, eType))
|
||||
else if ("binaryItemIDRef" == sAttributeName)
|
||||
m_sBinItemID = oReader.GetText();
|
||||
else if (GetAttributeName(EAttribute::Alpha, eType) == sAttributeName)
|
||||
else if ("alpha" == sAttributeName)
|
||||
m_chAlpha = (HWP_BYTE)oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
@ -377,51 +375,39 @@ CHWPRecordBorderFill::CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, int nTagNum, i
|
||||
m_pFill = new CFill(oBuffer, 0, 0); // TODO:: перейти от использования off и size
|
||||
}
|
||||
|
||||
CHWPRecordBorderFill::CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType)
|
||||
CHWPRecordBorderFill::CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_BORDER_FILL, 0, 0), m_pFill(nullptr)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::ThreeD, eType) == sAttributeName)
|
||||
if ("threeD" == sAttributeName)
|
||||
m_bThreeD = oReader.GetBool();
|
||||
else if (GetAttributeName(EAttribute::Shadow, eType) == sAttributeName)
|
||||
else if ("shadow" == sAttributeName)
|
||||
m_bShadow = oReader.GetBool();
|
||||
else if (GetAttributeName(EAttribute::BreakCellSeparateLine, eType) == sAttributeName)
|
||||
else if ("breakCellSeparateLine" == sAttributeName)
|
||||
m_bBreakCellSeparateLine = oReader.GetBool();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if (GetNodeName(ENode::LeftBorder, eType) == sNodeName)
|
||||
m_oLeft.Read(oReader, eType);
|
||||
else if (GetNodeName(ENode::RightBorder, eType) == sNodeName)
|
||||
m_oRight.Read(oReader, eType);
|
||||
else if (GetNodeName(ENode::TopBorder, eType) == sNodeName)
|
||||
m_oTop.Read(oReader, eType);
|
||||
else if (GetNodeName(ENode::BottomBorder, eType) == sNodeName)
|
||||
m_oBottom.Read(oReader, eType);
|
||||
else if (GetNodeName(ENode::Diagonal, eType) == sNodeName)
|
||||
m_oDiagonal.Read(oReader, eType);
|
||||
else if (GetNodeName(ENode::FillBrush, eType) == sNodeName)
|
||||
m_pFill = new CFill(oReader, eType);
|
||||
else if (Equals(ENode::Slash, eType, sNodeName))
|
||||
if ("hh:slash" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::Type, eType) == sAttributeName)
|
||||
if ("type" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if (GetValueName(EValue::None, eType) == sType)
|
||||
|
||||
if ("NONE" == sType)
|
||||
m_chSlash = 0x0;
|
||||
else if (GetValueName(EValue::Center, eType) == sType)
|
||||
else if ("CENTER" == sType)
|
||||
m_chSlash = 0b010;
|
||||
else if (GetValueName(EValue::CenterBelow, eType) == sType)
|
||||
else if ("CENTER_BELOW" == sType)
|
||||
m_chSlash = 0b011;
|
||||
else if (GetValueName(EValue::CenterAbove, eType) == sType)
|
||||
else if ("CENTER_ABOVE" == sType)
|
||||
m_chSlash = 0b110;
|
||||
else if (GetValueName(EValue::All, eType) == sType)
|
||||
else if ("ALL" == sType)
|
||||
m_chSlash = 0b111;
|
||||
}
|
||||
else if ("Crooked" == sAttributeName)
|
||||
@ -431,23 +417,23 @@ CHWPRecordBorderFill::CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, CXMLReader& oR
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if (GetNodeName(ENode::BackSlash, eType) == sNodeName)
|
||||
else if ("hh:backSlash" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::Type, eType) == sAttributeName)
|
||||
if ("type" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if (GetValueName(EValue::None, eType) == sType)
|
||||
if ("NONE" == sType)
|
||||
m_chBackSlash = 0x0;
|
||||
else if (GetValueName(EValue::Center, eType) == sType)
|
||||
else if ("CENTER" == sType)
|
||||
m_chBackSlash = 0b010;
|
||||
else if (GetValueName(EValue::CenterBelow, eType) == sType)
|
||||
else if ("CENTER_BELOW" == sType)
|
||||
m_chBackSlash = 0b011;
|
||||
else if (GetValueName(EValue::CenterAbove, eType) == sType)
|
||||
else if ("CENTER_ABOVE" == sType)
|
||||
m_chBackSlash = 0b110;
|
||||
else if (GetValueName(EValue::All, eType) == sType)
|
||||
else if ("ALL" == sType)
|
||||
m_chBackSlash = 0b111;
|
||||
}
|
||||
else if ("Crooked" == sAttributeName)
|
||||
@ -457,6 +443,18 @@ CHWPRecordBorderFill::CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, CXMLReader& oR
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hh:leftBorder" == sNodeName)
|
||||
m_oLeft.Read(oReader);
|
||||
else if ("hh:rightBorder" == sNodeName)
|
||||
m_oRight.Read(oReader);
|
||||
else if ("hh:topBorder" == sNodeName)
|
||||
m_oTop.Read(oReader);
|
||||
else if ("hh:bottomBorder" == sNodeName)
|
||||
m_oBottom.Read(oReader);
|
||||
else if ("hh:diagonal" == sNodeName)
|
||||
m_oDiagonal.Read(oReader);
|
||||
else if ("hc:fillBrush" == sNodeName)
|
||||
m_pFill = new CFill(oReader);
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ struct TBorder
|
||||
HWP_BYTE m_chWidth;
|
||||
int m_nColor;
|
||||
|
||||
void Read(CXMLReader& oReader, EHanType eType);
|
||||
void Read(CXMLReader& oReader);
|
||||
};
|
||||
|
||||
enum class EImageFillType
|
||||
@ -86,13 +86,13 @@ class CFill : public IRef
|
||||
|
||||
HWP_BYTE m_chAlpha;
|
||||
|
||||
void ReadWinBrush(CXMLReader& oReader, EHanType eType);
|
||||
void ReadGradation(CXMLReader& oReader, EHanType eType);
|
||||
void ReadImgBrush(CXMLReader& oReader, EHanType eType);
|
||||
void ReadWinBrush(CXMLReader& oReader);
|
||||
void ReadGradation(CXMLReader& oReader);
|
||||
void ReadImgBrush(CXMLReader& oReader);
|
||||
public:
|
||||
CFill();
|
||||
CFill(CHWPStream& oBuffer, int nOff, int nSize);
|
||||
CFill(CXMLReader& oReader, EHanType eType);
|
||||
CFill(CXMLReader& oReader);
|
||||
|
||||
int GetSize() const;
|
||||
bool NoneFill() const;
|
||||
@ -136,7 +136,7 @@ class CHWPRecordBorderFill : public CHWPRecord
|
||||
public:
|
||||
CHWPRecordBorderFill(int nTagNum, int nLevel, int nSize);
|
||||
CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType);
|
||||
CHWPRecordBorderFill(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
~CHWPRecordBorderFill();
|
||||
|
||||
TBorder GetLeftBorder() const;
|
||||
|
||||
@ -45,12 +45,9 @@ CHWPRecordBullet::CHWPRecordBullet(CHWPDocInfo& oDocInfo, int nTagNum, int nLeve
|
||||
oBuffer.ReadChar(m_chCheckBulletChar);
|
||||
}
|
||||
|
||||
CHWPRecordBullet::CHWPRecordBullet(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType)
|
||||
CHWPRecordBullet::CHWPRecordBullet(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_BULLET, 0, 0), m_pParent(&oDocInfo)
|
||||
{
|
||||
if (EHanType::HWPML == eType)
|
||||
return; // TODO:: реализовать как встретится пример
|
||||
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("char" == sAttributeName)
|
||||
|
||||
@ -24,7 +24,7 @@ class CHWPRecordBullet : public CHWPRecord
|
||||
HWP_CHAR m_chCheckBulletChar;
|
||||
public:
|
||||
CHWPRecordBullet(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordBullet(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType);
|
||||
CHWPRecordBullet(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
#include "HWPRecordCharShape.h"
|
||||
#include "../HWPElements/HWPRecordFaceName.h"
|
||||
|
||||
#include "../Common/NodeNames.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
EAccent GetAccent(int nValue)
|
||||
@ -19,25 +17,15 @@ EAccent GetAccent(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
//Всречается только в hwpx
|
||||
EAccent GetAccent(const std::string& sValue)
|
||||
EAccent GetAccent(const HWP_STRING& sValue)
|
||||
{
|
||||
if (sValue.empty() || "NONE" == sValue)
|
||||
return EAccent::NONE;
|
||||
if ("DOT" == sValue)
|
||||
return EAccent::DOT;
|
||||
if ("RING" == sValue)
|
||||
return EAccent::RING;
|
||||
if ("CARON" == sValue)
|
||||
return EAccent::CARON;
|
||||
if ("TILDE" == sValue)
|
||||
return EAccent::TILDE;
|
||||
if ("ARAEA" == sValue)
|
||||
return EAccent::ARAEA;
|
||||
if ("TWOARAEA" == sValue)
|
||||
return EAccent::TWOARAEA;
|
||||
|
||||
return EAccent::NONE;
|
||||
IF_STRING_IN_ENUM(DOT, sValue, EAccent);
|
||||
ELSE_IF_STRING_IN_ENUM(RING, sValue, EAccent);
|
||||
ELSE_IF_STRING_IN_ENUM(CARON, sValue, EAccent);
|
||||
ELSE_IF_STRING_IN_ENUM(TILDE, sValue, EAccent);
|
||||
ELSE_IF_STRING_IN_ENUM(ARAEA, sValue, EAccent);
|
||||
ELSE_IF_STRING_IN_ENUM(TWOARAEA, sValue, EAccent);
|
||||
ELSE_STRING_IN_ENUM(NONE, EAccent);
|
||||
}
|
||||
|
||||
ELang GetLang(int nValue)
|
||||
@ -69,18 +57,37 @@ EUnderline GetUnderline(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
EUnderline GetUnderline(const std::string& sValue, EHanType eType)
|
||||
EUnderline GetUnderline(const HWP_STRING& sValue)
|
||||
{
|
||||
if (sValue.empty() || GetValueName(EValue::None, eType) == sValue)
|
||||
return EUnderline::NONE;
|
||||
if (GetValueName(EValue::Bottom, eType) == sValue)
|
||||
return EUnderline::BOTTOM;
|
||||
if (GetValueName(EValue::Center, eType) == sValue)
|
||||
return EUnderline::CENTER;
|
||||
if (GetValueName(EValue::Top, eType) == sValue)
|
||||
return EUnderline::TOP;
|
||||
IF_STRING_IN_ENUM(BOTTOM, sValue, EUnderline);
|
||||
ELSE_IF_STRING_IN_ENUM(CENTER, sValue, EUnderline);
|
||||
ELSE_IF_STRING_IN_ENUM(TOP, sValue, EUnderline);
|
||||
ELSE_STRING_IN_ENUM(NONE, EUnderline);
|
||||
}
|
||||
|
||||
return EUnderline::NONE;
|
||||
EOutline GetOutline(int nValue)
|
||||
{
|
||||
SWITCH(EOutline, nValue)
|
||||
{
|
||||
DEFAULT(EOutline::NONE);
|
||||
CASE(EOutline::SOLID);
|
||||
CASE(EOutline::DOTTED);
|
||||
CASE(EOutline::BOLD);
|
||||
CASE(EOutline::DASHED);
|
||||
CASE(EOutline::DASH_DOT);
|
||||
CASE(EOutline::DASH_2DOT);
|
||||
}
|
||||
}
|
||||
|
||||
EOutline GetOutline(const HWP_STRING& sValue)
|
||||
{
|
||||
IF_STRING_IN_ENUM(SOLID, sValue, EOutline);
|
||||
ELSE_IF_STRING_IN_ENUM(DOTTED, sValue, EOutline);
|
||||
ELSE_IF_STRING_IN_ENUM(BOLD, sValue, EOutline);
|
||||
ELSE_IF_STRING_IN_ENUM(DASHED, sValue, EOutline);
|
||||
ELSE_IF_STRING_IN_ENUM(DASH_DOT, sValue, EOutline);
|
||||
ELSE_IF_STRING_IN_ENUM(DASH_2DOT, sValue, EOutline);
|
||||
ELSE_STRING_IN_ENUM(NONE, EOutline);
|
||||
}
|
||||
|
||||
EShadow GetShadow(int nValue)
|
||||
@ -93,14 +100,11 @@ EShadow GetShadow(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
EShadow GetShadow(const std::string& sValue, EHanType eType)
|
||||
EShadow GetShadow(const HWP_STRING& sValue)
|
||||
{
|
||||
if (sValue.empty() || GetValueName(EValue::None, eType) == sValue)
|
||||
return EShadow::NONE;
|
||||
if (GetValueName(EValue::Discrete, eType) == sValue)
|
||||
return EShadow::DISCRETE;
|
||||
if (GetValueName(EValue::Continuous, eType) == sValue)
|
||||
return EShadow::CONTINUOUS;
|
||||
IF_STRING_IN_ENUM(DISCRETE, sValue, EShadow);
|
||||
ELSE_IF_STRING_IN_ENUM(CONTINUOUS, sValue, EShadow);
|
||||
ELSE_STRING_IN_ENUM(NONE, EShadow);
|
||||
}
|
||||
|
||||
void CHWPRecordCharShape::ReadContainerData(CXMLReader& oReader, short arValues[], int nDefaultValue)
|
||||
@ -110,8 +114,6 @@ void CHWPRecordCharShape::ReadContainerData(CXMLReader& oReader, short arValues[
|
||||
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
TO_LOWER(sAttributeName);
|
||||
|
||||
if ("hangul" == sAttributeName)
|
||||
arValues[(int)ELang::HANGUL] = oReader.GetInt();
|
||||
else if ("latin" == sAttributeName)
|
||||
@ -178,7 +180,7 @@ CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, int nTagNum, int
|
||||
m_bBold = CHECK_FLAG(nAttrBits, 0x02);
|
||||
m_eUnderline = GetUnderline((nAttrBits >> 2) & 0x03);
|
||||
m_eUnderLineShape = GetLineStyle1((nAttrBits >> 4) & 0x0F);
|
||||
m_eOutline = GetLineStyle3((nAttrBits >> 8) & 0x07);
|
||||
m_eOutline = GetOutline((nAttrBits >> 8) & 0x07);
|
||||
m_eShadow = GetShadow((nAttrBits >> 11) & 0x03);
|
||||
m_bEmboss = CHECK_FLAG(nAttrBits, 0x2000);
|
||||
m_bEngrave = CHECK_FLAG(nAttrBits, 0x4000);
|
||||
@ -206,34 +208,34 @@ CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, int nTagNum, int
|
||||
oBuffer.RemoveLastSavedPos();
|
||||
}
|
||||
|
||||
CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType)
|
||||
CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_HWP_CHAR_SHAPE, 0, 0), m_pParent(&oDocInfo),
|
||||
m_nHeight(1000), m_bItalic(false), m_bBold(false), m_eUnderline(EUnderline::NONE),
|
||||
m_eUnderLineShape(ELineStyle1::SOLID), m_eOutline(ELineStyle3::NONE), m_eShadow(EShadow::NONE), m_bEmboss(false), m_bEngrave(false),
|
||||
m_eUnderLineShape(ELineStyle1::SOLID), m_eOutline(EOutline::NONE), m_eShadow(EShadow::NONE), m_bEmboss(false), m_bEngrave(false),
|
||||
m_bSuperScript(false), m_bSubScript(false), m_eStrikeOutShape(ELineStyle2::NONE), m_nShadeColor(0xFFFFFFFF)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::Height, eType) == sAttributeName)
|
||||
if ("height" == sAttributeName)
|
||||
m_nHeight = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::TextColor, eType)== sAttributeName)
|
||||
else if ("textColor" == sAttributeName)
|
||||
m_nTextColor = oReader.GetColor();
|
||||
else if (GetAttributeName(EAttribute::ShadeColor, eType) == sAttributeName)
|
||||
else if ("shadeColor" == sAttributeName)
|
||||
m_nShadeColor = oReader.GetColor(0xFFFFFFFF);
|
||||
else if (GetAttributeName(EAttribute::UseFontSpace, eType) == sAttributeName)
|
||||
else if ("useFontSpace" == sAttributeName)
|
||||
m_bUseFontSpace = oReader.GetBool();
|
||||
else if (GetAttributeName(EAttribute::Height, eType) == sAttributeName)
|
||||
else if ("useKerning" == sAttributeName)
|
||||
m_bUseKerning = oReader.GetBool();
|
||||
else if (GetAttributeName(EAttribute::SymMask, eType) == sAttributeName)
|
||||
m_eSymMark = ((EHanType::HWPX == eType) ? GetAccent(oReader.GetTextA()) : GetAccent(oReader.GetInt()));
|
||||
else if (GetAttributeName(EAttribute::BorderFillId, eType) == sAttributeName)
|
||||
else if ("symMark" == sAttributeName)
|
||||
m_eSymMark = GetAccent(oReader.GetText());
|
||||
else if ("borderFillIDRef" == sAttributeName)
|
||||
m_shBorderFillIDRef = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if (GetNodeName(ENode::FontId, eType) == sNodeName)
|
||||
if ("hh:fontRef" == sNodeName)
|
||||
{
|
||||
if (nullptr == m_pParent)
|
||||
continue;
|
||||
@ -249,8 +251,6 @@ CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLReader& oRea
|
||||
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
TO_LOWER(sAttributeName);
|
||||
|
||||
if ("hangul" == sAttributeName)
|
||||
UPDATE_FACENAME(ELang::HANGUL)
|
||||
else if ("latin" == sAttributeName)
|
||||
@ -268,76 +268,76 @@ CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLReader& oRea
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if (GetNodeName(ENode::Ratio, eType) == sNodeName)
|
||||
else if ("hh:ratio" == sNodeName)
|
||||
ReadContainerData(oReader, m_arRatios, 100);
|
||||
else if (GetNodeName(ENode::CharSpacing, eType) == sNodeName)
|
||||
else if ("hh:spacing" == sNodeName)
|
||||
ReadContainerData(oReader, m_arSpacings);
|
||||
else if (GetNodeName(ENode::RelSize, eType) == sNodeName)
|
||||
else if ("hh:relSz" == sNodeName)
|
||||
ReadContainerData(oReader, m_arRelSizes, 100);
|
||||
else if (GetNodeName(ENode::CharOffset, eType) == sNodeName)
|
||||
else if ("hh:offset" == sNodeName)
|
||||
ReadContainerData(oReader, m_arCharOffset);
|
||||
else if (GetNodeName(ENode::Underline, eType) == sNodeName)
|
||||
else if ("hh:underline" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::Type, eType) == sAttributeName)
|
||||
m_eUnderline = GetUnderline(oReader.GetTextA(), eType);
|
||||
else if (GetAttributeName(EAttribute::Shape, eType) == sAttributeName)
|
||||
m_eUnderLineShape = GetLineStyle1(oReader.GetTextA(), eType);
|
||||
else if (GetAttributeName(EAttribute::Color, eType) == sAttributeName)
|
||||
if ("type" == sAttributeName)
|
||||
m_eUnderline = GetUnderline(oReader.GetText());
|
||||
else if ("shape" == sAttributeName)
|
||||
m_eUnderLineShape = GetLineStyle1(oReader.GetText());
|
||||
else if ("color" == sAttributeName)
|
||||
m_nUnderlineColor = oReader.GetColor();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if (GetNodeName(ENode::Outline, eType) == sNodeName)
|
||||
m_eOutline = GetLineStyle3(oReader.GetAttributeA(GetAttributeName(EAttribute::Type, eType)), eType);
|
||||
else if (GetNodeName(ENode::Shadow, eType) == sNodeName)
|
||||
else if ("hh:strikeout" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::Type, eType) == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if (GetValueName(EValue::Drop, eType))
|
||||
m_eShadow = EShadow::DISCRETE;
|
||||
else if (GetValueName(EValue::Continuous, eType))
|
||||
m_eShadow = EShadow::CONTINUOUS;
|
||||
else
|
||||
m_eShadow = EShadow::NONE;
|
||||
}
|
||||
else if (GetAttributeName(EAttribute::Color, eType) == sAttributeName)
|
||||
m_nShadowColor = oReader.GetColor();
|
||||
else if (GetAttributeName(EAttribute::OffsetX, eType) == sAttributeName)
|
||||
m_chShadowOffsetX = (HWP_BYTE)oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::OffsetY, eType) == sAttributeName)
|
||||
m_chShadowOffsetY = (HWP_BYTE)oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if (GetNodeName(ENode::Italic, eType) == sNodeName)
|
||||
m_bItalic = true;
|
||||
else if (GetNodeName(ENode::Bold, eType) == sNodeName)
|
||||
m_bBold = true;
|
||||
else if (GetNodeName(ENode::Emboss, eType) == sNodeName)
|
||||
m_bEmboss = true;
|
||||
else if (GetNodeName(ENode::Engrave, eType) == sNodeName)
|
||||
m_bEngrave = true;
|
||||
else if (GetNodeName(ENode::SuperScript, eType) == sNodeName)
|
||||
m_bSuperScript = true;
|
||||
else if (GetNodeName(ENode::SubScript, eType) == sNodeName)
|
||||
m_bSubScript = true;
|
||||
else if (EHanType::HWPX == eType && "hh:strikeout" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::Shape, eType) == sAttributeName)
|
||||
m_eStrikeOutShape = GetLineStyle2(oReader.GetTextA(), eType);
|
||||
else if (GetAttributeName(EAttribute::Color, eType) == sAttributeName)
|
||||
if ("shape" == sAttributeName)
|
||||
m_eStrikeOutShape = GetLineStyle2(oReader.GetText());
|
||||
else if ("color" == sAttributeName)
|
||||
m_nStrikeOutColor = oReader.GetColor();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hh:outline" == sNodeName)
|
||||
m_eOutline = GetOutline(oReader.GetAttribute("type"));
|
||||
else if ("hh:shadow" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("type" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if ("DROP" == sType)
|
||||
m_eShadow = EShadow::DISCRETE;
|
||||
else if ("CONTINUOUS" == sType)
|
||||
m_eShadow = EShadow::CONTINUOUS;
|
||||
else
|
||||
m_eShadow = EShadow::NONE;
|
||||
}
|
||||
else if ("color" == sAttributeName)
|
||||
m_nShadowColor = oReader.GetColor();
|
||||
else if ("offsetX" == sAttributeName)
|
||||
m_chShadowOffsetX = (HWP_BYTE)oReader.GetInt();
|
||||
else if ("offsetY" == sAttributeName)
|
||||
m_chShadowOffsetY = (HWP_BYTE)oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("hh:italic" == sNodeName)
|
||||
m_bItalic = true;
|
||||
else if ("hh:bold" == sNodeName)
|
||||
m_bBold = true;
|
||||
else if ("hh:emboss" == sNodeName)
|
||||
m_bEmboss = true;
|
||||
else if ("hh:engrave" == sNodeName)
|
||||
m_bEngrave = true;
|
||||
else if ("hh:supscript" == sNodeName)
|
||||
m_bSuperScript = true;
|
||||
else if ("hh:subscript" == sNodeName)
|
||||
m_bSubScript = true;
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
|
||||
enum class ELang
|
||||
{
|
||||
HANGUL,
|
||||
@ -29,6 +30,17 @@ enum class EUnderline
|
||||
TOP
|
||||
};
|
||||
|
||||
enum class EOutline
|
||||
{
|
||||
NONE,
|
||||
SOLID,
|
||||
DOTTED,
|
||||
BOLD,
|
||||
DASHED,
|
||||
DASH_DOT,
|
||||
DASH_2DOT
|
||||
};
|
||||
|
||||
enum class EShadow
|
||||
{
|
||||
NONE,
|
||||
@ -48,7 +60,7 @@ enum class EAccent
|
||||
};
|
||||
|
||||
EAccent GetAccent(int nValue);
|
||||
EAccent GetAccent(const std::string &sValue);
|
||||
EAccent GetAccent(const HWP_STRING& sValue);
|
||||
|
||||
#define MAX_ELEMENTS (int)ELang::MAX
|
||||
|
||||
@ -68,7 +80,7 @@ class CHWPRecordCharShape : public CHWPRecord
|
||||
EUnderline m_eUnderline;
|
||||
ELineStyle1 m_eUnderLineShape;
|
||||
int m_nUnderlineColor;
|
||||
ELineStyle3 m_eOutline;
|
||||
EOutline m_eOutline;
|
||||
EShadow m_eShadow;
|
||||
bool m_bEmboss;
|
||||
bool m_bEngrave;
|
||||
@ -91,7 +103,7 @@ class CHWPRecordCharShape : public CHWPRecord
|
||||
void ReadContainerData(CXMLReader& oReader, short arValues[], int nDefaultValue = 0);
|
||||
public:
|
||||
CHWPRecordCharShape(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType);
|
||||
CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
|
||||
bool Bold() const;
|
||||
bool Italic() const;
|
||||
|
||||
@ -16,7 +16,7 @@ CHWPRecordDocumentProperties::CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo
|
||||
oBuffer.ReadInt(m_nCharUnitLocInPara);
|
||||
}
|
||||
|
||||
CHWPRecordDocumentProperties::CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, CXMLReader& oReader)
|
||||
CHWPRecordDocumentProperties::CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_DOCUMENT_PROPERTIES, 0, 0), m_pParent(&oDocInfo)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
|
||||
@ -24,7 +24,7 @@ class CHWPRecordDocumentProperties : public CHWPRecord
|
||||
int m_nCharUnitLocInPara;
|
||||
public:
|
||||
CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, CXMLReader& oReader);
|
||||
CHWPRecordDocumentProperties(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
#include "HWPRecordFaceName.h"
|
||||
|
||||
#include "../Common/NodeNames.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
|
||||
EAltType GetAltType(int nValue)
|
||||
{
|
||||
switch(static_cast<EAltType>(nValue))
|
||||
@ -54,29 +53,28 @@ CHWPRecordFaceName::CHWPRecordFaceName(CHWPDocInfo& oDocInfo, int nTagNum, int n
|
||||
oBuffer.ReadString(m_sBasicFaceName, EStringCharacter::UTF16);
|
||||
}
|
||||
|
||||
CHWPRecordFaceName::CHWPRecordFaceName(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType)
|
||||
CHWPRecordFaceName::CHWPRecordFaceName(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_FACE_NAME, 0, 0), m_pParent(&oDocInfo)
|
||||
{
|
||||
m_sFaceName = oReader.GetAttribute(GetAttributeName(EAttribute::FaceName, eType));
|
||||
m_sFaceName = oReader.GetAttribute("face");
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if (GetNodeName(ENode::SubFont, eType) == sNodeName)
|
||||
if ("hh:substFont" == sNodeName)
|
||||
{
|
||||
m_bSubstExists = true;
|
||||
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::FaceName, eType) == sAttributeName)
|
||||
if ("face" == sAttributeName)
|
||||
m_sSubstFace = oReader.GetText();
|
||||
else if (GetAttributeName(EAttribute::Type, eType) == sAttributeName)
|
||||
else if ("type" == sAttributeName)
|
||||
{
|
||||
std::string sType{oReader.GetTextA()};
|
||||
TO_LOWER(sType);
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if ("ttf" == sType)
|
||||
if ("TTF" == sType)
|
||||
m_eSubstType = EAltType::FFT;
|
||||
else if ("hft" == sType)
|
||||
else if ("HFT" == sType)
|
||||
m_eSubstType = EAltType::HFT;
|
||||
else
|
||||
m_eSubstType = EAltType::UNKNOWN;
|
||||
@ -84,36 +82,36 @@ CHWPRecordFaceName::CHWPRecordFaceName(CHWPDocInfo& oDocInfo, CXMLReader& oReade
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if (GetNodeName(ENode::TypeInfo, eType) == sNodeName)
|
||||
else if ("hh:typeInfo" == sNodeName)
|
||||
{
|
||||
m_bAttrExists = true;
|
||||
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::FamilyType, eType) == sAttributeName)
|
||||
if ("familyType" == sAttributeName)
|
||||
{
|
||||
m_sBasicFaceName = oReader.GetText();
|
||||
|
||||
if (!m_sBasicFaceName.empty())
|
||||
m_bBasicFaceExists = true;
|
||||
}
|
||||
else if (GetAttributeName(EAttribute::SerifStyle, eType) == sAttributeName)
|
||||
else if ("serifStyle" == sAttributeName)
|
||||
m_chSerifStyle = (HWP_BYTE)oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::Weight, eType) == sAttributeName)
|
||||
else if ("weight" == sAttributeName)
|
||||
m_shWeight = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::Proportion, eType) == sAttributeName)
|
||||
else if ("proportion" == sAttributeName)
|
||||
m_shPropotion = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::Contrast, eType) == sAttributeName)
|
||||
else if ("contrast" == sAttributeName)
|
||||
m_shContrast = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::StrokeVariation, eType) == sAttributeName)
|
||||
else if ("strokeVariation" == sAttributeName)
|
||||
m_shStrokeVariation = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::ArmStyle, eType) == sAttributeName)
|
||||
else if ("armStyle" == sAttributeName)
|
||||
m_shArmStyle = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::Letterform, eType) == sAttributeName)
|
||||
else if ("letterform" == sAttributeName)
|
||||
m_shLetterform = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::Midline, eType) == sAttributeName)
|
||||
else if ("midline" == sAttributeName)
|
||||
m_shMidLine = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::XHeight, eType) == sAttributeName)
|
||||
else if ("xHeight" == sAttributeName)
|
||||
m_shXHeight = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
@ -41,7 +41,7 @@ class CHWPRecordFaceName : public CHWPRecord
|
||||
short m_shXHeight;
|
||||
public:
|
||||
CHWPRecordFaceName(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordFaceName(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType);
|
||||
CHWPRecordFaceName(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
|
||||
HWP_STRING GetFaceName() const;
|
||||
};
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
#include "HWPRecordNumbering.h"
|
||||
|
||||
#include "../Common/NodeNames.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
|
||||
@ -56,10 +54,10 @@ CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, int nTagNum, int
|
||||
oBuffer.RemoveLastSavedPos();
|
||||
}
|
||||
|
||||
CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType)
|
||||
CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_NUMBERING, 0, 0), m_pParent(&oDocInfo)
|
||||
{
|
||||
m_shStart = oReader.GetAttributeInt(GetAttributeName(EAttribute::Start, eType), 1);
|
||||
m_shStart = oReader.GetAttributeInt("start", 1);
|
||||
|
||||
unsigned int unIndex = 0;
|
||||
short shLevel = 0;
|
||||
@ -67,142 +65,139 @@ CHWPRecordNumbering::CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLReader& oRea
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
TO_LOWER(sNodeName);
|
||||
if ("hh:paraHead" == sNodeName ||
|
||||
"paraHead" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("align" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if (GetNodeName(ENode::ParaHead, eType) != sNodeName &&
|
||||
(EHanType::HWPX == eType && "parahead" != sNodeName))
|
||||
continue;
|
||||
if ("LEFT" == sType)
|
||||
m_arNumbering[unIndex].m_chAlign = 0;
|
||||
else if ("CENTER" == sType)
|
||||
m_arNumbering[unIndex].m_chAlign = 1;
|
||||
else if ("RIGHT" == sType)
|
||||
m_arNumbering[unIndex].m_chAlign = 2;
|
||||
}
|
||||
else if ("useInstWidth" == sAttributeName)
|
||||
m_arNumbering[unIndex].m_bUseInstWidth = oReader.GetBool();
|
||||
else if ("autoIndent" == sAttributeName)
|
||||
m_arNumbering[unIndex].m_bAutoIndent = oReader.GetBool();
|
||||
else if ("widthAdjust" == sAttributeName)
|
||||
m_arNumbering[unIndex].m_shWidthAdjust = oReader.GetInt();
|
||||
else if ("textOffsetType" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::Aligment, eType) == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
if ("PERCENT" == sType)
|
||||
m_arNumbering[unIndex].m_chTextOffsetType = 0;
|
||||
else if ("HWPUNIT" == sType)
|
||||
m_arNumbering[unIndex].m_chTextOffsetType = 1;
|
||||
}
|
||||
else if ("textOffset" == sAttributeName)
|
||||
m_arNumbering[unIndex].m_shTextOffset = oReader.GetInt();
|
||||
else if ("charPrIDRef" == sAttributeName)
|
||||
m_arNumbering[unIndex].m_nCharShape = std::abs(oReader.GetInt());
|
||||
else if ("start" == sAttributeName)
|
||||
m_arNumbering[unIndex].m_nStartNumber = oReader.GetInt();
|
||||
else if ("numFormat" == sAttributeName)
|
||||
sNumFormat = oReader.GetTextA();
|
||||
else if ("level" == sAttributeName)
|
||||
shLevel = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
if (GetValueName(EValue::Left, eType) == sType)
|
||||
m_arNumbering[unIndex].m_chAlign = 0;
|
||||
else if (GetValueName(EValue::Center, eType) == sType)
|
||||
m_arNumbering[unIndex].m_chAlign = 1;
|
||||
else if (GetValueName(EValue::Right, eType) == sType)
|
||||
m_arNumbering[unIndex].m_chAlign = 2;
|
||||
}
|
||||
else if (GetAttributeName(EAttribute::UseInstWidth, eType) == sAttributeName)
|
||||
m_arNumbering[unIndex].m_bUseInstWidth = oReader.GetBool();
|
||||
else if (GetAttributeName(EAttribute::AutoIndent, eType) == sAttributeName)
|
||||
m_arNumbering[unIndex].m_bAutoIndent = oReader.GetBool();
|
||||
else if (GetAttributeName(EAttribute::WidthAdjust, eType) == sAttributeName)
|
||||
m_arNumbering[unIndex].m_shWidthAdjust = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::TextOffsetType, eType) == sAttributeName)
|
||||
if ("DIGIT" == sNumFormat)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
if (shLevel > 0 && shLevel < 11)
|
||||
m_arNumbering[unIndex].m_sNumFormat = L'^' + std::to_wstring(shLevel) + L'.';
|
||||
}
|
||||
else if ("HANGUL_SYLLABLE" == sNumFormat ||
|
||||
"HANGUL_JAMO" == sNumFormat)
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
case 1: m_arNumbering[unIndex].m_sNumFormat = L"^가."; break;
|
||||
case 2: m_arNumbering[unIndex].m_sNumFormat = L"^나."; break;
|
||||
case 3: m_arNumbering[unIndex].m_sNumFormat = L"^다."; break;
|
||||
case 4: m_arNumbering[unIndex].m_sNumFormat = L"^라."; break;
|
||||
case 5: m_arNumbering[unIndex].m_sNumFormat = L"^마."; break;
|
||||
case 6: m_arNumbering[unIndex].m_sNumFormat = L"^바."; break;
|
||||
case 7: m_arNumbering[unIndex].m_sNumFormat = L"^사."; break;
|
||||
case 8: m_arNumbering[unIndex].m_sNumFormat = L"^아."; break;
|
||||
case 9: m_arNumbering[unIndex].m_sNumFormat = L"^자."; break;
|
||||
case 10: m_arNumbering[unIndex].m_sNumFormat = L"^차."; break;
|
||||
}
|
||||
}
|
||||
else if ("CIRCLED_DIGIT" == sNumFormat)
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
case 1: m_arNumbering[unIndex].m_sNumFormat = L"^\u2460."; break;
|
||||
case 2: m_arNumbering[unIndex].m_sNumFormat = L"^\u2461."; break;
|
||||
case 3: m_arNumbering[unIndex].m_sNumFormat = L"^\u2462."; break;
|
||||
case 4: m_arNumbering[unIndex].m_sNumFormat = L"^\u2463."; break;
|
||||
case 5: m_arNumbering[unIndex].m_sNumFormat = L"^\u2464."; break;
|
||||
case 6: m_arNumbering[unIndex].m_sNumFormat = L"^\u2465."; break;
|
||||
case 7: m_arNumbering[unIndex].m_sNumFormat = L"^\u2466."; break;
|
||||
case 8: m_arNumbering[unIndex].m_sNumFormat = L"^\u2467."; break;
|
||||
case 9: m_arNumbering[unIndex].m_sNumFormat = L"^\u2468."; break;
|
||||
case 10: m_arNumbering[unIndex].m_sNumFormat = L"^\u2469."; break;
|
||||
}
|
||||
}
|
||||
else if ("LATIN_SMALL" == sNumFormat)
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
case 1: m_arNumbering[unIndex].m_sNumFormat = L"^a."; break;
|
||||
case 2: m_arNumbering[unIndex].m_sNumFormat = L"^b."; break;
|
||||
case 3: m_arNumbering[unIndex].m_sNumFormat = L"^c."; break;
|
||||
case 4: m_arNumbering[unIndex].m_sNumFormat = L"^d."; break;
|
||||
case 5: m_arNumbering[unIndex].m_sNumFormat = L"^e."; break;
|
||||
case 6: m_arNumbering[unIndex].m_sNumFormat = L"^f."; break;
|
||||
case 7: m_arNumbering[unIndex].m_sNumFormat = L"^g."; break;
|
||||
case 8: m_arNumbering[unIndex].m_sNumFormat = L"^h."; break;
|
||||
case 9: m_arNumbering[unIndex].m_sNumFormat = L"^i."; break;
|
||||
case 10: m_arNumbering[unIndex].m_sNumFormat = L"^j."; break;
|
||||
}
|
||||
}
|
||||
else if ("CIRCLED_HANGUL_SYLLABLE" == sNumFormat)
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
case 1: m_arNumbering[unIndex].m_sNumFormat = L"^\u326E."; break;
|
||||
case 2: m_arNumbering[unIndex].m_sNumFormat = L"^\u326F."; break;
|
||||
case 3: m_arNumbering[unIndex].m_sNumFormat = L"^\u3270."; break;
|
||||
case 4: m_arNumbering[unIndex].m_sNumFormat = L"^\u3271."; break;
|
||||
case 5: m_arNumbering[unIndex].m_sNumFormat = L"^\u3272."; break;
|
||||
case 6: m_arNumbering[unIndex].m_sNumFormat = L"^\u3273."; break;
|
||||
case 7: m_arNumbering[unIndex].m_sNumFormat = L"^\u3274."; break;
|
||||
case 8: m_arNumbering[unIndex].m_sNumFormat = L"^\u3275."; break;
|
||||
case 9: m_arNumbering[unIndex].m_sNumFormat = L"^\u3276."; break;
|
||||
case 10: m_arNumbering[unIndex].m_sNumFormat = L"^\u3277."; break;
|
||||
}
|
||||
}
|
||||
else if ("ROMAN_SMALL" == sNumFormat)
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
case 1: m_arNumbering[unIndex].m_sNumFormat = L"^\u2170."; break;
|
||||
case 2: m_arNumbering[unIndex].m_sNumFormat = L"^\u2171."; break;
|
||||
case 3: m_arNumbering[unIndex].m_sNumFormat = L"^\u2172."; break;
|
||||
case 4: m_arNumbering[unIndex].m_sNumFormat = L"^\u2173."; break;
|
||||
case 5: m_arNumbering[unIndex].m_sNumFormat = L"^\u2174."; break;
|
||||
case 6: m_arNumbering[unIndex].m_sNumFormat = L"^\u2175."; break;
|
||||
case 7: m_arNumbering[unIndex].m_sNumFormat = L"^\u2176."; break;
|
||||
case 8: m_arNumbering[unIndex].m_sNumFormat = L"^\u2177."; break;
|
||||
case 9: m_arNumbering[unIndex].m_sNumFormat = L"^\u2178."; break;
|
||||
case 10: m_arNumbering[unIndex].m_sNumFormat = L"^\u2179."; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (GetValueName(EValue::Percent, eType) == sType)
|
||||
m_arNumbering[unIndex].m_chTextOffsetType = 0;
|
||||
else if (GetValueName(EValue::HwpUnit, eType) == sType)
|
||||
m_arNumbering[unIndex].m_chTextOffsetType = 1;
|
||||
}
|
||||
else if (GetAttributeName(EAttribute::TextOffset, eType) == sAttributeName)
|
||||
m_arNumbering[unIndex].m_shTextOffset = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::CharShape, eType) == sAttributeName)
|
||||
m_arNumbering[unIndex].m_nCharShape = std::abs(oReader.GetInt());
|
||||
else if (GetAttributeName(EAttribute::Start, eType) == sAttributeName)
|
||||
m_arNumbering[unIndex].m_nStartNumber = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::NumFormat, eType) == sAttributeName)
|
||||
sNumFormat = oReader.GetTextA();
|
||||
else if (GetAttributeName(EAttribute::Level, eType) == sAttributeName)
|
||||
shLevel = oReader.GetInt();
|
||||
++unIndex;
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
if (GetValueName(EValue::Digit, eType))
|
||||
{
|
||||
if (shLevel > 0 && shLevel < 11)
|
||||
m_arNumbering[unIndex].m_sNumFormat = L'^' + std::to_wstring(shLevel) + L'.';
|
||||
}
|
||||
else if (GetValueName(EValue::HangulSyllable, eType) ||
|
||||
GetValueName(EValue::HangulJamo, eType))
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
case 1: m_arNumbering[unIndex].m_sNumFormat = L"^가."; break;
|
||||
case 2: m_arNumbering[unIndex].m_sNumFormat = L"^나."; break;
|
||||
case 3: m_arNumbering[unIndex].m_sNumFormat = L"^다."; break;
|
||||
case 4: m_arNumbering[unIndex].m_sNumFormat = L"^라."; break;
|
||||
case 5: m_arNumbering[unIndex].m_sNumFormat = L"^마."; break;
|
||||
case 6: m_arNumbering[unIndex].m_sNumFormat = L"^바."; break;
|
||||
case 7: m_arNumbering[unIndex].m_sNumFormat = L"^사."; break;
|
||||
case 8: m_arNumbering[unIndex].m_sNumFormat = L"^아."; break;
|
||||
case 9: m_arNumbering[unIndex].m_sNumFormat = L"^자."; break;
|
||||
case 10: m_arNumbering[unIndex].m_sNumFormat = L"^차."; break;
|
||||
}
|
||||
}
|
||||
else if (GetValueName(EValue::CircledDigit, eType))
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
case 1: m_arNumbering[unIndex].m_sNumFormat = L"^\u2460."; break;
|
||||
case 2: m_arNumbering[unIndex].m_sNumFormat = L"^\u2461."; break;
|
||||
case 3: m_arNumbering[unIndex].m_sNumFormat = L"^\u2462."; break;
|
||||
case 4: m_arNumbering[unIndex].m_sNumFormat = L"^\u2463."; break;
|
||||
case 5: m_arNumbering[unIndex].m_sNumFormat = L"^\u2464."; break;
|
||||
case 6: m_arNumbering[unIndex].m_sNumFormat = L"^\u2465."; break;
|
||||
case 7: m_arNumbering[unIndex].m_sNumFormat = L"^\u2466."; break;
|
||||
case 8: m_arNumbering[unIndex].m_sNumFormat = L"^\u2467."; break;
|
||||
case 9: m_arNumbering[unIndex].m_sNumFormat = L"^\u2468."; break;
|
||||
case 10: m_arNumbering[unIndex].m_sNumFormat = L"^\u2469."; break;
|
||||
}
|
||||
}
|
||||
else if (GetValueName(EValue::LatinSmall, eType))
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
case 1: m_arNumbering[unIndex].m_sNumFormat = L"^a."; break;
|
||||
case 2: m_arNumbering[unIndex].m_sNumFormat = L"^b."; break;
|
||||
case 3: m_arNumbering[unIndex].m_sNumFormat = L"^c."; break;
|
||||
case 4: m_arNumbering[unIndex].m_sNumFormat = L"^d."; break;
|
||||
case 5: m_arNumbering[unIndex].m_sNumFormat = L"^e."; break;
|
||||
case 6: m_arNumbering[unIndex].m_sNumFormat = L"^f."; break;
|
||||
case 7: m_arNumbering[unIndex].m_sNumFormat = L"^g."; break;
|
||||
case 8: m_arNumbering[unIndex].m_sNumFormat = L"^h."; break;
|
||||
case 9: m_arNumbering[unIndex].m_sNumFormat = L"^i."; break;
|
||||
case 10: m_arNumbering[unIndex].m_sNumFormat = L"^j."; break;
|
||||
}
|
||||
}
|
||||
else if (GetValueName(EValue::CircledHangulSyllable, eType) ||
|
||||
GetValueName(EValue::CircledHangulJamo, eType))
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
case 1: m_arNumbering[unIndex].m_sNumFormat = L"^\u326E."; break;
|
||||
case 2: m_arNumbering[unIndex].m_sNumFormat = L"^\u326F."; break;
|
||||
case 3: m_arNumbering[unIndex].m_sNumFormat = L"^\u3270."; break;
|
||||
case 4: m_arNumbering[unIndex].m_sNumFormat = L"^\u3271."; break;
|
||||
case 5: m_arNumbering[unIndex].m_sNumFormat = L"^\u3272."; break;
|
||||
case 6: m_arNumbering[unIndex].m_sNumFormat = L"^\u3273."; break;
|
||||
case 7: m_arNumbering[unIndex].m_sNumFormat = L"^\u3274."; break;
|
||||
case 8: m_arNumbering[unIndex].m_sNumFormat = L"^\u3275."; break;
|
||||
case 9: m_arNumbering[unIndex].m_sNumFormat = L"^\u3276."; break;
|
||||
case 10: m_arNumbering[unIndex].m_sNumFormat = L"^\u3277."; break;
|
||||
}
|
||||
}
|
||||
else if (GetValueName(EValue::RomanSmall, eType))
|
||||
{
|
||||
switch (shLevel)
|
||||
{
|
||||
case 1: m_arNumbering[unIndex].m_sNumFormat = L"^\u2170."; break;
|
||||
case 2: m_arNumbering[unIndex].m_sNumFormat = L"^\u2171."; break;
|
||||
case 3: m_arNumbering[unIndex].m_sNumFormat = L"^\u2172."; break;
|
||||
case 4: m_arNumbering[unIndex].m_sNumFormat = L"^\u2173."; break;
|
||||
case 5: m_arNumbering[unIndex].m_sNumFormat = L"^\u2174."; break;
|
||||
case 6: m_arNumbering[unIndex].m_sNumFormat = L"^\u2175."; break;
|
||||
case 7: m_arNumbering[unIndex].m_sNumFormat = L"^\u2176."; break;
|
||||
case 8: m_arNumbering[unIndex].m_sNumFormat = L"^\u2177."; break;
|
||||
case 9: m_arNumbering[unIndex].m_sNumFormat = L"^\u2178."; break;
|
||||
case 10: m_arNumbering[unIndex].m_sNumFormat = L"^\u2179."; break;
|
||||
}
|
||||
}
|
||||
|
||||
++unIndex;
|
||||
|
||||
if (7 == unIndex)
|
||||
return;
|
||||
|
||||
@ -36,7 +36,7 @@ class CHWPRecordNumbering : public CHWPRecord
|
||||
int m_arExtLevelStart[3];
|
||||
public:
|
||||
CHWPRecordNumbering(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType);
|
||||
CHWPRecordNumbering(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
|
||||
short GetStart() const;
|
||||
HWP_STRING GetNumFormat(unsigned short ushIndex) const;
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
#include "HWPRecordParaShape.h"
|
||||
|
||||
#include "../Common/NodeNames.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
EHeadingType GetHeadingType(int nValue)
|
||||
@ -15,18 +13,12 @@ EHeadingType GetHeadingType(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
EHeadingType GetHeadingType(const std::string& sValue, EHanType eType)
|
||||
EHeadingType GetHeadingType(const HWP_STRING& sValue)
|
||||
{
|
||||
if (sValue.empty() || GetValueName(EValue::None, eType) == sValue)
|
||||
return EHeadingType::NONE;
|
||||
if (GetValueName(EValue::Outline, eType) == sValue)
|
||||
return EHeadingType::OUTLINE;
|
||||
if (GetValueName(EValue::Number, eType) == sValue)
|
||||
return EHeadingType::NUMBER;
|
||||
if (GetValueName(EValue::Bullet, eType) == sValue)
|
||||
return EHeadingType::BULLET;
|
||||
|
||||
return EHeadingType::NONE;
|
||||
IF_STRING_IN_ENUM(OUTLINE, sValue, EHeadingType);
|
||||
ELSE_IF_STRING_IN_ENUM(NUMBER, sValue, EHeadingType);
|
||||
ELSE_IF_STRING_IN_ENUM(BULLET, sValue, EHeadingType);
|
||||
ELSE_STRING_IN_ENUM(NONE, EHeadingType);
|
||||
}
|
||||
|
||||
EHorizontalAlign GetHorizontalAlign(int nValue)
|
||||
@ -42,22 +34,14 @@ EHorizontalAlign GetHorizontalAlign(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
EHorizontalAlign GetHorizontalAlign(const std::string& sValue, EHanType eType)
|
||||
EHorizontalAlign GetHorizontalAlign(const HWP_STRING& sValue)
|
||||
{
|
||||
if (sValue.empty() || GetValueName(EValue::Left, eType) == sValue)
|
||||
return EHorizontalAlign::LEFT;
|
||||
if (GetValueName(EValue::Center, eType) == sValue)
|
||||
return EHorizontalAlign::CENTER;
|
||||
if (GetValueName(EValue::Right, eType) == sValue)
|
||||
return EHorizontalAlign::RIGHT;
|
||||
if (GetValueName(EValue::Distribute, eType) == sValue)
|
||||
return EHorizontalAlign::DISTRIBUTE;
|
||||
if (GetValueName(EValue::DistributeSpace, eType) == sValue)
|
||||
return EHorizontalAlign::DISTRIBUTE_SPACE;
|
||||
if (GetValueName(EValue::Justify, eType) == sValue)
|
||||
return EHorizontalAlign::JUSTIFY;
|
||||
|
||||
return EHorizontalAlign::LEFT;
|
||||
IF_STRING_IN_ENUM(RIGHT, sValue, EHorizontalAlign);
|
||||
ELSE_IF_STRING_IN_ENUM(CENTER, sValue, EHorizontalAlign);
|
||||
ELSE_IF_STRING_IN_ENUM(DISTRIBUTE, sValue, EHorizontalAlign);
|
||||
ELSE_IF_STRING_IN_ENUM(DISTRIBUTE_SPACE, sValue, EHorizontalAlign);
|
||||
ELSE_IF_STRING_IN_ENUM(JUSTIFY, sValue, EHorizontalAlign);
|
||||
ELSE_STRING_IN_ENUM(LEFT, EHorizontalAlign);
|
||||
}
|
||||
|
||||
EVerticalAlign GetVerticalAlign(int nValue)
|
||||
@ -71,18 +55,12 @@ EVerticalAlign GetVerticalAlign(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
EVerticalAlign GetVerticalAlign(const std::string& sValue, EHanType eType)
|
||||
EVerticalAlign GetVerticalAlign(const HWP_STRING& sValue)
|
||||
{
|
||||
if (sValue.empty() || GetValueName(EValue::Top, eType) == sValue)
|
||||
return EVerticalAlign::TOP;
|
||||
if (GetValueName(EValue::Center, eType) == sValue)
|
||||
return EVerticalAlign::CENTER;
|
||||
if (GetValueName(EValue::Bottom, eType) == sValue)
|
||||
return EVerticalAlign::BOTTOM;
|
||||
if (GetValueName(EValue::Baseline, eType) == sValue)
|
||||
return EVerticalAlign::BASELINE;
|
||||
|
||||
return EVerticalAlign::TOP;
|
||||
IF_STRING_IN_ENUM(CENTER, sValue, EVerticalAlign);
|
||||
ELSE_IF_STRING_IN_ENUM(BOTTOM, sValue, EVerticalAlign);
|
||||
ELSE_IF_STRING_IN_ENUM(BASELINE, sValue, EVerticalAlign);
|
||||
ELSE_STRING_IN_ENUM(TOP, EVerticalAlign);
|
||||
}
|
||||
|
||||
CHWPRecordParaShape::CHWPRecordParaShape(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
|
||||
@ -153,155 +131,26 @@ CHWPRecordParaShape::CHWPRecordParaShape(CHWPDocInfo& oDocInfo, int nTagNum, int
|
||||
oBuffer.Skip(8);
|
||||
}
|
||||
|
||||
CHWPRecordParaShape::CHWPRecordParaShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType)
|
||||
CHWPRecordParaShape::CHWPRecordParaShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_PARA_SHAPE, 0, 0), m_pParent(&oDocInfo),
|
||||
m_eAlign(EHorizontalAlign::JUSTIFY), m_bWidowOrphan(false), m_bKeepWithNext(false),
|
||||
m_bPageBreakBefore(false), m_eVertAlign(EVerticalAlign::BASELINE), m_eHeadingType(EHeadingType::NONE),
|
||||
m_bConnect(false), m_bIgnoreMargin(false), m_bParaTailShape(false), m_nIndent(0), m_nMarginLeft(0),
|
||||
m_nMarginRight(0), m_nMarginPrev(0), m_nMarginNext(0)
|
||||
m_bConnect(false), m_bIgnoreMargin(false), m_bParaTailShape(false)
|
||||
{
|
||||
//В HWPX в данной ноде данный пишутся по типу данный в нодах
|
||||
//В HWPML в данной ноде данные пишутся по типу данные в аргументах
|
||||
|
||||
if (EHanType::HWPX == eType)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::TabDef, eType))
|
||||
m_shTabDef = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::Condense, eType) == sAttributeName)
|
||||
m_chCondense = (HWP_BYTE)oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::FontLineHeight, eType) == sAttributeName)
|
||||
m_bFontLineHeight = oReader.GetBool();
|
||||
else if (GetAttributeName(EAttribute::SnapToGrid, eType) == sAttributeName)
|
||||
m_bSnapToGrid = oReader.GetBool();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
RecursiveParaShape(oReader);
|
||||
return;
|
||||
}
|
||||
else if (EHanType::HWPML != eType)
|
||||
return;
|
||||
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("Align" == sAttributeName)
|
||||
m_eAlign = ::HWP::GetHorizontalAlign(oReader.GetTextA(), eType);
|
||||
else if ("VerAlign" == sAttributeName)
|
||||
m_eVertAlign = ::HWP::GetVerticalAlign(oReader.GetTextA(), eType);
|
||||
else if ("HeadingType" == sAttributeName)
|
||||
m_eHeadingType = ::HWP::GetHeadingType(oReader.GetTextA(), eType);
|
||||
else if ("Heading" == sAttributeName)
|
||||
m_shHeadingIdRef = oReader.GetInt();
|
||||
else if ("Level" == sAttributeName)
|
||||
m_chHeadingLevel = (HWP_BYTE)oReader.GetInt();
|
||||
else if ("TabDef" == sAttributeName)
|
||||
if ("tabPrIDRef" == sAttributeName)
|
||||
m_shTabDef = oReader.GetInt();
|
||||
else if ("BreakLatinWord" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if ("KeepWord" == sType)
|
||||
m_chBreakLatinWord = 0;
|
||||
else if ("BreakWord" == sType)
|
||||
m_chBreakLatinWord = 1;
|
||||
else if ("Hyphenation" == sType)
|
||||
m_chBreakLatinWord = 2;
|
||||
}
|
||||
else if ("BreakNonLatinWord" == sAttributeName)
|
||||
{
|
||||
//TODO:: проверить соответсвие hwpx и hwpml
|
||||
}
|
||||
else if ("Condense" == sAttributeName)
|
||||
else if ("condense" == sAttributeName)
|
||||
m_chCondense = (HWP_BYTE)oReader.GetInt();
|
||||
else if ("WidowOrphan" == sAttributeName)
|
||||
m_bWidowOrphan = oReader.GetBool();
|
||||
else if ("KeepWithNext" == sAttributeName)
|
||||
m_bKeepWithNext = oReader.GetBool();
|
||||
else if ("KeepLines" == sAttributeName)
|
||||
{ /*TODO:: проверить соответсвие hwpx и hwpml*/ }
|
||||
else if ("PageBreakBefore" == sAttributeName)
|
||||
m_bPageBreakBefore = oReader.GetBool();
|
||||
else if ("FontLineHeight" == sAttributeName)
|
||||
else if ("fontLineHeight" == sAttributeName)
|
||||
m_bFontLineHeight = oReader.GetBool();
|
||||
else if ("SnapToGrid" == sAttributeName)
|
||||
else if ("snapToGrid" == sAttributeName)
|
||||
m_bSnapToGrid = oReader.GetBool();
|
||||
else if ("LineWrap" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if ("Break" == sType)
|
||||
m_chLineWrap = 0;
|
||||
else if ("Squeeze" == sType)
|
||||
m_chLineWrap = 1;
|
||||
else if ("Keep" == sType)
|
||||
m_chLineWrap = 2;
|
||||
}
|
||||
else if ("AutoSpaceEAsianEng" == sAttributeName)
|
||||
m_bAutoSpaceEAsianEng = oReader.GetBool();
|
||||
else if ("AutoSpaceEAsianNum" == sAttributeName)
|
||||
m_bAutoSpaceEAsianNum = oReader.GetBool();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if ("PARAMARGIN" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("Indent" == sAttributeName)
|
||||
m_nIndent = oReader.GetInt();
|
||||
else if ("Left" == sAttributeName)
|
||||
m_nMarginLeft = oReader.GetInt();
|
||||
else if ("Right" == sAttributeName)
|
||||
m_nMarginRight = oReader.GetInt();
|
||||
else if ("Prev" == sAttributeName)
|
||||
m_nMarginPrev = oReader.GetInt();
|
||||
else if ("Next" == sAttributeName)
|
||||
m_nMarginNext = oReader.GetInt();
|
||||
else if ("LineSpacingType" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if ("Percent" == sType)
|
||||
m_nLineSpacingType = 0;
|
||||
else if ("Fixed" == sType)
|
||||
m_nLineSpacingType = 1;
|
||||
else if ("BetweenLines" == sType)
|
||||
m_nLineSpacingType = 2;
|
||||
else if ("AtLeast" == sType)
|
||||
m_nLineSpacingType = 4;
|
||||
}
|
||||
else if ("LineSpacing" == sAttributeName)
|
||||
m_nLineSpacing = oReader.GetInt();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
else if ("PARABORDER" == sNodeName)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("BorderFill" == sAttributeName)
|
||||
m_shBorderFill = oReader.GetInt();
|
||||
else if ("OffsetLeft" == sAttributeName)
|
||||
m_shOffsetLeft = oReader.GetInt();
|
||||
else if ("OffsetRigth" == sAttributeName)
|
||||
m_shOffsetRight = oReader.GetInt();
|
||||
else if ("OffsetTop" == sAttributeName)
|
||||
m_shOffsetTop = oReader.GetInt();
|
||||
else if ("OffsetBottom" == sAttributeName)
|
||||
m_shOffsetBottom = oReader.GetInt();
|
||||
else if ("Connect" == sAttributeName)
|
||||
m_bConnect = oReader.GetBool();
|
||||
else if ("IgnoreMargin" == sAttributeName)
|
||||
m_bIgnoreMargin = oReader.GetBool();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
}
|
||||
END_WHILE
|
||||
RecursiveParaShape(oReader);
|
||||
}
|
||||
|
||||
void CHWPRecordParaShape::RecursiveParaShape(CXMLReader& oReader)
|
||||
@ -313,9 +162,9 @@ void CHWPRecordParaShape::RecursiveParaShape(CXMLReader& oReader)
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("horizontal" == sAttributeName)
|
||||
m_eAlign = ::HWP::GetHorizontalAlign(oReader.GetTextA(), EHanType::HWPX);
|
||||
m_eAlign = ::HWP::GetHorizontalAlign(oReader.GetText());
|
||||
else if ("vertical" == sAttributeName)
|
||||
m_eVertAlign = ::HWP::GetVerticalAlign(oReader.GetTextA(), EHanType::HWPX);
|
||||
m_eVertAlign = ::HWP::GetVerticalAlign(oReader.GetText());
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
@ -324,7 +173,7 @@ void CHWPRecordParaShape::RecursiveParaShape(CXMLReader& oReader)
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("type" == sAttributeName)
|
||||
m_eHeadingType = ::HWP::GetHeadingType(oReader.GetTextA(), EHanType::HWPX);
|
||||
m_eHeadingType = ::HWP::GetHeadingType(oReader.GetText());
|
||||
else if ("idRef" == sAttributeName)
|
||||
m_shHeadingIdRef = oReader.GetInt();
|
||||
else if ("level" == sAttributeName)
|
||||
|
||||
@ -77,7 +77,7 @@ class CHWPRecordParaShape : public CHWPRecord
|
||||
void RecursiveParaShape(CXMLReader& oReader);
|
||||
public:
|
||||
CHWPRecordParaShape(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordParaShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType);
|
||||
CHWPRecordParaShape(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
|
||||
EHorizontalAlign GetHorizantalAlign() const;
|
||||
EVerticalAlign GetVerticalAlign() const;
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
#include "HWPRecordStyle.h"
|
||||
|
||||
#include "../Common/NodeNames.h"
|
||||
#include <iostream>
|
||||
namespace HWP
|
||||
{
|
||||
CHWPRecordStyle::CHWPRecordStyle(int nTagNum, int nLevel, int nSize)
|
||||
@ -22,33 +20,33 @@ CHWPRecordStyle::CHWPRecordStyle(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel,
|
||||
m_nCharShape = oBuffer.ReadShort();
|
||||
}
|
||||
|
||||
CHWPRecordStyle::CHWPRecordStyle(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType)
|
||||
CHWPRecordStyle::CHWPRecordStyle(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_STYLE, 0, 0), m_pParent(&oDocInfo)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::Type, eType) == sAttributeName)
|
||||
if ("type" == sAttributeName)
|
||||
{
|
||||
const std::string sType{oReader.GetTextA()};
|
||||
|
||||
if (GetValueName(EValue::Para, eType) == sType)
|
||||
if ("PARA" == sType)
|
||||
m_chType = 0;
|
||||
else if (GetValueName(EValue::Char, eType) == sType)
|
||||
else if ("CHAR" == sType)
|
||||
m_chType = 1;
|
||||
}
|
||||
else if (GetAttributeName(EAttribute::Name, eType) == sAttributeName)
|
||||
else if ("name" == sAttributeName)
|
||||
m_sName = oReader.GetText();
|
||||
else if (GetAttributeName(EAttribute::EngName, eType) == sAttributeName)
|
||||
else if ("engName" == sAttributeName)
|
||||
m_sEngName = oReader.GetText();
|
||||
else if (GetAttributeName(EAttribute::ParaShape, eType) == sAttributeName)
|
||||
else if ("paraPrIDRef" == sAttributeName)
|
||||
m_nParaShape = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::CharShape, eType) == sAttributeName)
|
||||
else if ("charPrIDRef" == sAttributeName)
|
||||
m_nCharShape = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::NextStyle, eType) == sAttributeName)
|
||||
else if ("nextStyleIDRef" == sAttributeName)
|
||||
m_chNextStyle = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::LangId, eType) == sAttributeName)
|
||||
else if ("langID" == sAttributeName)
|
||||
m_shLangID = oReader.GetInt();
|
||||
else if (GetAttributeName(EAttribute::LockForm, eType) == sAttributeName)
|
||||
else if ("lockForm" == sAttributeName)
|
||||
m_bLockForm = oReader.GetBool();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
@ -22,7 +22,7 @@ class CHWPRecordStyle : public CHWPRecord
|
||||
public:
|
||||
CHWPRecordStyle(int nTagNum, int nLevel, int nSize);
|
||||
CHWPRecordStyle(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHWPRecordStyle(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType);
|
||||
CHWPRecordStyle(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
|
||||
HWP_STRING GetName() const;
|
||||
HWP_STRING GetEngName() const;
|
||||
|
||||
17
HwpFile/HwpDoc/HWPElements/HWPType.h
Normal file
17
HwpFile/HwpDoc/HWPElements/HWPType.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef HWPTYPE_H
|
||||
#define HWPTYPE_H
|
||||
|
||||
#include "HWPTag.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
class CHWPType
|
||||
{
|
||||
public:
|
||||
CHWPType(){};
|
||||
|
||||
EHWPTag m_eTag;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // HWPTYPE_H
|
||||
@ -1,7 +1,5 @@
|
||||
#include "HwpRecordTabDef.h"
|
||||
|
||||
#include "../Common/NodeNames.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
TTab::TTab()
|
||||
@ -16,7 +14,7 @@ TTab::TTab(CXMLReader& oReader)
|
||||
else if ("type" == sAttributeName)
|
||||
SetType(oReader.GetInt());
|
||||
else if ("leader" == sAttributeName)
|
||||
m_eLeader = GetLineStyle2(oReader.GetTextA(), EHanType::HWPX);
|
||||
m_eLeader = GetLineStyle2(oReader.GetText());
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
@ -71,19 +69,19 @@ CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, int nTagNum, int nLeve
|
||||
oBuffer.RemoveLastSavedPos();
|
||||
}
|
||||
|
||||
CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType)
|
||||
CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion)
|
||||
: CHWPRecord(EHWPTag::HWPTAG_TAB_DEF, 0, 0), m_pParent(&oDocInfo), m_nAttr(0)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if (GetAttributeName(EAttribute::AutoTabLeft, eType) == sAttributeName)
|
||||
if ("autoTabLeft" == sAttributeName)
|
||||
{
|
||||
if (oReader.GetBool())
|
||||
m_nAttr |= 0x00000001;
|
||||
else
|
||||
m_nAttr &= 0xFFFFFFFE;
|
||||
}
|
||||
else if (GetAttributeName(EAttribute::AutoTabRight, eType) == sAttributeName)
|
||||
else if ("autoTabRight" == sAttributeName)
|
||||
{
|
||||
if (oReader.GetBool())
|
||||
m_nAttr |= 0x00000002;
|
||||
@ -93,10 +91,6 @@ CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, CXMLReader& oReader, E
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
// Дальнейшая структура встречается лишь в HWPX формате
|
||||
if (EHanType::HWPX != eType)
|
||||
return;
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:switch")
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Child, "hp:default")
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, TabChild, "hh:tabItem")
|
||||
@ -104,6 +98,7 @@ CHwpRecordTabDef::CHwpRecordTabDef(CHWPDocInfo& oDocInfo, CXMLReader& oReader, E
|
||||
END_WHILE
|
||||
END_WHILE
|
||||
END_WHILE
|
||||
|
||||
}
|
||||
|
||||
int CHwpRecordTabDef::GetCount() const
|
||||
|
||||
@ -36,7 +36,7 @@ class CHwpRecordTabDef : public CHWPRecord
|
||||
public:
|
||||
CHwpRecordTabDef(int nTagNum, int nLevel, int nSize);
|
||||
CHwpRecordTabDef(CHWPDocInfo& oDocInfo, int nTagNum, int nLevel, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
CHwpRecordTabDef(CHWPDocInfo& oDocInfo, CXMLReader& oReader, EHanType eType);
|
||||
CHwpRecordTabDef(CHWPDocInfo& oDocInfo, CXMLReader& oReader, int nVersion);
|
||||
|
||||
int GetCount() const;
|
||||
const TTab* GetTab(unsigned int unIndex) const;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
#define HWPRECORDTYPES_H
|
||||
|
||||
#include "../Common/Common.h"
|
||||
#include "../Common/NodeNames.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
@ -51,47 +50,26 @@ inline ELineStyle1 GetLineStyle1(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
inline ELineStyle1 GetLineStyle1(const std::string& sValue, EHanType eType)
|
||||
inline ELineStyle1 GetLineStyle1(const HWP_STRING& sValue)
|
||||
{
|
||||
if (sValue.empty() || GetValueName(EValue::Solid, eType) == sValue)
|
||||
return ELineStyle1::SOLID;
|
||||
if (GetValueName(EValue::Dash, eType) == sValue)
|
||||
return ELineStyle1::DASH;
|
||||
if (GetValueName(EValue::DashDot, eType) == sValue)
|
||||
return ELineStyle1::DASH_DOT;
|
||||
if (GetValueName(EValue::DashDotDot, eType) == sValue)
|
||||
return ELineStyle1::DASH_DOT_DOT;
|
||||
if (GetValueName(EValue::LongDash, eType) == sValue)
|
||||
return ELineStyle1::LONG_DASH;
|
||||
if (GetValueName(EValue::Circle, eType) == sValue)
|
||||
return ELineStyle1::CIRCLE;
|
||||
if (GetValueName(EValue::DoubleSlim, eType) == sValue)
|
||||
return ELineStyle1::DOUBLE_SLIM;
|
||||
if (GetValueName(EValue::SlimThick, eType) == sValue)
|
||||
return ELineStyle1::SLIM_THICK;
|
||||
if (GetValueName(EValue::ThickSlim, eType) == sValue)
|
||||
return ELineStyle1::THICK_SLIM;
|
||||
if (GetValueName(EValue::SlimThickSlim, eType) == sValue)
|
||||
return ELineStyle1::SLIM_THICK_SLIM;
|
||||
|
||||
// Остальные значения встречаются только в hwpx
|
||||
if (EHanType::HWPX != eType)
|
||||
return ELineStyle1::SOLID;
|
||||
|
||||
if ("WAVE" == sValue)
|
||||
return ELineStyle1::WAVE;
|
||||
if ("DOUBLE_WAVE" == sValue)
|
||||
return ELineStyle1::DOUBLE_WAVE;
|
||||
if ("THICK_3D" == sValue)
|
||||
return ELineStyle1::THICK_3D;
|
||||
if ("THICK_3D_REVERS_LI" == sValue)
|
||||
return ELineStyle1::THICK_3D_REVERS_LI;
|
||||
if ("SOLID_3D" == sValue)
|
||||
return ELineStyle1::SOLID_3D;
|
||||
if ("SOLID_3D_REVERS_LI" == sValue)
|
||||
return ELineStyle1::SOLID_3D_REVERS_LI;
|
||||
|
||||
return ELineStyle1::SOLID;
|
||||
IF_STRING_IN_ENUM(SOLID, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(DASH, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(DOT, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(DASH_DOT, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(DASH_DOT_DOT, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(LONG_DASH, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLE, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(DOUBLE_SLIM, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(SLIM_THICK, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(THICK_SLIM, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(SLIM_THICK_SLIM, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(WAVE, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(DOUBLE_WAVE, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(THICK_3D, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(THICK_3D_REVERS_LI, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(SOLID_3D, sValue, ELineStyle1);
|
||||
ELSE_IF_STRING_IN_ENUM(SOLID_3D_REVERS_LI, sValue, ELineStyle1);
|
||||
ELSE_STRING_IN_ENUM(SOLID, ELineStyle1);
|
||||
}
|
||||
|
||||
enum class ELineStyle2
|
||||
@ -129,79 +107,21 @@ inline ELineStyle2 GetLineStyle2(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
inline ELineStyle2 GetLineStyle2(const std::string& sValue, EHanType eType)
|
||||
inline ELineStyle2 GetLineStyle2(const HWP_STRING& sValue)
|
||||
{
|
||||
if (sValue.empty() || GetValueName(EValue::None, eType) == sValue)
|
||||
return ELineStyle2::NONE;
|
||||
if (GetValueName(EValue::Solid, eType) == sValue)
|
||||
return ELineStyle2::SOLID;
|
||||
if (GetValueName(EValue::Dash, eType) == sValue)
|
||||
return ELineStyle2::DASH;
|
||||
if (GetValueName(EValue::Dot, eType) == sValue)
|
||||
return ELineStyle2::DOT;
|
||||
if (GetValueName(EValue::DashDot, eType) == sValue)
|
||||
return ELineStyle2::DASH_DOT;
|
||||
if (GetValueName(EValue::DashDotDot, eType) == sValue)
|
||||
return ELineStyle2::DASH_DOT_DOT;
|
||||
if (GetValueName(EValue::LongDash, eType) == sValue)
|
||||
return ELineStyle2::LONG_DASH;
|
||||
if (GetValueName(EValue::Circle, eType) == sValue)
|
||||
return ELineStyle2::CIRCLE;
|
||||
if (GetValueName(EValue::DoubleSlim, eType) == sValue)
|
||||
return ELineStyle2::DOUBLE_SLIM;
|
||||
if (GetValueName(EValue::SlimThick, eType) == sValue)
|
||||
return ELineStyle2::SLIM_THICK;
|
||||
if (GetValueName(EValue::ThickSlim, eType) == sValue)
|
||||
return ELineStyle2::THICK_SLIM;
|
||||
if (GetValueName(EValue::SlimThickSlim, eType) == sValue)
|
||||
return ELineStyle2::SLIM_THICK_SLIM;
|
||||
|
||||
return ELineStyle2::NONE;
|
||||
}
|
||||
|
||||
enum class ELineStyle3
|
||||
{
|
||||
NONE,
|
||||
SOLID,
|
||||
DOT,
|
||||
THICK,
|
||||
DASH,
|
||||
DASH_DOT,
|
||||
DASH_DOT_DOT
|
||||
};
|
||||
|
||||
inline ELineStyle3 GetLineStyle3(int nValue)
|
||||
{
|
||||
SWITCH(ELineStyle3, nValue)
|
||||
{
|
||||
DEFAULT(ELineStyle3::NONE);
|
||||
CASE(ELineStyle3::SOLID);
|
||||
CASE(ELineStyle3::DOT);
|
||||
CASE(ELineStyle3::THICK);
|
||||
CASE(ELineStyle3::DASH);
|
||||
CASE(ELineStyle3::DASH_DOT);
|
||||
CASE(ELineStyle3::DASH_DOT_DOT);
|
||||
}
|
||||
}
|
||||
|
||||
inline ELineStyle3 GetLineStyle3(const std::string& sValue, EHanType eType)
|
||||
{
|
||||
if (sValue.empty() || GetValueName(EValue::None, eType) == sValue)
|
||||
return ELineStyle3::NONE;
|
||||
if (GetValueName(EValue::Solid, eType) == sValue)
|
||||
return ELineStyle3::SOLID;
|
||||
if (GetValueName(EValue::Dot, eType) == sValue)
|
||||
return ELineStyle3::DOT;
|
||||
if (GetValueName(EValue::Thick, eType) == sValue)
|
||||
return ELineStyle3::THICK;
|
||||
if (GetValueName(EValue::Dash, eType) == sValue)
|
||||
return ELineStyle3::DASH;
|
||||
if (GetValueName(EValue::DashDot, eType) == sValue)
|
||||
return ELineStyle3::DASH_DOT;
|
||||
if (GetValueName(EValue::DashDotDot, eType) == sValue)
|
||||
return ELineStyle3::DASH_DOT_DOT;
|
||||
|
||||
return ELineStyle3::NONE;
|
||||
IF_STRING_IN_ENUM(NONE, sValue, ELineStyle2);
|
||||
ELSE_IF_STRING_IN_ENUM(SOLID, sValue, ELineStyle2);
|
||||
ELSE_IF_STRING_IN_ENUM(DASH, sValue, ELineStyle2);
|
||||
ELSE_IF_STRING_IN_ENUM(DOT, sValue, ELineStyle2);
|
||||
ELSE_IF_STRING_IN_ENUM(DASH_DOT, sValue, ELineStyle2);
|
||||
ELSE_IF_STRING_IN_ENUM(DASH_DOT_DOT, sValue, ELineStyle2);
|
||||
ELSE_IF_STRING_IN_ENUM(LONG_DASH, sValue, ELineStyle2);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLE, sValue, ELineStyle2);
|
||||
ELSE_IF_STRING_IN_ENUM(DOUBLE_SLIM, sValue, ELineStyle2);
|
||||
ELSE_IF_STRING_IN_ENUM(SLIM_THICK, sValue, ELineStyle2);
|
||||
ELSE_IF_STRING_IN_ENUM(THICK_SLIM, sValue, ELineStyle2);
|
||||
ELSE_IF_STRING_IN_ENUM(SLIM_THICK_SLIM, sValue, ELineStyle2);
|
||||
ELSE_STRING_IN_ENUM(NONE, ELineStyle2);
|
||||
}
|
||||
|
||||
enum class ENumberShape1
|
||||
@ -214,7 +134,7 @@ enum class ENumberShape1
|
||||
LATIN_SMALL,
|
||||
CIRCLED_LATIN_CAPITAL,
|
||||
CIRCLED_LATIN_SMALL,
|
||||
HANGUL_SYLLABLE,
|
||||
HANGLE_SYLLABLE,
|
||||
CIRCLED_HANGUL_SYLLABLE,
|
||||
HANGUL_JAMO,
|
||||
CIRCLED_HANGUL_JAMO,
|
||||
@ -235,7 +155,7 @@ inline ENumberShape1 GetNumberShape1(int nValue)
|
||||
CASE(ENumberShape1::LATIN_SMALL);
|
||||
CASE(ENumberShape1::CIRCLED_LATIN_CAPITAL);
|
||||
CASE(ENumberShape1::CIRCLED_LATIN_SMALL);
|
||||
CASE(ENumberShape1::HANGUL_SYLLABLE);
|
||||
CASE(ENumberShape1::HANGLE_SYLLABLE);
|
||||
CASE(ENumberShape1::CIRCLED_HANGUL_SYLLABLE);
|
||||
CASE(ENumberShape1::HANGUL_JAMO);
|
||||
CASE(ENumberShape1::CIRCLED_HANGUL_JAMO);
|
||||
@ -245,38 +165,24 @@ inline ENumberShape1 GetNumberShape1(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
inline ENumberShape1 GetNumberShape1(const std::string& sValue, EHanType eType)
|
||||
inline ENumberShape1 GetNumberShape1(const HWP_STRING& sValue)
|
||||
{
|
||||
if (sValue.empty() || GetValueName(EValue::Digit, eType) == sValue)
|
||||
return ENumberShape1::DIGIT;
|
||||
if (GetValueName(EValue::CircledDigit, eType) == sValue)
|
||||
return ENumberShape1::CIRCLE_DIGIT;
|
||||
if (GetValueName(EValue::RomanCapital, eType) == sValue)
|
||||
return ENumberShape1::ROMAN_CAPITAL;
|
||||
if (GetValueName(EValue::RomanSmall, eType) == sValue)
|
||||
return ENumberShape1::ROMAN_SMALL;
|
||||
if (GetValueName(EValue::LatinCapital, eType) == sValue)
|
||||
return ENumberShape1::LATIN_SMALL;
|
||||
if (GetValueName(EValue::CircledLatinCapital, eType) == sValue)
|
||||
return ENumberShape1::CIRCLED_LATIN_CAPITAL;
|
||||
if (GetValueName(EValue::CircledLatinSmall, eType) == sValue)
|
||||
return ENumberShape1::CIRCLED_LATIN_SMALL;
|
||||
if (GetValueName(EValue::HangulSyllable, eType) == sValue)
|
||||
return ENumberShape1::HANGUL_SYLLABLE;
|
||||
if (GetValueName(EValue::CircledHangulSyllable, eType) == sValue)
|
||||
return ENumberShape1::CIRCLED_HANGUL_SYLLABLE;
|
||||
if (GetValueName(EValue::HangulJamo, eType) == sValue)
|
||||
return ENumberShape1::HANGUL_JAMO;
|
||||
if (GetValueName(EValue::CircledHangulJamo, eType) == sValue)
|
||||
return ENumberShape1::CIRCLED_HANGUL_JAMO;
|
||||
if (GetValueName(EValue::HangulPhonetic, eType) == sValue)
|
||||
return ENumberShape1::HANGUL_PHONETIC;
|
||||
if (GetValueName(EValue::Ideograph, eType) == sValue)
|
||||
return ENumberShape1::IDEOGRAPH;
|
||||
if (GetValueName(EValue::CircledIdeograph, eType) == sValue)
|
||||
return ENumberShape1::CIRCLED_IDEOGRAPH;
|
||||
|
||||
return ENumberShape1::DIGIT;
|
||||
IF_STRING_IN_ENUM(DIGIT, sValue, ENumberShape1);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLE_DIGIT, sValue, ENumberShape1);
|
||||
ELSE_IF_STRING_IN_ENUM(ROMAN_CAPITAL, sValue, ENumberShape1);
|
||||
ELSE_IF_STRING_IN_ENUM(ROMAN_SMALL, sValue, ENumberShape1);
|
||||
ELSE_IF_STRING_IN_ENUM(LATIN_CAPITAL, sValue, ENumberShape1);
|
||||
ELSE_IF_STRING_IN_ENUM(LATIN_SMALL, sValue, ENumberShape1);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLED_LATIN_CAPITAL, sValue, ENumberShape1);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLED_LATIN_SMALL, sValue, ENumberShape1);
|
||||
ELSE_IF_STRING_IN_ENUM(HANGLE_SYLLABLE, sValue, ENumberShape1);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLED_HANGUL_SYLLABLE, sValue, ENumberShape1);
|
||||
ELSE_IF_STRING_IN_ENUM(HANGUL_JAMO, sValue, ENumberShape1);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLED_HANGUL_JAMO, sValue, ENumberShape1);
|
||||
ELSE_IF_STRING_IN_ENUM(HANGUL_PHONETIC, sValue, ENumberShape1);
|
||||
ELSE_IF_STRING_IN_ENUM(IDEOGRAPH, sValue, ENumberShape1);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLED_IDEOGRAPH, sValue, ENumberShape1);
|
||||
ELSE_STRING_IN_ENUM(DIGIT, ENumberShape1);
|
||||
}
|
||||
|
||||
enum class ENumberShape2
|
||||
@ -289,7 +195,7 @@ enum class ENumberShape2
|
||||
LATIN_SMALL,
|
||||
CIRCLED_LATIN_CAPITAL,
|
||||
CIRCLED_LATIN_SMALL,
|
||||
HANGUL_SYLLABLE,
|
||||
HANGLE_SYLLABLE,
|
||||
CIRCLED_HANGUL_SYLLABLE,
|
||||
HANGUL_JAMO,
|
||||
CIRCLED_HANGUL_JAMO,
|
||||
@ -314,7 +220,7 @@ inline ENumberShape2 GetNumberShape2(int nValue)
|
||||
CASE(ENumberShape2::LATIN_SMALL);
|
||||
CASE(ENumberShape2::CIRCLED_LATIN_CAPITAL);
|
||||
CASE(ENumberShape2::CIRCLED_LATIN_SMALL);
|
||||
CASE(ENumberShape2::HANGUL_SYLLABLE);
|
||||
CASE(ENumberShape2::HANGLE_SYLLABLE);
|
||||
CASE(ENumberShape2::CIRCLED_HANGUL_SYLLABLE);
|
||||
CASE(ENumberShape2::HANGUL_JAMO);
|
||||
CASE(ENumberShape2::CIRCLED_HANGUL_JAMO);
|
||||
@ -328,46 +234,28 @@ inline ENumberShape2 GetNumberShape2(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
inline ENumberShape2 GetNumberShape2(const std::string& sValue, EHanType eType)
|
||||
inline ENumberShape2 GetNumberShape2(const HWP_STRING& sValue)
|
||||
{
|
||||
if (sValue.empty() || GetValueName(EValue::Digit, eType) == sValue)
|
||||
return ENumberShape2::DIGIT;
|
||||
if (GetValueName(EValue::CircledDigit, eType) == sValue)
|
||||
return ENumberShape2::CIRCLE_DIGIT;
|
||||
if (GetValueName(EValue::RomanCapital, eType) == sValue)
|
||||
return ENumberShape2::ROMAN_CAPITAL;
|
||||
if (GetValueName(EValue::RomanSmall, eType) == sValue)
|
||||
return ENumberShape2::ROMAN_SMALL;
|
||||
if (GetValueName(EValue::LatinCapital, eType) == sValue)
|
||||
return ENumberShape2::LATIN_SMALL;
|
||||
if (GetValueName(EValue::CircledLatinCapital, eType) == sValue)
|
||||
return ENumberShape2::CIRCLED_LATIN_CAPITAL;
|
||||
if (GetValueName(EValue::CircledLatinSmall, eType) == sValue)
|
||||
return ENumberShape2::CIRCLED_LATIN_SMALL;
|
||||
if (GetValueName(EValue::HangulSyllable, eType) == sValue)
|
||||
return ENumberShape2::HANGUL_SYLLABLE;
|
||||
if (GetValueName(EValue::CircledHangulSyllable, eType) == sValue)
|
||||
return ENumberShape2::CIRCLED_HANGUL_SYLLABLE;
|
||||
if (GetValueName(EValue::HangulJamo, eType) == sValue)
|
||||
return ENumberShape2::HANGUL_JAMO;
|
||||
if (GetValueName(EValue::CircledHangulJamo, eType) == sValue)
|
||||
return ENumberShape2::CIRCLED_HANGUL_JAMO;
|
||||
if (GetValueName(EValue::HangulPhonetic, eType) == sValue)
|
||||
return ENumberShape2::HANGUL_PHONETIC;
|
||||
if (GetValueName(EValue::Ideograph, eType) == sValue)
|
||||
return ENumberShape2::IDEOGRAPH;
|
||||
if (GetValueName(EValue::CircledIdeograph, eType) == sValue)
|
||||
return ENumberShape2::CIRCLED_IDEOGRAPH;
|
||||
if (GetValueName(EValue::DecagonCircle, eType) == sValue)
|
||||
return ENumberShape2::DECAGON_CIRCLE;
|
||||
if (GetValueName(EValue::DecagonCircleHanja, eType) == sValue)
|
||||
return ENumberShape2::DECAGON_CRICLE_HANGJA;
|
||||
if (GetValueName(EValue::Symbol, eType) == sValue)
|
||||
return ENumberShape2::SYMBOL;
|
||||
if (GetValueName(EValue::UserChar, eType) == sValue)
|
||||
return ENumberShape2::USER_HWP_CHAR;
|
||||
|
||||
return ENumberShape2::DIGIT;
|
||||
IF_STRING_IN_ENUM(DIGIT, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLE_DIGIT, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(ROMAN_CAPITAL, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(ROMAN_SMALL, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(LATIN_CAPITAL, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(LATIN_SMALL, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLED_LATIN_CAPITAL, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLED_LATIN_SMALL, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(HANGLE_SYLLABLE, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLED_HANGUL_SYLLABLE, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(HANGUL_JAMO, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLED_HANGUL_JAMO, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(HANGUL_PHONETIC, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(IDEOGRAPH, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLED_IDEOGRAPH, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(DECAGON_CIRCLE, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(DECAGON_CRICLE_HANGJA, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(SYMBOL, sValue, ENumberShape2);
|
||||
ELSE_IF_STRING_IN_ENUM(USER_HWP_CHAR, sValue, ENumberShape2);
|
||||
ELSE_STRING_IN_ENUM(DIGIT, ENumberShape2);
|
||||
}
|
||||
|
||||
enum class ELineArrowStyle
|
||||
@ -402,46 +290,19 @@ inline ELineArrowStyle GetLineArrowStyle(int nNum, bool bFill)
|
||||
}
|
||||
}
|
||||
|
||||
inline ELineArrowStyle GetLineArrowStyle(const std::string& sValue, EHanType eType, bool bHeadFill = false)
|
||||
inline ELineArrowStyle GetLineArrowStyle(const HWP_STRING& sValue)
|
||||
{
|
||||
if (sValue.empty() || GetValueName(EValue::Normal, eType) == sValue)
|
||||
return ELineArrowStyle::NORMAL;
|
||||
|
||||
if (GetValueName(EValue::Arrow, eType) == sValue)
|
||||
return ELineArrowStyle::ARROW;
|
||||
else if (GetValueName(EValue::Spear, eType) == sValue)
|
||||
return ELineArrowStyle::SPEAR;
|
||||
else if (GetValueName(EValue::ConcaveArrow, eType) == sValue)
|
||||
return ELineArrowStyle::CONCAVE_ARROW;
|
||||
if (GetValueName(EValue::Diamond, eType) == sValue)
|
||||
return ELineArrowStyle::DIAMOND;
|
||||
if (GetValueName(EValue::Circle, eType) == sValue)
|
||||
return ELineArrowStyle::CIRCLE;
|
||||
if (GetValueName(EValue::Box, eType) == sValue)
|
||||
return ELineArrowStyle::BOX;
|
||||
else if (GetValueName(EValue::EmptyDiamond, eType) == sValue)
|
||||
{
|
||||
if (EHanType::HWPX == eType)
|
||||
return bHeadFill ? ELineArrowStyle::DIAMOND : ELineArrowStyle::EMPTY_DIAMOND;
|
||||
|
||||
return ELineArrowStyle::EMPTY_DIAMOND;
|
||||
}
|
||||
else if (GetValueName(EValue::EmptyCircle, eType) == sValue)
|
||||
{
|
||||
if (EHanType::HWPX == eType)
|
||||
return bHeadFill ? ELineArrowStyle::CIRCLE : ELineArrowStyle::EMPTY_CIRCLE;
|
||||
|
||||
return ELineArrowStyle::EMPTY_CIRCLE;
|
||||
}
|
||||
else if (GetValueName(EValue::EmptyBox, eType) == sValue)
|
||||
{
|
||||
if (EHanType::HWPX == eType)
|
||||
return bHeadFill ? ELineArrowStyle::BOX : ELineArrowStyle::EMPTY_BOX;
|
||||
|
||||
return ELineArrowStyle::EMPTY_BOX;
|
||||
}
|
||||
|
||||
return ELineArrowStyle::NORMAL;
|
||||
IF_STRING_IN_ENUM(NORMAL, sValue, ELineArrowStyle);
|
||||
ELSE_IF_STRING_IN_ENUM(ARROW, sValue, ELineArrowStyle);
|
||||
ELSE_IF_STRING_IN_ENUM(SPEAR, sValue, ELineArrowStyle);
|
||||
ELSE_IF_STRING_IN_ENUM(CONCAVE_ARROW, sValue, ELineArrowStyle);
|
||||
ELSE_IF_STRING_IN_ENUM(DIAMOND, sValue, ELineArrowStyle);
|
||||
ELSE_IF_STRING_IN_ENUM(CIRCLE, sValue, ELineArrowStyle);
|
||||
ELSE_IF_STRING_IN_ENUM(BOX, sValue, ELineArrowStyle);
|
||||
ELSE_IF_STRING_IN_ENUM(EMPTY_DIAMOND, sValue, ELineArrowStyle);
|
||||
ELSE_IF_STRING_IN_ENUM(EMPTY_CIRCLE, sValue, ELineArrowStyle);
|
||||
ELSE_IF_STRING_IN_ENUM(EMPTY_BOX, sValue, ELineArrowStyle);
|
||||
ELSE_STRING_IN_ENUM(NORMAL, ELineArrowStyle);
|
||||
}
|
||||
|
||||
enum class ELineArrowSize
|
||||
@ -473,28 +334,18 @@ inline ELineArrowSize GetLineArrowSize(int nValue)
|
||||
}
|
||||
}
|
||||
|
||||
inline ELineArrowSize GetLineArrowSize(const std::string& sValue, EHanType eType)
|
||||
inline ELineArrowSize GetLineArrowSize(const HWP_STRING& sValue)
|
||||
{
|
||||
if (sValue.empty() && GetValueName(EValue::SmallSmall, eType) == sValue)
|
||||
return ELineArrowSize::SMALL_SMALL;
|
||||
if (GetValueName(EValue::SmallMedium, eType) == sValue)
|
||||
return ELineArrowSize::SMALL_MEDIUM;
|
||||
if (GetValueName(EValue::SmallLarge, eType) == sValue)
|
||||
return ELineArrowSize::SMALL_LARGE;
|
||||
if (GetValueName(EValue::MediumSmall, eType) == sValue)
|
||||
return ELineArrowSize::MEDIUM_SMALL;
|
||||
if (GetValueName(EValue::MediumMedium, eType) == sValue)
|
||||
return ELineArrowSize::MEDIUM_MEDIUM;
|
||||
if (GetValueName(EValue::MediumLarge, eType) == sValue)
|
||||
return ELineArrowSize::MEDIUM_LARGE;
|
||||
if (GetValueName(EValue::LargeSmall, eType) == sValue)
|
||||
return ELineArrowSize::LARGE_SMALL;
|
||||
if (GetValueName(EValue::LargeMedium, eType) == sValue)
|
||||
return ELineArrowSize::LARGE_MEDIUM;
|
||||
if (GetValueName(EValue::LargeLarge, eType) == sValue)
|
||||
return ELineArrowSize::LARGE_LARGE;
|
||||
|
||||
return ELineArrowSize::SMALL_SMALL;
|
||||
IF_STRING_IN_ENUM(SMALL_SMALL, sValue, ELineArrowSize);
|
||||
ELSE_IF_STRING_IN_ENUM(SMALL_MEDIUM, sValue, ELineArrowSize);
|
||||
ELSE_IF_STRING_IN_ENUM(SMALL_LARGE, sValue, ELineArrowSize);
|
||||
ELSE_IF_STRING_IN_ENUM(MEDIUM_SMALL, sValue, ELineArrowSize);
|
||||
ELSE_IF_STRING_IN_ENUM(MEDIUM_MEDIUM, sValue, ELineArrowSize);
|
||||
ELSE_IF_STRING_IN_ENUM(MEDIUM_LARGE, sValue, ELineArrowSize);
|
||||
ELSE_IF_STRING_IN_ENUM(LARGE_SMALL, sValue, ELineArrowSize);
|
||||
ELSE_IF_STRING_IN_ENUM(LARGE_MEDIUM, sValue, ELineArrowSize);
|
||||
ELSE_IF_STRING_IN_ENUM(LARGE_LARGE, sValue, ELineArrowSize);
|
||||
ELSE_STRING_IN_ENUM(SMALL_SMALL, ELineArrowSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,171 +0,0 @@
|
||||
#include "HWPMLFile.h"
|
||||
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
#include "../../DesktopEditor/common/Base64.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
|
||||
CHWPMLFile::CHWPMLFile(const HWP_STRING &wsFilePath)
|
||||
: m_wsFilePath(wsFilePath), m_oDocInfo(this)
|
||||
{}
|
||||
|
||||
CHWPMLFile::~CHWPMLFile()
|
||||
{
|
||||
CLEAR_ARRAY(CHWPSection, m_arSections);
|
||||
|
||||
for (BinMap::iterator itBegin = m_mBinDates.begin(); itBegin != m_mBinDates.end(); ++itBegin)
|
||||
if (nullptr != itBegin->second)
|
||||
delete itBegin->second;
|
||||
}
|
||||
|
||||
bool CHWPMLFile::Open()
|
||||
{
|
||||
if (m_wsFilePath.empty() || !NSFile::CFileBinary::Exists(m_wsFilePath) || !Detect())
|
||||
return false;
|
||||
|
||||
CXMLReader oReader;
|
||||
|
||||
oReader.GetReader()->FromFile(m_wsFilePath);
|
||||
oReader.ReadNextNode();
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if ("HEAD" == sNodeName)
|
||||
ReadHead(oReader);
|
||||
else if ("BODY" == sNodeName)
|
||||
ReadBody(oReader);
|
||||
else if ("TAIL" == sNodeName)
|
||||
ReadTail(oReader);
|
||||
}
|
||||
END_WHILE
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHWPMLFile::Detect() const
|
||||
{
|
||||
if (m_wsFilePath.empty())
|
||||
return false;
|
||||
|
||||
CXMLReader oReader;
|
||||
|
||||
if (nullptr == oReader.GetReader() || !oReader.GetReader()->FromFile(m_wsFilePath))
|
||||
return false;
|
||||
|
||||
if (!oReader.ReadNextNode() && "HWPML" != oReader.GetName())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CHWPMLFile::Close()
|
||||
{}
|
||||
|
||||
const CHWPDocInfo* CHWPMLFile::GetDocInfo() const
|
||||
{
|
||||
return &m_oDocInfo;
|
||||
}
|
||||
|
||||
void CHWPMLFile::ReadHead(CXMLReader &oReader)
|
||||
{
|
||||
m_oDocInfo.ParseHWPML(oReader);
|
||||
}
|
||||
|
||||
void CHWPMLFile::ReadBody(CXMLReader &oReader)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "SECTION")
|
||||
ReadSection(oReader);
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
void CHWPMLFile::ReadTail(CXMLReader &oReader)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "BINDATASTORAGE")
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_AND_NAME(oReader, Item)
|
||||
{
|
||||
if ("BINDATA" == sNodeItemName)
|
||||
ReadBinData(oReader);
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
void CHWPMLFile::ReadSection(CXMLReader &oReader)
|
||||
{
|
||||
CHWPSection* pSection = new CHWPSection();
|
||||
|
||||
if (pSection->Parse(oReader, EHanType::HWPML))
|
||||
m_arSections.push_back(pSection);
|
||||
else
|
||||
delete pSection;
|
||||
}
|
||||
|
||||
void CHWPMLFile::ReadBinData(CXMLReader &oReader)
|
||||
{
|
||||
size_t unSize = 0;
|
||||
std::string sEncoding;
|
||||
HWP_STRING sId;
|
||||
bool bCompress = true;
|
||||
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("Size" == sAttributeName)
|
||||
unSize = oReader.GetInt();
|
||||
else if ("Encoding" == sAttributeName)
|
||||
sEncoding = oReader.GetTextA();
|
||||
else if ("Id" == sAttributeName)
|
||||
sId = oReader.GetText();
|
||||
else if ("Compress" == sAttributeName)
|
||||
bCompress = oReader.GetBool();
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
|
||||
if (sId.empty())
|
||||
return;
|
||||
|
||||
const std::wstring wsImageData{oReader.GetText()};
|
||||
|
||||
int nImageSize = NSBase64::Base64DecodeGetRequiredLength(wsImageData.length());
|
||||
|
||||
BYTE* pBuffer = new(std::nothrow) BYTE[nImageSize];
|
||||
|
||||
if (nullptr == pBuffer)
|
||||
return;
|
||||
|
||||
if (FALSE == NSBase64::Base64Decode(wsImageData.c_str(), wsImageData.length(), pBuffer, &nImageSize))
|
||||
{
|
||||
delete[] pBuffer;
|
||||
return;
|
||||
}
|
||||
|
||||
BinMap::iterator itFound = m_mBinDates.find(sId);
|
||||
|
||||
if (m_mBinDates.end() != itFound)
|
||||
{
|
||||
((CHWPStream*)itFound->second)->Clear();
|
||||
((CHWPStream*)itFound->second)->SetStream((HWP_BYTE*)pBuffer, nImageSize, false);
|
||||
}
|
||||
else
|
||||
m_mBinDates.insert(std::make_pair(sId, new CHWPStream((HWP_BYTE*)pBuffer, nImageSize, false)));
|
||||
}
|
||||
|
||||
VECTOR<const CHWPSection*> CHWPMLFile::GetSections() const
|
||||
{
|
||||
RETURN_VECTOR_CONST_PTR(CHWPSection, m_arSections);
|
||||
}
|
||||
|
||||
bool CHWPMLFile::GetBinData(const HWP_STRING &sId, CHWPStream &oBuffer) const
|
||||
{
|
||||
BinMap::const_iterator itFound = m_mBinDates.find(sId);
|
||||
|
||||
if (m_mBinDates.cend() == itFound || nullptr == itFound->second)
|
||||
return false;
|
||||
|
||||
oBuffer.SetStream(((CHWPStream*)(itFound->second))->GetCurPtr(), ((CHWPStream*)(itFound->second))->SizeToEnd());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
#ifndef CHWPMLFILE_H
|
||||
#define CHWPMLFILE_H
|
||||
|
||||
#include "Common/XMLReader.h"
|
||||
#include "HWPSection.h"
|
||||
|
||||
namespace HWP
|
||||
{
|
||||
class CHWPMLFile
|
||||
{
|
||||
using BinMap = std::map <HWP_STRING, CHWPStream*>;
|
||||
|
||||
HWP_STRING m_wsFilePath;
|
||||
CHWPDocInfo m_oDocInfo;
|
||||
VECTOR<CHWPSection*> m_arSections;
|
||||
BinMap m_mBinDates;
|
||||
|
||||
void ReadHead(CXMLReader& oReader);
|
||||
void ReadBody(CXMLReader& oReader);
|
||||
void ReadTail(CXMLReader& oReader);
|
||||
|
||||
void ReadSection(CXMLReader& oReader);
|
||||
void ReadBinData(CXMLReader& oReader);
|
||||
public:
|
||||
CHWPMLFile(const HWP_STRING& wsFilePath);
|
||||
~CHWPMLFile();
|
||||
|
||||
bool Open();
|
||||
bool Detect() const;
|
||||
void Close();
|
||||
|
||||
const CHWPDocInfo* GetDocInfo() const;
|
||||
VECTOR<const CHWPSection*> GetSections() const;
|
||||
bool GetBinData(const HWP_STRING& sId, CHWPStream& oBuffer) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CHWPMLFILE_H
|
||||
@ -1,6 +1,6 @@
|
||||
#include "HWPSection.h"
|
||||
|
||||
#include "Common/NodeNames.h"
|
||||
#include "HWPElements/HWPTag.h"
|
||||
|
||||
#include "HwpDoc/Paragraph/CtrlEqEdit.h"
|
||||
#include "Paragraph/CtrlTable.h"
|
||||
@ -111,10 +111,10 @@ CHWPSection::~CHWPSection()
|
||||
CLEAR_ARRAY(CHWPPargraph, m_arParas);
|
||||
}
|
||||
|
||||
bool CHWPSection::Parse(CXMLReader& oReader, EHanType eType)
|
||||
bool CHWPSection::Parse(CXMLReader& oReader, int nVersion)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, GetNodeName(ENode::Paragraph, eType))
|
||||
m_arParas.push_back(new CHWPPargraph(oReader, eType));
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "hp:p")
|
||||
m_arParas.push_back(new CHWPPargraph(oReader, nVersion));
|
||||
END_WHILE
|
||||
|
||||
return true;
|
||||
|
||||
@ -15,8 +15,8 @@ class CHWPSection
|
||||
public:
|
||||
CHWPSection();
|
||||
~CHWPSection();
|
||||
|
||||
bool Parse(CXMLReader& oReader, EHanType eType);
|
||||
|
||||
bool Parse(CXMLReader& oReader, int nVersion);
|
||||
bool Parse(CHWPStream& oBuffer, int nVersion);
|
||||
int ParseRecurse(CHWPPargraph* oCurrPara, int nRunLevel, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
int ParseCtrlRecurse(CCtrl* oCurrCtrl, int nRunLevel, CHWPStream& oBuffer, int nOff, int nVersion);
|
||||
|
||||
@ -55,11 +55,6 @@ HWP_BYTE* CHWPStream::GetCurPtr()
|
||||
return m_pCur;
|
||||
}
|
||||
|
||||
const HWP_BYTE *CHWPStream::GetCurPtr() const
|
||||
{
|
||||
return m_pCur;
|
||||
}
|
||||
|
||||
unsigned long CHWPStream::Tell() const
|
||||
{
|
||||
return (!IsValid()) ? 0 : m_pCur - m_pBegin;
|
||||
|
||||
@ -33,7 +33,6 @@ public:
|
||||
void SetStream(HWP_BYTE* pBuffer, unsigned long ulSize, bool bExternalBuffer = true);
|
||||
|
||||
HWP_BYTE* GetCurPtr();
|
||||
const HWP_BYTE* GetCurPtr() const;
|
||||
unsigned long Tell() const;
|
||||
unsigned long SizeToEnd() const;
|
||||
|
||||
|
||||
@ -34,11 +34,21 @@ bool CHWPXFile::Detect()
|
||||
|
||||
bool CHWPXFile::Open()
|
||||
{
|
||||
if (!NSFile::CFileBinary::Exists(m_sFileName) || !Detect() || !ReadDocInfo())
|
||||
if (!NSFile::CFileBinary::Exists(m_sFileName))
|
||||
return false;
|
||||
|
||||
for (const std::wstring& wsPath : GetPathsToSections())
|
||||
ReadSection(wsPath);
|
||||
if (m_oFileHeader.VersionEmpty() && !Detect())
|
||||
return false;
|
||||
|
||||
m_nVersion = std::stoi(m_oFileHeader.GetVersion());
|
||||
|
||||
if (!GetDocInfo(m_nVersion))
|
||||
return false;
|
||||
|
||||
std::vector<std::wstring> arPathToSections{GetPathsToSections()};
|
||||
|
||||
for (const std::wstring& wsPath : arPathToSections)
|
||||
ReadSection(wsPath, m_nVersion);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -138,27 +148,27 @@ bool CHWPXFile::GetChildStream(const HWP_STRING& sFileName, CHWPStream& oBuffer)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CHWPXFile::ReadDocInfo()
|
||||
bool CHWPXFile::GetDocInfo(int nVersion)
|
||||
{
|
||||
CXMLReader oContentReader;
|
||||
|
||||
if (!GetDocument(L"Contents/content.hpf", oContentReader))
|
||||
return false;
|
||||
|
||||
if (m_oDocInfo.ReadContentHpf(oContentReader))
|
||||
if (m_oDocInfo.ReadContentHpf(oContentReader, nVersion))
|
||||
{
|
||||
CXMLReader oHeaderReader;
|
||||
|
||||
if (!GetDocument(L"Contents/header.xml", oHeaderReader))
|
||||
return false;
|
||||
|
||||
return m_oDocInfo.ParseHWPX(oHeaderReader);
|
||||
return m_oDocInfo.Parse(oHeaderReader, nVersion);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CHWPXFile::ReadSection(const HWP_STRING& sName)
|
||||
bool CHWPXFile::ReadSection(const HWP_STRING& sName, int nVersion)
|
||||
{
|
||||
CXMLReader oReader;
|
||||
|
||||
@ -166,7 +176,7 @@ bool CHWPXFile::ReadSection(const HWP_STRING& sName)
|
||||
return false;
|
||||
|
||||
CHWPSection* pSection = new CHWPSection();
|
||||
const bool bResult = pSection->Parse(oReader, EHanType::HWPX);
|
||||
const bool bResult = pSection->Parse(oReader, nVersion);
|
||||
|
||||
if (bResult)
|
||||
m_arSections.push_back(pSection);
|
||||
|
||||
@ -13,6 +13,7 @@ class CHWPXFile
|
||||
HWP_STRING m_sFileName;
|
||||
CZipFolderMemory *m_pZipFolder;
|
||||
CHwpFileHeader m_oFileHeader;
|
||||
int m_nVersion;
|
||||
CHWPDocInfo m_oDocInfo;
|
||||
VECTOR<CHWPSection*> m_arSections;
|
||||
public:
|
||||
@ -29,8 +30,8 @@ public:
|
||||
private:
|
||||
VECTOR<HWP_STRING> GetPathsToSections() const;
|
||||
bool GetFileHeader();
|
||||
bool ReadDocInfo();
|
||||
bool ReadSection(const HWP_STRING& sName);
|
||||
bool GetDocInfo(int nVersion);
|
||||
bool ReadSection(const HWP_STRING& sName, int nVersion);
|
||||
bool GetDocument(const HWP_STRING& sEntryName, CXMLReader& oReader);
|
||||
};
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ enum class EHanType
|
||||
{
|
||||
NONE,
|
||||
HWP,
|
||||
HWPML,
|
||||
HWPX
|
||||
};
|
||||
}
|
||||
|
||||
@ -6,8 +6,8 @@ CCapParagraph::CCapParagraph()
|
||||
: CHWPPargraph()
|
||||
{}
|
||||
|
||||
CCapParagraph::CCapParagraph(CXMLReader& oReader, EHanType eType)
|
||||
: CHWPPargraph(oReader, eType)
|
||||
CCapParagraph::CCapParagraph(CXMLReader& oReader, int nVersion)
|
||||
: CHWPPargraph(oReader, nVersion)
|
||||
{}
|
||||
|
||||
EParagraphType CCapParagraph::GetType() const
|
||||
|
||||
@ -9,7 +9,7 @@ class CCapParagraph : public CHWPPargraph
|
||||
{
|
||||
public:
|
||||
CCapParagraph();
|
||||
CCapParagraph(CXMLReader& oReader, EHanType eType);
|
||||
CCapParagraph(CXMLReader& oReader, int nVersion);
|
||||
|
||||
EParagraphType GetType() const override;
|
||||
};
|
||||
|
||||
@ -4,10 +4,11 @@ namespace HWP
|
||||
{
|
||||
CCellParagraph::CCellParagraph()
|
||||
: CHWPPargraph()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
CCellParagraph::CCellParagraph(CXMLReader& oReader, EHanType eType)
|
||||
: CHWPPargraph(oReader, eType)
|
||||
CCellParagraph::CCellParagraph(CXMLReader& oReader, int nVersion)
|
||||
: CHWPPargraph(oReader, nVersion)
|
||||
{}
|
||||
|
||||
EParagraphType CCellParagraph::GetType() const
|
||||
|
||||
@ -9,7 +9,7 @@ class CCellParagraph : public CHWPPargraph
|
||||
{
|
||||
public:
|
||||
CCellParagraph();
|
||||
CCellParagraph(CXMLReader& oReader, EHanType eType);
|
||||
CCellParagraph(CXMLReader& oReader, int nVersion);
|
||||
|
||||
EParagraphType GetType() const override;
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user