diff options
Diffstat (limited to 'chart2/source/controller/main/CommandDispatchContainer.cxx')
-rw-r--r-- | chart2/source/controller/main/CommandDispatchContainer.cxx | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/chart2/source/controller/main/CommandDispatchContainer.cxx b/chart2/source/controller/main/CommandDispatchContainer.cxx index b007ebe5c652..31b49c76889c 100644 --- a/chart2/source/controller/main/CommandDispatchContainer.cxx +++ b/chart2/source/controller/main/CommandDispatchContainer.cxx @@ -23,10 +23,12 @@ #include <DisposeHelper.hxx> #include "DrawCommandDispatch.hxx" #include "ShapeController.hxx" +#include <ChartModel.hxx> #include <com/sun/star/frame/XDispatchProvider.hpp> -#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> +#include <osl/diagnose.h> +#include <rtl/ref.hxx> #include <o3tl/sorted_vector.hxx> @@ -47,18 +49,18 @@ CommandDispatchContainer::CommandDispatchContainer( } void CommandDispatchContainer::setModel( - const Reference< frame::XModel > & xModel ) + const rtl::Reference<::chart::ChartModel> & xModel ) { // remove all existing dispatcher that base on the old model m_aCachedDispatches.clear(); DisposeHelper::DisposeAllElements( m_aToBeDisposedDispatches ); m_aToBeDisposedDispatches.clear(); - m_xModel = xModel; + m_xModel = xModel.get(); } void CommandDispatchContainer::setChartDispatch( const Reference< frame::XDispatch >& rChartDispatch, - const o3tl::sorted_vector< OUString > & rChartCommands ) + const o3tl::sorted_vector< std::u16string_view > & rChartCommands ) { OSL_ENSURE(rChartDispatch.is(),"Invalid fall back dispatcher!"); m_xChartDispatcher.set( rChartDispatch ); @@ -69,10 +71,10 @@ void CommandDispatchContainer::setChartDispatch( Reference< frame::XDispatch > CommandDispatchContainer::getDispatchForURL( const util::URL & rURL ) { - static const o3tl::sorted_vector< OUString > s_aContainerDocumentCommands { - "AddDirect", "NewDoc", "Open", - "Save", "SaveAs", "SendMail", - "EditDoc", "ExportDirectToPDF", "PrintDefault"}; + static const o3tl::sorted_vector< std::u16string_view > s_aContainerDocumentCommands { + u"AddDirect", u"NewDoc", u"Open", + 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 )); @@ -82,32 +84,32 @@ Reference< frame::XDispatch > CommandDispatchContainer::getDispatchForURL( } else { - uno::Reference< frame::XModel > xModel( m_xModel ); + rtl::Reference< ::chart::ChartModel > xModel( m_xModel ); if( xModel.is() && ( rURL.Path == "Undo" || rURL.Path == "Redo" || rURL.Path == "GetUndoStrings" || rURL.Path == "GetRedoStrings" ) ) { - CommandDispatch * pDispatch = new UndoCommandDispatch( m_xContext, xModel ); + rtl::Reference<CommandDispatch> pDispatch = new UndoCommandDispatch( m_xContext, xModel ); xResult.set( pDispatch ); pDispatch->initialize(); - m_aCachedDispatches[ ".uno:Undo" ].set( xResult ); - m_aCachedDispatches[ ".uno:Redo" ].set( xResult ); - m_aCachedDispatches[ ".uno:GetUndoStrings" ].set( xResult ); - m_aCachedDispatches[ ".uno:GetRedoStrings" ].set( xResult ); + 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 ); } else if( xModel.is() && ( rURL.Path == "Context" || rURL.Path == "ModifiedStatus" ) ) { Reference< view::XSelectionSupplier > xSelSupp( xModel->getCurrentController(), uno::UNO_QUERY ); - CommandDispatch * pDispatch = new StatusBarCommandDispatch( m_xContext, xModel, xSelSupp ); + rtl::Reference<CommandDispatch> pDispatch = new StatusBarCommandDispatch( m_xContext, xModel, xSelSupp ); xResult.set( pDispatch ); pDispatch->initialize(); - m_aCachedDispatches[ ".uno:Context" ].set( xResult ); - m_aCachedDispatches[ ".uno:ModifiedStatus" ].set( xResult ); + m_aCachedDispatches[ u".uno:Context"_ustr ].set( xResult ); + m_aCachedDispatches[ u".uno:ModifiedStatus"_ustr ].set( xResult ); m_aToBeDisposedDispatches.push_back( xResult ); } else if( xModel.is() && - (s_aContainerDocumentCommands.find( rURL.Path ) != s_aContainerDocumentCommands.end()) ) + (s_aContainerDocumentCommands.find( std::u16string_view(rURL.Path) ) != s_aContainerDocumentCommands.end()) ) { xResult.set( getContainerDispatchForURL( xModel->getCurrentController(), rURL )); // ToDo: can those dispatches be cached? @@ -143,11 +145,12 @@ Sequence< Reference< frame::XDispatch > > CommandDispatchContainer::getDispatche { sal_Int32 nCount = aDescriptors.getLength(); uno::Sequence< uno::Reference< frame::XDispatch > > aRet( nCount ); + auto aRetRange = asNonConstRange(aRet); for( sal_Int32 nPos = 0; nPos < nCount; ++nPos ) { if ( aDescriptors[ nPos ].FrameName == "_self" ) - aRet[ nPos ] = getDispatchForURL( aDescriptors[ nPos ].FeatureURL ); + aRetRange[ nPos ] = getDispatchForURL( aDescriptors[ nPos ].FeatureURL ); } return aRet; } @@ -175,7 +178,7 @@ Reference< frame::XDispatch > CommandDispatchContainer::getContainerDispatchForU { Reference< frame::XDispatchProvider > xDispProv( xFrame->getCreator(), uno::UNO_QUERY ); if( xDispProv.is()) - xResult.set( xDispProv->queryDispatch( rURL, "_self", 0 )); + xResult.set( xDispProv->queryDispatch( rURL, u"_self"_ustr, 0 )); } } return xResult; |