[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sc/qa sc/source

2015-09-30 Thread Caolán McNamara
 sc/qa/unit/data/xls/pass/crash-1.xls |binary
 sc/source/filter/excel/xicontent.cxx |   11 ---
 2 files changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 648a60212c3429ea8b1794247bb4d5fb832e3cc5
Author: Caolán McNamara 
Date:   Wed Sep 30 17:01:23 2015 +0100

don't believe xls wrt size to reserve

(cherry picked from commit 358ca9eaa3d85236047a7a2781e38f57209c2858)

Change-Id: Id9864f199e270d13d801348b12f1e94dd80558c7
Reviewed-on: https://gerrit.libreoffice.org/19043
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 

diff --git a/sc/qa/unit/data/xls/pass/crash-1.xls 
b/sc/qa/unit/data/xls/pass/crash-1.xls
new file mode 100644
index 000..724bfc1
Binary files /dev/null and b/sc/qa/unit/data/xls/pass/crash-1.xls differ
diff --git a/sc/source/filter/excel/xicontent.cxx 
b/sc/source/filter/excel/xicontent.cxx
index 79c78ea..bb17b66 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -75,10 +75,15 @@ XclImpSst::XclImpSst( const XclImpRoot& rRoot ) :
 void XclImpSst::ReadSst( XclImpStream& rStrm )
 {
 rStrm.Ignore( 4 );
-sal_uInt32 nStrCount(0);
-rStrm >> nStrCount;
+sal_uInt32 nStrCount = rStrm.ReaduInt32();
+auto nBytesAvailable = rStrm.GetRecLeft();
+if (nStrCount > nBytesAvailable)
+{
+SAL_WARN("sc.filter", "xls claimed to have " << nStrCount << " 
strings, but only " << nBytesAvailable << " bytes available, truncating");
+nStrCount = nBytesAvailable;
+}
 maStrings.clear();
-maStrings.reserve( static_cast< size_t >( nStrCount ) );
+maStrings.reserve(nStrCount);
 while( (nStrCount > 0) && rStrm.IsValid() )
 {
 XclImpString aString;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sc/qa sc/source

2015-03-09 Thread Henry Castro
 sc/qa/unit/ucalc.cxx|   68 +++-
 sc/qa/unit/ucalc.hxx|4 ++
 sc/source/core/data/column4.cxx |2 -
 3 files changed, 72 insertions(+), 2 deletions(-)

New commits:
commit 319042492ffcdf9ab5fb78c6c46c4f381a02cfa7
Author: Henry Castro hcvcas...@gmail.com
Date:   Fri Mar 6 13:51:25 2015 -0400

Resolves tdf#80137 Paste array formula into range pastes as non-array 
formula

Reviewed-on: https://gerrit.libreoffice.org/14770
Tested-by: Jenkins c...@libreoffice.org
Reviewed-by: Andras Timar andras.ti...@collabora.com
(cherry picked from commit 097a16b59884c777f724cec6c5d42734974ed44b)
Signed-off-by: Andras Timar andras.ti...@collabora.com

Conflicts:
sc/qa/unit/ucalc.cxx
sc/qa/unit/ucalc.hxx

Change-Id: I58b32e5af07702b76afb901a3ec270453462

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index ce5efc2..db306e7 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1,4 +1,3 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /*
  * This file is part of the LibreOffice project.
  *
@@ -6203,6 +6202,73 @@ void Test::testMixData()
 m_pDoc-DeleteTab(0);
 }
 
+void Test::testCopyPasteMatrixFormula()
+{
+m_pDoc-InsertTab(0, hcv);
+
+// Set Values to B1, C1, D1
+m_pDoc-SetValue(ScAddress(1,0,0), 2.0);// B1
+m_pDoc-SetValue(ScAddress(2,0,0), 5.0);// C1
+m_pDoc-SetValue(ScAddress(3,0,0), 3.0);// D1
+
+// Set Values to B2, C2
+m_pDoc-SetString(ScAddress(1,1,0), B2);  // B2
+//m_pDoc-SetString(ScAddress(2,1,0), C2);  // C2
+m_pDoc-SetString(ScAddress(3,1,0), D2);  // D2
+
+// Set Vallues to D3
+//m_pDoc-SetValue(ScAddress(1,2,0), 9.0);// B3
+//m_pDoc-SetString(ScAddress(2,2,0), C3);  // C3
+m_pDoc-SetValue(ScAddress(3,2,0), 11.0);   // D3
+
+// Insert matrix formula to A1
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+m_pDoc-InsertMatrixFormula(0, 0, 0, 0, aMark, 
=COUNTIF(ISBLANK(B1:D1);TRUE()));
+m_pDoc-CalcAll();
+// A1 should containg 0
+CPPUNIT_ASSERT_EQUAL( 0.0, m_pDoc-GetValue(ScAddress(0,0,0)) ); // A1
+
+// Copy cell A1 to clipboard.
+ScAddress aPos(0,0,0);  // A1
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+ScClipParam aParam(aPos, false);
+m_pDoc-CopyToClip(aParam, aClipDoc, aMark);
+// Formula string should be equal.
+CPPUNIT_ASSERT_EQUAL(m_pDoc-GetString(aPos), aClipDoc.GetString(aPos));
+
+// First try single range.
+// Paste matrix formula to A2
+pasteFromClip(m_pDoc, ScRange(0,1,0,0,1,0), aClipDoc); // A2
+// A2 Cell value should contain 1.0
+CPPUNIT_ASSERT_EQUAL( 1.0, m_pDoc-GetValue(ScAddress(0,1,0)));
+
+// Paste matrix formula to A3
+pasteFromClip(m_pDoc, ScRange(0,2,0,0,2,0), aClipDoc); // A3
+// A3 Cell value should contain 2.0
+CPPUNIT_ASSERT_EQUAL( 2.0, m_pDoc-GetValue(ScAddress(0,2,0)));
+
+// Paste matrix formula to A4
+pasteFromClip(m_pDoc, ScRange(0,3,0,0,3,0), aClipDoc); // A4
+// A4 Cell value should contain 3.0
+CPPUNIT_ASSERT_EQUAL( 3.0, m_pDoc-GetValue(ScAddress(0,3,0)));
+
+// Clear cell A2:A4
+clearRange(m_pDoc, ScRange(0,1,0,0,3,0));
+
+// Paste matrix formula to range A2:A4
+pasteFromClip(m_pDoc, ScRange(0,1,0,0,3,0), aClipDoc); // A2:A4
+
+// A2 Cell value should contain 1.0
+CPPUNIT_ASSERT_EQUAL( 1.0, m_pDoc-GetValue(ScAddress(0,1,0)));
+// A3 Cell value should contain 2.0
+CPPUNIT_ASSERT_EQUAL( 2.0, m_pDoc-GetValue(ScAddress(0,2,0)));
+// A4 Cell value should contain 3.0
+CPPUNIT_ASSERT_EQUAL( 3.0, m_pDoc-GetValue(ScAddress(0,3,0)));
+
+m_pDoc-DeleteTab(0);
+}
+
 ScDocShell* Test::findLoadedDocShellByName(const OUString rName)
 {
 TypeId aType(TYPE(ScDocShell));
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 28e0e01..794482a 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -418,6 +418,9 @@ public:
 
 void testColumnFindEditCells();
 
+// tdf#80137
+void testCopyPasteMatrixFormula();
+
 CPPUNIT_TEST_SUITE(Test);
 #if CALC_TEST_PERF
 CPPUNIT_TEST(testPerf);
@@ -615,6 +618,7 @@ public:
 CPPUNIT_TEST(testFormulaToValue);
 CPPUNIT_TEST(testFormulaToValue2);
 CPPUNIT_TEST(testColumnFindEditCells);
+CPPUNIT_TEST(testCopyPasteMatrixFormula);
 CPPUNIT_TEST_SUITE_END();
 
 private:
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 19e3b14..63534c3 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -516,7 +516,7 @@ void ScColumn::CloneFormulaCell(
 xGroup-compileCode(*pDocument, aPos, pDocument-GetGrammar());
 for (size_t i = 0; i  nLen; ++i, aPos.IncRow())
 {
-ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, 
xGroup);
+ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, 
xGroup, 

[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sc/qa

2015-02-14 Thread Markus Mohrhard
 sc/qa/unit/ucalc.hxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 7d46f7a465336f32223f1226dc8093c9a6f0e7a5
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Sat Feb 14 23:28:47 2015 +0100

fix windows build

Why do we backport unit tests?

Change-Id: I052eefa4ab84db49d396d871c0b594d10f317e3c

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 9ebae4c..19b3b5f 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -454,7 +454,7 @@ public:
 CPPUNIT_TEST(testFormulaRefUpdateNameExpandRef);
 CPPUNIT_TEST(testFormulaRefUpdateNameDeleteRow);
 CPPUNIT_TEST(testFormulaRefUpdateValidity);
-CPPUNIT_TEST(testErrorOnExternalReferences);
+//CPPUNIT_TEST(testErrorOnExternalReferences);
 CPPUNIT_TEST(testMultipleOperations);
 CPPUNIT_TEST(testFuncCOLUMN);
 CPPUNIT_TEST(testFuncCOUNT);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sc/qa

2014-12-11 Thread Eike Rathke
 sc/qa/unit/ucalc.cxx |   22 ++
 sc/qa/unit/ucalc.hxx |2 ++
 2 files changed, 24 insertions(+)

New commits:
commit a6a0e8059d4996c579d47171a5b833f9b4c22975
Author: Eike Rathke er...@redhat.com
Date:   Thu Dec 11 18:51:04 2014 +0100

unit test for matrix comparison error propagation, fdo#87237

Change-Id: Id02f169b111945673a16d0c852940c805aa89319
(cherry picked from commit 6c41a1272e43a3e3b785724991837b597dbf00ef)

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 248a0e9..49027cf 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1961,6 +1961,28 @@ void Test::testMatrix()
 }
 }
 
+void Test::testMatrixComparisonWithErrors()
+{
+m_pDoc-InsertTab(0, foo);
+
+// Insert the source values in A1:A2.
+m_pDoc-SetString(0, 0, 0, =1/0);
+m_pDoc-SetValue( 0, 1, 0, 1.0);
+
+// Create a matrix formula in B3:B4 referencing A1:A2 and doing a greater
+// than comparison on it's values. Error value must be propagated.
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+m_pDoc-InsertMatrixFormula(1, 2, 1, 3, aMark, =A1:A20);
+
+CPPUNIT_ASSERT_EQUAL(OUString(#DIV/0!), m_pDoc-GetString(0,0,0));
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc-GetValue( 0,1,0));
+CPPUNIT_ASSERT_EQUAL(OUString(#DIV/0!), m_pDoc-GetString(1,2,0));
+CPPUNIT_ASSERT_EQUAL(OUString(TRUE),m_pDoc-GetString(1,3,0));
+
+m_pDoc-DeleteTab(0);
+}
+
 void Test::testEnterMixedMatrix()
 {
 m_pDoc-InsertTab(0, foo);
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 269e84e..72ecaa0 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -213,6 +213,7 @@ public:
 void testInsertNameList();
 void testCSV();
 void testMatrix();
+void testMatrixComparisonWithErrors();
 void testEnterMixedMatrix();
 void testMatrixEditable();
 
@@ -494,6 +495,7 @@ public:
 CPPUNIT_TEST(testInsertNameList);
 CPPUNIT_TEST(testCSV);
 CPPUNIT_TEST(testMatrix);
+CPPUNIT_TEST(testMatrixComparisonWithErrors);
 CPPUNIT_TEST(testEnterMixedMatrix);
 CPPUNIT_TEST(testMatrixEditable);
 CPPUNIT_TEST(testPivotTable);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sc/qa

2014-11-21 Thread Eike Rathke
 sc/qa/unit/filters-test.cxx |   27 ---
 1 file changed, 20 insertions(+), 7 deletions(-)

New commits:
commit 7feda69016fc42b889dfc5b8de088bbca36ba931
Author: Eike Rathke er...@redhat.com
Date:   Fri Nov 21 19:26:06 2014 +0100

check that sort with absolute references works in both modes

Change-Id: I7de490377fbceb17e7d678590c46d24674bd8024
(cherry picked from commit 674c7abbd6b5e9014812d4f8839f62639fe9a7f4)

diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 618fd94..1592241 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -613,22 +613,35 @@ void ScFiltersTest::testSortWithSharedFormulasODS()
 // Document contains cached external references.
 void ScFiltersTest::testSortWithSheetExternalReferencesODS()
 {
-// this test only works with UpdateReferenceOnSort == true, set it now.
-// we reset the value back to the original in tearDown()
-ScInputOptions aInputOption = SC_MOD()-GetInputOptions();
-aInputOption.SetSortRefUpdate(true);
-SC_MOD()-SetInputOptions(aInputOption);
-
 ScDocShellRef xDocSh = loadDoc(sort-with-sheet-external-references., 
ODS, true);
 CPPUNIT_ASSERT(xDocSh.Is());
 ScDocument rDoc = xDocSh-GetDocument();
 sc::AutoCalcSwitch aACSwitch(rDoc, true); // turn auto calc on.
 rDoc.CalcAll();
 
+// The relative test only works with UpdateReferenceOnSort == true, set it
+// now. We reset the value back to the original in tearDown()
+ScInputOptions aInputOption = SC_MOD()-GetInputOptions();
+aInputOption.SetSortRefUpdate(true);
+SC_MOD()-SetInputOptions(aInputOption);
+
 // Sort A15:D20 with relative row references.
 testSortWithSheetExternalReferencesODS_Impl( xDocSh, 14, 19);
 
-// Sort A23:D28 with absolute row references.
+// Sort with absolute references has to work in both UpdateReferenceOnSort
+// modes.
+
+// Sort A23:D28 with absolute row references. UpdateReferenceOnSort==true
+testSortWithSheetExternalReferencesODS_Impl( xDocSh, 22, 27);
+
+// Undo sort with absolute references to perform same sort.
+rDoc.GetUndoManager()-Undo();
+rDoc.CalcAll();
+
+aInputOption.SetSortRefUpdate(false);
+SC_MOD()-SetInputOptions(aInputOption);
+
+// Sort A23:D28 with absolute row references. UpdateReferenceOnSort==false
 testSortWithSheetExternalReferencesODS_Impl( xDocSh, 22, 27);
 
 xDocSh-DoClose();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits