[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 3 commits - sc/inc sc/qa sc/source

2013-08-05 Thread Kohei Yoshida
 sc/inc/column.hxx  |5 -
 sc/inc/document.hxx|1 
 sc/inc/formulacell.hxx |   12 ++
 sc/inc/table.hxx   |1 
 sc/inc/tokenarray.hxx  |6 +
 sc/qa/unit/data/xls/shared-formula.xls |binary
 sc/qa/unit/filters-test.cxx|9 ++
 sc/source/core/data/column3.cxx|   25 -
 sc/source/core/data/documen2.cxx   |8 +
 sc/source/core/data/formulacell.cxx|  103 ++--
 sc/source/core/data/table2.cxx |8 +
 sc/source/core/tool/token.cxx  |   36 
 sc/source/filter/excel/excform.cxx |  141 +++--
 sc/source/filter/excel/impop.cxx   |2 
 sc/source/filter/excel/namebuff.cxx|   97 ++
 sc/source/filter/excel/read.cxx|2 
 sc/source/filter/inc/excform.hxx   |2 
 sc/source/filter/inc/namebuff.hxx  |   35 +++-
 sc/source/filter/inc/root.hxx  |4 
 19 files changed, 294 insertions(+), 203 deletions(-)

New commits:
commit c12146c1c0614b9ddd55ec5bed458e581369af16
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Aug 6 00:15:10 2013 -0400

Map shared formula from xls to formula groups, and share the tokens as well.

No more mapping to range names.

Change-Id: Ic43b6ef35a91fe4d6fff748ebc22969ba4e036db

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 045b76a..22bb9bd 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -275,6 +275,7 @@ public:
  */
 ScFormulaCell* SetFormulaCell( SCROW nRow, ScFormulaCell* pCell );
 ScFormulaCell* SetFormulaCell( sc::ColumnBlockPosition rBlockPos, SCROW 
nRow, ScFormulaCell* pCell );
+bool SetGroupFormulaCell( SCROW nRow, ScFormulaCell* pCell );
 
 void SetRawString( SCROW nRow, const OUString rStr, bool bBroadcast = 
true );
 void SetRawString( sc::ColumnBlockPosition rBlockPos, SCROW nRow, const 
OUString rStr, bool bBroadcast = true );
@@ -507,8 +508,8 @@ private:
 
 sc::CellStoreType::iterator GetPositionToInsert( SCROW nRow );
 sc::CellStoreType::iterator GetPositionToInsert( const 
sc::CellStoreType::iterator it, SCROW nRow );
-void ActivateNewFormulaCell( const sc::CellStoreType::iterator itPos, 
SCROW nRow, ScFormulaCell rCell );
-void ActivateNewFormulaCell( const sc::CellStoreType::position_type aPos, 
ScFormulaCell rCell );
+void ActivateNewFormulaCell( const sc::CellStoreType::iterator itPos, 
SCROW nRow, ScFormulaCell rCell, bool bJoin = true );
+void ActivateNewFormulaCell( const sc::CellStoreType::position_type aPos, 
ScFormulaCell rCell, bool bJoin = true );
 void BroadcastNewCell( SCROW nRow );
 bool UpdateScriptType( sc::CellTextAttr rAttr, SCROW nRow );
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 90e0148..8b82fb7 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -804,6 +804,7 @@ public:
  * is deleted automatically on failure to insert.
  */
 SC_DLLPUBLIC ScFormulaCell* SetFormulaCell( const ScAddress rPos, 
ScFormulaCell* pCell );
+SC_DLLPUBLIC bool SetGroupFormulaCell( const ScAddress rPos, 
ScFormulaCell* pCell );
 
 SC_DLLPUBLIC void InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
 SCCOL nCol2, SCROW nRow2,
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 6480056..f857aff 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -27,6 +27,7 @@
 #include types.hxx
 
 #include set
+#include boost/noncopyable.hpp
 
 namespace sc {
 
@@ -43,7 +44,7 @@ class ScProgress;
 class ScTokenArray;
 struct ScSimilarFormulaDelta;
 
-struct SC_DLLPUBLIC ScFormulaCellGroup
+struct SC_DLLPUBLIC ScFormulaCellGroup : boost::noncopyable
 {
 mutable size_t mnRefCount;
 
@@ -55,6 +56,8 @@ struct SC_DLLPUBLIC ScFormulaCellGroup
 
 ScFormulaCellGroup();
 ~ScFormulaCellGroup();
+
+void setCode( const ScTokenArray rCode );
 };
 
 inline void intrusive_ptr_add_ref(const ScFormulaCellGroup *p)
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 37c1430..a95f2bc 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -340,6 +340,7 @@ public:
  * is deleted automatically on failure to insert.
  */
 ScFormulaCell* SetFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* 
pCell );
+bool SetGroupFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell );
 
 voidSetValue( SCCOL nCol, SCROW nRow, const double rVal );
 voidSetError( SCCOL nCol, SCROW nRow, sal_uInt16 nError);
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index f9a4ff1..09a9798 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -62,6 +62,12 @@ public:
 
 ScFormulaVectorState GetVectorState() const;
 
+/**
+ * If the array contains at least one relative row reference or named
+ * expression, it's variant. Otherwise invariant.
+ */
+

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 3 commits - sc/inc sc/qa sc/source

2013-07-26 Thread Kohei Yoshida
 sc/inc/document.hxx   |2 
 sc/qa/unit/data/ods/fdo62729.ods  |binary
 sc/qa/unit/data/xls/inline-array.xls  |binary
 sc/qa/unit/subsequent_export-test.cxx |   83 ++
 sc/source/filter/xml/xmlexprt.cxx |1 
 5 files changed, 85 insertions(+), 1 deletion(-)

New commits:
commit 5300d19c19e3ee5cb8f55cf3f104d4b046041c1c
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri Jul 26 11:50:30 2013 -0400

Add export test for exporting inline arrays to xls format.

Change-Id: I8f6e32adcbd33362f20eca3ce329633bf9fbf039

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 09f0874..39334ee 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -566,7 +566,7 @@ public:
 SCCOL nEndCol, SCROW nEndRow,
 const ScMarkData rMark ) const;
 
-boolGetMatrixFormulaRange( const ScAddress rCellPos, ScRange 
rMatrix );
+SC_DLLPUBLIC bool GetMatrixFormulaRange( const ScAddress rCellPos, 
ScRange rMatrix );
 
 boolIsEmbedded() const;
 voidGetEmbedded( ScRange rRange ) const;
diff --git a/sc/qa/unit/data/xls/inline-array.xls 
b/sc/qa/unit/data/xls/inline-array.xls
new file mode 100644
index 000..64574f8
Binary files /dev/null and b/sc/qa/unit/data/xls/inline-array.xls differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 600bc5a..ad7a514 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -26,6 +26,7 @@
 #include scitems.hxx
 #include document.hxx
 #include cellform.hxx
+#include formulacell.hxx
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -51,6 +52,8 @@ public:
 void testMiscRowHeightExport();
 void testNamedRangeBugfdo62729();
 
+void testInlineArrayXLS();
+
 CPPUNIT_TEST_SUITE(ScExportTest);
 CPPUNIT_TEST(test);
 #if !defined(MACOSX)  !defined(DRAGONFLY)
@@ -62,6 +65,7 @@ public:
 CPPUNIT_TEST(testColorScaleExportXLSX);
 CPPUNIT_TEST(testMiscRowHeightExport);
 CPPUNIT_TEST(testNamedRangeBugfdo62729);
+CPPUNIT_TEST(testInlineArrayXLS);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -319,6 +323,55 @@ void ScExportTest::testNamedRangeBugfdo62729()
 xDocSh-DoClose();
 }
 
+namespace {
+
+void checkMatrixRange(ScDocument rDoc, const ScRange rRange)
+{
+ScRange aMatRange;
+ScAddress aMatOrigin;
+for (SCCOL nCol = rRange.aStart.Col(); nCol = rRange.aEnd.Col(); ++nCol)
+{
+for (SCROW nRow = rRange.aStart.Row(); nRow = rRange.aEnd.Row(); 
++nRow)
+{
+ScAddress aPos(nCol, nRow, rRange.aStart.Tab());
+bool bIsMatrix = rDoc.GetMatrixFormulaRange(aPos, aMatRange);
+CPPUNIT_ASSERT_MESSAGE(Matrix expected, but not found., 
bIsMatrix);
+CPPUNIT_ASSERT_MESSAGE(Wrong matrix range., rRange == aMatRange);
+const ScFormulaCell* pCell = rDoc.GetFormulaCell(aPos);
+CPPUNIT_ASSERT_MESSAGE(This must be a formula cell., pCell);
+
+bIsMatrix = pCell-GetMatrixOrigin(aMatOrigin);
+CPPUNIT_ASSERT_MESSAGE(Not a part of matrix formula., bIsMatrix);
+CPPUNIT_ASSERT_MESSAGE(Wrong matrix origin., aMatOrigin == 
aMatRange.aStart);
+}
+}
+}
+
+}
+
+void ScExportTest::testInlineArrayXLS()
+{
+ScDocShellRef xShell = loadDoc(inline-array., XLS);
+CPPUNIT_ASSERT(xShell.Is());
+
+ScDocShellRef xDocSh = saveAndReload(xShell, XLS);
+CPPUNIT_ASSERT(xDocSh.Is());
+
+ScDocument* pDoc = xDocSh-GetDocument();
+CPPUNIT_ASSERT(pDoc);
+
+// B2:C3 contains a matrix.
+checkMatrixRange(*pDoc, ScRange(1,1,0,2,2,0));
+
+// B5:D6 contains a matrix.
+checkMatrixRange(*pDoc, ScRange(1,4,0,3,5,0));
+
+// B8:C10 as well.
+checkMatrixRange(*pDoc, ScRange(1,7,0,2,9,0));
+
+xDocSh-DoClose();
+}
+
 ScExportTest::ScExportTest()
   : ScBootstrapFixture(/sc/qa/unit/data)
 {
commit b7df19862d6fbf4d05950540bd49885813312ec7
Author: Noel Power noel.po...@suse.com
Date:   Fri Jul 26 13:13:37 2013 +0100

unit test for fdo#62729

Change-Id: Ib9be75459aa49b8bab968dedae9e0760ccef9a26

diff --git a/sc/qa/unit/data/ods/fdo62729.ods b/sc/qa/unit/data/ods/fdo62729.ods
new file mode 100644
index 000..00b5079
Binary files /dev/null and b/sc/qa/unit/data/ods/fdo62729.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 05b0c35..600bc5a 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -49,6 +49,7 @@ public:
 void testDataBarExportODS();
 void testDataBarExportXLSX();
 void testMiscRowHeightExport();
+void testNamedRangeBugfdo62729();
 
 CPPUNIT_TEST_SUITE(ScExportTest);
 CPPUNIT_TEST(test);
@@ -60,6 +61,7 @@ public:
 CPPUNIT_TEST(testColorScaleExportODS);
 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 3 commits - sc/inc sc/qa sc/source

2013-07-25 Thread Kohei Yoshida
 sc/inc/calcmacros.hxx|2 
 sc/inc/tokenarray.hxx|2 
 sc/qa/unit/ucalc.cxx |4 -
 sc/qa/unit/ucalc_formula.cxx |   37 ++---
 sc/source/core/data/conditio.cxx |   32 +++
 sc/source/core/data/documen4.cxx |2 
 sc/source/core/data/formulacell.cxx  |   41 ++-
 sc/source/core/tool/compiler.cxx |6 +-
 sc/source/core/tool/token.cxx|   66 ++--
 sc/source/filter/excel/excform.cxx   |   32 +--
 sc/source/filter/excel/excform8.cxx  |   32 +--
 sc/source/filter/excel/xeformula.cxx |   26 +++-
 sc/source/filter/excel/xelink.cxx|   12 ++---
 sc/source/filter/lotus/lotform.cxx   |4 -
 sc/source/filter/lotus/tool.cxx  |6 --
 sc/source/ui/unoobj/tokenuno.cxx |   72 +++
 16 files changed, 234 insertions(+), 142 deletions(-)

New commits:
commit 7f78d759afc1cd05f25b37ee994b649351dad9dc
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Jul 25 15:59:00 2013 -0400

Re-work reference update on sheet insertion  fix one bug on sheet deletion.

Change-Id: I1405eb54c3c530e2c22be1f1d7728fa0d84ad447

diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 2ae6c90..1e8ced1 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -143,6 +143,8 @@ public:
  */
 bool AdjustReferenceOnDeletedTab( SCTAB nDelPos, SCTAB nSheets, const 
ScAddress rOldPos );
 
+bool AdjustReferenceOnInsertedTab( SCTAB nInsPos, SCTAB nSheets, const 
ScAddress rOldPos );
+
 #if DEBUG_FORMULA_COMPILER
 void Dump() const;
 #endif
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 6407b72..531d1d3 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -765,12 +765,12 @@ void Test::testFormulaRefUpdateSheets()
 
 // Set formulas to B2 and B3 on sheet Sheet2.
 m_pDoc-SetString(ScAddress(1,1,1), =SUM(Sheet1.B2:C3));
-m_pDoc-SetString(ScAddress(1,2,1), =SUM(Sheet1.$B$2:$C$3));
+m_pDoc-SetString(ScAddress(1,2,1), =SUM($Sheet1.$B$2:$C$3));
 
 if (!checkFormula(*m_pDoc, ScAddress(1,1,1), SUM(Sheet1.B2:C3)))
 CPPUNIT_FAIL(Wrong formula in Sheet2.B2.);
 
-if (!checkFormula(*m_pDoc, ScAddress(1,2,1), SUM(Sheet1.$B$2:$C$3)))
+if (!checkFormula(*m_pDoc, ScAddress(1,2,1), SUM($Sheet1.$B$2:$C$3)))
 CPPUNIT_FAIL(Wrong formula in Sheet2.B3.);
 
 // Swap the sheets.
@@ -783,7 +783,7 @@ void Test::testFormulaRefUpdateSheets()
 if (!checkFormula(*m_pDoc, ScAddress(1,1,0), SUM(Sheet1.B2:C3)))
 CPPUNIT_FAIL(Wrong formula in Sheet2.B2.);
 
-if (!checkFormula(*m_pDoc, ScAddress(1,2,0), SUM(Sheet1.$B$2:$C$3)))
+if (!checkFormula(*m_pDoc, ScAddress(1,2,0), SUM($Sheet1.$B$2:$C$3)))
 CPPUNIT_FAIL(Wrong formula in Sheet2.B3.);
 
 // Swap back.
@@ -796,7 +796,7 @@ void Test::testFormulaRefUpdateSheets()
 if (!checkFormula(*m_pDoc, ScAddress(1,1,1), SUM(Sheet1.B2:C3)))
 CPPUNIT_FAIL(Wrong formula in Sheet2.B2.);
 
-if (!checkFormula(*m_pDoc, ScAddress(1,2,1), SUM(Sheet1.$B$2:$C$3)))
+if (!checkFormula(*m_pDoc, ScAddress(1,2,1), SUM($Sheet1.$B$2:$C$3)))
 CPPUNIT_FAIL(Wrong formula in Sheet2.B3.);
 
 // Insert a new sheet between the two.
@@ -810,7 +810,7 @@ void Test::testFormulaRefUpdateSheets()
 if (!checkFormula(*m_pDoc, ScAddress(1,1,2), SUM(Sheet1.B2:C3)))
 CPPUNIT_FAIL(Wrong formula in Sheet2.B2.);
 
-if (!checkFormula(*m_pDoc, ScAddress(1,2,2), SUM(Sheet1.$B$2:$C$3)))
+if (!checkFormula(*m_pDoc, ScAddress(1,2,2), SUM($Sheet1.$B$2:$C$3)))
 CPPUNIT_FAIL(Wrong formula in Sheet2.B3.);
 
 // Delete the temporary sheet.
@@ -822,7 +822,30 @@ void Test::testFormulaRefUpdateSheets()
 if (!checkFormula(*m_pDoc, ScAddress(1,1,1), SUM(Sheet1.B2:C3)))
 CPPUNIT_FAIL(Wrong formula in Sheet2.B2.);
 
-if (!checkFormula(*m_pDoc, ScAddress(1,2,1), SUM(Sheet1.$B$2:$C$3)))
+if (!checkFormula(*m_pDoc, ScAddress(1,2,1), SUM($Sheet1.$B$2:$C$3)))
+CPPUNIT_FAIL(Wrong formula in Sheet2.B3.);
+
+// Insert a new sheet before the first one.
+m_pDoc-InsertTab(0, Temp);
+
+m_pDoc-GetName(1, aName);
+CPPUNIT_ASSERT_EQUAL(OUString(Sheet1), aName);
+m_pDoc-GetName(2, aName);
+CPPUNIT_ASSERT_EQUAL(OUString(Sheet2), aName);
+
+if (!checkFormula(*m_pDoc, ScAddress(1,1,2), SUM(Sheet1.B2:C3)))
+CPPUNIT_FAIL(Wrong formula in Sheet2.B2.);
+
+if (!checkFormula(*m_pDoc, ScAddress(1,2,2), SUM($Sheet1.$B$2:$C$3)))
+CPPUNIT_FAIL(Wrong formula in Sheet2.B3.);
+
+// Delete the temporary sheet.
+m_pDoc-DeleteTab(0);
+
+if (!checkFormula(*m_pDoc, ScAddress(1,1,1), SUM(Sheet1.B2:C3)))
+CPPUNIT_FAIL(Wrong formula in Sheet2.B2.);
+
+if (!checkFormula(*m_pDoc, ScAddress(1,2,1), SUM($Sheet1.$B$2:$C$3)))
 CPPUNIT_FAIL(Wrong formula in Sheet2.B3.);
 
  

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 3 commits - sc/inc sc/qa sc/source

2013-07-23 Thread Kohei Yoshida
 sc/inc/tokenarray.hxx   |3 +
 sc/qa/unit/ucalc.hxx|2 
 sc/qa/unit/ucalc_formula.cxx|   73 
 sc/source/core/data/formulacell.cxx |   22 --
 sc/source/core/tool/token.cxx   |   52 +
 5 files changed, 139 insertions(+), 13 deletions(-)

New commits:
commit a62b7f10ec1fddd7d2bd6517dec75a617aaa12be
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Jul 23 22:33:27 2013 -0400

Re-implement adjusting of references on move.

Change-Id: I52a8b78ed072eb6bcd86b4f80936a869046cbc4d

diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 5ff7da0..2ae6c90 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -129,6 +129,9 @@ public:
  */
 sc::RefUpdateResult AdjustReferenceOnShift( const sc::RefUpdateContext 
rCxt, const ScAddress rOldPos );
 
+sc::RefUpdateResult AdjustReferenceOnMove(
+const sc::RefUpdateContext rCxt, const ScAddress rOldPos, const 
ScAddress rNewPos );
+
 /**
  * Adjust all references on sheet deletion.
  *
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 63d2c9b..725c5d9 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2365,7 +2365,6 @@ bool ScFormulaCell::UpdateReferenceOnMove(
 aOldPos.Set(aPos.Col() - rCxt.mnColDelta, aPos.Row() - 
rCxt.mnRowDelta, aPos.Tab() - rCxt.mnTabDelta);
 }
 
-
 // Check presence of any references or column row names.
 pCode-Reset();
 bool bHasRefs = (pCode-GetNextReferenceRPN() != NULL);
@@ -2389,22 +2388,19 @@ bool ScFormulaCell::UpdateReferenceOnMove(
 pOldCode.reset(pCode-Clone());
 
 bool bValChanged = false;
-bool bRangeModified = false;// any range, not only shared formula
+bool bRefModified = false;
 bool bRefSizeChanged = false;
 
 if (bHasRefs)
 {
 // Update cell or range references.
-ScCompiler aComp(pDocument, aPos, *pCode);
-aComp.SetGrammar(pDocument-GetGrammar());
-aComp.UpdateReference(
-URM_MOVE, aOldPos, rCxt.maRange,
-rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta,
-bValChanged, bRefSizeChanged);
-bRangeModified = aComp.HasModifiedRange();
+sc::RefUpdateResult aRes = pCode-AdjustReferenceOnMove(rCxt, aOldPos, 
aPos);
+bRefModified = aRes.mbReferenceModified;
+bValChanged = aRes.mbValueChanged;
 }
 
-bCellStateChanged |= bValChanged;
+if (bValChanged || bRefModified)
+bCellStateChanged = true;
 
 if (bOnRefMove)
 // Cell may reference itself, e.g. ocColumn, ocRow without parameter
@@ -2429,7 +2425,7 @@ bool ScFormulaCell::UpdateReferenceOnMove(
 bHasRelName = HasRelNameReference();
 // Reference changed and new listening needed?
 // Except in Insert/Delete without specialties.
-bNewListening = (bRangeModified || bColRowNameCompile
+bNewListening = (bRefModified || bColRowNameCompile
 || bValChanged || bHasRelName)
 // #i36299# Don't duplicate action during cutpaste / dragdrop
 // on a cell in the range moved, start/end listeners is done
@@ -2442,7 +2438,7 @@ bool ScFormulaCell::UpdateReferenceOnMove(
 
 bool bNeedDirty = false;
 // NeedDirty for changes except for Copy and Move/Insert without RelNames
-if ( bRangeModified || bColRowNameCompile ||
+if ( bRefModified || bColRowNameCompile ||
  (bValChanged  bHasRelName  (bHasRelName || bInDeleteUndo || 
bRefSizeChanged)) || bOnRefMove)
 bNeedDirty = true;
 
@@ -2451,7 +2447,7 @@ bool ScFormulaCell::UpdateReferenceOnMove(
 
 bValChanged = false;
 
-if ( ( bCompile = (bCompile || bValChanged || bRangeModified || 
bColRowNameCompile) ) != 0 )
+if ( ( bCompile = (bCompile || bValChanged || bRefModified || 
bColRowNameCompile) ) != 0 )
 {
 CompileTokenArray( bNewListening ); // no Listening
 bNeedDirty = true;
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 64beedf..b783525 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2472,6 +2472,58 @@ sc::RefUpdateResult 
ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon
 return aRes;
 }
 
+sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
+const sc::RefUpdateContext rCxt, const ScAddress rOldPos, const 
ScAddress rNewPos )
+{
+// When moving, the range is the destination range. We need to use the old
+// range prior to the move for hit analysis.
+ScRange aOldRange = rCxt.maRange;
+aOldRange.Move(-rCxt.mnColDelta, -rCxt.mnRowDelta, -rCxt.mnTabDelta);
+
+sc::RefUpdateResult aRes;
+
+FormulaToken** p = pCode;
+FormulaToken** pEnd = p + static_castsize_t(nLen);
+for (; p != pEnd; ++p)
+{
+switch ((*p)-GetType())
+{
+ 

[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 3 commits - sc/inc sc/qa sc/source

2013-06-21 Thread Kohei Yoshida
 sc/inc/column.hxx   |   10 ---
 sc/qa/extras/testdocuments/Ranges-3.xls |binary
 sc/source/core/data/column.cxx  |   93 
 sc/source/core/data/column2.cxx |   18 +-
 sc/source/core/data/column3.cxx |8 +-
 sc/source/core/data/formulacell.cxx |   17 -
 6 files changed, 72 insertions(+), 74 deletions(-)

New commits:
commit ea5a4946c7be75eb9fa6dab62c0bb6a14887adae
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri Jun 21 11:54:18 2013 -0400

Avoid having formula cell directly update text attributes.

This would cause column cell and text attribute arrays to go out of
sync, because the formula cells may be stored and interpreted in places
such as change track and conditional formatting.

We still need to find a good way to mark text attributes obsolete when
formula cells are re-calculated.

Change-Id: Ida612806d3afec23c5ae501f2fc8cc7d52e019a8

diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 845fa33..3ce95d4 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -728,11 +728,8 @@ void ScFormulaCell::Compile( const OUString rFormula, 
bool bNoListening,
 CompileTokenArray( bNoListening );
 }
 else
-{
 bChanged = true;
-pDocument-SetTextWidth(aPos, TEXTWIDTH_DIRTY);
-pDocument-SetScriptType(aPos, SC_SCRIPTTYPE_UNKNOWN);
-}
+
 if ( bWasInFormulaTree )
 pDocument-PutInFormulaTree( this );
 }
@@ -822,11 +819,7 @@ void ScFormulaCell::CompileXML( ScProgress rProgress )
 pDocument-AddSubTotalCell(this);
 }
 else
-{
 bChanged = true;
-pDocument-SetTextWidth(aPos, TEXTWIDTH_DIRTY);
-pDocument-SetScriptType(aPos, SC_SCRIPTTYPE_UNKNOWN);
-}
 
 //  Same as in Load: after loading, it must be known if ocMacro is in any 
formula
 //  (for macro warning, CompileXML is called at the end of loading XML 
file)
@@ -1096,8 +1089,6 @@ void ScFormulaCell::Interpret()
 pIterCell-bTableOpDirty = false;
 pIterCell-aResult.SetResultError( 
errNoConvergence);
 pIterCell-bChanged = true;
-pDocument-SetTextWidth(pIterCell-aPos, 
TEXTWIDTH_DIRTY);
-pDocument-SetScriptType(pIterCell-aPos, 
SC_SCRIPTTYPE_UNKNOWN);
 }
 }
 // End this iteration and remove entries.
@@ -1389,11 +1380,7 @@ void ScFormulaCell::InterpretTail( 
ScInterpretTailParameter eTailParam )
 aResult.SetResultError( nErr);
 bChanged = bContentChanged = true;
 }
-if( bChanged )
-{
-pDocument-SetTextWidth(aPos, TEXTWIDTH_DIRTY);
-pDocument-SetScriptType(aPos, SC_SCRIPTTYPE_UNKNOWN);
-}
+
 if (bContentChanged  pDocument-IsStreamValid(aPos.Tab()))
 {
 // pass bIgnoreLock=true, because even if called from pending row 
height update,
commit d0c5ec0220f5dd8fe5285709ae5d6165e6a3027f
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri Jun 21 10:57:35 2013 -0400

Add more calls to CellStorageModified() when it's called for.

Change-Id: Ib7a7abd82060b19f7911f1fef5ff5d850055

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index e287a5b..e7c58c1 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -464,7 +464,7 @@ private:
 sc::CellStoreType::iterator GetPositionToInsert( const 
sc::CellStoreType::iterator it, SCROW nRow );
 void ActivateNewFormulaCell( ScFormulaCell* pCell );
 void BroadcastNewCell( SCROW nRow );
-void UpdateScriptType( sc::CellTextAttr rAttr, SCROW nRow );
+bool UpdateScriptType( sc::CellTextAttr rAttr, SCROW nRow );
 
 const ScFormulaCell* FetchFormulaCell( SCROW nRow ) const;
 
@@ -476,7 +476,7 @@ private:
  * Called whenever the state of cell array gets modified i.e. new cell
  * insertion, cell removal or relocation, cell value update and so on.
  *
- * Call this only from those methods where maItems is modified directly.
+ * Call this only from those methods where maCells is modified directly.
  */
 void CellStorageModified();
 
diff --git a/sc/qa/extras/testdocuments/Ranges-3.xls 
b/sc/qa/extras/testdocuments/Ranges-3.xls
index c23b70a..5151fa7 100644
Binary files a/sc/qa/extras/testdocuments/Ranges-3.xls and 
b/sc/qa/extras/testdocuments/Ranges-3.xls differ
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 66166be..bd1eeae 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1369,6 +1369,8 @@ void ScColumn::CopyStaticToDocument(SCROW nRow1, SCROW 
nRow2, ScColumn rDestCol
 if (bLastBlock)
 break;
 }
+
+rDestCol.CellStorageModified();
 }
 
 void