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 /sfx2 | |
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
Diffstat (limited to 'sfx2')
-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 |
3 files changed, 51 insertions, 53 deletions
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)) ); } |