chart2/source/controller/inc/CommandDispatchContainer.hxx    |    9 ++++---
 chart2/source/controller/inc/ControllerCommandDispatch.hxx   |    2 -
 chart2/source/controller/main/ChartController.cxx            |    5 +--
 chart2/source/controller/main/ChartController_Window.cxx     |   14 +++--------
 chart2/source/controller/main/CommandDispatch.cxx            |    4 ++-
 chart2/source/controller/main/CommandDispatchContainer.cxx   |    7 +++--
 chart2/source/controller/main/ControllerCommandDispatch.cxx  |    6 +++-
 chart2/source/controller/main/FeatureCommandDispatchBase.hxx |    4 ++-
 chart2/source/controller/main/StatusBarCommandDispatch.hxx   |    4 ++-
 chart2/source/controller/main/UndoCommandDispatch.hxx        |    4 ++-
 solenv/clang-format/excludelist                              |    4 +--
 11 files changed, 37 insertions(+), 26 deletions(-)

New commits:
commit 3ce08409b2947cc62837960045016900a1b2f8a4
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Jul 6 17:02:51 2025 +0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Jul 9 16:21:11 2025 +0200

    Use concrete type for m_xChartDispatcher
    
    Avoids a dynamic_cast
    
    Change-Id: I5f55e7730fd4b5e35cc57c570bdcedbe413a64cd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187443
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187521
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/chart2/source/controller/main/CommandDispatch.hxx 
b/chart2/source/controller/inc/CommandDispatch.hxx
similarity index 100%
rename from chart2/source/controller/main/CommandDispatch.hxx
rename to chart2/source/controller/inc/CommandDispatch.hxx
diff --git a/chart2/source/controller/inc/CommandDispatchContainer.hxx 
b/chart2/source/controller/inc/CommandDispatchContainer.hxx
index 34c80e7bf319..daf0b48ccf14 100644
--- a/chart2/source/controller/inc/CommandDispatchContainer.hxx
+++ b/chart2/source/controller/inc/CommandDispatchContainer.hxx
@@ -21,6 +21,8 @@
 #include <unotools/weakref.hxx>
 #include <o3tl/sorted_vector.hxx>
 
+#include "ControllerCommandDispatch.hxx"
+
 #include <map>
 #include <vector>
 
@@ -71,6 +73,7 @@ public:
     // itself)
     explicit CommandDispatchContainer(
         const css::uno::Reference< css::uno::XComponentContext > & xContext );
+    ~CommandDispatchContainer();
 
     void setModel(
         const rtl::Reference<::chart::ChartModel> & xModel );
@@ -79,7 +82,7 @@ public:
         rChartCommands
      */
     void setChartDispatch(
-        const css::uno::Reference< css::frame::XDispatch >& rChartDispatch,
+        const rtl::Reference< ControllerCommandDispatch >& rChartDispatch,
         const o3tl::sorted_vector< std::u16string_view > & rChartCommands );
 
     /** Returns the dispatch that is able to do the command given in rURL, if
@@ -102,7 +105,7 @@ public:
             const css::uno::Reference< css::frame::XController > & 
xChartController,
             const css::util::URL & rURL );
 
-    const css::uno::Reference< css::frame::XDispatch > & getChartDispatcher() 
const { return m_xChartDispatcher; }
+    ControllerCommandDispatch* getChartDispatcher() { return 
m_xChartDispatcher.get(); }
 
     void setDrawCommandDispatch( DrawCommandDispatch* pDispatch );
     DrawCommandDispatch* getDrawCommandDispatch() { return 
m_pDrawCommandDispatch; }
@@ -124,7 +127,7 @@ private:
     css::uno::Reference< css::uno::XComponentContext >    m_xContext;
     unotools::WeakReference< ::chart::ChartModel >         m_xModel;
 
-    css::uno::Reference< css::frame::XDispatch >          m_xChartDispatcher;
+    rtl::Reference<ControllerCommandDispatch> m_xChartDispatcher;
     o3tl::sorted_vector< std::u16string_view >            m_aChartCommands;
 
     DrawCommandDispatch* m_pDrawCommandDispatch;
diff --git a/chart2/source/controller/main/ControllerCommandDispatch.hxx 
b/chart2/source/controller/inc/ControllerCommandDispatch.hxx
similarity index 98%
rename from chart2/source/controller/main/ControllerCommandDispatch.hxx
rename to chart2/source/controller/inc/ControllerCommandDispatch.hxx
index a5cc5b9e39cb..c336a8ea3952 100644
--- a/chart2/source/controller/main/ControllerCommandDispatch.hxx
+++ b/chart2/source/controller/inc/ControllerCommandDispatch.hxx
@@ -64,7 +64,7 @@ public:
     // late initialisation, especially for adding as listener
     virtual void initialize() override;
 
-    bool commandAvailable( const OUString & rCommand );
+    bool commandAvailable(const OUString& rCommand) const;
     void updateAndFireStatus();
 
 protected:
diff --git a/chart2/source/controller/main/ChartController.cxx 
b/chart2/source/controller/main/ChartController.cxx
index d5315e2f0fca..5b1f2b2b3e18 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -29,7 +29,7 @@
 #include <ChartModel.hxx>
 #include <ChartModelHelper.hxx>
 #include <ChartType.hxx>
-#include "ControllerCommandDispatch.hxx"
+#include <ControllerCommandDispatch.hxx>
 #include <DataSeries.hxx>
 #include <Diagram.hxx>
 #include <strings.hrc>
@@ -1438,8 +1438,7 @@ void SAL_CALL ChartController::dispatch(
 
                             // update the sidebar
                             ControllerCommandDispatch* pCommandDispatch
-                                = dynamic_cast<ControllerCommandDispatch*>(
-                                    
m_aDispatchContainer.getChartDispatcher().get());
+                                = m_aDispatchContainer.getChartDispatcher();
                             if (pCommandDispatch)
                             {
                                 pCommandDispatch->updateAndFireStatus();
diff --git a/chart2/source/controller/main/ChartController_Window.cxx 
b/chart2/source/controller/main/ChartController_Window.cxx
index 484093daf878..f04389a4b558 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -55,7 +55,7 @@
 #include <servicenames_charttypes.hxx>
 #include "DrawCommandDispatch.hxx"
 #include <PopupRequest.hxx>
-#include "ControllerCommandDispatch.hxx"
+#include <ControllerCommandDispatch.hxx>
 
 #include <com/sun/star/chart2/RelativePosition.hpp>
 #include <com/sun/star/chart2/RelativeSize.hpp>
@@ -599,9 +599,7 @@ void ChartController::execute_MouseButtonDown( const 
MouseEvent& rMEvt )
              ( rMEvt.IsRight() && pDrawViewWrapper->PickAnything( rMEvt, 
SdrMouseEventKind::BUTTONDOWN, aVEvt ) == SdrHitKind::MarkedObject ) )
         {
             pDrawViewWrapper->MouseButtonDown(rMEvt, 
pChartWindow->GetOutDev());
-            ControllerCommandDispatch* pCommandDispatch
-                = dynamic_cast<ControllerCommandDispatch*>(
-                    m_aDispatchContainer.getChartDispatcher().get());
+            ControllerCommandDispatch* pCommandDispatch = 
m_aDispatchContainer.getChartDispatcher();
             if (pCommandDispatch)
             {
                 pCommandDispatch->updateAndFireStatus();
@@ -780,8 +778,7 @@ void ChartController::execute_MouseButtonUp( const 
MouseEvent& rMEvt )
             if( 
pDrawViewWrapper->MouseButtonUp(rMEvt,pChartWindow->GetOutDev()) )
             {
                 ControllerCommandDispatch* pCommandDispatch
-                    = dynamic_cast<ControllerCommandDispatch*>(
-                        m_aDispatchContainer.getChartDispatcher().get());
+                    = m_aDispatchContainer.getChartDispatcher();
                 if (pCommandDispatch)
                 {
                     pCommandDispatch->updateAndFireStatus();
@@ -1289,7 +1286,7 @@ void ChartController::execute_Command( const 
CommandEvent& rCEvt )
         {
             if (SfxViewShell* pViewShell = SfxViewShell::Current())
             {
-                ControllerCommandDispatch* pCommandDispatch = 
dynamic_cast<ControllerCommandDispatch*>(m_aDispatchContainer.getChartDispatcher().get());
+                const ControllerCommandDispatch* pCommandDispatch = 
m_aDispatchContainer.getChartDispatcher();
                 if (pCommandDispatch)
                 {
                     for (int nPos = 0, nCount = xPopupMenu->getItemCount(); 
nPos < nCount; ++nPos)
@@ -1371,8 +1368,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& 
rKEvt )
                     EndTextEdit();
                 }
                 ControllerCommandDispatch* pCommandDispatch
-                    = dynamic_cast<ControllerCommandDispatch*>(
-                        m_aDispatchContainer.getChartDispatcher().get());
+                    = m_aDispatchContainer.getChartDispatcher();
                 if (pCommandDispatch)
                 {
                     pCommandDispatch->updateAndFireStatus();
diff --git a/chart2/source/controller/main/CommandDispatch.cxx 
b/chart2/source/controller/main/CommandDispatch.cxx
index 2cb25f68d5bf..e4f8b1acebcf 100644
--- a/chart2/source/controller/main/CommandDispatch.cxx
+++ b/chart2/source/controller/main/CommandDispatch.cxx
@@ -17,7 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "CommandDispatch.hxx"
+#include <sal/config.h>
+
+#include <CommandDispatch.hxx>
 #include <com/sun/star/util/URLTransformer.hpp>
 
 using namespace ::com::sun::star;
diff --git a/chart2/source/controller/main/CommandDispatchContainer.cxx 
b/chart2/source/controller/main/CommandDispatchContainer.cxx
index f300e5f5fcae..f3b547eebd30 100644
--- a/chart2/source/controller/main/CommandDispatchContainer.cxx
+++ b/chart2/source/controller/main/CommandDispatchContainer.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <CommandDispatchContainer.hxx>
+#include <ControllerCommandDispatch.hxx>
 #include "UndoCommandDispatch.hxx"
 #include "StatusBarCommandDispatch.hxx"
 #include <DisposeHelper.hxx>
@@ -48,6 +49,8 @@ CommandDispatchContainer::CommandDispatchContainer(
 {
 }
 
+CommandDispatchContainer::~CommandDispatchContainer() = default;
+
 void CommandDispatchContainer::setModel(
     const rtl::Reference<::chart::ChartModel> & xModel )
 {
@@ -59,11 +62,11 @@ void CommandDispatchContainer::setModel(
 }
 
 void CommandDispatchContainer::setChartDispatch(
-    const Reference< frame::XDispatch >& rChartDispatch,
+    const rtl::Reference< ControllerCommandDispatch >& rChartDispatch,
     const o3tl::sorted_vector< std::u16string_view > & rChartCommands )
 {
     OSL_ENSURE(rChartDispatch.is(),"Invalid fall back dispatcher!");
-    m_xChartDispatcher.set( rChartDispatch );
+    m_xChartDispatcher = rChartDispatch;
     m_aChartCommands = rChartCommands;
     m_aToBeDisposedDispatches.push_back( m_xChartDispatcher );
 }
diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx 
b/chart2/source/controller/main/ControllerCommandDispatch.cxx
index 8168966d5e46..89c25ed148a7 100644
--- a/chart2/source/controller/main/ControllerCommandDispatch.cxx
+++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx
@@ -17,7 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "ControllerCommandDispatch.hxx"
+#include <sal/config.h>
+
+#include <ControllerCommandDispatch.hxx>
 #include <ChartModel.hxx>
 #include <Diagram.hxx>
 #include <Axis.hxx>
@@ -950,7 +952,7 @@ void ControllerCommandDispatch::updateCommandAvailability()
     m_aCommandAvailability[ u".uno:DeleteDataTable"_ustr ] = bIsWritable && 
bModelStateIsValid && m_apModelState->bDataTable;
 }
 
-bool ControllerCommandDispatch::commandAvailable( const OUString & rCommand )
+bool ControllerCommandDispatch::commandAvailable(const OUString& rCommand) 
const
 {
     std::map< OUString, bool >::const_iterator aIt( 
m_aCommandAvailability.find( rCommand ));
     if( aIt != m_aCommandAvailability.end())
diff --git a/chart2/source/controller/main/FeatureCommandDispatchBase.hxx 
b/chart2/source/controller/main/FeatureCommandDispatchBase.hxx
index 271a3c6cd282..ef8b968287bf 100644
--- a/chart2/source/controller/main/FeatureCommandDispatchBase.hxx
+++ b/chart2/source/controller/main/FeatureCommandDispatchBase.hxx
@@ -18,7 +18,9 @@
  */
 #pragma once
 
-#include "CommandDispatch.hxx"
+#include <sal/config.h>
+
+#include <CommandDispatch.hxx>
 
 #include <com/sun/star/frame/DispatchInformation.hpp>
 
diff --git a/chart2/source/controller/main/StatusBarCommandDispatch.hxx 
b/chart2/source/controller/main/StatusBarCommandDispatch.hxx
index ae9dcaf4f67a..35674fa21b8d 100644
--- a/chart2/source/controller/main/StatusBarCommandDispatch.hxx
+++ b/chart2/source/controller/main/StatusBarCommandDispatch.hxx
@@ -18,7 +18,9 @@
  */
 #pragma once
 
-#include "CommandDispatch.hxx"
+#include <sal/config.h>
+
+#include <CommandDispatch.hxx>
 #include <ObjectIdentifier.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <com/sun/star/view/XSelectionChangeListener.hpp>
diff --git a/chart2/source/controller/main/UndoCommandDispatch.hxx 
b/chart2/source/controller/main/UndoCommandDispatch.hxx
index f872387c761b..8e253b52c41f 100644
--- a/chart2/source/controller/main/UndoCommandDispatch.hxx
+++ b/chart2/source/controller/main/UndoCommandDispatch.hxx
@@ -18,7 +18,9 @@
  */
 #pragma once
 
-#include "CommandDispatch.hxx"
+#include <sal/config.h>
+
+#include <CommandDispatch.hxx>
 #include <rtl/ref.hxx>
 
 namespace com::sun::star::document { class XUndoManager; }
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index 1111f5117fc9..e0fbec3743e6 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -853,7 +853,9 @@ chart2/source/controller/inc/ChartController.hxx
 chart2/source/controller/inc/ChartDocumentWrapper.hxx
 chart2/source/controller/inc/ChartToolbarController.hxx
 chart2/source/controller/inc/ChartWindow.hxx
+chart2/source/controller/inc/CommandDispatch.hxx
 chart2/source/controller/inc/CommandDispatchContainer.hxx
+chart2/source/controller/inc/ControllerCommandDispatch.hxx
 chart2/source/controller/inc/DataPointItemConverter.hxx
 chart2/source/controller/inc/DrawViewWrapper.hxx
 chart2/source/controller/inc/ErrorBarItemConverter.hxx
@@ -919,11 +921,9 @@ chart2/source/controller/main/ChartTransferable.cxx
 chart2/source/controller/main/ChartTransferable.hxx
 chart2/source/controller/main/ChartWindow.cxx
 chart2/source/controller/main/CommandDispatch.cxx
-chart2/source/controller/main/CommandDispatch.hxx
 chart2/source/controller/main/CommandDispatchContainer.cxx
 chart2/source/controller/main/ConfigurationAccess.cxx
 chart2/source/controller/main/ControllerCommandDispatch.cxx
-chart2/source/controller/main/ControllerCommandDispatch.hxx
 chart2/source/controller/main/DragMethod_Base.cxx
 chart2/source/controller/main/DragMethod_Base.hxx
 chart2/source/controller/main/DragMethod_PieSegment.cxx

Reply via email to