mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-16 12:56:09 +08:00
Compare commits
3 Commits
fix/html2m
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d06219664 | |||
| e936b0e4e7 | |||
| a22f0bfb60 |
@ -6,13 +6,12 @@ import os
|
||||
if not base.is_dir("glm"):
|
||||
base.cmd("git", ["clone", "https://github.com/g-truc/glm.git"])
|
||||
base.cmd_in_dir("glm", "git", ["checkout", "33b4a621a697a305bc3a7610d290677b96beb181", "--quiet"])
|
||||
base.replaceInFile("./glm/glm/detail/func_common.inl", "vec<L, T, Q> v;", "vec<L, T, Q> v{};")
|
||||
|
||||
if not base.is_dir("mdds"):
|
||||
base.cmd("git", ["clone", "https://github.com/kohei-us/mdds.git"])
|
||||
base.cmd_in_dir("mdds", "git", ["checkout", "0783158939c6ce4b0b1b89e345ab983ccb0f0ad0"], "--quiet")
|
||||
|
||||
fix_cpp_version = "#if __cplusplus < 201703L\n"
|
||||
fix_cpp_version = "#if __cplusplus < 201402L\n"
|
||||
fix_cpp_version += "#ifndef _MSC_VER\n"
|
||||
fix_cpp_version += "namespace std {\n"
|
||||
fix_cpp_version += " template<bool __v>\n"
|
||||
|
||||
@ -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 \
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
|
||||
#include <iostream>
|
||||
#include "../../../../../DesktopEditor/common/File.h"
|
||||
#include "StaticFunctions.h"
|
||||
#include "ConstValues.h"
|
||||
@ -17,16 +18,14 @@ namespace NSCSS
|
||||
{
|
||||
typedef std::map<std::wstring, std::wstring>::const_iterator styles_iterator;
|
||||
|
||||
CCompiledStyle::CCompiledStyle()
|
||||
: m_nDpi(96), m_UnitMeasure(Point), m_dCoreFontSize(DEFAULT_FONT_SIZE)
|
||||
CCompiledStyle::CCompiledStyle() : m_nDpi(96), m_UnitMeasure(Point), m_dCoreFontSize(DEFAULT_FONT_SIZE)
|
||||
{}
|
||||
|
||||
CCompiledStyle::CCompiledStyle(const CCompiledStyle& oStyle) :
|
||||
m_arParentsStyles(oStyle.m_arParentsStyles), m_sId(oStyle.m_sId),
|
||||
m_nDpi(oStyle.m_nDpi), m_UnitMeasure(oStyle.m_UnitMeasure), m_dCoreFontSize(oStyle.m_dCoreFontSize),
|
||||
m_oFont(oStyle.m_oFont), m_oMargin(oStyle.m_oMargin), m_oPadding(oStyle.m_oPadding), m_oBackground(oStyle.m_oBackground),
|
||||
m_oText(oStyle.m_oText), m_oBorder(oStyle.m_oBorder), m_oDisplay(oStyle.m_oDisplay), m_oTransform(oStyle.m_oTransform)
|
||||
{}
|
||||
m_oText(oStyle.m_oText), m_oBorder(oStyle.m_oBorder), m_oDisplay(oStyle.m_oDisplay), m_oTransform(oStyle.m_oTransform){}
|
||||
|
||||
CCompiledStyle::~CCompiledStyle()
|
||||
{
|
||||
@ -35,8 +34,6 @@ namespace NSCSS
|
||||
|
||||
CCompiledStyle& CCompiledStyle::operator+= (const CCompiledStyle &oElement)
|
||||
{
|
||||
m_arParentsStyles.insert(oElement.m_arParentsStyles.begin(), oElement.m_arParentsStyles.end());
|
||||
|
||||
if (oElement.Empty())
|
||||
return *this;
|
||||
|
||||
@ -52,6 +49,8 @@ namespace NSCSS
|
||||
if (!oElement.m_sId.empty())
|
||||
m_sId += L'+' + oElement.m_sId;
|
||||
|
||||
m_arParentsStyles.insert(oElement.m_arParentsStyles.begin(), oElement.m_arParentsStyles.end());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@ -15,33 +15,29 @@ inline static std::wstring StringifyValueList(const KatanaArray* oValues);
|
||||
inline static std::wstring StringifyValue(const KatanaValue* oValue);
|
||||
inline static bool IsTableElement(const std::wstring& wsNameTag);
|
||||
|
||||
bool operator<(const std::vector<NSCSS::CNode> &arLeftSelectors, const std::vector<NSCSS::CNode> &arRightSelectors)
|
||||
{
|
||||
const size_t& sizeLeftSelectors = arLeftSelectors.size();
|
||||
const size_t& sizeRightSelectors = arRightSelectors.size();
|
||||
|
||||
if (sizeLeftSelectors < sizeRightSelectors)
|
||||
return true;
|
||||
else if (sizeLeftSelectors > sizeRightSelectors)
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < arLeftSelectors.size(); ++i)
|
||||
{
|
||||
if (arLeftSelectors[i] < arRightSelectors[i])
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
bool operator<(const std::vector<NSCSS::CNode> &arLeftSelectors, const std::vector<NSCSS::CNode> &arRightSelectors)
|
||||
{
|
||||
if (arLeftSelectors.size() < arRightSelectors.size())
|
||||
return true;
|
||||
else if (arLeftSelectors.size() > arRightSelectors.size())
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < arLeftSelectors.size(); ++i)
|
||||
{
|
||||
if (arLeftSelectors[i] == arRightSelectors[i])
|
||||
continue;
|
||||
|
||||
if (arLeftSelectors[i] < arRightSelectors[i])
|
||||
return true;
|
||||
else if (arRightSelectors[i] < arLeftSelectors[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CStyleStorage::CStyleStorage()
|
||||
{
|
||||
InitDefaultStyles();
|
||||
}
|
||||
{}
|
||||
|
||||
CStyleStorage::~CStyleStorage()
|
||||
{
|
||||
@ -66,7 +62,6 @@ namespace NSCSS
|
||||
m_arEmptyStyleFiles.clear();
|
||||
|
||||
ClearEmbeddedStyles();
|
||||
ClearDefaultStyles();
|
||||
ClearAllowedStyleFiles();
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
@ -213,16 +208,6 @@ namespace NSCSS
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const CElement* CStyleStorage::FindDefaultElement(const std::wstring& wsSelector) const
|
||||
{
|
||||
if (wsSelector.empty())
|
||||
return nullptr;
|
||||
|
||||
const CElement* pFoundElement = FindSelectorFromStyleData(wsSelector, m_mDefaultStyleData);
|
||||
|
||||
return (nullptr != pFoundElement) ? pFoundElement : nullptr;
|
||||
}
|
||||
|
||||
void CStyleStorage::AddStyles(const std::string& sStyle, std::map<std::wstring, CElement*>& mStyleData)
|
||||
{
|
||||
if (sStyle.empty())
|
||||
@ -242,15 +227,6 @@ namespace NSCSS
|
||||
m_mEmbeddedStyleData.clear();
|
||||
}
|
||||
|
||||
void CStyleStorage::ClearDefaultStyles()
|
||||
{
|
||||
for (std::map<std::wstring, CElement*>::iterator oIter = m_mDefaultStyleData.begin(); oIter != m_mDefaultStyleData.end(); ++oIter)
|
||||
if (oIter->second != nullptr)
|
||||
delete oIter->second;
|
||||
|
||||
m_mDefaultStyleData.clear();
|
||||
}
|
||||
|
||||
void CStyleStorage::ClearAllowedStyleFiles()
|
||||
{
|
||||
m_arAllowedStyleFiles.clear();
|
||||
@ -504,33 +480,7 @@ namespace NSCSS
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CStyleStorage::InitDefaultStyles()
|
||||
{
|
||||
m_mDefaultStyleData[L"b"] = new CElement(L"b", {{L"font-weight", L"bold"}});
|
||||
m_mDefaultStyleData[L"center"] = new CElement(L"center", {{L"text-align", L"center"}});
|
||||
m_mDefaultStyleData[L"i"] = new CElement(L"i", {{L"font-style", L"italic"}});
|
||||
m_mDefaultStyleData[L"code"] = new CElement(L"code", {{L"font-family", L"Courier New"}});
|
||||
m_mDefaultStyleData[L"kbd"] = new CElement(L"kbd", {{L"font-family", L"Courier New"},
|
||||
{L"font_weight", L"bold"}});
|
||||
m_mDefaultStyleData[L"s"] = new CElement(L"s", {{L"text-decoration", L"line-through"}});
|
||||
m_mDefaultStyleData[L"u"] = new CElement(L"u", {{L"text-decoration", L"underline"}});
|
||||
m_mDefaultStyleData[L"mark"] = new CElement(L"mark", {{L"background-color", L"yellow"}});
|
||||
m_mDefaultStyleData[L"sup"] = new CElement(L"sup", {{L"vertical-align", L"top"}});
|
||||
m_mDefaultStyleData[L"sub"] = new CElement(L"sub", {{L"vertical-align", L"bottom"}});
|
||||
m_mDefaultStyleData[L"dd"] = new CElement(L"dd", {{L"margin-left", L"720tw"}});
|
||||
m_mDefaultStyleData[L"pre"] = new CElement(L"pre", {{L"font-family", L"Courier New"},
|
||||
{L"margin-top", L"0"},
|
||||
{L"margin-bottom", L"0"}});
|
||||
m_mDefaultStyleData[L"blockquote"] = new CElement(L"blockquote", {{L"margin", L"0px"}});
|
||||
m_mDefaultStyleData[L"ul"] = new CElement(L"ul", {{L"margin-top", L"100tw"},
|
||||
{L"margin-bottom", L"100tw"}});
|
||||
m_mDefaultStyleData[L"textarea"] = new CElement(L"textarea", {{L"border", L"1px solid black"}});
|
||||
}
|
||||
|
||||
CCssCalculator_Private::CCssCalculator_Private()
|
||||
: m_nDpi(96), m_nCountNodes(0), m_sEncoding(L"UTF-8")
|
||||
{
|
||||
}
|
||||
CCssCalculator_Private::CCssCalculator_Private() : m_nDpi(96), m_nCountNodes(0), m_sEncoding(L"UTF-8"){}
|
||||
|
||||
CCssCalculator_Private::~CCssCalculator_Private()
|
||||
{}
|
||||
@ -553,17 +503,12 @@ namespace NSCSS
|
||||
arSelectors.back().m_pCompiledStyle->m_oBorder.Clear();
|
||||
}
|
||||
|
||||
if (arSelectors.size() > 1)
|
||||
arSelectors.back().m_pCompiledStyle->AddParent(arSelectors[arSelectors.size() - 2].m_wsName);
|
||||
|
||||
arSelectors.back().m_pCompiledStyle->SetID(L"text-" + std::to_wstring(++m_nCountNodes));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::const_iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (oItem != m_mUsedStyles.cend())
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
{
|
||||
arSelectors.back().SetCompiledStyle(new CCompiledStyle(oItem->second));
|
||||
return true;
|
||||
@ -597,8 +542,7 @@ namespace NSCSS
|
||||
if (0 != i)
|
||||
*arSelectors[i].m_pCompiledStyle += *arSelectors[i - 1].m_pCompiledStyle;
|
||||
|
||||
if (i != arSelectors.size() - 1)
|
||||
arSelectors[i].m_pCompiledStyle->AddParent(arSelectors[i].m_wsName);
|
||||
arSelectors[i].m_pCompiledStyle->AddParent(arSelectors[i].m_wsName);
|
||||
|
||||
if (!bInTable)
|
||||
bInTable = IsTableElement(arSelectors[i].m_wsName);
|
||||
@ -671,8 +615,8 @@ namespace NSCSS
|
||||
std::vector<std::wstring> arClasses = NS_STATIC_FUNCTIONS::GetWordsW(oNode->m_wsClass, false, L" ");
|
||||
|
||||
arNodes.push_back(std::accumulate(arClasses.begin(), arClasses.end(), std::wstring(),
|
||||
[](std::wstring sRes, const std::wstring& sClass)
|
||||
{return sRes += L'.' + sClass + L' ';}));
|
||||
[](std::wstring sRes, const std::wstring& sClass)
|
||||
{return sRes += L'.' + sClass + L' ';}));
|
||||
}
|
||||
else
|
||||
arNodes.push_back(L'.' + oNode->m_wsClass);
|
||||
@ -700,36 +644,6 @@ namespace NSCSS
|
||||
arFindedElements.insert(arFindedElements.end(), arTempKins.begin(), arTempKins.end());
|
||||
}
|
||||
|
||||
inline std::wstring GetAlternativeDefaultNodeName(const std::wstring& wsNodeName)
|
||||
{
|
||||
if (L"strong" == wsNodeName)
|
||||
return L"b";
|
||||
|
||||
if (L"cite" == wsNodeName || L"dfn" == wsNodeName || L"em" == wsNodeName ||
|
||||
L"var" == wsNodeName || L"adress" == wsNodeName)
|
||||
return L"i";
|
||||
|
||||
if (L"tt" == wsNodeName || L"samp" == wsNodeName)
|
||||
return L"code";
|
||||
|
||||
if (L"strike" == wsNodeName || L"del" == wsNodeName)
|
||||
return L"s";
|
||||
|
||||
if (L"ins" == wsNodeName)
|
||||
return L"u";
|
||||
|
||||
if (L"xmp" == wsNodeName || L"nobr" == wsNodeName)
|
||||
return L"pre";
|
||||
|
||||
if (L"ol" == wsNodeName)
|
||||
return L"ul";
|
||||
|
||||
if (L"fieldset" == wsNodeName)
|
||||
return L"textarea";
|
||||
|
||||
return wsNodeName;
|
||||
}
|
||||
|
||||
std::vector<const CElement*> CCssCalculator_Private::FindElements(std::vector<std::wstring> &arNodes, std::vector<std::wstring> &arNextNodes)
|
||||
{
|
||||
if (arNodes.empty())
|
||||
@ -788,11 +702,6 @@ namespace NSCSS
|
||||
}
|
||||
}
|
||||
|
||||
const CElement* pFoundDefault = m_oStyleStorage.FindDefaultElement(GetAlternativeDefaultNodeName(wsName));
|
||||
|
||||
if (nullptr != pFoundDefault)
|
||||
arFindedElements.push_back(pFoundDefault);
|
||||
|
||||
const CElement* pFoundName = m_oStyleStorage.FindElement(wsName);
|
||||
|
||||
if (nullptr != pFoundName)
|
||||
|
||||
@ -27,7 +27,6 @@ namespace NSCSS
|
||||
void AddStylesFromFile(const std::wstring& wsFileName);
|
||||
|
||||
void ClearEmbeddedStyles();
|
||||
void ClearDefaultStyles();
|
||||
void ClearAllowedStyleFiles();
|
||||
void ClearStylesFromFile(const std::wstring& wsFileName);
|
||||
|
||||
@ -39,7 +38,6 @@ namespace NSCSS
|
||||
#endif
|
||||
|
||||
const CElement* FindElement(const std::wstring& wsSelector) const;
|
||||
const CElement* FindDefaultElement(const std::wstring& wsSelector) const;
|
||||
private:
|
||||
typedef struct
|
||||
{
|
||||
@ -51,7 +49,6 @@ namespace NSCSS
|
||||
std::set<std::wstring> m_arAllowedStyleFiles;
|
||||
std::vector<TStyleFileData*> m_arStyleFiles;
|
||||
std::map<std::wstring, CElement*> m_mEmbeddedStyleData;
|
||||
std::map<std::wstring, CElement*> m_mDefaultStyleData;
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
typedef struct
|
||||
@ -81,8 +78,6 @@ namespace NSCSS
|
||||
void GetOutputData(KatanaOutput* oOutput, std::map<std::wstring, CElement*>& mStyleData);
|
||||
|
||||
const CElement* FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData) const;
|
||||
|
||||
void InitDefaultStyles();
|
||||
};
|
||||
|
||||
class CCssCalculator_Private
|
||||
|
||||
@ -9,13 +9,6 @@ namespace NSCSS
|
||||
CElement::CElement()
|
||||
{
|
||||
}
|
||||
|
||||
CElement::CElement(const std::wstring& wsSelector, std::map<std::wstring, std::wstring> mStyle)
|
||||
: m_mStyle(mStyle), m_sSelector(wsSelector), m_sFullSelector(wsSelector)
|
||||
{
|
||||
UpdateWeight();
|
||||
}
|
||||
|
||||
CElement::~CElement()
|
||||
{
|
||||
for (CElement* oElement : m_arPrevElements)
|
||||
@ -25,6 +18,7 @@ namespace NSCSS
|
||||
continue;
|
||||
|
||||
m_mStyle.clear();
|
||||
|
||||
}
|
||||
|
||||
std::wstring CElement::GetSelector() const
|
||||
|
||||
@ -22,7 +22,6 @@ namespace NSCSS
|
||||
|
||||
public:
|
||||
CElement();
|
||||
CElement(const std::wstring& wsSelector, std::map<std::wstring, std::wstring> mStyle);
|
||||
~CElement();
|
||||
|
||||
std::wstring GetSelector() const;
|
||||
|
||||
@ -17,7 +17,8 @@ namespace NSCSS
|
||||
m_wsStyle(oNode.m_wsStyle), m_mAttributes(oNode.m_mAttributes)
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
m_pCompiledStyle = new CCompiledStyle(*oNode.m_pCompiledStyle);
|
||||
m_pCompiledStyle = new CCompiledStyle();
|
||||
*m_pCompiledStyle = *oNode.m_pCompiledStyle;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -41,23 +42,6 @@ namespace NSCSS
|
||||
return m_wsName.empty() && m_wsClass.empty() && m_wsId.empty() && m_wsStyle.empty();
|
||||
}
|
||||
|
||||
bool CNode::GetAttributeValue(const std::wstring& wsAttributeName, std::wstring& wsAttributeValue) const
|
||||
{
|
||||
const std::map<std::wstring, std::wstring>::const_iterator itFound{m_mAttributes.find(wsAttributeName)};
|
||||
|
||||
if (m_mAttributes.cend() == itFound)
|
||||
return false;
|
||||
|
||||
wsAttributeValue = itFound->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring CNode::GetAttributeValue(const std::wstring& wsAttributeName) const
|
||||
{
|
||||
const std::map<std::wstring, std::wstring>::const_iterator itFound{m_mAttributes.find(wsAttributeName)};
|
||||
return (m_mAttributes.cend() != itFound) ? itFound->second : std::wstring();
|
||||
}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void CNode::SetCompiledStyle(CCompiledStyle* pCompiledStyle)
|
||||
{
|
||||
@ -102,9 +86,6 @@ namespace NSCSS
|
||||
if(m_wsStyle != oNode.m_wsStyle)
|
||||
return m_wsStyle < oNode.m_wsStyle;
|
||||
|
||||
if (m_mAttributes.size() != oNode.m_mAttributes.size())
|
||||
return m_mAttributes.size() < oNode.m_mAttributes.size();
|
||||
|
||||
if (m_mAttributes != oNode.m_mAttributes)
|
||||
return m_mAttributes < oNode.m_mAttributes;
|
||||
|
||||
@ -114,9 +95,9 @@ namespace NSCSS
|
||||
bool CNode::operator==(const CNode& oNode) const
|
||||
{
|
||||
return((m_wsId == oNode.m_wsId) &&
|
||||
(m_wsName == oNode.m_wsName) &&
|
||||
(m_wsClass == oNode.m_wsClass) &&
|
||||
(m_wsStyle == oNode.m_wsStyle) &&
|
||||
(m_mAttributes == oNode.m_mAttributes));
|
||||
(m_wsName == oNode.m_wsName) &&
|
||||
(m_wsClass == oNode.m_wsClass) &&
|
||||
(m_wsStyle == oNode.m_wsStyle) &&
|
||||
(m_mAttributes == oNode.m_mAttributes));
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,9 +31,6 @@ namespace NSCSS
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
bool GetAttributeValue(const std::wstring& wsAttributeName, std::wstring& wsAttributeValue) const;
|
||||
std::wstring GetAttributeValue(const std::wstring& wsAttributeName) const;
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void SetCompiledStyle(CCompiledStyle* pCompiledStyle);
|
||||
#endif
|
||||
|
||||
@ -70,9 +70,7 @@ namespace NSCSS
|
||||
R_Shd,
|
||||
R_SmallCaps,
|
||||
R_Kern,
|
||||
R_Vanish,
|
||||
R_Strike,
|
||||
R_VertAlign
|
||||
R_Vanish
|
||||
} RunnerProperties;
|
||||
|
||||
typedef enum
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -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,21 @@ 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();
|
||||
};
|
||||
|
||||
typedef enum
|
||||
@ -358,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:
|
||||
@ -383,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
|
||||
@ -696,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:
|
||||
@ -727,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;
|
||||
@ -740,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;
|
||||
@ -752,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;
|
||||
|
||||
@ -22,11 +22,6 @@ namespace NSCSS
|
||||
: m_oStyle(oStyle), m_bIsPStyle(bIsPStyle)
|
||||
{}
|
||||
|
||||
void CStyleUsed::SetFinalId(const std::wstring& wsFinalId)
|
||||
{
|
||||
m_wsFinalId = wsFinalId;
|
||||
}
|
||||
|
||||
bool CheckArrays(const std::vector<std::wstring>& arInitial, const std::set<std::wstring>& arFirst, const std::set<std::wstring>& arSecond)
|
||||
{
|
||||
std::unordered_set<std::wstring> arInitialSet(arInitial.begin(), arInitial.end());
|
||||
@ -62,14 +57,19 @@ namespace NSCSS
|
||||
m_oStyle == oUsedStyle.m_oStyle;
|
||||
}
|
||||
|
||||
std::wstring CStyleUsed::GetId() const
|
||||
std::wstring CStyleUsed::getId()
|
||||
{
|
||||
return m_wsFinalId;
|
||||
if (m_bIsPStyle)
|
||||
return m_oStyle.GetId();
|
||||
|
||||
return m_oStyle.GetId() + L"-c";
|
||||
}
|
||||
|
||||
CDocumentStyle::CDocumentStyle()
|
||||
: m_arStandardStyles(Names_Standard_Styles)
|
||||
{}
|
||||
CDocumentStyle::CDocumentStyle() : m_arStandardStyles(Names_Standard_Styles)
|
||||
{
|
||||
for (const std::wstring& oNameStandardStyle : Names_Standard_Styles)
|
||||
m_arStandardStyles.push_back(oNameStandardStyle + L"-c");
|
||||
}
|
||||
|
||||
CDocumentStyle::~CDocumentStyle()
|
||||
{
|
||||
@ -85,7 +85,7 @@ namespace NSCSS
|
||||
|
||||
std::wstring CDocumentStyle::GetIdAndClear()
|
||||
{
|
||||
const std::wstring sId = m_sId;
|
||||
std::wstring sId = m_sId;
|
||||
Clear();
|
||||
return sId;
|
||||
}
|
||||
@ -110,10 +110,10 @@ namespace NSCSS
|
||||
m_sId = sId;
|
||||
}
|
||||
|
||||
bool CDocumentStyle::CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement)
|
||||
void CDocumentStyle::CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement)
|
||||
{
|
||||
if (arStandartedStyles.empty())
|
||||
return false;
|
||||
return;
|
||||
|
||||
std::vector<std::wstring> arStyles;
|
||||
for (const std::wstring& sStyleName : arStandartedStyles)
|
||||
@ -123,7 +123,7 @@ namespace NSCSS
|
||||
}
|
||||
|
||||
if (arStyles.empty())
|
||||
return false;
|
||||
return;
|
||||
|
||||
std::wstring sId;
|
||||
for (std::vector<std::wstring>::const_reverse_iterator iStyleName = arStyles.rbegin(); iStyleName != arStyles.rend(); ++iStyleName)
|
||||
@ -142,25 +142,18 @@ namespace NSCSS
|
||||
|
||||
oElement.AddBasicProperties(BProperties::B_Name, sId);
|
||||
oElement.AddBasicProperties(BProperties::B_StyleId, sId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDocumentStyle::CreateStandardStyle(const std::wstring& sNameStyle, CXmlElement& oElement)
|
||||
void CDocumentStyle::CreateStandardStyle(const std::wstring& sNameStyle, CXmlElement& oElement)
|
||||
{
|
||||
if (std::find(m_arStandardStyles.begin(), m_arStandardStyles.end(), sNameStyle) != m_arStandardStyles.end())
|
||||
{
|
||||
oElement.CreateDefaultElement(sNameStyle);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDocumentStyle::ConvertStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle)
|
||||
void CDocumentStyle::ConvertStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle)
|
||||
{
|
||||
if (oStyle.GetId().empty())
|
||||
return false;
|
||||
return;
|
||||
|
||||
std::wstring sName = oStyle.GetId();
|
||||
const size_t posPoint = sName.find(L'.');
|
||||
@ -190,25 +183,25 @@ namespace NSCSS
|
||||
for (std::wstring& sParentName : arParentsName)
|
||||
sParentName += L"-c";
|
||||
|
||||
bool bResult{false};
|
||||
|
||||
if (!arParentsName.empty())
|
||||
{
|
||||
bResult = CombineStandardStyles(arParentsName, oParentStyle);
|
||||
CombineStandardStyles(arParentsName, oParentStyle);
|
||||
|
||||
if (!oParentStyle.Empty())
|
||||
{
|
||||
oParentStyle.AddBasicProperties(BProperties::B_BasedOn, L"normal");
|
||||
oParentStyle.AddBasicProperties(BProperties::B_StyleId, oParentStyle.GetStyleId());
|
||||
oParentStyle.AddBasicProperties(BProperties::B_StyleId, L"(" + oParentStyle.GetStyleId() + L")");
|
||||
if (!bIsPStyle)
|
||||
{
|
||||
oParentStyle.AddBasicProperties(BProperties::B_StyleId, oParentStyle.GetStyleId() + L"-c");
|
||||
oParentStyle.AddBasicProperties(BProperties::B_Type, L"character");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CXmlElement oStandardXmlElement;
|
||||
if (std::find(m_arStandardStyles.begin(), m_arStandardStyles.end(), sName) != m_arStandardStyles.end())
|
||||
if (CreateStandardStyle(sName, oStandardXmlElement))
|
||||
bResult = true;
|
||||
CreateStandardStyle(sName, oStandardXmlElement);
|
||||
|
||||
if (oStandardXmlElement.Empty() && !oParentStyle.Empty())
|
||||
{
|
||||
@ -228,7 +221,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty())
|
||||
{
|
||||
m_sId = sParentsStyleID;
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
oElement.AddBasicProperties(BProperties::B_BasedOn, sParentsStyleID);
|
||||
@ -241,7 +234,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty())
|
||||
{
|
||||
m_sId = sStandPlusParent;
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
oElement.AddBasicProperties(BProperties::B_BasedOn, sStandPlusParent);
|
||||
}
|
||||
@ -265,7 +258,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty())
|
||||
{
|
||||
m_sId = sStandPlusParent;
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
oElement.AddBasicProperties(BProperties::B_BasedOn, oTempElement.GetStyleId());
|
||||
}
|
||||
@ -288,7 +281,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty())
|
||||
{
|
||||
m_sId = sStandartStyleID;
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
oElement.AddBasicProperties(BProperties::B_BasedOn, sStandartStyleID);
|
||||
}
|
||||
@ -296,7 +289,7 @@ namespace NSCSS
|
||||
if (oStyle.Empty() && oElement.Empty())
|
||||
{
|
||||
m_sId = L"normal";
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
m_sId = oStyle.GetId();
|
||||
@ -309,19 +302,15 @@ namespace NSCSS
|
||||
oElement.AddBasicProperties(BProperties::B_Name, m_sId);
|
||||
oElement.AddBasicProperties(BProperties::B_Type, bIsPStyle ? L"paragraph" : L"character");
|
||||
oElement.AddBasicProperties(BProperties::B_CustomStyle, L"1");
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
bool CDocumentStyle::SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite)
|
||||
void CDocumentStyle::SetPStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite)
|
||||
{
|
||||
bool bResult{false};
|
||||
|
||||
if (!bIsLite)
|
||||
bResult = ConvertStyle(oStyle, oXmlElement, true);
|
||||
ConvertStyle(oStyle, oXmlElement, true);
|
||||
|
||||
if (oStyle.Empty())
|
||||
return bResult;
|
||||
return;
|
||||
|
||||
const bool bInTable{oStyle.HaveThisParent(L"table")};
|
||||
|
||||
@ -401,8 +390,6 @@ namespace NSCSS
|
||||
SetBorderStyle(oStyle, oXmlElement, PProperties::P_LeftBorder);
|
||||
}
|
||||
}
|
||||
|
||||
return bResult || !oXmlElement.Empty();
|
||||
}
|
||||
|
||||
void CDocumentStyle::SetBorderStyle(const CCompiledStyle &oStyle, CXmlElement &oXmlElement, const PProperties &enBorderProperty)
|
||||
@ -486,15 +473,13 @@ namespace NSCSS
|
||||
return L"w:val=\"" + wsStyle + L"\" w:sz=\"" + std::to_wstring(nWidth) + + L"\" w:space=\"" + std::to_wstring(nSpace) + L"\" w:color=\"" + wsColor + L"\"";
|
||||
}
|
||||
|
||||
bool CDocumentStyle::SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite)
|
||||
void CDocumentStyle::SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite)
|
||||
{
|
||||
bool bResult{false};
|
||||
|
||||
if (!bIsLite)
|
||||
bResult = ConvertStyle(oStyle, oXmlElement, false);
|
||||
ConvertStyle(oStyle, oXmlElement, false);
|
||||
|
||||
if (oStyle.Empty() && oXmlElement.Empty())
|
||||
return bResult;
|
||||
return;
|
||||
|
||||
if (!oStyle.m_oFont.GetSize().Empty())
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Sz, std::to_wstring(static_cast<int>(oStyle.m_oFont.GetSize().ToDouble(NSCSS::Point) * 2. * oStyle.m_oTransform.GetMatrix().GetFinalValue().sy() + 0.5))); // Значения шрифта увеличивает на 2
|
||||
@ -531,18 +516,6 @@ namespace NSCSS
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_I, oStyle.m_oFont.GetStyle().ToWString());
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_B, oStyle.m_oFont.GetWeight().ToWString());
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_SmallCaps, oStyle.m_oFont.GetVariant().ToWString());
|
||||
|
||||
if (oStyle.m_oText.LineThrough())
|
||||
{
|
||||
if (L"double" == oStyle.m_oText.GetDecoration().m_oStyle.ToWString())
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Strike, L"dstrike");
|
||||
else
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Strike, L"strike");
|
||||
}
|
||||
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_VertAlign, oStyle.m_oDisplay.GetVAlign().ToWString());
|
||||
|
||||
return bResult || !oXmlElement.Empty();
|
||||
}
|
||||
|
||||
bool CDocumentStyle::WriteRStyle(const NSCSS::CCompiledStyle& oStyle)
|
||||
@ -558,16 +531,16 @@ namespace NSCSS
|
||||
|
||||
if (oItem != m_arStyleUsed.end())
|
||||
{
|
||||
m_sId = (*oItem).GetId();
|
||||
m_sId = (*oItem).getId();
|
||||
return true;
|
||||
}
|
||||
|
||||
CXmlElement oXmlElement;
|
||||
SetRStyle(oStyle, oXmlElement);
|
||||
|
||||
if (!SetRStyle(oStyle, oXmlElement))
|
||||
if (oXmlElement.Empty())
|
||||
return false;
|
||||
|
||||
structStyle.SetFinalId(m_sId);
|
||||
m_arStyleUsed.push_back(structStyle);
|
||||
m_sStyle += oXmlElement.GetRStyle();
|
||||
|
||||
@ -620,16 +593,16 @@ namespace NSCSS
|
||||
|
||||
if (oItem != m_arStyleUsed.end())
|
||||
{
|
||||
m_sId = (*oItem).GetId();
|
||||
m_sId = (*oItem).getId();
|
||||
return true;
|
||||
}
|
||||
|
||||
CXmlElement oXmlElement;
|
||||
SetPStyle(oStyle, oXmlElement);
|
||||
|
||||
if (!SetPStyle(oStyle, oXmlElement))
|
||||
if (oXmlElement.Empty())
|
||||
return false;
|
||||
|
||||
structStyle.SetFinalId(m_sId);
|
||||
m_arStyleUsed.push_back(structStyle);
|
||||
m_sStyle += oXmlElement.GetPStyle();
|
||||
|
||||
|
||||
@ -12,19 +12,16 @@ namespace NSCSS
|
||||
{
|
||||
CCompiledStyle m_oStyle;
|
||||
bool m_bIsPStyle;
|
||||
std::wstring m_wsFinalId;
|
||||
|
||||
public:
|
||||
CStyleUsed(const CCompiledStyle& oStyle, bool bIsPStyle);
|
||||
|
||||
void SetFinalId(const std::wstring& wsFinalId);
|
||||
|
||||
bool operator==(const CStyleUsed& oUsedStyle) const;
|
||||
|
||||
std::wstring GetId() const;
|
||||
std::wstring getId();
|
||||
};
|
||||
|
||||
static const std::vector<std::wstring> Names_Standard_Styles = {L"a", L"a-c", L"li", L"h1", L"h2", L"h3", L"h4", L"h5", L"h6", L"h1-c", L"h2-c", L"h3-c", L"h4-c", L"h5-c", L"h6-c"};
|
||||
static const std::vector<std::wstring> Names_Standard_Styles = {L"a", L"li", L"h1", L"h2", L"h3", L"h4", L"h5", L"h6",L"p", L"div"};
|
||||
|
||||
class CSSCALCULATOR_EXPORT CDocumentStyle
|
||||
{
|
||||
@ -39,12 +36,12 @@ namespace NSCSS
|
||||
std::wstring m_sStyle;
|
||||
std::wstring m_sId;
|
||||
|
||||
bool CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement);
|
||||
bool CreateStandardStyle (const std::wstring& sNameStyle, CXmlElement& oElement);
|
||||
bool ConvertStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle);
|
||||
void CombineStandardStyles(const std::vector<std::wstring>& arStandartedStyles, CXmlElement& oElement);
|
||||
void CreateStandardStyle (const std::wstring& sNameStyle, CXmlElement& oElement);
|
||||
void ConvertStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle);
|
||||
|
||||
bool SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite = false);
|
||||
bool SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite = false);
|
||||
void SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite = false);
|
||||
void SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite = false);
|
||||
|
||||
void SetBorderStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, const PProperties& enBorderProperty);
|
||||
public:
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include <cwctype>
|
||||
#include <functional>
|
||||
|
||||
#include <iostream>
|
||||
#include "../ConstValues.h"
|
||||
|
||||
#define DEFAULTFONTNAME L"Times New Roman"
|
||||
@ -66,7 +67,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h1-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"0");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h2")
|
||||
{
|
||||
@ -77,7 +78,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h2-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"1");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h3")
|
||||
{
|
||||
@ -88,7 +89,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h3-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"2");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h4")
|
||||
{
|
||||
@ -99,7 +100,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h4-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"3");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h5")
|
||||
{
|
||||
@ -110,7 +111,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h5-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"4");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
|
||||
}
|
||||
else if (sNameDefaultElement == L"h6")
|
||||
@ -122,13 +123,13 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h6-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"5");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h1-c")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h1-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 1 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 1 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h1");
|
||||
@ -141,7 +142,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h2-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 2 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 2 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
@ -154,7 +155,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h3-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 3 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 3 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
@ -167,7 +168,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h4-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 4 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 4 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
@ -180,7 +181,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h5-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 5 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 5 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
@ -193,7 +194,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"h6-c");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Heading 6 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Title 6 Sign");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_CustomStyle, L"1");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UiPriority, L"9");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
@ -478,19 +479,6 @@ std::wstring CXmlElement::ConvertRStyle(bool bIsLite) const
|
||||
sRStyle += L"<w:vanish/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::RunnerProperties::R_Strike:
|
||||
{
|
||||
sRStyle += L"<w:" + oItem.second + L"/>";
|
||||
break;
|
||||
}
|
||||
case CSSProperties::RunnerProperties::R_VertAlign:
|
||||
{
|
||||
if (L"top" == oItem.second)
|
||||
sRStyle += L"<w:vertAlign w:val=\"superscript\"/>";
|
||||
else if (L"bottom" == oItem.second)
|
||||
sRStyle += L"<w:vertAlign w:val=\"subscript\"/>";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -7,5 +7,4 @@ core_windows:INCLUDEPATH += $$PWD/gumbo-parser/visualc/include
|
||||
HEADERS += $$files($$PWD/gumbo-parser/src/*.h, true) \
|
||||
$$PWD/htmltoxhtml.h
|
||||
|
||||
SOURCES += $$files($$PWD/gumbo-parser/src/*.c, true) \
|
||||
$$PWD/htmltoxhtml.cpp
|
||||
SOURCES += $$files($$PWD/gumbo-parser/src/*.c, true)
|
||||
|
||||
@ -1,657 +0,0 @@
|
||||
#include "htmltoxhtml.h"
|
||||
|
||||
#include <map>
|
||||
#include <cctype>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "gumbo-parser/src/gumbo.h"
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
#include "../../../DesktopEditor/common/Directory.h"
|
||||
#include "../../../DesktopEditor/common/StringBuilder.h"
|
||||
#include "../../../UnicodeConverter/UnicodeConverter.h"
|
||||
#include "../../../HtmlFile2/src/StringFinder.h"
|
||||
|
||||
namespace HTML
|
||||
{
|
||||
#if defined(CreateDirectory)
|
||||
#undef CreateDirectory
|
||||
#endif
|
||||
|
||||
static std::string nonbreaking_inline = "|a|abbr|acronym|b|bdo|big|cite|code|dfn|em|font|i|img|kbd|nobr|s|small|span|strike|strong|sub|sup|tt|";
|
||||
static std::string empty_tags = "|area|base|basefont|bgsound|br|command|col|embed|event-source|frame|hr|image|img|input|keygen|link|menuitem|meta|param|source|spacer|track|wbr|";
|
||||
static std::string preserve_whitespace = "|pre|textarea|script|style|";
|
||||
static std::string special_handling = "|html|body|";
|
||||
static std::string treat_like_inline = "|p|";
|
||||
|
||||
static std::vector<std::string> html_tags = {"div","span","a","img","p","h1","h2","h3","h4","h5","h6",
|
||||
"ul", "ol", "li","td","tr","table","thead","tbody","tfoot","th",
|
||||
"br","form","input","button","section","nav","header","footer",
|
||||
"main","figure","figcaption","strong","em","i", "b", "u","pre",
|
||||
"code","blockquote","hr","script","link","meta","style","title",
|
||||
"head","body","html","legend","optgroup","option","select","dl",
|
||||
"dt","dd","time","data","abbr","address","area","base","bdi",
|
||||
"bdo","cite","col","iframe","video","source","track","textarea",
|
||||
"label","fieldset","colgroup","del","ins","details","summary",
|
||||
"dialog","embed","kbd","map","mark","menu","meter","object",
|
||||
"output","param","progress","q","samp","small","sub","sup","var",
|
||||
"wbr","acronym","applet","article","aside","audio","basefont",
|
||||
"bgsound","big","blink","canvas","caption","center","command",
|
||||
"comment","datalist","dfn","dir","font","frame","frameset",
|
||||
"hgroup","isindex","keygen","marquee","nobr","noembed","noframes",
|
||||
"noscript","plaintext","rp","rt","ruby","s","strike","tt","xmp"};
|
||||
|
||||
static std::vector<std::string> unchecked_nodes_new = {"svg"};
|
||||
|
||||
static void replace_all(std::string& s, const std::string& s1, const std::string& s2)
|
||||
{
|
||||
size_t pos = s.find(s1);
|
||||
while(pos != std::string::npos)
|
||||
{
|
||||
s.replace(pos, s1.length(), s2);
|
||||
pos = s.find(s1, pos + s2.length());
|
||||
}
|
||||
}
|
||||
|
||||
static bool NodeIsUnprocessed(const std::string& sTagName)
|
||||
{
|
||||
return "xml" == sTagName;
|
||||
}
|
||||
|
||||
static bool IsUnckeckedNodes(const std::string& sValue)
|
||||
{
|
||||
return unchecked_nodes_new.end() != std::find(unchecked_nodes_new.begin(), unchecked_nodes_new.end(), sValue);
|
||||
}
|
||||
|
||||
static std::string Base64ToString(const std::string& sContent, const std::string& sCharset)
|
||||
{
|
||||
std::string sRes;
|
||||
int nSrcLen = (int)sContent.length();
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen);
|
||||
BYTE* pData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(sContent.c_str(), nSrcLen, pData, &nDecodeLen))
|
||||
{
|
||||
std::wstring sConvert;
|
||||
if(!sCharset.empty() && NSStringFinder::Equals<std::string>("utf-8", sCharset))
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sConvert = oConverter.toUnicode(reinterpret_cast<char *>(pData), (unsigned)nDecodeLen, sCharset.data());
|
||||
}
|
||||
sRes = sConvert.empty() ? std::string(reinterpret_cast<char *>(pData), nDecodeLen) : U_TO_UTF8(sConvert);
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
return sRes;
|
||||
}
|
||||
|
||||
static std::string QuotedPrintableDecode(const std::string& sContent, std::string& sCharset)
|
||||
{
|
||||
NSStringUtils::CStringBuilderA sRes;
|
||||
size_t ip = 0;
|
||||
size_t i = sContent.find('=');
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
size_t nIgnore = 12;
|
||||
std::string charset = sContent.substr(0, nIgnore);
|
||||
if(charset == "=00=00=FE=FF")
|
||||
sCharset = "UTF-32BE";
|
||||
else if(charset == "=FF=FE=00=00")
|
||||
sCharset = "UTF-32LE";
|
||||
else if(charset == "=2B=2F=76=38" || charset == "=2B=2F=76=39" ||
|
||||
charset == "=2B=2F=76=2B" || charset == "=2B=2F=76=2F")
|
||||
sCharset = "UTF-7";
|
||||
else if(charset == "=DD=73=66=73")
|
||||
sCharset = "UTF-EBCDIC";
|
||||
else if(charset == "=84=31=95=33")
|
||||
sCharset = "GB-18030";
|
||||
else
|
||||
{
|
||||
nIgnore -= 3;
|
||||
charset.erase(nIgnore);
|
||||
if(charset == "=EF=BB=BF")
|
||||
sCharset = "UTF-8";
|
||||
else if(charset == "=F7=64=4C")
|
||||
sCharset = "UTF-1";
|
||||
else if(charset == "=0E=FE=FF")
|
||||
sCharset = "SCSU";
|
||||
else if(charset == "=FB=EE=28")
|
||||
sCharset = "BOCU-1";
|
||||
else
|
||||
{
|
||||
nIgnore -= 3;
|
||||
charset.erase(nIgnore);
|
||||
if(charset == "=FE=FF")
|
||||
sCharset = "UTF-16BE";
|
||||
else if(charset == "=FF=FE")
|
||||
sCharset = "UTF-16LE";
|
||||
else
|
||||
nIgnore -= 6;
|
||||
}
|
||||
}
|
||||
|
||||
ip = nIgnore;
|
||||
i = sContent.find('=', ip);
|
||||
}
|
||||
|
||||
while(i != std::string::npos && i + 2 < sContent.length())
|
||||
{
|
||||
sRes.WriteString(sContent.c_str() + ip, i - ip);
|
||||
std::string str = sContent.substr(i + 1, 2);
|
||||
if(str.front() == '\n' || str.front() == '\r')
|
||||
{
|
||||
char ch = str[1];
|
||||
if(ch != '\n' && ch != '\r')
|
||||
sRes.WriteString(&ch, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
char* err;
|
||||
char ch = (int)strtol(str.data(), &err, 16);
|
||||
if(*err)
|
||||
sRes.WriteString('=' + str);
|
||||
else
|
||||
sRes.WriteString(&ch, 1);
|
||||
}
|
||||
ip = i + 3;
|
||||
i = sContent.find('=', ip);
|
||||
}
|
||||
if(ip != std::string::npos)
|
||||
sRes.WriteString(sContent.c_str() + ip);
|
||||
return sRes.GetData();
|
||||
}
|
||||
|
||||
static std::string mhtTohtml(const std::string& sFileContent);
|
||||
|
||||
static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::string>& sRes, NSStringUtils::CStringBuilderA& oRes)
|
||||
{
|
||||
size_t unContentPosition = 0, unCharsetBegin = 0, unCharsetEnd = std::string::npos;
|
||||
|
||||
NSStringFinder::TFoundedData<char> oData;
|
||||
|
||||
// Content-Type
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentType{oData.m_sValue};
|
||||
|
||||
if (sContentType.empty())
|
||||
return;
|
||||
|
||||
if (NSStringFinder::Equals(sContentType, "multipart/alternative"))
|
||||
{
|
||||
oRes.WriteString(mhtTohtml(sMhtContent.substr(oData.m_unEndPosition, sMhtContent.length() - oData.m_unEndPosition)));
|
||||
return;
|
||||
}
|
||||
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetBegin = oData.m_unEndPosition;
|
||||
|
||||
// name
|
||||
// std::string sName = NSStringFinder::FindProperty(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
// unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
|
||||
// Content-Location
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentLocation{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
|
||||
// Content-ID
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentID{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
{
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetEnd = std::min(unCharsetEnd, oData.m_unBeginPosition);
|
||||
NSStringFinder::CutInside<std::string>(sContentID, "<", ">");
|
||||
}
|
||||
|
||||
if (sContentLocation.empty() && !sContentID.empty())
|
||||
sContentLocation = "cid:" + sContentID;
|
||||
|
||||
// Content-Transfer-Encoding
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentEncoding{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
{
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetEnd = std::min(unCharsetEnd, oData.m_unBeginPosition);
|
||||
}
|
||||
|
||||
// charset
|
||||
std::string sCharset = "utf-8";
|
||||
|
||||
if (std::string::npos != unCharsetEnd && unCharsetBegin < unCharsetEnd)
|
||||
{
|
||||
sCharset = NSStringFinder::FindProperty(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
|
||||
NSStringFinder::CutInside<std::string>(sCharset, "\"");
|
||||
}
|
||||
|
||||
// Content
|
||||
std::string sContent = sMhtContent.substr(unContentPosition, sMhtContent.length() - unContentPosition);
|
||||
|
||||
// std::wstring sExtention = NSFile::GetFileExtention(UTF8_TO_U(sName));
|
||||
// std::transform(sExtention.begin(), sExtention.end(), sExtention.begin(), tolower);
|
||||
// Основной документ
|
||||
if (NSStringFinder::Equals(sContentType, "multipart/alternative"))
|
||||
oRes.WriteString(mhtTohtml(sContent));
|
||||
else if ((NSStringFinder::Find(sContentType, "text") /*&& (sExtention.empty() || NSStringFinder::EqualOf(sExtention, {L"htm", L"html", L"xhtml", L"css"}))*/)
|
||||
|| (NSStringFinder::Equals(sContentType, "application/octet-stream") && NSStringFinder::Find(sContentLocation, "css")))
|
||||
{
|
||||
// Стили заключаются в тэг <style>
|
||||
const bool bAddTagStyle = NSStringFinder::Equals(sContentType, "text/css") /*|| NSStringFinder::Equals(sExtention, L"css")*/ || NSStringFinder::Find(sContentLocation, "css");
|
||||
|
||||
if (bAddTagStyle)
|
||||
oRes.WriteString("<style>");
|
||||
|
||||
if (NSStringFinder::Equals(sContentEncoding, "base64"))
|
||||
sContent = Base64ToString(sContent, sCharset);
|
||||
else if (NSStringFinder::EqualOf(sContentEncoding, {"8bit", "7bit"}) || sContentEncoding.empty())
|
||||
{
|
||||
if (!NSStringFinder::Equals(sCharset, "utf-8") && !sCharset.empty())
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
|
||||
}
|
||||
}
|
||||
else if (NSStringFinder::Equals(sContentEncoding, "quoted-printable"))
|
||||
{
|
||||
sContent = QuotedPrintableDecode(sContent, sCharset);
|
||||
if (!NSStringFinder::Equals(sCharset, "utf-8") && !sCharset.empty())
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
|
||||
}
|
||||
}
|
||||
|
||||
if (NSStringFinder::Equals(sContentType, "text/html"))
|
||||
sContent = U_TO_UTF8(htmlToXhtml(sContent, false));
|
||||
|
||||
oRes.WriteString(sContent);
|
||||
|
||||
if(bAddTagStyle)
|
||||
oRes.WriteString("</style>");
|
||||
}
|
||||
// Картинки
|
||||
else if ((NSStringFinder::Find(sContentType, "image") /*|| NSStringFinder::Equals(sExtention, L"gif")*/ || NSStringFinder::Equals(sContentType, "application/octet-stream")) &&
|
||||
NSStringFinder::Equals(sContentEncoding, "base64"))
|
||||
{
|
||||
// if (NSStringFinder::Equals(sExtention, L"ico") || NSStringFinder::Find(sContentType, "ico"))
|
||||
// sContentType = "image/jpg";
|
||||
// else if(NSStringFinder::Equals(sExtention, L"gif"))
|
||||
// sContentType = "image/gif";
|
||||
int nSrcLen = (int)sContent.length();
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen);
|
||||
BYTE* pData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(sContent.c_str(), nSrcLen, pData, &nDecodeLen))
|
||||
sRes.insert(std::make_pair(sContentLocation, "data:" + sContentType + ";base64," + sContent));
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
}
|
||||
}
|
||||
|
||||
static std::string mhtTohtml(const std::string& sFileContent)
|
||||
{
|
||||
std::map<std::string, std::string> sRes;
|
||||
NSStringUtils::CStringBuilderA oRes;
|
||||
|
||||
// Поиск boundary
|
||||
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindProperty(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
|
||||
|
||||
size_t nFound{oData.m_unEndPosition};
|
||||
std::string sBoundary{oData.m_sValue};
|
||||
|
||||
if (sBoundary.empty())
|
||||
{
|
||||
size_t nFoundEnd = sFileContent.length();
|
||||
nFound = 0;
|
||||
ReadMht(sFileContent.substr(nFound, nFoundEnd), sRes, oRes);
|
||||
return oRes.GetData();
|
||||
}
|
||||
|
||||
NSStringFinder::CutInside<std::string>(sBoundary, "\"");
|
||||
|
||||
size_t nFoundEnd{nFound};
|
||||
|
||||
sBoundary = "--" + sBoundary;
|
||||
size_t nBoundaryLength = sBoundary.length();
|
||||
|
||||
nFound = sFileContent.find(sBoundary, nFound) + nBoundaryLength;
|
||||
|
||||
// Цикл по boundary
|
||||
while(nFound != std::string::npos)
|
||||
{
|
||||
nFoundEnd = sFileContent.find(sBoundary, nFound + nBoundaryLength);
|
||||
if(nFoundEnd == std::string::npos)
|
||||
break;
|
||||
|
||||
ReadMht(sFileContent.substr(nFound, nFoundEnd - nFound), sRes, oRes);
|
||||
|
||||
nFound = sFileContent.find(sBoundary, nFoundEnd);
|
||||
}
|
||||
|
||||
std::string sFile = oRes.GetData();
|
||||
for(const std::pair<std::string, std::string>& item : sRes)
|
||||
{
|
||||
std::string sName = item.first;
|
||||
size_t found = sFile.find(sName);
|
||||
size_t sfound = sName.rfind('/');
|
||||
if(found == std::string::npos && sfound != std::string::npos)
|
||||
found = sFile.find(sName.erase(0, sfound + 1));
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
size_t fq = sFile.find_last_of("\"\'>=", found);
|
||||
|
||||
if (std::string::npos == fq)
|
||||
break;
|
||||
|
||||
char ch = sFile[fq];
|
||||
if(ch != '\"' && ch != '\'')
|
||||
fq++;
|
||||
size_t tq = sFile.find_first_of("\"\'<> ", found) + 1;
|
||||
|
||||
if (std::string::npos == tq)
|
||||
break;
|
||||
|
||||
if(sFile[tq] != '\"' && sFile[tq] != '\'')
|
||||
tq--;
|
||||
if(ch != '>')
|
||||
{
|
||||
std::string is = '\"' + item.second + '\"';
|
||||
sFile.replace(fq, tq - fq, is);
|
||||
found = sFile.find(sName, fq + is.length());
|
||||
}
|
||||
else
|
||||
found = sFile.find(sName, tq);
|
||||
}
|
||||
}
|
||||
|
||||
return sFile;
|
||||
}
|
||||
|
||||
// Заменяет сущности &,<,> в text
|
||||
static void substitute_xml_entities_into_text(std::string& text)
|
||||
{
|
||||
// replacing & must come first
|
||||
replace_all(text, "&", "&");
|
||||
replace_all(text, "<", "<");
|
||||
replace_all(text, ">", ">");
|
||||
}
|
||||
|
||||
// After running through Gumbo, the values of type "" are replaced with the corresponding code '0x01'
|
||||
// Since the attribute value does not use control characters (value <= 0x09),
|
||||
// then just delete them, otherwise XmlUtils::CXmlLiteReader crashes on them.
|
||||
// bug#73486
|
||||
static void remove_control_symbols(std::string& text)
|
||||
{
|
||||
std::string::iterator itFound = std::find_if(text.begin(), text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
|
||||
while (itFound != text.end())
|
||||
{
|
||||
itFound = text.erase(itFound);
|
||||
itFound = std::find_if(itFound, text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
}
|
||||
}
|
||||
|
||||
// Заменяет сущности " в text
|
||||
static void substitute_xml_entities_into_attributes(std::string& text)
|
||||
{
|
||||
remove_control_symbols(text);
|
||||
substitute_xml_entities_into_text(text);
|
||||
replace_all(text, "\"", """);
|
||||
}
|
||||
|
||||
static std::string handle_unknown_tag(GumboStringPiece* text)
|
||||
{
|
||||
if (text->data == NULL)
|
||||
return "";
|
||||
GumboStringPiece gsp = *text;
|
||||
gumbo_tag_from_original_text(&gsp);
|
||||
std::string sAtr = std::string(gsp.data, gsp.length);
|
||||
size_t found = sAtr.find_first_of("-'+,./=?;!*#@$_%<>&;\"\'()[]{}");
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
sAtr.erase(found, 1);
|
||||
found = sAtr.find_first_of("-'+,./=?;!*#@$_%<>&;\"\'()[]{}", found);
|
||||
}
|
||||
return sAtr;
|
||||
}
|
||||
|
||||
static std::string get_tag_name(GumboNode* node)
|
||||
{
|
||||
std::string tagname = (node->type == GUMBO_NODE_DOCUMENT ? "document" : gumbo_normalized_tagname(node->v.element.tag));
|
||||
if (tagname.empty())
|
||||
tagname = handle_unknown_tag(&node->v.element.original_tag);
|
||||
return tagname;
|
||||
}
|
||||
|
||||
static void build_doctype(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder)
|
||||
{
|
||||
if (node->v.document.has_doctype)
|
||||
{
|
||||
oBuilder.WriteString("<!DOCTYPE ");
|
||||
oBuilder.WriteString(node->v.document.name);
|
||||
std::string pi(node->v.document.public_identifier);
|
||||
remove_control_symbols(pi);
|
||||
if ((node->v.document.public_identifier != NULL) && !pi.empty())
|
||||
{
|
||||
oBuilder.WriteString(" PUBLIC \"");
|
||||
oBuilder.WriteString(pi);
|
||||
oBuilder.WriteString("\" \"");
|
||||
oBuilder.WriteString(node->v.document.system_identifier);
|
||||
oBuilder.WriteString("\"");
|
||||
}
|
||||
oBuilder.WriteString(">");
|
||||
}
|
||||
}
|
||||
|
||||
static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringBuilderA& atts)
|
||||
{
|
||||
std::vector<std::string> arrRepeat;
|
||||
for (size_t i = 0; i < attribs->length; ++i)
|
||||
{
|
||||
GumboAttribute* at = static_cast<GumboAttribute*>(attribs->data[i]);
|
||||
std::string sVal(at->value);
|
||||
std::string sName(at->name);
|
||||
|
||||
remove_control_symbols(sVal);
|
||||
remove_control_symbols(sName);
|
||||
|
||||
atts.WriteString(" ");
|
||||
|
||||
bool bCheck = false;
|
||||
size_t nBad = sName.find_first_of("+,.=?#%<>&;\"\'()[]{}");
|
||||
while(nBad != std::string::npos)
|
||||
{
|
||||
sName.erase(nBad, 1);
|
||||
nBad = sName.find_first_of("+,.=?#%<>&;\"\'()[]{}", nBad);
|
||||
if(sName.empty())
|
||||
break;
|
||||
bCheck = true;
|
||||
}
|
||||
if(sName.empty())
|
||||
continue;
|
||||
while(sName.front() >= '0' && sName.front() <= '9')
|
||||
{
|
||||
sName.erase(0, 1);
|
||||
if(sName.empty())
|
||||
break;
|
||||
bCheck = true;
|
||||
}
|
||||
if(bCheck)
|
||||
{
|
||||
GumboAttribute* check = gumbo_get_attribute(attribs, sName.c_str());
|
||||
if(check || std::find(arrRepeat.begin(), arrRepeat.end(), sName) != arrRepeat.end())
|
||||
continue;
|
||||
else
|
||||
arrRepeat.push_back(sName);
|
||||
}
|
||||
|
||||
if(sName.empty())
|
||||
continue;
|
||||
atts.WriteString(sName);
|
||||
|
||||
// determine original quote character used if it exists
|
||||
std::string qs ="\"";
|
||||
atts.WriteString("=");
|
||||
atts.WriteString(qs);
|
||||
substitute_xml_entities_into_attributes(sVal);
|
||||
atts.WriteString(sVal);
|
||||
atts.WriteString(qs);
|
||||
}
|
||||
}
|
||||
|
||||
static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder, bool bCheckValidNode = true);
|
||||
|
||||
static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA& contents, bool bCheckValidNode)
|
||||
{
|
||||
std::string key = "|" + get_tag_name(node) + "|";
|
||||
bool keep_whitespace = preserve_whitespace.find(key) != std::string::npos;
|
||||
bool is_inline = nonbreaking_inline.find(key) != std::string::npos;
|
||||
bool is_like_inline = treat_like_inline.find(key) != std::string::npos;
|
||||
|
||||
GumboVector* children = &node->v.element.children;
|
||||
|
||||
for (size_t i = 0; i < children->length; i++)
|
||||
{
|
||||
GumboNode* child = static_cast<GumboNode*> (children->data[i]);
|
||||
|
||||
if (child->type == GUMBO_NODE_TEXT)
|
||||
{
|
||||
std::string val(child->v.text.text);
|
||||
remove_control_symbols(val);
|
||||
substitute_xml_entities_into_text(val);
|
||||
|
||||
// Избавление от FF
|
||||
size_t found = val.find_first_of("\014");
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
val.erase(found, 1);
|
||||
found = val.find_first_of("\014", found);
|
||||
}
|
||||
|
||||
contents.WriteString(val);
|
||||
}
|
||||
else if ((child->type == GUMBO_NODE_ELEMENT) || (child->type == GUMBO_NODE_TEMPLATE))
|
||||
prettyprint(child, contents, bCheckValidNode);
|
||||
else if (child->type == GUMBO_NODE_WHITESPACE)
|
||||
{
|
||||
if (keep_whitespace || is_inline || is_like_inline)
|
||||
contents.WriteString(child->v.text.text);
|
||||
}
|
||||
else if (child->type != GUMBO_NODE_COMMENT)
|
||||
{
|
||||
// Сообщение об ошибке
|
||||
// Does this actually exist: (child->type == GUMBO_NODE_CDATA)
|
||||
// fprintf(stderr, "unknown element of type: %d\n", child->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder, bool bCheckValidNode)
|
||||
{
|
||||
// special case the document node
|
||||
if (node->type == GUMBO_NODE_DOCUMENT)
|
||||
{
|
||||
build_doctype(node, oBuilder);
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string tagname = get_tag_name(node);
|
||||
remove_control_symbols(tagname);
|
||||
|
||||
if (NodeIsUnprocessed(tagname))
|
||||
return;
|
||||
|
||||
if (bCheckValidNode)
|
||||
bCheckValidNode = !IsUnckeckedNodes(tagname);
|
||||
|
||||
if (bCheckValidNode && html_tags.end() == std::find(html_tags.begin(), html_tags.end(), tagname))
|
||||
{
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string close = "";
|
||||
std::string closeTag = "";
|
||||
std::string key = "|" + tagname + "|";
|
||||
bool is_empty_tag = empty_tags.find(key) != std::string::npos;
|
||||
|
||||
// determine closing tag type
|
||||
if (is_empty_tag)
|
||||
close = "/";
|
||||
else
|
||||
closeTag = "</" + tagname + ">";
|
||||
|
||||
// build results
|
||||
oBuilder.WriteString("<" + tagname);
|
||||
|
||||
// build attr string
|
||||
const GumboVector* attribs = &node->v.element.attributes;
|
||||
build_attributes(attribs, oBuilder);
|
||||
oBuilder.WriteString(close + ">");
|
||||
|
||||
// prettyprint your contents
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
oBuilder.WriteString(closeTag);
|
||||
}
|
||||
|
||||
std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
|
||||
{
|
||||
if (bNeedConvert)
|
||||
{ // Определение кодировки
|
||||
std::string sEncoding = NSStringFinder::FindProperty(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\"", "'"}).m_sValue;
|
||||
|
||||
if (sEncoding.empty())
|
||||
sEncoding = NSStringFinder::FindProperty(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
|
||||
if (!sEncoding.empty() && !NSStringFinder::Equals("utf-8", sEncoding))
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sFileContent = U_TO_UTF8(oConverter.toUnicode(sFileContent, sEncoding.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
// Избавляемся от лишних символов до <...
|
||||
boost::regex oRegex("<[a-zA-Z]");
|
||||
boost::match_results<typename std::string::const_iterator> oResult;
|
||||
|
||||
if (boost::regex_search(sFileContent, oResult, oRegex))
|
||||
sFileContent.erase(0, oResult.position());
|
||||
|
||||
//Избавление от <a ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "a"));
|
||||
//Избавление от <title ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "title"));
|
||||
//Избавление от <script ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "script"));
|
||||
|
||||
// Gumbo
|
||||
GumboOptions options = kGumboDefaultOptions;
|
||||
GumboOutput* output = gumbo_parse_with_options(&options, sFileContent.data(), sFileContent.length());
|
||||
|
||||
// prettyprint
|
||||
NSStringUtils::CStringBuilderA oBuilder;
|
||||
prettyprint(output->document, oBuilder);
|
||||
|
||||
// Конвертирование из string utf8 в wstring
|
||||
return UTF8_TO_U(oBuilder.GetData());
|
||||
}
|
||||
|
||||
std::wstring mhtToXhtml(std::string& sFileContent)
|
||||
{
|
||||
sFileContent = mhtTohtml(sFileContent);
|
||||
|
||||
// Gumbo
|
||||
GumboOptions options = kGumboDefaultOptions;
|
||||
GumboOutput* output = gumbo_parse_with_options(&options, sFileContent.data(), sFileContent.length());
|
||||
|
||||
// prettyprint
|
||||
NSStringUtils::CStringBuilderA oBuilder;
|
||||
prettyprint(output->document, oBuilder);
|
||||
|
||||
// Конвертирование из string utf8 в wstring
|
||||
return UTF8_TO_U(oBuilder.GetData());
|
||||
}
|
||||
}
|
||||
@ -2,11 +2,658 @@
|
||||
#define HTMLTOXHTML_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <cctype>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace HTML
|
||||
#include "gumbo-parser/src/gumbo.h"
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
#include "../../../DesktopEditor/common/Directory.h"
|
||||
#include "../../../DesktopEditor/common/StringBuilder.h"
|
||||
#include "../../../DesktopEditor/xml/include/xmlutils.h"
|
||||
#include "../../../UnicodeConverter/UnicodeConverter.h"
|
||||
#include "../../../HtmlFile2/src/StringFinder.h"
|
||||
|
||||
#if defined(CreateDirectory)
|
||||
#undef CreateDirectory
|
||||
#endif
|
||||
|
||||
static std::string nonbreaking_inline = "|a|abbr|acronym|b|bdo|big|cite|code|dfn|em|font|i|img|kbd|nobr|s|small|span|strike|strong|sub|sup|tt|";
|
||||
static std::string empty_tags = "|area|base|basefont|bgsound|br|command|col|embed|event-source|frame|hr|image|img|input|keygen|link|menuitem|meta|param|source|spacer|track|wbr|";
|
||||
static std::string preserve_whitespace = "|pre|textarea|script|style|";
|
||||
static std::string special_handling = "|html|body|";
|
||||
static std::string treat_like_inline = "|p|";
|
||||
|
||||
static std::vector<std::string> html_tags = {"div","span","a","img","p","h1","h2","h3","h4","h5","h6",
|
||||
"ul", "ol", "li","td","tr","table","thead","tbody","tfoot","th",
|
||||
"br","form","input","button","section","nav","header","footer",
|
||||
"main","figure","figcaption","strong","em","i", "b", "u","pre",
|
||||
"code","blockquote","hr","script","link","meta","style","title",
|
||||
"head","body","html","legend","optgroup","option","select","dl",
|
||||
"dt","dd","time","data","abbr","address","area","base","bdi",
|
||||
"bdo","cite","col","iframe","video","source","track","textarea",
|
||||
"label","fieldset","colgroup","del","ins","details","summary",
|
||||
"dialog","embed","kbd","map","mark","menu","meter","object",
|
||||
"output","param","progress","q","samp","small","sub","sup","var",
|
||||
"wbr","acronym","applet","article","aside","audio","basefont",
|
||||
"bgsound","big","blink","canvas","caption","center","command",
|
||||
"comment","datalist","dfn","dir","font","frame","frameset",
|
||||
"hgroup","isindex","keygen","marquee","nobr","noembed","noframes",
|
||||
"noscript","plaintext","rp","rt","ruby","s","strike","tt","xmp"};
|
||||
|
||||
static std::vector<std::string> unchecked_nodes_new = {"svg"};
|
||||
|
||||
static void prettyprint(GumboNode*, NSStringUtils::CStringBuilderA& oBuilder, bool bCheckValidNode = true);
|
||||
static std::string mhtTohtml(const std::string &sFileContent);
|
||||
|
||||
// Заменяет в строке s все символы s1 на s2
|
||||
static void replace_all(std::string& s, const std::string& s1, const std::string& s2)
|
||||
{
|
||||
std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert);
|
||||
std::wstring mhtToXhtml(std::string& sFileContent);
|
||||
size_t pos = s.find(s1);
|
||||
while(pos != std::string::npos)
|
||||
{
|
||||
s.replace(pos, s1.length(), s2);
|
||||
pos = s.find(s1, pos + s2.length());
|
||||
}
|
||||
}
|
||||
|
||||
static bool NodeIsUnprocessed(const std::string& wsTagName)
|
||||
{
|
||||
return "xml" == wsTagName;
|
||||
}
|
||||
|
||||
static bool IsUnckeckedNodes(const std::string& sValue)
|
||||
{
|
||||
return unchecked_nodes_new.end() != std::find(unchecked_nodes_new.begin(), unchecked_nodes_new.end(), sValue);
|
||||
}
|
||||
|
||||
static std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
|
||||
{
|
||||
if (bNeedConvert)
|
||||
{ // Определение кодировки
|
||||
std::string sEncoding = NSStringFinder::FindProperty(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\"", "'"}).m_sValue;
|
||||
|
||||
if (sEncoding.empty())
|
||||
sEncoding = NSStringFinder::FindProperty(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
|
||||
if (!sEncoding.empty() && !NSStringFinder::Equals("utf-8", sEncoding))
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sFileContent = U_TO_UTF8(oConverter.toUnicode(sFileContent, sEncoding.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
// Избавляемся от лишних символов до <...
|
||||
boost::regex oRegex("<[a-zA-Z]");
|
||||
boost::match_results<typename std::string::const_iterator> oResult;
|
||||
|
||||
if (boost::regex_search(sFileContent, oResult, oRegex))
|
||||
sFileContent.erase(0, oResult.position());
|
||||
|
||||
//Избавление от <a ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "a"));
|
||||
//Избавление от <title ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "title"));
|
||||
//Избавление от <script ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "script"));
|
||||
|
||||
// Gumbo
|
||||
GumboOptions options = kGumboDefaultOptions;
|
||||
GumboOutput* output = gumbo_parse_with_options(&options, sFileContent.data(), sFileContent.length());
|
||||
|
||||
// prettyprint
|
||||
NSStringUtils::CStringBuilderA oBuilder;
|
||||
prettyprint(output->document, oBuilder);
|
||||
|
||||
// Конвертирование из string utf8 в wstring
|
||||
return UTF8_TO_U(oBuilder.GetData());
|
||||
}
|
||||
|
||||
static std::string Base64ToString(const std::string& sContent, const std::string& sCharset)
|
||||
{
|
||||
std::string sRes;
|
||||
int nSrcLen = (int)sContent.length();
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen);
|
||||
BYTE* pData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(sContent.c_str(), nSrcLen, pData, &nDecodeLen))
|
||||
{
|
||||
std::wstring sConvert;
|
||||
if(!sCharset.empty() && NSStringFinder::Equals<std::string>("utf-8", sCharset))
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sConvert = oConverter.toUnicode(reinterpret_cast<char *>(pData), (unsigned)nDecodeLen, sCharset.data());
|
||||
}
|
||||
sRes = sConvert.empty() ? std::string(reinterpret_cast<char *>(pData), nDecodeLen) : U_TO_UTF8(sConvert);
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
return sRes;
|
||||
}
|
||||
|
||||
static std::string QuotedPrintableDecode(const std::string& sContent, std::string& sCharset)
|
||||
{
|
||||
NSStringUtils::CStringBuilderA sRes;
|
||||
size_t ip = 0;
|
||||
size_t i = sContent.find('=');
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
size_t nIgnore = 12;
|
||||
std::string charset = sContent.substr(0, nIgnore);
|
||||
if(charset == "=00=00=FE=FF")
|
||||
sCharset = "UTF-32BE";
|
||||
else if(charset == "=FF=FE=00=00")
|
||||
sCharset = "UTF-32LE";
|
||||
else if(charset == "=2B=2F=76=38" || charset == "=2B=2F=76=39" ||
|
||||
charset == "=2B=2F=76=2B" || charset == "=2B=2F=76=2F")
|
||||
sCharset = "UTF-7";
|
||||
else if(charset == "=DD=73=66=73")
|
||||
sCharset = "UTF-EBCDIC";
|
||||
else if(charset == "=84=31=95=33")
|
||||
sCharset = "GB-18030";
|
||||
else
|
||||
{
|
||||
nIgnore -= 3;
|
||||
charset.erase(nIgnore);
|
||||
if(charset == "=EF=BB=BF")
|
||||
sCharset = "UTF-8";
|
||||
else if(charset == "=F7=64=4C")
|
||||
sCharset = "UTF-1";
|
||||
else if(charset == "=0E=FE=FF")
|
||||
sCharset = "SCSU";
|
||||
else if(charset == "=FB=EE=28")
|
||||
sCharset = "BOCU-1";
|
||||
else
|
||||
{
|
||||
nIgnore -= 3;
|
||||
charset.erase(nIgnore);
|
||||
if(charset == "=FE=FF")
|
||||
sCharset = "UTF-16BE";
|
||||
else if(charset == "=FF=FE")
|
||||
sCharset = "UTF-16LE";
|
||||
else
|
||||
nIgnore -= 6;
|
||||
}
|
||||
}
|
||||
|
||||
ip = nIgnore;
|
||||
i = sContent.find('=', ip);
|
||||
}
|
||||
|
||||
while(i != std::string::npos && i + 2 < sContent.length())
|
||||
{
|
||||
sRes.WriteString(sContent.c_str() + ip, i - ip);
|
||||
std::string str = sContent.substr(i + 1, 2);
|
||||
if(str.front() == '\n' || str.front() == '\r')
|
||||
{
|
||||
char ch = str[1];
|
||||
if(ch != '\n' && ch != '\r')
|
||||
sRes.WriteString(&ch, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
char* err;
|
||||
char ch = (int)strtol(str.data(), &err, 16);
|
||||
if(*err)
|
||||
sRes.WriteString('=' + str);
|
||||
else
|
||||
sRes.WriteString(&ch, 1);
|
||||
}
|
||||
ip = i + 3;
|
||||
i = sContent.find('=', ip);
|
||||
}
|
||||
if(ip != std::string::npos)
|
||||
sRes.WriteString(sContent.c_str() + ip);
|
||||
return sRes.GetData();
|
||||
}
|
||||
|
||||
static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::string>& sRes, NSStringUtils::CStringBuilderA& oRes)
|
||||
{
|
||||
size_t unContentPosition = 0, unCharsetBegin = 0, unCharsetEnd = std::string::npos;
|
||||
|
||||
NSStringFinder::TFoundedData<char> oData;
|
||||
|
||||
// Content-Type
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentType{oData.m_sValue};
|
||||
|
||||
if (sContentType.empty())
|
||||
return;
|
||||
|
||||
if (NSStringFinder::Equals(sContentType, "multipart/alternative"))
|
||||
{
|
||||
oRes.WriteString(mhtTohtml(sMhtContent.substr(oData.m_unEndPosition, sMhtContent.length() - oData.m_unEndPosition)));
|
||||
return;
|
||||
}
|
||||
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetBegin = oData.m_unEndPosition;
|
||||
|
||||
// name
|
||||
// std::string sName = NSStringFinder::FindProperty(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
// unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
|
||||
// Content-Location
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentLocation{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
|
||||
// Content-ID
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentID{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
{
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetEnd = std::min(unCharsetEnd, oData.m_unBeginPosition);
|
||||
NSStringFinder::CutInside<std::string>(sContentID, "<", ">");
|
||||
}
|
||||
|
||||
if (sContentLocation.empty() && !sContentID.empty())
|
||||
sContentLocation = "cid:" + sContentID;
|
||||
|
||||
// Content-Transfer-Encoding
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentEncoding{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
{
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetEnd = std::min(unCharsetEnd, oData.m_unBeginPosition);
|
||||
}
|
||||
|
||||
// charset
|
||||
std::string sCharset = "utf-8";
|
||||
|
||||
if (std::string::npos != unCharsetEnd && unCharsetBegin < unCharsetEnd)
|
||||
{
|
||||
sCharset = NSStringFinder::FindProperty(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
|
||||
NSStringFinder::CutInside<std::string>(sCharset, "\"");
|
||||
}
|
||||
|
||||
// Content
|
||||
std::string sContent = sMhtContent.substr(unContentPosition, sMhtContent.length() - unContentPosition);
|
||||
|
||||
// std::wstring sExtention = NSFile::GetFileExtention(UTF8_TO_U(sName));
|
||||
// std::transform(sExtention.begin(), sExtention.end(), sExtention.begin(), tolower);
|
||||
// Основной документ
|
||||
if (NSStringFinder::Equals(sContentType, "multipart/alternative"))
|
||||
oRes.WriteString(mhtTohtml(sContent));
|
||||
else if ((NSStringFinder::Find(sContentType, "text") /*&& (sExtention.empty() || NSStringFinder::EqualOf(sExtention, {L"htm", L"html", L"xhtml", L"css"}))*/)
|
||||
|| (NSStringFinder::Equals(sContentType, "application/octet-stream") && NSStringFinder::Find(sContentLocation, "css")))
|
||||
{
|
||||
// Стили заключаются в тэг <style>
|
||||
const bool bAddTagStyle = NSStringFinder::Equals(sContentType, "text/css") /*|| NSStringFinder::Equals(sExtention, L"css")*/ || NSStringFinder::Find(sContentLocation, "css");
|
||||
|
||||
if (bAddTagStyle)
|
||||
oRes.WriteString("<style>");
|
||||
|
||||
if (NSStringFinder::Equals(sContentEncoding, "base64"))
|
||||
sContent = Base64ToString(sContent, sCharset);
|
||||
else if (NSStringFinder::EqualOf(sContentEncoding, {"8bit", "7bit"}) || sContentEncoding.empty())
|
||||
{
|
||||
if (!NSStringFinder::Equals(sCharset, "utf-8") && !sCharset.empty())
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
|
||||
}
|
||||
}
|
||||
else if (NSStringFinder::Equals(sContentEncoding, "quoted-printable"))
|
||||
{
|
||||
sContent = QuotedPrintableDecode(sContent, sCharset);
|
||||
if (!NSStringFinder::Equals(sCharset, "utf-8") && !sCharset.empty())
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
|
||||
}
|
||||
}
|
||||
|
||||
if (NSStringFinder::Equals(sContentType, "text/html"))
|
||||
sContent = U_TO_UTF8(htmlToXhtml(sContent, false));
|
||||
|
||||
oRes.WriteString(sContent);
|
||||
|
||||
if(bAddTagStyle)
|
||||
oRes.WriteString("</style>");
|
||||
}
|
||||
// Картинки
|
||||
else if ((NSStringFinder::Find(sContentType, "image") /*|| NSStringFinder::Equals(sExtention, L"gif")*/ || NSStringFinder::Equals(sContentType, "application/octet-stream")) &&
|
||||
NSStringFinder::Equals(sContentEncoding, "base64"))
|
||||
{
|
||||
// if (NSStringFinder::Equals(sExtention, L"ico") || NSStringFinder::Find(sContentType, "ico"))
|
||||
// sContentType = "image/jpg";
|
||||
// else if(NSStringFinder::Equals(sExtention, L"gif"))
|
||||
// sContentType = "image/gif";
|
||||
int nSrcLen = (int)sContent.length();
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen);
|
||||
BYTE* pData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(sContent.c_str(), nSrcLen, pData, &nDecodeLen))
|
||||
sRes.insert(std::make_pair(sContentLocation, "data:" + sContentType + ";base64," + sContent));
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
}
|
||||
}
|
||||
|
||||
static std::string mhtTohtml(const std::string& sFileContent)
|
||||
{
|
||||
std::map<std::string, std::string> sRes;
|
||||
NSStringUtils::CStringBuilderA oRes;
|
||||
|
||||
// Поиск boundary
|
||||
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindProperty(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
|
||||
|
||||
size_t nFound{oData.m_unEndPosition};
|
||||
std::string sBoundary{oData.m_sValue};
|
||||
|
||||
if (sBoundary.empty())
|
||||
{
|
||||
size_t nFoundEnd = sFileContent.length();
|
||||
nFound = 0;
|
||||
ReadMht(sFileContent.substr(nFound, nFoundEnd), sRes, oRes);
|
||||
return oRes.GetData();
|
||||
}
|
||||
|
||||
NSStringFinder::CutInside<std::string>(sBoundary, "\"");
|
||||
|
||||
size_t nFoundEnd{nFound};
|
||||
|
||||
sBoundary = "--" + sBoundary;
|
||||
size_t nBoundaryLength = sBoundary.length();
|
||||
|
||||
nFound = sFileContent.find(sBoundary, nFound) + nBoundaryLength;
|
||||
|
||||
// Цикл по boundary
|
||||
while(nFound != std::string::npos)
|
||||
{
|
||||
nFoundEnd = sFileContent.find(sBoundary, nFound + nBoundaryLength);
|
||||
if(nFoundEnd == std::string::npos)
|
||||
break;
|
||||
|
||||
ReadMht(sFileContent.substr(nFound, nFoundEnd - nFound), sRes, oRes);
|
||||
|
||||
nFound = sFileContent.find(sBoundary, nFoundEnd);
|
||||
}
|
||||
|
||||
std::string sFile = oRes.GetData();
|
||||
for(const std::pair<std::string, std::string>& item : sRes)
|
||||
{
|
||||
std::string sName = item.first;
|
||||
size_t found = sFile.find(sName);
|
||||
size_t sfound = sName.rfind('/');
|
||||
if(found == std::string::npos && sfound != std::string::npos)
|
||||
found = sFile.find(sName.erase(0, sfound + 1));
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
size_t fq = sFile.find_last_of("\"\'>=", found);
|
||||
|
||||
if (std::string::npos == fq)
|
||||
break;
|
||||
|
||||
char ch = sFile[fq];
|
||||
if(ch != '\"' && ch != '\'')
|
||||
fq++;
|
||||
size_t tq = sFile.find_first_of("\"\'<> ", found) + 1;
|
||||
|
||||
if (std::string::npos == tq)
|
||||
break;
|
||||
|
||||
if(sFile[tq] != '\"' && sFile[tq] != '\'')
|
||||
tq--;
|
||||
if(ch != '>')
|
||||
{
|
||||
std::string is = '\"' + item.second + '\"';
|
||||
sFile.replace(fq, tq - fq, is);
|
||||
found = sFile.find(sName, fq + is.length());
|
||||
}
|
||||
else
|
||||
found = sFile.find(sName, tq);
|
||||
}
|
||||
}
|
||||
|
||||
return sFile;
|
||||
}
|
||||
|
||||
static std::wstring mhtToXhtml(std::string& sFileContent)
|
||||
{
|
||||
sFileContent = mhtTohtml(sFileContent);
|
||||
|
||||
// Gumbo
|
||||
GumboOptions options = kGumboDefaultOptions;
|
||||
GumboOutput* output = gumbo_parse_with_options(&options, sFileContent.data(), sFileContent.length());
|
||||
|
||||
// prettyprint
|
||||
NSStringUtils::CStringBuilderA oBuilder;
|
||||
prettyprint(output->document, oBuilder);
|
||||
|
||||
// Конвертирование из string utf8 в wstring
|
||||
return UTF8_TO_U(oBuilder.GetData());
|
||||
}
|
||||
|
||||
// Заменяет сущности &,<,> в text
|
||||
static void substitute_xml_entities_into_text(std::string& text)
|
||||
{
|
||||
// replacing & must come first
|
||||
replace_all(text, "&", "&");
|
||||
replace_all(text, "<", "<");
|
||||
replace_all(text, ">", ">");
|
||||
}
|
||||
|
||||
// After running through Gumbo, the values of type "" are replaced with the corresponding code '0x01'
|
||||
// Since the attribute value does not use control characters (value <= 0x09),
|
||||
// then just delete them, otherwise XmlUtils::CXmlLiteReader crashes on them.
|
||||
// bug#73486
|
||||
static void remove_control_symbols(std::string& text)
|
||||
{
|
||||
std::string::iterator itFound = std::find_if(text.begin(), text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
|
||||
while (itFound != text.end())
|
||||
{
|
||||
itFound = text.erase(itFound);
|
||||
itFound = std::find_if(itFound, text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
}
|
||||
}
|
||||
|
||||
// Заменяет сущности " в text
|
||||
static void substitute_xml_entities_into_attributes(std::string& text)
|
||||
{
|
||||
remove_control_symbols(text);
|
||||
substitute_xml_entities_into_text(text);
|
||||
replace_all(text, "\"", """);
|
||||
}
|
||||
|
||||
static std::string handle_unknown_tag(GumboStringPiece* text)
|
||||
{
|
||||
if (text->data == NULL)
|
||||
return "";
|
||||
GumboStringPiece gsp = *text;
|
||||
gumbo_tag_from_original_text(&gsp);
|
||||
std::string sAtr = std::string(gsp.data, gsp.length);
|
||||
size_t found = sAtr.find_first_of("-'+,./=?;!*#@$_%<>&;\"\'()[]{}");
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
sAtr.erase(found, 1);
|
||||
found = sAtr.find_first_of("-'+,./=?;!*#@$_%<>&;\"\'()[]{}", found);
|
||||
}
|
||||
return sAtr;
|
||||
}
|
||||
|
||||
static std::string get_tag_name(GumboNode* node)
|
||||
{
|
||||
std::string tagname = (node->type == GUMBO_NODE_DOCUMENT ? "document" : gumbo_normalized_tagname(node->v.element.tag));
|
||||
if (tagname.empty())
|
||||
tagname = handle_unknown_tag(&node->v.element.original_tag);
|
||||
return tagname;
|
||||
}
|
||||
|
||||
static void build_doctype(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder)
|
||||
{
|
||||
if (node->v.document.has_doctype)
|
||||
{
|
||||
oBuilder.WriteString("<!DOCTYPE ");
|
||||
oBuilder.WriteString(node->v.document.name);
|
||||
std::string pi(node->v.document.public_identifier);
|
||||
remove_control_symbols(pi);
|
||||
if ((node->v.document.public_identifier != NULL) && !pi.empty())
|
||||
{
|
||||
oBuilder.WriteString(" PUBLIC \"");
|
||||
oBuilder.WriteString(pi);
|
||||
oBuilder.WriteString("\" \"");
|
||||
oBuilder.WriteString(node->v.document.system_identifier);
|
||||
oBuilder.WriteString("\"");
|
||||
}
|
||||
oBuilder.WriteString(">");
|
||||
}
|
||||
}
|
||||
|
||||
static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringBuilderA& atts)
|
||||
{
|
||||
std::vector<std::string> arrRepeat;
|
||||
for (size_t i = 0; i < attribs->length; ++i)
|
||||
{
|
||||
GumboAttribute* at = static_cast<GumboAttribute*>(attribs->data[i]);
|
||||
std::string sVal(at->value);
|
||||
std::string sName(at->name);
|
||||
|
||||
remove_control_symbols(sVal);
|
||||
remove_control_symbols(sName);
|
||||
|
||||
atts.WriteString(" ");
|
||||
|
||||
bool bCheck = false;
|
||||
size_t nBad = sName.find_first_of("+,.=?#%<>&;\"\'()[]{}");
|
||||
while(nBad != std::string::npos)
|
||||
{
|
||||
sName.erase(nBad, 1);
|
||||
nBad = sName.find_first_of("+,.=?#%<>&;\"\'()[]{}", nBad);
|
||||
if(sName.empty())
|
||||
break;
|
||||
bCheck = true;
|
||||
}
|
||||
if(sName.empty())
|
||||
continue;
|
||||
while(sName.front() >= '0' && sName.front() <= '9')
|
||||
{
|
||||
sName.erase(0, 1);
|
||||
if(sName.empty())
|
||||
break;
|
||||
bCheck = true;
|
||||
}
|
||||
if(bCheck)
|
||||
{
|
||||
GumboAttribute* check = gumbo_get_attribute(attribs, sName.c_str());
|
||||
if(check || std::find(arrRepeat.begin(), arrRepeat.end(), sName) != arrRepeat.end())
|
||||
continue;
|
||||
else
|
||||
arrRepeat.push_back(sName);
|
||||
}
|
||||
|
||||
if(sName.empty())
|
||||
continue;
|
||||
atts.WriteString(sName);
|
||||
|
||||
// determine original quote character used if it exists
|
||||
std::string qs ="\"";
|
||||
atts.WriteString("=");
|
||||
atts.WriteString(qs);
|
||||
substitute_xml_entities_into_attributes(sVal);
|
||||
atts.WriteString(sVal);
|
||||
atts.WriteString(qs);
|
||||
}
|
||||
}
|
||||
|
||||
static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA& contents, bool bCheckValidNode)
|
||||
{
|
||||
std::string key = "|" + get_tag_name(node) + "|";
|
||||
bool keep_whitespace = preserve_whitespace.find(key) != std::string::npos;
|
||||
bool is_inline = nonbreaking_inline.find(key) != std::string::npos;
|
||||
bool is_like_inline = treat_like_inline.find(key) != std::string::npos;
|
||||
|
||||
GumboVector* children = &node->v.element.children;
|
||||
|
||||
for (size_t i = 0; i < children->length; i++)
|
||||
{
|
||||
GumboNode* child = static_cast<GumboNode*> (children->data[i]);
|
||||
|
||||
if (child->type == GUMBO_NODE_TEXT)
|
||||
{
|
||||
std::string val(child->v.text.text);
|
||||
remove_control_symbols(val);
|
||||
substitute_xml_entities_into_text(val);
|
||||
|
||||
// Избавление от FF
|
||||
size_t found = val.find_first_of("\014");
|
||||
while(found != std::string::npos)
|
||||
{
|
||||
val.erase(found, 1);
|
||||
found = val.find_first_of("\014", found);
|
||||
}
|
||||
|
||||
contents.WriteString(val);
|
||||
}
|
||||
else if ((child->type == GUMBO_NODE_ELEMENT) || (child->type == GUMBO_NODE_TEMPLATE))
|
||||
prettyprint(child, contents, bCheckValidNode);
|
||||
else if (child->type == GUMBO_NODE_WHITESPACE)
|
||||
{
|
||||
if (keep_whitespace || is_inline || is_like_inline)
|
||||
contents.WriteString(child->v.text.text);
|
||||
}
|
||||
else if (child->type != GUMBO_NODE_COMMENT)
|
||||
{
|
||||
// Сообщение об ошибке
|
||||
// Does this actually exist: (child->type == GUMBO_NODE_CDATA)
|
||||
// fprintf(stderr, "unknown element of type: %d\n", child->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilder, bool bCheckValidNode)
|
||||
{
|
||||
// special case the document node
|
||||
if (node->type == GUMBO_NODE_DOCUMENT)
|
||||
{
|
||||
build_doctype(node, oBuilder);
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string tagname = get_tag_name(node);
|
||||
remove_control_symbols(tagname);
|
||||
|
||||
if (NodeIsUnprocessed(tagname))
|
||||
return;
|
||||
|
||||
if (bCheckValidNode)
|
||||
bCheckValidNode = !IsUnckeckedNodes(tagname);
|
||||
|
||||
if (bCheckValidNode && html_tags.end() == std::find(html_tags.begin(), html_tags.end(), tagname))
|
||||
{
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string close = "";
|
||||
std::string closeTag = "";
|
||||
std::string key = "|" + tagname + "|";
|
||||
bool is_empty_tag = empty_tags.find(key) != std::string::npos;
|
||||
|
||||
// determine closing tag type
|
||||
if (is_empty_tag)
|
||||
close = "/";
|
||||
else
|
||||
closeTag = "</" + tagname + ">";
|
||||
|
||||
// build results
|
||||
oBuilder.WriteString("<" + tagname);
|
||||
|
||||
// build attr string
|
||||
const GumboVector* attribs = &node->v.element.attributes;
|
||||
build_attributes(attribs, oBuilder);
|
||||
oBuilder.WriteString(close + ">");
|
||||
|
||||
// prettyprint your contents
|
||||
prettyprint_contents(node, oBuilder, bCheckValidNode);
|
||||
oBuilder.WriteString(closeTag);
|
||||
}
|
||||
|
||||
#endif // HTMLTOXHTML_H
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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)){
|
||||
>>>>>>>
|
||||
@ -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);
|
||||
|
||||
@ -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,12 +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".tsv"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_TSV;
|
||||
else if (0 == sExt.compare(L".scsv"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_SCSV;
|
||||
else if (0 == sExt.compare(L".csv") || 0 == sExt.compare(L".tsv") || 0 == sExt.compare(L".dsv") || 0 == sExt.compare(L".cssv")
|
||||
|| 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;
|
||||
@ -1804,10 +1785,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".ods";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV:
|
||||
return L".csv";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_TSV:
|
||||
return L".tsv";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_SCSV:
|
||||
return L".scsv";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT:
|
||||
return L".fods";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS:
|
||||
@ -1997,11 +1974,7 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSB;
|
||||
if (L".xls" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS;
|
||||
if (L".tsv" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_TSV;
|
||||
if (L".scsv" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_SCSV;
|
||||
if (L".csv" == ext || L".dsv" == ext)
|
||||
if (L".csv" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
|
||||
if (L".fods" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT;
|
||||
|
||||
@ -87,14 +87,13 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0005
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTX AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0006
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0007
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSB AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0008
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0009
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000a
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_FLAT AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000b
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_PACKAGE AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000c
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000d
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_TSV AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0014
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_SCSV AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0024
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM 0x0200
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0001
|
||||
@ -137,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
|
||||
|
||||
123
Common/base.pri
123
Common/base.pri
@ -118,13 +118,13 @@ win32:contains(QMAKE_TARGET.arch, arm64): {
|
||||
}
|
||||
|
||||
linux-clang-libc++ {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_64
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-64-clang-libc++")
|
||||
}
|
||||
linux-clang-libc++-32 {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_32
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-32-clang-libc++")
|
||||
@ -180,9 +180,9 @@ mac {
|
||||
!core_ios {
|
||||
CONFIG += core_mac
|
||||
CONFIG += core_mac_64
|
||||
}
|
||||
|
||||
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
|
||||
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
|
||||
}
|
||||
}
|
||||
|
||||
# DEFINES
|
||||
@ -199,13 +199,6 @@ core_win_64 {
|
||||
DEFINES += WIN64 _WIN64
|
||||
}
|
||||
|
||||
defineTest(startsWith) {
|
||||
tmp = $$2
|
||||
tmp ~= s,^$$re_escape($$1),,
|
||||
!equals(tmp, $$2): return(true)
|
||||
return(false)
|
||||
}
|
||||
|
||||
core_linux {
|
||||
DEFINES += LINUX _LINUX
|
||||
|
||||
@ -220,7 +213,7 @@ core_linux {
|
||||
}
|
||||
QMAKE_CUSTOM_SYSROOT_BIN = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , /)
|
||||
|
||||
startsWith($$QMAKE_CUSTOM_SYSROOT, $$QMAKE_CUSTOM_SYSROOT_BIN) {
|
||||
contains(QMAKE_CUSTOM_SYSROOT_BIN, $$QMAKE_CUSTOM_SYSROOT) {
|
||||
message("Using compilers from same sysroot")
|
||||
QMAKE_CC = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "gcc")
|
||||
QMAKE_CXX = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
@ -250,7 +243,7 @@ core_linux {
|
||||
}
|
||||
|
||||
gcc {
|
||||
COMPILER_VERSION = $$system($$QMAKE_CXX " -dumpversion")
|
||||
COMPILER_VERSION = $$system($$QMAKE_CXX " -dumpversion")
|
||||
COMPILER_MAJOR_VERSION_ARRAY = $$split(COMPILER_VERSION, ".")
|
||||
COMPILER_MAJOR_VERSION = $$member(COMPILER_MAJOR_VERSION_ARRAY, 0)
|
||||
lessThan(COMPILER_MAJOR_VERSION, 5): CONFIG += build_gcc_less_5
|
||||
@ -356,7 +349,7 @@ core_win_64 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_64
|
||||
}
|
||||
core_win_arm64 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_arm64
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_arm64
|
||||
}
|
||||
core_linux_32 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = linux_32
|
||||
@ -704,105 +697,3 @@ ADD_INC_PATH = $$(ADDITIONAL_INCLUDE_PATH)
|
||||
!disable_precompiled_header {
|
||||
CONFIG += precompile_header
|
||||
}
|
||||
|
||||
SWIFT_SOURCES=
|
||||
defineTest(UseSwift) {
|
||||
isEmpty(SWIFT_SOURCES): return(false)
|
||||
# work only on ios and mac
|
||||
!core_ios:!core_mac {
|
||||
return(false)
|
||||
}
|
||||
|
||||
# path to the bridging header that exposes Objective-C code to Swift
|
||||
BRIDGING_HEADER = $$1
|
||||
# sdk and toolchain (set from environment variables)
|
||||
SDK_PATH = $$(SDK_PATH)
|
||||
XCODE_TOOLCHAIN_PATH = $$(XCODE_TOOLCHAIN_PATH)
|
||||
|
||||
IOS_TARGET_PLATFORM = apple-ios11.0
|
||||
SWIFT_GEN_HEADERS_PATH = $$PWD_ROOT_DIR/core_build/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX
|
||||
ARCHS = arm64
|
||||
# simulator
|
||||
xcframework_platform_ios_simulator {
|
||||
IOS_TARGET_PLATFORM = $${IOS_TARGET_PLATFORM}-simulator
|
||||
SWIFT_GEN_HEADERS_PATH = $$SWIFT_GEN_HEADERS_PATH/simulator
|
||||
ARCHS += x86_64
|
||||
}
|
||||
|
||||
# add swift compiler for each architecture
|
||||
SWIFT_COMPILERS_OUT =
|
||||
for(ARCH, ARCHS) {
|
||||
COMPILER_NAME = swift_compiler_$${ARCH}
|
||||
COMPILER_OUTPUT = $$SWIFT_GEN_HEADERS_PATH/swift_module_$${ARCH}.o
|
||||
SWIFT_COMPILERS_OUT += $$COMPILER_OUTPUT
|
||||
|
||||
$${COMPILER_NAME}.name = SwiftCompiler_$${ARCH}
|
||||
$${COMPILER_NAME}.input = SWIFT_SOURCES
|
||||
$${COMPILER_NAME}.output = $$COMPILER_OUTPUT
|
||||
SWIFT_CMD = swiftc -c $$SWIFT_SOURCES \
|
||||
-module-name SwiftModule \
|
||||
-whole-module-optimization \
|
||||
-emit-objc-header \
|
||||
-emit-objc-header-path $$SWIFT_GEN_HEADERS_PATH/SwiftModule-Swift.h \
|
||||
-emit-object \
|
||||
-sdk $$SDK_PATH \
|
||||
-target $${ARCH}-$${IOS_TARGET_PLATFORM} \
|
||||
-o $$COMPILER_OUTPUT \
|
||||
-framework UIKit
|
||||
|
||||
!isEmpty(BRIDGING_HEADER) {
|
||||
SWIFT_CMD += -import-objc-header $$BRIDGING_HEADER
|
||||
}
|
||||
|
||||
$${COMPILER_NAME}.commands = $$SWIFT_CMD
|
||||
$${COMPILER_NAME}.CONFIG = combine target_predeps no_link
|
||||
|
||||
export($${COMPILER_NAME}.name)
|
||||
export($${COMPILER_NAME}.input)
|
||||
export($${COMPILER_NAME}.output)
|
||||
export($${COMPILER_NAME}.commands)
|
||||
export($${COMPILER_NAME}.CONFIG)
|
||||
QMAKE_EXTRA_COMPILERS += $${COMPILER_NAME}
|
||||
}
|
||||
|
||||
# add lipo tool execution to form universal binary
|
||||
LIPO_OUT = $$SWIFT_GEN_HEADERS_PATH/swift_module.o
|
||||
lipo_tool.name = LipoTool
|
||||
# as input for lipo_tool we set SWIFT_SOURCES (not SWIFT_COMPILERS_OUT as it won't be executed otherwise!)
|
||||
lipo_tool.input = SWIFT_SOURCES
|
||||
# compiled swift sources go into depends
|
||||
lipo_tool.depends = $$SWIFT_COMPILERS_OUT
|
||||
lipo_tool.output = $$LIPO_OUT
|
||||
lipo_tool.commands = lipo -create $$SWIFT_COMPILERS_OUT -output $$LIPO_OUT
|
||||
lipo_tool.CONFIG = combine target_predeps no_link
|
||||
lipo_tool.variable_out = OBJECTS
|
||||
|
||||
export(lipo_tool.name)
|
||||
export(lipo_tool.input)
|
||||
export(lipo_tool.depends)
|
||||
export(lipo_tool.output)
|
||||
export(lipo_tool.commands)
|
||||
export(lipo_tool.CONFIG)
|
||||
export(lipo_tool.variable_out)
|
||||
QMAKE_EXTRA_COMPILERS += lipo_tool
|
||||
|
||||
export(QMAKE_EXTRA_COMPILERS)
|
||||
|
||||
INCLUDEPATH += $$SWIFT_GEN_HEADERS_PATH
|
||||
export(INCLUDEPATH)
|
||||
|
||||
# link with libs from toolchain
|
||||
SWIFT_LIB_PATH = $$XCODE_TOOLCHAIN_PATH/usr/lib/swift/iphoneos
|
||||
xcframework_platform_ios_simulator {
|
||||
SWIFT_LIB_PATH = $$XCODE_TOOLCHAIN_PATH/usr/lib/swift/iphonesimulator
|
||||
}
|
||||
LIBS += -L$$SWIFT_LIB_PATH
|
||||
LIBS += -lswiftCore -lswiftFoundation -lswiftObjectiveC
|
||||
|
||||
export(LIBS)
|
||||
|
||||
OTHER_FILES += $$SWIFT_SOURCES
|
||||
export(OTHER_FILES)
|
||||
return(true)
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -26,7 +26,7 @@ def _loadLibrary(path):
|
||||
library_name = 'libdocbuilder.c.dylib'
|
||||
# if there is no dylib file, get library from framework
|
||||
if not os.path.exists(path + '/' + library_name):
|
||||
path = path + '/docbuilder.c.framework/Versions/A'
|
||||
path = path + '/docbuilder.c.framework'
|
||||
library_name = 'docbuilder.c'
|
||||
|
||||
_lib = ctypes.CDLL(path + '/' + library_name)
|
||||
|
||||
@ -120,7 +120,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
bool OpenFile(const std::wstring& sFile, const wchar_t* sPassword)
|
||||
bool OpenFile(const std::wstring& sFile, const std::wstring& sPassword)
|
||||
{
|
||||
CloseFile();
|
||||
|
||||
@ -171,7 +171,7 @@ public:
|
||||
|
||||
return m_pFile ? true : false;
|
||||
}
|
||||
bool OpenFile(BYTE* data, LONG size, const wchar_t* sPassword)
|
||||
bool OpenFile(BYTE* data, LONG size, const std::wstring& sPassword)
|
||||
{
|
||||
CloseFile();
|
||||
|
||||
@ -245,18 +245,7 @@ public:
|
||||
|
||||
return 0;
|
||||
}
|
||||
bool CheckOwnerPassword(const wchar_t* 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;
|
||||
@ -454,20 +443,6 @@ public:
|
||||
if (m_nType == 0)
|
||||
((CPdfFile*)m_pFile)->SetCMapMemory(data, size);
|
||||
}
|
||||
void SetScanPageFonts(int nPageIndex)
|
||||
{
|
||||
if (NULL == m_pImageStorage)
|
||||
m_pImageStorage = NSDocxRenderer::CreateWasmImageStorage();
|
||||
|
||||
CDocxRenderer oRenderer(m_pApplicationFonts);
|
||||
oRenderer.SetExternalImageStorage(m_pImageStorage);
|
||||
oRenderer.SetTextAssociationType(NSDocxRenderer::TextAssociationType::tatParagraphToShape);
|
||||
|
||||
oRenderer.ScanPageBin(m_pFile, nPageIndex);
|
||||
|
||||
if (m_nType == 0)
|
||||
((CPdfFile*)m_pFile)->SetPageFonts(nPageIndex);
|
||||
}
|
||||
BYTE* ScanPage(int nPageIndex, int mode)
|
||||
{
|
||||
if (NULL == m_pImageStorage)
|
||||
@ -504,9 +479,6 @@ public:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (m_nType == 0)
|
||||
((CPdfFile*)m_pFile)->SetPageFonts(nPageIndex);
|
||||
|
||||
BYTE* res = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
return res;
|
||||
@ -595,19 +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);
|
||||
}
|
||||
BYTE* GetGIDByUnicode(const std::wstring& wsPathA)
|
||||
{
|
||||
if (m_nType != 0)
|
||||
return NULL;
|
||||
return ((CPdfFile*)m_pFile)->GetGIDByUnicode(wsPathA);
|
||||
}
|
||||
|
||||
std::wstring GetFontBinaryNative(const std::wstring& sName)
|
||||
{
|
||||
|
||||
@ -26,8 +26,7 @@ CDrawingFileEmbed::~CDrawingFileEmbed()
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::OpenFile(JSSmart<CJSValue> sFile, JSSmart<CJSValue> sPassword)
|
||||
{
|
||||
std::wstring wsPassword = sPassword->isString() ? sPassword->toStringW() : L"";
|
||||
bool bResult = m_pFile->OpenFile(sFile->toStringW(), sPassword->isString() ? wsPassword.c_str() : NULL);
|
||||
bool bResult = m_pFile->OpenFile(sFile->toStringW(), sPassword->isString() ? sPassword->toStringW() : L"");
|
||||
return CJSContext::createBool(bResult);
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::CloseFile()
|
||||
@ -137,10 +136,6 @@ JSSmart<CJSValue> CDrawingFileEmbed::DestroyTextInfo()
|
||||
m_pFile->DestroyTextInfo();
|
||||
return CJSContext::createUndefined();
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetGIDByUnicode(JSSmart<CJSValue> sId)
|
||||
{
|
||||
return WasmMemoryToJS(m_pFile->GetGIDByUnicode(sId->toStringW()));
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::IsNeedCMap()
|
||||
{
|
||||
return CJSContext::createBool(false);
|
||||
@ -149,11 +144,6 @@ JSSmart<CJSValue> CDrawingFileEmbed::ScanPage(JSSmart<CJSValue> nPageIndex, JSSm
|
||||
{
|
||||
return WasmMemoryToJS(m_pFile->ScanPage(nPageIndex->toInt32(), mode->toInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::SetScanPageFonts(JSSmart<CJSValue> nPageIndex)
|
||||
{
|
||||
m_pFile->SetScanPageFonts(nPageIndex->toInt32());
|
||||
return CJSContext::createUndefined();
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetImageBase64(JSSmart<CJSValue> rId)
|
||||
{
|
||||
@ -252,17 +242,6 @@ JSSmart<CJSValue> CDrawingFileEmbed::UndoRedact()
|
||||
return CJSContext::createBool(false);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::CheckOwnerPassword(JSSmart<CJSValue> sPassword)
|
||||
{
|
||||
std::wstring wsPassword = sPassword->isString() ? sPassword->toStringW() : L"";
|
||||
bool bResult = m_pFile->CheckOwnerPassword(sPassword->isString() ? wsPassword.c_str() : NULL);
|
||||
return CJSContext::createBool(bResult);
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::CheckPerm(JSSmart<CJSValue> nPerm)
|
||||
{
|
||||
return CJSContext::createBool(m_pFile->CheckPerm(nPerm->toInt32()));
|
||||
}
|
||||
|
||||
bool EmbedDrawingFile(JSSmart<NSJSBase::CJSContext>& context, IOfficeDrawingFile* pFile)
|
||||
{
|
||||
CJSContext::Embed<CDrawingFileEmbed>(false);
|
||||
|
||||
@ -43,11 +43,9 @@ public:
|
||||
JSSmart<CJSValue> GetFontBinary(JSSmart<CJSValue> Id);
|
||||
JSSmart<CJSValue> GetGlyphs(JSSmart<CJSValue> nPageIndex);
|
||||
JSSmart<CJSValue> DestroyTextInfo();
|
||||
JSSmart<CJSValue> GetGIDByUnicode(JSSmart<CJSValue> sId);
|
||||
|
||||
JSSmart<CJSValue> IsNeedCMap();
|
||||
JSSmart<CJSValue> ScanPage(JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> mode);
|
||||
JSSmart<CJSValue> SetScanPageFonts(JSSmart<CJSValue> nPageIndex);
|
||||
|
||||
JSSmart<CJSValue> GetImageBase64(JSSmart<CJSValue> rId);
|
||||
|
||||
@ -59,9 +57,6 @@ public:
|
||||
JSSmart<CJSValue> RedactPage(JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> arrRedactBox, JSSmart<CJSValue> dataFiller);
|
||||
JSSmart<CJSValue> UndoRedact();
|
||||
|
||||
JSSmart<CJSValue> CheckOwnerPassword(JSSmart<CJSValue> sPassword);
|
||||
JSSmart<CJSValue> CheckPerm(JSSmart<CJSValue> nPerm);
|
||||
|
||||
DECLARE_EMBED_METHODS
|
||||
};
|
||||
|
||||
|
||||
@ -23,10 +23,8 @@
|
||||
-(JSValue*) GetFontBinary : (JSValue*)Id;
|
||||
-(JSValue*) GetGlyphs : (JSValue*)nPageIndex;
|
||||
-(JSValue*) DestroyTextInfo;
|
||||
-(JSValue*) GetGIDByUnicode : (JSValue*)sId;
|
||||
-(JSValue*) IsNeedCMap;
|
||||
-(JSValue*) ScanPage : (JSValue*)nPageIndex : (JSValue*)mode;
|
||||
-(JSValue*) SetScanPageFonts : (JSValue*)nPageIndex;
|
||||
-(JSValue*) GetImageBase64 : (JSValue*)rId;
|
||||
-(JSValue*) FreeWasmData : (JSValue*)typedArray;
|
||||
-(JSValue*) SplitPages : (JSValue*)arrPageIndexes : (JSValue*)data;
|
||||
@ -34,8 +32,6 @@
|
||||
-(JSValue*) UnmergePages;
|
||||
-(JSValue*) RedactPage : (JSValue*)nPageIndex : (JSValue*)arrRedactBox : (JSValue*)dataFiller;
|
||||
-(JSValue*) UndoRedact;
|
||||
-(JSValue*) CheckOwnerPassword : (JSValue*)sPassword;
|
||||
-(JSValue*) CheckPerm : (JSValue*)nPerm;
|
||||
@end
|
||||
|
||||
@interface CJSCDrawingFileEmbed : NSObject<IJSCDrawingFileEmbed, JSEmbedObjectProtocol>
|
||||
@ -66,10 +62,8 @@ FUNCTION_WRAPPER_JS_6(GetAnnotationsAP, GetAnnotationsAP)
|
||||
FUNCTION_WRAPPER_JS_1(GetFontBinary, GetFontBinary)
|
||||
FUNCTION_WRAPPER_JS_1(GetGlyphs, GetGlyphs)
|
||||
FUNCTION_WRAPPER_JS_0(DestroyTextInfo, DestroyTextInfo)
|
||||
FUNCTION_WRAPPER_JS_1(GetGIDByUnicode, GetGIDByUnicode)
|
||||
FUNCTION_WRAPPER_JS_0(IsNeedCMap, IsNeedCMap)
|
||||
FUNCTION_WRAPPER_JS_2(ScanPage, ScanPage)
|
||||
FUNCTION_WRAPPER_JS_1(SetScanPageFonts, SetScanPageFonts)
|
||||
FUNCTION_WRAPPER_JS_1(GetImageBase64, GetImageBase64)
|
||||
FUNCTION_WRAPPER_JS_1(FreeWasmData, FreeWasmData)
|
||||
FUNCTION_WRAPPER_JS_2(SplitPages, SplitPages)
|
||||
@ -77,8 +71,6 @@ FUNCTION_WRAPPER_JS_3(MergePages, MergePages)
|
||||
FUNCTION_WRAPPER_JS_0(UnmergePages, UnmergePages)
|
||||
FUNCTION_WRAPPER_JS_3(RedactPage, RedactPage)
|
||||
FUNCTION_WRAPPER_JS_0(UndoRedact, UndoRedact)
|
||||
FUNCTION_WRAPPER_JS_1(CheckOwnerPassword, CheckOwnerPassword)
|
||||
FUNCTION_WRAPPER_JS_1(CheckPerm, CheckPerm)
|
||||
@end
|
||||
|
||||
class CDrawingFileEmbedAdapter : public CJSEmbedObjectAdapterJSC
|
||||
|
||||
@ -26,10 +26,8 @@ namespace NSDrawingFileEmbed
|
||||
FUNCTION_WRAPPER_V8_1(_GetFontBinary, GetFontBinary)
|
||||
FUNCTION_WRAPPER_V8_1(_GetGlyphs, GetGlyphs)
|
||||
FUNCTION_WRAPPER_V8_0(_DestroyTextInfo, DestroyTextInfo)
|
||||
FUNCTION_WRAPPER_V8_1(_GetGIDByUnicode, GetGIDByUnicode)
|
||||
FUNCTION_WRAPPER_V8_0(_IsNeedCMap, IsNeedCMap)
|
||||
FUNCTION_WRAPPER_V8_2(_ScanPage, ScanPage)
|
||||
FUNCTION_WRAPPER_V8_1(_SetScanPageFonts, SetScanPageFonts)
|
||||
FUNCTION_WRAPPER_V8_1(_GetImageBase64, GetImageBase64)
|
||||
FUNCTION_WRAPPER_V8_1(_FreeWasmData, FreeWasmData)
|
||||
FUNCTION_WRAPPER_V8_2(_SplitPages, SplitPages)
|
||||
@ -37,8 +35,6 @@ namespace NSDrawingFileEmbed
|
||||
FUNCTION_WRAPPER_V8_0(_UnmergePages, UnmergePages)
|
||||
FUNCTION_WRAPPER_V8_3(_RedactPage, RedactPage)
|
||||
FUNCTION_WRAPPER_V8_0(_UndoRedact, UndoRedact)
|
||||
FUNCTION_WRAPPER_V8_1(_CheckOwnerPassword, CheckOwnerPassword)
|
||||
FUNCTION_WRAPPER_V8_1(_CheckPerm, CheckPerm)
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
@ -64,10 +60,8 @@ namespace NSDrawingFileEmbed
|
||||
NSV8Objects::Template_Set(result, "GetFontBinary", _GetFontBinary);
|
||||
NSV8Objects::Template_Set(result, "GetGlyphs", _GetGlyphs);
|
||||
NSV8Objects::Template_Set(result, "DestroyTextInfo", _DestroyTextInfo);
|
||||
NSV8Objects::Template_Set(result, "GetGIDByUnicode", _GetGIDByUnicode);
|
||||
NSV8Objects::Template_Set(result, "IsNeedCMap", _IsNeedCMap);
|
||||
NSV8Objects::Template_Set(result, "ScanPage", _ScanPage);
|
||||
NSV8Objects::Template_Set(result, "SetScanPageFonts", _SetScanPageFonts);
|
||||
NSV8Objects::Template_Set(result, "GetImageBase64", _GetImageBase64);
|
||||
NSV8Objects::Template_Set(result, "FreeWasmData", _FreeWasmData);
|
||||
NSV8Objects::Template_Set(result, "SplitPages", _SplitPages);
|
||||
@ -75,8 +69,6 @@ namespace NSDrawingFileEmbed
|
||||
NSV8Objects::Template_Set(result, "UnmergePages", _UnmergePages);
|
||||
NSV8Objects::Template_Set(result, "RedactPage", _RedactPage);
|
||||
NSV8Objects::Template_Set(result, "UndoRedact", _UndoRedact);
|
||||
NSV8Objects::Template_Set(result, "CheckOwnerPassword", _CheckOwnerPassword);
|
||||
NSV8Objects::Template_Set(result, "CheckPerm", _CheckPerm);
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
|
||||
@ -461,8 +461,6 @@ namespace NSJSBase
|
||||
v8::SnapshotCreator snapshotCreator;
|
||||
v8::Isolate* isolate = snapshotCreator.GetIsolate();
|
||||
{
|
||||
CV8TryCatch try_catch(isolate);
|
||||
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
// Create a new context
|
||||
v8::Local<v8::Context> context = v8::Context::New(isolate);
|
||||
@ -474,12 +472,11 @@ namespace NSJSBase
|
||||
global->Set(context, v8::String::NewFromUtf8Literal(isolate, "self"), global).Check();
|
||||
global->Set(context, v8::String::NewFromUtf8Literal(isolate, "native"), v8::Undefined(isolate)).Check();
|
||||
|
||||
// Compile
|
||||
// Compile and run
|
||||
v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, script.c_str()).ToLocalChecked();
|
||||
v8::Local<v8::Script> script = v8::Script::Compile(context, source).ToLocalChecked();
|
||||
// Run
|
||||
script->Run(context).IsEmpty();
|
||||
|
||||
script->Run(context).IsEmpty();
|
||||
snapshotCreator.SetDefaultContext(context);
|
||||
}
|
||||
v8::StartupData data = snapshotCreator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kKeep);
|
||||
|
||||
@ -62,13 +62,7 @@ v8::Local<v8::String> CreateV8String(v8::Isolate* i, const std::string& str);
|
||||
#include <android/log.h>
|
||||
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, "js", __VA_ARGS__)
|
||||
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "js", __VA_ARGS__)
|
||||
#ifdef _DEBUG
|
||||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "js", __VA_ARGS__)
|
||||
#else
|
||||
// should be disabled for release builds
|
||||
#define LOGD(...)
|
||||
#endif // _DEBUG
|
||||
#endif // ANDROID_LOGS
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -805,9 +799,6 @@ namespace NSJSBase
|
||||
CV8TryCatch() : CJSTryCatch(), try_catch(V8IsolateOneArg)
|
||||
{
|
||||
}
|
||||
CV8TryCatch(v8::Isolate* isolate) : CJSTryCatch(), try_catch(isolate)
|
||||
{
|
||||
}
|
||||
virtual ~CV8TryCatch()
|
||||
{
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -85,13 +85,6 @@ bool Segment::IsEmpty() const noexcept
|
||||
return Id == 0 && Index == -1 && P.IsZero() && HI.IsZero() && HO.IsZero();
|
||||
}
|
||||
|
||||
bool Segment::Equals(const Segment& other) const noexcept
|
||||
{
|
||||
return isZero(P.X - other.P.X) && isZero(P.Y - other.P.Y) &&
|
||||
isZero(HI.X - other.HI.X) && isZero(HI.Y - other.HI.Y) &&
|
||||
isZero(HO.X - other.HO.X) && isZero(HO.Y - other.HO.Y);
|
||||
}
|
||||
|
||||
bool Segment::operator==(const Segment& other) const noexcept
|
||||
{
|
||||
return (Index == other.Index) && (Id == other.Id);
|
||||
@ -697,12 +690,6 @@ bool Curve::IsStraight() const noexcept
|
||||
return !Segment2.IsCurve;
|
||||
}
|
||||
|
||||
bool Curve::Equals(const Curve& other) const noexcept
|
||||
{
|
||||
return Segment1.Equals(other.Segment1) &&
|
||||
Segment2.Equals(other.Segment2);
|
||||
}
|
||||
|
||||
bool Curve::operator==(const Curve& other) const noexcept
|
||||
{
|
||||
return Segment1 == other.Segment1 &&
|
||||
@ -750,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)
|
||||
@ -799,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);
|
||||
@ -812,7 +798,7 @@ void CBooleanOperations::TraceBoolean()
|
||||
|
||||
GetIntersection();
|
||||
|
||||
if (IsSelf)
|
||||
if (self)
|
||||
{
|
||||
if (Op == Subtraction)
|
||||
return;
|
||||
@ -837,13 +823,8 @@ void CBooleanOperations::TraceBoolean()
|
||||
CreateNewPath(adj_matr);
|
||||
return;
|
||||
}
|
||||
else if (Path1 == Path2)
|
||||
{
|
||||
Result = std::move(Path1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Locations.empty() && !IsOnlyEnds())
|
||||
if (!Locations.empty())
|
||||
{
|
||||
int length = static_cast<int>(Locations.size());
|
||||
for (int i = 0; i < length; i++)
|
||||
@ -1858,7 +1839,7 @@ void CBooleanOperations::GetCurveIntersection(const Curve& curve1, const Curve&
|
||||
AddCurveIntersection(flip ? curve2 : curve1, flip ? curve1 : curve2,
|
||||
flip ? curve2 : curve1, flip ? curve1 : curve2, flip);
|
||||
|
||||
if (Locations.size() == before && (!straight /*|| Locations.empty()*/))
|
||||
if (Locations.size() == before && (!straight || Locations.empty()))
|
||||
{
|
||||
double t = curve2.GetTimeOf(curve1.Segment1.P);
|
||||
if (t != -1.0)
|
||||
@ -2071,27 +2052,17 @@ bool CBooleanOperations::IsInside(const Segment& segment) const
|
||||
|
||||
void CBooleanOperations::SetWinding()
|
||||
{
|
||||
if (Locations.empty() || (Locations.size() == 2 && Locations[0]->Ends) || IsOnlyEnds())
|
||||
if (Locations.empty() || (Locations.size() == 2 && Locations[0]->Ends))
|
||||
{
|
||||
Segment s1 = Segments1[0], s2 = Segments2[0];
|
||||
Segment s1, s2;
|
||||
|
||||
for (const auto& s : Segments1)
|
||||
{
|
||||
bool skip = false;
|
||||
for (const auto& ss : Segments2)
|
||||
skip = skip || !s.Equals(ss);
|
||||
if (!s.Inters && !skip)
|
||||
if (!s.Inters)
|
||||
s1 = s;
|
||||
}
|
||||
|
||||
for (const auto& s : Segments2)
|
||||
{
|
||||
bool skip = false;
|
||||
for (const auto& ss : Segments1)
|
||||
skip = skip || !s.Equals(ss);
|
||||
if (!s.Inters && !skip)
|
||||
if (!s.Inters)
|
||||
s2 = s;
|
||||
}
|
||||
|
||||
bool winding = IsInside(s1);
|
||||
|
||||
@ -2308,8 +2279,8 @@ bool CBooleanOperations::IsOneCurvePath(int pathIndex) const noexcept
|
||||
void CBooleanOperations::AddLocation(Curve curve1, Curve curve2, double t1,
|
||||
double t2, bool overlap, bool filter, bool ends)
|
||||
{
|
||||
bool excludeStart = !overlap && GetPreviousCurve(curve1).Equals(curve2),
|
||||
excludeEnd = !overlap && curve1 != curve2 && GetNextCurve(curve1).Equals(curve2);
|
||||
bool excludeStart = !overlap && GetPreviousCurve(curve1) == curve2,
|
||||
excludeEnd = !overlap && curve1 != curve2 && GetNextCurve(curve1) == curve2;
|
||||
double tMin = CURVETIME_EPSILON,
|
||||
tMax = 1 - tMin;
|
||||
|
||||
@ -2368,18 +2339,6 @@ bool CBooleanOperations::CheckLocation(std::shared_ptr<Location> loc, bool start
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CBooleanOperations::IsOnlyEnds() const noexcept
|
||||
{
|
||||
bool onlyEnds1 = true;
|
||||
bool onlyEnds2 = true;
|
||||
for (const auto& l : Locations)
|
||||
{
|
||||
onlyEnds1 = onlyEnds1 && l->Ends;
|
||||
onlyEnds2 = onlyEnds2 && l->Inters->Ends;
|
||||
}
|
||||
return onlyEnds1 || onlyEnds2;
|
||||
}
|
||||
|
||||
CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
const CGraphicsPath& path2,
|
||||
BooleanOpType op,
|
||||
@ -2396,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();
|
||||
@ -2411,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();
|
||||
@ -2421,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());
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,6 @@ namespace Aggplus
|
||||
|
||||
bool IsValid(const BooleanOpType& op) const noexcept;
|
||||
bool IsEmpty() const noexcept;
|
||||
bool Equals(const Segment& other) const noexcept;
|
||||
bool operator==(const Segment& other) const noexcept;
|
||||
bool operator!=(const Segment& other) const noexcept;
|
||||
};
|
||||
@ -83,7 +82,6 @@ namespace Aggplus
|
||||
void Flip() noexcept;
|
||||
|
||||
bool IsStraight() const noexcept;
|
||||
bool Equals(const Curve& other) const noexcept;
|
||||
bool operator==(const Curve& other) const noexcept;
|
||||
bool operator!=(const Curve& other) const noexcept;
|
||||
};
|
||||
@ -110,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);
|
||||
@ -161,7 +159,6 @@ namespace Aggplus
|
||||
bool IsOneCurvePath(int pathIndex) const noexcept;
|
||||
void AddOffsets(std::vector<double>& offsets, const Curve& curve, bool end);
|
||||
bool CheckLocation(std::shared_ptr<Location> loc, bool start) const noexcept;
|
||||
bool IsOnlyEnds() const noexcept;
|
||||
|
||||
private:
|
||||
BooleanOpType Op = Intersection;
|
||||
@ -169,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;
|
||||
|
||||
@ -419,7 +419,6 @@ namespace Aggplus
|
||||
m_bReleaseImage = FALSE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_bIsScale = false;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(const std::wstring& strName, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
|
||||
@ -428,7 +427,6 @@ namespace Aggplus
|
||||
m_bReleaseImage = TRUE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_bIsScale = false;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(CImage *pImage, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
|
||||
@ -437,7 +435,6 @@ namespace Aggplus
|
||||
m_bReleaseImage = FALSE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_bIsScale = false;
|
||||
}
|
||||
|
||||
CBrushTexture::~CBrushTexture()
|
||||
|
||||
@ -205,10 +205,6 @@ public:
|
||||
bool m_bUseBounds;
|
||||
CDoubleRect m_oBounds;
|
||||
|
||||
bool m_bIsScale;
|
||||
double m_dScaleX;
|
||||
double m_dScaleY;
|
||||
|
||||
BYTE Alpha;
|
||||
};
|
||||
}
|
||||
|
||||
@ -847,8 +847,6 @@ namespace Aggplus
|
||||
double dScaleY = m_dDpiY / m_dDpiTile;
|
||||
|
||||
brushMatrix.Scale(dScaleX, dScaleY, Aggplus::MatrixOrderAppend);
|
||||
if (ptxBrush->m_bIsScale)
|
||||
brushMatrix.Scale(ptxBrush->m_dScaleX, ptxBrush->m_dScaleY, Aggplus::MatrixOrderAppend);
|
||||
}
|
||||
|
||||
brushMatrix.Translate(x, y, Aggplus::MatrixOrderAppend);
|
||||
@ -2144,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));
|
||||
@ -2247,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)
|
||||
{
|
||||
|
||||
@ -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;
|
||||
@ -1007,18 +1007,16 @@ namespace Aggplus
|
||||
bool CGraphicsPath::operator==(const CGraphicsPath& other) noexcept
|
||||
{
|
||||
unsigned pointsCount = GetPointCount(),
|
||||
otherPointsCount = other.GetPointCount();
|
||||
otherPointsCount = other.GetPointCount();
|
||||
|
||||
if (pointsCount != otherPointsCount)
|
||||
return false;
|
||||
|
||||
std::vector<PointD> points = GetPoints(0, pointsCount),
|
||||
otherPoints = other.GetPoints(0, otherPointsCount);
|
||||
|
||||
bool reverse = IsClockwise() ^ other.IsClockwise();
|
||||
otherPoints = other.GetPoints(0, otherPointsCount);
|
||||
|
||||
for (unsigned i = 0; i < pointsCount; i++)
|
||||
if (!points[i].Equals(otherPoints[reverse ? pointsCount - i - 1 : i]))
|
||||
if (!points[i].Equals(otherPoints[i]))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -1551,31 +1549,3 @@ namespace Aggplus
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT IRenderer::AddPath(const Aggplus::CGraphicsPath& path)
|
||||
{
|
||||
if (path.GetPointCount() == 0)
|
||||
return S_FALSE;
|
||||
|
||||
size_t length = path.GetPointCount() + path.GetCloseCount();
|
||||
std::vector<Aggplus::PointD> points = path.GetPoints(0, length);
|
||||
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
if (path.IsCurvePoint(i))
|
||||
{
|
||||
PathCommandCurveTo(points[i].X, points[i].Y,
|
||||
points[i + 1].X, points[i + 1].Y,
|
||||
points[i + 2].X, points[i + 2].Y);
|
||||
i += 2;
|
||||
}
|
||||
else if (path.IsMovePoint(i))
|
||||
PathCommandMoveTo(points[i].X, points[i].Y);
|
||||
else if (path.IsLinePoint(i))
|
||||
PathCommandLineTo(points[i].X, points[i].Y);
|
||||
else
|
||||
PathCommandClose();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -613,32 +613,6 @@ HRESULT CGraphicsRenderer::put_BrushTransform(const Aggplus::CMatrix& oMatrix)
|
||||
m_oBrush.Transform = oMatrix;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::get_BrushOffset(double& offsetX, double& offsetY) const
|
||||
{
|
||||
offsetX = m_oBrush.OffsetX;
|
||||
offsetY = m_oBrush.OffsetY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::put_BrushOffset(const double& offsetX, const double& offsetY)
|
||||
{
|
||||
m_oBrush.OffsetX = offsetX;
|
||||
m_oBrush.OffsetY = offsetY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const
|
||||
{
|
||||
isScale = m_oBrush.IsScale;
|
||||
scaleX = m_oBrush.ScaleX;
|
||||
scaleY = m_oBrush.ScaleY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::put_BrushScale(bool isScale, const double& scaleX, const double& scaleY)
|
||||
{
|
||||
m_oBrush.IsScale = isScale;
|
||||
m_oBrush.ScaleX = scaleX;
|
||||
m_oBrush.ScaleY = scaleY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height)
|
||||
{
|
||||
m_oBrush.Rectable = val;
|
||||
@ -972,17 +946,10 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
switch (m_oBrush.TextureMode)
|
||||
{
|
||||
case c_BrushTextureModeTile:
|
||||
case c_BrushTextureModeTileCenter:
|
||||
oMode = Aggplus::WrapModeTile;
|
||||
break;
|
||||
case c_BrushTextureModeTileFlipX:
|
||||
oMode = Aggplus::WrapModeTileFlipX;
|
||||
break;
|
||||
case c_BrushTextureModeTileFlipY:
|
||||
oMode = Aggplus::WrapModeTileFlipY;
|
||||
break;
|
||||
case c_BrushTextureModeTileFlipXY:
|
||||
oMode = Aggplus::WrapModeTileFlipXY;
|
||||
case c_BrushTextureModeTileCenter:
|
||||
oMode = Aggplus::WrapModeTile;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -1056,18 +1023,11 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
if (m_oBrush.Rectable == 1)
|
||||
{
|
||||
pTextureBrush->m_bUseBounds = true;
|
||||
pTextureBrush->m_oBounds.left = m_oBrush.Rect.X + m_oBrush.OffsetX;
|
||||
pTextureBrush->m_oBounds.top = m_oBrush.Rect.Y + m_oBrush.OffsetY;
|
||||
pTextureBrush->m_oBounds.left = m_oBrush.Rect.X;
|
||||
pTextureBrush->m_oBounds.top = m_oBrush.Rect.Y;
|
||||
pTextureBrush->m_oBounds.right = pTextureBrush->m_oBounds.left + m_oBrush.Rect.Width;
|
||||
pTextureBrush->m_oBounds.bottom = pTextureBrush->m_oBounds.top + m_oBrush.Rect.Height;
|
||||
}
|
||||
|
||||
if (m_oBrush.IsScale == 1)
|
||||
{
|
||||
pTextureBrush->m_bIsScale = true;
|
||||
pTextureBrush->m_dScaleX = m_oBrush.ScaleX;
|
||||
pTextureBrush->m_dScaleY = m_oBrush.ScaleY;
|
||||
}
|
||||
}
|
||||
|
||||
pBrush = pTextureBrush;
|
||||
|
||||
@ -189,10 +189,6 @@ public:
|
||||
virtual HRESULT put_BrushLinearAngle(const double& dAngle);
|
||||
virtual HRESULT get_BrushTransform(Aggplus::CMatrix& oMatrix);
|
||||
virtual HRESULT put_BrushTransform(const Aggplus::CMatrix& oMatrix);
|
||||
virtual HRESULT get_BrushOffset(double& offsetX, double& offsetY) const;
|
||||
virtual HRESULT put_BrushOffset(const double& offsetX, const double& offsetY);
|
||||
virtual HRESULT get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const;
|
||||
virtual HRESULT put_BrushScale(bool isScale, const double& scaleX, const double& scaleY);
|
||||
virtual HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height);
|
||||
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height);
|
||||
virtual HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount);
|
||||
|
||||
@ -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;
|
||||
@ -169,10 +168,7 @@ public:
|
||||
AdvancedCommandType GetCommandType() { return m_nCommandType; }
|
||||
};
|
||||
|
||||
namespace Aggplus {
|
||||
class CImage;
|
||||
class CGraphicsPath;
|
||||
}
|
||||
namespace Aggplus { class CImage; }
|
||||
|
||||
// IRenderer
|
||||
class IRenderer : public IGrObject
|
||||
@ -244,32 +240,6 @@ public:
|
||||
virtual HRESULT put_BrushTransform(const Aggplus::CMatrix& oMatrix) = 0;
|
||||
virtual HRESULT get_BrushLinearAngle(double* dAngle) = 0;
|
||||
virtual HRESULT put_BrushLinearAngle(const double& dAngle) = 0;
|
||||
virtual HRESULT get_BrushOffset(double& offsetX, double& offsetY) const
|
||||
{
|
||||
UNUSED_VARIABLE(offsetX);
|
||||
UNUSED_VARIABLE(offsetY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT put_BrushOffset(const double& offsetX, const double& offsetY)
|
||||
{
|
||||
UNUSED_VARIABLE(offsetX);
|
||||
UNUSED_VARIABLE(offsetY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const
|
||||
{
|
||||
UNUSED_VARIABLE(isScale);
|
||||
UNUSED_VARIABLE(scaleX);
|
||||
UNUSED_VARIABLE(scaleY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT put_BrushScale(bool isScale, const double& scaleX, const double& scaleY)
|
||||
{
|
||||
UNUSED_VARIABLE(isScale);
|
||||
UNUSED_VARIABLE(scaleX);
|
||||
UNUSED_VARIABLE(scaleY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height) = 0;
|
||||
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height) = 0;
|
||||
|
||||
@ -329,8 +299,6 @@ public:
|
||||
virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT PathCommandTextEx(const std::wstring& sText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
|
||||
HRESULT AddPath(const Aggplus::CGraphicsPath& path);
|
||||
|
||||
//-------- Функции для вывода изображений ---------------------------------------------------
|
||||
virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha = 255) = 0;
|
||||
|
||||
@ -36,7 +36,6 @@
|
||||
#include "../fontengine/FontManager.h"
|
||||
#include "../raster/BgraFrame.h"
|
||||
#include "../common/StringExt.h"
|
||||
#include "GraphicsPath.h"
|
||||
|
||||
// этот класс нужно переписать. должно работать как и в js
|
||||
// а не просто на каждом символе переключаться, если нужно
|
||||
@ -352,13 +351,7 @@ namespace NSOnlineOfficeBinToPdf
|
||||
bool bIsPathOpened = false;
|
||||
bool bIsEnableBrushRect = false;
|
||||
|
||||
double old_t1, old_t2, old_t3, old_t4, old_t5, old_t6;
|
||||
|
||||
CBufferReader oReader(pBuffer, lBufferLen);
|
||||
Aggplus::CGraphicsPath path;
|
||||
Aggplus::CMatrix transMatrRot;
|
||||
Aggplus::RectF_T<double> clipRect;
|
||||
bool isResetRot = false;
|
||||
while (oReader.Check())
|
||||
{
|
||||
eCommand = (CommandType)(oReader.ReadByte());
|
||||
@ -389,8 +382,6 @@ namespace NSOnlineOfficeBinToPdf
|
||||
if (bIsPathOpened)
|
||||
{
|
||||
pRenderer->PathCommandEnd();
|
||||
if (path.GetPointCount())
|
||||
path.Reset();
|
||||
pRenderer->EndCommand(c_nPathType);
|
||||
}
|
||||
bIsPathOpened = false;
|
||||
@ -480,17 +471,6 @@ namespace NSOnlineOfficeBinToPdf
|
||||
double m2 = oReader.ReadDouble();
|
||||
double m3 = oReader.ReadDouble();
|
||||
double m4 = oReader.ReadDouble();
|
||||
|
||||
clipRect = Aggplus::RectF_T<double>(m1, m2, m3, m4);
|
||||
|
||||
long type;
|
||||
pRenderer->get_BrushTextureMode(&type);
|
||||
if (type != c_BrushTextureModeStretch)
|
||||
{
|
||||
m1 = 0.0;
|
||||
m2 = 0.0;
|
||||
}
|
||||
|
||||
pRenderer->BrushRect(bIsEnableBrushRect ? 1 : 0, m1, m2, m3, m4);
|
||||
break;
|
||||
}
|
||||
@ -499,10 +479,7 @@ namespace NSOnlineOfficeBinToPdf
|
||||
bIsEnableBrushRect = oReader.ReadBool();
|
||||
|
||||
if (!bIsEnableBrushRect)
|
||||
{
|
||||
pRenderer->BrushRect(bIsEnableBrushRect ? 1 : 0, 0, 0, 1, 1);
|
||||
clipRect = Aggplus::RectF_T<double>();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ctBrushTexturePathOld:
|
||||
@ -613,16 +590,6 @@ namespace NSOnlineOfficeBinToPdf
|
||||
pRenderer->put_BrushTextureAlpha(lAlpha);
|
||||
break;
|
||||
}
|
||||
case ctBrushResetRotation:
|
||||
{
|
||||
pRenderer->GetTransform(&old_t1, &old_t2, &old_t3, &old_t4, &old_t5, &old_t6);
|
||||
|
||||
Aggplus::CMatrix mtr(old_t1, old_t2, old_t3, old_t4, old_t5, old_t6);
|
||||
double rot = mtr.rotation();
|
||||
transMatrRot.Rotate(agg::rad2deg(rot));
|
||||
isResetRot = true;
|
||||
break;
|
||||
}
|
||||
case ctSetTransform:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
@ -639,15 +606,11 @@ namespace NSOnlineOfficeBinToPdf
|
||||
if (bIsPathOpened)
|
||||
{
|
||||
pRenderer->PathCommandEnd();
|
||||
if (path.GetPointCount())
|
||||
path.Reset();
|
||||
pRenderer->EndCommand(c_nPathType);
|
||||
}
|
||||
|
||||
pRenderer->BeginCommand(c_nPathType);
|
||||
pRenderer->PathCommandStart();
|
||||
path.Reset();
|
||||
path.StartFigure();
|
||||
|
||||
bIsPathOpened = true;
|
||||
break;
|
||||
@ -656,14 +619,14 @@ namespace NSOnlineOfficeBinToPdf
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
path.MoveTo(m1, m2);
|
||||
pRenderer->PathCommandMoveTo(m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandLineTo:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
path.LineTo(m1, m2);
|
||||
pRenderer->PathCommandLineTo(m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandCurveTo:
|
||||
@ -674,12 +637,12 @@ namespace NSOnlineOfficeBinToPdf
|
||||
double m4 = oReader.ReadDouble();
|
||||
double m5 = oReader.ReadDouble();
|
||||
double m6 = oReader.ReadDouble();
|
||||
path.CurveTo(m1, m2, m3, m4, m5, m6);
|
||||
pRenderer->PathCommandCurveTo(m1, m2, m3, m4, m5, m6);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandClose:
|
||||
{
|
||||
path.CloseFigure();
|
||||
pRenderer->PathCommandClose();
|
||||
break;
|
||||
}
|
||||
case ctPathCommandEnd:
|
||||
@ -687,107 +650,14 @@ namespace NSOnlineOfficeBinToPdf
|
||||
if (bIsPathOpened)
|
||||
{
|
||||
pRenderer->PathCommandEnd();
|
||||
if (path.GetPointCount())
|
||||
path.Reset();
|
||||
pRenderer->EndCommand(c_nPathType);
|
||||
bIsPathOpened = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ctPathCommandOffset:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
|
||||
pRenderer->put_BrushOffset(m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandScale:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
|
||||
pRenderer->put_BrushScale(true, m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctDrawPath:
|
||||
{
|
||||
long fill = oReader.ReadInt();
|
||||
long type;
|
||||
pRenderer->get_BrushType(&type);
|
||||
|
||||
if (fill != c_nStroke && type == c_BrushTypeTexture)
|
||||
{
|
||||
Aggplus::CGraphicsPath clipPath;
|
||||
Aggplus::CGraphicsPath drawPath(path);
|
||||
|
||||
if (isResetRot)
|
||||
{
|
||||
pRenderer->get_BrushTextureMode(&type);
|
||||
bool isStretch = type == c_BrushTextureModeStretch;
|
||||
|
||||
double left, top, width, height;
|
||||
drawPath.GetBounds(left, top, width, height);
|
||||
|
||||
double rot = transMatrRot.rotation();
|
||||
double cX = left + width / 2.0;
|
||||
double cY = top + height / 2.0;
|
||||
|
||||
bool isZeroPt = clipRect.X < 0.1 && clipRect.X > -0.1 && clipRect.Y < 0.1 && clipRect.Y > -0.1;
|
||||
bool isZeroRot = rot < 1e-6 && rot > -1e-6;
|
||||
|
||||
transMatrRot.Reset();
|
||||
transMatrRot.RotateAt(agg::rad2deg(rot), cX, cY, Aggplus::MatrixOrderAppend);
|
||||
|
||||
double offX = old_t5 - transMatrRot.tx();
|
||||
double offY = old_t6 - transMatrRot.ty();
|
||||
|
||||
drawPath.Transform(&transMatrRot);
|
||||
pRenderer->SetTransform(1.0, 0.0, 0.0, 1.0, offX, offY);
|
||||
|
||||
if (isZeroPt && !isZeroRot && isStretch)
|
||||
drawPath.GetBounds(left, top, width, height);
|
||||
else
|
||||
{
|
||||
Aggplus::CGraphicsPath tmpPath;
|
||||
tmpPath.AddRectangle(left, top, width, height);
|
||||
tmpPath.Transform(&transMatrRot);
|
||||
tmpPath.GetBounds(left, top, width, height);
|
||||
}
|
||||
|
||||
if (isZeroPt || !isStretch)
|
||||
clipRect = Aggplus::RectF_T<double>(left, top, width, height);
|
||||
|
||||
if (isStretch)
|
||||
{
|
||||
if (!isZeroPt)
|
||||
clipRect.Offset(-offX, -offY);
|
||||
pRenderer->BrushRect(true, clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
double tileOffX, tileOffY;
|
||||
pRenderer->get_BrushOffset(tileOffX, tileOffY);
|
||||
pRenderer->put_BrushOffset(tileOffX - offX, tileOffY - offY);
|
||||
}
|
||||
}
|
||||
|
||||
clipPath.AddRectangle(clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height);
|
||||
path = Aggplus::CalcBooleanOperation(drawPath, clipPath, Aggplus::Intersection);
|
||||
}
|
||||
|
||||
pRenderer->AddPath(path);
|
||||
pRenderer->DrawPath(fill);
|
||||
|
||||
if (isResetRot)
|
||||
{
|
||||
pRenderer->SetTransform(old_t1, old_t2, old_t3, old_t4, old_t5, old_t6);
|
||||
transMatrRot.Reset();
|
||||
isResetRot = false;
|
||||
}
|
||||
|
||||
pRenderer->put_BrushScale(false, 1.0, 1.0);
|
||||
pRenderer->put_BrushOffset(0.0, 0.0);
|
||||
pRenderer->DrawPath(oReader.ReadInt());
|
||||
break;
|
||||
}
|
||||
case ctDrawImageFromFile:
|
||||
@ -864,8 +734,6 @@ namespace NSOnlineOfficeBinToPdf
|
||||
if (bIsPathOpened)
|
||||
{
|
||||
pRenderer->PathCommandEnd();
|
||||
if (path.GetPointCount())
|
||||
path.Reset();
|
||||
pRenderer->EndCommand(4);
|
||||
bIsPathOpened = false;
|
||||
}
|
||||
@ -879,13 +747,8 @@ namespace NSOnlineOfficeBinToPdf
|
||||
pRenderer->EndCommand(4);
|
||||
bIsPathOpened = false;
|
||||
}
|
||||
int nCommand = oReader.ReadInt();
|
||||
if (path.GetPointCount() && nCommand == c_nClipType)
|
||||
pRenderer->AddPath(path);
|
||||
pRenderer->EndCommand((DWORD)nCommand);
|
||||
pRenderer->EndCommand((DWORD)(oReader.ReadInt()));
|
||||
pRenderer->PathCommandEnd();
|
||||
if (path.GetPointCount())
|
||||
path.Reset();
|
||||
break;
|
||||
}
|
||||
case ctGradientFill:
|
||||
@ -1269,10 +1132,6 @@ namespace NSOnlineOfficeBinToPdf
|
||||
oReader.Skip(1);
|
||||
break;
|
||||
}
|
||||
case ctBrushResetRotation:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case ctSetTransform:
|
||||
{
|
||||
oReader.SkipInt(6);
|
||||
@ -1305,16 +1164,6 @@ namespace NSOnlineOfficeBinToPdf
|
||||
{
|
||||
break;
|
||||
}
|
||||
case ctPathCommandOffset:
|
||||
{
|
||||
oReader.SkipInt(2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandScale:
|
||||
{
|
||||
oReader.SkipInt(2);
|
||||
break;
|
||||
}
|
||||
case ctDrawPath:
|
||||
{
|
||||
oReader.SkipInt();
|
||||
|
||||
@ -108,7 +108,6 @@ namespace NSOnlineOfficeBinToPdf
|
||||
ctBrushRectableEnabled = 30,
|
||||
ctBrushGradient = 31,
|
||||
ctBrushTexturePath = 32,
|
||||
ctBrushResetRotation = 33,
|
||||
|
||||
// font
|
||||
ctFontXML = 40,
|
||||
@ -154,8 +153,6 @@ namespace NSOnlineOfficeBinToPdf
|
||||
ctPathCommandGetCurrentPoint = 101,
|
||||
ctPathCommandText = 102,
|
||||
ctPathCommandTextEx = 103,
|
||||
ctPathCommandOffset = 104,
|
||||
ctPathCommandScale = 105,
|
||||
|
||||
// image
|
||||
ctDrawImage = 110,
|
||||
|
||||
@ -214,18 +214,6 @@ public:
|
||||
|
||||
inline bool IsPositive() { return Width > 0 && Height > 0; }
|
||||
|
||||
RectF_T& operator=(const RectF_T& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
X = other.X;
|
||||
Y = other.Y;
|
||||
Width = other.Width;
|
||||
Height = other.Height;
|
||||
|
||||
return *this;
|
||||
};
|
||||
public:
|
||||
T X, Y, Width, Height;
|
||||
};
|
||||
|
||||
@ -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->ReadInt();
|
||||
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;
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -181,6 +181,7 @@ public:
|
||||
int nPage;
|
||||
double dX;
|
||||
double dY;
|
||||
CHeading* pParent;
|
||||
std::vector<CHeading*> arrHeading;
|
||||
|
||||
CHeading();
|
||||
|
||||
@ -46,20 +46,16 @@
|
||||
"_InitializeFontsRanges",
|
||||
"_SetFontBinary",
|
||||
"_GetFontBinary",
|
||||
"_GetGIDByUnicode",
|
||||
"_IsFontBinaryExist",
|
||||
"_DestroyTextInfo",
|
||||
"_IsNeedCMap",
|
||||
"_SetCMapData",
|
||||
"_SetScanPageFonts",
|
||||
"_ScanPage",
|
||||
"_SplitPages",
|
||||
"_MergePages",
|
||||
"_UnmergePages",
|
||||
"_RedactPage",
|
||||
"_UndoRedact",
|
||||
"_CheckOwnerPassword",
|
||||
"_CheckPerm",
|
||||
"_GetImageBase64",
|
||||
"_GetImageBase64Len",
|
||||
"_GetImageBase64Ptr",
|
||||
@ -197,7 +193,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/SrcReader/",
|
||||
"files": ["Adaptors.cpp", "GfxClip.cpp", "RendererOutputDev.cpp", "JPXStream2.cpp", "PdfAnnot.cpp", "PdfFont.cpp"]
|
||||
"files": ["Adaptors.cpp", "GfxClip.cpp", "RendererOutputDev.cpp", "JPXStream2.cpp", "PdfAnnot.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/SrcWriter/",
|
||||
|
||||
@ -639,7 +639,6 @@ SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcReader/Adaptors.cpp \
|
||||
$$PDF_ROOT_DIR/SrcReader/GfxClip.cpp \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.cpp \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfFont.cpp \
|
||||
$$PDF_ROOT_DIR/Resources/BaseFonts.cpp \
|
||||
$$PDF_ROOT_DIR/Resources/CMapMemory/cmap_memory.cpp
|
||||
|
||||
@ -665,7 +664,6 @@ HEADERS +=\
|
||||
$$PDF_ROOT_DIR/SrcReader/MemoryUtils.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/GfxClip.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/FontsWasm.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfFont.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.h
|
||||
|
||||
DEFINES += CRYPTOPP_DISABLE_ASM
|
||||
|
||||
@ -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,26 +354,6 @@ CFile.prototype["getFontByID"] = function(ID)
|
||||
return this._getFontByID(ID);
|
||||
};
|
||||
|
||||
CFile.prototype["getGIDByUnicode"] = function(ID)
|
||||
{
|
||||
let ptr = this._getGIDByUnicode(ID);
|
||||
let reader = ptr.getReader();
|
||||
if (!reader)
|
||||
return {};
|
||||
|
||||
let res = {};
|
||||
let nFontLength = reader.readInt();
|
||||
for (let i = 0; i < nFontLength; i++)
|
||||
{
|
||||
let np1 = reader.readInt();
|
||||
let np2 = reader.readInt();
|
||||
res[np2] = np1;
|
||||
}
|
||||
|
||||
ptr.free();
|
||||
return res;
|
||||
};
|
||||
|
||||
CFile.prototype["setCMap"] = function(memoryBuffer)
|
||||
{
|
||||
if (!this.nativeFile)
|
||||
@ -429,7 +401,7 @@ function readAction(reader, rec, readDoubleFunc, readStringFunc)
|
||||
case 6:
|
||||
case 7:
|
||||
{
|
||||
let nFlag = reader.readInt();
|
||||
let nFlag = reader.readByte();
|
||||
if (nFlag & (1 << 0))
|
||||
rec["left"] = readDoubleFunc.call(reader);
|
||||
if (nFlag & (1 << 1))
|
||||
@ -441,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:
|
||||
@ -1055,37 +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"] = {};
|
||||
if (isRead)
|
||||
readStringFunc.call(reader);
|
||||
readAction(reader, rec["A"], readDoubleFunc, readStringFunc);
|
||||
}
|
||||
if (flags & (1 << 1))
|
||||
{
|
||||
rec["PA"] = {};
|
||||
if (isRead)
|
||||
readStringFunc.call(reader);
|
||||
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)
|
||||
{
|
||||
@ -1230,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
|
||||
@ -1721,11 +1648,6 @@ CFile.prototype["readAnnotationsInfoFromBinary"] = function(AnnotInfo)
|
||||
};
|
||||
|
||||
// SCAN PAGES
|
||||
CFile.prototype["scanPageFonts"] = function(page)
|
||||
{
|
||||
this._setScanPageFonts(page);
|
||||
};
|
||||
|
||||
CFile.prototype["scanPage"] = function(page, mode)
|
||||
{
|
||||
let ptr = this._scanPage(page, mode);
|
||||
|
||||
@ -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);
|
||||
@ -252,11 +236,6 @@ CFile.prototype._getInteractiveFormsAP = function(width, height, backgroundColor
|
||||
};
|
||||
|
||||
// SCAN PAGES
|
||||
CFile.prototype._setScanPageFonts = function(page)
|
||||
{
|
||||
g_native_drawing_file["SetScanPageFonts"](page);
|
||||
};
|
||||
|
||||
CFile.prototype._scanPage = function(page, mode)
|
||||
{
|
||||
g_module_pointer.ptr = g_native_drawing_file["ScanPage"](page, (mode === undefined) ? 0 : mode);
|
||||
|
||||
@ -106,7 +106,7 @@ CFile.prototype._openFile = function(buffer, password)
|
||||
}
|
||||
|
||||
let passwordPtr = 0;
|
||||
if (password !== undefined)
|
||||
if (password)
|
||||
{
|
||||
let passwordBuf = password.toUtf8();
|
||||
passwordPtr = Module["_malloc"](passwordBuf.length);
|
||||
@ -224,29 +224,6 @@ CFile.prototype._UndoRedact = function()
|
||||
return Module["_UndoRedact"](this.nativeFile) == 1;
|
||||
};
|
||||
|
||||
CFile.prototype._CheckOwnerPassword = function(password)
|
||||
{
|
||||
let passwordPtr = 0;
|
||||
if (password !== undefined)
|
||||
{
|
||||
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,19 +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);
|
||||
return g_module_pointer;
|
||||
}
|
||||
|
||||
CFile.prototype._getInteractiveFormsFonts = function(type)
|
||||
{
|
||||
g_module_pointer.ptr = Module["_GetInteractiveFormsFonts"](this.nativeFile, type);
|
||||
@ -373,11 +337,6 @@ CFile.prototype._getInteractiveFormsAP = function(width, height, backgroundColor
|
||||
};
|
||||
|
||||
// SCAN PAGES
|
||||
CFile.prototype._setScanPageFonts = function(page)
|
||||
{
|
||||
Module["_SetScanPageFonts"](this.nativeFile, page);
|
||||
};
|
||||
|
||||
CFile.prototype._scanPage = function(page, mode)
|
||||
{
|
||||
g_module_pointer.ptr = Module["_ScanPage"](this.nativeFile, page, (mode === undefined) ? 0 : mode);
|
||||
|
||||
@ -80,7 +80,7 @@ WASM_EXPORT CDrawingFile* Open(BYTE* data, LONG size, const char* password)
|
||||
std::wstring sPassword = L"";
|
||||
if (NULL != password)
|
||||
sPassword = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)password, strlen(password));
|
||||
pFile->OpenFile(data, size, password ? sPassword.c_str() : NULL);
|
||||
pFile->OpenFile(data, size, sPassword);
|
||||
return pFile;
|
||||
}
|
||||
WASM_EXPORT int GetType(CDrawingFile* pFile)
|
||||
@ -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();
|
||||
@ -166,10 +162,6 @@ WASM_EXPORT void SetCMapData(CDrawingFile* pFile, BYTE* data, int size)
|
||||
{
|
||||
pFile->SetCMapData(data, size);
|
||||
}
|
||||
WASM_EXPORT void SetScanPageFonts(CDrawingFile* pFile, int nPageIndex)
|
||||
{
|
||||
return pFile->SetScanPageFonts(nPageIndex);
|
||||
}
|
||||
WASM_EXPORT BYTE* ScanPage(CDrawingFile* pFile, int nPageIndex, int mode)
|
||||
{
|
||||
return pFile->ScanPage(nPageIndex, mode);
|
||||
@ -199,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(password ? sPassword.c_str() : NULL) ? 1 : 0;
|
||||
}
|
||||
WASM_EXPORT int CheckPerm(CDrawingFile* pFile, int nPermFlag)
|
||||
{
|
||||
return pFile->CheckPerm(nPermFlag) ? 1 : 0;
|
||||
}
|
||||
|
||||
WASM_EXPORT void* GetImageBase64(CDrawingFile* pFile, int rId)
|
||||
{
|
||||
|
||||
@ -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 << "GIDtoUnicode" << 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 << "gid\t" << code << "\tunicode\t" << unicode << std::endl;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
if (pFont)
|
||||
free(pFont);
|
||||
}
|
||||
@ -1072,7 +1025,7 @@ int main(int argc, char* argv[])
|
||||
if (!NSFile::CFileBinary::ReadAllBytes(sFilePath, &pFileData, nFileDataLen))
|
||||
return 1;
|
||||
|
||||
CDrawingFile* pGrFile = Open(pFileData, (LONG)nFileDataLen, NULL);
|
||||
CDrawingFile* pGrFile = Open(pFileData, (LONG)nFileDataLen, "");
|
||||
int nError = GetErrorCode(pGrFile);
|
||||
|
||||
if (nError != 0)
|
||||
@ -1080,7 +1033,7 @@ int main(int argc, char* argv[])
|
||||
Close(pGrFile);
|
||||
if (nError == 4)
|
||||
{
|
||||
std::string sPassword = "";
|
||||
std::string sPassword = "123456";
|
||||
pGrFile = Open(pFileData, nFileDataLen, sPassword.c_str());
|
||||
}
|
||||
else
|
||||
@ -1100,7 +1053,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
if (true && GetFromBase64(NSFile::GetProcessDirectory() + L"/split.txt", &pBuffer, &nBufferLen))
|
||||
{
|
||||
std::vector<int> arrPages = { 0 };
|
||||
std::vector<int> arrPages = { 2 };
|
||||
BYTE* pSplitPages = SplitPages(pGrFile, arrPages.data(), arrPages.size(), pBuffer, nBufferLen);
|
||||
int nLength = READ_INT(pSplitPages);
|
||||
|
||||
@ -1172,38 +1125,26 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// OWNER PASSWORD
|
||||
if (false)
|
||||
{
|
||||
std::string sPassword = "";
|
||||
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)
|
||||
{
|
||||
BYTE* pColor = new BYTE[12] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
int pRect[8] = { 307499, 217499, 307499, 1124999, 1799999, 1124999, 1799999, 217499 };
|
||||
if (!RedactPage(pGrFile, nTestPage, pRect, 1, pColor, 12))
|
||||
std::cout << "Redact false" << std::endl;
|
||||
}
|
||||
|
||||
// RASTER
|
||||
if (false)
|
||||
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;
|
||||
}
|
||||
@ -2251,13 +2154,12 @@ int main(int argc, char* argv[])
|
||||
free(pAnnotAP);
|
||||
}
|
||||
|
||||
// SCAN PAGE Fonts
|
||||
// SCAN PAGE
|
||||
if (false)
|
||||
{
|
||||
SetScanPageFonts(pGrFile, nTestPage);
|
||||
|
||||
ReadInteractiveFormsFonts(pGrFile, 1);
|
||||
ReadInteractiveFormsFonts(pGrFile, 2);
|
||||
BYTE* pScan = ScanPage(pGrFile, nTestPage, 1);
|
||||
if (pScan)
|
||||
free(pScan);
|
||||
}
|
||||
|
||||
Close(pGrFile);
|
||||
|
||||
@ -63,9 +63,9 @@ public:
|
||||
|
||||
// Open
|
||||
virtual bool LoadFromFile(const std::wstring& file, const std::wstring& options = L"",
|
||||
const wchar_t* owner_password = NULL, const wchar_t* user_password = NULL) = 0;
|
||||
const std::wstring& owner_password = L"", const std::wstring& user_password = L"") = 0;
|
||||
virtual bool LoadFromMemory(unsigned char* data, unsigned long length, const std::wstring& options = L"",
|
||||
const wchar_t* owner_password = NULL, const wchar_t* user_password = NULL) = 0;
|
||||
const std::wstring& owner_password = L"", const std::wstring& user_password = L"") = 0;
|
||||
|
||||
// Close
|
||||
virtual void Close() = 0;
|
||||
|
||||
@ -113,10 +113,7 @@ const long c_BrushTypeTensorCurveGradient = 6007;
|
||||
|
||||
const long c_BrushTextureModeStretch = 0;
|
||||
const long c_BrushTextureModeTile = 1;
|
||||
const long c_BrushTextureModeTileFlipX = 2;
|
||||
const long c_BrushTextureModeTileFlipY = 3;
|
||||
const long c_BrushTextureModeTileFlipXY = 4;
|
||||
const long c_BrushTextureModeTileCenter = 5;
|
||||
const long c_BrushTextureModeTileCenter = 2;
|
||||
// --------------------------------------------------------------
|
||||
|
||||
namespace Aggplus { class CImage; }
|
||||
@ -287,13 +284,6 @@ namespace NSStructures
|
||||
Aggplus::RectF Rect;
|
||||
Aggplus::CDoubleRect Bounds;
|
||||
|
||||
int IsScale;
|
||||
double ScaleX;
|
||||
double ScaleY;
|
||||
|
||||
double OffsetX;
|
||||
double OffsetY;
|
||||
|
||||
double LinearAngle;
|
||||
std::vector<TSubColor> m_arrSubColors;
|
||||
NSStructures::GradientInfo m_oGradientInfo;
|
||||
@ -425,13 +415,6 @@ namespace NSStructures
|
||||
Rect.Width = 0.0F;
|
||||
Rect.Height = 0.0F;
|
||||
|
||||
IsScale = FALSE;
|
||||
ScaleX = 1.0;
|
||||
ScaleY = 1.0;
|
||||
|
||||
OffsetX = 0.0;
|
||||
OffsetY = 0.0;
|
||||
|
||||
Bounds.left = 0;
|
||||
Bounds.top = 0;
|
||||
Bounds.right = 0;
|
||||
@ -471,10 +454,6 @@ namespace NSStructures
|
||||
Rect = other.Rect;
|
||||
Bounds = other.Bounds;
|
||||
|
||||
IsScale = other.IsScale;
|
||||
ScaleX = other.ScaleX;
|
||||
ScaleY = other.ScaleY;
|
||||
|
||||
LinearAngle = other.LinearAngle;
|
||||
m_arrSubColors = other.m_arrSubColors;
|
||||
m_oGradientInfo = other.m_oGradientInfo;
|
||||
|
||||
@ -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]
|
||||
//4–7 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)
|
||||
@ -349,7 +336,7 @@ bool CImageFileFormatChecker::isSvgFile(BYTE* pBuffer,DWORD dwBytes)
|
||||
{
|
||||
if (eFileType)return false;
|
||||
|
||||
if ( (6 <= dwBytes) && (0x3C == pBuffer[0] && 0x3F == pBuffer[1] && 0x78 == pBuffer[2] && 0x6D == pBuffer[3]
|
||||
if ( (6 <= dwBytes) &&(0x3C == pBuffer[0] && 0x3F == pBuffer[1] && 0x78 == pBuffer[2] && 0x6D == pBuffer[3]
|
||||
&& 0x6C == pBuffer[4] && 0x20 == pBuffer[5]))
|
||||
{
|
||||
std::string sXml_part = std::string((char*)pBuffer, dwBytes);
|
||||
@ -358,11 +345,6 @@ bool CImageFileFormatChecker::isSvgFile(BYTE* pBuffer,DWORD dwBytes)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ( (6 <= dwBytes) && (0x3C == pBuffer[0] && 's' == pBuffer[1] && 'v' == pBuffer[2] && 'g' == pBuffer[3]
|
||||
&& 0x20 == pBuffer[4]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -527,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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -74,7 +74,7 @@ namespace MetaFile
|
||||
virtual void EndClipPath(unsigned int unMode) = 0;
|
||||
|
||||
virtual void UpdateDC() = 0;
|
||||
virtual void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) = 0;
|
||||
virtual void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) = 0;
|
||||
virtual void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -914,7 +914,7 @@ namespace MetaFile
|
||||
|
||||
m_bStartedPath = false;
|
||||
}
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY)
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY)
|
||||
{
|
||||
double dKoefX = m_dScaleX;
|
||||
double dKoefY = m_dScaleY;
|
||||
@ -1270,6 +1270,19 @@ namespace MetaFile
|
||||
|
||||
if ((NULL != pDataDash && 0 != unSizeDash) || PS_SOLID != ulPenStyle)
|
||||
{
|
||||
// Дублированный код из Graphics
|
||||
// Без этого используется оригинальный код в Graphics, который отрисовывает уже неверно
|
||||
double dDashWidth{dWidth};
|
||||
|
||||
if (!Equals(dWidthMinSize, dWidth))
|
||||
{
|
||||
double dDet = oMatrix.Determinant();
|
||||
|
||||
if (fabs(dDet) < 0.0001)
|
||||
dDashWidth *= dSqrtDet;
|
||||
}
|
||||
// -----------------------------
|
||||
|
||||
if (NULL != pDataDash && 0 != unSizeDash)
|
||||
{
|
||||
m_pRenderer->put_PenDashOffset(pPen->GetDashOffset());
|
||||
@ -1277,7 +1290,7 @@ namespace MetaFile
|
||||
std::vector<double> arDashes(unSizeDash);
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < unSizeDash; ++unIndex)
|
||||
arDashes[unIndex] = pDataDash[unIndex] * dWidth;
|
||||
arDashes[unIndex] = pDataDash[unIndex] * dDashWidth;
|
||||
|
||||
m_pRenderer->PenDashPattern(arDashes.data(), unSizeDash);
|
||||
|
||||
@ -1291,35 +1304,35 @@ namespace MetaFile
|
||||
{
|
||||
case PS_DASH:
|
||||
{
|
||||
arDashPattern.push_back(9 * dWidth);
|
||||
arDashPattern.push_back(3 * dWidth);
|
||||
arDashPattern.push_back(9 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DOT:
|
||||
{
|
||||
arDashPattern.push_back(3 * dWidth);
|
||||
arDashPattern.push_back(3 * dWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DASHDOT:
|
||||
{
|
||||
arDashPattern.push_back(9 * dWidth);
|
||||
arDashPattern.push_back(6 * dWidth);
|
||||
arDashPattern.push_back(3 * dWidth);
|
||||
arDashPattern.push_back(6 * dWidth);
|
||||
arDashPattern.push_back(9 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
case PS_DASHDOTDOT:
|
||||
{
|
||||
arDashPattern.push_back(9 * dWidth);
|
||||
arDashPattern.push_back(6 * dWidth);
|
||||
arDashPattern.push_back(3 * dWidth);
|
||||
arDashPattern.push_back(6 * dWidth);
|
||||
arDashPattern.push_back(3 * dWidth);
|
||||
arDashPattern.push_back(6 * dWidth);
|
||||
arDashPattern.push_back(9 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
arDashPattern.push_back(3 * dDashWidth);
|
||||
arDashPattern.push_back(6 * dDashWidth);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ namespace MetaFile
|
||||
void EndClipPath(unsigned int unMode) override {};
|
||||
|
||||
void UpdateDC() override {};
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) override {};
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override {};
|
||||
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override {};
|
||||
};
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ namespace MetaFile
|
||||
pInterpretator->UpdateDC();
|
||||
}
|
||||
|
||||
void CEmfInterpretatorArray::SetTransform(const double &dM11, const double &dM12, const double &dM21, const double &dM22, const double &dX, const double &dY)
|
||||
void CEmfInterpretatorArray::SetTransform(double &dM11, double &dM12, double &dM21, double &dM22, double &dX, double &dY)
|
||||
{
|
||||
for (CEmfInterpretatorBase* pInterpretator : m_arInterpretators)
|
||||
pInterpretator->SetTransform(dM11, dM12, dM21, dM22, dX, dY);
|
||||
|
||||
@ -57,7 +57,7 @@ namespace MetaFile
|
||||
void EndClipPath(unsigned int unMode) override;
|
||||
|
||||
void UpdateDC() override;
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) override;
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override;
|
||||
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override;
|
||||
|
||||
void HANDLE_EMR_HEADER(const TEmfHeader& oTEmfHeader) override;
|
||||
|
||||
@ -18,8 +18,8 @@ namespace MetaFile
|
||||
|
||||
void CEmfInterpretatorRender::ChangeConditional()
|
||||
{
|
||||
if (NULL != m_pMetaFileRenderer)
|
||||
m_pMetaFileRenderer->ChangeConditional();
|
||||
if (NULL != m_pMetaFileRenderer)
|
||||
m_pMetaFileRenderer->ChangeConditional();
|
||||
}
|
||||
|
||||
void CEmfInterpretatorRender::Begin()
|
||||
@ -143,7 +143,7 @@ namespace MetaFile
|
||||
m_pMetaFileRenderer->UpdateDC();
|
||||
}
|
||||
|
||||
void CEmfInterpretatorRender::SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY)
|
||||
void CEmfInterpretatorRender::SetTransform(double &dM11, double &dM12, double &dM21, double &dM22, double &dX, double &dY)
|
||||
{
|
||||
if (NULL != m_pMetaFileRenderer)
|
||||
m_pMetaFileRenderer->SetTransform(dM11, dM12, dM21, dM22, dX, dY);
|
||||
|
||||
@ -43,7 +43,7 @@ namespace MetaFile
|
||||
void EndClipPath(unsigned int unMode) override;
|
||||
|
||||
void UpdateDC() override;
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) override;
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override;
|
||||
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override;
|
||||
|
||||
CMetaFileRenderer* GetRenderer() const;
|
||||
|
||||
@ -223,7 +223,7 @@ namespace MetaFile
|
||||
void EndPath() override {};
|
||||
|
||||
void UpdateDC() override {};
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) override {};
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override {};
|
||||
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override {};
|
||||
|
||||
void SwapClips(CSvgClip& oFirstClip, CSvgClip& oSecondClip);
|
||||
|
||||
@ -237,7 +237,7 @@ namespace MetaFile
|
||||
void EndClipPath(unsigned int unMode) override {};
|
||||
|
||||
void UpdateDC() override {};
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) override {};
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override {};
|
||||
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override {};
|
||||
};
|
||||
}
|
||||
|
||||
@ -1264,11 +1264,7 @@ namespace MetaFile
|
||||
|
||||
if (NULL != m_pPath)
|
||||
{
|
||||
TEmfXForm oTransform{m_pDC->GetFinalTransform(GM_ADVANCED)};
|
||||
oTransform.Dx -= GetDCBounds().Left;
|
||||
oTransform.Dy -= GetDCBounds().Top;
|
||||
|
||||
m_pDC->GetClip()->SetPath(*m_pPath, unRegionMode, oTransform);
|
||||
m_pDC->GetClip()->SetPath(*m_pPath, unRegionMode, m_pDC->GetFinalTransform(GM_ADVANCED));
|
||||
RELEASEOBJECT(m_pPath);
|
||||
UpdateOutputDC();
|
||||
}
|
||||
|
||||
@ -3284,10 +3284,6 @@ namespace MetaFile
|
||||
void CEmfPlusParser::Read_EMFPLUS_SETCLIPRECT(unsigned short unShFlags)
|
||||
{
|
||||
short shCM = ExpressValue(unShFlags, 8, 11);
|
||||
|
||||
if (0 == shCM)
|
||||
shCM = RGN_COPY;
|
||||
|
||||
TEmfPlusRectF oRect;
|
||||
|
||||
m_oStream >> oRect;
|
||||
|
||||
@ -627,13 +627,15 @@ namespace MetaFile
|
||||
|
||||
void CInterpretatorSvgBase::PathClip(const CPath &oPath, int nClipMode, TXForm *pTransform)
|
||||
{
|
||||
const std::wstring wsPath = CreatePath(oPath, pTransform);
|
||||
std::wstring wsPath = CreatePath(oPath, pTransform);
|
||||
|
||||
if (wsPath.empty())
|
||||
return;
|
||||
|
||||
m_oClip.AddClipValue(L"PATHCLIP_" + ConvertToWString(++m_unNumberDefs, 0),
|
||||
L"<path d=\"" + wsPath + L"\"/>", nClipMode);
|
||||
const std::wstring wsClipId = L"PATHCLIP_" + ConvertToWString(++m_unNumberDefs, 0);
|
||||
const std::wstring wsValue = L"<path d=\"" + wsPath + L"\"/>";
|
||||
|
||||
m_oClip.AddClipValue(wsClipId, wsValue, nClipMode);
|
||||
}
|
||||
|
||||
void CInterpretatorSvgBase::AddStroke(NodeAttributes &arAttributes) const
|
||||
|
||||
@ -131,7 +131,7 @@ namespace MetaFile
|
||||
m_pMetaFileRenderer->UpdateDC();
|
||||
}
|
||||
|
||||
void CWmfInterpretatorRender::SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY)
|
||||
void CWmfInterpretatorRender::SetTransform(double &dM11, double &dM12, double &dM21, double &dM22, double &dX, double &dY)
|
||||
{
|
||||
if (NULL != m_pMetaFileRenderer)
|
||||
m_pMetaFileRenderer->SetTransform(dM11, dM12, dM21, dM22, dX, dY);
|
||||
|
||||
@ -40,7 +40,7 @@ namespace MetaFile
|
||||
void EndClipPath(unsigned int unMode) override;
|
||||
|
||||
void UpdateDC() override;
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) override;
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override;
|
||||
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override;
|
||||
|
||||
CMetaFileRenderer* GetRenderer() const;
|
||||
|
||||
@ -130,7 +130,7 @@ namespace MetaFile
|
||||
void EndClipPath(unsigned int unMode) override {};
|
||||
|
||||
void UpdateDC() override {};
|
||||
void SetTransform(const double& dM11, const double& dM12, const double& dM21, const double& dM22, const double& dX, const double& dY) override {};
|
||||
void SetTransform(double& dM11, double& dM12, double& dM21, double& dM22, double& dX, double& dY) override {};
|
||||
void GetTransform(double* pdM11, double* pdM12, double* pdM21, double* pdM22, double* pdX, double* pdY) override {};
|
||||
};
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 || pStroke->m_oColor.None() || (!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 || pFill->None() || (!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);
|
||||
|
||||
@ -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()));
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -40,14 +40,13 @@
|
||||
CPictFile::CPictFile()
|
||||
{
|
||||
m_pRenderer = NSGraphics::Create();
|
||||
m_pFontManager = NSFonts::NSFontManager::Create();
|
||||
m_pRenderer->SetFontManager(m_pFontManager);
|
||||
}
|
||||
|
||||
CPictFile::~CPictFile()
|
||||
{
|
||||
if (m_pAppFonts)
|
||||
RELEASEINTERFACE(m_pAppFonts);
|
||||
if (m_pFontManager)
|
||||
RELEASEINTERFACE(m_pFontManager);
|
||||
RELEASEINTERFACE(m_pFontManager);
|
||||
RELEASEINTERFACE(m_pRenderer);
|
||||
}
|
||||
|
||||
@ -1672,7 +1671,6 @@ void CPictFile::DrawArc()
|
||||
void CPictFile::ReadAndDrawText(int x, int y)
|
||||
{
|
||||
InitializeRenderer();
|
||||
InitializeFonts();
|
||||
|
||||
char text[256];
|
||||
char byte_len = fgetc(m_pFile);
|
||||
@ -1697,20 +1695,6 @@ void CPictFile::ReadAndDrawText(int x, int y)
|
||||
m_pRenderer->EndCommand(c_nTextGraphicType);
|
||||
}
|
||||
|
||||
void CPictFile::InitializeFonts()
|
||||
{
|
||||
if (m_pAppFonts)
|
||||
return;
|
||||
|
||||
m_pAppFonts = NSFonts::NSApplication::Create();
|
||||
m_pAppFonts->Initialize();
|
||||
m_pFontManager = m_pAppFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* fonts_cache = NSFonts::NSFontCache::Create();
|
||||
fonts_cache->SetStreams(m_pAppFonts->GetStreams());
|
||||
m_pFontManager->SetOwnerCache(fonts_cache);
|
||||
m_pRenderer->SetFontManager(m_pFontManager);
|
||||
}
|
||||
|
||||
void CPictFile::InitializeRenderer()
|
||||
{
|
||||
if (m_pFrameData)
|
||||
|
||||
@ -247,7 +247,6 @@ private:
|
||||
void DrawArc();
|
||||
void ReadAndDrawText(int x, int y);
|
||||
|
||||
void InitializeFonts();
|
||||
void InitializeRenderer();
|
||||
|
||||
private:
|
||||
@ -258,8 +257,8 @@ private:
|
||||
CBgraFrame m_oFrame{};
|
||||
BYTE* m_pFrameData{nullptr};
|
||||
|
||||
size_t m_nPenHeight{1};
|
||||
size_t m_nPenWidth{1};
|
||||
size_t m_nPenHeight{0};
|
||||
size_t m_nPenWidth{0};
|
||||
|
||||
int m_nFontStyle{0};
|
||||
int m_nFontSize{0};
|
||||
@ -276,7 +275,6 @@ private:
|
||||
std::vector<Aggplus::Point> m_arLastPolygon{};
|
||||
|
||||
NSGraphics::IGraphicsRenderer* m_pRenderer{nullptr};
|
||||
NSFonts::IApplicationFonts* m_pAppFonts{nullptr};
|
||||
NSFonts::IFontManager* m_pFontManager{nullptr};
|
||||
};
|
||||
|
||||
|
||||
@ -105,13 +105,13 @@ namespace NSHeif {
|
||||
|
||||
inline bool CHeifFile::Decode(heif_context* ctx, CBgraFrame* frame, bool isRGBA)
|
||||
{
|
||||
heif_image_handle* handle = nullptr;
|
||||
heif_image_handle* handle;
|
||||
defer(heif_image_handle_release(handle););
|
||||
|
||||
if (IsError(heif_context_get_primary_image_handle(ctx, &handle)))
|
||||
return false;
|
||||
|
||||
heif_image* img = nullptr;
|
||||
heif_image* img;
|
||||
defer(heif_image_release(img););
|
||||
|
||||
if (IsError(heif_decode_image(handle, &img, heif_colorspace_RGB, heif_chroma_444, nullptr)))
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
#include <openssl/engine.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@ -605,12 +604,6 @@ public:
|
||||
evp = EVP_sha512();
|
||||
else if (m_alg == OOXML_HASH_ALG_ECDSA_384)
|
||||
evp = EVP_sha384();
|
||||
else if (m_alg == OOXML_HASH_ALG_SHA256)
|
||||
evp = EVP_sha256();
|
||||
else if (m_alg == OOXML_HASH_ALG_SHA384)
|
||||
evp = EVP_sha384();
|
||||
else if (m_alg == OOXML_HASH_ALG_SHA512)
|
||||
evp = EVP_sha512();
|
||||
|
||||
if (!PKCS7_sign_add_signer(pkcs7, m_cert, m_key, evp, 0))
|
||||
{
|
||||
|
||||
@ -42,7 +42,7 @@ CDjVuFile::~CDjVuFile()
|
||||
delete m_pImplementation;
|
||||
}
|
||||
bool CDjVuFile::LoadFromFile(const std::wstring& file, const std::wstring& options,
|
||||
const wchar_t* owner_password, const wchar_t* user_password)
|
||||
const std::wstring& owner_password, const std::wstring& user_password)
|
||||
{
|
||||
if (m_pImplementation)
|
||||
return m_pImplementation->LoadFromFile(file, options);
|
||||
@ -50,7 +50,7 @@ bool CDjVuFile::LoadFromFile(const std::wstring& file, const std::wstring& optio
|
||||
return false;
|
||||
}
|
||||
bool CDjVuFile::LoadFromMemory(BYTE* data, DWORD length, const std::wstring& options,
|
||||
const wchar_t* owner_password, const wchar_t* user_password)
|
||||
const std::wstring& owner_password, const std::wstring& user_password)
|
||||
{
|
||||
if (m_pImplementation)
|
||||
return m_pImplementation->LoadFromMemory(data, length, options);
|
||||
|
||||
@ -55,9 +55,9 @@ public:
|
||||
virtual ~CDjVuFile();
|
||||
|
||||
virtual bool LoadFromFile(const std::wstring& file, const std::wstring& options = L"",
|
||||
const wchar_t* owner_password = NULL, const wchar_t* user_password = NULL);
|
||||
const std::wstring& owner_password = L"", const std::wstring& user_password = L"");
|
||||
virtual bool LoadFromMemory(BYTE* data, DWORD length, const std::wstring& options = L"",
|
||||
const wchar_t* owner_password = NULL, const wchar_t* user_password = NULL);
|
||||
const std::wstring& owner_password = L"", const std::wstring& user_password = L"");
|
||||
|
||||
virtual void Close();
|
||||
virtual NSFonts::IApplicationFonts* GetFonts();
|
||||
|
||||
@ -92,7 +92,6 @@ int CDocxRenderer::Convert(IOfficeDrawingFile* pFile, const std::wstring& sDst,
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bUseDefaultFont = false;
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = false;
|
||||
m_pInternal->m_bIsSupportShapeCommands = false;
|
||||
m_pInternal->m_oDocument.m_bIsRecord = true;
|
||||
|
||||
if (bIsOutCompress)
|
||||
m_pInternal->m_oDocument.m_strTempDirectory = NSDirectory::CreateDirectoryWithUniqueName(m_pInternal->m_sTempDirectory);
|
||||
@ -131,7 +130,6 @@ std::vector<std::wstring> CDocxRenderer::ScanPage(IOfficeDrawingFile* pFile, siz
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bUseDefaultFont = true;
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_bWriteStyleRaw = true;
|
||||
m_pInternal->m_bIsSupportShapeCommands = false;
|
||||
m_pInternal->m_oDocument.m_bIsRecord = false;
|
||||
|
||||
DrawPage(pFile, nPage);
|
||||
|
||||
@ -146,9 +144,7 @@ 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_oDocument.m_bIsRecord = false;
|
||||
|
||||
m_pInternal->m_eShapeSerializeType = ShapeSerializeType::sstXml;
|
||||
DrawPage(pFile, nPage);
|
||||
@ -164,11 +160,7 @@ 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_oDocument.m_bIsRecord = false;
|
||||
m_pInternal->m_bIsSupportShapeCommands = true;
|
||||
m_pInternal->m_oDocument.m_oFontStyleManager.Clear();
|
||||
m_pInternal->m_oDocument.m_oFontSelector.ClearCache();
|
||||
|
||||
DrawPage(pFile, nPage);
|
||||
|
||||
@ -740,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)
|
||||
|
||||
@ -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)
|
||||
@ -572,11 +571,8 @@ namespace NSDocxRenderer
|
||||
m_oPageBuilder.ClearNoAttack();
|
||||
|
||||
m_oCurrentPage.Analyze();
|
||||
if (m_bIsRecord)
|
||||
{
|
||||
m_oCurrentPage.Record(m_oPageBuilder, m_lPageNum >= m_lNumberPages - 1);
|
||||
m_arXmlString.push_back(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(m_oPageBuilder.GetBuffer(), (LONG)m_oPageBuilder.GetCurSize()));
|
||||
}
|
||||
m_oCurrentPage.Record(m_oPageBuilder, m_lPageNum >= m_lNumberPages - 1);
|
||||
m_arXmlString.push_back(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(m_oPageBuilder.GetBuffer(), (LONG)m_oPageBuilder.GetCurSize()));
|
||||
|
||||
if (m_oPageBuilder.GetCurSize() > 100000000/*100Mb*/)
|
||||
m_oPageBuilder.Clear();
|
||||
@ -648,15 +644,11 @@ namespace NSDocxRenderer
|
||||
if ((nType > 0xFF) && (c_BrushTypeTexture == m_oCurrentPage.m_oBrush.Type))
|
||||
{
|
||||
double x = 0, y = 0, w = 0, h = 0;
|
||||
if (m_oCurrentPage.IsCurrVectorClockwise())
|
||||
h = -1; // to flip image later
|
||||
|
||||
if (m_oCurrentPage.m_oBrush.Image)
|
||||
pInfo = m_oImageManager.WriteImage(m_oCurrentPage.m_oBrush.Image, x, y, w, h);
|
||||
else
|
||||
pInfo = m_oImageManager.WriteImage(m_oCurrentPage.m_oBrush.TexturePath);
|
||||
pInfo = m_oImageManager.WriteImage(m_oCurrentPage.m_oBrush.TexturePath, x, y, w, h);
|
||||
}
|
||||
|
||||
m_oCurrentPage.DrawPath(nType, pInfo);
|
||||
return S_OK;
|
||||
}
|
||||
@ -716,7 +708,7 @@ namespace NSDocxRenderer
|
||||
}
|
||||
HRESULT CDocument::DrawImageFromFile(const std::wstring& sVal, double fX, double fY, double fWidth, double fHeight)
|
||||
{
|
||||
m_oCurrentPage.WriteImage(m_oImageManager.WriteImage(sVal), fX, fY, fWidth, fHeight);
|
||||
m_oCurrentPage.WriteImage(m_oImageManager.WriteImage(sVal, fX, fY, fWidth, fHeight), fX, fY, fWidth, fHeight);
|
||||
return S_OK;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
@ -40,7 +40,6 @@ namespace NSDocxRenderer
|
||||
LONG m_lNumberPages{0};
|
||||
|
||||
bool m_bIsDisablePageCommand {false}; // disable commands inside draw function
|
||||
bool m_bIsRecord {true};
|
||||
|
||||
NSStringUtils::CStringBuilder m_oPageBuilder;
|
||||
std::list<std::string> m_arXmlString;
|
||||
|
||||
@ -70,8 +70,6 @@ namespace NSDocxRenderer
|
||||
m_oContBuilder.Clear();
|
||||
m_arCompleteObjectsXml.clear();
|
||||
m_arLuminosityShapes.clear();
|
||||
|
||||
m_bFontSubstitution = false;
|
||||
}
|
||||
|
||||
CPage::~CPage()
|
||||
@ -195,17 +193,14 @@ namespace NSDocxRenderer
|
||||
|
||||
if (!m_arShapes.empty())
|
||||
{
|
||||
auto& last_shape = m_arShapes.back();
|
||||
if (last_shape->IsEqual(top, bot, left, right) && rotation == last_shape->m_dRotation && lType != m_lLastType && m_lLastType != 0)
|
||||
auto& last_shape = m_arShapes.back();
|
||||
if (last_shape->IsEqual(top, bot, left, right) && rotation == last_shape->m_dRotation)
|
||||
{
|
||||
set_fill_mode(last_shape);
|
||||
// Reset stroke/fill logic
|
||||
m_lLastType = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_lLastType = lType;
|
||||
auto shape = std::make_shared<CShape>();
|
||||
shape->m_oPen.Size *= transform_det;
|
||||
set_fill_mode(shape);
|
||||
@ -273,14 +268,10 @@ namespace NSDocxRenderer
|
||||
|
||||
if (!skip_shape)
|
||||
{
|
||||
shape->m_nOrder = ++m_nCurrentOrder;
|
||||
shape->m_nOrder = ++m_nShapeOrder;
|
||||
m_arShapes.push_back(shape);
|
||||
}
|
||||
}
|
||||
bool CPage::IsCurrVectorClockwise() const
|
||||
{
|
||||
return m_oCurrVectorGraphics.IsClockwise();
|
||||
}
|
||||
|
||||
void CPage::AddText(
|
||||
const PUINT pUnicodes,
|
||||
@ -336,15 +327,13 @@ namespace NSDocxRenderer
|
||||
m_oManagers.pFontManager->SetStringGid(0);
|
||||
m_oManagers.pFontManager->MeasureStringGids(pUnicodes, nCount, dTextX, dTextY, _x, _y, _w, _h, CFontManager::mtPosition);
|
||||
}
|
||||
_h = m_oManagers.pFontManager->GetFontHeight();
|
||||
double baseline = dTextY + fBaseLineOffset;
|
||||
|
||||
_h = m_oManagers.pFontManager->GetFontHeight();
|
||||
|
||||
double baseline = dTextY + fBaseLineOffset;
|
||||
double top = baseline - _h;
|
||||
double left = dTextX;
|
||||
double right = dTextR;
|
||||
|
||||
if (left == right) // XPS
|
||||
right = left + _w;
|
||||
double right = left + _w;
|
||||
|
||||
// use forced fold option
|
||||
const auto& oParams = m_oManagers.pFontManager->GetFontSelectParams();
|
||||
@ -353,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()
|
||||
@ -496,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;
|
||||
});
|
||||
}
|
||||
@ -652,8 +627,20 @@ namespace NSDocxRenderer
|
||||
{
|
||||
for (auto& line : m_arTextLines)
|
||||
for (auto& cont : line->m_arConts)
|
||||
if (cont && !m_bUseDefaultFont)
|
||||
cont->CalcSelected();
|
||||
{
|
||||
if (cont && cont->m_oSelectedSizes.dHeight == 0.0 && cont->m_oSelectedSizes.dWidth == 0.0)
|
||||
{
|
||||
if (m_bUseDefaultFont)
|
||||
{
|
||||
cont->m_oSelectedSizes.dHeight = cont->m_dHeight;
|
||||
cont->m_oSelectedSizes.dWidth = cont->m_dWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
cont->CalcSelected();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPage::AnalyzeShapes()
|
||||
@ -766,19 +753,6 @@ namespace NSDocxRenderer
|
||||
if (line && line->m_arConts.empty())
|
||||
line = nullptr;
|
||||
|
||||
for (auto& line : m_arTextLines)
|
||||
if (line)
|
||||
{
|
||||
bool is_remove = true;
|
||||
for(auto& cont : line->m_arConts)
|
||||
if (cont && !cont->IsOnlySpaces())
|
||||
is_remove = false;
|
||||
|
||||
if (is_remove)
|
||||
line = nullptr;
|
||||
}
|
||||
|
||||
|
||||
auto right = MoveNullptr(m_arTextLines.begin(), m_arTextLines.end());
|
||||
m_arTextLines.erase(right, m_arTextLines.end());
|
||||
|
||||
@ -847,8 +821,7 @@ namespace NSDocxRenderer
|
||||
// шейпы из буквиц
|
||||
for (auto&& drop_cap : drop_caps)
|
||||
{
|
||||
if (!m_bUseDefaultFont)
|
||||
drop_cap->CalcSelected();
|
||||
drop_cap->CalcSelected();
|
||||
|
||||
auto line = std::make_shared<CTextLine>();
|
||||
line->AddCont(drop_cap);
|
||||
@ -910,9 +883,7 @@ namespace NSDocxRenderer
|
||||
pNextLine->m_pLine = pCurrLine;
|
||||
}
|
||||
}
|
||||
else if (!is_font_effect && pCurrCont->IsDuplicate(pNextCont.get(), eVType, eHType)
|
||||
&& (fabs(pCurrCont->m_dLeft - pNextCont->m_dLeft) < c_dTHE_STRING_X_PRECISION_MM ||
|
||||
fabs(pCurrCont->m_dRight - pNextCont->m_dRight) < c_dTHE_STRING_X_PRECISION_MM))
|
||||
else if (!is_font_effect && pCurrCont->IsDuplicate(pNextCont.get(), eVType, eHType))
|
||||
{
|
||||
pNextCont = nullptr;
|
||||
pCurrCont->m_iNumDuplicates++;
|
||||
@ -1181,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;
|
||||
@ -1366,21 +1331,6 @@ namespace NSDocxRenderer
|
||||
|
||||
return IsHorizontalLineTrough(dummy_cont);
|
||||
}
|
||||
bool CPage::IsTextLineBetween(text_line_ptr_t pFirst, text_line_ptr_t pSecond) const noexcept
|
||||
{
|
||||
double left = std::min(pFirst->m_dLeft, pSecond->m_dLeft);
|
||||
double right = std::max(pFirst->m_dRight, pSecond->m_dRight);
|
||||
double top = std::min(pFirst->m_dBotWithMaxDescent, pSecond->m_dBotWithMaxDescent);
|
||||
double bot = std::max(pFirst->m_dTopWithMaxAscent, pSecond->m_dTopWithMaxAscent);
|
||||
|
||||
auto dummy_cont = std::make_shared<CContText>();
|
||||
dummy_cont->m_dLeft = left - c_dGRAPHICS_ERROR_MM;
|
||||
dummy_cont->m_dRight = right + c_dGRAPHICS_ERROR_MM;
|
||||
dummy_cont->m_dTop = top - c_dGRAPHICS_ERROR_MM;
|
||||
dummy_cont->m_dBot = bot + c_dGRAPHICS_ERROR_MM;
|
||||
|
||||
return IsTextLineTrough(dummy_cont);
|
||||
}
|
||||
|
||||
bool CPage::IsVerticalLineTrough(base_item_ptr_t pFirst) const noexcept
|
||||
{
|
||||
@ -1389,9 +1339,7 @@ namespace NSDocxRenderer
|
||||
const auto center = pFirst->m_dTop + height / 2;
|
||||
|
||||
for (const auto& line : ver_lines)
|
||||
if (line.pos - pFirst->m_dLeft > c_dGRAPHICS_ERROR_IN_LINES_MM &&
|
||||
pFirst->m_dRight - line.pos > c_dGRAPHICS_ERROR_IN_LINES_MM &&
|
||||
line.min <= center && line.max >= center)
|
||||
if (line.pos > pFirst->m_dLeft && line.pos < pFirst->m_dRight && line.min <= center && line.max >= center)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -1408,20 +1356,6 @@ namespace NSDocxRenderer
|
||||
|
||||
return false;
|
||||
}
|
||||
bool CPage::IsTextLineTrough(base_item_ptr_t pFirst) const noexcept
|
||||
{
|
||||
const auto width = pFirst->m_dRight - pFirst->m_dLeft;
|
||||
const auto center = pFirst->m_dLeft + width / 2;
|
||||
|
||||
for (const auto& text_line : m_arShapes)
|
||||
if (text_line && text_line->m_eType == CShape::eShapeType::stTextBox && text_line->m_dBot > pFirst->m_dTop &&
|
||||
text_line->m_dBot < pFirst->m_dBot &&
|
||||
text_line->m_dLeft <= center &&
|
||||
text_line->m_dRight >= center)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPage::SplitLines()
|
||||
{
|
||||
@ -1491,7 +1425,7 @@ namespace NSDocxRenderer
|
||||
|
||||
for (const auto& line : m_arTextLines)
|
||||
{
|
||||
if (fabs(line->m_dBot - curr_bot) < 4 * c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
if (fabs(line->m_dBotWithMaxDescent - curr_bot) < 4 * c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
{
|
||||
bot_aligned_text_lines.back().push_back(line);
|
||||
}
|
||||
@ -1499,7 +1433,7 @@ namespace NSDocxRenderer
|
||||
{
|
||||
bot_aligned_text_lines.push_back({});
|
||||
bot_aligned_text_lines.back().push_back(line);
|
||||
curr_bot = line->m_dBot;
|
||||
curr_bot = line->m_dBotWithMaxDescent;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1617,12 +1551,10 @@ namespace NSDocxRenderer
|
||||
curr_line->CalcFirstWordWidth();
|
||||
|
||||
for (auto& cont : prev_line->m_arConts)
|
||||
if (!m_bUseDefaultFont)
|
||||
cont->CalcSelected();
|
||||
cont->CalcSelected();
|
||||
|
||||
for (auto& cont : curr_line->m_arConts)
|
||||
if (!m_bUseDefaultFont)
|
||||
cont->CalcSelected();
|
||||
cont->CalcSelected();
|
||||
|
||||
m_arShapes.push_back(CreateSingleLineShape(prev_line));
|
||||
m_arShapes.push_back(CreateSingleLineShape(curr_line));
|
||||
@ -1654,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) {
|
||||
|
||||
std::shared_ptr<CTextLine>& firstLine = paragraph->m_arTextLines.front();
|
||||
paragraph->m_dBot = paragraph->m_arTextLines.back()->m_dBotWithMaxDescent;
|
||||
paragraph->m_dTop = firstLine->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;
|
||||
|
||||
@ -1673,23 +1604,6 @@ namespace NSDocxRenderer
|
||||
|
||||
paragraph->MergeLines();
|
||||
|
||||
// Correct first line position
|
||||
double firstLine_height = firstLine->m_dBotWithMaxDescent - firstLine->m_dTopWithMaxAscent;
|
||||
if (paragraph->m_dLineHeight > firstLine_height)
|
||||
{
|
||||
double offset = paragraph->m_dLineHeight - firstLine_height;
|
||||
paragraph->m_dTop -= offset;
|
||||
paragraph->m_dBot -= offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
double ascent = firstLine->m_dBot - firstLine->m_dTopWithMaxAscent;
|
||||
double newAscent = ascent * paragraph->m_dLineHeight / firstLine_height;
|
||||
double offset = ascent - newAscent;
|
||||
paragraph->m_dTop += offset;
|
||||
paragraph->m_dBot += offset;
|
||||
}
|
||||
|
||||
// setting TextAlignmentType
|
||||
if (paragraph->m_arTextLines.size() > 1)
|
||||
{
|
||||
@ -1751,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) {
|
||||
@ -1912,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
|
||||
@ -1959,8 +1859,10 @@ namespace NSDocxRenderer
|
||||
|
||||
if (position.right && !position.left)
|
||||
diff = line_with_first_left - curr_min_left;
|
||||
else if (position.left || ar_indents[index] || position.center)
|
||||
else if (position.left || ar_indents[index])
|
||||
diff = curr_max_right - line_with_first_right;
|
||||
else if (position.center)
|
||||
continue;
|
||||
|
||||
if (diff <= 0)
|
||||
continue;
|
||||
@ -1985,8 +1887,6 @@ namespace NSDocxRenderer
|
||||
{
|
||||
if (IsHorizontalLineBetween(text_lines[index], text_lines[index + 1]))
|
||||
ar_delims[index] = true;
|
||||
if (IsTextLineBetween(text_lines[index], text_lines[index + 1]))
|
||||
ar_delims[index] = true;
|
||||
}
|
||||
|
||||
// на основе ar_delims разбиваем на параграфы
|
||||
@ -2339,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)
|
||||
@ -2619,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_dBotWithMaxDescent;
|
||||
pParagraph->m_dTop = pLine->m_dTop;
|
||||
pParagraph->m_dBot = pLine->m_dBot;
|
||||
pParagraph->m_dWidth = pLine->m_dWidth;
|
||||
pParagraph->m_dHeight = pLine->m_dBotWithMaxDescent - pLine->m_dTopWithMaxAscent;
|
||||
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)
|
||||
{
|
||||
@ -2639,12 +2537,11 @@ namespace NSDocxRenderer
|
||||
pShape->m_eType = CShape::eShapeType::stTextBox;
|
||||
|
||||
pShape->m_dLeft = pParagraph->m_dLeft;
|
||||
pShape->m_dRight = pParagraph->m_dRight * 1.025;
|
||||
pShape->m_dTop = pParagraph->m_dTop;
|
||||
pShape->m_dBot = pParagraph->m_dBot;
|
||||
pShape->m_dWidth = pShape->m_dRight - pShape->m_dLeft;
|
||||
pShape->m_dWidth = pParagraph->m_dWidth;
|
||||
pShape->m_dHeight = pParagraph->m_dHeight;
|
||||
pShape->m_nOrder = pParagraph->m_nOrder;
|
||||
pShape->m_dRight = pParagraph->m_dRight;
|
||||
pShape->m_bIsBehindDoc = false;
|
||||
|
||||
return pShape;
|
||||
@ -2655,13 +2552,11 @@ namespace NSDocxRenderer
|
||||
auto pShape = std::make_shared<CShape>();
|
||||
|
||||
pShape->m_dLeft = pParagraph->m_dLeft;
|
||||
pShape->m_dRight = pParagraph->m_dRight;
|
||||
if (pParagraph->m_arTextLines.size() == 1) pShape->m_dRight *= 1.025;
|
||||
pShape->m_dTop = pParagraph->m_dTop;
|
||||
pShape->m_dRight = pParagraph->m_dRight;
|
||||
pShape->m_dBot = pParagraph->m_dBot;
|
||||
pShape->m_dHeight = pParagraph->m_dHeight;
|
||||
pShape->m_dWidth = pShape->m_dRight - pShape->m_dLeft;
|
||||
pShape->m_nOrder = pParagraph->m_nOrder;
|
||||
pShape->m_dWidth = pParagraph->m_dWidth;
|
||||
|
||||
if (pParagraph->m_bIsNeedFirstLineIndent && pParagraph->m_dFirstLine < 0)
|
||||
pParagraph->m_dLeftBorder = -pParagraph->m_dFirstLine;
|
||||
|
||||
@ -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();
|
||||
@ -68,7 +66,6 @@ namespace NSDocxRenderer
|
||||
void PathEnd();
|
||||
void PathClose();
|
||||
void DrawPath(LONG lType, const std::shared_ptr<CImageInfo> pInfo);
|
||||
bool IsCurrVectorClockwise() const;
|
||||
|
||||
void AddText(
|
||||
const PUINT pUnicodes,
|
||||
@ -195,11 +192,9 @@ namespace NSDocxRenderer
|
||||
|
||||
bool IsVerticalLineBetween(text_line_ptr_t pFirst, text_line_ptr_t pSecond) const noexcept;
|
||||
bool IsHorizontalLineBetween(text_line_ptr_t pFirst, text_line_ptr_t pSecond) const noexcept;
|
||||
bool IsTextLineBetween(text_line_ptr_t pFirst, text_line_ptr_t pSecond) const noexcept;
|
||||
|
||||
bool IsVerticalLineTrough(base_item_ptr_t pFirst) const noexcept;
|
||||
bool IsHorizontalLineTrough(base_item_ptr_t pFirst) const noexcept;
|
||||
bool IsTextLineTrough(base_item_ptr_t pFirst) const noexcept;
|
||||
|
||||
void ToXml(NSStringUtils::CStringBuilder& oWriter) const noexcept;
|
||||
void WriteSectionToFile(bool bLastPage, NSStringUtils::CStringBuilder& oWriter) const noexcept;
|
||||
@ -234,8 +229,6 @@ namespace NSDocxRenderer
|
||||
std::vector<shape_ptr_t> m_arLuminosityShapes;
|
||||
std::vector<shape_ptr_t> m_arOneColorGradientShape;
|
||||
|
||||
long m_lLastType = 0;
|
||||
|
||||
size_t m_nCurrentOrder = 0;
|
||||
size_t m_nShapeOrder = 0;
|
||||
};
|
||||
}
|
||||
|
||||
@ -178,10 +178,7 @@ namespace NSDocxRenderer
|
||||
}
|
||||
bool CBaseItem::IsEqual(double dTop, double dBot, double dLeft, double dRight) const noexcept
|
||||
{
|
||||
return fabs(m_dLeft - dLeft) < c_dGRAPHICS_ERROR_MM &&
|
||||
fabs(m_dTop - dTop) < c_dGRAPHICS_ERROR_MM &&
|
||||
fabs(m_dBot - dBot) < c_dGRAPHICS_ERROR_MM &&
|
||||
fabs(m_dRight - dRight) < c_dGRAPHICS_ERROR_MM;
|
||||
return m_dLeft == dLeft && m_dTop == dTop && m_dBot == dBot && m_dRight == dRight;
|
||||
}
|
||||
bool CBaseItem::operator==(const CBaseItem& other)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -73,27 +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;
|
||||
m_dSpacing = rCont.m_dSpacing;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -101,6 +85,7 @@ namespace NSDocxRenderer
|
||||
{
|
||||
if (!m_pFontStyle->wsFontName.empty() && !m_oText.empty())
|
||||
{
|
||||
// нужно перемерять...
|
||||
if (m_oSelectedFont.Path.empty())
|
||||
m_pManager->LoadFontByName(m_oSelectedFont);
|
||||
else
|
||||
@ -121,7 +106,6 @@ namespace NSDocxRenderer
|
||||
|
||||
m_oSelectedSizes.dWidth = dBoxWidth;
|
||||
m_oSelectedSizes.dHeight = dBoxHeight;
|
||||
m_dSpacing = (m_dWidth - m_oSelectedSizes.dWidth) / (m_oText.length());
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,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;
|
||||
@ -208,34 +178,34 @@ namespace NSDocxRenderer
|
||||
return eVerticalCrossingType::vctCurrentInsideNext;
|
||||
|
||||
else if (this_top < other_top && this_bot > other_bot)
|
||||
return eVerticalCrossingType::vctCurrentOutsideNext;
|
||||
return eVerticalCrossingType::vctCurrentOutsideNext;
|
||||
|
||||
else if (this_top < other_top && this_bot < other_bot && this_bot > other_top &&
|
||||
this_bot - other_top > c_dOVERLAP_TEXT_LINE_ERROR_MM)
|
||||
return eVerticalCrossingType::vctCurrentAboveNext;
|
||||
else if (this_top < other_top && this_bot < other_bot &&
|
||||
(this_bot >= other_top || fabs(this_bot - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
|
||||
return eVerticalCrossingType::vctCurrentAboveNext;
|
||||
|
||||
else if (this_top > other_top && this_bot > other_bot && this_top < other_bot &&
|
||||
other_bot - this_top > c_dOVERLAP_TEXT_LINE_ERROR_MM)
|
||||
return eVerticalCrossingType::vctCurrentBelowNext;
|
||||
else if (this_top > other_top && this_bot > other_bot &&
|
||||
(this_top <= other_bot || fabs(this_top - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM))
|
||||
return eVerticalCrossingType::vctCurrentBelowNext;
|
||||
|
||||
else if (this_top == other_top && this_bot == other_bot)
|
||||
return eVerticalCrossingType::vctDublicate;
|
||||
|
||||
else if (fabs(this_top - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM &&
|
||||
fabs(this_bot - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
return eVerticalCrossingType::vctTopAndBottomBordersMatch;
|
||||
return eVerticalCrossingType::vctTopAndBottomBordersMatch;
|
||||
|
||||
else if (fabs(this_top - other_top) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
return eVerticalCrossingType::vctTopBorderMatch;
|
||||
return eVerticalCrossingType::vctTopBorderMatch;
|
||||
|
||||
else if (fabs(this_bot - other_bot) < c_dTHE_SAME_STRING_Y_PRECISION_MM)
|
||||
return eVerticalCrossingType::vctBottomBorderMatch;
|
||||
return eVerticalCrossingType::vctBottomBorderMatch;
|
||||
|
||||
else if (other_top - this_bot > -c_dOVERLAP_TEXT_LINE_ERROR_MM)
|
||||
return eVerticalCrossingType::vctNoCrossingCurrentAboveNext;
|
||||
else if (this_bot < other_top)
|
||||
return eVerticalCrossingType::vctNoCrossingCurrentAboveNext;
|
||||
|
||||
else if (this_top - other_bot > -c_dOVERLAP_TEXT_LINE_ERROR_MM)
|
||||
return eVerticalCrossingType::vctNoCrossingCurrentBelowNext;
|
||||
else if (this_top > other_bot)
|
||||
return eVerticalCrossingType::vctNoCrossingCurrentBelowNext;
|
||||
|
||||
else
|
||||
return eVerticalCrossingType::vctUnknown;
|
||||
@ -259,11 +229,18 @@ namespace NSDocxRenderer
|
||||
|
||||
LONG lCalculatedSpacing = 0;
|
||||
|
||||
// mm to points * 20
|
||||
if (!m_oText.empty())
|
||||
lCalculatedSpacing = static_cast<LONG>(m_dSpacing * c_dMMToDx);
|
||||
{
|
||||
double dSpacing = (m_dWidth - m_oSelectedSizes.dWidth) / (m_oText.length());
|
||||
dSpacing *= c_dMMToDx;
|
||||
|
||||
//mm to points * 20
|
||||
lCalculatedSpacing = static_cast<LONG>(dSpacing);
|
||||
}
|
||||
|
||||
// принудительно уменьшаем spacing чтобы текстовые линии не выходили за правую границу
|
||||
lCalculatedSpacing -= 1;
|
||||
|
||||
if (lCalculatedSpacing != 0)
|
||||
{
|
||||
oWriter.WriteString(L"<w:spacing w:val=\"");
|
||||
@ -390,7 +367,14 @@ namespace NSDocxRenderer
|
||||
|
||||
LONG lCalculatedSpacing = 0;
|
||||
if (!m_oText.empty())
|
||||
lCalculatedSpacing = static_cast<LONG>(m_dSpacing * c_dMMToPt * 100);
|
||||
{
|
||||
double dSpacing = (m_dWidth - m_oSelectedSizes.dWidth) / (m_oText.length());
|
||||
dSpacing *= c_dMMToPt * 100;
|
||||
lCalculatedSpacing = static_cast<LONG>(dSpacing);
|
||||
}
|
||||
|
||||
// принудительно уменьшаем spacing чтобы текстовые линии не выходили за правую границу
|
||||
lCalculatedSpacing -= 15;
|
||||
|
||||
oWriter.WriteString(L" spc=\"");
|
||||
oWriter.AddInt(lCalculatedSpacing);
|
||||
@ -486,49 +470,36 @@ 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
|
||||
{
|
||||
int lCalculatedSpacing = 0;
|
||||
if (!m_oText.empty())
|
||||
lCalculatedSpacing = static_cast<LONG>(m_dSpacing * c_dMMToPt * 100);
|
||||
{
|
||||
double dSpacing = (m_dWidth - m_oSelectedSizes.dWidth) / (m_oText.length());
|
||||
dSpacing *= c_dMMToPt * 100;
|
||||
lCalculatedSpacing = static_cast<LONG>(dSpacing);
|
||||
}
|
||||
lCalculatedSpacing -= 15;
|
||||
|
||||
const BYTE kPARRUN_TYPE_RUN = 1;
|
||||
oWriter.StartRecord(kPARRUN_TYPE_RUN);
|
||||
@ -537,34 +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";";
|
||||
// add offset for last symbol
|
||||
if (!m_arSymWidths.empty())
|
||||
origin_lefts += std::to_wstring(static_cast<int>((m_arOriginLefts.back() + m_arSymWidths.back()) * 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);
|
||||
@ -661,7 +604,6 @@ namespace NSDocxRenderer
|
||||
|
||||
bool CContText::IsEqual(const CContText *pCont) const noexcept
|
||||
{
|
||||
bool bIf0 = IsFontsEqual(m_oSelectedFont, pCont->m_oSelectedFont);
|
||||
bool bIf1 = m_pFontStyle->wsFontStyleId == pCont->m_pFontStyle->wsFontStyleId;
|
||||
bool bIf2 = m_bIsStrikeoutPresent == pCont->m_bIsStrikeoutPresent;
|
||||
bool bIf3 = m_bIsDoubleStrikeout == pCont->m_bIsDoubleStrikeout;
|
||||
@ -678,7 +620,7 @@ namespace NSDocxRenderer
|
||||
bool bIf14 = m_eVertAlignType == eVertAlignType::vatUnknown && pCont->m_eVertAlignType == eVertAlignType::vatBase;
|
||||
bool bIf15 = m_eVertAlignType == eVertAlignType::vatBase && pCont->m_eVertAlignType == eVertAlignType::vatUnknown;
|
||||
|
||||
return (bIf0 && bIf1 && bIf2 && bIf3 && bIf4 && bIf5 && bIf6 && bIf7 &&
|
||||
return (bIf1 && bIf2 && bIf3 && bIf4 && bIf5 && bIf6 && bIf7 &&
|
||||
bIf8 && bIf9 && bIf10 && bIf11 && bIf12 && (bIf13 || bIf14 || bIf15));
|
||||
}
|
||||
|
||||
@ -722,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;
|
||||
@ -740,47 +679,22 @@ namespace NSDocxRenderer
|
||||
continue;
|
||||
}
|
||||
m_arSymWidths.push_back(w);
|
||||
m_dWidth += w;
|
||||
m_oText += oText.at(i);
|
||||
m_arOriginLefts.push_back(arOriginLefts[i]);
|
||||
m_dRight = arOriginLefts[i] + w;
|
||||
|
||||
if (!arGids.empty() && m_bCollectMetaInfo)
|
||||
m_arGids.push_back(arGids[i]);
|
||||
}
|
||||
m_dWidth = m_dRight - m_dLeft;
|
||||
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;
|
||||
|
||||
auto ar_sym_w = m_arSymWidths;
|
||||
m_arSymWidths = arSymWidths;
|
||||
|
||||
for (auto& w : ar_sym_w)
|
||||
m_arSymWidths.push_back(w);
|
||||
|
||||
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);
|
||||
|
||||
m_dLeft = m_arOriginLefts.back();
|
||||
m_dWidth = m_dRight - m_dLeft;
|
||||
}
|
||||
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();
|
||||
@ -791,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_dRight = dLeft + dWidth;
|
||||
m_dWidth = m_dRight - m_dLeft;
|
||||
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 = dLeft;
|
||||
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;
|
||||
@ -844,34 +738,13 @@ 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()
|
||||
{
|
||||
m_oText = m_oText.substr(0, m_oText.length() - 1);
|
||||
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_arOriginLefts.empty())
|
||||
m_dRight = m_arOriginLefts.back() + m_arSymWidths.back();
|
||||
else
|
||||
m_dRight = m_dLeft;
|
||||
|
||||
m_dWidth = m_dRight - m_dLeft;
|
||||
|
||||
if (!m_arGids.empty() && m_bCollectMetaInfo)
|
||||
m_arGids.resize(m_arGids.size() - 1);
|
||||
}
|
||||
uint32_t CContText::GetLastSym() const
|
||||
{
|
||||
@ -886,9 +759,16 @@ namespace NSDocxRenderer
|
||||
{
|
||||
return m_arSymWidths;
|
||||
}
|
||||
const std::vector<double>& CContText::GetSymLefts() const noexcept
|
||||
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
|
||||
@ -898,12 +778,12 @@ namespace NSDocxRenderer
|
||||
eHorizontalCrossingType eHType)
|
||||
{
|
||||
//Условие пересечения по вертикали
|
||||
bool bIf1 = eVType == eVerticalCrossingType::vctCurrentAboveNext;
|
||||
bool bIf2 = eVType == eVerticalCrossingType::vctCurrentBelowNext;
|
||||
bool bIf1 = eVType == eVerticalCrossingType::vctCurrentAboveNext; //текущий cont выше
|
||||
bool bIf2 = eVType == eVerticalCrossingType::vctCurrentBelowNext; //текущий cont ниже
|
||||
|
||||
//Условие пересечения по горизонтали
|
||||
bool bIf3 = eHType == eHorizontalCrossingType::hctCurrentLeftOfNext;
|
||||
bool bIf4 = eHType == eHorizontalCrossingType::hctCurrentRightOfNext;
|
||||
bool bIf3 = eHType == eHorizontalCrossingType::hctCurrentLeftOfNext; //текущий cont левее
|
||||
bool bIf4 = eHType == eHorizontalCrossingType::hctCurrentRightOfNext; //текущий cont правее
|
||||
|
||||
//Размеры шрифта и текст должны бать одинаковыми
|
||||
bool bIf5 = pFirstCont->m_pFontStyle->dFontSize == pSecondCont->m_pFontStyle->dFontSize;
|
||||
@ -919,7 +799,9 @@ namespace NSDocxRenderer
|
||||
bool bIf11 = pFirstCont->m_pFontStyle->oBrush.Color1 == c_iGreyColor2;
|
||||
bool bIf12 = pSecondCont->m_pFontStyle->oBrush.Color1 == c_iGreyColor2;
|
||||
|
||||
// каждый символ с Emboss или Engrave разбиваются на 3 символа с разными цветами
|
||||
//note Каждый символ с Emboss или Engrave разбиваются на 3 символа с разными цветами
|
||||
//note Логика подобрана для конкретного примера - возможно нужно будет ее обобщить.
|
||||
//todo существует проблема неправильного определением FontEffects с физически пересекаемыми строчками - файл generaltest.pdf p.14
|
||||
if (bIf5 && bIf6)
|
||||
{
|
||||
if (bIf12 && pFirstCont->m_bIsEmbossPresent)
|
||||
@ -979,20 +861,18 @@ namespace NSDocxRenderer
|
||||
eHorizontalCrossingType eHType)
|
||||
{
|
||||
|
||||
double first_height = pFirstCont->m_dBotWithDescent - pFirstCont->m_dTopWithAscent;
|
||||
bool bIf1 = eVType == eVerticalCrossingType::vctCurrentAboveNext ||
|
||||
eVType == eVerticalCrossingType::vctCurrentInsideNext &&
|
||||
pSecondCont->m_dBotWithDescent - pFirstCont->m_dBotWithDescent > first_height * 0.2;
|
||||
eVType == eVerticalCrossingType::vctCurrentInsideNext;
|
||||
|
||||
bool bIf2 = eVType == eVerticalCrossingType::vctCurrentBelowNext;
|
||||
|
||||
bool bIf3 = (eHType == eHorizontalCrossingType::hctNoCrossingCurrentLeftOfNext ||
|
||||
eHType == eHorizontalCrossingType::hctCurrentLeftOfNext) &&
|
||||
fabs(pFirstCont->m_dRight - pSecondCont->m_dLeft) < c_dTHE_STRING_X_PRECISION_MM;
|
||||
fabs(pFirstCont->m_dRight - pSecondCont->m_dLeft) < c_dTHE_STRING_X_PRECISION_MM * 3;
|
||||
|
||||
bool bIf4 = (eHType == eHorizontalCrossingType::hctNoCrossingCurrentRightOfNext ||
|
||||
eHType == eHorizontalCrossingType::hctCurrentRightOfNext) &&
|
||||
fabs(pFirstCont->m_dLeft - pSecondCont->m_dRight) < c_dTHE_STRING_X_PRECISION_MM;
|
||||
fabs(pFirstCont->m_dLeft - pSecondCont->m_dRight) < c_dTHE_STRING_X_PRECISION_MM * 3;
|
||||
|
||||
//Размеры шрифта должны бать разными
|
||||
bool bIf5 = pFirstCont->m_pFontStyle->dFontSize * 0.8 > pSecondCont->m_pFontStyle->dFontSize;
|
||||
@ -1094,19 +974,6 @@ namespace NSDocxRenderer
|
||||
{
|
||||
return 0x0300 <= cSym && 0x036F >= cSym;
|
||||
}
|
||||
bool CContText::IsFontsEqual(const NSStructures::CFont& oFont1, const NSStructures::CFont& oFont2)
|
||||
{
|
||||
bool res = oFont1.Name == oFont2.Name;
|
||||
res = res && oFont1.Path == oFont2.Path;
|
||||
res = res && oFont1.FaceIndex == oFont2.FaceIndex;
|
||||
res = res && oFont1.StringGID == oFont2.StringGID;
|
||||
res = res && oFont1.Size == oFont2.Size;
|
||||
res = res && oFont1.Bold == oFont2.Bold;
|
||||
res = res && oFont1.Italic == oFont2.Italic;
|
||||
res = res && oFont1.Underline == oFont2.Underline;
|
||||
res = res && oFont1.Strikeout == oFont2.Strikeout;
|
||||
return res;
|
||||
}
|
||||
|
||||
double CContText::CalculateSpace() const noexcept
|
||||
{
|
||||
@ -1137,81 +1004,55 @@ 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();
|
||||
for (size_t i = 0; i < oText.length(); ++i)
|
||||
if (oText.at(i) == c_SPACE_SYM)
|
||||
m_pCurrCont->m_pFontStyle->UpdateAvgSpaceWidth(avg_width);
|
||||
|
||||
double avg_space_width = m_pCurrCont->m_pFontStyle->GetAvgSpaceWidth();
|
||||
double space_width =
|
||||
avg_space_width != 0.0 ?
|
||||
avg_space_width * c_dAVERAGE_SPACE_WIDTH_COEF :
|
||||
m_pCurrCont->CalculateSpace() * c_dSPACE_WIDTH_COEF;
|
||||
|
||||
double spacing = dLeft - m_dPrevRight;
|
||||
bool is_added = false;
|
||||
bool diff_spacing = false;
|
||||
|
||||
// set spacing at the second symbol
|
||||
if (m_pCurrCont->GetLength() == 1)
|
||||
m_pCurrCont->m_dSpacing = spacing;
|
||||
|
||||
if (fabs(spacing - m_pCurrCont->m_dSpacing) > c_dTHE_SAME_SPACING_ERROR)
|
||||
diff_spacing = true;
|
||||
|
||||
// some_text+more_text
|
||||
if (!diff_spacing && fabs(m_pCurrCont->m_dRight - dLeft) < space_width && dRight > m_pCurrCont->m_dRight)
|
||||
if (fabs(m_pCurrCont->m_dRight - dLeft) < space_width && dRight > m_pCurrCont->m_dRight)
|
||||
{
|
||||
double left_avg_width = (dRight - m_pCurrCont->m_dRight) / oText.length();
|
||||
std::vector<double> ar_widths;
|
||||
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;
|
||||
|
||||
}
|
||||
// more_text+some_text
|
||||
else if (diff_spacing && fabs(m_pCurrCont->m_dLeft - dRight) < space_width && dLeft < m_pCurrCont->m_dLeft)
|
||||
else if (fabs(m_pCurrCont->m_dLeft - dRight) < space_width && dLeft < m_pCurrCont->m_dLeft)
|
||||
{
|
||||
double right_avg_width = (m_pCurrCont->m_dLeft - dLeft) / oText.length();
|
||||
std::vector<double> ar_widths;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1221,8 +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;
|
||||
m_dPrevRight = dRight;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1246,31 +1085,29 @@ namespace NSDocxRenderer
|
||||
m_pFontSelector->IsSelectedItalic(),
|
||||
m_pFontSelector->IsSelectedBold() || bForcedBold);
|
||||
|
||||
double avg_width = dWidth / oText.length();
|
||||
for (size_t i = 0; i < oText.length(); ++i)
|
||||
if (oText.at(i) == c_SPACE_SYM)
|
||||
pCont->m_pFontStyle->UpdateAvgSpaceWidth(avg_width);
|
||||
|
||||
// just in case if oText contains more than 1 symbol
|
||||
std::vector<double> ar_widths;
|
||||
double avg_width = abs(dRight - dLeft) / oText.length();
|
||||
for (size_t i = 0; i < oText.length(); ++i)
|
||||
{
|
||||
if (oText.at(i) == c_SPACE_SYM) pCont->m_pFontStyle->UpdateAvgSpaceWidth(avg_width);
|
||||
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;
|
||||
pCont->m_dRight = dRight;
|
||||
|
||||
double ascent = pFontManager->GetFontAscent();
|
||||
double descent = pFontManager->GetFontDescent();
|
||||
double font_size = oFont.Size;
|
||||
double em_height = oMetrics.dEmHeight;
|
||||
double ratio = font_size / em_height * c_dPtToMM;
|
||||
|
||||
pCont->m_dTopWithAscent = pCont->m_dBot - ascent;
|
||||
pCont->m_dBotWithDescent = pCont->m_dBot + fabs(descent);
|
||||
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)
|
||||
{
|
||||
@ -1287,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())
|
||||
{
|
||||
@ -1302,7 +1137,6 @@ namespace NSDocxRenderer
|
||||
m_pCurrCont = pCont;
|
||||
m_oPrevFont = oFont;
|
||||
m_oPrevBrush = oBrush;
|
||||
m_dPrevRight = dRight;
|
||||
}
|
||||
|
||||
void CContTextBuilder::NullCurrCont()
|
||||
|
||||
@ -63,11 +63,9 @@ namespace NSDocxRenderer
|
||||
|
||||
// origin font
|
||||
std::wstring m_wsOriginFontName{};
|
||||
int m_nOriginFontFaceIndex{};
|
||||
|
||||
// sizes
|
||||
double m_dSpaceWidthMM{0};
|
||||
double m_dSpacing{0};
|
||||
CSelectedSizes m_oSelectedSizes{};
|
||||
|
||||
double m_dTopWithAscent{0};
|
||||
@ -78,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) {}
|
||||
@ -99,30 +92,20 @@ 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;
|
||||
|
||||
const NSStringUtils::CStringUTF32& GetText() const noexcept;
|
||||
const std::vector<double>& GetSymWidths() const noexcept;
|
||||
const std::vector<double>& GetSymLefts() const noexcept;
|
||||
const std::vector<double> GetSymLefts() const noexcept;
|
||||
|
||||
std::shared_ptr<CContText> Split(size_t index);
|
||||
std::shared_ptr<CContText> Split(double dLeft);
|
||||
@ -159,8 +142,6 @@ namespace NSDocxRenderer
|
||||
static bool IsUnicodeSymbol(uint32_t symbol);
|
||||
static bool IsUnicodeDiacriticalMark(uint32_t symbol);
|
||||
|
||||
static bool IsFontsEqual(const NSStructures::CFont& oFont1, const NSStructures::CFont& oFont2);
|
||||
|
||||
private:
|
||||
NSStringUtils::CStringUTF32 m_oText{};
|
||||
std::vector<double> m_arSymWidths{};
|
||||
@ -191,18 +172,14 @@ 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();
|
||||
private:
|
||||
|
||||
private:
|
||||
std::vector<cont_ptr_t> m_arConts;
|
||||
std::vector<cont_ptr_t> m_arDiacs;
|
||||
|
||||
@ -213,6 +190,5 @@ namespace NSDocxRenderer
|
||||
|
||||
CFontStyleManager* m_pFontStyleManager {nullptr};
|
||||
CFontSelector* m_pFontSelector {nullptr};
|
||||
double m_dPrevRight = 0;
|
||||
};
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user