[Libreoffice-commits] core.git: include/svtools svtools/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Fri Sep 11 13:20:14 UTC 2020
include/svtools/ctrlbox.hxx | 6 ++--
svtools/source/control/ctrlbox.cxx | 51 ++++++++++++++++++++++++++-----------
2 files changed, 40 insertions(+), 17 deletions(-)
New commits:
commit 6a12fa6a77e407bf2d1e8be47f915ade8e1eab28
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Sep 11 11:53:12 2020 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Sep 11 15:19:32 2020 +0200
invalidate prerendered fontname cache on style change
Change-Id: Ie2111f23dc3346b914442090e3d9257c5659fafc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102459
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/svtools/ctrlbox.hxx b/include/svtools/ctrlbox.hxx
index 7411976b1642..817e276665d4 100644
--- a/include/svtools/ctrlbox.hxx
+++ b/include/svtools/ctrlbox.hxx
@@ -30,10 +30,11 @@
namespace weld { class CustomWeld; }
-class VirtualDevice;
class BitmapEx;
class BorderWidthImpl;
class FontList;
+class VclSimpleEvent;
+class VirtualDevice;
/** Utility class storing the border line width, style and colors. The widths
are defined in Twips.
@@ -339,7 +340,8 @@ private:
SVT_DLLPRIVATE void ImplDestroyFontList();
DECL_LINK(CustomRenderHdl, weld::ComboBox::render_args, void);
- DECL_STATIC_LINK(FontNameBox, CustomGetSizeHdl, OutputDevice&, Size);
+ DECL_LINK(CustomGetSizeHdl, OutputDevice&, Size);
+ DECL_LINK(SettingsChangedHdl, VclSimpleEvent&, void);
DECL_LINK(UpdateHdl, Timer*, void);
void LoadMRUEntries( const OUString& aFontMRUEntriesFile );
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 8287418a4fe4..3c553f531556 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -336,6 +336,35 @@ static size_t gPreviewsPerDevice;
static std::vector<VclPtr<VirtualDevice>> gFontPreviewVirDevs;
static std::vector<OUString> gRenderedFontNames;
+namespace
+{
+ void calcCustomItemSize(weld::ComboBox& rComboBox)
+ {
+ gUserItemSz = Size(rComboBox.get_approximate_digit_width() * 52, rComboBox.get_text_height());
+ gUserItemSz.setHeight(gUserItemSz.Height() * 16);
+ gUserItemSz.setHeight(gUserItemSz.Height() / 10);
+
+ size_t nMaxDeviceHeight = SAL_MAX_INT16 / 2; // see limitXCreatePixmap
+ gPreviewsPerDevice = nMaxDeviceHeight / gUserItemSz.Height();
+ }
+}
+
+IMPL_LINK(FontNameBox, SettingsChangedHdl, VclSimpleEvent&, rEvent, void)
+{
+ if (rEvent.GetId() != VclEventId::ApplicationDataChanged)
+ return;
+
+ DataChangedEvent* pData = static_cast<DataChangedEvent*>(static_cast<VclWindowEvent&>(rEvent).GetData());
+ if (pData->GetType() == DataChangedEventType::SETTINGS)
+ {
+ gFontPreviewVirDevs.clear();
+ gRenderedFontNames.clear();
+ calcCustomItemSize(*m_xComboBox);
+ if (mbWYSIWYG)
+ maUpdateIdle.Start();
+ }
+}
+
FontNameBox::FontNameBox(std::unique_ptr<weld::ComboBox> p)
: m_xComboBox(std::move(p))
, mnPreviewProgress(0)
@@ -347,10 +376,14 @@ FontNameBox::FontNameBox(std::unique_ptr<weld::ComboBox> p)
maUpdateIdle.SetPriority(TaskPriority::LOWEST);
maUpdateIdle.SetInvokeHandler(LINK(this, FontNameBox, UpdateHdl));
+
+ Application::AddEventListener(LINK(this, FontNameBox, SettingsChangedHdl));
}
FontNameBox::~FontNameBox()
{
+ Application::RemoveEventListener(LINK(this, FontNameBox, SettingsChangedHdl));
+
if (mpFontList)
{
SaveMRUEntries (maFontMRUEntriesFile);
@@ -473,21 +506,9 @@ void FontNameBox::EnableWYSIWYG(bool bEnable)
return;
mbWYSIWYG = bEnable;
- static bool bGlobalsInited;
- if (mbWYSIWYG && !bGlobalsInited)
- {
- gUserItemSz = Size(m_xComboBox->get_approximate_digit_width() * 52, m_xComboBox->get_text_height());
- gUserItemSz.setHeight(gUserItemSz.Height() * 16);
- gUserItemSz.setHeight(gUserItemSz.Height() / 10);
-
- size_t nMaxDeviceHeight = SAL_MAX_INT16 / 2; // see limitXCreatePixmap
- gPreviewsPerDevice = nMaxDeviceHeight / gUserItemSz.Height();
-
- bGlobalsInited = true;
- }
-
if (mbWYSIWYG)
{
+ calcCustomItemSize(*m_xComboBox);
m_xComboBox->connect_custom_get_size(LINK(this, FontNameBox, CustomGetSizeHdl));
m_xComboBox->connect_custom_render(LINK(this, FontNameBox, CustomRenderHdl));
}
@@ -499,9 +520,9 @@ void FontNameBox::EnableWYSIWYG(bool bEnable)
m_xComboBox->set_custom_renderer(mbWYSIWYG);
}
-IMPL_STATIC_LINK_NOARG(FontNameBox, CustomGetSizeHdl, OutputDevice&, Size)
+IMPL_LINK_NOARG(FontNameBox, CustomGetSizeHdl, OutputDevice&, Size)
{
- return gUserItemSz;
+ return mbWYSIWYG ? gUserItemSz : Size();
}
namespace
More information about the Libreoffice-commits
mailing list