diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-29 09:35:32 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-30 00:30:25 +0200 |
commit | 52f6aa4bf1047f98ab9884799baa104bca9d2a47 (patch) | |
tree | 761cdfcc048feed5703a5080eecf685cb8bb2b7b /embedserv | |
parent | 1e562859d597e2523159d93d04e205017da092f4 (diff) |
Prepare for removal of non-const operator[] from Sequence in embedserv
Change-Id: Iaed5b6db7b31eadcb5f94d444ba183e943141421
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124362
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'embedserv')
-rw-r--r-- | embedserv/source/embed/docholder.cxx | 24 | ||||
-rw-r--r-- | embedserv/source/embed/ed_ipersiststr.cxx | 33 | ||||
-rw-r--r-- | embedserv/source/embed/intercept.cxx | 44 | ||||
-rw-r--r-- | embedserv/source/inc/intercept.hxx | 2 |
4 files changed, 46 insertions, 57 deletions
diff --git a/embedserv/source/embed/docholder.cxx b/embedserv/source/embed/docholder.cxx index cfa7cb87e88c..e79c26a2a0d5 100644 --- a/embedserv/source/embed/docholder.cxx +++ b/embedserv/source/embed/docholder.cxx @@ -60,6 +60,7 @@ #include <com/sun/star/util/XCloseable.hpp> #include <com/sun/star/util/XModifyBroadcaster.hpp> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <o3tl/any.hxx> #include <osl/diagnose.h> #include <rtl/process.h> @@ -111,22 +112,22 @@ void DocumentHolder::LoadDocInFrame( bool bPluginMode ) uno::Reference< task::XInteractionHandler2 > xHandler( task::InteractionHandler::createWithParent(comphelper::getComponentContext(m_xFactory), nullptr) ); - sal_Int32 nLen = 3; + sal_Int32 nLen = bPluginMode ? 6 : 5; uno::Sequence<beans::PropertyValue> aSeq( nLen ); - - aSeq[0] = beans::PropertyValue( + auto pSeq = aSeq.getArray(); + pSeq[0] = beans::PropertyValue( "Model", -1, uno::Any(uno::Reference<uno::XInterface>(m_xDocument, uno::UNO_QUERY)), beans::PropertyState_DIRECT_VALUE); - aSeq[1] = beans::PropertyValue( + pSeq[1] = beans::PropertyValue( "ReadOnly", -1, uno::Any(false), beans::PropertyState_DIRECT_VALUE); - aSeq[2] = beans::PropertyValue( + pSeq[2] = beans::PropertyValue( "NoAutoSave", -1, uno::Any(true), @@ -134,22 +135,20 @@ void DocumentHolder::LoadDocInFrame( bool bPluginMode ) if ( bPluginMode ) { - aSeq.realloc( ++nLen ); - aSeq[nLen-1] = beans::PropertyValue( + pSeq[3] = beans::PropertyValue( "PluginMode", -1, uno::Any(sal_Int16(3)), beans::PropertyState_DIRECT_VALUE); } - aSeq.realloc( nLen+=2 ); - aSeq[nLen-2] = beans::PropertyValue( + pSeq[nLen-2] = beans::PropertyValue( "InteractionHandler", -1, uno::Any(xHandler), beans::PropertyState_DIRECT_VALUE); - aSeq[nLen-1] = beans::PropertyValue( + pSeq[nLen-1] = beans::PropertyValue( "MacroExecutionMode", -1, uno::Any(m_nMacroExecMode), @@ -701,9 +700,8 @@ void DocumentHolder::SetDocument( const uno::Reference< frame::XModel >& xDoc, b if ( m_xDocument.is() && !m_bLink ) { // set the document mode to embedded - uno::Sequence< beans::PropertyValue > aSeq(1); - aSeq[0].Name = "SetEmbedded"; - aSeq[0].Value <<= true; + uno::Sequence< beans::PropertyValue > aSeq{ comphelper::makePropertyValue("SetEmbedded", + true) }; m_xDocument->attachResource(OUString(),aSeq); } } diff --git a/embedserv/source/embed/ed_ipersiststr.cxx b/embedserv/source/embed/ed_ipersiststr.cxx index c23141636de0..698bbe13f586 100644 --- a/embedserv/source/embed/ed_ipersiststr.cxx +++ b/embedserv/source/embed/ed_ipersiststr.cxx @@ -195,22 +195,21 @@ EmbedDocument_Impl::~EmbedDocument_Impl() uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForLoading_Impl( uno::Reference< io::XInputStream > const & xStream, DWORD /*nStreamMode*/, LPCOLESTR pFilePath ) { - uno::Sequence< beans::PropertyValue > aArgs( 3 ); - - sal_Int32 nInd = 0; // must not be bigger than the preset size - aArgs[nInd].Name = "FilterName"; - aArgs[nInd++].Value <<= getFilterNameFromGUID_Impl( &m_guid ); + uno::Sequence< beans::PropertyValue > aArgs( xStream.is() ? 3 : 2 ); + auto pArgs = aArgs.getArray(); + pArgs[0].Name = "FilterName"; + pArgs[0].Value <<= getFilterNameFromGUID_Impl( &m_guid ); if ( xStream.is() ) { - aArgs[nInd].Name = "InputStream"; - aArgs[nInd++].Value <<= xStream; - aArgs[nInd].Name = "URL"; - aArgs[nInd++].Value <<= OUString( "private:stream" ); + pArgs[1].Name = "InputStream"; + pArgs[1].Value <<= xStream; + pArgs[2].Name = "URL"; + pArgs[2].Value <<= OUString( "private:stream" ); } else { - aArgs[nInd].Name = "URL"; + pArgs[1].Name = "URL"; OUString sDocUrl; if ( pFilePath ) @@ -224,11 +223,9 @@ uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForLoading_Imp sDocUrl = aURL.Complete; } - aArgs[nInd++].Value <<= sDocUrl; + pArgs[1].Value <<= sDocUrl; } - aArgs.realloc( nInd ); - // aArgs[].Name = "ReadOnly"; // aArgs[].Value <<= sal_False; //( ( nStreamMode & ( STGM_READWRITE | STGM_WRITE ) ) ? sal_True : sal_False ); @@ -238,14 +235,14 @@ uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForLoading_Imp uno::Sequence< beans::PropertyValue > EmbedDocument_Impl::fillArgsForStoring_Impl( uno::Reference< io::XOutputStream > const & xStream) { uno::Sequence< beans::PropertyValue > aArgs( xStream.is() ? 2 : 1 ); - - aArgs[0].Name = "FilterName"; - aArgs[0].Value <<= getFilterNameFromGUID_Impl( &m_guid ); + auto pArgs = aArgs.getArray(); + pArgs[0].Name = "FilterName"; + pArgs[0].Value <<= getFilterNameFromGUID_Impl( &m_guid ); if ( xStream.is() ) { - aArgs[1].Name = "OutputStream"; - aArgs[1].Value <<= xStream; + pArgs[1].Name = "OutputStream"; + pArgs[1].Value <<= xStream; } return aArgs; diff --git a/embedserv/source/embed/intercept.cxx b/embedserv/source/embed/intercept.cxx index 2caeec236536..ec10c642657b 100644 --- a/embedserv/source/embed/intercept.cxx +++ b/embedserv/source/embed/intercept.cxx @@ -28,8 +28,13 @@ using namespace ::com::sun::star; #define IUL 6 - -uno::Sequence< OUString > Interceptor::m_aInterceptedURL(IUL); +constexpr OUStringLiteral IU0 = u".uno:Save"; +constexpr OUStringLiteral IU1 = u".uno:SaveAll"; +constexpr OUStringLiteral IU2 = u".uno:CloseDoc"; +constexpr OUStringLiteral IU3 = u".uno:CloseWin"; +constexpr OUStringLiteral IU4 = u".uno:CloseFrame"; +constexpr OUStringLiteral IU5 = u".uno:SaveAs"; +const uno::Sequence< OUString > Interceptor::m_aInterceptedURL{ IU0, IU1, IU2, IU3, IU4, IU5}; class StatusChangeListenerContainer : public comphelper::OMultiTypeInterfaceContainerHelperVar2<OUString> @@ -96,12 +101,6 @@ Interceptor::Interceptor( m_pStatCL(nullptr), m_bLink( bLink ) { - m_aInterceptedURL[0] = ".uno:Save"; - m_aInterceptedURL[1] = ".uno:SaveAll"; - m_aInterceptedURL[2] = ".uno:CloseDoc"; - m_aInterceptedURL[3] = ".uno:CloseWin"; - m_aInterceptedURL[4] = ".uno:CloseFrame"; - m_aInterceptedURL[5] = ".uno:SaveAs"; } @@ -165,7 +164,7 @@ Interceptor::dispatch( { if ( aNewArgs[nInd].Name == "SaveTo" ) { - aNewArgs[nInd].Value <<= true; + aNewArgs.getArray()[nInd].Value <<= true; break; } nInd++; @@ -174,8 +173,9 @@ Interceptor::dispatch( if ( nInd == aNewArgs.getLength() ) { aNewArgs.realloc( nInd + 1 ); - aNewArgs[nInd].Name = "SaveTo"; - aNewArgs[nInd].Value <<= true; + auto pNewArgs = aNewArgs.getArray(); + pNewArgs[nInd].Name = "SaveTo"; + pNewArgs[nInd].Value <<= true; } uno::Reference< frame::XDispatch > xDispatch = m_xSlaveDispatchProvider->queryDispatch( @@ -383,13 +383,7 @@ Interceptor::getInterceptedURLs( ) { // now implemented as update if ( m_bLink ) - { - uno::Sequence< OUString > aResult( 2 ); - aResult[0] = m_aInterceptedURL[1]; - aResult[1] = m_aInterceptedURL[5]; - - return aResult; - } + return { m_aInterceptedURL[1], m_aInterceptedURL[5] }; return m_aInterceptedURL; } @@ -435,20 +429,20 @@ Interceptor::queryDispatches( aRet = m_xSlaveDispatchProvider->queryDispatches(Requests); else aRet.realloc(Requests.getLength()); - + auto aRetRange = asNonConstRange(aRet); for(sal_Int32 i = 0; i < Requests.getLength(); ++i) if ( !m_bLink && m_aInterceptedURL[0] == Requests[i].FeatureURL.Complete ) - aRet[i] = static_cast<frame::XDispatch*>(this); + aRetRange[i] = static_cast<frame::XDispatch*>(this); else if(m_aInterceptedURL[1] == Requests[i].FeatureURL.Complete) - aRet[i] = nullptr; + aRetRange[i] = nullptr; else if( !m_bLink && m_aInterceptedURL[2] == Requests[i].FeatureURL.Complete ) - aRet[i] = static_cast<frame::XDispatch*>(this); + aRetRange[i] = static_cast<frame::XDispatch*>(this); else if( !m_bLink && m_aInterceptedURL[3] == Requests[i].FeatureURL.Complete ) - aRet[i] = static_cast<frame::XDispatch*>(this); + aRetRange[i] = static_cast<frame::XDispatch*>(this); else if( !m_bLink && m_aInterceptedURL[4] == Requests[i].FeatureURL.Complete ) - aRet[i] = static_cast<frame::XDispatch*>(this); + aRetRange[i] = static_cast<frame::XDispatch*>(this); else if(m_aInterceptedURL[5] == Requests[i].FeatureURL.Complete) - aRet[i] = static_cast<frame::XDispatch*>(this); + aRetRange[i] = static_cast<frame::XDispatch*>(this); return aRet; } diff --git a/embedserv/source/inc/intercept.hxx b/embedserv/source/inc/intercept.hxx index ab3fb63cad8f..db47362c9bec 100644 --- a/embedserv/source/inc/intercept.hxx +++ b/embedserv/source/inc/intercept.hxx @@ -136,7 +136,7 @@ private: css::uno::Reference< css::frame::XDispatchProvider > m_xMasterDispatchProvider; - static css::uno::Sequence< OUString > m_aInterceptedURL; + static const css::uno::Sequence< OUString > m_aInterceptedURL; comphelper::OInterfaceContainerHelper2* m_pDisposeEventListeners; StatusChangeListenerContainer* m_pStatCL; |