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

2023-11-29 Thread Stephan Bergmann (via logerrit)
 sc/qa/unit/tiledrendering/tiledrendering.cxx   |   14 +++---
 sc/source/filter/excel/export/SparklineExt.cxx |2 +-
 sc/source/filter/excel/xeescher.cxx|4 ++--
 sc/source/filter/excel/xepivotxml.cxx  |   14 +++---
 sc/source/filter/lotus/lotform.cxx |2 +-
 sc/source/ui/view/tabvwshc.cxx |6 +++---
 6 files changed, 21 insertions(+), 21 deletions(-)

New commits:
commit f4ce98bd1a1b183bb21c60b85e17dc6575f9ce98
Author: Stephan Bergmann 
AuthorDate: Wed Nov 29 14:39:38 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Nov 29 19:59:49 2023 +0100

Extended loplugin:ostr: sc

Change-Id: I2b69249d6e0e35945e37e04ea885bb8ab3e781f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160103
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index b27664e5df41..b33960af5f22 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -173,7 +173,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testRowColumnSelections)
 
 // Check if all the rows from 5th to 10th get selected
 aResult = 
apitest::helper::transferable::getTextSelection(pModelObj->getSelection(), 
"text/plain;charset=utf-8"_ostr);
-aExpected = 
"1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\n2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\n3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\n4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\n5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\t25\n6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\t25\t26\n";
+aExpected = 
"1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\n2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\n3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\n4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\n5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\t25\n6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\t22\t23\t24\t25\t26\n"_ostr;
 CPPUNIT_ASSERT_EQUAL(aExpected, aResult);
 
 // Select the 10th row with ctrl modifier
@@ -218,7 +218,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testRowColumnSelections)
 
 //  only row 5 should remain selected
 aResult = 
apitest::helper::transferable::getTextSelection(pModelObj->getSelection(), 
"text/plain;charset=utf-8"_ostr);
-aExpected = 
"1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\n";
+aExpected = 
"1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\t15\t16\t17\t18\t19\t20\t21\n"_ostr;
 CPPUNIT_ASSERT_EQUAL(aExpected, aResult);
 }
 
@@ -2305,7 +2305,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testDeleteCellMultilineContent)
 ViewCallback aView1;
 CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
 
-aView1.m_sInvalidateHeader = "";
+aView1.m_sInvalidateHeader = ""_ostr;
 ScDocument& rDoc = pDocSh->GetDocument();
 sal_uInt16 nRow1Height = rDoc.GetRowHeight(static_cast(0), 
static_cast(0), false);
 
@@ -2370,7 +2370,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testPasteIntoWrapTextCell)
 // Go to A2 and paste.
 pView->SetCursor(0, 1);
 Scheduler::ProcessEventsToIdle();
-aView.m_sInvalidateSheetGeometry = "";
+aView.m_sInvalidateSheetGeometry = ""_ostr;
 pView->GetViewFrame().GetBindings().Execute(SID_PASTE);
 Scheduler::ProcessEventsToIdle();
 
@@ -2399,7 +2399,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testPasteIntoWrapTextCell)
 // Go to A3 and paste.
 pView->SetCursor(0, 2);
 Scheduler::ProcessEventsToIdle();
-aView.m_sInvalidateSheetGeometry = "";
+aView.m_sInvalidateSheetGeometry = ""_ostr;
 pView->GetViewFrame().GetBindings().Execute(SID_PASTE);
 Scheduler::ProcessEventsToIdle();
 
@@ -2424,7 +2424,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testSortAscendingDescending)
 pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEMOVE, 820, 1336, 1, 
MOUSE_LEFT, 0);
 pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, 820, 1359, 1, 
MOUSE_LEFT, 0);
 Scheduler::ProcessEventsToIdle();
-aView.m_sInvalidateSheetGeometry = "";
+aView.m_sInvalidateSheetGeometry = ""_ostr;
 
 // sort ascending
 uno::Sequence aArgs;
@@ -2439,7 +2439,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testSortAscendingDescending)
 Scheduler::ProcessEventsToIdle();
 CPPUNIT_ASSERT_EQUAL("rows"_ostr, aView.m_sInvalidateSheetGeometry);
 
-aView.m_sInvalidateSheetGeometry = "";
+aView.m_sInvalidateSheetGeometry = ""_ostr;
 // sort descending
 dispatchCommand(mxComponent, ".uno:SortDescending", aArgs);
 
diff --git 

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

2023-11-19 Thread Stephan Bergmann (via logerrit)
 sc/qa/extras/htmlexporttest.cxx  |   14 
 sc/qa/extras/macros-test.cxx |8 
 sc/qa/unit/SparklineImportExportTest.cxx |   67 +-
 sc/qa/unit/ThemeImportExportTest.cxx |   62 +-
 sc/qa/unit/dataproviders_test.cxx|6 
 sc/qa/unit/jumbosheets-test.cxx  |   14 
 sc/qa/unit/pivottable_filters_test.cxx   |  687 ++-
 sc/qa/unit/screenshots/screenshots.cxx   |   30 -
 sc/qa/unit/subsequent_export_test.cxx|  560 +++---
 sc/qa/unit/subsequent_export_test2.cxx   |  377 --
 sc/qa/unit/subsequent_export_test3.cxx   |  138 ++---
 sc/qa/unit/subsequent_export_test4.cxx   |  318 ++--
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   42 -
 sc/qa/unit/ucalc_copypaste.cxx   |   10 
 sc/source/core/data/document10.cxx   |2 
 sc/source/core/data/table7.cxx   |4 
 sc/source/filter/excel/xecontent.cxx |   18 
 sc/source/filter/excel/xeescher.cxx  |2 
 sc/source/filter/excel/xeextlst.cxx  |   16 
 sc/source/filter/excel/xepivotxml.cxx|   24 
 sc/source/filter/excel/xeview.cxx|2 
 sc/source/filter/html/htmlexp.cxx|2 
 sc/source/ui/app/inputhdl.cxx|6 
 sc/source/ui/app/scmod.cxx   |2 
 sc/source/ui/unoobj/docuno.cxx   |8 
 sc/source/ui/view/drawview.cxx   |2 
 sc/source/ui/view/gridwin.cxx|   26 -
 sc/source/ui/view/tabview3.cxx   |2 
 sc/source/ui/view/tabvwsh4.cxx   |8 
 29 files changed, 1310 insertions(+), 1147 deletions(-)

New commits:
commit 099be392bfc5ddba21370726fa887a2fd6c99cd5
Author: Stephan Bergmann 
AuthorDate: Sun Nov 19 17:31:36 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Sun Nov 19 20:38:33 2023 +0100

Extended loplugin:ostr: sc

Change-Id: I44536a13f4c31558671c1166d06b7f6216456641
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159680
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sc/qa/extras/htmlexporttest.cxx b/sc/qa/extras/htmlexporttest.cxx
index 6e28d791fbb3..774f75078a85 100644
--- a/sc/qa/extras/htmlexporttest.cxx
+++ b/sc/qa/extras/htmlexporttest.cxx
@@ -38,16 +38,16 @@ public:
 htmlDocUniquePtr pDoc = parseHtml(maTempFile);
 CPPUNIT_ASSERT (pDoc);
 
-assertXPath(pDoc, "/html/body", 1);
-assertXPath(pDoc, "/html/body/table/tr/td/img", 1);
+assertXPath(pDoc, "/html/body"_ostr, 1);
+assertXPath(pDoc, "/html/body/table/tr/td/img"_ostr, 1);
 
 setFilterOptions("SkipImages");
 save("HTML (StarCalc)");
 
 pDoc = parseHtml(maTempFile);
 CPPUNIT_ASSERT (pDoc);
-assertXPath(pDoc, "/html/body", 1);
-assertXPath(pDoc, "/html/body/table/tr/td/img", 0);
+assertXPath(pDoc, "/html/body"_ostr, 1);
+assertXPath(pDoc, "/html/body/table/tr/td/img"_ostr, 0);
 }
 
 void testTdf155244()
@@ -58,10 +58,10 @@ public:
 xmlDocUniquePtr pXmlDoc = parseXml(maTempFile);
 CPPUNIT_ASSERT(pXmlDoc);
 
-assertXPath(pXmlDoc, "/xhtml:html", 1);
+assertXPath(pXmlDoc, "/xhtml:html"_ostr, 1);
 // the problem was that there were 2 CSS styles named "Default"
-assertXPath(pXmlDoc, 
"/xhtml:html/xhtml:body/xhtml:table/xhtml:tr/xhtml:td", "class", 
"cell-Default");
-OUString const styles = getXPathContent(pXmlDoc, 
"/xhtml:html/xhtml:head/xhtml:style");
+assertXPath(pXmlDoc, 
"/xhtml:html/xhtml:body/xhtml:table/xhtml:tr/xhtml:td"_ostr, "class"_ostr, 
"cell-Default");
+OUString const styles = getXPathContent(pXmlDoc, 
"/xhtml:html/xhtml:head/xhtml:style"_ostr);
 CPPUNIT_ASSERT(styles.indexOf(".graphic-Default{ 
background-color:#729fcf;") != -1);
 CPPUNIT_ASSERT(styles.indexOf(".cell-Default{ font-size:10pt; 
font-family:'Liberation Sans'; }") != -1);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), styles.indexOf(".Default"));
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index f1602465f7d2..c483a05c9300 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -167,13 +167,13 @@ CPPUNIT_TEST_FIXTURE(ScMacrosTest, 
testMacroButtonFormControlXlsxExport)
 // Without the fix in place, this test would have failed with:
 // - XPath '//x:controlPr' no attribute 'macro' exist
 // i.e. the macro was lost on export.
-assertXPath(pSheetDoc, "//x:controlPr", "macro", "Module1.Button1_Click");
+assertXPath(pSheetDoc, "//x:controlPr"_ostr, "macro"_ostr, 
"Module1.Button1_Click");
 
 // Then also make sure that there is no defined name for the macro, which 
is only needed for
 // XLS:
 xmlDocUniquePtr pWorkbookDoc = parseExport("xl/workbook.xml");
 CPPUNIT_ASSERT(pWorkbookDoc);
-assertXPath(pWorkbookDoc, "//x:workbook/definedNames", 0);

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

2023-10-26 Thread Andreas Heinisch (via logerrit)
 sc/qa/unit/uicalc/data/tdf157897_linked.ods |binary
 sc/qa/unit/uicalc/data/tdf157897_main.ods   |binary
 sc/qa/unit/uicalc/uicalc.cxx|   18 ++
 sc/source/core/data/documen2.cxx|2 ++
 4 files changed, 20 insertions(+)

New commits:
commit 96b91357fb93028d35d70bdb52b4bac3ecbfbf57
Author: Andreas Heinisch 
AuthorDate: Mon Oct 23 23:13:51 2023 +0200
Commit: Andreas Heinisch 
CommitDate: Thu Oct 26 18:41:49 2023 +0200

tdf#157897 - Clear print ranges before adding additional ones

Otherwise, additional print ranges will be added for linked files after
the external link will be updated.

Change-Id: I0556fda6609d3e18f1ca992dc6a0399be01bc841
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158365
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/unit/uicalc/data/tdf157897_linked.ods 
b/sc/qa/unit/uicalc/data/tdf157897_linked.ods
new file mode 100755
index ..bb75c31d82ae
Binary files /dev/null and b/sc/qa/unit/uicalc/data/tdf157897_linked.ods differ
diff --git a/sc/qa/unit/uicalc/data/tdf157897_main.ods 
b/sc/qa/unit/uicalc/data/tdf157897_main.ods
new file mode 100755
index ..1e1af575145f
Binary files /dev/null and b/sc/qa/unit/uicalc/data/tdf157897_main.ods differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 4259f56a..15795baceaa1 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -1395,6 +1395,24 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf146994)
 CPPUNIT_ASSERT_EQUAL(OUString("Sheet1.D3:Sheet1.D4"), aMarkedAreaString);
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf157897_duplicated_print_ranges)
+{
+createScDoc("tdf157897_main.ods");
+ScDocument* pDoc = getScDoc();
+
+const sal_uInt16 nPos = 0;
+const SCTAB nFirstTab = 0;
+// Ensure that there exists a print range in the first documents tab
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
pDoc->GetPrintRangeCount(nFirstTab));
+
+// Reload all links and check if the print range was not duplicated
+const auto initialPrintRange = pDoc->GetPrintRange(nFirstTab, nPos);
+pDoc->GetDocumentShell()->ReloadAllLinks();
+
+// Without the fix in place, the print range in the linked tab will be 
duplicated
+CPPUNIT_ASSERT_EQUAL(initialPrintRange, pDoc->GetPrintRange(nFirstTab, 
nPos));
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf154991)
 {
 createScDoc("tdf154991.ods");
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 4b07b0d33ff5..c53dc6b3e305 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1040,6 +1040,8 @@ sal_uLong ScDocument::TransferTab( ScDocument& rSrcDoc, 
SCTAB nSrcPos,
 maTabs[nDestPos]->SetPrintEntireSheet();
 else
 {
+// tdf#157897 - clear print ranges before adding additional ones
+maTabs[nDestPos]->ClearPrintRanges();
 const auto nPrintRangeCount = 
rSrcDoc.maTabs[nSrcPos]->GetPrintRangeCount();
 for (auto nPos = 0; nPos < nPrintRangeCount; nPos++)
 {


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

2023-10-20 Thread Stephan Bergmann (via logerrit)
 sc/qa/extras/macros-test.cxx |   12 ++--
 sc/qa/unit/ThemeImportExportTest.cxx |2 
 sc/qa/unit/helper/shared_test_impl.hxx   |2 
 sc/qa/unit/screenshots/screenshots.cxx   |2 
 sc/qa/unit/ucalc.cxx |2 
 sc/source/core/data/dpobject.cxx |2 
 sc/source/core/data/tabprotection.cxx|6 +-
 sc/source/core/tool/addincol.cxx |6 +-
 sc/source/core/tool/autoform.cxx |2 
 sc/source/core/tool/compiler.cxx |6 +-
 sc/source/core/tool/stylehelper.cxx  |2 
 sc/source/filter/excel/xechart.cxx   |2 
 sc/source/filter/excel/xestream.cxx  |2 
 sc/source/filter/excel/xiescher.cxx  |4 -
 sc/source/filter/oox/defnamesbuffer.cxx  |2 
 sc/source/filter/oox/pagesettings.cxx|4 -
 sc/source/filter/oox/querytablebuffer.cxx|2 
 sc/source/filter/xcl97/xcl97esc.cxx  |2 
 sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx   |2 
 sc/source/filter/xml/XMLCodeNameProvider.cxx |4 -
 sc/source/filter/xml/XMLExportDatabaseRanges.cxx |2 
 sc/source/filter/xml/XMLStylesExportHelper.cxx   |2 
 sc/source/filter/xml/xmlexprt.cxx|8 +--
 sc/source/filter/xml/xmlimprt.cxx|4 -
 sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx  |2 
 sc/source/ui/StatisticsDialogs/FourierAnalysisDialog.cxx |2 
 sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx |2 
 sc/source/ui/dbgui/csvruler.cxx  |4 -
 sc/source/ui/docshell/datastream.cxx |2 
 sc/source/ui/docshell/docsh.cxx  |   10 +--
 sc/source/ui/docshell/docsh4.cxx |8 +--
 sc/source/ui/docshell/docsh8.cxx |   14 ++---
 sc/source/ui/docshell/impex.cxx  |2 
 sc/source/ui/miscdlgs/linkarea.cxx   |4 -
 sc/source/ui/miscdlgs/solverutil.cxx |2 
 sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx |4 -
 sc/source/ui/unoobj/afmtuno.cxx  |2 
 sc/source/ui/unoobj/appluno.cxx  |6 +-
 sc/source/ui/unoobj/cellsuno.cxx |   18 +++
 sc/source/ui/unoobj/confuno.cxx  |2 
 sc/source/ui/unoobj/cursuno.cxx  |4 -
 sc/source/ui/unoobj/dapiuno.cxx  |2 
 sc/source/ui/unoobj/dispuno.cxx  |2 
 sc/source/ui/unoobj/docuno.cxx   |8 +--
 sc/source/ui/unoobj/filtuno.cxx  |   10 +--
 sc/source/ui/unoobj/funcuno.cxx  |4 -
 sc/source/ui/unoobj/nameuno.cxx  |2 
 sc/source/ui/unoobj/shapeuno.cxx |8 +--
 sc/source/ui/unoobj/srchuno.cxx  |4 -
 sc/source/ui/unoobj/styleuno.cxx |   16 +++---
 sc/source/ui/unoobj/viewuno.cxx  |4 -
 sc/source/ui/vba/vbaaxis.cxx |6 +-
 sc/source/ui/vba/vbaborders.cxx  |2 
 sc/source/ui/vba/vbachart.cxx|   28 +--
 sc/source/ui/vba/vbaformat.cxx   |4 -
 sc/source/ui/vba/vbainterior.cxx |6 +-
 sc/source/ui/vba/vbarange.cxx|   12 ++--
 sc/source/ui/vba/vbasheetobject.cxx  |4 -
 sc/source/ui/vba/vbastyle.cxx|2 
 sc/source/ui/view/formatsh.cxx   |2 
 sc/source/ui/view/viewdata.cxx   |2 
 61 files changed, 150 insertions(+), 150 deletions(-)

New commits:
commit da3a91e89f803d1c42b764c90071b30b547e686b
Author: Stephan Bergmann 
AuthorDate: Thu Oct 19 10:30:24 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Oct 20 09:45:32 2023 +0200

Extended loplugin:ostr: Automatic rewrite O[U]StringLiteral: sc

Change-Id: Ieed908bfa2cb6370ead922dfc00dbdb4f905f3cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158216
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index d8590804a165..f1602465f7d2 100644
--- 

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

2023-08-31 Thread Tibor Nagy (via logerrit)
 sc/qa/unit/data/ods/tdf150815.ods   |binary
 sc/qa/unit/subsequent_filters_test3.cxx |   22 +-
 sc/source/ui/inc/viewfunc.hxx   |4 ++--
 sc/source/ui/view/viewfunc.cxx  |   22 ++
 4 files changed, 45 insertions(+), 3 deletions(-)

New commits:
commit d1411afab98f7b41e9e700ef26b43dc77242d917
Author: Tibor Nagy 
AuthorDate: Wed Aug 30 16:22:02 2023 +0200
Commit: László Németh 
CommitDate: Thu Aug 31 18:01:33 2023 +0200

tdf#150815 sc: fix repainting sparkline

On Windows, if the input range of the sparkline is not in the
same row as the output range, the sparkline wasn't repainted
after changing the data within its range. Force the update
to avoid of showing obsolete data.

Change-Id: Id56209b20387ee68144507a0102d3a0d093ff1ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156304
Reviewed-by: László Németh 
Tested-by: László Németh 

diff --git a/sc/qa/unit/data/ods/tdf150815.ods 
b/sc/qa/unit/data/ods/tdf150815.ods
new file mode 100644
index ..2dd407b6cea5
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf150815.ods differ
diff --git a/sc/qa/unit/subsequent_filters_test3.cxx 
b/sc/qa/unit/subsequent_filters_test3.cxx
index d277e0858905..ff19d3d55c3c 100644
--- a/sc/qa/unit/subsequent_filters_test3.cxx
+++ b/sc/qa/unit/subsequent_filters_test3.cxx
@@ -393,7 +393,8 @@ struct PaintListener : public SfxListener
 {
 if ((pPaintHint->GetStartCol() <= 0 && pPaintHint->GetEndCol() >= 
0)
 && ((pPaintHint->GetStartRow() <= 9 && pPaintHint->GetEndRow() 
>= 9)
-|| (pPaintHint->GetStartRow() == 2 && 
pPaintHint->GetEndRow() == 3)))
+|| (pPaintHint->GetStartRow() == 2 && 
pPaintHint->GetEndRow() == 3)
+|| (pPaintHint->GetStartRow() == 1 && 
pPaintHint->GetEndRow() == 1)))
 {
 mbCalled = true;
 }
@@ -441,6 +442,25 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf131471)
 CPPUNIT_ASSERT(aListener.mbCalled);
 }
 
+CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf150815_RepaintSparkline)
+{
+createScDoc("ods/tdf150815.ods");
+
+ScDocument* pDoc = getScDoc();
+ScDocShell* pDocSh = getScDocShell();
+
+PaintListener aListener;
+aListener.StartListening(*pDocSh);
+
+auto pSparkline = pDoc->GetSparkline(ScAddress(0, 1, 0));
+CPPUNIT_ASSERT(pSparkline);
+
+ScTabViewShell* pViewShell = getViewShell();
+pViewShell->EnterData(0, 0, 0, "10");
+
+CPPUNIT_ASSERT(aListener.mbCalled);
+}
+
 CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf137091)
 {
 // Set the system locale to Turkish
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 0d8d7515441a..323e7cbbe793 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -90,8 +90,8 @@ public:
 boolAutoSum( const ScRange& rRange, bool bSubTotal, bool 
bSetCursor, bool bContinue, const OpCode eCode );
 OUStringGetAutoSumFormula( const ScRangeList& rRangeList, bool 
bSubTotal, const ScAddress& rAddr, const OpCode eCode );
 
-voidEnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const 
OUString& rString,
-   const EditTextObject* pData = nullptr, bool 
bMatrixExpand = false );
+SC_DLLPUBLIC void EnterData(SCCOL nCol, SCROW nRow, SCTAB nTab, const 
OUString& rString,
+const EditTextObject* pData = nullptr, bool 
bMatrixExpand = false);
 voidEnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
const EditTextObject& rData, bool bTestSimple = 
false );
 voidEnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const 
double& rValue );
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 13c4ce63c6e7..af0dc57357f9 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -77,6 +77,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -103,6 +104,26 @@ static void lcl_PostRepaintCondFormat( const 
ScConditionalFormat *pCondFmt, ScDo
 }
 }
 
+static void lcl_PostRepaintSparkLine(sc::SparklineList* pSparklineList, const 
ScRange& rRange,
+ ScDocShell* pDocSh)
+{
+if (pSparklineList)
+{
+for (auto& rSparkLineGroup : pSparklineList->getSparklineGroups())
+{
+for (auto& rSparkline : 
pSparklineList->getSparklinesFor(rSparkLineGroup))
+{
+if (rSparkline->getInputRange().Contains(rRange))
+{
+pDocSh->PostPaint(
+ScRange(rSparkline->getColumn(), rSparkline->getRow(), 
rRange.aStart.Tab()),
+PaintPartFlags::All, SC_PF_TESTMERGE);
+}
+}
+}
+}
+}
+
 ScViewFunc::ScViewFunc( vcl::Window* pParent, ScDocShell& 

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

2023-08-28 Thread Paris Oplopoios (via logerrit)
 sc/qa/unit/subsequent_export_test3.cxx   |3 +--
 sc/source/filter/oox/sheetdatabuffer.cxx |2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

New commits:
commit 16d43b7c5396d6382926d514dc9ce10b3ce94cba
Author: Paris Oplopoios 
AuthorDate: Mon Aug 28 20:40:33 2023 +0300
Commit: Paris Oplopoios 
CommitDate: Mon Aug 28 22:12:43 2023 +0200

Shared string shouldn't account preserve space property

XLSX documents opened in Excel don't seem to account for the
xml:space="preserve" value for whether the string is single line or not

The test that was changed seems to have more accurate behavior now,
where the second cell does not have multiple lines (like in Excel)

Change-Id: Iad8f351c19102249e2cb1e1d063c8690dfb3d753
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156206
Tested-by: Jenkins
Reviewed-by: Paris Oplopoios 

diff --git a/sc/qa/unit/subsequent_export_test3.cxx 
b/sc/qa/unit/subsequent_export_test3.cxx
index ff8a27727a1b..45e65cf8bed8 100644
--- a/sc/qa/unit/subsequent_export_test3.cxx
+++ b/sc/qa/unit/subsequent_export_test3.cxx
@@ -1424,8 +1424,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest3, 
testPreserveTextWhitespace2XLSX)
 xmlDocUniquePtr pDoc = parseExport("xl/sharedStrings.xml");
 CPPUNIT_ASSERT(pDoc);
 assertXPath(pDoc, "/x:sst/x:si[1]/x:t", "space", "preserve");
-assertXPath(pDoc, "/x:sst/x:si[2]/x:r[1]/x:t", "space", "preserve");
-assertXPath(pDoc, "/x:sst/x:si[2]/x:r[2]/x:t", "space", "preserve");
+assertXPath(pDoc, "/x:sst/x:si[2]/x:t", "space", "preserve");
 }
 
 CPPUNIT_TEST_FIXTURE(ScExportTest3, testHiddenShapeXLS)
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx 
b/sc/source/filter/oox/sheetdatabuffer.cxx
index 76721ded0d17..d1410eb04970 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -122,7 +122,7 @@ void SheetDataBuffer::setStringCell( const CellModel& 
rModel, const RichStringRe
 OSL_ENSURE( rxString, "SheetDataBuffer::setStringCell - missing rich 
string object" );
 const oox::xls::Font* pFirstPortionFont = getStyles().getFontFromCellXf( 
rModel.mnXfId ).get();
 const Xf* pXf = getStyles().getCellXf( rModel.mnXfId ).get();
-bool bSingleLine = pXf ? !rxString->isPreserveSpace() && 
!pXf->getAlignment().getModel().mbWrapText : false;
+bool bSingleLine = pXf ? !pXf->getAlignment().getModel().mbWrapText : 
false;
 OUString aText;
 if( rxString->extractPlainString( aText, pFirstPortionFont ) )
 {


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

2023-08-28 Thread Paris Oplopoios (via logerrit)
 sc/qa/unit/data/xlsx/wrap-text.xlsx   |binary
 sc/qa/unit/subsequent_export_test.cxx |   20 
 sc/source/filter/excel/xestyle.cxx|2 +-
 sc/source/filter/excel/xetable.cxx|2 +-
 4 files changed, 22 insertions(+), 2 deletions(-)

New commits:
commit 1760ee4d328cfb6ba22a5b3c84016625b12adb25
Author: Paris Oplopoios 
AuthorDate: Wed Aug 23 12:31:15 2023 +0300
Commit: Paris Oplopoios 
CommitDate: Mon Aug 28 10:27:37 2023 +0200

sc: Fix wrapText not being applied correctly on export

Change-Id: I03aaa36af8fe820fa07d2eea13c5b0f69ad74dad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155970
Tested-by: Jenkins
Reviewed-by: Paris Oplopoios 

diff --git a/sc/qa/unit/data/xlsx/wrap-text.xlsx 
b/sc/qa/unit/data/xlsx/wrap-text.xlsx
new file mode 100644
index ..961cfcbdc02e
Binary files /dev/null and b/sc/qa/unit/data/xlsx/wrap-text.xlsx differ
diff --git a/sc/qa/unit/subsequent_export_test.cxx 
b/sc/qa/unit/subsequent_export_test.cxx
index 1ce8ef99c926..60b9f9fb1c0f 100644
--- a/sc/qa/unit/subsequent_export_test.cxx
+++ b/sc/qa/unit/subsequent_export_test.cxx
@@ -1805,6 +1805,26 @@ CPPUNIT_TEST_FIXTURE(ScExportTest, 
testRichTextCellFormatXLSX)
 assertXPath(pStyles, aXPath3, "val", "true");
 }
 
+CPPUNIT_TEST_FIXTURE(ScExportTest, testWrapText)
+{
+createScDoc("xlsx/wrap-text.xlsx");
+
+save("Calc Office Open XML");
+
+xmlDocUniquePtr pStyles = parseExport("xl/styles.xml");
+CPPUNIT_ASSERT(pStyles);
+
+assertXPath(pStyles, "/x:styleSheet/x:cellXfs", "count", "7");
+
+assertXPath(pStyles, "/x:styleSheet/x:cellXfs/x:xf[1]/x:alignment", 
"wrapText", "false");
+assertXPath(pStyles, "/x:styleSheet/x:cellXfs/x:xf[2]/x:alignment", 
"wrapText", "false");
+assertXPath(pStyles, "/x:styleSheet/x:cellXfs/x:xf[3]/x:alignment", 
"wrapText", "false");
+assertXPath(pStyles, "/x:styleSheet/x:cellXfs/x:xf[4]/x:alignment", 
"wrapText", "false");
+assertXPath(pStyles, "/x:styleSheet/x:cellXfs/x:xf[5]/x:alignment", 
"wrapText", "true");
+assertXPath(pStyles, "/x:styleSheet/x:cellXfs/x:xf[6]/x:alignment", 
"wrapText", "true");
+assertXPath(pStyles, "/x:styleSheet/x:cellXfs/x:xf[7]/x:alignment", 
"wrapText", "true");
+}
+
 CPPUNIT_TEST_FIXTURE(ScExportTest, testFormulaRefSheetNameODS)
 {
 createScDoc("ods/formula-quote-in-sheet-name.ods");
diff --git a/sc/source/filter/excel/xestyle.cxx 
b/sc/source/filter/excel/xestyle.cxx
index 191dab1822d9..f7f24c17d223 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -1507,7 +1507,7 @@ bool XclExpCellAlign::FillFromItemSet(const XclRoot& 
rRoot, const SfxItemSet& rI
 case EXC_BIFF3: // attributes new in BIFF3
 {
 // text wrap
-mbLineBreak = bForceLineBreak || rItemSet.Get( ATTR_LINEBREAK 
).GetValue();
+mbLineBreak = bForceLineBreak;
 bUsed |= bForceLineBreak || ScfTools::CheckItem( rItemSet, 
ATTR_LINEBREAK, bStyle );
 
 [[fallthrough]];
diff --git a/sc/source/filter/excel/xetable.cxx 
b/sc/source/filter/excel/xetable.cxx
index 022da6cd754f..f7b9a81be9f0 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -745,7 +745,7 @@ void XclExpLabelCell::Init( const XclExpRoot& rRoot,
 if( GetXFId() == EXC_XFID_NOTFOUND )
 {
OSL_ENSURE( nXclFont != EXC_FONT_NOTFOUND, "XclExpLabelCell::Init - 
leading font not found" );
-   bool bForceLineBreak = mxText->IsWrapped();
+   bool bForceLineBreak = pPattern->GetItemSet().Get(ATTR_LINEBREAK 
).GetValue();
SetXFId( rRoot.GetXFBuffer().InsertWithFont( pPattern, 
ApiScriptType::WEAK, nXclFont, bForceLineBreak ) );
 }
 


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

2023-08-27 Thread Szymon Kłos (via logerrit)
 sc/qa/unit/tiledrendering/tiledrendering.cxx |4 ++--
 sc/source/ui/docshell/docsh3.cxx |5 -
 2 files changed, 6 insertions(+), 3 deletions(-)

New commits:
commit 34d5abf464dfbf4bdc36f6b87e606c84a1f4d99d
Author: Szymon Kłos 
AuthorDate: Tue Jul 25 14:35:49 2023 +0200
Commit: Caolán McNamara 
CommitDate: Sun Aug 27 20:42:13 2023 +0200

lok: notify only affected tabs on cell resize

When row has automatic height and we type something into
one cell - it may be resized. That caused sending
document size changed callback to all the views, also
affecting all the parts/tabs.

This patch calls that only for affected views which
are looking at modified parts. It will not invalidate
all the tabs when only one is modified.

Change-Id: I93e574cf967d608696c1a95ad8b5a7614973c3f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154891
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156156
Tested-by: Jenkins

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 35304683e724..76286912a698 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1054,7 +1054,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testInvalidateOnInserRowCol)
 aView.m_aInvalidations.clear();
 dispatchCommand(mxComponent, ".uno:InsertRows", aArgs);
 CPPUNIT_ASSERT(aView.m_bInvalidateTiles);
-CPPUNIT_ASSERT_EQUAL(size_t(2), aView.m_aInvalidations.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), aView.m_aInvalidations.size());
 CPPUNIT_ASSERT_EQUAL(tools::Rectangle(-75, 51240, 32212230, 63990), 
aView.m_aInvalidations[0]);
 
 // move on the right
@@ -1070,7 +1070,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testInvalidateOnInserRowCol)
 aView.m_aInvalidations.clear();
 dispatchCommand(mxComponent, ".uno:InsertColumns", aArgs);
 CPPUNIT_ASSERT(aView.m_bInvalidateTiles);
-CPPUNIT_ASSERT_EQUAL(size_t(2), aView.m_aInvalidations.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), aView.m_aInvalidations.size());
 CPPUNIT_ASSERT_EQUAL(tools::Rectangle(254925, -15, 32212230, 63990), 
aView.m_aInvalidations[0]);
 }
 
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index 789737e5f824..50e99f36f109 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -109,6 +109,7 @@ void ScDocShell::PostPaint( SCCOL nStartCol, SCROW 
nStartRow, SCTAB nStartTab,
 void ScDocShell::PostPaint( const ScRangeList& rRanges, PaintPartFlags nPart, 
sal_uInt16 nExtFlags )
 {
 ScRangeList aPaintRanges;
+std::set aTabsInvalidated;
 for (size_t i = 0, n = rRanges.size(); i < n; ++i)
 {
 const ScRange& rRange = rRanges[i];
@@ -167,6 +168,7 @@ void ScDocShell::PostPaint( const ScRangeList& rRanges, 
PaintPartFlags nPart, sa
 }
 }
 aPaintRanges.push_back(ScRange(nCol1, nRow1, nTab1, nCol2, nRow2, 
nTab2));
+aTabsInvalidated.insert(nTab1);
 }
 
 Broadcast(ScPaintHint(aPaintRanges.Combine(), nPart));
@@ -176,7 +178,8 @@ void ScDocShell::PostPaint( const ScRangeList& rRanges, 
PaintPartFlags nPart, sa
 if ((nPart & (PaintPartFlags::Top | PaintPartFlags::Left)) && 
comphelper::LibreOfficeKit::isActive())
 {
 ScModelObj* pModel = GetModel();
-SfxLokHelper::notifyDocumentSizeChangedAllViews(pModel);
+for (auto nTab : aTabsInvalidated)
+SfxLokHelper::notifyPartSizeChangedAllViews(pModel, nTab);
 }
 }
 


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

2023-08-22 Thread Czeber László Ádám (via logerrit)
 sc/qa/unit/ucalc_copypaste.cxx   |   17 +
 sc/source/core/data/documen3.cxx |9 -
 2 files changed, 25 insertions(+), 1 deletion(-)

New commits:
commit cb141564733eef078347b89ea657e46e193bd140
Author: Czeber László Ádám 
AuthorDate: Mon Jul 17 11:41:17 2023 +0200
Commit: László Németh 
CommitDate: Tue Aug 22 11:56:13 2023 +0200

tdf#103480 sc: fix lost hyperlink at merging an empty cell with its cell

Merging a cell containing a hyperlink with an empty cell
resulted the loss of the hyperlink, i.e. only the text
content was kept.

Change-Id: I5148ce55157e3ad7926f5b5a82a682b837a784ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154520
Reviewed-by: László Németh 
Tested-by: László Németh 

diff --git a/sc/qa/unit/ucalc_copypaste.cxx b/sc/qa/unit/ucalc_copypaste.cxx
index bad57d8646a7..575cfb90f9f7 100644
--- a/sc/qa/unit/ucalc_copypaste.cxx
+++ b/sc/qa/unit/ucalc_copypaste.cxx
@@ -10752,6 +10752,23 @@ CPPUNIT_TEST_FIXTURE(TestCopyPaste, 
testUndoBackgroundColor)
 m_pDoc->DeleteTab(0);
 }
 
+CPPUNIT_TEST_FIXTURE(TestCopyPaste, testMergedHyperlink)
+{
+m_pDoc->InsertTab(0, "Table1");
+m_pDoc->InitDrawLayer(m_xDocShell.get());
+
+ScFieldEditEngine& pEE = m_pDoc->GetEditEngine();
+pEE.SetTextCurrentDefaults("https://libreoffice.org/;);
+m_pDoc->SetEditText(ScAddress(1, 0, 0), pEE.CreateTextObject()); // B1
+
+m_pDoc->DoMergeContents(0, 0, 1, 0, 0); // A1:B1
+
+CPPUNIT_ASSERT_EQUAL(CELLTYPE_EDIT, m_pDoc->GetCellType(ScAddress(0, 0, 
0))); // A1
+const EditTextObject* pEditObj = m_pDoc->GetEditText(ScAddress(0, 0, 0)); 
// A1
+CPPUNIT_ASSERT(pEditObj);
+CPPUNIT_ASSERT_EQUAL(OUString("https://libreoffice.org/;), 
pEditObj->GetText(0));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 73cf516c4d49..b52deed7d85b 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -2030,6 +2030,7 @@ void ScDocument::DoMergeContents( SCCOL nStartCol, SCROW 
nStartRow,
 OUString aCellStr;
 SCCOL nCol;
 SCROW nRow;
+ScCellValue aCell;
 for (nRow=nStartRow; nRow<=nEndRow; nRow++)
 for (nCol=nStartCol; nCol<=nEndCol; nCol++)
 {
@@ -2039,12 +2040,18 @@ void ScDocument::DoMergeContents( SCCOL nStartCol, 
SCROW nStartRow,
 if (!aTotal.isEmpty())
 aTotal.append(' ');
 aTotal.append(aCellStr);
+ScAddress aPos(nCol, nRow, nTab);
+if ((GetCellType(aPos) == CELLTYPE_EDIT) && aCell.isEmpty())
+aCell = ScRefCellValue(*this, aPos);
 }
 if (nCol != nStartCol || nRow != nStartRow)
 SetString(nCol,nRow,nTab,"");
 }
 
-SetString(nStartCol,nStartRow,nTab,aTotal.makeStringAndClear());
+if (aCell.isEmpty() || !GetString(nStartCol, nStartRow, nTab).isEmpty())
+SetString(nStartCol, nStartRow, nTab, aTotal.makeStringAndClear());
+else
+aCell.release(*this, ScAddress(nStartCol, nStartRow, nTab));
 }
 
 void ScDocument::DoEmptyBlock( SCCOL nStartCol, SCROW nStartRow,


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

2023-07-26 Thread Caolán McNamara (via logerrit)
 sc/qa/unit/tiledrendering/tiledrendering.cxx |3 +
 sc/source/ui/inc/tabview.hxx |6 ++-
 sc/source/ui/view/cellsh4.cxx|8 ++--
 sc/source/ui/view/tabview2.cxx   |   47 +--
 sc/source/ui/view/tabview3.cxx   |4 +-
 5 files changed, 56 insertions(+), 12 deletions(-)

New commits:
commit 6568a29fa256d143a332b424c0582b0e665b65d6
Author: Caolán McNamara 
AuthorDate: Tue Jul 25 14:16:39 2023 +0100
Commit: Caolán McNamara 
CommitDate: Wed Jul 26 09:54:03 2023 +0200

cool#6931 on ctrl+[right/down] don't leap to the limits of the document

...when there is no more data, instead jump a generous block of emptiness.

Limit to direct interaction by user and the simple navigation case
(leaving block selection alone) and only for LibreOfficeKit::isActive

Change-Id: I66234394529785d3f0f8fe6a6524239dad8ffb32
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154892
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index fd2413e9f0af..254fb5e8a042 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1896,7 +1896,8 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testJumpToLastRowInvalidation)
 Scheduler::ProcessEventsToIdle();
 CPPUNIT_ASSERT(aView1.m_bInvalidateTiles);
 CPPUNIT_ASSERT_EQUAL(size_t(1), aView1.m_aInvalidations.size());
-CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 13005, 26775, 267386880), 
aView1.m_aInvalidations[0]);
+// 261375 because we limit how far we jump into empty space in online, 
267386880 if we don't limit
+CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 13005, 26775, 261375), 
aView1.m_aInvalidations[0]);
 }
 
 // We need to ensure that views are not perterbed by rendering (!?) hmm ...
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 3f270770ec89..edb9dd991971 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -241,7 +241,8 @@ private:
 static tools::Long GetScrollBarPos( const ScrollAdaptor& rScroll );
 
 voidGetAreaMoveEndPosition(SCCOL nMovX, SCROW nMovY, 
ScFollowMode eMode,
-   SCCOL& rAreaX, SCROW& rAreaY, 
ScFollowMode& rMode);
+   SCCOL& rAreaX, SCROW& rAreaY, 
ScFollowMode& rMode,
+   bool bInteractiveByUser = false);
 
 voidSkipCursorHorizontal(SCCOL& rCurX, SCROW& rCurY, SCCOL 
nOldX, SCCOL nMovX);
 voidSkipCursorVertical(SCCOL& rCurX, SCROW& rCurY, SCROW 
nOldY, SCROW nMovY);
@@ -435,7 +436,8 @@ public:
 voidMoveCursorPage( SCCOL nMovX, SCROW nMovY, ScFollowMode 
eMode,
 bool bShift, bool bKeepSel = false );
 voidMoveCursorArea( SCCOL nMovX, SCROW nMovY, ScFollowMode 
eMode,
-bool bShift, bool bKeepSel = false );
+bool bShift, bool bKeepSel = false,
+bool bInteractiveByUser = false );
 voidMoveCursorEnd( SCCOL nMovX, SCROW nMovY, ScFollowMode 
eMode,
bool bShift, bool bKeepSel = false );
 voidMoveCursorScreen( SCCOL nMovX, SCROW nMovY, ScFollowMode 
eMode, bool bShift );
diff --git a/sc/source/ui/view/cellsh4.cxx b/sc/source/ui/view/cellsh4.cxx
index e44dbe599dba..8cf13970bdeb 100644
--- a/sc/source/ui/view/cellsh4.cxx
+++ b/sc/source/ui/view/cellsh4.cxx
@@ -141,7 +141,7 @@ void ScCellShell::ExecuteCursor( SfxRequest& rReq )
 break;
 
 case SID_CURSORBLKDOWN:
-pTabViewShell->MoveCursorArea( 0, nRepeat, SC_FOLLOW_JUMP, bSel, 
bKeep );
+pTabViewShell->MoveCursorArea( 0, nRepeat, SC_FOLLOW_JUMP, bSel, 
bKeep, !rReq.IsAPI() );
 break;
 
 case SID_CURSORUP:
@@ -152,7 +152,7 @@ void ScCellShell::ExecuteCursor( SfxRequest& rReq )
 break;
 
 case SID_CURSORBLKUP:
-pTabViewShell->MoveCursorArea( 0, -nRepeat, SC_FOLLOW_JUMP, bSel, 
bKeep );
+pTabViewShell->MoveCursorArea( 0, -nRepeat, SC_FOLLOW_JUMP, bSel, 
bKeep, !rReq.IsAPI() );
 break;
 
 case SID_CURSORLEFT:
@@ -163,7 +163,7 @@ void ScCellShell::ExecuteCursor( SfxRequest& rReq )
 break;
 
 case SID_CURSORBLKLEFT:
-pTabViewShell->MoveCursorArea( static_cast(-nRepeat * 
nRTLSign), 0, SC_FOLLOW_JUMP, bSel, bKeep );
+pTabViewShell->MoveCursorArea( static_cast(-nRepeat * 
nRTLSign), 0, SC_FOLLOW_JUMP, bSel, bKeep, !rReq.IsAPI() );
 break;
 
 case SID_CURSORRIGHT:
@@ -174,7 +174,7 @@ void ScCellShell::ExecuteCursor( SfxRequest& rReq )
 break;
 
 

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

2023-07-25 Thread Czeber László Ádám (via logerrit)
 sc/qa/unit/data/xlsx/tdf142905.xlsx |binary
 sc/qa/unit/subsequent_filters_test4.cxx |   12 
 sc/source/filter/oox/excelhandlers.cxx  |4 +++-
 3 files changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 7ec4c6df68233b73b1e257e013583ca49fc2ec9b
Author: Czeber László Ádám 
AuthorDate: Thu Jul 20 13:14:21 2023 +0200
Commit: László Németh 
CommitDate: Tue Jul 25 15:50:15 2023 +0200

tdf#142905 XLSX import: don't trim leading spaces in formula cell

When importing an XLSX file, there was a discrepancy between the
read and recalculated cell values if it contains leading/ending
spaces. With this fix, trimming in worksheet files is only applied
to elements that contain a parameter and do not have a
space="preserved" parameter.

Change-Id: I91e09eaa3cb79537ddbed36e1124e4afd124d8f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154674
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/unit/data/xlsx/tdf142905.xlsx 
b/sc/qa/unit/data/xlsx/tdf142905.xlsx
new file mode 100644
index ..b6e8296581c3
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf142905.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters_test4.cxx 
b/sc/qa/unit/subsequent_filters_test4.cxx
index 646b1e66f5b7..27d9d6f29150 100644
--- a/sc/qa/unit/subsequent_filters_test4.cxx
+++ b/sc/qa/unit/subsequent_filters_test4.cxx
@@ -1918,6 +1918,18 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testTdf155402)
 CPPUNIT_ASSERT_EQUAL(OUString("/[tdf155402.xlsx]Sheet1"), aFilename);
 }
 
+CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testTdf142905)
+{
+createScDoc("xlsx/tdf142905.xlsx");
+ScDocument* pDoc = getScDoc();
+
+// Without the fix, trims the spaces in cell C1 after reading the XLSX 
file.
+// After recalculation it is fixed.
+// - Expected: " 3M   "
+// - Actual  : "3M"
+CPPUNIT_ASSERT_EQUAL(OUString(" 3M   "), pDoc->GetString(2, 0, 0));
+}
+
 ScFiltersTest4::ScFiltersTest4()
 : ScModelTestBase("sc/qa/unit/data")
 {
diff --git a/sc/source/filter/oox/excelhandlers.cxx 
b/sc/source/filter/oox/excelhandlers.cxx
index ab39116b695b..77b5dda2ade7 100644
--- a/sc/source/filter/oox/excelhandlers.cxx
+++ b/sc/source/filter/oox/excelhandlers.cxx
@@ -30,9 +30,11 @@ WorkbookFragmentBase::WorkbookFragmentBase(
 {
 }
 
+// tdf142905: Change mbEnableTrimSpace default value is false,
+// because it will not trim members that do not have an attribute.
 WorksheetFragmentBase::WorksheetFragmentBase(
 const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
-FragmentHandler2( rHelper.getOoxFilter(), rFragmentPath ),
+FragmentHandler2( rHelper.getOoxFilter(), rFragmentPath, false ),
 WorksheetHelper( rHelper )
 {
 }


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

2023-07-25 Thread Tünde Tóth (via logerrit)
 sc/qa/unit/uicalc/uicalc2.cxx|   26 ++
 sc/source/core/tool/refupdat.cxx |7 +--
 2 files changed, 27 insertions(+), 6 deletions(-)

New commits:
commit 94ca402cd1fe2fd9776d08448f7216b7f638e69a
Author: Tünde Tóth 
AuthorDate: Tue Jul 18 15:20:47 2023 +0200
Commit: László Németh 
CommitDate: Tue Jul 25 15:04:01 2023 +0200

tdf#156174 sc DBData: fix regression of database ranges

Regression from commit 0c0444c44107f1a18f23dd0833d462d8dbf56569
"tdf#126926 sc DBData: delete the database range".

Change-Id: If641af42a44cadbb8485bfa5b9a8eca5a757
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154582
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/unit/uicalc/uicalc2.cxx b/sc/qa/unit/uicalc/uicalc2.cxx
index 44ebf12935bc..4e154f8bbb83 100644
--- a/sc/qa/unit/uicalc/uicalc2.cxx
+++ b/sc/qa/unit/uicalc/uicalc2.cxx
@@ -1446,6 +1446,32 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf155796)
 CPPUNIT_ASSERT_EQUAL(OUString("Sheet1.A1:Sheet1.A3"), aMarkedAreaString);
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf156174)
+{
+createScDoc();
+ScDocument* pDoc = getScDoc();
+
+insertNewSheet(*pDoc);
+
+insertStringToCell("A1", u"1");
+insertStringToCell("A2", u"2");
+insertStringToCell("B1", u"3");
+insertStringToCell("B2", u"4");
+
+ScDBData* pDBData = new ScDBData("testDB", 1, 0, 0, 1, 1);
+bool bInserted
+= 
pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr(pDBData));
+CPPUNIT_ASSERT(bInserted);
+
+insertNewSheet(*pDoc);
+uno::Sequence aArgs(
+comphelper::InitPropertySequence({ { "Index", uno::Any(sal_uInt16(3)) 
} }));
+dispatchCommand(mxComponent, ".uno:Remove", aArgs);
+
+ScDBCollection* pDBs = pDoc->GetDBCollection();
+CPPUNIT_ASSERT(!pDBs->empty());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/refupdat.cxx b/sc/source/core/tool/refupdat.cxx
index ef0902aab3f4..e05a14d0137f 100644
--- a/sc/source/core/tool/refupdat.cxx
+++ b/sc/source/core/tool/refupdat.cxx
@@ -286,12 +286,7 @@ ScRefUpdateRes ScRefUpdate::Update( const ScDocument* 
pDoc, UpdateRefMode eUpdat
 bool bExp = (bExpand && IsExpand( theTab1, theTab2, nTab1, nDz ));
 bCut1 = lcl_MoveStart( theTab1, nTab1, nDz, nMaxTab );
 bCut2 = lcl_MoveEnd( theTab2, nTab1, nDz, nMaxTab );
-if ( theTab2 < theTab1 )
-{
-eRet = UR_INVALID;
-theTab2 = theTab1;
-}
-else if ( bCut1 || bCut2 )
+if ( bCut1 || bCut2 )
 eRet = UR_UPDATED;
 if ( bExp )
 {


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

2023-07-25 Thread Tibor Nagy (via logerrit)
 sc/qa/unit/ucalc_condformat.cxx   |   54 ++
 sc/source/ui/docshell/docfunc.cxx |2 -
 2 files changed, 55 insertions(+), 1 deletion(-)

New commits:
commit e384be0f6ea6453e57cd4a7c4402d26b49debc41
Author: Tibor Nagy 
AuthorDate: Thu Jul 13 14:54:55 2023 +0200
Commit: László Németh 
CommitDate: Tue Jul 25 14:12:34 2023 +0200

tdf#99808 sc: fix background of conditional formatting in merged cell

The background color of conditional formatting is applied only to the
first cell in the merged block, at least under Windows.

Note: Undo/Redo is still not perfect, at least under Linux.

Change-Id: Ic87983fa6e3279a64841babc565fbe97710ff730
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154390
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index 634373b58ccc..6b79a4318501 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -12,6 +12,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -25,6 +26,23 @@
 
 namespace {
 
+struct PaintListener : public SfxListener
+{
+bool mbPaintAllMergedCell = false;
+virtual void Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint) override
+{
+const ScPaintHint* pPaintHint = dynamic_cast();
+if (pPaintHint)
+{
+if (pPaintHint->GetStartCol() == 0 && pPaintHint->GetEndCol() == 0
+&& pPaintHint->GetStartRow() == 0 && pPaintHint->GetEndRow() 
== 1)
+{
+mbPaintAllMergedCell = true;
+}
+}
+}
+};
+
 struct ScDataBarLengthData
 {
 double nVal;
@@ -1361,6 +1379,42 @@ CPPUNIT_TEST_FIXTURE(TestCondformat, 
testCondFormatVolatileFunctionRecalc)
 m_pDoc->DeleteTab(0);
 }
 
+CPPUNIT_TEST_FIXTURE(TestCondformat, testConditionStyleInMergedCell)
+{
+m_pDoc->InsertTab(0, "Test");
+
+PaintListener aListener;
+aListener.StartListening(*m_xDocShell);
+
+m_pDoc->DoMerge(0, 0, 0, 1, 0); // A1:A2
+CPPUNIT_ASSERT(m_pDoc->IsMerged(ScAddress(0, 0, 0)));
+
+m_pDoc->SetValue(ScAddress(0, 0, 0), 1.0);
+
+// Add a conditional format.
+auto pFormat = std::make_unique(1, m_pDoc);
+pFormat->SetRange(ScRange(0, 0, 0, 0, 0, 0));
+auto pFormatTmp = pFormat.get();
+sal_uLong nKey = m_pDoc->AddCondFormat(std::move(pFormat), 0);
+
+// Add condition in which if the value equals 1, set the "Good" style.
+ScCondFormatEntry* pEntry = new ScCondFormatEntry(
+ScConditionMode::Equal, "=1", "", *m_pDoc, ScAddress(0, 0, 0), 
ScResId(STR_STYLENAME_GOOD));
+pFormatTmp->AddEntry(pEntry);
+
+// Apply the format to the range.
+m_pDoc->AddCondFormatData(pFormatTmp->GetRange(), 0, nKey);
+
+ScDocFunc& rFunc = m_xDocShell->GetDocFunc();
+sal_uInt32 nOldFormat = pFormatTmp->GetKey();
+const ScRangeList& rRangeList = pFormatTmp->GetRange();
+rFunc.ReplaceConditionalFormat(nOldFormat, pFormatTmp->Clone(), 0, 
rRangeList);
+
+CPPUNIT_ASSERT_EQUAL(true, aListener.mbPaintAllMergedCell);
+
+m_pDoc->DeleteTab(0);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docfunc.cxx 
b/sc/source/ui/docshell/docfunc.cxx
index 4d99824fe0a0..4d3288558c40 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5670,7 +5670,7 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong 
nOldFormat, std::unique_ptr<
 }
 
 if(pRepaintRange)
-rDocShell.PostPaint(*pRepaintRange, PaintPartFlags::Grid);
+rDocShell.PostPaint(*pRepaintRange, PaintPartFlags::Grid, 
SC_PF_TESTMERGE);
 
 aModificator.SetDocumentModified();
 SfxGetpApp()->Broadcast(SfxHint(SfxHintId::ScAreasChanged));


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

2023-07-25 Thread Tibor Nagy (via logerrit)
 sc/qa/unit/ucalc_condformat.cxx  |   52 +++
 sc/source/core/data/fillinfo.cxx |   20 +++
 2 files changed, 72 insertions(+)

New commits:
commit ee4bd745be5dee15b68ca483f7f7771957ae3b3e
Author: Tibor Nagy 
AuthorDate: Wed Jul 12 17:17:10 2023 +0200
Commit: László Németh 
CommitDate: Tue Jul 25 10:28:32 2023 +0200

tdf#155322 sc: fix conditional format color scale in merged cells

Only first cell of a merged range got coloring, now all of them.

See also commit f142b3e84f97ae678bd0a94614e867d369680458
"tdf#131471 sc: fix background color of conditional formatting style".

Change-Id: I0e95bf49369de219e659295643aaf2659dd3de48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154362
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index 78978daec33a..634373b58ccc 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -319,6 +319,58 @@ CPPUNIT_TEST_FIXTURE(TestCondformat, 
testDataBarCondCopyPaste)
 m_pDoc->DeleteTab(0);
 }
 
+CPPUNIT_TEST_FIXTURE(TestCondformat, testColorScaleInMergedCell)
+{
+m_pDoc->InsertTab(0, "Test");
+m_pDoc->SetValue(ScAddress(0, 0, 0), 1.0);
+
+// Add a conditional format to A1.
+auto pFormat = std::make_unique(1, m_pDoc);
+pFormat->SetRange(ScRange(0, 0, 0, 0, 0, 0));
+auto pFormatTmp = pFormat.get();
+sal_uLong nKey = m_pDoc->AddCondFormat(std::move(pFormat), 0);
+
+// Add color scale entries.
+// The coloring is based on the value. (BLUE (x <= 0), GREEN (x == 1), RED 
(x >= 2))
+ScColorScaleFormat* pColorScaleFormat = new ScColorScaleFormat(m_pDoc);
+ScColorScaleEntry* pEntryBlue = new ScColorScaleEntry(0, COL_BLUE);
+ScColorScaleEntry* pEntryGreen = new ScColorScaleEntry(1, COL_GREEN);
+ScColorScaleEntry* pEntryRed = new ScColorScaleEntry(2, COL_RED);
+pColorScaleFormat->AddEntry(pEntryBlue);
+pColorScaleFormat->AddEntry(pEntryGreen);
+pColorScaleFormat->AddEntry(pEntryRed);
+
+pFormatTmp->AddEntry(pColorScaleFormat);
+
+// Apply the format to the range.
+m_pDoc->AddCondFormatData(pFormatTmp->GetRange(), 0, nKey);
+
+m_pDoc->DoMerge(0, 0, 0, 1, 0);  // A1:A2
+CPPUNIT_ASSERT(m_pDoc->IsMerged(ScAddress(0, 0, 0)));
+
+ScTableInfo aTabInfo;
+m_pDoc->FillInfo(aTabInfo, 0, 0, 0, 1, 0, 1, 1, false, false);
+RowInfo* pRowInfo = aTabInfo.mpRowInfo.get();
+
+RowInfo* pRowInfoA1 = [1];
+ScCellInfo* pCellInfoA1 = >cellInfo(0);
+// Check if there is a color scale in A1.
+CPPUNIT_ASSERT_EQUAL_MESSAGE("There is no color scale in cell A1!", true,
+ pCellInfoA1->mxColorScale.has_value());
+
+RowInfo* pRowInfoA2 = [2];
+ScCellInfo* pCellInfoA2 = >cellInfo(0);
+// Check if there is a color scale in A2.
+CPPUNIT_ASSERT_EQUAL_MESSAGE("There is no color scale in cell A2!", true,
+ pCellInfoA2->mxColorScale.has_value());
+
+// Check that cells A1 and A2 have the same color scale. (GREEN)
+
CPPUNIT_ASSERT(pCellInfoA1->mxColorScale.value().IsRGBEqual(pCellInfoA2->mxColorScale.value()));
+
+m_pDoc->DeleteTab(0);
+}
+
+
 CPPUNIT_TEST_FIXTURE(TestCondformat, testColorScaleCondCopyPaste)
 {
 m_pDoc->InsertTab(0, "Test");
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 94d79da68031..2e268239b048 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -743,6 +743,26 @@ void ScDocument::FillInfo(
 pInfo->pShadowAttr = pShadowItem;
 if (pInfo->pShadowAttr != pDefShadow)
 bAnyShadow = true;
+
+const ScCondFormatIndexes& rCondFormatIndex
+= 
pStartPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData();
+
+if (pCondFormList && !pStartCond && 
!rCondFormatIndex.empty())
+{
+for (const auto& rItem : rCondFormatIndex)
+{
+const ScConditionalFormat* pCondForm = 
pCondFormList->GetFormat(rItem);
+if (pCondForm)
+{
+ScCondFormatData aData = pCondForm->GetData(
+pInfo->maCell, ScAddress(nStartX, nStartY, 
nTab));
+
+// Color scale
+if (aData.mxColorScale && !pInfo->mxColorScale)
+pInfo->mxColorScale = aData.mxColorScale;
+}
+}
+}
 }
 }
 }


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

2023-07-24 Thread Tibor Nagy (via logerrit)
 sc/qa/unit/data/ods/tdf131471.ods   |binary
 sc/qa/unit/subsequent_filters_test3.cxx |   25 +++--
 sc/source/ui/unoobj/docuno.cxx  |2 +-
 3 files changed, 24 insertions(+), 3 deletions(-)

New commits:
commit f142b3e84f97ae678bd0a94614e867d369680458
Author: Tibor Nagy 
AuthorDate: Mon Jul 10 17:53:49 2023 +0200
Commit: László Németh 
CommitDate: Mon Jul 24 15:03:58 2023 +0200

tdf#131471 sc: fix background color of conditional formatting style

The issue appears for merged cells when you trigger a change that
causes the condition to be evaluated again.

Manual test: open unit test document, put "1" in A1, and press Undo:
the green background color of the condition was removed only
partially.

Change-Id: I8bb17c77ac49a1ee897c3e2b4902723d237765d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154277
Reviewed-by: László Németh 
Tested-by: László Németh 

diff --git a/sc/qa/unit/data/ods/tdf131471.ods 
b/sc/qa/unit/data/ods/tdf131471.ods
new file mode 100644
index ..31f079274256
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf131471.ods differ
diff --git a/sc/qa/unit/subsequent_filters_test3.cxx 
b/sc/qa/unit/subsequent_filters_test3.cxx
index 44cd7024506c..54d5061d2cd9 100644
--- a/sc/qa/unit/subsequent_filters_test3.cxx
+++ b/sc/qa/unit/subsequent_filters_test3.cxx
@@ -391,8 +391,9 @@ struct PaintListener : public SfxListener
 const ScPaintHint* pPaintHint = dynamic_cast();
 if (pPaintHint)
 {
-if (pPaintHint->GetStartCol() <= 0 && pPaintHint->GetEndCol() >= 0
-&& pPaintHint->GetStartRow() <= 9 && pPaintHint->GetEndRow() 
>= 9)
+if ((pPaintHint->GetStartCol() <= 0 && pPaintHint->GetEndCol() >= 
0)
+&& ((pPaintHint->GetStartRow() <= 9 && pPaintHint->GetEndRow() 
>= 9)
+|| (pPaintHint->GetStartRow() == 2 && 
pPaintHint->GetEndRow() == 3)))
 {
 mbCalled = true;
 }
@@ -420,6 +421,26 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest3, 
testCondFormatFormulaListenerXLSX)
 CPPUNIT_ASSERT(aListener.mbCalled);
 }
 
+CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf131471)
+{
+// Repaint range of conditional format in merged cell.
+createScDoc("ods/tdf131471.ods");
+ScDocShell* pDocSh = getScDocShell();
+PaintListener aListener;
+aListener.StartListening(*pDocSh);
+ScDocument* pDoc = getScDoc();
+ScConditionalFormatList* pList = pDoc->GetCondFormList(0);
+CPPUNIT_ASSERT(pList);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), pList->size());
+ScConditionalFormat* pFormat = pList->begin()->get();
+CPPUNIT_ASSERT(pFormat);
+pDoc->SetDocVisible(true);
+pDoc->SetValue(0, 0, 0, 1.0);
+
+CPPUNIT_ASSERT(aListener.mbCalled);
+}
+
 CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf137091)
 {
 // Set the system locale to Turkish
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 33ffbd393f12..66c2667a1a1f 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -488,7 +488,7 @@ void ScModelObj::RepaintRange( const ScRange& rRange )
 void ScModelObj::RepaintRange( const ScRangeList& rRange )
 {
 if (pDocShell)
-pDocShell->PostPaint( rRange, PaintPartFlags::Grid );
+pDocShell->PostPaint(rRange, PaintPartFlags::Grid, SC_PF_TESTMERGE);
 }
 
 static ScViewData* lcl_getViewMatchingDocZoomTab(const Fraction& rZoomX,


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

2023-07-07 Thread Jaume Pujantell (via logerrit)
 sc/qa/unit/uicalc/uicalc2.cxx  |   27 ++
 sc/source/ui/view/tabview2.cxx |  375 +++--
 2 files changed, 245 insertions(+), 157 deletions(-)

New commits:
commit 341029de72cf957b7bc7775e51544070d4a49874
Author: Jaume Pujantell 
AuthorDate: Thu Jul 6 09:22:15 2023 +0200
Commit: Jaume Pujantell 
CommitDate: Fri Jul 7 08:59:31 2023 +0200

tdf#155796 sc: fix select with merged cells

When selecting multiple cells or modifying a selection with shift+arrow
make sure that a merge group is never partially selected.

This also fixes tdf#128678

Change-Id: Ida00939cec11240c0d06375feb21afa82a6876da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154093
Tested-by: Jenkins
Reviewed-by: Jaume Pujantell 

diff --git a/sc/qa/unit/uicalc/uicalc2.cxx b/sc/qa/unit/uicalc/uicalc2.cxx
index 3be123de219d..44ebf12935bc 100644
--- a/sc/qa/unit/uicalc/uicalc2.cxx
+++ b/sc/qa/unit/uicalc/uicalc2.cxx
@@ -1419,6 +1419,33 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf152577)
 CPPUNIT_ASSERT(!pDBs->empty());
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf155796)
+{
+createScDoc();
+
+goToCell("A1:A3");
+dispatchCommand(mxComponent, ".uno:ToggleMergeCells", {});
+goToCell("A4:A6");
+dispatchCommand(mxComponent, ".uno:ToggleMergeCells", {});
+
+goToCell("A1:A6");
+
+ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel(mxComponent);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_SHIFT | KEY_UP);
+Scheduler::ProcessEventsToIdle();
+
+ScRangeList aMarkedArea = 
getViewShell()->GetViewData().GetMarkData().GetMarkedRanges();
+ScDocument* pDoc = getScDoc();
+OUString aMarkedAreaString;
+ScRangeStringConverter::GetStringFromRangeList(aMarkedAreaString, 
, pDoc,
+   
formula::FormulaGrammar::CONV_OOO);
+
+// Without the fix in place, this test would have failed with
+// - Expected: Sheet1.A1:Sheet1.A3
+// - Actual  : Sheet1.A1:Sheet1.A5
+CPPUNIT_ASSERT_EQUAL(OUString("Sheet1.A1:Sheet1.A3"), aMarkedAreaString);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index 6b1cfef156f7..442dc92ccb73 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -58,6 +58,19 @@ bool isCellQualified(const ScDocument* pDoc, SCCOL nCol, 
SCROW nRow, SCTAB nTab,
 return true;
 }
 
+bool areCellsQualified(const ScDocument* pDoc, SCCOL nColStart, SCROW 
nRowStart, SCCOL nColEnd,
+   SCROW nRowEnd, SCTAB nTab, bool bSelectLocked, bool 
bSelectUnlocked)
+{
+PutInOrder(nColStart, nColEnd);
+PutInOrder(nRowStart, nRowEnd);
+for (SCCOL col = nColStart; col <= nColEnd; ++col)
+for (SCROW row = nRowStart; row <= nRowEnd; ++row)
+if (!isCellQualified(pDoc, col, row, nTab, bSelectLocked, 
bSelectUnlocked))
+return false;
+
+return true;
+}
+
 void moveCursorByProtRule(
 SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY, SCTAB nTab, const 
ScDocument* pDoc)
 {
@@ -180,13 +193,9 @@ bool checkBoundary(const ScDocument* pDoc, SCCOL& rCol, 
SCROW& rRow)
 return bGood;
 }
 
-void moveCursorByMergedCell(
-SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW nMovY, SCTAB nTab,
-const ScDocument* pDoc, const ScViewData& rViewData)
+void moveCursorByMergedCell(SCCOL& rCol, SCROW& rRow, SCCOL nMovX, SCROW 
nMovY, SCCOL nStartX,
+SCROW nStartY, SCTAB nTab, const ScDocument* pDoc)
 {
-SCCOL nOrigX = rViewData.GetCurX();
-SCROW nOrigY = rViewData.GetCurY();
-
 const ScTableProtection* pTabProtection = pDoc->GetTabProtection(nTab);
 bool bSelectLocked = true;
 bool bSelectUnlocked = true;
@@ -196,108 +205,198 @@ void moveCursorByMergedCell(
 bSelectUnlocked = 
pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
 }
 
-const ScMergeAttr* pMergeAttr = pDoc->GetAttr(nOrigX, nOrigY, nTab, 
ATTR_MERGE);
-
-bool bOriginMerged = false;
-SCCOL nColSpan = 1;
-SCROW nRowSpan = 1;
-if (pMergeAttr && pMergeAttr->IsMerged())
-{
-nColSpan = pMergeAttr->GetColMerge();
-nRowSpan = pMergeAttr->GetRowMerge();
-bOriginMerged = true;
-}
-
 if (nMovX > 0)
 {
-SCCOL nOld = rCol;
-if (bOriginMerged)
-{
-// Original cell is merged.  Push the block end outside the merged 
region.
-if (nOrigX < pDoc->MaxCol() && nOrigX < rCol && rCol <= nOrigX + 
nColSpan - 1)
-rCol = nOrigX + nColSpan;
-}
-else
-{
-pDoc->SkipOverlapped(rCol, rRow, nTab);
-}
+SCROW rowStart = std::min(rRow, nStartY);
+SCROW rowEnd = std::max(rRow, nStartY);
 
-if (nOld < rCol)
+for (SCROW i = rowStart; i <= rowEnd && rCol < 

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

2023-07-04 Thread Tomaž Vajngerl (via logerrit)
 sc/qa/unit/ThemeImportExportTest.cxx   |   34 +--
 sc/qa/unit/subsequent_export_test4.cxx |2 
 sc/source/filter/excel/xestyle.cxx |   72 ++---
 sc/source/filter/inc/xestyle.hxx   |   20 +
 4 files changed, 85 insertions(+), 43 deletions(-)

New commits:
commit 42bbc9fbdf940e55213ee2a259c1d31de2e4cbec
Author: Tomaž Vajngerl 
AuthorDate: Sat Jul 1 14:26:08 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Jul 4 08:42:51 2023 +0200

sc: add border export and enable round-trip test

Change-Id: I76071185d819b9645d97a3e599ea7f48b341a145
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153820
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/qa/unit/ThemeImportExportTest.cxx 
b/sc/qa/unit/ThemeImportExportTest.cxx
index 95e6d0e2351e..0cf03ea6c010 100644
--- a/sc/qa/unit/ThemeImportExportTest.cxx
+++ b/sc/qa/unit/ThemeImportExportTest.cxx
@@ -60,6 +60,12 @@ CPPUNIT_TEST_FIXTURE(ThemeImportExportTest, testThemeExport)
 assertXPath(pXmlDoc, 
"/x:styleSheet/x:fills/x:fill[4]/x:patternFill/x:fgColor", "theme", "4");
 }
 
+// Round 100th percent to percent value - so that small differences don't fail 
the test
+sal_Int32 roundToPercent(sal_Int16 n100Percent)
+{
+return sal_Int32(std::round(double(n100Percent) / 100.0));
+}
+
 void checkCellBackgroundThemeColor(ScDocument* pDoc)
 {
 // A1
@@ -90,9 +96,9 @@ void checkCellBackgroundThemeColor(ScDocument* pDoc)
 auto& rTransformations = aComplexColor.getTransformations();
 CPPUNIT_ASSERT_EQUAL(size_t(2), rTransformations.size());
 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, 
rTransformations[0].meType);
-CPPUNIT_ASSERT_EQUAL(20, 
sal_Int32(std::round(rTransformations[0].mnValue / 100.0)));
+CPPUNIT_ASSERT_EQUAL(20, roundToPercent(rTransformations[0].mnValue));
 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, 
rTransformations[1].meType);
-CPPUNIT_ASSERT_EQUAL(80, 
sal_Int32(std::round(rTransformations[1].mnValue / 100.0)));
+CPPUNIT_ASSERT_EQUAL(80, roundToPercent(rTransformations[1].mnValue));
 }
 
 // A3
@@ -109,7 +115,7 @@ void checkCellBackgroundThemeColor(ScDocument* pDoc)
 auto& rTransformations = aComplexColor.getTransformations();
 CPPUNIT_ASSERT_EQUAL(size_t(1), rTransformations.size());
 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, 
rTransformations[0].meType);
-CPPUNIT_ASSERT_EQUAL(sal_Int16(5000), rTransformations[0].mnValue);
+CPPUNIT_ASSERT_EQUAL(50, roundToPercent(rTransformations[0].mnValue));
 }
 }
 
@@ -151,9 +157,9 @@ void checkCellTextThemeColor(ScDocument* pDoc)
 auto& rTransformations = aComplexColor.getTransformations();
 CPPUNIT_ASSERT_EQUAL(size_t(2), rTransformations.size());
 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, 
rTransformations[0].meType);
-CPPUNIT_ASSERT_EQUAL(60, 
sal_Int32(std::round(rTransformations[0].mnValue / 100.0)));
+CPPUNIT_ASSERT_EQUAL(60, roundToPercent(rTransformations[0].mnValue));
 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, 
rTransformations[1].meType);
-CPPUNIT_ASSERT_EQUAL(40, 
sal_Int32(std::round(rTransformations[1].mnValue / 100.0)));
+CPPUNIT_ASSERT_EQUAL(40, roundToPercent(rTransformations[1].mnValue));
 }
 
 // B3
@@ -170,7 +176,7 @@ void checkCellTextThemeColor(ScDocument* pDoc)
 auto& rTransformations = aComplexColor.getTransformations();
 CPPUNIT_ASSERT_EQUAL(size_t(1), rTransformations.size());
 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, 
rTransformations[0].meType);
-CPPUNIT_ASSERT_EQUAL(sal_Int16(5000), rTransformations[0].mnValue);
+CPPUNIT_ASSERT_EQUAL(50, roundToPercent(rTransformations[0].mnValue));
 }
 }
 
@@ -226,9 +232,9 @@ void checkCellBorderThemeColor(ScDocument* pDoc)
 auto& rTransformations = aComplexColor.getTransformations();
 CPPUNIT_ASSERT_EQUAL(size_t(2), rTransformations.size());
 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, 
rTransformations[0].meType);
-CPPUNIT_ASSERT_EQUAL(sal_Int16(2000), rTransformations[0].mnValue);
+CPPUNIT_ASSERT_EQUAL(20, 
roundToPercent(rTransformations[0].mnValue));
 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff, 
rTransformations[1].meType);
-CPPUNIT_ASSERT_EQUAL(sal_Int16(7999), rTransformations[1].mnValue);
+CPPUNIT_ASSERT_EQUAL(80, 
roundToPercent(rTransformations[1].mnValue));
 }
 {
 auto* pTop = pBoxItem->GetRight();
@@ -239,9 +245,9 @@ void checkCellBorderThemeColor(ScDocument* pDoc)
 auto& rTransformations = aComplexColor.getTransformations();
 CPPUNIT_ASSERT_EQUAL(size_t(2), rTransformations.size());
 CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod, 

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

2023-06-27 Thread luigiiucci (via logerrit)
 sc/qa/unit/helper/qahelper.cxx   |   38 ++
 sc/source/core/data/dpoutput.cxx |6 +-
 2 files changed, 43 insertions(+), 1 deletion(-)

New commits:
commit 3551d18404cb19cdaa8edb170a549f5c5405d0cb
Author: luigiiucci 
AuthorDate: Wed May 17 11:02:37 2023 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 28 02:07:03 2023 +0200

Header columns can disappear with filtered data in pivot tables

When we set on a pivot table a filter that filters all the rows,
the pivot table showed only the first header columns and computed
column, but all the columns headers should still be shown so we can
adjust the filter for the column. This fixes this issue.

Also add more debug output and prevent a crash when running pivot
table tests.

Change-Id: I30b4ee72cf8436c4522ab4ba0781462b214816dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151871
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 890a330f147d..eff2c62d9aeb 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -481,6 +482,43 @@ bool checkOutput(
 svl::GridPrinter printer(e.Row() - s.Row() + 1, e.Col() - s.Col() + 1, 
CALC_DEBUG_OUTPUT != 0);
 SCROW nOutRowSize = e.Row() - s.Row() + 1;
 SCCOL nOutColSize = e.Col() - s.Col() + 1;
+
+// Check if expected size iz smaller than actual size (and prevent a crash)
+if (aCheck.size() < o3tl::make_unsigned(nOutRowSize) || aCheck[0].size() < 
o3tl::make_unsigned(nOutColSize))
+{
+// Dump the arrays to console, so we can compare
+std::cout << "Expected data:" << std::endl;
+for (size_t nRow = 0; nRow < aCheck.size(); ++nRow)
+{
+for (size_t nCol = 0; nCol < aCheck[nRow].size(); ++nCol)
+{
+const char* p = aCheck[nRow][nCol];
+if (p)
+{
+OUString aCheckVal = OUString::createFromAscii(p);
+std::cout << "'" << aCheckVal << "', ";
+}
+else
+std::cout << "null, ";
+}
+std::cout << std::endl;
+}
+
+std::cout << "Actual data:" << std::endl;
+for (SCROW nRow = 0; nRow < nOutRowSize; ++nRow)
+{
+for (SCCOL nCol = 0; nCol < nOutColSize; ++nCol)
+{
+OUString aVal = pDoc->GetString(nCol + s.Col(), nRow + 
s.Row(), s.Tab());
+std::cout << "'" << aVal << "', ";
+}
+std::cout << std::endl;
+}
+std::cout << std::endl;
+
+return false;
+}
+
 for (SCROW nRow = 0; nRow < nOutRowSize; ++nRow)
 {
 for (SCCOL nCol = 0; nCol < nOutColSize; ++nCol)
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 00d8f2aabeb4..c964dda14c7a 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -608,7 +608,11 @@ ScDPOutput::ScDPOutput( ScDocument* pD, 
uno::Reference 
aResult = xLevRes->getResults();
 ++nRowDims;
-if (!lcl_MemberEmpty(aResult))
+// We want only to remove the DATA 
column if it is empty
+// and not any other empty columns (to 
still show the
+// header columns)
+bool bSkip = lcl_MemberEmpty(aResult) 
&& bIsDataLayout;
+if (!bSkip)
 {
 bool bFieldCompact = false;
 try


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

2023-06-27 Thread Tibor Nagy (via logerrit)
 sc/qa/uitest/calc_tests8/tdf54768.py |   32 
 sc/qa/uitest/data/tdf54768.ods   |binary
 sc/source/ui/view/drawvie4.cxx   |   16 
 3 files changed, 36 insertions(+), 12 deletions(-)

New commits:
commit f5bf91ea73bf8a7cd3abc0f343ab2bdceaad905a
Author: Tibor Nagy 
AuthorDate: Thu Jun 22 09:53:59 2023 +0200
Commit: László Németh 
CommitDate: Tue Jun 27 14:18:42 2023 +0200

tdf#54768 sc: fix resizing of cropped images to original size

This is a follow up to commit a4e12cbfc69cfe668fa30756a3c5843e911e22b1
(tdf#155863 sd: fix resizing of cropped images to original size)

Change-Id: I923ed8b1df6c6559d527d43e4abe842497c4c28f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153449
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/uitest/calc_tests8/tdf54768.py 
b/sc/qa/uitest/calc_tests8/tdf54768.py
new file mode 100644
index ..a4342fb8e238
--- /dev/null
+++ b/sc/qa/uitest/calc_tests8/tdf54768.py
@@ -0,0 +1,32 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+from uitest.framework import UITestCase
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_url_for_data_file
+
+class tdf54768(UITestCase):
+def test_tdf54768(self):
+# This document contains an image with an original size of 7.99cm x 
5.74cm.
+# The image has been cropped 2.73cm at the top.
+# Also, it has been resized to a width of 4.04cm.
+with self.ui_test.load_file(get_url_for_data_file("tdf54768.ods")) as 
document:
+xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window")
+
+# select the image
+xGridWin.executeAction("SELECT", 
mkPropertyValues({"OBJECT":"Image"}))
+
+# click "Original Size"
+self.xUITest.executeCommand(".uno:OriginalSize")
+
+# tdf#155863: Without the fix in place, the image stays cropped,
+# but stretches to the size of original image
+self.assertEqual(7988, 
document.DrawPages[0].getByIndex(0).Size.Width)
+self.assertEqual(3005, 
document.DrawPages[0].getByIndex(0).Size.Height)
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/data/tdf54768.ods b/sc/qa/uitest/data/tdf54768.ods
new file mode 100644
index ..222481db8bb0
Binary files /dev/null and b/sc/qa/uitest/data/tdf54768.ods differ
diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx
index 5cc1655b83c4..2bd329098206 100644
--- a/sc/source/ui/view/drawvie4.cxx
+++ b/sc/source/ui/view/drawvie4.cxx
@@ -476,9 +476,9 @@ void ScDrawView::SetMarkedOriginalSize()
 }
 else if (nIdent == SdrObjKind::Graphic)
 {
-const Graphic& rGraphic = 
static_cast(pObj)->GetGraphic();
+const SdrGrafObj* pSdrGrafObj = static_cast(pObj);
 
-MapMode aSourceMap = rGraphic.GetPrefMapMode();
+MapMode aSourceMap = pSdrGrafObj->GetGraphic().GetPrefMapMode();
 MapMode aDestMap( MapUnit::Map100thMM );
 if (aSourceMap.GetMapUnit() == MapUnit::MapPixel)
 {
@@ -488,16 +488,8 @@ void ScDrawView::SetMarkedOriginalSize()
 aDestMap.SetScaleX(aNormScaleX);
 aDestMap.SetScaleY(aNormScaleY);
 }
-if (pViewData)
-{
-vcl::Window* pActWin = pViewData->GetActiveWin();
-if (pActWin)
-{
-aOriginalSize = pActWin->LogicToLogic(
-rGraphic.GetPrefSize(), , 
 );
-bDo = true;
-}
-}
+aOriginalSize = pSdrGrafObj->getOriginalSize();
+bDo = true;
 }
 
 if ( bDo )


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

2023-06-27 Thread Tibor Nagy (via logerrit)
 sc/qa/unit/data/xlsx/tdf156028.xlsx|binary
 sc/qa/unit/subsequent_filters_test.cxx |   11 +++
 sc/source/core/data/colorscale.cxx |2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)

New commits:
commit 3e0537a6e746db6ea746af6b91f94aeb9d2b05d9
Author: Tibor Nagy 
AuthorDate: Mon Jun 26 11:35:38 2023 +0200
Commit: László Németh 
CommitDate: Tue Jun 27 14:09:27 2023 +0200

tdf#156028 sc: use color of the highest value if only one value

(in a single cell or the same value repeating in all cells of the
data set) on percentile color scale, like other spreadsheets do.

This is a follow up to commit 6a059f8d1b0a7a5b64bd272e1e7b8291979bcd56
(tdf#155321 sc: fix color of the highest value on percentile color scale
if the highest value occurs multiple times in the data set.)

Change-Id: I630df332e403705e8338e3441af093c2de95c280
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153577
Reviewed-by: László Németh 
Tested-by: László Németh 

diff --git a/sc/qa/unit/data/xlsx/tdf156028.xlsx 
b/sc/qa/unit/data/xlsx/tdf156028.xlsx
new file mode 100644
index ..6fc2fc814fe3
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf156028.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters_test.cxx 
b/sc/qa/unit/subsequent_filters_test.cxx
index f633073c85f9..d02ebc075e3e 100644
--- a/sc/qa/unit/subsequent_filters_test.cxx
+++ b/sc/qa/unit/subsequent_filters_test.cxx
@@ -134,6 +134,17 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest, 
testTdf155321_CondFormatColor_XLSX)
 CPPUNIT_ASSERT_EQUAL(Color(99, 190, 123), aColor);
 }
 
+CPPUNIT_TEST_FIXTURE(ScFiltersTest, testTdf156028_ColorScale_XLSX)
+{
+createScDoc("xlsx/tdf156028.xlsx");
+
+ScDocument* pDoc = getScDoc();
+ScConditionalFormat* pCondFormat = pDoc->GetCondFormat(0, 0, 0);
+ScRefCellValue aCellA1(*pDoc, ScAddress(0, 0, 0));
+Color aColor = pCondFormat->GetData(aCellA1, ScAddress(0, 0, 
0)).mxColorScale.value();
+CPPUNIT_ASSERT_EQUAL(Color(99, 190, 123), aColor);
+}
+
 CPPUNIT_TEST_FIXTURE(ScFiltersTest, testTdf138601_CondFormatXLSX)
 {
 createScDoc("xlsx/tdf138601.xlsx");
diff --git a/sc/source/core/data/colorscale.cxx 
b/sc/source/core/data/colorscale.cxx
index 4e61dbdbc228..20ea2b5186f6 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -647,7 +647,7 @@ std::optional ScColorScaleFormat::GetColor( const 
ScAddress& rAddr ) cons
 calcMinMax(nMin, nMax);
 
 // this check is for safety
-if(nMin >= nMax)
+if(nMin > nMax)
 return std::optional();
 
 ScColorScaleEntries::const_iterator itr = begin();


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

2023-06-17 Thread Balazs Varga (via logerrit)
 sc/qa/unit/data/xlsx/tdf155402.xlsx |binary
 sc/qa/unit/subsequent_filters_test4.cxx |   13 
 sc/source/core/tool/interpr1.cxx|   50 +++-
 3 files changed, 56 insertions(+), 7 deletions(-)

New commits:
commit 5c7196acbdd949005c1b52aeab34b5448e09011e
Author: Balazs Varga 
AuthorDate: Wed Jun 14 23:01:26 2023 +0200
Commit: Balazs Varga 
CommitDate: Sat Jun 17 15:59:02 2023 +0200

tdf#155402 - sc improving CELL() function return value in case of OOXML

In case of Excel/OOXML formula syntax:
Before the patch =CELL("FILENAME";D2) returns 
'file:///X:/dr/own.ods'#$Sheet1
After the patch =CELL("FILENAME";D2) returns file:///X:/dr/[own.ods]Sheet1

Change-Id: I34c805aef813632c45ac3fe930d690ae3c1d5d96
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153098
Tested-by: Jenkins
Reviewed-by: Balazs Varga 

diff --git a/sc/qa/unit/data/xlsx/tdf155402.xlsx 
b/sc/qa/unit/data/xlsx/tdf155402.xlsx
new file mode 100644
index ..c1f73562547f
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf155402.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters_test4.cxx 
b/sc/qa/unit/subsequent_filters_test4.cxx
index d6b853607e51..646b1e66f5b7 100644
--- a/sc/qa/unit/subsequent_filters_test4.cxx
+++ b/sc/qa/unit/subsequent_filters_test4.cxx
@@ -1905,6 +1905,19 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testForcepoint107)
 pDocSh->DoHardRecalc();
 }
 
+CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testTdf155402)
+{
+createScDoc("xlsx/tdf155402.xlsx");
+ScDocument* pDoc = getScDoc();
+
+// Before the fix =CELL("FILENAME"; D2) returns 
'file:///X:/dr/own.ods'#$Sheet1
+// After the fix =CELL("FILENAME"; D2) returns file 
:///X:/dr/[own.ods]Sheet1
+OUString aFilename = pDoc->GetString(1, 0, 0);
+sal_Int32 nPos = aFilename.lastIndexOf('/');
+aFilename = OUString::Concat(aFilename.subView(nPos));
+CPPUNIT_ASSERT_EQUAL(OUString("/[tdf155402.xlsx]Sheet1"), aFilename);
+}
+
 ScFiltersTest4::ScFiltersTest4()
 : ScModelTestBase("sc/qa/unit/data")
 {
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 2f48398827ed..bf8c89d0d125 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2331,7 +2331,7 @@ void ScInterpreter::ScCell()
 PushString(aStr);
 }
 else if( aInfoType == "FILENAME" )
-{   // file name and table name: 'FILENAME'#$TABLE
+{
 SCTAB nTab = aCellPos.Tab();
 OUString aFuncResult;
 if( nTab < mrDoc.GetTableCount() )
@@ -2346,9 +2346,27 @@ void ScInterpreter::ScCell()
 const INetURLObject& rURLObj = 
pShell->GetMedium()->GetURLObject();
 OUString aTabName;
 mrDoc.GetName( nTab, aTabName );
-aFuncResult = "'"
-+ 
rURLObj.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous)
-+ "'#$" + aTabName;
+
+FormulaGrammar::AddressConvention eConv = 
maCalcConfig.meStringRefAddressSyntax;
+if (eConv == FormulaGrammar::CONV_UNSPECIFIED)
+eConv = mrDoc.GetAddressConvention();
+
+if (eConv == FormulaGrammar::CONV_XL_A1 ||
+eConv == FormulaGrammar::CONV_XL_R1C1 ||
+eConv == FormulaGrammar::CONV_XL_OOX)
+{
+// file name and table name: 
FILEPATH/[FILENAME]TABLE
+aFuncResult = rURLObj.GetPartBeforeLastName()
++ "[" + 
rURLObj.GetLastName(INetURLObject::DecodeMechanism::Unambiguous)
++ "]" + aTabName;
+}
+else
+{
+// file name and table name: 
'FILEPATH/FILENAME'#$TABLE
+aFuncResult = "'"
++ 
rURLObj.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous)
++ "'#$" + aTabName;
+}
 }
 }
 }
@@ -2515,8 +2533,6 @@ void ScInterpreter::ScCellExternal()
 }
 else if ( aInfoType == "FILENAME" )
 {
-// 'file URI'#$SheetName
-
 const OUString* p = pRefMgr->getExternalFileName(nFileId);
 if (!p)
 {
@@ -2525,7 +2541,27 @@ void ScInterpreter::ScCellExternal()
 return;
 }
 
-OUString aBuf = "'" + *p + "'#$" + aTabName;
+OUString aBuf;
+FormulaGrammar::AddressConvention eConv = 
maCalcConfig.meStringRefAddressSyntax;
+if (eConv == FormulaGrammar::CONV_UNSPECIFIED)
+eConv = mrDoc.GetAddressConvention();
+
+if (eConv == FormulaGrammar::CONV_XL_A1 ||
+eConv 

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

2023-06-02 Thread Baole Fang (via logerrit)
 sc/qa/uitest/calc_tests8/tdf132026.py |   44 ++
 sc/qa/uitest/data/tdf132026.ods   |binary
 sc/source/ui/view/tabvwsha.cxx|   12 ++---
 3 files changed, 53 insertions(+), 3 deletions(-)

New commits:
commit 0450c7177f61ba5be15f7b4175b9fb5e89f850ae
Author: Baole Fang 
AuthorDate: Sun May 28 10:28:24 2023 -0400
Commit: Mike Kaganski 
CommitDate: Fri Jun 2 20:02:39 2023 +0200

tdf#132026: Fix selection in text cell

Change-Id: Ic2bf869efa198cba83d1b781b419c3a9e0e606f3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152356
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sc/qa/uitest/calc_tests8/tdf132026.py 
b/sc/qa/uitest/calc_tests8/tdf132026.py
new file mode 100644
index ..abd3a86e720b
--- /dev/null
+++ b/sc/qa/uitest/calc_tests8/tdf132026.py
@@ -0,0 +1,44 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_url_for_data_file
+from libreoffice.calc.document import get_cell_by_position
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+class tdf132026(UITestCase):
+
+def test_tdf132026(self):
+with self.ui_test.load_file(get_url_for_data_file("tdf132026.ods")) as 
calc_doc:
+MainWindow = self.xUITest.getTopFocusWindow()
+grid_window = MainWindow.getChild("grid_window")
+
+chars=["=","+","-"]
+directions=["UP","DOWN","LEFT","RIGHT"]
+
+# format general, should select cell
+for c in chars:
+sign=-1 if c=="-" else 1
+for i,direction in enumerate(directions):
+grid_window.executeAction("SELECT", 
mkPropertyValues({"CELL": "B2"}))
+grid_window.executeAction("TYPE", 
mkPropertyValues({"TEXT": c}))
+grid_window.executeAction("TYPE", 
mkPropertyValues({"KEYCODE": direction}))
+grid_window.executeAction("TYPE", 
mkPropertyValues({"KEYCODE": "RETURN"}))
+self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 
1).getString(), str(sign*(i+1)))
+
+# format text, shouldn't select cell
+for c in chars:
+for direction in directions:
+grid_window.executeAction("SELECT", 
mkPropertyValues({"CELL": "E2"}))
+grid_window.executeAction("TYPE", 
mkPropertyValues({"TEXT": c}))
+grid_window.executeAction("TYPE", 
mkPropertyValues({"KEYCODE": direction}))
+grid_window.executeAction("TYPE", 
mkPropertyValues({"KEYCODE": "RETURN"}))
+self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 
1).getString(), c)
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/data/tdf132026.ods b/sc/qa/uitest/data/tdf132026.ods
new file mode 100644
index ..03c6c654fdc5
Binary files /dev/null and b/sc/qa/uitest/data/tdf132026.ods differ
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 4021f1937f91..f1305672a096 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -640,13 +640,19 @@ bool ScTabViewShell::IsRefInputMode() const
 ScInputHandler* pHdl = pScMod->GetInputHdl();
 if ( pHdl )
 {
+const ScViewData& rViewData = GetViewData();
+ScDocument& rDoc = rViewData.GetDocument();
+const ScAddress aPos( rViewData.GetCurPos() );
+const sal_uInt32 nIndex = rDoc.GetAttr(aPos, ATTR_VALUE_FORMAT 
)->GetValue();
+const SvNumFormatType nType = 
rDoc.GetFormatTable()->GetType(nIndex);
+if (nType == SvNumFormatType::TEXT)
+{
+return false;
+}
 OUString aString = pHdl->GetEditString();
 if ( !pHdl->GetSelIsRef() && aString.getLength() > 1 &&
  ( aString[0] == '+' || aString[0] == '-' ) )
 {
-const ScViewData& rViewData = GetViewData();
-ScDocument& rDoc = rViewData.GetDocument();
-const ScAddress aPos( rViewData.GetCurPos() );
 ScCompiler aComp( rDoc, aPos, rDoc.GetGrammar() );
 aComp.SetCloseBrackets( false );
 std::unique_ptr 
pArr(aComp.CompileString(aString));


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

2023-06-02 Thread Baole Fang (via logerrit)
 sc/qa/uitest/calc_tests8/tdf131638.py |   26 ++
 sc/qa/uitest/data/tdf131638.ods   |binary
 sc/source/ui/view/viewfunc.cxx|   10 +-
 3 files changed, 31 insertions(+), 5 deletions(-)

New commits:
commit 730e6fa063fccbd12913362dd5d3c74ea14957be
Author: Baole Fang 
AuthorDate: Sat May 27 21:05:01 2023 -0400
Commit: Mike Kaganski 
CommitDate: Fri Jun 2 10:22:10 2023 +0200

tdf#131638: Fix text cell incorrect formula

Change-Id: I086f077540f52c6ed5fb4df9f0ea64aa95aea152
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152348
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sc/qa/uitest/calc_tests8/tdf131638.py 
b/sc/qa/uitest/calc_tests8/tdf131638.py
new file mode 100644
index ..bafbfc5d8567
--- /dev/null
+++ b/sc/qa/uitest/calc_tests8/tdf131638.py
@@ -0,0 +1,26 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_url_for_data_file
+from libreoffice.calc.document import get_cell_by_position
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+class tdf137726(UITestCase):
+
+def test_tdf137726(self):
+with self.ui_test.load_file(get_url_for_data_file("tdf131638.ods")) as 
calc_doc:
+MainWindow = self.xUITest.getTopFocusWindow()
+grid_window = MainWindow.getChild("grid_window")
+grid_window.executeAction("SELECT", mkPropertyValues({"CELL": 
"A1"}))
+grid_window.executeAction("TYPE", mkPropertyValues({"TEXT": 
"-/2"}))
+grid_window.executeAction("TYPE", mkPropertyValues({"KEYCODE": 
"RETURN"}))
+self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 
0).getString(), "-/2")
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/data/tdf131638.ods b/sc/qa/uitest/data/tdf131638.ods
new file mode 100644
index ..a66a7e9c9de9
Binary files /dev/null and b/sc/qa/uitest/data/tdf131638.ods differ
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 78080364e928..bc149f62b40e 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -408,8 +408,11 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB 
nTab,
 
 bool bFormula = false;
 
+// do not check formula if it is a text cell
+sal_uInt32 format = rDoc.GetNumberFormat( nCol, nRow, nTab );
+SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
 // a single '=' character is handled as string (needed for special filters)
-if ( rString.getLength() > 1 )
+if ( pFormatter->GetType(format) != SvNumFormatType::TEXT && 
rString.getLength() > 1 )
 {
 if ( rString[0] == '=' )
 {
@@ -431,10 +434,8 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB 
nTab,
 // is non-empty and not a number, handle as formula
 if ( aString.getLength() > 1 )
 {
-sal_uInt32 nFormat = rDoc.GetNumberFormat( nCol, nRow, nTab );
-SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
 double fNumber = 0;
-if ( !pFormatter->IsNumberFormat( aString, nFormat, fNumber ) )
+if ( !pFormatter->IsNumberFormat( aString, format, fNumber ) )
 {
 bFormula = true;
 }
@@ -568,7 +569,6 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB 
nTab,
 
 ScFormulaCell aCell(rDoc, aPos, std::move( pArr ), 
formula::FormulaGrammar::GRAM_DEFAULT, ScMatrixMode::NONE);
 
-SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
 for (const auto& rTab : rMark)
 {
 i = rTab;


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

2023-06-02 Thread Xisco Fauli (via logerrit)
 sc/qa/unit/ucalc.cxx   |4 
 sc/source/core/data/table1.cxx |6 ++
 2 files changed, 6 insertions(+), 4 deletions(-)

New commits:
commit 8731701481de649a65d59e018d0ba0c381f670c3
Author: Xisco Fauli 
AuthorDate: Tue May 30 11:34:21 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Jun 2 08:04:19 2023 +0200

sc: fix bug in GetPrintAreaVer

it should return false when checking a non-exising column.
Since ad2bc869bfe2d34bde7d42e10593db1c5ffccc2a
"tdf#50916 : Refactor table1.cxx wherever there is column access"

Change-Id: I01a53f5fec7e2029badc5c23c1e26fc0723ba0ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152386
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index a1951cdc5b95..f966fdecea18 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5269,6 +5269,10 @@ CPPUNIT_TEST_FIXTURE(Test, testAreasWithNotes)
 CPPUNIT_ASSERT_MESSAGE("No PrintAreaVer found", dataFound);
 CPPUNIT_ASSERT_EQUAL_MESSAGE("PrintAreaVer wrong row for notes", 
static_cast(2), row);
 
+dataFound = m_pDoc->GetPrintAreaVer(0,20,21,row, bNotes); // cols 20 & 21
+CPPUNIT_ASSERT_MESSAGE("PrintAreaVer found", !dataFound);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("PrintAreaVer wrong row for notes", 
static_cast(0), row);
+
 bNotes = false;
 dataFound = m_pDoc->GetPrintAreaVer(0,0,1,row, bNotes); // col 0 & 1
 CPPUNIT_ASSERT_MESSAGE("No PrintAreaVer should be found", !dataFound);
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 6cb5384c05f9..99e0c5f39b0d 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -756,13 +756,11 @@ bool ScTable::GetPrintAreaHor( SCROW nStartRow, SCROW 
nEndRow,
 bool ScTable::GetPrintAreaVer( SCCOL nStartCol, SCCOL nEndCol,
 SCROW& rEndRow, bool bNotes ) const
 {
-nStartCol = std::min( nStartCol, aCol.size()-1 );
-nEndCol   = std::min( nEndCol,   aCol.size()-1 );
 bool bFound = false;
 SCROW nMaxY = 0;
 SCCOL i;
 
-for (i=nStartCol; i<=nEndCol; i++)  // Test attribute
+for (i=nStartCol; i<=nEndCol && i < aCol.size(); i++)  // Test 
attribute
 {
 SCROW nLastRow;
 if (aCol[i].GetLastVisibleAttr( nLastRow ))
@@ -773,7 +771,7 @@ bool ScTable::GetPrintAreaVer( SCCOL nStartCol, SCCOL 
nEndCol,
 }
 }
 
-for (i=nStartCol; i<=nEndCol; i++)  // Test data
+for (i=nStartCol; i<=nEndCol && i < aCol.size(); i++)  // Test 
data
 {
 if (!aCol[i].IsEmptyData())
 {


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

2023-06-01 Thread Czeber László Ádám (via logerrit)
 sc/qa/uitest/calc_tests9/tdf154174.py |   35 ++
 sc/source/ui/view/viewfunc.cxx|2 +
 2 files changed, 37 insertions(+)

New commits:
commit a5c1b749a89b662f9a136d774b3dfd5fbd639c50
Author: Czeber László Ádám 
AuthorDate: Wed May 31 13:06:50 2023 +0200
Commit: László Németh 
CommitDate: Thu Jun 1 09:55:40 2023 +0200

tdf#154174 sc: fix input line to update to the repeated content

Repeating the last text edit by Repeat, e.g. by pressing
Ctrl-Shift-Y, the input line still contained the old content
of the cell, and only updated to the new content after moving
the cursor to another cell and back. Now the input line is updated
automatically, and the actual content of the cell can be modified
immediately by pressing F2 or clicking in the input line.

Change-Id: Ia38b833ff77c75d37700715638aa71c7f1863e91
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152423
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/uitest/calc_tests9/tdf154174.py 
b/sc/qa/uitest/calc_tests9/tdf154174.py
new file mode 100644
index ..3cb0da9ea2a3
--- /dev/null
+++ b/sc/qa/uitest/calc_tests9/tdf154174.py
@@ -0,0 +1,35 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+from uitest.framework import UITestCase
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from libreoffice.calc.document import get_cell_by_position
+from uitest.uihelper.calc import enter_text_to_cell
+
+#Bug 154174 - empty edit cell after fill (Ctrl+Shft+Y)
+
+class tdf154174(UITestCase):
+def test_tdf154174_repeat_empty(self):
+with self.ui_test.create_doc_in_start_center("calc") as document:
+xCalcDoc = self.xUITest.getTopFocusWindow()
+gridwin = xCalcDoc.getChild("grid_window")
+# enter data
+enter_text_to_cell(gridwin, "A1", "")
+# focus on A2
+gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"}))
+# repeat (Ctrl+Shft+Y)
+gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": 
"SHIFT+CTRL+Y"}))
+# edit A2 data
+gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F2"}))
+# if is empty, then erased, else unchanged
+gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": 
"DELETE"}))
+gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": 
"RETURN"}))
+# test A2
+self.assertEqual(get_cell_by_position(document, 0, 0, 
1).getString(), "")
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 204d5d31bae7..78080364e928 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -832,6 +832,8 @@ void ScViewFunc::EnterDataAtCursor( const OUString& rString 
)
 SCTAB nTab = GetViewData().GetTabNo();
 
 EnterData( nPosX, nPosY, nTab, rString );
+// tdf#154174: update repeated data in the cell
+GetViewData().GetViewShell()->UpdateInputHandler();
 }
 
 void ScViewFunc::EnterMatrix( const OUString& rString, 
::formula::FormulaGrammar::Grammar eGram )


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

2023-05-31 Thread Czeber László Ádám (via logerrit)
 sc/qa/unit/ucalc_copypaste.cxx |   43 +
 sc/source/core/data/table1.cxx |9 ++--
 2 files changed, 50 insertions(+), 2 deletions(-)

New commits:
commit 7be7e1ff95af485a9cb00748800d3d084f96387c
Author: Czeber László Ádám 
AuthorDate: Wed May 24 09:05:16 2023 +0200
Commit: László Németh 
CommitDate: Wed May 31 11:49:58 2023 +0200

tdf#153437 sc: fix broken formatting at Undo of row/column insertion

Performance fix for the 16k rows resulted broken
formatting during Undo of row insertion, e.g. rows
with background color fell apart, highlighting partially
also the row under the deleted row removed by Undo, or
Undo of inserted/copied columns removed the background
coloring at the place of the removed columns.

Formatting was always deleted after the last column
containing data, because the row was only allocated until
then. When deleting row(s) or column(s), allocate the last
column before updating the references.

Regression from commit 2e86718626a07e1656661df3ad69a64848bf4614
"don't allocate unnecessary columns when inserting a row".

Change-Id: I8d74d59ff0051fdfe183e14a16d987edc71d55e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152185
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/unit/ucalc_copypaste.cxx b/sc/qa/unit/ucalc_copypaste.cxx
index 695b5b8f6214..bad57d8646a7 100644
--- a/sc/qa/unit/ucalc_copypaste.cxx
+++ b/sc/qa/unit/ucalc_copypaste.cxx
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -10709,6 +10710,48 @@ CPPUNIT_TEST_FIXTURE(TestCopyPaste, 
testCopyPasteMatrixFormula)
 m_pDoc->DeleteTab(0);
 }
 
+CPPUNIT_TEST_FIXTURE(TestCopyPaste, testUndoBackgroundColor)
+{
+m_pDoc->InsertTab(0, "Table1");
+
+ScDocument aClipDoc(SCDOCMODE_CLIP);
+ScMarkData aMark(m_pDoc->GetSheetLimits());
+
+// Set Values to B1, C2, D5
+m_pDoc->SetValue(ScAddress(1, 0, 0), 1.0); // B1
+m_pDoc->SetValue(ScAddress(2, 1, 0), 2.0); // C2
+m_pDoc->SetValue(ScAddress(3, 4, 0), 3.0); // D5
+
+// Add patterns
+ScPatternAttr aCellBlueColor(m_pDoc->GetPool());
+aCellBlueColor.GetItemSet().Put(SvxBrushItem(COL_BLUE, ATTR_BACKGROUND));
+m_pDoc->ApplyPatternAreaTab(0, 3, m_pDoc->MaxCol(), 3, 0, aCellBlueColor);
+
+// Insert a new row at row 3
+ScRange aRowOne(0, 2, 0, m_pDoc->MaxCol(), 2, 0);
+aMark.SetMarkArea(aRowOne);
+ScDocFunc& rFunc = m_xDocShell->GetDocFunc();
+rFunc.InsertCells(aRowOne, , INS_INSROWS_BEFORE, true, true);
+
+// Check patterns
+const SfxPoolItem* pItem = nullptr;
+m_pDoc->GetPattern(ScAddress(1000, 4, 
0))->GetItemSet().HasItem(ATTR_BACKGROUND, );
+CPPUNIT_ASSERT(pItem);
+CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast(pItem)->GetColor());
+
+// Undo the new row
+m_pDoc->GetUndoManager()->Undo();
+
+// Check patterns
+// Failed if row 3 is not blue all the way through
+pItem = nullptr;
+m_pDoc->GetPattern(ScAddress(1000, 3, 
0))->GetItemSet().HasItem(ATTR_BACKGROUND, );
+CPPUNIT_ASSERT(pItem);
+CPPUNIT_ASSERT_EQUAL(COL_BLUE, static_cast(pItem)->GetColor());
+
+m_pDoc->DeleteTab(0);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 78c49912bcc9..6cb5384c05f9 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1851,8 +1851,13 @@ void ScTable::UpdateReference(
 }
 else
 {
-for( SCCOL col : GetAllocatedColumnsRange( 0, rDocument.MaxCol()))
-bUpdated |= aCol[col].UpdateReference(rCxt, pUndoDoc);
+// When deleting row(s) or column(s), allocate the last column
+// before updating the references
+if (nDx < 0 || nDy < 0)
+CreateColumnIfNotExists(rDocument.MaxCol());
+
+for (SCCOL col : GetColumnsRange(0, rDocument.MaxCol()))
+bUpdated |= CreateColumnIfNotExists(col).UpdateReference(rCxt, 
pUndoDoc);
 }
 
 if ( bIncludeDraw )


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

2023-05-23 Thread Czeber László Ádám (via logerrit)
 sc/qa/unit/data/xlsx/tdf100034.xlsx|binary
 sc/qa/unit/subsequent_export_test4.cxx |   16 
 sc/source/filter/excel/xename.cxx  |5 +
 3 files changed, 21 insertions(+)

New commits:
commit 639519dc2bad058197b6ff73c9e3df622f979f97
Author: Czeber László Ádám 
AuthorDate: Mon May 22 09:58:29 2023 +0200
Commit: László Németh 
CommitDate: Tue May 23 12:15:56 2023 +0200

tdf#100034: Fix to persistently remove print-range

Don't save print range if the builtin index is unknow
and sheet index is vaild (this is a deleted range).

Change-Id: I10dfa98ad4f24d0f5958053974bd75cb19c85147
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152081
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/unit/data/xlsx/tdf100034.xlsx 
b/sc/qa/unit/data/xlsx/tdf100034.xlsx
new file mode 100644
index ..b053a34bca43
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf100034.xlsx differ
diff --git a/sc/qa/unit/subsequent_export_test4.cxx 
b/sc/qa/unit/subsequent_export_test4.cxx
index 46ea2547eadc..9d7dddc99c78 100644
--- a/sc/qa/unit/subsequent_export_test4.cxx
+++ b/sc/qa/unit/subsequent_export_test4.cxx
@@ -1697,6 +1697,22 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf152980)
 CPPUNIT_ASSERT_EQUAL(OUString("a\n\nb"), pDoc->GetString(0, 7, 0));
 }
 
+CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf100034)
+{
+createScDoc("xlsx/tdf100034.xlsx");
+ScDocument* pDoc = getScDoc();
+
+// Clear print ranges
+pDoc->ClearPrintRanges(0);
+
+// Save and load back
+saveAndReload("Calc Office Open XML");
+
+// Check if the same print ranges are present
+pDoc = getScDoc();
+CPPUNIT_ASSERT_EQUAL(static_cast(0), 
pDoc->GetPrintRangeCount(0));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/excel/xename.cxx 
b/sc/source/filter/excel/xename.cxx
index 4e837a97fadf..5ce4a2ff18c4 100644
--- a/sc/source/filter/excel/xename.cxx
+++ b/sc/source/filter/excel/xename.cxx
@@ -324,6 +324,11 @@ OUString XclExpName::GetWithDefaultRangeSeparator( const 
OUString& rSymbol ) con
 
 void XclExpName::SaveXml( XclExpXmlStream& rStrm )
 {
+// tdf#100034: Don't save print range if the built-in index is unknown
+// and sheet index is valid (this is a deleted range)
+if (mcBuiltIn == EXC_BUILTIN_UNKNOWN && mnScTab != SCTAB_GLOBAL)
+return;
+
 sax_fastparser::FSHelperPtr& rWorkbook = rStrm.GetCurrentStream();
 rWorkbook->startElement( XML_definedName,
 // OOXTODO: XML_comment, "",


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

2023-05-20 Thread Dennis Francis (via logerrit)
 sc/qa/unit/data/xlsx/tablerefsnamed.xlsx |binary
 sc/qa/unit/subsequent_filters_test2.cxx  |   15 ++
 sc/source/core/tool/interpr1.cxx |   43 +++
 3 files changed, 48 insertions(+), 10 deletions(-)

New commits:
commit 4536694edb7e564ea1f4ae871e9107f52ed0972f
Author: Dennis Francis 
AuthorDate: Sat May 13 13:37:39 2023 +0530
Commit: Dennis Francis 
CommitDate: Sat May 20 17:07:21 2023 +0200

tdf#155369 ScIndirect: handle names that resolve to...

table structured references.

Conflicts:
sc/qa/unit/subsequent_filters_test2.cxx

Change-Id: I897feeeb49e63c1758cf64450799acb192e2d593
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151888
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/qa/unit/data/xlsx/tablerefsnamed.xlsx 
b/sc/qa/unit/data/xlsx/tablerefsnamed.xlsx
new file mode 100644
index ..825103d54993
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tablerefsnamed.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx 
b/sc/qa/unit/subsequent_filters_test2.cxx
index cd5f073f46c4..a00558730d0b 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -1565,6 +1565,21 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest2, 
testBorderDirectionsXLSXML)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(ScFiltersTest2, testNamedTableRef)
+{
+createScDoc("xlsx/tablerefsnamed.xlsx");
+ScDocument* pDoc = getScDoc();
+for (sal_Int32 nRow = 1; nRow < 7; ++nRow)
+{
+ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(5, nRow, 0));
+CPPUNIT_ASSERT(pFC);
+// Without the fix there will be #REF in F2:F7.
+CPPUNIT_ASSERT_EQUAL(FormulaError::NONE, pFC->GetErrCode());
+// Without the fix value will be 0 (FALSE).
+CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(ScAddress(6, nRow, 0)));
+}
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 9e2277f60392..2f48398827ed 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8187,6 +8187,12 @@ void ScInterpreter::ScDBVarP()
 PushDouble(fVal/fCount);
 }
 
+static bool lcl_IsTableStructuredRef(const OUString& sRefStr, sal_Int32& 
nIndex)
+{
+nIndex = ScGlobal::FindUnquoted(sRefStr, '[');
+return (nIndex > 0 && ScGlobal::FindUnquoted(sRefStr, ']', nIndex + 1) > 
nIndex);
+}
+
 void ScInterpreter::ScIndirect()
 {
 sal_uInt8 nParamCount = GetByte();
@@ -8223,6 +8229,10 @@ void ScInterpreter::ScIndirect()
 const ScAddress::Details aDetailsXlA1( FormulaGrammar::CONV_XL_A1, aPos );
 SCTAB nTab = aPos.Tab();
 
+bool bTableRefNamed = false;
+sal_Int32 nTableRefNamedIndex = -1;
+OUString sTabRefStr;
+
 // Named expressions and DB range names need to be tried first, as older 1K
 // columns allowed names that would now match a 16k columns cell address.
 do
@@ -8238,8 +8248,14 @@ void ScInterpreter::ScIndirect()
 
 // This is the usual way to treat named ranges containing
 // relative references.
-if (!pData->IsReference( aRange, aPos))
+if (!pData->IsReference(aRange, aPos))
+{
+sTabRefStr = pData->GetSymbol();
+bTableRefNamed = lcl_IsTableStructuredRef(sTabRefStr, 
nTableRefNamedIndex);
+// if bTableRefNamed is true, we have a name that maps to a table 
structured reference.
+// Such a case is handled below.
 break;
+}
 
 if (aRange.aStart == aRange.aEnd)
 PushSingleRef( aRange.aStart.Col(), aRange.aStart.Row(),
@@ -8256,6 +8272,9 @@ void ScInterpreter::ScIndirect()
 
 do
 {
+if (bTableRefNamed)
+break;
+
 const OUString & aName( sSharedRefStr.getIgnoreCaseString() );
 ScDBCollection::NamedDBs& rDBs = 
mrDoc.GetDBCollection()->getNamedDBs();
 const ScDBData* pData = rDBs.findByUpperName( aName);
@@ -8291,9 +8310,10 @@ void ScInterpreter::ScIndirect()
 
 ScRefAddress aRefAd, aRefAd2;
 ScAddress::ExternalInfo aExtInfo;
-if ( ConvertDoubleRef(mrDoc, sRefStr, nTab, aRefAd, aRefAd2, aDetails, 
) ||
- ( bTryXlA1 && ConvertDoubleRef(mrDoc, sRefStr, nTab, aRefAd,
-aRefAd2, aDetailsXlA1, ) ) )
+if ( !bTableRefNamed &&
+ (ConvertDoubleRef(mrDoc, sRefStr, nTab, aRefAd, aRefAd2, aDetails, 
) ||
+( bTryXlA1 && ConvertDoubleRef(mrDoc, sRefStr, nTab, aRefAd,
+   aRefAd2, aDetailsXlA1, ) ) 
) )
 {
 if (aExtInfo.mbExternal)
 {
@@ -8305,9 +8325,10 @@ void ScInterpreter::ScIndirect()
 else
 PushDoubleRef( aRefAd, aRefAd2);
 }
-else if ( ConvertSingleRef(mrDoc, sRefStr, nTab, aRefAd, aDetails, 
) ||
-  ( bTryXlA1 && ConvertSingleRef 

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

2023-05-18 Thread Regina Henschel (via logerrit)
 sc/qa/unit/data/ods/tdf154821_shape_in_group.ods |binary
 sc/qa/unit/scshapetest.cxx   |   46 
 sc/source/core/data/drwlayer.cxx |   24 +-
 sc/source/filter/xml/xmlexprt.cxx|  230 +++
 4 files changed, 173 insertions(+), 127 deletions(-)

New commits:
commit 800f9233513a45aa8f8950cf929fd44cb9381d72
Author: Regina Henschel 
AuthorDate: Sat May 13 01:36:44 2023 +0200
Commit: Regina Henschel 
CommitDate: Thu May 18 14:45:48 2023 +0200

tdf#154821 improve shape export with hidden row/col

XML needs shape geometry so as if no rows/cols are hidden. This had
been calculated by using the shape start and end cell. But that did
not work in some cases. Now the snap rectangle of the shape is used.

During testing I noticed, that the fix in tdf#154005 does not work
correctly. The fix had provided only a workaround for controls. It did
not address the root cause that a shape was size protected but has an
anchor 'To Cell (resize with cell)' at the same time. Such combination
is no longer needed as we have 'To Cell' anchor now, but shapes using
it still exist. The current solution catches such cases now in general.

As large parts of the method are changed anyway, I have put existance
tests at the beginning. That allows shorter conditions and flattens
if-constructions.

Change-Id: I6bd1e15dbdafc43e309a6e12c1c5e3218bb12675
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151717
Tested-by: Jenkins
Reviewed-by: Regina Henschel 

diff --git a/sc/qa/unit/data/ods/tdf154821_shape_in_group.ods 
b/sc/qa/unit/data/ods/tdf154821_shape_in_group.ods
new file mode 100644
index ..905a64418cf6
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf154821_shape_in_group.ods 
differ
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index 0e4f1b555f99..21406c52cc7d 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -1169,6 +1169,52 @@ CPPUNIT_TEST_FIXTURE(ScShapeTest, 
testTdf125938_anchor_after_copy_paste)
 CPPUNIT_ASSERT_EQUAL(aExpectedAddress, (*pObjData).maStart);
 }
 
+CPPUNIT_TEST_FIXTURE(ScShapeTest, testTdf154821_shape_in_group)
+{
+// The document contains a shape in A7, a group spanning rows 2 to 4 and a 
second group spanning
+// rows 6 to 10. Error was, that when the document was saved with 
collapsed groups, the shape
+// lost its position.
+createScDoc("ods/tdf154821_shape_in_group.ods");
+
+// Get snap rectangle before collapse and save
+ScDocument* pDoc = getScDoc();
+SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
+tools::Rectangle aRectOrig = pObj->GetSnapRect();
+
+// Collapse the lower group
+ScTabViewShell* pViewShell = getViewShell();
+pViewShell->GetViewData().SetCurX(0);
+pViewShell->GetViewData().SetCurY(5);
+pViewShell->GetViewData().GetDispatcher().Execute(SID_OUTLINE_HIDE);
+// Collapse the upper group
+pViewShell->GetViewData().SetCurX(0);
+pViewShell->GetViewData().SetCurY(1);
+pViewShell->GetViewData().GetDispatcher().Execute(SID_OUTLINE_HIDE);
+
+// Save and reload
+// FIXME: validation fails with
+// Error: unexpected attribute "drawooo:display"
+skipValidation();
+saveAndReload("calc8");
+
+// Expand the lower group
+pViewShell = getViewShell();
+pViewShell->GetViewData().SetCurX(0);
+pViewShell->GetViewData().SetCurY(5);
+pViewShell->GetViewData().GetDispatcher().Execute(SID_OUTLINE_SHOW);
+// Expande the upper group
+pViewShell = getViewShell();
+pViewShell->GetViewData().SetCurX(0);
+pViewShell->GetViewData().SetCurY(1);
+pViewShell->GetViewData().GetDispatcher().Execute(SID_OUTLINE_SHOW);
+
+// Verify shape position is not changed besides rounding errors from 
twips<->mm
+pDoc = getScDoc();
+pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
+tools::Rectangle aRectReload = pObj->GetSnapRect();
+CPPUNIT_ASSERT_RECTANGLE_EQUAL_WITH_TOLERANCE(aRectOrig, aRectReload, 1);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 134c7258ed4a..8e989012b4e8 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -776,15 +776,6 @@ void lcl_SetLogicRectFromAnchor(SdrObject* pObj, const 
ScDrawObjData& rAnchor, c
 if (!pObj || !pDoc || !rAnchor.maEnd.IsValid() || 
!rAnchor.maStart.IsValid())
 return;
 
-SCROW nHiddenRows = 0;
-SCCOL nHiddenCols = 0;
-// tdf#154005: Handle hidden row/col: remove hidden row/cols size from the 
ScDrawObjData shape size in case of forms
-if (pObj->GetObjIdentifier() == SdrObjKind::UNO && pObj->GetObjInventor() 
== SdrInventor::FmForm)
-{
-nHiddenRows = pDoc->CountHiddenRows(rAnchor.maStart.Row(), 
rAnchor.maEnd.Row(), 

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

2023-05-16 Thread Andreas Heinisch (via logerrit)
 sc/qa/unit/ucalc_copypaste.cxx   |   14 --
 sc/qa/unit/uicalc/uicalc.cxx |   35 +++
 sc/source/core/data/document.cxx |5 +++--
 3 files changed, 46 insertions(+), 8 deletions(-)

New commits:
commit 535f8fde0c33c435e4a8e9f768003516ce933666
Author: Andreas Heinisch 
AuthorDate: Mon May 15 09:01:21 2023 +0200
Commit: Andreas Heinisch 
CommitDate: Tue May 16 11:05:04 2023 +0200

tdf#141440 - Do not delete notes when pasting contents

Contents include cells with values, datetimes, strings, formulas, outlines, 
and sparklines.

Change-Id: I9acf3a33c7723300d6b85f0abe468db28de6ebcb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151759
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/unit/ucalc_copypaste.cxx b/sc/qa/unit/ucalc_copypaste.cxx
index 43f9272a13c0..695b5b8f6214 100644
--- a/sc/qa/unit/ucalc_copypaste.cxx
+++ b/sc/qa/unit/ucalc_copypaste.cxx
@@ -9407,10 +9407,11 @@ CPPUNIT_TEST_FIXTURE(TestCopyPaste, 
testCopyPasteSkipEmpty)
 
 // Check the content after the paste.
 {
+// tdf#141440 - do not delete notes when pasting contents
 static const Check aChecks[] = {
-{ "Clip1", COL_YELLOW, false }, { "B", COL_BLUE, true },
-{ "Clip2", COL_YELLOW, false }, { "D", COL_BLUE, true },
-{ "Clip3", COL_YELLOW, false },
+{ "Clip1", COL_YELLOW, true }, { "B", COL_BLUE, true },
+{ "Clip2", COL_YELLOW, true }, { "D", COL_BLUE, true },
+{ "Clip3", COL_YELLOW, true },
 };
 
 bool bRes
@@ -9434,10 +9435,11 @@ CPPUNIT_TEST_FIXTURE(TestCopyPaste, 
testCopyPasteSkipEmpty)
 // Redo, and check the content again.
 aUndo.Redo();
 {
+// tdf#141440 - do not delete notes when pasting contents
 static const Check aChecks[] = {
-{ "Clip1", COL_YELLOW, false }, { "B", COL_BLUE, true },
-{ "Clip2", COL_YELLOW, false }, { "D", COL_BLUE, true },
-{ "Clip3", COL_YELLOW, false },
+{ "Clip1", COL_YELLOW, true }, { "B", COL_BLUE, true },
+{ "Clip2", COL_YELLOW, true }, { "D", COL_BLUE, true },
+{ "Clip3", COL_YELLOW, true },
 };
 
 bool bRes
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index d3ae6e4d02fe..a6854ae76d56 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -1893,6 +1893,41 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf150219)
 CPPUNIT_ASSERT_EQUAL(OUString(""), pDoc->GetString(ScAddress(0, 0, 1)));
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf141440)
+{
+createScDoc();
+ScDocument* pDoc = getScDoc();
+
+// Insert a note to cell A1
+goToCell("A1");
+uno::Sequence aArgs
+= comphelper::InitPropertySequence({ { "Text", uno::Any(OUString("Note 
in A1")) } });
+dispatchCommand(mxComponent, ".uno:InsertAnnotation", aArgs);
+
+// Insert a formula to cell A2
+insertStringToCell("A2", u"=1+1");
+CPPUNIT_ASSERT_EQUAL(OUString("2"), pDoc->GetString(ScAddress(0, 1, 0)));
+
+// Copy content of A2 to A1 using paste special command as a formula 
(Flags F)
+goToCell("A2");
+dispatchCommand(mxComponent, ".uno:Copy", {});
+goToCell("A1");
+aArgs = comphelper::InitPropertySequence(
+{ { "Flags", uno::Any(OUString("F")) },
+  { "FormulaCommand", uno::Any(sal_uInt16(ScPasteFunc::ADD)) },
+  { "SkipEmptyCells", uno::Any(false) },
+  { "Transpose", uno::Any(false) },
+  { "AsLink", uno::Any(false) },
+  { "MoveMode", uno::Any(sal_uInt16(InsCellCmd::INS_NONE)) } });
+dispatchCommand(mxComponent, ".uno:InsertContents", aArgs);
+
+// Check if string in cell A2 was copied to cell A1
+CPPUNIT_ASSERT_EQUAL(OUString("2"), pDoc->GetString(ScAddress(0, 0, 0)));
+// Without the fix in place, there would be no note in cell A1 after using 
paste special
+CPPUNIT_ASSERT_MESSAGE("There should be a note on A1", 
pDoc->HasNote(ScAddress(0, 0, 0)));
+CPPUNIT_ASSERT_EQUAL(OUString("Note in A1"), pDoc->GetNote(ScAddress(0, 0, 
0))->GetText());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 25d0363c35f4..cab1dc364b31 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2905,8 +2905,9 @@ void ScDocument::CopyFromClip(
 InsertDeleteFlags nDelFlag = InsertDeleteFlags::NONE;
 if ( (nInsFlag & (InsertDeleteFlags::CONTENTS | 
InsertDeleteFlags::ADDNOTES)) == (InsertDeleteFlags::NOTE | 
InsertDeleteFlags::ADDNOTES) )
 nDelFlag |= InsertDeleteFlags::NOTE;
-else if ( nInsFlag & InsertDeleteFlags::CONTENTS )
-nDelFlag |= InsertDeleteFlags::CONTENTS;
+// tdf#141440 - do not delete notes when pasting contents (see 
InsertDeleteFlags::CONTENTS)
+else if 

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

2023-05-15 Thread Justin Luth (via logerrit)
 sc/qa/unit/data/xls/tdf79542_radioGroupBox.xls |binary
 sc/qa/unit/subsequent_filters_test4.cxx|   20 
 sc/source/filter/excel/xiescher.cxx|   60 +
 sc/source/filter/inc/xiescher.hxx  |6 ++
 4 files changed, 86 insertions(+)

New commits:
commit 25fed4ae027b9680597ea498c25acc3f854db4bf
Author: Justin Luth 
AuthorDate: Thu Aug 4 19:52:23 2022 -0400
Commit: Justin Luth 
CommitDate: Tue May 16 01:01:27 2023 +0200

tdf#79542 xls: applyGroupBox to radiobutton groups

A group box control links radiobuttons together,
and so does a sheet.

No matching unit tests were found.

make CppunitTest_sc_subsequent_filters_test4 \
CPPUNIT_TEST_NAME=testLegacyOptionButtonGroupBox

Change-Id: Ib5b03c68b5218649268f283d11981cc03fe4850a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137838
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sc/qa/unit/data/xls/tdf79542_radioGroupBox.xls 
b/sc/qa/unit/data/xls/tdf79542_radioGroupBox.xls
new file mode 100644
index ..1861913020d3
Binary files /dev/null and b/sc/qa/unit/data/xls/tdf79542_radioGroupBox.xls 
differ
diff --git a/sc/qa/unit/subsequent_filters_test4.cxx 
b/sc/qa/unit/subsequent_filters_test4.cxx
index fcbc02ebe0a3..d6b853607e51 100644
--- a/sc/qa/unit/subsequent_filters_test4.cxx
+++ b/sc/qa/unit/subsequent_filters_test4.cxx
@@ -116,6 +116,26 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testControlImport)
  UNO_QUERY_THROW);
 }
 
+CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testLegacyOptionButtonGroupBox)
+{
+createScDoc("xls/tdf79542_radioGroupBox.xls");
+uno::Reference xDoc(mxComponent, 
UNO_QUERY_THROW);
+uno::Reference xIA(xDoc->getSheets(), 
UNO_QUERY_THROW);
+uno::Reference 
xDrawPageSupplier(xIA->getByIndex(0),
+ 
UNO_QUERY_THROW);
+uno::Reference 
xIA_DrawPage(xDrawPageSupplier->getDrawPage(),
+ UNO_QUERY_THROW);
+
+OUString sGroupName;
+uno::Reference 
xControlShape(xIA_DrawPage->getByIndex(1),
+ UNO_QUERY_THROW);
+uno::Reference 
xPropertySet(xControlShape->getControl(),
+ uno::UNO_QUERY_THROW);
+// The radio buttons are grouped by GroupBoxes - so the name comes from 
the group shape name
+xPropertySet->getPropertyValue("GroupName") >>= sGroupName;
+CPPUNIT_ASSERT_EQUAL(OUString("Casella di gruppo 1"), sGroupName);
+}
+
 CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testActiveXOptionButtonGroup)
 {
 createScDoc("xlsx/tdf111980_radioButtons.xlsx");
diff --git a/sc/source/filter/excel/xiescher.cxx 
b/sc/source/filter/excel/xiescher.cxx
index e9a47fada31c..1805b7a26312 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -378,6 +378,11 @@ void XclImpDrawObjBase::SetAnchor( const XclObjAnchor& 
rAnchor )
 mbHasAnchor = true;
 }
 
+const tools::Rectangle& XclImpDrawObjBase::GetDffRect() const
+{
+return maDffRect;
+}
+
 void XclImpDrawObjBase::SetDffData(
 const DffObjData& rDffObjData, const OUString& rObjName, const OUString& 
rHyperlink,
 bool bVisible, bool bAutoMargin )
@@ -388,6 +393,7 @@ void XclImpDrawObjBase::SetDffData(
 maHyperlink = rHyperlink;
 mbVisible = bVisible;
 mbAutoMargin = bAutoMargin;
+maDffRect = rDffObjData.aChildAnchor;
 }
 
 OUString XclImpDrawObjBase::GetObjName() const
@@ -2086,6 +2092,16 @@ void XclImpTbxObjBase::SetDffProperties( const 
DffPropSet& rDffPropSet )
 ::set_flag( maLineData.mnAuto, EXC_OBJ_FILL_AUTO, false );
 }
 
+void XclImpControlHelper::SetStringProperty(const OUString& sName, const 
OUString& sVal)
+{
+Reference xCtrlModel = 
XclControlHelper::GetControlModel(mxShape);
+if (!xCtrlModel.is())
+return;
+
+ScfPropertySet aProps(xCtrlModel);
+aProps.SetStringProperty(sName, sVal);
+}
+
 bool XclImpTbxObjBase::FillMacroDescriptor( ScriptEventDescriptor& rDescriptor 
) const
 {
 return XclControlHelper::FillMacroDescriptor( rDescriptor, 
DoGetEventType(), GetMacroName(), GetDocShell() );
@@ -2393,6 +2409,11 @@ XclTbxEventType XclImpOptionButtonObj::DoGetEventType() 
const
 return EXC_TBX_EVENT_ACTION;
 }
 
+bool XclImpOptionButtonObj::IsInGroup() const
+{
+return mnNextInGroup;
+}
+
 XclImpLabelObj::XclImpLabelObj( const XclImpRoot& rRoot ) :
 XclImpTbxObjBase( rRoot )
 {
@@ -4070,6 +4091,43 @@ const XclImpObjTextData* XclImpDrawing::FindTextData( 
const DffRecordHeader& rHe
 return nullptr;
 }
 
+void XclImpDrawing::ApplyGroupBoxes()
+{
+// sorted: smallest to largest - looking for smallest contained-in GroupBox
+// multimap: allows duplicate key values - may have identical areas.
+std::multimap aGroupBoxAreaMap;
+for (auto& 

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

2023-05-12 Thread Andreas Heinisch (via logerrit)
 sc/qa/uitest/pasteSpecial/tdf139858.py |   60 +
 sc/source/ui/miscdlgs/inscodlg.cxx |3 +
 2 files changed, 62 insertions(+), 1 deletion(-)

New commits:
commit 28bcb35b12f19858eca3d08559d7914e36ad1d2b
Author: Andreas Heinisch 
AuthorDate: Wed May 10 09:08:47 2023 +0200
Commit: Andreas Heinisch 
CommitDate: Fri May 12 09:01:56 2023 +0200

tdf#139858 - Do not delete existing cell contents when pasting notes

Change-Id: I9befa9e28f70ba767bbd9c4694521964a40c4463
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151603
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/uitest/pasteSpecial/tdf139858.py 
b/sc/qa/uitest/pasteSpecial/tdf139858.py
new file mode 100755
index ..ca81c7715cb6
--- /dev/null
+++ b/sc/qa/uitest/pasteSpecial/tdf139858.py
@@ -0,0 +1,60 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+from uitest.framework import UITestCase
+
+from libreoffice.calc.document import get_cell_by_position
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.calc import enter_text_to_cell
+from libreoffice.calc.paste_special import reset_default_values
+
+class tdf139858(UITestCase):
+def test_tdf139858_paste_comment(self):
+with self.ui_test.create_doc_in_start_center("calc") as document:
+xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window")
+
+# Write text to cell A1 and B1
+enter_text_to_cell(xGridWin, "A1", "A1 sample text")
+enter_text_to_cell(xGridWin, "B1", "B1 sample text")
+
+# Insert a comment in cell B1
+xArgs = mkPropertyValues({"Text": "Comment 1"})
+self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", 
xArgs)
+
+# Insert a comment in cell A2
+xGridWin.executeAction("SELECT", mkPropertyValues({"CELL":"A2"}))
+xArgs = mkPropertyValues({"Text": "Comment 2"})
+self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", 
xArgs)
+
+# Copy cell A2 to clipboard
+xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"}))
+self.xUITest.executeCommand(".uno:Copy")
+
+# Set cursor to cells and paste data using special options (check 
only comments)
+targetCells = ["A1", "B1"]
+for index, targetCell in enumerate(targetCells):
+xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": 
targetCell}))
+with 
self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") as 
xPasteSpecialDlg:
+reset_default_values(self, xPasteSpecialDlg)
+xDateTimeChkBox = xPasteSpecialDlg.getChild("datetime")
+xDateTimeChkBox.executeAction("CLICK", tuple())
+xTextChkBox = xPasteSpecialDlg.getChild("text")
+xTextChkBox.executeAction("CLICK", tuple())
+xNumbersChkBox = xPasteSpecialDlg.getChild("numbers")
+xNumbersChkBox.executeAction("CLICK", tuple())
+xCommentsChkBox = xPasteSpecialDlg.getChild("comments")
+xCommentsChkBox.executeAction("CLICK", tuple())
+
+# Without the fix in place, this test would have failed with
+# AssertionError: 'A1 sample text' != ''
+# i.e., the cell content was overwritten
+self.assertEqual(targetCell + " sample text", 
get_cell_by_position(document, 0, index, 0).getString())
+self.assertEqual("Comment 2", get_cell_by_position(document, 
0, index, 0).Annotation.String)
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/ui/miscdlgs/inscodlg.cxx 
b/sc/source/ui/miscdlgs/inscodlg.cxx
index ca4fd1cfa8bd..84292dcd91c4 100644
--- a/sc/source/ui/miscdlgs/inscodlg.cxx
+++ b/sc/source/ui/miscdlgs/inscodlg.cxx
@@ -213,8 +213,9 @@ InsertDeleteFlags 
ScInsertContentsDlg::GetInsContentsCmdBits() const
 ScInsertContentsDlg::nPreviousChecks |= InsertDeleteFlags::DATETIME;
 if ( mxBtnInsFormulas->get_active())
 ScInsertContentsDlg::nPreviousChecks |= InsertDeleteFlags::FORMULA;
+// tdf#139858 - do not delete existing cell contents when pasting notes
 if ( mxBtnInsNotes->get_active()   )
-ScInsertContentsDlg::nPreviousChecks |= InsertDeleteFlags::NOTE;
+ScInsertContentsDlg::nPreviousChecks |= InsertDeleteFlags::ADDNOTES;
 if ( mxBtnInsAttrs->get_active()   )
 ScInsertContentsDlg::nPreviousChecks |= InsertDeleteFlags::ATTRIB;
 if ( mxBtnInsObjects->get_active() )


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

2023-05-08 Thread Czeber László Ádám (via logerrit)
 sc/qa/unit/data/csv/tdf152980.csv  |9 ++
 sc/qa/unit/subsequent_export_test4.cxx |   27 +++
 sc/source/filter/oox/richstring.cxx|  112 -
 3 files changed, 37 insertions(+), 111 deletions(-)

New commits:
commit 96965871f4cd2e4afbdf3bcae9dc0c43d1543e1d
Author: Czeber László Ádám 
AuthorDate: Mon May 8 09:33:07 2023 +0200
Commit: Eike Rathke 
CommitDate: Tue May 9 00:05:57 2023 +0200

tdf#152980 CSV import: Fix control character length in XLSX save

Converting from CSV to XLSX corrupts text that looks like a control
character. Only 4 numeric length escape character allowed, in _x000D_
format, not _x0D_ for exampled.

Change lcl_unEscapeUnicodeChars function to decodeXString. Delete not used 
functions and add multiple occurence for unit test.

Change-Id: Id1d4bfcf7d27cf5005e7bea8e289303c5d9aca73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151494
Reviewed-by: Eike Rathke 
Tested-by: Eike Rathke 

diff --git a/sc/qa/unit/data/csv/tdf152980.csv 
b/sc/qa/unit/data/csv/tdf152980.csv
new file mode 100644
index ..c5050b86d968
--- /dev/null
+++ b/sc/qa/unit/data/csv/tdf152980.csv
@@ -0,0 +1,9 @@
+"a_x1_b"
+"a_x01_b"
+"a_x001_b"
+"a_x0001_b"
+"a_xfoo
b"
+"a b"
+"a
+b"
+"a

b"
diff --git a/sc/qa/unit/subsequent_export_test4.cxx 
b/sc/qa/unit/subsequent_export_test4.cxx
index 79b5441c8f17..233195b2ebde 100644
--- a/sc/qa/unit/subsequent_export_test4.cxx
+++ b/sc/qa/unit/subsequent_export_test4.cxx
@@ -1638,6 +1638,33 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf119565)
  
xShapeProps->getPropertyValue("LineJoint").get());
 }
 
+CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf152980)
+{
+createScDoc("csv/tdf152980.csv");
+ScDocShell* pDocSh = getScDocShell();
+pDocSh->DoHardRecalc();
+saveAndReload("Calc Office Open XML");
+pDocSh = getScDocShell();
+pDocSh->DoHardRecalc();
+
+ScDocument* pDoc = getScDoc();
+
+// - Expected: The part between a and b does not change
+// - Actual  : Only the characters a and b remain
+CPPUNIT_ASSERT_EQUAL(OUString("a_x1_b"), pDoc->GetString(0, 0, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("a_x01_b"), pDoc->GetString(0, 1, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("a_x001_b"), pDoc->GetString(0, 2, 0));
+
+// The character code does not change in both cases
+CPPUNIT_ASSERT_EQUAL(OUString("a_x0001_b"), pDoc->GetString(0, 3, 0));
+
+// The escape characters are handled correctly in both cases
+CPPUNIT_ASSERT_EQUAL(OUString("a_xfoo\nb"), pDoc->GetString(0, 4, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("a\tb"), pDoc->GetString(0, 5, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("a\nb"), pDoc->GetString(0, 6, 0));
+CPPUNIT_ASSERT_EQUAL(OUString("a\n\nb"), pDoc->GetString(0, 7, 0));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/oox/richstring.cxx 
b/sc/source/filter/oox/richstring.cxx
index a9b272d62a9a..8d2f964362d0 100644
--- a/sc/source/filter/oox/richstring.cxx
+++ b/sc/source/filter/oox/richstring.cxx
@@ -48,116 +48,6 @@ bool lclNeedsRichTextFormat( const oox::xls::Font* pFont )
 return pFont && pFont->needsRichTextFormat();
 }
 
-sal_Int32 lcl_getHexLetterValue(sal_Unicode nCode)
-{
-if (nCode >= '0' && nCode <= '9')
-return nCode - '0';
-
-if (nCode >= 'A' && nCode <= 'F')
-return nCode - 'A' + 10;
-
-if (nCode >= 'a' && nCode <= 'f')
-return nCode - 'a' + 10;
-
-return -1;
-}
-
-bool lcl_validEscape(sal_Unicode nCode)
-{
-// Valid XML chars that can be escaped (ignoring the restrictions) as in 
the OOX open spec
-// 2.1.1742 Part 1 Section 22.9.2.19, ST_Xstring (Escaped String)
-if (nCode == 0x000D || nCode == 0x000A || nCode == 0x0009 || nCode == 
0x005F)
-return true;
-
-// Other valid XML chars in basic multilingual plane that cannot be 
escaped.
-if ((nCode >= 0x0020 && nCode <= 0xD7FF) || (nCode >= 0xE000 && nCode <= 
0xFFFD))
-return false;
-
-return true;
-}
-
-OUString lcl_unEscapeUnicodeChars(const OUString& rSrc)
-{
-// Example: Escaped representation of unicode char 0x000D is _x000D_
-
-sal_Int32 nLen = rSrc.getLength();
-if (!nLen)
-return rSrc;
-
-sal_Int32 nStart = 0;
-bool bFound = false;
-const OUString aPrefix = "_x";
-sal_Int32 nPrefixStart = rSrc.indexOf(aPrefix, nStart);
-
-if (nPrefixStart == -1)
-return rSrc;
-
-OUStringBuffer aBuf(rSrc);
-sal_Int32 nOffset = 0; // index offset in aBuf w.r.t rSrc.
-
-do
-{
-sal_Int32 nEnd = -1;
-sal_Unicode nCode = 0;
-bool bFoundThis = false;
-for (sal_Int32 nIdx = 0; nIdx < 5; ++nIdx)
-{
-sal_Int32 nThisIdx = nPrefixStart + nIdx + 2;
-if (nThisIdx >= nLen)
-break;
-
-sal_Unicode nThisCode = rSrc[nThisIdx];
-sal_Int32 

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

2023-05-07 Thread Andreas Heinisch (via logerrit)
 sc/qa/uitest/calc_tests6/moveCopySheet.py |   32 ++
 sc/source/ui/inc/mvtabdlg.hxx |3 ++
 sc/source/ui/miscdlgs/mvtabdlg.cxx|   15 ++
 3 files changed, 42 insertions(+), 8 deletions(-)

New commits:
commit 6f67eb36d035fa3fe4103e497207452602ff993b
Author: Andreas Heinisch 
AuthorDate: Fri May 5 19:28:58 2023 +0200
Commit: Andreas Heinisch 
CommitDate: Sun May 7 13:39:12 2023 +0200

tdf#96854 - Remember last used option in copy/move sheet dialog

Change-Id: Iebfd224091c108bb5068b716c39da0979a7ab3ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151437
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/uitest/calc_tests6/moveCopySheet.py 
b/sc/qa/uitest/calc_tests6/moveCopySheet.py
index 80bd9f830a27..5b21e6e86cb0 100644
--- a/sc/qa/uitest/calc_tests6/moveCopySheet.py
+++ b/sc/qa/uitest/calc_tests6/moveCopySheet.py
@@ -23,8 +23,10 @@ class moveCopySheet(UITestCase):
 newName.executeAction("TYPE", 
mkPropertyValues({"TEXT":"newName"}))
 #verify, the file has 2 sheets; first one "newName" is selected
 self.assertEqual(document.Sheets.getCount(), 2)
-# dialog move/copy sheet ; Move is selected; select -move to end 
position - ; New Name = moveName
+# dialog move/copy sheet ; Copy is selected; Select move and -move 
to end position - ; New Name = moveName
 with self.ui_test.execute_dialog_through_command(".uno:Move") as 
xDialog:
+xMoveButton = xDialog.getChild("move")
+xMoveButton.executeAction("CLICK", tuple())
 insertBefore = xDialog.getChild("insertBefore")
 
 xTreeEntry = insertBefore.getChild('2')
@@ -76,6 +78,29 @@ class moveCopySheet(UITestCase):
 self.assertEqual(get_state_as_dict(xMoveButton)["Checked"], 
"false")
 self.assertEqual(get_state_as_dict(xMoveButton)["Enabled"], 
"false")
 
+# tdf#96854 - remember last used option for copy/move sheet
+def test_tdf96854_remember_copy_move_option(self):
+with self.ui_test.create_doc_in_start_center("calc"):
+# Add a second sheet to the calc document
+with self.ui_test.execute_dialog_through_command(".uno:Move") as 
xDialog:
+pass
+
+# Check if the copy option was remembered
+with self.ui_test.execute_dialog_through_command(".uno:Move") as 
xDialog:
+xCopyButton = xDialog.getChild("copy")
+self.assertEqual(get_state_as_dict(xCopyButton)["Checked"], 
"true")
+xMoveButton = xDialog.getChild("move")
+self.assertEqual(get_state_as_dict(xMoveButton)["Checked"], 
"false")
+# Move selected sheet and check if option was remembered
+xMoveButton.executeAction("CLICK", tuple())
+
+# Check if move option was remembered
+with self.ui_test.execute_dialog_through_command(".uno:Move") as 
xDialog:
+xCopyButton = xDialog.getChild("copy")
+self.assertEqual(get_state_as_dict(xCopyButton)["Checked"], 
"false")
+xMoveButton = xDialog.getChild("move")
+self.assertEqual(get_state_as_dict(xMoveButton)["Checked"], 
"true")
+
 #tdf#139464 Set OK button label to selected action: Move or Copy
 def test_tdf139464_move_sheet(self):
 with self.ui_test.create_doc_in_start_center("calc"):
@@ -87,11 +112,10 @@ class moveCopySheet(UITestCase):
 xOkButton = xDialog.getChild("ok")
 xCopyButton = xDialog.getChild("copy")
 xMoveButton = xDialog.getChild("move")
-self.assertEqual(get_state_as_dict(xMoveButton)['Text'], 
get_state_as_dict(xOkButton)['Text'])
-xCopyButton.executeAction("CLICK", tuple())
 self.assertEqual(get_state_as_dict(xCopyButton)['Text'], 
get_state_as_dict(xOkButton)['Text'])
 xMoveButton.executeAction("CLICK", tuple())
 self.assertEqual(get_state_as_dict(xMoveButton)['Text'], 
get_state_as_dict(xOkButton)['Text'])
-
+xCopyButton.executeAction("CLICK", tuple())
+self.assertEqual(get_state_as_dict(xCopyButton)['Text'], 
get_state_as_dict(xOkButton)['Text'])
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx
index c6e89ab9fed0..665d3cd46085 100644
--- a/sc/source/ui/inc/mvtabdlg.hxx
+++ b/sc/source/ui/inc/mvtabdlg.hxx
@@ -61,6 +61,9 @@ private:
 boolbRenameTable:1;
 boolmbEverEdited:1;
 
+// tdf#96854 - remember last used option for copy/move sheet
+static bool mbRememeberedCopy;
+
 std::unique_ptr m_xBtnMove;
 std::unique_ptr m_xBtnCopy;
 std::unique_ptr m_xFtDoc;
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx 

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

2023-04-27 Thread Tünde Tóth (via logerrit)
 sc/qa/unit/uicalc/uicalc2.cxx|   24 
 sc/source/core/tool/refupdat.cxx |2 --
 2 files changed, 24 insertions(+), 2 deletions(-)

New commits:
commit b88d11ba05085002cf847d4828ded52a3dfb3b09
Author: Tünde Tóth 
AuthorDate: Wed Apr 26 15:31:46 2023 +0200
Commit: László Németh 
CommitDate: Thu Apr 27 18:58:32 2023 +0200

tdf#152577 sc DBData: fix regression of database ranges

Regression from commit 0c0444c44107f1a18f23dd0833d462d8dbf56569
"tdf#126926 sc DBData: delete the database range".

Change-Id: I04923decdc768770f98763e60cd295400d15c769
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151065
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/unit/uicalc/uicalc2.cxx b/sc/qa/unit/uicalc/uicalc2.cxx
index a09c9b8e20e9..69db567f305c 100644
--- a/sc/qa/unit/uicalc/uicalc2.cxx
+++ b/sc/qa/unit/uicalc/uicalc2.cxx
@@ -1395,6 +1395,30 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testAutoSum)
 CPPUNIT_ASSERT_EQUAL(OUString("=SUM(B207:D207)"), pDoc->GetFormula(4, 206, 
0));
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf152577)
+{
+createScDoc();
+ScDocument* pDoc = getScDoc();
+
+insertStringToCell("A1", u"1");
+insertStringToCell("A2", u"2");
+insertStringToCell("B1", u"3");
+insertStringToCell("B2", u"4");
+
+ScDBData* pDBData = new ScDBData("testDB", 0, 0, 0, 1, 1);
+bool bInserted
+= 
pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr(pDBData));
+CPPUNIT_ASSERT(bInserted);
+
+insertNewSheet(*pDoc);
+uno::Sequence aArgs(
+comphelper::InitPropertySequence({ { "Index", uno::Any(sal_uInt16(2)) 
} }));
+dispatchCommand(mxComponent, ".uno:Remove", aArgs);
+
+ScDBCollection* pDBs = pDoc->GetDBCollection();
+CPPUNIT_ASSERT(!pDBs->empty());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/refupdat.cxx b/sc/source/core/tool/refupdat.cxx
index 3fce7c714423..ef0902aab3f4 100644
--- a/sc/source/core/tool/refupdat.cxx
+++ b/sc/source/core/tool/refupdat.cxx
@@ -291,8 +291,6 @@ ScRefUpdateRes ScRefUpdate::Update( const ScDocument* pDoc, 
UpdateRefMode eUpdat
 eRet = UR_INVALID;
 theTab2 = theTab1;
 }
-else if (bCut2 && theTab2 == 0)
-eRet = UR_INVALID;
 else if ( bCut1 || bCut2 )
 eRet = UR_UPDATED;
 if ( bExp )


[Libreoffice-commits] core.git: sc/qa sc/source sd/source sfx2/source shell/source svx/source sw/source toolkit/source

2023-04-23 Thread Gabor Kelemen (via logerrit)
 sc/qa/unit/helper/debughelper.hxx|4 
 sc/qa/unit/helper/qahelper.cxx   |3 +++
 sc/qa/unit/pivottable_filters_test.cxx   |3 +++
 sc/qa/unit/subsequent_export_test3.cxx   |2 ++
 sc/qa/unit/ucalc.cxx |2 ++
 sc/qa/unit/ucalc_copypaste.cxx   |3 +++
 sc/qa/unit/ucalc_formula.cxx |2 ++
 sc/qa/unit/ucalc_formula2.cxx|3 +++
 sc/qa/unit/ucalc_sharedformula.cxx   |3 +++
 sc/qa/unit/ucalc_sort.cxx|3 +++
 sc/source/filter/excel/xeescher.cxx  |1 -
 sc/source/filter/excel/xltracer.cxx  |3 ---
 sc/source/filter/xml/XMLStylesImportHelper.cxx   |1 -
 sc/source/filter/xml/XMLTableShapeResizer.cxx|1 -
 sc/source/filter/xml/xmltabi.cxx |1 -
 sc/source/ui/undo/undorangename.cxx  |2 --
 sd/source/core/drawdoc.cxx   |1 -
 sd/source/ui/framework/module/ModuleController.cxx   |1 -
 sfx2/source/doc/docmacromode.cxx |1 -
 shell/source/win32/simplemail/smplmailmsg.cxx|2 --
 svx/source/accessibility/AccessibleFrameSelector.cxx |2 --
 sw/source/core/access/accpara.cxx|1 -
 sw/source/filter/xml/XMLRedlineImportHelper.cxx  |1 -
 sw/source/filter/xml/xmlitmpr.cxx|3 ---
 sw/source/uibase/inc/mailmergewizard.hxx |1 -
 toolkit/source/awt/vclxtopwindow.cxx |1 -
 toolkit/source/controls/unocontroltablemodel.cxx |1 -
 27 files changed, 24 insertions(+), 28 deletions(-)

New commits:
commit d7e0247ed43091172c2cc3827399bb111416d617
Author: Gabor Kelemen 
AuthorDate: Wed Apr 12 00:27:47 2023 +0200
Commit: Gabor Kelemen 
CommitDate: Sun Apr 23 13:05:21 2023 +0200

Run clang-tidy with misc-unused-using-decls on modules [s-t]*

To remove unneeded using declarations.

Via the simple script:

for i in $(find $dirname -name "*cxx" -o -name "*hxx" ); do
clang-tidy-12  --checks="-*,misc-unused-using-decls" "$i";
done

Change-Id: I596299084471b2904548d23875866f1583b00b2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150610
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen 

diff --git a/sc/qa/unit/helper/debughelper.hxx 
b/sc/qa/unit/helper/debughelper.hxx
index af7a11a65fdd..47d0e25e0842 100644
--- a/sc/qa/unit/helper/debughelper.hxx
+++ b/sc/qa/unit/helper/debughelper.hxx
@@ -28,9 +28,5 @@
 #include 
 
 using namespace ::com::sun::star;
-using ::std::cout;
-using ::std::cerr;
-using ::std::endl;
-using ::std::vector;
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index dbfb6af398f2..af8e5ad8dca1 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -48,6 +48,9 @@
 
 using namespace com::sun::star;
 using namespace ::com::sun::star::uno;
+using ::std::cout;
+using ::std::cerr;
+using ::std::endl;
 
 FormulaGrammarSwitch::FormulaGrammarSwitch(ScDocument* pDoc, 
formula::FormulaGrammar::Grammar eGrammar) :
 mpDoc(pDoc), meOldGrammar(pDoc->GetGrammar())
diff --git a/sc/qa/unit/pivottable_filters_test.cxx 
b/sc/qa/unit/pivottable_filters_test.cxx
index b9c92e252db5..372d81b83ec0 100644
--- a/sc/qa/unit/pivottable_filters_test.cxx
+++ b/sc/qa/unit/pivottable_filters_test.cxx
@@ -34,6 +34,9 @@
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
+using ::std::cerr;
+using ::std::cout;
+using ::std::endl;
 
 class ScPivotTableFiltersTest : public ScModelTestBase
 {
diff --git a/sc/qa/unit/subsequent_export_test3.cxx 
b/sc/qa/unit/subsequent_export_test3.cxx
index 4039f54547ef..b1ce4c1a6125 100644
--- a/sc/qa/unit/subsequent_export_test3.cxx
+++ b/sc/qa/unit/subsequent_export_test3.cxx
@@ -37,6 +37,8 @@
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
+using ::std::cerr;
+using ::std::endl;
 
 class ScExportTest3 : public ScModelTestBase
 {
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 6ca40d64582e..a1951cdc5b95 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -69,6 +69,8 @@
 
 class ScUndoPaste;
 class ScUndoCut;
+using ::std::cerr;
+using ::std::endl;
 
 namespace {
 
diff --git a/sc/qa/unit/ucalc_copypaste.cxx b/sc/qa/unit/ucalc_copypaste.cxx
index c54107e08998..43f9272a13c0 100644
--- a/sc/qa/unit/ucalc_copypaste.cxx
+++ b/sc/qa/unit/ucalc_copypaste.cxx
@@ -32,6 +32,9 @@
 
 #include 
 
+using ::std::cerr;
+using ::std::endl;
+
 class TestCopyPaste : public ScUcalcTestBase
 {
 protected:
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 0c0c5d4481ad..feb0e8fef22a 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ 

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

2023-04-19 Thread Maxim Monastirsky (via logerrit)
 sc/qa/unit/subsequent_export_test4.cxx |7 +--
 sc/source/ui/unoobj/styleuno.cxx   |7 +++
 sc/source/ui/view/tabvwsha.cxx |   25 +
 3 files changed, 37 insertions(+), 2 deletions(-)

New commits:
commit 0f6e6e82a4a693a6970540db6e98d0302f3fefa6
Author: Maxim Monastirsky 
AuthorDate: Wed Apr 19 01:47:10 2023 +0300
Commit: Maxim Monastirsky 
CommitDate: Wed Apr 19 13:31:17 2023 +0200

sc drawstyles: Fix export of transparency

Change-Id: I1abf277223718ae2d650728e5bd141372a771a87
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150590
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky 

diff --git a/sc/qa/unit/subsequent_export_test4.cxx 
b/sc/qa/unit/subsequent_export_test4.cxx
index eb3af3a2b2bf..25eb30e19245 100644
--- a/sc/qa/unit/subsequent_export_test4.cxx
+++ b/sc/qa/unit/subsequent_export_test4.cxx
@@ -1499,8 +1499,9 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testShapeStyles)
 uno::Reference xStyle(
 xMSF->createInstance("com.sun.star.style.GraphicStyle"), 
uno::UNO_QUERY_THROW);
 xGraphicStyles->insertByName("MyStyle1", Any(xStyle));
-uno::Reference(xStyle, uno::UNO_QUERY_THROW)
-->setPropertyValue("FillColor", Any(COL_RED));
+uno::Reference xPropertySet(xStyle, 
uno::UNO_QUERY_THROW);
+xPropertySet->setPropertyValue("FillColor", Any(COL_RED));
+xPropertySet->setPropertyValue("FillTransparence", Any(sal_Int16(40)));
 
 xStyle.set(xMSF->createInstance("com.sun.star.style.GraphicStyle"), 
uno::UNO_QUERY_THROW);
 xGraphicStyles->insertByName("MyStyle2", Any(xStyle));
@@ -1540,6 +1541,8 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testShapeStyles)
 Color nColor;
 xShape->getPropertyValue("FillColor") >>= nColor;
 CPPUNIT_ASSERT_EQUAL(COL_RED, nColor);
+CPPUNIT_ASSERT_EQUAL(sal_Int16(40),
+ 
xShape->getPropertyValue("FillTransparence").get());
 }
 }
 
diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx
index f4280dd2a679..a97c12e3dec5 100644
--- a/sc/source/ui/unoobj/styleuno.cxx
+++ b/sc/source/ui/unoobj/styleuno.cxx
@@ -2025,6 +2025,13 @@ uno::Any ScStyleObj::getPropertyValue_Impl( 
std::u16string_view aPropertyName )
 {
 if (!SvxUnoTextRangeBase::GetPropertyValueHelper(*pItemSet, 
pResultEntry, aAny))
 aAny = SvxItemPropertySet_getPropertyValue(pResultEntry, 
*pItemSet);
+
+// since the sfx uint16 item now exports a sal_Int32, we may 
have to fix this here
+if (pResultEntry->aType == ::cppu::UnoType::get() &&
+aAny.getValueType() == ::cppu::UnoType::get())
+{
+aAny <<= static_cast(aAny.get());
+}
 }
 }
 }
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index a3eb7bd5403d..b309ac6156d5 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -40,6 +40,13 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 
 #include 
@@ -1587,6 +1594,24 @@ void ScTabViewShell::ExecStyle( SfxRequest& rReq )
 SfxItemSet& rAttr = pStyleSheet->GetItemSet();
 sdr::properties::CleanupFillProperties(rAttr);
 
+// check for unique names of named items for xml
+auto checkForUniqueItem = [&] (auto nWhichId)
+{
+if (auto pOldItem = rAttr.GetItemIfSet(nWhichId, 
false))
+{
+if (auto pNewItem = 
pOldItem->checkForUniqueItem(()->GetModel()))
+rAttr.Put(std::move(pNewItem));
+}
+};
+
+checkForUniqueItem(XATTR_FILLBITMAP);
+checkForUniqueItem(XATTR_LINEDASH);
+checkForUniqueItem(XATTR_LINESTART);
+checkForUniqueItem(XATTR_LINEEND);
+checkForUniqueItem(XATTR_FILLGRADIENT);
+checkForUniqueItem(XATTR_FILLFLOATTRANSPARENCE);
+checkForUniqueItem(XATTR_FILLHATCH);
+
 
static_cast(pStyleSheet)->Broadcast(SfxHint(SfxHintId::DataChanged));
 GetScDrawView()->InvalidateAttribs();
 }


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

2023-04-18 Thread Andreas Heinisch (via logerrit)
 sc/qa/extras/macros-test.cxx|   32 
 sc/source/ui/unoobj/viewuno.cxx |   18 +-
 2 files changed, 45 insertions(+), 5 deletions(-)

New commits:
commit 10f2e8363076fb9217b4fc8acf12b4d9c13328cc
Author: Andreas Heinisch 
AuthorDate: Fri Apr 14 14:29:12 2023 +0200
Commit: Andreas Heinisch 
CommitDate: Tue Apr 18 12:40:49 2023 +0200

tdf#154803 - Check if range is entirely merged

Regression from commit b9411e587586750f36ba9009b5f1e29fe461d8b5 where I
missinterpreted the check to get merged cells.

Regression:
tdf#147122 - Return cell object when a simple selection is merged
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145378

Change-Id: I2e39599a206cf102b1da8c7fc4bb2d8c0a4b106c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150412
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index dd971e36dec1..1135fbd38f69 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -911,6 +911,38 @@ CPPUNIT_TEST_FIXTURE(ScMacrosTest, testTdf147122)
 CPPUNIT_ASSERT_EQUAL(Any(OUString("This is a test")), aRet);
 }
 
+CPPUNIT_TEST_FIXTURE(ScMacrosTest, testTdf154803)
+{
+mxComponent = loadFromDesktop("private:factory/scalc");
+
+css::uno::Reference xDocScr(mxComponent, 
UNO_QUERY_THROW);
+auto xLibs = xDocScr->getBasicLibraries();
+auto xLibrary = xLibs->createLibrary("TestLibrary");
+xLibrary->insertByName(
+"TestModule",
+uno::Any(
+OUString("Function TestExtendedMergedSelection\n"
+ // Merge A1:B2 cell range
+ "  oActiveSheet = 
ThisComponent.CurrentController.ActiveSheet\n"
+ "  oRange = oActiveSheet.getCellRangeByName(\"A1:B2\")\n"
+ "  ThisComponent.getCurrentController.Select(oRange)\n"
+ "  oActiveCell = ThisComponent.CurrentSelection\n"
+ "  oActiveCell.Merge(True)\n"
+ // Select A1:B3 range and check for its implementation 
name
+ "  oRange = oActiveSheet.getCellRangeByName(\"A1:B3\")\n"
+ "  ThisComponent.getCurrentController.Select(oRange)\n"
+ "  TestExtendedMergedSelection = 
ThisComponent.CurrentSelection.ImplementationName\n"
+ "End Function\n")));
+
+Any aRet = 
executeMacro("vnd.sun.Star.script:TestLibrary.TestModule.TestExtendedMergedSelection?"
+"language=Basic=document");
+// Without the fix in place, this test would have failed with
+// - Expected : ScCellRangeObj
+// - Actual   : ScCellObj
+// i.e. the selection was interpreted as a single cell instead of a range
+CPPUNIT_ASSERT_EQUAL(Any(OUString("ScCellRangeObj")), aRet);
+}
+
 CPPUNIT_TEST_FIXTURE(ScMacrosTest, testTdf116127)
 {
 mxComponent = loadFromDesktop("private:factory/scalc");
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index 96b055250c72..bfde44272010 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -54,6 +54,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -873,13 +874,20 @@ uno::Any SAL_CALL ScTabViewObj::getSelection()
 ScMarkType eMarkType = rViewData.GetSimpleArea(aRange);
 if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE) )
 {
-// tdf#147122 - return cell object when a simple selection is 
merged
+// tdf#154803 - check if range is entirely merged
 ScDocument& rDoc = pDocSh->GetDocument();
-const ScPatternAttr* pMarkPattern = rDoc.GetPattern(aRange.aStart);
+const ScMergeAttr* pMergeAttr = rDoc.GetAttr(aRange.aStart, 
ATTR_MERGE);
+SCCOL nColSpan = 1;
+SCROW nRowSpan = 1;
+if (pMergeAttr && pMergeAttr->IsMerged())
+{
+nColSpan = pMergeAttr->GetColMerge();
+nRowSpan = pMergeAttr->GetRowMerge();
+}
+// tdf#147122 - return cell object when a simple selection is 
entirely merged
 if (aRange.aStart == aRange.aEnd
-|| (pMarkPattern
-&& pMarkPattern->GetItemSet().GetItemState(ATTR_MERGE, 
false)
-   == SfxItemState::SET))
+|| (aRange.aEnd.Col() - aRange.aStart.Col() == nColSpan - 1
+&& aRange.aEnd.Row() - aRange.aStart.Row() == nRowSpan - 
1))
 pObj = new ScCellObj( pDocSh, aRange.aStart );
 else
 pObj = new ScCellRangeObj( pDocSh, aRange );


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

2023-04-17 Thread Maxim Monastirsky (via logerrit)
 sc/qa/unit/subsequent_export_test4.cxx |   16 +++-
 sc/source/filter/excel/xlroot.cxx  |1 +
 2 files changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 86cbbbccba19ba0433693e3e5c59c67e9dc6a003
Author: Maxim Monastirsky 
AuthorDate: Fri Apr 14 02:19:44 2023 +0300
Commit: Maxim Monastirsky 
CommitDate: Tue Apr 18 01:56:31 2023 +0200

sc drawstyles: Fix xlsx export for text attributes in comments

Change-Id: Ic5b6099460bd5e978c04aff3233537059ce711b9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150379
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky 

diff --git a/sc/qa/unit/subsequent_export_test4.cxx 
b/sc/qa/unit/subsequent_export_test4.cxx
index 5d629e83eb4a..663767c7374f 100644
--- a/sc/qa/unit/subsequent_export_test4.cxx
+++ b/sc/qa/unit/subsequent_export_test4.cxx
@@ -1583,7 +1583,21 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testCommentStyles)
 
 // Check that the style was imported, and survived copying
 CPPUNIT_ASSERT_EQUAL(OUString("MyStyle1"), 
pCaption->GetStyleSheet()->GetName());
-// Check that the style formatting is in effect
+}
+
+saveAndReload("Calc Office Open XML");
+
+{
+ScDocument* pDoc = getScDoc();
+
+ScAddress aPos(0, 0, 0);
+ScPostIt* pNote = pDoc->GetNote(aPos);
+CPPUNIT_ASSERT(pNote);
+
+auto pCaption = pNote->GetOrCreateCaption(aPos);
+CPPUNIT_ASSERT(pCaption);
+
+// Check that the style formatting is preserved
 CPPUNIT_ASSERT_EQUAL(sal_uInt32(1129),
  
pCaption->GetMergedItemSet().Get(EE_CHAR_FONTHEIGHT).GetHeight());
 }
diff --git a/sc/source/filter/excel/xlroot.cxx 
b/sc/source/filter/excel/xlroot.cxx
index 47f5ff7806c1..71d308d2f29c 100644
--- a/sc/source/filter/excel/xlroot.cxx
+++ b/sc/source/filter/excel/xlroot.cxx
@@ -408,6 +408,7 @@ EditEngine& XclRoot::GetDrawEditEngine() const
 {
 mrData.mxDrawEditEng = std::make_shared( 
().GetDrawLayer()->GetItemPool() );
 EditEngine& rEE = *mrData.mxDrawEditEng;
+
rEE.SetStyleSheetPool(static_cast(GetDoc().GetDrawLayer()->GetStyleSheetPool()));
 rEE.SetRefMapMode(MapMode(MapUnit::Map100thMM));
 rEE.SetUpdateLayout( false );
 rEE.EnableUndo( false );


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

2023-04-17 Thread Maxim Monastirsky (via logerrit)
 sc/qa/unit/subsequent_export_test4.cxx |   13 ++
 sc/qa/unit/ucalc.cxx   |   18 
 sc/source/core/data/document.cxx   |7 -
 sc/source/core/data/drwlayer.cxx   |   59 +
 sc/source/core/data/postit.cxx |   63 --
 sc/source/core/tool/detfunc.cxx|  147 -
 sc/source/core/tool/stylehelper.cxx|1 
 7 files changed, 130 insertions(+), 178 deletions(-)

New commits:
commit 3e4b8463f288d87f91cd5bc864d30ae02d4f5579
Author: Maxim Monastirsky 
AuthorDate: Mon Apr 10 00:38:33 2023 +0300
Commit: Maxim Monastirsky 
CommitDate: Tue Apr 18 01:09:21 2023 +0200

sc drawstyles: Maintain comment formatting with styles

Up to now the look of comments was maintained with the comment
shape's DF, with the default formatting being reapplied on
import (for hidden comments), on changing Tools > Options... >
LibreOffice > AC > Notes background, and on changing the
default cell style, while keeping the user-applied DF to some
extent. However, as we attempt to support drawing styles, this
approach is no longer viable, as applying DF on top of styles
at random times makes styles useless in the context of
comments.

(One might argue, that the look of comments should ideally be
treated as an app view setting, and not as a formatting of an
individual shape. This definitely makes sense, but has compat.
implications, as both LO and Excel allow formatting individual
comments (e.g. show a comment, right click > Area...). However
we will probably do it anyway if we ever implement threaded
comments like in recent Excel [1], as the callout shape based
approach seems to not scale to it.)

One way around it could be to explicitly disable any style
interaction with comments. But this will be unfortunate, as
styles have a clear advantage of being able to consistently
maintain the same formatting for several elements, much more
that the fragile approach of mixing the default formatting and
user-applied formatting in the same formatting layer. Not to
mention the possibility to define several custom styles. In
addition there is a request in tdf#55682 to disconnect the
formatting of comments from the default cell style, having a
dedicated style instead, which I find reasonable.

So this commit introduces a comment style, and uses it for new
comments instead of DF, making it easy to format all comments at
once. And a style based formatting is never overriden with DF,
unless explicitly set by the user. Changing Tools > Options... >
LibreOffice > AC > Notes background still has an effect in two
ways: (1) Sets the default background of the comment style for new
documents, and (2) if changed while a document is open, changes
also the comment style of the current document. An undo action
is also added, in case changing the current document wasn't
deliberate. Changing the default cell style no longer has any
effect on comment formatting.

One unfortunate side effect of this change, is that newly
created and permanently visible comments will lose their
default look when opened in an older version. But there is not
much I can do here, as older versions don't support styles, and
I believe the advantage of using styles outweigh this concern.
Hidden comments are not affected by this.

[1] see 
https://support.microsoft.com/en-us/office/the-difference-between-threaded-comments-and-notes-75a51eec-4092-42ab-abf8-7669077b7be3

Change-Id: I84215791b9e6ce393c6d979aa2b19ef70c76dff9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150352
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky 

diff --git a/sc/qa/unit/subsequent_export_test4.cxx 
b/sc/qa/unit/subsequent_export_test4.cxx
index 9d6e38ef8a09..5d629e83eb4a 100644
--- a/sc/qa/unit/subsequent_export_test4.cxx
+++ b/sc/qa/unit/subsequent_export_test4.cxx
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1553,12 +1554,14 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testCommentStyles)
 ScPostIt* pNote = pDoc->GetNote(aPos);
 CPPUNIT_ASSERT(pNote);
 
-pNote->ShowCaption(aPos, true);
 auto pCaption = pNote->GetCaption();
 CPPUNIT_ASSERT(pCaption);
 
 auto pStyleSheet = >GetStyleSheetPool()->Make("MyStyle1", 
SfxStyleFamily::Frame);
-pCaption->SetStyleSheet(static_cast(pStyleSheet), 
true);
+auto& rSet = pStyleSheet->GetItemSet();
+rSet.Put(SvxFontHeightItem(1129, 100, EE_CHAR_FONTHEIGHT));
+
+pCaption->SetStyleSheet(static_cast(pStyleSheet), 
false);
 
 // Hidden comments use different code path on import
 pNote->ShowCaption(aPos, false);
@@ -1575,12 +1578,14 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testCommentStyles)
 ScPostIt* pNote = 

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

2023-04-07 Thread Andreas Heinisch (via logerrit)
 sc/qa/unit/ucalc.cxx|   26 ++
 sc/source/core/tool/reffind.cxx |4 ++--
 2 files changed, 28 insertions(+), 2 deletions(-)

New commits:
commit 40e3e9fd1c501cc1978d4370b6392701ccd42a71
Author: Andreas Heinisch 
AuthorDate: Thu Apr 6 17:38:52 2023 +0200
Commit: Andreas Heinisch 
CommitDate: Fri Apr 7 14:00:42 2023 +0200

tdf#113027 - Allow cycling cell reference types including whitespaces

A formula containing a remote reference to a sheet including a
whitespace in its name does not correctly handle switching from
relative to absolute cell references using the EXCEL R1C1
formular grammar.

Change-Id: I3391f4e8f57993899b5e97f0a173b624b5ef0b22
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150109
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 8563ef8283c3..aa8dbc32b220 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -450,6 +450,32 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf66613)
 m_pDoc->DeleteTab(nSecondTab);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf113027)
+{
+// Insert some sheets including a whitespace in their name and switch the 
grammar to R1C1
+CPPUNIT_ASSERT(m_pDoc->InsertTab(0, "Sheet 1"));
+CPPUNIT_ASSERT(m_pDoc->InsertTab(1, "Sheet 2"));
+FormulaGrammarSwitch aFGSwitch(m_pDoc, 
formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
+
+// Add a formula containing a remote reference, i.e., to another sheet
+const ScAddress aScAddress(0, 0, 0);
+const OUString aFormula = "='Sheet 2'!RC";
+m_pDoc->SetString(aScAddress, aFormula);
+
+// Switch from relative to absolute cell reference
+ScRefFinder aFinder(aFormula, aScAddress, *m_pDoc, 
m_pDoc->GetAddressConvention());
+aFinder.ToggleRel(0, aFormula.getLength());
+
+// Without the fix in place, this test would have failed with
+// - Expected: ='Sheet 2'!R1C1
+// - Actual  : ='Sheet 2'!RC
+// i.e. the cell reference was not changed from relative to absolute
+CPPUNIT_ASSERT_EQUAL(OUString("='Sheet 2'!R1C1"), aFinder.GetText());
+
+m_pDoc->DeleteTab(0);
+m_pDoc->DeleteTab(1);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf90698)
 {
 CPPUNIT_ASSERT(m_pDoc->InsertTab (0, "Test"));
diff --git a/sc/source/core/tool/reffind.cxx b/sc/source/core/tool/reffind.cxx
index ab276196d399..ac080ae5a56e 100644
--- a/sc/source/core/tool/reffind.cxx
+++ b/sc/source/core/tool/reffind.cxx
@@ -91,7 +91,7 @@ sal_Int32 FindEndPosR1C1(const sal_Unicode* p, sal_Int32 
nStartPos, sal_Int32 nE
 if (*p == '\'')
 {
 // Skip until the closing quote.
-for (; nNewEnd <= nEndPos; ++p, ++nNewEnd)
+for (++p; nNewEnd <= nEndPos; ++p, ++nNewEnd)
 if (*p == '\'')
 break;
 if (nNewEnd > nEndPos)
@@ -100,7 +100,7 @@ sal_Int32 FindEndPosR1C1(const sal_Unicode* p, sal_Int32 
nStartPos, sal_Int32 nE
 else if (*p == '[')
 {
 // Skip until the closing bracket.
-for (; nNewEnd <= nEndPos; ++p, ++nNewEnd)
+for (++p; nNewEnd <= nEndPos; ++p, ++nNewEnd)
 if (*p == ']')
 break;
 if (nNewEnd > nEndPos)


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

2023-04-06 Thread Eike Rathke (via logerrit)
 sc/qa/unit/data/contentCSV/statistical-functions.csv |6 +++---
 sc/qa/unit/data/ods/functions.ods|binary
 sc/source/core/tool/interpr3.cxx |8 ++--
 3 files changed, 9 insertions(+), 5 deletions(-)

New commits:
commit 74d39f5cff324d76092268418028bd882d8a4d60
Author: Eike Rathke 
AuthorDate: Thu Apr 6 14:41:39 2023 +0200
Commit: Eike Rathke 
CommitDate: Thu Apr 6 16:58:12 2023 +0200

Resolves: tdf#154627 RANK() query value not in data must return error

For all RANK(), RANK.EQ(), RANK.AVG().
Also, use #N/A NotAvailable instead of #VALUE! NoValue.

This made it necessary to adapt sc/qa/unit/data/ods/functions.ods and
result check that had a totally senseless query value with arbitrary
results.

Change-Id: If835b5ed49caf16a813b4ea897e1d7dd1aa02954
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150067
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/qa/unit/data/contentCSV/statistical-functions.csv 
b/sc/qa/unit/data/contentCSV/statistical-functions.csv
index 2e3c45cdb4a3..b9dbe2f2fbd9 100644
--- a/sc/qa/unit/data/contentCSV/statistical-functions.csv
+++ b/sc/qa/unit/data/contentCSV/statistical-functions.csv
@@ -117,9 +117,9 @@
 1
 -0.1225598712
 -0.1363480926
-2
-9
-2
+10
+11
+10
 0.5,0.1
 121,216
 120
diff --git a/sc/qa/unit/data/ods/functions.ods 
b/sc/qa/unit/data/ods/functions.ods
index 04c6e6ed1274..1ef3a7217b34 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/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 0153ee612e1c..88b32b44af1e 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -4254,7 +4254,7 @@ void ScInterpreter::ScRank( bool bAverage )
 else
 {
 if ( fVal < aSortArray[ 0 ] || fVal > aSortArray[ nSize - 1 ] )
-PushNoValue();
+PushError( FormulaError::NotAvailable);
 else
 {
 double fLastPos = 0;
@@ -4279,7 +4279,11 @@ void ScInterpreter::ScRank( bool bAverage )
 }
 if ( !bFinished )
 fLastPos = i;
-if ( !bAverage )
+if (fFirstPos <= 0)
+{
+PushError( FormulaError::NotAvailable);
+}
+else if ( !bAverage )
 {
 if ( bAscending )
 PushDouble( fFirstPos );


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

2023-04-04 Thread Andreas Heinisch (via logerrit)
 sc/qa/uitest/autofilter/autofilter.py |2 ++
 sc/qa/uitest/autofilter2/tdf97340.py  |3 +++
 sc/source/ui/cctrl/checklistmenu.cxx  |   12 +++-
 sc/source/ui/inc/checklistmenu.hxx|4 
 4 files changed, 20 insertions(+), 1 deletion(-)

New commits:
commit 37928bef1c23f30df04bc7e95fcbc202c8cb4299
Author: Andreas Heinisch 
AuthorDate: Mon Apr 3 12:43:51 2023 +0200
Commit: Andreas Heinisch 
CommitDate: Tue Apr 4 18:13:08 2023 +0200

tdf#151206 - Sc Auto Filter: filter items after search edit timeout

In addition, UI tests have been adapted to address the timeout of the 
search process.

Change-Id: Id9d78896e45da43734346654762c3541b8c07ba2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149958
Tested-by: Andreas Heinisch 
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/uitest/autofilter/autofilter.py 
b/sc/qa/uitest/autofilter/autofilter.py
index f792c0fdad33..8ffba26539a5 100644
--- a/sc/qa/uitest/autofilter/autofilter.py
+++ b/sc/qa/uitest/autofilter/autofilter.py
@@ -154,6 +154,7 @@ class AutofilterTest(UITestCase):
 xSearchEdit = xFloatWindow.getChild("search_edit")
 xSearchEdit.executeAction("TYPE", mkPropertyValues({"TEXT" : 
"11"}))
 
+self.ui_test.wait_until_property_is_updated(xList, "Children", 
str(1))
 self.assertEqual(1, len(xList.getChildren()))
 self.assertEqual("11", 
get_state_as_dict(xList.getChild('0'))['Text'])
 
@@ -179,6 +180,7 @@ class AutofilterTest(UITestCase):
 xSearchEdit = xFloatWindow.getChild("search_edit")
 xSearchEdit.executeAction("TYPE", mkPropertyValues({"TEXT" : 
"22"}))
 
+self.ui_test.wait_until_property_is_updated(xList, "Children", 
str(1))
 self.assertEqual(1, len(xList.getChildren()))
 self.assertEqual("22", 
get_state_as_dict(xList.getChild('0'))['Text'])
 
diff --git a/sc/qa/uitest/autofilter2/tdf97340.py 
b/sc/qa/uitest/autofilter2/tdf97340.py
index 31e41ff6c358..884caa00a5db 100644
--- a/sc/qa/uitest/autofilter2/tdf97340.py
+++ b/sc/qa/uitest/autofilter2/tdf97340.py
@@ -29,11 +29,14 @@ class tdf97340(UITestCase):
 
 xsearchEdit = xFloatWindow.getChild("search_edit")
 xsearchEdit.executeAction("TYPE", mkPropertyValues({"TEXT":" "}))
+self.ui_test.wait_until_property_is_updated(xTreeList, "Children", 
str(0))
 self.assertEqual(0, len(xTreeList.getChildren()))
 
 xsearchEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": 
"BACKSPACE"}))
 
 #tdf#133785, without the fix in place, it would have been 0
+self.ui_test.wait_until_property_is_updated(xTreeList, "Children", 
str(8))
+# Number of children differs due to xTreeList.getChildren() 
returns only direct descendants
 self.assertEqual(2, len(xTreeList.getChildren()))
 self.assertEqual("2016", 
get_state_as_dict(xTreeList.getChild('0'))['Text'])
 self.assertEqual("2017", 
get_state_as_dict(xTreeList.getChild('1'))['Text'])
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx 
b/sc/source/ui/cctrl/checklistmenu.cxx
index a89d852e6de0..456b0fe8b76a 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -507,6 +507,7 @@ 
ScCheckListMenuControl::ScCheckListMenuControl(weld::Widget* pParent, ScViewData
 , mbIsPoppedUp(false)
 , maOpenTimer(this)
 , maCloseTimer(this)
+, maSearchEditTimer("ScCheckListMenuControl maSearchEditTimer")
 {
 mxTreeChecks->set_clicks_to_toggle(1);
 mxListChecks->set_clicks_to_toggle(1);
@@ -583,6 +584,9 @@ 
ScCheckListMenuControl::ScCheckListMenuControl(weld::Widget* pParent, ScViewData
 // bulk_insert_for_each
 mxTreeChecks->set_size_request(mnCheckWidthReq, nChecksHeight);
 mxListChecks->set_size_request(mnCheckWidthReq, nChecksHeight);
+
+maSearchEditTimer.SetTimeout(EDIT_UPDATEDATA_TIMEOUT);
+maSearchEditTimer.SetInvokeHandler(LINK(this, ScCheckListMenuControl, 
SearchEditTimeoutHdl));
 }
 
 void ScCheckListMenuControl::GrabFocus()
@@ -612,6 +616,7 @@ void ScCheckListMenuControl::DropPendingEvents()
 
 ScCheckListMenuControl::~ScCheckListMenuControl()
 {
+maSearchEditTimer.Stop();
 EndPopupMode();
 for (auto& rMenuItem : maMenuItems)
 rMenuItem.mxSubMenuWin.reset();
@@ -739,7 +744,7 @@ namespace
 }
 }
 
-IMPL_LINK_NOARG(ScCheckListMenuControl, EdModifyHdl, weld::Entry&, void)
+IMPL_LINK_NOARG(ScCheckListMenuControl, SearchEditTimeoutHdl, Timer*, void)
 {
 OUString aSearchText = mxEdSearch->get_text();
 aSearchText = ScGlobal::getCharClass().lowercase( aSearchText );
@@ -875,6 +880,11 @@ IMPL_LINK_NOARG(ScCheckListMenuControl, EdModifyHdl, 
weld::Entry&, void)
 }
 }
 
+IMPL_LINK_NOARG(ScCheckListMenuControl, EdModifyHdl, weld::Entry&, void)
+{
+maSearchEditTimer.Start();
+}
+
 IMPL_LINK_NOARG(ScCheckListMenuControl, EdActivateHdl, weld::Entry&, bool)
 {
 

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

2023-04-03 Thread Andreas Heinisch (via logerrit)
 sc/qa/extras/macros-test.cxx|   26 ++
 sc/qa/extras/testdocuments/tdf89920.ods |binary
 sc/source/core/data/table6.cxx  |   15 ---
 3 files changed, 30 insertions(+), 11 deletions(-)

New commits:
commit 56ae7d01505fdae421109cfc78449230ba589d79
Author: Andreas Heinisch 
AuthorDate: Mon Mar 13 08:49:27 2023 +0100
Commit: Andreas Heinisch 
CommitDate: Mon Apr 3 08:43:06 2023 +0200

tdf#89920 - Handle embedded newline in Calc's search cell

If the replaced string contains a newline after find and replace,
insert an edit cell in order to handle an embedded line correctly
regardless of the content in the source cell.

Change-Id: Ic8a5fc80b85546897572a228511b319cd5a8b9aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148752
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index a77147504ae4..ec41a2fbe4a9 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -279,6 +279,32 @@ CPPUNIT_TEST_FIXTURE(ScMacrosTest, testTdf142033)
 CPPUNIT_ASSERT_EQUAL(OUString(u"string with" + OUStringChar(u'\xA') + 
u"newlines"), rDoc.GetString(ScAddress(1,1,0)));
 }
 
+CPPUNIT_TEST_FIXTURE(ScMacrosTest, testTdf89920)
+{
+loadFromURL(u"tdf89920.ods");
+
+
executeMacro("vnd.sun.Star.script:Standard.Module1.SearchAndReplaceNewline?language=Basic&"
+ "location=document");
+
+// Export to ODS
+saveAndReload("calc8");
+
+xmlDocUniquePtr pContentXml = parseExport("content.xml");
+CPPUNIT_ASSERT(pContentXml);
+
+assertXPathContent(pContentXml,
+   
"/office:document-content/office:body/office:spreadsheet/table:table[1]/"
+   "table:table-row[1]/table:table-cell[1]/text:p[1]",
+   "aa bb");
+
+// Without the fix in place, this test would have failed here with
+// - Expression: xmlXPathNodeSetGetLength(pXmlNodes) > 0
+assertXPathContent(pContentXml,
+   
"/office:document-content/office:body/office:spreadsheet/table:table[1]/"
+   "table:table-row[1]/table:table-cell[1]/text:p[2]",
+   "cc dd");
+}
+
 CPPUNIT_TEST_FIXTURE(ScMacrosTest, testPasswordProtectedUnicodeString)
 {
 const OUString sCorrectString(u"English Русский 中文");
diff --git a/sc/qa/extras/testdocuments/tdf89920.ods 
b/sc/qa/extras/testdocuments/tdf89920.ods
new file mode 100644
index ..216a5cc75d9d
Binary files /dev/null and b/sc/qa/extras/testdocuments/tdf89920.ods differ
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index 1f0fc1efbf3d..1ea4a5ace99d 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -35,14 +35,11 @@
 
 namespace {
 
-bool lcl_GetTextWithBreaks( const EditTextObject& rData, ScDocument* pDoc, 
OUString& rVal )
+void lcl_GetTextWithBreaks( const EditTextObject& rData, ScDocument* pDoc, 
OUString& rVal )
 {
-//  true = more than 1 paragraph
-
 EditEngine& rEngine = pDoc->GetEditEngine();
 rEngine.SetText(rData);
 rVal = rEngine.GetText();
-return ( rEngine.GetParagraphCount() > 1 );
 }
 
 }
@@ -81,7 +78,6 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, 
SCCOL nCol, sc::Colum
 pNote = nullptr;
 }
 
-bool bMultiLine = false;
 CellType eCellType = aCell.getType();
 switch (rSearchItem.GetCellType())
 {
@@ -90,7 +86,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, 
SCCOL nCol, sc::Colum
 if ( eCellType == CELLTYPE_FORMULA )
 aString = 
aCell.getFormula()->GetFormula(rDocument.GetGrammar());
 else if ( eCellType == CELLTYPE_EDIT )
-bMultiLine = lcl_GetTextWithBreaks(*aCell.getEditText(), 
, aString);
+lcl_GetTextWithBreaks(*aCell.getEditText(), , 
aString);
 else
 {
 if( !bSearchFormatted )
@@ -102,7 +98,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, 
SCCOL nCol, sc::Colum
 }
 case SvxSearchCellType::VALUE:
 if ( eCellType == CELLTYPE_EDIT )
-bMultiLine = lcl_GetTextWithBreaks(*aCell.getEditText(), 
, aString);
+lcl_GetTextWithBreaks(*aCell.getEditText(), , 
aString);
 else
 {
 if( !bSearchFormatted )
@@ -114,10 +110,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, 
SCCOL nCol, sc::Colum
 case SvxSearchCellType::NOTE:
 {
 if (pNote)
-{
 aString = pNote->GetText();
-bMultiLine = pNote->HasMultiLineText();
-}
 break;
 }
 default:
@@ -264,7 +257,7 @@ bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, 
SCCOL nCol, sc::Colum
 pFCell->SetMatColsRows( nMatCols, nMatRows 

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

2023-03-29 Thread Andreas Heinisch (via logerrit)
 sc/qa/unit/subsequent_export_test4.cxx |   23 +++
 sc/source/filter/xml/xmlexprt.cxx  |6 --
 2 files changed, 27 insertions(+), 2 deletions(-)

New commits:
commit 8085a68be7604e7bd4e0d9445be5e266ffbb
Author: Andreas Heinisch 
AuthorDate: Wed Mar 29 16:53:48 2023 +0200
Commit: Andreas Heinisch 
CommitDate: Wed Mar 29 17:22:55 2023 +

tdf#154445 - Export all page styles even if they are not in use

Change-Id: If0ca5ea97ad545058c6a70d223158a87bf9207ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149729
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/unit/subsequent_export_test4.cxx 
b/sc/qa/unit/subsequent_export_test4.cxx
index 3033ff4fef85..275493f61387 100644
--- a/sc/qa/unit/subsequent_export_test4.cxx
+++ b/sc/qa/unit/subsequent_export_test4.cxx
@@ -18,6 +18,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -418,6 +420,27 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, 
testHeaderFontStyleXLSX)
 CPPUNIT_ASSERT_MESSAGE("Second line should be italic.", bHasItalic);
 }
 
+CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf154445_unused_pagestyles)
+{
+createScDoc("ods/tdf108188_pagestyle.ods");
+
+// Check if the user defined page style is present
+const OUString aTestPageStyle = "TestPageStyle";
+ScDocument* pDoc = getScDoc();
+CPPUNIT_ASSERT_EQUAL(aTestPageStyle, pDoc->GetPageStyle(0));
+
+// Change page style to default so the user defined one is not used anymore
+pDoc->SetPageStyle(0, ScResId(STR_STYLENAME_STANDARD));
+
+// Save and reload the document to check if the unused page styles are 
still present
+saveAndReload("calc8");
+pDoc = getScDoc();
+
+// Without the accompanying fix in place, the unused page styles don't 
exist anymore
+ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+CPPUNIT_ASSERT(pStylePool->Find(aTestPageStyle, SfxStyleFamily::Page));
+}
+
 CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf135828_Shape_Rect)
 {
 if (!IsDefaultDPI())
diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index cbf8dcf11a0a..4c306de2c907 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2609,7 +2609,8 @@ void ScXMLExport::collectAutoStyles()
 }
 
 if (getExportFlags() & SvXMLExportFlags::MASTERSTYLES)
-GetPageExport()->collectAutoStyles(true);
+// tdf#154445 - export all page styles even if they are not in use
+GetPageExport()->collectAutoStyles(false);
 
 mbAutoStylesCollected = true;
 }
@@ -2671,7 +2672,8 @@ void ScXMLExport::ExportAutoStyles_()
 
 void ScXMLExport::ExportMasterStyles_()
 {
-GetPageExport()->exportMasterStyles( true );
+// tdf#154445 - export all page styles even if they are not in use
+GetPageExport()->exportMasterStyles( false );
 }
 
 void ScXMLExport::CollectInternalShape( uno::Reference< drawing::XShape > 
const & xShape )


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

2023-03-26 Thread Noel Grandin (via logerrit)
 sc/qa/unit/helper/qahelper.cxx   |6 -
 sc/qa/unit/subsequent_export_test3.cxx   |   21 +
 sc/source/core/data/documen4.cxx |   39 +-
 sc/source/core/data/document.cxx |   10 +-
 sc/source/core/data/documentimport.cxx   |   39 +-
 sc/source/core/data/funcdesc.cxx |   61 +---
 sc/source/core/tool/address.cxx  |4 -
 sc/source/core/tool/chgtrack.cxx |   16 +---
 sc/source/core/tool/compiler.cxx |4 -
 sc/source/core/tool/formulalogger.cxx|   41 --
 sc/source/core/tool/rangeutl.cxx |3 
 sc/source/core/tool/reffind.cxx  |3 
 sc/source/filter/dif/difexp.cxx  |   55 ++
 sc/source/filter/excel/read.cxx  |5 -
 sc/source/filter/excel/xecontent.cxx |   10 --
 sc/source/filter/excel/xetable.cxx   |6 -
 sc/source/filter/excel/xipivot.cxx   |3 
 sc/source/filter/html/htmlexp.cxx|   29 +++
 sc/source/filter/oox/formulabase.cxx |3 
 sc/source/filter/xml/xmlexprt.cxx|  102 ---
 sc/source/ui/app/inputhdl.cxx|   23 ++
 sc/source/ui/condformat/condformathelper.cxx |   38 --
 sc/source/ui/dbgui/asciiopt.cxx  |3 
 sc/source/ui/dbgui/csvruler.cxx  |3 
 sc/source/ui/dbgui/dbnamdlg.cxx  |9 --
 sc/source/ui/view/cellsh3.cxx|   40 +-
 sc/source/ui/view/dbfunc3.cxx|6 -
 sc/source/ui/view/gridwin.cxx|8 --
 sc/source/ui/view/viewfun2.cxx   |4 -
 29 files changed, 252 insertions(+), 342 deletions(-)

New commits:
commit 86313f053315cd0ba896e494d7bac14d2279c9b4
Author: Noel Grandin 
AuthorDate: Sat Mar 25 19:30:24 2023 +0200
Commit: Noel Grandin 
CommitDate: Sun Mar 26 11:24:13 2023 +

loplugin:stringadd in sc

after my patch to merge the bufferadd loplugin into stringadd

Change-Id: Ifa70db5be4719fe66d3043e5e49403246f6aa8bd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149582
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 27230e0d2b43..dbfb6af398f2 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -131,8 +131,7 @@ void ScModelTestBase::testFile(const OUString& aFileName, 
ScDocument& rDoc, SCTA
 catch (const orcus::parse_error& e)
 {
 std::cout << "reading csv content file failed: " << e.what() << 
std::endl;
-OStringBuffer aErrorMsg("csv parser error: ");
-aErrorMsg.append(e.what());
+OString aErrorMsg = OString::Concat("csv parser error: ") + e.what();
 CPPUNIT_ASSERT_MESSAGE(aErrorMsg.getStr(), false);
 }
 }
@@ -155,8 +154,7 @@ void ScModelTestBase::testCondFile( const OUString& 
aFileName, ScDocument* pDoc,
 catch (const orcus::parse_error& e)
 {
 std::cout << "reading csv content file failed: " << e.what() << 
std::endl;
-OStringBuffer aErrorMsg("csv parser error: ");
-aErrorMsg.append(e.what());
+OString aErrorMsg = OString::Concat("csv parser error: ") + e.what();
 CPPUNIT_ASSERT_MESSAGE(aErrorMsg.getStr(), false);
 }
 }
diff --git a/sc/qa/unit/subsequent_export_test3.cxx 
b/sc/qa/unit/subsequent_export_test3.cxx
index f07f25b2e3a7..4039f54547ef 100644
--- a/sc/qa/unit/subsequent_export_test3.cxx
+++ b/sc/qa/unit/subsequent_export_test3.cxx
@@ -264,22 +264,11 @@ CPPUNIT_TEST_FIXTURE(ScExportTest3, 
testBordersExchangeXLSX)
 
 static OUString toString(const ScBigRange& rRange)
 {
-OUStringBuffer aBuf;
-aBuf.append("(columns:");
-aBuf.append(rRange.aStart.Col());
-aBuf.append('-');
-aBuf.append(rRange.aEnd.Col());
-aBuf.append(";rows:");
-aBuf.append(rRange.aStart.Row());
-aBuf.append('-');
-aBuf.append(rRange.aEnd.Row());
-aBuf.append(";sheets:");
-aBuf.append(rRange.aStart.Tab());
-aBuf.append('-');
-aBuf.append(rRange.aEnd.Tab());
-aBuf.append(')');
-
-return aBuf.makeStringAndClear();
+return "(columns:" + OUString::number(rRange.aStart.Col()) + "-"
+   + OUString::number(rRange.aEnd.Col()) + ";rows:" + 
OUString::number(rRange.aStart.Row())
+   + "-" + OUString::number(rRange.aEnd.Row())
+   + ";sheets:" + OUString::number(rRange.aStart.Tab()) + "-"
+   + OUString::number(rRange.aEnd.Tab()) + ")";
 }
 
 CPPUNIT_TEST_FIXTURE(ScExportTest3, testTrackChangesSimpleXLSX)
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index e7945b773d9d..0db93c0aeb5b 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -386,19 +386,18 @@ void ScDocument::InsertTableOp(const ScTabOpParam& 
rParam,  // multiple (repeate
 }
 
 ScRefAddress aRef;
-   

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

2023-03-23 Thread Maxim Monastirsky (via logerrit)
 sc/qa/unit/subsequent_export_test4.cxx |   61 +
 sc/source/filter/xml/xmlexprt.cxx  |8 +---
 sc/source/filter/xml/xmlstyli.cxx  |   23 
 sc/source/filter/xml/xmlstyli.hxx  |8 
 xmloff/source/draw/shapeexport.cxx |3 +
 xmloff/source/draw/ximpshap.cxx|6 ++-
 6 files changed, 102 insertions(+), 7 deletions(-)

New commits:
commit b1393fd5ce847f40abab49f57c67929bb0087fae
Author: Maxim Monastirsky 
AuthorDate: Fri Mar 17 14:54:30 2023 +0200
Commit: Maxim Monastirsky 
CommitDate: Thu Mar 23 08:54:06 2023 +

sc drawstyles: ODF import and export

Change-Id: Id92088a7d70c550682fe707d81e94157edc7caa8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149330
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky 

diff --git a/sc/qa/unit/subsequent_export_test4.cxx 
b/sc/qa/unit/subsequent_export_test4.cxx
index 024019e89c1e..3033ff4fef85 100644
--- a/sc/qa/unit/subsequent_export_test4.cxx
+++ b/sc/qa/unit/subsequent_export_test4.cxx
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 using namespace ::com::sun::star;
@@ -1456,6 +1457,66 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, 
testAutofilterHiddenButton)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(ScExportTest4, testShapeStyles)
+{
+createScDoc();
+
+{
+uno::Reference xMSF(mxComponent, 
uno::UNO_QUERY_THROW);
+uno::Reference 
xStyleFamiliesSupplier(mxComponent,
+ 
uno::UNO_QUERY_THROW);
+uno::Reference xGraphicStyles(
+
xStyleFamiliesSupplier->getStyleFamilies()->getByName("GraphicStyles"),
+uno::UNO_QUERY_THROW);
+
+// create styles
+uno::Reference xStyle(
+xMSF->createInstance("com.sun.star.style.GraphicStyle"), 
uno::UNO_QUERY_THROW);
+xGraphicStyles->insertByName("MyStyle1", Any(xStyle));
+uno::Reference(xStyle, uno::UNO_QUERY_THROW)
+->setPropertyValue("FillColor", Any(COL_RED));
+
+xStyle.set(xMSF->createInstance("com.sun.star.style.GraphicStyle"), 
uno::UNO_QUERY_THROW);
+xGraphicStyles->insertByName("MyStyle2", Any(xStyle));
+xStyle->setParentStyle("MyStyle1");
+
+xStyle.set(xMSF->createInstance("com.sun.star.style.GraphicStyle"), 
uno::UNO_QUERY_THROW);
+xGraphicStyles->insertByName("MyStyle3", Any(xStyle));
+xStyle->setParentStyle("MyStyle2");
+
+// create shape
+uno::Reference xShape(
+xMSF->createInstance("com.sun.star.drawing.RectangleShape"), 
uno::UNO_QUERY_THROW);
+
+uno::Reference xDPS(mxComponent, 
uno::UNO_QUERY_THROW);
+uno::Reference 
xShapes(xDPS->getDrawPages()->getByIndex(0),
+ uno::UNO_QUERY_THROW);
+xShapes->add(xShape);
+uno::Reference(xShape, uno::UNO_QUERY_THROW)
+->setPropertyValue("Style", Any(xStyle));
+}
+
+saveAndReload("calc8");
+
+{
+uno::Reference xDPS(mxComponent, 
uno::UNO_QUERY_THROW);
+uno::Reference 
xShapes(xDPS->getDrawPages()->getByIndex(0),
+ uno::UNO_QUERY_THROW);
+uno::Reference xShape(xShapes->getByIndex(0), 
uno::UNO_QUERY_THROW);
+
+// check style hierarchy
+uno::Reference xStyle(xShape->getPropertyValue("Style"),
+ uno::UNO_QUERY_THROW);
+CPPUNIT_ASSERT_EQUAL(OUString("MyStyle3"), xStyle->getName());
+CPPUNIT_ASSERT_EQUAL(OUString("MyStyle2"), xStyle->getParentStyle());
+
+// check that styles have effect on shapes
+Color nColor;
+xShape->getPropertyValue("FillColor") >>= nColor;
+CPPUNIT_ASSERT_EQUAL(COL_RED, nColor);
+}
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 2e35f05367ca..df2d26e49d20 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -392,6 +392,8 @@ ScXMLExport::ScXMLExport(
 GetAutoStylePool()->AddFamily(XmlStyleFamily::TABLE_TABLE, 
XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME,
 xTableStylesExportPropertySetMapper, 
XML_STYLE_FAMILY_TABLE_TABLE_STYLES_PREFIX);
 
+GetShapeExport(); // make sure the graphics styles family is added
+
 if( !(getExportFlags() & 
(SvXMLExportFlags::STYLES|SvXMLExportFlags::AUTOSTYLES|SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::CONTENT))
 )
 return;
 
@@ -1980,10 +1982,7 @@ void ScXMLExport::ExportStyles_( bool bUsed )
 uno::Reference  
xProperties(xMultiServiceFactory->createInstance("com.sun.star.sheet.Defaults"),
 uno::UNO_QUERY);
 if (xProperties.is())
 aStylesExp->exportDefaultStyle(xProperties, 
XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME, 

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

2023-03-08 Thread Andreas Heinisch (via logerrit)
 sc/qa/unit/ucalc.cxx |   63 +++
 sc/source/core/data/documen2.cxx |   30 ++
 2 files changed, 93 insertions(+)

New commits:
commit c1af1b9c555480305862336954ceefe14865e27d
Author: Andreas Heinisch 
AuthorDate: Sun Mar 5 17:11:27 2023 +0100
Commit: Andreas Heinisch 
CommitDate: Wed Mar 8 17:48:11 2023 +

tdf#66613 - Transfer tab: preserve print ranges and col/row repetitions

Change-Id: Ib0e6f9942c2bae1f1fdfa2d0ead0868e9b790b1a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148284
Tested-by: Jenkins
Tested-by: Andreas Heinisch 
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index b9217b2b5e6e..7f50f33cb3dc 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -387,6 +387,69 @@ CPPUNIT_TEST_FIXTURE(Test, testColumnIterator) // 
tdf#118620
 m_pDoc->DeleteTab(0);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf66613)
+{
+// Create different print ranges and col/row repetitions for two tabs
+const SCTAB nFirstTab = 0;
+CPPUNIT_ASSERT(m_pDoc->InsertTab(nFirstTab, "FirstPrintRange"));
+ScRange aFirstPrintRange(0, 0, nFirstTab, 2, 2, nFirstTab);
+m_pDoc->AddPrintRange(nFirstTab, aFirstPrintRange);
+ScRange aFirstRepeatColRange(0, 0, nFirstTab, 0, 0, nFirstTab);
+m_pDoc->SetRepeatColRange(nFirstTab, aFirstRepeatColRange);
+ScRange aFirstRepeatRowRange(1, 1, nFirstTab, 1, 1, nFirstTab);
+m_pDoc->SetRepeatRowRange(nFirstTab, aFirstRepeatRowRange);
+
+const SCTAB nSecondTab = 1;
+CPPUNIT_ASSERT(m_pDoc->InsertTab(nSecondTab, "SecondPrintRange"));
+ScRange aSecondPrintRange(0, 0, nSecondTab, 3, 3, nSecondTab);
+m_pDoc->AddPrintRange(nSecondTab, aSecondPrintRange);
+ScRange aSecondRepeatColRange(1, 1, nSecondTab, 1, 1, nSecondTab);
+m_pDoc->SetRepeatColRange(nSecondTab, aSecondRepeatColRange);
+ScRange aSecondRepeatRowRange(2, 2, nSecondTab, 2, 2, nSecondTab);
+m_pDoc->SetRepeatRowRange(nSecondTab, aSecondRepeatRowRange);
+
+// Transfer generated tabs to a new document with different order
+ScDocument aScDocument;
+aScDocument.TransferTab(*m_pDoc, nSecondTab, nFirstTab);
+aScDocument.TransferTab(*m_pDoc, nFirstTab, nSecondTab);
+
+// Check the number of print ranges in both documents
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
m_pDoc->GetPrintRangeCount(nFirstTab));
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
m_pDoc->GetPrintRangeCount(nSecondTab));
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
aScDocument.GetPrintRangeCount(nFirstTab));
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
aScDocument.GetPrintRangeCount(nSecondTab));
+
+// Check the print ranges and col/row repetitions in both documents
+CPPUNIT_ASSERT_EQUAL(aFirstPrintRange, *m_pDoc->GetPrintRange(nFirstTab, 
0));
+CPPUNIT_ASSERT_EQUAL(aFirstRepeatColRange, 
*m_pDoc->GetRepeatColRange(nFirstTab));
+CPPUNIT_ASSERT_EQUAL(aFirstRepeatRowRange, 
*m_pDoc->GetRepeatRowRange(nFirstTab));
+CPPUNIT_ASSERT_EQUAL(aSecondPrintRange, *m_pDoc->GetPrintRange(nSecondTab, 
0));
+CPPUNIT_ASSERT_EQUAL(aSecondRepeatColRange, 
*m_pDoc->GetRepeatColRange(nSecondTab));
+CPPUNIT_ASSERT_EQUAL(aSecondRepeatRowRange, 
*m_pDoc->GetRepeatRowRange(nSecondTab));
+
+// Tabs have to be adjusted since the order of the tabs is inverted in the 
new document
+std::vector aScRanges
+= { ,  ,  ,
+, ,  
};
+for (size_t i = 0; i < aScRanges.size(); i++)
+{
+const SCTAB nTab = i >= 3 ? nFirstTab : nSecondTab;
+aScRanges[i]->aStart.SetTab(nTab);
+aScRanges[i]->aEnd.SetTab(nTab);
+}
+
+// Without the fix in place, no print ranges and col/row repetitions would 
be present
+CPPUNIT_ASSERT_EQUAL(aFirstPrintRange, 
*aScDocument.GetPrintRange(nSecondTab, 0));
+CPPUNIT_ASSERT_EQUAL(aFirstRepeatColRange, 
*aScDocument.GetRepeatColRange(nSecondTab));
+CPPUNIT_ASSERT_EQUAL(aFirstRepeatRowRange, 
*aScDocument.GetRepeatRowRange(nSecondTab));
+CPPUNIT_ASSERT_EQUAL(aSecondPrintRange, 
*aScDocument.GetPrintRange(nFirstTab, 0));
+CPPUNIT_ASSERT_EQUAL(aSecondRepeatColRange, 
*aScDocument.GetRepeatColRange(nFirstTab));
+CPPUNIT_ASSERT_EQUAL(aSecondRepeatRowRange, 
*aScDocument.GetRepeatRowRange(nFirstTab));
+
+m_pDoc->DeleteTab(nFirstTab);
+m_pDoc->DeleteTab(nSecondTab);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf90698)
 {
 CPPUNIT_ASSERT(m_pDoc->InsertTab (0, "Test"));
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index e21da4be599b..a7ea162177a9 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1023,6 +1023,36 @@ sal_uLong ScDocument::TransferTab( ScDocument& rSrcDoc, 
SCTAB nSrcPos,
 maTabs[nDestPos]->SetTabNo(nDestPos);
 
maTabs[nDestPos]->SetTabBgColor(rSrcDoc.maTabs[nSrcPos]->GetTabBgColor());
 
+// tdf#66613 - copy existing print ranges and col/row 

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

2023-02-18 Thread Andreas Heinisch (via logerrit)
 sc/qa/unit/data/csv/testTdf82254-csv-bom.csv |3 +++
 sc/qa/unit/subsequent_filters_test.cxx   |   21 +
 sc/source/ui/dbgui/asciiopt.cxx  |8 +++-
 sc/source/ui/dbgui/imoptdlg.cxx  |7 ++-
 sc/source/ui/docshell/docsh.cxx  |   13 +
 sc/source/ui/docshell/impex.cxx  |   11 +++
 sc/source/ui/inc/asciiopt.hxx|3 +++
 sc/source/ui/inc/imoptdlg.hxx|3 ++-
 sc/source/ui/inc/impex.hxx   |4 
 sc/source/ui/unoobj/filtuno.cxx  |6 ++
 10 files changed, 72 insertions(+), 7 deletions(-)

New commits:
commit 509ab788baf54285b4e38f2560326657d97510fd
Author: Andreas Heinisch 
AuthorDate: Fri Jan 20 12:08:13 2023 +0100
Commit: Eike Rathke 
CommitDate: Sat Feb 18 20:05:49 2023 +

tdf#82254 - Don't remove UTF-8 BOM from CSV when saving file

Don't remove the byte-order-mark in the resulting CSV file
when it was present in the CSV source file.

Change-Id: Id26abad2686917f320f2ace85441621bcf57ea9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145879
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/sc/qa/unit/data/csv/testTdf82254-csv-bom.csv 
b/sc/qa/unit/data/csv/testTdf82254-csv-bom.csv
new file mode 100755
index ..eabb18da0bf0
--- /dev/null
+++ b/sc/qa/unit/data/csv/testTdf82254-csv-bom.csv
@@ -0,0 +1,3 @@
+col1  col2col3
+row1-1 row1-2  row1-3
+row2-1 row2-2  row2-3
diff --git a/sc/qa/unit/subsequent_filters_test.cxx 
b/sc/qa/unit/subsequent_filters_test.cxx
index 10cf129c0412..6af0460170be 100644
--- a/sc/qa/unit/subsequent_filters_test.cxx
+++ b/sc/qa/unit/subsequent_filters_test.cxx
@@ -54,6 +54,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 
@@ -196,6 +198,7 @@ public:
 void testImportCrashes();
 void testTdf129681();
 void testTdf149484();
+void testTdf82254_csv_bom();
 void testEscapedUnicodeXLSX();
 void testTdf144758_DBDataDefaultOrientation();
 void testSharedFormulaXLS();
@@ -321,6 +324,7 @@ public:
 CPPUNIT_TEST(testImportCrashes);
 CPPUNIT_TEST(testTdf129681);
 CPPUNIT_TEST(testTdf149484);
+CPPUNIT_TEST(testTdf82254_csv_bom);
 CPPUNIT_TEST(testEscapedUnicodeXLSX);
 CPPUNIT_TEST(testTdf144758_DBDataDefaultOrientation);
 CPPUNIT_TEST(testSharedFormulaXLS);
@@ -3203,6 +3207,23 @@ void ScFiltersTest::testTdf149484()
 CPPUNIT_ASSERT_EQUAL(OUString("-TRUE-"), pDoc->GetString(0, 2, 0));
 }
 
+void ScFiltersTest::testTdf82254_csv_bom()
+{
+setImportFilterName(SC_TEXT_CSV_FILTER_NAME);
+createScDoc("csv/testTdf82254-csv-bom.csv");
+saveAndReload(SC_TEXT_CSV_FILTER_NAME);
+ScDocShell* pDocSh = getScDocShell();
+SvStream* pStream = pDocSh->GetMedium()->GetInStream();
+
+pStream->Seek(0);
+CPPUNIT_ASSERT_EQUAL(sal_uInt64(0), pStream->Tell());
+pStream->StartReadingUnicodeText(RTL_TEXTENCODING_UTF8);
+// Without the fix in place, this test would have failed with
+// - Expected: 3
+// - Actual  : 0 (no byte order mark was read)
+CPPUNIT_ASSERT_EQUAL(sal_uInt64(3), pStream->Tell());
+}
+
 void ScFiltersTest::testEscapedUnicodeXLSX()
 {
 createScDoc("xlsx/escape-unicode.xlsx");
diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx
index 933491efbbe5..4234794ea279 100644
--- a/sc/source/ui/dbgui/asciiopt.cxx
+++ b/sc/source/ui/dbgui/asciiopt.cxx
@@ -37,6 +37,7 @@ ScAsciiOptions::ScAsciiOptions() :
 bSkipEmptyCells(false),
 bSaveAsShown(true),
 bSaveFormulas(false),
+bIncludeBOM(false),
 cTextSep( cDefaultTextSep ),
 eCharSet( osl_getThreadTextEncoding() ),
 eLang   ( LANGUAGE_SYSTEM ),
@@ -192,6 +193,9 @@ void ScAsciiOptions::ReadFromString( std::u16string_view 
rString )
 }
 else
 bEvaluateFormulas = true;   // default of versions that didn't add the 
parameter
+
+// Token 13: include BOM.
+bIncludeBOM = nPos >= 0 && o3tl::getToken(rString, 0, ',', nPos) == 
u"true";
 }
 
 OUString ScAsciiOptions::WriteToString() const
@@ -261,7 +265,9 @@ OUString ScAsciiOptions::WriteToString() const
// Token 11: sheet to export, always 0 for current sheet
",0," +
// Token 12: evaluate formulas in import
-   OUString::boolean( bEvaluateFormulas )
+   OUString::boolean( bEvaluateFormulas ) + "," +
+   // Token 13: include BOM
+   OUString::boolean(bIncludeBOM)
 );
 return aOutStr.makeStringAndClear();
 }
diff --git a/sc/source/ui/dbgui/imoptdlg.cxx b/sc/source/ui/dbgui/imoptdlg.cxx
index b285c6ae968e..2777eb9e450b 100644
--- a/sc/source/ui/dbgui/imoptdlg.cxx
+++ b/sc/source/ui/dbgui/imoptdlg.cxx
@@ -47,6 +47,7 @@ ScImportOptions::ScImportOptions( std::u16string_view rStr )
 bRemoveSpace = false;
 nSheetToExport = 0;
 

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

2023-02-15 Thread Tibor Nagy (via logerrit)
 sc/qa/unit/data/xlsx/tdf138601.xlsx   |binary
 sc/qa/unit/subsequent_filters_test.cxx|   26 ++
 sc/source/filter/oox/condformatbuffer.cxx |   20 
 3 files changed, 46 insertions(+)

New commits:
commit 8c9a6abf30e9ff1ebd5647f7c271e0d64643860a
Author: Tibor Nagy 
AuthorDate: Thu Feb 2 20:16:04 2023 +0100
Commit: László Németh 
CommitDate: Wed Feb 15 10:17:06 2023 +

tdf#138601 XLSX import: fix priority of conditional formatting rules

Multiple conditional formattings can intersect or have the same
range of cell with different rules. Without sorting the rules
by their priority, the cells got bad formatting, e.g. different
colors than what was set in MSO.

Change-Id: I619359877f1a3e55fc8f895d5ba6f0f4f30e07f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146513
Tested-by: Jenkins
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/unit/data/xlsx/tdf138601.xlsx 
b/sc/qa/unit/data/xlsx/tdf138601.xlsx
new file mode 100644
index ..81107ee09c30
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf138601.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters_test.cxx 
b/sc/qa/unit/subsequent_filters_test.cxx
index 7749106a3883..45598beae411 100644
--- a/sc/qa/unit/subsequent_filters_test.cxx
+++ b/sc/qa/unit/subsequent_filters_test.cxx
@@ -78,6 +78,7 @@ public:
 ScFiltersTest();
 
 //ods, xls, xlsx filter tests
+void testTdf138601_CondFormatXLSX();
 void testContentODS();
 void testContentXLS();
 void testContentXLSX();
@@ -210,6 +211,7 @@ public:
 void testForcepoint107();
 
 CPPUNIT_TEST_SUITE(ScFiltersTest);
+CPPUNIT_TEST(testTdf138601_CondFormatXLSX);
 CPPUNIT_TEST(testContentODS);
 CPPUNIT_TEST(testContentXLS);
 CPPUNIT_TEST(testContentXLSX);
@@ -421,6 +423,30 @@ void testContentImpl(ScDocument& rDoc, bool 
bCheckMergedCells)
 }
 }
 
+void ScFiltersTest::testTdf138601_CondFormatXLSX()
+{
+createScDoc("xlsx/tdf138601.xlsx");
+
+ScDocument* pDoc = getScDoc();
+ScConditionalFormat* pFormat1 = pDoc->GetCondFormat(0, 0, 0);
+const ScFormatEntry* pEntry1 = pFormat1->GetEntry(0);
+const ScColorScaleFormat* pColorScale1 = static_cast(pEntry1);
+const ScColorScaleEntry* pColorScaleEntry1 = pColorScale1->GetEntry(0);
+CPPUNIT_ASSERT_EQUAL(Color(255, 255, 201), pColorScaleEntry1->GetColor());
+
+ScConditionalFormat* pFormat2 = pDoc->GetCondFormat(1, 0, 0);
+const ScFormatEntry* pEntry2 = pFormat2->GetEntry(0);
+const ScColorScaleFormat* pColorScale2 = static_cast(pEntry2);
+const ScColorScaleEntry* pColorScaleEntry2 = pColorScale2->GetEntry(0);
+CPPUNIT_ASSERT_EQUAL(Color(255, 139, 139), pColorScaleEntry2->GetColor());
+
+ScConditionalFormat* pFormat3 = pDoc->GetCondFormat(0, 1, 0);
+const ScFormatEntry* pEntry3 = pFormat3->GetEntry(0);
+const ScColorScaleFormat* pColorScale3 = static_cast(pEntry3);
+const ScColorScaleEntry* pColorScaleEntry3 = pColorScale3->GetEntry(0);
+CPPUNIT_ASSERT_EQUAL(Color(255, 255, 201), pColorScaleEntry3->GetColor());
+}
+
 void ScFiltersTest::testContentODS()
 {
 createScDoc("ods/universal-content.ods");
diff --git a/sc/source/filter/oox/condformatbuffer.cxx 
b/sc/source/filter/oox/condformatbuffer.cxx
index 87b47456ab97..1abb3bf91938 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -1163,6 +1163,26 @@ void CondFormatBuffer::finalizeImport()
 ++nExtCFIndex;
 }
 
+// tdf#138601 sort conditional formatting rules by their priority
+if (maCondFormats.size() > 1)
+{
+size_t minIndex;
+for (size_t i = 0; i < maCondFormats.size() - 1; ++i)
+{
+minIndex = i;
+for (size_t j = i + 1; j < maCondFormats.size(); ++j)
+{
+if (maCondFormats[j]->maRules.begin()->first
+< maCondFormats[minIndex]->maRules.begin()->first)
+{
+minIndex = j;
+}
+}
+if (i != minIndex)
+std::swap(maCondFormats[i], maCondFormats[minIndex]);
+}
+}
+
 for( const auto& rxCondFormat : maCondFormats )
 {
 if ( rxCondFormat)


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

2023-01-26 Thread Kohei Yoshida (via logerrit)
 sc/qa/unit/data/xml/wrap-and-shrink.xml |   82 
 sc/qa/unit/subsequent_filters_test2.cxx |   34 +
 sc/source/filter/orcus/interface.cxx|6 ++
 3 files changed, 122 insertions(+)

New commits:
commit 14c0efccba84a002050d081c961bb0b6e90b009f
Author: Kohei Yoshida 
AuthorDate: Thu Jan 26 19:41:16 2023 -0500
Commit: Kohei Yoshida 
CommitDate: Fri Jan 27 01:38:03 2023 +

tdf#147620: Pick up wrap-text and shrink-to-fit flags in Excel 2003 XML

Change-Id: I8afd0522b441a90b431ff433ff87e0c095c8cb95
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146222
Tested-by: Jenkins
Reviewed-by: Kohei Yoshida 

diff --git a/sc/qa/unit/data/xml/wrap-and-shrink.xml 
b/sc/qa/unit/data/xml/wrap-and-shrink.xml
new file mode 100644
index ..429110c64399
--- /dev/null
+++ b/sc/qa/unit/data/xml/wrap-and-shrink.xml
@@ -0,0 +1,82 @@
+
+
+http://www.w3.org/TR/REC-html40;>
+ 
+  Kohei Yoshida
+  Kohei Yoshida
+  2022-05-18T00:46:32Z
+  2022-05-18T01:44:54Z
+  16.00
+ 
+ 
+  
+ 
+ 
+  15990
+  29040
+  32767
+  32767
+  False
+  False
+ 
+ 
+  
+   
+   
+   
+   
+   
+   
+  
+  
+   
+  
+  
+   
+  
+ 
+ 
+  
+   
+   
+   
+Default
+Text long enough to spill over
+   
+   
+Wrap text
+Text long enough to spill 
over
+   
+   
+Shrink to fit
+Text long enough to spill 
over
+   
+  
+  
+   
+
+
+
+   
+   
+
+0
+   
+   
+   
+
+ 3
+ 9
+ 14
+
+   
+   False
+   False
+  
+ 
+
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx 
b/sc/qa/unit/subsequent_filters_test2.cxx
index da79b48af6b5..56e5e85ecdf6 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -153,6 +153,7 @@ public:
 void testHiddenRowsColumnsXLSXML();
 void testColumnWidthRowHeightXLSXML();
 void testCharacterSetXLSXML();
+void testWrapAndShrinkXLSXML();
 void testTdf137091();
 void testTdf141495();
 void testTdf70455();
@@ -272,6 +273,7 @@ public:
 CPPUNIT_TEST(testHiddenRowsColumnsXLSXML);
 CPPUNIT_TEST(testColumnWidthRowHeightXLSXML);
 CPPUNIT_TEST(testCharacterSetXLSXML);
+CPPUNIT_TEST(testWrapAndShrinkXLSXML);
 CPPUNIT_TEST(testCondFormatFormulaListenerXLSX);
 CPPUNIT_TEST(testTdf137091);
 CPPUNIT_TEST(testTdf141495);
@@ -1986,6 +1988,38 @@ void ScFiltersTest2::testCharacterSetXLSXML()
 CPPUNIT_ASSERT_EQUAL(aExpected, aVal);
 }
 
+void ScFiltersTest2::testWrapAndShrinkXLSXML()
+{
+createScDoc("xml/wrap-and-shrink.xml");
+ScDocument* pDoc = getScDoc();
+
+CPPUNIT_ASSERT_EQUAL(SCTAB(1), pDoc->GetTableCount());
+
+struct Check
+{
+SCCOL nCol;
+SCROW nRow;
+
+bool bWrapText;
+bool bShrinkToFit;
+};
+
+constexpr Check aChecks[] = {
+{ 1, 0, false, false },
+{ 1, 1, true, false },
+{ 1, 2, false, true },
+};
+
+for (const auto& rC : aChecks)
+{
+const ScLineBreakCell* pLB = pDoc->GetAttr(rC.nCol, rC.nRow, 0, 
ATTR_LINEBREAK);
+CPPUNIT_ASSERT_EQUAL(pLB->GetValue(), rC.bWrapText);
+
+const ScShrinkToFitCell* pSTF = pDoc->GetAttr(rC.nCol, rC.nRow, 0, 
ATTR_SHRINKTOFIT);
+CPPUNIT_ASSERT_EQUAL(pSTF->GetValue(), rC.bShrinkToFit);
+}
+}
+
 void ScFiltersTest2::testCondFormatXLSB()
 {
 createScDoc("xlsb/cond_format.xlsb");
diff --git a/sc/source/filter/orcus/interface.cxx 
b/sc/source/filter/orcus/interface.cxx
index a26beeb5a19c..1563a46f6299 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -2258,6 +2258,12 @@ void ScOrcusStyles::applyXfToItemSet( SfxItemSet& rSet, 
const ScOrcusXf& rXf )
 rSet.Put(SvxJustifyMethodItem(rXf.meHorAlignMethod, 
ATTR_HOR_JUSTIFY_METHOD));
 rSet.Put(SvxJustifyMethodItem(rXf.meVerAlignMethod, 
ATTR_VER_JUSTIFY_METHOD));
 }
+
+if (rXf.mbWrapText)
+rSet.Put(ScLineBreakCell(*rXf.mbWrapText));
+
+if (rXf.mbShrinkToFit)
+rSet.Put(ScShrinkToFitCell(*rXf.mbShrinkToFit));
 }
 
 void ScOrcusStyles::applyXfToItemSet( SfxItemSet& rSet, std::size_t xfId )


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

 sc/qa/uitest/validity/tdf150098.py |   47 +
 sc/source/core/data/validat.cxx|  175 +
 2 files changed, 205 insertions(+), 17 deletions(-)

New commits:
commit 5f2d7db094fc0f4e7ae40987c3c6762b11184419
Author: Balazs Varga 
AuthorDate: Mon Jan 23 16:48:04 2023 +0100
Commit: Balazs Varga 
CommitDate: Wed Jan 25 11:01:27 2023 +

tdf#150098 sc validation: allowing formulas for validity test

Calculate the formula results, before checking the validity test.

Change-Id: I7420982a8cbcd2df6ab0adea6e3cf61aaccb1600
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146011
Tested-by: Jenkins
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 
Reviewed-by: Balazs Varga 

diff --git a/sc/qa/uitest/validity/tdf150098.py 
b/sc/qa/uitest/validity/tdf150098.py
new file mode 100644
index ..5d29a4afaadf
--- /dev/null
+++ b/sc/qa/uitest/validity/tdf150098.py
@@ -0,0 +1,47 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+from uitest.framework import UITestCase
+from uitest.uihelper.calc import enter_text_to_cell
+from libreoffice.calc.document import get_cell_by_position
+from uitest.uihelper.common import select_by_text, select_pos
+
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+
+class EvaluateFormulaInputs(UITestCase):
+
+def test_inputs_with_formula(self):
+with self.ui_test.create_doc_in_start_center("calc") as document:
+xCalcDoc = self.xUITest.getTopFocusWindow()
+gridwin = xCalcDoc.getChild("grid_window")
+enter_text_to_cell(gridwin, "A1", "5")
+enter_text_to_cell(gridwin, "A2", "7")
+enter_text_to_cell(gridwin, "A3", "12")
+
+#Select the cells to be validated
+gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A4"}))
+#Apply Data > Validity ... > Whole Numbers
+with 
self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog:
+xTabs = xDialog.getChild("tabcontrol")
+select_pos(xTabs, "0")
+xallow = xDialog.getChild("allow")
+xallowempty = xDialog.getChild("allowempty")
+xdata = xDialog.getChild("data")
+xmin = xDialog.getChild("min")
+
+select_by_text(xallow, "Whole Numbers")
+xallowempty.executeAction("CLICK", tuple())
+select_by_text(xdata, "equal")
+xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"A3"}))
+
+enter_text_to_cell(gridwin, "A4", "=SUM(A1:A2)")
+# without the fix in place, an error message would have appeared
+self.assertEqual(get_cell_by_position(document, 0, 0, 
3).getValue(), 12.0)
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 08f77ad4f862..2cdafa132594 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -438,15 +439,85 @@ bool ScValidationData::IsDataValidCustom(
 if (rTest.isEmpty())  // check whether empty cells are allowed
 return IsIgnoreBlank();
 
-if (rTest[0] == '=')   // formulas do not pass the validity test
-return false;
+SvNumberFormatter* pFormatter = nullptr;
+sal_uInt32 nFormat = 0;
+double nVal = 0.0;
+OUString rStrResult = "";
+bool bIsVal = false;
 
-SvNumberFormatter* pFormatter = GetDocument()->GetFormatTable();
+if (rTest[0] == '=')
+{
+std::optional pFCell(std::in_place, *mpDoc, 
rPos, rTest, true);
+pFCell->SetLimitString(true);
 
-// get the value if any
-sal_uInt32 nFormat = rPattern.GetNumberFormat( pFormatter );
-double nVal;
-bool bIsVal = pFormatter->IsNumberFormat( rTest, nFormat, nVal );
+bool bColRowName = pFCell->HasColRowName();
+if (bColRowName)
+{
+// ColRowName from RPN-Code?
+if (pFCell->GetCode()->GetCodeLen() <= 1)
+{   // ==1: area
+// ==0: would be an area if...
+OUString aBraced = "(" + rTest + ")";
+pFCell.emplace(*mpDoc, rPos, aBraced, true);
+pFCell->SetLimitString(true);
+}
+else
+bColRowName = false;
+}
+
+FormulaError nErrCode = pFCell->GetErrCode();
+if (nErrCode == FormulaError::NONE || pFCell->IsMatrix())
+{
+pFormatter = mpDoc->GetFormatTable();
+const Color* pColor;
+if 

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

 sc/qa/unit/subsequent_export_test2.cxx |4 
 sc/source/filter/excel/xeescher.cxx|   17 +++--
 2 files changed, 19 insertions(+), 2 deletions(-)

New commits:
commit 7f23dae00fedc9d7119b44b6c44d9eca4f8c87b8
Author: Justin Luth 
AuthorDate: Sat Jan 21 21:40:25 2023 -0500
Commit: Justin Luth 
CommitDate: Tue Jan 24 02:14:12 2023 +

tdf#135987 xlsx vml export: retain checkbox link to cell

The checkbox can be linked to a cell, so that the cell's value
is toggled between true and false.
This was lost on a round-trip.

Change-Id: I4f2d44a594a92caedb29ded9b2c292006c803115
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145962
Tested-by: Justin Luth 
Reviewed-by: Justin Luth 

diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index 3093e63500dd..81df3cb9452f 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -1075,6 +1075,10 @@ void ScExportTest2::testTdf106181()
 pDrawing,
 
"/xdr:wsDr/mc:AlternateContent/mc:Choice/xdr:twoCellAnchor/xdr:sp/xdr:nvSpPr/xdr:cNvPr",
 "hidden", "0");
+
+xmlDocUniquePtr pVmlDrawing = parseExport("xl/drawings/vmlDrawing1.vml");
+CPPUNIT_ASSERT(pVmlDrawing);
+assertXPathContent(pVmlDrawing, "//xx:ClientData/xx:FmlaLink", "$D$9");
 }
 
 void ScExportTest2::testTdf145057()
diff --git a/sc/source/filter/excel/xeescher.cxx 
b/sc/source/filter/excel/xeescher.cxx
index c0c15fda599a..4e9491cc94c3 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -1094,13 +1094,14 @@ class VmlFormControlExporter : public 
oox::vml::VMLExport
 tools::Rectangle m_aAreaFrom;
 tools::Rectangle m_aAreaTo;
 OUString m_sControlName;
+OUString m_sFmlaLink;
 OUString m_aLabel;
 OUString m_aMacroName;
 
 public:
 VmlFormControlExporter(const sax_fastparser::FSHelperPtr& p, sal_uInt16 
nObjType,
const tools::Rectangle& rAreaFrom, const 
tools::Rectangle& rAreaTo,
-   const OUString& sControlName,
+   const OUString& sControlName, const OUString& 
sFmlaLink,
OUString aLabel, OUString aMacroName);
 
 protected:
@@ -1115,12 +1116,14 @@ VmlFormControlExporter::VmlFormControlExporter(const 
sax_fastparser::FSHelperPtr
const tools::Rectangle& 
rAreaFrom,
const tools::Rectangle& rAreaTo,
const OUString& sControlName,
+   const OUString& sFmlaLink,
OUString aLabel, OUString 
aMacroName)
 : VMLExport(p)
 , m_nObjType(nObjType)
 , m_aAreaFrom(rAreaFrom)
 , m_aAreaTo(rAreaTo)
 , m_sControlName(sControlName)
+, m_sFmlaLink(sFmlaLink)
 , m_aLabel(std::move(aLabel))
 , m_aMacroName(std::move(aMacroName))
 {
@@ -1178,6 +1181,9 @@ void VmlFormControlExporter::EndShape(sal_Int32 
nShapeElement)
 }
 XclXmlUtils::WriteElement(pVmlDrawing, FSNS(XML_x, XML_TextVAlign), 
"Center");
 
+if (!m_sFmlaLink.isEmpty())
+XclXmlUtils::WriteElement(pVmlDrawing, FSNS(XML_x, XML_FmlaLink), 
m_sFmlaLink);
+
 pVmlDrawing->endElement(FSNS(XML_x, XML_ClientData));
 VMLExport::EndShape(nShapeElement);
 }
@@ -1192,8 +1198,15 @@ void XclExpTbxControlObj::SaveVml(XclExpXmlStream& rStrm)
 tools::Rectangle aAreaTo;
 // Unlike XclExpTbxControlObj::SaveXml(), this is not calculated in EMUs.
 lcl_GetFromTo(mrRoot, pObj->GetLogicRect(), GetTab(), aAreaFrom, aAreaTo);
+
+const OUString sCellLink
+= mxCellLinkAddress.IsValid()
+  ? mxCellLinkAddress.Format(ScRefFlags::ADDR_ABS, (),
+ 
ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1))
+  : OUString();
+
 VmlFormControlExporter aFormControlExporter(rStrm.GetCurrentStream(), 
GetObjType(), aAreaFrom,
-aAreaTo, msCtrlName, msLabel, 
GetMacroName());
+aAreaTo, msCtrlName, 
sCellLink, msLabel, GetMacroName());
 aFormControlExporter.SetSkipwzName(true);  // use XML_id for legacyid, not 
XML_ID
 aFormControlExporter.OverrideShapeIDGen(true, "_x_s");
 aFormControlExporter.AddSdrObject(*pObj, /*bIsFollowingTextFlow=*/false, 
/*eHOri=*/-1,


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

 sc/qa/extras/macros-test.cxx|   34 ++
 sc/source/ui/unoobj/viewuno.cxx |9 -
 2 files changed, 42 insertions(+), 1 deletion(-)

New commits:
commit b9411e587586750f36ba9009b5f1e29fe461d8b5
Author: Andreas Heinisch 
AuthorDate: Thu Jan 12 07:46:43 2023 +0100
Commit: Andreas Heinisch 
CommitDate: Mon Jan 16 08:28:49 2023 +

tdf#147122 - Return cell object when a simple selection is merged

Change-Id: I4ddd3b3a804f8300a5ec15526f4c9c77aaf45fc5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145378
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index f53389f40459..24379362bed5 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -71,6 +71,7 @@ public:
 void testTdf107572();
 void testShapeLayerId();
 void testFunctionAccessIndirect();
+void testTdf147122();
 
 CPPUNIT_TEST_SUITE(ScMacrosTest);
 CPPUNIT_TEST(testStarBasic);
@@ -105,6 +106,7 @@ public:
 CPPUNIT_TEST(testTdf107572);
 CPPUNIT_TEST(testShapeLayerId);
 CPPUNIT_TEST(testFunctionAccessIndirect);
+CPPUNIT_TEST(testTdf147122);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -898,6 +900,38 @@ void ScMacrosTest::testFunctionAccessIndirect()
 CPPUNIT_ASSERT_EQUAL(css::uno::Any(OUString("a1")), aResult);
 }
 
+void ScMacrosTest::testTdf147122()
+{
+mxComponent = loadFromDesktop("private:factory/scalc");
+
+css::uno::Reference xDocScr(mxComponent, 
UNO_QUERY_THROW);
+auto xLibs = xDocScr->getBasicLibraries();
+auto xLibrary = xLibs->createLibrary("TestLibrary");
+xLibrary->insertByName(
+"TestModule",
+uno::Any(
+OUString("Function TestMergedSelection\n"
+ // Insert test string into cell A1
+ "  oActiveSheet = 
ThisComponent.CurrentController.ActiveSheet\n"
+ "  oActiveCell = 
oActiveSheet.getCellRangeByName(\"A1\")\n"
+ "  oActiveCell.setString(\"This is a test\")\n"
+ // Merge A1:B2 cell range and return the content of the 
merged range
+ "  oRange = oActiveSheet.getCellRangeByName(\"A1:B2\")\n"
+ "  ThisComponent.getCurrentController.Select(oRange)\n"
+ "  oActiveCell = ThisComponent.CurrentSelection\n"
+ "  oActiveCell.Merge(True)\n"
+ "  TestMergedSelection = 
ThisComponent.getCurrentSelection().getString()\n"
+ "End Function\n")));
+
+Any aRet = 
executeMacro("vnd.sun.Star.script:TestLibrary.TestModule.TestMergedSelection?"
+"language=Basic=document");
+// Without the fix in place, this test would have failed with
+// - Expression: false
+// - Unexpected dialog: Error: BASIC runtime error.
+// Property or method not found: getString.
+CPPUNIT_ASSERT_EQUAL(Any(OUString("This is a test")), aRet);
+}
+
 ScMacrosTest::ScMacrosTest()
   : UnoApiXmlTest("/sc/qa/extras/testdocuments")
 {
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index 5a7a8a391427..f8940594746c 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -70,6 +70,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace com::sun::star;
 
@@ -872,7 +873,13 @@ uno::Any SAL_CALL ScTabViewObj::getSelection()
 ScMarkType eMarkType = rViewData.GetSimpleArea(aRange);
 if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE) )
 {
-if (aRange.aStart == aRange.aEnd)
+// tdf#147122 - return cell object when a simple selection is 
merged
+ScDocument& rDoc = pDocSh->GetDocument();
+const ScPatternAttr* pMarkPattern = rDoc.GetPattern(aRange.aStart);
+if (aRange.aStart == aRange.aEnd
+|| (pMarkPattern
+&& pMarkPattern->GetItemSet().GetItemState(ATTR_MERGE, 
false)
+   == SfxItemState::SET))
 pObj = new ScCellObj( pDocSh, aRange.aStart );
 else
 pObj = new ScCellRangeObj( pDocSh, aRange );


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

 sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods |   41 --
 sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods |   65 +++-
 sc/source/core/tool/interpr1.cxx|   17 +++-
 3 files changed, 112 insertions(+), 11 deletions(-)

New commits:
commit bf432958c1d6d204511a6bb32e2c06161d811676
Author: Winfried Donkers 
AuthorDate: Sat Jan 14 18:01:12 2023 +0100
Commit: Eike Rathke 
CommitDate: Sun Jan 15 16:02:49 2023 +

tdf#152774 Fix incorrect result with HLOOKUP and VLOOKUP.

Use case now complies with ODF 6.9.5 (HLOOKUP) and 6.9.12 (VLOOKUP).
Added use case to unit test.

Change-Id: I19df718b6446098f614136f462662c753a515036
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145514
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods 
b/sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods
index e3b38cf6c85b..8e14a315ac2a 100644
--- a/sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods
+++ b/sc/qa/unit/data/functions/spreadsheet/fods/hlookup.fods
@@ -1304,10 +1304,41 @@
  
  
 
-
- 
- 
- 
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=HLOOKUP(a,{1;3;b;d},1,1)
+ 
+ 
+  tdf152774
+ 
+ 
+
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=HLOOKUP(a,{1;3;b;d},1,0)
+ 
+ 
+  tdf152774
+ 
+ 
 
 
  
@@ -1391,4 +1422,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods 
b/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods
index 354aff0d763d..e0a0530a65e7 100644
--- a/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods
+++ b/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods
@@ -2559,8 +2559,67 @@
  
  
 
-
- 
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=VLOOKUP(a,{1;3;b;d},1,1)
+ 
+ 
+  tdf152774
+ 
+ 
+
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=VLOOKUP(a,{1;3;b;d},1,0)
+ 
+ 
+  tdf152774
+ 
+ 
+
+
+ 
+  c
+ 
+ 
+  c
+ 
+ 
+  TRUE
+ 
+ 
+  =VLOOKUP(3, 
{1,a,d;2,b,e;3,c,f},
 2, 1)
+ 
+ 
+  tdf152774
+ 
+ 
+
+
+ 
+ 
+ 
+
+
+ 
 
 
  
@@ -2592,4 +2651,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index c47aec4b052c..d82acb37494c 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -5064,6 +5064,7 @@ void ScInterpreter::ScMatch()
 return;
 }
 
+// The source data is cell range.
 SCCOLROW nDelta = 0;
 if (nCol1 == nCol2)
 {   // search row in column
@@ -7508,16 +7509,26 @@ void ScInterpreter::CalculateLookup(bool bHLookup)
 {
 SCSIZE nX = static_cast(nSpIndex);
 SCSIZE nY = nDelta;
+SCSIZE nXs = 0;
+SCSIZE nYs = nY;
 if ( bHLookup )
 {
 nX = nDelta;
 nY = static_cast(nZIndex);
+nXs = nX;
+nYs = 0;
 }
 assert( nX < nC && nY < nR );
-if ( pMat->IsStringOrEmpty( nX, nY) )
-PushString(pMat->GetString( nX,nY).getString());
+if (!(rItem.meType == ScQueryEntry::ByString && pMat->IsValue( 
nXs, nYs)))
+{
+if (pMat->IsStringOrEmpty( nX, nY))
+PushString(pMat->GetString( nX, nY).getString());
+else
+PushDouble(pMat->GetDouble( nX, nY));
+}
 else
-PushDouble(pMat->GetDouble( nX,nY));
+PushNA();
+return;
 }
 else
 PushNA();


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

 sc/qa/unit/data/functions/spreadsheet/fods/match.fods |   46 +-
 sc/source/core/tool/interpr1.cxx  |6 +-
 2 files changed, 40 insertions(+), 12 deletions(-)

New commits:
commit 0ce4c1e6898ba83d487f1b225dc9ee0bbc00d9fc
Author: Winfried Donkers 
AuthorDate: Sat Dec 31 15:54:57 2022 +0100
Commit: Eike Rathke 
CommitDate: Thu Jan 12 14:55:30 2023 +

tdf#152774 Fix incorrect result with MATCH.

Use case now complies with ODF 6.9.14 (MATCH).
Added use case to unit test.

Change-Id: I749a979135fbc01a3bb1583092fb6d6a100e2d2d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144883
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/match.fods 
b/sc/qa/unit/data/functions/spreadsheet/fods/match.fods
index a050773c07e3..d5debd0d6339 100644
--- a/sc/qa/unit/data/functions/spreadsheet/fods/match.fods
+++ b/sc/qa/unit/data/functions/spreadsheet/fods/match.fods
@@ -5716,11 +5716,23 @@
  
  
 
-
- 
- 
- 
- 
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  
=MATCH(a,{1,3,b,d},1)
+ 
+ 
+  Tdf#152774
+ 
+ 
  
   4
  
@@ -5731,11 +5743,23 @@
  
  
 
-
- 
- 
- 
- 
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  TRUE
+ 
+ 
+  =MATCH(4,{d,b,3,1},-1)
+ 
+ 
+  Tdf#152774
+ 
+ 
  
   3
  
@@ -6255,4 +6279,4 @@

   
  
-
\ No newline at end of file
+
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 0785318da871..c47aec4b052c 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -5052,7 +5052,11 @@ void ScInterpreter::ScMatch()
 
 if (nHitIndex > 0) // valid hit must be 2nd item or higher
 {
-PushDouble( nHitIndex); // non-exact match
+if ( ! ( rItem.meType == ScQueryEntry::ByString &&  
aMatAcc.IsValue( nHitIndex-1 ) ) &&
+ ! ( rItem.meType == ScQueryEntry::ByValue  && 
!aMatAcc.IsValue( nHitIndex-1 ) ) )
+PushDouble( nHitIndex); // non-exact match
+else
+PushNA();
 return;
 }
 


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

 sc/qa/uitest/calc_tests6/moveCopySheet.py |   13 +
 sc/source/ui/miscdlgs/mvtabdlg.cxx|1 -
 vcl/source/uitest/uiobject.cxx|1 +
 3 files changed, 14 insertions(+), 1 deletion(-)

New commits:
commit a8d3b8985a79c216c3c132fb2e6bb0f85a27831a
Author: Andreas Heinisch 
AuthorDate: Thu Jan 5 08:21:35 2023 +0100
Commit: Andreas Heinisch 
CommitDate: Thu Jan 5 16:06:06 2023 +

tdf#56973 - Copy/paste (single) sheet is checked but not enabled

Enable the "copy" radio button in the move/copy sheet dialog, if there is 
just a single sheet in a spreadsheet document. Otherwise, users get the 
impression that a single sheet cannot be copied because the "copy" radio button 
is selected but not enabled, i.e., greyed out.

Change-Id: Icf98973585491b0c8c9a74aad3900f6cc2895d11
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145064
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/uitest/calc_tests6/moveCopySheet.py 
b/sc/qa/uitest/calc_tests6/moveCopySheet.py
index a80b7c329173..80bd9f830a27 100644
--- a/sc/qa/uitest/calc_tests6/moveCopySheet.py
+++ b/sc/qa/uitest/calc_tests6/moveCopySheet.py
@@ -63,6 +63,19 @@ class moveCopySheet(UITestCase):
 self.assertEqual(document.Sheets[1].Name, "Sheet1")
 self.assertEqual(document.Sheets[2].Name, "moveName")
 
+# tdf#56973 - copy/paste (single) sheet is checked but not enabled
+def test_tdf56973_copy_paste_inactive(self):
+with self.ui_test.create_doc_in_start_center("calc"):
+with self.ui_test.execute_dialog_through_command(".uno:Move") as 
xDialog:
+# A single sheet can only be copied
+xCopyButton = xDialog.getChild("copy")
+self.assertEqual(get_state_as_dict(xCopyButton)["Checked"], 
"true")
+self.assertEqual(get_state_as_dict(xCopyButton)["Enabled"], 
"true")
+# A single sheet can not be moved
+xMoveButton = xDialog.getChild("move")
+self.assertEqual(get_state_as_dict(xMoveButton)["Checked"], 
"false")
+self.assertEqual(get_state_as_dict(xMoveButton)["Enabled"], 
"false")
+
 #tdf#139464 Set OK button label to selected action: Move or Copy
 def test_tdf139464_move_sheet(self):
 with self.ui_test.create_doc_in_start_center("calc"):
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx 
b/sc/source/ui/miscdlgs/mvtabdlg.cxx
index 9cc587aa56e0..e64a29b6b471 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -74,7 +74,6 @@ void ScMoveTableDlg::SetForceCopyTable()
 {
 m_xBtnCopy->set_active(true);
 m_xBtnMove->set_sensitive(false);
-m_xBtnCopy->set_sensitive(false);
 SetOkBtnLabel();
 }
 
diff --git a/vcl/source/uitest/uiobject.cxx b/vcl/source/uitest/uiobject.cxx
index 0b55d4c96857..9b8616c3906b 100644
--- a/vcl/source/uitest/uiobject.cxx
+++ b/vcl/source/uitest/uiobject.cxx
@@ -1018,6 +1018,7 @@ StringMap RadioButtonUIObject::get_state()
 {
 StringMap aMap = WindowUIObject::get_state();
 aMap["Checked"] = OUString::boolean(mxRadioButton->IsChecked());
+aMap["Enabled"] = OUString::boolean(mxRadioButton->IsEnabled());
 
 return aMap;
 }


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

 sc/qa/unit/SparklineImportExportTest.cxx |9 +++--
 sc/qa/unit/copy_paste_test.cxx   |   29 +
 sc/qa/unit/helper/qahelper.cxx   |3 +
 sc/qa/unit/jumbosheets-test.cxx  |   27 
 sc/qa/unit/opencl-test.cxx   |3 +
 sc/qa/unit/tiledrendering/tiledrendering.cxx |5 +--
 sc/qa/unit/uicalc/uicalc.cxx |   45 +--
 sc/source/filter/excel/xestream.cxx  |3 +
 sc/source/filter/oox/workbookhelper.cxx  |3 +
 sc/source/ui/vba/excelvbahelper.cxx  |3 +
 10 files changed, 70 insertions(+), 60 deletions(-)

New commits:
commit 5940427063f7a6ef914b65cf9e2396eb2cc828ca
Author: Stephan Bergmann 
AuthorDate: Wed Dec 21 11:54:23 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Dec 21 14:41:10 2022 +

Use ScModelObj's existing XUnoTunnel

Change-Id: I2f0a6bbc5fe382a64d0a32ba955a28f44dad388c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144681
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sc/qa/unit/SparklineImportExportTest.cxx 
b/sc/qa/unit/SparklineImportExportTest.cxx
index 993303e00a4e..681cbd35ec79 100644
--- a/sc/qa/unit/SparklineImportExportTest.cxx
+++ b/sc/qa/unit/SparklineImportExportTest.cxx
@@ -10,6 +10,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -149,13 +150,13 @@ void checkSparklines(ScDocument& rDocument)
 void SparklineImportExportTest::testSparklinesRoundtripXLSX()
 {
 loadFromURL(u"xlsx/Sparklines.xlsx");
-ScModelObj* pModelObj = dynamic_cast(mxComponent.get());
+ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel(mxComponent);
 CPPUNIT_ASSERT(pModelObj);
 
 checkSparklines(*pModelObj->GetDocument());
 
 saveAndReload("Calc Office Open XML");
-pModelObj = dynamic_cast(mxComponent.get());
+pModelObj = comphelper::getFromUnoTunnel(mxComponent);
 CPPUNIT_ASSERT(pModelObj);
 
 checkSparklines(*pModelObj->GetDocument());
@@ -212,14 +213,14 @@ void SparklineImportExportTest::testSparklinesExportODS()
 void SparklineImportExportTest::testSparklinesRoundtripODS()
 {
 loadFromURL(u"xlsx/Sparklines.xlsx");
-ScModelObj* pModelObj = dynamic_cast(mxComponent.get());
+ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel(mxComponent);
 CPPUNIT_ASSERT(pModelObj);
 
 checkSparklines(*pModelObj->GetDocument());
 
 // Trigger export and import of sparklines
 saveAndReload("calc8");
-pModelObj = dynamic_cast(mxComponent.get());
+pModelObj = comphelper::getFromUnoTunnel(mxComponent);
 CPPUNIT_ASSERT(pModelObj);
 
 checkSparklines(*pModelObj->GetDocument());
diff --git a/sc/qa/unit/copy_paste_test.cxx b/sc/qa/unit/copy_paste_test.cxx
index c020565655ef..b91dee89dea2 100644
--- a/sc/qa/unit/copy_paste_test.cxx
+++ b/sc/qa/unit/copy_paste_test.cxx
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -76,7 +77,7 @@ void ScCopyPasteTest::testCopyPasteXLS()
 {
 loadFromURL(u"xls/chartx2.xls");
 
-ScModelObj* pModelObj = dynamic_cast(mxComponent.get());
+ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel(mxComponent);
 CPPUNIT_ASSERT(pModelObj);
 ScDocument* pDoc = pModelObj->GetDocument();
 
@@ -148,7 +149,7 @@ void ScCopyPasteTest::testTdf84411()
 {
 mxComponent = loadFromDesktop("private:factory/scalc");
 
-ScModelObj* pModelObj = dynamic_cast(mxComponent.get());
+ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel(mxComponent);
 CPPUNIT_ASSERT(pModelObj);
 ScDocument* pDoc = pModelObj->GetDocument();
 
@@ -190,7 +191,7 @@ void ScCopyPasteTest::testTdf124565()
 {
 mxComponent = loadFromDesktop("private:factory/scalc");
 
-ScModelObj* pModelObj = dynamic_cast(mxComponent.get());
+ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel(mxComponent);
 CPPUNIT_ASSERT(pModelObj);
 ScDocument* pDoc = pModelObj->GetDocument();
 
@@ -229,7 +230,7 @@ void ScCopyPasteTest::testTdf126421()
 {
 mxComponent = loadFromDesktop("private:factory/scalc");
 
-ScModelObj* pModelObj = dynamic_cast(mxComponent.get());
+ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel(mxComponent);
 CPPUNIT_ASSERT(pModelObj);
 ScDocument* pDoc = pModelObj->GetDocument();
 
@@ -257,7 +258,7 @@ void ScCopyPasteTest::testTdf107394()
 {
 mxComponent = loadFromDesktop("private:factory/scalc");
 
-ScModelObj* pModelObj = dynamic_cast(mxComponent.get());
+ScModelObj* pModelObj = 
comphelper::getFromUnoTunnel(mxComponent);
 CPPUNIT_ASSERT(pModelObj);
 ScDocument* pDoc = pModelObj->GetDocument();
 
@@ -315,7 +316,7 @@ static ScAddress lcl_getMergeSizeOfCell(const ScDocument& 
rDoc, SCCOL nCol, SCRO
 void ScCopyPasteTest::testTdf53431_fillOnAutofilter()
 {
 loadFromURL(u"ods/tdf53431_autofilterFilldown.ods");
-ScModelObj* pModelObj = dynamic_cast(mxComponent.get());
+ScModelObj* 

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

 sc/qa/unit/data/xlsx/tdf152581_bordercolorNotExportedToXLSX.xlsx |binary
 sc/qa/unit/subsequent_export_test2.cxx   |   15 
+
 sc/source/filter/excel/xeroot.cxx|1 
 sc/source/filter/excel/xestyle.cxx   |   16 
++
 sc/source/filter/inc/xestyle.hxx |3 +
 5 files changed, 35 insertions(+)

New commits:
commit b66e35c721742d2ad1c8c2cc3251661b6ce81952
Author: Attila Szűcs 
AuthorDate: Mon Dec 19 05:35:36 2022 +0100
Commit: Andras Timar 
CommitDate: Tue Dec 20 12:57:14 2022 +

tdf#152581 SC: fix export of conditional border color

Call XclExpDxf::mpBorder->SetFinalColors(..) during export, before 
SaveXml().
It will calculate the prepered colors from mnLeftColorId to mnLeftColor,
so saveXml() will be able to save it.

Change-Id: I1a1ed621c6d0e883cb9016e60ae0b344bf90
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144576
Tested-by: Jenkins
Reviewed-by: Andras Timar 

diff --git a/sc/qa/unit/data/xlsx/tdf152581_bordercolorNotExportedToXLSX.xlsx 
b/sc/qa/unit/data/xlsx/tdf152581_bordercolorNotExportedToXLSX.xlsx
new file mode 100644
index ..2423f4cc0243
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/tdf152581_bordercolorNotExportedToXLSX.xlsx differ
diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index 9717f3579972..5a1ebc5c2d3c 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -167,6 +167,7 @@ public:
 void testTdf144642_RowHeightRounding();
 void testTdf145129_DefaultRowHeightRounding();
 void testTdf151755_stylesLostOnXLSXExport();
+void testTdf152581_bordercolorNotExportedToXLSX();
 void testTdf140431();
 void testCheckboxFormControlXlsxExport();
 void testButtonFormControlXlsxExport();
@@ -295,6 +296,7 @@ public:
 CPPUNIT_TEST(testTdf144642_RowHeightRounding);
 CPPUNIT_TEST(testTdf145129_DefaultRowHeightRounding);
 CPPUNIT_TEST(testTdf151755_stylesLostOnXLSXExport);
+CPPUNIT_TEST(testTdf152581_bordercolorNotExportedToXLSX);
 CPPUNIT_TEST(testTdf140431);
 CPPUNIT_TEST(testCheckboxFormControlXlsxExport);
 CPPUNIT_TEST(testButtonFormControlXlsxExport);
@@ -2290,6 +2292,19 @@ void 
ScExportTest2::testTdf151755_stylesLostOnXLSXExport()
 assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[4]", "s", 
aCellStyleId);
 }
 
+void ScExportTest2::testTdf152581_bordercolorNotExportedToXLSX()
+{
+createScDoc("xlsx/tdf152581_bordercolorNotExportedToXLSX.xlsx");
+
+// Resave the xlsx file without any modification.
+save("Calc Office Open XML");
+xmlDocUniquePtr pStyles = parseExport("xl/styles.xml");
+CPPUNIT_ASSERT(pStyles);
+
+// Check if conditional format border color is exported
+assertXPath(pStyles, "/x:styleSheet/x:dxfs/x:dxf/x:border/x:left/x:color", 
"rgb", "FFED7D31");
+}
+
 void ScExportTest2::testTdf140431()
 {
 createScDoc("xlsx/129969-min.xlsx");
diff --git a/sc/source/filter/excel/xeroot.cxx 
b/sc/source/filter/excel/xeroot.cxx
index 38884c48415c..807a24aae60b 100644
--- a/sc/source/filter/excel/xeroot.cxx
+++ b/sc/source/filter/excel/xeroot.cxx
@@ -276,6 +276,7 @@ void XclExpRoot::InitializeSave()
 {
 GetPalette().Finalize();
 GetXFBuffer().Finalize();
+GetDxfs().Finalize();
 }
 
 XclExpRecordRef XclExpRoot::CreateRecord( sal_uInt16 nRecId ) const
diff --git a/sc/source/filter/excel/xestyle.cxx 
b/sc/source/filter/excel/xestyle.cxx
index cb1c3c8fe26a..3e335a50110c 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -3210,6 +3210,14 @@ void XclExpDxfs::SaveXml( XclExpXmlStream& rStrm )
 rStyleSheet->endElement( XML_dxfs );
 }
 
+void XclExpDxfs::Finalize()
+{
+for (auto& rxDxf : maDxf)
+{
+rxDxf->SetFinalColors();
+}
+}
+
 XclExpDxf::XclExpDxf( const XclExpRoot& rRoot, 
std::unique_ptr pAlign, std::unique_ptr 
pBorder,
 std::unique_ptr pFont, 
std::unique_ptr pNumberFmt, std::unique_ptr pProt,
 std::unique_ptr pColor)
@@ -3233,6 +3241,14 @@ XclExpDxf::~XclExpDxf()
 {
 }
 
+void XclExpDxf::SetFinalColors()
+{
+if (mpBorder)
+{
+mpBorder->SetFinalColors(GetPalette());
+}
+}
+
 void XclExpDxf::SaveXml( XclExpXmlStream& rStrm )
 {
 sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream();
diff --git a/sc/source/filter/inc/xestyle.hxx b/sc/source/filter/inc/xestyle.hxx
index 7857e215557b..8c3493d352f3 100644
--- a/sc/source/filter/inc/xestyle.hxx
+++ b/sc/source/filter/inc/xestyle.hxx
@@ -734,6 +734,7 @@ public:
 
 virtual void SaveXml( XclExpXmlStream& rStrm ) override;
 void SaveXmlExt( XclExpXmlStream& rStrm);
+void SetFinalColors();
 
 private:
 std::unique_ptr mpAlign;
@@ -755,6 +756,8 @@ public:
 void AddColor(Color aColor);
 
 virtual void SaveXml( 

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

 sc/qa/uitest/autofilter2/tdf151152.py |   52 ++
 sc/source/ui/view/gridwin.cxx |   14 +++--
 2 files changed, 63 insertions(+), 3 deletions(-)

New commits:
commit 2298087db28ee1b4251cac6e12c1d4806b395a1e
Author: Tünde Tóth 
AuthorDate: Wed Dec 7 13:34:37 2022 +0100
Commit: László Németh 
CommitDate: Mon Dec 19 11:02:53 2022 +

tdf#151152 sc filter: fix string entry checking

When a column was filtered for values that included 0,
the all string entries were always checked in the Autofilter
dropdown (because their conversion to number, i.e. value 0
was used to check their existence in the filtered values
instead of their string value).

Regression from commit f6b143a57d9bd8f5d7b29febcb4e01ee1eb2ff1d
"tdf#142910 sc filter: fix "greater than" or "smaller than" etc".

Change-Id: Ib659aba9d6f3d6bc3557547b1a27963f51e3eca3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143777
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/uitest/autofilter2/tdf151152.py 
b/sc/qa/uitest/autofilter2/tdf151152.py
new file mode 100644
index ..6971096e9844
--- /dev/null
+++ b/sc/qa/uitest/autofilter2/tdf151152.py
@@ -0,0 +1,52 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+from uitest.framework import UITestCase
+from uitest.uihelper.calc import enter_text_to_cell
+from uitest.uihelper.common import get_state_as_dict
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+#Bug 151152 - Autofilter checkbox status is wrong when I deselect one item, 
click OK, then click on the dropdown again (2nd case)
+
+class tdf151152(UITestCase):
+def test_tdf151152(self):
+with self.ui_test.create_doc_in_start_center("calc"):
+calcDoc = self.xUITest.getTopFocusWindow()
+gridwin = calcDoc.getChild("grid_window")
+
+enter_text_to_cell(gridwin, "A1", "A")
+enter_text_to_cell(gridwin, "A2", "0")
+enter_text_to_cell(gridwin, "A3", "a")
+enter_text_to_cell(gridwin, "A4", "b")
+
+gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": 
"A1:A4"}))
+
+self.xUITest.executeCommand(".uno:DataFilterAutoFilter")
+
+gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": 
"", "COL": "0", "ROW": "0"}))
+xFloatWindow = self.xUITest.getFloatWindow()
+xCheckListMenu = xFloatWindow.getChild("FilterDropDown")
+xList = xCheckListMenu.getChild("check_list_box")
+xEntry = xList.getChild("1")
+xEntry.executeAction("CLICK", tuple())
+
+xOkButton = xFloatWindow.getChild("ok")
+xOkButton.executeAction("CLICK", tuple())
+
+gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": 
"", "COL": "0", "ROW": "0"}))
+xFloatWindow = self.xUITest.getFloatWindow()
+xCheckListMenu = xFloatWindow.getChild("FilterDropDown")
+xList = xCheckListMenu.getChild("check_list_box")
+self.assertEqual(3, len(xList.getChildren()))
+self.assertEqual('true', 
get_state_as_dict(xList.getChild('0'))['IsChecked'])
+self.assertEqual('false', 
get_state_as_dict(xList.getChild('1'))['IsChecked'])
+self.assertEqual('true', 
get_state_as_dict(xList.getChild('2'))['IsChecked'])
+xCloseBtn = xFloatWindow.getChild("cancel")
+xCloseBtn.executeAction("CLICK", tuple())
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 3316afdf95e4..547338589298 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -963,10 +963,18 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW 
nRow)
 
 if (!aSelectedValue.empty() || !aSelectedString.empty())
 {
-if (aDoubleVal == aRDoubleVal)
-bSelected = aSelectedValue.count(aDoubleVal) > 0 || 
aSelectedString.count(aStringVal) > 0;
+if (rEntry.GetStringType() == ScTypedStrData::Value)
+{
+if (aDoubleVal == aRDoubleVal)
+bSelected = aSelectedValue.count(aDoubleVal) > 0
+|| aSelectedString.count(aStringVal) > 0;
+else
+bSelected = aSelectedValue.count(aDoubleVal) > 0
+|| aSelectedValue.count(aRDoubleVal) > 0
+|| aSelectedString.count(aStringVal) > 0;
+}
 else
-bSelected = aSelectedValue.count(aDoubleVal) > 0 || 

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

 sc/qa/uitest/autofilter/autofilterBugs.py  |   18 ++
 sc/qa/uitest/data/autofilter/tdf152082.ods |binary
 sc/source/filter/xml/xmlfilti.cxx  |2 ++
 3 files changed, 20 insertions(+)

New commits:
commit 1f30f9cf012cee6823029ef5a96a1d91a0e16cdc
Author: Tünde Tóth 
AuthorDate: Wed Dec 7 12:44:18 2022 +0100
Commit: László Németh 
CommitDate: Mon Dec 19 10:38:36 2022 +

tdf#152082 ODS: fix import of Empty filter operator

Bad import of the Empty filter operator resulted shifted
filter settings, e.g. selected "A" and "B" instead of
"empty" and "A" from the range "empty", "A" and "B".

Regression from commit f6b143a57d9bd8f5d7b29febcb4e01ee1eb2ff1d
"tdf#142910 sc filter: fix "greater than" or "smaller than" etc".

Change-Id: I33082d77fb9e707aa474fb22753a001960341d66
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143776
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/uitest/autofilter/autofilterBugs.py 
b/sc/qa/uitest/autofilter/autofilterBugs.py
index 100ceaf246f1..6fa029985fcc 100644
--- a/sc/qa/uitest/autofilter/autofilterBugs.py
+++ b/sc/qa/uitest/autofilter/autofilterBugs.py
@@ -252,4 +252,22 @@ class autofilter(UITestCase):
 xCancel = xFloatWindow.getChild("cancel")
 xCancel.executeAction("CLICK", tuple())
 
+#tdf152082
+   def test_tdf152082(self):
+with self.ui_test.load_file(get_url_for_data_file("tdf152082.ods")):
+xCalcDoc = self.xUITest.getTopFocusWindow()
+gridwin = xCalcDoc.getChild("grid_window")
+
+gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": 
"", "COL": "0", "ROW": "0"}))
+xFloatWindow = self.xUITest.getFloatWindow()
+xCheckListMenu = xFloatWindow.getChild("FilterDropDown")
+xTreeList = xCheckListMenu.getChild("check_list_box")
+self.assertEqual(4, len(xTreeList.getChildren()))
+self.assertEqual('true', 
get_state_as_dict(xTreeList.getChild('0'))['IsChecked'])
+self.assertEqual('true', 
get_state_as_dict(xTreeList.getChild('1'))['IsChecked'])
+self.assertEqual('true', 
get_state_as_dict(xTreeList.getChild('2'))['IsChecked'])
+self.assertEqual('false', 
get_state_as_dict(xTreeList.getChild('3'))['IsChecked'])
+xCancelBtn = xFloatWindow.getChild("cancel")
+xCancelBtn.executeAction("CLICK", tuple())
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/qa/uitest/data/autofilter/tdf152082.ods 
b/sc/qa/uitest/data/autofilter/tdf152082.ods
new file mode 100644
index ..6a0e1cac6751
Binary files /dev/null and b/sc/qa/uitest/data/autofilter/tdf152082.ods differ
diff --git a/sc/source/filter/xml/xmlfilti.cxx 
b/sc/source/filter/xml/xmlfilti.cxx
index e549a3438d78..7585ce0c50fa 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -422,6 +422,8 @@ void SAL_CALL ScXMLConditionContext::endFastElement( 
sal_Int32 /*nElement*/ )
 if (maQueryItems.empty())
 {
 ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+if (IsXMLToken(sOperator, XML_EMPTY))
+return;
 if (IsXMLToken(sDataType, XML_NUMBER))
 {
 rItem.mfVal = sConditionValue.toDouble();


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

 sc/qa/unit/data/xlsx/tdf151755_stylesLostOnXLSXExport.xlsx |binary
 sc/qa/unit/subsequent_export_test2.cxx |   21 +
 sc/source/filter/excel/xetable.cxx |8 +++-
 3 files changed, 26 insertions(+), 3 deletions(-)

New commits:
commit c57d113e9ef8608f5690e8707a97879cb4f6a185
Author: Attila Szűcs 
AuthorDate: Tue Nov 29 09:45:36 2022 +0100
Commit: Andras Timar 
CommitDate: Mon Dec 19 06:16:08 2022 +

tdf#151755 fix export of borders of contentless cells

Change-Id: I650aeebb4d021911c1f14d4867c5beee84020155
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143880
Tested-by: Jenkins
Reviewed-by: Andras Timar 

diff --git a/sc/qa/unit/data/xlsx/tdf151755_stylesLostOnXLSXExport.xlsx 
b/sc/qa/unit/data/xlsx/tdf151755_stylesLostOnXLSXExport.xlsx
new file mode 100644
index ..e48562022af8
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/tdf151755_stylesLostOnXLSXExport.xlsx differ
diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index 4010cc9dce1f..40fb4f360536 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -166,6 +166,7 @@ public:
 void testTdf139258_rotated_image();
 void testTdf144642_RowHeightRounding();
 void testTdf145129_DefaultRowHeightRounding();
+void testTdf151755_stylesLostOnXLSXExport();
 void testTdf140431();
 void testCheckboxFormControlXlsxExport();
 void testButtonFormControlXlsxExport();
@@ -293,6 +294,7 @@ public:
 CPPUNIT_TEST(testTdf139258_rotated_image);
 CPPUNIT_TEST(testTdf144642_RowHeightRounding);
 CPPUNIT_TEST(testTdf145129_DefaultRowHeightRounding);
+CPPUNIT_TEST(testTdf151755_stylesLostOnXLSXExport);
 CPPUNIT_TEST(testTdf140431);
 CPPUNIT_TEST(testCheckboxFormControlXlsxExport);
 CPPUNIT_TEST(testButtonFormControlXlsxExport);
@@ -2269,6 +2271,25 @@ void 
ScExportTest2::testTdf145129_DefaultRowHeightRounding()
 CPPUNIT_ASSERT_EQUAL(tools::Long(555 * 52), pDoc->GetRowHeight(0, 51, 0, 
true));
 }
 
+void ScExportTest2::testTdf151755_stylesLostOnXLSXExport()
+{
+// Check if empty cells with custom sytle are exported, even if
+// there is other empty cells with default style, left of it.
+createScDoc("xlsx/tdf151755_stylesLostOnXLSXExport.xlsx");
+
+// Resave the xlsx file without any modification.
+save("Calc Office Open XML");
+xmlDocUniquePtr pSheet = parseExport("xl/worksheets/sheet1.xml");
+CPPUNIT_ASSERT(pSheet);
+
+// Check if all the 3 empty cells with styles are saved, and have the same 
style id.
+assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c", 4);
+OUString aCellStyleId = getXPath(pSheet, 
"/x:worksheet/x:sheetData/x:row[4]/x:c[2]", "s");
+assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[2]", "s", 
aCellStyleId);
+assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[3]", "s", 
aCellStyleId);
+assertXPath(pSheet, "/x:worksheet/x:sheetData/x:row[4]/x:c[4]", "s", 
aCellStyleId);
+}
+
 void ScExportTest2::testTdf140431()
 {
 createScDoc("xlsx/129969-min.xlsx");
diff --git a/sc/source/filter/excel/xetable.cxx 
b/sc/source/filter/excel/xetable.cxx
index 146f6a06833b..e7abb111c63e 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -1310,12 +1310,14 @@ void XclExpMultiCellBase::RemoveUnusedXFIndexes( const 
ScfUInt16Vec& rXFIndexes,
 sal_uInt16 XclExpMultiCellBase::GetStartColAllDefaultCell() const
 {
 sal_uInt16 col = GetXclCol();
+sal_uInt16 nMaxNonDefCol = col;
 for( const auto& rXFId : maXFIds )
 {
-if( rXFId.mnXFIndex != EXC_XF_DEFAULTCELL )
-col += rXFId.mnCount;
+col += rXFId.mnCount;
+if (rXFId.mnXFIndex != EXC_XF_DEFAULTCELL)
+nMaxNonDefCol = col;
 }
-return col;
+return nMaxNonDefCol;
 }
 
 XclExpBlankCell::XclExpBlankCell( const XclAddress& rXclPos, const 
XclExpMultiXFId& rXFId ) :


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

 sc/qa/unit/data/xlsx/hiddenButton.xlsx|binary
 sc/qa/unit/subsequent_export_test2.cxx|   15 
 sc/source/filter/excel/excrecds.cxx   |   54 ++
 sc/source/filter/inc/autofilterbuffer.hxx |1 
 sc/source/filter/inc/excrecds.hxx |5 ++
 sc/source/filter/oox/autofilterbuffer.cxx |   18 +-
 6 files changed, 85 insertions(+), 8 deletions(-)

New commits:
commit 2942fdc8dbda375622d0add8c36df2d6679e321a
Author: offtkp 
AuthorDate: Fri Nov 25 15:16:53 2022 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Dec 1 13:05:54 2022 +0100

tdf#144786 Implement XML_hiddenButton functionality

Now hides autofilter button when there's an XML_hiddenButton=true
or a XML_showButton=false attribute

Change-Id: I911ef23fb5e4feff8c7de0ec154bff871a29f2e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143300
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/qa/unit/data/xlsx/hiddenButton.xlsx 
b/sc/qa/unit/data/xlsx/hiddenButton.xlsx
new file mode 100644
index ..20019f4d181b
Binary files /dev/null and b/sc/qa/unit/data/xlsx/hiddenButton.xlsx differ
diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index 628401167d5a..77b033d042a3 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -189,6 +189,7 @@ public:
 void testTdf148820();
 void testEmbeddedTextInDecimal();
 void testTotalsRowFunction();
+void testAutofilterHiddenButton();
 
 CPPUNIT_TEST_SUITE(ScExportTest2);
 
@@ -315,6 +316,7 @@ public:
 CPPUNIT_TEST(testTdf148820);
 CPPUNIT_TEST(testEmbeddedTextInDecimal);
 CPPUNIT_TEST(testTotalsRowFunction);
+CPPUNIT_TEST(testAutofilterHiddenButton);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -2849,6 +2851,19 @@ void ScExportTest2::testTotalsRowFunction()
 }
 }
 
+void ScExportTest2::testAutofilterHiddenButton()
+{
+createScDoc("xlsx/hiddenButton.xlsx");
+saveAndReload("Calc Office Open XML");
+xmlDocUniquePtr pDocXml = parseExport("xl/tables/table1.xml");
+CPPUNIT_ASSERT(pDocXml);
+for (int i = 1; i <= 5; i++)
+{
+auto sPath = "/x:table/x:autoFilter/x:filterColumn[" + 
std::to_string(i) + "]";
+assertXPath(pDocXml, sPath.c_str(), "hiddenButton", "1");
+}
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/excel/excrecds.cxx 
b/sc/source/filter/excel/excrecds.cxx
index b175445bc388..3feac86be5a2 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -47,6 +47,8 @@
 
 #include 
 #include 
+#include 
+#include 
 
 using namespace ::oox;
 
@@ -603,11 +605,12 @@ void ExcFilterCondition::SaveText( XclExpStream& rStrm )
 }
 }
 
-XclExpAutofilter::XclExpAutofilter( const XclExpRoot& rRoot, sal_uInt16 nC ) :
+XclExpAutofilter::XclExpAutofilter( const XclExpRoot& rRoot, sal_uInt16 nC, 
bool bIsEmpty ) :
 XclExpRecord( EXC_ID_AUTOFILTER, 24 ),
 XclExpRoot( rRoot ),
-meType(FilterCondition),
+meType(bIsEmpty ? Empty : FilterCondition),
 nCol( nC ),
+bIsButtonHidden( false ),
 nFlags( 0 ),
 bHasBlankValue( false )
 {
@@ -818,10 +821,13 @@ void XclExpAutofilter::SaveXml( XclExpXmlStream& rStrm )
 
 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
 
+std::optional sHiddenButtonValue;
+if (bIsButtonHidden)
+sHiddenButtonValue = "1";
+
 rWorksheet->startElement( XML_filterColumn,
-XML_colId, OString::number(nCol)
-// OOXTODO: XML_hiddenButton,   AutoFilter12 fHideArrow?
-// OOXTODO: XML_showButton
+XML_colId, OString::number(nCol),
+XML_hiddenButton, sHiddenButtonValue
 );
 
 switch (meType)
@@ -911,6 +917,8 @@ void XclExpAutofilter::SaveXml( XclExpXmlStream& rStrm )
 rWorksheet->endElement(XML_filters);
 }
 break;
+// Used for constructing an empty filterColumn element for exporting 
the XML_hiddenButton attribute
+case Empty: break;
 }
 rWorksheet->endElement( XML_filterColumn );
 }
@@ -971,6 +979,8 @@ ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& 
rRoot, SCTAB nTab, const
 boolbContLoop   = true;
 boolbHasOr  = false;
 SCCOLROW nFirstField = aParam.GetEntry( 0 ).nField;
+ScDocument& rDoc = rRoot.GetDoc();
+SCROW nRow = aRange.aStart.Row();
 
 // create AUTOFILTER records for filtered columns
 for( SCSIZE nEntry = 0; !bConflict && bContLoop && (nEntry < 
aParam.GetEntryCount()); nEntry++ )
@@ -980,7 +990,11 @@ ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& 
rRoot, SCTAB nTab, const
 bContLoop = rEntry.bDoQuery;
 if( bContLoop )
 {
-XclExpAutofilter* pFilter = GetByCol( 
static_cast(rEntry.nField) - 

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

 sc/qa/unit/data/ods/tdf152081_UndoHideColsWithNotes.ods |binary
 sc/qa/unit/scshapetest.cxx  |   31 
 sc/source/core/data/drwlayer.cxx|2 -
 3 files changed, 32 insertions(+), 1 deletion(-)

New commits:
commit c9807faad6a154b57a99adfdf9b02bd9e588250f
Author: Balazs Varga 
AuthorDate: Fri Nov 25 14:03:45 2022 +0100
Commit: Balazs Varga 
CommitDate: Sat Nov 26 22:41:04 2022 +0100

Related: tdf#46444 tdf#152081 sc: add unit test for note hiding

Add unit test for column hiding with notes and undo that.

Change-Id: I880ca1565dbefea5e8776b0d137da409ce816ac1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143299
Tested-by: Jenkins
Reviewed-by: Balazs Varga 

diff --git a/sc/qa/unit/data/ods/tdf152081_UndoHideColsWithNotes.ods 
b/sc/qa/unit/data/ods/tdf152081_UndoHideColsWithNotes.ods
new file mode 100644
index ..6d2b480db7b6
Binary files /dev/null and 
b/sc/qa/unit/data/ods/tdf152081_UndoHideColsWithNotes.ods differ
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index af3d7308ee0e..58a9623ec4ec 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -61,6 +61,7 @@ public:
 void testLoadVerticalFlip();
 void testTdf117948_CollapseBeforeShape();
 void testTdf137355_UndoHideRows();
+void testTdf152081_UndoHideColsWithNotes();
 void testTdf115655_HideDetail();
 void testFitToCellSize();
 void testCustomShapeCellAnchoredRotatedShape();
@@ -88,6 +89,7 @@ public:
 CPPUNIT_TEST(testLoadVerticalFlip);
 CPPUNIT_TEST(testTdf117948_CollapseBeforeShape);
 CPPUNIT_TEST(testTdf137355_UndoHideRows);
+CPPUNIT_TEST(testTdf152081_UndoHideColsWithNotes);
 CPPUNIT_TEST(testTdf115655_HideDetail);
 CPPUNIT_TEST(testFitToCellSize);
 CPPUNIT_TEST(testCustomShapeCellAnchoredRotatedShape);
@@ -945,6 +947,35 @@ void ScShapeTest::testTdf137355_UndoHideRows()
  aSnapRectUndo, 1);
 }
 
+void ScShapeTest::testTdf152081_UndoHideColsWithNotes()
+{
+createScDoc("tdf152081_UndoHideColsWithNotes.ods");
+
+// Get document and shape
+ScDocument* pDoc = getScDoc();
+SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
+
+CPPUNIT_ASSERT_MESSAGE("Load: Note object should be visible", 
pObj->IsVisible());
+
+// Hide B column
+uno::Sequence aPropertyValues = {
+comphelper::makePropertyValue("ToPoint", OUString("$B$2:$B$2")),
+};
+dispatchCommand(mxComponent, ".uno:GoToCell", aPropertyValues);
+ScTabViewShell* pViewShell = getViewShell();
+pViewShell->GetViewData().GetDispatcher().Execute(FID_COL_HIDE);
+
+// Check object is invisible
+CPPUNIT_ASSERT_MESSAGE("Hide: Note object should be invisible", 
!pObj->IsVisible());
+
+// Undo
+pViewShell->GetViewData().GetDispatcher().Execute(SID_UNDO);
+
+// Check object is visible
+CPPUNIT_ASSERT_MESSAGE("Undo: Note object should exist", pObj);
+CPPUNIT_ASSERT_MESSAGE("Undo: Note object should be visible", 
pObj->IsVisible());
+}
+
 void ScShapeTest::testTdf115655_HideDetail()
 {
 // The document contains an image inside a cell anchored "To Cell (resize 
with cell)". The cell
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 9474d5859407..ec4fee275ed1 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -1035,7 +1035,7 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, 
ScDrawObjData& rData, bool bNegati
 additional boolean stating if the cells are already moved. */
 /*  tdf #152081 Do not change hidden objects. That would produce zero 
height
 or width and loss of caption.*/
-if (pObj->IsVisible() && bUpdateNoteCaptionPos)
+if (bUpdateNoteCaptionPos && pObj->IsVisible())
 {
 /*  When inside an undo action, there may be pending note captions
 where cell note is already deleted (thus document cannot find


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

 sc/qa/unit/data/xlsx/groupShape.xlsx   |binary
 sc/qa/unit/subsequent_export_test2.cxx |   12 
 sc/source/filter/xcl97/xcl97rec.cxx|   25 ++---
 3 files changed, 30 insertions(+), 7 deletions(-)

New commits:
commit c4d7b9c3ec6e44b96134fdfb036be7f9fcf39f9d
Author: Tibor Nagy 
AuthorDate: Wed Nov 23 12:14:31 2022 +0100
Commit: Nagy Tibor 
CommitDate: Fri Nov 25 14:01:09 2022 +0100

tdf#70293 XLSX export: fix lost grouping of shapes

SaveDrawingMLObjects() needs to skip all
the grouped objects, including subgroups
of a group to avoid of broken export. Fixing
this and reverting the old workaround
commit c323e60157422ae264e798b9a279a532fe9997af
"ignore the (unsupported ) group customshape when exporting xlsx",
Calc keeps the grouped state of the objects now.

Change-Id: Ic320248a1c646d8adb9ce55bb2e5dcd880c1df6f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143142
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/unit/data/xlsx/groupShape.xlsx 
b/sc/qa/unit/data/xlsx/groupShape.xlsx
new file mode 100644
index ..060b3fd2e377
Binary files /dev/null and b/sc/qa/unit/data/xlsx/groupShape.xlsx differ
diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index 03f747e82b63..55c628f1de6b 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -64,6 +64,7 @@ protected:
 public:
 ScExportTest2();
 
+void testGroupShape();
 void testMatrixMultiplicationXLSX();
 void testTdf121260();
 void testTextDirectionXLSX();
@@ -189,6 +190,7 @@ public:
 
 CPPUNIT_TEST_SUITE(ScExportTest2);
 
+CPPUNIT_TEST(testGroupShape);
 CPPUNIT_TEST(testMatrixMultiplicationXLSX);
 CPPUNIT_TEST(testTdf121260);
 CPPUNIT_TEST(testTextDirectionXLSX);
@@ -324,6 +326,16 @@ void ScExportTest2::registerNamespaces(xmlXPathContextPtr& 
pXmlXPathCtx)
 XmlTestTools::registerODFNamespaces(pXmlXPathCtx);
 }
 
+void ScExportTest2::testGroupShape()
+{
+createScDoc("xlsx/groupShape.xlsx");
+save("Calc Office Open XML");
+
+xmlDocUniquePtr pDoc = parseExport("xl/drawings/drawing1.xml");
+CPPUNIT_ASSERT(pDoc);
+assertXPath(pDoc, "/xdr:wsDr/xdr:twoCellAnchor/xdr:grpSp/xdr:grpSpPr");
+}
+
 void ScExportTest2::testMatrixMultiplicationXLSX()
 {
 createScDoc("xlsx/matrix-multiplication.xlsx");
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx 
b/sc/source/filter/xcl97/xcl97rec.cxx
index 55ec685428ae..84718321b126 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -225,13 +225,29 @@ bool IsValidObject( const XclObj& rObj )
 void SaveDrawingMLObjects( XclExpObjList& rList, XclExpXmlStream& rStrm )
 {
 std::vector aList;
-aList.reserve(rList.size());
+// do not add objects to the list that are in the group,
+// because the group already contains them. For this, count
+// the next skipped objects, i.e. objects of a group,
+// including objects of its subgroups
+size_t nSkipObj = 0;
 for (const auto& rxObj : rList)
 {
+// FIXME: Can DrawingML objects be grouped with VML or not valid 
objects?
 if (IsVmlObject(rxObj.get()) || !IsValidObject(*rxObj))
 continue;
 
-aList.push_back(rxObj.get());
+if (nSkipObj == 0)
+aList.push_back(rxObj.get());
+else
+--nSkipObj;
+
+if (rxObj->GetObjType() == 0) // group (it can be a subgroup)
+{
+XclObjAny* pObj = dynamic_cast(rxObj.get());
+css::uno::Reference 
mXShapes(pObj->GetShape(), UNO_QUERY);
+// skip (also) the objects of this group
+nSkipObj += mXShapes->getCount();
+}
 }
 
 if (aList.empty())
@@ -1284,11 +1300,6 @@ bool ScURLTransformer::isExternalURL(const OUString& 
rURL) const
 
 void XclObjAny::SaveXml( XclExpXmlStream& rStrm )
 {
-// ignore group shapes at the moment, we don't process them correctly
-// leading to ms2010 rejecting the content
-if( !mxShape.is() || mxShape->getShapeType() == 
"com.sun.star.drawing.GroupShape" )
-return;
-
 // Do not output any of the detective shapes and validation circles.
 SdrObject* pObject = SdrObject::getSdrObjectFromXShape(mxShape);
 if (pObject)


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

 sc/qa/extras/vba-macro-test.cxx |   66 
 sc/source/ui/vba/vbawindows.cxx |   22 +
 2 files changed, 88 insertions(+)

New commits:
commit deb0bb9f2635a8dfec90b42e3727f4224548a8e9
Author: Andreas Heinisch 
AuthorDate: Mon Sep 26 20:36:15 2022 +0200
Commit: Andreas Heinisch 
CommitDate: Sun Nov 20 12:02:58 2022 +0100

tdf#126457 - Add URL and workbook name to window titles

The Windows object allows to activate a window using its caption. The 
window caption is the text shown in the title bar at the top of the window. It 
can be changed which does not affect the name of the workbook. In MS these 
captions are unique, i.e., a file with the same file name stored in a different 
directory can't be open.

However, LibreOffice allows to open files with the same name. So in order 
to make it as closely to the functionality of MS, the windows activate method 
now works with URLs and changed window captions.

It has still to be clarified what happens if two workbooks have the same 
caption.

Change-Id: I77a8680bc64b5992191df2fa1a7d475f9a48f518
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140627
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/extras/vba-macro-test.cxx b/sc/qa/extras/vba-macro-test.cxx
index 30375807a6ad..5c4bb5b88cc4 100644
--- a/sc/qa/extras/vba-macro-test.cxx
+++ b/sc/qa/extras/vba-macro-test.cxx
@@ -31,6 +31,8 @@
 
 #include 
 
+#include 
+
 using namespace css;
 using namespace ooo::vba;
 
@@ -62,6 +64,7 @@ public:
 void testTdf90278();
 void testTdf149531();
 void testTdf118247();
+void testTdf126457();
 
 CPPUNIT_TEST_SUITE(VBAMacroTest);
 CPPUNIT_TEST(testSimpleCopyAndPaste);
@@ -84,6 +87,7 @@ public:
 CPPUNIT_TEST(testTdf90278);
 CPPUNIT_TEST(testTdf149531);
 CPPUNIT_TEST(testTdf118247);
+CPPUNIT_TEST(testTdf126457);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -763,6 +767,68 @@ void VBAMacroTest::testTdf118247()
 CPPUNIT_ASSERT_EQUAL(sRange, aReturnValue);
 }
 }
+
+void VBAMacroTest::testTdf126457()
+{
+auto xComponent = loadFromDesktop("private:factory/scalc");
+
+// Save a copy of the file to get its URL
+uno::Reference xDocStorable(xComponent, uno::UNO_QUERY);
+utl::TempFileNamed aTempFile(u"testWindowsActivate", true, u".ods");
+aTempFile.EnableKillingFile();
+uno::Sequence descSaveAs(
+comphelper::InitPropertySequence({ { "FilterName", 
uno::Any(OUString("calc8")) } }));
+xDocStorable->storeAsURL(aTempFile.GetURL(), descSaveAs);
+
+// Insert initial library
+css::uno::Reference xDocScr(xComponent, 
uno::UNO_QUERY_THROW);
+auto xLibs = xDocScr->getBasicLibraries();
+auto xLibrary = xLibs->createLibrary("TestLibrary");
+xLibrary->insertByName(
+"TestModule",
+uno::Any(OUString("Option VBASupport 1\n"
+  "Function TestWindowsActivate\n"
+  "  dirName = Workbooks(1).Path\n"
+  "  workbookName = Workbooks(1).Name\n"
+  "  fileName = dirName + Application.PathSeparator + 
workbookName\n"
+  "  Workbooks.Open Filename := fileName\n"
+  "  On Error Goto handler\n"
+  // activate window using its URL
+  "  Windows(fileName).Activate\n"
+  // activate window using its caption name
+  "  Windows(workbookName).Activate\n"
+  // activate window using a newly generated window 
caption
+  "  newCaption = \"New Window Caption\"\n"
+  "  Windows(fileName).Caption = newCaption\n"
+  "  Windows(newCaption).Activate\n"
+  "  TestWindowsActivate = 0\n"
+  "  Exit Function\n"
+  "handler:\n"
+  "  TestWindowsActivate = 1\n"
+  "End Function\n")));
+
+uno::Any aRet;
+uno::Sequence aOutParamIndex;
+uno::Sequence aOutParam;
+
+SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(xComponent);
+ScDocShell* pDocSh = static_cast(pFoundShell);
+CPPUNIT_ASSERT(pDocSh);
+
+ErrCode result
+= SfxObjectShell::CallXScript(xComponent,
+  
"vnd.sun.Star.script:TestLibrary.TestModule."
+  
"TestWindowsActivate?language=Basic=document",
+  {}, aRet, aOutParamIndex, aOutParam);
+
+// Without the fix in place, the windows could not be activated in the 
macro
+CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, result);
+sal_Int16 nReturnValue;
+aRet >>= nReturnValue;
+CPPUNIT_ASSERT_EQUAL(sal_Int16(0), nReturnValue);
+
+pDocSh->DoClose();
+}
 

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

 sc/qa/unit/data/xlsx/tdf151818_SmartartThemeFontColor.xlsx |binary
 sc/qa/unit/subsequent_filters_test2.cxx|   58 +
 sc/source/filter/inc/drawingfragment.hxx   |5 +
 sc/source/filter/oox/drawingfragment.cxx   |   14 +++
 4 files changed, 77 insertions(+)

New commits:
commit 4d15adebcc492112ca88e36aa7e8799b62d86466
Author: Regina Henschel 
AuthorDate: Sun Oct 30 00:35:31 2022 +0200
Commit: Regina Henschel 
CommitDate: Sun Oct 30 13:30:21 2022 +0100

tdf#151818 xlsx SmartArt import, apply theme text color

Similar as patch 2406ba67 for tdf#54095 but now for import of
SmartArt objects in xlsx files.

Change-Id: I12ca8c476fb9d141cef991e8e98ad13b53c70613
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142027
Tested-by: Jenkins
Reviewed-by: Regina Henschel 

diff --git a/sc/qa/unit/data/xlsx/tdf151818_SmartartThemeFontColor.xlsx 
b/sc/qa/unit/data/xlsx/tdf151818_SmartartThemeFontColor.xlsx
new file mode 100644
index ..c1851ca3791d
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/tdf151818_SmartartThemeFontColor.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx 
b/sc/qa/unit/subsequent_filters_test2.cxx
index 8ae23af8048c..293c7300d7fb 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -55,6 +55,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -188,6 +189,7 @@ public:
 void testTooManyColsRows();
 void testTdf83671_SmartArt_import();
 void testTdf83671_SmartArt_import2();
+void testTdf151818_SmartArtFontColor();
 
 CPPUNIT_TEST_SUITE(ScFiltersTest2);
 
@@ -306,6 +308,7 @@ public:
 CPPUNIT_TEST(testTooManyColsRows);
 CPPUNIT_TEST(testTdf83671_SmartArt_import);
 CPPUNIT_TEST(testTdf83671_SmartArt_import2);
+CPPUNIT_TEST(testTdf151818_SmartArtFontColor);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -3137,6 +3140,61 @@ void ScFiltersTest2::testTdf83671_SmartArt_import2()
 xDocSh->DoClose();
 }
 
+void ScFiltersTest2::testTdf151818_SmartArtFontColor()
+{
+// The document contains a SmartArt where the color for the texts in the 
shapes is given by
+// the theme.
+// Error was, that the theme was not considered and therefore the text was 
white.
+
+// Make sure it is not loaded as metafile but with single shapes.
+bool bUseGroup = 
officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::get();
+if (!bUseGroup)
+{
+std::shared_ptr pChange(
+comphelper::ConfigurationChanges::create());
+
officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(true,
 pChange);
+pChange->commit();
+}
+
+// Get document and shape in SmartArt object
+ScDocShellRef xDocSh = loadDoc(u"tdf151818_SmartartThemeFontColor.", 
FORMAT_XLSX);
+uno::Reference xDoc(xDocSh->GetModel(), 
uno::UNO_QUERY_THROW);
+uno::Reference 
xPage(xDoc->getDrawPages()->getByIndex(0),
+ uno::UNO_QUERY_THROW);
+uno::Reference xSmartArt(xPage->getByIndex(0), 
uno::UNO_QUERY_THROW);
+// shape 0 is the background shape without text
+uno::Reference xShape(xSmartArt->getByIndex(1), 
uno::UNO_QUERY);
+
+// text color
+uno::Reference xText(xShape->getText(), 
uno::UNO_QUERY);
+uno::Reference 
xPara(xText->createEnumeration()->nextElement(),
+uno::UNO_QUERY);
+uno::Reference 
xPortion(xPara->createEnumeration()->nextElement(),
+ uno::UNO_QUERY);
+sal_Int32 nActualColor{ 0 };
+xPortion->getPropertyValue("CharColor") >>= nActualColor;
+// Without fix the test would have failed with:
+// - Expected:  4478058 (0x44546A)
+// - Actual  : 16777215 (0xFF), that is text was white
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0x44546A), nActualColor);
+
+// clrScheme. For map between name in xlsx and index from CharColorTheme 
see
+// oox::drawingml::Color::getSchemeColorIndex()
+// Without fix the color scheme was "lt1" (1) but should be "dk2" (2).
+CPPUNIT_ASSERT_EQUAL(sal_Int16(2),
+ 
xPortion->getPropertyValue("CharColorTheme").get());
+
+if (!bUseGroup)
+{
+std::shared_ptr pChange(
+comphelper::ConfigurationChanges::create());
+
officecfg::Office::Common::Filter::Microsoft::Import::SmartArtToShapes::set(false,
 pChange);
+pChange->commit();
+}
+
+xDocSh->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScFiltersTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/inc/drawingfragment.hxx 
b/sc/source/filter/inc/drawingfragment.hxx
index b9fda07553f5..0ba281db09a6 100644
--- a/sc/source/filter/inc/drawingfragment.hxx
+++ b/sc/source/filter/inc/drawingfragment.hxx
@@ -21,6 +21,7 @@
 
 #include 
 #include 
+#include 
 

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

 sc/qa/uitest/autofilter/autofilterBugs.py |   48 ++
 sc/source/core/tool/typedstrdata.cxx  |7 +---
 2 files changed, 51 insertions(+), 4 deletions(-)

New commits:
commit 2e887e04c0008a4eb6cbf34050b6fa463a33599f
Author: Andreas Heinisch 
AuthorDate: Fri Oct 7 11:59:33 2022 +0200
Commit: Eike Rathke 
CommitDate: Thu Oct 13 12:28:14 2022 +0200

tdf#125363, tdf#123095 - Use CaseTransliteration for autofilter

Change-Id: Ib6f1edebe26a69d3316a901e00d2bc6e0c66695f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141047
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/sc/qa/uitest/autofilter/autofilterBugs.py 
b/sc/qa/uitest/autofilter/autofilterBugs.py
index 1a9d2261d631..a295c6307793 100644
--- a/sc/qa/uitest/autofilter/autofilterBugs.py
+++ b/sc/qa/uitest/autofilter/autofilterBugs.py
@@ -25,6 +25,54 @@ class autofilter(UITestCase):
 #autofilter still exist
 
self.assertEqual(calc_doc.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter,
 True)
 
+   def test_tdf123095(self):
+with self.ui_test.create_doc_in_start_center("calc") as document:
+calcDoc = self.xUITest.getTopFocusWindow()
+xGridWindow = calcDoc.getChild("grid_window")
+enter_text_to_cell(xGridWindow, "A1", "乙二醇(进口料件)")
+enter_text_to_cell(xGridWindow, "A2", "乙二醇(进口料件)")
+xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": 
"A1:A2"}))
+
+with 
self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", 
close_button="no"):
+pass
+
+xGridWindow.executeAction("LAUNCH", 
mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
+xFloatWindow = self.xUITest.getFloatWindow()
+xTreeList = xFloatWindow.getChild("check_list_box")
+
+# Without the fix in place, the second entry would not exist
+self.assertEqual(2, len(xTreeList.getChildren()))
+
self.assertEqual(get_state_as_dict(xTreeList.getChild("0"))["Text"], 
"乙二醇(进口料件)")
+
self.assertEqual(get_state_as_dict(xTreeList.getChild("1"))["Text"], 
"乙二醇(进口料件)")
+
+   def test_tdf125363(self):
+with self.ui_test.create_doc_in_start_center("calc") as document:
+calcDoc = self.xUITest.getTopFocusWindow()
+xGridWindow = calcDoc.getChild("grid_window")
+enter_text_to_cell(xGridWindow, "A1", "guet")
+enter_text_to_cell(xGridWindow, "A2", "guͤt")
+enter_text_to_cell(xGridWindow, "A3", "tuon")
+enter_text_to_cell(xGridWindow, "A4", "tuͦn")
+enter_text_to_cell(xGridWindow, "A5", "vröude")
+enter_text_to_cell(xGridWindow, "A6", "vröudᵉ")
+xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": 
"A1:A6"}))
+
+with 
self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", 
close_button="no"):
+pass
+
+xGridWindow.executeAction("LAUNCH", 
mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"}))
+xFloatWindow = self.xUITest.getFloatWindow()
+xTreeList = xFloatWindow.getChild("check_list_box")
+
+# Without the fix in place, the entries with superscript/modifier 
letters would not exist
+self.assertEqual(6, len(xTreeList.getChildren()))
+
self.assertEqual(get_state_as_dict(xTreeList.getChild("0"))["Text"], "guet")
+
self.assertEqual(get_state_as_dict(xTreeList.getChild("1"))["Text"], "guͤt")
+
self.assertEqual(get_state_as_dict(xTreeList.getChild("2"))["Text"], "tuon")
+
self.assertEqual(get_state_as_dict(xTreeList.getChild("3"))["Text"], "tuͦn")
+
self.assertEqual(get_state_as_dict(xTreeList.getChild("4"))["Text"], "vröude")
+
self.assertEqual(get_state_as_dict(xTreeList.getChild("5"))["Text"], "vröudᵉ")
+
def test_tdf94055(self):
 with self.ui_test.create_doc_in_start_center("calc") as document:
 calcDoc = self.xUITest.getTopFocusWindow()
diff --git a/sc/source/core/tool/typedstrdata.cxx 
b/sc/source/core/tool/typedstrdata.cxx
index bf659733366a..e00c1bc18d91 100644
--- a/sc/source/core/tool/typedstrdata.cxx
+++ b/sc/source/core/tool/typedstrdata.cxx
@@ -11,6 +11,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 bool ScTypedStrData::LessHiddenRows::operator() (const ScTypedStrData& left, 
const ScTypedStrData& right) const
@@ -77,8 +78,7 @@ bool ScTypedStrData::EqualCaseSensitive::operator() (const 
ScTypedStrData& left,
 if (left.mbIsDate != right.mbIsDate )
 return false;
 
-return ScGlobal::GetCaseCollator().compareString(
-left.maStrValue, right.maStrValue) == 0;
+return ScGlobal::GetCaseTransliteration().isEqual(left.maStrValue, 
right.maStrValue);
 }
 
 bool ScTypedStrData::EqualCaseInsensitive::operator() (const ScTypedStrData& 
left, 

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

 sc/qa/uitest/autofilter/autofilter.py |   39 ++
 sc/source/ui/view/viewfunc.cxx|   28 +++-
 2 files changed, 66 insertions(+), 1 deletion(-)

New commits:
commit 3394e8746c505a8dae112f555cb2bb3e4596cbba
Author: Andreas Heinisch 
AuthorDate: Tue Sep 13 22:18:09 2022 +0200
Commit: Eike Rathke 
CommitDate: Wed Oct 5 17:30:46 2022 +0200

tdf#36383 - sc AutoFilter: fix changing row height

Changing row height showed the rows hidden
by AutoFilter, removing the result of the filtering.

Change-Id: Iecc8eb03ed563de126e7a376dad41a4ab2434f0e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139883
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/sc/qa/uitest/autofilter/autofilter.py 
b/sc/qa/uitest/autofilter/autofilter.py
index 8f6db292230e..f792c0fdad33 100644
--- a/sc/qa/uitest/autofilter/autofilter.py
+++ b/sc/qa/uitest/autofilter/autofilter.py
@@ -376,6 +376,45 @@ class AutofilterTest(UITestCase):
 self.assertFalse(is_row_hidden(doc, 6))
 self.assertFalse(is_row_hidden(doc, 7))
 
+def test_tdf36383_row_height(self):
+with self.ui_test.create_doc_in_start_center("calc") as document:
+calcDoc = self.xUITest.getTopFocusWindow()
+gridwin = calcDoc.getChild("grid_window")
+
+enter_text_to_cell(gridwin, "A1", "A")
+enter_text_to_cell(gridwin, "A2", "1")
+enter_text_to_cell(gridwin, "A3", "2")
+enter_text_to_cell(gridwin, "A4", "3")
+gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": 
"A1:A4"}))
+
+self.xUITest.executeCommand(".uno:DataFilterAutoFilter")
+gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": 
"", "COL": "0", "ROW": "0"}))
+xFloatWindow = self.xUITest.getFloatWindow()
+xCheckListMenu = xFloatWindow.getChild("FilterDropDown")
+xTreeList = xCheckListMenu.getChild("check_list_box")
+xEntry = xTreeList.getChild("1")
+xEntry.executeAction("CLICK", tuple())
+
+xOkButton = xFloatWindow.getChild("ok")
+xOkButton.executeAction("CLICK", tuple())
+
+self.assertTrue(is_row_hidden(document, 2))
+
+# row height
+with self.ui_test.execute_dialog_through_command(".uno:RowHeight") 
as xDialog:
+xvalue = xDialog.getChild("value")
+xvalue.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"CTRL+A"}))
+xvalue.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
+
+self.assertTrue(is_row_hidden(document, 2))
+
+# optimal row height
+with 
self.ui_test.execute_dialog_through_command(".uno:SetOptimalRowHeight"):
+pass
+
+self.assertTrue(is_row_hidden(document, 2))
+
 def test_tdf142350(self):
 with self.ui_test.create_doc_in_start_center("calc") as document:
 calcDoc = self.xUITest.getTopFocusWindow()
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index c5341aadfa65..423c66abef2b 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -80,6 +80,19 @@
 
 #include 
 
+static void ShowFilteredRows(ScDocument& rDoc, SCTAB nTab, SCCOLROW nStartNo, 
SCCOLROW nEndNo,
+ bool bShow)
+{
+SCROW nFirstRow = nStartNo;
+SCROW nLastRow = nStartNo;
+do
+{
+if (!rDoc.RowFiltered(nFirstRow, nTab, nullptr, ))
+rDoc.ShowRows(nFirstRow, nLastRow < nEndNo ? nLastRow : nEndNo, 
nTab, bShow);
+nFirstRow = nLastRow + 1;
+} while (nFirstRow <= nEndNo);
+}
+
 static void lcl_PostRepaintCondFormat( const ScConditionalFormat *pCondFmt, 
ScDocShell *pDocSh )
 {
 if( pCondFmt )
@@ -2202,6 +2215,7 @@ void ScViewFunc::SetWidthOrHeight(
 if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
 {
 bool bAll = ( eMode==SC_SIZE_OPTIMAL );
+bool bFiltered = false;
 if (!bAll)
 {
 //  delete CRFlags::ManualSize for all in range,
@@ -2220,6 +2234,14 @@ void ScViewFunc::SetWidthOrHeight(
 rDoc.SetRowFlags(nRow, nTab, nOld & 
~CRFlags::ManualSize);
 }
 }
+else
+{
+SCROW nLastRow = nStartNo;
+if (rDoc.RowFiltered(nStartNo, nTab, nullptr, 
)
+|| nLastRow < nEndNo)
+bFiltered = true;
+}
+
 
 double nPPTX = GetViewData().GetPPTX();
 double nPPTY = GetViewData().GetPPTY();
@@ -2239,6 +2261,9 @@ void 

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

 sc/qa/unit/data/contentCSV/fdo48621_broken_quotes_exported.csv |8 
 sc/source/ui/docshell/impex.cxx|  102 
--
 2 files changed, 87 insertions(+), 23 deletions(-)

New commits:
commit cf777cfcb22647b1f2d6ace307fbcc4f6d2cca30
Author: Eike Rathke 
AuthorDate: Sun Oct 2 01:16:00 2022 +0200
Commit: Eike Rathke 
CommitDate: Sun Oct 2 17:07:06 2022 +0200

Resolves: tdf#125110 tdf#151211 Disentangle the convoluted CSV/TSV-clip 
import

The chain of fixes for #i119960# tdf#48621 tdf#125440 produced
code that is suboptimal and not robust enough against some further
corner cases, taking quoted field content where there shouldn't
be.

First, in ReadCsvLine() assume that if a generator is broken
enough to start a field quoted followed by containing an unescaped
embedded quote and there is no closing quote (i.e. immediately
before a field delimiter) until the line end then the generator
will not be clever enough to write embedded linefeeds either and
the field starting quote wasn't one but to be taken literally as
all other quotes until the now unquoted field end. In this case do
not read a subsequent source line for the current row.

Then, for individual fields of a row make a similar assumption, a
quote-started field has to end with a quote before a field
separator (or line end) or otherwise all quotes of that field are
literal data up to the next field separator.

This made it necessary to adapt two test cases of the garbage CSV
import test to produce different garbage than before.

Change-Id: I4424b65c87c7f9dcbe717a7e6cf207352cb613f3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140850
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/qa/unit/data/contentCSV/fdo48621_broken_quotes_exported.csv 
b/sc/qa/unit/data/contentCSV/fdo48621_broken_quotes_exported.csv
index dfc83c5f3ced..8e10063eefe5 100644
--- a/sc/qa/unit/data/contentCSV/fdo48621_broken_quotes_exported.csv
+++ b/sc/qa/unit/data/contentCSV/fdo48621_broken_quotes_exported.csv
@@ -53,8 +53,8 @@ No it doesn't,,,
 ",<- needed to end test file here,,
 ,,,
 i80385_test2.csv,,,
-test,"a""b, ""a"," d""a""c ", m ,j ,d,"b""A""","D""E","f,1","a,b","de""b,a
-""abcdef"" test ""abc","def""g""h","def""gh""",,,
+test,"a""b, ""a"," d""a""c ", m ,j 
,d,"b""A""","D""E","f,1","a,b","""de""b",a
+"abcdef"" test ""abc","def""g""h","def""gh""",
 "this is
 a test","yes
 it
@@ -78,8 +78,8 @@ No it doesn't,,,
 ""a""b""",,,
 ,,,
 i80385_test4.csv,,,
-test,"a""b, ""a"," d""a""c ", m ,j ,d,"b""A""","D""E","f,1","a,b","de""b,a
-""abcdef"" test ""abc","def""g""h","def""gh""",,,
+test,"a""b, ""a"," d""a""c ", m ,j 
,d,"b""A""","D""E","f,1","a,b","""de""b",a
+"abcdef"" test ""abc","def""g""h","def""gh""",
 "this is
 a test","yes
 it
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 59d8f9a3538c..2a7ed9da5d06 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -581,6 +581,11 @@ void ScImportExport::SetNoEndianSwap( SvStream& rStrm )
 #endif
 }
 
+static inline bool lcl_isFieldEnd( sal_Unicode c, const sal_Unicode* pSeps )
+{
+return !c || ScGlobal::UnicodeStrChr( pSeps, c);
+}
+
 namespace {
 
 enum QuoteType
@@ -615,7 +620,7 @@ static QuoteType lcl_isFieldEndQuote( const sal_Unicode* p, 
const sal_Unicode* p
 const bool bBlankSep = (p[1] == cBlank && !rcDetectSep && p[2] && p[2] != 
cBlank);
 while (p[1] == cBlank)
 ++p;
-if (!p[1] || ScGlobal::UnicodeStrChr( pSeps, p[1]))
+if (lcl_isFieldEnd( p[1], pSeps))
 return FIELDEND_QUOTE;
 // Extended separator detection after a closing quote (with or without
 // blanks). Note that nQuotes is incremented *after* the call so is not yet
@@ -712,9 +717,30 @@ enum class DoubledQuoteMode
 
 }
 
-static const sal_Unicode* lcl_ScanString( const sal_Unicode* p, OUString& 
rString,
+/** Scan for a quoted string.
+
+Precondition: initial current position *p is a cStr quote.
+
+For DoubledQuoteMode::ESCAPE, if after the closing quote there is a field
+end (with or without trailing blanks and as determined by
+lcl_isFieldEndQuote()), then the content is appended to rField with quotes
+processed and removed. Else if no field end after the quoted string was
+detected, nothing is appended and processing continues and is repeated
+until the next quote. If no closing quote at a field end was found at all,
+nothing is appended and the initial 

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

 sc/qa/unit/subsequent_export_test2.cxx |2 +-
 sc/source/filter/xml/xmlcelli.cxx  |3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 8f5f0c754222425af019a9fdc1ba47d72c541d9e
Author: Justin Luth 
AuthorDate: Tue Sep 20 14:28:19 2022 -0400
Commit: Justin Luth 
CommitDate: Wed Sep 21 19:27:44 2022 +0200

tdf#75702 ODS import: send text:line-break to editeng

A cell with a line-break specified is no longer a simple string,
so send the string to editeng where it can be properly displayed.

This already works fine for XLS and XLSX.

This change effectively means that text:line-break
will disappear, and become two separate paragraphs.
Given the nature of spreadsheets, the precidence in
various other patches and the failure to properly
display without this, I think I'm fine with
unilaterally changing one paragraph into two.

Change-Id: I7abcbc6f698a4cb319aea5465a8b0393cf63f31f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140262
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index 7bbb908a96fb..cadc2da0d595 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -1456,7 +1456,7 @@ void ScExportTest2::testTdf75702()
 
 xmlDocUniquePtr pContent
 = XPathHelper::parseExport2(*this, *xShell, m_xSFactory, 
"content.xml", FORMAT_ODS);
-assertXPath(pContent, 
"//table:table-row[1]/table:table-cell/text:p/text:line-break");
+assertXPath(pContent, "//table:table-row[1]/table:table-cell/text:p", 2);
 }
 
 void ScExportTest2::testTdf103829()
diff --git a/sc/source/filter/xml/xmlcelli.cxx 
b/sc/source/filter/xml/xmlcelli.cxx
index e7a8037cd7eb..29450409e608 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -47,6 +47,7 @@
 #include "editattributemap.hxx"
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -612,7 +613,7 @@ void ScXMLTableRowCellContext::PushParagraphEnd()
 }
 mpEditEngine->InsertParagraph(mpEditEngine->GetParagraphCount(), 
maParagraph.makeStringAndClear());
 }
-else if (mbHasFormatRuns)
+else if (mbHasFormatRuns || ScStringUtil::isMultiline(maParagraph))
 {
 mpEditEngine->Clear();
 mpEditEngine->SetTextCurrentDefaults(maParagraph.makeStringAndClear());


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

 sc/qa/unit/subsequent_export_test2.cxx |3 +--
 sc/source/filter/xml/xmlexprt.cxx  |3 ++-
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit eab9015d1e17950ee5a49f93a6ad40e7726f5050
Author: Justin Luth 
AuthorDate: Mon Sep 12 11:51:07 2022 -0400
Commit: Justin Luth 
CommitDate: Fri Sep 16 00:54:20 2022 +0200

tdf#103829 ods export: don't output invalid office:string-value

If the formatted (i.e. \t) string was different from
the raw string (i.e. \x001 EE_FEATURE_TAB marker),
then export was outputing office:string-value
with IsInvalidChar \x001.

The impact on import is that the cell wants to display
this string-value, which is missing all of the "invalid char"
stuff. So, just don't export a wrong string at all.

Change-Id: Ib98e58d0c6e1186d199a4dcf294b56403b710f48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139816
Tested-by: Jenkins
Reviewed-by: Justin Luth 

diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index 2d1ecb212ae6..b722137934fa 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -1449,13 +1449,12 @@ void ScExportTest2::testTdf103829()
 ScDocShellRef xShell = loadDoc(u"tdf103829_textTab.", FORMAT_ODS);
 ScDocument& rDoc = xShell->GetDocument();
 CPPUNIT_ASSERT_EQUAL_MESSAGE("load a1", sA1, rDoc.GetString(0, 0, 0));
-CPPUNIT_ASSERT_EQUAL_MESSAGE("load a1", sA1, rDoc.GetString(0, 0, 0));
 CPPUNIT_ASSERT_EQUAL_MESSAGE("load a2", sA2, rDoc.GetString(0, 1, 0));
 
 xShell = saveAndReload(*xShell, FORMAT_ODS);
 ScDocument& rDoc2 = xShell->GetDocument();
 //CPPUNIT_ASSERT_EQUAL_MESSAGE("reload a1", sA1.getLength(), 
rDoc2.GetString(0, 0, 0).getLength());
-//CPPUNIT_ASSERT_EQUAL_MESSAGE("reload a1", sA1, rDoc2.GetString(0, 0, 0));
+CPPUNIT_ASSERT_EQUAL_MESSAGE("reload a1", sA1, rDoc2.GetString(0, 0, 0));
 CPPUNIT_ASSERT_EQUAL_MESSAGE("reload a2", sA2, rDoc2.GetString(0, 1, 0));
 }
 
diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 3f88b3c88acb..579b04623aec 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3170,8 +3170,9 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 
nEqualCellCount)
 {
 OUString sFormattedString(lcl_GetFormattedString(pDoc, 
aCell.maBaseCell, aCell.maCellAddress));
 OUString sCellString = aCell.maBaseCell.getString(pDoc);
+bool bExportValue = sCellString.indexOf('\x001') == -1;
 
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
-sCellString, sFormattedString);
+sCellString, sFormattedString, bExportValue);
 if (getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
 
GetNumberFormatAttributesExportHelper()->SetNumberFormatAttributes(
 sCellString, sFormattedString, false, 
XML_NAMESPACE_CALC_EXT);


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

 sc/qa/unit/data/ods/tdf103829_textTab.ods|binary
 sc/qa/unit/subsequent_export_test2.cxx   |   22 ++
 sc/source/filter/xml/celltextparacontext.cxx |4 
 3 files changed, 26 insertions(+)

New commits:
commit 690a35680adad07c4ab79d82cd1531bb82fe4bc1
Author: Justin Luth 
AuthorDate: Sat Sep 10 16:32:46 2022 -0400
Commit: Justin Luth 
CommitDate: Tue Sep 13 01:42:54 2022 +0200

tdf#103829 ods import: parse 

regression since LO 4.1

Change-Id: I65e847a45b8b233c558bf7bc90b554ba8b4b7763
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139757
Tested-by: Justin Luth 
Reviewed-by: Justin Luth 

diff --git a/sc/qa/unit/data/ods/tdf103829_textTab.ods 
b/sc/qa/unit/data/ods/tdf103829_textTab.ods
new file mode 100644
index ..7f5256ebe739
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf103829_textTab.ods differ
diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index 11d069c632b1..2d1ecb212ae6 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -125,6 +125,7 @@ public:
 void testTdf91634XLSX();
 void testTdf115159();
 void testTdf112567();
+void testTdf103829();
 void testTdf122191();
 void testTdf142881();
 void testTdf112567b();
@@ -248,6 +249,7 @@ public:
 CPPUNIT_TEST(testTdf91634XLSX);
 CPPUNIT_TEST(testTdf115159);
 CPPUNIT_TEST(testTdf112567);
+CPPUNIT_TEST(testTdf103829);
 CPPUNIT_TEST(testTdf122191);
 CPPUNIT_TEST(testTdf142881);
 CPPUNIT_TEST(testTdf112567b);
@@ -1437,6 +1439,26 @@ void ScExportTest2::testTdf112567()
 xDocSh->DoClose();
 }
 
+void ScExportTest2::testTdf103829()
+{
+// The problem was that tabspaces were not imported or exported at all.
+// These strings match the current implementations of CELLTYPE_EDIT and 
CELLTYPE_STRING.
+const OUString sA1("\x001Leading tab\nTHREE tabs inside: 
[\x001\x001\x001]");
+const OUString sA2("\tLeading tab. THREE tabs inside: [\t\t\t]");
+
+ScDocShellRef xShell = loadDoc(u"tdf103829_textTab.", FORMAT_ODS);
+ScDocument& rDoc = xShell->GetDocument();
+CPPUNIT_ASSERT_EQUAL_MESSAGE("load a1", sA1, rDoc.GetString(0, 0, 0));
+CPPUNIT_ASSERT_EQUAL_MESSAGE("load a1", sA1, rDoc.GetString(0, 0, 0));
+CPPUNIT_ASSERT_EQUAL_MESSAGE("load a2", sA2, rDoc.GetString(0, 1, 0));
+
+xShell = saveAndReload(*xShell, FORMAT_ODS);
+ScDocument& rDoc2 = xShell->GetDocument();
+//CPPUNIT_ASSERT_EQUAL_MESSAGE("reload a1", sA1.getLength(), 
rDoc2.GetString(0, 0, 0).getLength());
+//CPPUNIT_ASSERT_EQUAL_MESSAGE("reload a1", sA1, rDoc2.GetString(0, 0, 0));
+CPPUNIT_ASSERT_EQUAL_MESSAGE("reload a2", sA2, rDoc2.GetString(0, 1, 0));
+}
+
 void ScExportTest2::testTdf122191()
 {
 // Set the system locale to Hungarian
diff --git a/sc/source/filter/xml/celltextparacontext.cxx 
b/sc/source/filter/xml/celltextparacontext.cxx
index 5bbe5f20dea2..ff36a99cae92 100644
--- a/sc/source/filter/xml/celltextparacontext.cxx
+++ b/sc/source/filter/xml/celltextparacontext.cxx
@@ -63,7 +63,11 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL 
ScXMLCellTextParaContex
 return new ScXMLCellFieldURLContext(GetScImport(), *this);
 case XML_ELEMENT( TEXT, XML_RUBY ):
 return new ScXMLCellTextRubyContext(GetScImport(), *this);
+case XML_ELEMENT(TEXT, XML_TAB):
+maContent += "\t";
+break;
 default:
+assert(false && "unknown cell text: element");
 ;
 }
 


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

 sc/qa/unit/uicalc/uicalc.cxx   |   49 +
 sc/source/ui/view/viewfunc.cxx |   11 +
 2 files changed, 56 insertions(+), 4 deletions(-)

New commits:
commit 9caf9f8fde68f075a9ae1377bcc0cf6127c1737f
Author: Andreas Heinisch 
AuthorDate: Sat Sep 3 16:40:11 2022 +0200
Commit: Andreas Heinisch 
CommitDate: Mon Sep 12 10:26:01 2022 +0200

tdf#131073 - Don't show hidden rows/cols after setting optimal row/col 
height

Change-Id: I1dbe92cfc577e3425787b942415182889cda6a76
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139327
Tested-by: Jenkins
Reviewed-by: Heiko Tietze 
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index ab258894eb16..bd175ec1bde5 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -2277,6 +2277,55 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf132431)
 CPPUNIT_ASSERT_EQUAL(OUString("Err:502"), pDoc->GetString(ScAddress(7, 
219, 0)));
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf131073)
+{
+mxComponent = loadFromDesktop("private:factory/scalc");
+ScModelObj* pModelObj = dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pModelObj);
+ScDocument* pDoc = pModelObj->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+
+for (SCCOLROW nColRow = 0; nColRow < 3; nColRow++)
+{
+pDoc->SetString(ScAddress(0, nColRow, 0), "Hello World");
+pDoc->SetRowHeight(0, nColRow, 1000 * (nColRow + 1));
+pDoc->SetString(ScAddress(nColRow, 0, 0), "Hello World");
+pDoc->SetColWidth(nColRow, 0, 1000 * (nColRow + 1));
+}
+
+// Check rows
+pDoc->SetRowHidden(1, 1, 0, true);
+goToCell("A1:A3");
+dispatchCommand(
+mxComponent, ".uno:SetOptimalRowHeight",
+comphelper::InitPropertySequence({ { "aExtraHeight", 
uno::Any(sal_uInt16(0)) } }));
+
+CPPUNIT_ASSERT(!pDoc->RowHidden(0, 0));
+// tdf#131073: Without the fix in place, the second row would not be hidden
+CPPUNIT_ASSERT(pDoc->RowHidden(1, 0));
+CPPUNIT_ASSERT(!pDoc->RowHidden(2, 0));
+const sal_uInt16 nStdRowHeight = pDoc->GetRowHeight(4, 0);
+CPPUNIT_ASSERT_EQUAL(nStdRowHeight, pDoc->GetRowHeight(0, 0));
+CPPUNIT_ASSERT_EQUAL(nStdRowHeight, pDoc->GetRowHeight(1, SCTAB(0), 
false));
+CPPUNIT_ASSERT_EQUAL(nStdRowHeight, pDoc->GetRowHeight(2, 0));
+
+// Check columns
+pDoc->SetColHidden(1, 1, 0, true);
+goToCell("A1:C1");
+dispatchCommand(
+mxComponent, ".uno:SetOptimalColumnWidth",
+comphelper::InitPropertySequence({ { "aExtraWidth", 
uno::Any(sal_uInt16(0)) } }));
+
+CPPUNIT_ASSERT(!pDoc->ColHidden(0, 0));
+// tdf#131073: Without the fix in place, the second column would not be 
hidden
+CPPUNIT_ASSERT(pDoc->ColHidden(1, 0));
+CPPUNIT_ASSERT(!pDoc->ColHidden(2, 0));
+const sal_uInt16 nStdColWidth = pDoc->GetColWidth(0, 0);
+CPPUNIT_ASSERT_EQUAL(nStdColWidth, pDoc->GetColWidth(0, 0));
+CPPUNIT_ASSERT_EQUAL(nStdColWidth, pDoc->GetColWidth(1, SCTAB(0), false));
+CPPUNIT_ASSERT_EQUAL(nStdColWidth, pDoc->GetColWidth(2, 0));
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf83901)
 {
 mxComponent = loadFromDesktop("private:factory/scalc");
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index c1c003205828..c5341aadfa65 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -2238,8 +2238,6 @@ void ScViewFunc::SetWidthOrHeight(
 aCxt.setForceAutoSize(bAll);
 aCxt.setExtraHeight(nSizeTwips);
 rDoc.SetOptimalHeight(aCxt, nStartNo, nEndNo, nTab, true);
-if (bAll)
-rDoc.ShowRows( nStartNo, nEndNo, nTab, true );
 
 //  Manual-Flag already (re)set in SetOptimalHeight in 
case of bAll=sal_True
 //  (set for Extra-Height, else reset).
@@ -2268,7 +2266,8 @@ void ScViewFunc::SetWidthOrHeight(
 {
 for (SCCOL nCol=static_cast(nStartNo); 
nCol<=static_cast(nEndNo); nCol++)
 {
-if ( eMode != SC_SIZE_VISOPT || !rDoc.ColHidden(nCol, 
nTab) )
+const bool bIsColHidden = rDoc.ColHidden(nCol, nTab);
+if ( eMode != SC_SIZE_VISOPT || !bIsColHidden )
 {
 sal_uInt16 nThisSize = nSizeTwips;
 
@@ -2277,7 +2276,11 @@ void ScViewFunc::SetWidthOrHeight(
 if ( nThisSize )
 rDoc.SetColWidth( nCol, nTab, nThisSize );
 
-rDoc.ShowCol( nCol, nTab, bShow );
+// tdf#131073 - Don't show hidden cols after setting 
optimal col width
+if (eMode == SC_SIZE_OPTIMAL)
+rDoc.ShowCol(nCol, nTab, !bIsColHidden);
+else
+rDoc.ShowCol( 

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

 sc/qa/unit/data/functions/mathematical/fods/atan2.fods |   16 
 sc/source/core/opencl/op_math.cxx  |2 ++
 sc/source/core/opencl/opinlinefun_math.hxx |2 +-
 3 files changed, 15 insertions(+), 5 deletions(-)

New commits:
commit 218b288d0ca32e4372f546b143fa71542f75dcd0
Author: Luboš Luňák 
AuthorDate: Thu Sep 1 13:53:19 2022 +0200
Commit: Luboš Luňák 
CommitDate: Tue Sep 6 12:02:50 2022 +0200

fix opencl trigonometric functions

Change-Id: Iacdae9fceff2feb198bd722e7e58e5e6dff5facc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139194
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/qa/unit/data/functions/mathematical/fods/atan2.fods 
b/sc/qa/unit/data/functions/mathematical/fods/atan2.fods
index 4e11319cd652..b78437d3ed93 100644
--- a/sc/qa/unit/data/functions/mathematical/fods/atan2.fods
+++ b/sc/qa/unit/data/functions/mathematical/fods/atan2.fods
@@ -1925,10 +1925,18 @@
  
 
 
- 
- 
- 
- 
+ 
+  0
+ 
+ 
+  0
+ 
+ 
+  TRUE
+ 
+ 
+  =ATAN2(0;0)
+ 
  
  
  
diff --git a/sc/source/core/opencl/op_math.cxx 
b/sc/source/core/opencl/op_math.cxx
index dd70241c5f41..744c360a75bc 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1094,6 +1094,8 @@ void OpArcCosHyp::GenSlidingWindowFunction(outputstream 
,
 ss << ";\n";
 }
 
+ss << "if( tmp < 1 )\n";
+ss << "return CreateDoubleError(IllegalArgument);\n";
 ss << "return  log( tmp + pow( (pown(tmp, 2) - 1.0), 0.5));\n";
 ss << "}";
 }
diff --git a/sc/source/core/opencl/opinlinefun_math.hxx 
b/sc/source/core/opencl/opinlinefun_math.hxx
index dc962b4635f1..0160671ed164 100644
--- a/sc/source/core/opencl/opinlinefun_math.hxx
+++ b/sc/source/core/opencl/opinlinefun_math.hxx
@@ -62,7 +62,7 @@ std::string atan2Content =
 "double arctan2(double y, double x)\n"
 "{\n"
 "if(y==0.0)\n"
-"return 0.0;\n"
+"return x >= 0 ? 0.0 : M_PI;\n"
 "double a,num,den,tmpPi;\n"
 "int flag;\n"
 "tmpPi = 0;\n"


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

 sc/qa/extras/testdocuments/tdf118247.xlsm |binary
 sc/qa/extras/vba-macro-test.cxx   |   47 ++
 sc/source/ui/vba/vbarange.cxx |   23 ++
 3 files changed, 69 insertions(+), 1 deletion(-)

New commits:
commit f972f27b455ef78f0d5db5eea96edd707909a154
Author: Andreas Heinisch 
AuthorDate: Thu Sep 1 21:55:05 2022 +0200
Commit: Andreas Heinisch 
CommitDate: Tue Sep 6 11:31:42 2022 +0200

tdf#118247 - Correctly handle xlCellTypeConstants parameter

Change-Id: I5cc281d6193bcf03d2da3c594d427ec340c2cfc1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139239
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/extras/testdocuments/tdf118247.xlsm 
b/sc/qa/extras/testdocuments/tdf118247.xlsm
new file mode 100755
index ..73de66a0d423
Binary files /dev/null and b/sc/qa/extras/testdocuments/tdf118247.xlsm differ
diff --git a/sc/qa/extras/vba-macro-test.cxx b/sc/qa/extras/vba-macro-test.cxx
index 71c3b9033da1..24f8ddb996c6 100644
--- a/sc/qa/extras/vba-macro-test.cxx
+++ b/sc/qa/extras/vba-macro-test.cxx
@@ -29,7 +29,10 @@
 #include 
 #include 
 
+#include 
+
 using namespace css;
+using namespace ooo::vba;
 
 class VBAMacroTest : public UnoApiTest
 {
@@ -71,6 +74,7 @@ public:
 void testTdf107902();
 void testTdf90278();
 void testTdf149531();
+void testTdf118247();
 
 CPPUNIT_TEST_SUITE(VBAMacroTest);
 CPPUNIT_TEST(testSimpleCopyAndPaste);
@@ -92,6 +96,7 @@ public:
 CPPUNIT_TEST(testTdf107902);
 CPPUNIT_TEST(testTdf90278);
 CPPUNIT_TEST(testTdf149531);
+CPPUNIT_TEST(testTdf118247);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -928,6 +933,48 @@ void VBAMacroTest::testTdf149531()
 
 pDocSh->DoClose();
 }
+
+void VBAMacroTest::testTdf118247()
+{
+OUString aFileName;
+createFileURL(u"tdf118247.xlsm", aFileName);
+auto xComponent = loadFromDesktop(aFileName, 
"com.sun.star.sheet.SpreadsheetDocument");
+
+uno::Any aRet;
+uno::Sequence aOutParamIndex;
+uno::Sequence aOutParam;
+uno::Sequence aParams;
+
+SfxObjectShell::CallXScript(
+xComponent,
+
"vnd.sun.Star.script:VBAProject.Module1.testXlSpecialCellsValuesConstantsEmpty?"
+"language=Basic=document",
+aParams, aRet, aOutParamIndex, aOutParam);
+
+OUString aReturnValue;
+aRet >>= aReturnValue;
+CPPUNIT_ASSERT_EQUAL(OUString("$A$1:$A$3"), aReturnValue);
+
+const std::vector> aTestParams(
+{ { excel::XlSpecialCellsValue::xlNumbers, "$A$1:$A$2" },
+  { excel::XlSpecialCellsValue::xlTextValues, "$A$3" },
+  { excel::XlSpecialCellsValue::xlLogical, "$A$1:$A$2" },
+  { excel::XlSpecialCellsValue::xlErrors, "$A$1:$A$4" } });
+
+for (auto & [ nXlSpecialCellsValue, sRange ] : aTestParams)
+{
+aParams = { uno::Any(nXlSpecialCellsValue) };
+SfxObjectShell::CallXScript(
+xComponent,
+
"vnd.sun.Star.script:VBAProject.Module1.testXlSpecialCellsValuesConstants?"
+"language=Basic=document",
+aParams, aRet, aOutParamIndex, aOutParam);
+aRet >>= aReturnValue;
+CPPUNIT_ASSERT_EQUAL(sRange, aReturnValue);
+}
+css::uno::Reference xCloseable(xComponent, 
css::uno::UNO_QUERY_THROW);
+xCloseable->close(true);
+}
 CPPUNIT_TEST_SUITE_REGISTRATION(VBAMacroTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 279a4a53b930..d2bd37db518d 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -5536,6 +5536,27 @@ ScVbaRange::SpecialCells( const uno::Any& _oType, const 
uno::Any& _oValue)
 return pRangeToUse->SpecialCellsImpl( nType, _oValue );
 }
 
+static sal_Int32 getContentResultFlags(const uno::Any& aValue)
+{
+if (sal_Int32 aType; aValue >>= aType)
+{
+switch (aType)
+{
+case excel::XlSpecialCellsValue::xlNumbers:
+return sheet::CellFlags::VALUE | sheet::CellFlags::DATETIME;
+case excel::XlSpecialCellsValue::xlTextValues:
+return sheet::CellFlags::STRING;
+case excel::XlSpecialCellsValue::xlLogical:
+return sheet::CellFlags::VALUE | sheet::CellFlags::DATETIME;
+case excel::XlSpecialCellsValue::xlErrors:
+return 0;
+default:
+DebugHelper::basicexception(ERRCODE_BASIC_BAD_PARAMETER, {});
+}
+}
+return sheet::CellFlags::VALUE | sheet::CellFlags::STRING | 
sheet::CellFlags::DATETIME;
+}
+
 /// @throws script::BasicErrorException
 static sal_Int32 lcl_getFormulaResultFlags(const uno::Any& aType)
 {
@@ -5589,7 +5610,7 @@ ScVbaRange::SpecialCellsImpl( sal_Int32 nType, const 
uno::Any& _oValue)
 xLocSheetCellRanges = 
xQuery->queryContentCells(sheet::CellFlags::ANNOTATION);
 break;
 case 

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

 sc/qa/unit/data/ods/pivottable_restore_query_filter.ods |binary
 sc/qa/unit/pivottable_filters_test.cxx  |   41 
 sc/source/filter/xml/xmlfilti.cxx   |2 
 3 files changed, 42 insertions(+), 1 deletion(-)

New commits:
commit 26e3bfa02c4d582fd430171d509fa570ca364d35
Author: Chenxiong Qi 
AuthorDate: Sat Aug 27 16:00:19 2022 +0800
Commit: Hossein 
CommitDate: Mon Sep 5 11:42:29 2022 +0200

tdf#73845 restore Empty and NonEmpty query filter after FILEOPEN

Signed-off-by: Chenxiong Qi 
Change-Id: I659e0d97c44bf189f457ca04eb49248121278c10
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138919
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/sc/qa/unit/data/ods/pivottable_restore_query_filter.ods 
b/sc/qa/unit/data/ods/pivottable_restore_query_filter.ods
new file mode 100644
index ..7eb038646fa6
Binary files /dev/null and 
b/sc/qa/unit/data/ods/pivottable_restore_query_filter.ods differ
diff --git a/sc/qa/unit/pivottable_filters_test.cxx 
b/sc/qa/unit/pivottable_filters_test.cxx
index f0e5d5a8b830..69a1d4a3b7f0 100644
--- a/sc/qa/unit/pivottable_filters_test.cxx
+++ b/sc/qa/unit/pivottable_filters_test.cxx
@@ -25,6 +25,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -96,6 +99,7 @@ public:
 void testTdf125046();
 void testTdf125055();
 void testTdf125086();
+void testTdf73845();
 
 CPPUNIT_TEST_SUITE(ScPivotTableFiltersTest);
 
@@ -149,6 +153,7 @@ public:
 CPPUNIT_TEST(testTdf125046);
 CPPUNIT_TEST(testTdf125055);
 CPPUNIT_TEST(testTdf125086);
+CPPUNIT_TEST(testTdf73845);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -2743,6 +2748,42 @@ void ScPivotTableFiltersTest::testTdf125086()
 assertXPath(pDoc, "/x:pivotTableDefinition/x:pivotFields/x:pivotField[2]", 
"dataField", "1");
 }
 
+void ScPivotTableFiltersTest::testTdf73845()
+{
+// Query filter is set for individual pivot table in this ODS document.
+// This test checks the query filter is restored for ByEmpty and 
ByNonEmpty query.
+ScDocShellRef xDocSh = loadDoc(u"pivottable_restore_query_filter.", 
FORMAT_ODS);
+ScDocument& rDoc = xDocSh->GetDocument();
+ScDPCollection* pDPs = rDoc.GetDPCollection();
+CPPUNIT_ASSERT_MESSAGE("Failed to get a live ScDPCollection instance.", 
pDPs);
+
+// Three pivot tables are created in the spreadsheet. Query filters are 
set as follow:
+// pivot table 0: Confirmed Date = Not Empty
+// pivot table 1: Confirmed Date = Empty
+// pivot table 2: Category > C1 AND Confirmed Date = Not Empty
+//
+// Following assertions check the Confirmed Date is restored properly
+// after file is opened again.
+const SCCOLROW nConfirmedDateCol = SCCOLROW(2);
+size_t nDPCount = pDPs->GetCount();
+for (size_t i = 0; i < nDPCount; i++)
+{
+ScDPObject& pDPObj = (*pDPs)[i];
+ScQueryParam aQueryParam(pDPObj.GetSheetDesc()->GetQueryParam());
+size_t nEntriesCount = aQueryParam.GetEntryCount();
+for (size_t j = 0; j < nEntriesCount; j++)
+{
+ScQueryEntry rEntry = aQueryParam.GetEntry(j);
+if (rEntry.IsQueryByEmpty() || rEntry.IsQueryByNonEmpty())
+{
+const OString msg = "Query entry " + OString::number(j) + " on 
pivot table "
++ OString::number(i) + " is not restored.";
+CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.getStr(), nConfirmedDateCol, 
rEntry.nField);
+}
+}
+}
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScPivotTableFiltersTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/xml/xmlfilti.cxx 
b/sc/source/filter/xml/xmlfilti.cxx
index 20a89d5763ec..e549a3438d78 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -745,6 +745,7 @@ void ScXMLDPConditionContext::getOperatorXML(
 void SAL_CALL ScXMLDPConditionContext::endFastElement( sal_Int32 /*nElement*/ )
 {
 ScQueryEntry aFilterField;
+aFilterField.nField = nField;
 if (pFilterContext->GetConnection())
 aFilterField.eConnect = SC_OR;
 else
@@ -759,7 +760,6 @@ void SAL_CALL ScXMLDPConditionContext::endFastElement( 
sal_Int32 /*nElement*/ )
 utl::SearchParam::SearchType eSearchType = 
utl::SearchParam::SearchType::Normal;
 getOperatorXML(sOperator, aFilterField.eOp, eSearchType);
 pFilterContext->SetSearchType(eSearchType);
-aFilterField.nField = nField;
 ScQueryEntry::Item& rItem = aFilterField.GetQueryItem();
 svl::SharedStringPool& rPool = 
GetScImport().GetDocument()->GetSharedStringPool();
 


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

 sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods |  220 +
 sc/source/core/opencl/op_spreadsheet.cxx|  252 +++-
 2 files changed, 334 insertions(+), 138 deletions(-)

New commits:
commit 0db5b15e8e2799ed28ed4baa9939b76c90e944fb
Author: Luboš Luňák 
AuthorDate: Tue Aug 30 12:19:16 2022 +0200
Commit: Luboš Luňák 
CommitDate: Tue Aug 30 15:51:39 2022 +0200

opencl VLOOKUP should not look up in other columns

VLOOKUP searches only the first column, I have no idea why this was
made to search all of them.

Change-Id: I3297a723a727ba3f56db9bbb320d5b868b247db7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139026
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods 
b/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods
index 301b9bfaf690..354aff0d763d 100644
--- a/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods
+++ b/sc/qa/unit/data/functions/spreadsheet/fods/vlookup.fods
@@ -991,6 +991,15 @@
  
   False
  
+ 
+ 
+  Sorted num
+ 
+ 
+ 
+  Unsorted num
+ 
+ 
 
 
  
@@ -1068,6 +1077,20 @@
  
   cherry
  
+ 
+ 
+  1
+ 
+ 
+  11
+ 
+ 
+ 
+  5
+ 
+ 
+  21
+ 
 
 
  
@@ -1129,6 +1152,20 @@
  
   banana
  
+ 
+ 
+  2
+ 
+ 
+  12
+ 
+ 
+ 
+  8
+ 
+ 
+  24
+ 
 
 
  
@@ -1188,6 +1225,20 @@
  
   blackberry
  
+ 
+ 
+  4
+ 
+ 
+  14
+ 
+ 
+ 
+  6
+ 
+ 
+  22
+ 
 
 
  
@@ -2343,14 +2394,179 @@
  
  
 
-
+
+ 
+  11
+ 
+ 
+  11
+ 
+ 
+  PRAVDA
+ 
+ 
+  =VLOOKUP(1;$AJ$2:$AK$4;2;1)
+ 
+ 
+
+
+ 
+  14
+ 
+ 
+  14
+ 
+ 
+  PRAVDA
+ 
+ 
+  =VLOOKUP(4;$AJ$2:$AK$4;2;1)
+ 
+ 
+
+
+ 
+  12
+ 
+ 
+  12
+ 
+ 
+  PRAVDA
+ 
+ 
+  =VLOOKUP(3,5;$AJ$2:$AK$4;2;1)
+ 
+ 
+
+
+ 
+  14
+ 
+ 
+  14
+ 
+ 
+  PRAVDA
+ 
+ 
+  =VLOOKUP(5;$AJ$2:$AK$4;2;1)
+ 
+ 
+
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  PRAVDA
+ 
+ 
+  =VLOOKUP(-0,5;$AJ$2:$AK$4;2;1)
+ 
+ 
+
+
+ 
+  14
+ 
+ 
+  14
+ 
+ 
+  PRAVDA
+ 
+ 
+  =VLOOKUP(11;$AJ$2:$AK$4;2;1)
+ 
+ 
+
+
+ 
+  21
+ 
+ 
+  21
+ 
+ 
+  PRAVDA
+ 
+ 
+  =VLOOKUP(5;$AM$2:$AN$4;2;0)
+ 
+ 
+
+
+ 
+  22
+ 
+ 
+  22
+ 
+ 
+  PRAVDA
+ 
+ 
+  =VLOOKUP(6;$AM$2:$AN$4;2;0)
+ 
+ 
+
+
+ 
+  24
+ 
+ 
+  24
+ 
+ 
+  PRAVDA
+ 
+ 
+  =VLOOKUP(8;$AM$2:$AN$4;2;0)
+ 
+ 
+
+
+ 
+  #N/A
+ 
+ 
+  #N/A
+ 
+ 
+  PRAVDA
+ 
+ 
+  =VLOOKUP(7;$AM$2:$AN$4;2;0)
+ 
+ 
+
+
+ 
+  21
+ 
+ 
+  #N/A
+ 
+ 
+  NEPRAVDA
+ 
+ 
+  =VLOOKUP(21;$AM$2:$AN$4;2;0)
+ 
+ 
+
+
  
 
 
  
 
 
- 
+ 
   
   
   
diff --git a/sc/source/core/opencl/op_spreadsheet.cxx 
b/sc/source/core/opencl/op_spreadsheet.cxx
index 48789d582b07..d088b718b442 100644
--- a/sc/source/core/opencl/op_spreadsheet.cxx
+++ b/sc/source/core/opencl/op_spreadsheet.cxx
@@ -115,155 +115,135 @@ void 
OpVLookup::GenSlidingWindowFunction(std::stringstream ,
 ss << "loop = "IsEndFixed())
-{
-ss << "int doubleIndex = i+gid0;\n";
-}
-else
-{
-ss << "int doubleIndex = i;\n";
-}
-ss << "if(tmp";
-ss << 3+(secondParaWidth-1);
-ss << " == 1)\n";
-ss << "{\n";
-
-for (int j = 0;j < unrollSize; j++)
-{
-CheckSubArgumentIsNan(ss,vSubArguments,1+i);
-
-ss << "if((tmp0 - tmp";
-ss << 1+i;
-ss << ")>=0 && intermediate > ( tmp0 -tmp";
-ss << 1+i;
-ss << "))\n";
-ss << "{\n";
-ss << "rowNum = doubleIndex;\n";
-ss << "intermediate = tmp0 - tmp";
-ss << 1+i;
-ss << ";\n";
-ss << "}\n";
-ss << "i++;\n";
-ss << "doubleIndex++;\n";
-}
-
-ss << "}else\n";
-ss << "   

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

 sc/qa/unit/data/xls/tdf90299.xls  |binary
 sc/qa/unit/subsequent_export_test.cxx |   77 ++
 sc/source/filter/excel/xehelper.cxx   |   76 ++---
 3 files changed, 129 insertions(+), 24 deletions(-)

New commits:
commit 59ddcb0445da12f2b912f1a8a876117fec112c41
Author: Łukasz Leszko 
AuthorDate: Thu Mar 17 17:13:24 2022 +0100
Commit: Mike Kaganski 
CommitDate: Tue Aug 30 06:34:06 2022 +0200

tdf#90299 Fix saving external links as relative

In current build some links to external xls files are not saved as relative 
even if
"Save URLs relative to file system" option is checked. This patch aims to
solve this issue.

Change-Id: I6d0984bdcdeef57b227c8ab1353e002fa4355fc9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131711
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sc/qa/unit/data/xls/tdf90299.xls b/sc/qa/unit/data/xls/tdf90299.xls
new file mode 100644
index ..0028e11cfd51
Binary files /dev/null and b/sc/qa/unit/data/xls/tdf90299.xls differ
diff --git a/sc/qa/unit/subsequent_export_test.cxx 
b/sc/qa/unit/subsequent_export_test.cxx
index 15155636d2a1..b460319bd0a3 100644
--- a/sc/qa/unit/subsequent_export_test.cxx
+++ b/sc/qa/unit/subsequent_export_test.cxx
@@ -44,6 +44,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -182,6 +186,7 @@ public:
 void testPreserveTextWhitespace2XLSX();
 void testTdf113646();
 void testDateStandardfilterXLSX();
+void testTdf90299();
 
 CPPUNIT_TEST_SUITE(ScExportTest);
 CPPUNIT_TEST(test);
@@ -287,6 +292,7 @@ public:
 CPPUNIT_TEST(testMoveCellAnchoredShapesODS);
 CPPUNIT_TEST(testTdf113646);
 CPPUNIT_TEST(testDateStandardfilterXLSX);
+CPPUNIT_TEST(testTdf90299);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4519,6 +4525,77 @@ void ScExportTest::testDateStandardfilterXLSX()
 xDocSh->DoClose();
 }
 
+void ScExportTest::testTdf90299()
+{
+utl::TempFile aTmpDirectory1(nullptr, true);
+utl::TempFile aTmpDirectory2(nullptr, true);
+utl::TempFile aSavedFile(());
+
+struct
+{
+void checkFormula(ScDocShellRef xShell, OUString aExpectedFormula)
+{
+CPPUNIT_ASSERT(xShell.is());
+xShell->ReloadAllLinks();
+
+ScDocument& rDoc = xShell->GetDocument();
+
+ScAddress aPos(0, 0, 0);
+ScTokenArray* pCode = getTokens(rDoc, aPos);
+CPPUNIT_ASSERT_MESSAGE("empty token array", pCode);
+
+OUString aFormula = toString(rDoc, aPos, *pCode, 
rDoc.GetGrammar());
+
+CPPUNIT_ASSERT_EQUAL(aExpectedFormula, aFormula);
+}
+
+} aCheckShell;
+
+OUString aReferencedFileURL;
+OUString aReferencingFileURL;
+createFileURL(u"tdf90299.", u"xls", aReferencingFileURL);
+
+auto eError = osl::File::copy(aReferencingFileURL, aTmpDirectory1.GetURL() 
+ "/tdf90299.xls");
+CPPUNIT_ASSERT_EQUAL(osl::File::E_None, eError);
+
+aReferencingFileURL = aTmpDirectory1.GetURL() + "/tdf90299.xls";
+aReferencedFileURL = aTmpDirectory1.GetURL() + "/dummy.xls";
+
+ScDocShellRef xShell = load(aReferencingFileURL, FORMAT_XLS);
+aCheckShell.checkFormula(xShell, "'" + aReferencedFileURL + 
"'#$Sheet1.A1");
+
+aReferencingFileURL = aSavedFile.GetURL();
+
+FileFormat afilterFormat = 
ScBootstrapFixture::getFileFormats()[FORMAT_XLS];
+OUString aFilterName(afilterFormat.pFilterName, 
strlen(afilterFormat.pFilterName),
+ RTL_TEXTENCODING_UTF8);
+OUString aFilterType(afilterFormat.pTypeName, 
strlen(afilterFormat.pTypeName),
+ RTL_TEXTENCODING_UTF8);
+
+SfxMedium aStoreMedium(aReferencingFileURL, StreamMode::STD_WRITE);
+
+auto pExportFilter = std::make_shared(
+aFilterName, OUString(), afilterFormat.nFormatType, 
SotClipboardFormatId::NONE, aFilterType,
+OUString(), OUString(), "private:factory/scalc*");
+pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
+
+aStoreMedium.SetFilter(pExportFilter);
+
+xShell->DoSaveAs(aStoreMedium);
+xShell->DoClose();
+
+eError = osl::File::copy(aReferencingFileURL, aTmpDirectory2.GetURL() + 
"/tdf90299.xls");
+CPPUNIT_ASSERT_EQUAL(osl::File::E_None, eError);
+
+aReferencingFileURL = aTmpDirectory2.GetURL() + "/tdf90299.xls";
+aReferencedFileURL = aTmpDirectory2.GetURL() + "/dummy.xls";
+
+xShell = load(aReferencingFileURL, FORMAT_XLS);
+aCheckShell.checkFormula(xShell, "'" + aReferencedFileURL + 
"'#$Sheet1.A1");
+
+xShell->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/excel/xehelper.cxx 
b/sc/source/filter/excel/xehelper.cxx
index 2e5ebba684c4..2025e65a7bd2 100644
--- a/sc/source/filter/excel/xehelper.cxx
+++ b/sc/source/filter/excel/xehelper.cxx
@@ -23,6 +23,10 @@
 
 #include 
 

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

 sc/qa/uitest/inputLine/tdf131326.py |   26 ++
 sc/source/ui/view/viewfun2.cxx  |2 ++
 2 files changed, 28 insertions(+)

New commits:
commit 82b27fabfe20e504233bdb0bac860266270bd6f6
Author: Andreas Heinisch 
AuthorDate: Tue Aug 9 20:05:43 2022 +0200
Commit: Andreas Heinisch 
CommitDate: Sun Aug 21 14:58:41 2022 +0200

tdf#131326 - Invalidate cell slots and update input line with new content

Change-Id: I4881b73bb230380388ed366818d7e0808aec11e9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138065
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/uitest/inputLine/tdf131326.py 
b/sc/qa/uitest/inputLine/tdf131326.py
new file mode 100755
index ..6fbfe25f02bd
--- /dev/null
+++ b/sc/qa/uitest/inputLine/tdf131326.py
@@ -0,0 +1,26 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+from uitest.framework import UITestCase
+from uitest.uihelper.calc import enter_text_to_cell
+from uitest.uihelper.common import get_state_as_dict
+
+# Bug 131326 - Formula to Value does not automatically change text in input 
line
+class tdf131326(UITestCase):
+
+def test_tdf131326_formula_to_value_input_line(self):
+with self.ui_test.create_doc_in_start_center("calc"):
+xCalcDoc = self.xUITest.getTopFocusWindow()
+gridwin = xCalcDoc.getChild("grid_window")
+xInputWin = xCalcDoc.getChild("sc_input_window")
+
+enter_text_to_cell(gridwin, "A1", "=1")
+self.xUITest.executeCommand(".uno:ConvertFormulaToValue")
+self.assertEqual(get_state_as_dict(xInputWin)["Text"], "1")
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 30f3d3fe083f..c8ed4cc9e485 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -1874,6 +1874,8 @@ void ScViewFunc::ConvertFormulaToValue()
 
 ScDocShell* pDocSh = GetViewData().GetDocShell();
 pDocSh->GetDocFunc().ConvertFormulaToValue(aRange, true);
+// tdf#131326 - invalidate cell slots and update input line with new 
content
+CellContentChanged();
 pDocSh->PostPaint(aRange, PaintPartFlags::Grid);
 }
 


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

 sc/qa/unit/data/xls/pass/ofz49713-1.xls |binary
 sc/source/core/data/table2.cxx  |   20 
 2 files changed, 16 insertions(+), 4 deletions(-)

New commits:
commit 6c81a09e3ef239a2d7a991d00fe3620a67298b99
Author: Caolán McNamara 
AuthorDate: Sun Aug 14 20:46:49 2022 +0100
Commit: Caolán McNamara 
CommitDate: Mon Aug 15 00:50:46 2022 +0200

ofz#49713 Heap-use-after-free

the dtor of ScAttrArray where the std::vector ends up
will call ScDocumentPool::Remove on each entries pPattern, assuming
that a matching ScDocumentPool::Put was called on each, something
that is elided if we just do a simply copy here.

probably a problem since:

commit dddee125cc32f1ad5228e598a7de04e9654e65c1
Date:   Thu Mar 10 15:03:25 2022 +0100

load ods/xlsx with full row attributes without allocating all columns

Change-Id: I3a5e2e3fa4d40343f30f9eefbabd1579d8a97e02
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138262
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sc/qa/unit/data/xls/pass/ofz49713-1.xls 
b/sc/qa/unit/data/xls/pass/ofz49713-1.xls
new file mode 100644
index ..b32574013e95
Binary files /dev/null and b/sc/qa/unit/data/xls/pass/ofz49713-1.xls differ
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index c7c8a92b03dc..4eb5671f0dc7 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2897,6 +2897,20 @@ void ScTable::ApplyPatternArea( SCCOL nStartCol, SCROW 
nStartRow, SCCOL nEndCol,
 CreateColumnIfNotExists(i).ApplyPatternArea(nStartRow, nEndRow, rAttr, 
pDataArray, pIsChanged);
 }
 
+namespace
+{
+std::vector duplicateScAttrEntries(ScDocument& rDocument, 
const std::vector& rOrigData)
+{
+std::vector aData(rOrigData);
+for (size_t nIdx = 0; nIdx < aData.size(); ++nIdx)
+{
+ScPatternAttr aNewPattern(*aData[nIdx].pPattern);
+aData[nIdx].pPattern = ()->Put(aNewPattern);
+}
+return aData;
+}
+}
+
 void ScTable::SetAttrEntries( SCCOL nStartCol, SCCOL nEndCol, 
std::vector && vNewData)
 {
 if (!ValidCol(nStartCol) || !ValidCol(nEndCol))
@@ -2908,8 +2922,7 @@ void ScTable::SetAttrEntries( SCCOL nStartCol, SCCOL 
nEndCol, std::vector(vNewData));
+aCol[i].SetAttrEntries(duplicateScAttrEntries(rDocument, 
vNewData));
 aDefaultColData.SetAttrEntries(std::move(vNewData));
 }
 else
@@ -2922,8 +2935,7 @@ void ScTable::SetAttrEntries( SCCOL nStartCol, SCCOL 
nEndCol, std::vector(vNewData));
+aCol[i].SetAttrEntries(duplicateScAttrEntries(rDocument, 
vNewData));
 aCol[nEndCol].SetAttrEntries( std::move(vNewData));
 }
 }


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

 sc/qa/unit/tiledrendering/tiledrendering.cxx |   80 +++
 sc/source/ui/inc/undomanager.hxx |2 
 sc/source/ui/undo/undobase.cxx   |   44 +++---
 3 files changed, 116 insertions(+), 10 deletions(-)

New commits:
commit 80cdfe4512a66ab58e0ae27c9fafad601c2f84b2
Author: Noel Grandin 
AuthorDate: Sat Jul 30 09:02:31 2022 +0200
Commit: Noel Grandin 
CommitDate: Sun Jul 31 09:27:23 2022 +0200

sc, out of order undo: allow a subset of a non-empty redo list

This is the calc analogue of
commit 60665dc4a2af238939b1a5056ae4a4ce2c083159
sw, out of order undo: allow a subset of a non-empty redo list

Specifically, we used to not allow out of order undo at all if the redo
list was non-empty. This relaxes that condition a bit. Out of order undo
is OK with a non-empty redo list, in case all undo actions in the redo
list are either

1) owned by the current view or

2) independent from the undo action to be executed

I.e. if view1 has lots of type undo actions and an view2 adds a
single type undo action on top of it, then allow view 1 to execute
multiple of its typing undo actions, not just a single one.

Change-Id: Ib7ab88e9ebbefce267d3c7d567debd1cd98d7d6d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137628
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index f8498fae1b95..9ed5cf471269 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -129,6 +129,7 @@ public:
 void testCommentCellCopyPaste();
 void testInvalidEntrySave();
 void testUndoReordering();
+void testUndoReorderingRedo();
 
 CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
 CPPUNIT_TEST(testRowColumnHeaders);
@@ -187,6 +188,7 @@ public:
 CPPUNIT_TEST(testCommentCellCopyPaste);
 CPPUNIT_TEST(testInvalidEntrySave);
 CPPUNIT_TEST(testUndoReordering);
+CPPUNIT_TEST(testUndoReorderingRedo);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3047,6 +3049,84 @@ void ScTiledRenderingTest::testUndoReordering()
 CPPUNIT_ASSERT_EQUAL(std::size_t(0), pUndoManager->GetUndoActionCount());
 }
 
+void ScTiledRenderingTest::testUndoReorderingRedo()
+{
+ScModelObj* pModelObj = createDoc("empty.ods");
+CPPUNIT_ASSERT(pModelObj);
+ScDocument* pDoc = pModelObj->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+ScUndoManager* pUndoManager = pDoc->GetUndoManager();
+CPPUNIT_ASSERT(pUndoManager);
+CPPUNIT_ASSERT_EQUAL(std::size_t(0), pUndoManager->GetUndoActionCount());
+
+// view #1
+int nView1 = SfxLokHelper::getView();
+ViewCallback aView1;
+
+// view #2
+SfxLokHelper::createView();
+int nView2 = SfxLokHelper::getView();
+
pModelObj->initializeForTiledRendering(uno::Sequence());
+ViewCallback aView2;
+
+// text edit a cell in view #1
+SfxLokHelper::setView(nView1);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
+Scheduler::ProcessEventsToIdle();
+CPPUNIT_ASSERT_EQUAL(std::size_t(1), pUndoManager->GetUndoActionCount());
+
+// text edit another cell in view #1
+SfxLokHelper::setView(nView1);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'y', 0);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'y', 0);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'y', 0);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'y', 0);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
+Scheduler::ProcessEventsToIdle();
+CPPUNIT_ASSERT_EQUAL(std::size_t(2), pUndoManager->GetUndoActionCount());
+CPPUNIT_ASSERT_EQUAL(OUString("xx"), pDoc->GetString(ScAddress(0, 0, 0)));
+CPPUNIT_ASSERT_EQUAL(OUString("yy"), pDoc->GetString(ScAddress(0, 1, 0)));
+
+// text edit a different cell in view #2
+SfxLokHelper::setView(nView2);
+ScTabViewShell* pView2 = 
dynamic_cast(SfxViewShell::Current());
+pView2->SetCursor(0, 2);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'C', 0);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'C', 0);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'C', 0);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'C', 0);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
+Scheduler::ProcessEventsToIdle();
+CPPUNIT_ASSERT_EQUAL(std::size_t(3), pUndoManager->GetUndoActionCount());
+

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

 sc/qa/unit/data/xlsx/forcepoint107.xlsx |binary
 sc/qa/unit/filters-test.cxx |9 +
 sc/source/core/data/documentimport.cxx  |8 
 sc/source/core/data/formulacell.cxx |3 +++
 4 files changed, 20 insertions(+)

New commits:
commit 6721eddbcfefd9503a49499956e53d1a76f6712f
Author: Caolán McNamara 
AuthorDate: Tue Jun 21 10:38:30 2022 +0100
Commit: Caolán McNamara 
CommitDate: Wed Jul 20 10:00:39 2022 +0200

forcepoint#107: reproducible testcase

make this reproducible without asan

Change-Id: I32cee0a22616e96d85c59d76319a6f6074fcde8b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136228
Tested-by: Jenkins
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/sc/qa/unit/data/xlsx/forcepoint107.xlsx 
b/sc/qa/unit/data/xlsx/forcepoint107.xlsx
new file mode 100644
index ..f5238dcb5c3e
Binary files /dev/null and b/sc/qa/unit/data/xlsx/forcepoint107.xlsx differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 9c14df33b862..44aadbbba7b7 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -82,6 +82,7 @@ public:
 void testSortWithSheetExternalReferencesODS_Impl( ScDocShellRef const & 
xDocShRef, SCROW nRow1, SCROW nRow2,
 bool bCheckRelativeInSheet );
 void testSortWithFormattingXLS();
+void testForcepoint107();
 
 CPPUNIT_TEST_SUITE(ScFiltersTest);
 CPPUNIT_TEST(testCVEs);
@@ -108,6 +109,7 @@ public:
 CPPUNIT_TEST(testSortWithSharedFormulasODS);
 CPPUNIT_TEST(testSortWithSheetExternalReferencesODS);
 CPPUNIT_TEST(testSortWithFormattingXLS);
+CPPUNIT_TEST(testForcepoint107);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -869,6 +871,13 @@ void ScFiltersTest::testSortWithFormattingXLS()
 xDocSh->DoClose();
 }
 
+// just needs to not crash on recalc
+void ScFiltersTest::testForcepoint107()
+{
+ScDocShellRef xDocSh = loadDoc(u"forcepoint107.", FORMAT_XLSX, true);
+xDocSh->DoHardRecalc();
+}
+
 ScFiltersTest::ScFiltersTest()
 : ScBootstrapFixture( "sc/qa/unit/data" )
 , mbUpdateReferenceOnSort(false)
diff --git a/sc/source/core/data/documentimport.cxx 
b/sc/source/core/data/documentimport.cxx
index 5a2e77e66ffb..9f2af767b42f 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -385,6 +385,14 @@ void ScDocumentImport::setFormulaCell(const ScAddress& 
rPos, ScFormulaCell* pCel
 mpImpl->mrDoc.CheckLinkFormulaNeedingCheck( *pCell->GetCode());
 
 sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
+
+sc::CellStoreType::position_type aPos = rCells.position(rPos.Row());
+if (aPos.first != rCells.end() && aPos.first->type == 
sc::element_type_formula)
+{
+ScFormulaCell* p = sc::formula_block::at(*aPos.first->data, 
aPos.second);
+sc::SharedFormulaUtil::unshareFormulaCell(aPos, *p);
+}
+
 pBlockPos->miCellPos =
 rCells.set(pBlockPos->miCellPos, rPos.Row(), pCell);
 }
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index e44e0e47a9a9..7e0400514122 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -925,6 +925,9 @@ ScFormulaCell::~ScFormulaCell()
 if (!mxGroup || !mxGroup->mpCode)
 // Formula token is not shared.
 delete pCode;
+
+if (mxGroup && mxGroup->mpTopCell == this)
+mxGroup->mpTopCell = nullptr;
 }
 
 ScFormulaCell* ScFormulaCell::Clone() const


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

 sc/qa/unit/uicalc/data/tdf149502_HangOnDeletingSheet1.ods |binary
 sc/qa/unit/uicalc/uicalc.cxx  |   17 ++
 sc/source/core/data/document.cxx  |7 +
 3 files changed, 24 insertions(+)

New commits:
commit 954d119db932434dc976ef739c643be0d9c7023c
Author: Attila Szűcs 
AuthorDate: Wed Jun 22 14:43:04 2022 +0200
Commit: László Németh 
CommitDate: Thu Jun 23 15:34:02 2022 +0200

tdf#149502 sc: crash fix: Change in Table destruction

Postpone ScTable destruction a bit, when ScTable::nTab is synchronized
with ScDocument::maTabs[] to avoid crashing.

Before the fix random crashing occurred if the ScTable::nTab was
already updated when ~ScTable() called, but the ScDocument::maTabs[]
was not reordered yet, so nTab could have pointed to the actually
deleted table in mTabs[].

Co-authored-by: Tibor Nagy (NISZ)

Change-Id: I2ac1450e3483ab334b4e20ac2598c2191e0135c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136284
Tested-by: László Németh 
Reviewed-by: László Németh 

diff --git a/sc/qa/unit/uicalc/data/tdf149502_HangOnDeletingSheet1.ods 
b/sc/qa/unit/uicalc/data/tdf149502_HangOnDeletingSheet1.ods
new file mode 100644
index ..e34a75c32308
Binary files /dev/null and 
b/sc/qa/unit/uicalc/data/tdf149502_HangOnDeletingSheet1.ods differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index a6f648ce9766..2e48f42f2e73 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -1512,6 +1512,23 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf86166)
 CPPUNIT_ASSERT_EQUAL(static_cast(1), pDoc->GetTableCount());
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf149502_HangOnDeletingSheet1)
+{
+ScModelObj* pModelObj = createDoc("tdf149502_HangOnDeletingSheet1.ods");
+ScDocument* pDoc = pModelObj->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+
+CPPUNIT_ASSERT_EQUAL(static_cast(4), pDoc->GetTableCount());
+
+uno::Sequence aArgs(
+comphelper::InitPropertySequence({ { "Index", uno::Any(sal_uInt16(0)) 
} }));
+
+// Before the fix in place, this test frozen here
+dispatchCommand(mxComponent, ".uno:Remove", aArgs);
+
+CPPUNIT_ASSERT_EQUAL(static_cast(3), pDoc->GetTableCount());
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf149503)
 {
 ScModelObj* pModelObj = createDoc("tdf149503.xls");
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 15f44a1ef4d5..db6500e5b390 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -727,7 +727,14 @@ bool ScDocument::DeleteTab( SCTAB nTab )
 if (pTab)
 pTab->UpdateDeleteTab(aCxt);
 
+// tdf#149502 make sure ScTable destructor called after the 
erase is finished, when
+// maTabs[x].nTab==x is true again, as it should be always 
true.
+// In the end of maTabs.erase, maTabs indexes change, but nTab 
updated before erase.
+// ~ScTable expect that maTabs[x].nTab==x so it shouldn't be 
called during erase.
+ScTableUniquePtr pErasedTab = std::move(maTabs[nTab]);
 maTabs.erase(maTabs.begin() + nTab);
+delete pErasedTab.release();
+
 // UpdateBroadcastAreas must be called between UpdateDeleteTab,
 // which ends listening, and StartAllListeners, to not modify
 // areas that are to be inserted by starting listeners.


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

 sc/qa/unit/data/ods/LargeAnchorOffset.ods |binary
 sc/qa/unit/scshapetest.cxx|   34 ++
 sc/source/filter/xml/xmlexprt.cxx |8 ++-
 3 files changed, 37 insertions(+), 5 deletions(-)

New commits:
commit 7d5dcf5f547e29d61e788b88f7a3f7b4feafb6b2
Author: Mike Kaganski 
AuthorDate: Wed Jun 22 16:22:50 2022 +0300
Commit: Mike Kaganski 
CommitDate: Wed Jun 22 19:28:19 2022 +0200

Fix shape rectangle calculation

At specific screen resolutions, caused failed CppunitTest_sc_shapetest:

  C:/lo/src/core/sc/qa/unit/scshapetest.cxx(169) : error : Assertion
  Test name: 
sc_apitest::ScShapeTest::testTdf137576_LogicRectInDefaultMeasureline
  assertion failed
  - Expression: std::abs(rExpected.Y() - rActual.Y()) <= nTolerance
  - after reload Y expected 9731 actual 10287 Tolerance 1

which manifested the actual wrong position of shape written into ODF.
Commit cd966aac6ecd8ce606ac3f2ccd602e467114ba3f
  Author Regina Henschel 
  Date   Fri Dec 25 19:27:51 2020 +0100
tdf#137033 improve save of cell anchored shapes

had corrected the calculation of anchor point, but the overlook was
that in some cases of non-transformed shapes, rMyCell.maCellAddress
may differ from pObjData->maStart. Since aSnapStartAddress could be
not set to pObjData->maStart for such shapes, the wrong cell range
could be calculated for resized-with-cell objects.

Fix this by using pObjData->maStart whenever there is pObjData. If
it turns out that in some cases, rMyCell.maCellAddress is needed in
calculations before the 'if (rShape.bResizeWithCell && pObjData)',
aSnapStartAddress should be assigned to pObjData->maStart after the
check.

Change-Id: I7e0dc834c2ffb147430fb5b2cb8bdb4dca201b3b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136285
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sc/qa/unit/data/ods/LargeAnchorOffset.ods 
b/sc/qa/unit/data/ods/LargeAnchorOffset.ods
new file mode 100644
index ..c7e44527e235
Binary files /dev/null and b/sc/qa/unit/data/ods/LargeAnchorOffset.ods differ
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index 761db2da687c..dc47be21b0d3 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -71,6 +71,7 @@ public:
 void testCustomShapeCellAnchoredRotatedShape();
 void testTdf144242_Line_noSwapWH();
 void testTdf144242_OpenBezier_noSwapWH();
+void testLargeAnchorOffset();
 
 CPPUNIT_TEST_SUITE(ScShapeTest);
 CPPUNIT_TEST(testTdf143619_validation_circle_pos);
@@ -100,6 +101,7 @@ public:
 CPPUNIT_TEST(testCustomShapeCellAnchoredRotatedShape);
 CPPUNIT_TEST(testTdf144242_Line_noSwapWH);
 CPPUNIT_TEST(testTdf144242_OpenBezier_noSwapWH);
+CPPUNIT_TEST(testLargeAnchorOffset);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -1234,6 +1236,38 @@ void 
ScShapeTest::testCustomShapeCellAnchoredRotatedShape()
 pDocSh->DoClose();
 }
 
+void ScShapeTest::testLargeAnchorOffset()
+{
+// The example doc contains a resize-with-cell-anchored measure line
+// with a large vertical offset that shifts the start point onto the
+// next cell below.
+OUString aFileURL;
+createFileURL(u"LargeAnchorOffset.ods", aFileURL);
+uno::Reference xComponent = 
loadFromDesktop(aFileURL);
+
+ScDocShell* pDocSh = lcl_getScDocShellWithAssert(xComponent);
+SdrObject* pObj = lcl_getSdrObjectWithAssert(pDocSh->GetDocument(), 0);
+
+const Point aOldPos = pObj->GetRelativePos();
+// Just to check that it imports correctly
+lcl_AssertPointEqualWithTolerance("before reload", { 9504, 9089 }, 
aOldPos, 1);
+
+saveAndReload(xComponent, "calc8");
+
+pDocSh = lcl_getScDocShellWithAssert(xComponent);
+pObj = lcl_getSdrObjectWithAssert(pDocSh->GetDocument(), 0);
+
+// Without the fix, this would fail:
+//   Test name: sc_apitest::ScShapeTest::testLargeAnchorOffset
+//   assertion failed
+//   - Expression: std::abs(rExpected.Y() - rActual.Y()) <= nTolerance
+//   - after reload Y expected 9089 actual 9643 Tolerance 1
+const Point aNewPos = pObj->GetRelativePos();
+lcl_AssertPointEqualWithTolerance("after reload", aOldPos, aNewPos, 1);
+
+pDocSh->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScShapeTest);
 }
 
diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 57c041f7f5ee..8a781127035a 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3481,14 +3481,12 @@ void ScXMLExport::WriteShapes(const ScMyCell& rMyCell)
 // end cell address of snap rect. In case of a transformed shape, 
it is not in rMyCell.
 ScAddress aSnapStartAddress = rMyCell.maCellAddress;
 ScDrawObjData* pObjData = nullptr;
-bool bIsShapeTransformed = false;
 if (pObj)
 {
   

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

 sc/qa/unit/ucalc_formula.cxx|4 ++--
 sc/source/core/tool/refdata.cxx |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 104596d005b32bd2bba15554e8c9ae740327aa46
Author: Eike Rathke 
AuthorDate: Mon Jun 6 14:34:34 2022 +0200
Commit: Eike Rathke 
CommitDate: Mon Jun 6 16:55:21 2022 +0200

Resolves: tdf#148163 Preserve names of bad cell reference input again

A regression of

commit e247262327d04ad9933f4af354050f4420c6e303
CommitDate: Tue Jul 30 23:49:55 2013 -0400

More on avoiding direct access to data members.

that changed, for example, invalid sheet references

-aRef.nTab = MAXTAB+3;
+aRef.SetTabDeleted(true);

The then following

commit 8a19af57bbcc57a02a7d87c6408d1e3212a6deba
CommitDate: Tue Jul 30 23:50:03 2013 -0400

Now nobody accesses reference members directly. Make them private.

changed ScSingleRefData::Valid()

-return  nCol >= 0 && nCol <= MAXCOL &&
-nRow >= 0 && nRow <= MAXROW &&
-nTab >= 0 && nTab <= MAXTAB;
+return ColValid() && RowValid() && TabValid();

without taking the deleted flags into account, where previous to
commit e247262327d04ad9933f4af354050f4420c6e303 nTab > MAXTAB
fulfilled the condition of not valid.

This makes it necessary to adjust the
TestFormula::testFuncRangeOp() test case that relied on the broken
behaviour.

Change-Id: I42e769ca0d56a2eb786bb6f65917f0c15d082763
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135453
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 6bad4a40127c..e1df10374d43 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -7415,8 +7415,8 @@ void TestFormula::testFuncRangeOp()
 // have to be adapted.
 aPos.IncRow();
 m_pDoc->SetString( aPos, "=SUM(B1:Sheet2.B2:Sheet3.B3)");
-ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(#REF!.B2:#REF!.B3)", "Wrong 
formula.");
-CPPUNIT_ASSERT_EQUAL( OUString("#REF!"), m_pDoc->GetString(aPos));
+ASSERT_FORMULA_EQUAL(*m_pDoc, aPos, "SUM(b1:sheet2.b2:Sheet3.B3)", "Wrong 
formula.");
+CPPUNIT_ASSERT_EQUAL( OUString("#NAME?"), m_pDoc->GetString(aPos));
 
 aPos.IncRow();
 m_pDoc->SetString( aPos, "=SUM(Sheet1.B1:Sheet3.B2:Sheet2.B3)");
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index ec18dc06f598..8bd55dfc92ec 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -129,7 +129,7 @@ bool ScSingleRefData::IsDeleted() const
 
 bool ScSingleRefData::Valid(const ScDocument& rDoc) const
 {
-return ColValid(rDoc) && RowValid(rDoc) && TabValid();
+return !IsDeleted() && ColValid(rDoc) && RowValid(rDoc) && TabValid();
 }
 
 bool ScSingleRefData::ColValid(const ScDocument& rDoc) const


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

 sc/qa/unit/ucalc_sort.cxx|6 +++---
 sc/source/core/data/documen7.cxx |6 +++---
 sc/source/ui/view/viewdata.cxx   |   18 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

New commits:
commit 6573ade5cf0cd63ff283446822e3bc87cd8a749b
Author: Stephan Bergmann 
AuthorDate: Tue May 31 15:36:24 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Tue May 31 18:51:58 2022 +0200

Use some range-based for loops

Change-Id: I26ad6ff194742b69cb6048c48fa01de7715865ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135191
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx
index bdf2e82d2932..27839c28e1d0 100644
--- a/sc/qa/unit/ucalc_sort.cxx
+++ b/sc/qa/unit/ucalc_sort.cxx
@@ -573,9 +573,9 @@ void TestSort::testSortInFormulaGroup()
 
 m_pDoc->InsertTab(0, "sorttest");
 
-for ( SCROW i = 0; i < SCROW(SAL_N_ELEMENTS( aEntries )); ++i )
-m_pDoc->SetString( aEntries[i].nCol, aEntries[i].nRow, 0,
-   OUString::createFromAscii( aEntries[i].pData) );
+for ( auto const & i: aEntries )
+m_pDoc->SetString( i.nCol, i.nRow, 0,
+   OUString::createFromAscii( i.pData) );
 
 ScSortParam aSortData;
 aSortData.nCol1 = 0;
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index 28941db7c6d9..61f6b68f0543 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -588,9 +588,9 @@ void ScDocument::TrackFormulas( SfxHintId nHintId )
 void ScDocument::StartAllListeners()
 {
 sc::StartListeningContext aCxt(*this);
-for ( SCTAB i = 0; i < static_cast(maTabs.size()); ++i )
-if ( maTabs[i] )
-maTabs[i]->StartListeners(aCxt, true);
+for ( auto const & i: maTabs )
+if ( i )
+i->StartListeners(aCxt, true);
 }
 
 void ScDocument::UpdateBroadcastAreas( UpdateRefMode eUpdateRefMode,
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index ac31e522ac79..88d57f106a3b 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -1004,10 +1004,10 @@ void ScViewData::SetZoomType( SvxZoomType eNew, 
std::vector< SCTAB >& tabs )
 
 if ( bAll )
 {
-for ( SCTAB i = 0; i < static_cast(maTabData.size()); ++i )
+for ( auto & i: maTabData )
 {
-if ( maTabData[i] )
-maTabData[i]->eZoomType = eNew;
+if ( i )
+i->eZoomType = eNew;
 }
 eDefZoomType = eNew;
 }
@@ -1046,19 +1046,19 @@ void ScViewData::SetZoom( const Fraction& rNewX, const 
Fraction& rNewY, std::vec
 
 if ( bAll )
 {
-for ( SCTAB i = 0; i < static_cast(maTabData.size()); ++i )
+for ( auto & i: maTabData )
 {
-if ( maTabData[i] )
+if ( i )
 {
 if ( bPagebreak )
 {
-maTabData[i]->aPageZoomX = rNewX;
-maTabData[i]->aPageZoomY = rNewY;
+i->aPageZoomX = rNewX;
+i->aPageZoomY = rNewY;
 }
 else
 {
-maTabData[i]->aZoomX = rNewX;
-maTabData[i]->aZoomY = rNewY;
+i->aZoomX = rNewX;
+i->aZoomY = rNewY;
 }
 }
 }


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

 sc/qa/uitest/conditional_format/tdf81696.py |2 
 sc/qa/uitest/sort/naturalSort.py|5 
 sc/qa/uitest/sort/sorting.py|4 
 sc/qa/uitest/sort/tdf49531.py   |6 
 sc/qa/uitest/sort/tdf53482.py   |7 
 sc/qa/uitest/sort/tdf57465.py   |8 -
 sc/qa/uitest/sort/tdf91305.py   |9 -
 sc/qa/uitest/sort/tdf99208.py   |   11 -
 sc/source/ui/dbgui/sortdlg.cxx  |2 
 sc/source/ui/dbgui/sortkeydlg.cxx   |6 
 sc/source/ui/dbgui/tpsort.cxx   |  198 ++--
 sc/source/ui/inc/sortdlg.hxx|9 -
 sc/source/ui/inc/tpsort.hxx |   17 +-
 sc/uiconfig/scalc/ui/sortcriteriapage.ui|  154 -
 sc/uiconfig/scalc/ui/sortkey.ui |3 
 sc/uiconfig/scalc/ui/sortoptionspage.ui |  123 ++---
 16 files changed, 270 insertions(+), 294 deletions(-)

New commits:
commit 7c2bcac3e6aac31811adede6f466d2125184da4c
Author: Heiko Tietze 
AuthorDate: Wed Mar 2 12:20:44 2022 +0100
Commit: Heiko Tietze 
CommitDate: Mon May 23 09:02:45 2022 +0200

Resolves tdf#131155 - Keep frequently used options on sort criteria tab

* Row/Column header moved
* Sort by row/column moved
* Extra variables removed
* UI tests adjusted to read/set sort direction and header from first tab

Change-Id: I9fc0406806256f289d52e45b096e392067768eaa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130843
Tested-by: Heiko Tietze 
Reviewed-by: Heiko Tietze 

diff --git a/sc/qa/uitest/conditional_format/tdf81696.py 
b/sc/qa/uitest/conditional_format/tdf81696.py
index 6b9bb7903154..0fca31e2bd98 100644
--- a/sc/qa/uitest/conditional_format/tdf81696.py
+++ b/sc/qa/uitest/conditional_format/tdf81696.py
@@ -28,7 +28,7 @@ class tdf81696(UITestCase):
 #Open sort dialog by DATA - SORT,Just sort it by Column A, 
ascending. (it's default)
 with self.ui_test.execute_dialog_through_command(".uno:DataSort") 
as xDialog:
 xTabs = xDialog.getChild("tabcontrol")
-xleftright = xDialog.getChild("leftright")
+xleftright = xDialog.getChild("rbLeftRight")
 select_pos(xTabs, "0")
 
 #verify
diff --git a/sc/qa/uitest/sort/naturalSort.py b/sc/qa/uitest/sort/naturalSort.py
index ca8384d5f2bf..6d9dd3edd7ca 100644
--- a/sc/qa/uitest/sort/naturalSort.py
+++ b/sc/qa/uitest/sort/naturalSort.py
@@ -85,12 +85,13 @@ class CalcNaturalSorting(UITestCase):
 #Open sort dialog by DATA - SORT
 with self.ui_test.execute_dialog_through_command(".uno:DataSort") 
as xDialog:
 xTabs = xDialog.getChild("tabcontrol")
-xleftright = xDialog.getChild("leftright")
 select_pos(xTabs, "1")
 xNatural = xDialog.getChild("naturalsort")
-xleftright.executeAction("CLICK", tuple())
 if (get_state_as_dict(xNatural)["Selected"]) == "false":
 xNatural.executeAction("CLICK", tuple())
+select_pos(xTabs, "0")
+xleftright = xDialog.getChild("rbLeftRight")
+xleftright.executeAction("CLICK", tuple())
 
 #Verify
 self.assertEqual(get_cell_by_position(document, 0, 0, 
0).getString(), "MW-1")
diff --git a/sc/qa/uitest/sort/sorting.py b/sc/qa/uitest/sort/sorting.py
index 10645827435c..a3c901574109 100644
--- a/sc/qa/uitest/sort/sorting.py
+++ b/sc/qa/uitest/sort/sorting.py
@@ -58,7 +58,7 @@ class CalcSorting(UITestCase):
 xTabs = xDialog.getChild("tabcontrol")
 select_pos(xTabs, "1")
 #Verify that option "Range contains column labels" is set
-xHeader = xDialog.getChild("header")
+xHeader = xDialog.getChild("cbHeader")
 self.assertEqual(get_state_as_dict(xHeader)["Selected"], 
"true")
 #Cancel dialog
 #Select Range A1:B5
@@ -100,7 +100,7 @@ class CalcSorting(UITestCase):
 xTabs = xDialog.getChild("tabcontrol")
 select_pos(xTabs, "1")
 #Verify that option "Range contains column labels" is not set
-xHeader = xDialog.getChild("header")
+xHeader = xDialog.getChild("cbHeader")
 self.assertEqual(get_state_as_dict(xHeader)["Selected"], 
"false")
 #Cancel dialog
 
diff --git a/sc/qa/uitest/sort/tdf49531.py b/sc/qa/uitest/sort/tdf49531.py
index 08f94cd1a275..98d705bf8dd3 100644
--- a/sc/qa/uitest/sort/tdf49531.py
+++ b/sc/qa/uitest/sort/tdf49531.py
@@ -31,14 +31,14 @@ class tdf49531(UITestCase):
 xTabs = xDialog.getChild("tabcontrol")
 select_pos(xTabs, "1")
 xNatural = xDialog.getChild("naturalsort")
-xtopdown = xDialog.getChild("topdown")
-

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

 sc/qa/unit/SparklineImportExportTest.cxx   |   22 ++
 sc/source/filter/excel/export/SparklineExt.cxx |7 ++-
 2 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit 2c4330b3570f16d6668936fd05e1ab2ade597bae
Author: Tomaž Vajngerl 
AuthorDate: Wed May 11 12:26:11 2022 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu May 12 11:10:21 2022 +0200

tdf#148835 don't write any sparkline xml elements if none exists

Change-Id: Idd4058a88639cebceded13110dc367e74b6f7097
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134141
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/qa/unit/SparklineImportExportTest.cxx 
b/sc/qa/unit/SparklineImportExportTest.cxx
index 3ae19881f8aa..d5d2c38b58c6 100644
--- a/sc/qa/unit/SparklineImportExportTest.cxx
+++ b/sc/qa/unit/SparklineImportExportTest.cxx
@@ -47,17 +47,20 @@ public:
 
 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathContextPtr) 
override
 {
+XmlTestTools::registerOOXMLNamespaces(pXmlXPathContextPtr);
 XmlTestTools::registerODFNamespaces(pXmlXPathContextPtr);
 }
 
 void testSparklinesRoundtripXLSX();
 void testSparklinesExportODS();
 void testSparklinesRoundtripODS();
+void testNoSparklinesInDocumentXLSX();
 
 CPPUNIT_TEST_SUITE(SparklineImportExportTest);
 CPPUNIT_TEST(testSparklinesRoundtripXLSX);
 CPPUNIT_TEST(testSparklinesExportODS);
 CPPUNIT_TEST(testSparklinesRoundtripODS);
+CPPUNIT_TEST(testNoSparklinesInDocumentXLSX);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -238,6 +241,25 @@ void 
SparklineImportExportTest::testSparklinesRoundtripODS()
 xDocSh->DoClose();
 }
 
+void SparklineImportExportTest::testNoSparklinesInDocumentXLSX()
+{
+// tdf#148835
+// Check no sparkline elements are written when there is none in the 
document
+
+// Load the document containing NO sparklines
+ScDocShellRef xDocSh = loadDoc(u"empty.", FORMAT_XLSX);
+
+std::shared_ptr pXPathFile = 
ScBootstrapFixture::exportTo(*xDocSh, FORMAT_XLSX);
+xmlDocUniquePtr pXmlDoc
+= XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/worksheets/sheet1.xml");
+CPPUNIT_ASSERT(pXmlDoc);
+
+assertXPath(pXmlDoc, "/x:worksheet", 1);
+assertXPath(pXmlDoc, "/x:worksheet/x:extLst/x:ext/x14:sparklineGroups", 0);
+assertXPath(pXmlDoc, "/x:worksheet/x:extLst/x:ext", 0);
+assertXPath(pXmlDoc, "/x:worksheet/x:extLst", 0);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SparklineImportExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/excel/export/SparklineExt.cxx 
b/sc/source/filter/excel/export/SparklineExt.cxx
index 5202c3e92449..487698e19ba1 100644
--- a/sc/source/filter/excel/export/SparklineExt.cxx
+++ b/sc/source/filter/excel/export/SparklineExt.cxx
@@ -230,7 +230,12 @@ void SparklineExt::addSparklineGroup(XclExpXmlStream& 
rStream, sc::SparklineGrou
 SparklineBuffer::SparklineBuffer(const XclExpRoot& rRoot, XclExtLstRef const& 
xExtLst)
 : XclExpRoot(rRoot)
 {
-xExtLst->AddRecord(new xcl::exp::SparklineExt(GetRoot()));
+auto& rDocument = GetDoc();
+auto* pSparklineList = rDocument.GetSparklineList(GetCurrScTab());
+if (pSparklineList && !pSparklineList->getSparklineGroups().empty())
+{
+xExtLst->AddRecord(new xcl::exp::SparklineExt(GetRoot()));
+}
 }
 
 } // end namespace xcl::exp


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

 sc/qa/unit/bugfix-test.cxx  |   21 
 sc/qa/unit/data/ods/tdf108188_pagestyle.ods |binary
 sc/source/core/data/stlsheet.cxx|   35 +++-
 sfx2/source/dialog/StyleList.cxx|   15 
 4 files changed, 45 insertions(+), 26 deletions(-)

New commits:
commit ad79900cd62c487bda9d2515892d62b3b08a5dfa
Author: Andreas Heinisch 
AuthorDate: Sun May 8 14:31:00 2022 +0200
Commit: Andreas Heinisch 
CommitDate: Tue May 10 20:30:56 2022 +0200

tdf#108188, tdf#131190 - Verify that the page style is actually used

Change-Id: I007d26c6fcaf60d2a2378cc00e630da447f95a8a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134022
Tested-by: Andreas Heinisch 
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx
index 3b3cc27439df..2975b0b0a834 100644
--- a/sc/qa/unit/bugfix-test.cxx
+++ b/sc/qa/unit/bugfix-test.cxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -63,6 +64,7 @@ public:
 void testTdf129789();
 void testTdf130725();
 void testTdf104502_hiddenColsCountedInPageCount();
+void testTdf108188_pagestyle();
 
 CPPUNIT_TEST_SUITE(ScFiltersTest);
 CPPUNIT_TEST(testTdf137576_Measureline);
@@ -87,6 +89,7 @@ public:
 CPPUNIT_TEST(testTdf129789);
 CPPUNIT_TEST(testTdf130725);
 CPPUNIT_TEST(testTdf104502_hiddenColsCountedInPageCount);
+CPPUNIT_TEST(testTdf108188_pagestyle);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -726,6 +729,24 @@ void 
ScFiltersTest::testTdf104502_hiddenColsCountedInPageCount()
 
 xShell->DoClose();
 }
+void ScFiltersTest::testTdf108188_pagestyle()
+{
+ScDocShellRef xDocSh = loadDoc(u"tdf108188_pagestyle.", FORMAT_ODS);
+CPPUNIT_ASSERT(xDocSh);
+
+// Check if the user defined page style is present
+const OUString aTestPageStyle = "TestPageStyle";
+ScDocument& rDoc = xDocSh->GetDocument();
+CPPUNIT_ASSERT_EQUAL(aTestPageStyle, rDoc.GetPageStyle(0));
+
+// Without the accompanying fix in place, the page styles are always used
+ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
+CPPUNIT_ASSERT(pStylePool->Find(aTestPageStyle, 
SfxStyleFamily::Page)->IsUsed());
+CPPUNIT_ASSERT(!pStylePool->Find("Default", 
SfxStyleFamily::Page)->IsUsed());
+
+xDocSh->DoClose();
+}
+
 
 ScFiltersTest::ScFiltersTest()
   : ScBootstrapFixture( "sc/qa/unit/data" )
diff --git a/sc/qa/unit/data/ods/tdf108188_pagestyle.ods 
b/sc/qa/unit/data/ods/tdf108188_pagestyle.ods
new file mode 100644
index ..d0ecf9f88453
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf108188_pagestyle.ods differ
diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx
index e485b5f7fc99..fdf09e7cde3e 100644
--- a/sc/source/core/data/stlsheet.cxx
+++ b/sc/source/core/data/stlsheet.cxx
@@ -250,19 +250,32 @@ SfxItemSet& ScStyleSheet::GetItemSet()
 
 bool ScStyleSheet::IsUsed() const
 {
-if ( GetFamily() == SfxStyleFamily::Para )
+switch (GetFamily())
 {
-// Always query the document to let it decide if a rescan is necessary,
-// and store the state.
-ScDocument* pDoc = 
static_cast(m_pPool)->GetDocument();
-if ( pDoc && pDoc->IsStyleSheetUsed( *this ) )
-eUsage = Usage::USED;
-else
-eUsage = Usage::NOTUSED;
-return eUsage == Usage::USED;
+case SfxStyleFamily::Para:
+{
+// Always query the document to let it decide if a rescan is 
necessary,
+// and store the state.
+ScDocument* pDoc = 
static_cast(m_pPool)->GetDocument();
+if ( pDoc && pDoc->IsStyleSheetUsed( *this ) )
+eUsage = Usage::USED;
+else
+eUsage = Usage::NOTUSED;
+return eUsage == Usage::USED;
+}
+case SfxStyleFamily::Page:
+{
+// tdf#108188 - verify that the page style is actually used
+ScDocument* pDoc = 
static_cast(m_pPool)->GetDocument();
+if (pDoc && pDoc->IsPageStyleInUse(GetName(), nullptr))
+eUsage = Usage::USED;
+else
+eUsage = Usage::NOTUSED;
+return eUsage == Usage::USED;
+}
+default:
+return true;
 }
-else
-return true;
 }
 
 void ScStyleSheet::Notify( SfxBroadcaster&, const SfxHint& rHint )
diff --git a/sfx2/source/dialog/StyleList.cxx b/sfx2/source/dialog/StyleList.cxx
index 6f8e3543aac8..a25050ead918 100644
--- a/sfx2/source/dialog/StyleList.cxx
+++ b/sfx2/source/dialog/StyleList.cxx
@@ -1321,21 +1321,6 @@ IMPL_LINK_NOARG(StyleList, EnableDelete, void*, void)
 {
 bEnableDelete = true;
 }
-else if (pStyle->GetFamily() == SfxStyleFamily::Page)
-{
-// Hack to 

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

 sc/qa/unit/ucalc_sort.cxx |   10 +-
 sc/source/core/data/queryiter.cxx |   23 +--
 2 files changed, 18 insertions(+), 15 deletions(-)

New commits:
commit 6a5464b800aa0b0ce35d602fd008b555d96a94af
Author: Luboš Luňák 
AuthorDate: Fri May 6 09:59:01 2022 +0200
Commit: Luboš Luňák 
CommitDate: Tue May 10 16:24:13 2022 +0200

make query iterator's BinarySearch() find the last matching item

If the code found a matching value, it didn't bother finding
the last one in the range if there were several adjacent ones.

Change-Id: Ie1f4c7bd3dcbd2aaf653f5b74e159902de4cf93d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134098
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx
index ca4b9c319e80..698cbb1bde97 100644
--- a/sc/qa/unit/ucalc_sort.cxx
+++ b/sc/qa/unit/ucalc_sort.cxx
@@ -2100,7 +2100,7 @@ void TestSort::testQueryBinarySearch()
 ScQueryParam param = makeSearchParam( range, ascendingCol, 
SC_LESS_EQUAL, 5 );
 TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, 
param, false );
 CPPUNIT_ASSERT(it.BinarySearch());
-// CPPUNIT_ASSERT_EQUAL(SCROW(8), it.GetRow());
+CPPUNIT_ASSERT_EQUAL(SCROW(8), it.GetRow());
 }
 
 {
@@ -2112,7 +2112,7 @@ void TestSort::testQueryBinarySearch()
 ScQueryParam param = makeSearchParam( range, descendingCol, 
SC_GREATER_EQUAL, 5 );
 TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, 
param, false );
 CPPUNIT_ASSERT(it.BinarySearch());
-// CPPUNIT_ASSERT_EQUAL(SCROW(6), it.GetRow());
+CPPUNIT_ASSERT_EQUAL(SCROW(6), it.GetRow());
 }
 
 {
@@ -2124,7 +2124,7 @@ void TestSort::testQueryBinarySearch()
 ScQueryParam param = makeSearchParam( range, ascendingCol, 
SC_LESS_EQUAL, 6 );
 TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, 
param, false );
 CPPUNIT_ASSERT(it.BinarySearch());
-// CPPUNIT_ASSERT_EQUAL(SCROW(8), it.GetRow());
+CPPUNIT_ASSERT_EQUAL(SCROW(8), it.GetRow());
 }
 
 {
@@ -2136,7 +2136,7 @@ void TestSort::testQueryBinarySearch()
 ScQueryParam param = makeSearchParam( range, descendingCol, 
SC_GREATER_EQUAL, 6 );
 TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, 
param, false );
 CPPUNIT_ASSERT(it.BinarySearch());
-// CPPUNIT_ASSERT_EQUAL(SCROW(1), it.GetRow());
+CPPUNIT_ASSERT_EQUAL(SCROW(1), it.GetRow());
 }
 
 {
@@ -2172,7 +2172,7 @@ void TestSort::testQueryBinarySearch()
 ScQueryParam param = makeSearchParam( range, ascendingCol, 
SC_LESS_EQUAL, 10 );
 TestQueryIterator it( *m_pDoc, m_pDoc->GetNonThreadedContext(), 0, 
param, false );
 CPPUNIT_ASSERT(it.BinarySearch());
-// CPPUNIT_ASSERT_EQUAL(SCROW(10), it.GetRow());
+CPPUNIT_ASSERT_EQUAL(SCROW(10), it.GetRow());
 }
 
 {
diff --git a/sc/source/core/data/queryiter.cxx 
b/sc/source/core/data/queryiter.cxx
index ec88e35ff6a5..60d62ad2da60 100644
--- a/sc/source/core/data/queryiter.cxx
+++ b/sc/source/core/data/queryiter.cxx
@@ -394,7 +394,7 @@ bool ScQueryCellIteratorBase< accessType, queryType 
>::BinarySearch()
 }
 
 sal_Int32 nRes = 0;
-bool bFound = false;
+std::optional found;
 bool bDone = false;
 while (nLo <= nHi && !bDone)
 {
@@ -426,12 +426,12 @@ bool ScQueryCellIteratorBase< accessType, queryType 
>::BinarySearch()
 nRes = -1;
 if (bLessEqual)
 {
-if (fLastInRangeValue < nCellVal)
+if (fLastInRangeValue <= nCellVal)
 {
 fLastInRangeValue = nCellVal;
 nLastInRange = i;
 }
-else if (fLastInRangeValue > nCellVal)
+else if (fLastInRangeValue >= nCellVal)
 {
 // not strictly sorted, continue with GetThis()
 nLastInRange = nFirstLastInRange;
@@ -445,12 +445,12 @@ bool ScQueryCellIteratorBase< accessType, queryType 
>::BinarySearch()
 nRes = 1;
 if (!bLessEqual)
 {
-if (fLastInRangeValue > nCellVal)
+if (fLastInRangeValue >= nCellVal)
 {
 fLastInRangeValue = nCellVal;
 nLastInRange = i;
 }
-else if (fLastInRangeValue < nCellVal)
+else if (fLastInRangeValue <= nCellVal)
 {
 // not strictly sorted, continue with GetThis()
 nLastInRange = nFirstLastInRange;
@@ -469,7 +469,7 @@ bool ScQueryCellIteratorBase< accessType, queryType 
>::BinarySearch()
 {
 sal_Int32 

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

 sc/qa/uitest/calc_tests6/moveCopySheet.py |   17 +
 sc/source/ui/inc/mvtabdlg.hxx |1 +
 sc/source/ui/miscdlgs/mvtabdlg.cxx|   11 +++
 3 files changed, 29 insertions(+)

New commits:
commit 170cdf5e335f8803b6d851a9d16020d277e73288
Author: Laurent BP 
AuthorDate: Mon Apr 25 09:30:38 2022 +0200
Commit: Andreas Heinisch 
CommitDate: Fri Apr 29 19:04:10 2022 +0200

tdf#139464 Change label of OK button

In Move/copy sheet UI, change label
according to selected action
 update: with UI test

Change-Id: I8244b1635f56574c7641191be7e15ee4a098dce9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133364
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/uitest/calc_tests6/moveCopySheet.py 
b/sc/qa/uitest/calc_tests6/moveCopySheet.py
index 9436364dd053..41019b371a83 100644
--- a/sc/qa/uitest/calc_tests6/moveCopySheet.py
+++ b/sc/qa/uitest/calc_tests6/moveCopySheet.py
@@ -65,5 +65,22 @@ class moveCopySheet(UITestCase):
 self.assertEqual(document.Sheets[1].Name, "Sheet1")
 self.assertEqual(document.Sheets[2].Name, "moveName")
 
+#tdf#139464 Set OK button label to selected action: Move or Copy
+def test_tdf139464_move_sheet(self):
+with self.ui_test.create_doc_in_start_center("calc") as document:
+with self.ui_test.execute_dialog_through_command(".uno:Move") as 
xDialog:
+xOkButton = xDialog.getChild("ok")
+xCopyButton = xDialog.getChild("copy")
+self.assertEqual(get_state_as_dict(xCopyButton)['Text'], 
get_state_as_dict(xOkButton)['Text'])
+with self.ui_test.execute_dialog_through_command(".uno:Move") as 
xDialog:
+xOkButton = xDialog.getChild("ok")
+xCopyButton = xDialog.getChild("copy")
+xMoveButton = xDialog.getChild("move")
+self.assertEqual(get_state_as_dict(xMoveButton)['Text'], 
get_state_as_dict(xOkButton)['Text'])
+xCopyButton.executeAction("CLICK", tuple())
+self.assertEqual(get_state_as_dict(xCopyButton)['Text'], 
get_state_as_dict(xOkButton)['Text'])
+xMoveButton.executeAction("CLICK", tuple())
+self.assertEqual(get_state_as_dict(xMoveButton)['Text'], 
get_state_as_dict(xOkButton)['Text'])
+
 
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx
index 2f11fd3868b4..9d121a928fa6 100644
--- a/sc/source/ui/inc/mvtabdlg.hxx
+++ b/sc/source/ui/inc/mvtabdlg.hxx
@@ -37,6 +37,7 @@ public:
 voidGetTabNameString( OUString& rString ) const;
 voidSetForceCopyTable   ();
 voidEnableRenameTable   (bool bFlag);
+voidSetOkBtnLabel   ();
 
 private:
 void ResetRenameInput();
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx 
b/sc/source/ui/miscdlgs/mvtabdlg.cxx
index 6ec7712f87ea..80eeaeadecfa 100644
--- a/sc/source/ui/miscdlgs/mvtabdlg.cxx
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -74,6 +74,7 @@ void ScMoveTableDlg::SetForceCopyTable()
 m_xBtnCopy->set_active(true);
 m_xBtnMove->set_sensitive(false);
 m_xBtnCopy->set_sensitive(false);
+SetOkBtnLabel();
 }
 
 void ScMoveTableDlg::EnableRenameTable(bool bFlag)
@@ -185,6 +186,7 @@ void ScMoveTableDlg::Init()
 m_xBtnOk->connect_clicked(LINK(this, ScMoveTableDlg, OkHdl));
 m_xLbDoc->connect_changed(LINK(this, ScMoveTableDlg, SelHdl));
 m_xBtnCopy->connect_toggled(LINK(this, ScMoveTableDlg, CheckBtnHdl));
+m_xBtnMove->connect_toggled(LINK(this, ScMoveTableDlg, CheckBtnHdl));
 m_xEdTabName->connect_changed(LINK(this, ScMoveTableDlg, CheckNameHdl));
 m_xBtnMove->set_active(true);
 m_xBtnCopy->set_active(false);
@@ -197,6 +199,7 @@ void ScMoveTableDlg::Init()
 m_xFtDoc->hide();
 m_xLbDoc->hide();
 }
+SetOkBtnLabel();
 }
 
 void ScMoveTableDlg::InitDocListBox()
@@ -236,12 +239,20 @@ void ScMoveTableDlg::InitDocListBox()
 m_xLbDoc->set_active(nSelPos);
 }
 
+void ScMoveTableDlg::SetOkBtnLabel()
+{
+// tdf#139464 Write "Copy" or "Move" on OK button
+m_xBtnOk->set_label(m_xBtnCopy->get_active() ? m_xBtnCopy->get_label()
+ : m_xBtnMove->get_label());
+}
+
 // Handler:
 
 IMPL_LINK(ScMoveTableDlg, CheckBtnHdl, weld::Toggleable&, rBtn, void)
 {
 if ( == m_xBtnCopy.get())
 ResetRenameInput();
+SetOkBtnLabel();
 }
 
 IMPL_LINK_NOARG(ScMoveTableDlg, OkHdl, weld::Button&, void)


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

 sc/qa/uitest/calc_tests9/tdf148437.py |   53 ++
 sc/source/ui/view/tabvwshe.cxx|3 +
 2 files changed, 55 insertions(+), 1 deletion(-)

New commits:
commit 66365e9fb2105c98f7bf16152fb4910f605dae78
Author: Andreas Heinisch 
AuthorDate: Sun Apr 10 18:36:01 2022 +0200
Commit: Andreas Heinisch 
CommitDate: Thu Apr 21 10:01:25 2022 +0200

tdf#148437 - Hyperlink: Replace entire content if cell contains a formula

Inserting a hyperlink through the hyperlink dialog should replace the
content of the entire cell if it contains a formula.

Change-Id: I2e06f134bfcd21ec3fef76f2a9b80e433adce1f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132785
Tested-by: Jenkins
Tested-by: Heiko Tietze 
Reviewed-by: Heiko Tietze 

diff --git a/sc/qa/uitest/calc_tests9/tdf148437.py 
b/sc/qa/uitest/calc_tests9/tdf148437.py
new file mode 100644
index ..d457b2324892
--- /dev/null
+++ b/sc/qa/uitest/calc_tests9/tdf148437.py
@@ -0,0 +1,53 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+from uitest.framework import UITestCase
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from libreoffice.calc.document import get_cell_by_position
+from uitest.uihelper.calc import enter_text_to_cell
+from uitest.uihelper.common import get_state_as_dict, select_pos
+
+class tdf148437(UITestCase):
+def test_tdf148437_formula_cell(self):
+with self.ui_test.create_doc_in_start_center("calc") as document:
+xCalcDoc = self.xUITest.getTopFocusWindow()
+xGridWindow = xCalcDoc.getChild("grid_window")
+
+# Select a cell including a formula and insert a hyperlink
+enter_text_to_cell(xGridWindow, "A1", 
"=HYPERLINK(\"www.libreoffice.org\";\"LibreOffice\")")
+# Move focus to ensure cell is not in edit mode
+xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": 
"A2"}))
+xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": 
"A1"}))
+with 
self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog:
+xTab = xDialog.getChild("tabcontrol")
+select_pos(xTab, "0")
+
+# Text should contain the text of the cell
+xTarget = xDialog.getChild("target")
+self.assertEqual(get_state_as_dict(xTarget)["Text"], "")
+xIndication = xDialog.getChild("indication")
+self.assertEqual(get_state_as_dict(xIndication)["Text"], 
"LibreOffice")
+
+# Insert a sample hyperlink
+xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": 
"https://www.documentfoundation.org/"}))
+xIndication.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"CTRL+A"}))
+xIndication.executeAction("TYPE", mkPropertyValues({"TEXT": 
"LibreOffice Document Foundation"}))
+
+# Move focus to ensure cell is not in edit mode
+xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": 
"A2"}))
+xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": 
"A1"}))
+
+# Check contents of the cell
+xCell = get_cell_by_position(document, 0, 0, 0)
+self.assertEqual(xCell.getString(), "LibreOffice Document 
Foundation")
+xTextFields = xCell.getTextFields()
+self.assertEqual(xTextFields.getCount(), 1)
+self.assertEqual(xTextFields.getByIndex(0).URL, 
"https://www.documentfoundation.org/;)
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/ui/view/tabvwshe.cxx b/sc/source/ui/view/tabvwshe.cxx
index fa3587dd70cc..d32500b74800 100644
--- a/sc/source/ui/view/tabvwshe.cxx
+++ b/sc/source/ui/view/tabvwshe.cxx
@@ -92,7 +92,8 @@ OUString ScTabViewShell::GetSelectionText( bool bWholeWord )
 }
 
 ScImportExport aObj( rDoc, aRange );
-aObj.SetFormulas( GetViewData().GetOptions().GetOption( 
VOPT_FORMULAS ) );
+// tdf#148437 - if cell contains a formula, overwrite entire 
content of the cell
+aObj.SetFormulas(true);
 OUString aExportOUString;
 /* TODO: STRING_TSVC under some circumstances? */
 aObj.ExportString( aExportOUString, SotClipboardFormatId::STRING );


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

 sc/qa/unit/tiledrendering/tiledrendering.cxx   |4 ++--
 sc/source/filter/inc/namebuff.hxx  |2 +-
 sc/source/filter/lotus/tool.cxx|6 +++---
 sc/source/filter/xml/XMLStylesExportHelper.cxx |   13 +++--
 sc/source/filter/xml/XMLStylesExportHelper.hxx |4 ++--
 sc/source/filter/xml/xmlexprt.cxx  |4 ++--
 6 files changed, 17 insertions(+), 16 deletions(-)

New commits:
commit 00e5bf746f85edf32ab7464abec2f4fccfc46bcd
Author: Noel Grandin 
AuthorDate: Sat Apr 16 19:51:34 2022 +0200
Commit: Noel Grandin 
CommitDate: Sun Apr 17 08:45:20 2022 +0200

use more string_view in sc

Change-Id: I5f77167ad874200fa4f7bc16e5de8a3348cb1886
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133097
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 935c04d14d46..296e2703ef87 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -846,9 +846,9 @@ void ScTiledRenderingTest::testViewLock()
 CPPUNIT_ASSERT(!aView1.m_bViewLock);
 }
 
-void lcl_extractHandleParameters(const OString& selection, sal_uInt32& id, 
sal_uInt32& x, sal_uInt32& y)
+void lcl_extractHandleParameters(std::string_view selection, sal_uInt32& id, 
sal_uInt32& x, sal_uInt32& y)
 {
-OString extraInfo = selection.copy(selection.indexOf("{"));
+OString extraInfo( selection.substr(selection.find("{")) );
 std::stringstream aStream(extraInfo.getStr());
 boost::property_tree::ptree aTree;
 boost::property_tree::read_json(aStream, aTree);
diff --git a/sc/source/filter/inc/namebuff.hxx 
b/sc/source/filter/inc/namebuff.hxx
index 24ff4dc395bd..4ad7bc102c6d 100644
--- a/sc/source/filter/inc/namebuff.hxx
+++ b/sc/source/filter/inc/namebuff.hxx
@@ -100,7 +100,7 @@ public:
 voidAdd( const ScDocument& rDoc, const OUString& 
rName, const ScComplexRefData& rCRD );
 inline void Add( const ScDocument& rDoc, const OUString& 
rName, const ScRange& aScRange );
 boolFindRel( const OUString& rRef, sal_uInt16& rIndex 
);
-boolFindAbs( const OUString& rRef, sal_uInt16& rIndex 
);
+boolFindAbs( std::u16string_view rRef, sal_uInt16& 
rIndex );
 };
 
 inline void RangeNameBufferWK3::Add( const ScDocument& rDoc, const OUString& 
rName, const ScRange& aScRange )
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index a38a7286385e..c3bf46b4f8ad 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -478,11 +478,11 @@ bool RangeNameBufferWK3::FindRel( const OUString& rRef, 
sal_uInt16& rIndex )
 return false;
 }
 
-bool RangeNameBufferWK3::FindAbs( const OUString& rRef, sal_uInt16& rIndex )
+bool RangeNameBufferWK3::FindAbs( std::u16string_view rRef, sal_uInt16& rIndex 
)
 {
-if (rRef.isEmpty())
+if (rRef.empty())
 return false;
-StringHashEntry aRef(rRef.copy(1)); // search w/o '$'!
+StringHashEntry aRef(OUString(rRef.substr(1))); // search w/o '$'!
 
 std::vector::iterator itr = std::find_if(maEntries.begin(), 
maEntries.end(),
 [](const Entry& rEntry) { return aRef == rEntry.aStrHashEntry; });
diff --git a/sc/source/filter/xml/XMLStylesExportHelper.cxx 
b/sc/source/filter/xml/XMLStylesExportHelper.cxx
index 0a403ac9de98..81c30e4241e8 100644
--- a/sc/source/filter/xml/XMLStylesExportHelper.cxx
+++ b/sc/source/filter/xml/XMLStylesExportHelper.cxx
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 using namespace com::sun::star;
@@ -701,11 +702,11 @@ bool ScFormatRangeStyles::AddStyleName(OUString const & 
rString, sal_Int32& rInd
 }
 }
 
-sal_Int32 ScFormatRangeStyles::GetIndexOfStyleName(const OUString& rString, 
const OUString& rPrefix, bool& bIsAutoStyle)
+sal_Int32 ScFormatRangeStyles::GetIndexOfStyleName(std::u16string_view 
rString, const OUString& rPrefix, bool& bIsAutoStyle)
 {
 sal_Int32 nPrefixLength(rPrefix.getLength());
-OUString sTemp(rString.copy(nPrefixLength));
-sal_Int32 nIndex(sTemp.toInt32());
+std::u16string_view sTemp(rString.substr(nPrefixLength));
+sal_Int32 nIndex(o3tl::toInt32(sTemp));
 if (nIndex > 0 && o3tl::make_unsigned(nIndex-1) < aAutoStyleNames.size() 
&& aAutoStyleNames.at(nIndex - 1) == rString)
 {
 bIsAutoStyle = true;
@@ -913,11 +914,11 @@ sal_Int32 ScColumnRowStylesBase::AddStyleName(const 
OUString & rString)
 return aStyleNames.size() - 1;
 }
 
-sal_Int32 ScColumnRowStylesBase::GetIndexOfStyleName(const OUString& rString, 
const OUString& rPrefix)
+sal_Int32 ScColumnRowStylesBase::GetIndexOfStyleName(std::u16string_view 
rString, const OUString& rPrefix)
 {
 sal_Int32 nPrefixLength(rPrefix.getLength());
-OUString sTemp(rString.copy(nPrefixLength));
-sal_Int32 nIndex(sTemp.toInt32());
+ 

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

 sc/qa/uitest/calc_tests9/tdf80043.py |  243 +++
 sc/source/ui/view/cellsh.cxx |8 +
 sc/source/ui/view/tabvwshe.cxx   |   11 -
 3 files changed, 254 insertions(+), 8 deletions(-)

New commits:
commit 803c9a6f8d8681e1862e4132dbbc8cdb2f61b7b6
Author: Andreas Heinisch 
AuthorDate: Mon Mar 7 22:30:13 2022 +0100
Commit: Andreas Heinisch 
CommitDate: Thu Apr 7 11:31:28 2022 +0200

tdf#80043 - Put selected text into hyperlink item

If the user selects an entire cell by a single click, and inserts an URL
via the hyperlink dialog, the entire content of the corresponding cell
will be replaced instead of inserting a duplicate, or appending the URL.
If the cell contains more than one URL or an URL including some
additional text within the cell, the hyperlink dialog will only
preselect the text field when opening. If this is not the case, it fill the 
URL field as well.

Change-Id: I9a10c3f302a6cf91a4d9dfadfbe775075eb00fad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131156
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/sc/qa/uitest/calc_tests9/tdf80043.py 
b/sc/qa/uitest/calc_tests9/tdf80043.py
new file mode 100644
index ..eb99f0038871
--- /dev/null
+++ b/sc/qa/uitest/calc_tests9/tdf80043.py
@@ -0,0 +1,243 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+from uitest.framework import UITestCase
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from libreoffice.calc.document import get_cell_by_position
+from uitest.uihelper.calc import enter_text_to_cell
+from uitest.uihelper.common import get_state_as_dict, select_pos
+
+class tdf80043(UITestCase):
+def test_tdf80043_empty_cell(self):
+with self.ui_test.create_doc_in_start_center("calc") as document:
+xCalcDoc = self.xUITest.getTopFocusWindow()
+xGridWindow = xCalcDoc.getChild("grid_window")
+
+# Select an empty cell and insert a hyperlink
+xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": 
"A1"}))
+with 
self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog:
+xTab = xDialog.getChild("tabcontrol")
+select_pos(xTab, "0")
+
+# Both fields in the hyperlink dialog should be empty
+xTarget = xDialog.getChild("target")
+self.assertEqual(get_state_as_dict(xTarget)["Text"], "")
+xIndication = xDialog.getChild("indication")
+self.assertEqual(get_state_as_dict(xIndication)["Text"], "")
+
+# Insert a sample hyperlink
+xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": 
"http://www.libreoffice.org/"}))
+xIndication.executeAction("TYPE", mkPropertyValues({"TEXT": 
"LibreOffice"}))
+
+# Move focus to ensure cell is not in edit mode
+xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": 
"A2"}))
+xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": 
"A1"}))
+
+# Check contents of the cell
+xCell = get_cell_by_position(document, 0, 0, 0)
+self.assertEqual(xCell.getString(), "LibreOffice")
+xTextFields = xCell.getTextFields()
+self.assertEqual(xTextFields.getCount(), 1)
+self.assertEqual(xTextFields.getByIndex(0).URL, 
"http://www.libreoffice.org/;)
+
+# Reopen hyperlink dialog and check the target and the indication 
of the hyperlink
+with 
self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog", 
close_button="cancel") as xDialog:
+xTab = xDialog.getChild("tabcontrol")
+select_pos(xTab, "0")
+
+# Text should contain the text of the cell
+xTarget = xDialog.getChild("target")
+self.assertEqual(get_state_as_dict(xTarget)["Text"], 
"http://www.libreoffice.org/;)
+xIndication = xDialog.getChild("indication")
+self.assertEqual(get_state_as_dict(xIndication)["Text"], 
"LibreOffice")
+
+def test_tdf80043_text_cell(self):
+with self.ui_test.create_doc_in_start_center("calc") as document:
+xCalcDoc = self.xUITest.getTopFocusWindow()
+xGridWindow = xCalcDoc.getChild("grid_window")
+
+# Select a cell including a text and insert a hyperlink
+enter_text_to_cell(xGridWindow, "A1", "LibreOffice")
+# Move focus to ensure cell is not in edit mode
+xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": 
"A2"}))
+

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

 sc/qa/unit/data/xlsx/too-many-cols-rows.xlsx |binary
 sc/qa/unit/subsequent_filters_test2.cxx  |6 ++
 sc/source/filter/oox/excelfilter.cxx |   74 ---
 3 files changed, 19 insertions(+), 61 deletions(-)

New commits:
commit a3988b2d147a2442b348d58b79dbd6e71472b7af
Author: Luboš Luňák 
AuthorDate: Wed Mar 23 11:48:09 2022 +0100
Commit: Luboš Luňák 
CommitDate: Wed Mar 30 00:02:52 2022 +0200

handle xlsx with too large sheets the same way as e.g. ods

The generic approach sets an error code on import and then
SfxBaseModel::handleLoadError() takes care of it. This also
allows checking for the warning in unittests. A drawback is
that this generic approach can handle only one error code,
so if a sheets has too many rows and column, there will be
only one warning, but I consider that to be minor.

Change-Id: I1d5f7f9162ef63c3c2e8414823d18a1ff50ad71e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131970
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/qa/unit/data/xlsx/too-many-cols-rows.xlsx 
b/sc/qa/unit/data/xlsx/too-many-cols-rows.xlsx
new file mode 100644
index ..45ef9a11f5e8
Binary files /dev/null and b/sc/qa/unit/data/xlsx/too-many-cols-rows.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx 
b/sc/qa/unit/subsequent_filters_test2.cxx
index d54267d99e56..a5173eda727b 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -3086,6 +3086,12 @@ void ScFiltersTest2::testTooManyColsRows()
 CPPUNIT_ASSERT(xDocSh->GetErrorCode() == SCWARN_IMPORT_ROW_OVERFLOW
|| xDocSh->GetErrorCode() == SCWARN_IMPORT_COLUMN_OVERFLOW);
 xDocSh->DoClose();
+
+xDocSh = loadDoc(u"too-many-cols-rows.", FORMAT_XLSX);
+CPPUNIT_ASSERT(xDocSh.is());
+CPPUNIT_ASSERT(xDocSh->GetErrorCode() == SCWARN_IMPORT_ROW_OVERFLOW
+   || xDocSh->GetErrorCode() == SCWARN_IMPORT_COLUMN_OVERFLOW);
+xDocSh->DoClose();
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScFiltersTest2);
diff --git a/sc/source/filter/oox/excelfilter.cxx 
b/sc/source/filter/oox/excelfilter.cxx
index e5815200e063..e73e0204c50f 100644
--- a/sc/source/filter/oox/excelfilter.cxx
+++ b/sc/source/filter/oox/excelfilter.cxx
@@ -33,11 +33,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
 
 namespace oox::xls {
@@ -108,66 +103,23 @@ bool ExcelFilter::importDocument()
 WorkbookGlobalsRef xBookGlob(WorkbookHelper::constructGlobals(*this));
 if (xBookGlob)
 {
-rtl::Reference xWorkbookFragment( new 
WorkbookFragment(*xBookGlob, aWorkbookPath));
+rtl::Reference xWorkbookFragment( new 
WorkbookFragment(*xBookGlob, aWorkbookPath));
 
-const WorkbookFragment* pWF = static_cast(xWorkbookFragment.get());
-const ScDocument& rDoc = pWF->getScDocument();
-if (ScDocShell* pDocSh = 
static_cast(rDoc.GetDocumentShell()))
-pDocSh->SetInitialLinkUpdate( pDocSh->GetMedium());
+ScDocument& rDoc = xWorkbookFragment->getScDocument();
+ScDocShell* pDocSh = 
static_cast(rDoc.GetDocumentShell());
+assert( pDocSh );
+pDocSh->SetInitialLinkUpdate( pDocSh->GetMedium());
 
 bool bRet = importFragment( xWorkbookFragment);
-if (bRet)
+if (bRet && !pDocSh->GetErrorCode())
 {
-const AddressConverter& rAC = pWF->getAddressConverter();
-if (rAC.isTabOverflow() || rAC.isColOverflow() || 
rAC.isRowOverflow())
-{
-if (rDoc.IsUserInteractionEnabled())
-{
-// Show data loss warning.
-
-INetURLObject aURL( getFileUrl());
-SfxErrorContext aContext( ERRCTX_SFX_OPENDOC,
-aURL.getName( INetURLObject::LAST_SEGMENT, 
true,
-
INetURLObject::DecodeMechanism::WithCharset),
-nullptr, RID_ERRCTX);
-
-OUString aWarning;
-aContext.GetString( ERRCODE_NONE.MakeWarning(), 
aWarning);
-aWarning += ":\n";
-
-OUString aMsg;
-if (rAC.isTabOverflow())
-{
-if (ErrorHandler::GetErrorString( 
SCWARN_IMPORT_SHEET_OVERFLOW, aMsg))
-aWarning += aMsg;
-}
-if (rAC.isColOverflow())
-{
-if (!aMsg.isEmpty())
-aWarning += "\n";
-if (ErrorHandler::GetErrorString( 
SCWARN_IMPORT_COLUMN_OVERFLOW, aMsg))
-aWarning += aMsg;
-

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

 sc/qa/unit/data/xlsx/tdf147014.xlsx  |binary
 sc/qa/unit/subsequent_filters_test2.cxx  |   18 ++
 sc/source/filter/oox/worksheethelper.cxx |   24 +++-
 3 files changed, 37 insertions(+), 5 deletions(-)

New commits:
commit c5160e2151cf9d5f1fac9975caeac10f9c40158d
Author: Aron Budea 
AuthorDate: Sun Feb 13 06:57:16 2022 +0100
Commit: Aron Budea 
CommitDate: Mon Mar 28 11:26:22 2022 +0200

tdf#147014 Image missing due to integer overflow

32-bit awt::Point/Size/Rectangle cannot fit size of 1M rows with
larger (eg. 5x the usual) height, and could overflow.

This causes problems in 64-bit Linux builds and, since the
following commit, in 64-bit Windows builds:
3d90997fb6f232d8008df4d166d7b97b869c200f

For now, clamp possibly overflowing values to 32-bit.

Change-Id: Ifda7265703388abdfb47f523da4f0c5822358404
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129876
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 
Reviewed-by: Aron Budea 

diff --git a/sc/qa/unit/data/xlsx/tdf147014.xlsx 
b/sc/qa/unit/data/xlsx/tdf147014.xlsx
new file mode 100644
index ..df4428795d9d
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf147014.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx 
b/sc/qa/unit/subsequent_filters_test2.cxx
index df6bb82fa518..d54267d99e56 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -179,6 +179,7 @@ public:
 void testTdf139612();
 void testTdf144740();
 void testTdf146722();
+void testTdf147014();
 void testTdf139763ShapeAnchor();
 void testAutofilterNamedRangesXLSX();
 void testInvalidBareBiff5();
@@ -291,6 +292,7 @@ public:
 CPPUNIT_TEST(testTdf139612);
 CPPUNIT_TEST(testTdf144740);
 CPPUNIT_TEST(testTdf146722);
+CPPUNIT_TEST(testTdf147014);
 CPPUNIT_TEST(testTdf139763ShapeAnchor);
 CPPUNIT_TEST(testAutofilterNamedRangesXLSX);
 CPPUNIT_TEST(testInvalidBareBiff5);
@@ -2907,6 +2909,22 @@ void ScFiltersTest2::testTdf146722()
 xDocSh->DoClose();
 }
 
+void ScFiltersTest2::testTdf147014()
+{
+ScDocShellRef xDocSh = loadDoc(u"tdf147014.", FORMAT_XLSX);
+CPPUNIT_ASSERT_MESSAGE("Failed to load tdf147014.xlsx", xDocSh.is());
+uno::Reference xModel = xDocSh->GetModel();
+uno::Reference xDoc(xModel, 
uno::UNO_QUERY_THROW);
+uno::Reference xIA(xDoc->getSheets(), 
uno::UNO_QUERY_THROW);
+uno::Reference 
xDrawPageSupplier(xIA->getByIndex(0),
+ 
uno::UNO_QUERY_THROW);
+xIA.set(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW);
+// The sheet has a single shape, without the fix it was not imported, 
except in 32-bit builds
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Shape not imported", 
static_cast(1), xIA->getCount());
+
+xDocSh->DoClose();
+}
+
 void ScFiltersTest2::testTdf139763ShapeAnchor()
 {
 ScDocShellRef xDocSh = loadDoc(u"tdf139763ShapeAnchor.", FORMAT_XLSX);
diff --git a/sc/source/filter/oox/worksheethelper.cxx 
b/sc/source/filter/oox/worksheethelper.cxx
index 3de0547393ca..0d0aa8ce795a 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -75,6 +75,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace oox::xls {
 
@@ -95,6 +96,18 @@ void lclUpdateProgressBar( const ISegmentProgressBarRef& 
rxProgressBar, double f
 rxProgressBar->setPosition( fPosition );
 }
 
+// TODO Needed because input might be >32-bit (in 64-bit builds),
+//  or a negative, already overflown value (in 32-bit builds)
+sal_Int32 lclClampToNonNegativeInt32( tools::Long aVal )
+{
+if ( aVal > SAL_MAX_INT32 || aVal < 0 )
+{
+SAL_WARN( "sc.filter", "Overflow detected, " << aVal << " does not fit 
into sal_Int32, or is negative." );
+return SAL_MAX_INT32;
+}
+return static_cast( aVal );
+}
+
 } // namespace
 
 ColumnModel::ColumnModel() :
@@ -537,9 +550,9 @@ const awt::Size& WorksheetGlobals::getDrawPageSize() const
 
 awt::Point WorksheetGlobals::getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) 
const
 {
-awt::Point aPoint;
-PropertySet aCellProp( getCell( ScAddress( nCol, nRow, getSheetIndex() ) ) 
);
-aCellProp.getProperty( aPoint, PROP_Position );
+const tools::Rectangle aMMRect( getScDocument().GetMMRect( nCol, nRow, 
nCol, nRow, getSheetIndex() ) );
+awt::Point aPoint( lclClampToNonNegativeInt32( aMMRect.Left() ),
+   lclClampToNonNegativeInt32( aMMRect.Top() ) );
 return aPoint;
 }
 
@@ -1356,8 +1369,9 @@ void WorksheetGlobals::groupColumnsOrRows( sal_Int32 
nFirstColRow, sal_Int32 nLa
 void WorksheetGlobals::finalizeDrawings()
 {
 // calculate the current drawing page size (after rows/columns are 
imported)
-PropertySet aRangeProp( getCellRange( ScRange( 0, 0, getSheetIndex(), 
mrMaxApiPos.Col(), mrMaxApiPos.Row(), getSheetIndex() ) ) 

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

 sc/qa/unit/data/ods/too-many-cols-rows.ods |binary
 sc/qa/unit/subsequent_filters_test2.cxx|   14 ++
 sc/source/filter/xml/xmlcelli.cxx  |6 ++
 3 files changed, 20 insertions(+)

New commits:
commit a0f616070f5a344038516d7225295733fd417283
Author: Luboš Luňák 
AuthorDate: Tue Mar 22 16:46:55 2022 +0100
Commit: Luboš Luňák 
CommitDate: Tue Mar 22 17:59:28 2022 +0100

warn on too many rows/column when loading ODS

There's a warning when loading XLSX, but not when loading ODS.
Now that 7.4 is going to support 16k columns, that would be a useful
warning, either if we raise the limits again, or backported to
7.2/7.3 .

Change-Id: I204bca32e1ff37332b86361d3d81d3fee29c15ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131940
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/qa/unit/data/ods/too-many-cols-rows.ods 
b/sc/qa/unit/data/ods/too-many-cols-rows.ods
new file mode 100644
index ..fcf1a0bc9ea8
Binary files /dev/null and b/sc/qa/unit/data/ods/too-many-cols-rows.ods differ
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx 
b/sc/qa/unit/subsequent_filters_test2.cxx
index 3f89b53e5412..e8164070fd47 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -180,6 +181,7 @@ public:
 void testTdf139763ShapeAnchor();
 void testAutofilterNamedRangesXLSX();
 void testInvalidBareBiff5();
+void testTooManyColsRows();
 
 CPPUNIT_TEST_SUITE(ScFiltersTest2);
 
@@ -290,6 +292,7 @@ public:
 CPPUNIT_TEST(testTdf139763ShapeAnchor);
 CPPUNIT_TEST(testAutofilterNamedRangesXLSX);
 CPPUNIT_TEST(testInvalidBareBiff5);
+CPPUNIT_TEST(testTooManyColsRows);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -3041,6 +3044,17 @@ void ScFiltersTest2::testInvalidBareBiff5()
 xDocSh->DoClose();
 }
 
+void ScFiltersTest2::testTooManyColsRows()
+{
+// The intentionally doc has cells beyond our MAXROW/MAXCOL, so there
+// should be a warning on load.
+ScDocShellRef xDocSh = loadDoc(u"too-many-cols-rows.", FORMAT_ODS);
+CPPUNIT_ASSERT(xDocSh.is());
+CPPUNIT_ASSERT(xDocSh->GetErrorCode() == SCWARN_IMPORT_ROW_OVERFLOW
+   || xDocSh->GetErrorCode() == SCWARN_IMPORT_COLUMN_OVERFLOW);
+xDocSh->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScFiltersTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/xml/xmlcelli.cxx 
b/sc/source/filter/xml/xmlcelli.cxx
index 2a843e7f75f6..266a520e384a 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1169,7 +1169,10 @@ void ScXMLTableRowCellContext::AddTextAndValueCell( 
const ScAddress& rCellPos,
 // it makes no sense to import data after the last supported column
 // fdo#58539 & gnome#627150
 if(rCurrentPos.Col() > pDoc->MaxCol())
+{
+rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_COLUMN_OVERFLOW);
 break;
+}
 
 if (i > 0)
 rTables.AddColumn(false);
@@ -1182,7 +1185,10 @@ void ScXMLTableRowCellContext::AddTextAndValueCell( 
const ScAddress& rCellPos,
 // it makes no sense to import data after last supported row
 // fdo#58539 & gnome#627150
 if(rCurrentPos.Row() > pDoc->MaxRow())
+{
+
rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_ROW_OVERFLOW);
 break;
+}
 
 if( (rCurrentPos.Col() == 0) && (j > 0) )
 {


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

 sc/qa/extras/macros-test.cxx |   21 +
 sc/source/ui/docshell/externalrefmgr.cxx |2 +-
 2 files changed, 22 insertions(+), 1 deletion(-)

New commits:
commit 7f58df88771767962fc4e98f2b6bed445ab18994
Author: Mike Kaganski 
AuthorDate: Thu Mar 17 00:28:07 2022 +0300
Commit: Mike Kaganski 
CommitDate: Thu Mar 17 16:19:32 2022 +0100

tdf#148040: allow external link update for css.sheet.FunctionAccess

Change-Id: I2608c10fd3354e90049d1c7315895922c865a648
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131682
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx
index 0d1be3d710c7..e69feea0e8ac 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -13,12 +13,14 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
 #include 
 #include 
 
+#include 
 #include 
 
 #include 
@@ -68,6 +70,7 @@ public:
 void testMacroButtonFormControlXlsxExport();
 void testShapeLayerId();
 void testVbaRangeSort();
+void testFunctionAccessIndirect();
 
 CPPUNIT_TEST_SUITE(ScMacrosTest);
 CPPUNIT_TEST(testStarBasic);
@@ -99,6 +102,7 @@ public:
 CPPUNIT_TEST(testMacroButtonFormControlXlsxExport);
 CPPUNIT_TEST(testShapeLayerId);
 CPPUNIT_TEST(testVbaRangeSort);
+CPPUNIT_TEST(testFunctionAccessIndirect);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -1158,6 +1162,23 @@ void ScMacrosTest::testVbaRangeSort()
 pDocSh->DoClose();
 }
 
+void ScMacrosTest::testFunctionAccessIndirect()
+{
+OUString aFileName;
+createFileURL(u"tdf120161.ods", aFileName); // just some document with 
known values in cells
+const OUString aReference = "'" + aFileName + "'#$Sheet1.A1";
+
+css::uno::Reference xFunc(
+
comphelper::getProcessServiceFactory()->createInstance("com.sun.star.sheet.FunctionAccess"),
+UNO_QUERY_THROW);
+
+// tdf#148040: without the fix in plcae, this would have failed with:
+//   An uncaught exception of type 
com.sun.star.lang.IllegalArgumentException
+// because of disallowed external link update (needed to obtain the cell 
value).
+css::uno::Any aResult = xFunc->callFunction("INDIRECT", 
{css::uno::Any(aReference)});
+CPPUNIT_ASSERT_EQUAL(css::uno::Any(OUString("a1")), aResult);
+}
+
 ScMacrosTest::ScMacrosTest()
   : UnoApiTest("/sc/qa/extras/testdocuments")
 {
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx 
b/sc/source/ui/docshell/externalrefmgr.cxx
index c25a79f1f919..3d1845cbeacb 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1655,7 +1655,7 @@ bool isLinkUpdateAllowedInDoc(const ScDocument& rDoc)
 {
 SfxObjectShell* pDocShell = rDoc.GetDocumentShell();
 if (!pDocShell)
-return false;
+return rDoc.IsFunctionAccess();
 
 return pDocShell->GetEmbeddedObjectContainer().getUserAllowsLinkUpdate();
 }


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

 sc/qa/unit/data/xlsx/tdf58243.xlsx   |binary
 sc/qa/unit/subsequent_export_test2.cxx   |   11 +++
 sc/source/core/data/attarray.cxx |9 +
 sc/source/filter/inc/sheetdatabuffer.hxx |9 +++--
 sc/source/filter/oox/sheetdatabuffer.cxx |2 --
 5 files changed, 27 insertions(+), 4 deletions(-)

New commits:
commit 1fa46653315810a579009f712f2c1bbdf1f5fd44
Author: Luboš Luňák 
AuthorDate: Tue Mar 15 20:03:50 2022 +0100
Commit: Luboš Luňák 
CommitDate: Tue Mar 15 22:39:17 2022 +0100

fix comparison operators in Excel export, #2

It turns out that the end-vs-start comparison was intentional and
the file causing problems is broken, so more or less revert
83d599fd7c530d14f70ac60bd673b66640191bf7, and I'll handle
the problematic file in another commit.

Change-Id: I5c7538a7c3eeea9c5fd1661e1a9a2c3370b799c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131636
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/sc/qa/unit/data/xlsx/tdf58243.xlsx 
b/sc/qa/unit/data/xlsx/tdf58243.xlsx
new file mode 100644
index ..f95e13b4b6db
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf58243.xlsx differ
diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index 0ed29cae605c..4d22a2ffdbc6 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -185,6 +185,7 @@ public:
 void testTdf145059();
 void testTdf130104_XLSXIndent();
 void testWholeRowBold();
+void testXlsxRowsOrder();
 
 CPPUNIT_TEST_SUITE(ScExportTest2);
 
@@ -303,6 +304,7 @@ public:
 CPPUNIT_TEST(testTdf145059);
 CPPUNIT_TEST(testTdf130104_XLSXIndent);
 CPPUNIT_TEST(testWholeRowBold);
+CPPUNIT_TEST(testXlsxRowsOrder);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -3099,6 +3101,15 @@ void ScExportTest2::testWholeRowBold()
 xDocSh3->DoClose();
 }
 
+void ScExportTest2::testXlsxRowsOrder()
+{
+ScDocShellRef xDocSh = loadDoc(u"tdf58243.", FORMAT_XLSX);
+CPPUNIT_ASSERT(xDocSh.is());
+// Make sure code in SheetDataBuffer doesn't assert columns/rows sorting.
+ScBootstrapFixture::exportTo(*xDocSh, FORMAT_XLSX);
+xDocSh->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index a7ee5ff2276e..042213bda05c 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -923,6 +923,15 @@ void ScAttrArray::SetAttrEntries(std::vector 
&& vNewData)
 pDocPool->Remove(*rEntry.pPattern);
 
 mvData = std::move(vNewData);
+
+#ifdef DBG_UTIL
+SCROW lastEndRow = -1;
+for(const auto& entry : mvData)
+{   // Verify that the data is not corrupted.
+assert(entry.nEndRow > lastEndRow);
+lastEndRow = entry.nEndRow;
+}
+#endif
 }
 
 static void lcl_MergeDeep( SfxItemSet& rMergeSet, const SfxItemSet& rSource )
diff --git a/sc/source/filter/inc/sheetdatabuffer.hxx 
b/sc/source/filter/inc/sheetdatabuffer.hxx
index 0cca3f0c7c84..c212c8f0e09d 100644
--- a/sc/source/filter/inc/sheetdatabuffer.hxx
+++ b/sc/source/filter/inc/sheetdatabuffer.hxx
@@ -198,14 +198,19 @@ private:
 {
 bool operator() (const RowRangeStyle& lhs, const RowRangeStyle& rhs) 
const
 {
-return lhs.mnStartRow 
RowStyles;
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx 
b/sc/source/filter/oox/sheetdatabuffer.cxx
index 6dbec9e6bd9d..259e3190107b 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -409,8 +409,6 @@ void SheetDataBuffer::addColXfStyleProcessRowRanges()
 RowRangeStyle aStyleRows;
 aStyleRows.mnNumFmt.first = nXfId;
 aStyleRows.mnNumFmt.second = -1;
-aStyleRows.mnStartRow = rRange.mnFirst;
-aStyleRows.mnEndRow = rRange.mnLast;
 
 // Reset row range for each column
 aStyleRows.mnStartRow = rRange.mnFirst;


  1   2   3   4   5   6   >