chart2/source/controller/inc/CommandDispatchContainer.hxx    |    9 ++++++---
 chart2/source/controller/inc/ControllerCommandDispatch.hxx   |    2 +-
 chart2/source/controller/main/ChartController.cxx            |    2 +-
 chart2/source/controller/main/ChartController_Window.cxx     |    4 ++--
 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, 33 insertions(+), 17 deletions(-)

New commits:
commit 405aa95218b8df947fc8a1a460f3fbd44b05da87
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Jul 6 17:02:51 2025 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sun Jul 6 17:09:22 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

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 a7c6111a3f4c..22cff84fe7fe 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>
 
@@ -70,6 +72,7 @@ public:
     // itself)
     explicit CommandDispatchContainer(
         const css::uno::Reference< css::uno::XComponentContext > & xContext );
+    ~CommandDispatchContainer();
 
     void setModel(
         const rtl::Reference<::chart::ChartModel> & xModel );
@@ -78,7 +81,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
@@ -101,7 +104,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; }
+    const ControllerCommandDispatch* getChartDispatcher() const { return 
m_xChartDispatcher.get(); }
 
     void setDrawCommandDispatch( DrawCommandDispatch* pDispatch );
     DrawCommandDispatch* getDrawCommandDispatch() { return 
m_pDrawCommandDispatch; }
@@ -123,7 +126,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 6a5e441e8e3c..0a6444d867c9 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;
 
 protected:
     // ____ XDispatch ____
diff --git a/chart2/source/controller/main/ChartController.cxx 
b/chart2/source/controller/main/ChartController.cxx
index fedcbf4e85dc..c7620c1f7b6a 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -28,7 +28,7 @@
 #include <dlg_DataSource.hxx>
 #include <ChartModel.hxx>
 #include <ChartType.hxx>
-#include "ControllerCommandDispatch.hxx"
+#include <ControllerCommandDispatch.hxx>
 #include <DataSeries.hxx>
 #include <Diagram.hxx>
 #include <strings.hrc>
diff --git a/chart2/source/controller/main/ChartController_Window.cxx 
b/chart2/source/controller/main/ChartController_Window.cxx
index cd57689af263..a7c315ba3231 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -53,7 +53,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>
@@ -1223,7 +1223,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)
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 bf96f8ecb356..b901e865553a 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>
@@ -908,7 +910,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 438952631206..2fc3a4c9fa25 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 f09554103844..4d3903bc8b62 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 14baa4309f5a..118104bfd9ff 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -754,7 +754,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
@@ -820,11 +822,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