diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-05-11 12:01:48 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-05-11 13:45:02 +0200 |
commit | 7ae4680c1ffaf1f67c4865270a21451c9e970510 (patch) | |
tree | b9b3d458d317f6c2583de917899bd3664772ed2f /vcl/source/font | |
parent | d4b0451a1ab416c406a74d6d33615d61acf6f7d2 (diff) |
ensure cow_wrapper contents are queried through a const pointer
otherwise the query will call make_unique to make this a unique
copy of the underlying shared font which is a waste if the
contents are going to be the same and the if branch contents
are skipped.
I was tempted to call the Font accessors like GetLanguage, etc.
but a bunch of the accessors have two versions, a const and non-const
one which behave differently so that looks like another rats nest
This relates to the changes of
commit 188439aac2e2e85821b4a114c1298bdf36a7b2ea
Date: Fri Apr 22 23:43:52 2016 +0200
tdf#62525 vcl: use cow_wrapper for font
Change-Id: Ic0661fccb414b3636308975e265fe5751476e1b8
Reviewed-on: https://gerrit.libreoffice.org/37502
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/font')
-rw-r--r-- | vcl/source/font/font.cxx | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx index 80b43e67ab74..4dc242e7abbd 100644 --- a/vcl/source/font/font.cxx +++ b/vcl/source/font/font.cxx @@ -80,7 +80,7 @@ Font::~Font() void Font::SetColor( const Color& rColor ) { - if( mpImplFont->maColor != rColor ) + if (const_cast<const ImplType&>(mpImplFont)->maColor != rColor) { mpImplFont->maColor = rColor; } @@ -95,13 +95,13 @@ void Font::SetFillColor( const Color& rColor ) void Font::SetTransparent( bool bTransparent ) { - if( mpImplFont->mbTransparent != bTransparent ) + if (const_cast<const ImplType&>(mpImplFont)->mbTransparent != bTransparent) mpImplFont->mbTransparent = bTransparent; } void Font::SetAlignment( FontAlign eAlign ) { - if( mpImplFont->meAlign != eAlign ) + if (const_cast<const ImplType&>(mpImplFont)->meAlign != eAlign) mpImplFont->SetAlignment(eAlign); } @@ -117,19 +117,19 @@ void Font::SetStyleName( const OUString& rStyleName ) void Font::SetFontSize( const Size& rSize ) { - if( mpImplFont->GetFontSize() != rSize ) + if (const_cast<const ImplType&>(mpImplFont)->GetFontSize() != rSize) mpImplFont->SetFontSize( rSize ); } void Font::SetFamily( FontFamily eFamily ) { - if( mpImplFont->GetFamilyTypeNoAsk() != eFamily ) + if (const_cast<const ImplType&>(mpImplFont)->GetFamilyTypeNoAsk() != eFamily) mpImplFont->SetFamilyType( eFamily ); } void Font::SetCharSet( rtl_TextEncoding eCharSet ) { - if( mpImplFont->GetCharSet() != eCharSet ) + if (const_cast<const ImplType&>(mpImplFont)->GetCharSet() != eCharSet) { mpImplFont->SetCharSet( eCharSet ); @@ -162,49 +162,49 @@ void Font::SetSymbolFlag( bool bSymbol ) void Font::SetLanguageTag( const LanguageTag& rLanguageTag ) { - if( mpImplFont->maLanguageTag != rLanguageTag ) + if (const_cast<const ImplType&>(mpImplFont)->maLanguageTag != rLanguageTag) mpImplFont->maLanguageTag = rLanguageTag; } void Font::SetCJKContextLanguageTag( const LanguageTag& rLanguageTag ) { - if( mpImplFont->maCJKLanguageTag != rLanguageTag ) + if (const_cast<const ImplType&>(mpImplFont)->maCJKLanguageTag != rLanguageTag) mpImplFont->maCJKLanguageTag = rLanguageTag; } void Font::SetLanguage( LanguageType eLanguage ) { - if( mpImplFont->maLanguageTag.getLanguageType( false) != eLanguage ) + if (const_cast<const ImplType&>(mpImplFont)->maLanguageTag.getLanguageType(false) != eLanguage) mpImplFont->maLanguageTag.reset( eLanguage); } void Font::SetCJKContextLanguage( LanguageType eLanguage ) { - if( mpImplFont->maCJKLanguageTag.getLanguageType( false) != eLanguage ) + if (const_cast<const ImplType&>(mpImplFont)->maCJKLanguageTag.getLanguageType(false) != eLanguage) mpImplFont->maCJKLanguageTag.reset( eLanguage); } void Font::SetPitch( FontPitch ePitch ) { - if( mpImplFont->GetPitchNoAsk() != ePitch ) + if (const_cast<const ImplType&>(mpImplFont)->GetPitchNoAsk() != ePitch) mpImplFont->SetPitch( ePitch ); } void Font::SetOrientation( short nOrientation ) { - if( mpImplFont->mnOrientation != nOrientation ) + if (const_cast<const ImplType&>(mpImplFont)->mnOrientation != nOrientation) mpImplFont->mnOrientation = nOrientation; } void Font::SetVertical( bool bVertical ) { - if( mpImplFont->mbVertical != bVertical ) + if (const_cast<const ImplType&>(mpImplFont)->mbVertical != bVertical) mpImplFont->mbVertical = bVertical; } void Font::SetKerning( FontKerning eKerning ) { - if( mpImplFont->meKerning != eKerning ) + if (const_cast<const ImplType&>(mpImplFont)->meKerning != eKerning) mpImplFont->meKerning = eKerning; } @@ -215,67 +215,67 @@ bool Font::IsKerning() const void Font::SetWeight( FontWeight eWeight ) { - if( mpImplFont->GetWeightNoAsk() != eWeight ) + if (const_cast<const ImplType&>(mpImplFont)->GetWeightNoAsk() != eWeight) mpImplFont->SetWeight( eWeight ); } void Font::SetWidthType( FontWidth eWidth ) { - if( mpImplFont->GetWidthTypeNoAsk() != eWidth ) + if (const_cast<const ImplType&>(mpImplFont)->GetWidthTypeNoAsk() != eWidth) mpImplFont->SetWidthType( eWidth ); } void Font::SetItalic( FontItalic eItalic ) { - if( mpImplFont->GetItalicNoAsk() != eItalic ) + if (const_cast<const ImplType&>(mpImplFont)->GetItalicNoAsk() != eItalic) mpImplFont->SetItalic( eItalic ); } void Font::SetOutline( bool bOutline ) { - if( mpImplFont->mbOutline != bOutline ) + if (const_cast<const ImplType&>(mpImplFont)->mbOutline != bOutline) mpImplFont->mbOutline = bOutline; } void Font::SetShadow( bool bShadow ) { - if( mpImplFont->mbShadow != bShadow ) + if (const_cast<const ImplType&>(mpImplFont)->mbShadow != bShadow) mpImplFont->mbShadow = bShadow; } void Font::SetUnderline( FontLineStyle eUnderline ) { - if( mpImplFont->meUnderline != eUnderline ) + if (const_cast<const ImplType&>(mpImplFont)->meUnderline != eUnderline) mpImplFont->meUnderline = eUnderline; } void Font::SetOverline( FontLineStyle eOverline ) { - if( mpImplFont->meOverline != eOverline ) + if (const_cast<const ImplType&>(mpImplFont)->meOverline != eOverline) mpImplFont->meOverline = eOverline; } void Font::SetStrikeout( FontStrikeout eStrikeout ) { - if( mpImplFont->meStrikeout != eStrikeout ) + if (const_cast<const ImplType&>(mpImplFont)->meStrikeout != eStrikeout) mpImplFont->meStrikeout = eStrikeout; } void Font::SetRelief( FontRelief eRelief ) { - if( mpImplFont->meRelief != eRelief ) + if (const_cast<const ImplType&>(mpImplFont)->meRelief != eRelief) mpImplFont->meRelief = eRelief; } void Font::SetEmphasisMark( FontEmphasisMark eEmphasisMark ) { - if( mpImplFont->meEmphasisMark != eEmphasisMark ) + if (const_cast<const ImplType&>(mpImplFont)->meEmphasisMark != eEmphasisMark ) mpImplFont->meEmphasisMark = eEmphasisMark; } void Font::SetWordLineMode( bool bWordLine ) { - if( mpImplFont->mbWordLine != bWordLine ) + if (const_cast<const ImplType&>(mpImplFont)->mbWordLine != bWordLine) mpImplFont->mbWordLine = bWordLine; } |