diff options
author | Noel Grandin <noel@peralex.com> | 2013-02-25 16:09:10 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-03-04 14:22:34 +0200 |
commit | dc00ad1e823e3b36619cd04c7e4d169362e199b3 (patch) | |
tree | 5650e5891532dde51346d8bf5e7703569712f025 | |
parent | 244c7cdede13980c29850b7b68e9da16cdc61879 (diff) |
fdo#46808, Use service constructor for task::InteractionHandler
a lot of code was loading the service using it's implementation name,
which is why this got missed earlier.
Change-Id: I0b150bc9383a1a3a09ab905c4ddb7f914e69638d
-rw-r--r-- | framework/inc/framework/preventduplicateinteraction.hxx | 5 | ||||
-rw-r--r-- | framework/inc/services.h | 1 | ||||
-rw-r--r-- | framework/source/fwe/interaction/preventduplicateinteraction.cxx | 12 | ||||
-rw-r--r-- | framework/source/inc/loadenv/loadenv.hxx | 9 | ||||
-rw-r--r-- | framework/source/loadenv/loadenv.cxx | 7 | ||||
-rw-r--r-- | framework/source/services/autorecovery.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/appl/appopen.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/dialog/filedlghelper.cxx | 93 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 3 |
9 files changed, 66 insertions, 74 deletions
diff --git a/framework/inc/framework/preventduplicateinteraction.hxx b/framework/inc/framework/preventduplicateinteraction.hxx index 559f6b4a7495..2d058c231777 100644 --- a/framework/inc/framework/preventduplicateinteraction.hxx +++ b/framework/inc/framework/preventduplicateinteraction.hxx @@ -26,7 +26,6 @@ #include <com/sun/star/task/XInteractionHandler2.hpp> #include <com/sun/star/task/XInteractionRequest.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <cppuhelper/implbase1.hxx> @@ -92,7 +91,7 @@ class FWE_DLLPUBLIC PreventDuplicateInteraction : private ThreadHelpBase2 private: /// Used to create needed uno services at runtime. - css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; + css::uno::Reference< css::uno::XComponentContext > m_xContext; /** The outside interaction handler, which is used to handle every incoming interaction, if it's not blocked. */ @@ -160,7 +159,7 @@ class FWE_DLLPUBLIC PreventDuplicateInteraction : private ThreadHelpBase2 @threadsafe not neccessary */ - PreventDuplicateInteraction(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR); + PreventDuplicateInteraction(const css::uno::Reference< css::uno::XComponentContext >& rxContext); //_________________________________ /** diff --git a/framework/inc/services.h b/framework/inc/services.h index 28f8b6d70bad..6fb4b45c723e 100644 --- a/framework/inc/services.h +++ b/framework/inc/services.h @@ -77,7 +77,6 @@ namespace framework{ #define IMPLEMENTATIONNAME_DISPATCHRECORDERSUPPLIER DECLARE_ASCII("com.sun.star.comp.framework.DispatchRecorderSupplier") #define IMPLEMENTATIONNAME_MAILTODISPATCHER DECLARE_ASCII("com.sun.star.comp.framework.MailToDispatcher" ) #define IMPLEMENTATIONNAME_SERVICEHANDLER DECLARE_ASCII("com.sun.star.comp.framework.ServiceHandler" ) -#define IMPLEMENTATIONNAME_UIINTERACTIONHANDLER DECLARE_ASCII("com.sun.star.comp.uui.UUIInteractionHandler" ) #define IMPLEMENTATIONNAME_SUBSTITUTEPATHVARIABLES DECLARE_ASCII("com.sun.star.comp.framework.PathSubstitution" ) #define IMPLEMENTATIONNAME_PATHSETTINGS DECLARE_ASCII("com.sun.star.comp.framework.PathSettings" ) #define IMPLEMENTATIONNAME_JOBDISPATCH DECLARE_ASCII("com.sun.star.comp.framework.jobs.JobDispatch" ) diff --git a/framework/source/fwe/interaction/preventduplicateinteraction.cxx b/framework/source/fwe/interaction/preventduplicateinteraction.cxx index eeddfd7717b2..0ccb88d805f5 100644 --- a/framework/source/fwe/interaction/preventduplicateinteraction.cxx +++ b/framework/source/fwe/interaction/preventduplicateinteraction.cxx @@ -19,16 +19,15 @@ #include "framework/preventduplicateinteraction.hxx" +#include <com/sun/star/task/InteractionHandler.hpp> #include <com/sun/star/task/XInteractionAbort.hpp> #include <com/sun/star/task/XInteractionRetry.hpp> namespace framework{ -#define IMPLEMENTATIONNAME_UIINTERACTIONHANDLER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.uui.UUIInteractionHandler")) - -PreventDuplicateInteraction::PreventDuplicateInteraction(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR) +PreventDuplicateInteraction::PreventDuplicateInteraction(const css::uno::Reference< css::uno::XComponentContext >& rxContext) : ThreadHelpBase2() - , m_xSMGR(xSMGR) + , m_xContext(rxContext) { } @@ -55,13 +54,10 @@ void PreventDuplicateInteraction::useDefaultUUIHandler() { // SAFE -> ::osl::ResettableMutexGuard aLock(m_aLock); - css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR; aLock.clear(); // <- SAFE - css::uno::Reference< css::task::XInteractionHandler > xHandler( - xSMGR->createInstance(IMPLEMENTATIONNAME_UIINTERACTIONHANDLER), - css::uno::UNO_QUERY_THROW); + css::uno::Reference< css::task::XInteractionHandler > xHandler( css::task::InteractionHandler::createWithParent( m_xContext, 0 ), css::uno::UNO_QUERY_THROW ); // SAFE -> aLock.reset(); diff --git a/framework/source/inc/loadenv/loadenv.hxx b/framework/source/inc/loadenv/loadenv.hxx index b82f0aba027f..c76877f2d09a 100644 --- a/framework/source/inc/loadenv/loadenv.hxx +++ b/framework/source/inc/loadenv/loadenv.hxx @@ -24,17 +24,16 @@ #include <loadenv/actionlockguard.hxx> #include <threadhelp/threadhelpbase.hxx> +#include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/frame/XFrameLoader.hpp> #include <com/sun/star/frame/XLoadEventListener.hpp> #include <com/sun/star/frame/XDispatchResultListener.hpp> #include <com/sun/star/frame/XFrame.hpp> -#include <com/sun/star/util/URL.hpp> - -#include <com/sun/star/lang/IllegalArgumentException.hpp> - #include <com/sun/star/io/IOException.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/util/URL.hpp> #include <comphelper/mediadescriptor.hxx> #include <comphelper/sequenceashashmap.hxx> @@ -370,7 +369,7 @@ public: /** TODO document me ... */ static void initializeUIDefaults( - const css::uno::Reference< css::lang::XMultiServiceFactory >& i_rSMGR, + const css::uno::Reference< css::uno::XComponentContext >& i_rxContext, ::comphelper::MediaDescriptor& io_lMediaDescriptor, const bool _bUIMode, QuietInteraction** o_ppQuiteInteraction diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index 332f3c911fb2..3b0f4cbe9160 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -37,6 +37,7 @@ #include "officecfg/Office/Common.hxx" #include <com/sun/star/task/ErrorCodeRequest.hpp> +#include <com/sun/star/task/InteractionHandler.hpp> #include <com/sun/star/uno/RuntimeException.hpp> #include <com/sun/star/frame/DispatchResultState.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> @@ -293,7 +294,7 @@ void LoadEnv::initializeLoading(const ::rtl::OUString& ( m_lMediaDescriptor.getUnpackedValueOrDefault( ::comphelper::MediaDescriptor::PROP_PREVIEW(), sal_False ) == sal_False ); initializeUIDefaults( - m_xSMGR, + comphelper::getComponentContext(m_xSMGR), m_lMediaDescriptor, bUIMode, &m_pQuietInteraction @@ -304,7 +305,7 @@ void LoadEnv::initializeLoading(const ::rtl::OUString& } -void LoadEnv::initializeUIDefaults( const css::uno::Reference< css::lang::XMultiServiceFactory >& i_rSMGR, +void LoadEnv::initializeUIDefaults( const css::uno::Reference< css::uno::XComponentContext >& i_rxContext, ::comphelper::MediaDescriptor& io_lMediaDescriptor, const bool i_bUIMode, QuietInteraction** o_ppQuietInteraction ) { @@ -318,7 +319,7 @@ void LoadEnv::initializeUIDefaults( const css::uno::Reference< css::lang::XMulti nUpdateMode = css::document::UpdateDocMode::ACCORDING_TO_CONFIG; try { - xInteractionHandler = css::uno::Reference< css::task::XInteractionHandler >(i_rSMGR->createInstance(IMPLEMENTATIONNAME_UIINTERACTIONHANDLER), css::uno::UNO_QUERY); + xInteractionHandler.set( css::task::InteractionHandler::createWithParent( i_rxContext, 0 ), css::uno::UNO_QUERY_THROW ); } catch(const css::uno::RuntimeException&) {throw;} catch(const css::uno::Exception& ) { } diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index 6248ae18225d..e6f35e8edb04 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -2523,7 +2523,7 @@ AutoRecovery::ETimerType AutoRecovery::implts_openDocs(const DispatchParams& aPa else continue; // TODO ERROR! - LoadEnv::initializeUIDefaults( m_xSMGR, lDescriptor, true, NULL ); + LoadEnv::initializeUIDefaults( comphelper::getComponentContext(m_xSMGR), lDescriptor, true, NULL ); // <- SAFE ------------------------------ aWriteLock.unlock(); diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 821b0b61f7ca..cce73e64be4c 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -36,6 +36,7 @@ #include <com/sun/star/document/MacroExecMode.hpp> #include <com/sun/star/document/UpdateDocMode.hpp> #include <com/sun/star/task/ErrorCodeRequest.hpp> +#include <com/sun/star/task/InteractionHandler.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/container/XNameAccess.hpp> @@ -696,7 +697,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) // intercept all incoming interactions and provide useful informations // later if the following transaction was finished. - ::framework::PreventDuplicateInteraction* pHandler = new ::framework::PreventDuplicateInteraction(::comphelper::getProcessServiceFactory()); + ::framework::PreventDuplicateInteraction* pHandler = new ::framework::PreventDuplicateInteraction(::comphelper::getProcessComponentContext()); css::uno::Reference< css::task::XInteractionHandler > xHandler (static_cast< css::task::XInteractionHandler* >(pHandler), css::uno::UNO_QUERY); css::uno::Reference< css::task::XInteractionHandler > xWrappedHandler; @@ -1032,9 +1033,8 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) if (!pInteractionItem) { - Reference < ::com::sun::star::task::XInteractionHandler > xHdl( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString("com.sun.star.comp.uui.UUIInteractionHandler")), UNO_QUERY ); - if (xHdl.is()) - rReq.AppendItem( SfxUnoAnyItem(SID_INTERACTIONHANDLER,::com::sun::star::uno::makeAny(xHdl)) ); + Reference < task::XInteractionHandler2 > xHdl = task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), 0 ); + rReq.AppendItem( SfxUnoAnyItem(SID_INTERACTIONHANDLER,::com::sun::star::uno::makeAny(xHdl)) ); } if (!pMacroExecItem) rReq.AppendItem( SfxUInt16Item(SID_MACROEXECMODE,::com::sun::star::document::MacroExecMode::USE_CONFIG) ); diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 2e4a53619f42..4a1c879731d9 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -40,6 +40,7 @@ #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/container/XEnumeration.hpp> #include <com/sun/star/container/XContainerQuery.hpp> +#include <com/sun/star/task/InteractionHandler.hpp> #include <com/sun/star/task/XInteractionRequest.hpp> #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> @@ -2689,69 +2690,65 @@ ErrCode FileOpenDialog_Impl( sal_Int16 nDialogType, ErrCode RequestPassword(const SfxFilter* pCurrentFilter, rtl::OUString& aURL, SfxItemSet* pSet) { - uno::Reference < ::com::sun::star::task::XInteractionHandler > xInteractionHandler( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString("com.sun.star.comp.uui.UUIInteractionHandler")), UNO_QUERY ); - if( xInteractionHandler.is() ) - { - // TODO: need a save way to distinguish MS filters from other filters - // for now MS-filters are the only alien filters that support encryption - sal_Bool bMSType = !pCurrentFilter->IsOwnFormat(); - ::comphelper::DocPasswordRequestType eType = bMSType ? - ::comphelper::DocPasswordRequestType_MS : - ::comphelper::DocPasswordRequestType_STANDARD; + uno::Reference < task::XInteractionHandler2 > xInteractionHandler = task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), 0 ); + // TODO: need a save way to distinguish MS filters from other filters + // for now MS-filters are the only alien filters that support encryption + sal_Bool bMSType = !pCurrentFilter->IsOwnFormat(); + ::comphelper::DocPasswordRequestType eType = bMSType ? + ::comphelper::DocPasswordRequestType_MS : + ::comphelper::DocPasswordRequestType_STANDARD; - ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, aURL, ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ) != 0 ) ); + ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, aURL, ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ) != 0 ) ); - uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() ); - xInteractionHandler->handle( rRequest ); - if ( pPasswordRequest->isPassword() ) + uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() ); + xInteractionHandler->handle( rRequest ); + if ( pPasswordRequest->isPassword() ) + { + if ( pPasswordRequest->getPassword().getLength() ) { - if ( pPasswordRequest->getPassword().getLength() ) + // TODO/LATER: The filters should show the password dialog themself in future + if ( bMSType ) { - // TODO/LATER: The filters should show the password dialog themself in future - if ( bMSType ) - { - // all the current MS-filters use MSCodec_Std97 implementation - uno::Sequence< sal_Int8 > aUniqueID = ::comphelper::DocPasswordHelper::GenerateRandomByteSequence( 16 ); - uno::Sequence< sal_Int8 > aEncryptionKey = ::comphelper::DocPasswordHelper::GenerateStd97Key( pPasswordRequest->getPassword(), aUniqueID ); + // all the current MS-filters use MSCodec_Std97 implementation + uno::Sequence< sal_Int8 > aUniqueID = ::comphelper::DocPasswordHelper::GenerateRandomByteSequence( 16 ); + uno::Sequence< sal_Int8 > aEncryptionKey = ::comphelper::DocPasswordHelper::GenerateStd97Key( pPasswordRequest->getPassword(), aUniqueID ); - if ( aEncryptionKey.getLength() ) - { - ::comphelper::SequenceAsHashMap aHashData; - aHashData[ ::rtl::OUString( "STD97EncryptionKey" ) ] <<= aEncryptionKey; - aHashData[ ::rtl::OUString( "STD97UniqueID" ) ] <<= aUniqueID; + if ( aEncryptionKey.getLength() ) + { + ::comphelper::SequenceAsHashMap aHashData; + aHashData[ ::rtl::OUString( "STD97EncryptionKey" ) ] <<= aEncryptionKey; + aHashData[ ::rtl::OUString( "STD97UniqueID" ) ] <<= aUniqueID; - pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aHashData.getAsConstNamedValueList() ) ) ); - } - else - return ERRCODE_IO_NOTSUPPORTED; + pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aHashData.getAsConstNamedValueList() ) ) ); } else - { - pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( ::comphelper::OStorageHelper::CreatePackageEncryptionData( pPasswordRequest->getPassword() ) ) ) ); - } - } - - if ( pPasswordRequest->getRecommendReadOnly() ) - pSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); - - if ( bMSType ) - { - // the empty password has 0 as Hash - sal_Int32 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( "com.sun.star.text.TextDocument" ).equals( pCurrentFilter->GetServiceName() ) ); - if ( nHash ) - pSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( nHash ) ) ); + return ERRCODE_IO_NOTSUPPORTED; } else { - uno::Sequence< beans::PropertyValue > aModifyPasswordInfo = ::comphelper::DocPasswordHelper::GenerateNewModifyPasswordInfo( pPasswordRequest->getPasswordToModify() ); - if ( aModifyPasswordInfo.getLength() ) - pSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( aModifyPasswordInfo ) ) ); + pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( ::comphelper::OStorageHelper::CreatePackageEncryptionData( pPasswordRequest->getPassword() ) ) ) ); } } + + if ( pPasswordRequest->getRecommendReadOnly() ) + pSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) ); + + if ( bMSType ) + { + // the empty password has 0 as Hash + sal_Int32 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( "com.sun.star.text.TextDocument" ).equals( pCurrentFilter->GetServiceName() ) ); + if ( nHash ) + pSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( nHash ) ) ); + } else - return ERRCODE_ABORT; + { + uno::Sequence< beans::PropertyValue > aModifyPasswordInfo = ::comphelper::DocPasswordHelper::GenerateNewModifyPasswordInfo( pPasswordRequest->getPasswordToModify() ); + if ( aModifyPasswordInfo.getLength() ) + pSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( aModifyPasswordInfo ) ) ); + } } - return ERRCODE_NONE; + else + return ERRCODE_ABORT; } // ------------------------------------------------------------------------ diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 9ec782e6aab1..98b2100fa5d8 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -65,6 +65,7 @@ #include <com/sun/star/embed/EmbedStates.hpp> #include <com/sun/star/document/XViewDataSupplier.hpp> #include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/task/InteractionHandler.hpp> #include <rtl/ustrbuf.hxx> #include <unotools/localfilehelper.hxx> @@ -694,7 +695,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) if (!pInteractionItem) { - Reference < ::com::sun::star::task::XInteractionHandler > xHdl( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString("com.sun.star.comp.uui.UUIInteractionHandler")), UNO_QUERY ); + Reference < task::XInteractionHandler2 > xHdl = task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), 0 ); if (xHdl.is()) pNewSet->Put( SfxUnoAnyItem(SID_INTERACTIONHANDLER,::com::sun::star::uno::makeAny(xHdl)) ); } |