include/sfx2/sidebar/TabBar.hxx           |    5 ++---
 sfx2/source/sidebar/SidebarController.cxx |    2 +-
 sfx2/source/sidebar/TabBar.cxx            |   16 ++++++++--------
 sfx2/source/sidebar/uiobject.cxx          |    2 +-
 4 files changed, 12 insertions(+), 13 deletions(-)

New commits:
commit 384331baab1166d9a7abdebc25e6ae1a1772179f
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Jun 17 13:26:18 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Jun 27 16:40:48 2024 +0200

    tdf#159835 sfx2: Use reference instead of pointer
    
    This e.g. makes it clear that this is never null.
    Also use an `m` prefix for the class member.
    
    Change-Id: Ia66245f17e7f0ca9e57750e8606c8ccc1387eb97
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169004
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    (cherry picked from commit 8a10012039204b208aea3bc2f9da9fe1162c4a2a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169244
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/include/sfx2/sidebar/TabBar.hxx b/include/sfx2/sidebar/TabBar.hxx
index 6ef0fc9c3ddd..bb7e48f3cd51 100644
--- a/include/sfx2/sidebar/TabBar.hxx
+++ b/include/sfx2/sidebar/TabBar.hxx
@@ -61,7 +61,7 @@ public:
         const css::uno::Reference<css::frame::XFrame>& rxFrame,
         ::std::function<void (const OUString& rsDeckId)> 
aDeckActivationFunctor,
         PopupMenuProvider aPopupMenuProvider,
-        SidebarController* rParentSidebarController);
+        SidebarController& rParentSidebarController);
 
     weld::Container* GetContainer() { return m_xContainer.get(); }
 
@@ -127,9 +127,8 @@ private:
 
     DECL_LINK(OnToolboxClicked, weld::Toggleable&, void);
 
-    SidebarController* pParentSidebarController;
+    SidebarController& mrParentSidebarController;
     std::unique_ptr<svt::AcceleratorExecute> mpAccel;
-
 };
 
 
diff --git a/sfx2/source/sidebar/SidebarController.cxx 
b/sfx2/source/sidebar/SidebarController.cxx
index 3e76cb2b14af..d7234553e86a 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -119,7 +119,7 @@ SidebarController::SidebarController (
               [this](const OUString& rsDeckId) { return 
this->OpenThenToggleDeck(rsDeckId); },
               [this](weld::Menu& rMainMenu, weld::Menu& rSubMenu,
                      const ::std::vector<TabBar::DeckMenuData>& rMenuData) { 
return this->ShowPopupMenu(rMainMenu, rSubMenu, rMenuData); },
-              this)),
+              *this)),
       maCurrentContext(OUString(), OUString()),
       maRequestedContext(OUString(), OUString()),
       mnRequestedForceFlags(SwitchFlag_NoForce),
diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx
index 9d92d24cd93a..ffc6959e3904 100644
--- a/sfx2/source/sidebar/TabBar.cxx
+++ b/sfx2/source/sidebar/TabBar.cxx
@@ -48,7 +48,7 @@ TabBar::TabBar(vcl::Window* pParentWindow,
                const Reference<frame::XFrame>& rxFrame,
                std::function<void (const OUString&)> aDeckActivationFunctor,
                PopupMenuProvider  aPopupMenuProvider,
-               SidebarController* rParentSidebarController
+               SidebarController& rParentSidebarController
               )
     : InterimItemWindow(pParentWindow, "sfx/ui/tabbar.ui", "TabBar")
     , mxFrame(rxFrame)
@@ -58,7 +58,7 @@ TabBar::TabBar(vcl::Window* pParentWindow,
     , mxMeasureBox(mxAuxBuilder->weld_widget("measure"))
     , maDeckActivationFunctor(std::move(aDeckActivationFunctor))
     , maPopupMenuProvider(std::move(aPopupMenuProvider))
-    , pParentSidebarController(rParentSidebarController)
+    , mrParentSidebarController(rParentSidebarController)
 {
     set_id("TabBar"); // for uitest
 
@@ -127,7 +127,7 @@ void TabBar::SetDecks(const 
ResourceManager::DeckContextDescriptorContainer& rDe
     maItems.clear();
     for (auto const& deck : rDecks)
     {
-        std::shared_ptr<DeckDescriptor> xDescriptor = 
pParentSidebarController->GetResourceManager()->GetDeckDescriptor(deck.msId);
+        std::shared_ptr<DeckDescriptor> xDescriptor = 
mrParentSidebarController.GetResourceManager()->GetDeckDescriptor(deck.msId);
         if (xDescriptor == nullptr)
         {
             OSL_ASSERT(xDescriptor!=nullptr);
@@ -153,7 +153,7 @@ void TabBar::UpdateButtonIcons()
 {
     for (auto const& item : maItems)
     {
-        std::shared_ptr<DeckDescriptor> xDeckDescriptor = 
pParentSidebarController->GetResourceManager()->GetDeckDescriptor(item->msDeckId);
+        std::shared_ptr<DeckDescriptor> xDeckDescriptor = 
mrParentSidebarController.GetResourceManager()->GetDeckDescriptor(item->msDeckId);
         if (!xDeckDescriptor)
             continue;
         item->mxButton->set_item_image("toggle", 
GetItemImage(*xDeckDescriptor));
@@ -297,13 +297,13 @@ void TabBar::ToggleHideFlag (const sal_Int32 nIndex)
 
     maItems[nIndex]->mbIsHidden = ! maItems[nIndex]->mbIsHidden;
 
-    std::shared_ptr<DeckDescriptor> xDeckDescriptor = 
pParentSidebarController->GetResourceManager()->GetDeckDescriptor(maItems[nIndex]->msDeckId);
+    std::shared_ptr<DeckDescriptor> xDeckDescriptor = 
mrParentSidebarController.GetResourceManager()->GetDeckDescriptor(maItems[nIndex]->msDeckId);
     if (xDeckDescriptor)
     {
         xDeckDescriptor->mbIsEnabled = ! maItems[nIndex]->mbIsHidden;
 
         Context aContext;
-        aContext.msApplication = 
pParentSidebarController->GetCurrentContext().msApplication;
+        aContext.msApplication = 
mrParentSidebarController.GetCurrentContext().msApplication;
         // leave aContext.msContext on default 'any' ... this func is used 
only for decks
         // and we don't have context-sensitive decks anyway
 
@@ -319,7 +319,7 @@ void TabBar::RestoreHideFlags()
         if (item->mbIsHidden != item->mbIsHiddenByDefault)
         {
             item->mbIsHidden = item->mbIsHiddenByDefault;
-            std::shared_ptr<DeckDescriptor> xDeckDescriptor = 
pParentSidebarController->GetResourceManager()->GetDeckDescriptor(item->msDeckId);
+            std::shared_ptr<DeckDescriptor> xDeckDescriptor = 
mrParentSidebarController.GetResourceManager()->GetDeckDescriptor(item->msDeckId);
             if (xDeckDescriptor)
                 xDeckDescriptor->mbIsEnabled = !item->mbIsHidden;
 
@@ -348,7 +348,7 @@ IMPL_LINK_NOARG(TabBar, OnToolboxClicked, 
weld::Toggleable&, void)
 
     for (auto const& item : maItems)
     {
-        std::shared_ptr<DeckDescriptor> xDeckDescriptor = 
pParentSidebarController->GetResourceManager()->GetDeckDescriptor(item->msDeckId);
+        std::shared_ptr<DeckDescriptor> xDeckDescriptor = 
mrParentSidebarController.GetResourceManager()->GetDeckDescriptor(item->msDeckId);
 
         if (!xDeckDescriptor)
             continue;
diff --git a/sfx2/source/sidebar/uiobject.cxx b/sfx2/source/sidebar/uiobject.cxx
index 13c21d2220b5..7d4327fb023b 100644
--- a/sfx2/source/sidebar/uiobject.cxx
+++ b/sfx2/source/sidebar/uiobject.cxx
@@ -40,7 +40,7 @@ void TabBarUIObject::execute(const OUString& rAction, const 
StringMap& rParamete
     if (rAction == "CLICK")
     {
         if (rParameters.find("POS") != rParameters.end())
-            mxTabBar->pParentSidebarController->OpenThenToggleDeck(
+            mxTabBar->mrParentSidebarController.OpenThenToggleDeck(
                 
mxTabBar->GetDeckIdForIndex(rParameters.find("POS")->second.toInt32()));
     }
     else

Reply via email to