diff options
author | Ádám Csaba Király <kiraly.adam.csaba@gmail.com> | 2013-04-03 21:05:12 +0200 |
---|---|---|
committer | Thorsten Behrens <tbehrens@suse.com> | 2013-05-02 09:40:10 +0000 |
commit | 7061e8403a3afddae253ad0a016e5613616030bb (patch) | |
tree | 7bceb8fe3f42eaab2b600e185d0bbe990a404ff3 /sfx2 | |
parent | cf685e9299ab9d196b7f90803f03d4fea8d16091 (diff) |
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 <tbehrens@suse.com>
Tested-by: Thorsten Behrens <tbehrens@suse.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/sdi/sfx.sdi | 9 | ||||
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/doc/guisaveas.cxx | 25 | ||||
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 22 |
4 files changed, 40 insertions, 25 deletions
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<beans::PropertyValue>& rArgs, SfxAllItemSet& rSet, const SfxSlot* pSlot ) @@ -1293,6 +1295,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b // used only internally if ( nId == SID_SAVETO ) continue; + if ( nId == SID_SAVEACOPYITEM ) + continue; if ( nId == SID_MODIFYPASSWORDINFO ) continue; if ( nId == SID_SUGGESTEDSAVEASDIR ) @@ -1424,7 +1428,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b } if ( nSlotId == SID_OPENDOC || nSlotId == SID_EXPORTDOC || nSlotId == SID_SAVEASDOC || nSlotId == SID_SAVEDOC || - nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF ) + nSlotId == SID_SAVETO || nSlotId == SID_EXPORTDOCASPDF || nSlotId == SID_DIRECTEXPORTDOCASPDF || + nSlotId == SID_SAVEACOPY ) { const SfxPoolItem *pItem=0; if ( rSet.GetItemState( SID_COMPONENTDATA, sal_False, &pItem ) == SFX_ITEM_SET ) diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index d795ea8228d8..f5e6a1b6e5e8 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -121,7 +121,7 @@ static sal_uInt16 getSlotIDFromMode( sal_Int8 nStoreMode ) // dialogs do not need parameters in SidSet representation any more sal_uInt16 nResult = 0; - if ( nStoreMode == EXPORT_REQUESTED ) + if ( nStoreMode == EXPORT_REQUESTED || nStoreMode == ( EXPORT_REQUESTED | SAVEACOPY_REQUESTED | WIDEEXPORT_REQUESTED ) ) nResult = SID_EXPORTDOC; else if ( nStoreMode == ( EXPORT_REQUESTED | PDFEXPORT_REQUESTED ) ) nResult = SID_EXPORTDOCASPDF; @@ -129,8 +129,6 @@ static sal_uInt16 getSlotIDFromMode( sal_Int8 nStoreMode ) nResult = SID_DIRECTEXPORTDOCASPDF; else if ( nStoreMode == SAVEAS_REQUESTED || nStoreMode == ( EXPORT_REQUESTED | WIDEEXPORT_REQUESTED ) ) nResult = SID_SAVEASDOC; - else if ( nStoreMode == SAVEACOPY_REQUESTED || nStoreMode == ( EXPORT_REQUESTED | WIDEEXPORT_REQUESTED ) ) - nResult = SID_SAVEACOPY; else { DBG_ASSERT( sal_False, "Unacceptable slot name is provided!\n" ); } @@ -152,8 +150,6 @@ static sal_uInt8 getStoreModeFromSlotName( const OUString& aSlotName ) nResult = SAVE_REQUESTED; else if ( aSlotName == "SaveAs" ) nResult = SAVEAS_REQUESTED; - else if ( aSlotName == "SaveACopy" ) - nResult = SAVEACOPY_REQUESTED; else throw task::ErrorCodeIOException( OUString(), uno::Reference< uno::XInterface >(), @@ -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: |