diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2025-03-19 13:23:22 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2025-03-19 17:24:38 +0100 |
commit | 599ab8dc3ae9d8b8749b6400e87d98a6dad2a03c (patch) | |
tree | 9e00bf1e54d609ca6a01dc327f377022ab1d31cc /vcl | |
parent | 7af8b3d3305fe8344cb9339269c5dc3f1cd44650 (diff) |
Rename con-const vcl::Font property getters for clarity
There are two sets of getters there; and the non-const ones may copy
the COW mpImplFont, and may call its AskConfig.
The name overload is unfortunate. It is not obvious at the call site,
which of the two will be called; and what is different. IMO, the way
to fix it would be to keep only one set of getters (the const one),
and make the call to AskConfig explicit (in the places that set font
name, and know that resolution of other properties will be needed).
But in this change, I only rename the non-const getters, making sure
to keep the behavior unchanged (at least the intention is to have a
non-functional change, meaning that the places that called non-const
overload, now use the renamed functions), to make it clear where we
actually may copy and initialize it.
Change-Id: I9a5cd91d5c1c0de7ff8577b9b982d165e4cdd2c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183116
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qa/cppunit/font.cxx | 16 | ||||
-rw-r--r-- | vcl/source/accessibility/textwindowaccessibility.cxx | 4 | ||||
-rw-r--r-- | vcl/source/components/fontident.cxx | 8 | ||||
-rw-r--r-- | vcl/source/filter/eps/eps.cxx | 10 | ||||
-rw-r--r-- | vcl/source/font/font.cxx | 11 | ||||
-rw-r--r-- | vcl/source/gdi/mtfxmldump.cxx | 2 | ||||
-rw-r--r-- | vcl/win/window/salframe.cxx | 2 | ||||
-rw-r--r-- | vcl/workben/listfonts.cxx | 10 |
8 files changed, 32 insertions, 31 deletions
diff --git a/vcl/qa/cppunit/font.cxx b/vcl/qa/cppunit/font.cxx index ce49723169fd..f7b5d2c245e9 100644 --- a/vcl/qa/cppunit/font.cxx +++ b/vcl/qa/cppunit/font.cxx @@ -68,20 +68,20 @@ void VclFontTest::testWeight() { vcl::Font aFont; - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Weight should be WEIGHT_DONTKNOW", FontWeight::WEIGHT_DONTKNOW, aFont.GetWeight()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Weight should be WEIGHT_DONTKNOW", FontWeight::WEIGHT_DONTKNOW, aFont.GetWeightMaybeAskConfig()); aFont.SetWeight(FontWeight::WEIGHT_BLACK); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Weight should be WEIGHT_BLACK", FontWeight::WEIGHT_BLACK, aFont.GetWeight()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Weight should be WEIGHT_BLACK", FontWeight::WEIGHT_BLACK, aFont.GetWeightMaybeAskConfig()); } void VclFontTest::testWidthType() { vcl::Font aFont; - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font width should be WIDTH_DONTKNOW", FontWidth::WIDTH_DONTKNOW, aFont.GetWidthType()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font width should be WIDTH_DONTKNOW", FontWidth::WIDTH_DONTKNOW, aFont.GetWidthTypeMaybeAskConfig()); aFont.SetWidthType(FontWidth::WIDTH_EXPANDED); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font width should be EXPANDED", FontWidth::WIDTH_EXPANDED, aFont.GetWidthType()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font width should be EXPANDED", FontWidth::WIDTH_EXPANDED, aFont.GetWidthTypeMaybeAskConfig()); } void VclFontTest::testItalic() @@ -89,10 +89,10 @@ void VclFontTest::testItalic() vcl::Font aFont; // shouldn't this be set to ITALIC_DONTKNOW? currently it defaults to ITALIC_NONE - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Italic should be ITALIC_NONE", FontItalic::ITALIC_NONE, aFont.GetItalic()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Italic should be ITALIC_NONE", FontItalic::ITALIC_NONE, aFont.GetItalicMaybeAskConfig()); aFont.SetItalic(FontItalic::ITALIC_NORMAL); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Italic should be EXPANDED", FontItalic::ITALIC_NORMAL, aFont.GetItalic()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Italic should be EXPANDED", FontItalic::ITALIC_NORMAL, aFont.GetItalicMaybeAskConfig()); } @@ -111,10 +111,10 @@ void VclFontTest::testPitch() { vcl::Font aFont; - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Pitch should be PITCH_DONTKNOW", FontPitch::PITCH_DONTKNOW, aFont.GetPitch()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Pitch should be PITCH_DONTKNOW", FontPitch::PITCH_DONTKNOW, aFont.GetPitchMaybeAskConfig()); aFont.SetPitch(FontPitch::PITCH_FIXED); - CPPUNIT_ASSERT_EQUAL_MESSAGE( "Pitch should be PITCH_FIXED", FontPitch::PITCH_FIXED, aFont.GetPitch()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Pitch should be PITCH_FIXED", FontPitch::PITCH_FIXED, aFont.GetPitchMaybeAskConfig()); } void VclFontTest::testQuality() diff --git a/vcl/source/accessibility/textwindowaccessibility.cxx b/vcl/source/accessibility/textwindowaccessibility.cxx index 287f26ac7a1d..8bed55efb786 100644 --- a/vcl/source/accessibility/textwindowaccessibility.cxx +++ b/vcl/source/accessibility/textwindowaccessibility.cxx @@ -848,7 +848,7 @@ Document::retrieveCharacterAttributes( //character posture aAttrib.Name = "CharPosture"; - aAttrib.Value <<= vcl::unohelper::ConvertFontSlant(aFont.GetItalic()); + aAttrib.Value <<= vcl::unohelper::ConvertFontSlant(aFont.GetItalicMaybeAskConfig()); aAttribs.push_back(aAttrib); //character relief @@ -870,7 +870,7 @@ Document::retrieveCharacterAttributes( //character weight aAttrib.Name = "CharWeight"; - aAttrib.Value <<= static_cast<float>(aFont.GetWeight()); + aAttrib.Value <<= static_cast<float>(aFont.GetWeightMaybeAskConfig()); aAttribs.push_back(aAttrib); //character alignment diff --git a/vcl/source/components/fontident.cxx b/vcl/source/components/fontident.cxx index b19da7af24ff..8a602c888115 100644 --- a/vcl/source/components/fontident.cxx +++ b/vcl/source/components/fontident.cxx @@ -96,7 +96,7 @@ css::uno::Any SAL_CALL FontIdentificator::getMaterial() aFD.Kerning = false; aFD.WordLineMode = false; aFD.Type = 0; - switch( m_aFont.GetFamilyType() ) + switch( m_aFont.GetFamilyTypeMaybeAskConfig() ) { case FAMILY_DECORATIVE: aFD.Family = css::awt::FontFamily::DECORATIVE;break; case FAMILY_MODERN: aFD.Family = css::awt::FontFamily::MODERN;break; @@ -108,7 +108,7 @@ css::uno::Any SAL_CALL FontIdentificator::getMaterial() aFD.Family = css::awt::FontFamily::DONTKNOW; break; } - switch( m_aFont.GetPitch() ) + switch( m_aFont.GetPitchMaybeAskConfig() ) { case PITCH_VARIABLE: aFD.Pitch = css::awt::FontPitch::VARIABLE;break; case PITCH_FIXED: aFD.Pitch = css::awt::FontPitch::FIXED;break; @@ -116,7 +116,7 @@ css::uno::Any SAL_CALL FontIdentificator::getMaterial() aFD.Pitch = css::awt::FontPitch::DONTKNOW; break; } - switch( m_aFont.GetWeight() ) + switch( m_aFont.GetWeightMaybeAskConfig() ) { case WEIGHT_THIN: aFD.Weight = css::awt::FontWeight::THIN;break; case WEIGHT_ULTRALIGHT: aFD.Weight = css::awt::FontWeight::ULTRALIGHT;break; @@ -132,7 +132,7 @@ css::uno::Any SAL_CALL FontIdentificator::getMaterial() aFD.Weight = css::awt::FontWeight::DONTKNOW; break; } - switch( m_aFont.GetItalic() ) + switch( m_aFont.GetItalicMaybeAskConfig() ) { case ITALIC_OBLIQUE: aFD.Slant = css::awt::FontSlant_OBLIQUE;break; case ITALIC_NORMAL: aFD.Slant = css::awt::FontSlant_ITALIC;break; diff --git a/vcl/source/filter/eps/eps.cxx b/vcl/source/filter/eps/eps.cxx index ccd62939fd56..314b182acf1e 100644 --- a/vcl/source/filter/eps/eps.cxx +++ b/vcl/source/filter/eps/eps.cxx @@ -2057,11 +2057,11 @@ void PSWriter::ImplSetAttrForText( const Point& rPoint ) if ( maLastFont != maFont ) { - if ( maFont.GetPitch() == PITCH_FIXED ) // a little bit font selection + if ( maFont.GetPitchMaybeAskConfig() == PITCH_FIXED ) // a little bit font selection ImplDefineFont( "Courier", "Oblique" ); else if ( maFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) ImplWriteLine( "/Symbol findfont" ); - else if ( maFont.GetFamilyType() == FAMILY_SWISS ) + else if ( maFont.GetFamilyTypeMaybeAskConfig() == FAMILY_SWISS ) ImplDefineFont( "Helvetica", "Oblique" ); else ImplDefineFont( "Times", "Italic" ); @@ -2091,18 +2091,18 @@ void PSWriter::ImplDefineFont( const char* pOriginalName, const char* pItalic ) { mpPS->WriteUChar( '/' ); //convert the font pOriginalName using ISOLatin1Encoding mpPS->WriteOString( pOriginalName ); - switch ( maFont.GetWeight() ) + switch ( maFont.GetWeightMaybeAskConfig() ) { case WEIGHT_SEMIBOLD : case WEIGHT_BOLD : case WEIGHT_ULTRABOLD : case WEIGHT_BLACK : mpPS->WriteOString( "-Bold" ); - if ( maFont.GetItalic() != ITALIC_NONE ) + if ( maFont.GetItalicMaybeAskConfig() != ITALIC_NONE ) mpPS->WriteOString( pItalic ); break; default: - if ( maFont.GetItalic() != ITALIC_NONE ) + if ( maFont.GetItalicMaybeAskConfig() != ITALIC_NONE ) mpPS->WriteOString( pItalic ); break; } diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx index c47fb0bbac4d..d84d2d28e6a2 100644 --- a/vcl/source/font/font.cxx +++ b/vcl/source/font/font.cxx @@ -368,7 +368,6 @@ void Font::Merge( const vcl::Font& rFont ) SetCharSet( rFont.GetCharSet() ); SetLanguageTag( rFont.GetLanguageTag() ); SetCJKContextLanguageTag( rFont.GetCJKContextLanguageTag() ); - // don't use access methods here, might lead to AskConfig(), if DONTKNOW SetFamily( rFont.GetFamilyType() ); SetPitch( rFont.GetPitch() ); } @@ -926,11 +925,11 @@ Degree10 Font::GetOrientation() const { return mpImplFont->mnOrientation; } bool Font::IsVertical() const { return mpImplFont->mbVertical; } FontKerning Font::GetKerning() const { return mpImplFont->meKerning; } -FontPitch Font::GetPitch() { return mpImplFont->GetPitch(); } -FontWeight Font::GetWeight() { return mpImplFont->GetWeight(); } -FontWidth Font::GetWidthType() { return mpImplFont->GetWidthType(); } -FontItalic Font::GetItalic() { return mpImplFont->GetItalic(); } -FontFamily Font::GetFamilyType() { return mpImplFont->GetFamilyType(); } +FontPitch Font::GetPitchMaybeAskConfig() { return mpImplFont->GetPitch(); } +FontWeight Font::GetWeightMaybeAskConfig() { return mpImplFont->GetWeight(); } +FontWidth Font::GetWidthTypeMaybeAskConfig() { return mpImplFont->GetWidthType(); } +FontItalic Font::GetItalicMaybeAskConfig() { return mpImplFont->GetItalic(); } +FontFamily Font::GetFamilyTypeMaybeAskConfig() { return mpImplFont->GetFamilyType(); } FontPitch Font::GetPitch() const { return mpImplFont->GetPitchNoAsk(); } FontWeight Font::GetWeight() const { return mpImplFont->GetWeightNoAsk(); } diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx index 84fb0019e9d1..8f490608d1e6 100644 --- a/vcl/source/gdi/mtfxmldump.cxx +++ b/vcl/source/gdi/mtfxmldump.cxx @@ -1331,7 +1331,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r rWriter.attribute("width", aFont.GetFontSize().Width()); rWriter.attribute("height", aFont.GetFontSize().Height()); rWriter.attribute("orientation", aFont.GetOrientation().get()); - rWriter.attribute("weight", convertFontWeightToString(aFont.GetWeight())); + rWriter.attribute("weight", convertFontWeightToString(aFont.GetWeightMaybeAskConfig())); rWriter.attribute("vertical", aFont.IsVertical() ? "true" : "false"); rWriter.attribute("emphasis", aFont.GetEmphasisMark() != FontEmphasisMark::NONE ? "true" : "false"); rWriter.attribute("shadow", aFont.IsShadow() ? "true" : "false"); diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 364bc44b7139..7c130ea6d3da 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -2882,7 +2882,7 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) aStyleSettings.SetHelpFont( aHelpFont ); aStyleSettings.SetIconFont( aIconFont ); - if ( aAppFont.GetWeight() > WEIGHT_NORMAL ) + if ( aAppFont.GetWeightMaybeAskConfig() > WEIGHT_NORMAL ) aAppFont.SetWeight( WEIGHT_NORMAL ); aStyleSettings.SetToolFont( aAppFont ); aStyleSettings.SetTabFont( aAppFont ); diff --git a/vcl/workben/listfonts.cxx b/vcl/workben/listfonts.cxx index 30718bb010b2..f15abddee5d1 100644 --- a/vcl/workben/listfonts.cxx +++ b/vcl/workben/listfonts.cxx @@ -374,11 +374,13 @@ int ListFonts::Main() FontMetric aFont = pOutDev->GetFontMetric(); - std::cout << aFont.GetFamilyName() << "\n\tFamily type: " << aFont.GetFamilyType() + std::cout << aFont.GetFamilyName() + << "\n\tFamily type: " << aFont.GetFamilyTypeMaybeAskConfig() << "\n\tStyle name: " << aFont.GetStyleName() - << "\n\tWeight: " << aFont.GetWeight() << "\n\tItalic: " << aFont.GetItalic() - << "\n\tPitch: " << aFont.GetPitch() - << "\n\tWidth type: " << aFont.GetWidthType() + << "\n\tWeight: " << aFont.GetWeightMaybeAskConfig() + << "\n\tItalic: " << aFont.GetItalicMaybeAskConfig() + << "\n\tPitch: " << aFont.GetPitchMaybeAskConfig() + << "\n\tWidth type: " << aFont.GetWidthTypeMaybeAskConfig() << "\n\tAlignment: " << aFont.GetAlignment() << "\n\tCharset: " << GetOctetTextEncodingName(aFont.GetCharSet()) << "\n\tAscent: " << aFont.GetAscent() |