summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÁdám Csaba Király <kiraly.adam.csaba@gmail.com>2013-04-03 21:05:12 +0200
committerThorsten Behrens <tbehrens@suse.com>2013-05-02 09:40:10 +0000
commit7061e8403a3afddae253ad0a016e5613616030bb (patch)
tree7bceb8fe3f42eaab2b600e185d0bbe990a404ff3
parentcf685e9299ab9d196b7f90803f03d4fea8d16091 (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>
-rw-r--r--include/sfx2/sfxsids.hrc1
-rw-r--r--oox/source/core/filterbase.cxx2
-rw-r--r--reportdesign/source/ui/report/ReportController.cxx4
-rw-r--r--sfx2/sdi/sfx.sdi9
-rw-r--r--sfx2/source/appl/appuno.cxx9
-rw-r--r--sfx2/source/doc/guisaveas.cxx25
-rw-r--r--sfx2/source/doc/objserv.cxx22
-rw-r--r--sw/source/ui/uiview/srcview.cxx3
-rw-r--r--sw/source/ui/uiview/view.hrc2
9 files changed, 51 insertions, 26 deletions
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 00923ffdc6a8..cd25c9ea05b7 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -118,6 +118,7 @@
#define SID_OPENTEMPLATE (SID_SFX_START + 594)
#define SID_SAVEASDOC (SID_SFX_START + 502)
#define SID_SAVEACOPY (SID_SFX_START + 999)
+#define SID_SAVEACOPYITEM (SID_SFX_START + 998)
#define SID_CLOSING (SID_SFX_START +1539)
#define SID_CLOSEDOC (SID_SFX_START + 503)
#define SID_CLOSEDOCS (SID_SFX_START + 595)
diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx
index 4d31f0547787..13551fe495e5 100644
--- a/oox/source/core/filterbase.cxx
+++ b/oox/source/core/filterbase.cxx
@@ -507,7 +507,7 @@ sal_Bool SAL_CALL FilterBase::filter( const Sequence< PropertyValue >& rMediaDes
}
break;
}
- mxImpl->finalizeFilter();
+ mxImpl->mxModel->unlockControllers();
}
return bRet;
}
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index 27c76ab9c35a..aa56679522ec 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -793,6 +793,9 @@ FeatureState OReportController::GetState(sal_uInt16 _nId) const
case SID_SAVEASDOC:
aReturn.bEnabled = isConnected() && isEditable();
break;
+ case SID_SAVEACOPY:
+ aReturn.bEnabled = isConnected() && isEditable();
+ break;
case SID_EDITDOC:
aReturn.bChecked = isEditable();
break;
@@ -1913,6 +1916,7 @@ void OReportController::describeSupportedFeatures()
implDescribeSupportedFeature( ".uno:NewDoc", SID_NEWDOC, CommandGroup::DOCUMENT );
implDescribeSupportedFeature( ".uno:Save", SID_SAVEDOC, CommandGroup::DOCUMENT );
implDescribeSupportedFeature( ".uno:SaveAs", SID_SAVEASDOC, CommandGroup::DOCUMENT );
+ implDescribeSupportedFeature( ".uno:SaveACopy", SID_SAVEACOPY, CommandGroup::DOCUMENT );
implDescribeSupportedFeature( ".uno:InsertPageNumberField", SID_INSERT_FLD_PGNUMBER, CommandGroup::INSERT );
implDescribeSupportedFeature( ".uno:InsertDateTimeField", SID_DATETIME, CommandGroup::INSERT );
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:
diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx
index 194fd2ee3ef3..53a856c39514 100644
--- a/sw/source/ui/uiview/srcview.cxx
+++ b/sw/source/ui/uiview/srcview.cxx
@@ -430,6 +430,9 @@ void SwSrcView::GetState(SfxItemSet& rSet)
case SID_SAVEASDOC:
rSet.Put(SfxStringItem(nWhich, String(SW_RES(STR_SAVEAS_SRC))));
break;
+ case SID_SAVEACOPY:
+ rSet.Put(SfxStringItem(nWhich, String(SW_RES(STR_SAVEACOPY_SRC))));
+ break;
case SID_SAVEDOC:
{
SwDocShell* pDocShell = GetDocShell();
diff --git a/sw/source/ui/uiview/view.hrc b/sw/source/ui/uiview/view.hrc
index a38e4385ec10..c987cdf97d39 100644
--- a/sw/source/ui/uiview/view.hrc
+++ b/sw/source/ui/uiview/view.hrc
@@ -56,6 +56,8 @@
#define RID_PVIEW_TOOLBOX (RC_VIEW_BEGIN + 31)
#define STR_WEBOPTIONS (RC_VIEW_BEGIN + 32)
#define STR_TEXTOPTIONS (RC_VIEW_BEGIN + 33)
+
+#define STR_SAVEACOPY_SRC (RC_VIEW_BEGIN + 34)
// MSG -------------------------------------------------------------------
#define MSG_ERR_INSERT_GLOS (RC_VIEW_BEGIN)