summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2016-05-26 21:28:35 +0200
committerJan Holesovsky <kendy@collabora.com>2016-05-31 17:01:12 +0200
commitb75670009ca885869aa6b58ac33766808e23653c (patch)
tree42447bb988efc534e9303c57412d6e5e6543b16b /sc/source
parenta1ebcf401da3ae0cc8a12320b8b549a2d8d6e5bf (diff)
tdf#100160 - Changing OpenCL state doesn't update sheet
now we re-check for vectorization state of formula token each time OpenCL is enabled or disabled Change-Id: I652397dd154f5fbf788cb511c70e53a47cc94293
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/column.cxx29
-rw-r--r--sc/source/core/data/document.cxx13
-rw-r--r--sc/source/core/data/table2.cxx8
-rw-r--r--sc/source/ui/unoobj/docuno.cxx9
4 files changed, 59 insertions, 0 deletions
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index f846028af0f7..8b6d1aa0a7ef 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2648,6 +2648,28 @@ public:
}
};
+class CheckVectorizationHandler
+{
+public:
+ CheckVectorizationHandler()
+ {}
+
+ void operator() (size_t /*nRow*/, ScFormulaCell* p)
+ {
+ ScTokenArray* pCode = p->GetCode();
+ if (pCode != nullptr && pCode->GetVectorState() == FormulaVectorDisabled)
+ {
+ pCode->ResetVectorState();
+ FormulaToken* pFT = pCode->First();
+ while (pFT != nullptr)
+ {
+ pCode->CheckToken(*pFT);
+ pFT = pCode->Next();
+ }
+ }
+ }
+};
+
struct SetDirtyVarHandler
{
void operator() (size_t /*nRow*/, ScFormulaCell* p)
@@ -3093,6 +3115,13 @@ bool ScColumn::IsFormulaDirty( SCROW nRow ) const
return p->GetDirty();
}
+void ScColumn::CheckVectorizationState()
+{
+ sc::AutoCalcSwitch aSwitch(*pDocument, false);
+ CheckVectorizationHandler aFunc;
+ sc::ProcessFormula(maCells, aFunc);
+}
+
void ScColumn::SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt )
{
// is only done documentwide, no FormulaTracking
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 68b1f8f52a7d..f9f3933dbf6c 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3717,6 +3717,19 @@ bool ScDocument::HasSelectionData( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
return HasStringCells( ScRange( nCol, 0, nTab, nCol, MAXROW, nTab ) );
}
+void ScDocument::CheckVectorizationState()
+{
+ bool bOldAutoCalc = GetAutoCalc();
+ bAutoCalc = false; // no mulitple calculations
+
+ TableContainer::iterator it = maTabs.begin();
+ for (; it != maTabs.end(); ++it)
+ if (*it)
+ (*it)->CheckVectorizationState();
+
+ SetAutoCalc(bOldAutoCalc);
+}
+
void ScDocument::SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt )
{
bool bOldAutoCalc = GetAutoCalc();
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index e6ab697941ba..682ce083805b 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1699,6 +1699,14 @@ void ScTable::SetDirtyVar()
aCol[i].SetDirtyVar();
}
+void ScTable::CheckVectorizationState()
+{
+ sc::AutoCalcSwitch aACSwitch(*pDocument, false);
+
+ for (SCCOL i = 0; i <= MAXCOL; i++)
+ aCol[i].CheckVectorizationState();
+}
+
void ScTable::SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt )
{
sc::AutoCalcSwitch aACSwitch(*pDocument, false);
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 43f5897930fd..56d5a6148d8d 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -2821,6 +2821,9 @@ sal_Bool ScModelObj::isOpenCLEnabled()
void ScModelObj::enableOpenCL(sal_Bool bEnable)
throw (uno::RuntimeException, std::exception)
{
+ if (ScCalcConfig::isOpenCLEnabled() == static_cast<bool>(bEnable))
+ return;
+
std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Misc::UseOpenCL::set(bEnable, batch);
batch->commit();
@@ -2829,6 +2832,12 @@ void ScModelObj::enableOpenCL(sal_Bool bEnable)
if (bEnable)
aConfig.setOpenCLConfigToDefault();
ScInterpreter::SetGlobalConfig(aConfig);
+
+ sc::FormulaGroupInterpreter::switchOpenCLDevice(OUString(), true, false);
+
+ ScDocument* pDoc = GetDocument();
+ pDoc->CheckVectorizationState();
+
}
void ScModelObj::enableAutomaticDeviceSelection(sal_Bool bForce)