diff --git a/Common/3dParty/html/css/src/CCssCalculator.cpp b/Common/3dParty/html/css/src/CCssCalculator.cpp
index bedad66c89..dee295f56c 100644
--- a/Common/3dParty/html/css/src/CCssCalculator.cpp
+++ b/Common/3dParty/html/css/src/CCssCalculator.cpp
@@ -13,14 +13,14 @@ namespace NSCSS
delete m_pInternal;
}
- CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector &arSelectors, const bool& bIsSettings, const UnitMeasure& unitMeasure) const
+ CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector &arSelectors) const
{
- return m_pInternal->GetCompiledStyle(arSelectors, bIsSettings, unitMeasure);
+ return m_pInternal->GetCompiledStyle(arSelectors);
}
- bool CCssCalculator::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector &arSelectors, const bool &bIsSettings, const UnitMeasure &unitMeasure) const
+ bool CCssCalculator::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector &arSelectors) const
{
- return m_pInternal->GetCompiledStyle(oStyle, arSelectors, bIsSettings, unitMeasure);
+ return m_pInternal->GetCompiledStyle(oStyle, arSelectors);
}
std::wstring CCssCalculator::CalculateStyleId(const CNode& oNode)
@@ -48,26 +48,11 @@ namespace NSCSS
m_pInternal->AddStylesFromFile(wsFileName);
}
- void CCssCalculator::SetUnitMeasure(const UnitMeasure& nType)
- {
- m_pInternal->SetUnitMeasure(nType);
- }
-
void CCssCalculator::SetDpi(const unsigned short int& nValue)
{
m_pInternal->SetDpi(nValue);
}
- void CCssCalculator::SetBodyTree(const CTree &oTree)
- {
- m_pInternal->SetBodyTree(oTree);
- }
-
- UnitMeasure CCssCalculator::GetUnitMeasure() const
- {
- return m_pInternal->GetUnitMeasure();
- }
-
std::wstring CCssCalculator::GetEncoding() const
{
return m_pInternal->GetEncoding();
diff --git a/Common/3dParty/html/css/src/CCssCalculator.h b/Common/3dParty/html/css/src/CCssCalculator.h
index 564adaa686..a6a0103e02 100644
--- a/Common/3dParty/html/css/src/CCssCalculator.h
+++ b/Common/3dParty/html/css/src/CCssCalculator.h
@@ -19,8 +19,8 @@ namespace NSCSS
CCssCalculator();
~CCssCalculator();
- CCompiledStyle GetCompiledStyle(const std::vector &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point) const;
- bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point) const;
+ CCompiledStyle GetCompiledStyle(const std::vector &arSelectors) const;
+ bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector &arSelectors) const;
std::wstring CalculateStyleId(const CNode& oNode);
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector &arSelectors);
@@ -30,11 +30,8 @@ namespace NSCSS
void AddStyles (const std::wstring& wsStyle);
void AddStylesFromFile(const std::wstring& wsFileName);
- void SetUnitMeasure(const UnitMeasure& nType);
void SetDpi(const unsigned short int& nValue);
- void SetBodyTree(const CTree &oTree);
- UnitMeasure GetUnitMeasure() const;
std::wstring GetEncoding() const;
unsigned short int GetDpi() const;
diff --git a/Common/3dParty/html/css/src/CCssCalculator_Private.cpp b/Common/3dParty/html/css/src/CCssCalculator_Private.cpp
index 25d13673ee..9850a43162 100644
--- a/Common/3dParty/html/css/src/CCssCalculator_Private.cpp
+++ b/Common/3dParty/html/css/src/CCssCalculator_Private.cpp
@@ -41,7 +41,7 @@ bool operator<(const std::vector &arLeftSelectors, const std::vect
namespace NSCSS
{
- CCssCalculator_Private::CCssCalculator_Private() : m_nDpi(96), m_nCountNodes(0), m_UnitMeasure(Point), m_mStatictics(NULL), m_sEncoding(L"UTF-8"){}
+ CCssCalculator_Private::CCssCalculator_Private() : m_nDpi(96), m_nCountNodes(0), m_sEncoding(L"UTF-8"){}
CCssCalculator_Private::~CCssCalculator_Private()
{
@@ -52,9 +52,6 @@ namespace NSCSS
delete oIter->second;
m_mData.clear();
-
- if (NULL != m_mStatictics)
- delete m_mStatictics;
}
inline void CCssCalculator_Private::GetOutputData(KatanaOutput *oOutput)
@@ -155,7 +152,7 @@ namespace NSCSS
arFindedElements.insert(arFindedElements.end(), arTempKins.begin(), arTempKins.end());
}
- std::vector CCssCalculator_Private::FindElements(std::vector &arNodes, std::vector &arNextNodes, bool bIsSettings)
+ std::vector CCssCalculator_Private::FindElements(std::vector &arNodes, std::vector &arNextNodes)
{
if (arNodes.empty())
return {};
@@ -193,17 +190,10 @@ namespace NSCSS
{
oFindId = m_mData.find(wsId);
- if (oFindId != m_mData.end() && NULL != m_mStatictics)
+ if (m_mData.cend() != oFindId)
{
- std::map::const_iterator oFindCountId = m_mStatictics->find(StatistickElement{StatistickElement::IsId, wsId});
-
- if ((m_mStatictics->end() != oFindCountId) &&
- (((bIsSettings && oFindCountId->second < MaxNumberRepetitions) ||
- (!bIsSettings && oFindCountId->second >= MaxNumberRepetitions))))
- {
- if (!oFindId->second->Empty())
- arFindedElements.push_back(oFindId->second);
- }
+ if (!oFindId->second->Empty())
+ arFindedElements.push_back(oFindId->second);
FindPrevAndKindElements(oFindId->second, arNextNodes, arFindedElements, wsName);
}
@@ -211,40 +201,34 @@ namespace NSCSS
if (!arClasses.empty())
{
- if (!bIsSettings)
+ for (std::vector::const_reverse_iterator iClass = arClasses.rbegin(); iClass != arClasses.rend(); ++iClass)
{
- for (std::vector::const_reverse_iterator iClass = arClasses.rbegin(); iClass != arClasses.rend(); ++iClass)
+ const std::map::const_iterator oFindClass = m_mData.find(*iClass);
+ if (oFindClass != m_mData.cend())
{
- const std::map::const_iterator oFindClass = m_mData.find(*iClass);
- if (oFindClass != m_mData.end())
- {
- if (!oFindClass->second->Empty())
- arFindedElements.push_back(oFindClass->second);
+ if (!oFindClass->second->Empty())
+ arFindedElements.push_back(oFindClass->second);
- FindPrevAndKindElements(oFindClass->second, arNextNodes, arFindedElements, wsName);
- }
+ FindPrevAndKindElements(oFindClass->second, arNextNodes, arFindedElements, wsName);
}
}
}
- if (oFindName != m_mData.end())
+ if (oFindName != m_mData.cend())
{
- if (!bIsSettings)
- {
- if (!oFindName->second->Empty())
- arFindedElements.push_back(oFindName->second);
+ if (!oFindName->second->Empty())
+ arFindedElements.push_back(oFindName->second);
- FindPrevAndKindElements(oFindName->second, arNextNodes, arFindedElements, wsName, arClasses);
- }
+ FindPrevAndKindElements(oFindName->second, arNextNodes, arFindedElements, wsName, arClasses);
}
if (arFindedElements.size() > 1)
{
std::sort(arFindedElements.rbegin(), arFindedElements.rend(),
- [](CElement* oFirstElement, CElement* oSecondElement)
- {
- return oFirstElement->GetWeight() > oSecondElement->GetWeight();
- });
+ [](CElement* oFirstElement, CElement* oSecondElement)
+ {
+ return oFirstElement->GetWeight() > oSecondElement->GetWeight();
+ });
}
return arFindedElements;
@@ -473,46 +457,32 @@ namespace NSCSS
}
#ifdef CSS_CALCULATOR_WITH_XHTML
- CCompiledStyle CCssCalculator_Private::GetCompiledStyle(const std::vector& arSelectors, const bool& bIsSettings, const UnitMeasure& unitMeasure)
+ CCompiledStyle CCssCalculator_Private::GetCompiledStyle(const std::vector& arSelectors)
{
if (arSelectors.empty())
return CCompiledStyle();
CCompiledStyle oStyle;
- GetCompiledStyle(oStyle, arSelectors, bIsSettings, unitMeasure);
+ GetCompiledStyle(oStyle, arSelectors);
return oStyle;
}
- bool CCssCalculator_Private::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector &arSelectors, const bool &bIsSettings, const UnitMeasure &unitMeasure)
+ bool CCssCalculator_Private::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector &arSelectors)
{
if (arSelectors.empty())
return false;
- SetUnitMeasure(unitMeasure);
+ const std::map, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
- if (!bIsSettings)
+ if (oItem != m_mUsedStyles.end())
{
- const std::map, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
-
- if (oItem != m_mUsedStyles.end())
- {
- oStyle = oItem->second;
- return true;
- }
- }
- else if (NULL == m_mStatictics || m_mStatictics->empty())
- {
- oStyle.SetDpi(m_nDpi);
- oStyle.SetUnitMeasure(m_UnitMeasure);
- oStyle.SetID(arSelectors.back().m_wsName + ((!arSelectors.back().m_wsClass.empty()) ? L'.' + arSelectors.back().m_wsClass : L"") + ((arSelectors.back().m_wsId.empty()) ? L"" : L'#' + arSelectors.back().m_wsId) + L'-' + std::to_wstring(++m_nCountNodes));
-
- return false;
+ oStyle = oItem->second;
+ return true;
}
oStyle.SetDpi(m_nDpi);
- oStyle.SetUnitMeasure(m_UnitMeasure);
std::vector arNodes = CalculateAllNodes(arSelectors);
std::vector arPrevNodes;
@@ -535,25 +505,10 @@ namespace NSCSS
oTempStyle.AddStyle(arSelectors[i].m_mAttributes, i + 1);
- for (const CElement* oElement : FindElements(arNodes, arPrevNodes, bIsSettings))
+ for (const CElement* oElement : FindElements(arNodes, arPrevNodes))
oTempStyle.AddStyle(oElement->GetStyle(), i + 1);
- if (NULL != m_mStatictics)
- {
- std::map::const_iterator oFindCountStyle = m_mStatictics->find(StatistickElement{StatistickElement::IsStyle, arSelectors[i].m_wsStyle});
-
- if (oFindCountStyle != m_mStatictics->end())
- {
- if ((bIsSettings && oFindCountStyle->second < MaxNumberRepetitions) ||
- (!bIsSettings && oFindCountStyle->second >= MaxNumberRepetitions))
- oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
- else if (!bIsSettings)
- oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
- }
- else /*if (bIsSettings)*/
- oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
- }
- else
+ if (!arSelectors[i].m_wsStyle.empty())
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
oStyle += oTempStyle;
@@ -569,7 +524,7 @@ namespace NSCSS
oStyle.SetID(CalculateStyleId(arSelectors.back()));
- if (!bIsSettings && !oStyle.Empty())
+ if (!oStyle.Empty())
m_mUsedStyles[arSelectors] = oStyle;
return true;
@@ -597,7 +552,7 @@ namespace NSCSS
SetPageData(oPageData, GetPageData(mRules[L"page"]), i + 1, true);
}
- for (const CElement* oElement : FindElements(arNodes, arNextNodes, false))
+ for (const CElement* oElement : FindElements(arNodes, arNextNodes))
{
std::map mRules = oElement->GetStyle();
if (mRules.end() != mRules.find(L"page"))
@@ -654,19 +609,6 @@ namespace NSCSS
m_nDpi = nValue;
}
- void CCssCalculator_Private::SetBodyTree(const CTree &oTree)
- {
- if (NULL == m_mStatictics)
- m_mStatictics = new std::map();
-
- CTree::CountingNumberRepetitions(oTree, *m_mStatictics);
- }
-
- void CCssCalculator_Private::SetUnitMeasure(const UnitMeasure& nType)
- {
- m_UnitMeasure = nType;
- }
-
unsigned short int CCssCalculator_Private::GetDpi() const
{
return m_nDpi;
@@ -677,11 +619,6 @@ namespace NSCSS
return &m_mData;
}
- UnitMeasure CCssCalculator_Private::GetUnitMeasure() const
- {
- return m_UnitMeasure;
- }
-
std::wstring CCssCalculator_Private::GetEncoding() const
{
return m_sEncoding;
@@ -691,7 +628,6 @@ namespace NSCSS
{
m_sEncoding = L"UTF-8";
m_nDpi = 96;
- m_UnitMeasure = Point;
m_mData.clear();
m_arFiles.clear();
diff --git a/Common/3dParty/html/css/src/CCssCalculator_Private.h b/Common/3dParty/html/css/src/CCssCalculator_Private.h
index 510bf0030d..f4837f9df7 100644
--- a/Common/3dParty/html/css/src/CCssCalculator_Private.h
+++ b/Common/3dParty/html/css/src/CCssCalculator_Private.h
@@ -20,7 +20,6 @@ namespace NSCSS
{
unsigned short int m_nDpi;
unsigned short int m_nCountNodes;
- UnitMeasure m_UnitMeasure;
std::list m_arFiles;
@@ -34,8 +33,6 @@ namespace NSCSS
std::vector m_arPageDatas;
- std::map *m_mStatictics; // Количество повторений свойств id и style у селекторов
-
#ifdef CSS_CALCULATOR_WITH_XHTML
std::map, CCompiledStyle> m_mUsedStyles;
@@ -45,7 +42,7 @@ namespace NSCSS
std::vector CalculateAllNodes(const std::vector& arSelectors);
void FindPrevAndKindElements(const CElement* pElement, const std::vector& arNextNodes, std::vector& arFindedElements, const std::wstring& wsName, const std::vector& arClasses = {});
- std::vector FindElements(std::vector& arNodes, std::vector& arNextNodes, bool bIsSettings);
+ std::vector FindElements(std::vector& arNodes, std::vector& arNextNodes);
#endif
std::wstring m_sEncoding;
@@ -72,8 +69,8 @@ namespace NSCSS
~CCssCalculator_Private();
#ifdef CSS_CALCULATOR_WITH_XHTML
- CCompiledStyle GetCompiledStyle(const std::vector &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point);
- bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point);
+ CCompiledStyle GetCompiledStyle(const std::vector &arSelectors);
+ bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector &arSelectors);
std::wstring CalculateStyleId(const CNode& oNode);
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector &arSelectors);
@@ -83,11 +80,8 @@ namespace NSCSS
void AddStyles(const std::wstring& wsStyle);
void AddStylesFromFile(const std::wstring& wsFileName);
- void SetUnitMeasure(const UnitMeasure& nType);
void SetDpi(unsigned short int nValue);
- void SetBodyTree(const CTree &oTree);
- UnitMeasure GetUnitMeasure() const;
std::wstring GetEncoding() const;
unsigned short int GetDpi() const;
diff --git a/Common/3dParty/html/css/src/ConstValues.cpp b/Common/3dParty/html/css/src/ConstValues.cpp
index edef26c42e..83d78fba90 100644
--- a/Common/3dParty/html/css/src/ConstValues.cpp
+++ b/Common/3dParty/html/css/src/ConstValues.cpp
@@ -2,29 +2,6 @@
namespace NSCSS
{
- bool StatistickElement::operator<(const StatistickElement &oStatistickElement) const
- {
- return sValue < oStatistickElement.sValue;
- }
-
- void CTree::Clear()
- {
- m_arrChild.clear();
- m_oNode.Clear();
- }
-
- void CTree::CountingNumberRepetitions(const CTree &oTree, std::map &mStatictics)
- {
- if (!oTree.m_oNode.m_wsId.empty())
- ++mStatictics[StatistickElement{StatistickElement::IsId, L'#' + oTree.m_oNode.m_wsId}];
- if (!oTree.m_oNode.m_wsStyle.empty())
- ++mStatictics[StatistickElement{StatistickElement::IsStyle, oTree.m_oNode.m_wsStyle}];
-
- if (!oTree.m_arrChild.empty())
- for (const CTree& oChildren : oTree.m_arrChild)
- CountingNumberRepetitions(oChildren, mStatictics);
- }
-
namespace NSConstValues
{
const std::map COLORS
diff --git a/Common/3dParty/html/css/src/ConstValues.h b/Common/3dParty/html/css/src/ConstValues.h
index 2bc546b54d..de5a434faa 100644
--- a/Common/3dParty/html/css/src/ConstValues.h
+++ b/Common/3dParty/html/css/src/ConstValues.h
@@ -16,28 +16,6 @@ namespace NSCSS
ScalingDirectionY = 2
} ScalingDirection;
- struct StatistickElement
- {
- enum TypeElement
- {
- IsStyle = 0,
- IsId
- } m_enType;
- std::wstring sValue;
-
- bool operator<(const StatistickElement& oStatistickElement) const;
- };
-
- struct CTree
- {
- NSCSS::CNode m_oNode;
- std::vector m_arrChild;
-
- void Clear();
-
- static void CountingNumberRepetitions(const CTree &oTree, std::map &mStatictics);
- };
-
namespace NSConstValues
{
extern const std::map COLORS;
diff --git a/HtmlFile2/htmlfile2.cpp b/HtmlFile2/htmlfile2.cpp
index d0eeb0f31c..9f48c4a0c1 100644
--- a/HtmlFile2/htmlfile2.cpp
+++ b/HtmlFile2/htmlfile2.cpp
@@ -1432,8 +1432,6 @@ public:
std::wstring m_sBase; // Полный базовый адрес
std::wstring m_sCore; // Путь до корневого файла (используется для работы с Epub)
- NSCSS::CTree m_oTree; // Дерево body html-файла
-
private:
int m_nFootnoteId; // ID сноски
int m_nHyperlinkId; // ID ссылки
@@ -1913,7 +1911,7 @@ public:
std::wstring sName = m_oLightReader.GetName();
if(sName == L"body")
- readStyle2(m_oTree);
+ readStyle2();
else
{
// Стиль по ссылке
@@ -1956,7 +1954,7 @@ public:
}
}
- void readStyle2(NSCSS::CTree& oTree)
+ void readStyle2()
{
std::wstring sName = m_oLightReader.GetName();
// Стиль по ссылке
@@ -1994,31 +1992,11 @@ public:
else if(sName == L"style")
m_oStylesCalculator.AddStyles(m_oLightReader.GetText2());
- oTree.m_oNode.m_wsName = sName;
- // Стиль по атрибуту
- while(m_oLightReader.MoveToNextAttribute())
- {
- std::wstring sNameA = m_oLightReader.GetName();
- if(sNameA == L"class")
- oTree.m_oNode.m_wsClass = m_oLightReader.GetText();
- else if(sNameA == L"id")
- oTree.m_oNode.m_wsId = m_oLightReader.GetText();
- else if(sNameA == L"style")
- oTree.m_oNode.m_wsStyle += m_oLightReader.GetText();
- else
- oTree.m_oNode.m_mAttributes[sNameA] = m_oLightReader.GetText();
- }
- m_oLightReader.MoveToElement();
-
int nDeath = m_oLightReader.GetDepth();
while(m_oLightReader.ReadNextSiblingNode(nDeath))
{
if(!m_oLightReader.IsEmptyNode())
- {
- NSCSS::CTree oChildTree;
- readStyle2(oChildTree);
- oTree.m_arrChild.push_back(oChildTree);
- }
+ readStyle2();
}
}
@@ -4292,13 +4270,11 @@ private:
if (m_oState.m_bWasPStyle)
return L"";
- NSCSS::CCompiledStyle oStyleSetting{m_oStylesCalculator.GetCompiledStyle(sSelectors, true)};
- NSCSS::CCompiledStyle oStyle{m_oStylesCalculator.GetCompiledStyle(sSelectors)};
+ NSCSS::CCompiledStyle oStyleSetting{oTS.oAdditionalStyle};
+ NSCSS::CCompiledStyle oStyle = m_oStylesCalculator.GetCompiledStyle(sSelectors);
NSCSS::CCompiledStyle::StyleEquation(oStyle, oStyleSetting);
- oStyleSetting += oTS.oAdditionalStyle;
-
std::wstring sPStyle = GetStyle(oStyle, true);
if (sPStyle.empty() && !ElementInTable(sSelectors))
@@ -4332,10 +4308,7 @@ private:
if (!m_oState.m_bInP)
return L"";
- NSCSS::CCompiledStyle oStyleSetting = m_oStylesCalculator.GetCompiledStyle(sSelectors, true);
-
- oStyleSetting += oTS.oAdditionalStyle;
-
+ NSCSS::CCompiledStyle oStyleSetting{oTS.oAdditionalStyle};
NSCSS::CCompiledStyle oStyle = m_oStylesCalculator.GetCompiledStyle(sSelectors);
NSCSS::CCompiledStyle::StyleEquation(oStyle, oStyleSetting);
@@ -4709,8 +4682,6 @@ HRESULT CHtmlFile2::OpenHtml(const std::wstring& sSrc, const std::wstring& sDst,
m_internal->CreateDocxEmpty(oParams);
m_internal->readStyle();
- m_internal->m_oStylesCalculator.SetBodyTree(m_internal->m_oTree);
-
// Переходим в начало
if(!m_internal->m_oLightReader.MoveToStart())
return S_FALSE;
@@ -4733,9 +4704,6 @@ HRESULT CHtmlFile2::OpenMht(const std::wstring& sSrc, const std::wstring& sDst,
m_internal->CreateDocxEmpty(oParams);
m_internal->readStyle();
- m_internal->m_oStylesCalculator.SetBodyTree(m_internal->m_oTree);
- m_internal->m_oTree.Clear();
-
// Переходим в начало
if(!m_internal->m_oLightReader.MoveToStart())
return S_FALSE;
@@ -4764,8 +4732,6 @@ HRESULT CHtmlFile2::OpenBatchHtml(const std::vector& sSrc, const s
continue;
m_internal->readStyle();
- m_internal->m_oStylesCalculator.SetBodyTree(m_internal->m_oTree);
-
// Переходим в начало
if(m_internal->m_oLightReader.MoveToStart())
{