[Libreoffice-commits] core.git: sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Wed Nov 27 07:26:33 PST 2013
sc/source/filter/oox/workbookfragment.cxx | 46 --------------------------
sc/source/filter/oox/workbookhelper.cxx | 53 ++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 46 deletions(-)
New commits:
commit 06b3ccf8069c6478634dc218eaad3f02ecbfbc85
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Nov 27 10:26:32 2013 -0500
Move recalc on-load to after ScDocumentImport::finalize().
Doing this would avoid re-grouping formula cells twice.
Change-Id: I732658fc92f2fb3ddde0c0c00ae85f72074b6b48
diff --git a/sc/source/filter/oox/workbookfragment.cxx b/sc/source/filter/oox/workbookfragment.cxx
index c189be9..7acb16a 100644
--- a/sc/source/filter/oox/workbookfragment.cxx
+++ b/sc/source/filter/oox/workbookfragment.cxx
@@ -26,7 +26,6 @@
#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"
@@ -46,12 +45,9 @@
#include "document.hxx"
#include "docsh.hxx"
-#include "globstr.hrc"
#include "calcconfig.hxx"
#include <oox/core/fastparser.hxx>
-#include <comphelper/processfactory.hxx>
-#include <officecfg/Office/Calc.hxx>
#include <salhelper/thread.hxx>
#include <osl/conditn.hxx>
@@ -529,48 +525,6 @@ void WorkbookFragment::finalizeImport()
// final conversions, e.g. calculation settings and view settings
finalizeWorkbookImport();
-
- // Recalculate formula cells.
- ScDocument& rDoc = getScDocument();
- rDoc.RebuildFormulaGroups();
- ScDocShell& rDocSh = getDocShell();
- Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
- ScRecalcOptions nRecalcMode =
- static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get(xContext));
- bool bHardRecalc = false;
- if (nRecalcMode == RECALC_ASK)
- {
- if (rDoc.IsUserInteractionEnabled())
- {
- // Ask the user if full re-calculation is desired.
- QueryBox aBox(
- rDocSh.GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
- ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
- aBox.SetCheckBoxText(ScGlobal::GetRscString(STR_ALWAYS_PERFORM_SELECTED));
-
- sal_Int32 nRet = aBox.Execute();
- bHardRecalc = nRet == RET_YES;
-
- if (aBox.GetCheckBoxState())
- {
- // Always perform selected action in the future.
- boost::shared_ptr< comphelper::ConfigurationChanges > batch( comphelper::ConfigurationChanges::create() );
- officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), batch);
- ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
- aOpt.SetOOXMLRecalcOptions(bHardRecalc ? RECALC_ALWAYS : RECALC_NEVER);
- SC_MOD()->SetFormulaOptions(aOpt);
-
- batch->commit();
- }
- }
- }
- else if (nRecalcMode == RECALC_ALWAYS)
- bHardRecalc = true;
-
- if (bHardRecalc)
- rDocSh.DoHardRecalc(false);
- else
- rDoc.CalcFormulaTree(false, true, false);
}
// private --------------------------------------------------------------------
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index 66a51b4..3cba32f 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -39,6 +39,7 @@
#include "oox/helper/progressbar.hxx"
#include "oox/helper/propertyset.hxx"
#include "oox/ole/vbaproject.hxx"
+#include "vcl/msgbox.hxx"
#include "addressconverter.hxx"
#include "biffinputstream.hxx"
#include "biffcodec.hxx"
@@ -73,12 +74,16 @@
#include "globalnames.hxx"
#include "documentimport.hxx"
#include "drwlayer.hxx"
+#include "globstr.hrc"
#include "formulabuffer.hxx"
#include "vcl/mapmod.hxx"
#include "editutil.hxx"
#include "editeng/editstat.hxx"
+#include <comphelper/processfactory.hxx>
+#include <officecfg/Office/Calc.hxx>
+
#include <boost/noncopyable.hpp>
#include <boost/scoped_ptr.hpp>
@@ -236,6 +241,8 @@ private:
/** Finalizes the filter process (sets some needed document properties). */
void finalize();
+ void recalcFormulaCells();
+
private:
typedef ::std::auto_ptr< ScEditEngineDefaulter > EditEngineDefaulterPtr;
typedef ::std::auto_ptr< FormulaBuffer > FormulaBufferPtr;
@@ -653,9 +660,55 @@ void WorkbookGlobals::finalize()
//ScDocShell::AfterXMLLoading() for ods
mpDoc->SetInsertingFromOtherDoc(false);
getDocImport().finalize();
+
+ recalcFormulaCells();
}
}
+void WorkbookGlobals::recalcFormulaCells()
+{
+ // Recalculate formula cells.
+ ScDocument& rDoc = getScDocument();
+ ScDocShell& rDocSh = getDocShell();
+ Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
+ ScRecalcOptions nRecalcMode =
+ static_cast<ScRecalcOptions>(officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get(xContext));
+ bool bHardRecalc = false;
+ if (nRecalcMode == RECALC_ASK)
+ {
+ if (rDoc.IsUserInteractionEnabled())
+ {
+ // Ask the user if full re-calculation is desired.
+ QueryBox aBox(
+ rDocSh.GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+ ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
+ aBox.SetCheckBoxText(ScGlobal::GetRscString(STR_ALWAYS_PERFORM_SELECTED));
+
+ sal_Int32 nRet = aBox.Execute();
+ bHardRecalc = nRet == RET_YES;
+
+ if (aBox.GetCheckBoxState())
+ {
+ // Always perform selected action in the future.
+ boost::shared_ptr< comphelper::ConfigurationChanges > batch( comphelper::ConfigurationChanges::create() );
+ officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), batch);
+ ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
+ aOpt.SetOOXMLRecalcOptions(bHardRecalc ? RECALC_ALWAYS : RECALC_NEVER);
+ SC_MOD()->SetFormulaOptions(aOpt);
+
+ batch->commit();
+ }
+ }
+ }
+ else if (nRecalcMode == RECALC_ALWAYS)
+ bHardRecalc = true;
+
+ if (bHardRecalc)
+ rDocSh.DoHardRecalc(false);
+ else
+ rDoc.CalcFormulaTree(false, true, false);
+}
+
// ============================================================================
WorkbookHelper::~WorkbookHelper()
More information about the Libreoffice-commits
mailing list