[Libreoffice-commits] core.git: 2 commits - sc/qa

2013-11-14 Thread Eike Rathke
 sc/qa/unit/data/xlsx/functions-excel-2010.xlsx |binary
 sc/qa/unit/subsequent_filters-test.cxx |   17 ++---
 2 files changed, 10 insertions(+), 7 deletions(-)

New commits:
commit bcd594902c366443f0d17b7599267793ac6da204
Author: Eike Rathke 
Date:   Thu Nov 14 20:48:15 2013 +0100

added import test for CONFIDENCE.NORM and CONFIDENCE.T, fdo#71350

Change-Id: Id564e201fab17cccaa6b3e9c4353f9f7719345f9

diff --git a/sc/qa/unit/data/xlsx/functions-excel-2010.xlsx 
b/sc/qa/unit/data/xlsx/functions-excel-2010.xlsx
index 03e570e..36756ac 100755
Binary files a/sc/qa/unit/data/xlsx/functions-excel-2010.xlsx and 
b/sc/qa/unit/data/xlsx/functions-excel-2010.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 3e90a88..100684b 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -380,7 +380,7 @@ void ScFiltersTest::testFunctionsExcel2010()
 ScDocument* pDoc = xDocSh->GetDocument();
 pDoc->CalcAll(); // perform hard re-calculation.
 
-// B2:B6 and B8 should all be formula cells, and shouldn't have errors.
+// B2:B6 and B8:B10 should all be formula cells, and shouldn't have errors.
 CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without error.", 
isFormulaWithoutError(*pDoc, ScAddress(1,1,0)));
 CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without error.", 
isFormulaWithoutError(*pDoc, ScAddress(1,2,0)));
 CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without error.", 
isFormulaWithoutError(*pDoc, ScAddress(1,3,0)));
@@ -392,6 +392,9 @@ void ScFiltersTest::testFunctionsExcel2010()
 CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without error.", 
isFormulaWithoutError(*pDoc, ScAddress(1,7,0)));
 #endif
 
+CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without error.", 
isFormulaWithoutError(*pDoc, ScAddress(1,8,0)));
+CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without error.", 
isFormulaWithoutError(*pDoc, ScAddress(1,9,0)));
+
 xDocSh->DoClose();
 }
 
commit 34aa35784fc23f0da55b2134c9e6e1077638f986
Author: Eike Rathke 
Date:   Thu Nov 14 20:43:30 2013 +0100

typo

Change-Id: I407cf45bde2733e9a242cfb1cea9825488cbf828

diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index c954048..3e90a88 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -381,15 +381,15 @@ void ScFiltersTest::testFunctionsExcel2010()
 pDoc->CalcAll(); // perform hard re-calculation.
 
 // B2:B6 and B8 should all be formula cells, and shouldn't have errors.
-CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", 
isFormulaWithoutError(*pDoc, ScAddress(1,1,0)));
-CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", 
isFormulaWithoutError(*pDoc, ScAddress(1,2,0)));
-CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", 
isFormulaWithoutError(*pDoc, ScAddress(1,3,0)));
-CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", 
isFormulaWithoutError(*pDoc, ScAddress(1,4,0)));
-CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", 
isFormulaWithoutError(*pDoc, ScAddress(1,5,0)));
+CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without error.", 
isFormulaWithoutError(*pDoc, ScAddress(1,1,0)));
+CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without error.", 
isFormulaWithoutError(*pDoc, ScAddress(1,2,0)));
+CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without error.", 
isFormulaWithoutError(*pDoc, ScAddress(1,3,0)));
+CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without error.", 
isFormulaWithoutError(*pDoc, ScAddress(1,4,0)));
+CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without error.", 
isFormulaWithoutError(*pDoc, ScAddress(1,5,0)));
 // Skip B7.
 
 #if 0 //F.DIST.RT not yet supported in the core.
-CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", 
isFormulaWithoutError(*pDoc, ScAddress(1,7,0)));
+CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without error.", 
isFormulaWithoutError(*pDoc, ScAddress(1,7,0)));
 #endif
 
 xDocSh->DoClose();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa

2013-10-30 Thread Kohei Yoshida
 dev/null|binary
 sc/qa/unit/data/ods/opencl/compiler/ineq.ods|binary
 sc/qa/unit/data/ods/opencl/compiler/nested.ods  |binary
 sc/qa/unit/data/ods/opencl/compiler/string.ods  |binary
 sc/qa/unit/data/ods/opencl/math/csc.ods |binary
 sc/qa/unit/data/ods/opencl/statistical/Correl.ods   |binary
 sc/qa/unit/data/xls/opencl/financial/Accrintm.xls   |binary
 sc/qa/unit/data/xls/opencl/financial/Coupdaybs.xls  |binary
 sc/qa/unit/data/xls/opencl/financial/Coupdays.xls   |binary
 sc/qa/unit/data/xls/opencl/financial/Coupdaysnc.xls |binary
 sc/qa/unit/data/xls/opencl/financial/Cumipmt.xls|binary
 sc/qa/unit/data/xls/opencl/financial/Cumprinc.xls   |binary
 sc/qa/unit/data/xls/opencl/financial/DISC.xls   |binary
 sc/qa/unit/data/xls/opencl/financial/Dollarde.xls   |binary
 sc/qa/unit/data/xls/opencl/financial/Dollarfr.xls   |binary
 sc/qa/unit/data/xls/opencl/financial/EFFECT_ADD.xls |binary
 sc/qa/unit/data/xls/opencl/financial/Fvschedule.xls |binary
 sc/qa/unit/data/xls/opencl/financial/INTRATE.xls|binary
 sc/qa/unit/data/xls/opencl/financial/IRR.xls|binary
 sc/qa/unit/data/xls/opencl/financial/MIRR.xls   |binary
 sc/qa/unit/data/xls/opencl/financial/Nominal.xls|binary
 sc/qa/unit/data/xls/opencl/financial/PriceMat.xls   |binary
 sc/qa/unit/data/xls/opencl/financial/RATE.xls   |binary
 sc/qa/unit/data/xls/opencl/financial/RRI.xls|binary
 sc/qa/unit/data/xls/opencl/financial/Received.xls   |binary
 sc/qa/unit/data/xls/opencl/financial/SLN.xls|binary
 sc/qa/unit/data/xls/opencl/financial/SYD.xls|binary
 sc/qa/unit/data/xls/opencl/financial/TBILLEQ.xls|binary
 sc/qa/unit/data/xls/opencl/financial/TBILLPRICE.xls |binary
 sc/qa/unit/data/xls/opencl/financial/TBILLYIELD.xls |binary
 sc/qa/unit/data/xls/opencl/financial/XNPV.xls   |binary
 sc/qa/unit/data/xls/opencl/financial/YIELD.xls  |binary
 sc/qa/unit/data/xls/opencl/financial/YIELDDISC.xls  |binary
 sc/qa/unit/data/xls/opencl/financial/YIELDMAT.xls   |binary
 sc/qa/unit/data/xls/opencl/financial/general.xls|binary
 sc/qa/unit/data/xls/opencl/math/cos.xls |binary
 sc/qa/unit/data/xls/opencl/statistical/Fisher.xls   |binary
 sc/qa/unit/data/xls/opencl/statistical/FisherInv.xls|binary
 sc/qa/unit/data/xls/opencl/statistical/Gamma.xls|binary
 sc/qa/unit/data/xls/opencl/statistical/GammaLn.xls  |binary
 sc/qa/unit/data/xls/opencl/statistical/Gauss.xls|binary
 sc/qa/unit/data/xls/opencl/statistical/GeoMean.xls  |binary
 sc/qa/unit/data/xls/opencl/statistical/HarMean.xls  |binary
 sc/qa/unit/data/xls/opencl/statistical/Negbinomdist.xls |binary
 sc/qa/unit/data/xls/opencl/statistical/Pearson.xls  |binary
 sc/qa/unit/data/xls/opencl/statistical/Rsq.xls  |binary
 sc/qa/unit/opencl-test.cxx  |  188 
 47 files changed, 97 insertions(+), 91 deletions(-)

New commits:
commit 5655b8ede2a5386b9d24d266ae08172a60b04618
Author: Kohei Yoshida 
Date:   Wed Oct 30 09:12:09 2013 -0400

Lower-case directory names, and rename to just 'opencl'.

Change-Id: I412298c73586c347d88f08bad0357a8142df3f63

diff --git a/sc/qa/unit/data/ods/OpenCLTests/Compiler/ineq.ods 
b/sc/qa/unit/data/ods/opencl/compiler/ineq.ods
similarity index 100%
rename from sc/qa/unit/data/ods/OpenCLTests/Compiler/ineq.ods
rename to sc/qa/unit/data/ods/opencl/compiler/ineq.ods
diff --git a/sc/qa/unit/data/ods/OpenCLTests/Compiler/nested.ods 
b/sc/qa/unit/data/ods/opencl/compiler/nested.ods
similarity index 100%
rename from sc/qa/unit/data/ods/OpenCLTests/Compiler/nested.ods
rename to sc/qa/unit/data/ods/opencl/compiler/nested.ods
diff --git a/sc/qa/unit/data/ods/OpenCLTests/Compiler/string.ods 
b/sc/qa/unit/data/ods/opencl/compiler/string.ods
similarity index 100%
rename from sc/qa/unit/data/ods/OpenCLTests/Compiler/string.ods
rename to sc/qa/unit/data/ods/opencl/compiler/string.ods
diff --git a/sc/qa/unit/data/ods/OpenCLTests/math/csc.ods 
b/sc/qa/unit/data/ods/opencl/math/csc.ods
similarity index 100%
rename from sc/qa/unit/data/ods/OpenCLTests/math/csc.ods
rename to sc/qa/unit/data/ods/opencl/math/csc.ods
diff --git a/sc/qa/unit/data/ods/OpenCLTests/statistical/Correl.ods 
b/sc/qa/unit/data/ods/opencl/statistical/Correl.ods
similarity index 100%
rename from sc/qa/unit/data/ods/OpenCLTests/statistical/Correl.ods
rename to sc/qa/unit/data/ods/opencl/statistical/Correl.ods
diff --git a/sc/qa/unit/data/xls/OpenclCase/financial/Accrintm.xls 
b/sc/qa/unit/data/xls/opencl/financial/Accrintm.xls
similarity index 100%
rename from sc/qa/unit/data/xls/OpenclCase/financial/Accrintm.xls
rename to sc/qa/unit/data/xls/opencl/financial/Accrintm.xls
diff --git a/sc/qa/unit/data/xls/OpenclCase/financial/Coupdaybs.xls 
b/sc/qa/unit/data/xls/o

[Libreoffice-commits] core.git: 2 commits - sc/qa

2014-05-11 Thread Markus Mohrhard
 sc/qa/unit/data/contentCSV/date-time-functions.csv |   29 +
 sc/qa/unit/data/ods/date-time-functions.ods|binary
 sc/qa/unit/subsequent_filters-test.cxx |9 ++
 3 files changed, 38 insertions(+)

New commits:
commit 28c9d9898064af9269526064cdb90b6c3427c72a
Author: Markus Mohrhard 
Date:   Mon May 12 05:50:56 2014 +0200

integrate the date time tests

Change-Id: Ie1660042abf6b5512c8bcaba067181826ca61df8

diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 2b4d689..ef0428d 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -429,6 +429,15 @@ void ScFiltersTest::testFunctionsODS()
 
 createCSVPath("database-functions.", aCSVFileName);
 testFile(aCSVFileName, pDoc, 0);
+
+xDocSh->DoClose();
+
+xDocSh = loadDoc("date-time-functions.", ODS);
+CPPUNIT_ASSERT_MESSAGE("Failed to load functions.*", xDocSh.Is());
+xDocSh->DoHardRecalc(true);
+pDoc = xDocSh->GetDocument();
+createCSVPath("date-time-functions.", aCSVFileName);
+testFile(aCSVFileName, pDoc, 0, PureString);
 }
 
 void ScFiltersTest::testFunctionsExcel2010()
commit adb497a0d2261f3b1233ffd25c6cade996072567
Author: Ken Biondi 
Date:   Mon May 12 05:50:38 2014 +0200

add tests for date time functions

Change-Id: I875f6faca6c6361c581ca751be8d89ab7392c938

diff --git a/sc/qa/unit/data/contentCSV/date-time-functions.csv 
b/sc/qa/unit/data/contentCSV/date-time-functions.csv
new file mode 100644
index 000..a43bdc3
--- /dev/null
+++ b/sc/qa/unit/data/contentCSV/date-time-functions.csv
@@ -0,0 +1,29 @@
+30347
+38,1,27,457,13937,57
+19925
+30,31,1,21
+3652
+5150
+30,28,29
+366,365
+41749
+36890
+37346
+17
+1,0
+58,59,45
+4
+2,3
+17
+15
+.18
+0,0.67,0.5
+4,3,4
+1,52
+52
+10,11
+52,52
+37253
+1899,1900,1991
+0.5,0.4972677596,0.505556,0.498630137,0.5
+1,2
diff --git a/sc/qa/unit/data/ods/date-time-functions.ods 
b/sc/qa/unit/data/ods/date-time-functions.ods
new file mode 100644
index 000..9f6e044
Binary files /dev/null and b/sc/qa/unit/data/ods/date-time-functions.ods differ
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa

2014-03-31 Thread Markus Mohrhard
 sc/qa/unit/filters-test.cxx|7 +++
 sc/qa/unit/subsequent_filters-test.cxx |4 
 2 files changed, 11 insertions(+)

New commits:
commit af9cb57b0d260eeb3433ab41d61b4b776b26e87f
Author: Markus Mohrhard 
Date:   Mon Mar 31 11:00:14 2014 +0200

close files after test

Change-Id: Ibf04fa79570a2417c965e773a789827a86787471

diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 7c974c8..9d0368d 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -2423,6 +2423,8 @@ void ScFiltersTest::testPrintRangeODS()
 pRange = pDoc->GetRepeatRowRange(1);
 CPPUNIT_ASSERT(pRange);
 CPPUNIT_ASSERT_EQUAL(ScRange(0,2,0,0,4,0), *pRange);
+
+xDocSh->DoClose();
 }
 
 void ScFiltersTest::testOutlineODS()
@@ -2476,6 +2478,8 @@ void ScFiltersTest::testOutlineODS()
 bool bVisible = pEntry->IsVisible();
 CPPUNIT_ASSERT_EQUAL(aRow[i].bVisible, bVisible);
 }
+
+xDocSh->DoClose();
 }
 
 void ScFiltersTest::testColumnStyleXLSX()
commit 3d28cd4df4e951be29294c7ca5b820d711c5a7eb
Author: Markus Mohrhard 
Date:   Mon Mar 31 10:57:13 2014 +0200

close the file at the end of the test

Change-Id: I9e0636af65258646572da126e93766552fa1e1df

diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index e556d53..b6d7d76 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -438,6 +438,8 @@ void ScFiltersTest::testLegacyCellAnchoredRotatedShape()
 pDoc = xDocSh->GetDocument();
 CPPUNIT_ASSERT(pDoc);
 impl_testLegacyCellAnchoredRotatedShape( pDoc, aRect, aAnchor );
+
+xDocSh->DoClose();
 }
 {
 // This example doc contains cell anchored shape that is rotated, the
@@ -466,6 +468,7 @@ void ScFiltersTest::testLegacyCellAnchoredRotatedShape()
 // apply hefty ( 1 mm ) tolerence here, as some opensuse tinderbox
 // failing
 impl_testLegacyCellAnchoredRotatedShape( pDoc, aRect, aAnchor, 100 );
+
 xDocSh->DoClose();
 }
 {
@@ -491,6 +494,8 @@ void ScFiltersTest::testLegacyCellAnchoredRotatedShape()
 pDoc = xDocSh->GetDocument();
 CPPUNIT_ASSERT(pDoc);
 impl_testLegacyCellAnchoredRotatedShape( pDoc, aRect, aAnchor );
+
+xDocSh->DoClose();
 }
 }
 
@@ -509,6 +514,8 @@ void ScFiltersTest::testEnhancedProtectionXLS()
 CPPUNIT_ASSERT(  pProt->isBlockEditable( ScRange( 0, 1, 0, 0, 2, 0)));  // 
union of two different editables
 CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 0, 0, 0, 1, 0)));  // 
union of locked and editable
 CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 2, 0, 0, 3, 0)));  // 
union of editable and password editable
+
+xDocSh->DoClose();
 }
 
 ScFiltersTest::ScFiltersTest()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa

2014-04-08 Thread Eike Rathke
 sc/qa/unit/data/xls/enhanced-protection.xls   |binary
 sc/qa/unit/data/xlsx/enhanced-protection.xlsx |binary
 sc/qa/unit/filters-test.cxx   |   30 +-
 3 files changed, 25 insertions(+), 5 deletions(-)

New commits:
commit b0a6b164951c692cf5940d0c6e0c102603738f95
Author: Eike Rathke 
Date:   Tue Apr 8 21:14:21 2014 +0200

add .xlsx unit test for enhanced protection

Change-Id: I8a6c6295998c6545318f6b490d1f617d6178013b

diff --git a/sc/qa/unit/data/xlsx/enhanced-protection.xlsx 
b/sc/qa/unit/data/xlsx/enhanced-protection.xlsx
new file mode 100644
index 000..d9225a2
Binary files /dev/null and b/sc/qa/unit/data/xlsx/enhanced-protection.xlsx 
differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 0072412..43692b5 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -71,6 +71,7 @@ public:
 void testSharedFormulaXLSX();
 void testLegacyCellAnchoredRotatedShape();
 void testEnhancedProtectionXLS();
+void testEnhancedProtectionXLSX();
 
 CPPUNIT_TEST_SUITE(ScFiltersTest);
 CPPUNIT_TEST(testCVEs);
@@ -85,6 +86,7 @@ public:
 CPPUNIT_TEST(testSharedFormulaXLSX);
 CPPUNIT_TEST(testLegacyCellAnchoredRotatedShape);
 CPPUNIT_TEST(testEnhancedProtectionXLS);
+CPPUNIT_TEST(testEnhancedProtectionXLSX);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -499,12 +501,8 @@ void ScFiltersTest::testLegacyCellAnchoredRotatedShape()
 }
 }
 
-void ScFiltersTest::testEnhancedProtectionXLS()
+void testEnhancedProtectionImpl( ScDocument* pDoc )
 {
-ScDocShellRef xDocSh = loadDoc("enhanced-protection.", XLS);
-CPPUNIT_ASSERT(xDocSh.Is());
-ScDocument* pDoc = xDocSh->GetDocument();
-
 const ScTableProtection* pProt = pDoc->GetTabProtection(0);
 
 CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 0, 0, 0, 0, 0)));  // 
locked
@@ -516,6 +514,26 @@ void ScFiltersTest::testEnhancedProtectionXLS()
 CPPUNIT_ASSERT(  pProt->isBlockEditable( ScRange( 0, 1, 0, 0, 2, 0)));  // 
union of two different editables
 CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 0, 0, 0, 1, 0)));  // 
union of locked and editable
 CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 2, 0, 0, 3, 0)));  // 
union of editable and password editable
+}
+
+void ScFiltersTest::testEnhancedProtectionXLS()
+{
+ScDocShellRef xDocSh = loadDoc("enhanced-protection.", XLS);
+CPPUNIT_ASSERT(xDocSh.Is());
+ScDocument* pDoc = xDocSh->GetDocument();
+
+testEnhancedProtectionImpl( pDoc);
+
+xDocSh->DoClose();
+}
+
+void ScFiltersTest::testEnhancedProtectionXLSX()
+{
+ScDocShellRef xDocSh = loadDoc("enhanced-protection.", XLSX);
+CPPUNIT_ASSERT(xDocSh.Is());
+ScDocument* pDoc = xDocSh->GetDocument();
+
+testEnhancedProtectionImpl( pDoc);
 
 xDocSh->DoClose();
 }
commit 6d658afd403d40071206f7e83cd7bd68d826a65b
Author: Eike Rathke 
Date:   Tue Apr 8 21:09:13 2014 +0200

add non-editable test for descriptor

Change-Id: I0a40e9e26e09e970023a749b7fd0a67ac29d1bc1

diff --git a/sc/qa/unit/data/xls/enhanced-protection.xls 
b/sc/qa/unit/data/xls/enhanced-protection.xls
index 00cc6e6..26e2327 100644
Binary files a/sc/qa/unit/data/xls/enhanced-protection.xls and 
b/sc/qa/unit/data/xls/enhanced-protection.xls differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index b6d7d76..0072412 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -511,6 +511,8 @@ void ScFiltersTest::testEnhancedProtectionXLS()
 CPPUNIT_ASSERT(  pProt->isBlockEditable( ScRange( 0, 1, 0, 0, 1, 0)));  // 
editable without password
 CPPUNIT_ASSERT(  pProt->isBlockEditable( ScRange( 0, 2, 0, 0, 2, 0)));  // 
editable without password
 CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 3, 0, 0, 3, 0)));  // 
editable with password "foo"
+CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 4, 0, 0, 4, 0)));  // 
editable with descriptor
+CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 5, 0, 0, 5, 0)));  // 
editable with descriptor and password "foo"
 CPPUNIT_ASSERT(  pProt->isBlockEditable( ScRange( 0, 1, 0, 0, 2, 0)));  // 
union of two different editables
 CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 0, 0, 0, 1, 0)));  // 
union of locked and editable
 CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 2, 0, 0, 3, 0)));  // 
union of editable and password editable
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa

2014-03-04 Thread Markus Mohrhard
 sc/qa/unit/data/contentCSV/financial-functions.csv |   55 +
 sc/qa/unit/data/ods/functions.ods  |binary
 sc/qa/unit/helper/csv_handler.hxx  |2 
 sc/qa/unit/subsequent_filters-test.cxx |3 +
 4 files changed, 59 insertions(+), 1 deletion(-)

New commits:
commit 8c443f5c03d5202a7ef0c2738a21c74c36ef06a2
Author: Markus Mohrhard 
Date:   Wed Mar 5 08:10:33 2014 +0100

integrate the financial-functions test

Change-Id: I1d7ccbf4ceb3e825737a6c0af228767dc3fbce2d

diff --git a/sc/qa/unit/helper/csv_handler.hxx 
b/sc/qa/unit/helper/csv_handler.hxx
index 1223ef6..fc2e011 100644
--- a/sc/qa/unit/helper/csv_handler.hxx
+++ b/sc/qa/unit/helper/csv_handler.hxx
@@ -167,7 +167,7 @@ public:
 std::cout << "CSVValue: " << nValue << std::endl;
 std::cout << "result: " << (int)(aValue == nValue) << 
std::endl;
 #endif //DEBUG_CSV_HANDLER
-CPPUNIT_ASSERT_MESSAGE(createErrorMessage(mnCol, mnRow, mnTab, 
nValue, aValue).getStr(), aValue == nValue);
+CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(createErrorMessage(mnCol, 
mnRow, mnTab, nValue, aValue).getStr(), nValue, aValue, 1e-10);
 }
 }
 ++mnCol;
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 4df450c..636b864 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -402,6 +402,9 @@ void ScFiltersTest::testFunctionsODS()
 // statistical functions
 createCSVPath(OUString("statistical-functions."), aCSVFileName);
 testFile(aCSVFileName, pDoc, 5);
+// financial functions
+createCSVPath("financial-functions.", aCSVFileName);
+testFile(aCSVFileName, pDoc, 6);
 
 xDocSh->DoClose();
 }
commit 35f39285991043a70f65c796c38624c9c51ec4b1
Author: Ken Biondi 
Date:   Wed Mar 5 08:16:01 2014 +0100

add import test for financial functions

Change-Id: Idda4de746db0c959ad31a6937a4aee877417e436

diff --git a/sc/qa/unit/data/contentCSV/financial-functions.csv 
b/sc/qa/unit/data/contentCSV/financial-functions.csv
new file mode 100644
index 000..814df6b
--- /dev/null
+++ b/sc/qa/unit/data/contentCSV/financial-functions.csv
@@ -0,0 +1,55 @@
+16.9
+20.5479452054794
+930
+375
+71
+92
+110
+37026
+2
+2
+-57.5412415342252
+-11135.2321307508,-937.5
+-3669.73551569782
+-934.107123420898,-68.2782711809783
+1075
+1721.80586824866
+0.0372448979591837
+1.125,1.125
+1.02,1.1
+79.4907946994012
+5.99195013802694
+0.0535426673707582
+0.10112312546402
+-4234
+1124.76
+0.0812374805252615
+-352.973422514773
+0.113321028236252
+-300
+4.02068710841898
+0.941647376706893
+0.127303166959042
+0.052500319868356
+-12.0207780851554
+49.432121038173
+99.8782860147214
+99.8782860147214
+0.0448731663302424
+-715.955334437392
+-350.992937038239
+95.0428743993921
+99.79583
+99.984498875557
+-35019.3680845542
+0.00770147248823279
+1014.42026586264
+0.074569931823542
+553.571428571429
+1.33
+0.094151493565943
+98.45
+0.0914169629253423
+8603.80245372397
+0.194818475056105
+332.570918796713
diff --git a/sc/qa/unit/data/ods/functions.ods 
b/sc/qa/unit/data/ods/functions.ods
index 9a1cb46..97d3b16 100644
Binary files a/sc/qa/unit/data/ods/functions.ods and 
b/sc/qa/unit/data/ods/functions.ods differ
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 2 commits - sc/qa

2013-05-21 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx |  152 ---
 1 file changed, 73 insertions(+), 79 deletions(-)

New commits:
commit df4d6b134bfe45e380416f0d9eecb482843e8a47
Author: Kohei Yoshida 
Date:   Tue May 21 20:48:42 2013 -0400

Disable the perf test for dbgutil build.

Change-Id: Ifd95ea4f88175b9010f93a4a064be5d908b2a224

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 8248419..c48d310 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -283,7 +283,9 @@ public:
 void testCondFormatINSDEL();
 
 CPPUNIT_TEST_SUITE(Test);
+#ifndef DBG_UTIL
 CPPUNIT_TEST(testPerf);
+#endif
 CPPUNIT_TEST(testCollator);
 CPPUNIT_TEST(testRangeList);
 CPPUNIT_TEST(testInput);
commit 7141c7517db5bbb9814308aa4c68bc95beb4de8c
Author: Michael Meeks 
Date:   Tue May 21 16:27:09 2013 +0100

make calc tests use some sort of pseudo-cycle measurement

Change-Id: I9f58a7b00a6e4441c08254ef99829fab805beef8

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 59201d4..8248419 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -445,11 +445,20 @@ public:
 class MeasureTimeSwitch
 {
 double& mrDiff;
+double mnScale;
 TimeValue maTimeBefore;
 public:
 MeasureTimeSwitch(double& rDiff) : mrDiff(rDiff)
 {
 mrDiff = .0;
+mnScale = 1.0;
+osl_getSystemTime(&maTimeBefore);
+}
+// Scaled pseudo-time
+MeasureTimeSwitch(double& rDiff, const double nScale ) : mrDiff(rDiff)
+{
+mrDiff = .0;
+mnScale = nScale;
 osl_getSystemTime(&maTimeBefore);
 }
 
@@ -457,7 +466,7 @@ public:
 {
 TimeValue aTimeAfter;
 osl_getSystemTime(&aTimeAfter);
-mrDiff = getTimeDiff(aTimeAfter, maTimeBefore);
+mrDiff = getTimeDiff(aTimeAfter, maTimeBefore) / mnScale;
 }
 };
 
@@ -486,25 +495,58 @@ void Test::tearDown()
 BootstrapFixture::tearDown();
 }
 
+#define PERF_ASSERT(df,time,message) \
+do { \
+if ((df) >= (time)) \
+{ \
+std::ostringstream os; \
+os << message << " took " << diff << " psuedo-cycles, expected: " 
<< time; \
+/* debugging - fprintf (stderr, "'%s'\n", os.str().c_str()); */ \
+CPPUNIT_FAIL(os.str().c_str()); \
+} \
+} while (0)
+
 void Test::testPerf()
 {
 CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, 
"foo"));
 
-double diff = .0;
+// First do a set of simple operations to try to work out
+// how fast (or not) this particular machine is:
+double scale;
+{
+MeasureTimeSwitch aTime(scale);
+for (int i = 0; i < 1000; ++i)
+{
+// Bang on the allocator
+volatile ScRange *pRange = new ScRange (ScAddress (0,0,0));
+// Calc does quite a bit of string conversion
+volatile double it = OUString::number ((double)i/253.0).toDouble();
+// Do we have floating point math ?
+volatile double another = rtl::math::sin (it);
+(void)another;
+delete pRange;
+}
+}
+printf("CPU scale factor %g\n", scale);
+
+// FIXME: we should check if this already took too long
+// and if so not run the perf. tests to have pity on some
+// slow ARM machines - I think.
+
+// to make the numbers more round and helpful,
+// but the calculation of scale reasonably precise.
+scale /= 10.0;
+
+double diff;
 
 // Clearing an already empty sheet should finish in a fraction of a
 // second.  Flag failure if it takes more than one second.  Clearing 100
 // columns should be large enough to flag if something goes wrong.
 {
-MeasureTimeSwitch aTime(diff);
+MeasureTimeSwitch aTime(diff, scale);
 clearRange(m_pDoc, ScRange(0,0,0,99,MAXROW,0));
 }
-if (diff >= 1.0)
-{
-std::ostringstream os;
-os << "Clearing an empty sheet took " << diff << " seconds. It should 
be instant.";
-CPPUNIT_FAIL(os.str().c_str());
-}
+PERF_ASSERT(diff, 1.0, "Clearing an empty sheet");
 
 {
 // Switch to R1C1 to make it easier to input relative references in 
multiple cells.
@@ -519,15 +561,10 @@ void Test::testPerf()
 // Now, Delete B2:B10. This should complete in a fraction of a 
second
 // (0.06 sec on my machine).
 {
-MeasureTimeSwitch aTime(diff);
+MeasureTimeSwitch aTime(diff, scale);
 clearRange(m_pDoc, ScRange(1,1,0,1,9,0));
 }
-if (diff >= 1.0)
-{
-std::ostringstream os;
-os << "Removal of a large array of formula cells took " << diff << 
" seconds. It should be instant.";
-CPPUNIT_FAIL(os.str().c_str());
-}
+PERF_ASSERT(diff, 2000, "Removal of a large array of formula cells");
 }
 
 clearRange(m_pDoc, ScRange(0,0,0,1,MAXROW

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

2013-07-26 Thread Noel Power
 sc/qa/unit/data/ods/fdo62729.ods  |binary
 sc/qa/unit/subsequent_export-test.cxx |   30 ++
 sc/source/filter/xml/xmlexprt.cxx |1 +
 3 files changed, 31 insertions(+)

New commits:
commit 7b3d8e0a7dcf6ae05e1de5c33ed382822cf52cce
Author: Noel Power 
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);
 CPPUNIT_TEST(testColorScaleExportXLSX);
 CPPUNIT_TEST(testMiscRowHeightExport);
+CPPUNIT_TEST(testNamedRangeBugfdo62729);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -289,6 +291,34 @@ void ScExportTest::testMiscRowHeightExport()
 miscRowHeightsTest( aTestValues, SAL_N_ELEMENTS(aTestValues) );
 }
 
+
+void ScExportTest::testNamedRangeBugfdo62729()
+{
+ScDocShellRef xShell = loadDoc("fdo62729.", ODS);
+CPPUNIT_ASSERT(xShell.Is());
+ScDocument* pDoc = xShell->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+
+ScRangeName* pNames = pDoc->GetRangeName();
+//should be just a single named range
+CPPUNIT_ASSERT(pNames->size() == 1 );
+pDoc->DeleteTab(0);
+//should be still a single named range
+CPPUNIT_ASSERT(pNames->size() == 1 );
+ScDocShellRef xDocSh = saveAndReload(xShell, ODS);
+xShell->DoClose();
+
+CPPUNIT_ASSERT(xDocSh.Is());
+pDoc = xDocSh->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+
+pNames = pDoc->GetRangeName();
+//after reload should still have a named range
+CPPUNIT_ASSERT(pNames->size() == 1 );
+
+xDocSh->DoClose();
+}
+
 ScExportTest::ScExportTest()
   : ScBootstrapFixture("/sc/qa/unit/data")
 {
commit b5fffdb8d0438a2fe933a5742d41fe50a14b71f3
Author: Noel Power 
Date:   Fri Jul 26 11:25:51 2013 +0100

fix for fdo#62729 reference pos can point to non existing table

there is an existing function ( called at least from uno names api also )
that updates the tab pos, calling that seems to fix this problem

Change-Id: I6f6f31895eda9c338eeabd3f3285bf2c9eb23b7e

diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 1943238..23fd580 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3727,6 +3727,7 @@ void ScXMLExport::WriteNamedRange(ScRangeName* pRangeName)
 AddAttribute(sAttrName, it->second->GetName());
 
 OUString sBaseCellAddress;
+it->second->ValidateTabRefs();
 ScRangeStringConverter::GetStringFromAddress( sBaseCellAddress, 
it->second->GetPos(), pDoc,
 FormulaGrammar::CONV_OOO, ' ', false, SCA_ABS_3D);
 AddAttribute(XML_NAMESPACE_TABLE, XML_BASE_CELL_ADDRESS, 
sBaseCellAddress);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2013-07-31 Thread Kohei Yoshida
 sc/qa/extras/macros-test.cxx  |2 --
 sc/qa/unit/ucalc_formula.cxx  |   18 ++
 sc/source/core/tool/token.cxx |   38 ++
 3 files changed, 52 insertions(+), 6 deletions(-)

New commits:
commit 3bade6b47973a228723b240b9410f15891487812
Author: Kohei Yoshida 
Date:   Wed Jul 31 21:10:50 2013 -0400

Fix reference update on range references in named expressions.

This fixes the macro test failure.

Change-Id: I8dd49d1faf36cc37212895c21023a4ab6135

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index 9bc3a0f..023f627 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -198,12 +198,10 @@ void ScMacrosTest::testVba()
 OUString("Shapes."),
 
OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
 },
-#if 0 // TODO : fix this
 {
 OUString("Ranges."),
 
OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
 },
-#endif
 {
 OUString("CheckOptionToggleValue."),
 
OUString("vnd.sun.Star.script:VBAProject.testMacros.test?language=Basic&location=document")
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 83094d2..4703cde 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2598,6 +2598,20 @@ bool adjustSingleRefInName(
 return bChanged;
 }
 
+bool adjustDoubleRefInName(
+ScComplexRefData& rRef, const sc::RefUpdateContext& rCxt, const ScAddress& 
rPos )
+{
+bool bRefChanged = false;
+
+if (adjustSingleRefInName(rRef.Ref1, rCxt, rPos))
+bRefChanged = true;
+
+if (adjustSingleRefInName(rRef.Ref2, rCxt, rPos))
+bRefChanged = true;
+
+return bRefChanged;
+}
+
 }
 
 sc::RefUpdateResult ScTokenArray::AdjustReferenceInName(
@@ -2623,10 +2637,26 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceInName(
 {
 ScToken* pToken = static_cast(*p);
 ScComplexRefData& rRef = pToken->GetDoubleRef();
-if (adjustSingleRefInName(rRef.Ref1, rCxt, rPos))
-aRes.mbReferenceModified = true;
-if (adjustSingleRefInName(rRef.Ref2, rCxt, rPos))
-aRes.mbReferenceModified = true;
+ScRange aAbs = rRef.toAbs(rPos);
+if (rCxt.maRange.In(aAbs))
+{
+// This range is entirely within the shifted region.
+if (adjustDoubleRefInName(rRef, rCxt, rPos))
+aRes.mbReferenceModified = true;
+}
+else if (rCxt.maRange.Intersects(aAbs))
+{
+if (rCxt.mnColDelta && rCxt.maRange.aStart.Row() <= 
aAbs.aStart.Row() && aAbs.aEnd.Row() <= rCxt.maRange.aEnd.Row())
+{
+if (adjustDoubleRefInName(rRef, rCxt, rPos))
+aRes.mbReferenceModified = true;
+}
+if (rCxt.mnRowDelta && rCxt.maRange.aStart.Col() <= 
aAbs.aStart.Col() && aAbs.aEnd.Col() <= rCxt.maRange.aEnd.Col())
+{
+if (adjustDoubleRefInName(rRef, rCxt, rPos))
+aRes.mbReferenceModified = true;
+}
+}
 }
 break;
 default:
commit 10dfaebc6cc2191745d4d7323596bb8e22c9d029
Author: Kohei Yoshida 
Date:   Wed Jul 31 19:19:41 2013 -0400

Add test on updating references in named range.

This currently fails.

Change-Id: Ibb2b9e4430c97479d068d94d233f04f60b255966

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index f731f2a..e85c01c55 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1064,6 +1064,24 @@ void Test::testFormulaRefUpdateNamedExpression()
 CPPUNIT_ASSERT_EQUAL(34.0, m_pDoc->GetValue(ScAddress(2,7,0)));
 #endif
 
+// Clear all and start over.
+clearRange(m_pDoc, ScRange(0,0,0,100,100,0));
+pGlobalNames->clear();
+
+pName = new ScRangeData(
+m_pDoc, "MyRange", "$B$1:$C$6", ScAddress(0,0,0), RT_NAME, 
formula::FormulaGrammar::GRAM_NATIVE);
+bInserted = pGlobalNames->insert(pName);
+CPPUNIT_ASSERT_MESSAGE("Failed to insert a new name.", bInserted);
+pName->GetSymbol(aExpr);
+CPPUNIT_ASSERT_EQUAL(OUString("$B$1:$C$6"), aExpr);
+
+// Insert range of cells to shift right. The range partially overlaps the 
named range.
+m_pDoc->InsertCol(ScRange(2,4,0,3,8,0));
+
+// This should not alter the range.
+pName->GetSymbol(aExpr);
+CPPUNIT_ASSERT_EQUAL(OUString("$B$1:$C$6"), aExpr);
+
 m_pDoc->DeleteTab(0);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedes

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

2013-12-01 Thread Markus Mohrhard
 sc/qa/unit/ucalc.cxx   |   35 +++
 sc/qa/unit/ucalc.hxx   |1 +
 sc/source/core/data/table2.cxx |2 +-
 3 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit a14cfd3d77104aee3e3c3d981a135161295197df
Author: Markus Mohrhard 
Date:   Mon Dec 2 07:37:15 2013 +0100

add test for fdo#72149

Change-Id: I303bbfe14c258f45985a6ed7a4130d1d0fe2dcd8

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 809b4c6..2fc7702 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4678,6 +4678,41 @@ void Test::testCondFormatInsertRow()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testCondCopyPaste()
+{
+m_pDoc->InsertTab(0, "Test");
+
+ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+ScRange aCondFormatRange(0,0,0,3,3,0);
+ScRangeList aRangeList(aCondFormatRange);
+pFormat->AddRange(aRangeList);
+
+ScCondFormatEntry* pEntry = new 
ScCondFormatEntry(SC_COND_DIRECT,"=B2","",m_pDoc,ScAddress(0,0,0),ScGlobal::GetRscString(STR_STYLENAME_RESULT));
+pFormat->AddEntry(pEntry);
+sal_uLong nIndex = m_pDoc->AddCondFormat(pFormat, 0);
+
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+copyToClip(m_pDoc, aCondFormatRange, &aClipDoc);
+
+ScRange aTargetRange(4,4,0,7,7,0);
+pasteFromClip(m_pDoc, aTargetRange, &aClipDoc);
+
+ScConditionalFormat* pPastedFormat = m_pDoc->GetCondFormat(7,7,0);
+CPPUNIT_ASSERT(pPastedFormat);
+
+CPPUNIT_ASSERT_EQUAL(ScRangeList(aTargetRange), pPastedFormat->GetRange());
+CPPUNIT_ASSERT( nIndex != pPastedFormat->GetKey());
+const SfxPoolItem* pItem = m_pDoc->GetAttr( 7, 7, 0, ATTR_CONDITIONAL );
+const ScCondFormatItem* pCondFormatItem = static_cast(pItem);
+
+CPPUNIT_ASSERT(pCondFormatItem);
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
pCondFormatItem->GetCondFormatData().size());
+CPPUNIT_ASSERT( nIndex != pCondFormatItem->GetCondFormatData().at(0) );
+
+
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testMixData()
 {
 m_pDoc->InsertTab(0, "Test");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 1298e73..6538efc 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -285,6 +285,7 @@ public:
 void testCondFormatINSDEL();
 void testCondFormatInsertRow();
 void testCondFormatInsertCol();
+void testCondCopyPaste();
 
 CPPUNIT_TEST_SUITE(Test);
 #if CALC_TEST_PERF
commit 7c2936757ca10ccb692b05e6564783313f3576d1
Author: Markus Mohrhard 
Date:   Mon Dec 2 06:05:19 2013 +0100

we want to delete anytime that attribs are overwritten, fdo#72149

Change-Id: I1ed50e6daf5b363c46e31d1a0efacf7728621b1a

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index d7fca4f..30771ab 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -662,7 +662,7 @@ void ScTable::CopyFromClip(
 for ( SCCOL i = nCol1; i <= nCol2; i++)
 aCol[i].CopyFromClip(rCxt, nRow1, nRow2, nDy, pTable->aCol[i - 
nDx]); // notes are handles at column level
 
-if (rCxt.getInsertFlag() == IDF_ATTRIB)
+if (rCxt.getInsertFlag() & IDF_ATTRIB)
 {
 // make sure that there are no old references to the cond formats
 sal_uInt16 nWhichArray[2];
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2013-12-25 Thread Markus Mohrhard
 sc/qa/unit/data/contentCSV/statistical-functions.csv |1 +
 sc/qa/unit/data/ods/functions.ods|binary
 sc/qa/unit/subsequent_filters-test.cxx   |3 +++
 sc/source/core/tool/interpr6.cxx |2 +-
 4 files changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 68cd5c4fa1b6190907ef4a121bac5d5eff0c13ec
Author: Markus Mohrhard 
Date:   Thu Dec 26 00:09:45 2013 +0100

add test case for fdo#72999

Change-Id: I256e0cb228edb85b402e6645fd40f24b7ccf234a

diff --git a/sc/qa/unit/data/contentCSV/statistical-functions.csv 
b/sc/qa/unit/data/contentCSV/statistical-functions.csv
new file mode 100644
index 000..e4e9574
--- /dev/null
+++ b/sc/qa/unit/data/contentCSV/statistical-functions.csv
@@ -0,0 +1 @@
+1,1,2,0,3,3
diff --git a/sc/qa/unit/data/ods/functions.ods 
b/sc/qa/unit/data/ods/functions.ods
index c3e2a34..9a1cb46 100644
Binary files a/sc/qa/unit/data/ods/functions.ods and 
b/sc/qa/unit/data/ods/functions.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index c036318..747fd66 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -373,6 +373,9 @@ void ScFiltersTest::testFunctionsODS()
 // text functions
 createCSVPath(OUString("text-functions."), aCSVFileName);
 testFile(aCSVFileName, pDoc, 4);
+// statistical functions
+createCSVPath(OUString("statistical-functions."), aCSVFileName);
+testFile(aCSVFileName, pDoc, 5);
 
 xDocSh->DoClose();
 }
commit 5bb8a2868316a644646857047be032c17787cac5
Author: Markus Mohrhard 
Date:   Wed Dec 25 23:50:40 2013 +0100

fix handling of range parameters in COUNT, fdo#72999

Change-Id: I352c6b415f0990890702fa21175c196d7f4b12ee

diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 8999e04..f404561 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -973,7 +973,7 @@ void ScInterpreter::ScCount()
 
 FuncCount aAction;
 aSet.executeColumnAction(*pDok, aAction);
-nCount = aAction.getCount();
+nCount += aAction.getCount();
 
 // Get the number format of the last iterated cell.
 nFuncFmtIndex = aAction.getNumberFormat();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2013-11-03 Thread xinjiang
 sc/qa/unit/data/xls/opencl/financial/ISPMT.xls |binary
 sc/qa/unit/opencl-test.cxx |   24 +
 sc/source/core/opencl/formulagroupcl.cxx   |3 +
 sc/source/core/opencl/op_financial.cxx |   45 +
 sc/source/core/opencl/op_financial.hxx |   11 ++
 sc/source/core/tool/token.cxx  |1 
 6 files changed, 84 insertions(+)

New commits:
commit 1c239f51064e30713ac87abd3697d73bc5e5bcc1
Author: xinjiang 
Date:   Mon Nov 4 10:40:51 2013 +0800

GPU Calc: implemented ISPMT in GPU calc

AMLOEXT-99 FIX

Change-Id: I8cd9f130c190e6925873a00579cb7c334201f418
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index d4dada6..9610a4a 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1013,6 +1013,9 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 case ocCosecant:
 mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new 
OpCsc));
 break;
+case ocISPMT:
+mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new 
OpISPMT));
+break;
 case ocExternal:
 if ( !(pChild->GetExternal().compareTo(OUString(
 "com.sun.star.sheet.addin.Analysis.getEffect"
diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index 329dd77..503087b 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -487,6 +487,51 @@ void OpINTRATE::GenSlidingWindowFunction(
 ss << "}";
 }
 
+void OpISPMT::GenSlidingWindowFunction(std::stringstream& ss,
+const std::string sSymName, SubArguments& vSubArguments)
+{
+ss << "\ndouble " << sSymName;
+ss << "_"<< BinFuncName() <<"(";
+for (unsigned i = 0; i < vSubArguments.size(); i++)
+{
+if (i)
+ss << ",";
+vSubArguments[i]->GenSlidingWindowDecl(ss);
+}
+ss << ") {\n";
+ss << "double tmp = " << GetBottom() << ";\n";
+ss << "int gid0 = get_global_id(0);\n";
+ss << "double arg0 = " << GetBottom() << ";\n";
+ss << "double arg1 = " << GetBottom() << ";\n";
+ss << "double arg2 = " << GetBottom() << ";\n";
+ss << "double arg3 = " << GetBottom() << ";\n";
+unsigned i = vSubArguments.size();
+while (i--)
+{
+FormulaToken* pCur = vSubArguments[i]->GetFormulaToken();
+assert(pCur);
+if(pCur->GetType() == formula::svSingleVectorRef)
+{
+#ifdef  ISNAN
+const formula::SingleVectorRefToken* pSVR =
+dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+ss << "if(gid0 >= " << pSVR->GetArrayLength() << " || isNan(";
+ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ss << "))\n";
+ss << "arg" << i << " = " <
Date:   Mon Nov 4 10:36:28 2013 +0800

GPU Calc: unit test cases for ISPMT in GPU calc

AMLOEXT-99 BUG

Change-Id: I4388b184b23cf616dacfb20c61d2295765925ede
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/qa/unit/data/xls/opencl/financial/ISPMT.xls 
b/sc/qa/unit/data/xls/opencl/financial/ISPMT.xls
new file mode 100644
index 000..8759e7e
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/financial/ISPMT.xls 
differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index c8cf326..dd626cd 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -118,6 +118,7 @@ public:
 void testFinacialYIELDMATFormula();
 void testFinacialPMTFormula();
 void testFinacialPPMTFormula();
+void testFinancialISPMTFormula();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -167,6 +168,7 @@ public:
 CPPUNIT_TEST(testFinacialYIELDMATFormula);
 CPPUNIT_TEST(testFinacialPPMTFormula);
 CPPUNIT_TEST(testFinacialPMTFormula);
+CPPUNIT_TEST(testFinancialISPMTFormula);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1258,6 +1260,28 @@ void ScOpenclTest::testFinacialXNPVFormula()
 xDocSh->DoClose();
 xDocShRes->DoClose();
 }
+//[AMLOEXT-99]
+void ScOpenclTest:: testFinancialISPMTFormula()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc("opencl/financial/ISPMT.", XLS);
+ScDocument* pDoc = xDocSh->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+enableOpenCL();
+pDoc->CalcAll();
+ScDocShellRef xDocShRes = loadDoc("opencl/financial/ISPMT.", XLS);
+ScDocument* pDocRes = xDocShRes->GetDocument();
+CPPUNIT_ASSERT(pDocRes);
+for (SCROW i = 0; i <= 9; ++i)
+

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

2013-11-03 Thread xinjiang
 sc/qa/unit/data/ods/opencl/financial/Duration.ods |binary
 sc/qa/unit/opencl-test.cxx|   24 
 sc/source/core/opencl/formulagroupcl.cxx  |4 ++
 sc/source/core/opencl/op_financial.cxx|   42 ++
 sc/source/core/opencl/op_financial.hxx|   12 ++
 sc/source/core/tool/token.cxx |1 
 6 files changed, 83 insertions(+)

New commits:
commit 0644c59f1e2822c687ef0366f6c02b3b21a3f01a
Author: xinjiang 
Date:   Mon Nov 4 11:18:04 2013 +0800

GPU Calc: implemented DURATION

AMLOEXT-111 FIX

Change-Id: I114e5b20326657f7fd3e0de7162a8ae190059b2a
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index ce3223e..24647bf 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1016,6 +1016,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 case ocISPMT:
 mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new 
OpISPMT));
 break;
+case ocLaufz:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpDuration));
+break;
 case ocExternal:
 if ( !(pChild->GetExternal().compareTo(OUString(
 "com.sun.star.sheet.addin.Analysis.getEffect"
diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index f9f1fa6..a40a113 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -531,6 +531,48 @@ void OpISPMT::GenSlidingWindowFunction(std::stringstream& 
ss,
 ss << "}";
 }
 
+void OpDuration::GenSlidingWindowFunction(std::stringstream& ss,
+const std::string sSymName, SubArguments& vSubArguments)
+{
+ss << "\ndouble " << sSymName;
+ss << "_"<< BinFuncName() <<"(";
+for (unsigned i = 0; i < vSubArguments.size(); i++)
+{
+if (i)
+ss << ",";
+vSubArguments[i]->GenSlidingWindowDecl(ss);
+}
+ss << ") {\n";
+ss << "double tmp = " << GetBottom() << ";\n";
+ss << "int gid0 = get_global_id(0);\n";
+ss << "double arg0 = " << GetBottom() << ";\n";
+ss << "double arg1 = " << GetBottom() << ";\n";
+ss << "double arg2 = " << GetBottom() << ";\n";
+unsigned i = vSubArguments.size();
+while (i--)
+{
+FormulaToken* pCur = vSubArguments[i]->GetFormulaToken();
+assert(pCur);
+if(pCur->GetType() == formula::svSingleVectorRef)
+{
+#ifdef  ISNAN
+const formula::SingleVectorRefToken* pSVR =
+dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+ss << "if(gid0 >= " << pSVR->GetArrayLength() << " || isNan(";
+ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ss << "))\n";
+ss << "arg" << i << " = " <
Date:   Mon Nov 4 11:12:17 2013 +0800

GPU Calc: unit test cases for DURATION

AMLOEXT-111 BUG

Change-Id: I1d206b0eda0dca8254f0491399d0a4679eb39ef8
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/qa/unit/data/ods/opencl/financial/Duration.ods 
b/sc/qa/unit/data/ods/opencl/financial/Duration.ods
new file mode 100644
index 000..d884dfe
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/financial/Duration.ods 
differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 7264c7e..0d228d5 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -120,6 +120,7 @@ public:
 void testFinacialPPMTFormula();
 void testFinancialISPMTFormula();
 void testFinacialPriceFormula();
+void testFinancialDurationFormula();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -171,6 +172,7 @@ public:
 CPPUNIT_TEST(testFinacialPMTFormula);
 CPPUNIT_TEST(testFinancialISPMTFormula);
 CPPUNIT_TEST(testFinacialPriceFormula);
+CPPUNIT_TEST(testFinancialDurationFormula);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1608,6 +1610,28 @@ void ScOpenclTest:: testFinacialPMTFormula()
 xDocSh->DoClose();
 xDocShRes->DoClose();
 }
+//[AMLOEXT-111]
+void ScOpenclTest:: testFinancialDurationFormula()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc("opencl/financial/Duration.", ODS);
+ScDocument* pDoc = xDocSh->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+enableOpenCL();
+pDoc->CalcAll();
+ScDocShellRef xDocShRes = loadDoc("opencl/financial/Duration.", ODS);
+ScDocument* pDocRes = xDocShRes->GetDocument();
+CPPUNIT_ASSERT(pDocRes);
+for (SCROW i = 0; 

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

2013-11-03 Thread minwang
 sc/qa/unit/data/xls/opencl/financial/Coupnum.xls |binary
 sc/qa/unit/opencl-test.cxx   |   25 +
 sc/source/core/opencl/formulagroupcl.cxx |6 +
 sc/source/core/opencl/op_financial.cxx   |   97 ++-
 sc/source/core/opencl/op_financial.hxx   |9 ++
 5 files changed, 136 insertions(+), 1 deletion(-)

New commits:
commit 457b349edbaf6d9dc747f3a631fee70e0c035bae
Author: minwang 
Date:   Mon Nov 4 11:32:43 2013 +0800

GPU Calc: implemented COUPNUM

AMLOEXT-74 FIX

Change-Id: Ic7f274f089f7f6cc6b767c4a07844014eeded61d
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index 24647bf..1cc0b9f 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1137,6 +1137,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
   ft->Children[i], new OpPrice));
 }
+else if ( !(pChild->GetExternal().compareTo(OUString(
+ "com.sun.star.sheet.addin.Analysis.getCoupnum"
+{
+mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
+new OpCoupnum));
+}
 break;
 default:
 throw UnhandledToken(pChild, "unhandled opcode");
diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index a40a113..b5b9a5c 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -2740,7 +2740,102 @@ void OpCoupdaysnc::GenSlidingWindowFunction(
 ss << "}";
 }
 
- void OpReceived::BinInlineFun(std::set& decls,
+void OpCoupnum::BinInlineFun(std::set& decls,
+std::set& funs)
+{
+decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl);
+decls.insert(DaysToDateDecl);decls.insert(DateToDaysDecl);
+decls.insert(GetNullDateDecl);decls.insert(lcl_GetcoupnumDecl);
+decls.insert(coupnumDecl);
+funs.insert(IsLeapYear);funs.insert(DaysInMonth);
+funs.insert(DaysToDate);funs.insert(DateToDays);
+funs.insert(GetNullDate);
+funs.insert(lcl_Getcoupnum);
+funs.insert(coupnum);
+}
+void OpCoupnum::GenSlidingWindowFunction(std::stringstream &ss,
+const std::string sSymName, SubArguments &vSubArguments)
+{
+ss << "\ndouble " << sSymName;
+ss << "_"<< BinFuncName() <<"(";
+for (unsigned i = 0; i < vSubArguments.size(); i++)
+{
+  if (i)
+  ss << ",";
+  vSubArguments[i]->GenSlidingWindowDecl(ss);
+}
+ss << ") {\n";
+ss << "double tmp = " << GetBottom() <<";\n";
+ss << "int gid0 = get_global_id(0);\n";
+ss << "int nSettle,nMat,nFreq,nBase;\n";
+#ifdef ISNAN
+FormulaToken* tmpCur0 = vSubArguments[0]->GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast(tmpCur0);
+FormulaToken* tmpCur1 = vSubArguments[1]->GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast(tmpCur1);
+FormulaToken* tmpCur2 = vSubArguments[2]->GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast(tmpCur2);
+FormulaToken* tmpCur3 = vSubArguments[3]->GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast(tmpCur3);
+ss<< "int buffer_nSettle_len = ";
+ss<< tmpCurDVR0->GetArrayLength();
+ss << ";\n";
+ss<< "int buffer_nMat_len = ";
+ss<< tmpCurDVR1->GetArrayLength();
+ss << ";\n";
+ss<< "int buffer_nFreq_len = ";
+ss<< tmpCurDVR2->GetArrayLength();
+ss << ";\n";
+ss<< "int buffer_nBase_len = ";
+ss<< tmpCurDVR3->GetArrayLength();
+ss << ";\n";
+#endif
+#ifdef ISNAN
+ss <<"if(gid0 >= buffer_nSettle_len || isNan(";
+ss GenSlidingWindowDeclRef();
+ss <<";\n";
+#ifdef ISNAN
+ss <<"if(gid0 >= buffer_nMat_len || isNan(";
+ss GenSlidingWindowDeclRef();
+ss << ";\n";
+#ifdef ISNAN
+ss <<"if(gid0 >= buffer_nFreq_len || isNan(";
+ss GenSlidingWindowDeclRef();
+ss <<";\n";
+#ifdef ISNAN
+ss <<"if(gid0 >= buffer_nBase_len || isNan(";
+ss 

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

2013-11-05 Thread yangzhang
 sc/qa/unit/data/ods/opencl/math/Abs.ods  |binary
 sc/qa/unit/opencl-test.cxx   |   28 +++
 sc/source/core/opencl/formulagroupcl.cxx |5 
 sc/source/core/opencl/op_math.cxx|   32 +++
 sc/source/core/opencl/op_math.hxx|8 +++
 sc/source/core/tool/token.cxx|1 
 6 files changed, 74 insertions(+)

New commits:
commit 01f6f620395a86abe1e7f503ae4b3b5f7124e144
Author: yangzhang 
Date:   Mon Nov 4 15:36:56 2013 +0800

GPU Calc: implement fix for ABS

AMLOEXT-47 FIX

Change-Id: I438ad01d717dbc34ea8bc45e8f6de4f7d0c2bf2c
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index f0fd68b..d3ad8bc 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1023,6 +1023,11 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 case ocSinHyp:
 mvSubArguments.push_back(SoPHelper(ts,
  ft->Children[i],new OpSinh));
+break;
+case ocAbs:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpAbs));
+break;
 case ocExternal:
 if ( !(pChild->GetExternal().compareTo(OUString(
 "com.sun.star.sheet.addin.Analysis.getEffect"
diff --git a/sc/source/core/opencl/op_math.cxx 
b/sc/source/core/opencl/op_math.cxx
index 32d2eb5..b3afda2 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -110,6 +110,38 @@ void OpSinh::GenSlidingWindowFunction(std::stringstream 
&ss,
 ss << "}";
 }
 
+void OpAbs::GenSlidingWindowFunction(std::stringstream &ss,
+const std::string sSymName, SubArguments &vSubArguments)
+{
+ss << "\ndouble " << sSymName;
+ss << "_"<< BinFuncName() <<"(";
+for (unsigned i = 0; i < vSubArguments.size(); i++)
+{
+if (i)
+ss << ",";
+vSubArguments[i]->GenSlidingWindowDecl(ss);
+}
+ss << ") {\n";
+ss << "int gid0   = get_global_id(0);\n";
+ss << "double tmp = " << GetBottom() << ";\n";
+#ifdef ISNAN
+FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR0=
+dynamic_cast(tmpCur0);
+ss << "int buffer_len = ";
+ss << tmpCurDVR0->GetArrayLength();
+ss << ";\n";
+ss << "if((gid0)>=buffer_len || isNan(";
+ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ss << "))\n";
+ss << "tmp = " << GetBottom() << ";\nelse \n";
+#endif
+ss << "tmp = ";
+ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ss << ";\n";
+ss << "return fabs(tmp);\n";
+ss << "}";
+}
 
 }}
 
diff --git a/sc/source/core/opencl/op_math.hxx 
b/sc/source/core/opencl/op_math.hxx
index 7399a6a..1e59c41 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -38,6 +38,14 @@ public:
 const std::string sSymName, SubArguments &vSubArguments);
 virtual std::string BinFuncName(void) const { return "Sinh"; }
 };
+
+class OpAbs:public Normal{
+public:
+virtual void GenSlidingWindowFunction(std::stringstream &ss,
+const std::string sSymName, SubArguments &vSubArguments);
+virtual std::string GetBottom(void) { return "0.0"; }
+virtual std::string BinFuncName(void) const { return "ScAbs"; }
+};
 }}
 
 #endif
commit 73cde39d6314fcc426165d1fea204f78de847ffb
Author: yangzhang 
Date:   Mon Nov 4 14:58:13 2013 +0800

GPU Calc: unit test cases for ABS

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-47 BUG

Change-Id: Ie33b4e5fad47f58a33ecdb0405521e7df694148c
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/qa/unit/data/ods/opencl/math/Abs.ods 
b/sc/qa/unit/data/ods/opencl/math/Abs.ods
new file mode 100644
index 000..2e55c73
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/Abs.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 88232aa..90867ba 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -123,6 +123,7 @@ public:
 void testFinancialDurationFormula();
 void testFinancialCoupnumFormula();
 void testMathFormulaSinh();
+void testMathFormulaAbs();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -177,6 +178,7 @@ public:
 CPPUNIT_TEST(testFinancialDurationFormula);
 CPPUNIT_TEST(testFinancialCoupnumFormula);
 CPPUNIT_TEST(testMathFormulaSinh);
+CPPUNIT_TEST(testMathFormulaAbs);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -775,6 +777,32 @@ void ScOpenclTest::testFinacialFvscheduleFormula()
 xDocSh->DoClose();

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

2013-11-05 Thread yiming ju
 sc/qa/unit/data/xls/opencl/financial/PV.xls |binary
 sc/qa/unit/opencl-test.cxx  |   24 
 sc/source/core/opencl/formulagroupcl.cxx|4 
 sc/source/core/opencl/op_financial.cxx  |  144 
 sc/source/core/opencl/op_financial.hxx  |8 +
 sc/source/core/tool/token.cxx   |1 
 6 files changed, 181 insertions(+)

New commits:
commit c1492fe9ea81eb7d6af3e636f022a23fb7874b9d
Author: yiming ju 
Date:   Mon Nov 4 15:54:15 2013 +0800

GPU Calc: implement fix for PV

AMLOEXT-73 FIX

Change-Id: I0b9014a5d78165adaaa41c7e6cc05e876981f37d
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index d3ad8bc..c8c07e4 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1028,6 +1028,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
  ft->Children[i], new OpAbs));
 break;
+case ocBW:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpPV));
+break;
 case ocExternal:
 if ( !(pChild->GetExternal().compareTo(OUString(
 "com.sun.star.sheet.addin.Analysis.getEffect"
diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index d5853f6..cb31cd1 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -3388,6 +3388,150 @@ void OpTbillyield::GenSlidingWindowFunction(
 ss << "}\n";
 }
 
+void OpPV::GenSlidingWindowFunction(
+std::stringstream &ss, const std::string sSymName, SubArguments &
+vSubArguments)
+{
+ss << "\ndouble " << sSymName;
+ss << "_"<< BinFuncName() <<"(";
+for (unsigned i = 0; i < vSubArguments.size(); i++)
+{
+if (i)
+ss << ",";
+vSubArguments[i]->GenSlidingWindowDecl(ss);
+}
+ss << ") {\n";
+ss << "double result = " <<"0"<<";\n";
+ss << "int gid0 = get_global_id(0);\n";
+ss << "double zins;\n";
+ss << "double zzr;\n";
+ss << "double rmz;\n";
+ss << "double zw;\n";
+ss << "double flag;\n";
+
+#ifdef ISNAN
+ FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast(tmpCur0);
+
+ FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast(tmpCur1);
+
+ FormulaToken *tmpCur2 = vSubArguments[2]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast(tmpCur2);
+
+ const formula::SingleVectorRefToken*tmpCurDVR3;
+ const formula::SingleVectorRefToken*tmpCurDVR4;
+
+if(vSubArguments.size()>3)
+{
+FormulaToken *tmpCur3 = vSubArguments[3]->GetFormulaToken();
+tmpCurDVR3= dynamic_cast(
+tmpCur3);
+ss<< "int buffer_zw_len = ";
+ss<< tmpCurDVR3->GetArrayLength();
+ss << ";\n";
+}
+
+if(vSubArguments.size()>4)
+{
+FormulaToken *tmpCur4 = vSubArguments[4]->GetFormulaToken();
+tmpCurDVR4= dynamic_cast(
+tmpCur4);
+ss<< "int buffer_flag_len = ";
+ss<< tmpCurDVR4->GetArrayLength();
+ss << ";\n";
+}
+
+ss<< "int buffer_zins_len = ";
+ss<< tmpCurDVR0->GetArrayLength();
+ss << ";\n";
+
+ss<< "int buffer_zzr_len = ";
+ss<< tmpCurDVR1->GetArrayLength();
+ss << ";\n";
+
+ss<< "int buffer_rmz_len = ";
+ss<< tmpCurDVR2->GetArrayLength();
+ss << ";\n";
+
+#endif
+
+#ifdef ISNAN
+ss<<"if(gid0>=buffer_zins_len || isNan(";
+ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ss<<"))\n";
+ss<<"zins = 0;\nelse \n";
+#endif
+ss<<"zins = ";
+ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ss<<";\n";
+
+#ifdef ISNAN
+ss<<"if(gid0>=buffer_zzr_len || isNan(";
+ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ss<<"))\n";
+ss<<"zzr = 0;\nelse \n";
+#endif
+ss<<"zzr = ";
+ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ss<<";\n";
+
+#ifdef ISNAN
+ss<<"if(gid0>=buffer_rmz_len || isNan(";
+ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+ss<<"))\n";
+ss<<"rmz = 0;\nelse \n";
+#endif
+ss<<"rmz = ";
+ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+ss<<";\n";
+
+if(vSubArguments.size()>3)
+{
+#ifdef ISNAN
+ss<<"if(gid0>=buffer_zw_len || isNan(";
+ss << vSubArguments[3]->GenSlidingWindowDeclRef();
+ss<<"))\n";
+ss<<"zw = 0;\nelse \n";
+#endif
+ss<<"zw = ";
+ss << vSubArguments[3]->Ge

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

2013-11-05 Thread fengzeng
 sc/qa/unit/data/xls/opencl/math/sin.xls  |binary
 sc/qa/unit/opencl-test.cxx   |   24 
 sc/source/core/opencl/formulagroupcl.cxx |4 
 sc/source/core/opencl/op_math.cxx|   30 +-
 sc/source/core/opencl/op_math.hxx|8 +++-
 sc/source/core/tool/token.cxx|1 +
 6 files changed, 65 insertions(+), 2 deletions(-)

New commits:
commit 8d460457876bbe696d6a2101ee49f81dedddb382
Author: fengzeng 
Date:   Mon Nov 4 16:25:48 2013 +0800

GPU Calc: implement fix for SIN

AMLOEXT-58 FIX

Change-Id: I68d23a66fd46b239911f8ba686b0492ca7783267
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index c8c07e4..a0a2d3a 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1032,6 +1032,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
  ft->Children[i], new OpPV));
 break;
+case ocSin:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpSin));
+break;
 case ocExternal:
 if ( !(pChild->GetExternal().compareTo(OUString(
 "com.sun.star.sheet.addin.Analysis.getEffect"
diff --git a/sc/source/core/opencl/op_math.cxx 
b/sc/source/core/opencl/op_math.cxx
index b3afda2..3d7d4c9 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -109,7 +109,35 @@ void OpSinh::GenSlidingWindowFunction(std::stringstream 
&ss,
 ss << "return tmp;\n";
 ss << "}";
 }
-
+void OpSin::GenSlidingWindowFunction(std::stringstream &ss,
+const std::string sSymName, SubArguments &vSubArguments)
+{
+FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast(tmpCur);
+ss << "\ndouble " << sSymName;
+ss << "_"<< BinFuncName() <<"(";
+for (unsigned i = 0; i < vSubArguments.size(); i++)
+{
+if (i)
+ss << ",";
+vSubArguments[i]->GenSlidingWindowDecl(ss);
+}
+ss << ")\n";
+ss << "{\n";
+ss << "int gid0=get_global_id(0);\n";
+ss << "double arg0 = "<< vSubArguments[0]->GenSlidingWindowDeclRef();
+ss << ";\n";
+#ifdef ISNAN
+ss << "if(isNan(arg0)||(gid0>=";
+ss << tmpCurDVR->GetArrayLength();
+ss << "))\n";
+ss << "arg0 = 0;\n";
+#endif
+ss << "double tmp=sin(arg0);\n";
+ss << "return tmp;\n";
+ss << "}";
+}
 void OpAbs::GenSlidingWindowFunction(std::stringstream &ss,
 const std::string sSymName, SubArguments &vSubArguments)
 {
diff --git a/sc/source/core/opencl/op_math.hxx 
b/sc/source/core/opencl/op_math.hxx
index 1e59c41..1dbfec9 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -38,7 +38,13 @@ public:
 const std::string sSymName, SubArguments &vSubArguments);
 virtual std::string BinFuncName(void) const { return "Sinh"; }
 };
-
+class OpSin: public Normal
+{
+public:
+virtual void GenSlidingWindowFunction(std::stringstream &ss,
+const std::string sSymName, SubArguments &vSubArguments);
+virtual std::string BinFuncName(void) const { return "Sin"; }
+};
 class OpAbs:public Normal{
 public:
 virtual void GenSlidingWindowFunction(std::stringstream &ss,
commit 041d7146412750ded74bfe7e59c14e7ffd9d35ac
Author: fengzeng 
Date:   Mon Nov 4 16:20:25 2013 +0800

GPU Calc: unit test cases for SIN

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-58 BUG

Change-Id: I484b86650e3e7bb11aa59aad6ae01be152aa2cef
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/qa/unit/data/xls/opencl/math/sin.xls 
b/sc/qa/unit/data/xls/opencl/math/sin.xls
new file mode 100644
index 000..71ea0d1
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/sin.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index de5bd74..415b99c 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -125,6 +125,7 @@ public:
 void testMathFormulaSinh();
 void testMathFormulaAbs();
 void testFinacialPVFormula();
+void testMathFormulaSin();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -181,6 +182,7 @@ public:
 CPPUNIT_TEST(testMathFormulaSinh);
 CPPUNIT_TEST(testMathFormulaAbs);
 CPPUNIT_TEST(testFinacialPVFormula);
+CPPUNIT_TEST(testMathFormulaSin);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1173,6 +1175,28 @@ void ScOpenclTest::testStatisticalFormulaNegbinomdist()
 xDocSh->DoClose();
 xDocShRes->DoClose();
 

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

2013-11-05 Thread fengzeng
 sc/qa/unit/data/xls/opencl/math/tan.xls  |binary
 sc/qa/unit/opencl-test.cxx   |   24 
 sc/source/core/opencl/formulagroupcl.cxx |4 
 sc/source/core/opencl/op_math.cxx|   30 +-
 sc/source/core/opencl/op_math.hxx|8 
 sc/source/core/tool/token.cxx|1 +
 6 files changed, 66 insertions(+), 1 deletion(-)

New commits:
commit ecda5dc6203cfefdb075984fb9826d33fc214c43
Author: fengzeng 
Date:   Mon Nov 4 16:36:26 2013 +0800

GPU Calc: implemented TAN

AMLOEXT-60 FIX

Change-Id: Ibdbc0f22e152f5b73191f3a16e9e5489c0007fc3
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index a0a2d3a..a710f22 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1036,6 +1036,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
  ft->Children[i], new OpSin));
 break;
+case ocTan:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpTan));
+break;
 case ocExternal:
 if ( !(pChild->GetExternal().compareTo(OUString(
 "com.sun.star.sheet.addin.Analysis.getEffect"
diff --git a/sc/source/core/opencl/op_math.cxx 
b/sc/source/core/opencl/op_math.cxx
index 3d7d4c9..c5c213c 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -170,7 +170,35 @@ void OpAbs::GenSlidingWindowFunction(std::stringstream &ss,
 ss << "return fabs(tmp);\n";
 ss << "}";
 }
-
+void OpTan::GenSlidingWindowFunction(std::stringstream &ss,
+const std::string sSymName, SubArguments &vSubArguments)
+{
+FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast(tmpCur);
+ss << "\ndouble " << sSymName;
+ss << "_"<< BinFuncName() <<"(";
+for (unsigned i = 0; i < vSubArguments.size(); i++)
+{
+if (i)
+ss << ",";
+vSubArguments[i]->GenSlidingWindowDecl(ss);
+}
+ss << ")\n";
+ss << "{\n";
+ss << "int gid0=get_global_id(0);\n";
+ss << "double arg0 = "<< vSubArguments[0]->GenSlidingWindowDeclRef();
+ss << ";\n";
+#ifdef ISNAN
+ss << "if(isNan(arg0)||(gid0>=";
+ss << tmpCurDVR->GetArrayLength();
+ss << "))\n";
+ss << "arg0 = 0;\n";
+#endif
+ss << "double tmp=tan(arg0);\n";
+ss << "return tmp;\n";
+ss << "}";
+}
 }}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_math.hxx 
b/sc/source/core/opencl/op_math.hxx
index 1dbfec9..ed5a4e9 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -52,6 +52,14 @@ public:
 virtual std::string GetBottom(void) { return "0.0"; }
 virtual std::string BinFuncName(void) const { return "ScAbs"; }
 };
+class OpTan: public Normal
+{
+public:
+virtual void GenSlidingWindowFunction(std::stringstream &ss,
+const std::string sSymName, SubArguments &vSubArguments);
+
+virtual std::string BinFuncName(void) const { return "Tan"; }
+};
 }}
 
 #endif
commit e7ff395a3f70573c0dbb4093e86ffe57e935fece
Author: fengzeng 
Date:   Mon Nov 4 16:32:44 2013 +0800

GPU Calc: unit test cases for TAN

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-60 BUG

Change-Id: I29433afcc8403fd6938d39667b18e786f4e5b6fc
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/qa/unit/data/xls/opencl/math/tan.xls 
b/sc/qa/unit/data/xls/opencl/math/tan.xls
new file mode 100644
index 000..2a73718
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/tan.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 415b99c..87c6bad 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -126,6 +126,7 @@ public:
 void testMathFormulaAbs();
 void testFinacialPVFormula();
 void testMathFormulaSin();
+void testMathFormulaTan();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -183,6 +184,7 @@ public:
 CPPUNIT_TEST(testMathFormulaAbs);
 CPPUNIT_TEST(testFinacialPVFormula);
 CPPUNIT_TEST(testMathFormulaSin);
+CPPUNIT_TEST(testMathFormulaTan);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1197,6 +1199,28 @@ void ScOpenclTest::testMathFormulaSin()
 xDocSh->DoClose();
 xDocShRes->DoClose();
 }
+//[AMLOEXT-60]
+void ScOpenclTest::testMathFormulaTan()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc("opencl/math/tan.", XLS);
+ScDoc

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

2013-11-05 Thread fengzeng
 sc/qa/unit/data/xls/opencl/math/tanh.xls |binary
 sc/qa/unit/opencl-test.cxx   |   24 
 sc/source/core/opencl/formulagroupcl.cxx |4 
 sc/source/core/opencl/op_math.cxx|   31 +++
 sc/source/core/opencl/op_math.hxx|8 
 sc/source/core/tool/token.cxx|1 +
 6 files changed, 68 insertions(+)

New commits:
commit 6786d9b887f821160f7d77b9a5854bc0b019b38a
Author: fengzeng 
Date:   Mon Nov 4 16:50:16 2013 +0800

GPU Calc: implemented TANH

AMLOEXT-61 FIX

Change-Id: I7c8dcc23d85aa809f134446dcab97e51405d58c2
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index a710f22..cd040d6 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1040,6 +1040,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
  ft->Children[i], new OpTan));
 break;
+case ocTanHyp:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpTanH));
+break;
 case ocExternal:
 if ( !(pChild->GetExternal().compareTo(OUString(
 "com.sun.star.sheet.addin.Analysis.getEffect"
diff --git a/sc/source/core/opencl/op_math.cxx 
b/sc/source/core/opencl/op_math.cxx
index c5c213c..d7286be 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -199,6 +199,37 @@ void OpTan::GenSlidingWindowFunction(std::stringstream &ss,
 ss << "return tmp;\n";
 ss << "}";
 }
+void OpTanH::GenSlidingWindowFunction(std::stringstream &ss,
+const std::string sSymName, SubArguments &vSubArguments)
+{
+FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast(tmpCur);
+ss << "\ndouble " << sSymName;
+ss << "_"<< BinFuncName() <<"(";
+for (unsigned i = 0; i < vSubArguments.size(); i++)
+{
+if (i)
+ss << ",";
+vSubArguments[i]->GenSlidingWindowDecl(ss);
+}
+ss << ")\n";
+ss << "{\n";
+ss << "int gid0=get_global_id(0);\n";
+ss << "double arg0 = "<< vSubArguments[0]->GenSlidingWindowDeclRef();
+ss << ";\n";
+#ifdef ISNAN
+ss << "if(isNan(arg0)||(gid0>=";
+ss << tmpCurDVR->GetArrayLength();
+ss << "))\n";
+ss << "arg0 = 0;\n";
+#endif
+ss << "double tmp=tanh(arg0);\n";
+ss << "return tmp;\n";
+ss << "}";
+}
+
+
 }}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_math.hxx 
b/sc/source/core/opencl/op_math.hxx
index ed5a4e9..d7ce226 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -60,6 +60,14 @@ public:
 
 virtual std::string BinFuncName(void) const { return "Tan"; }
 };
+class OpTanH: public Normal
+{
+public:
+virtual void GenSlidingWindowFunction(std::stringstream &ss,
+const std::string sSymName, SubArguments &vSubArguments);
+
+virtual std::string BinFuncName(void) const { return "TanH"; }
+};
 }}
 
 #endif
commit f69d6457840216a87093a503a648ee3c34a04e78
Author: fengzeng 
Date:   Mon Nov 4 16:47:01 2013 +0800

GPU Calc: unit test cases for TANH

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-61 BUG

Change-Id: I1db0693cdacdf437c413e56e3c97f0ff4d913211
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/qa/unit/data/xls/opencl/math/tanh.xls 
b/sc/qa/unit/data/xls/opencl/math/tanh.xls
new file mode 100644
index 000..a19efd3
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/tanh.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 87c6bad..87414c0 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -127,6 +127,7 @@ public:
 void testFinacialPVFormula();
 void testMathFormulaSin();
 void testMathFormulaTan();
+void testMathFormulaTanH();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -185,6 +186,7 @@ public:
 CPPUNIT_TEST(testFinacialPVFormula);
 CPPUNIT_TEST(testMathFormulaSin);
 CPPUNIT_TEST(testMathFormulaTan);
+CPPUNIT_TEST(testMathFormulaTanH);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1221,6 +1223,28 @@ void ScOpenclTest::testMathFormulaTan()
 xDocSh->DoClose();
 xDocShRes->DoClose();
 }
+//[AMLOEXT-61]
+void ScOpenclTest::testMathFormulaTanH()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc("opencl/math/tanh.", XLS);
+ScDocument* pDoc = xDocSh->GetDocument();
+CPPUNIT_ASSERT(pDo

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

2013-11-05 Thread shiming zhang
 sc/qa/unit/data/xls/opencl/statistical/Standard.xls |binary
 sc/qa/unit/opencl-test.cxx  |   27 +
 sc/source/core/opencl/formulagroupcl.cxx|4 
 sc/source/core/opencl/op_statistical.cxx|  107 
 sc/source/core/opencl/op_statistical.hxx|8 +
 sc/source/core/tool/token.cxx   |1 
 6 files changed, 147 insertions(+)

New commits:
commit f1d75291e3e04c636b4dc2c44827d85b0263c46b
Author: shiming zhang 
Date:   Mon Nov 4 17:05:54 2013 +0800

GPU Calc: implemented STANDARDIZE

AMLOEXT-77 FIX

Change-Id: I5f91d497417e87a489728949a4436f33ed3da235
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index cd040d6..a68188c 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1044,6 +1044,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts,
  ft->Children[i], new OpTanH));
 break;
+case ocStandard:
+mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpStandard));
+break;
 case ocExternal:
 if ( !(pChild->GetExternal().compareTo(OUString(
 "com.sun.star.sheet.addin.Analysis.getEffect"
diff --git a/sc/source/core/opencl/op_statistical.cxx 
b/sc/source/core/opencl/op_statistical.cxx
index 134a0ca..4128507 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -22,6 +22,113 @@ using namespace formula;
 
 namespace sc { namespace opencl {
 
+void OpStandard::GenSlidingWindowFunction(std::stringstream &ss,
+const std::string sSymName, SubArguments &vSubArguments)
+{
+ss << "\ndouble " << sSymName;
+ss << "_" << BinFuncName() << "(";
+for (unsigned i = 0; i < vSubArguments.size(); i++)
+{
+if (i)
+ss << ",";
+vSubArguments[i]->GenSlidingWindowDecl(ss);
+}
+ss << ") {\n";
+ss << "double tmp = 0;\n";
+ss << "int gid0 = get_global_id(0);\n";
+ss << "double x,mu,sigma;\n";
+if(vSubArguments.size() != 3)
+{
+ss << "return DBL_MAX;\n" << "}\n";
+return ;
+}
+FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+assert(tmpCur0);
+if(tmpCur0->GetType() == formula::svSingleVectorRef)
+{
+const formula::SingleVectorRefToken*tmpCurDVR0 =
+dynamic_cast(tmpCur0);
+#ifdef ISNAN
+ss << "int buffer_x_len = ";
+ss << tmpCurDVR0->GetArrayLength() << ";\n";
+ss << "if(gid0>=buffer_x_len || isNan(";
+ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
+ss << "x = 0.0;\n";
+ss << "else\n";
+#endif
+ss << "x = ";
+ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+}
+else if(tmpCur0->GetType() == formula::svDouble)
+{
+ss << "x=" GetFormulaToken();
+assert(tmpCur1);
+if(tmpCur1->GetType() == formula::svSingleVectorRef)
+{
+const formula::SingleVectorRefToken*tmpCurDVR1 =
+dynamic_cast(tmpCur1);
+#ifdef ISNAN
+ss << "int buffer_mu_len = ";
+ss << tmpCurDVR1->GetArrayLength() << ";\n";
+ss << "if(gid0>=buffer_mu_len || isNan(";
+ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+ss << "mu = 0.0;\n";
+ss << "else\n";
+#endif
+ss << "mu = ";
+ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+}
+else if(tmpCur1->GetType() == formula::svDouble)
+{
+ss << "mu=" GetFormulaToken();
+assert(tmpCur2);
+if(tmpCur2->GetType() == formula::svSingleVectorRef)
+{
+const formula::SingleVectorRefToken*tmpCurDVR2 =
+dynamic_cast(tmpCur2);
+#ifdef ISNAN
+ss << "int buffer_sigma_len = ";
+ss << tmpCurDVR2->GetArrayLength() << ";\n";
+ss << "if(gid0>=buffer_sigma_len || isNan(";
+ss << vSubArguments[2]->GenSlidingWindowDeclRef() << "))\n";
+ss << "sigma = 0.0;\n";
+ss << "else\n";
+#endif
+ss << "sigma = ";
+ss << vSubArguments[2]->GenSlidingWindowDeclRef() << ";\n";
+}
+else if(tmpCur2->GetType() == formula::svDouble)
+{
+ss << "sigma=" 

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

2013-11-09 Thread Stephan Bergmann
 sc/qa/extras/scoutlineobj.cxx|   10 +-
 test/source/calc_unoapi_test.cxx |2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 01d9f3fbeeb2a8f63a614fbc1a66ffb5c80c624f
Author: Stephan Bergmann 
Date:   Sat Nov 9 15:14:22 2013 +0100

The ScOutlineObj test still requires the fugdge

...that got moved from UnoApiTest to CalcUnoApiTest in
a071a29d4f7e8065a36a313027a007edac102e20 "UnoApiTest don't require Calc."

Change-Id: I1a38c496ef2baf42b5fd82ff653e822a8b80a124

diff --git a/sc/qa/extras/scoutlineobj.cxx b/sc/qa/extras/scoutlineobj.cxx
index 1e0479a..0d6183e 100644
--- a/sc/qa/extras/scoutlineobj.cxx
+++ b/sc/qa/extras/scoutlineobj.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include 
+#include 
 #include 
 
 #include 
@@ -20,7 +20,7 @@ namespace sc_apitest {
 
 #define NUMBER_OF_TESTS 6
 
-class ScOutlineObj : public UnoApiTest, apitest::XSheetOutline
+class ScOutlineObj : public CalcUnoApiTest, apitest::XSheetOutline
 {
 public:
 ScOutlineObj();
@@ -49,7 +49,7 @@ sal_Int32 ScOutlineObj::nTest = 0;
 uno::Reference< lang::XComponent > ScOutlineObj::mxComponent;
 
 ScOutlineObj::ScOutlineObj()
-: UnoApiTest("/sc/qa/extras/testdocuments")
+: CalcUnoApiTest("/sc/qa/extras/testdocuments")
 {
 }
 
@@ -73,7 +73,7 @@ uno::Reference< uno::XInterface > ScOutlineObj::init()
 void ScOutlineObj::setUp()
 {
 nTest++;
-UnoApiTest::setUp();
+CalcUnoApiTest::setUp();
 }
 
 void ScOutlineObj::tearDown()
@@ -81,7 +81,7 @@ void ScOutlineObj::tearDown()
 if (nTest == NUMBER_OF_TESTS)
 closeDocument(mxComponent);
 
-UnoApiTest::tearDown();
+CalcUnoApiTest::tearDown();
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScOutlineObj);
commit fe2e43280fc2007dcc819285270b2437ba56b8e3
Author: Stephan Bergmann 
Date:   Sat Nov 9 15:11:17 2013 +0100

Don't dispose twice in CalcUnoApiTest::tearDown

...i.e., skip UnoApiTest::tearDown's dispose of mxDesktop and go directly to
BootstrapFixture::tearDown.

Change-Id: If4555c812cb42c4b76a36d4e59c1d96211915dba

diff --git a/test/source/calc_unoapi_test.cxx b/test/source/calc_unoapi_test.cxx
index 8d7e218..f80e659 100644
--- a/test/source/calc_unoapi_test.cxx
+++ b/test/source/calc_unoapi_test.cxx
@@ -31,7 +31,7 @@ void CalcUnoApiTest::setUp()
 void CalcUnoApiTest::tearDown()
 {
 uno::Reference< lang::XComponent >( m_xCalcComponent, UNO_QUERY_THROW 
)->dispose();
-UnoApiTest::tearDown();
+test::BootstrapFixture::tearDown();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2013-11-12 Thread xinjiang
 sc/qa/unit/data/xls/opencl/financial/Duration_ADD.xls |binary
 sc/qa/unit/opencl-test.cxx|   25 +++
 sc/source/core/opencl/formulagroupcl.cxx  |6 +
 sc/source/core/opencl/op_financial.cxx|   60 ++
 sc/source/core/opencl/op_financial.hxx|   14 
 sc/source/core/opencl/opinlinefun_finacial.cxx|   32 +
 6 files changed, 136 insertions(+), 1 deletion(-)

New commits:
commit 20029a72b3bb9a119e99bff7974bf6bb20e17924
Author: xinjiang 
Date:   Tue Nov 5 09:31:14 2013 +0800

GPU Calc: unit test cases for DURATION_ADD

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-121 BUG

Change-Id: Id78c89f77cdfe14d368831c22ff708b968e8fee2
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/qa/unit/data/xls/opencl/financial/Duration_ADD.xls 
b/sc/qa/unit/data/xls/opencl/financial/Duration_ADD.xls
new file mode 100644
index 000..18e5ddb
Binary files /dev/null and 
b/sc/qa/unit/data/xls/opencl/financial/Duration_ADD.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index b593174..b040e32 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -131,6 +131,7 @@ public:
 void testStatisticalFormulaStandard();
 void testStatisticalFormulaWeibull();
 void testStatisticalFormulaMedian();
+void testFinancialDuration_ADDFormula();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -193,6 +194,7 @@ public:
 CPPUNIT_TEST(testStatisticalFormulaStandard);
 CPPUNIT_TEST(testStatisticalFormulaWeibull);
 CPPUNIT_TEST(testStatisticalFormulaMedian);
+CPPUNIT_TEST(testFinancialDuration_ADDFormula);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1902,7 +1904,28 @@ void ScOpenclTest:: testFinacialPPMTFormula()
 xDocSh->DoClose();
 xDocShRes->DoClose();
 }
-
+//[AMLOEXT-121]
+void ScOpenclTest:: testFinancialDuration_ADDFormula()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc("opencl/financial/Duration_ADD.", XLS);
+ScDocument* pDoc = xDocSh->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+enableOpenCL();
+pDoc->CalcAll();
+ScDocShellRef xDocShRes = loadDoc("opencl/financial/Duration_ADD.", XLS);
+ScDocument* pDocRes = xDocShRes->GetDocument();
+CPPUNIT_ASSERT(pDocRes);
+for (SCROW i = 0; i <= 9; ++i)
+{
+double fLibre = pDoc->GetValue(ScAddress(6, i, 0));
+double fExcel = pDocRes->GetValue(ScAddress(6, i, 0));
+CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+}
+xDocSh->DoClose();
+xDocShRes->DoClose();
+}
 ScOpenclTest::ScOpenclTest()
   : ScBootstrapFixture( "/sc/qa/unit/data" )
 {
commit 9425b3a938faf2df4d58acdcaf4437dc52ebd23c
Author: xinjiang 
Date:   Tue Nov 5 09:47:10 2013 +0800

GPU Calc: implement fix for DURATION_ADD

AMLOEXT-121 FIX

Change-Id: Ie6b10eacc4e5fc0b2dcfe816982836b8b244af05
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index c6ae8e8..6d613a4 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1179,6 +1179,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
 new OpCoupnum));
 }
+else if ( !(pChild->GetExternal().compareTo(OUString(
+   "com.sun.star.sheet.addin.Analysis.getDuration"
+{
+mvSubArguments.push_back(
+SoPHelper(ts, ft->Children[i], new OpDuration_ADD));
+}
 break;
 default:
 throw UnhandledToken(pChild, "unhandled opcode");
diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index cb31cd1..1db9119 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -574,6 +574,66 @@ void 
OpDuration::GenSlidingWindowFunction(std::stringstream& ss,
 ss << "}";
 }
 
+void OpDuration_ADD::BinInlineFun(std::set& decls,
+std::set& funs)
+{
+decls.insert(GetDurationDecl);decls.insert(lcl_GetcoupnumDecl);
+decls.insert(GetYearFracDecl);decls.insert(DaysToDateDecl);
+decls.insert(GetNullDateDecl);decls.insert(DateToDaysDecl);
+decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl);
+funs.insert(GetDuration);funs.insert(lcl_Getcoupnum);
+funs.insert(GetYearFrac);funs.insert(DaysToDate);
+funs.insert(GetNullDate);funs.insert(DateToDays);
+funs.insert(DaysInMonth);funs.insert(IsLeapYear);
+}
+
+void OpDuration_ADD::GenSlidingWindowFunction(std::stringstream

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

2013-11-12 Thread minwang
 sc/qa/unit/data/xls/opencl/financial/Amordegrc.xls |binary
 sc/qa/unit/opencl-test.cxx |   24 ++
 sc/source/core/opencl/formulagroupcl.cxx   |6 
 sc/source/core/opencl/op_financial.cxx |  171 +
 sc/source/core/opencl/op_financial.hxx |   10 +
 5 files changed, 211 insertions(+)

New commits:
commit 4bad711ff532bfc1f64b584e8c5cf8fbef38e2ca
Author: minwang 
Date:   Tue Nov 5 10:02:29 2013 +0800

GPU Calc: unit test cases for AMORDEGRC in GPU calc

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-98 BUG

Change-Id: I0867627c69eefdbc7127d19559af23fbd70b3ccc
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/qa/unit/data/xls/opencl/financial/Amordegrc.xls 
b/sc/qa/unit/data/xls/opencl/financial/Amordegrc.xls
new file mode 100644
index 000..7cb9e47
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/financial/Amordegrc.xls 
differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index b040e32..3c395c4 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -132,6 +132,7 @@ public:
 void testStatisticalFormulaWeibull();
 void testStatisticalFormulaMedian();
 void testFinancialDuration_ADDFormula();
+void testFinancialAmordegrcFormula();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -195,6 +196,7 @@ public:
 CPPUNIT_TEST(testStatisticalFormulaWeibull);
 CPPUNIT_TEST(testStatisticalFormulaMedian);
 CPPUNIT_TEST(testFinancialDuration_ADDFormula);
+CPPUNIT_TEST(testFinancialAmordegrcFormula);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1514,6 +1516,28 @@ void ScOpenclTest::testFinacialXNPVFormula()
 xDocSh->DoClose();
 xDocShRes->DoClose();
 }
+//[AMLOEXT-98]
+void ScOpenclTest::testFinancialAmordegrcFormula()
+{
+   if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc("opencl/financial/Amordegrc.", XLS);
+ScDocument* pDoc = xDocSh->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+enableOpenCL();
+pDoc->CalcAll();
+ScDocShellRef xDocShRes = loadDoc("opencl/financial/Amordegrc.", XLS);
+ScDocument* pDocRes = xDocShRes->GetDocument();
+CPPUNIT_ASSERT(pDocRes);
+for (SCROW i = 0; i <= 9; ++i)
+{
+double fLibre = pDoc->GetValue(ScAddress(7, i, 0));
+double fExcel = pDocRes->GetValue(ScAddress(7, i, 0));
+CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+}
+xDocSh->DoClose();
+xDocShRes->DoClose();
+}
 //[AMLOEXT-99]
 void ScOpenclTest:: testFinancialISPMTFormula()
 {
commit 153bb4cc1e7009f2e2fa5fe277c397d5ad9a1730
Author: minwang 
Date:   Tue Nov 5 10:16:40 2013 +0800

GPU Calc: implement fix for AMORDEGRC in GPU calc

AMLOEXT-98 FIX

Change-Id: I9f63d023161e5ad7981374dedffb6f00663a1c66
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index 6d613a4..fe0b8f8 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1185,6 +1185,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(
 SoPHelper(ts, ft->Children[i], new OpDuration_ADD));
 }
+else if ( !(pChild->GetExternal().compareTo(OUString(
+   "com.sun.star.sheet.addin.Analysis.getAmordegrc"
+{
+mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
+new OpAmordegrc));
+}
 break;
 default:
 throw UnhandledToken(pChild, "unhandled opcode");
diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index 1db9119..5e2509a 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -2892,6 +2892,177 @@ void 
OpCoupnum::GenSlidingWindowFunction(std::stringstream &ss,
 ss << "return tmp;\n";
 ss << "}";
 }
+void OpAmordegrc::BinInlineFun(std::set& decls,
+std::set& funs)
+{
+decls.insert(nKorrValDecl); decls.insert(RoundDecl);
+decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl);
+decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
+decls.insert(GetNullDateDecl); decls.insert(GetYearFracDecl);
+funs.insert(Round);
+funs.insert(IsLeapYear);funs.insert(DaysInMonth);
+funs.insert(DaysToDate);funs.insert(DateToDays);
+funs.insert(GetNullDate);funs.insert(GetYearFrac);
+}
+void OpAmordegrc::GenSlidingWindowFunction(std::stringstream &ss,
+const std::string sSymName, SubArguments &vSubArguments)
+{
+ss << "\ndouble " << sSymName;
+ss << "_"<< BinFuncName() <<"(";
+f

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

2013-11-12 Thread minwang
 sc/qa/unit/data/xls/opencl/financial/Amorlinc.xls |binary
 sc/qa/unit/opencl-test.cxx|   24 +++
 sc/source/core/opencl/formulagroupcl.cxx  |6 
 sc/source/core/opencl/op_financial.cxx|  154 +-
 sc/source/core/opencl/op_financial.hxx|9 +
 5 files changed, 192 insertions(+), 1 deletion(-)

New commits:
commit 89ed6a0e150549fb5aa00f06216637ea71b04f30
Author: minwang 
Date:   Tue Nov 5 10:28:57 2013 +0800

GPU Calc: unit test cases for AMORLINC in GPU calc

Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test

AMLOEXT-110 BUG

Change-Id: Ia6e1333e7d1c91ff9b8a916109a8aa60f4725e03
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/qa/unit/data/xls/opencl/financial/Amorlinc.xls 
b/sc/qa/unit/data/xls/opencl/financial/Amorlinc.xls
new file mode 100644
index 000..5962334
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/financial/Amorlinc.xls 
differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 3c395c4..bc26113 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -133,6 +133,7 @@ public:
 void testStatisticalFormulaMedian();
 void testFinancialDuration_ADDFormula();
 void testFinancialAmordegrcFormula();
+void testFinancialAmorlincFormula();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -197,6 +198,7 @@ public:
 CPPUNIT_TEST(testStatisticalFormulaMedian);
 CPPUNIT_TEST(testFinancialDuration_ADDFormula);
 CPPUNIT_TEST(testFinancialAmordegrcFormula);
+CPPUNIT_TEST(testFinancialAmorlincFormula);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1583,6 +1585,28 @@ void ScOpenclTest::testStatisticalFormulaMedian()
 xDocSh->DoClose();
 xDocShRes->DoClose();
 }
+//[AMLOEXT-110]
+void ScOpenclTest::testFinancialAmorlincFormula()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc("opencl/financial/Amorlinc.", XLS);
+ScDocument *pDoc = xDocSh->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+enableOpenCL();
+pDoc->CalcAll();
+ScDocShellRef xDocShRes = loadDoc("opencl/financial/Amorlinc.", XLS);
+ScDocument *pDocRes = xDocShRes->GetDocument();
+CPPUNIT_ASSERT(pDocRes);
+for (SCROW i = 0; i <= 9; ++i)
+{
+double fLibre = pDoc->GetValue(ScAddress(7, i, 0));
+double fExcel = pDocRes->GetValue(ScAddress(7, i, 0));
+CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+}
+xDocSh->DoClose();
+xDocShRes->DoClose();
+}
 void ScOpenclTest::testFinacialPriceMatFormula()
 {
 if (!detectOpenCLDevice())
commit 7b33d0c12d487d953634fa1e06c6902124455e38
Author: minwang 
Date:   Tue Nov 5 10:33:53 2013 +0800

GPU Calc: implement fix for AMORLINC in GPU calc

AMLOEXT-110 FIX

Change-Id: I068924cc83288261102ea03e29449e0faf8686f9
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index fe0b8f8..55d2f25 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1191,6 +1191,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
 mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
 new OpAmordegrc));
 }
+else if ( !(pChild->GetExternal().compareTo(OUString(
+   "com.sun.star.sheet.addin.Analysis.getAmorlinc"
+{
+mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
+new OpAmorlinc));
+}
 break;
 default:
 throw UnhandledToken(pChild, "unhandled opcode");
diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index 5e2509a..92a7f14 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -3063,7 +3063,159 @@ void 
OpAmordegrc::GenSlidingWindowFunction(std::stringstream &ss,
 ss <<"return tmp;\n";
 ss <<"}";
 }
-
+void OpAmorlinc::BinInlineFun(std::set& decls,
+std::set& funs)
+{
+decls.insert(nKorrValDecl); decls.insert(RoundDecl);
+decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl);
+decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
+decls.insert(GetNullDateDecl); decls.insert(GetYearFracDecl);
+funs.insert(Round);
+funs.insert(IsLeapYear);funs.insert(DaysInMonth);
+funs.insert(DaysToDate);funs.insert(DateToDays);
+funs.insert(GetNullDate);funs.insert(GetYearFrac);
+}
+void OpAmorlinc::GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments)
+{
+ss << "\ndouble " << sSymName;
+ss << "_"<< 

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

2013-11-17 Thread yiming ju
 sc/qa/unit/data/xls/opencl/math/sumproduct_mixSliding.xls |binary
 sc/qa/unit/opencl-test.cxx|   38 +
 sc/source/core/opencl/formulagroupcl.cxx  |   57 +++---
 3 files changed, 86 insertions(+), 9 deletions(-)

New commits:
commit 59c0051b26c28a0b277a83177f7e7d5db012b6cf
Author: yiming ju 
Date:   Sun Nov 17 18:29:16 2013 +0800

GPU Calc: unit test cases for SUMPRODUCT WITH FIXED WINDOWS

AMLOEXT-214 BUG

Change-Id: Ib5adff235593b3a38f6aa7e63edf0196d31b8e82
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/qa/unit/data/xls/opencl/math/sumproduct_mixSliding.xls 
b/sc/qa/unit/data/xls/opencl/math/sumproduct_mixSliding.xls
new file mode 100644
index 000..09ff33e
Binary files /dev/null and 
b/sc/qa/unit/data/xls/opencl/math/sumproduct_mixSliding.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 0cbf365..987fc40 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -240,6 +240,7 @@ public:
 void testStatisticalFormulaStDevP();
 void testStatisticalFormulaCovar();
 void testLogicalFormulaAnd();
+void testMathFormulaSumProduct();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testFinacialFormula);
@@ -411,6 +412,7 @@ public:
 CPPUNIT_TEST(testStatisticalFormulaStDevP);
 CPPUNIT_TEST(testStatisticalFormulaCovar);
 CPPUNIT_TEST(testLogicalFormulaAnd);
+CPPUNIT_TEST(testMathFormulaSumProduct);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4716,6 +4718,42 @@ void ScOpenclTest:: testArrayFormulaSumXMY2()
 xDocSh->DoClose();
 xDocShRes->DoClose();
 }
+//[AMLOEXT-214]
+void ScOpenclTest::testMathFormulaSumProduct()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc("opencl/math/sumproduct_mixSliding.", XLS);
+ScDocument* pDoc = xDocSh->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+enableOpenCL();
+pDoc->CalcAll();
+ScDocShellRef xDocShRes = loadDoc("opencl/math/sumproduct_mixSliding.", 
XLS);
+ScDocument* pDocRes = xDocShRes->GetDocument();
+CPPUNIT_ASSERT(pDocRes);
+// Check the results of formula cells in the shared formula range.
+for (SCROW i = 0; i <= 9; ++i)
+{
+double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+if ( i == 1 )
+CPPUNIT_ASSERT_DOUBLES_EQUAL(82,  fLibre, fabs(0.0001*fExcel));
+else if ( i == 2 )
+CPPUNIT_ASSERT_DOUBLES_EQUAL(113, fLibre, fabs(0.0001*fExcel));
+else if ( i == 4 )
+CPPUNIT_ASSERT_DOUBLES_EQUAL(175, fLibre, fabs(0.0001*fExcel));
+else if ( i == 5 )
+CPPUNIT_ASSERT_DOUBLES_EQUAL(206, fLibre, fabs(0.0001*fExcel));
+else if ( i == 6 )
+CPPUNIT_ASSERT_DOUBLES_EQUAL(237, fLibre, fabs(0.0001*fExcel));
+else if ( i == 7 )
+CPPUNIT_ASSERT_DOUBLES_EQUAL(268, fLibre, fabs(0.0001*fExcel));
+else
+CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+}
+xDocSh->DoClose();
+xDocShRes->DoClose();
+}
 //[AMLOEXT-217]
 void ScOpenclTest:: testLogicalFormulaAnd()
 {
commit 62f23965591ad3e2a3ee772e518d3fccd6b5ae9f
Author: yiming ju 
Date:   Sun Nov 17 18:58:23 2013 +0800

GPU Calc: implemented SUMPRODUCT WITH FIXED WINDOWS

AMLOEXT-214 FIX

Change-Id: Ifb2797899ec30f998a2387ce9c5752c8e8a03b79
Signed-off-by: haochen 
Signed-off-by: I-Jui (Ray) Sung 

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index 85ebdf0..43aa30d 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -808,6 +808,8 @@ public:
 const std::string sSymName, SubArguments &vSubArguments)
 {
 size_t nCurWindowSize = 0;
+FormulaToken *tmpCur = NULL;
+const formula::DoubleVectorRefToken *pCurDVR = NULL;
 ss << "\ndouble " << sSymName;
 ss << "_"<< BinFuncName() <<"(";
 for (unsigned i = 0; i < vSubArguments.size(); i++)
@@ -816,15 +818,50 @@ public:
 ss << ",";
 vSubArguments[i]->GenSlidingWindowDecl(ss);
 size_t nCurChildWindowSize = vSubArguments[i]->GetWindowSize();
-nCurWindowSize = (nCurWindowSize < nCurChildWindowSize) ?
+nCurWindowSize = (nCurWindowSize < nCurChildWindowSize)?
 nCurChildWindowSize:nCurWindowSize;
+tmpCur = vSubArguments[i]->GetFormulaToken();
+if (  ocPush==tmpCur->GetOpCode() )
+{
+
+pCurDVR = dynamic_cast<
+const formula::DoubleVectorRefToken*>(tmpCur);
+if ( !
+( (!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
+|| (pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) )
+

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

2013-11-22 Thread Wei Wei
 sc/qa/unit/data/ods/opencl/compiler/nested.ods  |binary
 sc/source/core/opencl/formulagroupcl.cxx|   57 ++--
 sc/source/core/opencl/formulagroupcl_public.hxx |1 
 sc/source/core/opencl/opbase.cxx|6 ++
 sc/source/core/opencl/opbase.hxx|1 
 5 files changed, 42 insertions(+), 23 deletions(-)

New commits:
commit 8b7853cc3a1727d6b0a9f7050b26680678e98de0
Author: Wei Wei 
Date:   Fri Nov 22 17:16:49 2013 -0600

GPU Calc: Sum of product doesn't check out-of-bound accesses

AMLOEXT-244 FIX

Change-Id: I5f49f7acccaabd2a97d8ac4bfba4b973889278f1

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index b0bb011..3405459 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -444,13 +444,26 @@ public:
 }
 virtual void GenSlidingWindowFunction(std::stringstream &) {}
 
-virtual std::string GenSlidingWindowDeclRef(bool=false) const
+virtual std::string GenSlidingWindowDeclRef(bool nested=false) const
 {
+size_t nArrayLength = mpDVR->GetArrayLength();
 std::stringstream ss;
 if (!bIsStartFixed && !bIsEndFixed)
+{
+if (nested)
+ss << "((i+gid0) <" << nArrayLength <<"?";
 ss << Base::GetName() << "[i + gid0]";
+if (nested)
+ss << ":NAN)";
+}
 else
+{
+if (nested)
+ss << "(i <" << nArrayLength <<"?";
 ss << Base::GetName() << "[i]";
+if (nested)
+ss << ":NAN)";
+}
 return ss.str();
 }
 /// Controls how the elements in the DoubleVectorRef are traversed
@@ -533,9 +546,9 @@ return nCurWindowSize;
 if(count==0){
 temp1 << "if(i + gid0 < " 
Gen2(GenSlidingWindowDeclRef(), "tmp");
-temp1 << ";\n\t\t\t";
+temp1 << ", tmp);\n\t\t\t";
 temp1 << "}\n\t";
 }
 ss << temp1.str();
@@ -548,9 +561,9 @@ return nCurWindowSize;
 if(count==nCurWindowSize/outLoopSize*outLoopSize){
 temp2 << "if(i + gid0 < " << mpDVR->GetArrayLength();
 temp2 << "){\n\t\t";
-temp2 << "tmp = ";
+temp2 << "tmp = legalize(";
 temp2 << mpCodeGen->Gen2(GenSlidingWindowDeclRef(), 
"tmp");
-temp2 << ";\n\t\t\t";
+temp2 << ", tmp);\n\t\t\t";
 temp2 << "}\n\t";
 }
 ss << temp2.str();
@@ -571,9 +584,9 @@ return nCurWindowSize;
 for(int count=0; count < outLoopSize; count++){
 ss << "i = outLoop*"Gen2(
+"A[loopOffset + lidx + offset]", "tmp") <<", tmp);\n";
+ss << "tmp = legalize(" << mpCodeGen->Gen2(
+"A[loopOffset + lidx + offset + 256]", "tmp") <<", tmp);\n";
 ss << "} else if ((loopOffset + lidx + offset) < end)\n";
-ss << "tmp = " << mpCodeGen->Gen2(
-"A[loopOffset + lidx + offset]", "tmp") <<";\n";
+ss << "tmp = legalize(" << mpCodeGen->Gen2(
+"A[loopOffset + lidx + offset]", "tmp") <<", tmp);\n";
 ss << "shm_buf[lidx] = tmp;\n";
 ss << "barrier(CLK_LOCAL_MEM_FENCE);\n"

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

2013-11-24 Thread Ray
 sc/qa/unit/data/xls/opencl/math/sumproductTest.xls |binary
 sc/qa/unit/opencl-test.cxx |   26 ++
 sc/source/core/opencl/formulagroupcl.cxx   |   52 ++---
 3 files changed, 72 insertions(+), 6 deletions(-)

New commits:
commit 01a977486f050bf61b2c8592426e26cfe4f8
Author: I-Jui (Ray) Sung 
Date:   Mon Nov 25 01:10:04 2013 -0600

GPU Calc: a test case for unrolling SumOfProduct

AMLOEXT-245 BUG

Change-Id: Ia8756af26c765820a04137a87f6681447dd18efd

diff --git a/sc/qa/unit/data/xls/opencl/math/sumproductTest.xls 
b/sc/qa/unit/data/xls/opencl/math/sumproductTest.xls
new file mode 100644
index 000..28eaebf
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/sumproductTest.xls 
differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index faf2ddb..833d9c0 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -242,6 +242,7 @@ public:
 void testStatisticalFormulaCovar();
 void testLogicalFormulaAnd();
 void testMathFormulaSumProduct();
+void testMathFormulaSumProduct2();
 void testStatisticalParallelCountBug();
 CPPUNIT_TEST_SUITE(ScOpenclTest);
 CPPUNIT_TEST(testSharedFormulaXLS);
@@ -416,6 +417,7 @@ public:
 CPPUNIT_TEST(testStatisticalFormulaCovar);
 CPPUNIT_TEST(testLogicalFormulaAnd);
 CPPUNIT_TEST(testMathFormulaSumProduct);
+CPPUNIT_TEST(testMathFormulaSumProduct2);
 CPPUNIT_TEST(testStatisticalParallelCountBug);
 CPPUNIT_TEST_SUITE_END();
 
@@ -4792,6 +4794,30 @@ void ScOpenclTest::testMathFormulaSumProduct()
 xDocSh->DoClose();
 xDocShRes->DoClose();
 }
+//[AMLOEXT-245]
+void ScOpenclTest::testMathFormulaSumProduct2()
+{
+if (!detectOpenCLDevice())
+return;
+ScDocShellRef xDocSh = loadDoc("opencl/math/sumproductTest.", XLS);
+ScDocument* pDoc = xDocSh->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+enableOpenCL();
+pDoc->CalcAll();
+ScDocShellRef xDocShRes = loadDoc("opencl/math/sumproductTest.", XLS);
+ScDocument* pDocRes = xDocShRes->GetDocument();
+CPPUNIT_ASSERT(pDocRes);
+// Check the results of formula cells in the shared formula range.
+for (SCROW i = 2; i <= 12; ++i)
+{
+double fLibre = pDoc->GetValue(ScAddress(4,i,1));
+double fExcel = pDocRes->GetValue(ScAddress(4,i,1));
+CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel,  fLibre, fabs(0.0001*fExcel));
+}
+xDocSh->DoClose();
+xDocShRes->DoClose();
+}
+
 //[AMLOEXT-217]
 void ScOpenclTest:: testLogicalFormulaAnd()
 {
commit 7e3d93e763770c7759555cfe7441573a97d276c1
Author: I-Jui (Ray) Sung 
Date:   Mon Nov 25 01:13:44 2013 -0600

GPU Calc: fixed a SUMPRODUCT problem

ALMOEXT-245

Change-Id: Iedbbdc612232a939b2270e373313c872de831c20

diff --git a/sc/source/core/opencl/formulagroupcl.cxx 
b/sc/source/core/opencl/formulagroupcl.cxx
index 3405459..bee159b 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1103,10 +1103,30 @@ public:
 ss << "for(int outLoop=0; outLoop<" <<
 nCurWindowSize/outLoopSize<< "; outLoop++){\n\t";
 for(int count=0; count < outLoopSize; count++){
-ss << "i = outLoop*"GetOpCode())
+{
+pCurDVR= dynamic_cast<
+const formula::DoubleVectorRefToken *>(tmpCur);
+if(!pCurDVR->IsStartFixed() && 
!pCurDVR->IsEndFixed())
+{
+temp3 << "currentCount";
+temp3 << i;
+temp3 <<" =i+gid0+1;\n";
+}
+else
+{
+temp3 << "currentCount";
+temp3 << i;
+temp3 << " =i+1;\n";
+}
+}
+}
+
 temp3 << "tmp = fsum(";
 for (unsigned i = 0; i < vSubArguments.size(); i++){
 if (i)
@@ -1149,10 +1169,30 @@ public:
 for(unsigned int count=nCurWindowSize/outLoopSize*outLoopSize;
 count < nCurWindowSize; count++)
 {
-ss << "i =" GetOpCode())
+{
+pCurDVR= dynamic_cast<
+const formula::DoubleVectorRefToken *>(tmpCur);
+if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
+{
+temp4 << "currentCount";
+temp4 << i;
+temp4 <<" =i+gid0+1;\n";
+}

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

2014-01-16 Thread Kohei Yoshida
 sc/qa/unit/helper/qahelper.cxx  |2 
 sc/qa/unit/ucalc.hxx|2 
 sc/qa/unit/ucalc_sharedformula.cxx  |   81 
 sc/source/core/data/formulacell.cxx |   17 +++
 4 files changed, 101 insertions(+), 1 deletion(-)

New commits:
commit 8c3b6b34cea6212f4f3f266cc92e76de97d0aa55
Author: Kohei Yoshida 
Date:   Thu Jan 16 12:50:48 2014 -0500

fdo#73655: Write unit test for this.

Change-Id: I0409e3c482d8a833672f41b1398333e5181847af

diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 7666c34..773b779 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -420,7 +420,7 @@ bool checkFormula(ScDocument& rDoc, const ScAddress& rPos, 
const char* pExpected
 return false;
 }
 
-OUString aFormula = toString(rDoc, rPos, *pCode);
+OUString aFormula = toString(rDoc, rPos, *pCode, rDoc.GetGrammar());
 if (aFormula != OUString::createFromAscii(pExpected))
 {
 cerr << "Formula '" << pExpected << "' expected, but '" << aFormula << 
"' found" << endl;
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 1f6f202..1dbfbbc 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -246,6 +246,7 @@ public:
 void testSharedFormulasRefUpdate();
 void testSharedFormulasRefUpdateRange();
 void testSharedFormulasDeleteRows();
+void testSharedFormulasRefUpdateMoveSheets();
 void testSharedFormulasCopyPaste();
 void testFormulaPosition();
 
@@ -396,6 +397,7 @@ public:
 CPPUNIT_TEST(testSharedFormulasRefUpdate);
 CPPUNIT_TEST(testSharedFormulasRefUpdateRange);
 CPPUNIT_TEST(testSharedFormulasDeleteRows);
+CPPUNIT_TEST(testSharedFormulasRefUpdateMoveSheets);
 CPPUNIT_TEST(testSharedFormulasCopyPaste);
 CPPUNIT_TEST(testFormulaPosition);
 CPPUNIT_TEST(testJumpToPrecedentsDependents);
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx 
b/sc/qa/unit/ucalc_sharedformula.cxx
index b1bdea2..b4ce117 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -515,7 +515,88 @@ void Test::testSharedFormulasDeleteRows()
 CPPUNIT_ASSERT_MESSAGE("1,6 must be a shared formula cell.", pFC && 
pFC->IsShared());
 CPPUNIT_ASSERT_EQUAL(static_cast(6), pFC->GetSharedTopRow());
 CPPUNIT_ASSERT_EQUAL(static_cast(8), pFC->GetSharedLength());
+}
+
+void Test::testSharedFormulasRefUpdateMoveSheets()
+{
+m_pDoc->InsertTab(0, "Sheet1");
+m_pDoc->InsertTab(1, "Sheet2");
+m_pDoc->InsertTab(2, "Sheet3");
+
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // make sure auto calc is on.
+
+// Switch to R1C1 for ease of repeated formula insertions.
+FormulaGrammarSwitch aFGSwitch(m_pDoc, 
formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
+
+// Fill numbers in A1:A8 on Sheet2.
+for (SCROW i = 0; i <= 7; ++i)
+m_pDoc->SetValue(ScAddress(0,i,1), i+1);
+
+// Fill formula cells A1:A8 on Sheet1, to refer to the same cell address 
on Sheet2.
+for (SCROW i = 0; i <= 7; ++i)
+m_pDoc->SetString(ScAddress(0,i,0), "=Sheet2!RC");
+
+// Check the results.
+for (SCROW i = 0; i <= 7; ++i)
+CPPUNIT_ASSERT_EQUAL(static_cast(i+1), 
m_pDoc->GetValue(ScAddress(0,i,0)));
+
+// Move Sheet3 to the leftmost position before Sheet1.
+m_pDoc->MoveTab(2, 0);
+
+// Check sheet names.
+std::vector aTabNames = m_pDoc->GetAllTableNames();
+CPPUNIT_ASSERT_MESSAGE("There should be at least 3 sheets.", 
aTabNames.size() >= 3);
+CPPUNIT_ASSERT_EQUAL(OUString("Sheet3"), aTabNames[0]);
+CPPUNIT_ASSERT_EQUAL(OUString("Sheet1"), aTabNames[1]);
+CPPUNIT_ASSERT_EQUAL(OUString("Sheet2"), aTabNames[2]);
+
+// Check the results again on Sheet1.
+for (SCROW i = 0; i <= 7; ++i)
+{
+CPPUNIT_ASSERT_EQUAL(static_cast(i+1), 
m_pDoc->GetValue(ScAddress(0,i,1)));
+if (!checkFormula(*m_pDoc, ScAddress(0,i,1), "Sheet2!RC"))
+CPPUNIT_FAIL("Wrong formula expression.");
+}
+
+// Insert a new sheet at the left end.
+m_pDoc->InsertTab(0, "Sheet4");
+
+// Check sheet names.
+aTabNames = m_pDoc->GetAllTableNames();
+CPPUNIT_ASSERT_MESSAGE("There should be at least 4 sheets.", 
aTabNames.size() >= 4);
+CPPUNIT_ASSERT_EQUAL(OUString("Sheet4"), aTabNames[0]);
+CPPUNIT_ASSERT_EQUAL(OUString("Sheet3"), aTabNames[1]);
+CPPUNIT_ASSERT_EQUAL(OUString("Sheet1"), aTabNames[2]);
+CPPUNIT_ASSERT_EQUAL(OUString("Sheet2"), aTabNames[3]);
+
+// Check the results again on Sheet1.
+for (SCROW i = 0; i <= 7; ++i)
+{
+CPPUNIT_ASSERT_EQUAL(static_cast(i+1), 
m_pDoc->GetValue(ScAddress(0,i,2)));
+if (!checkFormula(*m_pDoc, ScAddress(0,i,2), "Sheet2!RC"))
+CPPUNIT_FAIL("Wrong formula expression.");
+}
+
+// Delete Sheet4.
+m_pDoc->DeleteTab(0);
+
+// Check sheet names.
+aTabNames = m_pDoc->GetAllTableNames();
+CPPUNIT_ASSERT_MESSAGE("There should

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

2014-01-23 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   21 +
 sc/qa/unit/ucalc.hxx|2 ++
 sc/source/core/data/column3.cxx |2 +-
 3 files changed, 24 insertions(+), 1 deletion(-)

New commits:
commit 228cd29a48374833bbe305a434f7149a0ef3ddd1
Author: Kohei Yoshida 
Date:   Thu Jan 23 14:07:25 2014 -0500

fdo#73986: Write unit test for document statistics.

Change-Id: I8ff51fda91627b365cf71be8849d07b92b447ba9

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 357f596..111b940 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -634,6 +634,27 @@ void Test::testInput()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testDocStatistics()
+{
+SCTAB nStartTabs = m_pDoc->GetTableCount();
+m_pDoc->InsertTab(0, "Sheet1");
+CPPUNIT_ASSERT_MESSAGE("Failed to increment sheet count.", 
m_pDoc->GetTableCount() == nStartTabs+1);
+m_pDoc->InsertTab(1, "Sheet2");
+CPPUNIT_ASSERT_MESSAGE("Failed to increment sheet count.", 
m_pDoc->GetTableCount() == nStartTabs+2);
+
+CPPUNIT_ASSERT_EQUAL(static_cast(0), m_pDoc->GetCellCount());
+m_pDoc->SetValue(ScAddress(0,0,0), 2.0);
+CPPUNIT_ASSERT_EQUAL(static_cast(1), m_pDoc->GetCellCount());
+m_pDoc->SetValue(ScAddress(2,2,0), 2.5);
+CPPUNIT_ASSERT_EQUAL(static_cast(2), m_pDoc->GetCellCount());
+m_pDoc->SetString(ScAddress(1,1,1), "Test");
+CPPUNIT_ASSERT_EQUAL(static_cast(3), m_pDoc->GetCellCount());
+
+m_pDoc->DeleteTab(1);
+CPPUNIT_ASSERT_MESSAGE("Failed to decrement sheet count.", 
m_pDoc->GetTableCount() == nStartTabs+1);
+m_pDoc->DeleteTab(0); // This may fail in case there is only one sheet in 
the document.
+}
+
 void Test::testDataEntries()
 {
 m_pDoc->InsertTab(0, "Test");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 1dbfbbc..f6007ff 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -83,6 +83,7 @@ public:
 void testSharedStringPool();
 void testRangeList();
 void testInput();
+void testDocStatistics();
 
 /**
  * The 'data entries' data is a list of strings used for suggestions as
@@ -314,6 +315,7 @@ public:
 CPPUNIT_TEST(testSharedStringPool);
 CPPUNIT_TEST(testRangeList);
 CPPUNIT_TEST(testInput);
+CPPUNIT_TEST(testDocStatistics);
 CPPUNIT_TEST(testDataEntries);
 CPPUNIT_TEST(testSelectionFunction);
 CPPUNIT_TEST(testFormulaCreateStringFromTokens);
commit 9ce7ba209d28cd284ab5ea584bc130d7a081b0f9
Author: Kohei Yoshida 
Date:   Thu Jan 23 14:06:34 2014 -0500

fdo#73986: Don't forget to receive returned object from for_each.

Change-Id: Ia4ccb83c45ea3ce72a8e5c62a560ab1802bb2441

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 7675271..798d544 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2433,7 +2433,7 @@ public:
 SCSIZE ScColumn::GetCellCount() const
 {
 CellCounter aFunc;
-std::for_each(maCells.begin(), maCells.end(), aFunc);
+aFunc = std::for_each(maCells.begin(), maCells.end(), aFunc);
 return aFunc.getCount();
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2013-08-26 Thread Kohei Yoshida
 sc/qa/unit/subsequent_export-test.cxx |  183 --
 sc/source/filter/xml/xmlcelli.cxx |   16 +-
 sc/source/filter/xml/xmlcelli.hxx |2 
 3 files changed, 183 insertions(+), 18 deletions(-)

New commits:
commit 969d5a3b97903fe32b3a7da0c3de8bf86f323c17
Author: Kohei Yoshida 
Date:   Mon Aug 26 15:28:46 2013 -0400

fdo#68581: The first paragraph text can be legitimately empty.

Change-Id: I2309a0c6aebc8a111e67e2e3d591cbabfbbadfb4

diff --git a/sc/source/filter/xml/xmlcelli.cxx 
b/sc/source/filter/xml/xmlcelli.cxx
index 69f5a73..1f17009 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -600,10 +600,10 @@ void ScXMLTableRowCellContext::PushFormat(sal_Int32 
nBegin, sal_Int32 nEnd, cons
 
 OUString ScXMLTableRowCellContext::GetFirstParagraph() const
 {
-if (maFirstParagraph.isEmpty())
+if (!maFirstParagraph)
 return mpEditEngine->GetText(0);
 
-return maFirstParagraph;
+return *maFirstParagraph;
 }
 
 void ScXMLTableRowCellContext::PushParagraphFieldDate(const OUString& 
rStyleName)
@@ -635,12 +635,12 @@ void ScXMLTableRowCellContext::PushParagraphEnd()
 
 if (mbEditEngineHasText)
 {
-if (!maFirstParagraph.isEmpty())
+if (maFirstParagraph)
 {
 // Flush the cached first paragraph first.
 mpEditEngine->Clear();
-mpEditEngine->SetText(maFirstParagraph);
-maFirstParagraph = OUString();
+mpEditEngine->SetText(*maFirstParagraph);
+maFirstParagraph.reset();
 }
 mpEditEngine->InsertParagraph(mpEditEngine->GetParagraphCount(), 
maParagraph.makeStringAndClear());
 }
@@ -652,7 +652,7 @@ void ScXMLTableRowCellContext::PushParagraphEnd()
 }
 else if (mnCurParagraph == 0)
 {
-maFirstParagraph = maParagraph.makeStringAndClear();
+maFirstParagraph.reset(maParagraph.makeStringAndClear());
 mbEditEngineHasText = true;
 }
 
@@ -1089,10 +1089,10 @@ void ScXMLTableRowCellContext::PutTextCell( const 
ScAddress& rCurrentPos,
 }
 else if (mbEditEngineHasText)
 {
-if (!maFirstParagraph.isEmpty())
+if (maFirstParagraph)
 {
 // This is a normal text without format runs.
-rDoc.setStringCell(rCurrentPos, maFirstParagraph);
+rDoc.setStringCell(rCurrentPos, *maFirstParagraph);
 }
 else
 {
diff --git a/sc/source/filter/xml/xmlcelli.hxx 
b/sc/source/filter/xml/xmlcelli.hxx
index e49e3a3..15c95fb 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -63,9 +63,9 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
 boost::optional maFormula; /// table:formula 
attribute
 boost::optional maStringValue; /// office:string-value 
attribute
 boost::optional maContentValidationName;
+boost::optional maFirstParagraph; /// unformatted first 
paragraph, for better performance.
 
 ScEditEngineDefaulter* mpEditEngine;
-OUString maFirstParagraph; /// unformatted first paragraph, for better 
performance.
 OUStringBuffer maParagraph;
 sal_Int32 mnCurParagraph;
 
commit 70e582c8cd3f5f0eedfead6c9da8c771db34e49b
Author: Kohei Yoshida 
Date:   Mon Aug 26 15:11:33 2013 -0400

Add more test cases for rich text cell export to ODS.

This currently fails due to a real bug.

Change-Id: Ia8a91f0794837cae2b6c3beab656f3377f3d0f6a

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 6ec6550..b805e4f 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -36,6 +36,8 @@
 #include "editeng/postitem.hxx"
 #include "editeng/editdata.hxx"
 #include "editeng/eeitem.hxx"
+#include "editeng/editobj.hxx"
+#include "editeng/sectionattribute.hxx"
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -343,10 +345,140 @@ void ScExportTest::testNamedRangeBugfdo62729()
 
 void ScExportTest::testRichTextExportODS()
 {
+struct
+{
+static bool isBold(const editeng::SectionAttribute& rAttr)
+{
+if (rAttr.maAttributes.empty())
+return false;
+
+std::vector::const_iterator it = 
rAttr.maAttributes.begin(), itEnd = rAttr.maAttributes.end();
+for (; it != itEnd; ++it)
+{
+const SfxPoolItem* p = *it;
+if (p->Which() != EE_CHAR_WEIGHT)
+continue;
+
+return static_cast(p)->GetWeight() == 
WEIGHT_BOLD;
+}
+return false;
+}
+
+static bool isItalic(const editeng::SectionAttribute& rAttr)
+{
+if (rAttr.maAttributes.empty())
+return false;
+
+std::vector::const_iterator it = 
rAttr.maAttributes.begin(), itEnd = rAttr.maAttributes.end

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

2013-11-01 Thread mulei
 sc/qa/unit/data/xls/opencl/financial/PMT.xls |binary
 sc/qa/unit/opencl-test.cxx   |   25 +
 sc/source/core/opencl/op_financial.cxx   |  130 +--
 3 files changed, 127 insertions(+), 28 deletions(-)

New commits:
commit 35f8d734dd54cafd1e9d07a1e67b63c366b93a9d
Author: mulei 
Date:   Fri Nov 1 12:02:35 2013 -0500

GPU Calc: implement NAN argument handling in PMT

Change-Id: I1288a20652b4ceb66d90314f7acddb73506dfb43
Signed-off-by: I-Jui (Ray) Sung 
Signed-off-by: haochen 

diff --git a/sc/source/core/opencl/op_financial.cxx 
b/sc/source/core/opencl/op_financial.cxx
index da4845c..69f7d02 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -1837,44 +1837,118 @@ void OpYieldmat::GenSlidingWindowFunction(
 ss << "}";
 }
 
-void OpPMT::GenSlidingWindowFunction(
-std::stringstream &ss, const std::string sSymName, SubArguments 
&vSubArguments)
+void OpPMT::GenSlidingWindowFunction(std::stringstream &ss,
+const std::string sSymName, SubArguments &vSubArguments)
 {
 ss << "\ndouble " << sSymName;
 ss << "_"<< BinFuncName() <<"(";
 for (unsigned i = 0; i < vSubArguments.size(); i++)
 {
 if (i)
-ss << ",";
+ss << ", ";
 vSubArguments[i]->GenSlidingWindowDecl(ss);
 }
-ss << ") {\n\t";
-ss << "double tmp = 0;\n\t";
-ss<<"double tFv=0,tType=0;\n\t";
-ss << "int gid0 = get_global_id(0);\n\t";
- if(vSubArguments.size()==4)
-ss<<"tFv=" 1)
+for (size_t i = 0; i < vSubArguments.size(); i++)
 {
-ss<<"tType="GetFormulaToken();
+assert(pCur);
+if (pCur->GetType() == formula::svDoubleVectorRef)
+{
+const formula::DoubleVectorRefToken* pDVR =
+dynamic_cast(pCur);
+size_t nCurWindowSize = pDVR->GetRefRowSize();
+ss << "for (int i = ";
+if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
+#ifdef  ISNAN
+ss << "gid0; i < " << pDVR->GetArrayLength();
+ss << " && i < " << nCurWindowSize  << "; i++){\n";
+#else
+ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+} else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
+#ifdef  ISNAN
+ss << "0; i < " << pDVR->GetArrayLength();
+ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
+#else
+ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+#endif
+} else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
+#ifdef  ISNAN
+ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ss << " &&  i < "<< nCurWindowSize << "; i++){\n";
+#else
+ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+}
+else {
+#ifdef  ISNAN
+ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+#else
+ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+}
+nItems += nCurWindowSize;
+}
+else if (pCur->GetType() == formula::svSingleVectorRef)
+{
+#ifdef  ISNAN
+const formula::SingleVectorRefToken* pSVR =
+dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
+#else
+nItems += 1;
+#endif
+}
+else if (pCur->GetType() == formula::svDouble)
+{
+#ifdef  ISNAN
+ss << "{\n";
+#endif
+nItems += 1;
+}
+else
+{
+#ifdef  ISNAN
+#endif
+nItems += 1;
+}
+#ifdef  ISNAN
+if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+{
+ss << "if (isNan(";
+ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ss << "))\n";
+ss << "tmp"

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

2014-05-13 Thread Kohei Yoshida
 sc/qa/unit/data/xls/shared-formula/biff5.xls |binary
 sc/qa/unit/subsequent_filters-test.cxx   |   18 ++
 sc/source/filter/excel/read.cxx  |2 +-
 3 files changed, 19 insertions(+), 1 deletion(-)

New commits:
commit 286760359bae7e21a772dd104ab17a1df69a57b0
Author: Kohei Yoshida 
Date:   Tue May 13 14:02:45 2014 -0400

fdo#78471: Don't forget to record the ID of the last record for BIFF5.

Shared formula import code depends on this.

Change-Id: Iecb009252c56673df33e0d681de825911154903a

diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx
index 05d2fca..5c6e6f2 100644
--- a/sc/source/filter/excel/read.cxx
+++ b/sc/source/filter/excel/read.cxx
@@ -90,7 +90,7 @@ FltError ImportExcel::Read( void )
 sal_Size nProgressBasePos = 0;
 sal_Size nProgressBaseSize = 0;
 
-while( eAkt != Z_Ende )
+for (; eAkt != Z_Ende; mnLastRecId = nOpcode)
 {
 if( eAkt == Z_Biff5E )
 {
commit 14e21865443a7318c715c2f9ff655d5b21f716ea
Author: Kohei Yoshida 
Date:   Tue May 13 14:01:53 2014 -0400

fdo#78471: Write test for import of shared formulas from BIFF5.

Change-Id: I77fee109adf1c0decc6eb96cf2292f89fde1aceb

diff --git a/sc/qa/unit/data/xls/shared-formula/biff5.xls 
b/sc/qa/unit/data/xls/shared-formula/biff5.xls
new file mode 100644
index 000..ce72eb1
Binary files /dev/null and b/sc/qa/unit/data/xls/shared-formula/biff5.xls differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index ef0428d..2e5a8f6 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -170,6 +170,7 @@ public:
 
 void testSharedFormulaHorizontalXLS();
 void testSharedFormulaWrappedRefsXLS();
+void testSharedFormulaBIFF5();
 void testExternalRefCacheXLSX();
 void testExternalRefCacheODS();
 void testHybridSharedStringODS();
@@ -247,6 +248,7 @@ public:
 CPPUNIT_TEST(testColumnStyleXLSX);
 CPPUNIT_TEST(testSharedFormulaHorizontalXLS);
 CPPUNIT_TEST(testSharedFormulaWrappedRefsXLS);
+CPPUNIT_TEST(testSharedFormulaBIFF5);
 CPPUNIT_TEST(testExternalRefCacheXLSX);
 CPPUNIT_TEST(testExternalRefCacheODS);
 CPPUNIT_TEST(testHybridSharedStringODS);
@@ -2522,6 +2524,22 @@ void ScFiltersTest::testSharedFormulaWrappedRefsXLS()
 xDocSh->DoClose();
 }
 
+void ScFiltersTest::testSharedFormulaBIFF5()
+{
+ScDocShellRef xDocSh = loadDoc("shared-formula/biff5.", XLS);
+CPPUNIT_ASSERT(xDocSh.Is());
+ScDocument* pDoc = xDocSh->GetDocument();
+pDoc->CalcAll();
+
+// E6:E376 should be all formulas, and they should belong to the same 
group.
+const ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(4,5,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_EQUAL(static_cast(5), pFC->GetSharedTopRow());
+CPPUNIT_ASSERT_EQUAL(static_cast(371), pFC->GetSharedLength());
+
+xDocSh->DoClose();
+}
+
 void ScFiltersTest::testExternalRefCacheXLSX()
 {
 ScDocShellRef xDocSh = loadDoc("external-refs.", XLSX);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-05-13 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx |  106 +++
 sc/qa/unit/ucalc.hxx |2 
 sc/source/core/data/conditio.cxx |   37 +
 3 files changed, 145 insertions(+)

New commits:
commit 146f6e7e68ea56f79b72047b97bd9fba66db499d
Author: Kohei Yoshida 
Date:   Tue May 13 22:46:17 2014 -0400

fdo#76710: Adjust sheet position of conditional format entries.

When inserting or deleting sheets.

Change-Id: Ibf898350e22f092ec38b75ad98957832a5580e6a

diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 49f2fea..80a2b53 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -2002,12 +2002,49 @@ void ScConditionalFormat::InsertCol(SCTAB nTab, SCROW 
nRowStart, SCROW nRowEnd,
 
 void ScConditionalFormat::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt 
)
 {
+for (size_t i = 0, n = maRanges.size(); i < n; ++i)
+{
+// We assume that the start and end sheet indices are equal.
+ScRange* pRange = maRanges[i];
+SCTAB nTab = pRange->aStart.Tab();
+
+if (nTab < rCxt.mnInsertPos)
+// Unaffected.
+continue;
+
+pRange->aStart.IncTab(rCxt.mnSheets);
+pRange->aEnd.IncTab(rCxt.mnSheets);
+}
+
 for (CondFormatContainer::iterator it = maEntries.begin(); it != 
maEntries.end(); ++it)
 it->UpdateInsertTab(rCxt);
 }
 
 void ScConditionalFormat::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt 
)
 {
+for (size_t i = 0, n = maRanges.size(); i < n; ++i)
+{
+// We assume that the start and end sheet indices are equal.
+ScRange* pRange = maRanges[i];
+SCTAB nTab = pRange->aStart.Tab();
+
+if (nTab < rCxt.mnDeletePos)
+// Left of the deleted sheet(s).  Unaffected.
+continue;
+
+if (nTab <= rCxt.mnDeletePos+rCxt.mnSheets-1)
+{
+// On the deleted sheet(s).
+pRange->aStart.SetTab(-1);
+pRange->aEnd.SetTab(-1);
+continue;
+}
+
+// Right of the deleted sheet(s).  Adjust the sheet indices.
+pRange->aStart.IncTab(-1*rCxt.mnSheets);
+pRange->aEnd.IncTab(-1*rCxt.mnSheets);
+}
+
 for (CondFormatContainer::iterator it = maEntries.begin(); it != 
maEntries.end(); ++it)
 it->UpdateDeleteTab(rCxt);
 }
commit dff4725f0dbb3bd7c32155e51ba49c05ee104d4f
Author: Kohei Yoshida 
Date:   Tue May 13 22:42:44 2014 -0400

fdo#76710: Write test for this.

Change-Id: Ia0338d2839f0f319881948c208a74bee950da4af

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 2a2f706..14a323b 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5882,6 +5882,112 @@ void Test::testCondFormatInsertRow()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testCondFormatInsertDeleteSheets()
+{
+m_pDoc->InsertTab(0, "Test");
+
+// Add a conditional format to B2:B4.
+ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+pFormat->AddRange(ScRange(1,1,0,1,3,0));
+
+sal_uLong nKey = m_pDoc->AddCondFormat(pFormat, 0);
+
+// Add condition in which if the value equals 2, set the "Result" style.
+ScCondFormatEntry* pEntry = new ScCondFormatEntry(
+SC_COND_EQUAL, "=2", "" , m_pDoc, ScAddress(0,0,0), 
ScGlobal::GetRscString(STR_STYLENAME_RESULT));
+pFormat->AddEntry(pEntry);
+
+// Apply the format to the range.
+m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, nKey);
+
+// Make sure this conditional format entry is really there.
+ScConditionalFormatList* pList = m_pDoc->GetCondFormList(0);
+CPPUNIT_ASSERT(pList);
+const ScConditionalFormat* pCheck = pList->GetFormat(nKey);
+CPPUNIT_ASSERT_MESSAGE("Wrong condntional format instance.", pCheck == 
pFormat);
+
+// ... and its range is B2:B4.
+ScRangeList aCheckRange = pCheck->GetRange();
+CPPUNIT_ASSERT_MESSAGE("This should be a single range.", 
aCheckRange.size() == 1);
+const ScRange* pRange = aCheckRange[0];
+CPPUNIT_ASSERT(pRange);
+CPPUNIT_ASSERT_MESSAGE("Format should be applied to B2:B4.", *pRange == 
ScRange(1,1,0,1,3,0));
+
+ScDocFunc& rFunc = getDocShell().GetDocFunc();
+
+// Insert a new sheet at the left.
+bool bInserted = rFunc.InsertTable(0, "Inserted", true, true);
+CPPUNIT_ASSERT(bInserted);
+
+pList = m_pDoc->GetCondFormList(1);
+CPPUNIT_ASSERT(pList);
+pCheck = pList->GetFormat(nKey);
+CPPUNIT_ASSERT(pCheck);
+
+// Make sure the range also got shifted.
+aCheckRange = pCheck->GetRange();
+CPPUNIT_ASSERT_MESSAGE("This should be a single range.", 
aCheckRange.size() == 1);
+pRange = aCheckRange[0];
+CPPUNIT_ASSERT(pRange);
+CPPUNIT_ASSERT_MESSAGE("Format should be applied to B2:B4 on the 2nd sheet 
after the sheet insertion.", *pRange == ScRange(1,1,1,1,3,1));
+
+// Delete the sheet to the left.
+bool bDeleted = rFunc.DeleteTable(0, true,

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

2014-05-15 Thread Kohei Yoshida
 sc/qa/unit/subsequent_export-test.cxx |  113 --
 sc/source/filter/xml/xmlexprt.cxx |   14 +++-
 2 files changed, 107 insertions(+), 20 deletions(-)

New commits:
commit 48eccfb812284f43ba24c3be3903537ce954944d
Author: Kohei Yoshida 
Date:   Thu May 15 20:32:05 2014 -0400

fdo#77537: Exporting font names in edit text needs special handling.

Change-Id: Ia9c29d37eaf962e0245920e50f534dd779af72dc

diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index b1f831d..737a881 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1116,10 +1116,18 @@ const SvxFieldData* toXMLPropertyStates(
 case EE_CHAR_FONTINFO_CJK:
 case EE_CHAR_FONTINFO_CTL:
 {
-if (!static_cast(p)->QueryValue(aAny, 
pEntry->mnFlag))
-continue;
+// Apparently font info needs special handling.
+const SvxFontItem* pItem = static_cast(p);
 
-rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+sal_Int32 nIndexFontName = 
xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, "font-name", 0);
+
+if (nIndexFontName == -1 || nIndexFontName >= nEntryCount)
+break;
+
+if (!pItem->QueryValue(aAny, MID_FONT_FAMILY_NAME))
+break;
+
+rPropStates.push_back(XMLPropertyState(nIndexFontName, aAny));
 }
 break;
 case EE_CHAR_WEIGHT:
commit 90f7bd61fb1c4665051f721bb7721277a79eb267
Author: Kohei Yoshida 
Date:   Thu May 15 20:27:44 2014 -0400

fdo#77537: Write export test for this.

Change-Id: I2960713b1005c5f91fe78d12e33f1786978eac67

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index f984e69..ab25140 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -441,6 +442,19 @@ void setAttribute( ScFieldEditEngine& rEE, sal_Int32 
nPara, sal_Int32 nStart, sa
 }
 }
 
+void setFont( ScFieldEditEngine& rEE, sal_Int32 nPara, sal_Int32 nStart, 
sal_Int32 nEnd, const OUString& rFontName )
+{
+ESelection aSel;
+aSel.nStartPara = aSel.nEndPara = nPara;
+aSel.nStartPos = nStart;
+aSel.nEndPos = nEnd;
+
+SfxItemSet aItemSet = rEE.GetEmptyItemSet();
+SvxFontItem aItem(FAMILY_MODERN, rFontName, "", PITCH_VARIABLE, 
RTL_TEXTENCODING_UTF8, EE_CHAR_FONTINFO);
+aItemSet.Put(aItem);
+rEE.QuickSetAttribs(aItemSet, aSel);
+}
+
 }
 
 void ScExportTest::testNamedRangeBugfdo62729()
@@ -525,6 +539,23 @@ void ScExportTest::testRichTextExportODS()
 return false;
 }
 
+static bool isFont(const editeng::Section& rAttr, const OUString& 
rFontName)
+{
+if (rAttr.maAttributes.empty())
+return false;
+
+std::vector::const_iterator it = 
rAttr.maAttributes.begin(), itEnd = rAttr.maAttributes.end();
+for (; it != itEnd; ++it)
+{
+const SfxPoolItem* p = *it;
+if (p->Which() != EE_CHAR_FONTINFO)
+continue;
+
+return static_cast(p)->GetFamilyName() == 
rFontName;
+}
+return false;
+}
+
 bool checkB2(const EditTextObject* pText) const
 {
 if (!pText)
@@ -649,27 +680,62 @@ void ScExportTest::testRichTextExportODS()
 return true;
 }
 
+bool checkB7(const EditTextObject* pText) const
+{
+if (!pText)
+return false;
+
+if (pText->GetParagraphCount() != 1)
+return false;
+
+if (pText->GetText(0) != "Font1 and Font2")
+return false;
+
+std::vector aSecAttrs;
+pText->GetAllSections(aSecAttrs);
+if (aSecAttrs.size() != 3)
+return false;
+
+// First section should have "Courier" font applied.
+const editeng::Section* pAttr = &aSecAttrs[0];
+if (pAttr->mnParagraph != 0 ||pAttr->mnStart != 0 || pAttr->mnEnd 
!= 5)
+return false;
+
+if (pAttr->maAttributes.size() != 1 || !isFont(*pAttr, "Courier"))
+return false;
+
+// Last section should have "Luxi Mono" applied.
+pAttr = &aSecAttrs[2];
+if (pAttr->mnParagraph != 0 ||pAttr->mnStart != 10 || pAttr->mnEnd 
!= 15)
+return false;
+
+if (pAttr->maAttributes.size() != 1 || !isFont(*pAttr, "Luxi 
Mono"))
+return false;
+
+return true;
+}
+
 } aCheckFunc;
 
 // Start with an empty document, put one edit text cell, and make sure it
 // survives the save and reload.
-ScDocShellRef xOrigDocSh = loadDoc("empty."

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

2014-05-16 Thread Kohei Yoshida
 sc/qa/unit/subsequent_export-test.cxx |  131 +-
 sc/source/filter/xml/xmlexprt.cxx |   39 +-
 2 files changed, 149 insertions(+), 21 deletions(-)

New commits:
commit fcf5b5c081ded93b12dd888236d0a860b7693ed1
Author: Kohei Yoshida 
Date:   Fri May 16 10:45:40 2014 -0400

fdo#75056: Overline attribute needs special treatment as well.

Also fix the export of underline types as well.  It was always saved
as a single line.

Change-Id: I88cb0f3702a6afc14544ecbce8f200b5422fd78f

diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 737a881..d61496e 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1171,6 +1171,10 @@ const SvxFieldData* toXMLPropertyStates(
 if (nIndexWidth == -1 || nIndexWidth > nEntryCount)
 break;
 
+sal_Int32 nIndexType = 
xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, "text-underline-type", 0);
+if (nIndexType == -1 || nIndexType > nEntryCount)
+break;
+
 sal_Int32 nIndexColor = 
xMapper->FindEntryIndex("CharUnderlineColor", XML_NAMESPACE_STYLE, 
"text-underline-color");
 if (nIndexColor == -1 || nIndexColor > nEntryCount)
 break;
@@ -1182,6 +1186,7 @@ const SvxFieldData* toXMLPropertyStates(
 const SvxUnderlineItem* pUL = static_cast(p);
 pUL->QueryValue(aAny, MID_TL_STYLE);
 rPropStates.push_back(XMLPropertyState(nIndexStyle, aAny));
+rPropStates.push_back(XMLPropertyState(nIndexType,  aAny));
 rPropStates.push_back(XMLPropertyState(nIndexWidth, aAny));
 
 pUL->QueryValue(aAny, MID_TL_COLOR);
@@ -1193,10 +1198,38 @@ const SvxFieldData* toXMLPropertyStates(
 break;
 case EE_CHAR_OVERLINE:
 {
-if (!static_cast(p)->QueryValue(aAny, 
pEntry->mnFlag))
-continue;
+// Same with overline.  Do just as we do with underline 
attributes.
+sal_Int32 nIndexStyle = 
xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, "text-overline-style", 0);
+if (nIndexStyle == -1 || nIndexStyle > nEntryCount)
+break;
 
-rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+sal_Int32 nIndexWidth = 
xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, "text-overline-width", 0);
+if (nIndexWidth == -1 || nIndexWidth > nEntryCount)
+break;
+
+sal_Int32 nIndexType = 
xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, "text-overline-type", 0);
+if (nIndexType == -1 || nIndexType > nEntryCount)
+break;
+
+sal_Int32 nIndexColor = 
xMapper->FindEntryIndex("CharOverlineColor", XML_NAMESPACE_STYLE, 
"text-overline-color");
+if (nIndexColor == -1 || nIndexColor > nEntryCount)
+break;
+
+sal_Int32 nIndexHasColor = 
xMapper->FindEntryIndex("CharOverlineHasColor", XML_NAMESPACE_STYLE, 
"text-overline-color");
+if (nIndexHasColor == -1 || nIndexHasColor > nEntryCount)
+break;
+
+const SvxOverlineItem* pOL = static_cast(p);
+pOL->QueryValue(aAny, MID_TL_STYLE);
+rPropStates.push_back(XMLPropertyState(nIndexStyle, aAny));
+rPropStates.push_back(XMLPropertyState(nIndexType,  aAny));
+rPropStates.push_back(XMLPropertyState(nIndexWidth, aAny));
+
+pOL->QueryValue(aAny, MID_TL_COLOR);
+rPropStates.push_back(XMLPropertyState(nIndexColor, aAny));
+
+pOL->QueryValue(aAny, MID_TL_HASCOLOR);
+rPropStates.push_back(XMLPropertyState(nIndexHasColor, aAny));
 }
 break;
 case EE_CHAR_COLOR:
commit 5c0b8937f4f41ed1e4a01151bc96113f65c2770c
Author: Kohei Yoshida 
Date:   Fri May 16 10:45:09 2014 -0400

fdo#75056: Write test for this.

Change-Id: I716467ffe81a1f71f03e0dc7a17c33b2ed39d334

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index ab25140..2e36357 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -45,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -437,6 +438,20 @@ void setAttribute( ScFieldEditEngine& rEE, sal_Int32 
nPara, sal_Int32 nStart, sa
 rEE.QuickSetAttribs(aItemSet, aSel);
 }
 break;
+case EE_CHAR_OVERLINE:
+{
+SvxOverlineItem aItem(UNDERLINE_DOUBLE, nType);
+aItemSet.Put(aItem);
+rEE.QuickSetAttribs(aItemSet, aSel);
+}
+break;
+case EE_CHAR_UNDERLINE:
+{
+SvxUnderlineItem aItem(UNDERLINE_DOUB

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

2014-05-16 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   25 +
 sc/qa/unit/ucalc.hxx|2 ++
 sc/source/core/data/column4.cxx |4 
 3 files changed, 31 insertions(+)

New commits:
commit bc7e0967be52f5eb7948fbb1c30edc7dd5acc18d
Author: Kohei Yoshida 
Date:   Fri May 16 23:06:33 2014 -0400

fdo#77735: Don't proceed when all cells in the range are empty.

That means there is nothing to delete, and proceeding would cause Calc
to freeze.

Change-Id: I2a8fb5736870ba459082873c8f864283d8b9c664

diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index c5465c6..4acb374 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -59,6 +59,10 @@ void ScColumn::DeleteBeforeCopyFromClip( 
sc::CopyFromClipContext& rCxt, const Sc
 sc::SingleColumnSpanSet::SpansType aSpans;
 aSpanSet.getSpans(aSpans);
 
+if (aSpans.empty())
+// All cells in the range in the clip are empty.  Nothing to delete.
+return;
+
 // Translate the clip column spans into the destination column, and repeat 
as needed.
 std::vector aDestSpans;
 SCROW nDestOffset = aRange.mnRow1 - nClipRow1;
commit 30cc43a56d63ba9ffd588ebc589e3576483d7141
Author: Kohei Yoshida 
Date:   Fri May 16 23:05:40 2014 -0400

fdo#77735: Write test for this.  This test will freeze with the bug present.

Change-Id: I7b7e67fe2ee59b57ce74f8303d30bebc84f6b0d0

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 14a323b..b086711 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3706,6 +3706,31 @@ void Test::testCopyPasteSkipEmpty()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testCopyPasteSkipEmpty2()
+{
+m_pDoc->InsertTab(0, "Test");
+
+m_pDoc->SetString(ScAddress(0,0,0), "A");
+m_pDoc->SetString(ScAddress(2,0,0), "C");
+
+// Copy A1:C1 to clipboard.
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+aClipDoc.ResetClip(m_pDoc, static_cast(0));
+copyToClip(m_pDoc, ScRange(0,0,0,2,0,0), &aClipDoc);
+
+// Paste to A3 with the skip empty option set.  This used to freeze. 
(fdo#77735)
+ScRange aDestRange(0,2,0,2,2,0);
+ScMarkData aMark;
+aMark.SetMarkArea(aDestRange);
+m_pDoc->CopyFromClip(aDestRange, aMark, IDF_ALL, NULL, &aClipDoc, false, 
false, true, true);
+
+CPPUNIT_ASSERT_EQUAL(OUString("A"), m_pDoc->GetString(ScAddress(0,2,0)));
+CPPUNIT_ASSERT_MESSAGE("B3 should be empty.", 
m_pDoc->GetCellType(ScAddress(1,2,0)) == CELLTYPE_NONE);
+CPPUNIT_ASSERT_EQUAL(OUString("C"), m_pDoc->GetString(ScAddress(2,2,0)));
+
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testCopyPasteSkipEmptyConditionalFormatting()
 {
 m_pDoc->InsertTab(0, "Test");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 35d57ce..66fbfd5 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -273,6 +273,7 @@ public:
 void testCopyPasteTranspose();
 void testCopyPasteMultiRange();
 void testCopyPasteSkipEmpty();
+void testCopyPasteSkipEmpty2();
 void testCopyPasteSkipEmptyConditionalFormatting();
 void testCutPasteRefUndo();
 void testUndoCut();
@@ -469,6 +470,7 @@ public:
 CPPUNIT_TEST(testCopyPasteTranspose);
 CPPUNIT_TEST(testCopyPasteMultiRange);
 CPPUNIT_TEST(testCopyPasteSkipEmpty);
+CPPUNIT_TEST(testCopyPasteSkipEmpty2);
 //CPPUNIT_TEST(testCopyPasteSkipEmptyConditionalFormatting);
 CPPUNIT_TEST(testCutPasteRefUndo);
 CPPUNIT_TEST(testUndoCut);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-05-22 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   57 
 sc/qa/unit/ucalc.hxx|3 ++
 sc/source/core/data/column3.cxx |   22 ---
 3 files changed, 60 insertions(+), 22 deletions(-)

New commits:
commit cb167ac784f9b16944da4494b65e56b2a5b66bb7
Author: Kohei Yoshida 
Date:   Thu May 22 20:56:04 2014 -0400

fdo#78903: Don't broadcast prematurely during cell deletion.

We need to wait until all the affected cells get marked dirty at the
end of the deletion process.

Change-Id: I49618fcc386ec2209f5f0267d50257ecb8dd21d1

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 3d447d1..2d54fd5 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -169,11 +169,6 @@ public:
 maRows.push_back(i + nTopRow);
 }
 
-void endFormulas()
-{
-mrDoc.EndListeningFormulaCells(maFormulaCells);
-}
-
 const std::vector& getNonEmptyRows() const
 {
 return maRows;
@@ -266,12 +261,6 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
 
 sc::AutoCalcSwitch aACSwitch(*pDocument, false);
 
-// Parse all non-empty cells in the range to pick up their row positions,
-// and end all formula cells.
-DeleteRowsHandler aDeleteRowsFunc(*pDocument);
-sc::ProcessFormula(itCell, maCells, nStartRow, nEndRow, aDeleteRowsFunc, 
aDeleteRowsFunc);
-aDeleteRowsFunc.endFormulas();
-
 // Remove the cells.
 maCells.erase(nStartRow, nEndRow);
 maCells.resize(MAXROWCOUNT);
@@ -285,22 +274,11 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
 
 sc::SharedFormulaUtil::joinFormulaCellAbove(aPos);
 
-// Single cell broadcasts on deleted cells.
-BroadcastCells(aDeleteRowsFunc.getNonEmptyRows(), SC_HINT_DATACHANGED);
-
 // Shift the text attribute array too (before the broadcast).
 maCellTextAttrs.erase(nStartRow, nEndRow);
 maCellTextAttrs.resize(MAXROWCOUNT);
 
 CellStorageModified();
-
-if (!bShiftCells)
-return;
-
-// Do area broadcast on the old non-empty cell ranges prior to the shift.
-sc::SingleColumnSpanSet::SpansType aSpans;
-aNonEmptySpans.getSpans(aSpans);
-std::for_each(aSpans.begin(), aSpans.end(), RangeBroadcaster(*pDocument, 
nTab, nCol));
 }
 
 sc::CellStoreType::iterator ScColumn::GetPositionToInsert( SCROW nRow )
commit fa2751ea5ce9066002a250f06bf5d056f6e0b71b
Author: Kohei Yoshida 
Date:   Thu May 22 20:54:08 2014 -0400

fdo#78903: Write test for this.

Change-Id: If8ed8b74b58efd948772376a14172b52ff588f82

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 8e65f68..38f7a3b 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1352,6 +1352,63 @@ void Test::testFormulaDepTracking2()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testFormulaDepTrackingDeleteRow()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
+
+m_pDoc->InsertTab(0, "Test");
+
+// Values in A1:A3.
+m_pDoc->SetValue(ScAddress(0,0,0), 1.0);
+m_pDoc->SetValue(ScAddress(0,1,0), 3.0);
+m_pDoc->SetValue(ScAddress(0,2,0), 5.0);
+
+// SUM(A1:A3) in A5.
+m_pDoc->SetString(ScAddress(0,4,0), "=SUM(A1:A3)");
+
+// A6 to reference A5.
+m_pDoc->SetString(ScAddress(0,5,0), "=A5*10");
+const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0,5,0));
+CPPUNIT_ASSERT(pFC);
+
+// A4 should have a broadcaster with A5 listening to it.
+SvtBroadcaster* pBC = m_pDoc->GetBroadcaster(ScAddress(0,4,0));
+fprintf(stdout, "Test::testFormulaDepTrackingDeleteRow:   broadcaster at 
A5 = %p\n", pBC);
+CPPUNIT_ASSERT(pBC);
+SvtBroadcaster::ListenersType* pListeners = &pBC->GetAllListeners();
+CPPUNIT_ASSERT_MESSAGE("A5 should have one listener.", pListeners->size() 
== 1);
+SvtListener* pListener = pListeners->at(0);
+CPPUNIT_ASSERT_MESSAGE("A6 should be listening to A5.", pListener == pFC);
+
+// Check initial values.
+CPPUNIT_ASSERT_EQUAL(9.0, m_pDoc->GetValue(ScAddress(0,4,0)));
+CPPUNIT_ASSERT_EQUAL(90.0, m_pDoc->GetValue(ScAddress(0,5,0)));
+
+fprintf(stdout, "Test::testFormulaDepTrackingDeleteRow:   Deleting row 
2\n");
+// Delete row 2.
+ScDocFunc& rFunc = getDocShell().GetDocFunc();
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+rFunc.DeleteCells(ScRange(0,1,0,MAXCOL,1,0), &aMark, DEL_CELLSUP, true, 
true);
+fprintf(stdout, "Test::testFormulaDepTrackingDeleteRow:   Done deleting 
row 2.\n");
+
+pBC = m_pDoc->GetBroadcaster(ScAddress(0,3,0));
+fprintf(stdout, "Test::testFormulaDepTrackingDeleteRow:   broadcaster at 
A4 = %p\n", pBC);
+CPPUNIT_ASSERT_MESSAGE("Broadcaster at A5 should have shifted to A4.", 
pBC);
+pListeners = &pBC->GetAllListeners();
+CPPUNIT_ASSERT_MESSAGE("A3 should have one listener.", pListeners->size() 
== 1);
+pFC = m_pDoc->GetFormulaCell(ScAddress(0,4,0));
+CPPUNIT_ASSERT(pF

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

2014-05-27 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx   |   43 +
 sc/qa/unit/ucalc.hxx   |2 +
 sc/source/core/data/column.cxx |2 -
 3 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 054213e86b8f3b1084474b0447cc7ffaf82178c5
Author: Kohei Yoshida 
Date:   Tue May 27 14:47:24 2014 -0400

fdo#78976: Correct way to determine the end position for matrix check.

Change-Id: Ifd6acd85a9bf33742cb62327a3b8a4320f35d0f3

diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 485f5e8..7d6ebb1 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -154,7 +154,7 @@ sal_uInt16 ScColumn::GetBlockMatrixEdges( SCROW nRow1, 
SCROW nRow2, sal_uInt16 n
 }
 
 size_t nRowsToRead = nRow2 - nRow + 1;
-size_t nEnd = std::min(it->size, nRowsToRead);
+size_t nEnd = std::min(it->size, nOffset+nRowsToRead); // last row + 1
 sc::formula_block::const_iterator itCell = 
sc::formula_block::begin(*it->data);
 std::advance(itCell, nOffset);
 for (size_t i = nOffset; i < nEnd; ++itCell, ++i)
commit 175519643daa87ba3e65eb4b52df3c8a2f60ac64
Author: Kohei Yoshida 
Date:   Tue May 27 14:47:05 2014 -0400

fdo#78976: Test for this.

Change-Id: I454e29c2cdf0857d329d84000d79973489cebb41

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index aa7ac1a..3396446 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -64,6 +64,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 
 #include 
@@ -2196,6 +2198,47 @@ void Test::testEnterMixedMatrix()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testMatrixEditable()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+m_pDoc->InsertTab(0, "Test");
+
+// Values in A1:B1.
+m_pDoc->SetValue(ScAddress(0,0,0), 1.0);
+m_pDoc->SetValue(ScAddress(1,0,0), 2.0);
+
+// A2 is a normal formula.
+m_pDoc->SetString(ScAddress(0,1,0), "=5");
+
+// A3:A4 is a matrix.
+ScRange aMatRange(0,2,0,0,3,0);
+ScMarkData aMark;
+aMark.SetMarkArea(aMatRange);
+m_pDoc->InsertMatrixFormula(0, 2, 0, 3, aMark, "=TRANSPOSE(A1:B1)", NULL);
+
+// Check their values.
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,2,0)));
+CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,3,0)));
+
+// Make sure A3:A4 is a matrix.
+ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0,2,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_MESSAGE("A3 should be matrix origin.", pFC->GetMatrixFlag() 
== MM_FORMULA);
+
+pFC = m_pDoc->GetFormulaCell(ScAddress(0,3,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_MESSAGE("A4 should be matrix reference.", 
pFC->GetMatrixFlag() == MM_REFERENCE);
+
+// Check to make sure A3:A4 combined is editable.
+ScEditableTester aTester;
+aTester.TestSelection(m_pDoc, aMark);
+CPPUNIT_ASSERT(aTester.IsEditable());
+
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testCellCopy()
 {
 m_pDoc->InsertTab(0, "TestTab");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 39862ee..73181ee 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -195,6 +195,7 @@ public:
 void testCSV();
 void testMatrix();
 void testEnterMixedMatrix();
+void testMatrixEditable();
 
 /**
  * Basic test for pivot tables.
@@ -442,6 +443,7 @@ public:
 CPPUNIT_TEST(testCSV);
 CPPUNIT_TEST(testMatrix);
 CPPUNIT_TEST(testEnterMixedMatrix);
+CPPUNIT_TEST(testMatrixEditable);
 CPPUNIT_TEST(testPivotTable);
 CPPUNIT_TEST(testPivotTableLabels);
 CPPUNIT_TEST(testPivotTableDateLabels);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-07-29 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx  |   42 ++
 sc/qa/unit/ucalc.hxx  |2 ++
 sc/source/core/tool/token.cxx |5 +
 3 files changed, 49 insertions(+)

New commits:
commit 5e55d5ffb70437e917e4092f4030d5a454fd20d6
Author: Kohei Yoshida 
Date:   Tue Jul 29 22:33:56 2014 -0400

fdo#81330: When moving to a different sheet, set 3D flag on.

Change-Id: I16c6e687259635c4d0ac0e5dab0140941b409bc8

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 99a26a8..569834a 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2812,6 +2812,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
 ScRange aOldRange = rCxt.maRange;
 aOldRange.Move(-rCxt.mnColDelta, -rCxt.mnRowDelta, -rCxt.mnTabDelta);
 
+bool b3DFlag = rOldPos.Tab() != rNewPos.Tab();
+
 FormulaToken** p = pCode;
 FormulaToken** pEnd = p + static_cast(nLen);
 for (; p != pEnd; ++p)
@@ -2830,6 +2832,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
 }
 
 rRef.SetAddress(aAbs, rNewPos);
+rRef.SetFlag3D(b3DFlag);
 }
 break;
 case svDoubleRef:
@@ -2844,6 +2847,8 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
 }
 
 rRef.SetRange(aAbs, rNewPos);
+if (b3DFlag)
+rRef.Ref1.SetFlag3D(true);
 }
 break;
 case svIndex:
commit 6a816d1fdd63532c3a85ee9e7fe20040ee754f1a
Author: Kohei Yoshida 
Date:   Tue Jul 29 21:19:29 2014 -0400

fdo#81330: Write test for this.

Change-Id: Id781b13b180c0622bfb01cf2ca844fa452061b50

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index bbed0c7..02950cf 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3942,6 +3942,48 @@ void Test::testCutPasteRefUndo()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testMoveRefBetweenSheets()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+
+m_pDoc->InsertTab(0, "Test1");
+m_pDoc->InsertTab(1, "Test2");
+
+m_pDoc->SetValue(ScAddress(0,0,0), 12.0);
+m_pDoc->SetValue(ScAddress(1,0,0), 10.0);
+m_pDoc->SetValue(ScAddress(2,0,0),  8.0);
+m_pDoc->SetString(ScAddress(0,1,0), "=A1");
+m_pDoc->SetString(ScAddress(0,2,0), "=SUM(A1:C1)");
+
+CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0,0,0)));
+CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0,2,0)));
+
+// These formulas should not display the sheet name.
+if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "A1"))
+CPPUNIT_FAIL("Wrong formula!");
+if (!checkFormula(*m_pDoc, ScAddress(0,2,0), "SUM(A1:C1)"))
+CPPUNIT_FAIL("Wrong formula!");
+
+// Move Test1.A2:A3 to Test2.A2:A3.
+ScDocFunc& rFunc = getDocShell().GetDocFunc();
+bool bMoved = rFunc.MoveBlock(ScRange(0,1,0,0,2,0), ScAddress(0,1,1), 
true, true, false, true);
+CPPUNIT_ASSERT(bMoved);
+
+CPPUNIT_ASSERT_MESSAGE("This cell should be empty after the move.", 
m_pDoc->GetCellType(ScAddress(0,1,0)) == CELLTYPE_NONE);
+CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(0,1,1)));
+CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(ScAddress(0,2,1)));
+
+// The reference in the pasted formula should display sheet name after the 
move.
+if (!checkFormula(*m_pDoc, ScAddress(0,1,1), "Test1.A1"))
+CPPUNIT_FAIL("Wrong formula!");
+if (!checkFormula(*m_pDoc, ScAddress(0,2,1), "SUM(Test1.A1:C1)"))
+CPPUNIT_FAIL("Wrong formula!");
+
+m_pDoc->DeleteTab(1);
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testUndoCut()
 {
 m_pDoc->InsertTab(0, "Test");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index cf3d0d5..471cf82 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -280,6 +280,7 @@ public:
 void testCopyPasteSkipEmpty2();
 void testCopyPasteSkipEmptyConditionalFormatting();
 void testCutPasteRefUndo();
+void testMoveRefBetweenSheets();
 void testUndoCut();
 void testMoveBlock();
 void testCopyPasteRelativeFormula();
@@ -487,6 +488,7 @@ public:
 CPPUNIT_TEST(testCopyPasteSkipEmpty2);
 //CPPUNIT_TEST(testCopyPasteSkipEmptyConditionalFormatting);
 CPPUNIT_TEST(testCutPasteRefUndo);
+CPPUNIT_TEST(testMoveRefBetweenSheets);
 CPPUNIT_TEST(testUndoCut);
 CPPUNIT_TEST(testMoveBlock);
 CPPUNIT_TEST(testCopyPasteRelativeFormula);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-09-03 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx  |2 +
 sc/qa/unit/ucalc_formula.cxx  |   56 ++
 sc/source/core/tool/token.cxx |6 +++-
 3 files changed, 63 insertions(+), 1 deletion(-)

New commits:
commit 41afbdcc624c075888610a049e84a14c548bdaac
Author: Kohei Yoshida 
Date:   Wed Sep 3 22:59:11 2014 +0200

fdo#83217: Write test for this.

Change-Id: I5af25079a24d4c18eed70a7f0abc42d84cfc2242

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 031517b..ec9542c 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -131,6 +131,7 @@ public:
 void testFormulaRefUpdateInsertColumns();
 void testFormulaRefUpdateMove();
 void testFormulaRefUpdateMoveUndo();
+void testFormulaRefUpdateMoveToSheet();
 void testFormulaRefUpdateDeleteContent();
 void testFormulaRefUpdateNamedExpression();
 void testFormulaRefUpdateNamedExpressionMove();
@@ -412,6 +413,7 @@ public:
 CPPUNIT_TEST(testFormulaRefUpdateInsertColumns);
 CPPUNIT_TEST(testFormulaRefUpdateMove);
 CPPUNIT_TEST(testFormulaRefUpdateMoveUndo);
+CPPUNIT_TEST(testFormulaRefUpdateMoveToSheet);
 CPPUNIT_TEST(testFormulaRefUpdateDeleteContent);
 CPPUNIT_TEST(testFormulaRefUpdateNamedExpression);
 CPPUNIT_TEST(testFormulaRefUpdateNamedExpressionMove);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 416e41d..d4344e2 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1849,6 +1849,62 @@ void Test::testFormulaRefUpdateMoveUndo()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testFormulaRefUpdateMoveToSheet()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+m_pDoc->InsertTab(0, "Sheet1");
+m_pDoc->InsertTab(1, "Sheet2");
+
+// Set values to A1:A2 on Sheet1, and B1:B2 to reference them.
+m_pDoc->SetValue(ScAddress(0,0,0), 11);
+m_pDoc->SetValue(ScAddress(0,1,0), 12);
+m_pDoc->SetString(ScAddress(1,0,0), "=A1");
+m_pDoc->SetString(ScAddress(1,1,0), "=A2");
+
+if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "A1"))
+CPPUNIT_FAIL("Wrong formula");
+
+if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "A2"))
+CPPUNIT_FAIL("Wrong formula");
+
+CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(ScAddress(1,0,0)));
+CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(ScAddress(1,1,0)));
+
+// Move A1:A2 on Sheet1 to B3:B4 on Sheet2.
+ScDocFunc& rFunc = getDocShell().GetDocFunc();
+bool bMoved = rFunc.MoveBlock(ScRange(0,0,0,0,1,0), ScAddress(1,2,1), 
true, true, false, true);
+CPPUNIT_ASSERT(bMoved);
+
+if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "Sheet2.B3"))
+CPPUNIT_FAIL("Wrong formula");
+
+if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "Sheet2.B4"))
+CPPUNIT_FAIL("Wrong formula");
+
+// Undo and check again.
+SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
+pUndoMgr->Undo();
+
+if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "A1"))
+CPPUNIT_FAIL("Wrong formula");
+
+if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "A2"))
+CPPUNIT_FAIL("Wrong formula");
+
+// Redo and check.
+pUndoMgr->Redo();
+
+if (!checkFormula(*m_pDoc, ScAddress(1,0,0), "Sheet2.B3"))
+CPPUNIT_FAIL("Wrong formula");
+
+if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "Sheet2.B4"))
+CPPUNIT_FAIL("Wrong formula");
+
+m_pDoc->DeleteTab(1);
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testFormulaRefUpdateDeleteContent()
 {
 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
commit 31abf4ce4e18cf2e94c6e598f255ae7cd8f675fa
Author: Kohei Yoshida 
Date:   Wed Sep 3 22:32:07 2014 +0200

fdo#83217: Set 3D flags correctly when moving block of cells.

Change-Id: Ibca5ff36f50f2b6fe182b008ead3efcb1c5a0be6

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 7e04064..396ffcb 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2812,7 +2812,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
 ScRange aOldRange = rCxt.maRange;
 aOldRange.Move(-rCxt.mnColDelta, -rCxt.mnRowDelta, -rCxt.mnTabDelta);
 
-bool b3DFlag = rOldPos.Tab() != rNewPos.Tab();
+bool b3DFlag = rOldPos.Tab() != rNewPos.Tab() || rCxt.mnTabDelta;
 
 FormulaToken** p = pCode;
 FormulaToken** pEnd = p + static_cast(nLen);
@@ -2888,6 +2888,8 @@ sc::RefUpdateResult ScTokenArray::MoveReference( const 
ScAddress& rPos, const sc
 {
 aAbs.Move(rCxt.mnColDelta, rCxt.mnRowDelta, 
rCxt.mnTabDelta);
 rRef.SetAddress(aAbs, rPos);
+if (rCxt.mnTabDelta)
+rRef.SetFlag3D(aAbs.Tab()!=rPos.Tab());
 }
 }
 break;
@@ -2900,6 +2902,8 @@ sc::RefUpdateResult ScTokenArray::MoveReference( const 
ScAddress& rPos, const sc
 {
 aAbs.Move(rCxt.mnColDelta, rCx

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

2014-09-19 Thread Kohei Yoshida
 sc/qa/unit/ucalc_sort.cxx  |   18 ++
 sc/source/ui/docshell/dbdocfun.cxx |1 +
 2 files changed, 11 insertions(+), 8 deletions(-)

New commits:
commit 8af25862f1782ff1fb0f66415e3a2d624f61d737
Author: Kohei Yoshida 
Date:   Fri Sep 19 09:12:00 2014 -0400

fdo#84009: Adjust the test case to catch this.

Change-Id: I16bdc6760276b5bc0c78c3693d3f92c68ef67ed1

diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx
index 95a5e42..f81a394 100644
--- a/sc/qa/unit/ucalc_sort.cxx
+++ b/sc/qa/unit/ucalc_sort.cxx
@@ -1320,6 +1320,7 @@ void Test::testSortRefUpdate5()
 void Test::testSortOutOfPlaceResult()
 {
 m_pDoc->InsertTab(0, "Sort");
+m_pDoc->InsertTab(1, "Result");
 
 const char* pData[] = {
 "Header",
@@ -1356,7 +1357,7 @@ void Test::testSortOutOfPlaceResult()
 aSortData.nRow2 = 5;
 aSortData.bHasHeader = true;
 aSortData.bInplace = false;
-aSortData.nDestTab = 0;
+aSortData.nDestTab = 1;
 aSortData.nDestCol = 2;
 aSortData.nDestRow = 1;
 aSortData.maKeyState[0].bDoSort = true;
@@ -1373,14 +1374,15 @@ void Test::testSortOutOfPlaceResult()
 CPPUNIT_ASSERT_EQUAL( 9.0, m_pDoc->GetValue(ScAddress(0,4,0)));
 CPPUNIT_ASSERT_EQUAL(-2.0, m_pDoc->GetValue(ScAddress(0,5,0)));
 
-// Sort result in C2:C7.
-CPPUNIT_ASSERT_EQUAL(OUString("Header"), 
m_pDoc->GetString(ScAddress(2,1,0)));
-CPPUNIT_ASSERT_EQUAL(-2.0, m_pDoc->GetValue(ScAddress(2,2,0)));
-CPPUNIT_ASSERT_EQUAL( 1.0, m_pDoc->GetValue(ScAddress(2,3,0)));
-CPPUNIT_ASSERT_EQUAL( 2.0, m_pDoc->GetValue(ScAddress(2,4,0)));
-CPPUNIT_ASSERT_EQUAL( 9.0, m_pDoc->GetValue(ScAddress(2,5,0)));
-CPPUNIT_ASSERT_EQUAL(23.0, m_pDoc->GetValue(ScAddress(2,6,0)));
+// Sort result in C2:C7 on sheet "Result".
+CPPUNIT_ASSERT_EQUAL(OUString("Header"), 
m_pDoc->GetString(ScAddress(2,1,1)));
+CPPUNIT_ASSERT_EQUAL(-2.0, m_pDoc->GetValue(ScAddress(2,2,1)));
+CPPUNIT_ASSERT_EQUAL( 1.0, m_pDoc->GetValue(ScAddress(2,3,1)));
+CPPUNIT_ASSERT_EQUAL( 2.0, m_pDoc->GetValue(ScAddress(2,4,1)));
+CPPUNIT_ASSERT_EQUAL( 9.0, m_pDoc->GetValue(ScAddress(2,5,1)));
+CPPUNIT_ASSERT_EQUAL(23.0, m_pDoc->GetValue(ScAddress(2,6,1)));
 
+m_pDoc->DeleteTab(1);
 m_pDoc->DeleteTab(0);
 }
 
commit 5fd4679e7b92f344ea867e0dca1fc4c9363ae2cd
Author: Kohei Yoshida 
Date:   Fri Sep 19 09:11:09 2014 -0400

fdo#84009: Be sure to update the sheet index when moving the sort range.

Change-Id: Ic9ad51b33f6dfb6f90e76439c27eeff25ec4c7da

diff --git a/sc/source/ui/docshell/dbdocfun.cxx 
b/sc/source/ui/docshell/dbdocfun.cxx
index 7f30a02..fe843b5 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -499,6 +499,7 @@ bool ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& 
rSortParam,
 return false;
 
 aLocalParam.MoveToDest();
+nTab = aLocalParam.nDestTab;
 }
 
 ScEditableTester aTester( &rDoc, nTab, aLocalParam.nCol1,aLocalParam.nRow1,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-04-24 Thread Kohei Yoshida
 sc/qa/unit/ucalc_formula.cxx |8 
 sc/source/core/tool/interpr6.cxx |1 +
 sc/source/core/tool/scmatrix.cxx |   14 ++
 3 files changed, 15 insertions(+), 8 deletions(-)

New commits:
commit 4158d8843d50d50e9830c8dc24af8722de77f4af
Author: Kohei Yoshida 
Date:   Thu Apr 24 12:26:01 2014 -0400

fdo#76663: Let's not skip the first element of a matrix in PRODUCT.

Change-Id: I00683ce64fea58a80cd7137384e8f30464c44e9f

diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 97282d0..84d4599 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -387,6 +387,7 @@ void IterateMatrix(
 case ifPRODUCT:
 {
 ScMatrix::IterateResult aRes = pMat->Product(bTextAsZero);
+fRes = aRes.mfFirst;
 fRes *= aRes.mfRest;
 rCount += aRes.mnCount;
 }
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index e926e4b..b71da72 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -950,7 +950,7 @@ namespace {
 
 struct SumOp
 {
-static const int InitVal = 0;
+static const double InitVal;
 
 void operator() (double& rAccum, double fVal)
 {
@@ -958,9 +958,11 @@ struct SumOp
 }
 };
 
+const double SumOp::InitVal = 0.0;
+
 struct SumSquareOp
 {
-static const int InitVal = 0;
+static const double InitVal;
 
 void operator() (double& rAccum, double fVal)
 {
@@ -968,9 +970,11 @@ struct SumSquareOp
 }
 };
 
+const double SumSquareOp::InitVal = 0.0;
+
 struct ProductOp
 {
-static const int InitVal = 1;
+static const double InitVal;
 
 void operator() (double& rAccum, double fVal)
 {
@@ -978,6 +982,8 @@ struct ProductOp
 }
 };
 
+const double ProductOp::InitVal = 1.0;
+
 template
 class WalkElementBlocks : 
std::unary_function
 {
@@ -987,7 +993,7 @@ class WalkElementBlocks : 
std::unary_function
Date:   Thu Apr 24 12:31:02 2014 -0400

fdo#76663: Better test to really test PRODUCT with array input.

The first element should be something other than 1 to make this a better
check.

Change-Id: I2dc108a2e755034f584fef781eb5668b629dc3fd

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 4544ac6..254962e 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2163,6 +2163,8 @@ void Test::testFuncSUM()
 
 void Test::testFuncPRODUCT()
 {
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto recalc.
+
 OUString aTabName("foo");
 CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
 m_pDoc->InsertTab (0, aTabName));
@@ -2175,14 +2177,12 @@ void Test::testFuncPRODUCT()
 val = 3;
 m_pDoc->SetValue(0, 2, 0, val);
 m_pDoc->SetString(0, 3, 0, OUString("=PRODUCT(A1:A3)"));
-m_pDoc->CalcAll();
 m_pDoc->GetValue(0, 3, 0, result);
 CPPUNIT_ASSERT_MESSAGE("Calculation of PRODUCT failed", result == 6.0);
 
-m_pDoc->SetString(0, 4, 0, OUString("=PRODUCT({1;2;3})"));
-m_pDoc->CalcAll();
+m_pDoc->SetString(0, 4, 0, OUString("=PRODUCT({2;3;4})"));
 m_pDoc->GetValue(0, 4, 0, result);
-CPPUNIT_ASSERT_MESSAGE("Calculation of PRODUCT with inline array failed", 
result == 6.0);
+CPPUNIT_ASSERT_MESSAGE("Calculation of PRODUCT with inline array failed", 
result == 24.0);
 
 m_pDoc->DeleteTab(0);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-04-24 Thread Kohei Yoshida
 sc/qa/unit/ucalc_formula.cxx   |   17 +++--
 sc/source/core/tool/queryparam.cxx |   14 --
 2 files changed, 23 insertions(+), 8 deletions(-)

New commits:
commit 50708577850544920c746ebc382d47275452a761
Author: Kohei Yoshida 
Date:   Thu Apr 24 19:42:30 2014 -0400

fdo#77039: Fill the match string even if the raw string is empty.

And in case of an empty string, call svl::SharedString::getEmptyString()
to get an empty shared string instance.

Change-Id: I0923e59f03468790270de8ef22323c0cedad002f

diff --git a/sc/source/core/tool/queryparam.cxx 
b/sc/source/core/tool/queryparam.cxx
index c9d7e29..487a577 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -173,14 +173,16 @@ void ScQueryParamBase::FillInExcelSyntax(
 svl::SharedStringPool& rPool, const OUString& rStr, SCSIZE nIndex)
 {
 const OUString aCellStr = rStr;
-if (!aCellStr.isEmpty())
-{
-if ( nIndex >= maEntries.size() )
-Resize( nIndex+1 );
+if (nIndex >= maEntries.size())
+Resize(nIndex+1);
 
-ScQueryEntry& rEntry = GetEntry(nIndex);
-ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+ScQueryEntry& rEntry = GetEntry(nIndex);
+ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
 
+if (aCellStr.isEmpty())
+rItem.maString = svl::SharedString::getEmptyString();
+else
+{
 rEntry.bDoQuery = true;
 // Operatoren herausfiltern
 if (aCellStr[0] == '<')
commit 380631d0e24d8bf90a5431b3e3c5fb36f21dbcf0
Author: Kohei Yoshida 
Date:   Thu Apr 24 19:15:38 2014 -0400

fdo#77039: Write test for this.

Change-Id: If34291ffb9705c413a451091ac70d7f2c7ea8f63

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 254962e..e3283db 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2294,6 +2294,8 @@ void Test::testFuncN()
 
 void Test::testFuncCOUNTIF()
 {
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
 // COUNTIF (test case adopted from OOo i#36381)
 
 OUString aTabName("foo");
@@ -2345,7 +2347,6 @@ void Test::testFuncCOUNTIF()
 SCROW nRow = 20 + i;
 m_pDoc->SetString(0, nRow, 0, 
OUString::createFromAscii(aChecks[i].pFormula));
 }
-m_pDoc->CalcAll();
 
 for (SCROW i = 0; i < nRows; ++i)
 {
@@ -2368,11 +2369,23 @@ void Test::testFuncCOUNTIF()
 
 m_pDoc->SetString(0, 0, 0, OUString("=\"\""));
 m_pDoc->SetString(0, 1, 0, OUString("=COUNTIF(A1;1)"));
-m_pDoc->CalcAll();
 
 double result = m_pDoc->GetValue(0, 1, 0);
 CPPUNIT_ASSERT_MESSAGE("We shouldn't count empty string as valid number.", 
result == 0.0);
 
+// Another test case adopted from fdo#77039.
+clearSheet(m_pDoc, 0);
+
+// Set formula cells with blank results in A1:A4.
+for (SCROW i = 0; i <=3; ++i)
+m_pDoc->SetString(ScAddress(0,i,0), "=\"\"");
+
+// Insert formula into A5 to count all cells with empty strings.
+m_pDoc->SetString(ScAddress(0,4,0), "=COUNTIF(A1:A4;\"\"");
+
+// We should correctly count with empty string key.
+CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(0,4,0)));
+
 m_pDoc->DeleteTab(0);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-04-28 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx |2 ++
 sc/qa/unit/ucalc_formula.cxx |   33 +
 sc/source/core/tool/scmatrix.cxx |2 +-
 3 files changed, 36 insertions(+), 1 deletion(-)

New commits:
commit 5fab47ddbe332a150fb2005e941a2c19bd38ce7f
Author: Kohei Yoshida 
Date:   Mon Apr 28 11:55:23 2014 -0400

fdo#75397: Return an empty string for empty element.

This is the behavior as of 3.6.  It had changed in 4.0 and onward by
accident, and caused the bug as reported in fdo#75397.

Change-Id: Id96fea354604b3c13cbbf2d9a73223b7725c7d66

diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index b71da72..32da95a 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -579,7 +579,7 @@ svl::SharedString ScMatrixImpl::GetString( 
SvNumberFormatter& rFormatter, SCSIZE
 {
 if (!maMatFlag.get(nR, nC))
 // not an empty path.
-break;
+return svl::SharedString::getEmptyString();
 
 // result of empty FALSE jump path
 sal_uLong nKey = rFormatter.GetStandardFormat( 
NUMBERFORMAT_LOGICAL,
commit 18fa4733f46c2dae40bad7cdea9d3f98e24495dd
Author: Kohei Yoshida 
Date:   Mon Apr 28 11:16:29 2014 -0400

fdo#75397: Write unit test for this.

Change-Id: Id261aebd427eb032463668c2654ce837139b4a05

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 2939ac5..71b33a7 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -133,6 +133,7 @@ public:
 void testFuncN();
 void testFuncCOUNTIF();
 void testFuncNUMBERVALUE();
+void testFuncLEN();
 void testFuncLOOKUP();
 void testFuncVLOOKUP();
 void testFuncMATCH();
@@ -383,6 +384,7 @@ public:
 CPPUNIT_TEST(testFuncN);
 CPPUNIT_TEST(testFuncCOUNTIF);
 CPPUNIT_TEST(testFuncNUMBERVALUE);
+CPPUNIT_TEST(testFuncLEN);
 CPPUNIT_TEST(testFuncLOOKUP);
 CPPUNIT_TEST(testFuncVLOOKUP);
 CPPUNIT_TEST(testFuncMATCH);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 9776715..b2caf22 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2635,6 +2635,39 @@ void Test::testFuncNUMBERVALUE()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testFuncLEN()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+m_pDoc->InsertTab(0, "Formula");
+
+// Leave A1:A3 empty, and insert an array of LEN in B1:B3 that references
+// these empty cells.
+
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+m_pDoc->InsertMatrixFormula(1, 0, 1, 2, aMark, "=LEN(A1:A3)", NULL);
+
+ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_MESSAGE("This formulashould be a matrix origin.",
+   pFC->GetMatrixFlag() == MM_FORMULA);
+
+// This should be a 1x3 matrix.
+SCCOL nCols = -1;
+SCROW nRows = -1;
+pFC->GetMatColsRows(nCols, nRows);
+CPPUNIT_ASSERT_EQUAL(static_cast(1), nCols);
+CPPUNIT_ASSERT_EQUAL(static_cast(3), nRows);
+
+// LEN value should be 0 for an empty cell.
+CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(1,0,0)));
+CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(1,1,0)));
+CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(1,2,0)));
+
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testFuncLOOKUP()
 {
 FormulaGrammarSwitch aFGSwitch(m_pDoc, 
formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-04-29 Thread Kohei Yoshida
 sc/qa/unit/ucalc_formula.cxx   |   22 ++
 sc/source/core/data/document10.cxx |4 
 2 files changed, 26 insertions(+)

New commits:
commit ea0ac020160207a08de3168142abc2a74f17afd6
Author: Kohei Yoshida 
Date:   Tue Apr 29 11:40:06 2014 -0400

fdo#74322: Let's not handle cut mode here.

Things are a bit more complex in cut mode than what this method can handle.

Change-Id: Idadee23beff08c2df89d47bb237e8a2d2fd69dab

diff --git a/sc/source/core/data/document10.cxx 
b/sc/source/core/data/document10.cxx
index 2046b31..4112bb9 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -57,6 +57,10 @@ bool ScDocument::CopyOneCellFromClip(
 sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, 
SCROW nRow2 )
 {
 ScDocument* pClipDoc = rCxt.getClipDoc();
+if (pClipDoc->GetClipParam().mbCutMode)
+// We don't handle cut and paste or moving of cells here.
+return false;
+
 ScRange aClipRange = pClipDoc->GetClipParam().getWholeRange();
 if (aClipRange.aStart != aClipRange.aEnd)
 // The source is not really a single cell. Bail out.
commit fd65b90934d0c521de1f3b04214e364fd540f080
Author: Kohei Yoshida 
Date:   Tue Apr 29 11:20:55 2014 -0400

fdo#74322: Additional test for the followup issue.

Change-Id: I971e7ea2535138eb4ac901c227c72a50578746a8

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 937c96e..ae65185 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1932,6 +1932,28 @@ void Test::testFormulaRefUpdateNamedExpressionMove()
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,9,0)));
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,10,0)));
 
+// Clear and start over.
+clearSheet(m_pDoc, 0);
+m_pDoc->GetRangeName()->clear();
+
+// Set value to B2.
+m_pDoc->SetValue(ScAddress(1,1,0), 2.0);
+
+// Define B2 as 'MyCell'.
+bInserted = m_pDoc->InsertNewRangeName("MyCell", ScAddress(0,0,0), 
"$Test.$B$2");
+CPPUNIT_ASSERT(bInserted);
+
+// Set formula to B3 that references B2 via MyCell.
+m_pDoc->SetString(ScAddress(1,2,0), "=MyCell*2");
+CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(1,2,0)));
+
+// Move B2 to D2.
+bMoved = rFunc.MoveBlock(ScRange(1,1,0,1,1,0), ScAddress(3,1,0), true, 
true, false, true);
+CPPUNIT_ASSERT(bMoved);
+
+// Value in B3 should remain unchanged.
+CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(1,2,0)));
+
 m_pDoc->DeleteTab(0);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-05-06 Thread Kohei Yoshida
 sc/qa/unit/helper/qahelper.cxx  |4 +++
 sc/qa/unit/ucalc.cxx|   48 
 sc/qa/unit/ucalc.hxx|2 +
 sc/source/core/data/formulacell.cxx |2 -
 4 files changed, 55 insertions(+), 1 deletion(-)

New commits:
commit 67563fd55b230eb68fef705ff645af7dab73af73
Author: Kohei Yoshida 
Date:   Tue May 6 12:22:53 2014 -0400

fdo#77944: Put updated formula cells into undo document.

Change-Id: Ib9d6a73d485878bfe6c2a1875936025eb4d0a30a

diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index d7cef22..a233fe5 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2871,7 +2871,7 @@ bool ScFormulaCell::UpdateReferenceOnMove(
  (bValChanged && bHasRelName ) || bOnRefMove)
 bNeedDirty = true;
 
-if (pUndoDoc && (bValChanged || bOnRefMove))
+if (pUndoDoc && (bValChanged || bRefModified || bOnRefMove))
 setOldCodeToUndo(pUndoDoc, aUndoPos, pOldCode.get(), eTempGrammar, 
cMatrixFlag);
 
 bValChanged = false;
commit 5971a8f1cee915e762784e970f0eb10f2baf0f71
Author: Kohei Yoshida 
Date:   Tue May 6 12:22:13 2014 -0400

fdo#77944: Write test for this.

Change-Id: I0dae7533121d5501b35c289bd48ef8d139e37d3e

diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 776955f..e97329f 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -404,7 +404,11 @@ ScTokenArray* getTokens(ScDocument& rDoc, const ScAddress& 
rPos)
 {
 ScFormulaCell* pCell = rDoc.GetFormulaCell(rPos);
 if (!pCell)
+{
+OUString aStr = rPos.Format(SCA_VALID);
+cerr << aStr << " is not a formula cell." << endl;
 return NULL;
+}
 
 return pCell->GetCode();
 }
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index ace06b2..97e6521 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3772,6 +3772,54 @@ void Test::testCopyPasteSkipEmptyConditionalFormatting()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testCutPasteRefUndo()
+{
+// Testing scenario: A2 references B2, and B2 gets cut and pasted onto C2,
+// which updates A2's formula to reference C2. Then the paste action gets
+// undone, which should also undo A2's formula to reference back to B2.
+
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+
+m_pDoc->InsertTab(0, "Test");
+
+// A2 references B2.
+m_pDoc->SetString(ScAddress(0,1,0), "=B2");
+
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+
+// Set up clip document for cutting of B2.
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+aClipDoc.ResetClip(m_pDoc, &aMark);
+ScClipParam aParam(ScAddress(1,1,0), true);
+aClipDoc.SetClipParam(aParam);
+aClipDoc.SetValue(ScAddress(1,1,0), 12.0);
+
+// Set up undo document for reference update.
+ScDocument* pUndoDoc = new ScDocument(SCDOCMODE_UNDO);
+pUndoDoc->InitUndo(m_pDoc, 0, 0);
+
+// Do the pasting of 12 into C2.  This should update A2 to reference C2.
+m_pDoc->CopyFromClip(ScAddress(2,1,0), aMark, IDF_CONTENTS, pUndoDoc, 
&aClipDoc, true, false);
+CPPUNIT_ASSERT_EQUAL(12.0, m_pDoc->GetValue(0,1,0));
+
+if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "C2"))
+CPPUNIT_FAIL("A2 should be referencing C2.");
+
+// At this point, the ref undo document should contain a formula cell at 
A2 that references B2.
+if (!checkFormula(*pUndoDoc, ScAddress(0,1,0), "B2"))
+CPPUNIT_FAIL("A2 in the undo document should be referencing B2.");
+
+ScUndoPaste aUndo(&getDocShell(), ScRange(ScAddress(2,1,0)), aMark, 
pUndoDoc, NULL, IDF_CONTENTS, NULL, false, NULL);
+aUndo.Undo();
+
+// Now A2 should be referencing B2 once again.
+if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "B2"))
+CPPUNIT_FAIL("A2 should be referencing B2 after undo.");
+
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testUndoCut()
 {
 m_pDoc->InsertTab(0, "Test");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 2a256a1..f812630 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -261,6 +261,7 @@ public:
 void testCopyPasteMultiRange();
 void testCopyPasteSkipEmpty();
 void testCopyPasteSkipEmptyConditionalFormatting();
+void testCutPasteRefUndo();
 void testUndoCut();
 void testMoveBlock();
 void testCopyPasteRelativeFormula();
@@ -449,6 +450,7 @@ public:
 CPPUNIT_TEST(testCopyPasteMultiRange);
 CPPUNIT_TEST(testCopyPasteSkipEmpty);
 //CPPUNIT_TEST(testCopyPasteSkipEmptyConditionalFormatting);
+CPPUNIT_TEST(testCutPasteRefUndo);
 CPPUNIT_TEST(testUndoCut);
 CPPUNIT_TEST(testMoveBlock);
 CPPUNIT_TEST(testCopyPasteRelativeFormula);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-05-06 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx  |9 +++
 sc/qa/unit/ucalc.hxx  |8 ++
 sc/qa/unit/ucalc_formula.cxx  |   52 +-
 sc/source/core/tool/token.cxx |2 -
 4 files changed, 54 insertions(+), 17 deletions(-)

New commits:
commit 7aa32a759fb7b440f870739f7bb680f405f338ce
Author: Kohei Yoshida 
Date:   Tue May 6 15:24:50 2014 -0400

fdo#77647: Fix the column insertion use case.

Change-Id: I7c78f54c9386eced16113e69e625d23ed4acedd7

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index b1f8e02..636ff01 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2546,7 +2546,7 @@ bool expandRange( const sc::RefUpdateContext& rCxt, 
ScRange& rRefRange, const Sc
 // Selected range is only partially overlapping in vertical 
direction. Bail out.
 return false;
 
-if (!rCxt.mrDoc.IsExpandRefs() && rSelectedRange.aStart.Col() == 
rRefRange.aStart.Col())
+if (!rCxt.mrDoc.IsExpandRefs() && rSelectedRange.aStart.Col() <= 
rRefRange.aStart.Col())
 // Selected range is at the left end and the edge expansion is 
turned off.  No expansion.
 return false;
 
commit 48631bde1ccdbd618e5892b7050822b61b843332
Author: Kohei Yoshida 
Date:   Tue May 6 15:23:57 2014 -0400

fdo#77647: Test for reference adjustment on column insertion.

Change-Id: Ic95ff3892efbfc003ae9976b4fba4129de11bbef

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 97e6521..d764673 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -62,6 +62,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "formula/IFunctionDescription.hxx"
 
@@ -6139,6 +6140,14 @@ ScUndoPaste* Test::createUndoPaste(ScDocShell& rDocSh, 
const ScRange& rRange, Sc
 &rDocSh, rRange, aMarkData, pUndoDoc, NULL, IDF_ALL, pRefUndoData, 
false);
 }
 
+void Test::setExpandRefs(bool bExpand)
+{
+ScModule* pMod = SC_MOD();
+ScInputOptions aOpt = pMod->GetInputOptions();
+aOpt.SetExpandRefs(bExpand);
+pMod->SetInputOptions(aOpt);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index f812630..dbe84e7 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -47,6 +47,12 @@ public:
 static void pasteFromClip(ScDocument* pDestDoc, const ScRange& rDestRange, 
ScDocument* pClipDoc);
 static ScUndoPaste* createUndoPaste(ScDocShell& rDocSh, const ScRange& 
rRange, ScDocument* pUndoDoc);
 
+/**
+ * Enable or disable expand reference options which controls how
+ * references in formula are expanded when inserting rows or columns.
+ */
+static void setExpandRefs(bool bExpand);
+
 template
 static ScRange insertRangeData(ScDocument* pDoc, const ScAddress& rPos, 
const char* aData[][_Size], size_t nRowCount)
 {
@@ -119,6 +125,7 @@ public:
 void testFormulaRefUpdateRange();
 void testFormulaRefUpdateSheets();
 void testFormulaRefUpdateInsertRows();
+void testFormulaRefUpdateInsertColumns();
 void testFormulaRefUpdateMove();
 void testFormulaRefUpdateMoveUndo();
 void testFormulaRefUpdateNamedExpression();
@@ -375,6 +382,7 @@ public:
 CPPUNIT_TEST(testFormulaRefUpdateRange);
 CPPUNIT_TEST(testFormulaRefUpdateSheets);
 CPPUNIT_TEST(testFormulaRefUpdateInsertRows);
+CPPUNIT_TEST(testFormulaRefUpdateInsertColumns);
 CPPUNIT_TEST(testFormulaRefUpdateMove);
 CPPUNIT_TEST(testFormulaRefUpdateMoveUndo);
 CPPUNIT_TEST(testFormulaRefUpdateNamedExpression);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index efe73a0..3f75db8 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -17,7 +17,6 @@
 #include "scopetools.hxx"
 #include "formulacell.hxx"
 #include "formulagroup.hxx"
-#include "inputopt.hxx"
 #include "scmod.hxx"
 #include "docsh.hxx"
 #include "docfunc.hxx"
@@ -1036,10 +1035,7 @@ void Test::testFormulaRefUpdateRange()
 
 sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
 
-ScModule* pMod = SC_MOD();
-ScInputOptions aOpt = pMod->GetInputOptions();
-aOpt.SetExpandRefs(false);
-pMod->SetInputOptions(aOpt);
+setExpandRefs(false);
 
 // Set values to B2:C5.
 m_pDoc->SetValue(ScAddress(1,1,0), 1);
@@ -1166,7 +1162,7 @@ void Test::testFormulaRefUpdateRange()
 clearRange(m_pDoc, ScRange(0,0,0,20,20,0));
 
 // Disable expansion of range reference on insertion in adjacent areas.
-m_pDoc->SetExpandRefs(false);
+setExpandRefs(false);
 
 // Fill C2:D3 with values.
 m_pDoc->SetValue(ScAddress(2,1,0), 1);
@@ -1251,8 +1247,7 @@ void Test::testFormulaRefUpdateRange()
 clearRange(m_pDoc, ScRange(0,0,0,20,20,0));
 
 // Turn edge expansion on.
-aOpt.SetExpandRefs(true);
-pMod->SetInputOptions(aOpt);
+setExpandRefs(true);
 
 // Fill C6:D7 with values.
 m_p

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

2014-05-09 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx |9 +
 sc/source/core/data/document.cxx |   20 ++--
 2 files changed, 27 insertions(+), 2 deletions(-)

New commits:
commit a45973a90625f4b9e0f603154194f357ff2418d4
Author: Kohei Yoshida 
Date:   Fri May 9 11:44:51 2014 -0400

fdo#77806: Check the boundaries before accessing an array

Change-Id: I0878f734599f566cde83183947cd7613c0f8d5c6

diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 181f294..414abd4 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6135,14 +6135,30 @@ bool ScDocument::HasNote(const ScAddress& rPos) const
 {
 return HasNote(rPos.Col(), rPos.Row(), rPos.Tab());
 }
+
 bool ScDocument::HasNote(SCCOL nCol, SCROW nRow, SCTAB nTab) const
 {
-const ScPostIt* pNote = maTabs[nTab]->aCol[nCol].GetCellNote(nRow);
+if (!ValidColRow(nCol, nRow))
+return false;
+
+const ScTable* pTab = FetchTable(nTab);
+if (!pTab)
+return false;
+
+const ScPostIt* pNote = pTab->aCol[nCol].GetCellNote(nRow);
 return pNote != NULL;
 }
+
 bool ScDocument::HasColNotes(SCCOL nCol, SCTAB nTab) const
 {
-return maTabs[nTab]->aCol[nCol].HasCellNotes();
+if (!ValidCol(nCol))
+return false;
+
+const ScTable* pTab = FetchTable(nTab);
+if (!pTab)
+return false;
+
+return pTab->aCol[nCol].HasCellNotes();
 }
 
 bool ScDocument::HasTabNotes(SCTAB nTab) const
commit cd87cd92b95861e5cacb111dc33a809a9db884e3
Author: Kohei Yoshida 
Date:   Fri May 9 11:44:28 2014 -0400

fdo#77806: Write test for this.

Change-Id: Ic05b6fec2bfc89688cb1670a163f27caccc7f213

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index d764673..1ca19b8 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5176,6 +5176,15 @@ void Test::testNoteBasic()
 {
 m_pDoc->InsertTab(0, "PostIts");
 
+CPPUNIT_ASSERT(!m_pDoc->HasNotes());
+
+// Check for note's presence in all tables before inserting any notes.
+for (SCTAB i = 0; i <= MAXTAB; ++i)
+{
+bool bHasNotes = m_pDoc->HasTabNotes(i);
+CPPUNIT_ASSERT(!bHasNotes);
+}
+
 ScAddress aAddr(2, 2, 0); // cell C3
 ScPostIt *pNote = m_pDoc->GetOrCreateNote(aAddr);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-05-09 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   55 
 sc/qa/unit/ucalc.hxx|2 +
 sc/source/core/data/column3.cxx |4 +-
 3 files changed, 59 insertions(+), 2 deletions(-)

New commits:
commit f4673ccd5e26d38a28f297d64ed70ba719d21ef2
Author: Kohei Yoshida 
Date:   Fri May 9 14:04:30 2014 -0400

fdo#77379: Don't return from the call. Notes are handled at the end.

Returning prematurely would end up skipping pasting of notes.

Change-Id: I79e0968023342a68fe729f31eb6cfc3cfacd5850

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index e3a81a5..8bb8223 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -873,7 +873,7 @@ public:
 case sc::element_type_string:
 {
 if (!bString)
-return;
+break;
 
 sc::string_block::const_iterator it = 
sc::string_block::begin(*node.data);
 std::advance(it, nOffset);
@@ -897,7 +897,7 @@ public:
 case sc::element_type_edittext:
 {
 if (!bString)
-return;
+break;
 
 sc::edittext_block::const_iterator it = 
sc::edittext_block::begin(*node.data);
 std::advance(it, nOffset);
commit 71cd1ca57faf423fb607fab64914719238bc1e4f
Author: Kohei Yoshida 
Date:   Fri May 9 13:50:31 2014 -0400

fdo#77379: Write test for this.

Change-Id: Iccc0b499abae90f5b780aebab17ff6315b5690ec

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 1ca19b8..4cf444f 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5400,6 +5400,61 @@ void Test::testNoteLifeCycle()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testNoteCopyPaste()
+{
+m_pDoc->InsertTab(0, "Test");
+
+// We need a drawing layer in order to create caption objects.
+m_pDoc->InitDrawLayer(&getDocShell());
+
+// Insert in B2 a text and cell comment.
+ScAddress aPos(1,1,0);
+m_pDoc->SetString(aPos, "Text");
+ScPostIt* pNote = m_pDoc->GetOrCreateNote(aPos);
+CPPUNIT_ASSERT(pNote);
+pNote->SetText(aPos, "Note1");
+
+// Insert in B4 a number and cell comment.
+aPos.SetRow(3);
+m_pDoc->SetValue(aPos, 1.1);
+pNote = m_pDoc->GetOrCreateNote(aPos);
+CPPUNIT_ASSERT(pNote);
+pNote->SetText(aPos, "Note2");
+
+// Copy B2:B4 to clipboard.
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+ScRange aCopyRange(1,1,0,1,3,0);
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+aClipDoc.ResetClip(m_pDoc, &aMark);
+ScClipParam aClipParam(aCopyRange, false);
+m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false, false, 
true, false);
+
+// Make sure the notes are in the clipboard.
+pNote = aClipDoc.GetNote(ScAddress(1,1,0));
+CPPUNIT_ASSERT(pNote);
+CPPUNIT_ASSERT_EQUAL(OUString("Note1"), pNote->GetText());
+
+pNote = aClipDoc.GetNote(ScAddress(1,3,0));
+CPPUNIT_ASSERT(pNote);
+CPPUNIT_ASSERT_EQUAL(OUString("Note2"), pNote->GetText());
+
+// Paste to B6:B8 but only cell notes.
+ScRange aDestRange(1,5,0,1,7,0);
+m_pDoc->CopyFromClip(aDestRange, aMark, IDF_NOTE, NULL, &aClipDoc);
+
+// Make sure the notes are there.
+pNote = m_pDoc->GetNote(ScAddress(1,5,0));
+CPPUNIT_ASSERT(pNote);
+CPPUNIT_ASSERT_EQUAL(OUString("Note1"), pNote->GetText());
+
+pNote = m_pDoc->GetNote(ScAddress(1,7,0));
+CPPUNIT_ASSERT(pNote);
+CPPUNIT_ASSERT_EQUAL(OUString("Note2"), pNote->GetText());
+
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testAreasWithNotes()
 {
 ScDocument* pDoc = getDocShell().GetDocument();
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index dbe84e7..76c74cc 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -341,6 +341,7 @@ public:
 void testNoteDeleteRow();
 void testNoteDeleteCol();
 void testNoteLifeCycle();
+void testNoteCopyPaste();
 void testAreasWithNotes();
 void testAnchoredRotatedShape();
 void testCellTextWidth();
@@ -499,6 +500,7 @@ public:
 CPPUNIT_TEST(testNoteDeleteRow);
 CPPUNIT_TEST(testNoteDeleteCol);
 CPPUNIT_TEST(testNoteLifeCycle);
+CPPUNIT_TEST(testNoteCopyPaste);
 CPPUNIT_TEST(testAreasWithNotes);
 CPPUNIT_TEST(testAnchoredRotatedShape);
 CPPUNIT_TEST(testCellTextWidth);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-05-09 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   44 +---
 sc/source/core/data/column3.cxx |   43 +++
 2 files changed, 63 insertions(+), 24 deletions(-)

New commits:
commit 83a88b942134314e86ac612d0ef70a8e4919e4af
Author: Kohei Yoshida 
Date:   Fri May 9 22:19:15 2014 -0400

fdo#77056: Treat empty cells as if they have a value of 0.0.

Change-Id: Ibe64cf7177a5298c1878e0014c049dc9c82b1344

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 8bb8223..5db4625 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1158,6 +1158,23 @@ class MixDataHandler
 
 bool mbSkipEmpty;
 
+void doFunction( size_t nDestRow, double fVal1, double fVal2 )
+{
+bool bOk = lcl_DoFunction(fVal1, fVal2, mnFunction);
+
+if (bOk)
+miNewCellsPos = maNewCells.set(miNewCellsPos, 
nDestRow-mnRowOffset, fVal1);
+else
+{
+ScAddress aPos(mrDestColumn.GetCol(), nDestRow, 
mrDestColumn.GetTab());
+
+ScFormulaCell* pFC = new ScFormulaCell(&mrDestColumn.GetDoc(), 
aPos);
+pFC->SetErrCode(errNoValue);
+
+miNewCellsPos = maNewCells.set(miNewCellsPos, 
nDestRow-mnRowOffset, pFC);
+}
+}
+
 public:
 MixDataHandler(
 sc::ColumnBlockPosition& rBlockPos,
@@ -1180,22 +1197,15 @@ public:
 mrBlockPos.miCellPos = aPos.first;
 switch (aPos.first->type)
 {
+case sc::element_type_empty:
 case sc::element_type_numeric:
 {
-// Both src and dest are of numeric type.
-bool bOk = lcl_DoFunction(f, 
sc::numeric_block::at(*aPos.first->data, aPos.second), mnFunction);
-
-if (bOk)
-miNewCellsPos = maNewCells.set(miNewCellsPos, 
nRow-mnRowOffset, f);
-else
-{
-ScFormulaCell* pFC =
-new ScFormulaCell(
-&mrDestColumn.GetDoc(), 
ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab()));
+double fSrcVal = 0.0;
+if (aPos.first->type == sc::element_type_numeric)
+fSrcVal = sc::numeric_block::at(*aPos.first->data, 
aPos.second);
 
-pFC->SetErrCode(errNoValue);
-miNewCellsPos = maNewCells.set(miNewCellsPos, 
nRow-mnRowOffset, pFC);
-}
+// Both src and dest are of numeric type.
+doFunction(nRow, f, fSrcVal);
 }
 break;
 case sc::element_type_formula:
@@ -1229,7 +1239,6 @@ public:
 break;
 case sc::element_type_string:
 case sc::element_type_edittext:
-case sc::element_type_empty:
 {
 // Destination cell is not a number. Just take the source cell.
 miNewCellsPos = maNewCells.set(miNewCellsPos, 
nRow-mnRowOffset, f);
@@ -1346,9 +1355,9 @@ public:
 {
 case sc::element_type_numeric:
 {
-double fVal = sc::numeric_block::at(*aPos.first->data, 
aPos.second);
-miNewCellsPos = maNewCells.set(
-miNewCellsPos, nDestRow-mnRowOffset, fVal);
+double fVal1 = 0.0;
+double fVal2 = sc::numeric_block::at(*aPos.first->data, 
aPos.second);
+doFunction(nDestRow, fVal1, fVal2);
 }
 break;
 case sc::element_type_string:
commit b44f8185398ff6835a71fe237089746fca7f999d
Author: Kohei Yoshida 
Date:   Fri May 9 22:18:14 2014 -0400

fdo#77056: Modify existing test to cover the reported scenario.

Change-Id: I6d0fe13e6756d8b6c3e7ac9ffba828e3f9c2a7b5

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 4cf444f..4a9fb2f 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -6089,19 +6089,49 @@ void Test::testMixData()
 {
 m_pDoc->InsertTab(0, "Test");
 
-m_pDoc->SetValue(1,0,0,2);
-m_pDoc->SetValue(0,1,0,3);
+m_pDoc->SetValue(ScAddress(1,0,0), 2.0); // B1
+m_pDoc->SetValue(ScAddress(0,1,0), 3.0); // A2
+
+// Copy A1:B1 to the clip document.
 ScDocument aClipDoc(SCDOCMODE_CLIP);
-copyToClip(m_pDoc, ScRange(0,0,0,1,0,0), &aClipDoc);
+copyToClip(m_pDoc, ScRange(0,0,0,1,0,0), &aClipDoc); // A1:B1
 
+// Copy A2:B2 to the mix document (for arithemetic paste).
 ScDocument aMixDoc(SCDOCMODE_CLIP);
-copyToClip(m_pDoc, ScRange(0,1,0,1,1,0), &aMixDoc);
+copyToClip(m_pDoc, ScRange(0,1,0,1,1,0), &aMixDoc); // A2:B2
 
+// Paste A1:B1 to A2:B2 and perform addition.
 pasteFromClip(m_pDoc, ScRange(0,1,0,1,1,0), &aClipDoc);
-m_pDoc->MixDocument(ScRange(0,1,0,1,1,0), 1, false, &aMixDoc);
+m_pDoc->MixDocument(ScRange(0,1,0,1,1,0), PASTE_ADD, false, &aMixDoc)

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

2014-08-15 Thread Markus Mohrhard
 sc/qa/unit/ucalc.cxx   |   34 ++
 sc/qa/unit/ucalc.hxx   |2 ++
 sc/source/core/data/document10.cxx |5 +
 3 files changed, 41 insertions(+)

New commits:
commit 17f6f60c1c20782fb1cde69b949b97c2f3b0d830
Author: Markus Mohrhard 
Date:   Sat Aug 16 03:13:38 2014 +0200

add test case for fdo#82503

Change-Id: I715f8b2c09bd6af2cf1f45029f0561d79817deed

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 20b7ba7..644f7fb 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -6864,6 +6864,40 @@ void Test::testCondCopyPaste()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testCondCopyPasteSingleCell()
+{
+m_pDoc->InsertTab(0, "Test");
+
+ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc);
+ScRange aCondFormatRange(0,0,0,3,3,0);
+ScRangeList aRangeList(aCondFormatRange);
+pFormat->AddRange(aRangeList);
+
+ScCondFormatEntry* pEntry = new 
ScCondFormatEntry(SC_COND_DIRECT,"=B2","",m_pDoc,ScAddress(0,0,0),ScGlobal::GetRscString(STR_STYLENAME_RESULT));
+pFormat->AddEntry(pEntry);
+sal_uLong nIndex = m_pDoc->AddCondFormat(pFormat, 0);
+
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+copyToClip(m_pDoc, ScRange(0,0,0,0,0,0), &aClipDoc);
+
+ScRange aTargetRange(4,4,0,4,4,0);
+pasteFromClip(m_pDoc, aTargetRange, &aClipDoc);
+
+ScConditionalFormat* pPastedFormat = m_pDoc->GetCondFormat(4,4,0);
+CPPUNIT_ASSERT(pPastedFormat);
+
+CPPUNIT_ASSERT_EQUAL(ScRangeList(aTargetRange), pPastedFormat->GetRange());
+CPPUNIT_ASSERT( nIndex != pPastedFormat->GetKey());
+const SfxPoolItem* pItem = m_pDoc->GetAttr( 4, 4, 0, ATTR_CONDITIONAL );
+const ScCondFormatItem* pCondFormatItem = static_cast(pItem);
+
+CPPUNIT_ASSERT(pCondFormatItem);
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
pCondFormatItem->GetCondFormatData().size());
+CPPUNIT_ASSERT( nIndex != pCondFormatItem->GetCondFormatData().at(0) );
+
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testIconSet()
 {
 m_pDoc->InsertTab(0, "Test");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 80c46bf..5c03a70 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -374,6 +374,7 @@ public:
 void testCondFormatInsertCol();
 void testCondFormatInsertDeleteSheets();
 void testCondCopyPaste();
+void testCondCopyPasteSingleCell(); //e.g. fdo#82503
 void testIconSet();
 
 void testImportStream();
@@ -552,6 +553,7 @@ public:
 CPPUNIT_TEST(testCondFormatInsertCol);
 CPPUNIT_TEST(testCondFormatInsertDeleteSheets);
 CPPUNIT_TEST(testCondCopyPaste);
+CPPUNIT_TEST(testCondCopyPasteSingleCell);
 CPPUNIT_TEST(testIconSet);
 CPPUNIT_TEST(testImportStream);
 CPPUNIT_TEST(testDeleteContents);
commit 8c9014cc6e5a502f5719f17c111c29448d4d6f6b
Author: Markus Mohrhard 
Date:   Sat Aug 16 03:07:07 2014 +0200

copy conditional formatting for single cells, fdo#82503

Change-Id: I22f239fbbbfa3ac562b860efb990dff10d0e0e24

diff --git a/sc/source/core/data/document10.cxx 
b/sc/source/core/data/document10.cxx
index 49db92e..983e794 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -203,7 +203,12 @@ bool ScDocument::CopyOneCellFromClip(
 
 SCTAB nTabEnd = rCxt.getTabEnd();
 for (SCTAB i = rCxt.getTabStart(); i <= nTabEnd && i < 
static_cast(maTabs.size()); ++i)
+{
 maTabs[i]->CopyOneCellFromClip(rCxt, nCol1, nRow1, nCol2, nRow2);
+if (rCxt.getInsertFlag() & IDF_ATTRIB)
+maTabs[i]->CopyConditionalFormat(nCol1, nRow1, nCol2, nRow2, nCol1 
- aClipRange.aStart.Col(),
+nRow1 - aClipRange.aStart.Row(), pSrcTab);
+}
 
 return true;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-08-18 Thread Kohei Yoshida
 sc/qa/unit/subsequent_export-test.cxx |   18 ++
 sc/source/filter/excel/excrecds.cxx   |5 +++--
 2 files changed, 21 insertions(+), 2 deletions(-)

New commits:
commit 3104f95254530c76c3fc0c3b840254912c067ad8
Author: Kohei Yoshida 
Date:   Mon Aug 18 15:16:19 2014 -0400

Let's not export sheet tab color when it's not set.

COL_AUTO is the default value which is treated as color not being set.  The
old code would export it as a white color which is not correct.

Change-Id: Ib68fccfb228333f2059edc4cfffeed90880ebc60

diff --git a/sc/source/filter/excel/excrecds.cxx 
b/sc/source/filter/excel/excrecds.cxx
index 0ea43ff..d911c19 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -424,8 +424,9 @@ void XclExpXmlSheetPr::SaveXml( XclExpXmlStream& rStrm )
 
 // OOXTODO: XML_outlinePr
 
-rWorksheet->singleElement(
-XML_tabColor, XML_rgb, XclXmlUtils::ToOString(maTabColor).getStr(), 
FSEND);
+if (maTabColor != Color(COL_AUTO))
+rWorksheet->singleElement(
+XML_tabColor, XML_rgb, 
XclXmlUtils::ToOString(maTabColor).getStr(), FSEND);
 
 rWorksheet->singleElement(XML_pageSetUpPr,
 // OOXTODO: XML_autoPageBreaks,
commit ead1db7d4907ff70d412701f08b9c74481cef0bc
Author: Kohei Yoshida 
Date:   Mon Aug 18 15:15:03 2014 -0400

Write test to ensure that we export sheet tab color settings correctly.

Previously, we would incorrectly export a sheet tab without any color set
as a tab with white color.

Change-Id: I97e59a0d8e2fba6db64149f53acfe4331a5ce2ba

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 466ca67..8d9a67a 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -1757,6 +1757,24 @@ void ScExportTest::testSharedFormulaExportXLSX()
 {
 bool checkContent( ScDocument& rDoc )
 {
+SCTAB nTabCount = rDoc.GetTableCount();
+if (nTabCount != 2)
+{
+cerr << "Document should have exactly 2 sheets.  " << 
nTabCount << " found." << endl;
+return false;
+}
+
+// Make sure the sheet tab colors are not set.
+for (SCROW i = 0; i <= 1; ++i)
+{
+Color aTabBgColor = rDoc.GetTabBgColor(i);
+if (aTabBgColor != Color(COL_AUTO))
+{
+cerr << "The tab color of Sheet " << (i+1) << " should not 
be explicitly set." << endl;
+return false;
+}
+}
+
 // B2:B7 should show 1,2,3,4,5,6.
 double fExpected = 1.0;
 for (SCROW i = 1; i <= 6; ++i, ++fExpected)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-03-25 Thread Eike Rathke
 sc/qa/unit/data/xls/enhanced-protection.xls |binary
 sc/qa/unit/filters-test.cxx |   20 
 sc/source/core/data/tabprotection.cxx   |   27 +++
 3 files changed, 47 insertions(+)

New commits:
commit e27cc864be4d18d5bf307c58ebf1c1aa4ef90078
Author: Eike Rathke 
Date:   Tue Mar 25 20:41:52 2014 +0100

added unit test for .xls BIFF enhanced protection

Change-Id: I8f218f8f8ce12525b4c9995567d2864baa610c0b

diff --git a/sc/qa/unit/data/xls/enhanced-protection.xls 
b/sc/qa/unit/data/xls/enhanced-protection.xls
new file mode 100644
index 000..00cc6e6
Binary files /dev/null and b/sc/qa/unit/data/xls/enhanced-protection.xls differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 4de62d1..9d049f7 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -31,6 +31,7 @@
 #include "drwlayer.hxx"
 #include "userdat.hxx"
 #include "formulacell.hxx"
+#include "tabprotection.hxx"
 
 #include 
 
@@ -69,6 +70,7 @@ public:
 void testSharedFormulaXLS();
 void testSharedFormulaXLSX();
 void testLegacyCellAnchoredRotatedShape();
+void testEnhancedProtectionXLS();
 
 CPPUNIT_TEST_SUITE(ScFiltersTest);
 CPPUNIT_TEST(testCVEs);
@@ -82,6 +84,7 @@ public:
 CPPUNIT_TEST(testSharedFormulaXLS);
 CPPUNIT_TEST(testSharedFormulaXLSX);
 CPPUNIT_TEST(testLegacyCellAnchoredRotatedShape);
+CPPUNIT_TEST(testEnhancedProtectionXLS);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -491,6 +494,23 @@ void ScFiltersTest::testLegacyCellAnchoredRotatedShape()
 }
 }
 
+void ScFiltersTest::testEnhancedProtectionXLS()
+{
+ScDocShellRef xDocSh = loadDoc("enhanced-protection.", XLS);
+CPPUNIT_ASSERT(xDocSh.Is());
+ScDocument* pDoc = xDocSh->GetDocument();
+
+const ScTableProtection* pProt = pDoc->GetTabProtection(0);
+
+CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 0, 0, 0, 0, 0)));  // 
locked
+CPPUNIT_ASSERT(  pProt->isBlockEditable( ScRange( 0, 1, 0, 0, 1, 0)));  // 
editable without password
+CPPUNIT_ASSERT(  pProt->isBlockEditable( ScRange( 0, 2, 0, 0, 2, 0)));  // 
editable without password
+CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 3, 0, 0, 3, 0)));  // 
editable with password "foo"
+CPPUNIT_ASSERT(  pProt->isBlockEditable( ScRange( 0, 1, 0, 0, 2, 0)));  // 
union of two different editables
+CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 0, 0, 0, 1, 0)));  // 
union of locked and editable
+CPPUNIT_ASSERT( !pProt->isBlockEditable( ScRange( 0, 2, 0, 0, 3, 0)));  // 
union of editable and password editable
+}
+
 ScFiltersTest::ScFiltersTest()
   : ScBootstrapFixture( "/sc/qa/unit/data" )
 {
commit 98c6b4149e46eec6aaee5b64f2fa40678589dd4b
Author: Eike Rathke 
Date:   Tue Mar 25 20:39:10 2014 +0100

union of a to be edited range may be distributed over two different records

Change-Id: I1d0047e04394a79134beef35ba0cfe6a8ca1

diff --git a/sc/source/core/data/tabprotection.cxx 
b/sc/source/core/data/tabprotection.cxx
index 161cf65..a8aa278 100644
--- a/sc/source/core/data/tabprotection.cxx
+++ b/sc/source/core/data/tabprotection.cxx
@@ -434,6 +434,33 @@ bool ScTableProtectionImpl::isBlockEditable( const 
ScRange& rRange ) const
 }
 }
 
+// Ranges may even be distributed over different protection records, for
+// example if they are assigned different names, and can have different
+// passwords. Combine the ones that can be edited.
+/* TODO: once we handle passwords, remember a successful unlock at
+ * ScEnhancedProtection so we can use that here. */
+ScRangeList aRangeList;
+for (::std::vector::const_iterator 
it(maEnhancedProtection.begin()),
+itEnd(maEnhancedProtection.end()); it != itEnd; ++it)
+{
+if ((*it).maSecurityDescriptor.empty() && (*it).maRangeList.Is())
+{
+// Ranges are editable if no password is assigned.
+if (!(*it).mnPasswordVerifier)
+{
+const ScRangeList& rRanges = *(*it).maRangeList;
+size_t nRanges = rRanges.size();
+for (size_t i=0; i < nRanges; ++i)
+{
+aRangeList.Append( *rRanges[i]);
+}
+}
+}
+}
+ScRangeList aResultList( aRangeList.GetIntersectedRange( rRange));
+if (aResultList.size() == 1 && *aResultList[0] == rRange)
+return true;
+
 return false;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-03-28 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx |   48 ++
 sc/qa/unit/ucalc.hxx |2 
 sc/source/core/data/document.cxx |  101 ---
 3 files changed, 82 insertions(+), 69 deletions(-)

New commits:
commit 2ec45841b97a994ef9dca854e142598a063877fd
Author: Kohei Yoshida 
Date:   Fri Mar 28 20:50:29 2014 -0400

rhbz#1080196: Delete the destination first then paste.

Deleting in-between pasting was causing the block iterators to become
invalid when the deletion took place, which resulted in a segfault.

Also cleaned up the bits about handling filtered rows.  It was using the
old row flag which is empty these days (so it never would have worked).
Plus we do bail out earlier if the destination contains a filtered row.

Change-Id: I78d3ee8bce1647c1c8685f92a3df3c38cc014811

diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index e9417bf..421d64e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2820,21 +2820,6 @@ void ScDocument::CopyFromClip( const ScRange& 
rDestRange, const ScMarkData& rMar
 pClipDoc->GetClipParam().mbCutMode = false;
 }
 
-static SCROW lcl_getLastNonFilteredRow(
-const ScBitMaskCompressedArray& rFlags, SCROW nBegRow, 
SCROW nEndRow,
-SCROW nRowCount)
-{
-SCROW nFilteredRow = rFlags.GetFirstForCondition(
-nBegRow, nEndRow, CR_FILTERED, CR_FILTERED);
-
-SCROW nRow = nFilteredRow - 1;
-if (nRow - nBegRow + 1 > nRowCount)
-// make sure the row range stays within the data size.
-nRow = nBegRow + nRowCount - 1;
-
-return nRow;
-}
-
 void ScDocument::CopyMultiRangeFromClip(
 const ScAddress& rDestPos, const ScMarkData& rMark, sal_uInt16 nInsFlag, 
ScDocument* pClipDoc,
 bool bResetCut, bool bAsLink, bool /*bIncludeFiltered*/, bool 
bSkipAttrForEmpty)
@@ -2846,83 +2831,62 @@ void ScDocument::CopyMultiRangeFromClip(
 // There is nothing in the clip doc to copy.
 return;
 
-bool bOldAutoCalc = GetAutoCalc();
-SetAutoCalc( false );   // avoid multiple recalculations
+// Right now, we don't allow pasting into filtered rows, so we don't even 
handle it here.
 
+sc::AutoCalcSwitch aACSwitch(*this, false); // turn of auto calc 
temporarily.
 NumFmtMergeHandler aNumFmtMergeHdl(this, pClipDoc);
 
+ScRange aDestRange;
+rMark.GetMarkArea(aDestRange);
+
+bInsertingFromOtherDoc = true;  // kein Broadcast/Listener aufbauen bei 
Insert
+
 SCCOL nCol1 = rDestPos.Col();
 SCROW nRow1 = rDestPos.Row();
 ScClipParam& rClipParam = pClipDoc->GetClipParam();
 
+if (!bSkipAttrForEmpty)
+{
+// Do the deletion first.
+sal_uInt16 nDelFlag = IDF_CONTENTS;
+SCCOL nColSize = rClipParam.getPasteColSize();
+SCROW nRowSize = rClipParam.getPasteRowSize();
+
+DeleteArea(nCol1, nRow1, nCol1+nColSize-1, nRow1+nRowSize-1, rMark, 
nDelFlag);
+}
+
 sc::CopyFromClipContext aCxt(*this, NULL, pClipDoc, nInsFlag, bAsLink, 
bSkipAttrForEmpty);
 std::pair aTabRanges = getMarkedTableRange(maTabs, rMark);
 aCxt.setTabRange(aTabRanges.first, aTabRanges.second);
 
-ScRange aDestRange;
-rMark.GetMarkArea(aDestRange);
-SCROW nLastMarkedRow = aDestRange.aEnd.Row();
-
-bInsertingFromOtherDoc = true;  // kein Broadcast/Listener aufbauen bei 
Insert
-
-SCROW nBegRow = nRow1;
-sal_uInt16 nDelFlag = IDF_CONTENTS;
-const ScBitMaskCompressedArray& rFlags = 
GetRowFlagsArray(aCxt.getTabStart());
-
-for ( size_t i = 0, n = rClipParam.maRanges.size(); i < n; ++i )
+for (size_t i = 0, n = rClipParam.maRanges.size(); i < n; ++i)
 {
-ScRange* p = rClipParam.maRanges[ i ];
-// The begin row must not be filtered.
+ScRange* p = rClipParam.maRanges[i];
 
 SCROW nRowCount = p->aEnd.Row() - p->aStart.Row() + 1;
-
 SCsCOL nDx = static_cast(nCol1 - p->aStart.Col());
-SCsROW nDy = static_cast(nBegRow - p->aStart.Row());
+SCsROW nDy = static_cast(nRow1 - p->aStart.Row());
 SCCOL nCol2 = nCol1 + p->aEnd.Col() - p->aStart.Col();
+SCROW nEndRow = nRow1 + nRowCount - 1;
 
-SCROW nEndRow = lcl_getLastNonFilteredRow(rFlags, nBegRow, 
nLastMarkedRow, nRowCount);
-
-if (!bSkipAttrForEmpty)
-DeleteArea(nCol1, nBegRow, nCol2, nEndRow, rMark, nDelFlag);
+CopyBlockFromClip(aCxt, nCol1, nRow1, nCol2, nEndRow, rMark, nDx, nDy);
 
-CopyBlockFromClip(aCxt, nCol1, nBegRow, nCol2, nEndRow, rMark, nDx, 
nDy);
-nRowCount -= nEndRow - nBegRow + 1;
-
-while (nRowCount > 0)
+switch (rClipParam.meDirection)
 {
-// Get the first non-filtered row.
-SCROW nNonFilteredRow = rFlags.GetFirstForCondition(nEndRow+1, 
nLastMarkedRow, CR_FILTERED, 0);
-if (nNonFilteredRow > nLastMarkedRow)
-return;
-
-SCROW nRowsSkipped 

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

2014-04-10 Thread Kohei Yoshida
 sc/qa/unit/ucalc_sharedformula.cxx |8 
 sc/source/core/data/column4.cxx|   19 +++
 2 files changed, 19 insertions(+), 8 deletions(-)

New commits:
commit 66c6a3bfc9cd89c562107d3d369b3d82bae94d68
Author: Kohei Yoshida 
Date:   Fri Apr 11 00:43:18 2014 -0400

fdo#77300: Don't re-compile formulas when the hybrid formula is not there.

Change-Id: I9b0f8d031fec08bb8d92333ff67074fdc739e034

diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index c658124..7d87177 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -661,16 +661,19 @@ public:
 ScFormulaCell* pCell = rEntry.mpCell;
 OUString aFormula = pCell->GetHybridFormula();
 
-// Create token array from formula string.
-ScCompiler aComp(mrCompileFormulaCxt, pCell->aPos);
-ScTokenArray* pNewCode = aComp.CompileString(aFormula);
+if (!aFormula.isEmpty())
+{
+// Create token array from formula string.
+ScCompiler aComp(mrCompileFormulaCxt, pCell->aPos);
+ScTokenArray* pNewCode = aComp.CompileString(aFormula);
 
-// Generate RPN tokens.
-ScCompiler aComp2(mpDoc, pCell->aPos, *pNewCode);
-aComp2.CompileTokenArray();
+// Generate RPN tokens.
+ScCompiler aComp2(mpDoc, pCell->aPos, *pNewCode);
+aComp2.CompileTokenArray();
 
-pCell->SetCode(pNewCode);
-pCell->SetDirty();
+pCell->SetCode(pNewCode);
+pCell->SetDirty();
+}
 }
 }
 };
commit bdc8d5f9e712fce35098352b8c1d9028f4095d8c
Author: Kohei Yoshida 
Date:   Fri Apr 11 00:34:37 2014 -0400

fdo#77300: Add test for this.

Change-Id: Ib870d8f115b074a4ad80ee6910f92ba8d4b0c01e

diff --git a/sc/qa/unit/ucalc_sharedformula.cxx 
b/sc/qa/unit/ucalc_sharedformula.cxx
index acb249a..603e26e 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -1222,6 +1222,9 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
 m_pDoc->SetString(ScAddress(1,1,0), "=SUM(MyRange)");
 m_pDoc->SetString(ScAddress(1,2,0), "=SUM(MyRange)");
 
+// Set single formula with no named range to B5.
+m_pDoc->SetString(ScAddress(1,4,0), "=ROW()");
+
 // B1:B3 should be grouped.
 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0));
 CPPUNIT_ASSERT(pFC);
@@ -1232,6 +1235,8 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,1,0)));
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,2,0)));
 
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(1,4,0)));
+
 // Set a single formula to C1.
 m_pDoc->SetString(ScAddress(2,0,0), "=AVERAGE(MyRange)");
 pFC = m_pDoc->GetFormulaCell(ScAddress(2,0,0));
@@ -1260,6 +1265,8 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
 CPPUNIT_FAIL("Wrong formula!");
 if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM(MyRange)"))
 CPPUNIT_FAIL("Wrong formula!");
+if (!checkFormula(*m_pDoc, ScAddress(1,4,0), "ROW()"))
+CPPUNIT_FAIL("Wrong formula!");
 if (!checkFormula(*m_pDoc, ScAddress(2,0,0), "AVERAGE(MyRange)"))
 CPPUNIT_FAIL("Wrong formula!");
 
@@ -1267,6 +1274,7 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(1,0,0)));
 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(1,1,0)));
 CPPUNIT_ASSERT_EQUAL(10.0, m_pDoc->GetValue(ScAddress(1,2,0)));
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(1,4,0)));
 CPPUNIT_ASSERT_EQUAL(2.5, m_pDoc->GetValue(ScAddress(2,0,0)));
 
 m_pDoc->DeleteTab(0);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-04-10 Thread Kohei Yoshida
 sc/qa/unit/ucalc_sharedformula.cxx |   18 ++
 sc/source/core/data/column4.cxx|   35 +++
 2 files changed, 37 insertions(+), 16 deletions(-)

New commits:
commit 0e63ca4fde4e446f346e35849c756a30ca294aab
Author: Kohei Yoshida 
Date:   Fri Apr 11 00:55:10 2014 -0400

fdo#77300: Do the same for the shared formula case as well.

Change-Id: I560b0beabe81907e3f85d8845041a9df25d2200d

diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 7d87177..ec938d8 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -637,23 +637,26 @@ public:
 ScFormulaCell* pTop = *rEntry.mpCells;
 OUString aFormula = pTop->GetHybridFormula();
 
-// Create a new token array from the hybrid formula string, and
-// set it to the group.
-ScCompiler aComp(mrCompileFormulaCxt, pTop->aPos);
-ScTokenArray* pNewCode = aComp.CompileString(aFormula);
-ScFormulaCellGroupRef xGroup = pTop->GetCellGroup();
-assert(xGroup);
-xGroup->setCode(pNewCode);
-xGroup->compileCode(*mpDoc, pTop->aPos, mpDoc->GetGrammar());
-
-// Propagate the new token array to all formula cells in the group.
-ScFormulaCell** pp = rEntry.mpCells;
-ScFormulaCell** ppEnd = pp + rEntry.mnLength;
-for (; pp != ppEnd; ++pp)
+if (!aFormula.isEmpty())
 {
-ScFormulaCell* p = *pp;
-p->SyncSharedCode();
-p->SetDirty();
+// Create a new token array from the hybrid formula string, and
+// set it to the group.
+ScCompiler aComp(mrCompileFormulaCxt, pTop->aPos);
+ScTokenArray* pNewCode = aComp.CompileString(aFormula);
+ScFormulaCellGroupRef xGroup = pTop->GetCellGroup();
+assert(xGroup);
+xGroup->setCode(pNewCode);
+xGroup->compileCode(*mpDoc, pTop->aPos, mpDoc->GetGrammar());
+
+// Propagate the new token array to all formula cells in the 
group.
+ScFormulaCell** pp = rEntry.mpCells;
+ScFormulaCell** ppEnd = pp + rEntry.mnLength;
+for (; pp != ppEnd; ++pp)
+{
+ScFormulaCell* p = *pp;
+p->SyncSharedCode();
+p->SetDirty();
+}
 }
 }
 else
commit ed9d606306cc66ec89e9a6696494b6cdefd9b208
Author: Kohei Yoshida 
Date:   Fri Apr 11 00:53:49 2014 -0400

fdo#77300: Add more test to cover the shared formula case.

Change-Id: I076cb7b8d5f9b51e7337a512bb86efbabee021a8

diff --git a/sc/qa/unit/ucalc_sharedformula.cxx 
b/sc/qa/unit/ucalc_sharedformula.cxx
index 603e26e..d482216 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -1225,17 +1225,29 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
 // Set single formula with no named range to B5.
 m_pDoc->SetString(ScAddress(1,4,0), "=ROW()");
 
+// Set shared formula with no named range to B7:B8.
+m_pDoc->SetString(ScAddress(1,6,0), "=ROW()");
+m_pDoc->SetString(ScAddress(1,7,0), "=ROW()");
+
 // B1:B3 should be grouped.
 ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0));
 CPPUNIT_ASSERT(pFC);
 CPPUNIT_ASSERT_EQUAL(static_cast(0), pFC->GetSharedTopRow());
 CPPUNIT_ASSERT_EQUAL(static_cast(3), pFC->GetSharedLength());
 
+// B7:B8 should be grouped.
+pFC = m_pDoc->GetFormulaCell(ScAddress(1,6,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_EQUAL(static_cast(6), pFC->GetSharedTopRow());
+CPPUNIT_ASSERT_EQUAL(static_cast(2), pFC->GetSharedLength());
+
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,0,0)));
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,1,0)));
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(1,2,0)));
 
 CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(1,4,0)));
+CPPUNIT_ASSERT_EQUAL(7.0, m_pDoc->GetValue(ScAddress(1,6,0)));
+CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc->GetValue(ScAddress(1,7,0)));
 
 // Set a single formula to C1.
 m_pDoc->SetString(ScAddress(2,0,0), "=AVERAGE(MyRange)");
@@ -1267,6 +1279,10 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
 CPPUNIT_FAIL("Wrong formula!");
 if (!checkFormula(*m_pDoc, ScAddress(1,4,0), "ROW()"))
 CPPUNIT_FAIL("Wrong formula!");
+if (!checkFormula(*m_pDoc, ScAddress(1,6,0), "ROW()"))
+CPPUNIT_FAIL("Wrong formula!");
+if (!checkFormula(*m_pDoc, ScAddress(1,7,0), "ROW()"))
+CPPUNIT_FAIL("Wrong formula!");
 if (!checkFormula(*m_pDoc, ScAddress(2,0,0), "AVERAGE(MyRange)"))
 CPPUNIT_FAIL("Wrong formula!");
 
@@ -1275,6 +1291,8 @@ void Test::testSharedFormulaUpdateOnNamedRangeChange()
 CPPUNIT_ASS

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

2014-02-06 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx |   75 +++
 sc/qa/unit/ucalc.hxx |2 +
 sc/source/core/data/column3.cxx  |1 
 sc/source/core/data/document.cxx |3 +
 sc/source/ui/view/viewfun3.cxx   |3 +
 5 files changed, 81 insertions(+), 3 deletions(-)

New commits:
commit 0c12aa670b83b76241077dfb8bc21f40a55b1667
Author: Kohei Yoshida 
Date:   Thu Feb 6 14:11:43 2014 -0500

fdo#74573: Skip deletion of destination area when 'skip empty' is on.

Also, adjust handling of mix document aka paste functions with this
change.  When using paste function (add, subtract, etc), the behavior
between the 'skip empty' flag on and off makes no difference.  Let's
set the flag to off when paste function is used.

Change-Id: I67724ba923c9260b2c14464e4123b8445712dbaf

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index fb6518e..b97e396 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -731,7 +731,6 @@ public:
 
 void operator() (const sc::CellStoreType::value_type& node, size_t 
nOffset, size_t nDataSize)
 {
-
 SCROW nSrcRow1 = node.position + nOffset;
 bool bCopyCellNotes = mrCxt.isCloneNotes();
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9f5b3bb..fdbb1fa 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2690,7 +2690,8 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, 
const ScMarkData& rMar
 SCCOL nCol2 = pRange->aEnd.Col();
 SCROW nRow2 = pRange->aEnd.Row();
 
-DeleteArea(nCol1, nRow1, nCol2, nRow2, rMark, nDelFlag);
+if (!bSkipAttrForEmpty)
+DeleteArea(nCol1, nRow1, nCol2, nRow2, rMark, nDelFlag);
 
 if (CopyOneCellFromClip(aCxt, nCol1, nRow1, nCol2, nRow2))
 continue;
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index e501458..fd16a60 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -1188,8 +1188,9 @@ bool ScViewFunc::PasteFromClip( sal_uInt16 nFlags, 
ScDocument* pClipDoc,
 //
 
 ScDocument* pMixDoc = NULL;
-if ( bSkipEmpty || nFunction )
+if (nFunction)
 {
+bSkipEmpty = false;
 if ( nFlags & IDF_CONTENTS )
 {
 pMixDoc = new ScDocument( SCDOCMODE_UNDO );
commit 4f2482c6a82e2c32511cd9bd9adea863191f7199
Author: Kohei Yoshida 
Date:   Thu Feb 6 14:11:02 2014 -0500

fdo#74573: Write test for pasting with empty cells skipped.

Change-Id: I8ede86b248a9b3a17d077442537e2ec37034f597

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 3bab048..81e1902 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3594,6 +3594,81 @@ void Test::testCopyPasteTranspose()
 
 }
 
+void Test::testCopyPasteSkipEmpty()
+{
+m_pDoc->InsertTab(0, "Test");
+
+ScRange aSrcRange(0,0,0,0,4,0);
+ScRange aDestRange(1,0,0,1,4,0);
+
+ScMarkData aMark;
+aMark.SetMarkArea(aDestRange);
+
+// Put some texts in A1:A5.
+m_pDoc->SetString(ScAddress(1,0,0), "A");
+m_pDoc->SetString(ScAddress(1,1,0), "B");
+m_pDoc->SetString(ScAddress(1,2,0), "C");
+m_pDoc->SetString(ScAddress(1,3,0), "D");
+m_pDoc->SetString(ScAddress(1,4,0), "E");
+
+// Prepare a clipboard content interleaved with empty cells.
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+aClipDoc.ResetClip(m_pDoc, &aMark);
+aClipDoc.SetClipParam(ScClipParam(aSrcRange, false));
+aClipDoc.SetString(ScAddress(0,0,0), "Clip1");
+aClipDoc.SetString(ScAddress(0,2,0), "Clip2");
+aClipDoc.SetString(ScAddress(0,4,0), "Clip3");
+
+CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, 
aClipDoc.GetCellType(ScAddress(0,0,0)));
+CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE,   
aClipDoc.GetCellType(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, 
aClipDoc.GetCellType(ScAddress(0,2,0)));
+CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE,   
aClipDoc.GetCellType(ScAddress(0,3,0)));
+CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, 
aClipDoc.GetCellType(ScAddress(0,4,0)));
+
+// Create undo document.
+ScDocument* pUndoDoc = new ScDocument(SCDOCMODE_UNDO);
+pUndoDoc->InitUndo(m_pDoc, 0, 0);
+m_pDoc->CopyToDocument(aDestRange, IDF_CONTENTS, false, pUndoDoc, &aMark);
+
+// Paste clipboard content onto A1:A5 but skip empty cells.
+bool bSkipEmpty = true;
+m_pDoc->CopyFromClip(aDestRange, aMark, IDF_CONTENTS, pUndoDoc, &aClipDoc, 
true, false, false, bSkipEmpty);
+
+// Create redo document.
+ScDocument* pRedoDoc = new ScDocument(SCDOCMODE_UNDO);
+pRedoDoc->InitUndo(m_pDoc, 0, 0);
+m_pDoc->CopyToDocument(aDestRange, IDF_CONTENTS, false, pRedoDoc, &aMark);
+
+// Create an undo object for this.
+ScRefUndoData* pRefUndoData = new ScRefUndoData(m_pDoc);
+ScUndoPaste aUndo(&getDocShell(), aDestRange, aMark, pUndoDoc, pRedoDoc, 
IDF_CONTENTS, pRefUndoData);

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

2014-02-06 Thread Kohei Yoshida
 sc/qa/unit/data/xls/shared-formula/horizontal.xls |binary
 sc/qa/unit/subsequent_filters-test.cxx|   45 ++
 sc/source/filter/excel/excform.cxx|2 
 3 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 16442998b8b6ac7e284ab2377013f36c28b2cb8c
Author: Kohei Yoshida 
Date:   Thu Feb 6 18:08:03 2014 -0500

fdo#74553: Use the shared formula column position Excel tells you...

Because sometimes this may be correct.

Change-Id: Id2c47bb4ad3f91b366a25306169de58bb38c1e81

diff --git a/sc/source/filter/excel/excform.cxx 
b/sc/source/filter/excel/excform.cxx
index 6d925fb..cf44d3c 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -124,7 +124,7 @@ void ImportExcel::Formula(
 SCROW nSharedRow;
 if (pFormConv->ReadSharedFormulaPosition(maStrm, nSharedCol, 
nSharedRow))
 {
-ScAddress aRefPos(aScPos.Col(), nSharedRow, GetCurrScTab());
+ScAddress aRefPos(nSharedCol, nSharedRow, GetCurrScTab());
 const ScTokenArray* pSharedCode = 
pFormConv->GetSharedFormula(aRefPos);
 if (pSharedCode)
 {
commit 642d0c9abc30b5f9c06abe4d91b55fdf06427ce5
Author: Kohei Yoshida 
Date:   Thu Feb 6 18:05:50 2014 -0500

fdo#74553: Write unit test for this.

Change-Id: Ie33047dff35c7aa31aaed9ec6c8e1fe5f8f5b9d7

diff --git a/sc/qa/unit/data/xls/shared-formula/horizontal.xls 
b/sc/qa/unit/data/xls/shared-formula/horizontal.xls
new file mode 100644
index 000..318379f
Binary files /dev/null and b/sc/qa/unit/data/xls/shared-formula/horizontal.xls 
differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 003fdd0..448a9fa 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -158,6 +158,8 @@ public:
 
 void testColumnStyleXLSX();
 
+void testSharedFormulaHorizontalXLS();
+
 CPPUNIT_TEST_SUITE(ScFiltersTest);
 CPPUNIT_TEST(testBasicCellContentODS);
 CPPUNIT_TEST(testRangeNameXLS);
@@ -231,6 +233,7 @@ public:
 CPPUNIT_TEST(testPrintRangeODS);
 CPPUNIT_TEST(testOutlineODS);
 CPPUNIT_TEST(testColumnStyleXLSX);
+CPPUNIT_TEST(testSharedFormulaHorizontalXLS);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2443,6 +2446,48 @@ void ScFiltersTest::testColumnStyleXLSX()
 
 const ScProtectionAttr& rAttrNew = static_cast(pPattern->GetItem(ATTR_PROTECTION));
 CPPUNIT_ASSERT(!rAttrNew.GetProtection());
+
+xDocSh->DoClose();
+}
+
+void ScFiltersTest::testSharedFormulaHorizontalXLS()
+{
+ScDocShellRef xDocSh = loadDoc("shared-formula/horizontal.", XLS);
+CPPUNIT_ASSERT(xDocSh.Is());
+ScDocument* pDoc = xDocSh->GetDocument();
+
+// Make sure K2:S2 on the 2nd sheet are all formula cells.
+ScAddress aPos(0, 1, 1);
+for (SCCOL nCol = 10; nCol <= 18; ++nCol)
+{
+aPos.SetCol(nCol);
+CPPUNIT_ASSERT_MESSAGE("Formula cell is expected here.", 
pDoc->GetCellType(aPos) == CELLTYPE_FORMULA);
+}
+
+// Likewise, B3:J9 all should be formula cells.
+for (SCCOL nCol = 1; nCol <= 9; ++nCol)
+{
+aPos.SetCol(nCol);
+for (SCROW nRow = 2; nRow <= 8; ++nRow)
+{
+aPos.SetRow(nRow);
+CPPUNIT_ASSERT_MESSAGE("Formula cell is expected here.", 
pDoc->GetCellType(aPos) == CELLTYPE_FORMULA);
+}
+}
+
+// B2:I2 too.
+aPos.SetRow(1);
+for (SCCOL nCol = 1; nCol <= 8; ++nCol)
+{
+aPos.SetCol(nCol);
+CPPUNIT_ASSERT_MESSAGE("Formula cell is expected here.", 
pDoc->GetCellType(aPos) == CELLTYPE_FORMULA);
+}
+
+// J2 has a string of "MW".
+aPos.SetCol(9);
+CPPUNIT_ASSERT_EQUAL(OUString("MW"), pDoc->GetString(aPos));
+
+xDocSh->DoClose();
 }
 
 ScFiltersTest::ScFiltersTest()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-07 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   37 +
 sc/qa/unit/ucalc.hxx|2 ++
 sc/source/core/data/dociter.cxx |2 +-
 3 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit 738bd2cfd446debbc0e08fb554276fa28c7d
Author: Kohei Yoshida 
Date:   Fri Feb 7 11:52:16 2014 -0500

fdo#74507: Ensure that we have non-null pointer to ScColumn.

Else it would cause a null pointer dereferencing when "precision as shown"
option is set.

Change-Id: Ie8d2fdb916b575fff7e0217c45c18a2c799577cb

diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 188a3fc..5bb9236 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -170,7 +170,7 @@ bool ScValueIterator::GetThis(double& rValue, sal_uInt16& 
rErr)
 bNextColumn = true;
 }
 
-ScColumn* pCol = NULL;
+ScColumn* pCol = &(pDoc->maTabs[mnTab])->aCol[mnCol];
 if (bNextColumn)
 {
 // Find the next available column.
commit 6437313bdba12836d9e472654ad402601af58077
Author: Kohei Yoshida 
Date:   Fri Feb 7 11:45:07 2014 -0500

fdo#74507: Write test for this to induce the crash during unit test run.

Change-Id: Ib25136c203f7da17a9b7f086916d870225bc729b

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 596bd92..275e4a0 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -56,6 +56,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "formula/IFunctionDescription.hxx"
 
@@ -1189,6 +1190,42 @@ void Test::testHorizontalIterator()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testValueIterator()
+{
+m_pDoc->InsertTab(0, "Test");
+
+// Turn on "precision as shown" option.
+ScDocOptions aOpt = m_pDoc->GetDocOptions();
+aOpt.SetCalcAsShown(true);
+m_pDoc->SetDocOptions(aOpt);
+
+// Purely horizontal data layout with numeric data.
+for (SCCOL i = 1; i <= 3; ++i)
+m_pDoc->SetValue(ScAddress(i,2,0), i);
+
+double fVal;
+sal_uInt16 nErr;
+
+{
+const double aChecks[] = { 1.0, 2.0, 3.0 };
+size_t nCheckLen = SAL_N_ELEMENTS(aChecks);
+
+ScValueIterator aIter(m_pDoc, ScRange(1,2,0,3,2,0));
+bool bHas = false;
+
+size_t nCheckPos = 0;
+for (bHas = aIter.GetFirst(fVal, nErr); bHas; bHas = 
aIter.GetNext(fVal, nErr), ++nCheckPos)
+{
+CPPUNIT_ASSERT_MESSAGE("Iteration longer than expected.", 
nCheckPos < nCheckLen);
+CPPUNIT_ASSERT_EQUAL(aChecks[nCheckPos], fVal);
+CPPUNIT_ASSERT_EQUAL(static_cast(0), nErr);
+}
+}
+
+
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testFormulaDepTracking()
 {
 CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, 
"foo"));
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index dfa3a4b..74b79a3 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -137,6 +137,7 @@ public:
 void testVolatileFunc();
 
 void testHorizontalIterator();
+void testValueIterator();
 
 /**
  * Basic test for formula dependency tracking.
@@ -361,6 +362,7 @@ public:
 CPPUNIT_TEST(testSheetsFunc);
 CPPUNIT_TEST(testVolatileFunc);
 CPPUNIT_TEST(testHorizontalIterator);
+CPPUNIT_TEST(testValueIterator);
 CPPUNIT_TEST(testFormulaDepTracking);
 CPPUNIT_TEST(testFormulaDepTracking2);
 CPPUNIT_TEST(testCellBroadcaster);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-07 Thread Kohei Yoshida
 sc/qa/unit/data/xlsx/hyperlinks.xlsx |binary
 sc/qa/unit/subsequent_filters-test.cxx   |   14 ++
 sc/source/filter/oox/worksheethelper.cxx |1 +
 3 files changed, 15 insertions(+)

New commits:
commit 10da10ee6ba37f4861045d1f8db0022293433cec
Author: Kohei Yoshida 
Date:   Fri Feb 7 14:39:42 2014 -0500

fdo#74535: Don't forget clear the edit engine before re-using it.

Else you'd get a very comical result.

Change-Id: Ie73145dee47a8583f2e9cdb7ddb4f2d66f361dc1

diff --git a/sc/source/filter/oox/worksheethelper.cxx 
b/sc/source/filter/oox/worksheethelper.cxx
index 47b759d..0a560d1 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -1068,6 +1068,7 @@ void WorksheetGlobals::insertHyperlink( const 
CellAddress& rAddress, const OUStr
 {
 OUString aStr = aCell.getString(&rDoc.getDoc());
 ScFieldEditEngine& rEE = rDoc.getDoc().GetEditEngine();
+rEE.Clear();
 
 SvxURLField aURLField(rUrl, aStr, SVXURLFORMAT_REPR);
 SvxFieldItem aURLItem(aURLField, EE_FEATURE_FIELD);
commit 36e7fca5fa87fc72cdc9315438d9437fae9aa3da
Author: Kohei Yoshida 
Date:   Fri Feb 7 14:23:24 2014 -0500

fdo#74535: Write unit test for importing hyperlinks from xlsx.

Change-Id: I64e053106cee396a09f2a4915c19fcb1d69e5e82

diff --git a/sc/qa/unit/data/xlsx/hyperlinks.xlsx 
b/sc/qa/unit/data/xlsx/hyperlinks.xlsx
new file mode 100644
index 000..5faea7d
Binary files /dev/null and b/sc/qa/unit/data/xlsx/hyperlinks.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 448a9fa..83841b3 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -89,6 +89,7 @@ public:
 void testBasicCellContentODS();
 void testRangeNameXLS();
 void testRangeNameXLSX();
+void testHyperlinksXLSX();
 void testHardRecalcODS();
 void testFunctionsODS();
 void testFunctionsExcel2010();
@@ -164,6 +165,7 @@ public:
 CPPUNIT_TEST(testBasicCellContentODS);
 CPPUNIT_TEST(testRangeNameXLS);
 CPPUNIT_TEST(testRangeNameXLSX);
+CPPUNIT_TEST(testHyperlinksXLSX);
 CPPUNIT_TEST(testHardRecalcODS);
 CPPUNIT_TEST(testFunctionsODS);
 CPPUNIT_TEST(testFunctionsExcel2010);
@@ -342,6 +344,18 @@ void ScFiltersTest::testRangeNameXLSX()
 xDocSh->DoClose();
 }
 
+void ScFiltersTest::testHyperlinksXLSX()
+{
+ScDocShellRef xDocSh = loadDoc("hyperlinks.", XLSX);
+ScDocument* pDoc = xDocSh->GetDocument();
+
+CPPUNIT_ASSERT_EQUAL(OUString("10:ABC10"), 
pDoc->GetString(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(OUString("10:ABC11"), 
pDoc->GetString(ScAddress(0,2,0)));
+CPPUNIT_ASSERT_EQUAL(OUString("10:ABC12"), 
pDoc->GetString(ScAddress(0,3,0)));
+
+xDocSh->DoClose();
+}
+
 void ScFiltersTest::testHardRecalcODS()
 {
 ScDocShellRef xDocSh = loadDoc("hard-recalc.", ODS);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-07 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   52 +++-
 sc/qa/unit/ucalc.hxx|2 -
 sc/source/core/data/column3.cxx |4 ---
 3 files changed, 31 insertions(+), 27 deletions(-)

New commits:
commit 8f60dd0223f8834224b196153f0d8601403d76dc
Author: Kohei Yoshida 
Date:   Fri Feb 7 16:02:25 2014 -0500

fdo#74273: Let's not shift the note twice. Once is enough.

The notes already are shifted at the top of the function.  We don't
need this bottom one.

Change-Id: I10858d937674e236eecbc42ee08bf6eba197755a

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index ccd62e9..7da6860 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -291,10 +291,6 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
 maCellTextAttrs.erase(nStartRow, nEndRow);
 maCellTextAttrs.resize(MAXROWCOUNT);
 
-// Shift the cell notes array too (before the broadcast).
-maCellNotes.erase(nStartRow, nEndRow);
-maCellNotes.resize(MAXROWCOUNT);
-
 CellStorageModified();
 
 if (!bShiftCells)
commit 06c17598fb944aebcd0ef0783d2d4a81662208bb
Author: Kohei Yoshida 
Date:   Fri Feb 7 16:00:08 2014 -0500

fdo#74273: Adopt existing test to catch this.

Apparently having a non-empty cell where the note is makes the note take
a slightly different code path.

Change-Id: I23decb83eeb34ee9e16b4f56816648815f102db8

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 275e4a0..b91255e 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4763,59 +4763,67 @@ void Test::testNoteBasic()
 OUString aTabName2("Table2");
 m_pDoc->InsertTab(0, aTabName);
 
-ScAddress rAddr(2, 2, 0); // cell C3
-ScPostIt *pNote = m_pDoc->GetOrCreateNote(rAddr);
+ScAddress aAddr(2, 2, 0); // cell C3
+ScPostIt *pNote = m_pDoc->GetOrCreateNote(aAddr);
 
-pNote->SetText(rAddr, aHello);
+pNote->SetText(aAddr, aHello);
 pNote->SetAuthor(aJimBob);
 
-ScPostIt *pGetNote = m_pDoc->GetNote(rAddr);
-CPPUNIT_ASSERT_MESSAGE("note should be itself", pGetNote == pNote );
+ScPostIt *pGetNote = m_pDoc->GetNote(aAddr);
+CPPUNIT_ASSERT_MESSAGE("note should be itself", pGetNote == pNote);
 
 // Insert one row at row 1.
 bool bInsertRow = m_pDoc->InsertRow(0, 0, MAXCOL, 0, 1, 1);
 CPPUNIT_ASSERT_MESSAGE("failed to insert row", bInsertRow );
 
-CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(rAddr) == 
NULL);
-rAddr.IncRow(); // cell C4
-CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote);
+CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(aAddr) == 
NULL);
+aAddr.IncRow(); // cell C4
+CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote);
 
 // Insert column at column A.
 bool bInsertCol = m_pDoc->InsertCol(0, 0, MAXROW, 0, 1, 1);
 CPPUNIT_ASSERT_MESSAGE("failed to insert column", bInsertCol );
 
-CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(rAddr) == 
NULL);
-rAddr.IncCol(); // cell D4
-CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote);
+CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(aAddr) == 
NULL);
+aAddr.IncCol(); // cell D4
+CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote);
 
 // Insert a new sheet to shift the current sheet to the right.
 m_pDoc->InsertTab(0, aTabName2);
-CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(rAddr) == 
NULL);
-rAddr.IncTab(); // Move to the next sheet.
-CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote);
+CPPUNIT_ASSERT_MESSAGE("note hasn't moved", m_pDoc->GetNote(aAddr) == 
NULL);
+aAddr.IncTab(); // Move to the next sheet.
+CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote);
 
 m_pDoc->DeleteTab(0);
-rAddr.IncTab(-1);
-CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote);
+aAddr.IncTab(-1);
+CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(aAddr) == pNote);
 
 // Insert cell at C4.  This should NOT shift the note position.
 bInsertRow = m_pDoc->InsertRow(2, 0, 2, 0, 3, 1);
 CPPUNIT_ASSERT_MESSAGE("Failed to insert cell at C4.", bInsertRow);
-CPPUNIT_ASSERT_MESSAGE("Note shouldn't have moved but it has.", 
m_pDoc->GetNote(rAddr) == pNote);
+CPPUNIT_ASSERT_MESSAGE("Note shouldn't have moved but it has.", 
m_pDoc->GetNote(aAddr) == pNote);
 
 // Delete cell at C4.  Again, this should NOT shift the note position.
 m_pDoc->DeleteRow(2, 0, 2, 0, 3, 1);
-CPPUNIT_ASSERT_MESSAGE("Note shouldn't have moved but it has.", 
m_pDoc->GetNote(rAddr) == pNote);
+CPPUNIT_ASSERT_MESSAGE("Note shouldn't have moved but it has.", 
m_pDoc->GetNote(aAddr) == pNote);
 
 // Now, with the note at D4, delete cell D3. This should shift the note 
one cell up.
 

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

2014-02-07 Thread Kohei Yoshida
 sc/qa/unit/subsequent_export-test.cxx |  127 --
 xmloff/source/style/cdouthdl.cxx  |2 
 2 files changed, 106 insertions(+), 23 deletions(-)

New commits:
commit 503b7191737eafa5621dc0aa552092793676c998
Author: Kohei Yoshida 
Date:   Fri Feb 7 21:47:19 2014 -0500

fdo#73281: Why!?

This restriction makes absolutely no sense.  It was likely someone's
temporarily hack that was totally forgotten in the past 10 years...

Not to mention removing this fixes my bug.

Change-Id: I7394cccdc9fe486fda6cdd9b7eaf98fd291895a9

diff --git a/xmloff/source/style/cdouthdl.cxx b/xmloff/source/style/cdouthdl.cxx
index e2bf0e2..d559eb8 100644
--- a/xmloff/source/style/cdouthdl.cxx
+++ b/xmloff/source/style/cdouthdl.cxx
@@ -135,7 +135,7 @@ bool XMLCrossedOutTypePropHdl::exportXML( OUString& 
rStrExpValue, const uno::Any
 sal_Int16 nValue = sal_Int16();
 OUStringBuffer aOut;
 
-if( (rValue >>= nValue) && awt::FontStrikeout::DOUBLE==nValue )
+if (rValue >>= nValue)
 {
 bRet = SvXMLUnitConverter::convertEnum(
 aOut, (sal_uInt16)nValue, pXML_CrossedoutType_Enum );
commit 27251f37e564ed7b83891875d7d269ff21f18fd9
Author: Kohei Yoshida 
Date:   Fri Feb 7 21:46:33 2014 -0500

fdo#73281: Write an export test for strike-through text attribute.

Change-Id: Ib9cffac17a8f2e0bb016952ae5dd1b00bd4fc9f9

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 5e67df9..47278e0 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -41,6 +41,7 @@
 #include "editeng/eeitem.hxx"
 #include "editeng/editobj.hxx"
 #include "editeng/section.hxx"
+#include 
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -340,6 +341,45 @@ void ScExportTest::testMiscRowHeightExport()
 miscRowHeightsTest( aTestValues, SAL_N_ELEMENTS(aTestValues) );
 }
 
+namespace {
+
+void setAttribute( ScFieldEditEngine& rEE, sal_Int32 nPara, sal_Int32 nStart, 
sal_Int32 nEnd, sal_uInt16 nType )
+{
+ESelection aSel;
+aSel.nStartPara = aSel.nEndPara = nPara;
+aSel.nStartPos = nStart;
+aSel.nEndPos = nEnd;
+
+SfxItemSet aItemSet = rEE.GetEmptyItemSet();
+switch (nType)
+{
+case EE_CHAR_WEIGHT:
+{
+SvxWeightItem aWeight(WEIGHT_BOLD, nType);
+aItemSet.Put(aWeight);
+rEE.QuickSetAttribs(aItemSet, aSel);
+}
+break;
+case EE_CHAR_ITALIC:
+{
+SvxPostureItem aItalic(ITALIC_NORMAL, nType);
+aItemSet.Put(aItalic);
+rEE.QuickSetAttribs(aItemSet, aSel);
+}
+break;
+case EE_CHAR_STRIKEOUT:
+{
+SvxCrossedOutItem aCrossOut(STRIKEOUT_SINGLE, nType);
+aItemSet.Put(aCrossOut);
+rEE.QuickSetAttribs(aItemSet, aSel);
+}
+break;
+default:
+;
+}
+}
+
+}
 
 void ScExportTest::testNamedRangeBugfdo62729()
 {
@@ -406,6 +446,23 @@ void ScExportTest::testRichTextExportODS()
 return false;
 }
 
+static bool isStrikeOut(const editeng::Section& rAttr)
+{
+if (rAttr.maAttributes.empty())
+return false;
+
+std::vector::const_iterator it = 
rAttr.maAttributes.begin(), itEnd = rAttr.maAttributes.end();
+for (; it != itEnd; ++it)
+{
+const SfxPoolItem* p = *it;
+if (p->Which() != EE_CHAR_STRIKEOUT)
+continue;
+
+return static_cast(p)->GetStrikeout() == STRIKEOUT_SINGLE;
+}
+return false;
+}
+
 bool checkB2(const EditTextObject* pText) const
 {
 if (!pText)
@@ -498,6 +555,38 @@ void ScExportTest::testRichTextExportODS()
 return true;
 }
 
+bool checkB6(const EditTextObject* pText) const
+{
+if (!pText)
+return false;
+
+if (pText->GetParagraphCount() != 1)
+return false;
+
+if (pText->GetText(0) != "Strike Me")
+return false;
+
+std::vector aSecAttrs;
+pText->GetAllSections(aSecAttrs);
+if (aSecAttrs.size() != 2)
+return false;
+
+// Check the first strike-out section.
+const editeng::Section* pAttr = &aSecAttrs[0];
+if (pAttr->mnParagraph != 0 ||pAttr->mnStart != 0 || pAttr->mnEnd 
!= 6)
+return false;
+
+if (pAttr->maAttributes.size() != 1 || !isStrikeOut(*pAttr))
+return false;
+
+// The last section should be unformatted.
+pAttr = &aSecAttrs[1];
+if (pAttr->mnParagraph != 0 ||pAttr->mnStart != 6 || pAttr->mnEnd 
!= 9)
+return false;
+
+return true;
+}
+
 } aCheckFunc;
 
 // Start 

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

2014-02-08 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx   |   33 +
 sc/source/core/data/column.cxx |2 +-
 2 files changed, 30 insertions(+), 5 deletions(-)

New commits:
commit 1e3ef350d730bc54a3e9c393c2df6fd1f839a3a8
Author: Kohei Yoshida 
Date:   Sat Feb 8 09:42:46 2014 -0500

fdo#74414: No need to incremenet nRow here... It's just plain wrong.

Change-Id: Iecdbb3eba46ddf2f2bc4f2334c7d45a4e2d801c8

diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 7d10c20..8e3d365 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1928,7 +1928,7 @@ public:
 
 std::vector aCloned;
 aCloned.reserve(nDataSize);
-for (; it != itEnd; ++it, ++nRow)
+for (; it != itEnd; ++it)
 aCloned.push_back(ScEditUtil::Clone(**it, 
mrDestCol.GetDoc()));
 
 maDestPos.miCellPos = mrDestCol.GetCellStore().set(
commit 22cdd528d26d9e332df72135394f8d57bf227d03
Author: Kohei Yoshida 
Date:   Sat Feb 8 09:35:11 2014 -0500

fdo#74414: Add a bit more check in existing test to catch this.

Change-Id: I4ab844fe686e8c38968c34305936907380a1fe7b

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index b91255e..83498b3 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2042,15 +2042,27 @@ void Test::testCellCopy()
 void Test::testSheetCopy()
 {
 m_pDoc->InsertTab(0, "TestTab");
-m_pDoc->SetString(ScAddress(0,0,0), "copy me");
 CPPUNIT_ASSERT_MESSAGE("document should have one sheet to begin with.", 
m_pDoc->GetTableCount() == 1);
+
+// Insert text in A1.
+m_pDoc->SetString(ScAddress(0,0,0), "copy me");
+
+// Insert edit cells in B1:B3.
+ScFieldEditEngine& rEE = m_pDoc->GetEditEngine();
+rEE.SetText("Edit 1");
+m_pDoc->SetEditText(ScAddress(1,0,0), rEE.CreateTextObject());
+rEE.SetText("Edit 2");
+m_pDoc->SetEditText(ScAddress(1,1,0), rEE.CreateTextObject());
+rEE.SetText("Edit 3");
+m_pDoc->SetEditText(ScAddress(1,2,0), rEE.CreateTextObject());
+
 SCROW nRow1, nRow2;
 bool bHidden = m_pDoc->RowHidden(0, 0, &nRow1, &nRow2);
 CPPUNIT_ASSERT_MESSAGE("new sheet should have all rows visible", !bHidden 
&& nRow1 == 0 && nRow2 == MAXROW);
 
 // insert a note
-ScAddress aAdrA1 (0, 0, 0); // empty cell content
-OUString aHelloA1("Hello world in A1");
+ScAddress aAdrA1 (0,2,0); // empty cell content.
+OUString aHelloA1("Hello world in A3");
 ScPostIt *pNoteA1 = m_pDoc->GetOrCreateNote(aAdrA1);
 pNoteA1->SetText(aAdrA1, aHelloA1);
 
@@ -2059,7 +2071,20 @@ void Test::testSheetCopy()
 CPPUNIT_ASSERT_MESSAGE("document now should have two sheets.", 
m_pDoc->GetTableCount() == 2);
 bHidden = m_pDoc->RowHidden(0, 1, &nRow1, &nRow2);
 CPPUNIT_ASSERT_MESSAGE("copied sheet should also have all rows visible as 
the original.", !bHidden && nRow1 == 0 && nRow2 == MAXROW);
-CPPUNIT_ASSERT_MESSAGE("There should be note on A1 in new sheet", 
m_pDoc->HasNote(ScAddress (0, 0, 1)));
+CPPUNIT_ASSERT_MESSAGE("There should be note on A3 in new sheet", 
m_pDoc->HasNote(ScAddress(0,2,1)));
+CPPUNIT_ASSERT_EQUAL(OUString("copy me"), 
m_pDoc->GetString(ScAddress(0,0,1)));
+
+// Check the copied edit cells.
+const EditTextObject* pEditObj = m_pDoc->GetEditText(ScAddress(1,0,1));
+CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in B1.", pEditObj);
+CPPUNIT_ASSERT_EQUAL(OUString("Edit 1"), pEditObj->GetText(0));
+pEditObj = m_pDoc->GetEditText(ScAddress(1,1,1));
+CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in B2.", pEditObj);
+CPPUNIT_ASSERT_EQUAL(OUString("Edit 2"), pEditObj->GetText(0));
+pEditObj = m_pDoc->GetEditText(ScAddress(1,2,1));
+CPPUNIT_ASSERT_MESSAGE("There should be an edit cell in B3.", pEditObj);
+CPPUNIT_ASSERT_EQUAL(OUString("Edit 3"), pEditObj->GetText(0));
+
 m_pDoc->DeleteTab(1);
 
 m_pDoc->SetRowHidden(5, 10, 0, true);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-08 Thread Kohei Yoshida
 sc/qa/unit/data/ods/notes-on-3-sheets.ods |binary
 sc/qa/unit/subsequent_export-test.cxx |   45 ++
 sc/source/filter/excel/excdoc.cxx |5 +++
 3 files changed, 50 insertions(+)

New commits:
commit 771b9d2718f28beedbc1a913e8965cdd1fc75a88
Author: Kohei Yoshida 
Date:   Sat Feb 8 11:37:46 2014 -0500

fdo#74521: Only pick cell notes for that sheet, and skip the rest.

Change-Id: I06a069e835eb7f2f90d34f4fcdfd935aff0234de

diff --git a/sc/source/filter/excel/excdoc.cxx 
b/sc/source/filter/excel/excdoc.cxx
index a8bfbf7..9cf433d 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -421,7 +421,12 @@ void ExcTable::FillAsTable( SCTAB nCodeNameIdx )
 rDoc.GetAllNoteEntries(aNotes);
 std::vector::const_iterator it = aNotes.begin(), itEnd = 
aNotes.end();
 for (; it != itEnd; ++it)
+{
+if (it->maPos.Tab() != mnScTab)
+continue;
+
 mxNoteList->AppendNewRecord(new XclExpNote(GetRoot(), it->maPos, 
it->mpNote, OUString()));
+}
 
 if( GetOutput() != EXC_OUTPUT_BINARY )
 {
commit 7d71fd489c39f348c43477cafdc1bc150bf1ff68
Author: Kohei Yoshida 
Date:   Sat Feb 8 10:46:47 2014 -0500

fdo#74521: Write unit test for this first.

Change-Id: I1815464e25703f1b0181211ac74341edb41793be

diff --git a/sc/qa/unit/data/ods/notes-on-3-sheets.ods 
b/sc/qa/unit/data/ods/notes-on-3-sheets.ods
new file mode 100644
index 000..e7b6399
Binary files /dev/null and b/sc/qa/unit/data/ods/notes-on-3-sheets.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 47278e0..2db6307 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -70,6 +70,7 @@ public:
 
 void testCellValuesExportODS();
 void testCellNoteExportODS();
+void testCellNoteExportXLS();
 void testFormatExportODS();
 
 void testInlineArrayXLS();
@@ -91,6 +92,7 @@ public:
 CPPUNIT_TEST(testRichTextExportODS);
 CPPUNIT_TEST(testCellValuesExportODS);
 CPPUNIT_TEST(testCellNoteExportODS);
+CPPUNIT_TEST(testCellNoteExportXLS);
 CPPUNIT_TEST(testFormatExportODS);
 CPPUNIT_TEST(testInlineArrayXLS);
 CPPUNIT_TEST(testEmbeddedChartXLS);
@@ -775,6 +777,49 @@ void ScExportTest::testCellNoteExportODS()
 xNewDocSh->DoClose();
 }
 
+void ScExportTest::testCellNoteExportXLS()
+{
+// Start with an empty document.s
+ScDocShellRef xOrigDocSh = loadDoc("notes-on-3-sheets.", ODS);
+ScDocument* pDoc = xOrigDocSh->GetDocument();
+CPPUNIT_ASSERT_MESSAGE("This document should have 3 sheets.", 
pDoc->GetTableCount() == 3);
+
+// Check note's presence.
+CPPUNIT_ASSERT( pDoc->HasNote(ScAddress(0,0,0)));
+CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,1,0)));
+CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,2,0)));
+
+CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,0,1)));
+CPPUNIT_ASSERT( pDoc->HasNote(ScAddress(0,1,1)));
+CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,2,1)));
+
+CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,0,2)));
+CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,1,2)));
+CPPUNIT_ASSERT( pDoc->HasNote(ScAddress(0,2,2)));
+
+// save and reload as XLS.
+ScDocShellRef xNewDocSh = saveAndReload(xOrigDocSh, XLS);
+xOrigDocSh->DoClose();
+CPPUNIT_ASSERT(xNewDocSh.Is());
+pDoc = xNewDocSh->GetDocument();
+CPPUNIT_ASSERT_MESSAGE("This document should have 3 sheets.", 
pDoc->GetTableCount() == 3);
+
+// Check note's presence again.
+CPPUNIT_ASSERT( pDoc->HasNote(ScAddress(0,0,0)));
+CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,1,0)));
+CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,2,0)));
+
+CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,0,1)));
+CPPUNIT_ASSERT( pDoc->HasNote(ScAddress(0,1,1)));
+CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,2,1)));
+
+CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,0,2)));
+CPPUNIT_ASSERT(!pDoc->HasNote(ScAddress(0,1,2)));
+CPPUNIT_ASSERT( pDoc->HasNote(ScAddress(0,2,2)));
+
+xNewDocSh->DoClose();
+}
+
 namespace {
 
 void checkMatrixRange(ScDocument& rDoc, const ScRange& rRange)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-08 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx|2 +
 sc/qa/unit/ucalc_sharedformula.cxx  |   39 
 sc/source/core/data/formulacell.cxx |8 +++
 3 files changed, 49 insertions(+)

New commits:
commit 1556dbc451f067d8744378fb9bac0eaa7ef8f5ac
Author: Kohei Yoshida 
Date:   Sat Feb 8 15:13:18 2014 -0500

fdo#74453: Only adjust tokens for top formula cells of formula group.

Change-Id: Id04387dffac271b3d617da0fbc19c862c929d60a

diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index a1e9ec1..88ca441 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -3023,6 +3023,10 @@ void ScFormulaCell::UpdateInsertTabAbs(SCTAB nTable)
 if (pDocument->IsClipOrUndo())
 return;
 
+bool bAdjustCode = !mxGroup || mxGroup->mpTopCell == this;
+if (!bAdjustCode)
+return;
+
 pCode->Reset();
 ScToken* p = static_cast(pCode->GetNextReferenceRPN());
 while (p)
@@ -3045,6 +3049,10 @@ bool ScFormulaCell::TestTabRefAbs(SCTAB nTable)
 if (pDocument->IsClipOrUndo())
 return false;
 
+bool bAdjustCode = !mxGroup || mxGroup->mpTopCell == this;
+if (!bAdjustCode)
+return false;
+
 bool bRet = false;
 pCode->Reset();
 ScToken* p = static_cast(pCode->GetNextReferenceRPN());
commit ac5682aa3013550e3643026c571b5d851b9e7b67
Author: Kohei Yoshida 
Date:   Sat Feb 8 14:42:31 2014 -0500

fdo#74453: Write unit test for this.

Change-Id: Ic8cbc650d6608ff7af5d1d58deeeba409bb81725

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index f595467..053e607 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -252,6 +252,7 @@ public:
 void testSharedFormulasRefUpdateRange();
 void testSharedFormulasDeleteRows();
 void testSharedFormulasRefUpdateMoveSheets();
+void testSharedFormulasRefUpdateCopySheets();
 void testSharedFormulasCopyPaste();
 void testSharedFormulaInsertColumn();
 void testFormulaPosition();
@@ -414,6 +415,7 @@ public:
 CPPUNIT_TEST(testSharedFormulasRefUpdateRange);
 CPPUNIT_TEST(testSharedFormulasDeleteRows);
 CPPUNIT_TEST(testSharedFormulasRefUpdateMoveSheets);
+CPPUNIT_TEST(testSharedFormulasRefUpdateCopySheets);
 CPPUNIT_TEST(testSharedFormulasCopyPaste);
 CPPUNIT_TEST(testSharedFormulaInsertColumn);
 CPPUNIT_TEST(testFormulaPosition);
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx 
b/sc/qa/unit/ucalc_sharedformula.cxx
index 04e917f..a64398b 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -600,6 +600,45 @@ void Test::testSharedFormulasRefUpdateMoveSheets()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testSharedFormulasRefUpdateCopySheets()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // make sure auto calc is on.
+
+m_pDoc->InsertTab(0, "Sheet1");
+m_pDoc->InsertTab(1, "Sheet2");
+
+m_pDoc->SetValue(ScAddress(0,0,1), 1.0); // A1 on Sheet2
+m_pDoc->SetValue(ScAddress(0,1,1), 2.0); // A2 on Sheet2
+
+// Reference values on Sheet2, but use absolute sheet references.
+m_pDoc->SetString(ScAddress(0,0,0), "=$Sheet2.A1");
+m_pDoc->SetString(ScAddress(0,1,0), "=$Sheet2.A2");
+
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0)));
+CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+
+// Copy Sheet1 and insert the copied sheet before the current Sheet1 
position.
+m_pDoc->CopyTab(0, 0);
+
+if (!checkFormula(*m_pDoc, ScAddress(0,0,0), "$Sheet2.A1"))
+CPPUNIT_FAIL("Wrong formula");
+
+if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "$Sheet2.A2"))
+CPPUNIT_FAIL("Wrong formula");
+
+// Check the values on the copied sheet.
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0)));
+CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+
+// Check the values on the original sheet.
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,1)));
+CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,1)));
+
+m_pDoc->DeleteTab(2);
+m_pDoc->DeleteTab(1);
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testSharedFormulasCopyPaste()
 {
 m_pDoc->InsertTab(0, "Test");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-08 Thread Kohei Yoshida
 sc/qa/unit/ucalc_formula.cxx |   20 
 sc/source/core/tool/compiler.cxx |   28 
 2 files changed, 28 insertions(+), 20 deletions(-)

New commits:
commit 83cdcdb9f0fe11309939f5dca4fb46e426559896
Author: Kohei Yoshida 
Date:   Sat Feb 8 18:19:42 2014 -0500

fdo#74512: Generate escaped sheet names after the grammer is set.

Otherwise the single quote characters wouldn't be properly doubled.

Change-Id: I864ca8912a35049905e52e002d92d648e1278015

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 8c6dee9..f8d00f1 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -238,6 +238,14 @@ void ScCompiler::SetGrammar( const FormulaGrammar::Grammar 
eGrammar )
 if (eMyGrammar != GetGrammar())
 SetGrammarAndRefConvention( eMyGrammar, eOldGrammar);
 }
+
+if (pDoc && maTabNames.empty())
+{
+maTabNames = pDoc->GetAllTableNames();
+std::vector::iterator it = maTabNames.begin(), itEnd = 
maTabNames.end();
+for (; it != itEnd; ++it)
+ScCompiler::CheckTabQuotes(*it, 
formula::FormulaGrammar::extractRefConvention(meGrammar));
+}
 }
 
 void ScCompiler::SetNumberFormatter( SvNumberFormatter* pFormatter )
@@ -1546,16 +1554,6 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const 
ScAddress& rPos,ScTokenArra
 mbRewind( false )
 {
 nMaxTab = pDoc ? pDoc->GetTableCount() - 1 : 0;
-
-if (pDoc)
-{
-maTabNames = pDoc->GetAllTableNames();
-{
-std::vector::iterator it = maTabNames.begin(), itEnd = 
maTabNames.end();
-for (; it != itEnd; ++it)
-ScCompiler::CheckTabQuotes(*it, 
formula::FormulaGrammar::extractRefConvention(meGrammar));
-}
-}
 }
 
 ScCompiler::ScCompiler( sc::CompileFormulaContext& rCxt, const ScAddress& rPos 
) :
@@ -1589,16 +1587,6 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const 
ScAddress& rPos)
 mbRewind( false )
 {
 nMaxTab = pDoc ? pDoc->GetTableCount() - 1 : 0;
-
-if (pDoc)
-{
-maTabNames = pDoc->GetAllTableNames();
-{
-std::vector::iterator it = maTabNames.begin(), itEnd = 
maTabNames.end();
-for (; it != itEnd; ++it)
-ScCompiler::CheckTabQuotes(*it, 
formula::FormulaGrammar::extractRefConvention(meGrammar));
-}
-}
 }
 
 ScCompiler::~ScCompiler()
commit c4987cd730be2d4aa7c76e69fad4e3195413fb0c
Author: Kohei Yoshida 
Date:   Sat Feb 8 18:01:08 2014 -0500

fdo#74512: Add test for this.

Change-Id: I472a91375c6408761d9c300b3575cfe101649fca

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 411ed9e..05ff6b6 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -217,6 +217,26 @@ void Test::testFormulaParseReference()
 m_pDoc->GetName(4, aTabName);
 CPPUNIT_ASSERT_EQUAL(aTab4, aTabName);
 
+// Make sure the formula input and output match.
+{
+const char* aChecks[] = {
+"'90''s Music'.B12",
+"'90''s and 70''s'.$AB$100",
+"'All Others'.Z$100",
+"NoQuote.$C111"
+};
+
+for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
+{
+// Use the 'Dummy' sheet for this.
+OUString aInput("=");
+aInput += OUString::createFromAscii(aChecks[i]);
+m_pDoc->SetString(ScAddress(0,0,0), aInput);
+if (!checkFormula(*m_pDoc, ScAddress(0,0,0), aChecks[i]))
+CPPUNIT_FAIL("Wrong formula");
+}
+}
+
 ScAddress aPos;
 ScAddress::ExternalInfo aExtInfo;
 sal_uInt16 nRes = aPos.Parse("'90''s Music'.D10", m_pDoc, 
formula::FormulaGrammar::CONV_OOO, &aExtInfo);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-09 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx |2 ++
 sc/qa/unit/ucalc_formula.cxx |   25 +
 sc/source/core/tool/scmatrix.cxx |   11 ++-
 3 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit 295869ce95c00a0e0b192ea6bf62753f91badaf2
Author: Kohei Yoshida 
Date:   Sun Feb 9 11:34:11 2014 -0500

fdo#74479: Treat empty cells as if they have a value of 0.

Change-Id: I3701848016c230138e8791f683a2c8b97219198d

diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 74f7fa3..090cada 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -1612,7 +1612,16 @@ public:
 }
 break;
 case mdds::mtm::element_empty:
-std::advance(miPos, node.size);
+{
+// Empty element is equivalent of having a numeric value of 
0.0.
+for (size_t i = 0; i < node.size; ++i, ++miPos)
+{
+if (rtl::math::isNan(*miPos))
+continue;
+
+*miPos = op(*miPos, 0.0);
+}
+}
 default:
 ;
 }
commit 71fe47cfe652829ff7dc09ae49b1c6c22d9b6a6d
Author: Kohei Yoshida 
Date:   Sun Feb 9 11:10:34 2014 -0500

fdo#74479: Test case for SUMPRODUCT.

Change-Id: I2e8669c1cd6c824751d557c7c9ee735d580f17e9

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 053e607..a32b048 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -115,6 +115,7 @@ public:
 void testFuncROW();
 void testFuncSUM();
 void testFuncPRODUCT();
+void testFuncSUMPRODUCT();
 void testFuncN();
 void testFuncCOUNTIF();
 void testFuncNUMBERVALUE();
@@ -347,6 +348,7 @@ public:
 CPPUNIT_TEST(testFuncROW);
 CPPUNIT_TEST(testFuncSUM);
 CPPUNIT_TEST(testFuncPRODUCT);
+CPPUNIT_TEST(testFuncSUMPRODUCT);
 CPPUNIT_TEST(testFuncN);
 CPPUNIT_TEST(testFuncCOUNTIF);
 CPPUNIT_TEST(testFuncNUMBERVALUE);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 05ff6b6..a4b6289 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1790,6 +1790,31 @@ void Test::testFuncPRODUCT()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testFuncSUMPRODUCT()
+{
+m_pDoc->InsertTab(0, "Test");
+
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto recalc.
+
+ScAddress aPos(0,0,0);
+m_pDoc->SetString(aPos, "=SUMPRODUCT(B1:B3;C1:C3)");
+CPPUNIT_ASSERT_EQUAL(0.0,  m_pDoc->GetValue(aPos));
+m_pDoc->SetValue(ScAddress(2,0,0),  1.0); // C1
+CPPUNIT_ASSERT_EQUAL(0.0,  m_pDoc->GetValue(aPos));
+m_pDoc->SetValue(ScAddress(1,0,0),  1.0); // B1
+CPPUNIT_ASSERT_EQUAL(1.0,  m_pDoc->GetValue(aPos));
+m_pDoc->SetValue(ScAddress(1,1,0),  2.0); // B2
+CPPUNIT_ASSERT_EQUAL(1.0,  m_pDoc->GetValue(aPos));
+m_pDoc->SetValue(ScAddress(2,1,0),  3.0); // C2
+CPPUNIT_ASSERT_EQUAL(7.0,  m_pDoc->GetValue(aPos));
+m_pDoc->SetValue(ScAddress(2,2,0), -2.0); // C3
+CPPUNIT_ASSERT_EQUAL(7.0,  m_pDoc->GetValue(aPos));
+m_pDoc->SetValue(ScAddress(1,2,0),  5.0); // B3
+CPPUNIT_ASSERT_EQUAL(-3.0, m_pDoc->GetValue(aPos));
+
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testFuncN()
 {
 OUString aTabName("foo");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-09 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx   |   25 +
 sc/qa/unit/ucalc.hxx   |2 ++
 sc/source/core/data/table1.cxx |2 +-
 3 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit b6378a1651e7157063746d7001ef566545338bd0
Author: Kohei Yoshida 
Date:   Sun Feb 9 22:10:24 2014 -0500

fdo#74323: The end position is inclusive.

Change-Id: Ibd0ff19d7fd2de72a3b8d790a371da4b23df38c8

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 5291ad2..b3385a3 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1428,7 +1428,7 @@ bool ScTable::GetNextMarkedCell( SCCOL& rCol, SCROW& 
rRow, const ScMarkData& rMa
 }
 }
 
-if (nTestRow < nEnd)
+if (nTestRow <= nEnd)
 {
 // Cell found.
 rRow = nTestRow;
commit e041a1bfef98b54656cfaafcb0f586867a21edf1
Author: Kohei Yoshida 
Date:   Sun Feb 9 21:58:55 2014 -0500

fdo#74323: Add unit test for changing cases of text cells.

Change-Id: I858e18a03d97434275676e771d91bdf3209f63fb

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 83498b3..5ae240f 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -80,6 +80,8 @@
 #include 
 #include 
 
+#include 
+
 struct TestImpl
 {
 ScDocShellRef m_xDocShell;
@@ -5464,6 +5466,29 @@ void Test::testImportStream()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testTransliterateText()
+{
+m_pDoc->InsertTab(0, "Test");
+
+// Set texts to A1:A3.
+m_pDoc->SetString(ScAddress(0,0,0), "Mike");
+m_pDoc->SetString(ScAddress(0,1,0), "Noah");
+m_pDoc->SetString(ScAddress(0,2,0), "Oscar");
+
+// Change them to uppercase.
+ScMarkData aMark;
+aMark.SetMarkArea(ScRange(0,0,0,0,2,0));
+ScDocFunc& rFunc = getDocShell().GetDocFunc();
+rFunc.TransliterateText(
+aMark, i18n::TransliterationModules_LOWERCASE_UPPERCASE, true, true);
+
+CPPUNIT_ASSERT_EQUAL(OUString("MIKE"), 
m_pDoc->GetString(ScAddress(0,0,0)));
+CPPUNIT_ASSERT_EQUAL(OUString("NOAH"), 
m_pDoc->GetString(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(OUString("OSCAR"), 
m_pDoc->GetString(ScAddress(0,2,0)));
+
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testMixData()
 {
 m_pDoc->InsertTab(0, "Test");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index a32b048..64fde25 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -316,6 +316,7 @@ public:
 void testCondCopyPaste();
 
 void testImportStream();
+void testTransliterateText();
 
 void testColumnFindEditCells();
 
@@ -447,6 +448,7 @@ public:
 CPPUNIT_TEST(testCondFormatInsertCol);
 CPPUNIT_TEST(testCondCopyPaste);
 CPPUNIT_TEST(testImportStream);
+CPPUNIT_TEST(testTransliterateText);
 CPPUNIT_TEST(testColumnFindEditCells);
 CPPUNIT_TEST_SUITE_END();
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-10 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx   |   46 -
 sc/qa/unit/ucalc.hxx   |2 +
 sc/source/ui/undo/undoblk3.cxx |1 
 3 files changed, 48 insertions(+), 1 deletion(-)

New commits:
commit 182ac74065d8724bf74003cb72928b2cfa7388e9
Author: Kohei Yoshida 
Date:   Tue Feb 11 01:08:15 2014 -0500

fdo#74014: Broadcast here

Change-Id: Ib3c1e6b18af2c96c8c38237ab65f868ffec5f139

diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index 95949b8..5c44dd8 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -142,6 +142,7 @@ void ScUndoDeleteContents::DoChange( const sal_Bool bUndo )
 aCopyRange.aEnd.SetTab(nTabCount-1);
 
 pUndoDoc->CopyToDocument( aCopyRange, nUndoFlags, bMulti, pDoc, 
&aMarkData );
+BroadcastChanges(aCopyRange);
 
 DoSdrUndoAction( pDrawUndo, pDoc );
 
commit aa03bdcb5216ff82de22fc02ffa0746902f64972
Author: Kohei Yoshida 
Date:   Tue Feb 11 01:07:00 2014 -0500

fdo#74014: Additional test.

Though this one passes in unit test, but fails in real life session.  No
idea why.

Change-Id: I657ed5aa8b1aa0046458d26badf3cb22e3778d41

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index fc539d9..c06f82d 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5422,7 +5422,7 @@ void Test::testImportStream()
 
 m_pDoc->InsertTab(0, "Test");
 
-m_pDoc->SetString(ScAddress(0,1,0), "=SUM(A1:C1)");
+m_pDoc->SetString(ScAddress(0,1,0), "=SUM(A1:C1)"); // A2
 
 CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(0,1,0)));
 
@@ -5430,6 +5430,7 @@ void Test::testImportStream()
 ScAsciiOptions aOpt;
 aOpt.SetFieldSeps(",");
 
+// Import values to A1:C1.
 ScImportExport aObj(m_pDoc, ScAddress(0,0,0));
 aObj.SetImportBroadcast(true);
 aObj.SetExtOptions(aOpt);
@@ -5463,6 +5464,49 @@ void Test::testImportStream()
 CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,1,0))); // formula
 
 pUndoMgr->Clear();
+
+m_pDoc->DeleteTab(0);
+}
+
+void Test::testDeleteContents()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+sc::UndoSwitch aUndoSwitch(*m_pDoc, true); // enable undo.
+
+m_pDoc->InsertTab(0, "Test");
+
+m_pDoc->SetValue(ScAddress(3,1,0), 1.0);
+m_pDoc->SetValue(ScAddress(3,2,0), 1.0);
+m_pDoc->SetValue(ScAddress(3,3,0), 1.0);
+m_pDoc->SetValue(ScAddress(3,4,0), 1.0);
+m_pDoc->SetValue(ScAddress(3,5,0), 1.0);
+m_pDoc->SetValue(ScAddress(3,6,0), 1.0);
+m_pDoc->SetValue(ScAddress(3,7,0), 1.0);
+m_pDoc->SetValue(ScAddress(3,8,0), 1.0);
+m_pDoc->SetString(ScAddress(3,15,0), "=SUM(D2:D15)");
+
+CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc->GetValue(ScAddress(3,15,0))); // formula
+
+// Delete D2:D6.
+ScRange aRange(3,1,0,3,5,0);
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+aMark.SetMarkArea(aRange);
+
+ScDocument* pUndoDoc = new ScDocument(SCDOCMODE_UNDO);
+pUndoDoc->InitUndo(m_pDoc, 0, 0);
+m_pDoc->CopyToDocument(aRange, IDF_CONTENTS, false, pUndoDoc, &aMark);
+ScUndoDeleteContents aUndo(&getDocShell(), aMark, aRange, pUndoDoc, false, 
IDF_CONTENTS, true);
+
+clearRange(m_pDoc, aRange);
+CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(3,15,0))); // formula
+
+aUndo.Undo();
+CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc->GetValue(ScAddress(3,15,0))); // formula
+
+aUndo.Redo();
+CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(3,15,0))); // formula
+
 m_pDoc->DeleteTab(0);
 }
 
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 64fde25..f94ac91 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -316,6 +316,7 @@ public:
 void testCondCopyPaste();
 
 void testImportStream();
+void testDeleteContents();
 void testTransliterateText();
 
 void testColumnFindEditCells();
@@ -448,6 +449,7 @@ public:
 CPPUNIT_TEST(testCondFormatInsertCol);
 CPPUNIT_TEST(testCondCopyPaste);
 CPPUNIT_TEST(testImportStream);
+CPPUNIT_TEST(testDeleteContents);
 CPPUNIT_TEST(testTransliterateText);
 CPPUNIT_TEST(testColumnFindEditCells);
 CPPUNIT_TEST_SUITE_END();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-14 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx  |   28 
 sc/qa/unit/ucalc.hxx  |3 +++
 sc/source/core/tool/token.cxx |3 +++
 3 files changed, 34 insertions(+)

New commits:
commit 9bf907a8278cecd816368db7b8c4ab745a914a59
Author: Kohei Yoshida 
Date:   Fri Feb 14 20:39:18 2014 -0500

fdo#72691: Allow overwriting of string value with numeric one.

This can legitimately happen when you have a matrix with a reference to
another cell inside, and the referenced cell originally contained a
string value then later overwritten by a numeric value.

Example.  Put a "Text" in A1, and in B1 put a 1x1 matrix {=A1}.  It
displays "Text" in B1.  Then put 11 in A1.  Prior to this change, B1
would become blank.  With this change, B1 will display 11.

Change-Id: I3feba3a8658e1a5ebf6f9e5ac34de2d579464ddb

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6bb060b..769b886 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1146,6 +1146,9 @@ void ScMatrixFormulaCellToken::SetUpperLeftDouble( double 
f )
 case svDouble:
 
const_cast(xUpperLeft.get())->GetDoubleAsReference() = f;
 break;
+case svString:
+xUpperLeft = new FormulaDoubleToken( f);
+break;
 case svUnknown:
 if (!xUpperLeft)
 {
commit 1ffec457c86df0906b358ac431ffdb5d1d47de8c
Author: Kohei Yoshida 
Date:   Fri Feb 14 15:15:45 2014 -0500

fdo#72691: Write unit test for this.

One tricky bit was that in order to reproduce the bug in the unit test,
formula cell's bChanged flag needed to be cleared after each update,
because that's what happens when you display updated formula on screen.  
Each
time an updated formula cell gets drawn, the UI code clears this flag.  That
same flag was used to control the code path during interpretation...

Change-Id: I2eedea3c9294f4f545422b8611840c81f8c2304f

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index c06f82d..7176312 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1360,6 +1360,34 @@ void Test::testFormulaDepTracking2()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testFormulaDepTrackingMatrix()
+{
+m_pDoc->InsertTab(0, "Test");
+
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
+
+// Set a numeric value to A1.
+m_pDoc->SetValue(ScAddress(0,0,0), 11.0);
+
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+m_pDoc->InsertMatrixFormula(1, 0, 1, 0, aMark, "=A1", NULL);
+CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(ScAddress(1,0,0)));
+ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0));
+CPPUNIT_ASSERT_MESSAGE("Failed to get formula cell.", pFC);
+pFC->SetChanged(false); // Clear this flag to simulate displaying of 
formula cell value on screen.
+
+m_pDoc->SetString(ScAddress(0,0,0), "ABC");
+CPPUNIT_ASSERT_EQUAL(OUString("ABC"), m_pDoc->GetString(ScAddress(1,0,0)));
+pFC->SetChanged(false);
+
+// Put a new value into A1. The formula should update.
+m_pDoc->SetValue(ScAddress(0,0,0), 13.0);
+CPPUNIT_ASSERT_EQUAL(13.0, m_pDoc->GetValue(ScAddress(1,0,0)));
+
+m_pDoc->DeleteTab(0);
+}
+
 namespace {
 
 bool broadcasterShifted(const ScDocument& rDoc, const ScAddress& rFrom, const 
ScAddress& rTo)
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index f94ac91..9f6dc32 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -150,6 +150,8 @@ public:
  */
 void testFormulaDepTracking2();
 
+void testFormulaDepTrackingMatrix();
+
 /**
  * More direct test for cell broadcaster management, used to track formula
  * dependencies.
@@ -370,6 +372,7 @@ public:
 CPPUNIT_TEST(testValueIterator);
 CPPUNIT_TEST(testFormulaDepTracking);
 CPPUNIT_TEST(testFormulaDepTracking2);
+CPPUNIT_TEST(testFormulaDepTrackingMatrix);
 CPPUNIT_TEST(testCellBroadcaster);
 CPPUNIT_TEST(testFuncParam);
 CPPUNIT_TEST(testNamedRange);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-17 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx  |   64 ++
 sc/source/ui/undo/undoblk.cxx |5 ++-
 2 files changed, 57 insertions(+), 12 deletions(-)

New commits:
commit 9e49b6abe7cedd2ac7137170f76ec5d7e14bd295
Author: Kohei Yoshida 
Date:   Mon Feb 17 12:20:57 2014 -0500

fdo#75032: Skip notes when copying values from undo document.

Notes undo redo are handled separately by the drawing layer.

Change-Id: Iae37ac86889d7a25f25e6dd0b69f724107c6798a

diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 2b30fed..694e171 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -414,8 +414,11 @@ void ScUndoDeleteCells::DoChange( const sal_Bool bUndo )
 // if Undo, restore references
 for( i=0; iCopyToDocument( aEffRange.aStart.Col(), 
aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Col(), aEffRange.aEnd.Row(), 
pTabs[i]+pScenarios[i],
-IDF_ALL | IDF_NOCAPTIONS, false, pDoc );
+nFlags, false, pDoc );
 }
 
 ScRange aWorkRange( aEffRange );
commit 6a5df6427913af1df99e770ea68daaa02e7c
Author: Kohei Yoshida 
Date:   Mon Feb 17 11:38:35 2014 -0500

fdo#75032: Add a test case to reproduce the crash.

Change-Id: I1bb980e9872515a8684014a0e0be9fd4c717f9fd

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index a8ec5e2..67c6e8a 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4885,30 +4885,72 @@ void Test::testNoteBasic()
 
 void Test::testNoteDeleteRow()
 {
-ScDocument* pDoc = getDocShell().GetDocument();
 OUString aSheet1("Sheet1");
-pDoc->InsertTab(0, aSheet1);
+m_pDoc->InsertTab(0, aSheet1);
+
+// We need a drawing layer in order to create caption objects.
+m_pDoc->InitDrawLayer(&getDocShell());
 
 OUString aHello("Hello");
 OUString aJimBob("Jim Bob");
-ScAddress rAddr(1, 1, 0);
-ScPostIt* pNote = m_pDoc->GetOrCreateNote(rAddr);
-pNote->SetText(rAddr, aHello);
+ScAddress aPos(1, 1, 0);
+ScPostIt* pNote = m_pDoc->GetOrCreateNote(aPos);
+pNote->SetText(aPos, aHello);
 pNote->SetAuthor(aJimBob);
 
-CPPUNIT_ASSERT_MESSAGE("there should be a note", pDoc->HasNote(1, 1, 0));
+CPPUNIT_ASSERT_MESSAGE("there should be a note", m_pDoc->HasNote(1, 1, 0));
 
 // test with IsBlockEmpty
 bool bIgnoreNotes = true;
-CPPUNIT_ASSERT_MESSAGE("The Block should be detected as empty (no Notes)", 
pDoc->IsBlockEmpty(0, 0, 0, 100, 100, bIgnoreNotes));
+CPPUNIT_ASSERT_MESSAGE("The Block should be detected as empty (no Notes)", 
m_pDoc->IsBlockEmpty(0, 0, 0, 100, 100, bIgnoreNotes));
 bIgnoreNotes = false;
-CPPUNIT_ASSERT_MESSAGE("The Block should NOT be detected as empty", 
!pDoc->IsBlockEmpty(0, 0, 0, 100, 100, bIgnoreNotes));
+CPPUNIT_ASSERT_MESSAGE("The Block should NOT be detected as empty", 
!m_pDoc->IsBlockEmpty(0, 0, 0, 100, 100, bIgnoreNotes));
 
-pDoc->DeleteRow(0, 0, MAXCOL, 0, 1, 1);
+m_pDoc->DeleteRow(0, 0, MAXCOL, 0, 1, 1);
 
-CPPUNIT_ASSERT_MESSAGE("there should be no more note", !pDoc->HasNote(1, 
1, 0));
+CPPUNIT_ASSERT_MESSAGE("there should be no more note", !m_pDoc->HasNote(1, 
1, 0));
 
-pDoc->DeleteTab(0);
+// Set values and notes into B3:B4.
+aPos = ScAddress(1,2,0); // B3
+m_pDoc->SetString(aPos, "First");
+ScNoteUtil::CreateNoteFromString(*m_pDoc, aPos, "First Note", false, 
false);
+
+aPos = ScAddress(1,3,0); // B4
+m_pDoc->SetString(aPos, "Second");
+ScNoteUtil::CreateNoteFromString(*m_pDoc, aPos, "Second Note", false, 
false);
+
+ScDocFunc& rDocFunc = getDocShell().GetDocFunc();
+ScMarkData aMark;
+aMark.SelectOneTable(0);
+rDocFunc.DeleteCells(ScRange(0,1,0,MAXCOL,1,0), &aMark, DEL_CELLSUP, true, 
true);
+
+// Check to make sure the notes have shifted upward.
+pNote = m_pDoc->GetNote(ScAddress(1,1,0));
+CPPUNIT_ASSERT_MESSAGE("B2 should have a note.", pNote);
+CPPUNIT_ASSERT_EQUAL(OUString("First Note"), pNote->GetText());
+pNote = m_pDoc->GetNote(ScAddress(1,2,0));
+CPPUNIT_ASSERT_MESSAGE("B3 should have a note.", pNote);
+CPPUNIT_ASSERT_EQUAL(OUString("Second Note"), pNote->GetText());
+pNote = m_pDoc->GetNote(ScAddress(1,3,0));
+CPPUNIT_ASSERT_MESSAGE("B4 should NOT have a note.", !pNote);
+
+// Undo.
+
+SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
+CPPUNIT_ASSERT_MESSAGE("Failed to get undo manager.", pUndoMgr);
+m_pDoc->CreateAllNoteCaptions(); // to make sure that all notes have their 
corresponding caption objects...
+
+pUndoMgr->Undo();
+pNote = m_pDoc->GetNote(ScAddress(1,1,0));
+CPPUNIT_ASSERT_MESSAGE("B2 should NOT have a note.", !pNote);
+pNote = m_pDoc->GetNote(ScAddress(1,2,0));
+CPPUNIT_ASSERT_MESSAGE("B3 should have a note.", pNote);
+CPPUNIT_ASSERT_EQUAL(OUString("First Note"), pNote->GetText());
+pNote = m_pDoc->GetNote(ScAddress(1,3,0));
+CPPUNIT_ASSERT_MESSAGE("B4 should h

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

2014-02-17 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|  161 +++-
 sc/source/core/data/column3.cxx |2 
 2 files changed, 142 insertions(+), 21 deletions(-)

New commits:
commit 2f55cee39379a76920f3a4fb14e6c2774093bfcd
Author: Kohei Yoshida 
Date:   Mon Feb 17 19:45:06 2014 -0500

fdo#74573: Skip removing of cell notes on empty cells if the flag is set.

Change-Id: I0d9cb5b48c5fdf51cf290cd838f5d6d7cb572e8b

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 7da6860..5bc149b 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -736,7 +736,7 @@ public:
 
 if (node.type == sc::element_type_empty)
 {
-if (bCopyCellNotes)
+if (bCopyCellNotes && !mrCxt.isSkipAttrForEmptyCells())
 {
 bool bCloneCaption = (nFlags & IDF_NOCAPTIONS) == 0;
 duplicateNotes(nSrcRow1, nDataSize, bCloneCaption );
commit d2a80bcd494039bcb54693a8461d1645e51d1c1b
Author: Kohei Yoshida 
Date:   Mon Feb 17 16:01:48 2014 -0500

fdo#74573: Test pasting of cell attributes as well.

Change-Id: Ib38ac054b40ac21dd4b6088fafca33566d2fc436

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 67c6e8a..14dffd9 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -57,6 +57,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "formula/IFunctionDescription.hxx"
 
@@ -3688,7 +3690,75 @@ void Test::testCopyPasteTranspose()
 
 void Test::testCopyPasteSkipEmpty()
 {
+struct Check
+{
+const char* mpStr;
+Color maColor;
+bool mbHasNote;
+};
+
+struct Test
+{
+ScDocument* mpDoc;
+
+Test( ScDocument* pDoc ) : mpDoc(pDoc) {}
+
+bool checkRange( const ScAddress& rPos, const Check* p, const Check* 
pEnd )
+{
+ScAddress aPos(rPos);
+OUString aPosStr = aPos.Format(SCA_VALID);
+for (; p != pEnd; ++p, aPos.IncRow())
+{
+if (!mpDoc->GetString(aPos).equalsAscii(p->mpStr))
+{
+cerr << aPosStr << ": incorrect string value: expected='" 
<< p->mpStr << "' actual='" << mpDoc->GetString(aPos) << endl;
+return false;
+}
+
+const SvxBrushItem* pBrush =
+dynamic_cast(mpDoc->GetAttr(aPos, 
ATTR_BACKGROUND));
+
+if (!pBrush)
+{
+cerr << aPosStr << ": failed to get brush item from the 
cell." << endl;
+return false;
+}
+
+if (pBrush->GetColor() != p->maColor)
+{
+Color aExpected = p->maColor;
+Color aActual = pBrush->GetColor();
+cerr << aPosStr << ": incorrect cell background color: 
expected=("
+<< static_cast(aExpected.GetRed()) << ","
+<< static_cast(aExpected.GetGreen()) << ","
+<< static_cast(aExpected.GetBlue()) << "), 
actual=("
+<< static_cast(aActual.GetRed()) << ","
+<< static_cast(aActual.GetGreen()) << ","
+<< static_cast(aActual.GetBlue()) << ")" << endl;
+
+return false;
+}
+
+bool bHasNote = mpDoc->HasNote(aPos);
+if (bHasNote != p->mbHasNote)
+{
+cerr << aPosStr << ": ";
+if (p->mbHasNote)
+cerr << "this cell should have a cell note, but 
doesn't." << endl;
+else
+cerr << "this cell should NOT have a cell note, but 
one is found." << endl;
+
+return false;
+}
+}
+
+return true;
+}
+
+} aTest(m_pDoc);
+
 m_pDoc->InsertTab(0, "Test");
+m_pDoc->InitDrawLayer(&getDocShell()); // for cell note objects.
 
 ScRange aSrcRange(0,0,0,0,4,0);
 ScRange aDestRange(1,0,0,1,4,0);
@@ -3696,13 +3766,25 @@ void Test::testCopyPasteSkipEmpty()
 ScMarkData aMark;
 aMark.SetMarkArea(aDestRange);
 
-// Put some texts in A1:A5.
+// Put some texts in B1:B5.
 m_pDoc->SetString(ScAddress(1,0,0), "A");
 m_pDoc->SetString(ScAddress(1,1,0), "B");
 m_pDoc->SetString(ScAddress(1,2,0), "C");
 m_pDoc->SetString(ScAddress(1,3,0), "D");
 m_pDoc->SetString(ScAddress(1,4,0), "E");
 
+// Set the background color of B1:B5 to blue.
+ScPatternAttr aCellBackColor(m_pDoc->GetPool());
+aCellBackColor.GetItemSet().Put(SvxBrushItem(COL_BLUE, ATTR_BACKGROUND));
+m_pDoc->ApplyPatternAreaTab(1, 0, 1, 4, 0, aCellBackColor);
+
+// Insert notes to B1:B5.
+m_pDoc->GetOrCreateNote(ScAddress(1,0,0));
+m_pDoc->GetOrCreateNote(ScAddress(1,1,0));
+m_pDoc->GetOrCreateNote(ScAddress(1,2,0));
+   

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

2014-02-18 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   87 ++--
 sc/qa/unit/ucalc.hxx|9 
 sc/source/core/data/column3.cxx |   25 +--
 3 files changed, 95 insertions(+), 26 deletions(-)

New commits:
commit ca50752c34de4477c696471b707e1b8136e27661
Author: Kohei Yoshida 
Date:   Tue Feb 18 22:57:39 2014 -0500

fdo#72491: Always set input as text when that's requested.

Even when the text begins with '='.

Change-Id: I6e0a995f3042240b9f78068b5d0b9b758eb253ed

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 1445848..5776ac9 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1485,6 +1485,19 @@ void ScColumn::StartListeningInArea( 
sc::StartListeningContext& rCxt, SCROW nRow
 sc::ProcessFormula(maCells.begin(), maCells, nRow1, nRow2, aFunc);
 }
 
+namespace {
+
+void applyTextNumFormat( ScColumn& rCol, SCROW nRow, SvNumberFormatter* 
pFormatter )
+{
+sal_uInt32 nFormat = pFormatter->GetStandardFormat(NUMBERFORMAT_TEXT);
+ScPatternAttr aNewAttrs(rCol.GetDoc().GetPool());
+SfxItemSet& rSet = aNewAttrs.GetItemSet();
+rSet.Put(SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat));
+rCol.ApplyPattern(nRow, aNewAttrs);
+}
+
+}
+
 bool ScColumn::ParseString(
 ScCellValue& rCell, SCROW nRow, SCTAB nTabP, const OUString& rString,
 formula::FormulaGrammar::AddressConvention eConv,
@@ -1521,6 +1534,12 @@ bool ScColumn::ParseString(
 {
 rCell.set(rPool.intern(rString));
 }
+else if (aParam.meSetTextNumFormat == ScSetStringParam::Always)
+{
+// Set the cell format type to Text.
+applyTextNumFormat(*this, nRow, aParam.mpNumFormatter);
+rCell.set(rPool.intern(rString));
+}
 else // = Formula
 rCell.set(
 new ScFormulaCell(
@@ -1625,11 +1644,7 @@ bool ScColumn::ParseString(
 if (aParam.meSetTextNumFormat != ScSetStringParam::Never && 
aParam.mpNumFormatter->IsNumberFormat(rString, nIndex, nVal))
 {
 // Set the cell format type to Text.
-sal_uInt32 nFormat = 
aParam.mpNumFormatter->GetStandardFormat(NUMBERFORMAT_TEXT);
-ScPatternAttr aNewAttrs(pDocument->GetPool());
-SfxItemSet& rSet = aNewAttrs.GetItemSet();
-rSet.Put( SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat) );
-ApplyPattern(nRow, aNewAttrs);
+applyTextNumFormat(*this, nRow, aParam.mpNumFormatter);
 }
 
 rCell.set(rPool.intern(rString));
commit 891817922121765cef65ae73ebf7fdc524083d20
Author: Kohei Yoshida 
Date:   Tue Feb 18 22:11:10 2014 -0500

fdo#72491: Add test for this.

Change-Id: Ic37402cb950783b080e5f185b98b19aea62efa7e

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index c7c9ba5..ed84bf2 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1729,9 +1729,7 @@ void Test::testFuncParam()
 
 void Test::testNamedRange()
 {
-struct {
-const char* pName; const char* pExpr; sal_uInt16 nIndex;
-} aNames[] = {
+RangeNameDef aNames[] = {
 { "Divisor",  "$Sheet1.$A$1:$A$1048576", 1 },
 { "MyRange1", "$Sheet1.$A$1:$A$100", 2 },
 { "MyRange2", "$Sheet1.$B$1:$B$100", 3 },
@@ -1742,31 +1740,22 @@ void Test::testNamedRange()
 
 m_pDoc->SetValue (0, 0, 0, 101);
 
-ScAddress aA1(0, 0, 0);
-ScRangeName* pNewRanges = new ScRangeName();
-for (size_t i = 0; i < SAL_N_ELEMENTS(aNames); ++i)
-{
-ScRangeData* pNew = new ScRangeData(
-m_pDoc,
-OUString::createFromAscii(aNames[i].pName),
-OUString::createFromAscii(aNames[i].pExpr),
-aA1, 0, formula::FormulaGrammar::GRAM_ENGLISH);
-pNew->SetIndex(aNames[i].nIndex);
-bool bSuccess = pNewRanges->insert(pNew);
-CPPUNIT_ASSERT_MESSAGE ("insertion failed", bSuccess);
-}
+bool bSuccess = insertRangeNames(m_pDoc, aNames, aNames + 
SAL_N_ELEMENTS(aNames));
+CPPUNIT_ASSERT_MESSAGE("Failed to insert range names.", bSuccess);
+
+ScRangeName* pNewRanges = m_pDoc->GetRangeName();
+CPPUNIT_ASSERT(pNewRanges);
 
 // Make sure the index lookup does the right thing.
 for (size_t i = 0; i < SAL_N_ELEMENTS(aNames); ++i)
 {
-const ScRangeData* p = pNewRanges->findByIndex(aNames[i].nIndex);
+const ScRangeData* p = pNewRanges->findByIndex(aNames[i].mnIndex);
 CPPUNIT_ASSERT_MESSAGE("lookup of range name by index failed.", p);
 OUString aName = p->GetName();
-CPPUNIT_ASSERT_MESSAGE("wrong range name is retrieved.", 
aName.equalsAscii(aNames[i].pName));
+CPPUNIT_ASSERT_MESSAGE("wrong range name is retrieved.", 
aName.equalsAscii(aNames[i].mpName));
 }
 
 // Test usage in formula expression.
-m_pDoc->SetRangeName(pNewRanges);
 m_pDoc->SetString (1, 0, 0, OUS

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

2014-02-19 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx |2 ++
 sc/qa/unit/ucalc_formula.cxx |   28 
 sc/source/core/tool/interpr6.cxx |1 +
 3 files changed, 31 insertions(+)

New commits:
commit 9e183fbfdbfbe364d17f9d36a0b33d2fae89862d
Author: Kohei Yoshida 
Date:   Thu Feb 20 00:28:06 2014 -0500

fdo#75228: We still need to get the value only to pop value from the stack.

Change-Id: Iad231aa97ed35f91b96cddf8157ebcd9af0f8ec9

diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index f404561..a32b3c1 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -891,6 +891,7 @@ void ScInterpreter::ScCount()
 }
 break;
 case svDouble:
+GetDouble();
 nCount++;
 nFuncFmtType = NUMBERFORMAT_NUMBER;
 break;
commit e50f17ace67dc7dc1680494567d74b4c76ce21d3
Author: Kohei Yoshida 
Date:   Thu Feb 20 00:16:00 2014 -0500

fdo#75228: Add test for this.

Change-Id: Ie89c9f80db0da7d1d0a4a5c06495715aaf555f4c

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index c40469a..7ceabb4 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -119,6 +119,7 @@ public:
 void testFormulaRefUpdateNamedExpression();
 void testMultipleOperations();
 void testFuncCOLUMN();
+void testFuncCOUNT();
 void testFuncROW();
 void testFuncSUM();
 void testFuncPRODUCT();
@@ -358,6 +359,7 @@ public:
 CPPUNIT_TEST(testFormulaRefUpdateNamedExpression);
 CPPUNIT_TEST(testMultipleOperations);
 CPPUNIT_TEST(testFuncCOLUMN);
+CPPUNIT_TEST(testFuncCOUNT);
 CPPUNIT_TEST(testFuncROW);
 CPPUNIT_TEST(testFuncSUM);
 CPPUNIT_TEST(testFuncPRODUCT);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 02dfff2..35e6369 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1734,6 +1734,34 @@ void Test::testFuncCOLUMN()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testFuncCOUNT()
+{
+m_pDoc->InsertTab(0, "Formula");
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+m_pDoc->SetValue(ScAddress(0,0,0), 2); // A1
+m_pDoc->SetValue(ScAddress(0,1,0), 4); // A2
+m_pDoc->SetValue(ScAddress(0,2,0), 6); // A3
+
+ScAddress aPos(1,0,0);
+m_pDoc->SetString(aPos, "=COUNT(A1:A3)");
+CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(aPos));
+
+aPos.IncRow();
+m_pDoc->SetString(aPos, "=COUNT(A1:A3;2)");
+CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(aPos));
+
+aPos.IncRow();
+m_pDoc->SetString(aPos, "=COUNT(A1:A3;2;4)");
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(aPos));
+
+aPos.IncRow();
+m_pDoc->SetString(aPos, "=COUNT(A1:A3;2;4;6)");
+CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(aPos));
+
+m_pDoc->DeleteTab(0);
+}
+
 void Test::testFuncROW()
 {
 m_pDoc->InsertTab(0, "Formula");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-02-20 Thread Kohei Yoshida
 sc/qa/unit/subsequent_export-test.cxx  |   89 +
 sc/qa/unit/subsequent_filters-test.cxx |   69 -
 sc/source/filter/excel/xestyle.cxx |8 +-
 3 files changed, 93 insertions(+), 73 deletions(-)

New commits:
commit 1c1f42fdbad774cae7c45a7f8d60b9af766dee0a
Author: Kohei Yoshida 
Date:   Thu Feb 20 11:27:32 2014 -0500

fdo#75130: Export cell borders to xls and xlsx correctly.

Change-Id: Ic629fb4852d2ada9724dfee7618e2436c0fa28a8

diff --git a/sc/source/filter/excel/xestyle.cxx 
b/sc/source/filter/excel/xestyle.cxx
index f4f8ffc..c753228 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -1570,18 +1570,18 @@ void lclGetBorderLine(
 switch (pLine->GetBorderLineStyle())
 {
 case table::BorderLineStyle::DASHED:
+case table::BorderLineStyle::FINE_DASHED:
 rnXclLine = EXC_LINE_DASHED;
 break;
 case table::BorderLineStyle::DOTTED:
 rnXclLine = EXC_LINE_DOTTED;
 break;
-case table::BorderLineStyle::FINE_DASHED:
-rnXclLine = EXC_LINE_HAIR;
-break;
 default:
 break;
 }
 }
+else if (nOuterWidth >= EXC_BORDER_HAIR)
+rnXclLine = EXC_LINE_HAIR;
 else
 rnXclLine = EXC_LINE_NONE;
 }
@@ -1726,7 +1726,7 @@ static const char* ToLineStyle( sal_uInt8 nLineStyle )
 case EXC_LINE_HAIR: return "hair";
 case EXC_LINE_DOTTED: return "dotted";
 case EXC_LINE_DASHED: return "dashed";
-case EXC_LINE_MEDIUMDASHED: return "mediumdashed";
+case EXC_LINE_MEDIUMDASHED: return "mediumDashed";
 }
 return "*unknown*";
 }
commit 6d5270dab5c8ea8bae1ac3462aa5f6768f7d2c8f
Author: Kohei Yoshida 
Date:   Thu Feb 20 11:26:38 2014 -0500

fdo#75130: Move these tests to the export test and test their export.

Change-Id: Ia6a155f12e3b50c5841211d32e0f8ff2de2bc9c8

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 26fc12a..e834ca6 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -42,6 +42,9 @@
 #include "editeng/editobj.hxx"
 #include "editeng/section.hxx"
 #include 
+#include 
+
+#include 
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -79,6 +82,9 @@ public:
 void testFormulaReferenceXLS();
 void testSheetProtectionXLSX();
 
+void testCellBordersXLS();
+void testCellBordersXLSX();
+
 CPPUNIT_TEST_SUITE(ScExportTest);
 CPPUNIT_TEST(test);
 #if !defined(MACOSX) && !defined(DRAGONFLY)
@@ -100,10 +106,14 @@ public:
 CPPUNIT_TEST(testEmbeddedChartXLS);
 CPPUNIT_TEST(testFormulaReferenceXLS);
 CPPUNIT_TEST(testSheetProtectionXLSX);
+CPPUNIT_TEST(testCellBordersXLS);
+CPPUNIT_TEST(testCellBordersXLSX);
 
 CPPUNIT_TEST_SUITE_END();
 
 private:
+void testExcelCellBorders( sal_uLong nFormatType );
+
 uno::Reference m_xCalcComponent;
 
 };
@@ -991,6 +1001,85 @@ void ScExportTest::testSheetProtectionXLSX()
 xDocSh->DoClose();
 }
 
+namespace {
+
+const char* toBorderName( sal_Int16 eStyle )
+{
+switch (eStyle)
+{
+case table::BorderLineStyle::SOLID: return "SOLID";
+case table::BorderLineStyle::DOTTED: return "DOTTED";
+case table::BorderLineStyle::DASHED: return "DASHED";
+case table::BorderLineStyle::DOUBLE: return "DOUBLE";
+case table::BorderLineStyle::FINE_DASHED: return "FINE_DASHED";
+default:
+;
+}
+
+return "";
+}
+
+}
+
+void ScExportTest::testExcelCellBorders( sal_uLong nFormatType )
+{
+ScDocShellRef xDocSh = loadDoc("cell-borders.", nFormatType);
+
+CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.Is());
+ScDocument* pDoc = xDocSh->GetDocument();
+
+struct
+{
+SCROW mnRow;
+sal_Int16 mnStyle;
+long mnWidth;
+} aChecks[] = {
+{  1, table::BorderLineStyle::SOLID,1L }, // hair
+{  3, table::BorderLineStyle::DOTTED,  15L }, // thin
+{  9, table::BorderLineStyle::FINE_DASHED, 15L }, // dashed
+{ 11, table::BorderLineStyle::SOLID,   15L }, // thin
+{ 19, table::BorderLineStyle::DASHED,  35L }, // medium dashed
+{ 21, table::BorderLineStyle::SOLID,   35L }, // medium
+{ 23, table::BorderLineStyle::SOLID,   50L }, // thick
+{ 25, table::BorderLineStyle::DOUBLE,  -1L }, // double (don't 
check width)
+};
+
+for (size_t i = 0; i < SAL_N_ELEMENTS(aChecks); ++i)
+{
+const editeng::SvxBorderLine* pLine = NULL;
+pDoc->GetBorderLines(2, aChecks[i].mnRow, 0, NULL, &pLine, NULL, NULL);
+CPPUNIT_ASSERT(pLine);
+CPPUNIT_ASSERT_EQUAL(to

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

2014-03-07 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   36 
 sc/source/core/data/column2.cxx |   10 +-
 2 files changed, 41 insertions(+), 5 deletions(-)

New commits:
commit 01de94471c20a8b9c36d6080638d70e57eac55bf
Author: Kohei Yoshida 
Date:   Fri Mar 7 14:23:46 2014 -0500

fdo#75718: Correctly count the length of trailing empty range.

This affects auto fill, apparently.

Change-Id: I653918d374122bc9bb938231934c149da79a3306

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 6c6e47e..38eb94e 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1214,13 +1214,13 @@ bool ScColumn::IsNotesEmptyBlock(SCROW nStartRow, SCROW 
nEndRow) const
 
 SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, 
ScDirection eDir ) const
 {
-// Given a range of rows, find a top or bottom empty segment.
+// Given a range of rows, find a top or bottom empty segment.  Skip the 
start row.
 switch (eDir)
 {
 case DIR_TOP:
 {
 // Determine the length of empty head segment.
-size_t nLength = nEndRow - nStartRow + 1;
+size_t nLength = nEndRow - nStartRow;
 std::pair aPos = 
maCells.position(nStartRow);
 sc::CellStoreType::const_iterator it = aPos.first;
 if (it->type != sc::element_type_empty)
@@ -1234,8 +1234,8 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, 
SCROW nEndRow, ScDirecti
 break;
 case DIR_BOTTOM:
 {
-// Determine the length empty tail segment.
-size_t nLength = nEndRow - nStartRow + 1;
+// Determine the length of empty tail segment.
+size_t nLength = nEndRow - nStartRow;
 std::pair aPos = 
maCells.position(nEndRow);
 sc::CellStoreType::const_iterator it = aPos.first;
 if (it->type != sc::element_type_empty)
@@ -1243,7 +1243,7 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, 
SCROW nEndRow, ScDirecti
 return 0;
 
 // length of this empty block from the tip to the end row position.
-size_t nThisLen = aPos.second;
+size_t nThisLen = aPos.second + 1;
 return std::min(nThisLen, nLength);
 }
 break;
commit 9d54a7f67196cac2a5701c06d8dc55f102d0af60
Author: Kohei Yoshida 
Date:   Fri Mar 7 14:22:49 2014 -0500

fdo#75718: Write unit test for this.

Change-Id: I1f1fe515485209b67f14a1407ee20a88e71c08c9

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index bf691c6..a49b6d2 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4220,6 +4220,42 @@ void Test::testAutoFill()
 aTestValue = m_pDoc->GetString( 0, i, 0 );
 CPPUNIT_ASSERT_EQUAL( aTestValue, OUString("January") );
 }
+
+// Clear column A for a new test.
+clearRange(m_pDoc, ScRange(0,0,0,0,MAXROW,0));
+m_pDoc->SetRowHidden(0, MAXROW, 0, false); // Show all rows.
+
+// Fill A1:A6 with 1,2,3,4,5,6.
+ScDocFunc& rFunc = getDocShell().GetDocFunc();
+m_pDoc->SetValue(ScAddress(0,0,0), 1.0);
+ScRange aRange(0,0,0,0,5,0);
+aMarkData.SetMarkArea(aRange);
+rFunc.FillSeries(aRange, &aMarkData, FILL_TO_BOTTOM, FILL_AUTO, FILL_DAY, 
MAXDOUBLE, 1.0, MAXDOUBLE, true, true);
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0)));
+CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,2,0)));
+CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(0,3,0)));
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(0,4,0)));
+CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,5,0)));
+
+// Undo should clear the area except for the top cell.
+SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
+CPPUNIT_ASSERT(pUndoMgr);
+pUndoMgr->Undo();
+
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0)));
+for (SCROW i = 1; i <= 5; ++i)
+CPPUNIT_ASSERT(m_pDoc->GetCellType(ScAddress(0,i,0)) == CELLTYPE_NONE);
+
+// Redo should put the serial values back in.
+pUndoMgr->Redo();
+CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0)));
+CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,2,0)));
+CPPUNIT_ASSERT_EQUAL(4.0, m_pDoc->GetValue(ScAddress(0,3,0)));
+CPPUNIT_ASSERT_EQUAL(5.0, m_pDoc->GetValue(ScAddress(0,4,0)));
+CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,5,0)));
+
 m_pDoc->DeleteTab(0);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-03-07 Thread Kohei Yoshida
 sc/qa/unit/ucalc_formula.cxx |   29 ++
 sc/source/core/tool/interpr6.cxx |   42 +++
 2 files changed, 66 insertions(+), 5 deletions(-)

New commits:
commit d658c092f488fc0d4cb924fe3e34cab997db76e2
Author: Kohei Yoshida 
Date:   Fri Mar 7 18:03:24 2014 -0500

fdo#75628: SUM should inherit error if one is present in its references.

Change-Id: I94017fe91295dbb929f57be5e3fb26edf5032a8f

diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index a32b3c1..b98fb9b 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -210,8 +210,10 @@ namespace {
 class NumericCellAccumulator
 {
 double mfSum;
+sal_uInt16 mnError;
+
 public:
-NumericCellAccumulator() : mfSum(0.0) {}
+NumericCellAccumulator() : mfSum(0.0), mnError(0) {}
 
 void operator() (size_t, double fVal)
 {
@@ -220,11 +222,28 @@ public:
 
 void operator() (size_t, const ScFormulaCell* pCell)
 {
+if (mnError)
+// Skip all the rest if we have an error.
+return;
+
+double fVal = 0.0;
+sal_uInt16 nErr = 0;
 ScFormulaCell& rCell = const_cast(*pCell);
-if (rCell.IsValue())
-mfSum += rCell.GetValue();
+if (!rCell.GetErrorOrValue(nErr, fVal))
+// The cell has neither error nor value.  Perhaps string result.
+return;
+
+if (nErr)
+{
+// Cell has error.
+mnError = nErr;
+return;
+}
+
+mfSum += fVal;
 }
 
+sal_uInt16 getError() const { return mnError; }
 double getSum() const { return mfSum; }
 };
 
@@ -299,10 +318,11 @@ class FuncSum : public sc::ColumnSpanSet::ColumnAction
 sc::ColumnBlockConstPosition maPos;
 ScColumn* mpCol;
 double mfSum;
+sal_uInt16 mnError;
 sal_uInt32 mnNumFmt;
 
 public:
-FuncSum() : mpCol(0), mfSum(0.0), mnNumFmt(0) {}
+FuncSum() : mpCol(0), mfSum(0.0), mnError(0), mnNumFmt(0) {}
 
 virtual void startColumn(ScColumn* pCol)
 {
@@ -315,12 +335,20 @@ public:
 if (!bVal)
 return;
 
+if (mnError)
+return;
+
 NumericCellAccumulator aFunc;
 maPos.miCellPos = sc::ParseFormulaNumeric(maPos.miCellPos, 
mpCol->GetCellStore(), nRow1, nRow2, aFunc);
+mnError = aFunc.getError();
+if (mnError)
+return;
+
 mfSum += aFunc.getSum();
 mnNumFmt = mpCol->GetNumberFormat(nRow2);
 };
 
+sal_uInt16 getError() const { return mnError; }
 double getSum() const { return mfSum; }
 sal_uInt32 getNumberFormat() const { return mnNumFmt; }
 };
@@ -806,6 +834,12 @@ void ScInterpreter::ScSum()
 
 FuncSum aAction;
 aSet.executeColumnAction(*pDok, aAction);
+sal_uInt16 nErr = aAction.getError();
+if (nErr)
+{
+SetError(nErr);
+return;
+}
 fRes += aAction.getSum();
 
 // Get the number format of the last iterated cell.
commit 78e6b7a94265507e43dd80182706970f49cdb303
Author: Kohei Yoshida 
Date:   Fri Mar 7 18:00:24 2014 -0500

fdo#75628: Write unit test for this.

Change-Id: I26e5d0bf4344eeb518222ba036c61eca861c5fcf

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 580e2a3..f4c6f7a 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -1841,6 +1841,8 @@ void Test::testFuncSUM()
 CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet",
 m_pDoc->InsertTab (0, aTabName));
 
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+
 // Single argument case.
 m_pDoc->SetValue(ScAddress(0,0,0), 1);
 m_pDoc->SetValue(ScAddress(0,1,0), 1);
@@ -1864,11 +1866,36 @@ void Test::testFuncSUM()
 m_pDoc->SetString(ScAddress(3,0,0), "=SUM(A1:A2;B1:B2)");
 m_pDoc->SetString(ScAddress(3,1,0), "=SUM(A2:A3;B2:B3)");
 m_pDoc->SetString(ScAddress(3,2,0), "=SUM(A3:A4;B3:B4)");
-m_pDoc->CalcAll();
 CPPUNIT_ASSERT_EQUAL(30.0, m_pDoc->GetValue(ScAddress(3,0,0)));
 CPPUNIT_ASSERT_EQUAL(35.0, m_pDoc->GetValue(ScAddress(3,1,0)));
 CPPUNIT_ASSERT_EQUAL(20.0, m_pDoc->GetValue(ScAddress(3,2,0)));
 
+// Clear and start over.
+clearRange(m_pDoc, ScRange(0,0,0,3,MAXROW,0));
+
+// SUM needs to take the first error in case the range contains an error.
+m_pDoc->SetValue(ScAddress(0,0,0), 1.0);
+m_pDoc->SetValue(ScAddress(0,1,0), 10.0);
+m_pDoc->SetValue(ScAddress(0,2,0), 100.0);
+m_pDoc->SetString(ScAddress(0,3,0), "=SUM(A1:A3)");
+CPPUNIT_ASSERT_EQUAL(111.0, m_pDoc->GetValue(ScAddress(0,3,0)));
+
+// Set #DIV/0! error to A3. A4 should also inherit this error.
+m_pDoc->SetString(ScAddress(0,2,0), "=1/0");
+sal_uInt16 nErr = m_pDoc->GetErrCode(ScAddress(0,2,0));

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

2014-03-09 Thread Kohei Yoshida
 sc/qa/unit/ucalc_pivottable.cxx  |   25 +
 sc/source/core/data/dpoutput.cxx |4 +++-
 2 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit 0919979bd1da3379e030b353a097d8fe1fd8341a
Author: Kohei Yoshida 
Date:   Sun Mar 9 21:28:05 2014 -0400

fdo#75962: Avoid unwanted number detection when placing page field name.

Change-Id: I1a3c57ec029e03198b8f190acfa8d59e142acaba

diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index adff9b1..704861c 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -1003,7 +1003,9 @@ void ScDPOutput::Output()
 else if (n > 1)
 aPageValue = ScResId(SCSTR_MULTIPLE).toString();
 
-pDoc->SetString( nFldCol, nHdrRow, nTab, aPageValue );
+ScSetStringParam aParam;
+aParam.setTextInput();
+pDoc->SetString(nFldCol, nHdrRow, nTab, aPageValue, &aParam);
 
 lcl_SetFrame( pDoc,nTab, nFldCol,nHdrRow, nFldCol,nHdrRow, 20 );
 }
commit bd378b6346bf5aca4328c57f2ff3c18932691a47
Author: Kohei Yoshida 
Date:   Sun Mar 9 21:27:35 2014 -0400

fdo#75962: Write test for this first.

Change-Id: I731b4cbf72066f8a0cbabb5040acfe9c828afd8f

diff --git a/sc/qa/unit/ucalc_pivottable.cxx b/sc/qa/unit/ucalc_pivottable.cxx
index 00e83b9..7ad0c1e 100644
--- a/sc/qa/unit/ucalc_pivottable.cxx
+++ b/sc/qa/unit/ucalc_pivottable.cxx
@@ -1668,6 +1668,31 @@ void Test::testPivotTableTextNumber()
 CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
 }
 
+// Set the Name dimension to page dimension.
+pDPObj->BuildAllDimensionMembers();
+ScDPSaveData aSaveData(*pDPObj->GetSaveData());
+ScDPSaveDimension* pDim = aSaveData.GetExistingDimensionByName("Name");
+CPPUNIT_ASSERT(pDim);
+pDim->SetOrientation(sheet::DataPilotFieldOrientation_PAGE);
+OUString aVisiblePage("0004");
+pDim->SetCurrentPage(&aVisiblePage);
+pDPObj->SetSaveData(aSaveData);
+
+aOutRange = refresh(pDPObj);
+
+{
+// Expected output table content.  0 = empty cell
+const char* aOutputCheck[][2] = {
+{ "Name", "0004" },
+{  0, 0 },
+{ "Sum - Value", 0 },
+{ "4", 0 }
+};
+
+bSuccess = checkDPTableOutput<2>(m_pDoc, aOutRange, aOutputCheck, 
"Text number field members");
+CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
+}
+
 pDPs->FreeTable(pDPObj);
 CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be no more tables.", 
pDPs->GetCount(), static_cast(0));
 CPPUNIT_ASSERT_EQUAL_MESSAGE("There shouldn't be any more cache stored.",
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-03-10 Thread Kohei Yoshida
 sc/qa/unit/data/xlsx/shared-formula/3d-reference.xlsx |binary
 sc/qa/unit/subsequent_export-test.cxx |   74 ++
 sc/source/filter/excel/xecontent.cxx  |   12 +-
 sc/source/filter/excel/xeextlst.cxx   |2 
 sc/source/filter/excel/xeroot.cxx |6 -
 sc/source/filter/excel/xestream.cxx   |   17 
 sc/source/filter/excel/xetable.cxx|4 
 sc/source/filter/inc/xeroot.hxx   |2 
 sc/source/filter/inc/xestream.hxx |4 
 sc/source/filter/xcl97/XclExpChangeTrack.cxx  |3 
 10 files changed, 87 insertions(+), 37 deletions(-)

New commits:
commit ca8ca8c28742879220f3ff88ae0d71c8d69b11cd
Author: Kohei Yoshida 
Date:   Mon Mar 10 14:02:00 2014 -0400

fdo#75950: Just set the right grammar and be done with it.

Using the Excel A1 syntax with custom opcode was probably a hack back
in the day.  These days we can just set the right grammar and expect the
compiler to do the right thing.

Change-Id: Iae98f9f09a7da0b7b9549e06308d5d313bbff1ea

diff --git a/sc/source/filter/excel/xecontent.cxx 
b/sc/source/filter/excel/xecontent.cxx
index 14baaea..0df97bb 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -946,13 +946,13 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
 {
 rWorksheet->startElement( XML_formula, FSEND );
 rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), 
mrFormatEntry.GetValidSrcPos(),
-mrFormatEntry.CreateTokenArry( 0 ), 
GetRoot().GetOpCodeMap() ));
+mrFormatEntry.CreateTokenArry(0)));
 rWorksheet->endElement( XML_formula );
 if (bFmla2)
 {
 rWorksheet->startElement( XML_formula, FSEND );
 rWorksheet->write(XclXmlUtils::ToOUString( GetRoot().GetDoc(), 
mrFormatEntry.GetValidSrcPos(),
-mrFormatEntry.CreateTokenArry( 1 ), 
GetRoot().GetOpCodeMap() ));
+mrFormatEntry.CreateTokenArry(1)));
 rWorksheet->endElement( XML_formula );
 }
 }
@@ -1093,7 +1093,7 @@ void XclExpCfvo::SaveXml( XclExpXmlStream& rStrm )
 if(mrEntry.GetType() == COLORSCALE_FORMULA)
 {
 OUString aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), 
maSrcPos,
-mrEntry.GetFormula()->Clone(), GetRoot().GetOpCodeMap() );
+mrEntry.GetFormula()->Clone());
 aValue = OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 );
 }
 else
@@ -1602,7 +1602,7 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong 
nScHandle ) :
 CreateDataValFormula() and CreateListValFormula(). */
 mxTokArr1 = rFmlaComp.CreateFormula( EXC_FMLATYPE_LISTVAL, 
*xScTokArr );
 msFormula1 = XclXmlUtils::ToOUString( GetDoc(), 
pValData->GetSrcPos(),
-xScTokArr.get(), GetRoot().GetOpCodeMap() );
+xScTokArr.get());
 }
 }
 else
@@ -1610,7 +1610,7 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong 
nScHandle ) :
 // no list validation -> convert the formula
 mxTokArr1 = rFmlaComp.CreateFormula( EXC_FMLATYPE_DATAVAL, 
*xScTokArr );
 msFormula1 = XclXmlUtils::ToOUString( GetDoc(), 
pValData->GetSrcPos(),
-xScTokArr.get(), GetRoot().GetOpCodeMap() );
+xScTokArr.get());
 }
 }
 
@@ -1620,7 +1620,7 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong 
nScHandle ) :
 {
 mxTokArr2 = rFmlaComp.CreateFormula( EXC_FMLATYPE_DATAVAL, 
*xScTokArr );
 msFormula2 = XclXmlUtils::ToOUString( GetDoc(), 
pValData->GetSrcPos(),
-xScTokArr.get(), GetRoot().GetOpCodeMap() );
+xScTokArr.get());
 }
 }
 else
diff --git a/sc/source/filter/excel/xeextlst.cxx 
b/sc/source/filter/excel/xeextlst.cxx
index 92fb6c6..852647c 100644
--- a/sc/source/filter/excel/xeextlst.cxx
+++ b/sc/source/filter/excel/xeextlst.cxx
@@ -63,7 +63,7 @@ XclExpExtCfvo::XclExpExtCfvo( const XclExpRoot& rRoot, const 
ScColorScaleEntry&
 if(pArr)
 {
 aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), rSrcPos,
-pArr->Clone(), GetRoot().GetOpCodeMap() );
+pArr->Clone());
 }
 maValue = OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 );
 }
diff --git a/sc/source/filter/excel/xeroot.cxx 
b/sc/source/filter/excel/xeroot.cxx
index 88ab3e3..3da4427 100644
--- a/sc/source/filter/excel/xeroot.cxx
+++ b/sc/source/filter/excel/xeroot.cxx
@@ -167,12 +167,6 @@ XclExpPivotTableManager& 
XclExpRoot::GetPivotTableManager() const
 return *mrExpData.mxPTableMgr;
 }
 
-ScCompiler::OpCod

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

2014-03-10 Thread Kohei Yoshida
 sc/qa/unit/ucalc.hxx   |2 
 sc/qa/unit/ucalc_sharedformula.cxx |   87 +
 sc/source/core/tool/token.cxx  |   19 
 3 files changed, 108 insertions(+)

New commits:
commit dd7787ed75e33b65ebee2a6c0aa152efded6f1b8
Author: Kohei Yoshida 
Date:   Mon Mar 10 20:39:01 2014 -0400

fdo#75815: Adjust external references here too.

Adjusting external references are much simpler than adjusting internal
ones since we don't need to worry about deleted references etc.

Change-Id: I82111e383e1fc6976ef08c1438c3dd916a249af6

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index eee7c9d2..8057224 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2751,6 +2751,25 @@ sc::RefUpdateResult 
ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon
 rRef.SetRange(aAbs, aNewPos);
 }
 break;
+case svExternalSingleRef:
+{
+// For external reference, just reset the reference with
+// respect to the new cell position.
+ScToken* pToken = static_cast(*p);
+ScSingleRefData& rRef = pToken->GetSingleRef();
+ScAddress aAbs = rRef.toAbs(rOldPos);
+rRef.SetAddress(aAbs, aNewPos);
+}
+break;
+case svExternalDoubleRef:
+{
+// Same as above.
+ScToken* pToken = static_cast(*p);
+ScComplexRefData& rRef = pToken->GetDoubleRef();
+ScRange aAbs = rRef.toAbs(rOldPos);
+rRef.SetRange(aAbs, aNewPos);
+}
+break;
 case svIndex:
 {
 const formula::FormulaToken* pToken = *p;
commit 149b580900214c477f8eaf9dd51342796d27b296
Author: Kohei Yoshida 
Date:   Mon Mar 10 19:27:21 2014 -0400

fdo#75815: Write test for this first.

Change-Id: I2a5a1964dc6496aa4db15c9e8644692b460d0527

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 7c40fb8..58dc083 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -262,6 +262,7 @@ public:
 void testSharedFormulas();
 void testSharedFormulasRefUpdate();
 void testSharedFormulasRefUpdateRange();
+void testSharedFormulasRefUpdateExternal();
 void testSharedFormulasDeleteRows();
 void testSharedFormulasDeleteColumns();
 void testSharedFormulasRefUpdateMoveSheets();
@@ -435,6 +436,7 @@ public:
 CPPUNIT_TEST(testSharedFormulas);
 CPPUNIT_TEST(testSharedFormulasRefUpdate);
 CPPUNIT_TEST(testSharedFormulasRefUpdateRange);
+CPPUNIT_TEST(testSharedFormulasRefUpdateExternal);
 CPPUNIT_TEST(testSharedFormulasDeleteRows);
 CPPUNIT_TEST(testSharedFormulasDeleteColumns);
 CPPUNIT_TEST(testSharedFormulasRefUpdateMoveSheets);
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx 
b/sc/qa/unit/ucalc_sharedformula.cxx
index ae1ad58..98d087d 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -449,6 +449,93 @@ void Test::testSharedFormulasRefUpdateRange()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testSharedFormulasRefUpdateExternal()
+{
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+m_pDoc->InsertTab(0, "Formula");
+
+// Launch an external document shell.
+ScDocShellRef xExtDocSh = new ScDocShell;
+OUString aExtDocName("file:///extdata.fake");
+
+SfxMedium* pMed = new SfxMedium(aExtDocName, STREAM_STD_READWRITE);
+xExtDocSh->DoInitNew(pMed);
+ScDocument* pExtDoc = xExtDocSh->GetDocument();
+
+// Populate A1:A3.
+pExtDoc->InsertTab(0, "Data");
+pExtDoc->SetString(ScAddress(0,0,0), "A");
+pExtDoc->SetString(ScAddress(0,1,0), "B");
+pExtDoc->SetString(ScAddress(0,2,0), "C");
+
+// Insert formula cells in A7:A10 of the host document, referencing A1:A3
+// of the external document.
+m_pDoc->SetString(ScAddress(0,6,0), "='file:///extdata.fake'#$Data.A1");
+m_pDoc->SetString(ScAddress(0,7,0), "='file:///extdata.fake'#$Data.A2");
+m_pDoc->SetString(ScAddress(0,8,0), "='file:///extdata.fake'#$Data.A3");
+m_pDoc->SetString(ScAddress(0,9,0), 
"=COUNTA('file:///extdata.fake'#$Data.A1:A3)");
+
+// Check the formula results.
+CPPUNIT_ASSERT_EQUAL(OUString("A"), m_pDoc->GetString(ScAddress(0,6,0)));
+CPPUNIT_ASSERT_EQUAL(OUString("B"), m_pDoc->GetString(ScAddress(0,7,0)));
+CPPUNIT_ASSERT_EQUAL(OUString("C"), m_pDoc->GetString(ScAddress(0,8,0)));
+CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(0,9,0)));
+
+// Check the formulas too.
+if (!checkFormula(*m_pDoc, ScAddress(0,6,0), 
"'file:///extdata.fake'#$Data.A1"))
+CPPUNIT_FAIL("Wrong formula!");
+if (!checkFormula(*m_pDoc, ScAddress(0,7,0), 
"'file:///extdata.fake'#$Data.A2"))
+CPPUNIT_FAIL("Wrong formula!");
+if (!checkFormula(*m_pDoc, ScAdd

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

2014-03-13 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|6 ++
 sc/qa/unit/ucalc.hxx|1 +
 sc/qa/unit/ucalc_formula.cxx|   18 +-
 sc/source/core/data/dociter.cxx |4 +++-
 4 files changed, 27 insertions(+), 2 deletions(-)

New commits:
commit c078d5fef98ba77751b7a9593691d88dfc1c9ba1
Author: Kohei Yoshida 
Date:   Thu Mar 13 10:22:25 2014 -0400

fdo#75642: Check the high position block correctly.

Change-Id: I25deabf69e78c6e0354e8a528ab88891a30f9aec

diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 481796c..3a1e7d9 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1538,7 +1538,9 @@ public:
 // Move to the last position of the previous block.
 decBlock(aHiPos);
 
-if (aHiPos.first == mrCells.begin())
+// Check the row postion of the end of the previous block, and 
make sure it's valid.
+SCROW nBlockEndRow = aHiPos.first->position + aHiPos.first->size - 
1;
+if (nBlockEndRow < nStartRow)
 {
 mbValid = false;
 return;
commit e5802954853a9ec64fb5fec917f8c3b2daba6526
Author: Kohei Yoshida 
Date:   Thu Mar 13 09:53:23 2014 -0400

fdo#75642: Add test case for this.

Change-Id: I220cc3aeac79325e7664461d3bd5219e9e1f04f7

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 3c809a8..ed5e894 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5575,6 +5575,12 @@ void Test::clearRange(ScDocument* pDoc, const ScRange& 
rRange)
 rRange.aEnd.Col(), rRange.aEnd.Row(), aMarkData, IDF_CONTENTS);
 }
 
+void Test::clearSheet(ScDocument* pDoc, SCTAB nTab)
+{
+ScRange aRange(0,0,nTab,MAXCOL,MAXROW,nTab);
+clearRange(pDoc, aRange);
+}
+
 void Test::copyToClip(ScDocument* pSrcDoc, const ScRange& rRange, ScDocument* 
pClipDoc)
 {
 ScClipParam aClipParam(rRange, false);
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index d17c8f5..68f5bc4 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -42,6 +42,7 @@ public:
 static bool insertRangeNames(ScDocument* pDoc, const RangeNameDef* p, 
const RangeNameDef* pEnd);
 static void printRange(ScDocument* pDoc, const ScRange& rRange, const 
char* pCaption);
 static void clearRange(ScDocument* pDoc, const ScRange& rRange);
+static void clearSheet(ScDocument* pDoc, SCTAB nTab);
 static void copyToClip(ScDocument* pSrcDoc, const ScRange& rRange, 
ScDocument* pClipDoc);
 static void pasteFromClip(ScDocument* pDestDoc, const ScRange& rDestRange, 
ScDocument* pClipDoc);
 static ScUndoPaste* createUndoPaste(ScDocShell& rDocSh, const ScRange& 
rRange, ScDocument* pUndoDoc);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 3fcc896..8bf8435 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2458,7 +2458,7 @@ void Test::testFuncVLOOKUP()
 }
 
 // Clear the sheet and start over.
-clearRange(m_pDoc, ScRange(0,0,0,MAXCOL,MAXROW,0));
+clearSheet(m_pDoc, 0);
 
 // Lookup on sorted data intersparsed with empty cells.
 
@@ -2492,6 +2492,22 @@ void Test::testFuncVLOOKUP()
 CPPUNIT_ASSERT_EQUAL(OUString("Four"), 
m_pDoc->GetString(ScAddress(4,3,0)));
 CPPUNIT_ASSERT_EQUAL(OUString("Four"), 
m_pDoc->GetString(ScAddress(4,4,0)));
 
+// Start over again.
+clearSheet(m_pDoc, 0);
+
+// Set A,B,,G to A1:A7.
+m_pDoc->SetString(ScAddress(0,0,0), "A");
+m_pDoc->SetString(ScAddress(0,1,0), "B");
+m_pDoc->SetString(ScAddress(0,2,0), "C");
+m_pDoc->SetString(ScAddress(0,3,0), "D");
+m_pDoc->SetString(ScAddress(0,4,0), "E");
+m_pDoc->SetString(ScAddress(0,5,0), "F");
+m_pDoc->SetString(ScAddress(0,6,0), "G");
+
+// Set the formula in C1.
+m_pDoc->SetString(ScAddress(2,0,0), "=VLOOKUP(\"C\";A1:A16;1)");
+CPPUNIT_ASSERT_EQUAL(OUString("C"), m_pDoc->GetString(ScAddress(2,0,0)));
+
 m_pDoc->DeleteTab(0);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-03-13 Thread Kohei Yoshida
 sc/qa/unit/ucalc.cxx|   31 +++
 sc/source/core/data/column4.cxx |   35 +--
 2 files changed, 56 insertions(+), 10 deletions(-)

New commits:
commit 36bcab7859b7dfa1f1377bb5865c881742f178dd
Author: Kohei Yoshida 
Date:   Thu Mar 13 16:08:03 2014 -0400

fdo#76132: Don't create a formula group of length 1.

That's asking for trouble.

Change-Id: I6aaa4d1e2aed4f166ee216c3eb02d3b7794c9a8c

diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index fa18818..2f21623 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -334,25 +334,40 @@ void ScColumn::CloneFormulaCell( const ScFormulaCell& 
rSrc, const std::vectormnRow1, nRow2 = itSpan->mnRow2;
 size_t nLen = nRow2 - nRow1 + 1;
+assert(nLen > 0);
 aFormulas.clear();
 aFormulas.reserve(nLen);
 
 ScAddress aPos(nCol, nRow1, nTab);
-ScFormulaCellGroupRef xGroup(new ScFormulaCellGroup);
-xGroup->setCode(*rSrc.GetCode());
-xGroup->compileCode(*pDocument, aPos, pDocument->GetGrammar());
-for (size_t i = 0; i < nLen; ++i, aPos.IncRow())
+
+if (nLen == 1)
 {
-ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, xGroup);
-if (i == 0)
-{
-xGroup->mpTopCell = pCell;
-xGroup->mnLength = nLen;
-}
+// Single, ungrouped formula cell.
+ScFormulaCell* pCell =
+new ScFormulaCell(rSrc, *pDocument, aPos, 
pDocument->GetGrammar());
 pCell->StartListeningTo(aCxt);
 pCell->SetDirty();
 aFormulas.push_back(pCell);
 }
+else
+{
+// Create a group of formula cells.
+ScFormulaCellGroupRef xGroup(new ScFormulaCellGroup);
+xGroup->setCode(*rSrc.GetCode());
+xGroup->compileCode(*pDocument, aPos, pDocument->GetGrammar());
+for (size_t i = 0; i < nLen; ++i, aPos.IncRow())
+{
+ScFormulaCell* pCell = new ScFormulaCell(pDocument, aPos, 
xGroup);
+if (i == 0)
+{
+xGroup->mpTopCell = pCell;
+xGroup->mnLength = nLen;
+}
+pCell->StartListeningTo(aCxt);
+pCell->SetDirty();
+aFormulas.push_back(pCell);
+}
+}
 
 itPos = maCells.set(itPos, nRow1, aFormulas.begin(), aFormulas.end());
 
commit ce524556df4bf06cde1229475b9de9822a89f62b
Author: Kohei Yoshida 
Date:   Thu Mar 13 14:43:06 2014 -0400

fdo#76132: Write test for this first.

The crash is a result of the pasted formula cell (single cell) being marked
"shared", which should never happen.

Change-Id: I7b7fa536c520c76b56cce78457e11b6e2eaee76f

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index ed5e894..c903f4f 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3765,6 +3765,37 @@ void Test::testCopyPasteRelativeFormula()
 // B2 references A2, so the value should be 1.
 CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,1,0)));
 
+// Clear content and start over.
+clearSheet(m_pDoc, 0);
+clearSheet(&aClipDoc, 0);
+
+// Insert a single formula cell in A1.
+m_pDoc->SetString(ScAddress(0,0,0), "=ROW()");
+const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0,0,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT(!pFC->IsShared()); // single formula cell is never shared.
+
+// Copy A1 to clipboard.
+aClipParam = ScClipParam(ScAddress(0,0,0), false);
+m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark);
+
+pFC = aClipDoc.GetFormulaCell(ScAddress(0,0,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT(!pFC->IsShared());
+
+// Paste to A3.
+aDestRange = ScRange(0,2,0,0,2,0);
+aMark.SetMarkArea(aDestRange);
+m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, NULL, &aClipDoc);
+
+pFC = m_pDoc->GetFormulaCell(ScAddress(0,2,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT(!pFC->IsShared());
+
+// Delete A3 and make sure it doesn't crash (see fdo#76132).
+clearRange(m_pDoc, ScAddress(0,2,0));
+CPPUNIT_ASSERT(m_pDoc->GetCellType(ScAddress(0,2,0)) == CELLTYPE_NONE);
+
 m_pDoc->DeleteTab(0);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2014-03-13 Thread Kohei Yoshida
 sc/qa/unit/data/xlsx/row-index-1-based.xlsx |binary
 sc/qa/unit/subsequent_filters-test.cxx  |   39 
 sc/source/filter/inc/sheetdatacontext.hxx   |4 +-
 sc/source/filter/oox/sheetdatacontext.cxx   |4 +-
 4 files changed, 43 insertions(+), 4 deletions(-)

New commits:
commit ff56553e34dfed01b9226ce7a516dbeb6da32124
Author: Kohei Yoshida 
Date:   Thu Mar 13 18:01:21 2014 -0400

fdo#76032: This row index is 1-based whereas our own mnRow is 0-based.

Change-Id: I098d300532bef164bef0d40ebf62a6848bc19cb8

diff --git a/sc/source/filter/inc/sheetdatacontext.hxx 
b/sc/source/filter/inc/sheetdatacontext.hxx
index dba7a7e..e352cd0 100644
--- a/sc/source/filter/inc/sheetdatacontext.hxx
+++ b/sc/source/filter/inc/sheetdatacontext.hxx
@@ -129,8 +129,8 @@ private:
 boolmbHasFormula;   /// True = current cell has 
formula data (OOXML only).
 boolmbValidRange;   /// True = maFmlaData.maFormulaRef 
is valid (OOXML only).
 
-sal_Int32 mnRow;
-sal_Int32 mnCol;
+sal_Int32 mnRow; /// row index (0-based)
+sal_Int32 mnCol; /// column index (0-based)
 };
 
 
diff --git a/sc/source/filter/oox/sheetdatacontext.cxx 
b/sc/source/filter/oox/sheetdatacontext.cxx
index 9628e78..4d2c57a 100644
--- a/sc/source/filter/oox/sheetdatacontext.cxx
+++ b/sc/source/filter/oox/sheetdatacontext.cxx
@@ -279,11 +279,11 @@ ContextHandlerRef 
SheetDataContext::onCreateRecordContext( sal_Int32 nRecId, Seq
 void SheetDataContext::importRow( const AttributeList& rAttribs )
 {
 RowModel aModel;
-sal_Int32 nRow = rAttribs.getInteger( XML_r, -1 );
+sal_Int32 nRow = rAttribs.getInteger( XML_r, -1 ); // 1-based row index
 if(nRow != -1)
 {
 aModel.mnRow = nRow;
-mnRow = nRow;
+mnRow = nRow-1; // to 0-based row index.
 }
 else
 aModel.mnRow = ++mnRow;
commit a145e8859c5a878110ec1b346f244c51d1e5a80b
Author: Kohei Yoshida 
Date:   Thu Mar 13 18:00:19 2014 -0400

fdo#76032: Write test for this.

Change-Id: Iec8d32a4e53d2d5d3cdc9767c2ede7654fe2bdd6

diff --git a/sc/qa/unit/data/xlsx/row-index-1-based.xlsx 
b/sc/qa/unit/data/xlsx/row-index-1-based.xlsx
new file mode 100644
index 000..1f60c3b
Binary files /dev/null and b/sc/qa/unit/data/xlsx/row-index-1-based.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index f22e1e2..66bfb94 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -127,6 +127,12 @@ public:
 //change this test file only in excel and not in calc
 void testCellValueXLSX();
 
+/**
+ * Test importing of xlsx document that previously had its row index off
+ * by one. (fdo#76032)
+ */
+void testRowIndex1BasedXLSX();
+
 //misc tests unrelated to the import filters
 void testPasswordNew();
 void testPasswordOld();
@@ -195,6 +201,7 @@ public:
 CPPUNIT_TEST(testDataTableMultiTableXLSX);
 CPPUNIT_TEST(testBrokenQuotesCSV);
 CPPUNIT_TEST(testCellValueXLSX);
+CPPUNIT_TEST(testRowIndex1BasedXLSX);
 CPPUNIT_TEST(testControlImport);
 CPPUNIT_TEST(testChartImportODS);
 
@@ -1417,6 +1424,38 @@ void ScFiltersTest::testCellValueXLSX()
 xDocSh->DoClose();
 }
 
+void ScFiltersTest::testRowIndex1BasedXLSX()
+{
+ScDocShellRef xDocSh = loadDoc("row-index-1-based.", XLSX);
+CPPUNIT_ASSERT(xDocSh.Is());
+ScDocument* pDoc = xDocSh->GetDocument();
+
+// A1
+OUString aStr = pDoc->GetString(ScAddress(0,0,0));
+CPPUNIT_ASSERT_EQUAL(OUString("Action Plan.Name"), aStr);
+
+// B1
+aStr = pDoc->GetString(ScAddress(1,0,0));
+CPPUNIT_ASSERT_EQUAL(OUString("Action Plan.Description"), aStr);
+
+// A2
+aStr = pDoc->GetString(ScAddress(0,1,0));
+CPPUNIT_ASSERT_EQUAL(OUString("Jerry"), aStr);
+
+// B2 - multi-line text.
+const EditTextObject* pText = pDoc->GetEditText(ScAddress(1,1,0));
+CPPUNIT_ASSERT(pText);
+CPPUNIT_ASSERT(pText->GetParagraphCount() == 3);
+aStr = pText->GetText(0);
+CPPUNIT_ASSERT_EQUAL(OUString("This is a longer Text."), aStr);
+aStr = pText->GetText(1);
+CPPUNIT_ASSERT_EQUAL(OUString("Second line."), aStr);
+aStr = pText->GetText(2);
+CPPUNIT_ASSERT_EQUAL(OUString("Third line."), aStr);
+
+xDocSh->DoClose();
+}
+
 void ScFiltersTest::testPassword_Impl(const OUString& aFileNameBase)
 {
 OUString aFileExtension(getFileFormats()[0].pName, 
strlen(getFileFormats()[0].pName), RTL_TEXTENCODING_UTF8 );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits