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 bbd7f5ddf343376a965c43f1f2b4c9977f5acf9b Author: Szymon Kłos <[email protected]> AuthorDate: Mon Nov 17 08:20:05 2025 +0000 Commit: Szymon Kłos <[email protected]> CommitDate: Wed Nov 26 12:47: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-on: https://gerrit.libreoffice.org/c/core/+/194551 Reviewed-by: Szymon Kłos <[email protected]> Tested-by: Jenkins Code-Style: Szymon Kłos <[email protected]> diff --git a/svx/source/inc/StylesPreviewToolBoxControl.hxx b/svx/source/inc/StylesPreviewToolBoxControl.hxx index cc31845207e7..af489f6166a1 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 9c66c66bf57d..6f3ebd0dfa6b 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>>&& rDefaultStyles, + 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 Bitmap GetCachedPreview(const std::pair<OUString, OUString>& rStyle); - static OString GetCachedPreviewJson(const std::pair<OUString, OUString>& rStyle); + static Bitmap 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>>&& rDefaultStyles, + 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 92604f0da913..c5a9cadc4cd2 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>(rStyle, sName)); + m_aDefaultStyles.push_back(StylePreviewDescriptor(rStyle, 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 ec0988106784..44eed42120a9 100644 --- a/svx/source/tbxctrls/StylesPreviewWindow.cxx +++ b/svx/source/tbxctrls/StylesPreviewWindow.cxx @@ -174,7 +174,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)) { @@ -436,12 +436,12 @@ void StyleItemController::DrawText(vcl::RenderContext& rRenderContext) } StylesPreviewWindow_Base::StylesPreviewWindow_Base( - weld::Builder& xBuilder, std::vector<std::pair<OUString, OUString>>&& rDefaultStyles, + 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(rDefaultStyles)) + , m_aDefaultStyles(rDefaultStyles) { StylePreviewCache::RegisterClient(); @@ -565,7 +565,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; @@ -575,7 +575,7 @@ IMPL_LINK(StylesPreviewWindow_Base, GetPreviewImage, const weld::encoded_image_q return true; } -Bitmap StylesPreviewWindow_Base::GetCachedPreview(const std::pair<OUString, OUString>& rStyle) +Bitmap StylesPreviewWindow_Base::GetCachedPreview(const StylePreviewDescriptor& rStyle) { auto aFound = StylePreviewCache::Get().find(rStyle.second); if (aFound != StylePreviewCache::Get().end()) @@ -595,7 +595,7 @@ Bitmap StylesPreviewWindow_Base::GetCachedPreview(const std::pair<OUString, OUSt } } -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()) @@ -651,11 +651,11 @@ void StylesPreviewWindow_Base::UpdateStylesList() } StylesPreviewWindow_Impl::StylesPreviewWindow_Impl( - vcl::Window* pParent, std::vector<std::pair<OUString, OUString>>&& rDefaultStyles, + 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(rDefaultStyles), xFrame) + , StylesPreviewWindow_Base(*m_xBuilder, rDefaultStyles, xFrame) { SetOptimalSize(); }
