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 <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn 2024-12-04 13:11:19 +01:00
parent 78ef285661
commit 7431507d24
8 changed files with 13 additions and 26 deletions

View file

@ -443,8 +443,7 @@ namespace accessibility
aFont = m_pTabBar->GetControlFont();
else
aFont = m_pTabBar->GetFont();
rtl::Reference<VCLXFont> pVCLXFont = new VCLXFont;
pVCLXFont->Init( *xDev, aFont );
rtl::Reference<VCLXFont> pVCLXFont = new VCLXFont(*xDev, aFont);
xFont = pVCLXFont;
}
}

View file

@ -293,8 +293,8 @@ Reference< awt::XFont > OAccessibleMenuComponent::getFont( )
if ( xDev.is() )
{
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
rtl::Reference<VCLXFont> pVCLXFont = new VCLXFont;
pVCLXFont->Init( *xDev, rStyleSettings.GetMenuFont() );
rtl::Reference<VCLXFont> pVCLXFont
= new VCLXFont(*xDev, rStyleSettings.GetMenuFont());
xFont = pVCLXFont;
}
}

View file

@ -497,8 +497,7 @@ Reference< awt::XFont > AccessibleDialogControlShape::getFont( )
aFont = pWindow->GetControlFont();
else
aFont = pWindow->GetFont();
rtl::Reference<VCLXFont> pVCLXFont = new VCLXFont;
pVCLXFont->Init( *xDev, aFont );
rtl::Reference<VCLXFont> pVCLXFont = new VCLXFont(*xDev, aFont);
xFont = pVCLXFont;
}
}

View file

@ -766,8 +766,7 @@ Reference< awt::XFont > AccessibleDialogWindow::getFont( )
aFont = m_pDialogWindow->GetControlFont();
else
aFont = m_pDialogWindow->GetFont();
rtl::Reference<VCLXFont> pVCLXFont = new VCLXFont;
pVCLXFont->Init( *xDev, aFont );
rtl::Reference<VCLXFont> pVCLXFont = new VCLXFont(*xDev, aFont);
xFont = pVCLXFont;
}
}

View file

@ -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

View file

@ -820,8 +820,7 @@ uno::Reference< awt::XFont > SAL_CALL VCLXAccessibleComponent::getFont( )
aFont = pWindow->GetControlFont();
else
aFont = pWindow->GetFont();
rtl::Reference<VCLXFont> pVCLXFont = new VCLXFont;
pVCLXFont->Init( *xDev, aFont );
rtl::Reference<VCLXFont> pVCLXFont = new VCLXFont(*xDev, aFont);
xFont = pVCLXFont;
}
}

View file

@ -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<VCLXFont> pMetric = new VCLXFont;
pMetric->Init( *this, VCLUnoHelper::CreateFont( rDescriptor, mpOutputDevice->GetFont() ) );
rtl::Reference<VCLXFont> pMetric
= new VCLXFont(*this, VCLUnoHelper::CreateFont(rDescriptor, mpOutputDevice->GetFont()));
xRef = pMetric;
}
return xRef;

View file

@ -30,24 +30,16 @@
#include <vcl/outdev.hxx>
#include <vcl/svapp.hxx>
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() )