Kaydet (Commit) c0aba500 authored tarafından Eike Rathke's avatar Eike Rathke

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.

Change-Id: I6fa00fb4f442bf7c9410679e446ff460289e4b16
üst 07b18860
...@@ -1831,7 +1831,7 @@ void FormulaDlg::StoreFormEditData(FormEditData* pData) ...@@ -1831,7 +1831,7 @@ void FormulaDlg::StoreFormEditData(FormEditData* pData)
const IFunctionDescription* FormulaDlg::getCurrentFunctionDescription() const const IFunctionDescription* FormulaDlg::getCurrentFunctionDescription() const
{ {
OSL_VERIFY(!m_pImpl->pFuncDesc || m_pImpl->pFuncDesc->getSuppressedArgumentCount() == m_pImpl->nArgs); //OSL_VERIFY(!m_pImpl->pFuncDesc || m_pImpl->pFuncDesc->getSuppressedArgumentCount() == m_pImpl->nArgs);
return m_pImpl->pFuncDesc; return m_pImpl->pFuncDesc;
} }
......
...@@ -675,6 +675,8 @@ void WorkbookGlobals::recalcFormulaCells() ...@@ -675,6 +675,8 @@ void WorkbookGlobals::recalcFormulaCells()
officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), batch); officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), batch);
ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions(); ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
aOpt.SetOOXMLRecalcOptions(bHardRecalc ? RECALC_ALWAYS : RECALC_NEVER); 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); SC_MOD()->SetFormulaOptions(aOpt);
batch->commit(); batch->commit();
......
...@@ -1034,13 +1034,15 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet ) ...@@ -1034,13 +1034,15 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
if (pFormulaCfg && pFormulaCfg->GetCalcConfig() != rOpt.GetCalcConfig()) if (pFormulaCfg && pFormulaCfg->GetCalcConfig() != rOpt.GetCalcConfig())
bCalcAll = true; bCalcAll = true;
SetFormulaOptions( rOpt );
if ( pDocSh ) if ( pDocSh )
{ {
pDocSh->SetFormulaOptions( rOpt ); pDocSh->SetFormulaOptions( rOpt );
pDocSh->SetDocumentModified(); pDocSh->SetDocumentModified();
} }
// ScDocShell::SetFormulaOptions() may check for changed settings, so
// set the new options here after that has been called.
SetFormulaOptions( rOpt );
} }
// ViewOptions // ViewOptions
......
...@@ -484,6 +484,8 @@ bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::uno::R ...@@ -484,6 +484,8 @@ bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::uno::R
officecfg::Office::Calc::Formula::Load::ODFRecalcMode::set(sal_Int32(0), batch); officecfg::Office::Calc::Formula::Load::ODFRecalcMode::set(sal_Int32(0), batch);
ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions(); ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
aOpt.SetODFRecalcOptions(bHardRecalc ? RECALC_ALWAYS : RECALC_NEVER); 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); SC_MOD()->SetFormulaOptions(aOpt);
batch->commit(); batch->commit();
......
...@@ -417,7 +417,7 @@ void ScDocShell::InitOptions(bool bForLoading) // called from InitNew and L ...@@ -417,7 +417,7 @@ void ScDocShell::InitOptions(bool bForLoading) // called from InitNew and L
aDocument.SetDocOptions( aDocOpt ); aDocument.SetDocOptions( aDocOpt );
aDocument.SetViewOptions( aViewOpt ); aDocument.SetViewOptions( aViewOpt );
SetFormulaOptions( aFormulaOpt ); SetFormulaOptions( aFormulaOpt, bForLoading );
// Druck-Optionen werden jetzt direkt vor dem Drucken gesetzt // Druck-Optionen werden jetzt direkt vor dem Drucken gesetzt
......
...@@ -445,32 +445,48 @@ bool ScDocShell::ReloadTabLinks() ...@@ -445,32 +445,48 @@ bool ScDocShell::ReloadTabLinks()
return true; //! Fehler erkennen return true; //! Fehler erkennen
} }
void ScDocShell::SetFormulaOptions(const ScFormulaOptions& rOpt ) void ScDocShell::SetFormulaOptions( const ScFormulaOptions& rOpt, bool bForLoading )
{ {
aDocument.SetGrammar( rOpt.GetFormulaSyntax() ); aDocument.SetGrammar( rOpt.GetFormulaSyntax() );
// This needs to be called first since it may re-initialize the entire // This is nasty because it resets module globals from within a docshell!
// opcode map. // For actual damage caused see fdo#82183 where an unconditional
if (rOpt.GetUseEnglishFuncName()) // 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. */
if (!bForLoading)
{ {
// switch native symbols to English. if (rOpt.GetUseEnglishFuncName() != SC_MOD()->GetFormulaOptions().GetUseEnglishFuncName())
ScCompiler aComp(NULL, ScAddress()); {
ScCompiler::OpCodeMapPtr xMap = aComp.GetOpCodeMap(::com::sun::star::sheet::FormulaLanguage::ENGLISH); // This needs to be called first since it may re-initialize the entire
ScCompiler::SetNativeSymbols(xMap); // opcode map.
} if (rOpt.GetUseEnglishFuncName())
else {
// re-initialize native symbols with localized function names. // switch native symbols to English.
ScCompiler::ResetNativeSymbols(); 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. // Force re-population of function names for the function wizard, function tip etc.
ScGlobal::ResetFunctionList(); ScGlobal::ResetFunctionList();
}
// Update the separators. // Update the separators.
ScCompiler::UpdateSeparatorsNative( ScCompiler::UpdateSeparatorsNative(
rOpt.GetFormulaSepArg(), rOpt.GetFormulaSepArrayCol(), rOpt.GetFormulaSepArrayRow()); rOpt.GetFormulaSepArg(), rOpt.GetFormulaSepArrayCol(), rOpt.GetFormulaSepArrayRow());
// Global interpreter settings. // Global interpreter settings.
ScInterpreter::SetGlobalConfig(rOpt.GetCalcConfig()); ScInterpreter::SetGlobalConfig(rOpt.GetCalcConfig());
}
// Per document interpreter settings. // Per document interpreter settings.
SetCalcConfig( rOpt.GetCalcConfig()); SetCalcConfig( rOpt.GetCalcConfig());
......
...@@ -323,7 +323,7 @@ public: ...@@ -323,7 +323,7 @@ public:
void UpdateLinks() SAL_OVERRIDE; void UpdateLinks() SAL_OVERRIDE;
bool ReloadTabLinks(); bool ReloadTabLinks();
void SetFormulaOptions(const ScFormulaOptions& rOpt ); void SetFormulaOptions( const ScFormulaOptions& rOpt, bool bForLoading = false );
void SetCalcConfig( const ScCalcConfig& rConfig ); void SetCalcConfig( const ScCalcConfig& rConfig );
virtual void CheckConfigOptions() SAL_OVERRIDE; virtual void CheckConfigOptions() SAL_OVERRIDE;
......
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