Kaydet (Commit) 34c157e0 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

improve the recalc dialog for ooxml

Change-Id: I94ea2d52f86a340ce3802ea4b63642cfc637bd2d
üst 688c6680
......@@ -1506,6 +1506,36 @@
<value>false</value>
</prop>
</group>
<group oor:name="Load">
<info>
<desc>Contains settings that affect formula handling while laoding.</desc>
</info>
<prop oor:name="OOXMLRecalcMode" oor:type="xs:int" oor:nillable="false">
<!-- UIHint: Tools - Options - Spreadsheet - Formula -->
<info>
<author>Markus Mohrhard</author>
<desc>Specifies whether to force a hard recalc after load</desc>
</info>
<constraints>
<enumeration oor:value="0">
<info>
<desc>Recalc always</desc>
</info>
</enumeration>
<enumeration oor:value="1">
<info>
<desc>Ask before Recalc</desc>
</info>
</enumeration>
<enumeration oor:value="2">
<info>
<desc>Recalc never</desc>
</info>
</enumeration>
</constraints>
<value>1</value>
</prop>
</group>
</group>
<group oor:name="Revision">
<info>
......
......@@ -37,6 +37,14 @@
#include "global.hxx"
#include "calcconfig.hxx"
// have to match the registry values
enum SC_DLLPUBLIC ScRecalcOptions
{
RECALC_ALWAYS = 0,
RECALC_ASK = 1,
RECALC_NEVER = 2
};
class SC_DLLPUBLIC ScFormulaOptions
{
private:
......@@ -48,6 +56,8 @@ private:
::rtl::OUString aFormulaSepArrayRow;
::rtl::OUString aFormulaSepArrayCol;
ScRecalcOptions meOOXMLRecalc;
public:
ScFormulaOptions();
ScFormulaOptions( const ScFormulaOptions& rCpy );
......@@ -74,6 +84,9 @@ public:
void SetFormulaSepArrayCol(const ::rtl::OUString& rSep) { aFormulaSepArrayCol = rSep; }
::rtl::OUString GetFormulaSepArrayCol() const { return aFormulaSepArrayCol; }
void SetOOXMLRecalcOptions( ScRecalcOptions eOpt ) { meOOXMLRecalc = eOpt; }
ScRecalcOptions GetOOXMLRecalcOptions() const { return meOOXMLRecalc; }
void ResetFormulaSeparators();
static void GetDefaultFormulaSeparators(rtl::OUString& rSepArg, rtl::OUString& rSepArrayCol, rtl::OUString& rSepArrayRow);
......
......@@ -618,7 +618,9 @@
#define STR_QUERY_FORMULA_RECALC_ONLOAD_ODS 492
#define STR_QUERY_FORMULA_RECALC_ONLOAD_XLS 493
#define STR_ALWAYS 494
#define STR_NEVER 495
#define STR_COUNT 494
#define STR_COUNT 496
#endif
......@@ -173,14 +173,14 @@ public:
const ScDocOptions& GetDocOptions ();
SC_DLLPUBLIC const ScAppOptions& GetAppOptions ();
SC_DLLPUBLIC const ScDefaultsOptions& GetDefaultsOptions ();
const ScFormulaOptions& GetFormulaOptions ();
SC_DLLPUBLIC const ScFormulaOptions& GetFormulaOptions ();
const ScInputOptions& GetInputOptions ();
SC_DLLPUBLIC const ScPrintOptions& GetPrintOptions ();
void SetViewOptions ( const ScViewOptions& rOpt );
void SetDocOptions ( const ScDocOptions& rOpt );
SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rOpt );
void SetDefaultsOptions ( const ScDefaultsOptions& rOpt );
void SetFormulaOptions ( const ScFormulaOptions& rOpt );
SC_DLLPUBLIC void SetFormulaOptions ( const ScFormulaOptions& rOpt );
void SetInputOptions ( const ScInputOptions& rOpt );
void SetPrintOptions ( const ScPrintOptions& rOpt );
void InsertEntryToLRUList(sal_uInt16 nFIndex);
......
......@@ -58,7 +58,8 @@ ScFormulaOptions::ScFormulaOptions( const ScFormulaOptions& rCpy ) :
aCalcConfig(rCpy.aCalcConfig),
aFormulaSepArg ( rCpy.aFormulaSepArg ),
aFormulaSepArrayRow ( rCpy.aFormulaSepArrayRow ),
aFormulaSepArrayCol ( rCpy.aFormulaSepArrayCol )
aFormulaSepArrayCol ( rCpy.aFormulaSepArrayCol ),
meOOXMLRecalc ( rCpy.meOOXMLRecalc )
{
}
......@@ -70,6 +71,7 @@ void ScFormulaOptions::SetDefaults()
{
bUseEnglishFuncName = false;
eFormulaGrammar = ::formula::FormulaGrammar::GRAM_NATIVE;
meOOXMLRecalc = RECALC_ASK;
// unspecified means use the current formula syntax.
aCalcConfig.reset();
......@@ -148,6 +150,7 @@ ScFormulaOptions& ScFormulaOptions::operator=( const ScFormulaOptions& rCpy )
aFormulaSepArg = rCpy.aFormulaSepArg;
aFormulaSepArrayRow = rCpy.aFormulaSepArrayRow;
aFormulaSepArrayCol = rCpy.aFormulaSepArrayCol;
meOOXMLRecalc = rCpy.meOOXMLRecalc;
return *this;
}
......@@ -158,7 +161,8 @@ bool ScFormulaOptions::operator==( const ScFormulaOptions& rOpt ) const
&& aCalcConfig == rOpt.aCalcConfig
&& aFormulaSepArg == rOpt.aFormulaSepArg
&& aFormulaSepArrayRow == rOpt.aFormulaSepArrayRow
&& aFormulaSepArrayCol == rOpt.aFormulaSepArrayCol;
&& aFormulaSepArrayCol == rOpt.aFormulaSepArrayCol
&& meOOXMLRecalc == rOpt.meOOXMLRecalc;
}
bool ScFormulaOptions::operator!=( const ScFormulaOptions& rOpt ) const
......@@ -214,7 +218,8 @@ SfxPoolItem* ScTpFormulaItem::Clone( SfxItemPool * ) const
#define SCFORMULAOPT_SEP_ARRAY_COL 4
#define SCFORMULAOPT_STRING_REF_SYNTAX 5
#define SCFORMULAOPT_EMPTY_STRING_AS_ZERO 6
#define SCFORMULAOPT_COUNT 7
#define SCFORMULAOPT_OOXML_RECALC 7
#define SCFORMULAOPT_COUNT 8
Sequence<OUString> ScFormulaCfg::GetPropertyNames()
{
......@@ -227,6 +232,7 @@ Sequence<OUString> ScFormulaCfg::GetPropertyNames()
"Syntax/SeparatorArrayCol", // SCFORMULAOPT_SEP_ARRAY_COL
"Syntax/StringRefAddressSyntax", // SCFORMULAOPT_STRING_REF_SYNTAX
"Syntax/EmptyStringAsZero", // SCFORMULAOPT_EMPTY_STRING_AS_ZERO
"Load/OOXMLRecalcMode", // SCFORMULAOPT_OOXML_RECALC
};
Sequence<OUString> aNames(SCFORMULAOPT_COUNT);
OUString* pNames = aNames.getArray();
......@@ -350,6 +356,30 @@ ScFormulaCfg::ScFormulaCfg() :
GetCalcConfig().mbEmptyStringAsZero = bVal;
}
break;
case SCFORMULAOPT_OOXML_RECALC:
{
ScRecalcOptions eOpt = RECALC_ASK;
if (pValues[nProp] >>= nIntVal)
{
switch (nIntVal)
{
case 0:
eOpt = RECALC_ALWAYS;
break;
case 1:
eOpt = RECALC_ASK;
break;
case 2:
eOpt = RECALC_NEVER;
break;
default:
SAL_WARN("sc", "unknown ooxml recalc option!");
}
}
SetOOXMLRecalcOptions(eOpt);
}
break;
default:
;
}
......@@ -414,6 +444,25 @@ void ScFormulaCfg::Commit()
pValues[nProp] <<= bVal;
}
break;
case SCFORMULAOPT_OOXML_RECALC:
{
sal_Int32 nVal = 1;
switch (GetOOXMLRecalcOptions())
{
case RECALC_ALWAYS:
nVal = 0;
break;
case RECALC_ASK:
nVal = 1;
break;
case RECALC_NEVER:
nVal = 2;
break;
}
pValues[nProp] <<= nVal;
}
break;
default:
;
}
......
......@@ -48,6 +48,9 @@
#include "docsh.hxx"
#include "globstr.hrc"
#include <comphelper/processfactory.hxx>
#include <officecfg/Office/Calc.hxx>
namespace oox {
namespace xls {
......@@ -315,18 +318,63 @@ void WorkbookFragment::finalizeImport()
finalizeWorkbookImport();
// Recalculate formula cells.
bool bHardRecalc = false;
ScDocument& rDoc = getScDocument();
ScDocShell* pDocSh = static_cast<ScDocShell*>(rDoc.GetDocumentShell());
if (rDoc.IsUserInteractionEnabled())
Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
sal_Int32 nRecalcMode = officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::get(xContext);
bool bHardRecalc = false;
if (nRecalcMode == 1)
{
// Ask the user if full re-calculation is desired.
QueryBox aBox(
pDocSh->GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
if (rDoc.IsUserInteractionEnabled())
{
bHardRecalc = aBox.Execute() == RET_YES;
#define RET_ALWAYS 10
#define RET_NEVER 11
// Ask the user if full re-calculation is desired.
QueryBox aBox(
pDocSh->GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
aBox.AddButton(ScGlobal::GetRscString(STR_ALWAYS), RET_ALWAYS, 0);
aBox.AddButton(ScGlobal::GetRscString(STR_NEVER), RET_NEVER, 0);
boost::shared_ptr< comphelper::ConfigurationChanges > batch( comphelper::ConfigurationChanges::create() );
sal_Int32 nRet = aBox.Execute();
switch (nRet)
{
case RET_YES:
bHardRecalc = true;
break;
case RET_NO:
bHardRecalc = false;
break;
case RET_ALWAYS:
{
bHardRecalc = true;
officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(0), batch);
ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
aOpt.SetOOXMLRecalcOptions(RECALC_ALWAYS);
SC_MOD()->SetFormulaOptions(aOpt);
}
break;
case RET_NEVER:
{
bHardRecalc = false;
officecfg::Office::Calc::Formula::Load::OOXMLRecalcMode::set(sal_Int32(2), batch);
ScFormulaOptions aOpt = SC_MOD()->GetFormulaOptions();
aOpt.SetOOXMLRecalcOptions(RECALC_NEVER);
SC_MOD()->SetFormulaOptions(aOpt);
}
break;
default:
SAL_WARN("sc", "unknown return value!");
bHardRecalc = true;
}
batch->commit();
}
}
else if(nRecalcMode == 0)
bHardRecalc = true;
if (bHardRecalc)
pDocSh->DoHardRecalc(false);
......
......@@ -166,6 +166,8 @@
#define BTN_CUSTOM_CALC_DEFAULT 93
#define BTN_CUSTOM_CALC_CUSTOM 94
#define BTN_CUSTOM_CALC_DETAILS 95
#define FL_RECALC_OPTIONS 96
#define LB_OOXML_RECALC 97
// TP_COMPATIBILITY
#define FL_KEY_BINDINGS 1
......
......@@ -75,6 +75,9 @@ private:
RadioButton maBtnCustomCalcCustom;
PushButton maBtnCustomCalcDetails;
FixedLine maFlRecalcOptions;
ListBox maLbOOXMLRecalcOptions;
/** Stores old separator value of currently focused separator edit box.
This value is used to revert undesired value change. */
::rtl::OUString maOldSepValue;
......
......@@ -60,7 +60,8 @@ ScTpFormulaOptions::ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreA
maBtnCustomCalcDefault(this, ScResId(BTN_CUSTOM_CALC_DEFAULT)),
maBtnCustomCalcCustom(this, ScResId(BTN_CUSTOM_CALC_CUSTOM)),
maBtnCustomCalcDetails(this, ScResId(BTN_CUSTOM_CALC_DETAILS)),
maFlRecalcOptions(this, ScResId(FL_RECALC_OPTIONS)),
maLbOOXMLRecalcOptions( this, ScResId(LB_OOXML_RECALC)),
mnDecSep(0)
{
maLbFormulaSyntax.InsertEntry(ScResId(SCSTR_FORMULA_SYNTAX_CALC_A1).toString());
......@@ -245,6 +246,7 @@ sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
OUString aSep = maEdSepFuncArg.GetText();
OUString aSepArrayCol = maEdSepArrayCol.GetText();
OUString aSepArrayRow = maEdSepArrayRow.GetText();
sal_Int16 aOOXMLRecalcMode = maLbOOXMLRecalcOptions.GetSelectEntryPos();
if (maBtnCustomCalcDefault.IsChecked())
{
......@@ -257,6 +259,7 @@ sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
|| static_cast<OUString>(maEdSepFuncArg.GetSavedValue()) != aSep
|| static_cast<OUString>(maEdSepArrayCol.GetSavedValue()) != aSepArrayCol
|| static_cast<OUString>(maEdSepArrayRow.GetSavedValue()) != aSepArrayRow
|| maLbOOXMLRecalcOptions.GetSavedValue() != aOOXMLRecalcMode
|| maSavedConfig != maCurrentConfig )
{
::formula::FormulaGrammar::Grammar eGram = ::formula::FormulaGrammar::GRAM_DEFAULT;
......@@ -274,12 +277,27 @@ sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
break;
}
ScRecalcOptions eOOXMLRecalc = RECALC_ASK;
switch (aOOXMLRecalcMode)
{
case 0:
eOOXMLRecalc = RECALC_ALWAYS;
break;
case 1:
eOOXMLRecalc = RECALC_ASK;
break;
case 2:
eOOXMLRecalc = RECALC_NEVER;
break;
};
aOpt.SetFormulaSyntax(eGram);
aOpt.SetUseEnglishFuncName(bEnglishFuncName);
aOpt.SetFormulaSepArg(aSep);
aOpt.SetFormulaSepArrayCol(aSepArrayCol);
aOpt.SetFormulaSepArrayRow(aSepArrayRow);
aOpt.SetCalcConfig(maCurrentConfig);
aOpt.SetOOXMLRecalcOptions(eOOXMLRecalc);
rCoreSet.Put( ScTpFormulaItem( SID_SCFORMULAOPTIONS, aOpt ) );
bRet = true;
......@@ -315,6 +333,23 @@ void ScTpFormulaOptions::Reset(const SfxItemSet& rCoreSet)
maLbFormulaSyntax.SaveValue();
ScRecalcOptions eOOXMLRecalc = aOpt.GetOOXMLRecalcOptions();
switch (eOOXMLRecalc)
{
case RECALC_ALWAYS:
maLbOOXMLRecalcOptions.SelectEntryPos(0);
break;
case RECALC_ASK:
maLbOOXMLRecalcOptions.SelectEntryPos(1);
break;
case RECALC_NEVER:
maLbOOXMLRecalcOptions.SelectEntryPos(2);
break;
}
maLbOOXMLRecalcOptions.SaveValue();
// english function name.
maCbEnglishFuncName.Check( aOpt.GetUseEnglishFuncName() );
maCbEnglishFuncName.SaveValue();
......
......@@ -1956,5 +1956,14 @@ Resource RID_GLOBSTR
{
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?";
};
String STR_ALWAYS
{
Text [ en-US ] = "Always";
};
String STR_NEVER
{
Text [ en-US ] = "Never";
};
};
......@@ -284,6 +284,25 @@ TabPage RID_SCPAGE_FORMULA
Size = MAP_APPFONT ( 60, 14 ) ;
Text [ en-US ] = "Details...";
};
FixedLine FL_RECALC_OPTIONS
{
Pos = MAP_APPFONT ( 6, 178 );
Size = MAP_APPFONT( 248, 8 );
Text [ en-US ] = "Recalculation after laod settings";
};
ListBox LB_OOXML_RECALC
{
Pos = MAP_APPFONT( 21, 188);
Size = MAP_APPFONT( 100, 50 );
Border = TRUE;
DropDown = TRUE;
StringList [ en-US ] =
{
"Recalculate always";
"Ask before recalculation";
"Recalculate never";
};
};
};
TabPage RID_SCPAGE_COMPATIBILITY
......
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