summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-09-11 11:53:12 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-09-11 15:19:32 +0200
commit6a12fa6a77e407bf2d1e8be47f915ade8e1eab28 (patch)
tree7f30057a882c25c36d1f476179b7f04ffb8f3b2b
parente628b94ccf062c2f3161acef11012ae2f5fbc5a3 (diff)
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@redhat.com>
-rw-r--r--include/svtools/ctrlbox.hxx6
-rw-r--r--svtools/source/control/ctrlbox.cxx51
2 files changed, 40 insertions, 17 deletions
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