[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source
Marco Cecchetti
marco.cecchetti at collabora.com
Tue May 31 15:02:15 UTC 2016
sc/inc/column.hxx | 1 +
sc/inc/document.hxx | 1 +
sc/inc/table.hxx | 1 +
sc/inc/tokenarray.hxx | 1 +
sc/source/core/data/column.cxx | 29 +++++++++++++++++++++++++++++
sc/source/core/data/document.cxx | 13 +++++++++++++
sc/source/core/data/table2.cxx | 8 ++++++++
sc/source/core/tool/scmatrix.cxx | 4 ++++
sc/source/ui/unoobj/docuno.cxx | 9 +++++++++
9 files changed, 67 insertions(+)
New commits:
commit b933f9b817d8449a87841e413cbe96ce31a63555
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Tue May 31 10:42:06 2016 +0200
tdf#84411 - OpenCL: S/W interpreter throws std::out_of_range error
The problem is that in an array fragment, row start can be beyond data
row end.
Change-Id: I33658c87c21d1be237f4675241e3eabdd4ec7058
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 1689809..4aa0993 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -3362,6 +3362,10 @@ void ScVectorRefMatrix::ensureFullMatrix()
size_t nRowSize = mnRowSize;
size_t nRowEnd = mnRowStart + mnRowSize;
size_t nDataRowEnd = mpToken->GetArrayLength();
+
+ if (mnRowStart >= nDataRowEnd)
+ return;
+
if (nRowEnd > nDataRowEnd)
{
// Data array is shorter than the row size of the reference. Truncate
commit b75670009ca885869aa6b58ac33766808e23653c
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Thu May 26 21:28:35 2016 +0200
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
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 9754e5a..68fb09c 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -377,6 +377,7 @@ public:
bool IsFormulaDirty( SCROW nRow ) const;
+ void CheckVectorizationState();
void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
void SetDirtyFromClip( SCROW nRow1, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans );
void SetDirty( SCROW nRow1, SCROW nRow2, BroadcastMode );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 5696f26..e0237ac 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1162,6 +1162,7 @@ public:
void ResetChanged( const ScRange& rRange );
+ void CheckVectorizationState();
void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
void SetDirty( const ScRange&, bool bIncludeEmptyCells );
void SetTableOpDirty( const ScRange& ); // for Interpreter TableOp
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index a284d27..0f0887e 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -531,6 +531,7 @@ public:
void ResetChanged( const ScRange& rRange );
+ void CheckVectorizationState();
void SetAllFormulasDirty( const sc::SetFormulaDirtyContext& rCxt );
void SetDirty( const ScRange&, ScColumn::BroadcastMode );
void SetDirtyAfterLoad();
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index a69f624..7606431 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -65,6 +65,7 @@ public:
size_t GetHash() const { return mnHashValue;}
ScFormulaVectorState GetVectorState() const { return meVectorState;}
+ void ResetVectorState() { meVectorState = FormulaVectorEnabled; }
/**
* If the array contains at least one relative row reference or named
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index f846028..8b6d1aa 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 68b1f8f..f9f3933 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 e6ab697..682ce08 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 43f5897..56d5a61 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)
More information about the Libreoffice-commits
mailing list