From 7431507d247b6a5e867ae85647550f55d3641e31 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Wed, 4 Dec 2024 13:11:19 +0100 Subject: [PATCH] toolkit: Pass VCLXFont init args in ctor Pass arguments right away in ctor rather than having a ctor that takes no arguments and then having to call VCLXFont::Init with the arguments right after calling the ctor. Change-Id: I651e27154499f61638409377438f9589bc7412a3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177795 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- accessibility/source/extended/accessibletabbar.cxx | 3 +-- .../source/standard/accessiblemenucomponent.cxx | 4 ++-- .../accessibility/accessibledialogcontrolshape.cxx | 3 +-- .../accessibility/accessibledialogwindow.cxx | 3 +-- include/toolkit/awt/vclxfont.hxx | 5 ++--- toolkit/source/awt/vclxaccessiblecomponent.cxx | 3 +-- toolkit/source/awt/vclxdevice.cxx | 4 ++-- toolkit/source/awt/vclxfont.cxx | 14 +++----------- 8 files changed, 13 insertions(+), 26 deletions(-) diff --git a/accessibility/source/extended/accessibletabbar.cxx b/accessibility/source/extended/accessibletabbar.cxx index 2b1522f30a28..f6b722c09d88 100644 --- a/accessibility/source/extended/accessibletabbar.cxx +++ b/accessibility/source/extended/accessibletabbar.cxx @@ -443,8 +443,7 @@ namespace accessibility aFont = m_pTabBar->GetControlFont(); else aFont = m_pTabBar->GetFont(); - rtl::Reference pVCLXFont = new VCLXFont; - pVCLXFont->Init( *xDev, aFont ); + rtl::Reference pVCLXFont = new VCLXFont(*xDev, aFont); xFont = pVCLXFont; } } diff --git a/accessibility/source/standard/accessiblemenucomponent.cxx b/accessibility/source/standard/accessiblemenucomponent.cxx index 051828d21a1f..470a87fc8234 100644 --- a/accessibility/source/standard/accessiblemenucomponent.cxx +++ b/accessibility/source/standard/accessiblemenucomponent.cxx @@ -293,8 +293,8 @@ Reference< awt::XFont > OAccessibleMenuComponent::getFont( ) if ( xDev.is() ) { const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - rtl::Reference pVCLXFont = new VCLXFont; - pVCLXFont->Init( *xDev, rStyleSettings.GetMenuFont() ); + rtl::Reference pVCLXFont + = new VCLXFont(*xDev, rStyleSettings.GetMenuFont()); xFont = pVCLXFont; } } diff --git a/basctl/source/accessibility/accessibledialogcontrolshape.cxx b/basctl/source/accessibility/accessibledialogcontrolshape.cxx index 22e9403bfed2..0dbe0bbbf364 100644 --- a/basctl/source/accessibility/accessibledialogcontrolshape.cxx +++ b/basctl/source/accessibility/accessibledialogcontrolshape.cxx @@ -497,8 +497,7 @@ Reference< awt::XFont > AccessibleDialogControlShape::getFont( ) aFont = pWindow->GetControlFont(); else aFont = pWindow->GetFont(); - rtl::Reference pVCLXFont = new VCLXFont; - pVCLXFont->Init( *xDev, aFont ); + rtl::Reference pVCLXFont = new VCLXFont(*xDev, aFont); xFont = pVCLXFont; } } diff --git a/basctl/source/accessibility/accessibledialogwindow.cxx b/basctl/source/accessibility/accessibledialogwindow.cxx index 39b19e8a4462..48e887e34dd2 100644 --- a/basctl/source/accessibility/accessibledialogwindow.cxx +++ b/basctl/source/accessibility/accessibledialogwindow.cxx @@ -766,8 +766,7 @@ Reference< awt::XFont > AccessibleDialogWindow::getFont( ) aFont = m_pDialogWindow->GetControlFont(); else aFont = m_pDialogWindow->GetFont(); - rtl::Reference pVCLXFont = new VCLXFont; - pVCLXFont->Init( *xDev, aFont ); + rtl::Reference pVCLXFont = new VCLXFont(*xDev, aFont); xFont = pVCLXFont; } } diff --git a/include/toolkit/awt/vclxfont.hxx b/include/toolkit/awt/vclxfont.hxx index 16f349038287..4452659e8e4e 100644 --- a/include/toolkit/awt/vclxfont.hxx +++ b/include/toolkit/awt/vclxfont.hxx @@ -47,10 +47,9 @@ class UNLESS_MERGELIBS_MORE(TOOLKIT_DLLPUBLIC) VCLXFont final : bool ImplAssertValidFontMetric(); public: - VCLXFont(); - virtual ~VCLXFont() override; + VCLXFont(css::awt::XDevice& rxDev, const vcl::Font& rFont); + virtual ~VCLXFont() override; - void Init( css::awt::XDevice& rxDev, const vcl::Font& rFont ); const vcl::Font& GetFont() const { return maFont; } // css::lang::XFont diff --git a/toolkit/source/awt/vclxaccessiblecomponent.cxx b/toolkit/source/awt/vclxaccessiblecomponent.cxx index b53e56bf5921..e415f353c848 100644 --- a/toolkit/source/awt/vclxaccessiblecomponent.cxx +++ b/toolkit/source/awt/vclxaccessiblecomponent.cxx @@ -820,8 +820,7 @@ uno::Reference< awt::XFont > SAL_CALL VCLXAccessibleComponent::getFont( ) aFont = pWindow->GetControlFont(); else aFont = pWindow->GetFont(); - rtl::Reference pVCLXFont = new VCLXFont; - pVCLXFont->Init( *xDev, aFont ); + rtl::Reference pVCLXFont = new VCLXFont(*xDev, aFont); xFont = pVCLXFont; } } diff --git a/toolkit/source/awt/vclxdevice.cxx b/toolkit/source/awt/vclxdevice.cxx index c4ed98146713..13acc4d270ec 100644 --- a/toolkit/source/awt/vclxdevice.cxx +++ b/toolkit/source/awt/vclxdevice.cxx @@ -112,8 +112,8 @@ css::uno::Reference< css::awt::XFont > VCLXDevice::getFont( const css::awt::Font css::uno::Reference< css::awt::XFont > xRef; if( mpOutputDevice ) { - rtl::Reference pMetric = new VCLXFont; - pMetric->Init( *this, VCLUnoHelper::CreateFont( rDescriptor, mpOutputDevice->GetFont() ) ); + rtl::Reference pMetric + = new VCLXFont(*this, VCLUnoHelper::CreateFont(rDescriptor, mpOutputDevice->GetFont())); xRef = pMetric; } return xRef; diff --git a/toolkit/source/awt/vclxfont.cxx b/toolkit/source/awt/vclxfont.cxx index 32a42dec7579..d95ec480191b 100644 --- a/toolkit/source/awt/vclxfont.cxx +++ b/toolkit/source/awt/vclxfont.cxx @@ -30,24 +30,16 @@ #include #include -VCLXFont::VCLXFont() +VCLXFont::VCLXFont(css::awt::XDevice& rxDev, const vcl::Font& rFont) { - mpFontMetric = nullptr; + mxDevice = &rxDev; + maFont = rFont; } VCLXFont::~VCLXFont() { } -void VCLXFont::Init( css::awt::XDevice& rxDev, const vcl::Font& rFont ) -{ - mxDevice = &rxDev; - - mpFontMetric.reset(); - - maFont = rFont; -} - bool VCLXFont::ImplAssertValidFontMetric() { if ( !mpFontMetric && mxDevice.is() )