mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Working with svg text styles
This commit is contained in:
@ -671,6 +671,12 @@ namespace NSCSS
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMatrix::SetMatrix(const Aggplus::CMatrix &oValue)
|
||||
{
|
||||
m_oValue = oValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMatrix::Empty() const
|
||||
{
|
||||
return m_oValue.IsIdentity();
|
||||
@ -1030,6 +1036,12 @@ namespace NSCSS
|
||||
return m_oMatrix.SetValue(wsValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CTransform::SetMatrix(const Aggplus::CMatrix &oMatrix)
|
||||
{
|
||||
m_oMatrix.SetMatrix(oMatrix);
|
||||
return true;
|
||||
}
|
||||
|
||||
const CMatrix& CTransform::GetMatrix() const
|
||||
{
|
||||
return m_oMatrix;
|
||||
@ -1361,7 +1373,7 @@ namespace NSCSS
|
||||
{
|
||||
CDigit ::Equation(oFirstText.m_oIndent, oSecondText.m_oIndent);
|
||||
CString::Equation(oFirstText.m_oAlign, oSecondText.m_oAlign);
|
||||
CString::Equation(oFirstText.m_oDecoration, oSecondText.m_oDecoration);
|
||||
// CString::Equation(oFirstText.m_oDecoration, oSecondText.m_oDecoration);
|
||||
CColor ::Equation(oFirstText.m_oColor, oSecondText.m_oColor);
|
||||
}
|
||||
|
||||
@ -1378,13 +1390,25 @@ namespace NSCSS
|
||||
|
||||
bool CText::SetAlign(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oAlign.SetValue(wsValue, {std::make_pair(L"center", L"center"), std::make_pair(L"justify", L"both"), std::make_pair(L"left", L"left"), std::make_pair(L"start", L"left"), std::make_pair(L"right", L"right"), std::make_pair(L"end", L"right")}, unLevel, bHardMode);
|
||||
return m_oAlign.SetValue(wsValue, {std::make_pair(L"center", L"center"), std::make_pair(L"middle", L"center"), std::make_pair(L"justify", L"both"), std::make_pair(L"left", L"left"), std::make_pair(L"start", L"left"), std::make_pair(L"right", L"right"), std::make_pair(L"end", L"right")}, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CText::SetDecoration(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oDecoration.SetValue(wsValue, {std::make_pair(L"underline", L"single"), std::make_pair(L"line-through", L"line-through"), std::make_pair(L"none", L"none")}, unLevel, bHardMode);
|
||||
}
|
||||
if (wsValue.empty())
|
||||
return false;
|
||||
|
||||
for (const std::wstring& wsVal : NSCSS::NS_STATIC_FUNCTIONS::GetWordsW(wsValue))
|
||||
{
|
||||
if (m_oDecoration.m_oLine.SetValue(wsVal) ||
|
||||
m_oDecoration.m_oStyle.SetValue(wsValue, {L"solid", L"double", L"dotted", L"dashed", L"wavy"}, unLevel, bHardMode) ||
|
||||
m_oDecoration.m_oColor.SetValue(wsValue, unLevel, bHardMode))
|
||||
continue;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; }
|
||||
|
||||
bool CText::SetColor(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
@ -1401,7 +1425,7 @@ namespace NSCSS
|
||||
return m_oAlign;
|
||||
}
|
||||
|
||||
const CString& CText::GetDecoration() const
|
||||
const TTextDecoration& CText::GetDecoration() const
|
||||
{
|
||||
return m_oDecoration;
|
||||
}
|
||||
@ -1414,7 +1438,22 @@ namespace NSCSS
|
||||
bool CText::Empty() const
|
||||
{
|
||||
return m_oIndent.Empty() && m_oAlign.Empty() &&
|
||||
m_oDecoration.Empty() && m_oColor.Empty();
|
||||
m_oDecoration.m_oLine.Empty() && m_oColor.Empty();
|
||||
}
|
||||
|
||||
bool CText::Underline() const
|
||||
{
|
||||
return m_oDecoration.m_oLine.Underline();
|
||||
}
|
||||
|
||||
bool CText::Overline() const
|
||||
{
|
||||
return m_oDecoration.m_oLine.Overline();
|
||||
}
|
||||
|
||||
bool CText::LineThrough() const
|
||||
{
|
||||
return m_oDecoration.m_oLine.LineThrough();
|
||||
}
|
||||
|
||||
CText &CText::operator+=(const CText &oText)
|
||||
@ -1431,7 +1470,7 @@ namespace NSCSS
|
||||
{
|
||||
return m_oIndent == oText.m_oIndent &&
|
||||
m_oAlign == oText.m_oAlign &&
|
||||
m_oDecoration == oText.m_oDecoration &&
|
||||
// m_oDecoration == oText.m_oDecoration &&
|
||||
m_oColor == oText.m_oColor;
|
||||
}
|
||||
|
||||
@ -1588,6 +1627,77 @@ namespace NSCSS
|
||||
}
|
||||
|
||||
// FONT
|
||||
CTextDecorationLine::CTextDecorationLine()
|
||||
: m_bUnderline(false), m_bOverline(false), m_bLineThrough(false)
|
||||
{}
|
||||
|
||||
bool CTextDecorationLine::Empty() const
|
||||
{
|
||||
return false == m_bUnderline && false == m_bOverline && false == m_bLineThrough;
|
||||
}
|
||||
|
||||
bool CTextDecorationLine::SetValue(const std::wstring &wsValue)
|
||||
{
|
||||
if (L"underline" == wsValue)
|
||||
{
|
||||
m_bUnderline = true;
|
||||
return true;
|
||||
}
|
||||
else if (L"overline" == wsValue)
|
||||
{
|
||||
m_bOverline = true;
|
||||
return true;
|
||||
}
|
||||
else if (L"line-through" == wsValue)
|
||||
{
|
||||
m_bLineThrough = true;
|
||||
return true;
|
||||
}
|
||||
else if (L"none" == wsValue)
|
||||
{
|
||||
m_bUnderline = m_bOverline = m_bLineThrough = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CTextDecorationLine::Underline() const
|
||||
{
|
||||
return m_bUnderline;
|
||||
}
|
||||
|
||||
bool CTextDecorationLine::Overline() const
|
||||
{
|
||||
return m_bOverline;
|
||||
}
|
||||
|
||||
bool CTextDecorationLine::LineThrough() const
|
||||
{
|
||||
return m_bLineThrough;
|
||||
}
|
||||
|
||||
CTextDecorationLine &CTextDecorationLine::operator+=(const CTextDecorationLine &oTextDecoration)
|
||||
{
|
||||
if (oTextDecoration.m_bUnderline)
|
||||
m_bUnderline = true;
|
||||
if (oTextDecoration.m_bOverline)
|
||||
m_bOverline = true;
|
||||
if (oTextDecoration.m_bLineThrough)
|
||||
m_bLineThrough = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
TTextDecoration &TTextDecoration::operator+=(const TTextDecoration &oTextDecoration)
|
||||
{
|
||||
m_oLine += oTextDecoration.m_oLine;
|
||||
m_oStyle += oTextDecoration.m_oStyle;
|
||||
m_oColor += oTextDecoration.m_oColor;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CFont::CFont()
|
||||
: m_oSize(24., 0)
|
||||
{}
|
||||
@ -1725,6 +1835,22 @@ namespace NSCSS
|
||||
std::make_pair(L"700", L"bold"), std::make_pair(L"800", L"bold"), std::make_pair(L"900", L"bold")}, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CFont::UpdateSize(double dSize)
|
||||
{
|
||||
m_oSize = dSize;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFont::Bold() const
|
||||
{
|
||||
return m_oWeight == L"bold";
|
||||
}
|
||||
|
||||
bool CFont::Italic() const
|
||||
{
|
||||
return m_oStyle == L"italic";
|
||||
}
|
||||
|
||||
void CFont::Clear()
|
||||
{
|
||||
m_oSize = CDigit(24., 0);
|
||||
@ -1893,8 +2019,7 @@ namespace NSCSS
|
||||
|
||||
bool CColorValue::Empty() const
|
||||
{
|
||||
return (ColorEmpty == m_enType) || (ColorRGB == m_enType && static_cast<TRGB*>(m_pColor)->Empty()) ||
|
||||
((ColorHEX == m_enType || ColorUrl == m_enType) && static_cast<std::wstring*>(m_pColor)->empty());
|
||||
return ColorEmpty == m_enType;
|
||||
}
|
||||
|
||||
std::wstring CColorValue::GetColor() const
|
||||
|
||||
@ -196,6 +196,7 @@ namespace NSCSS
|
||||
CMatrix(const Aggplus::CMatrix& oValue, unsigned int unLevel, bool bImportant = false);
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode) override;
|
||||
bool SetMatrix(const Aggplus::CMatrix& oValue);
|
||||
|
||||
bool Empty() const override;
|
||||
void Clear() override;
|
||||
@ -310,6 +311,7 @@ namespace NSCSS
|
||||
static void Equation(CTransform &oFirstTransform, CTransform &oSecondTransform);
|
||||
|
||||
bool SetMatrix(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetMatrix(const Aggplus::CMatrix &oMatrix);
|
||||
|
||||
const CMatrix& GetMatrix() const;
|
||||
|
||||
@ -410,6 +412,34 @@ namespace NSCSS
|
||||
CBorderSide m_oBottom;
|
||||
};
|
||||
|
||||
class CTextDecorationLine
|
||||
{
|
||||
bool m_bUnderline;
|
||||
bool m_bOverline;
|
||||
bool m_bLineThrough;
|
||||
public:
|
||||
CTextDecorationLine();
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
bool SetValue(const std::wstring& wsValue);
|
||||
|
||||
bool Underline() const;
|
||||
bool Overline() const;
|
||||
bool LineThrough() const;
|
||||
|
||||
CTextDecorationLine &operator+=(const CTextDecorationLine& oTextDecoration);
|
||||
};
|
||||
|
||||
struct TTextDecoration
|
||||
{
|
||||
CTextDecorationLine m_oLine;
|
||||
CString m_oStyle;
|
||||
CColor m_oColor;
|
||||
|
||||
TTextDecoration& operator+=(const TTextDecoration& oTextDecoration);
|
||||
};
|
||||
|
||||
class CText
|
||||
{
|
||||
public:
|
||||
@ -422,20 +452,24 @@ namespace NSCSS
|
||||
bool SetDecoration(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
const CDigit& GetIndent() const;
|
||||
const CString& GetAlign() const;
|
||||
const CString& GetDecoration() const;
|
||||
const CColor& GetColor() const;
|
||||
const CDigit& GetIndent() const;
|
||||
const CString& GetAlign() const;
|
||||
const TTextDecoration& GetDecoration() const;
|
||||
const CColor& GetColor() const;
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
bool Underline() const;
|
||||
bool Overline() const;
|
||||
bool LineThrough() const;
|
||||
|
||||
CText& operator+=(const CText& oText);
|
||||
bool operator==(const CText& oText) const;
|
||||
private:
|
||||
CDigit m_oIndent;
|
||||
CString m_oAlign;
|
||||
CString m_oDecoration;
|
||||
CColor m_oColor;
|
||||
TTextDecoration m_oDecoration;
|
||||
CDigit m_oIndent;
|
||||
CString m_oAlign;
|
||||
CColor m_oColor;
|
||||
};
|
||||
|
||||
class CIndent
|
||||
@ -480,17 +514,22 @@ namespace NSCSS
|
||||
|
||||
static void Equation(CFont &oFirstFont, CFont &oSecondFont);
|
||||
|
||||
bool SetValue (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetSize (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetLineHeight(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetFamily (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStretch (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyle (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetVariant (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetValue (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetSize (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetLineHeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetFamily (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStretch (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyle (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetVariant (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
bool UpdateSize(double dSize);
|
||||
|
||||
void Clear();
|
||||
|
||||
bool Bold() const;
|
||||
bool Italic() const;
|
||||
|
||||
const CDigit& GetSize() const;
|
||||
const CDigit& GetLineHeight() const;
|
||||
const CString& GetFamily() const;
|
||||
@ -507,11 +546,13 @@ namespace NSCSS
|
||||
CDigit m_oSize;
|
||||
CDigit m_oLineHeight;
|
||||
CString m_oFamily;
|
||||
//TODO:: возможно стоит перейти в слудующих переменых на enum
|
||||
//TODO:: возможно стоит перейти в слудующих переменных на enum
|
||||
CString m_oStretch;
|
||||
CString m_oStyle;
|
||||
CString m_oVariant;
|
||||
CString m_oWeight;
|
||||
|
||||
TTextDecoration m_oTextDecoration;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -386,7 +386,7 @@ namespace NSCSS
|
||||
|
||||
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Highlight, oStyle.m_oBackground.GetColor().ToWString());
|
||||
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Color, oStyle.m_oText.GetColor().ToWString());
|
||||
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_U, oStyle.m_oText.GetDecoration().ToWString());
|
||||
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_U, (oStyle.m_oText.GetDecoration().m_oLine.Underline()) ? L"underline" : L"");
|
||||
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Sz, oStyle.m_oFont.GetSize().ToWString());
|
||||
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_RFonts, oStyle.m_oFont.GetFamily().ToWString());
|
||||
oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_I, oStyle.m_oFont.GetStyle().ToWString());
|
||||
|
||||
Reference in New Issue
Block a user