From 7061e8403a3afddae253ad0a016e5613616030bb Mon Sep 17 00:00:00 2001 From: Ádám Csaba Király Date: Wed, 3 Apr 2013 21:05:12 +0200 Subject: fdo#60780, refactor Save a Copy and fix Refactor Save a Copy, basing it on Export functionality. SID_SAVEACOPY takes its parameters, and sends a SID_EXPORTDOC request with them, using SID_SAVEACOPYITEM to differentiate Save a Copy from regular Export. Fix storing docx to url, by preventing finalizeFilter method, in filterbase.cxx, from writing back to the original file's MediaDescriptor. Change-Id: I876dbe17e43b26a43f29e797fdb157e31889ee1e Reviewed-on: https://gerrit.libreoffice.org/3355 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens --- sfx2/sdi/sfx.sdi | 9 +++------ sfx2/source/appl/appuno.cxx | 9 +++++++-- sfx2/source/doc/guisaveas.cxx | 25 +++++++++++++++---------- sfx2/source/doc/objserv.cxx | 22 +++++++++++++++------- 4 files changed, 40 insertions(+), 25 deletions(-) (limited to 'sfx2') diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index ad70c3ad1157..b8823d20a0fc 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -5586,8 +5586,9 @@ SfxBoolItem SaveAsTemplate SID_DOCTEMPLATE ] //-------------------------------------------------------------------------- + SfxBoolItem SaveACopy SID_SAVEACOPY -(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxBoolItem PasswordInteraction SID_PASSWORDINTERACTION,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO) +(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxBoolItem Overwrite SID_OVERWRITE, SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxBoolItem SaveACopy SID_SAVEACOPYITEM) [ /* flags: */ AutoUpdate = FALSE, @@ -5602,9 +5603,6 @@ SfxBoolItem SaveACopy SID_SAVEACOPY RecordPerSet; Synchron; - /* status: */ - SlotType = SfxStringItem - /* config: */ AccelConfig = TRUE, MenuConfig = TRUE, @@ -5612,7 +5610,6 @@ SfxBoolItem SaveACopy SID_SAVEACOPY ToolBoxConfig = TRUE, GroupId = GID_DOCUMENT; ] - //-------------------------------------------------------------------------- SfxVoidItem SaveBasicAs SID_BASICSAVEAS () @@ -7282,7 +7279,7 @@ TbxImageItem ZoomToolBox SID_ZOOM_TOOLBOX //-------------------------------------------------------------------------- SfxBoolItem ExportTo SID_EXPORTDOC -(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxBoolItem Overwrite SID_OVERWRITE, SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS) +(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxBoolItem Overwrite SID_OVERWRITE, SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxBoolItem SaveACopy SID_SAVEACOPYITEM) [ /* flags: */ AutoUpdate = FALSE, diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 6cbccc56b3de..e7e045d556a8 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -145,6 +145,7 @@ SfxFormalArgument aFormalArgs[] = { // SFX_ARGUMENT(SID_TEMPLATE_NAME,"Name",SfxStringItem), SFX_ARGUMENT(SID_UNPACK,"Unpacked",SfxBoolItem), SFX_ARGUMENT(SID_VERSION,"Version",SfxInt16Item), + SFX_ARGUMENT(SID_SAVEACOPYITEM,"SaveACopy",SfxBoolItem), }; static sal_uInt16 nMediaArgsCount = sizeof(aFormalArgs) / sizeof (SfxFormalArgument); @@ -210,7 +211,8 @@ static bool isMediaDescriptor( sal_uInt16 nSlotId ) return ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC || nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || - nSlotId == SID_DIRECTEXPORTDOCASPDF ); + nSlotId == SID_DIRECTEXPORTDOCASPDF || nSlotId == SID_SAVEACOPY || + nSlotId == SID_SAVEACOPYITEM); } void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence& rArgs, SfxAllItemSet& rSet, const SfxSlot* pSlot ) @@ -1293,6 +1295,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence(), @@ -927,7 +923,7 @@ sal_Bool ModelData_Impl::OutputFileDialog( sal_Int8 nStoreMode, aDialogFlags = SFXWB_EXPORT; } - if ( nStoreMode & SAVEACOPY_REQUESTED) + if( ( nStoreMode & EXPORT_REQUESTED ) && ( nStoreMode & SAVEACOPY_REQUESTED ) && ( nStoreMode & WIDEEXPORT_REQUESTED ) ) { aDialogFlags = SFXWB_SAVEACOPY; } @@ -1377,6 +1373,15 @@ sal_Bool SfxStoringHelper::GUIStoreModel( uno::Reference< frame::XModel > xModel sal_Int8 nStoreMode = getStoreModeFromSlotName( aSlotName ); sal_Int8 nStatusSave = STATUS_NO_ACTION; + ::comphelper::SequenceAsHashMap::const_iterator aSaveACopyIter = + aModelData.GetMediaDescr().find( ::rtl::OUString("SaveACopy") ); + if ( aSaveACopyIter != aModelData.GetMediaDescr().end() ) + { + sal_Bool bSaveACopy = sal_False; + aSaveACopyIter->second >>= bSaveACopy; + if ( bSaveACopy ) + nStoreMode = EXPORT_REQUESTED | SAVEACOPY_REQUESTED | WIDEEXPORT_REQUESTED; + } // handle the special cases if ( nStoreMode & SAVEAS_REQUESTED ) { @@ -1672,21 +1677,21 @@ sal_Bool SfxStoringHelper::GUIStoreModel( uno::Reference< frame::XModel > xModel try { // Document properties can contain streams that should be freed before storing aModelData.FreeDocumentProps(); - if ( ( (nStoreMode & EXPORT_REQUESTED) || (nStoreMode & SAVEACOPY_REQUESTED) ) ) + if ( nStoreMode & EXPORT_REQUESTED ) aModelData.GetStorable()->storeToURL( aURL.GetMainURL( INetURLObject::NO_DECODE ), aArgsSequence ); else aModelData.GetStorable()->storeAsURL( aURL.GetMainURL( INetURLObject::NO_DECODE ), aArgsSequence ); } catch( const uno::Exception& ) { - if ( ( nStoreMode & EXPORT_REQUESTED ) ) + if ( nStoreMode & EXPORT_REQUESTED ) { SetDocInfoState(aModelData.GetModel(), xOldDocProps, sal_True); } throw; } - if ( ( nStoreMode & EXPORT_REQUESTED ) ) + if ( nStoreMode & EXPORT_REQUESTED ) { SetDocInfoState(aModelData.GetModel(), xOldDocProps, sal_True); } @@ -1698,7 +1703,7 @@ sal_Bool SfxStoringHelper::GUIStoreModel( uno::Reference< frame::XModel > xModel // this is actually a save operation with different parameters // so storeTo or storeAs without DocInfo operations are used - if ( ( nStoreMode & EXPORT_REQUESTED ) || ( nStoreMode & SAVEACOPY_REQUESTED ) ) + if ( nStoreMode & EXPORT_REQUESTED ) aModelData.GetStorable()->storeToURL( aURL.GetMainURL( INetURLObject::NO_DECODE ), aArgsSequence ); else aModelData.GetStorable()->storeAsURL( aURL.GetMainURL( INetURLObject::NO_DECODE ), aArgsSequence ); diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index ef09a7efb972..907ee1a67228 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -542,7 +542,6 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) case SID_EXPORTDOC: case SID_SAVEASDOC: case SID_SAVEDOC: - case SID_SAVEACOPY: { // derived class may decide to abort this if( !QuerySlotExecutable( nId ) ) @@ -577,11 +576,6 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) rReq.AppendItem( SfxBoolItem( SID_SAVETO, sal_True ) ); } - if ( nId == SID_SAVEACOPY ) - { - rReq.AppendItem( SfxBoolItem( SID_SAVETO, sal_True ) ); - } - // TODO/LATER: do the following GUI related actions in standalown method // ======================================================================================================== // Introduce a status indicator for GUI operation @@ -755,7 +749,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) nErrorCode = ( lErr != ERRCODE_IO_ABORT ) && ( nErrorCode == ERRCODE_NONE ) ? nErrorCode : lErr; } - if ( (nId == SID_SAVEASDOC || nId == SID_SAVEACOPY) && nErrorCode == ERRCODE_NONE ) + if ( nId == SID_SAVEASDOC && nErrorCode == ERRCODE_NONE ) { SetReadOnlyUI(false); } @@ -768,6 +762,20 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) break; } + case SID_SAVEACOPY: + { + SfxAllItemSet aArgs( GetPool() ); + aArgs.Put( SfxBoolItem( SID_SAVEACOPYITEM, sal_True ) ); + SfxRequest aSaveACopyReq( SID_EXPORTDOC, SFX_CALLMODE_API, aArgs ); + ExecFile_Impl( aSaveACopyReq ); + if ( !aSaveACopyReq.IsDone() ) + { + rReq.Ignore(); + return; + } + break; + } + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - case SID_CLOSEDOC: -- cgit