Compare commits

..

2 Commits

Author SHA1 Message Date
c9100737e0 fix prev 2025-12-17 14:38:52 +03:00
bcdcfa8bf7 fix bug #74265 2025-12-08 16:36:25 +03:00
686 changed files with 3849 additions and 17522 deletions

View File

@ -3,8 +3,6 @@ DEPENDPATH += $$PWD
CORE_ROOT_DIR = $$PWD/../../../..
include($$CORE_ROOT_DIR/Common/3dParty/boost/boost.pri)
css_calculator_without_xhtml {
HEADERS += \
$$PWD/src/CCssCalculator_Private.h \

File diff suppressed because it is too large Load Diff

View File

@ -4,14 +4,11 @@
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include "../../../../DesktopEditor/graphics/Matrix.h"
#include "CUnitMeasureConverter.h"
#include <boost/optional.hpp>
#include "boost/blank.hpp"
#include <boost/variant2/variant.hpp>
namespace NSCSS
{
namespace NSProperties
@ -19,34 +16,33 @@ namespace NSCSS
#define NEXT_LEVEL UINT_MAX, true
template<typename T>
class CValueBase
class CValue
{
protected:
CValueBase()
: m_unLevel(0), m_bImportant(false)
{}
CValueBase(const CValueBase& oValue)
: m_oValue(oValue.m_oValue), m_unLevel(oValue.m_unLevel), m_bImportant(oValue.m_bImportant)
{}
CValueBase(const T& oValue, unsigned int unLevel, bool bImportant)
: m_oValue(oValue), m_unLevel(unLevel), m_bImportant(bImportant)
{}
friend class CString;
friend class CMatrix;
friend class CDigit;
friend class CColor;
friend class CEnum;
friend class CURL;
T m_oValue;
unsigned int m_unLevel;
bool m_bImportant;
public:
virtual bool Empty() const = 0;
virtual void Clear() = 0;
CValue(const T& oValue, unsigned int unLevel, bool bImportant) :
m_oValue(oValue), m_unLevel(unLevel), m_bImportant(bImportant)
{
}
virtual bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) = 0;
virtual bool Empty() const = 0;
virtual void Clear() = 0;
virtual int ToInt() const = 0;
virtual double ToDouble() const = 0;
virtual std::wstring ToWString() const = 0;
static void Equation(CValueBase &oFirstValue, CValueBase &oSecondValue)
static void Equation(CValue &oFirstValue, CValue &oSecondValue)
{
if (oFirstValue.m_bImportant && !oSecondValue.m_bImportant && oFirstValue.Empty())
oSecondValue.Clear();
@ -61,39 +57,18 @@ namespace NSCSS
}
}
static bool LevelIsSame(const CValueBase& oFirstValue, const CValueBase& oSecondValue)
static bool LevelIsSame(const CValue& oFirstValue, const CValue& oSecondValue)
{
return oFirstValue.m_unLevel == oSecondValue.m_unLevel;
}
friend bool operator==(const CValueBase& oLeftValue, const CValueBase& oRightValue)
{
if (oLeftValue.Empty() && oRightValue.Empty())
return true;
bool operator==(const T& oValue) const { return m_oValue == oValue; }
bool operator>=(const T& oValue) const { return m_oValue >= oValue; }
bool operator<=(const T& oValue) const { return m_oValue <= oValue; }
bool operator> (const T& oValue) const { return m_oValue > oValue; }
bool operator< (const T& oValue) const { return m_oValue < oValue; }
if (( oLeftValue.Empty() && !oRightValue.Empty()) ||
(!oLeftValue.Empty() && oRightValue.Empty()))
return false;
return oLeftValue.m_oValue == oRightValue.m_oValue;
}
friend bool operator!=(const CValueBase& oLeftValue, const CValueBase& oRightValue)
{
return !(oLeftValue == oRightValue);
}
bool operator==(const T& oValue) const
{
return m_oValue == oValue;
}
bool operator!=(const T& oValue) const
{
return m_oValue != oValue;
}
virtual CValueBase& operator =(const CValueBase& oValue)
virtual CValue& operator =(const CValue& oValue)
{
m_oValue = oValue.m_oValue;
m_unLevel = oValue.m_unLevel;
@ -102,93 +77,70 @@ namespace NSCSS
return *this;
}
virtual CValueBase& operator =(const T& oValue)
virtual CValue& operator =(const T& oValue)
{
m_oValue = oValue;
//m_oValue = oValue.m_oValue;
return *this;
}
virtual CValueBase& operator+=(const CValueBase& oValue)
virtual CValue& operator+=(const CValue& oValue)
{
if (m_unLevel > oValue.m_unLevel || (m_bImportant && !oValue.m_bImportant) || oValue.Empty())
return *this;
*this = oValue;
m_oValue = oValue.m_oValue;
m_unLevel = oValue.m_unLevel;
m_bImportant = oValue.m_bImportant;
return *this;
}
};
template<typename T>
class CValueOptional : public CValueBase<boost::optional<T>>
{
protected:
CValueOptional() = default;
CValueOptional(const T& oValue, unsigned int unLevel = 0, bool bImportant = false)
: CValueBase<boost::optional<T>>(oValue, unLevel, bImportant)
{}
public:
virtual bool Empty() const override
virtual bool operator==(const CValue& oValue) const
{
return !this->m_oValue.has_value();
}
void Clear() override
{
this->m_oValue.reset();
this->m_unLevel = 0;
this->m_bImportant = false;
return m_oValue == oValue.m_oValue;
}
bool operator==(const T& oValue) const
virtual bool operator!=(const CValue& oValue) const
{
if (!this->m_oValue.has_value())
return false;
return this->m_oValue.value() == oValue;
}
virtual CValueOptional& operator=(const T& oValue)
{
this->m_oValue = oValue;
return *this;
return m_oValue != oValue.m_oValue;
}
};
class CString : public CValueOptional<std::wstring>
class CString : public CValue<std::wstring>
{
public:
CString() = default;
CString(const std::wstring& wsValue, unsigned int unLevel = 0, bool bImportant = false);
CString();
CString(const std::wstring& wsValue, unsigned int unLevel, bool bImportant = false);
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) override;
bool SetValue(const std::wstring& wsValue, const std::vector<std::wstring>& arValiableValues, unsigned int unLevel, bool bHardMode);
bool SetValue(const std::wstring& wsValue, const std::map<std::wstring, std::wstring>& arValiableValues, unsigned int unLevel, bool bHardMode);
bool Empty() const override;
void Clear() override;
int ToInt() const override;
double ToDouble() const override;
std::wstring ToWString() const override;
bool operator==(const wchar_t* pValue) const;
bool operator!=(const wchar_t* pValue) const;
using CValueOptional<std::wstring>::operator=;
CString& operator+=(const CString& oString);
};
class CDigit : public CValueOptional<double>
class CDigit : public CValue<double>
{
UnitMeasure m_enUnitMeasure;
double ConvertValue(double dPrevValue, UnitMeasure enUnitMeasure) const;
public:
CDigit();
CDigit(const double& dValue, unsigned int unLevel = 0, bool bImportant = false);
CDigit(double dValue);
CDigit(double dValue, unsigned int unLevel, bool bImportant = false);
bool SetValue(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true) override;
bool SetValue(const CDigit& oValue);
bool SetValue(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel = 0, bool bHardMode = true);
bool Empty() const override;
bool Zero() const;
void Clear() override;
@ -204,7 +156,7 @@ namespace NSCSS
UnitMeasure GetUnitMeasure() const;
bool operator==(const double& dValue) const;
bool operator==(const double& oValue) const;
bool operator==(const CDigit& oDigit) const;
bool operator!=(const double& oValue) const;
@ -219,19 +171,11 @@ namespace NSCSS
CDigit& operator+=(const CDigit& oDigit);
CDigit& operator-=(const CDigit& oDigit);
CDigit& operator+=(const double& dValue);
CDigit& operator-=(const double& dValue);
CDigit& operator*=(const double& dValue);
CDigit& operator/=(const double& dValue);
using CValueOptional<double>::operator=;
private:
UnitMeasure m_enUnitMeasure;
double ConvertValue(double dPrevValue, UnitMeasure enUnitMeasure) const;
template <typename Operation>
CDigit ApplyOperation(const CDigit& oDigit, Operation operation) const;
CDigit& operator+=(double dValue);
CDigit& operator-=(double dValue);
CDigit& operator*=(double dValue);
CDigit& operator/=(double dValue);
CDigit& operator =(double dValue);
};
struct TRGB
@ -242,8 +186,6 @@ namespace NSCSS
bool Empty() const;
int ToInt() const;
bool operator==(const TRGB& oRGB) const;
bool operator!=(const TRGB& oRGB) const;
};
@ -269,58 +211,31 @@ namespace NSCSS
typedef enum
{
ColorEmpty,
ColorNone,
ColorRGB,
ColorHEX,
ColorUrl,
ColorContextStroke,
ColorContextFill
} EColorType;
} ColorType;
class CColorValue
{
using color_value = boost::variant2::variant<boost::blank, std::wstring, TRGB, CURL>;
protected:
EColorType m_eType;
public:
CColorValue();
CColorValue(const CColorValue& oValue);
CColorValue(const std::wstring& wsValue);
CColorValue(const TRGB& oValue);
CColorValue(const CURL& oValue);
EColorType GetType() const;
bool operator==(const CColorValue& oValue) const;
color_value m_oValue;
};
class CColorValueContextStroke : public CColorValue
{
public:
CColorValueContextStroke();
};
class CColorValueContextFill : public CColorValue
{
public:
CColorValueContextFill();
};
class CColor : public CValueOptional<CColorValue>
class CColor : public CValue<void*>
{
public:
CColor();
CColor(const CColor& oColor);
~CColor();
bool SetValue(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true) override;
bool SetOpacity(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true);
bool Empty() const override;
bool None() const;
bool Url() const;
void Clear() override;
EColorType GetType() const;
ColorType GetType() const;
double GetOpacity() const;
@ -334,15 +249,20 @@ namespace NSCSS
static TRGB ConvertHEXtoRGB(const std::wstring& wsValue);
static std::wstring ConvertRGBtoHEX(const TRGB& oValue);
using CValueOptional<CColorValue>::operator=;
bool operator==(const CColor& oColor) const;
bool operator!=(const CColor& oColor) const;
CColor& operator =(const CColor& oColor);
CColor& operator+=(const CColor& oColor);
private:
CDigit m_oOpacity;
CDigit m_oOpacity;
ColorType m_enType;
void SetEmpty(unsigned int unLevel = 0);
void SetRGB(unsigned char uchR, unsigned char uchG, unsigned char uchB);
void SetRGB(const TRGB& oRGB);
void SetHEX(const std::wstring& wsValue);
bool SetUrl(const std::wstring& wsValue);
void SetUrl(const std::wstring& wsValue);
void SetNone();
};
@ -359,7 +279,7 @@ namespace NSCSS
typedef std::vector<std::pair<std::vector<double>, TransformType>> MatrixValues;
class CMatrix : public CValueBase<MatrixValues>
class CMatrix : public CValue<MatrixValues>
{
std::vector<std::wstring> CutTransforms(const std::wstring& wsValue) const;
public:
@ -384,27 +304,29 @@ namespace NSCSS
bool operator==(const CMatrix& oMatrix) const;
CMatrix& operator+=(const CMatrix& oMatrix);
CMatrix& operator-=(const CMatrix& oMatrix);
using CValueBase<MatrixValues>::operator=;
};
class CEnum : public CValueOptional<int>
class CEnum : public CValue<int>
{
std::map<std::wstring, int> m_mMap;
public:
CEnum();
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) override;
void SetMapping(const std::map<std::wstring, int>& mMap, int nDefaulvalue = -1);
int ToInt() const override;
bool Empty() const override;
void Clear() override;
using CValueOptional<int>::operator=;
CEnum &operator =(int nValue);
bool operator==(int nValue) const;
bool operator!=(int nValue) const;
int ToInt() const override;
private:
double ToDouble() const override;
std::wstring ToWString() const override;
int m_nDefaultValue;
std::map<std::wstring, int> m_mMap;
};
// PROPERTIES
@ -697,30 +619,6 @@ namespace NSCSS
bool operator==(const TTextDecoration& oTextDecoration) const;
};
typedef enum
{
Baseline,
Sub,
Super,
Percentage,
Length
} EBaselineShift;
class CBaselineShift
{
CEnum m_eType;
CDigit m_oValue;
public:
CBaselineShift();
bool Empty() const;
EBaselineShift GetType() const;
double GetValue() const;
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
};
class CText
{
public:
@ -728,12 +626,11 @@ namespace NSCSS
static void Equation(CText &oFirstText, CText &oSecondText);
bool SetIndent (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetAlign (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetDecoration (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetHighlight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetBaselineShift (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetIndent (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetAlign (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetDecoration(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
bool SetHighlight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
const CDigit& GetIndent() const;
const CString& GetAlign() const;
@ -741,9 +638,6 @@ namespace NSCSS
const CColor& GetColor() const;
const CColor& GetHighlight() const;
EBaselineShift GetBaselineShiftType() const;
double GetBaselineShiftValue() const;
bool Empty() const;
bool Underline() const;
@ -753,7 +647,6 @@ namespace NSCSS
CText& operator+=(const CText& oText);
bool operator==(const CText& oText) const;
private:
CBaselineShift m_oBaselineShift;
TTextDecoration m_oDecoration;
CDigit m_oIndent;
CString m_oAlign;

View File

@ -5,7 +5,7 @@
namespace Md
{
#define MD_PARSER_FLAGS MD_DIALECT_GITHUB | MD_FLAG_NOINDENTEDCODEBLOCKS | MD_HTML_FLAG_SKIP_UTF8_BOM | MD_FLAG_HARD_SOFT_BREAKS | MD_HTML_FLAG_XHTML | MD_FLAG_LATEXMATHSPANS
#define MD_PARSER_FLAGS MD_DIALECT_GITHUB | MD_FLAG_NOINDENTEDCODEBLOCKS | MD_HTML_FLAG_SKIP_UTF8_BOM | MD_FLAG_HARD_SOFT_BREAKS | MD_HTML_FLAG_XHTML
#define MD_RENDERER_FLAGS MD_HTML_FLAG_XHTML
void ToHtml(const MD_CHAR* pValue, MD_SIZE uSize, void* pData)

View File

@ -90,7 +90,7 @@ static std::wstring convertUtf16ToWString(const UTF16 * Data, int nLength)
return std::wstring();
}
std::wstring wstr ((wchar_t *) pStrUtf32, nLength);
std::wstring wstr ((wchar_t *) pStrUtf32);
delete [] pStrUtf32;
return wstr;

View File

@ -0,0 +1,5 @@
<<<<<<<
if((c >= 'a' && c <= 'z') || (c>= 'A' && c<= 'Z') || (c >= '0' && c<= '9')){
=======
if((c >= 'a' && c <= 'z') || (c>= 'A' && c<= 'Z') || (c >= '0' && c<= '9') || ('-' == c) || ('_' == c) || ('.' == c) || ('~' == c)){
>>>>>>>

View File

@ -74,7 +74,6 @@ public:
bool isDocFormatFile(const std::wstring& fileName);
bool isXlsFormatFile(const std::wstring& fileName);
bool isCompoundFile (POLE::Storage* storage);
bool isOleObjectFile(POLE::Storage* storage);
bool isDocFormatFile(POLE::Storage* storage);
bool isXlsFormatFile(POLE::Storage* storage);

View File

@ -552,15 +552,6 @@ bool COfficeFileFormatChecker::isPptFormatFile(POLE::Storage *storage)
return true;
}
bool COfficeFileFormatChecker::isCompoundFile(POLE::Storage* storage)
{
if (storage == NULL) return false;
if (storage->GetAllStreams(L"/").size() == 1) return true;
return false;
}
std::wstring COfficeFileFormatChecker::getDocumentID(const std::wstring &_fileName)
{
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
@ -758,11 +749,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_VBAPROJECT;
return true;
}
else if (isCompoundFile(&storage))
{
nFileType = AVS_OFFICESTUDIO_FILE_OTHER_COMPOUND;
return true;
}
else if (isHwpFile(&storage))
{
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
@ -967,7 +953,7 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT;
else if (0 == sExt.compare(L".md"))
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MD;
else if (0 == sExt.compare(L".csv") || 0 == sExt.compare(L".tsv") || 0 == sExt.compare(L".xls") || 0 == sExt.compare(L".xlsx") || 0 == sExt.compare(L".xlsb"))
else if (0 == sExt.compare(L".csv") || 0 == sExt.compare(L".xls") || 0 == sExt.compare(L".xlsx") || 0 == sExt.compare(L".xlsb"))
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
else if (0 == sExt.compare(L".html") || 0 == sExt.compare(L".htm"))
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML;

View File

@ -136,7 +136,6 @@
#define AVS_OFFICESTUDIO_FILE_OTHER_MS_MITCRYPTO AVS_OFFICESTUDIO_FILE_OTHER + 0x000b
#define AVS_OFFICESTUDIO_FILE_OTHER_MS_VBAPROJECT AVS_OFFICESTUDIO_FILE_OTHER + 0x000c
#define AVS_OFFICESTUDIO_FILE_OTHER_PACKAGE_IN_OLE AVS_OFFICESTUDIO_FILE_OTHER + 0x000d
#define AVS_OFFICESTUDIO_FILE_OTHER_COMPOUND AVS_OFFICESTUDIO_FILE_OTHER + 0x000e
#define AVS_OFFICESTUDIO_FILE_TEAMLAB 0x1000
#define AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0001

View File

@ -33,7 +33,8 @@ OO_BUILD_BRANDING = $$(OO_BRANDING)
OO_DESTDIR_BUILD_OVERRIDE = $$(DESTDIR_BUILD_OVERRIDE)
win32 {
CURRENT_YEAR = $$system(powershell -NoLogo -NoProfile -Command "(Get-Date).Year")
CURRENT_YEAR = $$system(wmic PATH Win32_LocalTime GET ^Year /FORMAT:VALUE | find \"=\")
CURRENT_YEAR = $$replace(CURRENT_YEAR, "Year=", "")
CURRENT_YEAR = $$replace(CURRENT_YEAR, "\r", "")
CURRENT_YEAR = $$replace(CURRENT_YEAR, "\n", "")
CURRENT_YEAR = $$replace(CURRENT_YEAR, "\t", "")

View File

@ -60,7 +60,6 @@ namespace NSSystemUtils
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_EnvSigningKeystorePassphrase = L"SIGNING_KEYSTORE_PASSPHRASE";
KERNEL_DECL std::string GetEnvVariableA(const std::wstring& strName);
KERNEL_DECL std::wstring GetEnvVariable(const std::wstring& strName);

View File

@ -245,18 +245,7 @@ public:
return 0;
}
bool CheckOwnerPassword(const std::wstring& sPassword)
{
if (m_nType == 0)
return ((CPdfFile*)m_pFile)->CheckOwnerPassword(sPassword);
return true;
}
bool CheckPerm(int nPerm)
{
if (m_nType == 0)
return ((CPdfFile*)m_pFile)->CheckPerm(nPerm);
return true;
}
BYTE* GetInfo()
{
NSWasm::CData oRes;
@ -490,9 +479,6 @@ public:
return NULL;
}
if (m_nType == 0)
((CPdfFile*)m_pFile)->SetPageFonts(nPageIndex);
BYTE* res = oRes.GetBuffer();
oRes.ClearWithoutAttack();
return res;
@ -581,13 +567,6 @@ public:
}
return NULL;
}
BYTE* GetGIDByUnicode(const std::string& sPathA)
{
if (m_nType != 0)
return NULL;
std::wstring sFontName = UTF8_TO_U(sPathA);
return ((CPdfFile*)m_pFile)->GetGIDByUnicode(sFontName);
}
std::wstring GetFontBinaryNative(const std::wstring& sName)
{

View File

@ -194,9 +194,6 @@ JSSmart<CJSValue> CNativeControlEmbed::ZipOpenBase64(JSSmart<CJSValue> name)
JSSmart<CJSValue> CNativeControlEmbed::ZipFileAsString(JSSmart<CJSValue> name)
{
if (m_pInternal->m_oZipWorker.m_sTmpFolder.empty())
return CJSContext::createUndefined();
BYTE* pData = NULL;
DWORD len = 0;
m_pInternal->m_oZipWorker.GetFileData(name->toStringW(), pData, len);
@ -205,9 +202,6 @@ JSSmart<CJSValue> CNativeControlEmbed::ZipFileAsString(JSSmart<CJSValue> name)
JSSmart<CJSValue> CNativeControlEmbed::ZipFileAsBinary(JSSmart<CJSValue> name)
{
if (m_pInternal->m_oZipWorker.m_sTmpFolder.empty())
return CJSContext::createUndefined();
return CJSContext::createUint8Array(m_pInternal->m_oZipWorker.m_sTmpFolder + L"/" + name->toStringW());
}

View File

@ -30,8 +30,6 @@
-(JSValue*) SplitPages : (JSValue*)arrPageIndexes : (JSValue*)data;
-(JSValue*) MergePages : (JSValue*)data : (JSValue*)nMaxID : (JSValue*)sPrefixForm;
-(JSValue*) UnmergePages;
-(JSValue*) RedactPage : (JSValue*)nPageIndex : (JSValue*)arrRedactBox : (JSValue*)dataFiller;
-(JSValue*) UndoRedact;
@end
@interface CJSCDrawingFileEmbed : NSObject<IJSCDrawingFileEmbed, JSEmbedObjectProtocol>
@ -69,8 +67,6 @@ FUNCTION_WRAPPER_JS_1(FreeWasmData, FreeWasmData)
FUNCTION_WRAPPER_JS_2(SplitPages, SplitPages)
FUNCTION_WRAPPER_JS_3(MergePages, MergePages)
FUNCTION_WRAPPER_JS_0(UnmergePages, UnmergePages)
FUNCTION_WRAPPER_JS_3(RedactPage, RedactPage)
FUNCTION_WRAPPER_JS_0(UndoRedact, UndoRedact)
@end
class CDrawingFileEmbedAdapter : public CJSEmbedObjectAdapterJSC

View File

@ -67,7 +67,7 @@ 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, "RedactPage", _RedactPage);
NSV8Objects::Template_Set(result, "UndoRedact", _UndoRedact);
return handle_scope.Escape(result);

View File

@ -731,10 +731,10 @@ void CFontFile::CheckHintsSupport()
int CFontFile::SetCMapForCharCode(long lUnicode, int *pnCMapIndex)
{
*pnCMapIndex = -1;
if (!m_pFace || !m_pFace->num_charmaps)
if (!m_pFace)
return 0;
if ( m_bStringGID )
if ( m_bStringGID || 0 == m_pFace->num_charmaps )
return lUnicode;
int nCharIndex = 0;

View File

@ -117,7 +117,7 @@ WASM_EXPORT unsigned int ASC_FT_SetCMapForCharCode(FT_Face face, unsigned int un
return 0;
if ( 0 == face->num_charmaps )
return 0;
return unicode;
unsigned int nCharIndex = 0;

View File

@ -265,15 +265,15 @@
},
{
"folder": "../../",
"files": ["graphics/Image.cpp", "raster/BgraFrame.cpp", "raster/ImageFileFormatChecker.cpp", "graphics/Matrix.cpp", "graphics/GraphicsPath.cpp"]
"files": ["graphics/Image.cpp", "raster/BgraFrame.cpp", "raster/ImageFileFormatChecker.cpp", "graphics/Matrix.cpp"]
},
{
"folder": "../../agg-2.4/src/",
"files": ["agg_trans_affine.cpp", "agg_bezier_arc.cpp"]
"files": ["agg_trans_affine.cpp"]
},
{
"folder": "../../raster/",
"files": ["PICT/PICFile.cpp"]
"files": ["PICT/PICFile.cpp", "PICT/pic.cpp"]
},
{
"folder": "../../graphics/pro/js/qt/raster",

View File

@ -737,13 +737,11 @@ CBooleanOperations::CBooleanOperations(const CGraphicsPath& path1,
const CGraphicsPath& path2,
BooleanOpType op,
long fillType,
bool isLuminosity,
bool isSelf) :
bool isLuminosity) :
Op(op),
Close1(path1.Is_poly_closed()),
Close2(path2.Is_poly_closed()),
IsLuminosity(isLuminosity),
IsSelf(isSelf),
FillType(fillType),
Path1(path1),
Path2(path2)
@ -786,9 +784,10 @@ bool CBooleanOperations::IsSelfInters(const CGraphicsPath& p)
void CBooleanOperations::TraceBoolean()
{
bool reverse = false;
bool self = Path1 == Path2;
if (((Op == Subtraction || Op == Exclusion) ^
Path1.IsClockwise() ^
Path2.IsClockwise()) && !IsSelf)
Path2.IsClockwise()) && !self)
reverse = true;
PreparePath(Path1, 1, Segments1, Curves1);
@ -799,7 +798,7 @@ void CBooleanOperations::TraceBoolean()
GetIntersection();
if (IsSelf)
if (self)
{
if (Op == Subtraction)
return;
@ -824,11 +823,6 @@ void CBooleanOperations::TraceBoolean()
CreateNewPath(adj_matr);
return;
}
else if (Path1 == Path2)
{
Result = std::move(Path1);
return;
}
if (!Locations.empty())
{
@ -2361,7 +2355,7 @@ CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
CBooleanOperations o;
if (i > skip_end2 && o.IsSelfInters(paths2[i]))
{
CBooleanOperations operation(paths2[i], paths2[i], Intersection, fillType, isLuminosity, true);
CBooleanOperations operation(paths2[i], paths2[i], Intersection, fillType, isLuminosity);
CGraphicsPath p = std::move(operation.GetResult());
std::vector<CGraphicsPath> tmp_paths = p.GetSubPaths();
@ -2376,7 +2370,7 @@ CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
CBooleanOperations o2;
if (j > skip_end1 && o2.IsSelfInters(paths1[j]))
{
CBooleanOperations operation(paths1[j], paths1[j], Intersection, fillType, isLuminosity, true);
CBooleanOperations operation(paths1[j], paths1[j], Intersection, fillType, isLuminosity);
CGraphicsPath p = std::move(operation.GetResult());
std::vector<CGraphicsPath> tmp_paths = p.GetSubPaths();
@ -2386,7 +2380,7 @@ CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
paths1.insert(paths1.begin() + i + k, tmp_paths[k]);
}
CBooleanOperations operation(paths1[j], paths2[i], op, fillType, isLuminosity, false);
CBooleanOperations operation(paths1[j], paths2[i], op, fillType, isLuminosity);
paths.push_back(operation.GetResult());
}

View File

@ -108,7 +108,7 @@ namespace Aggplus
{
public:
CBooleanOperations() {};
CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType, bool isLuminosity, bool isSelf);
CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType, bool isLuminosity);
~CBooleanOperations();
CGraphicsPath&& GetResult();
bool IsSelfInters(const CGraphicsPath& p);
@ -166,7 +166,6 @@ namespace Aggplus
bool Close1 = true;
bool Close2 = true;
bool IsLuminosity = false;
bool IsSelf = false;
// c_nStroke, c_nWindingFillMode, c_nEvenOddFillMode
long FillType = c_nWindingFillMode;

View File

@ -2142,12 +2142,7 @@ namespace Aggplus
agg::trans_affine* full_trans = &m_oFullTransform.m_internal->m_agg_mtx;
double dDet = full_trans->determinant();
double sx = sqrt(full_trans->sx * full_trans->sx + full_trans->shx * full_trans->shx);
double sy = sqrt(full_trans->shy * full_trans->shy + full_trans->sy * full_trans->sy);
double scale = std::max(sx, sy);
double adaptive_threshold = 1.0 / (scale * scale * 10000.0);
if (fabs(dDet) < std::max(0.0001, adaptive_threshold))
if (fabs(dDet) < 0.0001)
{
path_copy.transform_all_paths(m_oFullTransform.m_internal->m_agg_mtx);
dWidth *= sqrt(fabs(dDet));
@ -2245,8 +2240,6 @@ namespace Aggplus
LONG lCount2 = lCount / 2;
double dKoef = 1.0;
if (bIsUseIdentity)
dKoef = sqrt(fabs(m_oFullTransform.m_internal->m_agg_mtx.determinant()));
for (LONG i = 0; i < lCount2; ++i)
{

View File

@ -886,17 +886,17 @@ namespace Aggplus
if (isCurve)
{
std::vector<PointD> points = GetPoints(idx, 4);
area = 3.0 * (points[3].Y - points[0].Y) * (points[1].X + points[2].X)
- (points[3].X - points[0].X) * (points[1].Y + points[2].Y)
+ points[1].Y * (points[0].X - points[2].X)
- points[1].X * (points[0].Y - points[2].Y)
+ points[3].Y * (points[2].X + points[0].X / 3.0)
- points[3].X * (points[2].Y + points[0].Y / 3.0) / 20.0;
area = (points[3].Y - points[0].Y) * (points[1].X + points[2].X)
- (points[3].X - points[0].X) * (points[1].Y + points[2].Y)
+ points[1].Y * (points[0].X - points[2].X)
- points[1].X * (points[0].Y - points[2].Y)
+ points[3].Y * (points[2].X + points[0].X / 3.0)
- points[3].X * (points[2].Y + points[0].Y / 3.0);
}
else
{
std::vector<PointD> points = GetPoints(idx, 2);
area = (points[1].Y * points[0].X - points[1].X * points[0].Y) / 2.0;
area = 4.0 * (points[1].Y * points[0].X - points[1].X * points[0].Y) / 3.0;
}
return area;

View File

@ -117,7 +117,6 @@ const long c_nDarkMode = 0x0008;
const long c_nUseDictionaryFonts = 0x0010;
const long c_nPenWidth0As1px = 0x0020;
const long c_nSupportPathTextAsText = 0x0040;
const long c_nFontSubstitution = 0x0080;
// типы рендерера
const long c_nUnknownRenderer = 0x0000;

View File

@ -46,92 +46,6 @@
// void Set(const std::wstring& ws) { m_ws = ws; }
// const std::wstring& Get() { return m_ws; }
CAnnotFieldInfo::CActionFieldPr* ReadAction(NSOnlineOfficeBinToPdf::CBufferReader* pReader)
{
CAnnotFieldInfo::CActionFieldPr* pRes = new CAnnotFieldInfo::CActionFieldPr();
pRes->nActionType = pReader->ReadByte();
switch (pRes->nActionType)
{
case 14: // JavaScript
{
pRes->wsStr1 = pReader->ReadString();
break;
}
case 1: // GoTo
{
pRes->nInt1 = pReader->ReadInt();
pRes->nKind = pReader->ReadByte();
switch (pRes->nKind)
{
case 0:
case 2:
case 3:
case 6:
case 7:
{
pRes->nFlags = pReader->ReadByte();
if (pRes->nFlags & (1 << 0))
pRes->dD[0] = pReader->ReadDouble();
if (pRes->nFlags & (1 << 1))
pRes->dD[1] = pReader->ReadDouble();
if (pRes->nFlags & (1 << 2))
pRes->dD[2] = pReader->ReadDouble();
break;
}
case 4:
{
pRes->dD[0] = pReader->ReadDouble();
pRes->dD[1] = pReader->ReadDouble();
pRes->dD[2] = pReader->ReadDouble();
pRes->dD[3] = pReader->ReadDouble();
break;
}
case 1:
case 5:
default:
{
break;
}
}
break;
}
case 10: // Named
{
pRes->wsStr1 = pReader->ReadString();
break;
}
case 6: // URI
{
pRes->wsStr1 = pReader->ReadString();
break;
}
case 9: // Hide
{
pRes->nKind = pReader->ReadByte();
int n = pReader->ReadInt();
pRes->arrStr.reserve(n);
for (int i = 0; i < n; ++i)
pRes->arrStr.push_back(pReader->ReadString());
break;
}
case 12: // ResetForm
{
pRes->nInt1 = pReader->ReadInt();
int n = pReader->ReadInt();
pRes->arrStr.reserve(n);
for (int i = 0; i < n; ++i)
pRes->arrStr.push_back(pReader->ReadString());
break;
}
}
if (pReader->ReadByte())
pRes->pNext = ReadAction(pReader);
return pRes;
}
CAnnotFieldInfo::CAnnotFieldInfo() : IAdvancedCommand(AdvancedCommandType::Annotaion)
{
m_nType = EAnnotType::Unknown;
@ -163,7 +77,6 @@ CAnnotFieldInfo::CAnnotFieldInfo() : IAdvancedCommand(AdvancedCommandType::Annot
m_pCaretPr = NULL;
m_pStampPr = NULL;
m_pRedactPr = NULL;
m_pLinkPr = NULL;
m_pWidgetPr = NULL;
}
CAnnotFieldInfo::~CAnnotFieldInfo()
@ -180,7 +93,6 @@ CAnnotFieldInfo::~CAnnotFieldInfo()
RELEASEOBJECT(m_pCaretPr);
RELEASEOBJECT(m_pStampPr);
RELEASEOBJECT(m_pRedactPr);
RELEASEOBJECT(m_pLinkPr);
RELEASEOBJECT(m_pWidgetPr);
}
@ -201,12 +113,6 @@ void CAnnotFieldInfo::SetType(int nType)
m_pTextPr = new CAnnotFieldInfo::CTextAnnotPr();
break;
}
case EAnnotType::Link:
{
RELEASEOBJECT(m_pLinkPr);
m_pLinkPr = new CAnnotFieldInfo::CLinkAnnotPr();
break;
}
case EAnnotType::FreeText:
{
CreateMarkup();
@ -399,10 +305,6 @@ bool CAnnotFieldInfo::IsRedact() const
{
return (m_nType == 25);
}
bool CAnnotFieldInfo::IsLink() const
{
return (m_nType == 1);
}
CAnnotFieldInfo::CMarkupAnnotPr* CAnnotFieldInfo::GetMarkupAnnotPr() { return m_pMarkupPr; }
CAnnotFieldInfo::CTextAnnotPr* CAnnotFieldInfo::GetTextAnnotPr() { return m_pTextPr; }
@ -416,7 +318,6 @@ CAnnotFieldInfo::CFreeTextAnnotPr* CAnnotFieldInfo::GetFreeTextAnnotPr()
CAnnotFieldInfo::CCaretAnnotPr* CAnnotFieldInfo::GetCaretAnnotPr() { return m_pCaretPr; }
CAnnotFieldInfo::CStampAnnotPr* CAnnotFieldInfo::GetStampAnnotPr() { return m_pStampPr; }
CAnnotFieldInfo::CRedactAnnotPr* CAnnotFieldInfo::GetRedactAnnotPr() { return m_pRedactPr; }
CAnnotFieldInfo::CLinkAnnotPr* CAnnotFieldInfo::GetLinkAnnotPr() { return m_pLinkPr; }
CAnnotFieldInfo::CWidgetAnnotPr* CAnnotFieldInfo::GetWidgetAnnotPr() { return m_pWidgetPr; }
bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
@ -511,8 +412,6 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
m_pPopupPr->Read(pReader);
else if (IsWidget())
m_pWidgetPr->Read(pReader, nType);
else if (IsLink())
m_pLinkPr->Read(pReader);
return m_nType != -1;
}
@ -822,45 +721,6 @@ void CAnnotFieldInfo::CRedactAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
}
}
CAnnotFieldInfo::CLinkAnnotPr::CLinkAnnotPr()
{
m_pAction = NULL;
m_pPA = NULL;
}
CAnnotFieldInfo::CLinkAnnotPr::~CLinkAnnotPr()
{
RELEASEOBJECT(m_pAction);
RELEASEOBJECT(m_pPA);
}
BYTE CAnnotFieldInfo::CLinkAnnotPr::GetH() const { return m_nH; }
int CAnnotFieldInfo::CLinkAnnotPr::GetFlags() const { return m_nFlags; }
const std::vector<double>& CAnnotFieldInfo::CLinkAnnotPr::GetQuadPoints() { return m_arrQuadPoints; }
CAnnotFieldInfo::CActionFieldPr* CAnnotFieldInfo::CLinkAnnotPr::GetA() { return m_pAction; }
CAnnotFieldInfo::CActionFieldPr* CAnnotFieldInfo::CLinkAnnotPr::GetPA() { return m_pPA; }
void CAnnotFieldInfo::CLinkAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader)
{
m_nFlags = pReader->ReadInt();
if (m_nFlags & (1 << 0))
{
pReader->ReadString();
m_pAction = ReadAction(pReader);
}
if (m_nFlags & (1 << 1))
{
pReader->ReadString();
m_pPA = ReadAction(pReader);
}
if (m_nFlags & (1 << 2))
m_nH = pReader->ReadByte();
if (m_nFlags & (1 << 3))
{
int n = pReader->ReadInt();
m_arrQuadPoints.reserve(n);
for (int i = 0; i < n; ++i)
m_arrQuadPoints.push_back(pReader->ReadDouble());
}
}
bool CAnnotFieldInfo::CPopupAnnotPr::IsOpen() const { return m_bOpen; }
int CAnnotFieldInfo::CPopupAnnotPr::GetFlag() const { return m_nFlag; }
int CAnnotFieldInfo::CPopupAnnotPr::GetParentID() const { return m_nParentID; }
@ -892,7 +752,7 @@ const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetFontKey() { return m_w
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetTC() { return m_arrTC; }
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetBC() { return m_arrBC; }
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetBG() { return m_arrBG; }
const std::vector<CAnnotFieldInfo::CActionFieldPr*>& CAnnotFieldInfo::CWidgetAnnotPr::GetActions() { return m_arrAction; }
const std::vector<CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget*>& CAnnotFieldInfo::CWidgetAnnotPr::GetActions() { return m_arrAction; }
CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr* CAnnotFieldInfo::CWidgetAnnotPr::GetButtonWidgetPr() { return m_pButtonPr; }
CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr* CAnnotFieldInfo::CWidgetAnnotPr::GetTextWidgetPr() { return m_pTextPr; }
CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr* CAnnotFieldInfo::CWidgetAnnotPr::GetChoiceWidgetPr() { return m_pChoicePr; }
@ -952,8 +812,93 @@ CAnnotFieldInfo::CWidgetAnnotPr::~CWidgetAnnotPr()
RELEASEOBJECT(m_arrAction[i]);
}
CAnnotFieldInfo::CActionFieldPr::CActionFieldPr() : pNext(NULL) {}
CAnnotFieldInfo::CActionFieldPr::~CActionFieldPr() { RELEASEOBJECT(pNext); }
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget::CActionWidget() : pNext(NULL) {}
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget::~CActionWidget() { RELEASEOBJECT(pNext); }
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* ReadAction(NSOnlineOfficeBinToPdf::CBufferReader* pReader)
{
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* pRes = new CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget();
pRes->nActionType = pReader->ReadByte();
switch (pRes->nActionType)
{
case 14: // JavaScript
{
pRes->wsStr1 = pReader->ReadString();
break;
}
case 1: // GoTo
{
pRes->nInt1 = pReader->ReadInt();
pRes->nKind = pReader->ReadByte();
switch (pRes->nKind)
{
case 0:
case 2:
case 3:
case 6:
case 7:
{
pRes->nFlags = pReader->ReadByte();
if (pRes->nFlags & (1 << 0))
pRes->dD[0] = pReader->ReadDouble();
if (pRes->nFlags & (1 << 1))
pRes->dD[1] = pReader->ReadDouble();
if (pRes->nFlags & (1 << 2))
pRes->dD[2] = pReader->ReadDouble();
break;
}
case 4:
{
pRes->dD[0] = pReader->ReadDouble();
pRes->dD[1] = pReader->ReadDouble();
pRes->dD[2] = pReader->ReadDouble();
pRes->dD[3] = pReader->ReadDouble();
break;
}
case 1:
case 5:
default:
{
break;
}
}
break;
}
case 10: // Named
{
pRes->wsStr1 = pReader->ReadString();
break;
}
case 6: // URI
{
pRes->wsStr1 = pReader->ReadString();
break;
}
case 9: // Hide
{
pRes->nKind = pReader->ReadByte();
int n = pReader->ReadInt();
pRes->arrStr.reserve(n);
for (int i = 0; i < n; ++i)
pRes->arrStr.push_back(pReader->ReadString());
break;
}
case 12: // ResetForm
{
pRes->nInt1 = pReader->ReadInt();
int n = pReader->ReadInt();
pRes->arrStr.reserve(n);
for (int i = 0; i < n; ++i)
pRes->arrStr.push_back(pReader->ReadString());
break;
}
}
if (pReader->ReadByte())
pRes->pNext = ReadAction(pReader);
return pRes;
}
void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, BYTE nType)
{
m_wsFN = pReader->ReadString();
@ -1012,7 +957,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
for (int i = 0; i < nAction; ++i)
{
std::wstring wsType = pReader->ReadString();
CAnnotFieldInfo::CActionFieldPr* pA = ReadAction(pReader);
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* pA = ReadAction(pReader);
if (pA)
{
pA->wsType = wsType;
@ -1042,7 +987,6 @@ const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr::GetCA() {
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr::GetRC() { return m_wsRC; }
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr::GetAC() { return m_wsAC; }
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr::GetAP_N_Yes() { return m_wsAP_N_Yes; }
const std::vector< std::pair<std::wstring, std::wstring> >& CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr::GetOpt() { return m_arrOpt; }
void CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, BYTE nType, int nFlags)
{
if (nType == 27)
@ -1083,17 +1027,6 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CButtonWidgetPr::Read(NSOnlineOfficeBinToP
if (nFlags & (1 << 9))
m_wsV = pReader->ReadString();
m_nStyle = pReader->ReadByte();
if (nFlags & (1 << 10))
{
int n = pReader->ReadInt();
m_arrOpt.reserve(n);
for (int i = 0; i < n; ++i)
{
std::wstring s1 = pReader->ReadString();
std::wstring s2 = pReader->ReadString();
m_arrOpt.push_back(std::make_pair(s1, s2));
}
}
if (nFlags & (1 << 14))
m_wsAP_N_Yes = pReader->ReadString();
}
@ -1259,7 +1192,7 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
for (int i = 0; i < nAction; ++i)
{
std::wstring wsType = pReader->ReadString();
CAnnotFieldInfo::CActionFieldPr* pA = ReadAction(pReader);
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* pA = ReadAction(pReader);
if (pA)
{
pA->wsType = wsType;

View File

@ -70,23 +70,6 @@ public:
WidgetSignature = 33
};
class GRAPHICS_DECL CActionFieldPr
{
public:
CActionFieldPr();
~CActionFieldPr();
BYTE nKind;
BYTE nFlags;
BYTE nActionType;
int nInt1;
double dD[4]{};
std::wstring wsType;
std::wstring wsStr1;
std::vector<std::wstring> arrStr;
CActionFieldPr* pNext;
};
class GRAPHICS_DECL CWidgetAnnotPr
{
public:
@ -107,7 +90,6 @@ public:
const std::wstring& GetRC();
const std::wstring& GetAC();
const std::wstring& GetAP_N_Yes();
const std::vector< std::pair<std::wstring, std::wstring> >& GetOpt();
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, BYTE nType, int nFlags);
@ -126,7 +108,6 @@ public:
std::wstring m_wsRC;
std::wstring m_wsAC;
std::wstring m_wsAP_N_Yes;
std::vector< std::pair<std::wstring, std::wstring> > m_arrOpt;
};
class GRAPHICS_DECL CTextWidgetPr
@ -178,6 +159,23 @@ public:
};
class GRAPHICS_DECL CActionWidget
{
public:
CActionWidget();
~CActionWidget();
BYTE nKind;
BYTE nFlags;
BYTE nActionType;
int nInt1;
double dD[4]{};
std::wstring wsType;
std::wstring wsStr1;
std::vector<std::wstring> arrStr;
CActionWidget* pNext;
};
CWidgetAnnotPr(BYTE nType);
~CWidgetAnnotPr();
@ -201,7 +199,7 @@ public:
const std::vector<double>& GetTC();
const std::vector<double>& GetBC();
const std::vector<double>& GetBG();
const std::vector<CActionFieldPr*>& GetActions();
const std::vector<CActionWidget*>& GetActions();
CButtonWidgetPr* GetButtonWidgetPr();
CTextWidgetPr* GetTextWidgetPr();
@ -231,7 +229,7 @@ public:
std::vector<double> m_arrTC;
std::vector<double> m_arrBC;
std::vector<double> m_arrBG;
std::vector<CActionFieldPr*> m_arrAction;
std::vector<CActionWidget*> m_arrAction;
CButtonWidgetPr* m_pButtonPr;
CTextWidgetPr* m_pTextPr;
@ -391,7 +389,7 @@ public:
{
public:
bool IsOpen() const;
int GetFlag() const;
int GetFlag() const;
int GetParentID() const;
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader);
@ -480,28 +478,6 @@ public:
std::vector<double> m_arrQuadPoints;
};
class GRAPHICS_DECL CLinkAnnotPr
{
public:
CLinkAnnotPr();
~CLinkAnnotPr();
BYTE GetH() const;
int GetFlags() const;
const std::vector<double>& GetQuadPoints();
CActionFieldPr* GetA();
CActionFieldPr* GetPA();
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader);
private:
BYTE m_nH;
int m_nFlags;
std::vector<double> m_arrQuadPoints;
CActionFieldPr* m_pAction;
CActionFieldPr* m_pPA;
};
CAnnotFieldInfo();
virtual ~CAnnotFieldInfo();
@ -542,7 +518,6 @@ public:
bool IsCaret() const;
bool IsStamp() const;
bool IsRedact() const;
bool IsLink() const;
CMarkupAnnotPr* GetMarkupAnnotPr();
CTextAnnotPr* GetTextAnnotPr();
@ -556,7 +531,6 @@ public:
CCaretAnnotPr* GetCaretAnnotPr();
CStampAnnotPr* GetStampAnnotPr();
CRedactAnnotPr* GetRedactAnnotPr();
CLinkAnnotPr* GetLinkAnnotPr();
CWidgetAnnotPr* GetWidgetAnnotPr();
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
@ -602,7 +576,6 @@ private:
CCaretAnnotPr* m_pCaretPr;
CStampAnnotPr* m_pStampPr;
CRedactAnnotPr* m_pRedactPr;
CLinkAnnotPr* m_pLinkPr;
CWidgetAnnotPr* m_pWidgetPr;
};
@ -637,7 +610,7 @@ public:
std::wstring sTU;
std::vector<int> arrI;
std::vector<std::wstring> arrV;
std::vector<CAnnotFieldInfo::CActionFieldPr*> arrAction;
std::vector<CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget*> arrAction;
std::vector< std::pair<std::wstring, std::wstring> > arrOpt;
};

View File

@ -179,6 +179,7 @@ CHeadings::CHeading::CHeading()
nPage = 0;
dX = 0.0;
dY = 0.0;
pParent = NULL;
}
CHeadings::CHeading::~CHeading()
{
@ -195,26 +196,35 @@ CHeadings::~CHeadings()
const std::vector<CHeadings::CHeading*>& CHeadings::GetHeading() { return m_arrHeading; }
bool CHeadings::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
{
std::vector<CHeading*> arrParentStack;
int nPredLevel = 0, nHeaderLevel = 0;
std::vector<CHeading*>* arrHeading = &m_arrHeading;
CHeading* pParent = NULL;
int nHeadings = pReader->ReadInt();
for (int i = 0; i < nHeadings; ++i)
{
int nLevel = pReader->ReadInt();
if (nLevel > nPredLevel && i > 0)
{
nHeaderLevel = nPredLevel;
pParent = arrHeading->back();
arrHeading = &pParent->arrHeading;
}
else if (nLevel < nPredLevel && nLevel <= nHeaderLevel)
{
nHeaderLevel = nLevel;
pParent = pParent ? pParent->pParent : NULL;
arrHeading = pParent ? &pParent->arrHeading : &m_arrHeading;
}
nPredLevel = nLevel;
CHeading* pHeading = new CHeading();
pHeading->nPage = pReader->ReadInt();
pHeading->dX = pReader->ReadDouble();
pHeading->dY = pReader->ReadDouble();
pHeading->wsTitle = pReader->ReadString();
pHeading->pParent = pParent;
while (arrParentStack.size() > nLevel)
arrParentStack.pop_back();
if (arrParentStack.empty())
m_arrHeading.push_back(pHeading);
else
arrParentStack.back()->arrHeading.push_back(pHeading);
arrParentStack.push_back(pHeading);
arrHeading->push_back(pHeading);
}
return true;
}

View File

@ -181,6 +181,7 @@ public:
int nPage;
double dX;
double dY;
CHeading* pParent;
std::vector<CHeading*> arrHeading;
CHeading();

View File

@ -46,7 +46,6 @@
"_InitializeFontsRanges",
"_SetFontBinary",
"_GetFontBinary",
"_GetGIDByUnicode",
"_IsFontBinaryExist",
"_DestroyTextInfo",
"_IsNeedCMap",
@ -57,8 +56,6 @@
"_UnmergePages",
"_RedactPage",
"_UndoRedact",
"_CheckOwnerPassword",
"_CheckPerm",
"_GetImageBase64",
"_GetImageBase64Len",
"_GetImageBase64Ptr",

View File

@ -145,14 +145,6 @@ CFile.prototype["isNeedPassword"] = function()
{
return this._isNeedPassword;
};
CFile.prototype["CheckOwnerPassword"] = function(password)
{
return this._CheckOwnerPassword(password);
};
CFile.prototype["CheckPerm"] = function(perm)
{
return this._CheckPerm(perm);
};
CFile.prototype["SplitPages"] = function(arrOriginIndex, arrayBufferChanges)
{
let ptr = this._SplitPages(arrOriginIndex, arrayBufferChanges);
@ -362,11 +354,6 @@ CFile.prototype["getFontByID"] = function(ID)
return this._getFontByID(ID);
};
CFile.prototype["getGIDByUnicode"] = function(ID)
{
return this._getGIDByUnicode(ID);
};
CFile.prototype["setCMap"] = function(memoryBuffer)
{
if (!this.nativeFile)
@ -426,9 +413,9 @@ function readAction(reader, rec, readDoubleFunc, readStringFunc)
case 4:
{
rec["left"] = readDoubleFunc.call(reader);
rec["top"] = readDoubleFunc.call(reader);
rec["bottom"] = readDoubleFunc.call(reader);
rec["right"] = readDoubleFunc.call(reader);
rec["bottom"] = readDoubleFunc.call(reader);
rec["top"] = readDoubleFunc.call(reader);
break;
}
case 1:
@ -1040,33 +1027,6 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
rec["font"]["style"] = reader.readInt();
}
}
// Link
else if (rec["type"] == 1)
{
flags = reader.readInt();
if (flags & (1 << 0))
{
rec["A"] = {};
readAction(reader, rec["A"], readDoubleFunc, readStringFunc);
}
if (flags & (1 << 1))
{
rec["PA"] = {};
readAction(reader, rec["PA"], readDoubleFunc, readStringFunc);
}
// Selection mode - H
// 0 - none, 1 - invert, 2 - push, 3 - outline
if (flags & (1 << 2))
rec["highlight"] = reader.readByte();
// QuadPoints
if (flags & (1 << 3))
{
let n = reader.readInt();
rec["QuadPoints"] = [];
for (let i = 0; i < n; ++i)
rec["QuadPoints"].push(readDoubleFunc.call(reader));
}
}
}
function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readStringFunc, isRead = false)
{
@ -1211,20 +1171,6 @@ function readWidgetType(reader, rec, readDoubleFunc, readDouble2Func, readString
rec["value"] = readStringFunc.call(reader);
// 0 - check, 1 - cross, 2 - diamond, 3 - circle, 4 - star, 5 - square
rec["style"] = reader.readByte();
if (flags & (1 << 10))
{
let n = reader.readInt();
rec["opt"] = [];
for (let i = 0; i < n; ++i)
{
let opt1 = readStringFunc.call(reader);
let opt2 = readStringFunc.call(reader);
if (opt1 == "")
rec["opt"].push(opt2);
else
rec["opt"].push([opt2, opt1]);
}
}
if (flags & (1 << 14))
rec["ExportValue"] = readStringFunc.call(reader);
// 12.7.4.2.1

View File

@ -146,16 +146,6 @@ CFile.prototype._UndoRedact = function()
return g_native_drawing_file["UndoRedact"]();
};
CFile.prototype._CheckOwnerPassword = function(password)
{
return true;
}
CFile.prototype._CheckPerm = function(perm)
{
return true;
}
// FONTS
CFile.prototype._isNeedCMap = function()
{
@ -172,12 +162,6 @@ CFile.prototype._getFontByID = function(ID)
return g_native_drawing_file["GetFontBinary"](ID);
};
CFile.prototype._getGIDByUnicode = function(ID)
{
g_module_pointer.ptr = g_native_drawing_file["GetGIDByUnicode"](ID);
return g_module_pointer;
}
CFile.prototype._getInteractiveFormsFonts = function(type)
{
g_module_pointer.ptr = g_native_drawing_file["GetInteractiveFormsFonts"](type);

View File

@ -224,29 +224,6 @@ CFile.prototype._UndoRedact = function()
return Module["_UndoRedact"](this.nativeFile) == 1;
};
CFile.prototype._CheckOwnerPassword = function(password)
{
let passwordPtr = 0;
if (password)
{
let passwordBuf = password.toUtf8();
passwordPtr = Module["_malloc"](passwordBuf.length);
Module["HEAP8"].set(passwordBuf, passwordPtr);
}
let bRes = Module["_CheckOwnerPassword"](this.nativeFile, passwordPtr);
if (passwordPtr)
Module["_free"](passwordPtr);
return bRes == 1;
}
CFile.prototype._CheckPerm = function(perm)
{
return Module["_CheckPerm"](this.nativeFile, perm) == 1;
}
// FONTS
CFile.prototype._isNeedCMap = function()
{
@ -286,34 +263,6 @@ CFile.prototype._getFontByID = function(ID)
return res;
};
CFile.prototype._getGIDByUnicode = function(ID)
{
if (ID === undefined)
return null;
let idBuffer = ID.toUtf8();
let idPointer = Module["_malloc"](idBuffer.length);
Module["HEAP8"].set(idBuffer, idPointer);
g_module_pointer.ptr = Module["_GetGIDByUnicode"](this.nativeFile, idPointer);
Module["_free"](idPointer);
let reader = g_module_pointer.getReader();
if (!reader)
return null;
let res = {};
let nFontLength = reader.readInt();
for (let i = 0; i < nFontLength; i++)
{
let np1 = reader.readInt();
let np2 = reader.readInt();
res[np2] = np1;
}
g_module_pointer.free();
return res;
}
CFile.prototype._getInteractiveFormsFonts = function(type)
{
g_module_pointer.ptr = Module["_GetInteractiveFormsFonts"](this.nativeFile, type);

View File

@ -150,10 +150,6 @@ WASM_EXPORT BYTE* GetFontBinary(CDrawingFile* pFile, char* path)
{
return pFile->GetFontBinary(std::string(path));
}
WASM_EXPORT BYTE* GetGIDByUnicode(CDrawingFile* pFile, char* path)
{
return pFile->GetGIDByUnicode(std::string(path));
}
WASM_EXPORT void DestroyTextInfo(CDrawingFile* pFile)
{
return pFile->DestroyTextInfo();
@ -195,17 +191,6 @@ WASM_EXPORT int UndoRedact(CDrawingFile* pFile)
{
return pFile->UndoRedact() ? 1 : 0;
}
WASM_EXPORT int CheckOwnerPassword(CDrawingFile* pFile, const char* password)
{
std::wstring sPassword = L"";
if (NULL != password)
sPassword = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)password, strlen(password));
return pFile->CheckOwnerPassword(sPassword) ? 1 : 0;
}
WASM_EXPORT int CheckPerm(CDrawingFile* pFile, int nPermFlag)
{
return pFile->CheckPerm(nPermFlag) ? 1 : 0;
}
WASM_EXPORT void* GetImageBase64(CDrawingFile* pFile, int rId)
{

View File

@ -704,23 +704,6 @@ void ReadInteractiveForms(BYTE* pWidgets, int& i)
i += 1;
std::cout << "Style " << arrStyle[nPathLength] << ", ";
if (nFlags & (1 << 10))
{
int nOptLength = READ_INT(pWidgets + i);
i += 4;
for (int j = 0; j < nOptLength; ++j)
{
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << std::to_string(j) << " Opt1 " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
i += nPathLength;
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << std::to_string(j) << " Opt2 " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
i += nPathLength;
}
}
if (nFlags & (1 << 14))
{
nPathLength = READ_INT(pWidgets + i);
@ -955,36 +938,6 @@ void ReadInteractiveFormsFonts(CDrawingFile* pGrFile, int nType)
std::cout << "font" << j << ".txt";
}
if (pFont)
free(pFont);
if (false)
continue;
pFont = GetGIDByUnicode(pGrFile, (char*)sFontName.c_str());
nLength2 = READ_INT(pFont);
i2 = 4;
nLength2 -= 4;
while (i2 < nLength2)
{
int nFontLength = READ_INT(pFont + i2);
i2 += 4;
std::cout << std::endl << "CIDtoUnicode" << std::endl;
for (int j = 0; j < nFontLength; ++j)
{
unsigned int code = READ_INT(pFont + i2);
i2 += 4;
unsigned int unicode = READ_INT(pFont + i2);
i2 += 4;
std::cout << "cid\t" << code << "\tunicode\t" << unicode << std::endl;
}
std::cout << std::endl;
}
if (pFont)
free(pFont);
}
@ -1172,18 +1125,6 @@ int main(int argc, char* argv[])
}
}
// OWNER PASSWORD
if (false)
{
std::string sPassword = "gfhjkmgfhjkm";
std::cout << "CheckPerm 4 Edit " << CheckPerm(pGrFile, 4) << std::endl;
std::cout << "CheckPerm 4 Print " << CheckPerm(pGrFile, 3) << std::endl;
std::cout << "CheckOwnerPassword " << CheckOwnerPassword(pGrFile, sPassword.c_str()) << std::endl;
std::cout << "CheckPerm 4 Edit " << CheckPerm(pGrFile, 4) << std::endl;
std::cout << "CheckPerm 4 Print " << CheckPerm(pGrFile, 3) << std::endl;
}
BYTE* pColor = new BYTE[12] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// REDACT
if (false)
@ -1193,17 +1134,17 @@ int main(int argc, char* argv[])
std::cout << "Redact false" << std::endl;
}
// RASTER
if (true)
int i = nTestPage;
//for (int i = 0; i < nPagesCount; ++i)
{
int i = nTestPage;
//for (int i = 0; i < nPagesCount; ++i)
// RASTER
if (true)
{
nWidth = READ_INT(pInfo + i * 16 + 12);
nHeight = READ_INT(pInfo + i * 16 + 16);
//nWidth *= 2;
//nHeight *= 2;
//nWidth *= 3;
//nHeight *= 3;
BYTE* res = NULL;
res = GetPixmap(pGrFile, i, nWidth, nHeight, 0xFFFFFF);
@ -1223,7 +1164,7 @@ int main(int argc, char* argv[])
free(pInfo);
// LINKS
if (false && nPagesCount > 0)
if (true && nPagesCount > 0)
{
BYTE* pLinks = GetLinks(pGrFile, nTestPage);
nLength = READ_INT(pLinks);
@ -1259,7 +1200,7 @@ int main(int argc, char* argv[])
}
// STRUCTURE
if (false)
if (true)
{
BYTE* pStructure = GetStructure(pGrFile);
nLength = READ_INT(pStructure);
@ -2191,44 +2132,6 @@ int main(int argc, char* argv[])
std::cout << nPathLength << ", ";
}
}
else if (sType == "Link")
{
nFlags = READ_INT(pAnnots + i);
i += 4;
if (nFlags & (1 << 0))
{
std::cout << std::endl << "A ";
ReadAction(pAnnots, i);
std::cout << std::endl;
}
if (nFlags & (1 << 1))
{
std::cout << std::endl << "PA ";
ReadAction(pAnnots, i);
std::cout << std::endl;
}
if (nFlags & (1 << 2))
{
std::string arrHighlighting[] = {"none", "invert", "push", "outline"};
nPathLength = READ_BYTE(pAnnots + i);
i += 1;
std::cout << "Highlight " << arrHighlighting[nPathLength] << ", ";
}
if (nFlags & (1 << 3))
{
std::cout << "QuadPoints";
int nQuadPointsLength = READ_INT(pAnnots + i);
i += 4;
for (int j = 0; j < nQuadPointsLength; ++j)
{
nPathLength = READ_INT(pAnnots + i);
i += 4;
std::cout << " " << (double)nPathLength / 100.0;
}
std::cout << ", ";
}
}
std::cout << std::endl << "]" << std::endl;
}
@ -2254,12 +2157,9 @@ int main(int argc, char* argv[])
// SCAN PAGE
if (false)
{
BYTE* pScan = ScanPage(pGrFile, nTestPage, 2);
BYTE* pScan = ScanPage(pGrFile, nTestPage, 1);
if (pScan)
free(pScan);
ReadInteractiveFormsFonts(pGrFile, 1);
ReadInteractiveFormsFonts(pGrFile, 2);
}
Close(pGrFile);

View File

@ -202,19 +202,6 @@ bool CImageFileFormatChecker::isWbcFile(BYTE* pBuffer,DWORD dwBytes)
return false;
}
//raster graphics file format developed by Google
bool CImageFileFormatChecker::isWebPFile(BYTE* pBuffer, DWORD dwBytes)
{
if (eFileType)return false;
if ((20 <= dwBytes) && ('R' == pBuffer[0] && 'I' == pBuffer[1] && 'F' == pBuffer[2] && 'F' == pBuffer[3]
//47 length + 12
&& 'W' == pBuffer[8] && 'E' == pBuffer[9] && 'B' == pBuffer[10] && 'P' == pBuffer[11])
&& 'V' == pBuffer[12] && 'P' == pBuffer[13] && '8' == pBuffer[14])
return true;
return false;
}
//webshot(wb ver 1) HEX 57 57 42 42 31 31 31 31
//webshot (wb ver 2) HEX 00 00 02 00 02 10 c9 00 02 00 c8 06 4c 00 02 00
bool CImageFileFormatChecker::isWbFile(BYTE* pBuffer,DWORD dwBytes)
@ -522,10 +509,6 @@ bool CImageFileFormatChecker::isImageFile(const std::wstring& fileName)
{
eFileType = _CXIMAGE_FORMAT_WB;
}
else if (isWebPFile(buffer, sizeRead))
{
eFileType = _CXIMAGE_FORMAT_WEBP;
}
else if (isPsdFile(buffer,sizeRead))
{
eFileType = _CXIMAGE_FORMAT_PSD;

View File

@ -64,7 +64,6 @@ enum __ENUM_CXIMAGE_FORMATS
_CXIMAGE_FORMAT_SVG = 24,
_CXIMAGE_FORMAT_PIC = 25,
_CXIMAGE_FORMAT_HEIF = 26,
_CXIMAGE_FORMAT_WEBP = 27
};
class GRAPHICS_DECL CImageFileFormatChecker
@ -97,7 +96,6 @@ public:
bool isTiffFile(BYTE* pBuffer,DWORD dwBytes);
bool isJpgFile(BYTE* pBuffer,DWORD dwBytes);
bool isWbFile(BYTE* pBuffer,DWORD dwBytes);
bool isWebPFile(BYTE* pBuffer, DWORD dwBytes);
bool isIcoFile(BYTE* pBuffer,DWORD dwBytes);
bool isRasFile(BYTE* pBuffer,DWORD dwBytes);

View File

@ -8,8 +8,8 @@ namespace SVG
: CObject(oReader), m_enUnits{EMarkerUnits::StrokeWidth}, m_enOrient{EMarkerOrient::Angle},
m_dAngle(0.), m_oBounds{0., 0., 0., 0.}
{
m_oWindow.m_oWidth.SetValue(3, NSCSS::Pixel);
m_oWindow.m_oHeight.SetValue(3, NSCSS::Pixel);
m_oWindow.m_oWidth.SetValue(3);
m_oWindow.m_oHeight.SetValue(3);
}
ObjectType CMarker::GetType() const

View File

@ -153,7 +153,7 @@ namespace SVG
bool CObject::ApplyClip(IRenderer *pRenderer, const TClip *pClip, const CSvgFile *pFile, const TBounds &oBounds) const
{
if (NULL == pRenderer || NULL == pClip || NULL == pFile || pClip->m_oHref.Empty() || NSCSS::NSProperties::EColorType::ColorUrl != pClip->m_oHref.GetType())
if (NULL == pRenderer || NULL == pClip || NULL == pFile || pClip->m_oHref.Empty() || NSCSS::NSProperties::ColorType::ColorUrl != pClip->m_oHref.GetType())
return false;
if (pClip->m_oRule == L"evenodd")
@ -169,7 +169,7 @@ namespace SVG
bool CObject::ApplyMask(IRenderer *pRenderer, const NSCSS::NSProperties::CColor *pMask, const CSvgFile *pFile, const TBounds &oBounds) const
{
if (NULL == pRenderer || NULL == pMask || NULL == pFile || NSCSS::NSProperties::EColorType::ColorUrl != pMask->GetType())
if (NULL == pRenderer || NULL == pMask || NULL == pFile || NSCSS::NSProperties::ColorType::ColorUrl != pMask->GetType())
return false;
return ApplyDef(pRenderer, pFile, pMask->ToWString(), oBounds);
@ -358,7 +358,7 @@ namespace SVG
bool CRenderedObject::ApplyStroke(IRenderer *pRenderer, const TStroke *pStroke, bool bUseDefault, const CRenderedObject* pContextObject) const
{
if (NULL == pRenderer || NULL == pStroke || NSCSS::NSProperties::EColorType::ColorNone == pStroke->m_oColor.GetType() || (!bUseDefault && ((pStroke->m_oWidth.Empty() || pStroke->m_oWidth.Zero()) && pStroke->m_oColor.Empty())))
if (NULL == pRenderer || NULL == pStroke || NSCSS::NSProperties::ColorType::ColorNone == pStroke->m_oColor.GetType() || (!bUseDefault && ((pStroke->m_oWidth.Empty() || pStroke->m_oWidth.Zero()) && pStroke->m_oColor.Empty())))
{
pRenderer->put_PenSize(0);
return false;
@ -369,12 +369,12 @@ namespace SVG
if (Equals(0., dStrokeWidth))
dStrokeWidth = 1.;
if (NSCSS::NSProperties::EColorType::ColorContextFill == pStroke->m_oColor.GetType() && NULL != pContextObject)
if (NSCSS::NSProperties::ColorType::ColorContextFill == pStroke->m_oColor.GetType() && NULL != pContextObject)
pRenderer->put_PenColor(pContextObject->m_oStyles.m_oFill.ToInt());
else if (NSCSS::NSProperties::EColorType::ColorContextStroke == pStroke->m_oColor.GetType() && NULL != pContextObject)
else if (NSCSS::NSProperties::ColorType::ColorContextStroke == pStroke->m_oColor.GetType() && NULL != pContextObject)
pRenderer->put_PenColor(pContextObject->m_oStyles.m_oStroke.m_oColor.ToInt());
else
pRenderer->put_PenColor((pStroke->m_oColor.Empty() || NSCSS::NSProperties::EColorType::ColorNone == pStroke->m_oColor.GetType()) ? 0 : pStroke->m_oColor.ToInt());
pRenderer->put_PenColor((pStroke->m_oColor.Empty() || NSCSS::NSProperties::ColorType::ColorNone == pStroke->m_oColor.GetType()) ? 0 : pStroke->m_oColor.ToInt());
pRenderer->put_PenSize(dStrokeWidth);
pRenderer->put_PenAlpha(255. * pStroke->m_oColor.GetOpacity());
@ -401,18 +401,18 @@ namespace SVG
bool CRenderedObject::ApplyFill(IRenderer *pRenderer, const NSCSS::NSProperties::CColor *pFill, const CSvgFile *pFile, bool bUseDefault, const CRenderedObject* pContextObject) const
{
if (NULL == pRenderer || NULL == pFill || NSCSS::NSProperties::EColorType::ColorNone == pFill->GetType() || (!bUseDefault && pFill->Empty()))
if (NULL == pRenderer || NULL == pFill || NSCSS::NSProperties::ColorType::ColorNone == pFill->GetType() || (!bUseDefault && pFill->Empty()))
{
pRenderer->put_BrushType(c_BrushTypeNoFill);
return false;
}
else if (NSCSS::NSProperties::EColorType::ColorHEX == pFill->GetType() ||
NSCSS::NSProperties::EColorType::ColorRGB == pFill->GetType())
else if (NSCSS::NSProperties::ColorType::ColorHEX == pFill->GetType() ||
NSCSS::NSProperties::ColorType::ColorRGB == pFill->GetType())
{
pRenderer->put_BrushColor1((pFill->Empty() && bUseDefault) ? 0 : pFill->ToInt());
pRenderer->put_BrushType(c_BrushTypeSolid);
}
else if (NSCSS::NSProperties::EColorType::ColorUrl == pFill->GetType())
else if (NSCSS::NSProperties::ColorType::ColorUrl == pFill->GetType())
{
if (!ApplyDef(pRenderer, pFile, pFill->ToWString(), GetBounds()))
{
@ -425,16 +425,10 @@ namespace SVG
return false;
}
}
else if (NSCSS::NSProperties::EColorType::ColorContextFill == pFill->GetType() && NULL != pContextObject)
{
if (!ApplyFill(pRenderer, &pContextObject->m_oStyles.m_oFill, pFile, bUseDefault, pContextObject))
return false;
}
else if (NSCSS::NSProperties::EColorType::ColorContextStroke == pFill->GetType() && NULL != pContextObject)
{
if (!ApplyFill(pRenderer, &pContextObject->m_oStyles.m_oStroke.m_oColor, pFile, bUseDefault, pContextObject))
return false;
}
else if (NSCSS::NSProperties::ColorType::ColorContextFill == pFill->GetType() && NULL != pContextObject)
pRenderer->put_BrushColor1(pContextObject->m_oStyles.m_oFill.ToInt());
else if (NSCSS::NSProperties::ColorType::ColorContextStroke == pFill->GetType() && NULL != pContextObject)
pRenderer->put_BrushColor1(pContextObject->m_oStyles.m_oStroke.m_oColor.ToInt());
else if (bUseDefault)
{
pRenderer->put_BrushColor1(0);

View File

@ -566,7 +566,7 @@ namespace SVG
#define CALCULATE_ANGLE(firstPoint, secondPoint) std::atan2(secondPoint.dY - firstPoint.dY, secondPoint.dX - firstPoint.dX) * 180. / M_PI
if (!m_oMarkers.m_oStart.Empty() && NSCSS::NSProperties::EColorType::ColorUrl == m_oMarkers.m_oStart.GetType())
if (!m_oMarkers.m_oStart.Empty() && NSCSS::NSProperties::ColorType::ColorUrl == m_oMarkers.m_oStart.GetType())
{
CMarker *pStartMarker = dynamic_cast<CMarker*>(pFile->GetMarkedObject(m_oMarkers.m_oStart.ToWString()));
@ -610,7 +610,7 @@ namespace SVG
}
}
if (!m_oMarkers.m_oMid.Empty() && NSCSS::NSProperties::EColorType::ColorUrl == m_oMarkers.m_oMid.GetType())
if (!m_oMarkers.m_oMid.Empty() && NSCSS::NSProperties::ColorType::ColorUrl == m_oMarkers.m_oMid.GetType())
{
CMarker *pMidMarker = dynamic_cast<CMarker*>(pFile->GetMarkedObject(m_oMarkers.m_oMid.ToWString()));
@ -638,7 +638,7 @@ namespace SVG
}
}
if (!m_oMarkers.m_oEnd.Empty() && NSCSS::NSProperties::EColorType::ColorUrl == m_oMarkers.m_oEnd.GetType())
if (!m_oMarkers.m_oEnd.Empty() && NSCSS::NSProperties::ColorType::ColorUrl == m_oMarkers.m_oEnd.GetType())
{
CMarker *pEndMarker = dynamic_cast<CMarker*>(pFile->GetMarkedObject(m_oMarkers.m_oEnd.ToWString()));

View File

@ -110,9 +110,6 @@ namespace SVG
if (mAttributes.end() != mAttributes.find(L"text-decoration"))
m_oText.SetDecoration(mAttributes.at(L"text-decoration"), ushLevel, bHardMode);
if (mAttributes.end() != mAttributes.find(L"baseline-shift"))
m_oText.SetBaselineShift(mAttributes.at(L"baseline-shift"), ushLevel, bHardMode);
//POSITION
if (mAttributes.end() != mAttributes.find(L"rotate"))
{
@ -244,27 +241,7 @@ namespace SVG
std::wstring wsFontFamily = DefaultFontFamily;
double dFontSize = ((!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Pixel) : DEFAULT_FONT_SIZE) * 72. / 25.4;
double dScaleX = 1., dScaleY = 1.;
NormalizeFontSize(dFontSize, dScaleX, dScaleY);
if (!Equals(1., dScaleX) || !Equals(1., dScaleY))
{
dX /= dScaleX;
dY /= dScaleY;
double dM11, dM12, dM21, dM22, dDx, dDy;
pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy);
oOldMatrix.SetElements(dM11, dM12, dM21, dM22, dDx, dDy);
Aggplus::CMatrix oMatrix(dM11, dM12, dM21, dM22, dDx, dDy);
oMatrix.Scale(dScaleX, dScaleY);
pRenderer->SetTransform(oMatrix.sx(), oMatrix.shy(), oMatrix.shx(), oMatrix.sy(), oMatrix.tx(), oMatrix.ty());
}
Normalize(pRenderer, dX, dY, dFontSize, oOldMatrix);
if (!m_oFont.GetFamily().Empty())
{
@ -294,12 +271,12 @@ namespace SVG
m_pFontManager->LoadFontByName(wsFontFamily, dFontSize, nStyle, 72., 72.);
m_pFontManager->SetCharSpacing(0);
const double dKoef = 25.4 / 72.;
double dKoef = 25.4 / 72.;
NSFonts::IFontFile* pFontFile = m_pFontManager->GetFile();
if (pFontFile)
dFHeight *= pFontFile->GetHeight() / pFontFile->Units_Per_Em() * dKoef;
dFHeight *= pFontFile->GetHeight() / pFontFile->Units_Per_Em() * dKoef;
m_pFontManager->LoadString1(m_wsText, 0, 0);
TBBox oBox = m_pFontManager->MeasureString2();
@ -322,45 +299,6 @@ namespace SVG
else if (L"center" == m_oText.GetAlign().ToWString())
dX += -fW / 2;
if (NSCSS::NSProperties::EBaselineShift::Baseline != m_oText.GetBaselineShiftType())
{
switch(m_oText.GetBaselineShiftType())
{
case NSCSS::NSProperties::Sub:
{
dY += dFHeight / 2.;
break;
}
case NSCSS::NSProperties::Super:
{
double dParentHeight{dFHeight};
if (nullptr != m_pParent)
dParentHeight = ((CTSpan*)m_pParent)->GetFontHeight() / dScaleY;
dY -= dParentHeight - dFHeight / 2.;
break;
}
case NSCSS::NSProperties::Percentage:
{
double dParentHeight{dFHeight};
if (nullptr != m_pParent)
dParentHeight = ((CTSpan*)m_pParent)->GetFontHeight() / dScaleY;
dY -= dParentHeight * (m_oText.GetBaselineShiftValue() / 100.);
break;
}
case NSCSS::NSProperties::Length:
{
dY -= m_oText.GetBaselineShiftValue() / dScaleY;
break;
}
default:
break;
}
}
if (m_oText.Underline() || m_oText.LineThrough() || m_oText.Overline())
{
pRenderer->put_PenSize((double)fUndSize);
@ -451,7 +389,7 @@ namespace SVG
oBounds.m_dRight = oBounds.m_dLeft + GetWidth();
oBounds.m_dBottom = m_oY.ToDouble(NSCSS::Pixel);
oBounds.m_dTop = oBounds.m_dBottom - ((!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Pixel) : DEFAULT_FONT_SIZE);
oBounds.m_dTop = oBounds.m_dBottom + ((!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Pixel) : DEFAULT_FONT_SIZE);
if (nullptr != pTransform)
{
@ -546,33 +484,56 @@ namespace SVG
dY = m_oY.ToDouble(NSCSS::Pixel, oBounds.m_dBottom - oBounds.m_dTop);
}
void CTSpan::NormalizeFontSize(double& dFontHeight, double& dScaleX, double& dScaleY) const
void CTSpan::Normalize(IRenderer *pRenderer, double &dX, double &dY, double &dFontHeight, Aggplus::CMatrix& oOldMatrix) const
{
if (NULL == pRenderer)
return;
Aggplus::CMatrix oCurrentMatrix(m_oTransformation.m_oTransform.GetMatrix().GetFinalValue());
double dXScale = 1., dYScale = 1.;
const double dModuleM11 = std::abs(oCurrentMatrix.sx());
const double dModuleM22 = std::abs(oCurrentMatrix.sy());
if (!ISZERO(dModuleM11) && (dModuleM11 < MIN_SCALE || dModuleM11 > MAX_SCALE))
dScaleX /= dModuleM11;
dXScale /= dModuleM11;
if (!ISZERO(dModuleM22) && (dModuleM22 < MIN_SCALE || dModuleM22 > MAX_SCALE))
dScaleY /= dModuleM22;
dYScale /= dModuleM22;
dFontHeight *= dScaleY;
dFontHeight *= dYScale;
if (!Equals(0., dFontHeight) && dFontHeight < MIN_FONT_SIZE)
{
dScaleX *= MIN_FONT_SIZE / dFontHeight;
dScaleY *= MIN_FONT_SIZE / dFontHeight;
dXScale *= MIN_FONT_SIZE / dFontHeight;
dYScale *= MIN_FONT_SIZE / dFontHeight;
dFontHeight = MIN_FONT_SIZE;
}
else if (!Equals(0., dFontHeight) && dFontHeight > MAX_FONT_SIZE)
{
dScaleX *= dFontHeight / MAX_FONT_SIZE;
dScaleY *= dFontHeight / MAX_FONT_SIZE;
dXScale *= dFontHeight / MAX_FONT_SIZE;
dYScale *= dFontHeight / MAX_FONT_SIZE;
dFontHeight = MAX_FONT_SIZE;
}
if (Equals(1., dXScale) && Equals(1., dYScale))
return;
dX /= dXScale;
dY /= dYScale;
double dM11, dM12, dM21, dM22, dDx, dDy;
pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy);
oOldMatrix.SetElements(dM11, dM12, dM21, dM22, dDx, dDy);
Aggplus::CMatrix oMatrix(dM11, dM12, dM21, dM22, dDx, dDy);
oMatrix.Scale(dXScale, dYScale);
pRenderer->SetTransform(oMatrix.sx(), oMatrix.shy(), oMatrix.shx(), oMatrix.sy(), oMatrix.tx(), oMatrix.ty());
}
void CTSpan::SetPosition(const Point &oPosition)
@ -608,40 +569,6 @@ namespace SVG
}
double CTSpan::GetFontHeight() const
{
if (NULL == m_pFontManager)
return ((!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Pixel) : DEFAULT_FONT_SIZE) * 72. / 25.4;
std::wstring wsFontFamily = DefaultFontFamily;
double dFontSize = ((!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Pixel) : DEFAULT_FONT_SIZE) * 72. / 25.4;
if (!m_oFont.GetFamily().Empty())
{
wsFontFamily = m_oFont.GetFamily().ToWString();
CorrectFontFamily(wsFontFamily);
}
int nStyle = 0;
if (m_oFont.GetWeight().ToWString() == L"bold")
nStyle |= 0x01;
if (m_oFont.GetStyle() .ToWString() == L"italic")
nStyle |= 0x02;
if (m_oText.Underline())
nStyle |= (1 << 2);
// Вычиления размеров текста
m_pFontManager->LoadFontByName(wsFontFamily, dFontSize, nStyle, 72., 72.);
m_pFontManager->SetCharSpacing(0);
m_pFontManager->LoadString1(m_wsText, 0, 0);
TBBox oBox = m_pFontManager->MeasureString2();
return (double)(25.4f / 72.f * (oBox.fMaxY - oBox.fMinY));
}
std::vector<CTSpan> CTSpan::Split() const
{
std::vector<CTSpan> arGlyphs;

View File

@ -44,13 +44,11 @@ namespace SVG
void CalculatePosition(double& dX, double& dY) const;
void NormalizeFontSize(double& dFontHeight, double& dScaleX, double& dScaleY) const;
void Normalize(IRenderer* pRenderer, double& dX, double& dY, double& dFontHeight, Aggplus::CMatrix& oOldMatrix) const;
void SetPosition(const Point& oPosition);
void SetPositionFromParent(CRenderedObject* pParent);
double GetFontHeight() const;
std::vector<CTSpan> Split() const;
NSFonts::IFontManager* m_pFontManager;

View File

@ -144,7 +144,6 @@ std::vector<std::wstring> CDocxRenderer::ScanPagePptx(IOfficeDrawingFile* pFile,
m_pInternal->m_oDocument.Init(false);
m_pInternal->m_oDocument.m_oCurrentPage.m_bUseDefaultFont = true;
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = true;
m_pInternal->m_oDocument.m_oCurrentPage.m_bCollectMetaInfo = true;
m_pInternal->m_bIsSupportShapeCommands = true;
m_pInternal->m_eShapeSerializeType = ShapeSerializeType::sstXml;
@ -161,7 +160,6 @@ NSWasm::CData CDocxRenderer::ScanPageBin(IOfficeDrawingFile* pFile, size_t nPage
m_pInternal->m_oDocument.Init(false);
m_pInternal->m_oDocument.m_oCurrentPage.m_bUseDefaultFont = true;
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = true;
m_pInternal->m_oDocument.m_oCurrentPage.m_bCollectMetaInfo = true;
m_pInternal->m_bIsSupportShapeCommands = true;
DrawPage(pFile, nPage);
@ -734,10 +732,6 @@ HRESULT CDocxRenderer::CommandLong(const LONG& lType, const LONG& lCommand)
return S_OK;
}
if (c_nFontSubstitution == lType)
{
m_pInternal->m_oDocument.m_oCurrentPage.m_bFontSubstitution = true;
}
return S_OK;
}
HRESULT CDocxRenderer::CommandDouble(const LONG& lType, const double& dCommand)

View File

@ -322,7 +322,6 @@ namespace NSDocxRenderer
HRESULT CDocument::put_FontName(std::wstring sName)
{
m_oCurrentPage.m_oFont.Name = sName;
m_oCurrentPage.m_bFontSubstitution = false;
return S_OK;
}
HRESULT CDocument::get_FontPath(std::wstring* sPath)

View File

@ -268,7 +268,7 @@ namespace NSDocxRenderer
if (!skip_shape)
{
shape->m_nOrder = ++m_nCurrentOrder;
shape->m_nOrder = ++m_nShapeOrder;
m_arShapes.push_back(shape);
}
}
@ -342,23 +342,7 @@ namespace NSDocxRenderer
bForcedBold = true;
m_oManagers.pParagraphStyleManager->UpdateAvgFontSize(m_oFont.Size);
m_nCurrentOrder++;
m_oContBuilder.AddUnicode(
top,
baseline,
left,
right,
m_oFont,
m_oBrush,
m_oManagers.pFontManager,
oText,
m_nCurrentOrder,
pGids,
bForcedBold,
m_bUseDefaultFont,
m_bWriteStyleRaw,
m_bCollectMetaInfo
);
m_oContBuilder.AddUnicode(top, baseline, left, right, m_oFont, m_oBrush, m_oManagers.pFontManager, oText, bForcedBold, m_bUseDefaultFont, m_bWriteStyleRaw);
}
void CPage::Analyze()
@ -485,6 +469,8 @@ namespace NSDocxRenderer
m_arShapes.erase(right, m_arShapes.end());
std::sort(m_arShapes.begin(), m_arShapes.end(), [] (const shape_ptr_t& s1, const shape_ptr_t& s2) {
if (s1->m_bIsBehindDoc && !s2->m_bIsBehindDoc) return true;
if (!s1->m_bIsBehindDoc && s2->m_bIsBehindDoc) return false;
return s1->m_nOrder < s2->m_nOrder;
});
}
@ -1166,17 +1152,11 @@ namespace NSDocxRenderer
if ((bIf1 && bIf6) || (bIf2 && bIf7) || (bIf4 && bIf8) || (bIf5 && bIf7))
{
if (m_bCollectMetaInfo)
cont->AddSymBack(d_sym->GetText().at(0), 0, d_sym->m_arOriginLefts.at(0), d_sym->m_arGids.at(0));
else
cont->AddSymBack(d_sym->GetText().at(0), 0, d_sym->m_arOriginLefts.at(0));
cont->AddSymBack(d_sym->GetText().at(0), 0);
}
else if (bIf3 && bIf7)
{
if (m_bCollectMetaInfo)
cont->AddSymFront(d_sym->GetText().at(0), 0, d_sym->m_arOriginLefts.at(0), d_sym->m_arGids.at(0));
else
cont->AddSymFront(d_sym->GetText().at(0), 0, d_sym->m_arOriginLefts.at(0));
cont->AddSymFront(d_sym->GetText().at(0), 0);
}
isBreak = true;
break;
@ -1606,9 +1586,8 @@ namespace NSDocxRenderer
// lamda to setup and add paragpraph
auto add_paragraph = [this, &max_right, &min_left, &ar_paragraphs] (paragraph_ptr_t& paragraph) {
double additional_bottom = paragraph->m_arTextLines.front()->m_dTopWithMaxAscent - paragraph->m_arTextLines.front()->m_dTop;
paragraph->m_dBot = paragraph->m_arTextLines.back()->m_dBot + additional_bottom;
paragraph->m_dTop = paragraph->m_arTextLines.front()->m_dTopWithMaxAscent;
paragraph->m_dBot = paragraph->m_arTextLines.back()->m_dBot;
paragraph->m_dTop = paragraph->m_arTextLines.front()->m_dTop;
paragraph->m_dRight = max_right;
paragraph->m_dLeft = min_left;
@ -1686,7 +1665,6 @@ namespace NSDocxRenderer
min_left = std::min(min_left, curr_line->m_dLeft);
max_right = std::max(max_right, curr_line->m_dRight);
paragraph->m_arTextLines.push_back(curr_line);
paragraph->m_nOrder = std::max(paragraph->m_nOrder, curr_line->m_nOrder);
};
auto build_paragraphs = [this, add_line, add_paragraph] (const std::vector<text_line_ptr_t>& text_lines) {
@ -1847,19 +1825,6 @@ namespace NSDocxRenderer
}
}
// 2 lines in paragraph fix
for (size_t index = 0; index < ar_positions.size() - 1; ++index)
{
auto& line_top = text_lines[index];
auto& line_bot = text_lines[index + 1];
bool is_start = index == 0 || ar_delims[index - 1] == true;
bool is_end = index == ar_positions.size() - 1 || ar_delims[index + 1] == true;
bool is_diff = fabs(line_top->m_dHeight - line_bot->m_dHeight) > (line_top->m_dHeight + line_bot->m_dHeight) / 4;
if (is_start && is_end && is_diff)
ar_delims[index] = true;
}
// gap check
//
// bla-bla-bla
@ -2274,7 +2239,6 @@ namespace NSDocxRenderer
if (direction == eLineDirection::ldLeft) return crossing->p.x - p.x;
if (direction == eLineDirection::ldBot) return p.y - crossing->p.y;
if (direction == eLineDirection::ldTop) return crossing->p.y - p.y;
return 0;
};
while (diff() > c_dMAX_TABLE_LINE_WIDTH_MM)
@ -2554,13 +2518,12 @@ namespace NSDocxRenderer
pParagraph->m_arTextLines.push_back(pLine);
pParagraph->m_dLeft = pLine->m_dLeft;
pParagraph->m_dTop = pLine->m_dTopWithMaxAscent;
pParagraph->m_dBot = pLine->m_dBot + (pLine->m_dTopWithMaxAscent - pLine->m_dTop);
pParagraph->m_dTop = pLine->m_dTop;
pParagraph->m_dBot = pLine->m_dBot;
pParagraph->m_dWidth = pLine->m_dWidth;
pParagraph->m_dHeight = pLine->m_dHeight;
pParagraph->m_dRight = pLine->m_dRight;
pParagraph->m_dLineHeight = pParagraph->m_dHeight;
pParagraph->m_nOrder = pLine->m_nOrder;
if (pLine->m_pDominantShape)
{
@ -2579,7 +2542,6 @@ namespace NSDocxRenderer
pShape->m_dWidth = pParagraph->m_dWidth;
pShape->m_dHeight = pParagraph->m_dHeight;
pShape->m_dRight = pParagraph->m_dRight;
pShape->m_nOrder = pParagraph->m_nOrder;
pShape->m_bIsBehindDoc = false;
return pShape;
@ -2595,7 +2557,6 @@ namespace NSDocxRenderer
pShape->m_dBot = pParagraph->m_dBot;
pShape->m_dHeight = pParagraph->m_dHeight;
pShape->m_dWidth = pParagraph->m_dWidth;
pShape->m_nOrder = pParagraph->m_nOrder;
if (pParagraph->m_bIsNeedFirstLineIndent && pParagraph->m_dFirstLine < 0)
pParagraph->m_dLeftBorder = -pParagraph->m_dFirstLine;

View File

@ -46,10 +46,8 @@ namespace NSDocxRenderer
bool m_bIsGradient {false};
bool m_bUseDefaultFont {false};
bool m_bWriteStyleRaw {false};
bool m_bCollectMetaInfo {false};
bool m_bIsBuildTables {false};
bool m_bIsLuminosityShapesFiled{false};
bool m_bFontSubstitution {false};
CPage(NSFonts::IApplicationFonts* pAppFonts, const CManagers& oManagers);
~CPage();
@ -231,6 +229,6 @@ namespace NSDocxRenderer
std::vector<shape_ptr_t> m_arLuminosityShapes;
std::vector<shape_ptr_t> m_arOneColorGradientShape;
size_t m_nCurrentOrder = 0;
size_t m_nShapeOrder = 0;
};
}

View File

@ -50,8 +50,6 @@ namespace NSDocxRenderer
double m_dHeight {0.0};
double m_dWidth {0.0};
size_t m_nOrder = 0;
CBaseItem();
CBaseItem(const CBaseItem& other);
CBaseItem(CBaseItem&& other);

View File

@ -73,26 +73,11 @@ namespace NSDocxRenderer
m_bPossibleHorSplit = rCont.m_bPossibleHorSplit;
m_bWriteStyleRaw = rCont.m_bWriteStyleRaw;
m_nOriginFontFaceIndex = rCont.m_nOriginFontFaceIndex;
m_wsOriginFontName = rCont.m_nOriginFontFaceIndex;
m_arSymWidths.clear();
m_arSymWidths.resize(rCont.m_arSymWidths.size());
for (size_t i = 0; i < rCont.m_arSymWidths.size(); ++i)
m_arSymWidths[i] = rCont.m_arSymWidths[i];
m_arGids.clear();
m_arGids.resize(rCont.m_arGids.size());
for (size_t i = 0; i < rCont.m_arGids.size(); ++i)
m_arGids[i] = rCont.m_arGids[i];
m_arOriginLefts.clear();
m_arOriginLefts.resize(rCont.m_arOriginLefts.size());
for (size_t i = 0; i < rCont.m_arOriginLefts.size(); ++i)
m_arOriginLefts[i] = rCont.m_arOriginLefts[i];
m_bFontSubstitution = rCont.m_bFontSubstitution;
return *this;
}
@ -143,27 +128,13 @@ namespace NSDocxRenderer
cont->m_dWidth = cont->m_dRight - cont->m_dLeft;
cont->m_arSymWidths.clear();
cont->m_arOriginLefts.clear();
cont->m_arGids.clear();
for (size_t i = index + 1; i < len; ++i)
{
cont->m_arSymWidths.push_back(m_arSymWidths[i]);
cont->m_arOriginLefts.push_back(m_arOriginLefts[i]);
if (!m_arGids.empty() && cont->m_bCollectMetaInfo)
cont->m_arGids.push_back(m_arGids[i]);
}
m_oText = m_oText.substr(0, index + 1);
m_dRight = cont->m_dLeft;
m_dWidth = m_dRight - m_dLeft;
m_arSymWidths.resize(index + 1);
m_arOriginLefts.resize(index + 1);
if (!m_arGids.empty())
m_arGids.resize(index + 1);
m_bPossibleHorSplit = false;
return cont;
@ -499,42 +470,24 @@ namespace NSDocxRenderer
oWriter.WriteString(L"</a:t>");
if (m_bIsAddBrEnd) oWriter.WriteString(L"<a:br/>");
std::wstring origin_gids{};
for (auto& gid : m_arGids)
origin_gids += std::to_wstring(gid) + L";";
// Origin width string
std::wstring origin_lefts{};
for (auto& l : m_arOriginLefts)
origin_lefts += std::to_wstring(static_cast<int>(l * c_dMMToEMU)) + L";";
// meta info for pdf-editor
oWriter.WriteString(L"<metaorigin:pos");
oWriter.WriteString(L" x=\"");
oWriter.AddInt(static_cast<int>(m_dLeft * c_dMMToEMU));
oWriter.AddDouble(m_dLeft, 4);
oWriter.WriteString(L"\" y=\"");
oWriter.AddInt(static_cast<int>(m_dBot * c_dMMToEMU));
oWriter.AddDouble(m_dBot, 4);
oWriter.WriteString(L"\" widths=\"");
for (auto& w : m_arSymWidths)
{
oWriter.AddDouble(w, 4);
oWriter.WriteString(L",");
}
oWriter.WriteString(L"\" />");
oWriter.WriteString(L"<metaorigin:font ");
oWriter.WriteString(L" name=\"");
oWriter.WriteString(L" font=\"");
oWriter.WriteString(m_wsOriginFontName);
oWriter.WriteString(L"\" faceindex=\"");
oWriter.AddInt(m_nOriginFontFaceIndex);
oWriter.WriteString(L"\" />");
oWriter.WriteString(L"<metaorigin:syminfo");
oWriter.WriteString(L" lefts=\"");
oWriter.WriteString(origin_lefts);
oWriter.WriteString(L"\" gids=\"");
oWriter.WriteString(origin_gids);
oWriter.WriteString(L"\" />");
oWriter.WriteString(L"<metaorigin:fontsubstitution");
oWriter.WriteString(L" value=\"");
oWriter.AddInt(m_bFontSubstitution);
oWriter.WriteString(L"\" />");
oWriter.WriteString(L"</a:r>");
}
void CContText::ToBin(NSWasm::CData& oWriter) const
@ -555,31 +508,6 @@ namespace NSDocxRenderer
oWriter.WriteBYTE(0); oWriter.WriteStringUtf16(m_oText.ToStdWString());
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
// Meta-info
oWriter.StartRecord(111);
oWriter.WriteBYTE(kBin_g_nodeAttributeStart);
oWriter.WriteBYTE(0); oWriter.WriteStringUtf16(m_wsOriginFontName); // Origin font name
oWriter.WriteBYTE(1); oWriter.AddInt(m_nOriginFontFaceIndex); // Origin face index
oWriter.WriteBYTE(2); oWriter.AddSInt(static_cast<int>(m_dLeft * c_dMMToEMU)); // Origin left
oWriter.WriteBYTE(3); oWriter.AddSInt(static_cast<int>(m_dBot * c_dMMToEMU)); // Origin bot
std::wstring origin_gids{};
for (auto& gid : m_arGids)
origin_gids += std::to_wstring(gid) + L";";
oWriter.WriteBYTE(4); oWriter.WriteStringUtf16(origin_gids); // Origin gids string
// Origin width string
std::wstring origin_lefts{};
for (auto& l : m_arOriginLefts)
origin_lefts += std::to_wstring(static_cast<int>(l * c_dMMToEMU)) + L";";
oWriter.WriteBYTE(5); oWriter.WriteStringUtf16(origin_lefts); // Origin lefts
oWriter.WriteBYTE(6); oWriter.WriteBool(m_bFontSubstitution); // Font Substitution (just pass from pdf)
oWriter.WriteBYTE(kBin_g_nodeAttributeEnd);
oWriter.EndRecord();
// WriteRecord WriteRunProperties
[&oWriter, this, lCalculatedSpacing] () {
oWriter.StartRecord(0);
@ -736,10 +664,7 @@ namespace NSDocxRenderer
return text.length() == 1 && CContText::IsUnicodeDiacriticalMark(text.at(0));
}
void CContText::AddTextBack(const NSStringUtils::CStringUTF32& oText,
const std::vector<double>& arSymWidths,
const std::vector<unsigned int>& arGids,
const std::vector<double>& arOriginLefts)
void CContText::AddTextBack(const NSStringUtils::CStringUTF32& oText, const std::vector<double>& arSymWidths)
{
bool is_space_twice = m_oText.at(m_oText.length() - 1) == c_SPACE_SYM &&
oText.at(0) == c_SPACE_SYM;
@ -756,49 +681,20 @@ namespace NSDocxRenderer
m_arSymWidths.push_back(w);
m_dWidth += w;
m_oText += oText.at(i);
m_arOriginLefts.push_back(arOriginLefts[i]);
if (!arGids.empty() && m_bCollectMetaInfo)
m_arGids.push_back(arGids[i]);
}
m_dRight = m_dLeft + m_dWidth;
}
void CContText::AddTextFront(const NSStringUtils::CStringUTF32& oText,
const std::vector<double>& arSymWidths,
const std::vector<unsigned int>& arGids,
const std::vector<double>& arOriginLefts)
void CContText::AddTextFront(const NSStringUtils::CStringUTF32& oText, const std::vector<double>& arSymWidths)
{
m_oText = oText + m_oText;
double addtitional_width = 0;
for (auto& w : arSymWidths)
addtitional_width += w;
auto ar_sym_w = m_arSymWidths;
m_arSymWidths = arSymWidths;
for (auto& w : ar_sym_w)
m_arSymWidths.push_back(w);
m_dWidth += addtitional_width;
m_dLeft = m_dRight - m_dWidth;
if (!arGids.empty() && m_bCollectMetaInfo)
{
auto ar_gids = m_arGids;
m_arGids = arGids;
for (auto& gid : ar_gids)
m_arGids.push_back(gid);
}
auto ar_lefts = m_arOriginLefts;
m_arOriginLefts = arOriginLefts;
for (auto& left : ar_lefts)
m_arOriginLefts.push_back(left);
}
void CContText::SetText(const NSStringUtils::CStringUTF32& oText,
const std::vector<double>& arSymWidths,
std::vector<unsigned int>&& arGids,
std::vector<double>&& arOriginLefts)
void CContText::SetText(const NSStringUtils::CStringUTF32& oText, const std::vector<double>& arSymWidths)
{
m_oText = oText;
m_arSymWidths.clear();
@ -809,52 +705,32 @@ namespace NSDocxRenderer
m_dWidth += w;
}
m_dRight = m_dLeft + m_dWidth;
m_arOriginLefts = std::move(arOriginLefts);
if (m_bCollectMetaInfo)
m_arGids = std::move(arGids);
}
void CContText::AddSymBack(uint32_t cSym, double dWidth, double dLeft, unsigned int nGid)
void CContText::AddSymBack(uint32_t cSym, double dWidth)
{
bool is_space_twice = m_oText.at(m_oText.length() - 1) == c_SPACE_SYM && cSym == c_SPACE_SYM;
if (is_space_twice)
{
m_arSymWidths.back() += dWidth;
}
else
{
m_arSymWidths.push_back(dWidth);
m_oText += cSym;
m_arOriginLefts.push_back(dLeft);
if (m_bCollectMetaInfo)
{
m_arGids.push_back(nGid);
}
}
m_dWidth += dWidth;
m_dRight = m_dLeft + m_dWidth;
}
void CContText::AddSymFront(uint32_t cSym, double dWidth, double dLeft, unsigned int nGid)
void CContText::AddSymFront(uint32_t cSym, double dWidth)
{
NSStringUtils::CStringUTF32 text;
text += cSym;
text += m_oText;
m_oText = text;
m_dLeft -= dWidth;
m_dWidth = m_dRight - m_dLeft;
m_arSymWidths.insert(m_arSymWidths.begin(), dWidth);
m_arOriginLefts.insert(m_arOriginLefts.begin(), dLeft);
if (m_bCollectMetaInfo)
{
m_arGids.insert(m_arGids.begin(), nGid);
}
}
void CContText::SetSym(uint32_t cSym, double dWidth, double dLeft, unsigned int nGid)
void CContText::SetSym(uint32_t cSym, double dWidth)
{
m_oText = L"";
m_oText += cSym;
@ -862,18 +738,6 @@ namespace NSDocxRenderer
m_arSymWidths.push_back(dWidth);
m_dWidth = dWidth;
m_dRight = m_dLeft + m_dWidth;
m_arSymWidths.clear();
m_arSymWidths.push_back(dWidth);
m_arOriginLefts.clear();
m_arOriginLefts.push_back(dLeft);
if (m_bCollectMetaInfo)
{
m_arGids.clear();
m_arGids.push_back(nGid);
}
}
void CContText::RemoveLastSym()
{
@ -881,10 +745,6 @@ namespace NSDocxRenderer
m_dWidth -= m_arSymWidths[m_arSymWidths.size() - 1];
m_dRight = m_dLeft + m_dWidth;
m_arSymWidths.resize(m_arSymWidths.size() - 1);
m_arOriginLefts.resize(m_arOriginLefts.size() - 1);
if (!m_arGids.empty() && m_bCollectMetaInfo)
m_arGids.resize(m_arGids.size() - 1);
}
uint32_t CContText::GetLastSym() const
{
@ -901,7 +761,14 @@ namespace NSDocxRenderer
}
const std::vector<double> CContText::GetSymLefts() const noexcept
{
return m_arOriginLefts;
std::vector<double> lefts;
double left = m_dLeft;
for (auto& w : m_arSymWidths)
{
lefts.push_back(left);
left += w;
}
return lefts;
}
bool CContText::CheckFontEffects
@ -1137,42 +1004,19 @@ namespace NSDocxRenderer
const NSStructures::CBrush& oBrush,
CFontManager* pFontManager,
const NSStringUtils::CStringUTF32& oText,
size_t nOrder,
const PUINT pGids,
bool bForcedBold,
bool bUseDefaultFont,
bool bWriteStyleRaw,
bool bCollectMetaInfo,
bool bFontSubstitution)
bool bWriteStyleRaw)
{
double dWidth = dRight - dLeft;
double dHeight = dBot - dTop;
std::vector<unsigned int> gids;
if (bCollectMetaInfo)
{
for (size_t i = 0; i < oText.length(); ++i)
if (pGids)
gids.push_back(pGids[i]);
else
gids.push_back(0);
}
std::vector<double> origin_lefts;
double curr_origin_left = dLeft;
for (size_t i = 0; i < oText.length(); ++i)
{
origin_lefts.push_back(curr_origin_left);
curr_origin_left += dWidth / oText.length();
}
// if new text is close to current cont
if (m_pCurrCont != nullptr &&
fabs(m_pCurrCont->m_dBot - dBot) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
m_oPrevFont.IsEqual2(&oFont) &&
m_oPrevBrush.IsEqual(&oBrush) && !(
oText.length() == 1 && CContText::IsUnicodeDiacriticalMark(oText.at(0))) &&
bFontSubstitution == m_pCurrCont->m_bFontSubstitution)
oText.length() == 1 && CContText::IsUnicodeDiacriticalMark(oText.at(0))))
{
double avg_width = dWidth / oText.length();
@ -1196,7 +1040,7 @@ namespace NSDocxRenderer
for (size_t i = 0; i < oText.length(); ++i)
ar_widths.push_back(left_avg_width);
m_pCurrCont->AddTextBack(oText, ar_widths, gids, origin_lefts);
m_pCurrCont->AddTextBack(oText, ar_widths);
is_added = true;
}
@ -1208,7 +1052,7 @@ namespace NSDocxRenderer
for (size_t i = 0; i < oText.length(); ++i)
ar_widths.push_back(right_avg_width);
m_pCurrCont->AddTextFront(oText, ar_widths, gids, origin_lefts);
m_pCurrCont->AddTextFront(oText, ar_widths);
is_added = true;
}
@ -1218,7 +1062,6 @@ namespace NSDocxRenderer
m_pCurrCont->m_dBot = std::max(m_pCurrCont->m_dBot, dBot);
m_pCurrCont->m_dHeight = m_pCurrCont->m_dBot - m_pCurrCont->m_dTop;
m_pCurrCont->m_dWidth = m_pCurrCont->m_dRight - m_pCurrCont->m_dLeft;
m_pCurrCont->m_nOrder = nOrder;
return;
}
}
@ -1251,8 +1094,7 @@ namespace NSDocxRenderer
ar_widths.push_back(avg_width);
}
pCont->m_bCollectMetaInfo = bCollectMetaInfo;
pCont->SetText(oText, ar_widths, std::move(gids), std::move(origin_lefts));
pCont->SetText(oText, ar_widths);
pCont->m_bIsRtl = CContText::IsUnicodeRtl(oText.at(0));
pCont->m_dWidth = dWidth;
@ -1262,12 +1104,10 @@ namespace NSDocxRenderer
double em_height = oMetrics.dEmHeight;
double ratio = font_size / em_height * c_dPtToMM;
pCont->m_dTopWithAscent = pCont->m_dBot - (oMetrics.dAscent * ratio);
pCont->m_dBotWithDescent = pCont->m_dBot + (oMetrics.dDescent * ratio);
pCont->m_dTopWithAscent = pCont->m_dBot - (oMetrics.dAscent * ratio) - oMetrics.dBaselineOffset;
pCont->m_dBotWithDescent = pCont->m_dBot + (oMetrics.dDescent * ratio) - oMetrics.dBaselineOffset;
pCont->m_dSpaceWidthMM = pFontManager->GetSpaceWidthMM();
pCont->m_wsOriginFontName = oFont.Name;
pCont->m_nOriginFontFaceIndex = oFont.FaceIndex;
if (bUseDefaultFont)
{
@ -1284,8 +1124,6 @@ namespace NSDocxRenderer
pCont->m_oSelectedFont.Italic = m_pFontSelector->IsSelectedItalic();
}
pCont->m_bWriteStyleRaw = bWriteStyleRaw;
pCont->m_bFontSubstitution = bFontSubstitution;
pCont->m_nOrder = nOrder;
if (pCont->IsDiacritical())
{

View File

@ -63,7 +63,6 @@ namespace NSDocxRenderer
// origin font
std::wstring m_wsOriginFontName{};
int m_nOriginFontFaceIndex{};
// sizes
double m_dSpaceWidthMM{0};
@ -77,11 +76,6 @@ namespace NSDocxRenderer
bool m_bIsAddBrEnd{false};
bool m_bWriteStyleRaw{false};
bool m_bPossibleHorSplit{false};
bool m_bCollectMetaInfo{false};
std::vector<unsigned int> m_arGids{};
std::vector<double> m_arOriginLefts{};
bool m_bFontSubstitution = false;
CContText() = default;
CContText(CFontManager* pManager) : m_pManager(pManager) {}
@ -98,23 +92,13 @@ namespace NSDocxRenderer
void CalcSelected();
size_t GetLength() const noexcept;
void AddTextBack(const NSStringUtils::CStringUTF32& oText,
const std::vector<double>& arSymWidths,
const std::vector<unsigned int>& arGids,
const std::vector<double>& arOriginLefts);
void AddTextFront(const NSStringUtils::CStringUTF32& oText,
const std::vector<double>& arSymWidths,
const std::vector<unsigned int>& arGids,
const std::vector<double>& arOriginLefts);
void SetText(const NSStringUtils::CStringUTF32& oText,
const std::vector<double>& arSymWidths,
std::vector<unsigned int>&& arGids,
std::vector<double>&& arOriginLefts);
void AddSymBack(uint32_t cSym, double dWidth, double dLeft, unsigned int nGid = 0);
void AddSymFront(uint32_t cSym, double dWidth, double dLeft, unsigned int nGid = 0);
void SetSym(uint32_t cSym, double dWidth, double dLeft, unsigned int nGid = 0);
void AddTextBack(const NSStringUtils::CStringUTF32& oText, const std::vector<double>& arSymWidths);
void AddTextFront(const NSStringUtils::CStringUTF32& oText, const std::vector<double>& arSymWidths);
void SetText(const NSStringUtils::CStringUTF32& oText, const std::vector<double>& arSymWidths);
void AddSymBack(uint32_t cSym, double dWidth);
void AddSymFront(uint32_t cSym, double dWidth);
void SetSym(uint32_t cSym, double dWidth);
void RemoveLastSym();
uint32_t GetLastSym() const;
@ -188,13 +172,9 @@ namespace NSDocxRenderer
const NSStructures::CBrush& oBrush,
CFontManager* pFontManager,
const NSStringUtils::CStringUTF32& oText,
size_t nOrder = 0,
const PUINT pGids = nullptr,
bool bForcedBold = false,
bool bUseDefaultFont = false,
bool bWriteStyleRaw = false,
bool bCollectMetaInfo = false,
bool bFontSubstitution = false);
bool bWriteStyleRaw = false);
void NullCurrCont();
void Clear();

View File

@ -313,7 +313,7 @@ namespace NSDocxRenderer
auto last_sym = text[text.length() - 1];
if (last_sym != c_SPACE_SYM && m_arTextLines.size() != 1)
pLastCont->AddSymBack(c_SPACE_SYM, 0, pLastCont->m_dRight, 0);
pLastCont->AddSymBack(c_SPACE_SYM, 0);
}
}
}

View File

@ -46,6 +46,7 @@ namespace NSDocxRenderer
std::wstring m_strDstMedia {};
double m_dRotation {0.0};
size_t m_nOrder {0};
bool m_bIsNoFill {true};
bool m_bIsNoStroke {true};

View File

@ -21,7 +21,6 @@ namespace NSDocxRenderer
{
RecalcWithNewItem(oCont.get());
m_arConts.push_back(oCont);
m_nOrder = std::max(m_nOrder, oCont->m_nOrder);
}
void CTextLine::AddConts(const std::vector<std::shared_ptr<CContText>>& arConts)
{
@ -113,7 +112,7 @@ namespace NSDocxRenderer
wide_space->m_dHeight = pCurrent->m_dHeight;
wide_space->SetSym(c_SPACE_SYM, wide_space->m_dRight - wide_space->m_dLeft, wide_space->m_dLeft, 0);
wide_space->SetSym(c_SPACE_SYM, wide_space->m_dRight - wide_space->m_dLeft);
wide_space->m_pFontStyle = pFirst->m_pFontStyle;
wide_space->m_pShape = nullptr;
wide_space->m_iNumDuplicates = 0;
@ -147,12 +146,12 @@ namespace NSDocxRenderer
{
if (!bIsSpaceDelta)
{
pFirst->AddTextBack(pCurrent->GetText(), pCurrent->GetSymWidths(), pCurrent->m_arGids, pCurrent->m_arOriginLefts);
pFirst->AddTextBack(pCurrent->GetText(), pCurrent->GetSymWidths());
}
else
{
pFirst->AddSymBack(c_SPACE_SYM, pCurrent->m_dLeft - pFirst->m_dRight, pFirst->m_dRight, 0);
pFirst->AddTextBack(pCurrent->GetText(), pCurrent->GetSymWidths(), pCurrent->m_arGids, pCurrent->m_arOriginLefts);
pFirst->AddSymBack(c_SPACE_SYM, pCurrent->m_dLeft - pFirst->m_dRight);
pFirst->AddTextBack(pCurrent->GetText(), pCurrent->GetSymWidths());
}
if (pFirst->m_pCont.expired())
@ -167,9 +166,9 @@ namespace NSDocxRenderer
if (bIsSpaceDelta)
{
if (pFirst->GetNumberOfFeatures() <= pCurrent->GetNumberOfFeatures())
pFirst->AddSymBack(c_SPACE_SYM, pCurrent->m_dLeft - pFirst->m_dRight, pFirst->m_dRight, 0);
pFirst->AddSymBack(c_SPACE_SYM, pCurrent->m_dLeft - pFirst->m_dRight);
else
pCurrent->AddSymFront(c_SPACE_SYM, pCurrent->m_dLeft - pFirst->m_dRight, pFirst->m_dRight, 0);
pCurrent->AddSymFront(c_SPACE_SYM, pCurrent->m_dLeft - pFirst->m_dRight);
}
pFirst = pCurrent;
}

View File

@ -288,8 +288,7 @@ struct CTextSettings
CTextSettings(const CTextSettings& oTS) :
bBdo(oTS.bBdo), bPre(oTS.bPre), bQ(oTS.bQ), bAddSpaces(oTS.bAddSpaces), bMergeText(oTS.bMergeText),
nLi(oTS.nLi), bNumberingLi(oTS.bNumberingLi), sPStyle(oTS.sPStyle), eTextMode(oTS.eTextMode),
oAdditionalStyle(oTS.oAdditionalStyle)
nLi(oTS.nLi), bNumberingLi(oTS.bNumberingLi), sPStyle(oTS.sPStyle), eTextMode(oTS.eTextMode)
{}
void AddPStyle(const std::wstring& wsStyle)
@ -332,12 +331,12 @@ void WriteEmptyParagraph(NSStringUtils::CStringBuilder* pXml, bool bVahish = fal
if (!bInP)
pXml->WriteString(L"<w:p><w:pPr>");
pXml->WriteString(L"<w:rPr><w:rFonts w:eastAsia=\"Times New Roman\"/>");
pXml->WriteString(L"<w:r><w:rPr><w:rFonts w:eastAsia=\"Times New Roman\"/>");
if (bVahish)
pXml->WriteString(L"<w:sz w:val=\"2\"/><w:szCs w:val=\"2\"/><w:vanish/>");
pXml->WriteString(L"<w:vanish/>");
pXml->WriteString(L"</w:rPr>");
pXml->WriteString(L"</w:rPr></w:r>");
if (!bInP)
pXml->WriteString(L"</w:pPr></w:p>");
@ -1405,123 +1404,6 @@ void ReplaceSpaces(std::wstring& wsValue)
}
}
std::wstring StandardizeHeaderId(const std::wstring& header)
{
if (header.empty())
return std::wstring();
std::wstring result;
result.reserve(header.size());
// Флаг, указывающий, был ли предыдущий символ дефисом
bool prevWasHyphen = false;
bool inWhitespaceSequence = false;
wchar_t lowerC;
for (wchar_t c : header)
{
// Приведение к нижнему регистру
lowerC = std::tolower(c);
// Проверяем, является ли символ буквой или цифрой
if (std::iswalnum(lowerC))
{
result.push_back(lowerC);
prevWasHyphen = false;
inWhitespaceSequence = false;
}
// Проверяем, является ли символ пробельным (пробел, табуляция и т.д.)
else if (std::iswspace(lowerC))
{
// Заменяем последовательности пробельных символов на один дефис
if (!inWhitespaceSequence && !result.empty())
{
result.push_back(L'-');
inWhitespaceSequence = true;
}
}
// Проверяем, является ли символ дефисом или подчеркиванием
else if (c == L'-' || c == L'_')
{
// Добавляем дефис, если предыдущий символ не был дефисом
if (!prevWasHyphen && !result.empty())
{
result.push_back(L'-');
prevWasHyphen = true;
}
inWhitespaceSequence = false;
}
// Все остальные символы (знаки препинания) пропускаем
// Но если это буква в Unicode, мы можем её обработать
else if (std::iswalpha(lowerC))
{
// Для Unicode-символов, которые являются буквами
result.push_back(lowerC);
prevWasHyphen = false;
inWhitespaceSequence = false;
}
// Остальные символы игнорируем
}
// Удаляем дефисы в начале и конце
size_t start = 0;
size_t end = result.length();
while (start < end && result[start] == L'-')
++start;
while (end > start && result[end - 1] == L'-')
--end;
// Удаляем последовательные дефисы
std::wstring finalResult;
finalResult.reserve(end - start);
bool lastWasHyphen = false;
for (size_t i = start; i < end; i++)
{
if (result[i] == L'-')
{
if (!lastWasHyphen)
{
finalResult.push_back(L'-');
lastWasHyphen = true;
}
}
else
{
finalResult.push_back(result[i]);
lastWasHyphen = false;
}
}
return finalResult;
}
bool ElementInHeader(const std::vector<NSCSS::CNode> arSelsectors)
{
for (const NSCSS::CNode& oNode : arSelsectors)
{
if (2 != oNode.m_wsName.length() && L'h' != oNode.m_wsName[0])
continue;
switch (GetHtmlTag(oNode.m_wsName))
{
case HTML_TAG(H1):
case HTML_TAG(H2):
case HTML_TAG(H3):
case HTML_TAG(H4):
case HTML_TAG(H5):
case HTML_TAG(H6):
return true;
default:
continue;
}
}
return false;
}
std::wstring EncodeXmlString(const std::wstring& s)
{
std::wstring sRes = s;
@ -1563,11 +1445,6 @@ bool CanUseThisPath(const std::wstring& wsPath, const std::wstring& wsSrcPath, c
return true;
}
bool UnreadableNode(const std::wstring& wsNodeName)
{
return L"head" == wsNodeName || L"meta" == wsNodeName || L"style" == wsNodeName;
}
class CHtmlFile2_Private
{
public:
@ -1590,9 +1467,6 @@ private:
int m_nId; // ID остальные элементы
int m_nShapeId; // Id shape's
using anchors_map = std::map<std::wstring, std::wstring>;
anchors_map m_mAnchors; // Map якорей с индивидуальными id
NSStringUtils::CStringBuilder m_oStylesXml; // styles.xml
NSStringUtils::CStringBuilder m_oDocXmlRels; // document.xml.rels
NSStringUtils::CStringBuilder m_oNoteXmlRels; // footnotes.xml.rels
@ -1612,10 +1486,8 @@ private:
bool m_bBanUpdatePageData; // Запретить обновление данных о странице?
HtmlTag m_eLastElement;
TState()
: m_bInP(false), m_bInR(false), m_bInT(false), m_bWasPStyle(false), m_bWasSpace(true), m_bInHyperlink(false), m_bBanUpdatePageData(false), m_eLastElement(HTML_TAG(UNKNOWN))
: m_bInP(false), m_bInR(false), m_bInT(false), m_bWasPStyle(false), m_bWasSpace(true), m_bInHyperlink(false), m_bBanUpdatePageData(false)
{}
} m_oState;
@ -2306,18 +2178,10 @@ private:
m_oState.m_bWasSpace = true;
}
std::wstring AddAnchor(const std::wstring& wsAnchorValue)
{
const std::wstring wsAnchorId{L"anchor-" + std::to_wstring(m_mAnchors.size() + 1)};
m_mAnchors[wsAnchorValue] = wsAnchorId;
return wsAnchorId;
}
std::wstring WriteBookmark(NSStringUtils::CStringBuilder* pXml, const std::wstring& wsId)
void WriteBookmark(NSStringUtils::CStringBuilder* pXml, const std::wstring& wsId)
{
if (NULL == pXml)
return std::wstring();
return;
const std::wstring sCrossId = std::to_wstring(m_mBookmarks.size() + 1);
std::wstring sName;
@ -2326,13 +2190,7 @@ private:
sName = wsId + L"_" + std::to_wstring(++m_mBookmarks[wsId]);
else
{
const anchors_map::const_iterator itFound{m_mAnchors.find(wsId)};
if (m_mAnchors.end() != itFound)
sName = itFound->second;
else
sName = AddAnchor(wsId);
sName = wsId;
m_mBookmarks.insert({wsId, 1});
}
@ -2340,20 +2198,8 @@ private:
pXml->WriteString(sCrossId);
pXml->WriteString(L"\" w:name=\"");
pXml->WriteEncodeXmlString(sName);
pXml->WriteString(L"\"/>");
return sCrossId;
}
void WriteEmptyBookmark(NSStringUtils::CStringBuilder* pXml, const std::wstring& wsId)
{
const std::wstring wsCrossId{WriteBookmark(pXml, wsId)};
if (wsCrossId.empty())
return;
pXml->WriteString(L"<w:bookmarkEnd w:id=\"");
pXml->WriteString(wsCrossId);
pXml->WriteString(L"\"/><w:bookmarkEnd w:id=\"");
pXml->WriteString(sCrossId);
pXml->WriteString(L"\"/>");
}
@ -2433,7 +2279,7 @@ private:
else if(sName == L"id")
{
oNode.m_wsId = EncodeXmlString(m_oLightReader.GetText());
WriteEmptyBookmark(oXml, oNode.m_wsId);
WriteBookmark(oXml, oNode.m_wsId);
if (!m_oStylesCalculator.HaveStylesById(oNode.m_wsId))
oNode.m_wsId.clear();
@ -2556,11 +2402,6 @@ private:
if (!bPre && sText.end() == std::find_if_not(sText.begin(), sText.end(), [](wchar_t wchChar){ return iswspace(wchChar) && 0xa0 != wchChar;}))
return false;
std::wstring wsHeaderId;
if (ElementInHeader(arSelectors))
wsHeaderId = StandardizeHeaderId(sText);
if(oTS.bBdo)
std::reverse(sText.begin(), sText.end());
@ -2577,11 +2418,6 @@ private:
WriteToStringBuilder(oPPr, *pXml);
std::wstring wsCrossId;
if (!wsHeaderId.empty())
WriteEmptyBookmark(pXml, wsHeaderId);
NSStringUtils::CStringBuilder oRPr;
std::wstring sRStyle;
@ -3230,10 +3066,11 @@ private:
bool readInside (NSStringUtils::CStringBuilder* oXml, std::vector<NSCSS::CNode>& sSelectors, CTextSettings& oTS, const std::wstring& sName)
{
//TODO:: обработать все варианты return'а
if(sName == L"#text")
return ReadText(oXml, sSelectors, oTS);
if (UnreadableNode(sName) || TagIsUnprocessed(sName))
if (TagIsUnprocessed(sName))
return false;
std::wstring sNote = GetSubClass(oXml, sSelectors);
@ -3541,12 +3378,7 @@ private:
}
if (HTML_TAG(DIV) != eHtmlTag && HTML_TAG(ASIDE) != eHtmlTag)
{
if (bResult)
m_oState.m_eLastElement = eHtmlTag;
m_oState.m_bBanUpdatePageData = true;
}
readNote(oXml, sSelectors, sNote);
sSelectors.pop_back();
@ -3923,9 +3755,6 @@ private:
if(m_oLightReader.IsEmptyNode())
return false;
if (HTML_TAG(TABLE) == m_oState.m_eLastElement)
WriteEmptyParagraph(oXml, true);
CTable oTable;
CTextSettings oTextSettings{oTS};
oTextSettings.sPStyle.clear();
@ -4042,6 +3871,7 @@ private:
oTable.Shorten();
oTable.CompleteTable();
oTable.ConvertToOOXML(*oXml);
WriteEmptyParagraph(oXml, true);
return true;
}
@ -4082,6 +3912,9 @@ private:
bool ReadListElement(NSStringUtils::CStringBuilder* oXml, std::vector<NSCSS::CNode>& arSelectors, CTextSettings& oTS)
{
if (OpenP(oXml))
wrP(oXml, arSelectors, oTS);
const bool bResult{readStream(oXml, arSelectors, oTS)};
CloseP(oXml, arSelectors);
@ -4094,6 +3927,8 @@ private:
if(m_oLightReader.IsEmptyNode())
return false;
GetSubClass(oXml, arSelectors);
CloseP(oXml, arSelectors);
CTextSettings oTSLi(oTS);
@ -4134,8 +3969,6 @@ private:
m_oNumberXml.WriteString(wsStart);
m_oNumberXml.WriteString(L"\"/><w:numFmt w:val=\"decimal\"/><w:isLgl w:val=\"false\"/><w:suff w:val=\"tab\"/><w:lvlText w:val=\"%9.\"/><w:lvlJc w:val=\"right\"/><w:pPr><w:ind w:left=\"6469\" w:hanging=\"180\"/></w:pPr></w:lvl></w:abstractNum>");
}
else
oTSLi.bNumberingLi = false;
CTextSettings oTSList{oTSLi};
@ -4157,6 +3990,7 @@ private:
}
CloseP(oXml, arSelectors);
arSelectors.pop_back();
return true;
}
@ -4324,28 +4158,12 @@ private:
if(bCross)
{
m_oState.m_bInHyperlink = true;
oXml->WriteString(L"<w:hyperlink w:anchor=\"");
oXml->WriteString(L"<w:hyperlink w:tooltip=\"Current Document\" w:anchor=\"");
size_t nSharp = sRef.find('#');
std::wstring wsAnchorValue;
if(nSharp == std::wstring::npos)
wsAnchorValue = NSFile::GetFileName(sRef);
oXml->WriteString(NSFile::GetFileName(sRef));
else
wsAnchorValue = (sRef.c_str() + nSharp + 1);
if (!wsAnchorValue.empty())
{
const anchors_map::iterator itFound = m_mAnchors.find(wsAnchorValue);
std::wstring wsAnchorId;
if (m_mAnchors.end() != itFound)
wsAnchorId = itFound->second;
else
wsAnchorId = AddAnchor(wsAnchorValue);
oXml->WriteEncodeXmlString(wsAnchorId);
}
oXml->WriteEncodeXmlString(sRef.c_str() + nSharp + 1);
}
// Внешняя ссылка
else
@ -4744,21 +4562,11 @@ private:
if (!m_oState.m_bInP)
return L"";
NSCSS::CCompiledStyle oMainStyle{*sSelectors.back().m_pCompiledStyle};
std::wstring sRSettings;
std::wstring sRStyle = GetStyle(*sSelectors.back().m_pCompiledStyle, false);
std::wstring sRStyle = GetStyle(oMainStyle, false);
if (!oTS.oAdditionalStyle.Empty())
{
NSCSS::CCompiledStyle oSettingStyle{oTS.oAdditionalStyle};
NSCSS::CCompiledStyle::StyleEquation(oMainStyle, oSettingStyle);
m_oXmlStyle.WriteLiteRStyle(oSettingStyle);
sRSettings = m_oXmlStyle.GetStyle();
m_oXmlStyle.Clear();
}
m_oXmlStyle.WriteLiteRStyle(oTS.oAdditionalStyle);
const std::wstring sRSettings = m_oXmlStyle.GetStyle();
m_oXmlStyle.Clear();
std::wstring wsFontSize;
@ -4766,7 +4574,7 @@ private:
if (0 != nCalculatedFontChange)
{
int nFontSizeLevel{static_cast<int>((oMainStyle.m_oFont.Empty()) ? 3 : GetFontSizeLevel(oMainStyle.m_oFont.GetSize().ToInt(NSCSS::Point) * 2))};
int nFontSizeLevel{static_cast<int>((sSelectors.back().m_pCompiledStyle->m_oFont.Empty()) ? 3 : GetFontSizeLevel(sSelectors.back().m_pCompiledStyle->m_oFont.GetSize().ToInt(NSCSS::Point) * 2))};
nFontSizeLevel += nCalculatedFontChange;

View File

@ -22,58 +22,6 @@ DEFINES += HWPFILE_USE_DYNAMIC_LIBRARY \
SOURCES += \
HWPFile.cpp \
HwpDoc/Chart/Attribute.cpp \
HwpDoc/Chart/Axis.cpp \
HwpDoc/Chart/Backdrop.cpp \
HwpDoc/Chart/Bar.cpp \
HwpDoc/Chart/Brush.cpp \
HwpDoc/Chart/CategoryScale.cpp \
HwpDoc/Chart/ChartReader.cpp \
HwpDoc/Chart/ChartStream.cpp \
HwpDoc/Chart/Contour.cpp \
HwpDoc/Chart/ContourGradient.cpp \
HwpDoc/Chart/Coor.cpp \
HwpDoc/Chart/Coor3.cpp \
HwpDoc/Chart/DataGrid.cpp \
HwpDoc/Chart/DataPoint.cpp \
HwpDoc/Chart/DateScale.cpp \
HwpDoc/Chart/Doughnut.cpp \
HwpDoc/Chart/Elevation.cpp \
HwpDoc/Chart/Fill.cpp \
HwpDoc/Chart/Footnote.cpp \
HwpDoc/Chart/Frame.cpp \
HwpDoc/Chart/Gradient.cpp \
HwpDoc/Chart/HiLo.cpp \
HwpDoc/Chart/Intersection.cpp \
HwpDoc/Chart/LCoor.cpp \
HwpDoc/Chart/LRect.cpp \
HwpDoc/Chart/Label.cpp \
HwpDoc/Chart/Legend.cpp \
HwpDoc/Chart/Light.cpp \
HwpDoc/Chart/Location.cpp \
HwpDoc/Chart/Marker.cpp \
HwpDoc/Chart/Pen.cpp \
HwpDoc/Chart/Pie.cpp \
HwpDoc/Chart/Plot.cpp \
HwpDoc/Chart/Position.cpp \
HwpDoc/Chart/PrintInformation.cpp \
HwpDoc/Chart/Rect.cpp \
HwpDoc/Chart/Series.cpp \
HwpDoc/Chart/Shadow.cpp \
HwpDoc/Chart/StatLine.cpp \
HwpDoc/Chart/Surface.cpp \
HwpDoc/Chart/TextLayout.cpp \
HwpDoc/Chart/Tick.cpp \
HwpDoc/Chart/Title.cpp \
HwpDoc/Chart/ValueScale.cpp \
HwpDoc/Chart/View3D.cpp \
HwpDoc/Chart/VtChart.cpp \
HwpDoc/Chart/VtColor.cpp \
HwpDoc/Chart/VtFont.cpp \
HwpDoc/Chart/VtPicture.cpp \
HwpDoc/Chart/Wall.cpp \
HwpDoc/Chart/Weighting.cpp \
HwpDoc/Chart/XYZ.cpp \
HwpDoc/Common/XMLReader.cpp \
HwpDoc/Common/WriterContext.cpp \
HwpDoc/Conversion/Converter2OOXML.cpp \
@ -151,61 +99,6 @@ SOURCES += \
HEADERS += \
HWPFile.h \
HwpDoc/Chart/Attribute.h \
HwpDoc/Chart/Axis.h \
HwpDoc/Chart/Backdrop.h \
HwpDoc/Chart/Bar.h \
HwpDoc/Chart/Brush.h \
HwpDoc/Chart/CategoryScale.h \
HwpDoc/Chart/CharCommon.h \
HwpDoc/Chart/ChartObject.h \
HwpDoc/Chart/ChartReader.h \
HwpDoc/Chart/ChartStream.h \
HwpDoc/Chart/Contour.h \
HwpDoc/Chart/ContourGradient.h \
HwpDoc/Chart/Coor.h \
HwpDoc/Chart/Coor3.h \
HwpDoc/Chart/DataGrid.h \
HwpDoc/Chart/DataPoint.h \
HwpDoc/Chart/DateScale.h \
HwpDoc/Chart/Doughnut.h \
HwpDoc/Chart/Elevation.h \
HwpDoc/Chart/Fill.h \
HwpDoc/Chart/Footnote.h \
HwpDoc/Chart/Frame.h \
HwpDoc/Chart/Gradient.h \
HwpDoc/Chart/HiLo.h \
HwpDoc/Chart/Intersection.h \
HwpDoc/Chart/LCoor.h \
HwpDoc/Chart/LRect.h \
HwpDoc/Chart/Label.h \
HwpDoc/Chart/Legend.h \
HwpDoc/Chart/Light.h \
HwpDoc/Chart/Location.h \
HwpDoc/Chart/Marker.h \
HwpDoc/Chart/Pen.h \
HwpDoc/Chart/Pie.h \
HwpDoc/Chart/Plot.h \
HwpDoc/Chart/Position.h \
HwpDoc/Chart/PrintInformation.h \
HwpDoc/Chart/Rect.h \
HwpDoc/Chart/Series.h \
HwpDoc/Chart/Shadow.h \
HwpDoc/Chart/StatLine.h \
HwpDoc/Chart/Surface.h \
HwpDoc/Chart/TextLayout.h \
HwpDoc/Chart/Tick.h \
HwpDoc/Chart/Title.h \
HwpDoc/Chart/Types.h \
HwpDoc/Chart/ValueScale.h \
HwpDoc/Chart/View3D.h \
HwpDoc/Chart/VtChart.h \
HwpDoc/Chart/VtColor.h \
HwpDoc/Chart/VtFont.h \
HwpDoc/Chart/VtPicture.h \
HwpDoc/Chart/Wall.h \
HwpDoc/Chart/Weighting.h \
HwpDoc/Chart/XYZ.h \
HwpDoc/Common/Common.h \
HwpDoc/Common/NodeNames.h \
HwpDoc/Common/WriterContext.h \

View File

@ -1,15 +0,0 @@
#include "Attribute.h"
namespace HWP { namespace CHART
{
CAttribute::CAttribute()
{
}
bool CAttribute::Read(CChartStream& oStream)
{
return m_oBrush.Read(oStream) && m_oPen.Read(oStream) &&
oStream.ReadString(m_sText) && oStream.ReadDouble(m_dValue);
}
}}

View File

@ -1,25 +0,0 @@
#ifndef ATTRIBUTE_H
#define ATTRIBUTE_H
#include "Brush.h"
#include "Pen.h"
#include "Collection.h"
namespace HWP { namespace CHART
{
class CAttribute : public IChartObject
{
CBrush m_oBrush;
CPen m_oPen;
CHART_STRING m_sText;
CHART_DOUBLE m_dValue;
public:
CAttribute();
bool Read(CChartStream& oStream) override;
};
using CAttributes = CCollection<CAttribute>;
}}
#endif // ATTRIBUTE_H

View File

@ -1,51 +0,0 @@
#include "Axis.h"
namespace HWP { namespace CHART
{
CAxisGrid::CAxisGrid()
{
}
bool CAxisGrid::Read(CChartStream& oStream)
{
return m_oMajorPen.Read(oStream) && m_oMinorPen.Read(oStream);
}
CAxisScale::CAxisScale()
{
}
bool CAxisScale::Read(CChartStream& oStream)
{
return oStream.ReadBoolean(m_bHide) && oStream.ReadInteger(m_nLogBase) &&
oStream.ReadString(m_sPercentBasis) && oStream.ReadInteger(m_nType);
}
CAxisTitle::CAxisTitle()
{
}
bool CAxisTitle::Read(CChartStream& oStream)
{
return m_oBackdrop.Read(oStream) && oStream.ReadString(m_sText) &&
m_oTextLayout.Read(oStream) && oStream.ReadInteger(m_nTextLength) &&
oStream.ReadBoolean(m_bVisible) && m_oVtFont.Read(oStream);
}
CAxis::CAxis()
{
}
bool CAxis::Read(CChartStream& oStream)
{
return m_oAxisGrid.Read(oStream) && m_oAxisScale.Read(oStream) &&
m_oAxisTitle.Read(oStream) && m_oCategoryScale.Read(oStream) &&
m_oDateScale.Read(oStream) && m_oIntersection.Read(oStream) &&
m_oLabels.Read(oStream) && oStream.ReadInteger(m_nLabelLevelCount) &&
m_oPen.Read(oStream) && m_oTick.Read(oStream) && m_oValueScale.Read(oStream);
}
}}

View File

@ -1,73 +0,0 @@
#ifndef AXIS_H
#define AXIS_H
#include "Pen.h"
#include "VtFont.h"
#include "Backdrop.h"
#include "TextLayout.h"
#include "CategoryScale.h"
#include "DateScale.h"
#include "Intersection.h"
#include "Label.h"
#include "Tick.h"
#include "ValueScale.h"
namespace HWP { namespace CHART
{
class CAxisGrid : public IChartObject
{
CPen m_oMajorPen;
CPen m_oMinorPen;
public:
CAxisGrid();
bool Read(CChartStream& oStream) override;
};
class CAxisScale : public IChartObject
{
CHART_BOOLEAN m_bHide;
CHART_INTEGER m_nLogBase;
CHART_STRING m_sPercentBasis;
CHART_INTEGER m_nType;
public:
CAxisScale();
bool Read(CChartStream& oStream) override;
};
class CAxisTitle : public IChartObject
{
CBackdrop m_oBackdrop;
CHART_STRING m_sText;
CTextLayout m_oTextLayout;
CHART_INTEGER m_nTextLength;
CHART_BOOLEAN m_bVisible;
CVtFont m_oVtFont;
public:
CAxisTitle();
bool Read(CChartStream& oStream) override;
};
class CAxis : public IChartObject
{
CAxisGrid m_oAxisGrid;
CAxisScale m_oAxisScale;
CAxisTitle m_oAxisTitle;
CCategoryScale m_oCategoryScale;
CDateScale m_oDateScale;
CIntersection m_oIntersection;
CLabels m_oLabels;
CHART_INTEGER m_nLabelLevelCount;
CPen m_oPen;
CTick m_oTick;
CValueScale m_oValueScale;
public:
CAxis();
bool Read(CChartStream& oStream) override;
};
}}
#endif // AXIS_H

View File

@ -1,14 +0,0 @@
#include "Backdrop.h"
namespace HWP { namespace CHART
{
CBackdrop::CBackdrop()
{
}
bool CBackdrop::Read(CChartStream& oStream)
{
return m_oFrame.Read(oStream) && m_oFill.Read(oStream) && m_oShadow.Read(oStream);
}
}}

View File

@ -1,22 +0,0 @@
#ifndef BACKDROP_H
#define BACKDROP_H
#include "Frame.h"
#include "Fill.h"
#include "Shadow.h"
namespace HWP { namespace CHART
{
class CBackdrop : public IChartObject
{
CFrame m_oFrame;
CFill m_oFill;
CShadow m_oShadow;
public:
CBackdrop();
bool Read(CChartStream& oStream) override;
};
}}
#endif // BACKDROP_H

View File

@ -1,14 +0,0 @@
#include "Bar.h"
namespace HWP { namespace CHART
{
CBar::CBar()
{
}
bool CBar::Read(CChartStream& oStream)
{
return oStream.ReadInteger(m_nSides) && oStream.ReadSingle(m_snTopRatio);
}
}}

View File

@ -1,19 +0,0 @@
#ifndef BAR_H
#define BAR_H
#include "ChartObject.h"
namespace HWP { namespace CHART
{
class CBar : public IChartObject
{
CHART_INTEGER m_nSides;
CHART_SINGLE m_snTopRatio;
public:
CBar();
bool Read(CChartStream& oStream) override;
};
}}
#endif // BAR_H

View File

@ -1,15 +0,0 @@
#include "Brush.h"
namespace HWP { namespace CHART
{
CBrush::CBrush()
{
}
bool CBrush::Read(CChartStream& oStream)
{
return m_oFillColor.Read(oStream) && oStream.ReadInteger(m_nIndex) &&
m_oPatternColor.Read(oStream) && oStream.ReadInteger(m_nStyle);
}
}}

View File

@ -1,21 +0,0 @@
#ifndef BRUSH_H
#define BRUSH_H
#include "VtColor.h"
namespace HWP { namespace CHART
{
class CBrush : public IChartObject
{
CVtColor m_oFillColor;
CHART_INTEGER m_nIndex;
CVtColor m_oPatternColor;
CHART_INTEGER m_nStyle;
public:
CBrush();
bool Read(CChartStream& oStream) override;
};
}}
#endif // BRUSH_H

View File

@ -1,15 +0,0 @@
#include "CategoryScale.h"
namespace HWP { namespace CHART
{
CCategoryScale::CCategoryScale()
{
}
bool CCategoryScale::Read(CChartStream& oStream)
{
return oStream.ReadBoolean(m_bAuto) && oStream.ReadInteger(m_nDivisionsPerLabel) &&
oStream.ReadInteger(m_nDivisionsPerTick) && oStream.ReadBoolean(m_bLabelTick);
}
}}

View File

@ -1,21 +0,0 @@
#ifndef CATEGORYSCALE_H
#define CATEGORYSCALE_H
#include "ChartObject.h"
namespace HWP { namespace CHART
{
class CCategoryScale : public IChartObject
{
CHART_BOOLEAN m_bAuto;
CHART_INTEGER m_nDivisionsPerLabel;
CHART_INTEGER m_nDivisionsPerTick;
CHART_BOOLEAN m_bLabelTick;
public:
CCategoryScale();
bool Read(CChartStream& oStream) override;
};
}}
#endif // CATEGORYSCALE_H

View File

@ -1,17 +0,0 @@
#ifndef CHARCOMMON_H
#define CHARCOMMON_H
#include <cstdint>
#include <string>
namespace HWP { namespace CHART
{
typedef bool CHART_BOOLEAN;
typedef int8_t CHART_INTEGER;
typedef int CHART_LONG;
typedef float CHART_SINGLE;
typedef double CHART_DOUBLE;
typedef std::wstring CHART_STRING;
}}
#endif // CHARCOMMON_H

View File

@ -1,21 +0,0 @@
#ifndef CHARTOBJECT_H
#define CHARTOBJECT_H
#include "Types.h"
#include "ChartStream.h"
namespace HWP { namespace CHART
{
class IChartObject
{
CHART_LONG m_lId;
CHART_LONG m_lStoredtypeId;
protected:
IChartObject() = default;
public:
virtual bool Read(CChartStream& oStream) = 0;
// virtual ETypes GetType() const = 0;
};
}}
#endif // CHARTOBJECT_H

View File

@ -1,28 +0,0 @@
#include "ChartReader.h"
#include "VtChart.h"
namespace HWP { namespace CHART
{
CChartReader::CChartReader()
{
}
bool CChartReader::ReadFromOle(CHWPStream& oOleData)
{
CChartStream oChartStream(&oOleData);
oChartStream.Skip(44); //Unknown data
CHART_STRING sStoredName;
oChartStream.ReadString(sStoredName);
CVtChart oVtChart;
if (!oVtChart.Read(oChartStream))
return false;
return false;
}
}}

View File

@ -1,17 +0,0 @@
#ifndef CHARTREADER_H
#define CHARTREADER_H
#include "../HWPStream.h"
namespace HWP { namespace CHART
{
class CChartReader
{
public:
CChartReader();
bool ReadFromOle(CHWPStream& oOleData);
};
}}
#endif // CHARTREADER_H

View File

@ -1,74 +0,0 @@
#include "ChartStream.h"
namespace HWP { namespace CHART
{
CChartStream::CChartStream()
: m_pStream(nullptr), m_bExternStream(false)
{}
CChartStream::CChartStream(CHWPStream* pStream, bool bExtern)
: m_pStream(pStream), m_bExternStream(bExtern)
{}
CChartStream::~CChartStream()
{
if (nullptr != m_pStream && !m_bExternStream)
delete m_pStream;
}
#define CHECK_VALID()\
if (!Valid())\
return false
bool CChartStream::ReadBoolean(CHART_BOOLEAN& bValue)
{
CHECK_VALID();
return m_pStream->ReadBool(bValue);
}
bool CChartStream::ReadInteger(CHART_INTEGER& nValue)
{
CHECK_VALID();
return m_pStream->ReadByte((HWP_BYTE&)nValue);
}
bool CChartStream::ReadLong(CHART_LONG& lValue)
{
CHECK_VALID();
return m_pStream->ReadInt(lValue);
}
bool CChartStream::ReadSingle(CHART_SINGLE& fValue)
{
CHECK_VALID();
return m_pStream->ReadFloat(fValue);
}
bool CChartStream::ReadDouble(CHART_DOUBLE& dValue)
{
CHECK_VALID();
return m_pStream->ReadDouble(dValue);
}
bool CChartStream::ReadString(HWP_STRING& sValue)
{
CHECK_VALID();
short shCount;
if (!m_pStream->ReadShort(shCount))
return false;
return m_pStream->ReadString(sValue, shCount, EStringCharacter::ASCII);
}
void CChartStream::Skip(int nStep)
{
if (nullptr != m_pStream)
m_pStream->Skip(nStep);
}
bool CChartStream::Valid() const
{
return nullptr != m_pStream && m_pStream->IsValid();
}
}}

View File

@ -1,31 +0,0 @@
#ifndef CHARTSTREAM_H
#define CHARTSTREAM_H
#include "../HWPStream.h"
#include "CharCommon.h"
namespace HWP { namespace CHART
{
class CChartStream
{
CHWPStream *m_pStream;
bool m_bExternStream;
public:
CChartStream();
CChartStream(CHWPStream* pStream, bool bExtern = true);
~CChartStream();
bool ReadBoolean(CHART_BOOLEAN& bValue);
bool ReadInteger(CHART_INTEGER& nValue);
bool ReadLong(CHART_LONG& lValue);
bool ReadSingle(CHART_SINGLE& fValue);
bool ReadDouble(CHART_DOUBLE& dValue);
bool ReadString(HWP_STRING& sValue);
void Skip(int nStep);
private:
bool Valid() const;
};
}}
#endif // CHARTSTREAM_H

View File

@ -1,7 +0,0 @@
#include "Collection.h"
CCollection::CCollection()
{
}

View File

@ -1,54 +0,0 @@
#ifndef COLLECTION_H
#define COLLECTION_H
#include "ChartObject.h"
namespace HWP { namespace CHART
{
template<typename T>
class CCollection : public IChartObject
{
std::vector<const T*> m_arItems;
public:
CCollection() = default;
~CCollection()
{
for (const T* pItem : m_arItems)
delete pItem;
}
bool AddItem(const T* pItem)
{
if(nullptr == pItem)
return false;
m_arItems.push_back(pItem);
return true;
}
virtual bool Read(CChartStream& oStream) override
{
CHART_LONG lCount;
if (!oStream.ReadLong(lCount))
return false;
for (long lIndex = 0; lIndex < lCount; ++lIndex)
{
T* pItem = new T();
if (nullptr == pItem)
continue;
if (!pItem->Read(oStream) || !AddItem(pItem))
{
delete pItem;
return false;
}
return true;
}
}
};
}}
#endif // COLLECTION_H

View File

@ -1,14 +0,0 @@
#include "Contour.h"
namespace HWP { namespace CHART
{
CContour::CContour()
{
}
bool CContour::Read(CChartStream& oStream)
{
return oStream.ReadInteger(m_nDisplayType);
}
}}

View File

@ -1,18 +0,0 @@
#ifndef CONTOUR_H
#define CONTOUR_H
#include "ChartObject.h"
namespace HWP { namespace CHART
{
class CContour : public IChartObject
{
CHART_INTEGER m_nDisplayType;
public:
CContour();
bool Read(CChartStream& oStream) override;
};
}}
#endif // CONTOUR_H

View File

@ -1,15 +0,0 @@
#include "ContourGradient.h"
namespace HWP { namespace CHART
{
CContourGradient::CContourGradient()
{
}
bool CContourGradient::Read(CChartStream& oStream)
{
return m_oFromBrushColor.Read(oStream) && m_oToBrushColor.Read(oStream) &&
m_oFromPenColor.Read(oStream) && m_oToPenColor.Read(oStream);
}
}}

View File

@ -1,21 +0,0 @@
#ifndef CONTOURGRADIENT_H
#define CONTOURGRADIENT_H
#include "VtColor.h"
namespace HWP { namespace CHART
{
class CContourGradient : public IChartObject
{
CVtColor m_oFromBrushColor;
CVtColor m_oToBrushColor;
CVtColor m_oFromPenColor;
CVtColor m_oToPenColor;
public:
CContourGradient();
bool Read(CChartStream& oStream) override;
};
}}
#endif // CONTOURGRADIENT_H

View File

@ -1,14 +0,0 @@
#include "Coor.h"
namespace HWP { namespace CHART
{
CCoor::CCoor()
{
}
bool CCoor::Read(CChartStream& oStream)
{
return oStream.ReadSingle(m_snX) && oStream.ReadSingle(m_snY);
}
}}

View File

@ -1,19 +0,0 @@
#ifndef COOR_H
#define COOR_H
#include "ChartObject.h"
namespace HWP { namespace CHART
{
class CCoor : public IChartObject
{
CHART_SINGLE m_snX;
CHART_SINGLE m_snY;
public:
CCoor();
bool Read(CChartStream& oStream) override;
};
}}
#endif // COOR_H

View File

@ -1,14 +0,0 @@
#include "Coor3.h"
namespace HWP { namespace CHART
{
CCoor3::CCoor3()
{
}
bool CCoor3::Read(CChartStream& oStream)
{
return oStream.ReadSingle(m_snX) && oStream.ReadSingle(m_snY) && oStream.ReadSingle(m_snZ);
}
}}

View File

@ -1,20 +0,0 @@
#ifndef COOR3_H
#define COOR3_H
#include "ChartObject.h"
namespace HWP { namespace CHART
{
class CCoor3 : public IChartObject
{
CHART_SINGLE m_snX;
CHART_SINGLE m_snY;
CHART_SINGLE m_snZ;
public:
CCoor3();
bool Read(CChartStream& oStream) override;
};
}}
#endif // COOR3_H

View File

@ -1,17 +0,0 @@
#include "DataGrid.h"
namespace HWP { namespace CHART
{
CDataGrid::CDataGrid()
{
}
bool CDataGrid::Read(CChartStream& oStream)
{
return oStream.ReadInteger(m_nColumnCount) && oStream.ReadString(m_sColumnLabel) &&
oStream.ReadInteger(m_nColumnLabelCount) && oStream.ReadInteger(m_nCompositeColumnLabel) &&
oStream.ReadString(m_sCompositeRowLabel) && oStream.ReadInteger(m_nRowCount) &&
oStream.ReadString(m_sRowLabel) && oStream.ReadInteger(m_nRowLabelCount);
}
}}

View File

@ -1,25 +0,0 @@
#ifndef DATAGRID_H
#define DATAGRID_H
#include "ChartObject.h"
namespace HWP { namespace CHART
{
class CDataGrid : public IChartObject
{
CHART_INTEGER m_nColumnCount;
CHART_STRING m_sColumnLabel;
CHART_INTEGER m_nColumnLabelCount;
CHART_INTEGER m_nCompositeColumnLabel;
CHART_STRING m_sCompositeRowLabel;
CHART_INTEGER m_nRowCount;
CHART_STRING m_sRowLabel;
CHART_INTEGER m_nRowLabelCount;
public:
CDataGrid();
bool Read(CChartStream& oStream) override;
};
}}
#endif // DATAGRID_H

View File

@ -1,31 +0,0 @@
#include "DataPoint.h"
namespace HWP { namespace CHART
{
CDataPointLabel::CDataPointLabel()
{
}
bool CDataPointLabel::Read(CChartStream& oStream)
{
return m_oBackdrop.Read(oStream) && oStream.ReadInteger(m_nComponent) &&
oStream.ReadBoolean(m_bCustom) && oStream.ReadInteger(m_nLineStyle) &&
oStream.ReadInteger(m_nLocationType) && m_oOffset.Read(oStream) &&
oStream.ReadString(m_sPercentFormat) && oStream.ReadString(m_sText) &&
m_oTextLayout.Read(oStream) && oStream.ReadInteger(m_nTextLength) &&
oStream.ReadString(m_sValueFormat) && m_oVtFont.Read(oStream);
}
CDataPoint::CDataPoint()
{
}
bool CDataPoint::Read(CChartStream& oStream)
{
return m_oBrush.Read(oStream) && m_oDataPointLabel.Read(oStream) &&
m_oEdgePen.Read(oStream) && oStream.ReadSingle(m_snOffset) &&
m_oMarker.Read(oStream) && m_oVtPicture.Read(oStream);
}
}}

View File

@ -1,53 +0,0 @@
#ifndef DATAPOINT_H
#define DATAPOINT_H
#include "Backdrop.h"
#include "Coor.h"
#include "TextLayout.h"
#include "VtFont.h"
#include "Pen.h"
#include "Marker.h"
#include "Brush.h"
#include "VtPicture.h"
#include "Collection.h"
namespace HWP { namespace CHART
{
class CDataPointLabel : public IChartObject
{
CBackdrop m_oBackdrop;
CHART_INTEGER m_nComponent;
CHART_BOOLEAN m_bCustom;
CHART_INTEGER m_nLineStyle;
CHART_INTEGER m_nLocationType;
CCoor m_oOffset;
CHART_STRING m_sPercentFormat;
CHART_STRING m_sText;
CTextLayout m_oTextLayout;
CHART_INTEGER m_nTextLength;
CHART_STRING m_sValueFormat;
CVtFont m_oVtFont;
public:
CDataPointLabel();
bool Read(CChartStream& oStream) override;
};
class CDataPoint : public IChartObject
{
CBrush m_oBrush;
CDataPointLabel m_oDataPointLabel;
CPen m_oEdgePen;
CHART_SINGLE m_snOffset;
CMarker m_oMarker;
CVtPicture m_oVtPicture;
public:
CDataPoint();
bool Read(CChartStream& oStream) override;
};
using CDataPoints = CCollection<CDataPoint>;
}}
#endif // DATAPOINT_H

View File

@ -1,17 +0,0 @@
#include "DateScale.h"
namespace HWP { namespace CHART
{
CDateScale::CDateScale()
{
}
bool CDateScale::Read(CChartStream& oStream)
{
return oStream.ReadBoolean(m_bAuto) && oStream.ReadInteger(m_nMajFreq) &&
oStream.ReadInteger(m_nMajInt) && oStream.ReadDouble(m_dMaximum) &&
oStream.ReadDouble(m_dMinimum) && oStream.ReadInteger(m_nMinFreq) &&
oStream.ReadInteger(m_nMinInt) && oStream.ReadBoolean(m_bSkipWeekend);
}
}}

View File

@ -1,25 +0,0 @@
#ifndef DATESCALE_H
#define DATESCALE_H
#include "ChartObject.h"
namespace HWP { namespace CHART
{
class CDateScale : public IChartObject
{
CHART_BOOLEAN m_bAuto;
CHART_INTEGER m_nMajFreq;
CHART_INTEGER m_nMajInt;
CHART_DOUBLE m_dMaximum;
CHART_DOUBLE m_dMinimum;
CHART_INTEGER m_nMinFreq;
CHART_INTEGER m_nMinInt;
CHART_BOOLEAN m_bSkipWeekend;
public:
CDateScale();
bool Read(CChartStream& oStream) override;
};
}}
#endif // DATESCALE_H

View File

@ -1,14 +0,0 @@
#include "Doughnut.h"
namespace HWP { namespace CHART
{
CDoughnut::CDoughnut()
{
}
bool CDoughnut::Read(CChartStream& oStream)
{
return oStream.ReadInteger(m_nSides) && oStream.ReadSingle(m_snInteriorRatio);
}
}}

View File

@ -1,19 +0,0 @@
#ifndef DOUGHNUT_H
#define DOUGHNUT_H
#include "ChartObject.h"
namespace HWP { namespace CHART
{
class CDoughnut : public IChartObject
{
CHART_INTEGER m_nSides;
CHART_SINGLE m_snInteriorRatio;
public:
CDoughnut();
bool Read(CChartStream& oStream) override;
};
}}
#endif // DOUGHNUT_H

View File

@ -1,18 +0,0 @@
#include "Elevation.h"
namespace HWP { namespace CHART
{
CElevation::CElevation()
{
}
bool CElevation::Read(CChartStream& oStream)
{
return m_oAttributes.Read(oStream) && oStream.ReadBoolean(m_bAutoValues) &&
oStream.ReadInteger(m_nColorType) && oStream.ReadInteger(m_nColSmoothing) &&
m_oContour.Read(oStream) && m_oContourGradient.Read(oStream) &&
oStream.ReadInteger(m_nRowSmoothing) && oStream.ReadBoolean(m_bSeparateContourData) &&
m_oSurface.Read(oStream);
}
}}

View File

@ -1,29 +0,0 @@
#ifndef ELEVATION_H
#define ELEVATION_H
#include "Attribute.h"
#include "Contour.h"
#include "ContourGradient.h"
#include "Surface.h"
namespace HWP { namespace CHART
{
class CElevation : public IChartObject
{
CAttributes m_oAttributes;
CHART_BOOLEAN m_bAutoValues;
CHART_INTEGER m_nColorType;
CHART_INTEGER m_nColSmoothing;
CContour m_oContour;
CContourGradient m_oContourGradient;
CHART_INTEGER m_nRowSmoothing;
CHART_BOOLEAN m_bSeparateContourData;
CSurface m_oSurface;
public:
CElevation();
bool Read(CChartStream& oStream) override;
};
}}
#endif // ELEVATION_H

View File

@ -1,15 +0,0 @@
#include "Fill.h"
namespace HWP { namespace CHART
{
CFill::CFill()
{
}
bool CFill::Read(CChartStream& oStream)
{
return m_oBrush.Read(oStream) && /*&&*/
oStream.ReadInteger(m_nStyle) && m_oVtPicture.Read(oStream);
}
}}

View File

@ -1,27 +0,0 @@
#ifndef FILL_H
#define FILL_H
#include "Brush.h"
#include "Gradient.h"
#include "VtPicture.h"
namespace HWP { namespace CHART
{
class CFill : public IChartObject
{
CBrush m_oBrush;
// union
// {
// CGradient m_oGradient;
// CVtPicture m_oPicture;
// } m_oGradient;
CHART_INTEGER m_nStyle;
CVtPicture m_oVtPicture;
public:
CFill();
bool Read(CChartStream& oStream) override;
};
}}
#endif // FILL_H

View File

@ -1,16 +0,0 @@
#include "Footnote.h"
namespace HWP { namespace CHART
{
CFootnote::CFootnote()
{
}
bool CFootnote::Read(CChartStream& oStream)
{
return m_oBackdrop.Read(oStream) && m_oLocation.Read(oStream) &&
oStream.ReadString(m_sText) && m_oTextLayout.Read(oStream) &&
oStream.ReadInteger(m_nTextLength) && m_oVtFont.Read(oStream);
}
}}

View File

@ -1,26 +0,0 @@
#ifndef FOOTNOTE_H
#define FOOTNOTE_H
#include "Backdrop.h"
#include "Location.h"
#include "TextLayout.h"
#include "VtFont.h"
namespace HWP { namespace CHART
{
class CFootnote : public IChartObject
{
CBackdrop m_oBackdrop;
CLocation m_oLocation;
CHART_STRING m_sText;
CTextLayout m_oTextLayout;
CHART_INTEGER m_nTextLength;
CVtFont m_oVtFont;
public:
CFootnote();
bool Read(CChartStream& oStream) override;
};
}}
#endif // FOOTNOTE_H

View File

@ -1,15 +0,0 @@
#include "Frame.h"
namespace HWP { namespace CHART
{
CFrame::CFrame()
{
}
bool CFrame::Read(CChartStream& oStream)
{
return oStream.ReadInteger(m_nStyle) && oStream.ReadSingle(m_snWidth) &&
m_oFrameColor.Read(oStream) && m_oSpaceColor.Read(oStream);
}
}}

View File

@ -1,21 +0,0 @@
#ifndef FRAME_H
#define FRAME_H
#include "VtColor.h"
namespace HWP { namespace CHART
{
class CFrame : public IChartObject
{
CHART_INTEGER m_nStyle;
CHART_SINGLE m_snWidth;
CVtColor m_oFrameColor;
CVtColor m_oSpaceColor;
public:
CFrame();
bool Read(CChartStream& oStream) override;
};
}}
#endif // FRAME_H

View File

@ -1,15 +0,0 @@
#include "Gradient.h"
namespace HWP { namespace CHART
{
CGradient::CGradient()
{
}
bool CGradient::Read(CChartStream& oStream)
{
return m_oFromColor.Read(oStream) && oStream.ReadInteger(m_nStyle) &&
m_oToColor.Read(oStream);
}
}}

View File

@ -1,20 +0,0 @@
#ifndef GRADIENT_H
#define GRADIENT_H
#include "VtColor.h"
namespace HWP { namespace CHART
{
class CGradient : public IChartObject
{
CVtColor m_oFromColor;
CHART_INTEGER m_nStyle;
CVtColor m_oToColor;
public:
CGradient();
bool Read(CChartStream& oStream) override;
};
}}
#endif // GRADIENT_H

View File

@ -1,14 +0,0 @@
#include "HiLo.h"
namespace HWP { namespace CHART
{
CHiLo::CHiLo()
{
}
bool CHiLo::Read(CChartStream& oStream)
{
return m_oGainColor.Read(oStream) && m_oLossColor.Read(oStream);
}
}}

View File

@ -1,19 +0,0 @@
#ifndef HILO_H
#define HILO_H
#include "VtColor.h"
namespace HWP { namespace CHART
{
class CHiLo : public IChartObject
{
CVtColor m_oGainColor;
CVtColor m_oLossColor;
public:
CHiLo();
bool Read(CChartStream& oStream) override;
};
}}
#endif // HILO_H

Some files were not shown because too many files have changed in this diff Show More