[PATCH] Save a Copy refactoring
Ádám Király (via_Code_Review)
gerrit at gerrit.libreoffice.org
Fri Apr 12 03:53:30 PDT 2013
Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/3355
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/55/3355/1
Save a Copy refactoring
The way it works now is: SID_SAVEACOPY takes its parameters, and
sends a SID_EXPORTDOC request with it. SID_SAVEACOPYITEM is used
to differentiate Save a Copy from regular Export.
Saving to docx is still buggy :(
(You have to close the original file before you can open it, and
then it complains of:
warn:legacy.osl:18912:1:oox/source/helper/storagebase.cxx:71:
StorageBase::StorageBase - missing base input stream)
Change-Id: I876dbe17e43b26a43f29e797fdb157e31889ee1e
---
M reportdesign/source/ui/report/ReportController.cxx
M sfx2/inc/sfx2/sfxsids.hrc
M sfx2/sdi/sfx.sdi
M sfx2/source/appl/appuno.cxx
M sfx2/source/doc/guisaveas.cxx
M sfx2/source/doc/objserv.cxx
M sw/source/ui/uiview/srcview.cxx
M sw/source/ui/uiview/view.hrc
8 files changed, 52 insertions(+), 27 deletions(-)
diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx
index 4498bed..15b0848 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -793,6 +793,9 @@
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 @@
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/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc
index 7130f06..121e080 100644
--- a/sfx2/inc/sfx2/sfxsids.hrc
+++ b/sfx2/inc/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/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 0fe9cdc..cdc922d 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -5583,8 +5583,9 @@
]
//--------------------------------------------------------------------------
+
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,
@@ -5599,9 +5600,6 @@
RecordPerSet;
Synchron;
- /* status: */
- SlotType = SfxStringItem
-
/* config: */
AccelConfig = TRUE,
MenuConfig = TRUE,
@@ -5609,7 +5607,6 @@
ToolBoxConfig = TRUE,
GroupId = GID_DOCUMENT;
]
-
//--------------------------------------------------------------------------
SfxVoidItem SaveBasicAs SID_BASICSAVEAS
()
@@ -7279,7 +7276,7 @@
//--------------------------------------------------------------------------
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 b707761..eefbd35 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -145,6 +145,7 @@
// 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 @@
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 @@
// 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 @@
}
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 d795ea8..7394936 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -121,7 +121,7 @@
// 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 ) )
nResult = SID_EXPORTDOC;
else if ( nStoreMode == ( EXPORT_REQUESTED | PDFEXPORT_REQUESTED ) )
nResult = SID_EXPORTDOCASPDF;
@@ -129,8 +129,6 @@
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 @@
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 >(),
@@ -166,7 +162,7 @@
static sal_Int32 getMustFlags( sal_Int8 nStoreMode )
{
return ( SFX_FILTER_EXPORT
- | ( ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) ) ? 0 : SFX_FILTER_IMPORT ) );
+ | ( ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) && !(nStoreMode & SAVEACOPY_REQUESTED) ) ? 0 : SFX_FILTER_IMPORT ) );
}
//-------------------------------------------------------------------------
@@ -174,7 +170,7 @@
{
return ( SFX_FILTER_INTERNAL
| SFX_FILTER_NOTINFILEDLG
- | ( ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) ) ? SFX_FILTER_IMPORT : 0 ) );
+ | ( ( ( nStoreMode & EXPORT_REQUESTED ) && !( nStoreMode & WIDEEXPORT_REQUESTED ) && !(nStoreMode & SAVEACOPY_REQUESTED) ) ? SFX_FILTER_IMPORT : 0 ) );
}
//=========================================================================
@@ -927,7 +923,7 @@
aDialogFlags = SFXWB_EXPORT;
}
- if ( nStoreMode & SAVEACOPY_REQUESTED)
+ if( ( nStoreMode & EXPORT_REQUESTED ) && ( nStoreMode & SAVEACOPY_REQUESTED ) )
{
aDialogFlags = SFXWB_SAVEACOPY;
}
@@ -1377,6 +1373,15 @@
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;
+ }
// handle the special cases
if ( nStoreMode & SAVEAS_REQUESTED )
{
@@ -1672,21 +1677,21 @@
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 @@
// 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 ef09a7e..907ee1a 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -542,7 +542,6 @@
case SID_EXPORTDOC:
case SID_SAVEASDOC:
case SID_SAVEDOC:
- case SID_SAVEACOPY:
{
// derived class may decide to abort this
if( !QuerySlotExecutable( nId ) )
@@ -575,11 +574,6 @@
SFX_ITEMSET_ARG( GetMedium()->GetItemSet(), pViewOnlyItem, SfxBoolItem, SID_VIEWONLY, sal_False );
if ( pViewOnlyItem && pViewOnlyItem->GetValue() )
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
@@ -755,7 +749,7 @@
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 @@
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 1405cd4..432afb8 100644
--- a/sw/source/ui/uiview/srcview.cxx
+++ b/sw/source/ui/uiview/srcview.cxx
@@ -430,6 +430,9 @@
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 256e394..92b3eaf 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)
--
To view, visit https://gerrit.libreoffice.org/3355
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I876dbe17e43b26a43f29e797fdb157e31889ee1e
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Ádám Király <kiraly.adam.csaba at gmail.com>
More information about the LibreOffice
mailing list