svx/source/inc/StylesPreviewToolBoxControl.hxx      |    2 -
 svx/source/inc/StylesPreviewWindow.hxx              |   22 ++++++++++----------
 svx/source/tbxctrls/StylesPreviewToolBoxControl.cxx |    8 +++----
 svx/source/tbxctrls/StylesPreviewWindow.cxx         |   16 +++++++-------
 4 files changed, 25 insertions(+), 23 deletions(-)

New commits:
commit 26cf5bcb27659d1c0a22de2b155968b8fcb2e750
Author:     Szymon Kłos <[email protected]>
AuthorDate: Mon Nov 17 08:20:05 2025 +0000
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Mon Nov 17 14:11:56 2025 +0100

    notebookbar: type definition for style preview entries
    
    - it helps with change of the used type in single place and identify
      pieces of code using the same structure
    - document what is inside of std::pair (id, name)
    
    Change-Id: I6e061d03c1ca540b25c253152c5641f6fc71060d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194093
    Reviewed-by: Tomaž Vajngerl <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/svx/source/inc/StylesPreviewToolBoxControl.hxx 
b/svx/source/inc/StylesPreviewToolBoxControl.hxx
index f0466fe6cd6c..a679f887dc5d 100644
--- a/svx/source/inc/StylesPreviewToolBoxControl.hxx
+++ b/svx/source/inc/StylesPreviewToolBoxControl.hxx
@@ -31,7 +31,7 @@ class StylesPreviewToolBoxControl final
     VclPtr<StylesPreviewWindow_Impl> m_xVclBox;
     std::unique_ptr<StylesPreviewWindow_Base> m_xWeldBox;
 
-    std::vector<std::pair<OUString, OUString>> m_aDefaultStyles;
+    StylePreviewList m_aDefaultStyles;
 
 public:
     StylesPreviewToolBoxControl();
diff --git a/svx/source/inc/StylesPreviewWindow.hxx 
b/svx/source/inc/StylesPreviewWindow.hxx
index 455462659079..d9e835bed16b 100644
--- a/svx/source/inc/StylesPreviewWindow.hxx
+++ b/svx/source/inc/StylesPreviewWindow.hxx
@@ -26,6 +26,10 @@
 #include <com/sun/star/frame/XFrame.hpp>
 #include <sfx2/sfxstatuslistener.hxx>
 
+// pair of id and name, name can be translated to other language
+typedef std::pair<OUString, OUString> StylePreviewDescriptor;
+typedef std::vector<StylePreviewDescriptor> StylePreviewList;
+
 class StylesPreviewWindow_Base;
 
 /// Listener for style selection
@@ -59,10 +63,10 @@ class StyleItemController
     static constexpr unsigned LEFT_MARGIN = 8;
 
     SfxStyleFamily m_eStyleFamily;
-    std::pair<OUString, OUString> m_aStyleName;
+    StylePreviewDescriptor m_aStyleName;
 
 public:
-    StyleItemController(std::pair<OUString, OUString> aStyleName);
+    StyleItemController(StylePreviewDescriptor aStyleName);
 
     void Paint(vcl::RenderContext& rRenderContext);
 
@@ -105,8 +109,8 @@ protected:
     rtl::Reference<StyleStatusListener> m_xStatusListener;
     std::unique_ptr<StylePoolChangeListener> m_pStylePoolChangeListener;
 
-    std::vector<std::pair<OUString, OUString>> m_aDefaultStyles;
-    std::vector<std::pair<OUString, OUString>> m_aAllStyles;
+    StylePreviewList m_aDefaultStyles;
+    StylePreviewList m_aAllStyles;
 
     OUString m_sSelectedStyle;
 
@@ -116,15 +120,14 @@ protected:
     DECL_LINK(GetPreviewImage, const weld::encoded_image_query&, bool);
 
 public:
-    StylesPreviewWindow_Base(weld::Builder& xBuilder,
-                             std::vector<std::pair<OUString, OUString>>&& 
aDefaultStyles,
+    StylesPreviewWindow_Base(weld::Builder& xBuilder, StylePreviewList& 
rDefaultStyles,
                              const css::uno::Reference<css::frame::XFrame>& 
xFrame);
     ~StylesPreviewWindow_Base();
 
     void Select(const OUString& rStyleName);
     void RequestStylesListUpdate();
-    static VclPtr<VirtualDevice> GetCachedPreview(const std::pair<OUString, 
OUString>& rStyle);
-    static OString GetCachedPreviewJson(const std::pair<OUString, OUString>& 
rStyle);
+    static VclPtr<VirtualDevice> GetCachedPreview(const 
StylePreviewDescriptor& rStyle);
+    static OString GetCachedPreviewJson(const StylePreviewDescriptor& rStyle);
 
 private:
     void UpdateStylesList();
@@ -135,8 +138,7 @@ private:
 class StylesPreviewWindow_Impl final : public InterimItemWindow, public 
StylesPreviewWindow_Base
 {
 public:
-    StylesPreviewWindow_Impl(vcl::Window* pParent,
-                             std::vector<std::pair<OUString, OUString>>&& 
aDefaultStyles,
+    StylesPreviewWindow_Impl(vcl::Window* pParent, StylePreviewList& 
rDefaultStyles,
                              const css::uno::Reference<css::frame::XFrame>& 
xFrame);
     ~StylesPreviewWindow_Impl();
 
diff --git a/svx/source/tbxctrls/StylesPreviewToolBoxControl.cxx 
b/svx/source/tbxctrls/StylesPreviewToolBoxControl.cxx
index a15d81f01be8..224a3bab82e8 100644
--- a/svx/source/tbxctrls/StylesPreviewToolBoxControl.cxx
+++ b/svx/source/tbxctrls/StylesPreviewToolBoxControl.cxx
@@ -76,7 +76,7 @@ void StylesPreviewToolBoxControl::InitializeStyles(
                     OUString sName;
                     xStyle->getPropertyValue(u"DisplayName"_ustr) >>= sName;
                     if (!sName.isEmpty())
-                        m_aDefaultStyles.push_back(std::pair<OUString, 
OUString>(aStyle, sName));
+                        
m_aDefaultStyles.push_back(StylePreviewDescriptor(aStyle, sName));
                 }
                 catch (const css::container::NoSuchElementException&)
                 {
@@ -109,7 +109,7 @@ void StylesPreviewToolBoxControl::InitializeStyles(
                             if (!sName.isEmpty())
                             {
                                 m_aDefaultStyles.push_back(
-                                    std::pair<OUString, OUString>(sStyleName, 
sName));
+                                    StylePreviewDescriptor(sStyleName, sName));
                             }
                         }
                     }
@@ -156,8 +156,8 @@ StylesPreviewToolBoxControl::createItemWindow(const 
css::uno::Reference<css::awt
         {
             SolarMutexGuard aSolarMutexGuard;
 
-            m_xVclBox = VclPtr<StylesPreviewWindow_Impl>::Create(
-                pParent, std::vector(m_aDefaultStyles), m_xFrame);
+            m_xVclBox
+                = VclPtr<StylesPreviewWindow_Impl>::Create(pParent, 
m_aDefaultStyles, m_xFrame);
             xItemWindow = VCLUnoHelper::GetInterface(m_xVclBox);
         }
     }
diff --git a/svx/source/tbxctrls/StylesPreviewWindow.cxx 
b/svx/source/tbxctrls/StylesPreviewWindow.cxx
index cd679978d572..4384281dafaf 100644
--- a/svx/source/tbxctrls/StylesPreviewWindow.cxx
+++ b/svx/source/tbxctrls/StylesPreviewWindow.cxx
@@ -179,7 +179,7 @@ void StylePoolChangeListener::Notify(SfxBroadcaster& 
/*rBC*/, const SfxHint& rHi
     m_pPreviewControl->RequestStylesListUpdate();
 }
 
-StyleItemController::StyleItemController(std::pair<OUString, OUString> 
aStyleName)
+StyleItemController::StyleItemController(StylePreviewDescriptor aStyleName)
     : m_eStyleFamily(SfxStyleFamily::Para)
     , m_aStyleName(std::move(aStyleName))
 {
@@ -443,12 +443,12 @@ void StyleItemController::DrawText(vcl::RenderContext& 
rRenderContext)
 }
 
 StylesPreviewWindow_Base::StylesPreviewWindow_Base(
-    weld::Builder& xBuilder, std::vector<std::pair<OUString, OUString>>&& 
aDefaultStyles,
+    weld::Builder& xBuilder, StylePreviewList& rDefaultStyles,
     const css::uno::Reference<css::frame::XFrame>& xFrame)
     : m_xFrame(xFrame)
     , m_xStylesView(xBuilder.weld_icon_view(u"stylesview"_ustr))
     , m_aUpdateTask(*this)
-    , m_aDefaultStyles(std::move(aDefaultStyles))
+    , m_aDefaultStyles(rDefaultStyles)
 {
     StylePreviewCache::RegisterClient();
 
@@ -572,7 +572,7 @@ IMPL_LINK(StylesPreviewWindow_Base, GetPreviewImage, const 
weld::encoded_image_q
     const weld::TreeIter& rIter = std::get<1>(rQuery);
     OUString sStyleId(m_xStylesView->get_id(rIter));
     OUString sStyleName(m_xStylesView->get_text(rIter));
-    OString sBase64Png(GetCachedPreviewJson(std::pair<OUString, 
OUString>(sStyleId, sStyleName)));
+    OString sBase64Png(GetCachedPreviewJson(StylePreviewDescriptor(sStyleId, 
sStyleName)));
     if (sBase64Png.isEmpty())
         return false;
 
@@ -583,7 +583,7 @@ IMPL_LINK(StylesPreviewWindow_Base, GetPreviewImage, const 
weld::encoded_image_q
 }
 
 VclPtr<VirtualDevice>
-StylesPreviewWindow_Base::GetCachedPreview(const std::pair<OUString, 
OUString>& rStyle)
+StylesPreviewWindow_Base::GetCachedPreview(const StylePreviewDescriptor& 
rStyle)
 {
     auto aFound = StylePreviewCache::Get().find(rStyle.second);
     if (aFound != StylePreviewCache::Get().end())
@@ -602,7 +602,7 @@ StylesPreviewWindow_Base::GetCachedPreview(const 
std::pair<OUString, OUString>&
     }
 }
 
-OString StylesPreviewWindow_Base::GetCachedPreviewJson(const 
std::pair<OUString, OUString>& rStyle)
+OString StylesPreviewWindow_Base::GetCachedPreviewJson(const 
StylePreviewDescriptor& rStyle)
 {
     auto aJsonFound = StylePreviewCache::GetJson().find(rStyle.second);
     if (aJsonFound != StylePreviewCache::GetJson().end())
@@ -654,11 +654,11 @@ void StylesPreviewWindow_Base::UpdateStylesList()
 }
 
 StylesPreviewWindow_Impl::StylesPreviewWindow_Impl(
-    vcl::Window* pParent, std::vector<std::pair<OUString, OUString>>&& 
aDefaultStyles,
+    vcl::Window* pParent, StylePreviewList& rDefaultStyles,
     const css::uno::Reference<css::frame::XFrame>& xFrame)
     : InterimItemWindow(pParent, u"svx/ui/stylespreview.ui"_ustr, 
u"ApplyStyleBox"_ustr, true,
                         reinterpret_cast<sal_uInt64>(SfxViewShell::Current()))
-    , StylesPreviewWindow_Base(*m_xBuilder, std::move(aDefaultStyles), xFrame)
+    , StylesPreviewWindow_Base(*m_xBuilder, rDefaultStyles, xFrame)
 {
     SetOptimalSize();
 }

Reply via email to