[Libreoffice-commits] .: sc/inc sc/qa sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Dec 4 13:24:47 PST 2012
sc/inc/document.hxx | 13 ++++++++-----
sc/inc/globstr.hrc | 5 ++++-
sc/qa/unit/filters-test.cxx | 2 ++
sc/qa/unit/subsequent_filters-test.cxx | 2 ++
sc/source/core/data/documen2.cxx | 1 +
sc/source/core/data/document.cxx | 10 ++++++++++
sc/source/filter/oox/workbookfragment.cxx | 29 +++++++++++++++++++++++++++--
sc/source/ui/docshell/docsh.cxx | 22 +++++++++++++++++-----
sc/source/ui/docshell/externalrefmgr.cxx | 1 +
sc/source/ui/src/globstr.src | 10 ++++++++++
10 files changed, 82 insertions(+), 13 deletions(-)
New commits:
commit 1732d9e96fc11417fb966f2127001711fa3af4f1
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Dec 4 16:23:18 2012 -0500
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
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index a202a54..7986930 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 4fc17bd..3f23dc1 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 b4a9fa1..060fbaa 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 a72629a..d31bd8d 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 58bfc9e..095b41a 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 06474f6..9d8a8c3 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 05f7fea..896f648 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 52355d6..22322ba 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 ed7b2fe..83b8bff 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 817ce4a..d4be6fa 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?";
+ };
};
More information about the Libreoffice-commits
mailing list