summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-12-04 16:23:18 -0500
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-12-04 16:25:47 -0500
commit1732d9e96fc11417fb966f2127001711fa3af4f1 (patch)
treed42ec38438212efc71a9cd26211c8db00deb7b97
parent65e36f20761ff191816f9a7e32da750ca3001e45 (diff)
Ask the user if she wants to do full recalc on load, for ods and xlsx import.
But allow it to be disabled for filters tests as well as external document loading. Change-Id: I5b8533532c6be8b7c2cfcbe15faf780d621aec65
-rw-r--r--sc/inc/document.hxx13
-rw-r--r--sc/inc/globstr.hrc5
-rw-r--r--sc/qa/unit/filters-test.cxx2
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx2
-rw-r--r--sc/source/core/data/documen2.cxx1
-rw-r--r--sc/source/core/data/document.cxx10
-rw-r--r--sc/source/filter/oox/workbookfragment.cxx29
-rw-r--r--sc/source/ui/docshell/docsh.cxx22
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx1
-rw-r--r--sc/source/ui/src/globstr.src10
10 files changed, 82 insertions, 13 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index a202a5487abe..79869300ae05 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -391,11 +391,12 @@ private:
mutable bool bStyleSheetUsageInvalid;
- bool mbUndoEnabled;
- bool mbAdjustHeightEnabled;
- bool mbExecuteLinkEnabled;
- bool mbChangeReadOnlyEnabled; // allow changes in read-only document (for API import filters)
- bool mbStreamValidLocked;
+ bool mbUndoEnabled:1;
+ bool mbAdjustHeightEnabled:1;
+ bool mbExecuteLinkEnabled:1;
+ bool mbChangeReadOnlyEnabled:1; // allow changes in read-only document (for API import filters)
+ bool mbStreamValidLocked:1;
+ bool mbUserInteractionEnabled:1; // whether or not to launch any kind of interactive dialogs.
sal_Int16 mnNamedRangesLockCount;
@@ -996,6 +997,8 @@ public:
void EnableExecuteLink( bool bVal ) { mbExecuteLinkEnabled = bVal; }
bool IsChangeReadOnlyEnabled() const { return mbChangeReadOnlyEnabled; }
void EnableChangeReadOnly( bool bVal ) { mbChangeReadOnlyEnabled = bVal; }
+ SC_DLLPUBLIC bool IsUserInteractionEnabled() const;
+ SC_DLLPUBLIC void EnableUserInteraction( bool bVal );
SC_DLLPUBLIC sal_Int16 GetNamedRangesLockCount() const { return mnNamedRangesLockCount; }
void SetNamedRangesLockCount( sal_Int16 nCount ) { mnNamedRangesLockCount = nCount; }
SC_DLLPUBLIC void ResetClip( ScDocument* pSourceDoc, const ScMarkData* pMarks );
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 4fc17bd9b9ee..3f23dc1936f2 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -616,6 +616,9 @@
#define STR_ERR_CONDFORMAT_PROTECTED 491
-#define STR_COUNT 492
+#define STR_QUERY_FORMULA_RECALC_ONLOAD_ODS 492
+#define STR_QUERY_FORMULA_RECALC_ONLOAD_XLS 493
+
+#define STR_COUNT 494
#endif
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index b4a9fa129eb5..060fbaad493c 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -156,7 +156,9 @@ ScDocShellRef ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUStr
pFilter->SetVersion(nFilterVersion);
ScDocShellRef xDocShRef = new ScDocShell;
+ xDocShRef->GetDocument()->EnableUserInteraction(false);
SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
+ pSrcMed->UseInteractionHandler(false);
pSrcMed->SetFilter(pFilter);
if (!xDocShRef->DoLoad(pSrcMed))
{
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index a72629a7be93..d31bd8de6ceb 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -244,7 +244,9 @@ ScDocShellRef ScFiltersTest::load(const rtl::OUString &rFilter, const rtl::OUStr
pFilter->SetVersion(nFilterVersion);
ScDocShellRef xDocShRef = new ScDocShell;
+ xDocShRef->GetDocument()->EnableUserInteraction(false);
SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
+ pSrcMed->UseInteractionHandler(false);
pSrcMed->SetFilter(pFilter);
if (!xDocShRef->DoLoad(pSrcMed))
{
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 58bfc9e38294..095b41ab5af0 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -205,6 +205,7 @@ ScDocument::ScDocument( ScDocumentMode eMode,
mbExecuteLinkEnabled( true ),
mbChangeReadOnlyEnabled( false ),
mbStreamValidLocked( false ),
+ mbUserInteractionEnabled(true),
mnNamedRangesLockCount( 0 ),
mbIsInTest( false )
{
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 06474f627e30..9d8a8c387db0 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -5668,6 +5668,16 @@ void ScDocument::EnableUndo( bool bVal )
mbUndoEnabled = bVal;
}
+bool ScDocument::IsUserInteractionEnabled() const
+{
+ return mbUserInteractionEnabled;
+}
+
+void ScDocument::EnableUserInteraction( bool bVal )
+{
+ mbUserInteractionEnabled = bVal;
+}
+
bool ScDocument::IsInVBAMode() const
{
if (!pShell)
diff --git a/sc/source/filter/oox/workbookfragment.cxx b/sc/source/filter/oox/workbookfragment.cxx
index 05f7feaef4d7..896f64834552 100644
--- a/sc/source/filter/oox/workbookfragment.cxx
+++ b/sc/source/filter/oox/workbookfragment.cxx
@@ -27,6 +27,8 @@
#include "oox/helper/progressbar.hxx"
#include "oox/helper/propertyset.hxx"
#include "oox/ole/olestorage.hxx"
+#include "vcl/msgbox.hxx"
+
#include "biffinputstream.hxx"
#include "chartsheetfragment.hxx"
#include "connectionsfragment.hxx"
@@ -43,6 +45,10 @@
#include "worksheetbuffer.hxx"
#include "worksheetfragment.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "globstr.hrc"
+
namespace oox {
namespace xls {
@@ -309,10 +315,29 @@ void WorkbookFragment::finalizeImport()
// final conversions, e.g. calculation settings and view settings
finalizeWorkbookImport();
- // Recalculate (only changed ones)
+ // Recalculate formula cells.
Reference< XCalculatable > xCalculatable( getDocument(), UNO_QUERY );
if( xCalculatable.is() )
- xCalculatable->calculate();
+ {
+ bool bHardRecalc = false;
+ ScDocument& rDoc = getScDocument();
+ if (rDoc.IsUserInteractionEnabled())
+ {
+ // Ask the user if full re-calculation is desired.
+ ScDocShell* pDocSh = static_cast<ScDocShell*>(rDoc.GetDocumentShell());
+
+ QueryBox aBox(
+ pDocSh->GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+ ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
+
+ bHardRecalc = aBox.Execute() == RET_YES;
+ }
+
+ if (bHardRecalc)
+ xCalculatable->calculateAll();
+ else
+ xCalculatable->calculate();
+ }
}
// private --------------------------------------------------------------------
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 52355d6c6f70..22322ba4da28 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -112,8 +112,6 @@
#include <vector>
#include <boost/shared_ptr.hpp>
-#define SC_LIBO_PROD_NAME "LibreOffice"
-
using namespace com::sun::star;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::UNO_QUERY;
@@ -426,10 +424,24 @@ sal_Bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::un
//did not use cached formula results.
uno::Reference<document::XDocumentPropertiesSupplier> xDPS(GetModel(), uno::UNO_QUERY_THROW);
uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
- rtl::OUString sGenerator(xDocProps->getGenerator());
- if(sGenerator.indexOf(SC_LIBO_PROD_NAME) == -1)
+ rtl::OUString sGenerator = xDocProps->getGenerator();
+
+ bool bHardRecalc = false;
+ if (aDocument.IsUserInteractionEnabled() && xDocProps->getGenerator().indexOf("LibreOffice") == -1)
+ {
+ // Generator is not LibreOffice. Ask if the user wants to perform
+ // full re-calculation.
+ QueryBox aBox(
+ GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+ ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_ODS));
+
+ bHardRecalc = aBox.Execute() == RET_YES;
+ }
+
+ if (bHardRecalc)
DoHardRecalc(false);
- else //still need to recalc volatile formula cells
+ else
+ // still need to recalc volatile formula cells.
aDocument.CalcFormulaTree(false, false, false);
aDocument.EnableAdjustHeight(false);
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index ed7b2feceebd..83b8bff74a5f 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -2189,6 +2189,7 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, OUSt
pSrcDoc->EnableExecuteLink(false); // to prevent circular access of external references.
pSrcDoc->EnableUndo(false);
pSrcDoc->EnableAdjustHeight(false);
+ pSrcDoc->EnableUserInteraction(false);
ScExtDocOptions* pExtOptNew = pSrcDoc->GetExtDocOptions();
if (!pExtOptNew)
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index 817ce4a5ef90..d4be6fa3a04c 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1946,5 +1946,15 @@ Resource RID_GLOBSTR
{
Text [ en-US ] = "Conditional Formats can not be created, deleted or changed in protected sheets!";
};
+
+ String STR_QUERY_FORMULA_RECALC_ONLOAD_ODS
+ {
+ Text [ en-US ] = "This document was last saved by application other than LibreOffice. Some formula cells may produce different results when recalculated.\n\nDo you want to recalculate all formula cells in this document now?";
+ };
+
+ String STR_QUERY_FORMULA_RECALC_ONLOAD_XLS
+ {
+ Text [ en-US ] = "This document was last saved by Excel. Some formula cells may produce different results when recalculated.\n\nDo you want to recalculate all formula cells now?";
+ };
};