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

2018-04-05 Thread Caolán McNamara
 sc/qa/unit/data/xls/fail/forcepoint-group-range-1.xls |binary
 sc/source/core/data/column3.cxx   |2 ++
 2 files changed, 2 insertions(+)

New commits:
commit e82beb0812f2f4742b80ba1f63a026cbe77f5b25
Author: Caolán McNamara 
Date:   Mon Mar 26 09:23:48 2018 +0100

forcepoint #30 check validity of group range

Change-Id: Ie0611f36809b051ce46030e44c137b4e1f8d2fe0
Reviewed-on: https://gerrit.libreoffice.org/51865
Tested-by: Jenkins 
Reviewed-by: Michael Stahl 

diff --git a/sc/qa/unit/data/xls/fail/forcepoint-group-range-1.xls 
b/sc/qa/unit/data/xls/fail/forcepoint-group-range-1.xls
new file mode 100755
index ..1aca9c7f113e
Binary files /dev/null and 
b/sc/qa/unit/data/xls/fail/forcepoint-group-range-1.xls differ
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 8e36534e8461..d3e3e24d88c5 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -3089,6 +3089,8 @@ public:
 xPrevGrp->mnLength += xCurGrp->mnLength;
 pCur->SetCellGroup(xPrevGrp);
 sc::formula_block::iterator itGrpEnd = it;
+if (xCurGrp->mnLength > std::distance(itGrpEnd, itEnd))
+throw css::lang::IllegalArgumentException();
 std::advance(itGrpEnd, xCurGrp->mnLength);
 for (++it; it != itGrpEnd; ++it)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-04-05 Thread Caolán McNamara
 sc/qa/unit/data/xls/pass/forcepoint-selfseriesadd.xls |binary
 sc/source/filter/excel/xichart.cxx|5 +
 2 files changed, 5 insertions(+)

New commits:
commit a471620af5099c960e22b46fad6e6f92a5055dbd
Author: Caolán McNamara 
Date:   Mon Mar 26 08:57:09 2018 +0100

forcepoint #29 detect illegal self series add

Change-Id: I3bba0f942780c54951a3a810c05cc3b56ca18a5e
Reviewed-on: https://gerrit.libreoffice.org/51862
Tested-by: Jenkins 
Reviewed-by: Michael Stahl 

diff --git a/sc/qa/unit/data/xls/pass/forcepoint-selfseriesadd.xls 
b/sc/qa/unit/data/xls/pass/forcepoint-selfseriesadd.xls
new file mode 100755
index ..e5eafd262520
Binary files /dev/null and 
b/sc/qa/unit/data/xls/pass/forcepoint-selfseriesadd.xls differ
diff --git a/sc/source/filter/excel/xichart.cxx 
b/sc/source/filter/excel/xichart.cxx
index 9eda9e33c883..db71be8dc037 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -1871,6 +1871,11 @@ void XclImpChSeries::SetDataLabel( const 
XclImpChTextRef& xLabel )
 void XclImpChSeries::AddChildSeries( const XclImpChSeries& rSeries )
 {
 OSL_ENSURE( !HasParentSeries(), "XclImpChSeries::AddChildSeries - not 
allowed for child series" );
+if ( == this)
+{
+SAL_WARN("sc.filter", "self add attempt");
+return;
+}
 
 /*  In Excel, trend lines and error bars are stored as own series. In Calc,
 these are properties of the parent series. This function adds the
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-01-23 Thread Tor Lillqvist
 sc/qa/unit/rangelst_test.cxx |   57 +++
 sc/source/core/tool/rangelst.cxx |   12 +---
 2 files changed, 65 insertions(+), 4 deletions(-)

New commits:
commit c0c65bfa65f33d9756ba1e4f58ebc691e321089f
Author: Tor Lillqvist 
Date:   Thu Sep 14 21:11:27 2017 +0300

Handle also the case where a range extends an existing one with overlap

Check for a new range being joined Extending an existing one in any of
four directions (up, right, down, left), within a tab (sheet), that
is. And add unit test for this.

Reviewed-on: https://gerrit.libreoffice.org/42304
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 
(cherry picked from commit 596efaad51735a130e7b7bd27dbc34dc07f32f68)

Change-Id: I4bd0525c2837f8b4b9d5a8967e0d5d661c6a5e2f
Reviewed-on: https://gerrit.libreoffice.org/48410
Tested-by: Jenkins 
Reviewed-by: Tor Lillqvist 

diff --git a/sc/qa/unit/rangelst_test.cxx b/sc/qa/unit/rangelst_test.cxx
index dce700164ecd..79c57364e209 100644
--- a/sc/qa/unit/rangelst_test.cxx
+++ b/sc/qa/unit/rangelst_test.cxx
@@ -44,6 +44,8 @@ public:
 void testDeleteArea_0Ranges();
 void testJoin_Case1();
 void testJoin_Case2();
+void testJoin_Case3();
+void testJoin_Case4();
 void testGetIntersectedRange();
 
 void testUpdateReference_DeleteRow();
@@ -72,6 +74,8 @@ public:
 CPPUNIT_TEST(testDeleteArea_0Ranges);
 CPPUNIT_TEST(testJoin_Case1);
 CPPUNIT_TEST(testJoin_Case2);
+CPPUNIT_TEST(testJoin_Case3);
+CPPUNIT_TEST(testJoin_Case4);
 CPPUNIT_TEST(testUpdateReference_DeleteRow);
 CPPUNIT_TEST(testUpdateReference_DeleteLastRow);
 CPPUNIT_TEST(testUpdateReference_DeleteCol);
@@ -424,6 +428,59 @@ void Test::testJoin_Case2()
 CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,9,3,0), *aList[0]);
 }
 
+void Test::testJoin_Case3()
+{
+ScRangeList aList;
+aList.Join(ScRange(1,1,0,6,6,0));
+aList.Join(ScRange(3,3,0,4,4,0));
+
+// The second one should have been swallowed by the first one
+CPPUNIT_ASSERT_EQUAL(static_cast(1), aList.size());
+CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,6,6,0), *aList[0]);
+
+// Add a disjoint one
+aList.Join(ScRange(8,8,0,9,9,0));
+
+// Should be two ones now
+CPPUNIT_ASSERT_EQUAL(static_cast(2), aList.size());
+// The first one should still be as is
+CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,6,6,0), *aList[0]);
+// Ditto for the second one
+CPPUNIT_ASSERT_EQUAL(ScRange(8,8,0,9,9,0), *aList[1]);
+}
+
+void Test::testJoin_Case4()
+{
+ScRangeList aList;
+aList.Join(ScRange(1,1,0,2,6,0));
+// Join a range that overlaps it and extends it vertically
+aList.Join(ScRange(1,4,0,2,8,0));
+
+// The one range in the list should have been extended
+CPPUNIT_ASSERT_EQUAL(static_cast(1), aList.size());
+CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,2,8,0), *aList[0]);
+
+// Join a range that overlaps it and extends it horizontally
+aList.Join(ScRange(2,1,0,4,8,0));
+
+// Again, should have just been extended
+CPPUNIT_ASSERT_EQUAL(static_cast(1), aList.size());
+CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,4,8,0), *aList[0]);
+
+// And then the same but on top / to the left of existing range
+ScRangeList aList2;
+aList2.Join(ScRange(4,4,0,8,8,0));
+aList2.Join(ScRange(4,1,0,8,6,0));
+
+CPPUNIT_ASSERT_EQUAL(static_cast(1), aList2.size());
+CPPUNIT_ASSERT_EQUAL(ScRange(4,1,0,8,8,0), *aList2[0]);
+
+aList2.Join(ScRange(1,1,0,6,8,0));
+
+CPPUNIT_ASSERT_EQUAL(static_cast(1), aList2.size());
+CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,8,8,0), *aList2[0]);
+}
+
 void Test::testUpdateReference_DeleteRow()
 {
 ScRangeList aList(ScRange(1,1,0,4,4,0));
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index 5ae74f9c0f3d..19fed29aba75 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -299,12 +299,14 @@ void ScRangeList::Join( const ScRange& r, bool bIsInList )
 {   // 2D
 if ( p->aStart.Col() == nCol1 && p->aEnd.Col() == nCol2 )
 {
-if ( p->aStart.Row() == nRow2+1 )
+if ( p->aStart.Row() <= nRow2+1 &&
+ p->aStart.Row() >= nRow1 )
 {   // top
 p->aStart.SetRow( nRow1 );
 bJoined = true;
 }
-else if ( p->aEnd.Row() == nRow1-1 )
+else if ( p->aEnd.Row() >= nRow1-1 &&
+  p->aEnd.Row() <= nRow2 )
 {   // bottom
 p->aEnd.SetRow( nRow2 );
 bJoined = true;
@@ -312,12 +314,14 @@ void ScRangeList::Join( const ScRange& r, bool bIsInList )
 }
 else if ( p->aStart.Row() == nRow1 && p->aEnd.Row() == nRow2 )
 {
-if ( 

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

2018-01-22 Thread Caolán McNamara
 sc/qa/unit/data/xls/fail/ofz5527-1.xls |binary
 sc/source/filter/excel/xicontent.cxx   |4 +++-
 2 files changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 915ce86d14eb219fee467443fe57a984648f3836
Author: Caolán McNamara 
Date:   Sun Jan 21 16:15:30 2018 +

copy ScAddress before possibly joining it

Change-Id: Ib1148584b9771da67d3f4b3141184228e1bbe3a2
Reviewed-on: https://gerrit.libreoffice.org/48271
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 
(cherry picked from commit f6eefd96cb16a9b5607fe59bdbf9b1121c9b56e8)
Reviewed-on: https://gerrit.libreoffice.org/48298
Reviewed-by: Eike Rathke 

diff --git a/sc/qa/unit/data/xls/fail/ofz5527-1.xls 
b/sc/qa/unit/data/xls/fail/ofz5527-1.xls
new file mode 100644
index ..334cafe42445
Binary files /dev/null and b/sc/qa/unit/data/xls/fail/ofz5527-1.xls differ
diff --git a/sc/source/filter/excel/xicontent.cxx 
b/sc/source/filter/excel/xicontent.cxx
index 150820e88ae0..14c2ad9d0a3f 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -678,6 +678,8 @@ void XclImpCondFormat::ReadCF( XclImpStream& rStrm )
 
 // *** create the Calc conditional formatting ***
 
+const ScAddress aPos(rPos); //in case maRanges.Join invalidates it
+
 if( !mxScCondFmt.get() )
 {
 sal_uLong nKey = 0;
@@ -687,7 +689,7 @@ void XclImpCondFormat::ReadCF( XclImpStream& rStrm )
 mxScCondFmt->SetRange(maRanges);
 }
 
-ScCondFormatEntry* pEntry = new ScCondFormatEntry( eMode, xTokArr1.get(), 
pTokArr2.get(), (), rPos, aStyleName );
+ScCondFormatEntry* pEntry = new ScCondFormatEntry(eMode, xTokArr1.get(), 
pTokArr2.get(), (), aPos, aStyleName);
 mxScCondFmt->AddEntry( pEntry );
 ++mnCondIndex;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-12-02 Thread Aron Budea
 sc/qa/unit/data/xlsx/built-in_ranges.xlsx |binary
 sc/qa/unit/subsequent_export-test.cxx |   28 
 sc/source/filter/excel/xltools.cxx|6 +-
 sc/source/filter/inc/xltools.hxx  |4 ++--
 4 files changed, 35 insertions(+), 3 deletions(-)

New commits:
commit d0f5f2bbd2bc6fee5ad4c4031f69c04e1c8fd3fb
Author: Aron Budea 
Date:   Tue Nov 28 07:23:12 2017 +0100

tdf#109240, tdf#112571: don't export dupe built-in named ranges

XclTools::GetBuiltInDefNameIndex(...) only checked for prefix used in
binary Excel format, and didn't recognize OOXML built-in names, which
resulted in saving them twice in OOXML files.

Adapt to check both binary and OOXML prefixes, similarly to
XclTools::IsBuiltInStyleName(...).

Saving "bad" files after the fix will purge bad "_0", "_0_0" etc.
suffixed built-in names due to how GetBuiltInDefNameIndex(...) works.

Change-Id: I1bbe11f9c654a142a4626003df4cb0fd2a0f9c71
Reviewed-on: https://gerrit.libreoffice.org/45381
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 
(cherry picked from commit f8b9d0fb0767d8bbe8477f92abaf6b8e0ff65546)
Reviewed-on: https://gerrit.libreoffice.org/45701
Tested-by: Jenkins 

diff --git a/sc/qa/unit/data/xlsx/built-in_ranges.xlsx 
b/sc/qa/unit/data/xlsx/built-in_ranges.xlsx
new file mode 100644
index ..b18a4862fdd6
Binary files /dev/null and b/sc/qa/unit/data/xlsx/built-in_ranges.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 4e692e570784..09b7f9e49cc8 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -105,6 +105,7 @@ public:
 void testConditionalFormatRangeListXLSX();
 void testMiscRowHeightExport();
 void testNamedRangeBugfdo62729();
+void testBuiltinRangesXLSX();
 void testRichTextExportODS();
 void testRichTextCellFormatXLSX();
 void testFormulaRefSheetNameODS();
@@ -214,6 +215,7 @@ public:
 CPPUNIT_TEST(testConditionalFormatRangeListXLSX);
 CPPUNIT_TEST(testMiscRowHeightExport);
 CPPUNIT_TEST(testNamedRangeBugfdo62729);
+CPPUNIT_TEST(testBuiltinRangesXLSX);
 CPPUNIT_TEST(testRichTextExportODS);
 CPPUNIT_TEST(testRichTextCellFormatXLSX);
 CPPUNIT_TEST(testFormulaRefSheetNameODS);
@@ -1145,6 +1147,32 @@ void ScExportTest::testNamedRangeBugfdo62729()
 xDocSh->DoClose();
 }
 
+void ScExportTest::testBuiltinRangesXLSX()
+{
+ScDocShellRef xShell = loadDoc("built-in_ranges.", FORMAT_XLSX);
+CPPUNIT_ASSERT(xShell.is());
+ScDocShellRef xDocSh = saveAndReload(xShell.get(), FORMAT_XLSX);
+CPPUNIT_ASSERT(xDocSh.is());
+xShell->DoClose();
+
+xmlDocPtr pDoc = XPathHelper::parseExport(*xDocSh, m_xSFactory, 
"xl/workbook.xml", FORMAT_XLSX);
+CPPUNIT_ASSERT(pDoc);
+
+//assert the existing OOXML built-in names are still there
+assertXPathContent(pDoc, 
"/x:workbook/x:definedNames/x:definedName[@name='_xlnm._FilterDatabase'][@localSheetId='0']",
 "'Sheet1 Test'!$A$1:$A$5");
+assertXPathContent(pDoc, 
"/x:workbook/x:definedNames/x:definedName[@name='_xlnm._FilterDatabase'][@localSheetId='1']",
 "'Sheet2 Test'!$K$10:$K$14");
+assertXPathContent(pDoc, 
"/x:workbook/x:definedNames/x:definedName[@name='_xlnm.Print_Area'][@localSheetId='0']",
 "'Sheet1 Test'!$A$1:$A$5");
+assertXPathContent(pDoc, 
"/x:workbook/x:definedNames/x:definedName[@name='_xlnm.Print_Area'][@localSheetId='1']",
 "'Sheet2 Test'!$K$10:$M$18");
+
+//...and that no extra ones are added (see tdf#112571)
+assertXPath(pDoc, 
"/x:workbook/x:definedNames/x:definedName[@name='_xlnm._FilterDatabase_0'][@localSheetId='0']",
 0);
+assertXPath(pDoc, 
"/x:workbook/x:definedNames/x:definedName[@name='_xlnm._FilterDatabase_0'][@localSheetId='1']",
 0);
+assertXPath(pDoc, 
"/x:workbook/x:definedNames/x:definedName[@name='_xlnm.Print_Area_0'][@localSheetId='0']",
 0);
+assertXPath(pDoc, 
"/x:workbook/x:definedNames/x:definedName[@name='_xlnm.Print_Area_0'][@localSheetId='1']",
 0);
+
+xDocSh->DoClose();
+}
+
 void ScExportTest::testRichTextExportODS()
 {
 struct
diff --git a/sc/source/filter/excel/xltools.cxx 
b/sc/source/filter/excel/xltools.cxx
index 374fc6256b21..a68327f93d39 100644
--- a/sc/source/filter/excel/xltools.cxx
+++ b/sc/source/filter/excel/xltools.cxx
@@ -482,8 +482,12 @@ OUString XclTools::GetBuiltInDefNameXml( sal_Unicode 
cBuiltIn )
 
 sal_Unicode XclTools::GetBuiltInDefNameIndex( const OUString& rDefName )
 {
-sal_Int32 nPrefixLen = strlen(maDefNamePrefix);
+sal_Int32 nPrefixLen = 0;
 if( rDefName.startsWithIgnoreAsciiCase( maDefNamePrefix ) )
+nPrefixLen = strlen(maDefNamePrefix);
+else if( rDefName.startsWithIgnoreAsciiCase( maDefNamePrefixXml ) )
+nPrefixLen = strlen(maDefNamePrefixXml);
+if( nPrefixLen 

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

2017-09-07 Thread Winfried Donkers
 sc/qa/unit/data/functions/financial/fods/nper.fods |   36 +++--
 sc/source/core/tool/interpr2.cxx   |2 -
 2 files changed, 27 insertions(+), 11 deletions(-)

New commits:
commit 085768b2a0dd1fc6371e8b2ba4e2418ba96cdb21
Author: Winfried Donkers 
Date:   Wed Sep 6 16:52:05 2017 +0200

tdf#112177 remove incorrect constraint for Calc function NPER.

Change-Id: I123ea8ee2e333665ac448c6b3814c3bac0b687ab
Reviewed-on: https://gerrit.libreoffice.org/42011
Tested-by: Jenkins 
Reviewed-by: Eike Rathke 
(cherry picked from commit 003c2cfaa258e204402a366a105366da74e220a2)
Reviewed-on: https://gerrit.libreoffice.org/42047

diff --git a/sc/qa/unit/data/functions/financial/fods/nper.fods 
b/sc/qa/unit/data/functions/financial/fods/nper.fods
index 22c06f914a25..2eac9b8f339f 100644
--- a/sc/qa/unit/data/functions/financial/fods/nper.fods
+++ b/sc/qa/unit/data/functions/financial/fods/nper.fods
@@ -1528,20 +1528,20 @@
  
 
 
- 
-  Err:502
+ 
+  27.6208695898296
  
- 
-  Err:502
+ 
+  27.6208695898296
  
- 
-  TRUE
+ 
+  WAAR
  
- 
-  =NPER(0.06/52, 0, 8000, 0 ,2)
+ 
+  =NPER(0,06; 0; -80; 400 ;2)
  
  
-  No payment, no result
+  future value achieved with interest from present value
  
  
  
@@ -1570,6 +1570,24 @@
  
 
 
+ 
+  #NUM!
+ 
++ 
++  #NUM!
+ 
+ 
+  WAAR
+ 
+ 
+  =NPER(0,06; 0; 80; 400 ;2)
+ 
+ 
+  future value cannot be achieved with interest from present 
value
+ 
+ 
+
+
  
  
  
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 3e61c081e24b..35f748a959e2 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -2007,8 +2007,6 @@ void ScInterpreter::ScNper()
 // amount to be paid to get from fPV to fFV is fFV_+_fPV.
 if ( fPV + fFV == 0.0 )
 PushDouble( 0.0 );
-else if ( fPmt == 0.0 )
-PushIllegalArgument();  // No payment, future value can never be 
reached
 else if (fInterest == 0.0)
 PushDouble(-(fPV + fFV)/fPmt);
 else if (bPayInAdvance)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-09-07 Thread Dennis Francis
 sc/qa/unit/data/xlsm/tdf111974.xlsm   |binary
 sc/qa/unit/subsequent_filters-test.cxx|   10 ++
 sc/source/filter/oox/workbookfragment.cxx |2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)

New commits:
commit 0b172f1d95c726c3e0bbc0b58a8605bf06bf6c67
Author: Dennis Francis 
Date:   Thu Aug 31 14:22:15 2017 +0530

tdf#111974: Ensure sufficient space for all sheets in FormulaBuffer...

and not just for the number of sheet fragments. This is important
because we changed the internal storage of FormulaBuffer from based
on std::map to std::vector in d17a83fa549f828f29e6939b16ba8b568a75f95e

Added simple unit test that loads the bugdoc in
subsequent_filters-test.cxx

Reviewed-on: https://gerrit.libreoffice.org/41792
Tested-by: Jenkins 
Reviewed-by: Dennis Francis 
(cherry picked from commit 20169423d492b58ab93fb0e8e9d2918c0baebc92)

Change-Id: I7320dd537266e540d585d3fccfbb8665bba457c7
Reviewed-on: https://gerrit.libreoffice.org/41841
Tested-by: Jenkins 
Reviewed-by: Eike Rathke 

diff --git a/sc/qa/unit/data/xlsm/tdf111974.xlsm 
b/sc/qa/unit/data/xlsm/tdf111974.xlsm
new file mode 100644
index ..bb6ac6d0a2d3
Binary files /dev/null and b/sc/qa/unit/data/xlsm/tdf111974.xlsm differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 6ba489456805..c619d71232c6 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -240,6 +240,7 @@ public:
 void testTdf100709XLSX();
 void testTdf97598XLSX();
 void testTdf110440XLSX();
+void testTdf111974XLSM();
 
 CPPUNIT_TEST_SUITE(ScFiltersTest);
 CPPUNIT_TEST(testBooleanFormatXLSX);
@@ -361,6 +362,7 @@ public:
 CPPUNIT_TEST(testTdf100709XLSX);
 CPPUNIT_TEST(testTdf97598XLSX);
 CPPUNIT_TEST(testTdf110440XLSX);
+CPPUNIT_TEST(testTdf111974XLSM);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -3784,6 +3786,14 @@ void ScFiltersTest::testTdf110440XLSX()
 xDocSh->DoClose();
 }
 
+void ScFiltersTest::testTdf111974XLSM()
+{
+// Would crash without the fix on loading
+ScDocShellRef xDocSh = loadDoc("tdf111974.", FORMAT_XLSM);
+CPPUNIT_ASSERT_MESSAGE("Failed to open doc", xDocSh.is());
+xDocSh->DoClose();
+}
+
 void ScFiltersTest::testBnc762542()
 {
 ScDocShellRef xDocSh = loadDoc("bnc762542.", FORMAT_XLSX);
diff --git a/sc/source/filter/oox/workbookfragment.cxx 
b/sc/source/filter/oox/workbookfragment.cxx
index 72d2985e536f..49343a831b22 100644
--- a/sc/source/filter/oox/workbookfragment.cxx
+++ b/sc/source/filter/oox/workbookfragment.cxx
@@ -450,7 +450,7 @@ void WorkbookFragment::finalizeImport()
 }
 
 // setup structure sizes for the number of sheets
-getFormulaBuffer().SetSheetCount( aSheetFragments.size() );
+getFormulaBuffer().SetSheetCount( nWorksheetCount );
 
 // create all database ranges and defined names, in that order
 getTables().finalizeImport();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-08-23 Thread Dennis Francis
 sc/qa/unit/subsequent_export-test.cxx |   67 +-
 sc/source/filter/xml/xmlexprt.cxx |8 +++-
 2 files changed, 73 insertions(+), 2 deletions(-)

New commits:
commit 1b4c5f66083a92f4bfc9bd20a2a5b1e863ec84c1
Author: Dennis Francis 
Date:   Tue Aug 15 11:21:04 2017 +0530

tdf#83562: Make the EditTextObject export of automatic colors...

... use the xml token "use-window-font-color" instead of "color"
to encode a boolean value of whether an auto color is used or not.
This is because the "auto" color is 0x and cannot be
written into "color" xml field which can store only 3 byte-hexcode.

This commit also adds a unit test in subsequent_export-test.cxx
to ensure the correct export of automatic color.

Change-Id: I42aab926f31669c1423bc09b96b45c410c9732de
Reviewed-on: https://gerrit.libreoffice.org/41252
Tested-by: Jenkins 
Reviewed-by: Dennis Francis 
(cherry picked from commit 06d104ecda085200fb6d22e0bd6d6cb89ca4f66c)
Reviewed-on: https://gerrit.libreoffice.org/41358
Reviewed-by: Michael Stahl 

diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index fb4d496243bf..26ac932a7765 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -26,6 +26,7 @@
 #include "userdat.hxx"
 #include "docsh.hxx"
 #include "patattr.hxx"
+#include "docpool.hxx"
 #include "scitems.hxx"
 #include "document.hxx"
 #include "cellform.hxx"
@@ -61,6 +62,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1029,7 +1031,7 @@ void ScExportTest::testMiscRowHeightExport()
 
 namespace {
 
-void setAttribute( ScFieldEditEngine& rEE, sal_Int32 nPara, sal_Int32 nStart, 
sal_Int32 nEnd, sal_uInt16 nType )
+void setAttribute( ScFieldEditEngine& rEE, sal_Int32 nPara, sal_Int32 nStart, 
sal_Int32 nEnd, sal_uInt16 nType, sal_uInt32 nColor = COL_BLACK )
 {
 ESelection aSel;
 aSel.nStartPara = aSel.nEndPara = nPara;
@@ -1074,6 +1076,13 @@ void setAttribute( ScFieldEditEngine& rEE, sal_Int32 
nPara, sal_Int32 nStart, sa
 rEE.QuickSetAttribs(aItemSet, aSel);
 }
 break;
+case EE_CHAR_COLOR:
+{
+SvxColorItem aItem(nColor, nType);
+aItemSet.Put(aItem);
+rEE.QuickSetAttribs(aItemSet, aSel);
+}
+break;
 default:
 ;
 }
@@ -1256,6 +1265,23 @@ void ScExportTest::testRichTextExportODS()
 return false;
 }
 
+static bool isColor(const editeng::Section& rAttr, sal_uInt32 nColor)
+{
+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_COLOR)
+continue;
+
+return static_cast(p)->GetValue() == 
nColor;
+}
+return false;
+}
+
 bool checkB2(const EditTextObject* pText) const
 {
 if (!pText)
@@ -1482,6 +1508,32 @@ void ScExportTest::testRichTextExportODS()
 return true;
 }
 
+bool checkB10(const EditTextObject* pText) const
+{
+if (!pText)
+return false;
+
+if (pText->GetParagraphCount() != 1)
+return false;
+
+if (pText->GetText(0) != "BLUE AUTO")
+return false;
+
+std::vector aSecAttrs;
+pText->GetAllSections(aSecAttrs);
+if (aSecAttrs.size() != 2)
+return false;
+
+// auto color
+const editeng::Section* pAttr = [1];
+if (pAttr->mnParagraph != 0 ||pAttr->mnStart != 5 || pAttr->mnEnd 
!= 9)
+return false;
+
+if (pAttr->maAttributes.size() != 1 || !isColor(*pAttr, COL_AUTO))
+return false;
+
+return true;
+}
 
 } aCheckFunc;
 
@@ -1583,6 +1635,17 @@ void ScExportTest::testRichTextExportODS()
 pEditText = rDoc3.GetEditText(ScAddress(1,8,0));
 CPPUNIT_ASSERT_MESSAGE("Incorrect B9 value.", 
aCheckFunc.checkB9(pEditText));
 
+ScPatternAttr aCellFontColor(rDoc3.GetPool());
+aCellFontColor.GetItemSet().Put(SvxColorItem(COL_BLUE, 
ATTR_FONT_COLOR));
+// Set font color of B10 to blue.
+rDoc3.ApplyPattern(1, 9, 0, aCellFontColor);
+pEE->Clear();
+pEE->SetText("BLUE AUTO");
+// Set the color of the string "AUTO" to automatic color.
+setAttribute(*pEE, 0, 5, 9, EE_CHAR_COLOR, COL_AUTO);
+rDoc3.SetEditText(ScAddress(1, 9, 0), pEE->CreateTextObject());
+pEditText = 

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

2017-07-19 Thread Dennis Francis
 sc/qa/unit/ucalc.hxx|2 ++
 sc/qa/unit/ucalc_formula.cxx|   34 ++
 sc/source/core/data/formulacell.cxx |4 
 3 files changed, 40 insertions(+)

New commits:
commit f5661ec96ea4e30abea2ad0b218024c6c747071b
Author: Dennis Francis 
Date:   Mon Jul 17 19:10:44 2017 +0530

tdf#93328 : Assign the ScInterpreter results back to ScFormulaCell...

when the formula cell type is unknown before interpreting, otherwise
the cell is treated as of type string later when used by the
interpreter.

Added unit-test testIterations() in ucalc that tests the
establishment of circular chain of references and editing of a
formula cell that already belong to the circular chain.

Change-Id: Ib13b05b20d17c0696fce0ac9eefd9e621bdc0c5f
Reviewed-on: https://gerrit.libreoffice.org/40165
Tested-by: Jenkins 
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 
(cherry picked from commit 5f2bcde100c278315609c221c48ff03aacdf9bdc)
Reviewed-on: https://gerrit.libreoffice.org/40199

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index bddf2eda1ff8..845599edf38e 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -218,6 +218,7 @@ public:
 void testMatConcatReplication();
 void testRefR1C1WholeCol();
 void testRefR1C1WholeRow();
+void testIterations();
 
 void testExternalRef();
 void testExternalRefFunctions();
@@ -610,6 +611,7 @@ public:
 CPPUNIT_TEST(testFuncGETPIVOTDATALeafAccess);
 CPPUNIT_TEST(testRefR1C1WholeCol);
 CPPUNIT_TEST(testRefR1C1WholeRow);
+CPPUNIT_TEST(testIterations);
 CPPUNIT_TEST(testMatrixOp);
 CPPUNIT_TEST(testFuncRangeOp);
 CPPUNIT_TEST(testFuncFORMULA);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 3f04ff0a0c45..277b224da8a7 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -8030,4 +8030,38 @@ void Test::testFuncRowsHidden()
 m_pDoc->DeleteTab(0);
 }
 
+// Test iterations with circular chain of references.
+void Test::testIterations()
+{
+ScDocOptions aDocOpts = m_pDoc->GetDocOptions();
+aDocOpts.SetIter( true );
+m_pDoc->SetDocOptions( aDocOpts );
+
+m_pDoc->InsertTab(0, "Test");
+
+m_pDoc->SetValue( 0, 0, 0, 0.01 ); // A1
+m_pDoc->SetString( 0, 1, 0, "=A1" );   // A2
+m_pDoc->SetString( 0, 2, 0, "=COS(A2)" );  // A3
+m_pDoc->CalcAll();
+
+// Establish reference cycle for the computation of the fixed point of 
COS() function
+m_pDoc->SetString( 0, 0, 0, "=A3" );   // A1
+m_pDoc->CalcAll();
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE( "Cell A3 should not have any formula error", 
FormulaError::NONE, m_pDoc->GetErrCode( ScAddress( 0, 2, 0) ) );
+CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Iterations to calculate fixed point 
of cos() failed", 0.7387, m_pDoc->GetValue(0, 2, 0), 1e-4 );
+
+// Modify the formula
+m_pDoc->SetString( 0, 2, 0, "=COS(A2)+0.001" );  // A3
+m_pDoc->CalcAll();
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE( "Cell A3 should not have any formula error 
after perturbation", FormulaError::NONE, m_pDoc->GetErrCode( ScAddress( 0, 2, 
0) ) );
+CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Iterations to calculate perturbed 
fixed point of cos() failed", 0.7399, m_pDoc->GetValue(0, 2, 0), 1e-4 );
+
+m_pDoc->DeleteTab(0);
+
+aDocOpts.SetIter( false );
+m_pDoc->SetDocOptions( aDocOpts );
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index 630ba6208869..2555c15b6371 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -1806,6 +1806,10 @@ void ScFormulaCell::InterpretTail( 
ScInterpretTailParameter eTailParam )
 {
 if (nSeenInIteration > 0)
 --nSeenInIteration; // retry when iteration is resumed
+
+if ( aResult.GetType() == formula::svUnknown )
+aResult.SetToken( pInterpreter->GetResultToken().get() );
+
 return;
 }
 bRunning = bOldRunning;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-07-14 Thread Dennis Francis
 sc/qa/unit/ucalc.hxx|4 +
 sc/qa/unit/ucalc_formula.cxx|  126 
 sc/source/core/data/formulacell.cxx |6 +
 3 files changed, 134 insertions(+), 2 deletions(-)

New commits:
commit 520a5a8a21e986355e4f7f5e8b5bddecb00a34d9
Author: Dennis Francis 
Date:   Thu Jul 13 11:35:41 2017 +0530

tdf#108758 : do not write to undo document when...

...updating references during a block move, for formula cells
that are in the target range of the move operation.

The fix is for formula cells that are not grouped. For the
grouped case, it was already doing correctly.

Added two unit tests in ucalc_formula.cxx for grouped formula
and non-grouped formula cases.

Change-Id: I9f4d988f5e154f56670bd1c0cc366ee6704fb858
Reviewed-on: https://gerrit.libreoffice.org/39883
Tested-by: Jenkins 
Reviewed-by: Eike Rathke 
(cherry picked from commit 2caaf9bfe8d3f81517467daf36de0bd8ddd6b543)
Reviewed-on: https://gerrit.libreoffice.org/39919

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 5d1def66c7c7..bddf2eda1ff8 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -152,6 +152,8 @@ public:
 void testFormulaRefUpdateMove();
 void testFormulaRefUpdateMoveUndo();
 void testFormulaRefUpdateMoveUndo2();
+void testFormulaRefUpdateMoveUndo3NonShared();
+void testFormulaRefUpdateMoveUndo3Shared();
 void testFormulaRefUpdateMoveToSheet();
 void testFormulaRefUpdateDeleteContent();
 void testFormulaRefUpdateDeleteAndShiftLeft();
@@ -562,6 +564,8 @@ public:
 CPPUNIT_TEST(testFormulaRefUpdateMove);
 CPPUNIT_TEST(testFormulaRefUpdateMoveUndo);
 CPPUNIT_TEST(testFormulaRefUpdateMoveUndo2);
+CPPUNIT_TEST(testFormulaRefUpdateMoveUndo3NonShared);
+CPPUNIT_TEST(testFormulaRefUpdateMoveUndo3Shared);
 CPPUNIT_TEST(testFormulaRefUpdateMoveToSheet);
 CPPUNIT_TEST(testFormulaRefUpdateDeleteContent);
 CPPUNIT_TEST(testFormulaRefUpdateDeleteAndShiftLeft);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 223b88dd1f2f..3f04ff0a0c45 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2316,6 +2316,132 @@ void Test::testFormulaRefUpdateMoveUndo2()
 m_pDoc->DeleteTab(0);
 }
 
+void Test::testFormulaRefUpdateMoveUndo3NonShared()
+{
+m_pDoc->InsertTab(0, "Test");
+
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+std::vector aData = {
+{ "10",   nullptr,  nullptr },
+{ "=A1",  nullptr,  nullptr },
+{ "=A2+A1",   nullptr,  nullptr },
+};
+
+ScRange aOutRange = insertRangeData(m_pDoc, ScAddress(0,0,0), aData);
+
+std::vector aCheckInitial = {
+{ "10", nullptr,  nullptr },
+{ "10", nullptr,  nullptr },
+{ "20", nullptr,  nullptr },
+};
+
+bool bGood = checkOutput(m_pDoc, aOutRange, aCheckInitial, "initial data");
+CPPUNIT_ASSERT(bGood);
+
+// Drag A2:A3 into C2:C3.
+ScDocFunc& rFunc = getDocShell().GetDocFunc();
+bool bMoved = rFunc.MoveBlock(ScRange(0,1,0,0,2,0), ScAddress(2,1,0), 
true, true, false, true);
+CPPUNIT_ASSERT(bMoved);
+
+std::vector aCheckAfter = {
+{ "10",nullptr, nullptr},
+{ nullptr, nullptr, "10" },
+{ nullptr, nullptr, "20" },
+};
+
+bGood = checkOutput(m_pDoc, aOutRange, aCheckAfter, "A2:A3 moved to 
C2:C3");
+CPPUNIT_ASSERT(bGood);
+
+// Undo the move.
+SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
+CPPUNIT_ASSERT(pUndoMgr);
+pUndoMgr->Undo();
+
+bGood = checkOutput(m_pDoc, aOutRange, aCheckInitial, "after undo");
+CPPUNIT_ASSERT(bGood);
+
+// Redo and check.
+pUndoMgr->Redo();
+
+bGood = checkOutput(m_pDoc, aOutRange, aCheckAfter, "after redo");
+CPPUNIT_ASSERT(bGood);
+
+m_pDoc->DeleteTab(0);
+}
+
+void Test::testFormulaRefUpdateMoveUndo3Shared()
+{
+m_pDoc->InsertTab(0, "Test");
+
+sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+std::vector aData = {
+{ "10",   nullptr,  nullptr },
+{ "=A1",  nullptr,  nullptr },
+{ "=A2+$A$1", nullptr,  nullptr },
+{ "=A3+$A$1", nullptr,  nullptr },
+};
+
+ScRange aOutRange = insertRangeData(m_pDoc, ScAddress(0,0,0), aData);
+
+std::vector aCheckInitial = {
+{ "10", nullptr,  nullptr },
+{ "10", nullptr,  nullptr },
+{ "20", nullptr,  nullptr },
+{ "30", nullptr,  nullptr },
+};
+
+bool bGood = checkOutput(m_pDoc, aOutRange, aCheckInitial, "initial data");
+CPPUNIT_ASSERT(bGood);
+
+// A3:A4 should be grouped.
+const ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(0,2,0));
+CPPUNIT_ASSERT(pFC);
+CPPUNIT_ASSERT_EQUAL(SCROW(2), 

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

2017-05-26 Thread Justin Luth
 sc/qa/unit/data/ods/tdf99856_dataValidationTest.ods |binary
 sc/qa/unit/subsequent_export-test.cxx   |   24 
 sc/source/filter/excel/xecontent.cxx|   10 
 3 files changed, 34 insertions(+)

New commits:
commit 21b7cb2737d95f281e28e248c4dad306a5c6463f
Author: Justin Luth 
Date:   Thu May 25 20:47:03 2017 +0300

tdf#99856 xlsx export: limit dataValidation list to 255 chars

Excel consider the file corrupt if it has an overly long
validation list.

includes followup commit b56d1e294d838d4b3d0f237c81325a0d1a1cff83

Change-Id: I4145859d4f76e0a70521c7bee33c96927b437ace
Reviewed-on: https://gerrit.libreoffice.org/38038
Reviewed-by: Justin Luth 
Tested-by: Jenkins 
Reviewed-by: Katarina Behrens 
Reviewed-on: https://gerrit.libreoffice.org/38053

diff --git a/sc/qa/unit/data/ods/tdf99856_dataValidationTest.ods 
b/sc/qa/unit/data/ods/tdf99856_dataValidationTest.ods
new file mode 100644
index ..b5e036e9b1f8
Binary files /dev/null and 
b/sc/qa/unit/data/ods/tdf99856_dataValidationTest.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 49e52a512a88..253134d5d29f 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -43,6 +43,7 @@
 #include 
 #include 
 #include 
+#include "validat.hxx"
 
 #include 
 #include 
@@ -94,6 +95,7 @@ public:
 void testPasswordExportODS();
 void testConditionalFormatExportODS();
 void testConditionalFormatExportXLSX();
+void testTdf99856_dataValidationTest();
 void testColorScaleExportODS();
 void testColorScaleExportXLSX();
 void testDataBarExportODS();
@@ -201,6 +203,7 @@ public:
 CPPUNIT_TEST(testPasswordExportODS);
 CPPUNIT_TEST(testConditionalFormatExportODS);
 CPPUNIT_TEST(testConditionalFormatExportXLSX);
+CPPUNIT_TEST(testTdf99856_dataValidationTest);
 CPPUNIT_TEST(testColorScaleExportODS);
 CPPUNIT_TEST(testColorScaleExportXLSX);
 CPPUNIT_TEST(testDataBarExportODS);
@@ -451,6 +454,27 @@ void ScExportTest::testConditionalFormatExportXLSX()
 xDocSh->DoClose();
 }
 
+void ScExportTest::testTdf99856_dataValidationTest()
+{
+ScDocShellRef xShell = loadDoc("tdf99856_dataValidationTest.", FORMAT_ODS);
+CPPUNIT_ASSERT_MESSAGE("Failed to load doc", xShell.is());
+
+ScDocShellRef xDocSh = saveAndReload( xShell.get(), FORMAT_XLSX);
+CPPUNIT_ASSERT_MESSAGE("Failed to reload doc", xDocSh.is());
+
+ScDocument& rDoc = xDocSh->GetDocument();
+const ScValidationData* pData = rDoc.GetValidationEntry(2);
+CPPUNIT_ASSERT(pData);
+
+// Excel can't open corrupt file if the list is longer than 255 characters
+std::vector aList;
+pData->FillSelectionList(aList, ScAddress(0, 1, 1));
+CPPUNIT_ASSERT_EQUAL(size_t(18), aList.size());
+CPPUNIT_ASSERT_EQUAL(OUString("18 Missis"), aList[17].GetString());
+
+xDocSh->DoClose();
+}
+
 void ScExportTest::testColorScaleExportODS()
 {
 ScDocShellRef xShell = loadDoc("colorscale.", FORMAT_ODS);
diff --git a/sc/source/filter/excel/xecontent.cxx 
b/sc/source/filter/excel/xecontent.cxx
index 81fe1e9a922b..706dcb67b9ec 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1671,6 +1671,16 @@ XclExpDV::XclExpDV( const XclExpRoot& rRoot, sal_uLong 
nScHandle ) :
 }
 ::set_flag( mnFlags, EXC_DV_STRINGLIST );
 
+// maximum length allowed in Excel is 255 characters, and 
don't end with an empty token
+sal_uInt32 nLen = sFormulaBuf.getLength();
+if( nLen > 256 )  // 255 + beginning quote mark
+{
+nLen = 256;
+if( sFormulaBuf[nLen - 1] == ',' )
+--nLen;
+sFormulaBuf = sFormulaBuf.copy(0, nLen);
+}
+
 sFormulaBuf.append( '"' );
 msFormula1 = sFormulaBuf.makeStringAndClear();
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-05-25 Thread Justin Luth
 sc/qa/unit/data/xlsb/tdf108017_calcProtection.xlsb |binary
 sc/qa/unit/subsequent_export-test.cxx  |   37 ++---
 sc/source/filter/oox/worksheetsettings.cxx |   30 -
 3 files changed, 41 insertions(+), 26 deletions(-)

New commits:
commit 47f3d3521c364a9133da26d3202225dc414662fb
Author: Justin Luth 
Date:   Tue May 23 15:35:13 2017 +0300

tdf#108017 xlsb import: protection settings were reversed

Back in LO4.3, commit 5728a56b20e01d6c9e86a23f20af64a1b68ad604
fdo#70499 selectn of lock/unlocked cells with worksheet protection reversed

...reversed finalizeImport's understanding of maSheetProt.* to match
xml import, but then it no longer matched the binary stream import.
So, .xlsb imported the opposite of what .xlsx/.xlsm imported.

Change-Id: I2da3967ef52187e4ef36ce7d01b17a4672f61e1c
Reviewed-on: https://gerrit.libreoffice.org/37952
Tested-by: Jenkins 
Reviewed-by: Justin Luth 
Reviewed-by: Markus Mohrhard 
(cherry picked from commit 0d3fcbf809852aab0d0f88272bbfd2e8507d1c5e)
Reviewed-on: https://gerrit.libreoffice.org/38041

diff --git a/sc/qa/unit/data/xlsb/tdf108017_calcProtection.xlsb 
b/sc/qa/unit/data/xlsb/tdf108017_calcProtection.xlsb
new file mode 100644
index ..31661ba009a8
Binary files /dev/null and b/sc/qa/unit/data/xlsb/tdf108017_calcProtection.xlsb 
differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 989623b065bc..49e52a512a88 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -127,6 +127,7 @@ public:
 
 void testFormulaReferenceXLS();
 void testSheetProtectionXLSX();
+void testSheetProtectionXLSB();
 
 void testCellBordersXLS();
 void testCellBordersXLSX();
@@ -234,6 +235,7 @@ public:
 
 CPPUNIT_TEST(testFormulaReferenceXLS);
 CPPUNIT_TEST(testSheetProtectionXLSX);
+CPPUNIT_TEST(testSheetProtectionXLSB);
 CPPUNIT_TEST(testCellBordersXLS);
 CPPUNIT_TEST(testCellBordersXLSX);
 CPPUNIT_TEST(testBordersExchangeXLSX);
@@ -1919,19 +1921,32 @@ void ScExportTest::testSheetProtectionXLSX()
 ScDocument& rDoc = xDocSh->GetDocument();
 const ScTableProtection* pTabProtect = rDoc.GetTabProtection(0);
 CPPUNIT_ASSERT(pTabProtect);
-if ( pTabProtect )
+Sequence aHash = pTabProtect->getPasswordHash(PASSHASH_XL);
+// check has
+if (aHash.getLength() >= 2)
 {
-Sequence aHash = pTabProtect->getPasswordHash(PASSHASH_XL);
-// check has
-if (aHash.getLength() >= 2)
-{
-CPPUNIT_ASSERT_EQUAL(sal_uInt8(204), (sal_uInt8)aHash[0]);
-CPPUNIT_ASSERT_EQUAL(sal_uInt8(61), (sal_uInt8)aHash[1]);
-}
-// we could flesh out this check I guess
-CPPUNIT_ASSERT ( !pTabProtect->isOptionEnabled( 
ScTableProtection::OBJECTS ) );
-CPPUNIT_ASSERT ( !pTabProtect->isOptionEnabled( 
ScTableProtection::SCENARIOS ) );
+CPPUNIT_ASSERT_EQUAL(sal_uInt8(204), (sal_uInt8)aHash[0]);
+CPPUNIT_ASSERT_EQUAL(sal_uInt8(61), (sal_uInt8)aHash[1]);
 }
+// we could flesh out this check I guess
+CPPUNIT_ASSERT ( !pTabProtect->isOptionEnabled( ScTableProtection::OBJECTS 
) );
+CPPUNIT_ASSERT ( !pTabProtect->isOptionEnabled( 
ScTableProtection::SCENARIOS ) );
+xDocSh->DoClose();
+}
+
+void ScExportTest::testSheetProtectionXLSB()
+{
+ScDocShellRef xShell = loadDoc("tdf108017_calcProtection.", FORMAT_XLSB);
+CPPUNIT_ASSERT(xShell.is());
+
+ScDocShellRef xDocSh = saveAndReload(xShell.get(), FORMAT_XLSX);
+CPPUNIT_ASSERT(xDocSh.is());
+
+ScDocument& rDoc = xDocSh->GetDocument();
+const ScTableProtection* pTabProtect = rDoc.GetTabProtection(0);
+CPPUNIT_ASSERT(pTabProtect);
+CPPUNIT_ASSERT(pTabProtect->isOptionEnabled( 
ScTableProtection::SELECT_UNLOCKED_CELLS ));
+CPPUNIT_ASSERT(!pTabProtect->isOptionEnabled( 
ScTableProtection::SELECT_LOCKED_CELLS ));
 xDocSh->DoClose();
 }
 
diff --git a/sc/source/filter/oox/worksheetsettings.cxx 
b/sc/source/filter/oox/worksheetsettings.cxx
index f83a759d33fd..896df326e39c 100644
--- a/sc/source/filter/oox/worksheetsettings.cxx
+++ b/sc/source/filter/oox/worksheetsettings.cxx
@@ -205,21 +205,21 @@ void WorksheetSettings::importSheetProtection( 
SequenceInputStream& rStrm )
 maSheetProt.mnPasswordHash = rStrm.readuInt16();
 // no flags field for all these boolean flags?!?
 maSheetProt.mbSheet= rStrm.readInt32() != 0;
-maSheetProt.mbObjects  = rStrm.readInt32() != 0;
-maSheetProt.mbScenarios= rStrm.readInt32() != 0;
-maSheetProt.mbFormatCells  = rStrm.readInt32() != 0;
-maSheetProt.mbFormatColumns= rStrm.readInt32() != 0;
-maSheetProt.mbFormatRows   = rStrm.readInt32() != 0;
-