Kaydet (Commit) 06b3ccf8 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Move recalc on-load to after ScDocumentImport::finalize().

Doing this would avoid re-grouping formula cells twice.

Change-Id: I732658fc92f2fb3ddde0c0c00ae85f72074b6b48
üst fdc57d0d
......@@ -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 --------------------------------------------------------------------
......
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment