chart2/source/controller/main/ChartController.cxx | 2 chart2/source/controller/main/CommandDispatchContainer.cxx | 71 ++++++------- 2 files changed, 34 insertions(+), 39 deletions(-)
New commits: commit 9b69bc0e7db564a2f61e7a2c6fbd7ff5ce1bbd17 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun Jul 6 13:08:24 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Jul 6 14:04:56 2025 +0200 Fix ChartController::queryDispatch In commit c6b95527d2e00ed3a4cf3bad3a328ca5b29a588a (INTEGRATION: CWS chart2mst3 (1.15.4); FILE MERGED, 2007-05-22), it was implemented to check that the target frame name is not empty and is equal to "_self". The "not empty" check was redundant as implemented; and was dropped in commit 33fe5b57eae6a3319b23afbe5be88f0548761f56 (Drop a redundant check, 2025-07-04). But it looks like the original implementation intended to do something different, namely check if the target frame name is *either* empty, *or* "_self": see documentation for _self in offapi/com/sun/star/frame/XFrame.idl (and implementation in various places, like framework/source/dispatch/dispatchprovider.cxx). This is fixed here. CommandDispatchContainer::getDispatchesForURLs is fixed as well. Change-Id: I9ed6981edeca16661f07e41b87b114a8e16d69ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187442 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index d49f49497f9f..fedcbf4e85dc 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -1028,7 +1028,7 @@ uno::Reference<frame::XDispatch> SAL_CALL if ( !m_aLifeTimeManager.impl_isDisposed() && getModel().is() ) { - if (rTargetFrameName == "_self") + if (rTargetFrameName.isEmpty() || rTargetFrameName == "_self") return m_aDispatchContainer.getDispatchForURL( rURL ); } return uno::Reference< frame::XDispatch > (); diff --git a/chart2/source/controller/main/CommandDispatchContainer.cxx b/chart2/source/controller/main/CommandDispatchContainer.cxx index 906baa8b3407..f300e5f5fcae 100644 --- a/chart2/source/controller/main/CommandDispatchContainer.cxx +++ b/chart2/source/controller/main/CommandDispatchContainer.cxx @@ -141,7 +141,7 @@ Sequence< Reference< frame::XDispatch > > CommandDispatchContainer::getDispatche for( sal_Int32 nPos = 0; nPos < nCount; ++nPos ) { - if ( aDescriptors[ nPos ].FrameName == "_self" ) + if (aDescriptors[nPos].FrameName.isEmpty() || aDescriptors[nPos].FrameName == "_self") aRetRange[ nPos ] = getDispatchForURL( aDescriptors[ nPos ].FeatureURL ); } return aRet; commit 970360adcc3a6445de0759530086bb6336b18a5a Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun Jul 6 13:03:37 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun Jul 6 14:04:51 2025 +0200 Fix CommandDispatchContainer::getDispatchForURL ... after commit 36b5f0ebf403f55fc1de5e9a45bcb9b6ce86bea6 (Flatten CommandDispatchContainer::getDispatchForURL a bit, 2025-07-04), which broke its logic (everything after the 'if xModel' needs to be also checked in case when nested checks fail). Change-Id: I608b53f993d60d9d0c873e951a1cb53106eeaeec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187441 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins diff --git a/chart2/source/controller/main/CommandDispatchContainer.cxx b/chart2/source/controller/main/CommandDispatchContainer.cxx index 7304c8e48e4e..906baa8b3407 100644 --- a/chart2/source/controller/main/CommandDispatchContainer.cxx +++ b/chart2/source/controller/main/CommandDispatchContainer.cxx @@ -76,65 +76,60 @@ Reference< frame::XDispatch > CommandDispatchContainer::getDispatchForURL( u"Save", u"SaveAs", u"SendMail", u"EditDoc", u"ExportDirectToPDF", u"PrintDefault"}; - Reference< frame::XDispatch > xResult; - tDispatchMap::const_iterator aIt( m_aCachedDispatches.find( rURL.Complete )); - if( aIt != m_aCachedDispatches.end()) + if (auto aIt = m_aCachedDispatches.find(rURL.Complete); aIt != m_aCachedDispatches.end()) + return aIt->second; + + auto cacheIt = [this, url = rURL.Complete](const Reference<frame::XDispatch>& val) { - xResult.set( (*aIt).second ); - } - else if (rtl::Reference<::chart::ChartModel> xModel{ m_xModel }) + m_aCachedDispatches[url].set(val); + return val; + }; + + if (rtl::Reference<::chart::ChartModel> xModel{ m_xModel }) { if (rURL.Path == "Undo" || rURL.Path == "Redo" || rURL.Path == "GetUndoStrings" || rURL.Path == "GetRedoStrings") { rtl::Reference<CommandDispatch> pDispatch = new UndoCommandDispatch( m_xContext, xModel ); - xResult.set( pDispatch ); pDispatch->initialize(); - m_aCachedDispatches[ u".uno:Undo"_ustr ].set( xResult ); - m_aCachedDispatches[ u".uno:Redo"_ustr ].set( xResult ); - m_aCachedDispatches[ u".uno:GetUndoStrings"_ustr ].set( xResult ); - m_aCachedDispatches[ u".uno:GetRedoStrings"_ustr ].set( xResult ); - m_aToBeDisposedDispatches.push_back( xResult ); + m_aCachedDispatches[u".uno:Undo"_ustr].set(pDispatch); + m_aCachedDispatches[u".uno:Redo"_ustr].set(pDispatch); + m_aCachedDispatches[u".uno:GetUndoStrings"_ustr].set(pDispatch); + m_aCachedDispatches[u".uno:GetRedoStrings"_ustr].set(pDispatch); + m_aToBeDisposedDispatches.push_back(pDispatch); + return pDispatch; } - else if (rURL.Path == "Context" || rURL.Path == "ModifiedStatus") + if (rURL.Path == "Context" || rURL.Path == "ModifiedStatus") { Reference< view::XSelectionSupplier > xSelSupp( xModel->getCurrentController(), uno::UNO_QUERY ); rtl::Reference<CommandDispatch> pDispatch = new StatusBarCommandDispatch( m_xContext, xModel, xSelSupp ); - xResult.set( pDispatch ); pDispatch->initialize(); - m_aCachedDispatches[ u".uno:Context"_ustr ].set( xResult ); - m_aCachedDispatches[ u".uno:ModifiedStatus"_ustr ].set( xResult ); - m_aToBeDisposedDispatches.push_back( xResult ); + m_aCachedDispatches[u".uno:Context"_ustr].set(pDispatch); + m_aCachedDispatches[u".uno:ModifiedStatus"_ustr].set(pDispatch); + m_aToBeDisposedDispatches.push_back(pDispatch); + return pDispatch; } - else if (s_aContainerDocumentCommands.find( std::u16string_view(rURL.Path) ) != s_aContainerDocumentCommands.end()) + if (s_aContainerDocumentCommands.count(rURL.Path) > 0) { - xResult.set( getContainerDispatchForURL( xModel->getCurrentController(), rURL )); // ToDo: can those dispatches be cached? - m_aCachedDispatches[ rURL.Complete ].set( xResult ); + return cacheIt(getContainerDispatchForURL(xModel->getCurrentController(), rURL)); } } - else if (m_xChartDispatcher.is() - && (m_aChartCommands.find(rURL.Path) != m_aChartCommands.end())) - { - xResult.set( m_xChartDispatcher ); - m_aCachedDispatches[ rURL.Complete ].set( xResult ); - } + + if (m_xChartDispatcher.is() && m_aChartCommands.count(rURL.Path) > 0) + return cacheIt(m_xChartDispatcher); + // #i12587# support for shapes in chart // Note, that the chart dispatcher must be queried first, because // the chart dispatcher is the default dispatcher for all context // sensitive commands. - else if ( m_pDrawCommandDispatch && m_pDrawCommandDispatch->isFeatureSupported( rURL.Complete ) ) - { - xResult.set( m_pDrawCommandDispatch ); - m_aCachedDispatches[ rURL.Complete ].set( xResult ); - } - else if ( m_pShapeController && m_pShapeController->isFeatureSupported( rURL.Complete ) ) - { - xResult.set( m_pShapeController ); - m_aCachedDispatches[ rURL.Complete ].set( xResult ); - } + if (m_pDrawCommandDispatch && m_pDrawCommandDispatch->isFeatureSupported(rURL.Complete)) + return cacheIt(m_pDrawCommandDispatch); - return xResult; + if (m_pShapeController && m_pShapeController->isFeatureSupported(rURL.Complete)) + return cacheIt(m_pShapeController); + + return {}; } Sequence< Reference< frame::XDispatch > > CommandDispatchContainer::getDispatchesForURLs(