[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2013-01-30 Thread Libreoffice Gerrit user
 sc/qa/unit/data/ods/miscemptyrepeatedrowheights.ods |binary
 sc/qa/unit/data/xlsx/miscrowheights.xlsx|binary
 sc/qa/unit/subsequent_export-test.cxx   |   74 ++
 sc/source/filter/excel/xetable.cxx  |   81 ++--
 sc/source/filter/inc/xetable.hxx|4 
 5 files changed, 138 insertions(+), 21 deletions(-)

New commits:
commit b75bf09a5b905a3ed9c251869983a400c70c7fc6
Author: Noel Power noel.po...@suse.com
Date:   Tue Jan 29 14:51:49 2013 +

correctly handle repeated row heights for empty rows ( fdo#59973 )

it seems both xls  xlsx export suffer from problems with multiple row 
heights
repeated ( if those rows are empty )

Change-Id: I3ed68a81517a3e55d1de1954fcb99e7cb39be337

diff --git a/sc/qa/unit/data/ods/miscemptyrepeatedrowheights.ods 
b/sc/qa/unit/data/ods/miscemptyrepeatedrowheights.ods
new file mode 100644
index 000..5511ad9
Binary files /dev/null and 
b/sc/qa/unit/data/ods/miscemptyrepeatedrowheights.ods differ
diff --git a/sc/qa/unit/data/xlsx/miscrowheights.xlsx 
b/sc/qa/unit/data/xlsx/miscrowheights.xlsx
new file mode 100755
index 000..dbdbc13
Binary files /dev/null and b/sc/qa/unit/data/xlsx/miscrowheights.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 7b0fde8..05c4873 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -77,6 +77,7 @@ public:
 void test();
 void testPasswordExport();
 void testConditionalFormatExportXLSX();
+void testMiscRowHeightExport();
 
 CPPUNIT_TEST_SUITE(ScExportTest);
 CPPUNIT_TEST(test);
@@ -84,6 +85,7 @@ public:
 CPPUNIT_TEST(testPasswordExport);
 #endif
 CPPUNIT_TEST(testConditionalFormatExportXLSX);
+CPPUNIT_TEST(testMiscRowHeightExport);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -297,6 +299,78 @@ void ScExportTest::testConditionalFormatExportXLSX()
 testCondFile(aCSVPath, pDoc, 0);
 }
 
+void ScExportTest::testMiscRowHeightExport()
+{
+
+struct TestParam
+{
+struct RowData
+{
+SCROW nStartRow;
+SCROW nEndRow;
+SCTAB nTab;
+int nExpectedHeight;
+};
+const char* sTestDoc;
+int nImportType;
+int nExportType;
+int nRowData;
+RowData* pData;
+};
+
+TestParam::RowData DfltRowData[] =
+{
+{ 0, 4, 0, 529 },
+{ 5, 10, 0, 1058 },
+{ 17, 20, 0, 1767 },
+{ 1048573, 1048575, 0, 529 },
+};
+
+TestParam::RowData EmptyRepeatRowData[] =
+{
+{ 0, 4, 0, 529 },
+{ 5, 10, 0, 1058 },
+{ 17, 20, 0, 1767 },
+};
+
+TestParam aTestValues[] =
+{
+{ miscrowheights., XLSX, XLSX, SAL_N_ELEMENTS(DfltRowData), 
DfltRowData },
+{ miscrowheights., XLSX, XLS, SAL_N_ELEMENTS(DfltRowData), 
DfltRowData },
+{ miscemptyrepeatedrowheights., ODS, XLSX, 
SAL_N_ELEMENTS(EmptyRepeatRowData), EmptyRepeatRowData },
+{ miscemptyrepeatedrowheights., ODS, XLS, 
SAL_N_ELEMENTS(EmptyRepeatRowData), EmptyRepeatRowData },
+};
+
+for ( unsigned int index=0; indexSAL_N_ELEMENTS(aTestValues); ++index )
+{
+OUString sFileName = OUString::createFromAscii( aTestValues[ index 
].sTestDoc );
+printf(aTestValues[%d] %s\n, index, OUStringToOString( sFileName, 
RTL_TEXTENCODING_UTF8 ).getStr() );
+int nImportType =  aTestValues[ index ].nImportType;
+int nExportType =  aTestValues[ index ].nExportType;
+ScDocShellRef xShell = loadDocument( sFileName, nImportType );
+CPPUNIT_ASSERT(xShell.Is());
+
+ScDocShellRef xDocSh = saveAndReload((*xShell), nExportType );
+CPPUNIT_ASSERT(xDocSh.Is());
+
+ScDocument* pDoc = xDocSh-GetDocument();
+
+for (int i=0; iaTestValues[ index ].nRowData; ++i)
+{
+SCROW nRow = aTestValues[ index ].pData[ i].nStartRow;
+SCROW nEndRow = aTestValues[ index ].pData[ i ].nEndRow;
+SCTAB nTab = aTestValues[ index ].pData[ i ].nTab;
+int nExpectedHeight = aTestValues[ index ].pData[ i 
].nExpectedHeight;
+for ( ; nRow = nEndRow; ++nRow )
+{
+printf(\t checking row %d for height %d\n, nRow, 
nExpectedHeight );
+int nHeight = sc::TwipsToHMM( pDoc-GetRowHeight(nRow, nTab, 
false) );
+CPPUNIT_ASSERT_EQUAL(nExpectedHeight, nHeight);
+}
+}
+}
+}
+
 ScExportTest::ScExportTest()
   : m_aBaseString(RTL_CONSTASCII_USTRINGPARAM(/sc/qa/unit/data))
 {
diff --git a/sc/source/filter/excel/xetable.cxx 
b/sc/source/filter/excel/xetable.cxx
index 178acd9..c44b32c 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -1709,6 +1709,7 @@ XclExpRow::XclExpRow( const XclExpRoot rRoot, sal_uInt32 
nXclRow,
 mnXFIndex( EXC_XF_DEFAULTCELL 

[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2013-01-23 Thread Libreoffice Gerrit user
 sc/qa/unit/subsequent_filters-test.cxx |4 ++--
 sc/source/core/tool/formularesult.cxx  |6 ++
 2 files changed, 4 insertions(+), 6 deletions(-)

New commits:
commit b1d0fd4f969976e2133f8eaa37c1fb8360c20f68
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Thu Jan 24 01:18:59 2013 +0100

small improvement of the code

Change-Id: I2ac599fa2897dc4fe3256b50300cb467c647e320

diff --git a/sc/source/core/tool/formularesult.cxx 
b/sc/source/core/tool/formularesult.cxx
index 9139c9a..9602c44 100644
--- a/sc/source/core/tool/formularesult.cxx
+++ b/sc/source/core/tool/formularesult.cxx
@@ -268,9 +268,8 @@ bool ScFormulaResult::IsEmptyDisplayedAsString() const
 bool ScFormulaResult::IsValue() const
 {
 formula::StackVar sv = GetCellResultType();
-if( sv == formula::svHybridValueCell )
-return true;
-return sv == formula::svDouble || sv == formula::svError || sv == 
formula::svEmptyCell;
+return sv == formula::svDouble || sv == formula::svError
+|| sv == formula::svEmptyCell || sv == formula::svHybridValueCell;
 }
 
 bool ScFormulaResult::IsMultiline() const
@@ -335,7 +334,6 @@ double ScFormulaResult::GetDouble() const
 case formula::svHybridCell:
 case formula::svHybridValueCell:
 return mpToken-GetDouble();
-return mpToken-GetDouble();
 case formula::svMatrixCell:
 {
 const ScMatrixCellResultToken* p =
commit 0ab1b83271e8e0d1ee9fa2ade4bd1dda63c5f5f3
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Thu Jan 24 01:18:25 2013 +0100

disable these two tests for now

Change-Id: I579694780b64e532b0e61017783bc4e72f8d2936

diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 72dabde..d934ce9 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -184,8 +184,8 @@ public:
 CPPUNIT_TEST(testHardRecalcODS);
 CPPUNIT_TEST(testFunctionsODS);
 CPPUNIT_TEST(testCachedFormulaResultsODS);
-CPPUNIT_TEST(testVolatileFunctionsODS);
-CPPUNIT_TEST(testCachedMatrixFormulaResultsODS);
+//CPPUNIT_TEST(testVolatileFunctionsODS);
+//CPPUNIT_TEST(testCachedMatrixFormulaResultsODS);
 CPPUNIT_TEST(testDatabaseRangesODS);
 CPPUNIT_TEST(testDatabaseRangesXLS);
 CPPUNIT_TEST(testDatabaseRangesXLSX);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2013-01-04 Thread Libreoffice Gerrit user
 sc/qa/unit/subsequent_filters-test.cxx |2 +-
 sc/source/filter/xml/xmlrowi.cxx   |7 ---
 sc/source/filter/xml/xmlrowi.hxx   |2 --
 3 files changed, 1 insertion(+), 10 deletions(-)

New commits:
commit 3e102b36977a62931b0de4176bcd92a307408d8b
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Sat Jan 5 00:18:21 2013 +0100

enable the unit test

diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 5acbfb8..618e627 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -213,7 +213,7 @@ public:
 CPPUNIT_TEST(testCellAnchoredShapesODS);
 
 CPPUNIT_TEST(testPivotTableBasicODS);
-//  CPPUNIT_TEST(testRowHeight);
+CPPUNIT_TEST(testRowHeight);
 CPPUNIT_TEST(testFormulaDependency);
 
 //disable testPassword on MacOSX due to problems with libsqlite3
commit 9ddd869873603f929d7c342d62a8d52d19de83ec
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Sat Jan 5 00:14:47 2013 +0100

Revert workaround problems with row import, fdo#58539

This reverts commit 119483d9b0af6b4830733161fcf56cea10ed01d7.

diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx
index a4434e1..ec4c5a5 100644
--- a/sc/source/filter/xml/xmlrowi.cxx
+++ b/sc/source/filter/xml/xmlrowi.cxx
@@ -98,7 +98,6 @@ ScXMLTableRowContext::ScXMLTableRowContext( ScXMLImport 
rImport,
 break;*/
 }
 }
-mnLastRow = GetScImport().GetTables().GetCurrentRow() + nRepeatedRows;
 GetScImport().GetTables().AddRow();
 GetScImport().GetTables().SetRowStyle(sCellStyleName);
 }
@@ -156,12 +155,6 @@ void ScXMLTableRowContext::EndElement()
 }
 SCTAB nSheet = rXMLImport.GetTables().GetCurrentSheet();
 sal_Int32 nCurrentRow(rXMLImport.GetTables().GetCurrentRow());
-if(nCurrentRow != mnLastRow)
-{
-// this document is most likely invalid in some way
-SAL_WARN(sc, we did not generate enough rows in the cell import!!);
-nCurrentRow = mnLastRow;
-}
 uno::Referencesheet::XSpreadsheet 
xSheet(rXMLImport.GetTables().GetCurrentXSheet());
 if(xSheet.is())
 {
diff --git a/sc/source/filter/xml/xmlrowi.hxx b/sc/source/filter/xml/xmlrowi.hxx
index 02c5255..a900ff7 100644
--- a/sc/source/filter/xml/xmlrowi.hxx
+++ b/sc/source/filter/xml/xmlrowi.hxx
@@ -29,8 +29,6 @@ class ScXMLTableRowContext : public SvXMLImportContext
 rtl::OUString sStyleName;
 rtl::OUString sVisibility;
 sal_Int32 nRepeatedRows;
-sal_Int32 mnLastRow; // to workaround problems with the cell import, can 
be removed when the cell
-// always adds enough rows
 bool bHasCell;
 
 const ScXMLImport GetScImport() const { return (const 
ScXMLImport)GetImport(); }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-12-25 Thread Libreoffice Gerrit user
 sc/qa/unit/rangelst_test.cxx |   33 +
 sc/source/core/data/conditio.cxx |5 -
 2 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit ef48f2fd617aad8a19c2d5613db8fa513b2ef455
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Wed Dec 26 04:10:50 2012 +0100

add a unit test for new method in ScRangeList

Change-Id: Id27973cc82c71daffec62cbaccba30777c08612b

diff --git a/sc/qa/unit/rangelst_test.cxx b/sc/qa/unit/rangelst_test.cxx
index b5381ec..62d9002 100644
--- a/sc/qa/unit/rangelst_test.cxx
+++ b/sc/qa/unit/rangelst_test.cxx
@@ -38,6 +38,7 @@ public:
 void testDeleteArea_0Ranges();
 void testJoin_Case1();
 void testJoin_Case2();
+void testGetIntersectedRange();
 
 void testUpdateReference_DeleteRow();
 void testUpdateReference_DeleteCol();
@@ -63,6 +64,7 @@ public:
 CPPUNIT_TEST(testJoin_Case2);
 CPPUNIT_TEST(testUpdateReference_DeleteRow);
 CPPUNIT_TEST(testUpdateReference_DeleteCol);
+CPPUNIT_TEST(testGetIntersectedRange);
 CPPUNIT_TEST_SUITE_END();
 
 
@@ -71,6 +73,30 @@ private:
 ScDocShellRef m_xDocShRef;
 };
 
+namespace {
+
+std::ostream operator(std::ostream rStrm, const ScAddress rAddr)
+{
+rStrm  Col:   rAddr.Col()   Row:   rAddr.Row()   Tab:   
rAddr.Tab()  \n;
+return rStrm;
+}
+
+std::ostream operator(std::ostream rStrm, const ScRange rRange)
+{
+rStrm  ScRange:   rRange.aStart  rRange.aEnd  \n;
+return rStrm;
+}
+
+std::ostream operator(std::ostream rStrm, const ScRangeList rList)
+{
+rStrm  ScRangeList: \n;
+for(size_t i = 0; i  rList.size(); ++i)
+rStrm  *rList[i];
+return rStrm;
+}
+
+}
+
 
 void Test::setUp()
 {
@@ -449,6 +475,13 @@ void Test::testUpdateReference_DeleteCol()
 CPPUNIT_ASSERT_EQUAL(static_castsize_t(12), aList.GetCellCount());
 }
 
+void Test::testGetIntersectedRange()
+{
+ScRangeList aList(ScRange(2, 2, 0, 5, 5, 0));
+ScRangeList aIntersecting = aList.GetIntersectedRange(ScRange(0, 0, 0, 3, 
3, 0));
+CPPUNIT_ASSERT_EQUAL(ScRangeList(ScRange(2,2,0,3,3,0)), aIntersecting);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 7c528f40e0aea9386d175b007974c02d265f96c6
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Wed Dec 26 04:09:31 2012 +0100

one more improvement around cond format rendering, fdo#57896

Change-Id: I5eb267ec2d1666edd53f5b9d58fd2a0cec044aa1

diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 3dcc3be..016c5e9 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1973,7 +1973,10 @@ void ScConditionalFormat::dumpInfo(rtl::OUStringBuffer 
rBuf) const
 void ScConditionalFormat::DoRepaint( const ScRange* pModified )
 {
 if(pModified)
-pDoc-RepaintRange(*pModified);
+{
+if(maRanges.Intersects(*pModified))
+pDoc-RepaintRange(*pModified);
+}
 else
 {
 // all conditional format cells
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-11-08 Thread Libreoffice Gerrit user
 sc/qa/unit/ucalc.cxx |   27 +++
 sc/source/core/tool/interpr5.cxx |6 +++---
 2 files changed, 30 insertions(+), 3 deletions(-)

New commits:
commit 70ec826eeb8f0b311095869e23be1db95fc9d109
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Nov 8 19:50:02 2012 -0500

New unit test to ensure correct matrix creation.

See fdo#56829 for what inspired this test case.

Change-Id: Iee15d85a35ae96769d21ce7061b352860a5b587b

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 5b48f25..0606562 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -125,6 +125,7 @@ public:
 void testNamedRange();
 void testCSV();
 void testMatrix();
+void testEnterMixedMatrix();
 
 /**
  * Basic test for pivot tables.
@@ -250,6 +251,7 @@ public:
 CPPUNIT_TEST(testNamedRange);
 CPPUNIT_TEST(testCSV);
 CPPUNIT_TEST(testMatrix);
+CPPUNIT_TEST(testEnterMixedMatrix);
 CPPUNIT_TEST(testPivotTable);
 CPPUNIT_TEST(testPivotTableLabels);
 CPPUNIT_TEST(testPivotTableDateLabels);
@@ -1513,6 +1515,31 @@ void Test::testMatrix()
 checkMatrixElementsPartiallyFilledEmptyMatrix(*pMat);
 }
 
+void Test::testEnterMixedMatrix()
+{
+m_pDoc-InsertTab(0, foo);
+
+// Insert the source values in A1:B2.
+m_pDoc-SetString(0, 0, 0, A);
+m_pDoc-SetString(1, 0, 0, B);
+double val = 1.0;
+m_pDoc-SetValue(0, 1, 0, val);
+val = 2.0;
+m_pDoc-SetValue(1, 1, 0, val);
+
+// Create a matrix range in A4:B5 referencing A1:B2.
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+m_pDoc-InsertMatrixFormula(0, 3, 1, 4, aMark, =A1:B2, NULL);
+
+CPPUNIT_ASSERT_EQUAL(m_pDoc-GetString(0,0,0), m_pDoc-GetString(0,3,0));
+CPPUNIT_ASSERT_EQUAL(m_pDoc-GetString(1,0,0), m_pDoc-GetString(1,3,0));
+CPPUNIT_ASSERT_EQUAL(m_pDoc-GetValue(0,1,0), m_pDoc-GetValue(0,4,0));
+CPPUNIT_ASSERT_EQUAL(m_pDoc-GetValue(1,1,0), m_pDoc-GetValue(1,4,0));
+
+m_pDoc-DeleteTab(0);
+}
+
 namespace {
 
 struct DPFieldDef
commit 78bf3c9abd4a8cd939e7ba4399ae4aab9f3b2982
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Thu Nov 8 19:49:10 2012 -0500

fdo#56829: Correctly pass element values to matrix.

Change-Id: I20045ae0ddcec228b153c4005855dca9c4ddbfca

diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 46fd6fc..faa0db5 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -453,7 +453,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const 
FormulaToken* pToken
 nGlobalError = 0;
 }
 
-if (nThisRow == nPrevRow + 1)
+if (!aBucket.maNumVals.empty()  nThisRow == nPrevRow + 1)
 {
 // Secondary numbers.
 aBucket.maNumVals.push_back(fVal);
@@ -475,7 +475,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const 
FormulaToken* pToken
 double fVal = CreateDoubleError( nGlobalError);
 nGlobalError = 0;
 
-if (nThisRow == nPrevRow + 1)
+if (!aBucket.maNumVals.empty()  nThisRow == nPrevRow + 1)
 {
 // Secondary numbers.
 aBucket.maNumVals.push_back(fVal);
@@ -490,7 +490,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const 
FormulaToken* pToken
 }
 else
 {
-if (nThisRow == nPrevRow + 1)
+if (!aBucket.maStrVals.empty()  nThisRow == nPrevRow + 1)
 {
 // Secondary numbers.
 aBucket.maStrVals.push_back(aStr);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-11-02 Thread Libreoffice Gerrit user
 sc/qa/unit/ucalc.cxx   |   12 +++-
 sc/source/core/data/table2.cxx |   16 
 2 files changed, 23 insertions(+), 5 deletions(-)

New commits:
commit d3344dd85ee31b195a3709d16e734245e1d0a4b6
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri Nov 2 13:27:31 2012 -0400

Correctly handle cell note shifting when immediate row/column is deleted.

Currently, having a note e.g. at D5, and deleting cell D4 and shifting
the cells below upward will remove the note at D5.  But the correct behavior
is to shift that note up to D4.  This change fixes it.

Change-Id: Ia37f1ce67a003deab424f2b805a2ce333fc10ed4

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 8bfb0e6..69e2f02 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -261,7 +261,8 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, 
SCROW nStartRow, SCSIZE
 
 if (nStartRow = nRow  nStartCol = nCol  nCol = nEndCol)
 {
-if(nRow - nStartRow  static_castSCROW(nSize))
+SCROW nEndRow = nStartRow + nSize - 1; // last row of deleted 
region
+if (nEndRow  nRow)
 {
 // This note will get shifted.
 aNotes.insert(nCol, nRow - nSize, pPostIt);
@@ -365,6 +366,7 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, 
SCROW nEndRow, SCSIZE
 aCol[MAXCOL - nSize - i].MoveTo(nStartRow, nEndRow, aCol[MAXCOL - 
i]);
 }
 
+// Transfer those notes that will get shifted into another container.
 ScNotes aNotes(pDocument);
 ScNotes::iterator itr = maNotes.begin();
 while( itr != maNotes.end() )
@@ -374,13 +376,14 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW 
nStartRow, SCROW nEndRow, SCSIZE
 ScPostIt* pPostIt = itr-second;
 ++itr;
 
-if (nCol = nStartCol)
+if (nStartCol = nCol  nStartRow = nRow  nRow = nEndRow)
 {
 aNotes.insert(nCol + nSize, nRow, pPostIt);
 maNotes.ReleaseNote(nCol, nRow);
 }
 }
 
+// Re-insert the shifted notes.
 itr = aNotes.begin();
 while( itr != aNotes.end() )
 {
@@ -471,6 +474,7 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, 
SCROW nEndRow, SCSIZE
 aCol[nStartCol + nSize + i].MoveTo(nStartRow, nEndRow, 
aCol[nStartCol + i]);
 }
 
+// Transfer those notes that will get shifted into another container.
 ScNotes aNotes(pDocument);
 ScNotes::iterator itr = maNotes.begin();
 while( itr != maNotes.end() )
@@ -480,18 +484,22 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW 
nStartRow, SCROW nEndRow, SCSIZE
 ScPostIt* pPostIt = itr-second;
 ++itr;
 
-if (nCol = nStartCol)
+if (nStartCol = nCol  nStartRow = nRow  nRow = nEndRow)
 {
-if(nCol - nStartCol  static_castSCCOL(nSize))
+SCCOL nEndCol = nStartCol + nSize - 1;
+if (nEndCol  nCol)
 {
+// This note will get shifted.
 aNotes.insert(nCol - nSize, nRow, pPostIt);
 maNotes.ReleaseNote(nCol, nRow);
 }
 else
+// The note is in the deleted region. Remove it.
 maNotes.erase(nCol, nRow);
 }
 }
 
+// Re-insert the shifted notes.
 itr = aNotes.begin();
 while( itr != aNotes.end() )
 {
commit 6bac39f309e11a515a2b2ecdf43a4b49ccd53502
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri Nov 2 13:23:58 2012 -0400

More test cases for cell notes that currently fail.

Change-Id: I23a5a39ab13106a27a02adbec0ff1ab64a43abef

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 62e98c6..ce8ea86 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4258,7 +4258,7 @@ void Test::testPostIts()
 rAddr.IncRow(); // cell C4
 CPPUNIT_ASSERT_MESSAGE(note not there, 
m_pDoc-GetNotes(rAddr.Tab())-findByAddress(rAddr) == pNote);
 
-// Insert column at column 1.
+// Insert column at column A.
 bool bInsertCol = m_pDoc-InsertCol(0, 0, MAXROW, 0, 1, 1);
 CPPUNIT_ASSERT_MESSAGE(failed to insert column, bInsertCol );
 
@@ -4285,6 +4285,16 @@ void Test::testPostIts()
 m_pDoc-DeleteRow(2, 0, 2, 0, 3, 1);
 CPPUNIT_ASSERT_MESSAGE(Note shouldn't have moved but it has., 
m_pDoc-GetNotes(rAddr.Tab())-findByAddress(rAddr) == pNote);
 
+// Now, with the note at D4, delete cell D3. This should shift the note 
one cell up.
+m_pDoc-DeleteRow(3, 0, 3, 0, 2, 1);
+rAddr.IncRow(-1); // cell D3
+CPPUNIT_ASSERT_MESSAGE(Note at D4 should have shifted up to D3., 
m_pDoc-GetNotes(rAddr.Tab())-findByAddress(rAddr) == pNote);
+
+// Delete column C. This should shift the note one cell left.
+m_pDoc-DeleteCol(0, 0, MAXROW, 0, 2, 1);
+rAddr.IncCol(-1); // cell C3
+CPPUNIT_ASSERT_MESSAGE(Note at D3 should have shifted left to C3., 

[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-09-23 Thread Libreoffice Gerrit user
 sc/qa/unit/subsequent_filters-test.cxx |   48 +++--
 sc/source/core/data/colorscale.cxx |4 +-
 2 files changed, 18 insertions(+), 34 deletions(-)

New commits:
commit 4c2a87d6e70040182d328c25d561b0de69e96a2b
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Sun Sep 23 21:22:29 2012 +0200

int to sal_Int32

Change-Id: I44c5027c15b4f77a3ee76b62673641cc200fbefe

diff --git a/sc/source/core/data/colorscale.cxx 
b/sc/source/core/data/colorscale.cxx
index 4ca1bc7..257ff1b 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -176,7 +176,7 @@ void ScColorScaleEntry::dumpInfo(rtl::OUStringBuffer rBuf) 
const
 default:
 rBuf.append( Unsupported Type\n );
 }
-rBuf.append( Color:  ).append( (int)maColor.GetRed() ).append( , 
).append( (int)maColor.GetGreen() ).append( , ).append( 
(int)maColor.GetBlue() ).append( \n );
+rBuf.append( Color:  ).append( (sal_Int32)maColor.GetRed() ).append( , 
).append( (sal_Int32)maColor.GetGreen() ).append( , ).append( 
(sal_Int32)maColor.GetBlue() ).append( \n );
 if(meType == COLORSCALE_FORMULA)
 rBuf.append( Formula:  ).append( GetFormula( 
formula::FormulaGrammar::GRAM_DEFAULT ) ).append(\n);
 else if( meType != COLORSCALE_MIN  meType != COLORSCALE_MAX )
@@ -549,7 +549,7 @@ void ScColorScaleFormat::dumpInfo(rtl::OUStringBuffer 
rBuf) const
 {
 boost::scoped_ptrColor pColor( GetColor(ScAddress(nCol, 
nRow, nTab)) );
 
rBuf.append(nCol).append(,).append(nRow).append(,).append(nTab).append(,);
-
rBuf.append(((int)pColor-GetRed())).append(,).append(((int)pColor-GetGreen())).append(,).append(((int)pColor-GetBlue())).append(\n);
+
rBuf.append(((sal_Int32)pColor-GetRed())).append(,).append(((sal_Int32)pColor-GetGreen())).append(,).append(((sal_Int32)pColor-GetBlue())).append(\n);
 }
 }
 }
commit 1245c2a7daba66e78a8548b0e5193d7e2b1f2a92
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Sun Sep 23 21:22:01 2012 +0200

little refactoring and code simplification

Change-Id: I41c7507d668eb0853b97c24217ff04f7dd4acd40

diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 8670345..2b6193f 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -1489,62 +1489,46 @@ void ScFiltersTest::testPivotTableBasicODS()
 
 namespace {
 
+void testColorScaleFormat_Impl(ScDocument* pDoc, const rtl::OUString 
rFilePath, const ScConditionalFormat* pFormat)
+{
+rtl::OUStringBuffer aBuf;
+CPPUNIT_ASSERT(pFormat);
+pFormat-dumpInfo(aBuf);
+rtl::OUString aString = aBuf.makeStringAndClear();
+std::string aStdString;
+loadFile(rFilePath, aStdString);
+rtl::OUString aRefString = 
rtl::OUString::createFromAscii(aStdString.c_str());
+CPPUNIT_ASSERT_EQUAL(aRefString, aString);
+}
+
 void testColorScale_Impl(ScDocument* pDoc, const rtl::OUString aBaseString)
 {
 // first color scale
 {
-rtl::OUStringBuffer aBuf;
 const ScConditionalFormat* pFormat = pDoc-GetCondFormat(1,1,0);
-CPPUNIT_ASSERT(pFormat);
-pFormat-dumpInfo(aBuf);
-rtl::OUString aString = aBuf.makeStringAndClear();
 rtl::OUString aFilePath = aBaseString + 
rtl::OUString(colorScale_1.txt);
-std::string aStdString;
-loadFile(aFilePath, aStdString);
-rtl::OUString aRefString = 
rtl::OUString::createFromAscii(aStdString.c_str());
-CPPUNIT_ASSERT_EQUAL(aRefString, aString);
+testColorScaleFormat_Impl(pDoc, aFilePath, pFormat);
 }
 
 // second cond format
 {
-rtl::OUStringBuffer aBuf;
 const ScConditionalFormat* pFormat = pDoc-GetCondFormat(4,1,0);
-CPPUNIT_ASSERT(pFormat);
-pFormat-dumpInfo(aBuf);
-rtl::OUString aString = aBuf.makeStringAndClear();
 rtl::OUString aFilePath = aBaseString + 
rtl::OUString(colorScale_2.txt);
-std::string aStdString;
-loadFile(aFilePath, aStdString);
-rtl::OUString aRefString = 
rtl::OUString::createFromAscii(aStdString.c_str());
-CPPUNIT_ASSERT_EQUAL(aRefString, aString);
+testColorScaleFormat_Impl(pDoc, aFilePath, pFormat);
 }
 
 // third cond format
 {
-rtl::OUStringBuffer aBuf;
 const ScConditionalFormat* pFormat = pDoc-GetCondFormat(7,1,0);
-CPPUNIT_ASSERT(pFormat);
-pFormat-dumpInfo(aBuf);
-rtl::OUString aString = aBuf.makeStringAndClear();
 rtl::OUString aFilePath = aBaseString + 
rtl::OUString(colorScale_3.txt);
-std::string aStdString;
-loadFile(aFilePath, aStdString);
-rtl::OUString aRefString = 
rtl::OUString::createFromAscii(aStdString.c_str());
-CPPUNIT_ASSERT_EQUAL(aRefString, aString);
+testColorScaleFormat_Impl(pDoc, aFilePath, pFormat);
   

[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-09-21 Thread Libreoffice Gerrit user
 sc/qa/unit/rangelst_test.cxx |4 
 sc/source/core/tool/rangelst.cxx |4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

New commits:
commit 16f1e6eddf457d03ece9f5e5967ad553730a44c0
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Fri Sep 21 13:38:18 2012 +0200

add test case for deleting the only row in ScRangeList::UpdateReference

Change-Id: I88cf1e679dc83e051e27a1d20775cc161cb9e3c5

diff --git a/sc/qa/unit/rangelst_test.cxx b/sc/qa/unit/rangelst_test.cxx
index b447dc1..7079166 100644
--- a/sc/qa/unit/rangelst_test.cxx
+++ b/sc/qa/unit/rangelst_test.cxx
@@ -184,6 +184,10 @@ void Test::testUpdateReference_DeleteRow()
 CPPUNIT_ASSERT(!aList.In(ScRange(nCol, 4, 0)));
 }
 CPPUNIT_ASSERT_EQUAL(static_castsize_t(12), aList.GetCellCount());
+
+ScRangeList aList2(ScRange(2,2,0,2,2,0));
+aList2.UpdateReference(URM_INSDEL, m_pDoc, ScRange(0,3,0,MAXCOL,MAXROW,0), 
0, -1, 0);
+CPPUNIT_ASSERT(aList2.empty());
 }
 
 void Test::testUpdateReference_DeleteCol()
commit 1e3919f040ade5d0f7f9fa854b3ed23366080c0c
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Fri Sep 21 13:37:31 2012 +0200

fix problem in ScRangeList::UpdateReference when deleting one row/col

Change-Id: I588565f65be5c9de54b9f038cf297fda4022fd9b

diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index 7a874e8..393d0f0 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -424,11 +424,11 @@ bool ScRangeList::UpdateReference(
 {
 if(nDx  0)
 {
-DeleteArea(nCol1+nDx, nRow1, nTab1, nCol1-1, nRow1, nTab2);
+DeleteArea(nCol1+nDx, nRow1, nTab1, nCol1-1, nRow2, nTab2);
 }
 if(nDy  0)
 {
-DeleteArea(nCol1, nRow1+nDy, nTab1, nCol1, nRow1-1, nTab2);
+DeleteArea(nCol1, nRow1+nDy, nTab1, nCol2, nRow1-1, nTab2);
 }
 SAL_WARN_IF(nDx  0  nDy  0, sc, nDx and nDy are negative, 
check why);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-09-21 Thread Libreoffice Gerrit user
 sc/qa/unit/rangelst_test.cxx |   87 +++
 sc/source/core/tool/rangelst.cxx |  442 +++
 2 files changed, 404 insertions(+), 125 deletions(-)

New commits:
commit cb7ee824dc0b9dcc2fd466f190945de01a9d1fa5
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Fri Sep 21 20:20:18 2012 -0400

Fixed all discovered errors and extra unit tests to cover them.

Change-Id: I1f91d66caed7fd3839f68f1e4495f0c05ee49acc

diff --git a/sc/qa/unit/rangelst_test.cxx b/sc/qa/unit/rangelst_test.cxx
index 7079166..f6e1d53 100644
--- a/sc/qa/unit/rangelst_test.cxx
+++ b/sc/qa/unit/rangelst_test.cxx
@@ -22,8 +22,12 @@ public:
 
 void testDeleteArea_4Ranges();
 void testDeleteArea_3Ranges();
+void testDeleteArea_3Ranges_Case2();
+void testDeleteArea_3Ranges_Case3();
 void testDeleteArea_2Ranges();
 void testDeleteArea_2Ranges_Case2();
+void testDeleteArea_2Ranges_Case3();
+void testDeleteArea_2Ranges_Case4();
 void testDeleteArea_1Range();
 void testDeleteArea_0Ranges();
 
@@ -33,8 +37,12 @@ public:
 CPPUNIT_TEST_SUITE(Test);
 CPPUNIT_TEST(testDeleteArea_4Ranges);
 CPPUNIT_TEST(testDeleteArea_3Ranges);
+CPPUNIT_TEST(testDeleteArea_3Ranges_Case2);
+CPPUNIT_TEST(testDeleteArea_3Ranges_Case3);
 CPPUNIT_TEST(testDeleteArea_2Ranges);
 CPPUNIT_TEST(testDeleteArea_2Ranges_Case2);
+CPPUNIT_TEST(testDeleteArea_2Ranges_Case3);
+CPPUNIT_TEST(testDeleteArea_2Ranges_Case4);
 CPPUNIT_TEST(testDeleteArea_1Range);
 CPPUNIT_TEST(testDeleteArea_0Ranges);
 CPPUNIT_TEST(testUpdateReference_DeleteRow);
@@ -105,6 +113,47 @@ void Test::testDeleteArea_3Ranges()
 CPPUNIT_ASSERT_EQUAL(static_castsize_t(28), aList.GetCellCount());
 }
 
+void Test::testDeleteArea_3Ranges_Case2()
+{
+ScRangeList aList(ScRange(1,1,0,6,6,0));
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(1), aList.size());
+aList.DeleteArea(0,2,0,2,4,0);
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(3), aList.size());
+
+// Column 1-2  Row 2-4 should not be in the range list. The rest should
+// be in the list.
+for (SCCOL nCol = 1; nCol = 6; ++nCol)
+{
+for (SCROW nRow = 1; nRow = 6; ++nRow)
+{
+if ((1 = nCol  nCol = 2)  (2 = nRow  nRow = 4))
+CPPUNIT_ASSERT(!aList.In(ScRange(nCol, nRow, 0)));
+else
+CPPUNIT_ASSERT(aList.In(ScRange(nCol, nRow, 0)));
+}
+}
+}
+
+void Test::testDeleteArea_3Ranges_Case3()
+{
+ScRangeList aList(ScRange(1,5,0,6,11,0));
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(1), aList.size());
+aList.DeleteArea(3,2,0,4,8,0);
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(3), aList.size());
+
+// Column 3-4  Row 5-8 should not be in the range list.
+for (SCCOL nCol = 1; nCol = 6; ++nCol)
+{
+for (SCROW nRow = 5; nRow = 11; ++nRow)
+{
+if ((3 = nCol  nCol = 4)  (5 = nRow  nRow = 8))
+CPPUNIT_ASSERT(!aList.In(ScRange(nCol, nRow, 0)));
+else
+CPPUNIT_ASSERT(aList.In(ScRange(nCol, nRow, 0)));
+}
+}
+}
+
 void Test::testDeleteArea_2Ranges()
 {
 ScRangeList aList(ScRange(0,0,0,5,5,5));
@@ -142,6 +191,44 @@ void Test::testDeleteArea_2Ranges_Case2()
 CPPUNIT_ASSERT_EQUAL(static_castsize_t(4), aList.GetCellCount());
 }
 
+void Test::testDeleteArea_2Ranges_Case3()
+{
+ScRangeList aList(ScRange(0,5,0,2,10,0));
+aList.DeleteArea(2,3,0,3,7,0);
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(2), aList.size());
+
+// Column 2 Row 5-7 shouldn't be in the list.
+for (SCCOL nCol = 0; nCol = 2; ++nCol)
+{
+for (SCROW nRow = 5; nRow = 10; ++nRow)
+{
+if (nCol == 2  (5 = nRow  nRow = 7))
+CPPUNIT_ASSERT(!aList.In(ScRange(nCol,nRow,0)));
+else
+CPPUNIT_ASSERT(aList.In(ScRange(nCol,nRow,0)));
+}
+}
+}
+
+void Test::testDeleteArea_2Ranges_Case4()
+{
+ScRangeList aList(ScRange(2,3,0,4,7,0));
+aList.DeleteArea(0,1,0,2,5,0);
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(2), aList.size());
+
+// Column 2 Row 3-5 shouldn't be in the list.
+for (SCCOL nCol = 2; nCol = 4; ++nCol)
+{
+for (SCROW nRow = 3; nRow = 7; ++nRow)
+{
+if (nCol == 2  (3 = nRow  nRow = 5))
+CPPUNIT_ASSERT(!aList.In(ScRange(nCol,nRow,0)));
+else
+CPPUNIT_ASSERT(aList.In(ScRange(nCol,nRow,0)));
+}
+}
+}
+
 void Test::testDeleteArea_1Range()
 {
 ScRangeList aList(ScRange(1,1,0,3,3,0));
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index b4b8732..96f7de5 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -517,6 +517,7 @@ bool handleOneRange( const ScRange rDeleteRange, ScRange* 
p )
 // +--+ (xxx) = deleted region
 
 p-aStart.SetRow(nDeleteRow1+1);
+return true;
 }

[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-09-21 Thread Libreoffice Gerrit user
 sc/qa/unit/rangelst_test.cxx |  128 +++
 sc/source/core/tool/rangelst.cxx |   12 +--
 2 files changed, 134 insertions(+), 6 deletions(-)

New commits:
commit fc0aa44b9d6aab7af68b00e4e26f3d9300e30fc2
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Sat Sep 22 04:45:10 2012 +0200

test cases for the changes to ScRangeList::DeleteArea

Change-Id: Iaf64a4cdceed76ba37e4486cfded18bd7e49b196

diff --git a/sc/qa/unit/rangelst_test.cxx b/sc/qa/unit/rangelst_test.cxx
index f6e1d53..2c618a5 100644
--- a/sc/qa/unit/rangelst_test.cxx
+++ b/sc/qa/unit/rangelst_test.cxx
@@ -24,10 +24,16 @@ public:
 void testDeleteArea_3Ranges();
 void testDeleteArea_3Ranges_Case2();
 void testDeleteArea_3Ranges_Case3();
+void testDeleteArea_3Ranges_Case4();
+void testDeleteArea_3Ranges_Case5();
 void testDeleteArea_2Ranges();
 void testDeleteArea_2Ranges_Case2();
 void testDeleteArea_2Ranges_Case3();
 void testDeleteArea_2Ranges_Case4();
+void testDeleteArea_2Ranges_Case5();
+void testDeleteArea_2Ranges_Case6();
+void testDeleteArea_2Ranges_Case7();
+void testDeleteArea_2Ranges_Case8();
 void testDeleteArea_1Range();
 void testDeleteArea_0Ranges();
 
@@ -39,10 +45,16 @@ public:
 CPPUNIT_TEST(testDeleteArea_3Ranges);
 CPPUNIT_TEST(testDeleteArea_3Ranges_Case2);
 CPPUNIT_TEST(testDeleteArea_3Ranges_Case3);
+CPPUNIT_TEST(testDeleteArea_3Ranges_Case4);
+CPPUNIT_TEST(testDeleteArea_3Ranges_Case5);
 CPPUNIT_TEST(testDeleteArea_2Ranges);
 CPPUNIT_TEST(testDeleteArea_2Ranges_Case2);
 CPPUNIT_TEST(testDeleteArea_2Ranges_Case3);
 CPPUNIT_TEST(testDeleteArea_2Ranges_Case4);
+CPPUNIT_TEST(testDeleteArea_2Ranges_Case5);
+CPPUNIT_TEST(testDeleteArea_2Ranges_Case6);
+CPPUNIT_TEST(testDeleteArea_2Ranges_Case7);
+CPPUNIT_TEST(testDeleteArea_2Ranges_Case8);
 CPPUNIT_TEST(testDeleteArea_1Range);
 CPPUNIT_TEST(testDeleteArea_0Ranges);
 CPPUNIT_TEST(testUpdateReference_DeleteRow);
@@ -154,6 +166,46 @@ void Test::testDeleteArea_3Ranges_Case3()
 }
 }
 
+void Test::testDeleteArea_3Ranges_Case4()
+{
+ScRangeList aList(ScRange(1,5,0,6,11,0));
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(1), aList.size());
+aList.DeleteArea(3,5,0,4,5,0);
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(3), aList.size());
+
+// Column 3-4  Row 5 should not be in the range list.
+for (SCCOL nCol = 1; nCol = 6; ++nCol)
+{
+for (SCROW nRow = 5; nRow = 11; ++nRow)
+{
+if ((3 = nCol  nCol = 4)  5 == nRow )
+CPPUNIT_ASSERT(!aList.In(ScRange(nCol, nRow, 0)));
+else
+CPPUNIT_ASSERT(aList.In(ScRange(nCol, nRow, 0)));
+}
+}
+}
+
+void Test::testDeleteArea_3Ranges_Case5()
+{
+ScRangeList aList(ScRange(1,5,0,6,11,0));
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(1), aList.size());
+aList.DeleteArea(6,7,0,6,9,0);
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(3), aList.size());
+
+// Column 6  Row 7-9 should not be in the range list.
+for (SCCOL nCol = 1; nCol = 6; ++nCol)
+{
+for (SCROW nRow = 5; nRow = 11; ++nRow)
+{
+if ( nCol == 6  (7 = nRow  nRow = 9))
+CPPUNIT_ASSERT(!aList.In(ScRange(nCol, nRow, 0)));
+else
+CPPUNIT_ASSERT(aList.In(ScRange(nCol, nRow, 0)));
+}
+}
+}
+
 void Test::testDeleteArea_2Ranges()
 {
 ScRangeList aList(ScRange(0,0,0,5,5,5));
@@ -229,6 +281,82 @@ void Test::testDeleteArea_2Ranges_Case4()
 }
 }
 
+void Test::testDeleteArea_2Ranges_Case5()
+{
+ScRangeList aList(ScRange(2,2,0,5,5,0));
+aList.DeleteArea(4,5,0,5,5,0);
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(2), aList.size());
+
+// Column 4 and 5 Row 5 shouldn't be in the list.
+for(SCCOL nCol = 2; nCol = 5; ++nCol)
+{
+for(SCROW nRow = 2; nRow = 5; ++nRow)
+{
+if(nRow == 5  4 = nCol)
+CPPUNIT_ASSERT(!aList.In(ScRange(nCol, nRow, 0)));
+else
+CPPUNIT_ASSERT(aList.In(ScRange(nCol, nRow, 0)));
+}
+}
+}
+
+void Test::testDeleteArea_2Ranges_Case6()
+{
+ScRangeList aList(ScRange(2,2,0,5,5,0));
+aList.DeleteArea(4,2,0,5,2,0);
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(2), aList.size());
+
+// Column 4 and 5 Row 2 shouldn't be in the list.
+for(SCCOL nCol = 2; nCol = 5; ++nCol)
+{
+for(SCROW nRow = 2; nRow = 5; ++nRow)
+{
+if(nRow == 2  4 = nCol)
+CPPUNIT_ASSERT(!aList.In(ScRange(nCol, nRow, 0)));
+else
+CPPUNIT_ASSERT(aList.In(ScRange(nCol, nRow, 0)));
+}
+}
+}
+
+void Test::testDeleteArea_2Ranges_Case7()
+{
+ScRangeList aList(ScRange(2,2,0,5,5,0));
+aList.DeleteArea(2,5,0,2,5,0);
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(2), aList.size());
+
+// Column 2 Row 5 shouldn't be in the list.
+for(SCCOL nCol = 

[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-09-17 Thread Libreoffice Gerrit user
 sc/qa/unit/rangelst_test.cxx |   33 +
 sc/source/core/tool/rangelst.cxx |   17 +
 2 files changed, 50 insertions(+)

New commits:
commit 764e7e71038d5ae66061f44bc0cd51ce33ae96ed
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Mon Sep 17 17:58:27 2012 +0200

hopefully a corect way to deal with deleting rows and cols, fdo#54842

Change-Id: I4ec1a8225ae3c84352643876065fb4cc7073b9f4

diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index e81ec82..c6b3bfc 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -417,6 +417,23 @@ bool ScRangeList::UpdateReference(
 SCTAB nTab2;
 rWhere.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
 
+if(eUpdateRefMode == URM_INSDEL)
+{
+// right now this only works for nTab1 == nTab2
+if(nTab1 == nTab2)
+{
+if(nDx  0)
+{
+DeleteArea(nCol1+nDx, nRow1, nTab1, nCol1-1, nRow1, nTab2);
+}
+if(nDy  0)
+{
+DeleteArea(nCol1, nRow1+nDy, nTab1, nCol1, nRow1-1, nTab2);
+}
+SAL_WARN_IF(nDx  0  nDy  0, sc, nDx and nDy are negative, 
check why);
+}
+}
+
 vectorScRange*::iterator itr = maRanges.begin(), itrEnd = maRanges.end();
 for (; itr != itrEnd; ++itr)
 {
commit f165111cf4f62353a674bd3497d8cf4a0480a3ab
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Mon Sep 17 16:07:19 2012 +0200

one more test for ScRangeList::DeleteArea

Change-Id: I42d31f6653990a81eff815d3d0feffad84b1379e

diff --git a/sc/qa/unit/rangelst_test.cxx b/sc/qa/unit/rangelst_test.cxx
index 2901965..41d4590 100644
--- a/sc/qa/unit/rangelst_test.cxx
+++ b/sc/qa/unit/rangelst_test.cxx
@@ -22,11 +22,16 @@ public:
 
 void testDeleteArea_4Ranges();
 void testDeleteArea_2Ranges();
+void testDeleteArea_2Ranges_Case2();
 void testDeleteArea_0Ranges();
 
+void testUpdateReference_DeleteRow();
+void testUpdateReference_DeleteCol();
+
 CPPUNIT_TEST_SUITE(Test);
 CPPUNIT_TEST(testDeleteArea_4Ranges);
 CPPUNIT_TEST(testDeleteArea_2Ranges);
+CPPUNIT_TEST(testDeleteArea_2Ranges_Case2);
 CPPUNIT_TEST(testDeleteArea_0Ranges);
 CPPUNIT_TEST_SUITE_END();
 
@@ -96,6 +101,21 @@ void Test::testDeleteArea_2Ranges()
 }
 }
 
+void Test::testDeleteArea_2Ranges_Case2()
+{
+ScRangeList aList(ScRange(1,1,0,1,5,0));
+aList.DeleteArea(0,3,0,MAXCOL,3,0);
+
+for(SCROW nRow = 1; nRow = 5; ++nRow)
+{
+if(nRow == 3)
+CPPUNIT_ASSERT(!aList.Intersects(ScRange(1,3,0)));
+else
+CPPUNIT_ASSERT(aList.Intersects(ScRange(1,nRow,0)));
+}
+CPPUNIT_ASSERT_EQUAL(static_castsize_t(4), aList.GetCellCount());
+}
+
 void Test::testDeleteArea_0Ranges()
 {
 ScRangeList aList(ScRange(1,1,0,3,3,0));
@@ -109,6 +129,19 @@ void Test::testDeleteArea_0Ranges()
 CPPUNIT_ASSERT(aList.empty());
 }
 
+void Test::testUpdateReference_DeleteRow()
+{
+ScRangeList aList(ScRange(1,1,0,4,4,0));
+bool bUpdated = aList.UpdateReference(URM_INSDEL, m_pDoc, 
ScRange(0,3,0,MAXCOL,MAXROW,0), 0, -1, 0);
+CPPUNIT_ASSERT(bUpdated);
+
+}
+
+void Test::testUpdateReference_DeleteCol()
+{
+
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-08-14 Thread Kohei Yoshida
 sc/qa/unit/data/ods/cell-anchored-shapes.ods |binary
 sc/qa/unit/subsequent_filters-test.cxx   |   41 +++
 sc/source/filter/xml/xmlimprt.cxx|3 +
 3 files changed, 44 insertions(+)

New commits:
commit a7a12bd3dee32db44a6b50a68ab700dc8ce437df
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Aug 14 17:16:18 2012 -0400

New unit test for importing cell-anchored shapes from ods.

Change-Id: I3cedafaf1862c69a40a7973ed056bf595f9e7d20

diff --git a/sc/qa/unit/data/ods/cell-anchored-shapes.ods 
b/sc/qa/unit/data/ods/cell-anchored-shapes.ods
new file mode 100644
index 000..5a006f6
Binary files /dev/null and b/sc/qa/unit/data/ods/cell-anchored-shapes.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 8d6a804..95009ac 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -38,6 +38,7 @@
 #include sfx2/docfile.hxx
 #include sfx2/sfxmodelfactory.hxx
 #include svl/stritem.hxx
+#include svx/svdpage.hxx
 
 #include editeng/brshitem.hxx
 #include editeng/justifyitem.hxx
@@ -45,6 +46,8 @@
 #include dbdata.hxx
 #include validat.hxx
 #include cell.hxx
+#include drwlayer.hxx
+#include userdat.hxx
 
 #include com/sun/star/drawing/XDrawPageSupplier.hpp
 #include com/sun/star/drawing/XControlShape.hpp
@@ -151,6 +154,8 @@ public:
 void testNumberFormatHTML();
 void testNumberFormatCSV();
 
+void testCellAnchoredShapesODS();
+
 CPPUNIT_TEST_SUITE(ScFiltersTest);
 CPPUNIT_TEST(testRangeNameXLS);
 CPPUNIT_TEST(testRangeNameXLSX);
@@ -187,6 +192,8 @@ public:
 CPPUNIT_TEST(testNumberFormatHTML);
 CPPUNIT_TEST(testNumberFormatCSV);
 
+CPPUNIT_TEST(testCellAnchoredShapesODS);
+
 //disable testPassword on MacOSX due to problems with libsqlite3
 //also crashes on DragonFly due to problems with nss/nspr headers
 #if !defined(MACOSX)  !defined(DRAGONFLY)  !defined(WNT)
@@ -1243,6 +1250,40 @@ void ScFiltersTest::testNumberFormatCSV()
 xDocSh-DoClose();
 }
 
+void ScFiltersTest::testCellAnchoredShapesODS()
+{
+OUString aFileNameBase(cell-anchored-shapes.);
+OUString aFileExt = OUString::createFromAscii(aFileFormats[ODS].pName);
+OUString aFilterName = 
OUString::createFromAscii(aFileFormats[ODS].pFilterName);
+OUString aFilterType = 
OUString::createFromAscii(aFileFormats[ODS].pTypeName);
+
+rtl::OUString aFileName;
+createFileURL(aFileNameBase, aFileExt, aFileName);
+ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), 
aFilterType, aFileFormats[ODS].nFormatType);
+CPPUNIT_ASSERT_MESSAGE(Failed to load cell-anchored-shapes.ods, 
xDocSh.Is());
+
+// There are two cell-anchored objects on the first sheet.
+ScDocument* pDoc = xDocSh-GetDocument();
+
+CPPUNIT_ASSERT_MESSAGE(There should be at least one sheet., 
pDoc-GetTableCount()  0);
+
+ScDrawLayer* pDrawLayer = pDoc-GetDrawLayer();
+SdrPage* pPage = pDrawLayer-GetPage(0);
+CPPUNIT_ASSERT_MESSAGE(draw page for sheet 1 should exist., pPage);
+sal_uIntPtr nCount = pPage-GetObjCount();
+CPPUNIT_ASSERT_MESSAGE(There should be 2 objects., nCount == 2);
+for (sal_uIntPtr i = 0; i  nCount; ++i)
+{
+SdrObject* pObj = pPage-GetObj(i);
+CPPUNIT_ASSERT_MESSAGE(Failed to get drawing object., pObj);
+ScDrawObjData* pData = ScDrawLayer::GetObjData(pObj, false);
+CPPUNIT_ASSERT_MESSAGE(Failed to retrieve user data for this 
object., pData);
+CPPUNIT_ASSERT_MESSAGE(Bounding rectangle should have been calculated 
upon import., !pData-maLastRect.IsEmpty());
+}
+
+xDocSh-DoClose();
+}
+
 void ScFiltersTest::testColorScale()
 {
 const rtl::OUString 
aFileNameBase(RTL_CONSTASCII_USTRINGPARAM(colorScale.));
commit 4606ca07de17c930b658206a19446516cf0d4eb7
Author: Kohei Yoshida kohei.yosh...@gmail.com
Date:   Tue Aug 14 16:46:44 2012 -0400

Calculate positions of cell-anchored objects upon ods import.

Since we no longer re-calc row heights on ods import, we need to do
this manually, in order to position cell-anchored objects correctly.
Previously we were getting this for free since the row height recalc
code path did it as part of it.

Change-Id: I8ab5dd1fe7cd8a45b7968e101c893b442d7ce132

diff --git a/sc/source/filter/xml/xmlimprt.cxx 
b/sc/source/filter/xml/xmlimprt.cxx
index dcf37b4..4f2ff59 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -3101,8 +3101,11 @@ throw( ::com::sun::star::xml::sax::SAXException, 
::com::sun::star::uno::RuntimeE
 
 SCTAB nTabCount = pDoc-GetTableCount();
 for (SCTAB nTab=0; nTabnTabCount; ++nTab)
+{
+pDoc-SetDrawPageSize(nTab);
 if (!pSheetData-IsSheetBlocked( nTab ))
 pDoc-SetStreamValid( nTab, true );
+}
 }
 aTables.FixupOLEs();
 }

[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-07-19 Thread Daniel Bankston
 sc/qa/unit/data/contentCSV/matrix2.csv |1 +
 sc/qa/unit/data/ods/matrix.ods |binary
 sc/qa/unit/subsequent_filters-test.cxx |   11 ++-
 sc/source/filter/xml/xmlcelli.cxx  |   24 +++-
 4 files changed, 30 insertions(+), 6 deletions(-)

New commits:
commit 61c39eae570d6d6040b65bfe93127b30e6080cc8
Author: Daniel Bankston daniel.e.banks...@gmail.com
Date:   Thu Jul 19 17:26:35 2012 -0500

Display blank cell instead of zero in matrix cells with blank text result

Change-Id: Id9d17403717e42b91b1f45b0a081e2fb5a27c06e

diff --git a/sc/source/filter/xml/xmlcelli.cxx 
b/sc/source/filter/xml/xmlcelli.cxx
index ede4131..26d01aa 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -189,7 +189,8 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( 
ScXMLImport rImport,
 bIsEmpty = false;
 
 //if office:value=0, treat like text in case the formula
-//result is Err:### or #N/A until we confirm otherwise
+//result is Err:###, #N/A, or matrix reference cell 
with
+//blank text result until we confirm otherwise.
 if(fValue == 0.0)
 bFormulaTextResult = true;
 }
@@ -1109,9 +1110,21 @@ void ScXMLTableRowCellContext::AddFormulaCell( const 
ScAddress rCellPos )
 
 namespace{
 
-bool isErrOrNA(const rtl::OUString rStr)
+bool isSpecialValue(const rtl::OUString rStr, sal_Int16 rnCellType)
 {
-return (rStr.indexOf(Err:)   -1) || (rStr.indexOf(#N/A)  -1);
+if( (rStr.indexOf(Err:)   -1) || (rStr.indexOf(#N/A)  -1) )
+return true;
+//If a matrix formula has a matrix reference cell that is intended to have
+//a blank text result, the matrix reference cell is actually saved(export)
+//as a float cell with 0 as the value and empty text:p/.
+//Import works around this by setting these cells as text cells so that
+//the blank text is used for display instead of the number 0.
+if( rStr.isEmpty() )
+{
+rnCellType = util::NumberFormat::TEXT;
+return true;
+}
+return false;
 }
 
 }
@@ -1132,8 +1145,9 @@ void ScXMLTableRowCellContext::EndElement()
 }
 }
 
-//if this is an Err:### or #N/A then use text:p value
-if( bFormulaTextResult  pOUTextContent  isErrOrNA(*pOUTextContent) )
+//if this is a blank matrix formula result, Err:###, or #N/A then
+//use text:p string because of the way export saves these types of cells.
+if( bFormulaTextResult  pOUTextContent  
isSpecialValue(*pOUTextContent, nCellType) )
 pOUTextValue.reset(*pOUTextContent);
 
 ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos();
commit abdffd2e442356782ee6bd947936afc7fb9e4287
Author: Daniel Bankston daniel.e.banks...@gmail.com
Date:   Thu Jul 19 17:23:06 2012 -0500

Add test case for matrix reference cells with blank text result

Change-Id: If00d424ebe0d82284c3281c3362f2a9e52ee384e

diff --git a/sc/qa/unit/data/contentCSV/matrix2.csv 
b/sc/qa/unit/data/contentCSV/matrix2.csv
index 955d345..2effd61 100644
--- a/sc/qa/unit/data/contentCSV/matrix2.csv
+++ b/sc/qa/unit/data/contentCSV/matrix2.csv
@@ -3,3 +3,4 @@ Err:502,Err:502,Err:502,,error result
 #N/A,#N/A,#N/A,,n/a
 TRUE,TRUE,TRUE,,Display TRUE instead of 1
 FALSE,FALSE,FALSE,,Display FALSE instead of 0
+42,,42,,Display blank cell instead of 0
diff --git a/sc/qa/unit/data/ods/matrix.ods b/sc/qa/unit/data/ods/matrix.ods
index 2a8c4ab..7d26c2f 100644
Binary files a/sc/qa/unit/data/ods/matrix.ods and 
b/sc/qa/unit/data/ods/matrix.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 9a3c5dd..6688e0f 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -44,6 +44,7 @@
 #include editeng/borderline.hxx
 #include dbdata.hxx
 #include validat.hxx
+#include cell.hxx
 
 #include com/sun/star/drawing/XDrawPageSupplier.hpp
 #include com/sun/star/drawing/XControlShape.hpp
@@ -423,9 +424,17 @@ void ScFiltersTest::testCachedMatrixFormulaResultsODS()
 rtl::OUString aCSVFileName;
 createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(matrix.)), 
aCSVFileName);
 testFile(aCSVFileName, pDoc, 0);
-//test matrix with errors
+//test matrices with special cases
 createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(matrix2.)), 
aCSVFileName);
 testFile(aCSVFileName, pDoc, 1);
+//The above testFile() does not catch the below case.
+//If a matrix formula has a matrix reference cell that is intended to have
+//a blank text result, the matrix reference cell is actually saved(export)
+//as a float cell with 0 as the value and an empty text:p/.
+//Import works around this by setting these cells as text cells so that
+//the blank text is used for display instead of the number 0.
+//If this is working properly, 

[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-07-18 Thread Eike Rathke
 sc/qa/unit/ucalc.cxx |   15 +++
 sc/source/core/tool/interpr4.cxx |   15 +++
 2 files changed, 30 insertions(+)

New commits:
commit 123fa79cb24dced9adea7ef4d007a4516c1555d4
Author: Eike Rathke er...@redhat.com
Date:   Wed Jul 18 17:24:08 2012 +0200

unit test fdo#50345 accept empty string as scalar numeric 0 argument

Change-Id: Ie04cb8d32e9328212d41fedb63cf81b235aa69de

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index b816f5c..7ea887c 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1042,6 +1042,21 @@ void Test::testFuncParam()
 m_pDoc-GetValue(0, 0, 0, val);
 CPPUNIT_ASSERT_MESSAGE(incorrect result, val == 0.25);
 
+// Conversion of string to numeric argument.
+m_pDoc-SetString(0, 0, 0, OUString(=\\+3));// empty string
+m_pDoc-SetString(0, 1, 0, OUString(=\ \+3));   // only blank
+m_pDoc-SetString(0, 2, 0, OUString(=\ 4 \+3)); // number in blanks
+m_pDoc-SetString(0, 3, 0, OUString(=\ x \+3)); // non-numeric = 
#VALUE! error
+m_pDoc-CalcFormulaTree(false, true);
+m_pDoc-GetValue(0, 0, 0, val);
+CPPUNIT_ASSERT_MESSAGE(incorrect result, val == 3);
+m_pDoc-GetValue(0, 1, 0, val);
+CPPUNIT_ASSERT_MESSAGE(incorrect result, val == 3);
+m_pDoc-GetValue(0, 2, 0, val);
+CPPUNIT_ASSERT_MESSAGE(incorrect result, val == 7);
+rtl::OUString aVal = m_pDoc-GetString( 0, 3, 0);
+CPPUNIT_ASSERT_MESSAGE(incorrect result, aVal == #VALUE!);
+
 m_pDoc-DeleteTab(0);
 }
 
commit a439cb5aba49d01df20f67a2c84b68542e4d3d5a
Author: Eike Rathke er...@redhat.com
Date:   Wed Jul 18 17:04:33 2012 +0200

resolved fdo#50345 accept empty string as scalar numeric 0 argument

For OOo/AOOi interoperability convert an empty string or string
containing only spaces to numeric 0 for scalar numeric arguments.

Change-Id: I551d10b647c961df08ca8c936ca8fed5de14d99f

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index bca2977..566d0b3 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -243,6 +243,21 @@ double ScInterpreter::ConvertStringToValue( const String 
rStr )
 SetError( mnStringNoValueError);
 return fValue;
 }
+// The number scanner does not accept empty strings or strings containing
+// only spaces, be on par in these cases with what was accepted in OOo and
+// is in AOO (see also the #else branch below) and convert to 0 to prevent
+// interoperability nightmares.
+if (!rStr.Len())
+return fValue;
+else if (rStr.GetChar(0) == ' ')
+{
+const sal_Unicode* p = rStr.GetBuffer() + 1;
+const sal_Unicode* const pStop = p - 1 + rStr.Len();
+while (p  pStop  *p == ' ')
+++p;
+if (p == pStop)
+return fValue;
+}
 sal_uInt32 nFIndex = 0;
 if (!pFormatter-IsNumberFormat(rStr, nFIndex, fValue))
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-07-12 Thread Daniel Bankston
 sc/qa/unit/data/ods/formats.ods|binary
 sc/qa/unit/subsequent_filters-test.cxx |   14 +-
 sc/source/filter/xml/xmlcoli.cxx   |   10 +-
 sc/source/filter/xml/xmlsubti.cxx  |8 
 sc/source/filter/xml/xmlsubti.hxx  |4 ++--
 5 files changed, 20 insertions(+), 16 deletions(-)

New commits:
commit 68eb65f19d4f3fb564ac993e8b2f37fb33d685c3
Author: Daniel Bankston daniel.e.banks...@gmail.com
Date:   Thu Jul 12 22:37:39 2012 -0500

Fix broken ODS column width import fdo#51446

Change-Id: I43b6558de6e92b0fe40a38b5f2417bebad2b7f8b

diff --git a/sc/source/filter/xml/xmlcoli.cxx b/sc/source/filter/xml/xmlcoli.cxx
index 624fa1d..81d0b6a 100644
--- a/sc/source/filter/xml/xmlcoli.cxx
+++ b/sc/source/filter/xml/xmlcoli.cxx
@@ -118,7 +118,7 @@ void ScXMLTableColContext::EndElement()
 {
 ScXMLImport rXMLImport = GetScImport();
 SCTAB nSheet = rXMLImport.GetTables().GetCurrentSheet();
-sal_Int32 nCurrentColumn = rXMLImport.GetTables().GetCurrentColumn();
+sal_Int32 nCurrentColumn = rXMLImport.GetTables().GetCurrentColCount();
 uno::Referencesheet::XSpreadsheet 
xSheet(rXMLImport.GetTables().GetCurrentXSheet());
 if(xSheet.is())
 {
@@ -187,10 +187,10 @@ ScXMLTableColsContext::ScXMLTableColsContext( 
ScXMLImport rImport,
 {
 // don't have any attributes
 if (bHeader)
-nHeaderStartCol = rImport.GetTables().GetCurrentColumn();
+nHeaderStartCol = rImport.GetTables().GetCurrentColCount();
 else if (bGroup)
 {
-nGroupStartCol = rImport.GetTables().GetCurrentColumn();
+nGroupStartCol = rImport.GetTables().GetCurrentColCount();
 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList-getLength() : 0;
 for( sal_Int16 i=0; i  nAttrCount; ++i )
 {
@@ -257,7 +257,7 @@ void ScXMLTableColsContext::EndElement()
 ScXMLImport rXMLImport = GetScImport();
 if (bHeader)
 {
-nHeaderEndCol = rXMLImport.GetTables().GetCurrentColumn();
+nHeaderEndCol = rXMLImport.GetTables().GetCurrentColCount();
 nHeaderEndCol--;
 if (nHeaderStartCol = nHeaderEndCol)
 {
@@ -284,7 +284,7 @@ void ScXMLTableColsContext::EndElement()
 else if (bGroup)
 {
 SCTAB nSheet = rXMLImport.GetTables().GetCurrentSheet();
-nGroupEndCol = rXMLImport.GetTables().GetCurrentColumn();
+nGroupEndCol = rXMLImport.GetTables().GetCurrentColCount();
 nGroupEndCol--;
 if (nGroupStartCol = nGroupEndCol)
 {
diff --git a/sc/source/filter/xml/xmlsubti.cxx 
b/sc/source/filter/xml/xmlsubti.cxx
index c5a5eeb..87cd34e 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -75,7 +75,7 @@ ScMyTables::ScMyTables(ScXMLImport rTempImport)
 : rImport(rTempImport),
 aFixupOLEs(rTempImport),
 maCurrentCellPos(ScAddress::INITIALIZE_INVALID),
-nCurrentColStylePos(0),
+nCurrentColCount(0),
 nCurrentDrawPage( -1 ),
 nCurrentXShapes( -1 )
 {
@@ -113,7 +113,7 @@ void ScMyTables::NewSheet(const rtl::OUString sTableName, 
const rtl::OUString
 {
 if (rImport.GetModel().is())
 {
-nCurrentColStylePos = 0;
+nCurrentColCount = 0;
 sCurrentSheetName = sTableName;
 //reset cols and rows for new sheet, but increment tab
 maCurrentCellPos.SetCol(-1);
@@ -227,8 +227,8 @@ void ScMyTables::DeleteTable()
 
 void ScMyTables::AddColStyle(const sal_Int32 nRepeat, const rtl::OUString 
rCellStyleName)
 {
-rImport.GetStylesImportHelper()-AddColumnStyle(rCellStyleName, 
nCurrentColStylePos, nRepeat);
-nCurrentColStylePos += nRepeat;
+rImport.GetStylesImportHelper()-AddColumnStyle(rCellStyleName, 
nCurrentColCount, nRepeat);
+nCurrentColCount += nRepeat;
 }
 
 uno::Reference drawing::XDrawPage  ScMyTables::GetCurrentXDrawPage()
diff --git a/sc/source/filter/xml/xmlsubti.hxx 
b/sc/source/filter/xml/xmlsubti.hxx
index e080cfd..b57f682 100644
--- a/sc/source/filter/xml/xmlsubti.hxx
+++ b/sc/source/filter/xml/xmlsubti.hxx
@@ -71,7 +71,7 @@ private:
 ScAddress   maCurrentCellPos;
 ScRangeList maMatrixRangeList;
 ScXMLTabProtectionData  maProtectionData;
-sal_Int32   nCurrentColStylePos;
+sal_Int32   nCurrentColCount;
 sal_Int16   nCurrentDrawPage;
 sal_Int16   nCurrentXShapes;
 
@@ -96,7 +96,7 @@ public:
 ScXMLTabProtectionData GetCurrentProtectionData() { return 
maProtectionData; }
 rtl::OUString   GetCurrentSheetName() const { return 
sCurrentSheetName; }
 SCTAB   GetCurrentSheet() const { return 
(maCurrentCellPos.Tab() = 0) ? maCurrentCellPos.Tab() : 0; }
-SCCOL   GetCurrentColumn() const { return 
(maCurrentCellPos.Col() = 0) ? maCurrentCellPos.Col() : 0; }
+

[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-07-05 Thread Markus Mohrhard
 sc/qa/unit/data/xlsx/singlecontrol.xlsx |binary
 sc/qa/unit/subsequent_filters-test.cxx  |   33 
 sc/source/ui/view/gridwin.cxx   |9 ++--
 3 files changed, 40 insertions(+), 2 deletions(-)

New commits:
commit c433fa0639ccf5caeb0c128c8a3794322e2a1c81
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Fri Jul 6 02:04:44 2012 +0200

adjust the calculation of the cursor pos if ALT is used, fdo#48869

Change-Id: I6316717c860d999270aa7f0fb50af5f6dfc7efd7

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 6187397..c98b89e 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -4113,6 +4113,9 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* 
pTransObj, SCCOL nDestPos
 String aUndo = ScGlobal::GetRscString( bIsMove ? STR_UNDO_MOVE 
: STR_UNDO_COPY );
 pDocSh-GetUndoManager()-EnterListAction( aUndo, aUndo );
 
+SCsCOL nCorrectCursorPosCol = 0;
+SCsROW nCorrectCursorPosRow = 0;
+
 bDone = sal_True;
 if ( meDragInsertMode != INS_NONE )
 {
@@ -4126,11 +4129,13 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* 
pTransObj, SCCOL nDestPos
  nDestPosX == aSource.aStart.Col()  
nDestPosY  aSource.aStart.Row() )
 {
 bDone = aSource.Move( 0, nSizeY, 0, pSourceDoc 
);
+nCorrectCursorPosRow = nSizeY;
 }
 else if ( meDragInsertMode == INS_CELLSRIGHT 
   nDestPosY == aSource.aStart.Row()  
nDestPosX  aSource.aStart.Col() )
 {
 bDone = aSource.Move( nSizeX, 0, 0, pSourceDoc 
);
+nCorrectCursorPosCol = nSizeX;
 }
 }
 pDocSh-UpdateOle( pViewData );
@@ -4189,8 +4194,8 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* 
pTransObj, SCCOL nDestPos
 {
 pView-MarkRange( aDest, false, false );
 
-SCCOL nDCol = pViewData-GetCurX() - aSource.aStart.Col();
-SCROW nDRow = pViewData-GetCurY() - aSource.aStart.Row();
+SCCOL nDCol = pViewData-GetCurX() - aSource.aStart.Col() 
+ nCorrectCursorPosCol;
+SCROW nDRow = pViewData-GetCurY() - aSource.aStart.Row() 
+ nCorrectCursorPosRow;
 pView-SetCursor( aDest.aStart.Col() + nDCol, 
aDest.aStart.Row() + nDRow );
 }
 
commit dd209b77391903cb6f9f04c44e10a05f31076f4a
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Fri Jul 6 02:04:21 2012 +0200

add a import test for control shapes

Change-Id: I2ac5e1bdd1c681c8ba58edded3ab1b57ac30c512

diff --git a/sc/qa/unit/data/xlsx/singlecontrol.xlsx 
b/sc/qa/unit/data/xlsx/singlecontrol.xlsx
new file mode 100644
index 000..513c05b
Binary files /dev/null and b/sc/qa/unit/data/xlsx/singlecontrol.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 62a9970..2fab37a 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -45,6 +45,12 @@
 #include dbdata.hxx
 #include validat.hxx
 
+#include com/sun/star/drawing/XDrawPageSupplier.hpp
+#include com/sun/star/drawing/XControlShape.hpp
+#include com/sun/star/sheet/XSpreadsheetDocument.hpp
+#include com/sun/star/container/XIndexAccess.hpp
+#include com/sun/star/frame/XModel.hpp
+
 #define CALC_DEBUG_OUTPUT 0
 #define TEST_BUG_FILES 0
 
@@ -127,6 +133,8 @@ public:
 void testPasswordNew();
 void testPasswordOld();
 
+//test shape import
+void testControlImport();
 
 CPPUNIT_TEST_SUITE(ScFiltersTest);
 CPPUNIT_TEST(testRangeNameXLS);
@@ -154,6 +162,7 @@ public:
 #endif
 CPPUNIT_TEST(testSharedFormulaXLSX);
 CPPUNIT_TEST(testCellValueXLSX);
+CPPUNIT_TEST(testControlImport);
 
 //disable testPassword on MacOSX due to problems with libsqlite3
 //also crashes on DragonFly due to problems with nss/nspr headers
@@ -1060,6 +1069,30 @@ void ScFiltersTest::testPasswordOld()
 testPassword_Impl(aFileNameBase);
 }
 
+void ScFiltersTest::testControlImport()
+{
+const rtl::OUString 
aFileNameBase(RTL_CONSTASCII_USTRINGPARAM(singlecontrol.));
+rtl::OUString aFileExtension(aFileFormats[XLSX].pName, 
strlen(aFileFormats[XLSX].pName), RTL_TEXTENCODING_UTF8 );
+rtl::OUString aFilterName(aFileFormats[XLSX].pFilterName, 
strlen(aFileFormats[XLSX].pFilterName), RTL_TEXTENCODING_UTF8) ;
+rtl::OUString aFileName;
+createFileURL(aFileNameBase, aFileExtension, aFileName);
+rtl::OUString aFilterType(aFileFormats[XLSX].pTypeName, 

[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-06-26 Thread Eike Rathke
 sc/qa/unit/ucalc.cxx |   32 +++
 sc/source/core/tool/interpr1.cxx |   45 ++-
 sc/source/core/tool/interpr4.cxx |8 ++
 sc/source/core/tool/parclass.cxx |   11 ++---
 4 files changed, 48 insertions(+), 48 deletions(-)

New commits:
commit d822c6afe6c1a676e9b86d67e599dbcf75512a7c
Author: Eike Rathke er...@redhat.com
Date:   Tue Jun 26 20:51:22 2012 +0200

resolved fdo#51442 N() inconsistent argument handling

5743e7b36220e9689091812cef7a4396dd48c4e6 introduced a different handling
of arguments in the N() spreadsheet function. That lost the ability to
use position dependent range intersections and suppressed every error
instead of propagating it. Previous versions suppressed only the #N/A
error. Excel propagates all errors instead.

Note that Excel for N() does not use position dependent range
intersection (SingleRef of DoubleRef) when a range reference is passed
and does not handle evaluation in array context (instead top left value
is always used), which both is inconsistent with other functions taking
a scalar value parameter. ODFF does not specify this function different.
This change re-enables range intersection and adds array evaluation.
Gnumeric does the same.

Change-Id: Ice35271e40f1a27cea384226e25945108003841a

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 1db6294..a86a3a0 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -433,25 +433,37 @@ void testFuncN(ScDocument* pDoc)
 pDoc-SetString(1, 13, 0, OUString(=N(\foo\)));
 
 // Range references
-pDoc-SetString(1, 14, 0, OUString(=N(A1:A8)));
-pDoc-SetString(1, 15, 0, OUString(=N(A4:B8)));
-pDoc-SetString(1, 16, 0, OUString(=N(A6:B8)));
-pDoc-SetString(1, 17, 0, OUString(=N(A2:B8)));
+pDoc-SetString(2, 2, 0, OUString(=N(A1:A8)));
+pDoc-SetString(2, 3, 0, OUString(=N(A1:A8)));
+pDoc-SetString(2, 4, 0, OUString(=N(A1:A8)));
+pDoc-SetString(2, 5, 0, OUString(=N(A1:A8)));
 
 // Calculate and check the results.
 pDoc-CalcAll();
-double checks[] = {
+double checks1[] = {
 0, 0,  0,1, -1, 12.3, 0, // cell reference
-0, 1, -1, 123,  0,0, 0, // in-line values
-0, 1, 12.3, 0// range references
+0, 1, -1, 123,  0,0, 0   // in-line values
 };
-for (size_t i = 0; i  SAL_N_ELEMENTS(checks); ++i)
+for (size_t i = 0; i  SAL_N_ELEMENTS(checks1); ++i)
 {
 pDoc-GetValue(1, i, 0, result);
-bool bGood = result == checks[i];
+bool bGood = result == checks1[i];
 if (!bGood)
 {
-cerr  row   (i+1)  : expected=  checks[i]   
actual=  result  endl;
+cerr  row   (i+1)  : expected=  checks1[i]   
actual=  result  endl;
+CPPUNIT_ASSERT_MESSAGE(Unexpected result for N, false);
+}
+}
+double checks2[] = {
+0, 1, -1, 12.3   // range references
+};
+for (size_t i = 0; i  SAL_N_ELEMENTS(checks2); ++i)
+{
+pDoc-GetValue(1, i+2, 0, result);
+bool bGood = result == checks2[i];
+if (!bGood)
+{
+cerr  row   (i+2+1)  : expected=  checks2[i]   
actual=  result  endl;
 CPPUNIT_ASSERT_MESSAGE(Unexpected result for N, false);
 }
 }
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 42f6457..f3090bf 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2952,40 +2952,19 @@ void ScInterpreter::ScIsOdd()
 
 void ScInterpreter::ScN()
 {
-switch (GetRawStackType())
-{
-case svSingleRef:
-case svDoubleRef:
-case svMatrix:
-case svExternalSingleRef:
-case svExternalDoubleRef:
-{
-ScMatrixRef pMat = GetMatrix();
-SCSIZE nC, nR;
-pMat-GetDimensions(nC, nR);
-if (!nC || !nR)
-PushDouble(0);
-else
-PushDouble(pMat-GetDouble(0, 0));
-return;
-}
-case svString:
-PopError();
-PushDouble(0);
-return;
-default:
-;
-}
-
-// Default action
+RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, sc, er, ScInterpreter::ScN );
+sal_uInt16 nErr = nGlobalError;
+nGlobalError = 0;
+// Temporarily override the ConvertStringToValue() error for
+// GetCellValue() / GetCellValueOrZero()
+sal_uInt16 nSErr = mnStringNoValueError;
+mnStringNoValueError = errCellNoValue;
 double fVal = GetDouble();
-if (nGlobalError)
-{
-// Don't propagate the error. Push 0 instead.
-nGlobalError = 0;
-PushDouble(0);
-return;
-}
+mnStringNoValueError = nSErr;
+if (nErr)
+nGlobalError = nErr;// preserve previous error if any
+else if (nGlobalError == 

[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2012-03-18 Thread Markus Mohrhard
 sc/qa/unit/data/ods/bug-fixes.ods  |binary
 sc/qa/unit/subsequent_filters-test.cxx |   21 ++---
 sc/source/ui/app/transobj.cxx  |   26 +-
 3 files changed, 31 insertions(+), 16 deletions(-)

New commits:
commit d58421c2cc5199e9892627b894eaab64265c82e7
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Sun Mar 18 19:20:06 2012 +0100

add test case for fdo#40426

diff --git a/sc/qa/unit/data/ods/bug-fixes.ods 
b/sc/qa/unit/data/ods/bug-fixes.ods
index 6864235..b7c0539 100644
Binary files a/sc/qa/unit/data/ods/bug-fixes.ods and 
b/sc/qa/unit/data/ods/bug-fixes.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index f5f1eaf..4aac0fc 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -41,6 +41,7 @@
 
 #include editeng/brshitem.hxx
 #include editeng/justifyitem.hxx
+#include dbdata.hxx
 
 #define CALC_DEBUG_OUTPUT 0
 #define TEST_BUG_FILES 0
@@ -483,9 +484,23 @@ void ScFiltersTest::testBugFixesODS()
 CPPUNIT_ASSERT_MESSAGE(Failed to load bugFixes.ods, xDocSh.Is());
 ScDocument* pDoc = xDocSh-GetDocument();
 
-rtl::OUString aCSVFileName;
-
createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(bugFix_Sheet2.)), 
aCSVFileName);
-testFile(aCSVFileName, pDoc, 1);
+{
+// fdo
+rtl::OUString aCSVFileName;
+
createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(bugFix_Sheet2.)), 
aCSVFileName);
+testFile(aCSVFileName, pDoc, 1);
+}
+
+{
+// fdo#40426
+ScDBData* pDBData = 
pDoc-GetDBCollection()-getNamedDBs().findByName(DBRange1);
+CPPUNIT_ASSERT(pDBData);
+CPPUNIT_ASSERT(pDBData-HasHeader());
+// no header
+pDBData = 
pDoc-GetDBCollection()-getNamedDBs().findByName(DBRange2);
+CPPUNIT_ASSERT(pDBData);
+CPPUNIT_ASSERT(!pDBData-HasHeader());
+}
 
 xDocSh-DoClose();
 }
commit 521456068d8a848e4e5a358b1ff7e8659c94a353
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Sun Mar 18 19:19:43 2012 +0100

some sal_Bool to bool in transobj.cxx

diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index cb1fa54..dbcfc54 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -150,7 +150,7 @@ ScTransferObj::ScTransferObj( ScDocument* pClipDoc, const 
TransferableObjectDesc
 SCCOL nCol2;
 SCROW nRow2;
 pDoc-GetClipStart( nCol1, nRow1 );
-pDoc-GetClipArea( nCol2, nRow2, sal_True );// real source area - 
include filtered rows
+pDoc-GetClipArea( nCol2, nRow2, true );// real source area - include 
filtered rows
 nCol2 = sal::static_int_castSCCOL( nCol2 + nCol1 );
 nRow2 = sal::static_int_castSCROW( nRow2 + nRow1 );
 
@@ -161,7 +161,7 @@ ScTransferObj::ScTransferObj( ScDocument* pClipDoc, const 
TransferableObjectDesc
 
 SCTAB nTab1=0;
 SCTAB nTab2=0;
-sal_Bool bFirst = sal_True;
+bool bFirst = true;
 for (SCTAB i=0; i pDoc-GetTableCount(); i++)
 if (pDoc-HasTable(i))
 {
@@ -260,7 +260,7 @@ void ScTransferObj::AddSupportedFormats()
 sal_Bool ScTransferObj::GetData( const datatransfer::DataFlavor rFlavor )
 {
 sal_uInt32  nFormat = SotExchange::GetFormat( rFlavor );
-sal_BoolbOK = false;
+boolbOK = false;
 
 if( HasFormat( nFormat ) )
 {
@@ -308,7 +308,7 @@ sal_Bool ScTransferObj::GetData( const 
datatransfer::DataFlavor rFlavor )
 if ( nFormat == SOT_FORMATSTR_ID_LINK )
 bUsedForLink = true;
 
-sal_Bool bIncludeFiltered = pDoc-IsCutMode() || bUsedForLink;
+bool bIncludeFiltered = pDoc-IsCutMode() || bUsedForLink;
 
 ScRange aReducedBlock = aBlock;
 if ( nFormat == SOT_FORMATSTR_ID_HTML  (aBlock.aEnd.Col() == 
MAXCOL || aBlock.aEnd.Row() == MAXROW)  aBlock.aStart.Tab() == 
aBlock.aEnd.Tab() )
@@ -481,7 +481,7 @@ sal_Bool ScTransferObj::WriteObject( SotStorageStreamRef 
rxOStm, void* pUserObj
 delete pSrcStm;
 }
 
-bRet = sal_True;
+bRet = true;
 
 xWorkStore-dispose();
 xWorkStore = uno::Reference  embed::XStorage ();
@@ -558,7 +558,7 @@ void ScTransferObj::SetDragSourceFlags( sal_uInt16 nFlags )
 
 void ScTransferObj::SetDragWasInternal()
 {
-bDragWasInternal = sal_True;
+bDragWasInternal = true;
 }
 
 void ScTransferObj::SetUseInApi( bool bSet )
@@ -610,7 +610,7 @@ void ScTransferObj::InitDocShell()
 
 ScDocument* pDestDoc = pDocSh-GetDocument();
 ScMarkData aDestMark;
-aDestMark.SelectTable( 0, sal_True );
+aDestMark.SelectTable( 0, true );
 
 pDestDoc-SetDocOptions( pDoc-GetDocOptions() );   // #i42666#
 
@@ -663,16 +663,16 @@ void ScTransferObj::InitDocShell()
 //  pDoc is always a Clipboard-document
 
 ScRange aDestRange( 

[Libreoffice-commits] .: 2 commits - sc/qa sc/source

2011-10-20 Thread Markus Mohrhard
 sc/qa/unit/ucalc.cxx  |   57 +-
 sc/source/core/data/cell2.cxx |2 -
 2 files changed, 52 insertions(+), 7 deletions(-)

New commits:
commit 16cf673187679b3f45f2623bc6e3a52bf7dbba45
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Thu Oct 20 19:16:06 2011 +0200

improve unit test for UpdateReference

check InsertTabs/InsertTab/DeleteTabs too

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 19741ed..232a62e 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -237,7 +237,7 @@ public:
 void testAutofilter();
 void testCopyPaste();
 void testMergedCells();
-void testSheetDelete();
+void testUpdateReference();
 
 /**
  * Make sure the sheet streams are invalidated properly.
@@ -282,7 +282,7 @@ public:
 CPPUNIT_TEST(testAutofilter);
 CPPUNIT_TEST(testCopyPaste);
 CPPUNIT_TEST(testMergedCells);
-CPPUNIT_TEST(testSheetDelete);
+CPPUNIT_TEST(testUpdateReference);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2312,32 +2312,77 @@ void Test::testMergedCells()
 m_pDoc-DeleteTab(0);
 }
 
-void Test::testSheetDelete()
+void Test::testUpdateReference()
 {
 //test that formulas are correctly updated during sheet delete
 //TODO: add test cases for InsertTabs/InsertTab and DeleteTabs
 //TODO: add tests for references to other sheets, relative references, 
updating of named ranges, ...
 //TODO: maybe rename then to testUpdateReference
-m_pDoc-InsertTab(0, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(Sheet1)));
-m_pDoc-InsertTab(1, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(Sheet2)));
-m_pDoc-InsertTab(2, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(Sheet3)));
+rtl::OUString aSheet1(RTL_CONSTASCII_USTRINGPARAM(Sheet1));
+rtl::OUString aSheet2(RTL_CONSTASCII_USTRINGPARAM(Sheet2));
+rtl::OUString aSheet3(RTL_CONSTASCII_USTRINGPARAM(Sheet3));
+rtl::OUString aSheet4(RTL_CONSTASCII_USTRINGPARAM(Sheet4));
+m_pDoc-InsertTab(0, aSheet1);
+m_pDoc-InsertTab(1, aSheet2);
+m_pDoc-InsertTab(2, aSheet3);
+m_pDoc-InsertTab(3, aSheet4);
 
 m_pDoc-SetValue(0,0,2, 1);
 m_pDoc-SetValue(1,0,2, 2);
+m_pDoc-SetValue(1,1,3, 4);
 m_pDoc-SetString(2,0,2, 
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(=A1+B1)));
+m_pDoc-SetString(2,1,2, 
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(=Sheet4.B2+A1)));
 
 double aValue;
 m_pDoc-GetValue(2,0,2, aValue);
 CPPUNIT_ASSERT_MESSAGE(formula does not return correct result, aValue == 
3);
+m_pDoc-GetValue(2,1,2, aValue);
+CPPUNIT_ASSERT_MESSAGE(formula does not return correct result, aValue == 
5);
 
 //test deleting both sheets: one is not directly before the sheet, the 
other one is
 m_pDoc-DeleteTab(0);
 m_pDoc-GetValue(2,0,1, aValue);
 CPPUNIT_ASSERT_MESSAGE(after deleting first sheet formula does not return 
correct result, aValue == 3);
+m_pDoc-GetValue(2,1,1, aValue);
+CPPUNIT_ASSERT_MESSAGE(after deleting first sheet formula does not return 
correct result, aValue == 5);
 
 m_pDoc-DeleteTab(0);
 m_pDoc-GetValue(2,0,0, aValue);
 CPPUNIT_ASSERT_MESSAGE(after deleting second sheet formula does not 
return correct result, aValue == 3);
+m_pDoc-GetValue(2,1,0, aValue);
+CPPUNIT_ASSERT_MESSAGE(after deleting second sheet formula does not 
return correct result, aValue == 5);
+
+//test adding two sheets
+m_pDoc-InsertTab(0, aSheet2);
+m_pDoc-GetValue(2,0,1, aValue);
+CPPUNIT_ASSERT_MESSAGE(after inserting first sheet formula does not 
return correct result, aValue == 3);
+m_pDoc-GetValue(2,1,1, aValue);
+CPPUNIT_ASSERT_MESSAGE(after inserting first sheet formula does not 
return correct result, aValue == 5);
+
+m_pDoc-InsertTab(0, aSheet1);
+m_pDoc-GetValue(2,0,2, aValue);
+CPPUNIT_ASSERT_MESSAGE(after inserting second sheet formula does not 
return correct result, aValue == 3);
+m_pDoc-GetValue(2,1,2, aValue);
+CPPUNIT_ASSERT_MESSAGE(after inserting second sheet formula does not 
return correct result, aValue == 5);
+
+m_pDoc-DeleteTabs(0, 2);
+m_pDoc-GetValue(2, 0, 0, aValue);
+CPPUNIT_ASSERT_MESSAGE(after deleting sheets formula does not return 
correct result, aValue == 3);
+m_pDoc-GetValue(2, 1, 0, aValue);
+CPPUNIT_ASSERT_MESSAGE(after deleting sheets formula does not return 
correct result, aValue == 5);
+
+std::vectorrtl::OUString aSheets;
+aSheets.push_back(aSheet1);
+aSheets.push_back(aSheet2);
+m_pDoc-InsertTabs(0, aSheets, false, true);
+m_pDoc-GetValue(2, 0, 2, aValue);
+rtl::OUString aFormula;
+m_pDoc-GetFormula(2,0,2, aFormula);
+std::cout  formel:   rtl::OUStringToOString(aFormula, 
RTL_TEXTENCODING_UTF8).getStr()  std::endl;
+std::cout  std::endl  aValue  std::endl;
+CPPUNIT_ASSERT_MESSAGE(after inserting sheets formula does not return 
correct result, aValue == 3);
+m_pDoc-GetValue(2, 1, 2, aValue);
+