summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-04-08 20:53:07 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-04-09 16:11:35 +0200
commit33fe4909e29654faeef7f665f31ff31776ecfeec (patch)
treef26c204dcf9af56111b9bb57df012e78860aa089
parent136d9b34459edb444fb5154fa8b5c74d877099d5 (diff)
add vcl::Font::EqualIgnoreColor()
The color values in vcl::Font are obsolete, and the underlying font is the same regardless of the color. Change-Id: I66801a07092bc189f43bf2b28bc54ead6d20f70e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132747 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--include/vcl/font.hxx1
-rw-r--r--vcl/inc/impfont.hxx1
-rw-r--r--vcl/source/font/font.cxx21
-rw-r--r--vcl/source/gdi/impglyphitem.cxx7
4 files changed, 24 insertions, 6 deletions
diff --git a/include/vcl/font.hxx b/include/vcl/font.hxx
index ddc98c0223b9..0f641100eecb 100644
--- a/include/vcl/font.hxx
+++ b/include/vcl/font.hxx
@@ -159,6 +159,7 @@ public:
bool operator!=( const Font& rFont ) const
{ return !(Font::operator==( rFont )); }
bool IsSameInstance( const Font& ) const;
+ bool EqualIgnoreColor( const Font& ) const;
friend VCL_DLLPUBLIC SvStream& ::ReadFont( SvStream& rIStm, vcl::Font& );
friend VCL_DLLPUBLIC SvStream& ::WriteFont( SvStream& rOStm, const vcl::Font& );
diff --git a/vcl/inc/impfont.hxx b/vcl/inc/impfont.hxx
index dc90f6d48bd5..2c8ce660ea91 100644
--- a/vcl/inc/impfont.hxx
+++ b/vcl/inc/impfont.hxx
@@ -92,6 +92,7 @@ public:
void SetCalculatedAverageFontWidth(tools::Long nNew) { mnCalculatedAverageFontWidth = nNew; }
bool operator==( const ImplFont& ) const;
+ bool EqualIgnoreColor( const ImplFont& ) const;
private:
friend class vcl::Font;
diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx
index 16678dd61ac7..3387dd196f1f 100644
--- a/vcl/source/font/font.cxx
+++ b/vcl/source/font/font.cxx
@@ -327,6 +327,11 @@ bool Font::operator==( const vcl::Font& rFont ) const
return mpImplFont == rFont.mpImplFont;
}
+bool Font::EqualIgnoreColor( const vcl::Font& rFont ) const
+{
+ return mpImplFont->EqualIgnoreColor( *rFont.mpImplFont );
+}
+
void Font::Merge( const vcl::Font& rFont )
{
if ( !rFont.GetFamilyName().isEmpty() )
@@ -961,6 +966,18 @@ ImplFont::ImplFont( const ImplFont& rImplFont ) :
bool ImplFont::operator==( const ImplFont& rOther ) const
{
+ if(!EqualIgnoreColor( rOther ))
+ return false;
+
+ if( (maColor != rOther.maColor)
+ || (maFillColor != rOther.maFillColor) )
+ return false;
+
+ return true;
+}
+
+bool ImplFont::EqualIgnoreColor( const ImplFont& rOther ) const
+{
// equality tests split up for easier debugging
if( (meWeight != rOther.meWeight)
|| (meItalic != rOther.meItalic)
@@ -983,10 +1000,6 @@ bool ImplFont::operator==( const ImplFont& rOther ) const
|| (maStyleName != rOther.maStyleName) )
return false;
- if( (maColor != rOther.maColor)
- || (maFillColor != rOther.maFillColor) )
- return false;
-
if( (meUnderline != rOther.meUnderline)
|| (meOverline != rOther.meOverline)
|| (meStrikeout != rOther.meStrikeout)
diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx
index e78d23b68676..130039ed88ee 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -188,8 +188,11 @@ inline bool SalLayoutGlyphsCache::CachedGlyphsKey::operator==(const CachedGlyphs
&& logicWidth == other.logicWidth && outputDevice == other.outputDevice
&& rtl == other.rtl && layoutMode == other.layoutMode
&& digitLanguage == other.digitLanguage
- // slower things here
- && font == other.font && vcl::text::FastStringCompareEqual()(text, other.text);
+ // Need to use EqualIgnoreColor, because sometimes the color changes, but it's irrelevant
+ // for text layout (and also obsolete in vcl::Font).
+ && font.EqualIgnoreColor(other.font)
+ && vcl::text::FastStringCompareEqual()(text, other.text);
+ // Slower things last in the comparison.
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */