summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2014-08-21 23:14:52 +0200
committerCaolán McNamara <caolanm@redhat.com>2014-09-05 10:49:58 -0500
commitfef72d750ea29dd3368f2e5f3099bb81e22ab07c (patch)
tree67eda9e568f8bd9c7d03baa3b9fcd7c40010e8f4
parenta7f7b93299a9a7af8b243099f78f236172c4cb51 (diff)
fdo#82183 do not reset globals while loading a document
Destroying the function list while an instance of the Formula Wizard is still open is a bad idea. Workaround not doing this when loading a document due to a DDE function or external reference being entered in the wizard. (cherry picked from commit c0aba5007b6e468336b41138f099914c32f4b0cf) Conflicts: sc/source/ui/app/scmod.cxx sc/source/ui/docshell/docsh6.cxx sc/source/ui/inc/docsh.hxx init formula options once, fdo#82183 (cherry picked from commit 10b6bda51c9da5429ca562c70ce75ee03e5f4e56) Change-Id: I6fa00fb4f442bf7c9410679e446ff460289e4b16 Reviewed-on: https://gerrit.libreoffice.org/11064 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sc/source/filter/oox/workbookhelper.cxx2
-rw-r--r--sc/source/ui/app/scmod.cxx6
-rw-r--r--sc/source/ui/docshell/docsh.cxx2
-rw-r--r--sc/source/ui/docshell/docsh3.cxx2
-rw-r--r--sc/source/ui/docshell/docsh6.cxx60
-rw-r--r--sc/source/ui/inc/docsh.hxx2
6 files changed, 51 insertions, 23 deletions
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index ca61154db340..219f2708c3ad 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -688,6 +688,8 @@ void WorkbookGlobals::recalcFormulaCells()
officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), batch);
ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
aOpt.SetOOXMLRecalcOptions(bHardRecalc ? RECALC_ALWAYS : RECALC_NEVER);
+ /* XXX is this really supposed to set the ScModule options?
+ * Not the ScDocShell options? */
SC_MOD()->SetFormulaOptions(aOpt);
batch->commit();
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 309da2c9f216..61b53c4a52d9 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1073,13 +1073,15 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
bCompileErrorCells = true;
}
- SetFormulaOptions( rOpt );
-
if ( pDocSh )
{
pDocSh->SetFormulaOptions( rOpt );
pDocSh->SetDocumentModified();
}
+
+ // ScDocShell::SetFormulaOptions() may check for changed settings, so
+ // set the new options here after that has been called.
+ SetFormulaOptions( rOpt );
}
//============================================
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 71dfa0ae37c6..6c03ec14319f 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -497,6 +497,8 @@ sal_Bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::un
officecfg::Office::Calc::Formula::Load::ODFRecalcMode::set(sal_Int32(0), batch);
ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
aOpt.SetODFRecalcOptions(bHardRecalc ? RECALC_ALWAYS : RECALC_NEVER);
+ /* XXX is this really supposed to set the ScModule options?
+ * Not the ScDocShell options? */
SC_MOD()->SetFormulaOptions(aOpt);
batch->commit();
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index 42817ee00ac2..4478daa9c88b 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -438,7 +438,7 @@ void ScDocShell::InitOptions(bool bForLoading) // called from InitNew and L
aDocument.SetDocOptions( aDocOpt );
aDocument.SetViewOptions( aViewOpt );
- SetFormulaOptions( aFormulaOpt );
+ SetFormulaOptions( aFormulaOpt, bForLoading );
// Druck-Optionen werden jetzt direkt vor dem Drucken gesetzt
diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx
index ca6aeb373f51..04b2c5496323 100644
--- a/sc/source/ui/docshell/docsh6.cxx
+++ b/sc/source/ui/docshell/docsh6.cxx
@@ -454,32 +454,54 @@ sal_Bool ScDocShell::ReloadTabLinks()
return sal_True; //! Fehler erkennen
}
-void ScDocShell::SetFormulaOptions(const ScFormulaOptions& rOpt )
+void ScDocShell::SetFormulaOptions( const ScFormulaOptions& rOpt, bool bForLoading )
{
aDocument.SetGrammar( rOpt.GetFormulaSyntax() );
- // This needs to be called first since it may re-initialize the entire
- // opcode map.
- if (rOpt.GetUseEnglishFuncName())
+ // This is nasty because it resets module globals from within a docshell!
+ // For actual damage caused see fdo#82183 where an unconditional
+ // ScGlobal::ResetFunctionList() (without checking GetUseEnglishFuncName())
+ // lead to a crash becasuse the function list was still used by the Formula
+ // Wizard when loading the second document.
+ // Do the stupid stuff only when we're not called while loading a document.
+
+ /* TODO: bForLoading is a workaround, rather get rid of setting any
+ * globals from per document instances like ScDocShell. */
+
+ /* XXX this is utter crap, we rely on the options being set here at least
+ * once, for the very first document, empty or loaded. */
+ static bool bInitOnce = true;
+
+ if (!bForLoading || bInitOnce)
{
- // switch native symbols to English.
- ScCompiler aComp(NULL, ScAddress());
- ScCompiler::OpCodeMapPtr xMap = aComp.GetOpCodeMap(::com::sun::star::sheet::FormulaLanguage::ENGLISH);
- ScCompiler::SetNativeSymbols(xMap);
- }
- else
- // re-initialize native symbols with localized function names.
- ScCompiler::ResetNativeSymbols();
+ bool bForceInit = bInitOnce;
+ bInitOnce = false;
+ if (bForceInit || rOpt.GetUseEnglishFuncName() != SC_MOD()->GetFormulaOptions().GetUseEnglishFuncName())
+ {
+ // This needs to be called first since it may re-initialize the entire
+ // opcode map.
+ if (rOpt.GetUseEnglishFuncName())
+ {
+ // switch native symbols to English.
+ ScCompiler aComp(NULL, ScAddress());
+ ScCompiler::OpCodeMapPtr xMap = aComp.GetOpCodeMap(::com::sun::star::sheet::FormulaLanguage::ENGLISH);
+ ScCompiler::SetNativeSymbols(xMap);
+ }
+ else
+ // re-initialize native symbols with localized function names.
+ ScCompiler::ResetNativeSymbols();
- // Force re-population of function names for the function wizard, function tip etc.
- ScGlobal::ResetFunctionList();
+ // Force re-population of function names for the function wizard, function tip etc.
+ ScGlobal::ResetFunctionList();
+ }
- // Update the separators.
- ScCompiler::UpdateSeparatorsNative(
- rOpt.GetFormulaSepArg(), rOpt.GetFormulaSepArrayCol(), rOpt.GetFormulaSepArrayRow());
+ // Update the separators.
+ ScCompiler::UpdateSeparatorsNative(
+ rOpt.GetFormulaSepArg(), rOpt.GetFormulaSepArrayCol(), rOpt.GetFormulaSepArrayRow());
- // Global interpreter settings.
- ScInterpreter::SetGlobalConfig(rOpt.GetCalcConfig());
+ // Global interpreter settings.
+ ScInterpreter::SetGlobalConfig(rOpt.GetCalcConfig());
+ }
}
void ScDocShell::CheckConfigOptions()
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 7e103902fb1f..b24be7d92d94 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -322,7 +322,7 @@ public:
void UpdateLinks();
sal_Bool ReloadTabLinks();
- void SetFormulaOptions(const ScFormulaOptions& rOpt );
+ void SetFormulaOptions( const ScFormulaOptions& rOpt, bool bForLoading = false );
virtual void CheckConfigOptions();
void PostEditView( ScEditEngineDefaulter* pEditEngine, const ScAddress& rCursorPos );