Refactoring

This commit is contained in:
Kirill Poljakov
2023-07-18 10:55:09 +03:00
parent f0130f92dc
commit 529acfbd5f
3 changed files with 31 additions and 16 deletions

View File

@ -733,11 +733,6 @@ namespace NSCSS
});
}
oStyle.AddStyle(arSelectors[i].m_mAttributes, i + 1);
for (const CElement* oElement : arFindElements)
oStyle.AddStyle(oElement->GetStyle(), i + 1);
if (NULL != m_mStatictics)
{
std::map<StatistickElement, unsigned int>::const_iterator oFindCountStyle = m_mStatictics->find(StatistickElement{StatistickElement::IsStyle, arSelectors[i].m_wsStyle});
@ -755,6 +750,11 @@ namespace NSCSS
}
else
oStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
for (const CElement* oElement : arFindElements)
oStyle.AddStyle(oElement->GetStyle(), i + 1);
oStyle.AddStyle(arSelectors[i].m_mAttributes, i + 1);
}
if (!bIsSettings)

View File

@ -7,6 +7,8 @@ namespace NSCSS
{
namespace NSProperties
{
#define CHECK_CONDITIONS (m_bImportant || unLevel <= m_unLevel)
static bool CutImportant(std::wstring& wsValue)
{
size_t unBegin = wsValue.find(L"!important");
@ -83,7 +85,7 @@ namespace NSCSS
template<typename T>
CValue<T>& CValue<T>::operator=(const T &oValue)
{
m_oValue = oValue.m_oValue;
// m_oValue = oValue.m_oValue;
return *this;
}
@ -117,7 +119,7 @@ namespace NSCSS
bool CString::SetValue(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
{
if (wsValue.empty() || ((m_bImportant || unLevel < m_unLevel) && !bHardMode))
if (wsValue.empty() || (CHECK_CONDITIONS && !bHardMode))
return false;
std::wstring wsNewValue = wsValue;
@ -136,7 +138,7 @@ namespace NSCSS
bool CString::SetValue(const std::wstring &wsValue, const std::vector<std::wstring> &arValiableValues, unsigned int unLevel, bool bHardMode)
{
if (wsValue.empty() || arValiableValues.empty() || ((m_bImportant || unLevel < m_unLevel) && !bHardMode))
if (wsValue.empty() || arValiableValues.empty() || (CHECK_CONDITIONS && !bHardMode))
return false;
std::wstring wsNewValue = wsValue;
@ -160,7 +162,7 @@ namespace NSCSS
bool CString::SetValue(const std::wstring &wsValue, const std::map<std::wstring, std::wstring> &arValiableValues, unsigned int unLevel, bool bHardMode)
{
if (wsValue.empty() || arValiableValues.empty() || ((m_bImportant || unLevel < m_unLevel) && !bHardMode))
if (wsValue.empty() || arValiableValues.empty() || (CHECK_CONDITIONS && !bHardMode))
return false;
std::wstring wsNewValue = wsValue;
@ -413,7 +415,7 @@ namespace NSCSS
bool CDigit::SetValue(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
{
if (wsValue.empty() || ((m_bImportant || unLevel < m_unLevel) && !bHardMode))
if (wsValue.empty() || (CHECK_CONDITIONS && !bHardMode))
return false;
std::wstring wsNewValue = wsValue;
@ -423,9 +425,22 @@ namespace NSCSS
if (m_bImportant && !bImportant)
return false;
if (!CUnitMeasureConverter::GetValue(wsValue, m_oValue, m_enUnitMeasure))
double dNewValue;
UnitMeasure enNewUnitMeasure;
if (!CUnitMeasureConverter::GetValue(wsValue, dNewValue, enNewUnitMeasure))
return false;
if (Percent == enNewUnitMeasure && !Empty() && unLevel > m_unLevel)
{
m_oValue *= dNewValue / 100.;
}
else
{
m_oValue = dNewValue;
m_enUnitMeasure = enNewUnitMeasure;
}
m_unLevel = unLevel;
m_bImportant = bImportant;
@ -496,7 +511,7 @@ namespace NSCSS
bool CColor::SetValue(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
{
if (((m_bImportant || unLevel < m_unLevel) && !bHardMode) || (wsValue.empty() && unLevel == m_unLevel))
if (wsValue.empty() || (CHECK_CONDITIONS && !bHardMode))
return false;
if (wsValue.empty())
@ -698,7 +713,7 @@ namespace NSCSS
bool CMatrix::SetValue(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
{
if (((m_bImportant || unLevel < m_unLevel) && !bHardMode) || (wsValue.empty() && unLevel == m_unLevel))
if ((CHECK_CONDITIONS && !bHardMode) || (wsValue.empty() && unLevel == m_unLevel))
return false;
std::wstring wsNewValue = wsValue;
@ -2326,7 +2341,7 @@ namespace NSCSS
bool CEnum::SetValue(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
{
if (wsValue.empty() || m_mMap.empty() || ((m_bImportant || unLevel < m_unLevel) && !bHardMode))
if (wsValue.empty() || m_mMap.empty() || (CHECK_CONDITIONS && !bHardMode))
return false;
std::wstring wsNewValue = wsValue;