summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-12-20 05:18:26 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-12-20 06:56:28 +0100
commit2b995d9f9a4f5b99a1c6e80be77a0a6dea2c968a (patch)
tree5a11b9e2039aede57b6a973e81bbdc87a27f87cd /sc
parentbacf1f9d7be4030b292e4f586654907601b9e4ed (diff)
add a warning dialog if we have ext refs to unsaved docs
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/externalrefmgr.hxx13
-rw-r--r--sc/inc/globstr.hrc3
-rw-r--r--sc/source/ui/docshell/docsh.cxx15
-rw-r--r--sc/source/ui/src/globstr.src4
4 files changed, 28 insertions, 7 deletions
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index b3a640e9cc78..c44c8f1dc623 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -687,6 +687,13 @@ public:
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+ /**
+ * If we still contain unsaved files we should warn the user before saving
+ *
+ * @return true if the document still contains references to an unsaved file
+ */
+ bool containsUnsavedReferences() { return !maUnsavedDocShells.empty(); }
+
private:
ScExternalRefManager();
ScExternalRefManager(const ScExternalRefManager&);
@@ -763,12 +770,6 @@ private:
sal_uInt32 getMappedNumberFormat(sal_uInt16 nFileId, sal_uInt32 nNumFmt, const ScDocument* pSrcDoc);
- /**
- * If we still contain unsaved files we should warn the user before saving
- *
- * @return true if the document still contains references to an unsaved file
- */
- bool containsUnsavedReferences() { return !maUnsavedDocShells.empty(); }
private:
/** cache of referenced ranges and names from source documents. */
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 2363aaf326fa..a545a0e69e17 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -599,8 +599,9 @@
#define STR_ERR_NAME_EXISTS 463
#define STR_ERR_NAME_INVALID 464
+#define STR_UNSAVED_EXT_REF 465
-#define STR_COUNT 465
+#define STR_COUNT 466
#endif
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 26cea1451242..8f4f3fc68f9f 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -913,11 +913,25 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
if ( !bSuccess )
SetError( ERRCODE_IO_ABORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); // this error code will produce no error message, but will break the further saving process
}
+
+
if (pSheetSaveData)
pSheetSaveData->SetInSupportedSave(true);
}
break;
case SFX_EVENT_SAVEASDOC:
+ {
+ if ( GetDocument()->GetExternalRefManager()->containsUnsavedReferences() )
+ {
+ WarningBox aBox( GetActiveDialogParent(), WinBits( WB_YES_NO ),
+ ScGlobal::GetRscString( STR_UNSAVED_EXT_REF ) );
+
+ if( RET_NO == aBox.Execute())
+ {
+ SetError( ERRCODE_IO_ABORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); // this error code will produce no error message, but will break the further saving process
+ }
+ }
+ } // fall through
case SFX_EVENT_SAVETODOC:
// #i108978# If no event is sent before saving, there will also be no "...DONE" event,
// and SAVE/SAVEAS can't be distinguished from SAVETO. So stream copying is only enabled
@@ -1557,6 +1571,7 @@ sal_Bool ScDocShell::SaveAs( SfxMedium& rMedium )
return false;
}
+
ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
PrepareSaveGuard aPrepareGuard( *this);
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index 464f14119a50..8d6425dfd45d 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1851,5 +1851,9 @@ Resource RID_GLOBSTR
{
Text [ en-US ] = "Invalid name. Only use letters, numbers and underscore.";
};
+ String STR_UNSAVED_EXT_REF
+ {
+ Text [ en-US ] = "This Document contains external references to unsaved documents.\n\nDo you want to continue?";
+ };
};