diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-03-12 12:29:52 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-03-13 20:28:12 +0100 |
commit | b8d3d4ad0f5bf4f449118214a91219b98ee506c3 (patch) | |
tree | 47bcf39252f1357b0e97a628be4f5b4611297f78 | |
parent | c58cc416b604de0891fc8976bcf7cf099e2e8e00 (diff) |
merge the various SetPointFont via DefaultDevice calls
Change-Id: I769bb95c588c7222ff0dc6c4b845dfc3f0d7cbc0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112390
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | cui/source/dialogs/hangulhanjadlg.cxx | 4 | ||||
-rw-r--r-- | cui/source/dialogs/linkdlg.cxx | 5 | ||||
-rw-r--r-- | desktop/source/deployment/gui/dp_gui_extlistbox.cxx | 4 | ||||
-rw-r--r-- | include/vcl/weldutils.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/app/inputwin.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/dbgui/csvgrid.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/control/emojiview.cxx | 16 | ||||
-rw-r--r-- | sfx2/source/control/thumbnailview.cxx | 10 | ||||
-rw-r--r-- | svtools/source/control/ctrlbox.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/dbui/mailmergehelper.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/docvw/FrameControlsManager.cxx | 4 | ||||
-rw-r--r-- | vcl/source/app/weldutils.cxx | 6 | ||||
-rw-r--r-- | vcl/source/window/printdlg.cxx | 7 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 3 |
14 files changed, 39 insertions, 42 deletions
diff --git a/cui/source/dialogs/hangulhanjadlg.cxx b/cui/source/dialogs/hangulhanjadlg.cxx index 76c6bdd000a7..9ec24c5cb72e 100644 --- a/cui/source/dialogs/hangulhanjadlg.cxx +++ b/cui/source/dialogs/hangulhanjadlg.cxx @@ -30,6 +30,7 @@ #include <i18nlangtag/languagetag.hxx> #include <vcl/svapp.hxx> #include <vcl/virdev.hxx> +#include <vcl/weldutils.hxx> #include <unotools/lingucfg.hxx> #include <unotools/linguprops.hxx> #include <com/sun/star/lang/NoSupportException.hpp> @@ -216,8 +217,7 @@ namespace svx , m_xControl(std::move(xControl)) { // expand the point size of the desired font to the equivalent pixel size - if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice())) - pDefaultDevice->SetPointFont(*m_xVirDev, m_xControl->get_font()); + weld::SetPointFont(*m_xVirDev, m_xControl->get_font()); } void RubyRadioButton::init( const OUString& rPrimaryText, const OUString& rSecondaryText, const PseudoRubyText::RubyPosition& rPosition ) diff --git a/cui/source/dialogs/linkdlg.cxx b/cui/source/dialogs/linkdlg.cxx index 764d29e0c191..cc26e551b994 100644 --- a/cui/source/dialogs/linkdlg.cxx +++ b/cui/source/dialogs/linkdlg.cxx @@ -26,7 +26,7 @@ #include <vcl/idle.hxx> #include <vcl/timer.hxx> #include <vcl/weld.hxx> -#include <vcl/window.hxx> +#include <vcl/weldutils.hxx> #include <strings.hrc> #include <sfx2/linkmgr.hxx> @@ -95,8 +95,7 @@ SvBaseLinksDlg::SvBaseLinksDlg(weld::Window * pParent, LinkManager* pMgr, bool b , m_xVirDev(VclPtr<VirtualDevice>::Create()) { // expand the point size of the desired font to the equivalent pixel size - if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice())) - pDefaultDevice->SetPointFont(*m_xVirDev, m_xTbLinks->get_font()); + weld::SetPointFont(*m_xVirDev, m_xTbLinks->get_font()); m_xTbLinks->set_size_request(m_xTbLinks->get_approximate_digit_width() * 90, m_xTbLinks->get_height_rows(12)); diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index 980e086ebc69..0adcfa1bf9a1 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -41,6 +41,7 @@ #include <vcl/ptrstyle.hxx> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> +#include <vcl/weldutils.hxx> #include <algorithm> #define USER_PACKAGE_MANAGER "user" @@ -422,8 +423,7 @@ void ExtensionBox_Impl::DrawRow(vcl::RenderContext& rRenderContext, const tools: // Setup fonts // expand the point size of the desired font to the equivalent pixel size - if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice())) - pDefaultDevice->SetPointFont(rRenderContext, GetDrawingArea()->get_font()); + weld::SetPointFont(rRenderContext, GetDrawingArea()->get_font()); vcl::Font aStdFont(rRenderContext.GetFont()); vcl::Font aBoldFont(aStdFont); aBoldFont.SetWeight(WEIGHT_BOLD); diff --git a/include/vcl/weldutils.hxx b/include/vcl/weldutils.hxx index 86af6c6e95ee..b75b94d99e52 100644 --- a/include/vcl/weldutils.hxx +++ b/include/vcl/weldutils.hxx @@ -434,6 +434,9 @@ VCL_DLLPUBLIC int GetMinimumEditHeight(); // from relative to rOutWin to relative to that weld::Window suitable for use // with popup_at_rect VCL_DLLPUBLIC weld::Window* GetPopupParent(vcl::Window& rOutWin, tools::Rectangle& rRect); + +// Use Application::GetDefaultDevice to set the PointFont rFont to the OutputDevice +VCL_DLLPUBLIC void SetPointFont(OutputDevice& rDevice, const vcl::Font& rFont); } #endif diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index bc91f0c835b6..926157e71d83 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -2051,8 +2051,7 @@ void ScTextWnd::SetDrawingArea(weld::DrawingArea* pDrawingArea) // always use application font, so a font with cjk chars can be installed vcl::Font aAppFont = Application::GetSettings().GetStyleSettings().GetAppFont(); - if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice())) - pDefaultDevice->SetPointFont(rDevice, aAppFont); + weld::SetPointFont(rDevice, aAppFont); aTextFont = rDevice.GetFont(); Size aFontSize = aTextFont.GetFontSize(); diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx index d289ec0f69d4..a732039c788f 100644 --- a/sc/source/ui/dbgui/csvgrid.cxx +++ b/sc/source/ui/dbgui/csvgrid.cxx @@ -38,6 +38,7 @@ #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <vcl/virdev.hxx> +#include <vcl/weldutils.hxx> #include <editeng/colritem.hxx> #include <editeng/fhgtitem.hxx> @@ -96,11 +97,8 @@ void ScCsvGrid::SetDrawingArea(weld::DrawingArea* pDrawingArea) maHeaderFont = Application::GetSettings().GetStyleSettings().GetAppFont(); // expand the point size of the desired font to the equivalent pixel size - if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice())) - { - pDefaultDevice->SetPointFont(rRefDevice, maHeaderFont); - maHeaderFont = rRefDevice.GetFont(); - } + weld::SetPointFont(rRefDevice, maHeaderFont); + maHeaderFont = rRefDevice.GetFont(); // Because this is an always LeftToRight layout widget the initial size of // this widget needs to be smaller than the size of the parent scrolling diff --git a/sfx2/source/control/emojiview.cxx b/sfx2/source/control/emojiview.cxx index 78b7dc96c19f..e5bebe9f8f3b 100644 --- a/sfx2/source/control/emojiview.cxx +++ b/sfx2/source/control/emojiview.cxx @@ -16,6 +16,7 @@ #include <comphelper/processfactory.hxx> #include <vcl/event.hxx> #include <vcl/svapp.hxx> +#include <vcl/weldutils.hxx> #include <orcus/json_document_tree.hpp> #include <orcus/config.hpp> @@ -82,15 +83,12 @@ void EmojiView::SetDrawingArea(weld::DrawingArea* pDrawingArea) { ThumbnailView::SetDrawingArea(pDrawingArea); - if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice())) - { - uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext()); - OUString sFontName(officecfg::Office::Common::Misc::EmojiFont::get(xContext)); - vcl::Font aFont = pDrawingArea->get_font(); - aFont.SetFamilyName(sFontName); - OutputDevice& rDevice = pDrawingArea->get_ref_device(); - pDefaultDevice->SetPointFont(rDevice, aFont); - } + uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext()); + OUString sFontName(officecfg::Office::Common::Misc::EmojiFont::get(xContext)); + vcl::Font aFont = pDrawingArea->get_font(); + aFont.SetFamilyName(sFontName); + OutputDevice& rDevice = pDrawingArea->get_ref_device(); + weld::SetPointFont(rDevice, aFont); mpItemAttrs->aFontSize.setX(ITEM_MAX_WIDTH - 2*ITEM_PADDING); mpItemAttrs->aFontSize.setY(ITEM_MAX_HEIGHT - 2*ITEM_PADDING); diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index f9624027755e..c8cd25e22d61 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -31,6 +31,7 @@ #include <vcl/settings.hxx> #include <vcl/event.hxx> #include <vcl/filter/PngImageReader.hxx> +#include <vcl/weldutils.hxx> #include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <com/sun/star/embed/ElementModes.hpp> @@ -890,12 +891,9 @@ void ThumbnailView::SetDrawingArea(weld::DrawingArea* pDrawingArea) { CustomWidgetController::SetDrawingArea(pDrawingArea); - if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice())) - { - OutputDevice& rDevice = pDrawingArea->get_ref_device(); - pDefaultDevice->SetPointFont(rDevice, pDrawingArea->get_font()); - mpItemAttrs->aFontAttr = getFontAttributeFromVclFont(mpItemAttrs->aFontSize, rDevice.GetFont(), false, true); - } + OutputDevice& rDevice = pDrawingArea->get_ref_device(); + weld::SetPointFont(rDevice, pDrawingArea->get_font()); + mpItemAttrs->aFontAttr = getFontAttributeFromVclFont(mpItemAttrs->aFontSize, rDevice.GetFont(), false, true); SetOutputSizePixel(pDrawingArea->get_preferred_size()); } diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx index 393c7439e2cb..7e39f8eab8c2 100644 --- a/svtools/source/control/ctrlbox.cxx +++ b/svtools/source/control/ctrlbox.cxx @@ -30,6 +30,7 @@ #include <vcl/settings.hxx> #include <vcl/image.hxx> #include <vcl/virdev.hxx> +#include <vcl/weldutils.hxx> #include <rtl/math.hxx> #include <sal/macros.h> #include <sal/log.hxx> @@ -772,8 +773,7 @@ OutputDevice& FontNameBox::CachePreview(size_t nIndex, Point* pTopLeft) gFontPreviewVirDevs.emplace_back(m_xComboBox->create_render_virtual_device()); VirtualDevice& rDevice = *gFontPreviewVirDevs.back(); rDevice.SetOutputSizePixel(Size(gUserItemSz.Width(), gUserItemSz.Height() * gPreviewsPerDevice)); - if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice())) - pDefaultDevice->SetPointFont(rDevice, m_xComboBox->get_font()); + weld::SetPointFont(rDevice, m_xComboBox->get_font()); assert(gFontPreviewVirDevs.size() == nPage + 1); } diff --git a/sw/source/uibase/dbui/mailmergehelper.cxx b/sw/source/uibase/dbui/mailmergehelper.cxx index 2ef71463f870..762956faba57 100644 --- a/sw/source/uibase/dbui/mailmergehelper.cxx +++ b/sw/source/uibase/dbui/mailmergehelper.cxx @@ -36,6 +36,7 @@ #include <vcl/event.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> +#include <vcl/weldutils.hxx> #include <tools/diagnose_ex.h> #include <sfx2/passwd.hxx> @@ -378,8 +379,7 @@ void SwAddressPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Re Color aPaintColor(IsEnabled() ? rSettings.GetWindowTextColor() : rSettings.GetDisableColor()); rRenderContext.SetLineColor(aPaintColor); - if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice())) - pDefaultDevice->SetPointFont(rRenderContext, GetDrawingArea()->get_font()); + weld::SetPointFont(rRenderContext, GetDrawingArea()->get_font()); vcl::Font aFont(rRenderContext.GetFont()); aFont.SetColor(aPaintColor); rRenderContext.SetFont(aFont); diff --git a/sw/source/uibase/docvw/FrameControlsManager.cxx b/sw/source/uibase/docvw/FrameControlsManager.cxx index c9503e2a06d6..aaf7aefd1302 100644 --- a/sw/source/uibase/docvw/FrameControlsManager.cxx +++ b/sw/source/uibase/docvw/FrameControlsManager.cxx @@ -23,6 +23,7 @@ #include <IDocumentOutlineNodes.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> +#include <vcl/weldutils.hxx> using namespace std; @@ -334,8 +335,7 @@ void SwFrameMenuButtonBase::SetVirDevFont() { // Get the font and configure it vcl::Font aFont = Application::GetSettings().GetStyleSettings().GetToolFont(); - if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice())) - pDefaultDevice->SetPointFont(*m_xVirDev, aFont); + weld::SetPointFont(*m_xVirDev, aFont); } SwFrameControl::SwFrameControl( const VclPtr<vcl::Window> &pWindow ) diff --git a/vcl/source/app/weldutils.cxx b/vcl/source/app/weldutils.cxx index be3618615b9c..b930e7a02187 100644 --- a/vcl/source/app/weldutils.cxx +++ b/vcl/source/app/weldutils.cxx @@ -614,6 +614,12 @@ weld::Window* GetPopupParent(vcl::Window& rOutWin, tools::Rectangle& rRect) return rOutWin.GetFrameWeld(); } + +void SetPointFont(OutputDevice& rDevice, const vcl::Font& rFont) +{ + if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice())) + pDefaultDevice->SetPointFont(rDevice, rFont); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index a7b1bd96e9ba..324f0f007736 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -35,6 +35,7 @@ #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <vcl/virdev.hxx> +#include <vcl/weldutils.hxx> #include <unotools/localedatawrapper.hxx> @@ -122,11 +123,7 @@ void PrintDialog::PrintPreviewWindow::Resize() void PrintDialog::PrintPreviewWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { rRenderContext.Push(); - if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice())) - { - Font aFont(rRenderContext.GetSettings().GetStyleSettings().GetLabelFont()); - pDefaultDevice->SetPointFont(rRenderContext, aFont); - } + weld::SetPointFont(rRenderContext, rRenderContext.GetSettings().GetStyleSettings().GetLabelFont()); rRenderContext.SetBackground(Wallpaper(Application::GetSettings().GetStyleSettings().GetDialogColor())); rRenderContext.Erase(); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index bdebc7985ba4..882a6f0210e5 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -12449,8 +12449,7 @@ void ensure_device(CustomCellRendererSurface *cellsurface, weld::Widget* pWidget cellsurface->device = VclPtr<VirtualDevice>::Create(); cellsurface->device->SetBackground(COL_TRANSPARENT); // expand the point size of the desired font to the equivalent pixel size - if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice())) - pDefaultDevice->SetPointFont(*cellsurface->device, pWidget->get_font()); + weld::SetPointFont(*cellsurface->device, pWidget->get_font()); } } |