mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Refactoring and fixed bugs
This commit is contained in:
@ -77,6 +77,9 @@ namespace NSCSS
|
||||
NSConstValues::NSCssProperties::Background::BackgroundEquation(oFirstStyle.m_pBackground, oSecondStyle.m_pBackground);
|
||||
NSConstValues::NSCssProperties::Text::TextEquation(oFirstStyle.m_pText, oSecondStyle.m_pText);
|
||||
NSConstValues::NSCssProperties::Border::BorderEquation(oFirstStyle.m_pBorder, oSecondStyle.m_pBorder);
|
||||
|
||||
oFirstStyle.ClearImportants();
|
||||
oSecondStyle.ClearImportants();
|
||||
}
|
||||
|
||||
void CCompiledStyle::SetDpi(const unsigned short &uiDpi)
|
||||
|
||||
@ -49,7 +49,7 @@ namespace NSCSS
|
||||
m_pInternal->SetBodyTree(oTree);
|
||||
}
|
||||
|
||||
CCompiledStyle* CCssCalculator::GetStyleSetting(const std::vector<CNode> &arSelectors)
|
||||
CCompiledStyle CCssCalculator::GetStyleSetting(const std::vector<CNode> &arSelectors)
|
||||
{
|
||||
return m_pInternal->GetStyleSetting(arSelectors);
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ namespace NSCSS
|
||||
~CCssCalculator();
|
||||
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors, const UnitMeasure& unitMeasure = Default) const;
|
||||
CCompiledStyle GetStyleSetting(const std::vector<CNode>& arSelectors);
|
||||
|
||||
// void AddStyle(const std::vector<std::string>& sSelectors, const std::string& sStyle);
|
||||
void AddStyles (const std::string& sStyle);
|
||||
@ -30,7 +31,6 @@ namespace NSCSS
|
||||
void SetDpi(const unsigned short int& nValue);
|
||||
void SetBodyTree(const CTree &oTree);
|
||||
|
||||
CCompiledStyle* GetStyleSetting(const std::vector<CNode>& arSelectors);
|
||||
|
||||
UnitMeasure GetUnitMeasure() const;
|
||||
std::wstring GetEncoding() const;
|
||||
|
||||
@ -40,7 +40,7 @@ bool operator<(const std::vector<NSCSS::CNode> &arLeftSelectors, const std::vect
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
CCssCalculator_Private::CCssCalculator_Private() : m_nDpi(96), m_nCountNodes(0), m_UnitMeasure(Default), m_mStatictics(NULL), m_sEncoding(L"UTF-8"), m_oLastStyle(NULL) {}
|
||||
CCssCalculator_Private::CCssCalculator_Private() : m_nDpi(96), m_nCountNodes(0), m_UnitMeasure(Default), m_mStatictics(NULL), m_sEncoding(L"UTF-8"){}
|
||||
|
||||
CCssCalculator_Private::~CCssCalculator_Private()
|
||||
{
|
||||
@ -482,13 +482,6 @@ namespace NSCSS
|
||||
|
||||
m_mUsedStyles[arSelectors] = oStyle;
|
||||
|
||||
if (NULL != m_oLastStyle && m_oLastStyle->GetId() == oStyle->GetId())
|
||||
{
|
||||
CCompiledStyle::StyleEquation(*oStyle, *m_oLastStyle);
|
||||
m_oLastStyle->SetDpi(5345);
|
||||
}
|
||||
oStyle->ClearImportants();
|
||||
|
||||
return *oStyle;
|
||||
}
|
||||
|
||||
@ -543,12 +536,12 @@ namespace NSCSS
|
||||
return m_nDpi;
|
||||
}
|
||||
|
||||
CCompiledStyle* CCssCalculator_Private::GetStyleSetting(const std::vector<CNode>& arSelectors)
|
||||
{
|
||||
CCompiledStyle CCssCalculator_Private::GetStyleSetting(const std::vector<CNode>& arSelectors)
|
||||
{
|
||||
if (NULL == m_mStatictics || m_mStatictics->empty())
|
||||
return NULL;
|
||||
return CCompiledStyle();
|
||||
|
||||
CCompiledStyle *oStyle = new CCompiledStyle();
|
||||
CCompiledStyle oStyle;
|
||||
|
||||
for (const CNode& oNode : arSelectors)
|
||||
{
|
||||
@ -561,23 +554,18 @@ namespace NSCSS
|
||||
oFindId = m_mData.find(L'#' + oNode.m_sId);
|
||||
|
||||
if (oFindId != m_mData.cend())
|
||||
oStyle->AddStyle(oFindId->second->GetStyle(), true);
|
||||
oStyle.AddStyle(oFindId->second->GetStyle(), true);
|
||||
}
|
||||
}
|
||||
if (!oNode.m_sStyle.empty())
|
||||
{
|
||||
std::map<StatistickElement, unsigned int>::const_iterator oFind = m_mStatictics->find(StatistickElement{StatistickElement::IsStyle, oNode.m_sStyle});
|
||||
if (oFind != m_mStatictics->cend() && oFind->second < MaxNumberRepetitions)
|
||||
oStyle->AddStyle(oNode.m_sStyle, true);
|
||||
oStyle.AddStyle(oNode.m_sStyle, true);
|
||||
}
|
||||
}
|
||||
|
||||
oStyle->SetID(arSelectors.back().m_sName + ((!arSelectors.back().m_sClass.empty()) ? L'.' + arSelectors.back().m_sClass : L"") + ((arSelectors.back().m_sId.empty()) ? L"" : L'#' + arSelectors.back().m_sId) + L'-' + std::to_wstring(1 + m_nCountNodes));
|
||||
|
||||
if (NULL != m_oLastStyle)
|
||||
delete m_oLastStyle;
|
||||
|
||||
m_oLastStyle = oStyle;
|
||||
oStyle.SetID(arSelectors.back().m_sName + ((!arSelectors.back().m_sClass.empty()) ? L'.' + arSelectors.back().m_sClass : L"") + ((arSelectors.back().m_sId.empty()) ? L"" : L'#' + arSelectors.back().m_sId) + L'-' + std::to_wstring(m_nCountNodes));
|
||||
|
||||
return oStyle;
|
||||
}
|
||||
|
||||
@ -24,7 +24,6 @@ namespace NSCSS
|
||||
std::map<StatistickElement, unsigned int> *m_mStatictics; // Количество повторений свойств id и style у селекторов
|
||||
|
||||
std::map<std::vector<CNode>, CCompiledStyle*> m_mUsedStyles;
|
||||
CCompiledStyle* m_oLastStyle;
|
||||
|
||||
std::wstring m_sEncoding;
|
||||
|
||||
@ -48,6 +47,7 @@ namespace NSCSS
|
||||
~CCssCalculator_Private();
|
||||
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors, const UnitMeasure& unitMeasure = Default);
|
||||
CCompiledStyle GetStyleSetting(const std::vector<CNode>& arSelectors);
|
||||
|
||||
void AddStyles(const std::string& sStyle);
|
||||
void AddStyles(const std::wstring& sStyle);
|
||||
@ -61,8 +61,6 @@ namespace NSCSS
|
||||
std::wstring GetEncoding() const;
|
||||
unsigned short int GetDpi() const;
|
||||
|
||||
CCompiledStyle* GetStyleSetting(const std::vector<CNode>& arSelectors);
|
||||
|
||||
void Clear();
|
||||
|
||||
};
|
||||
|
||||
@ -1249,8 +1249,8 @@ namespace NSCSS
|
||||
public:
|
||||
|
||||
BorderSide() : fWidth(fNoneValue),
|
||||
sStyle(L"single"),
|
||||
sColor(L"auto"),
|
||||
sStyle(L""),
|
||||
sColor(L""),
|
||||
bImportants({false, false, false}){}
|
||||
|
||||
void ClearImportants()
|
||||
@ -1275,17 +1275,17 @@ namespace NSCSS
|
||||
if (oFirstBorderSide.bImportants[0] && !oSecondBorderSide.bImportants[0] && oFirstBorderSide.fWidth != fNoneValue)
|
||||
oSecondBorderSide.fWidth = fNoneValue;
|
||||
else if (oSecondBorderSide.fWidth != fNoneValue)
|
||||
oSecondBorderSide.fWidth = fNoneValue;
|
||||
oFirstBorderSide.fWidth = fNoneValue;
|
||||
|
||||
if (oFirstBorderSide.bImportants[1] && !oSecondBorderSide.bImportants[1] && !oFirstBorderSide.sStyle.empty())
|
||||
oSecondBorderSide.sStyle.clear();
|
||||
else if (!oSecondBorderSide.sStyle.empty())
|
||||
oSecondBorderSide.sStyle.clear();
|
||||
oFirstBorderSide.sStyle.clear();
|
||||
|
||||
if (oFirstBorderSide.bImportants[2] && !oSecondBorderSide.bImportants[2] && !oFirstBorderSide.sColor.empty())
|
||||
oSecondBorderSide.sColor.clear();
|
||||
else if (!oSecondBorderSide.sColor.empty())
|
||||
oSecondBorderSide.sColor.clear();
|
||||
oFirstBorderSide.sColor.clear();
|
||||
}
|
||||
|
||||
bool operator==(const BorderSide& oBorderSide) const
|
||||
@ -1297,9 +1297,9 @@ namespace NSCSS
|
||||
|
||||
bool Empty() const
|
||||
{
|
||||
return fWidth <= 0 &&
|
||||
sStyle == L"single" &&
|
||||
sColor == L"auto";
|
||||
return fWidth <= 0 &&
|
||||
sStyle.empty() &&
|
||||
sColor.empty();
|
||||
}
|
||||
|
||||
void SetWidthWithoutChecking(const float& fWidth, const bool &bHardMode = false)
|
||||
|
||||
Reference in New Issue
Block a user