core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-05-02 Thread Regina Henschel (via logerrit)
 sc/qa/unit/data/ods/tdf160329_sortWithHiddenRows.ods |binary
 sc/qa/unit/scshapetest.cxx   |   37 +
 sc/source/core/data/table3.cxx   |   78 +--
 3 files changed, 109 insertions(+), 6 deletions(-)

New commits:
commit 1347274fc1cb780db4c7c9b8c0272e1730b95c04
Author: Regina Henschel 
AuthorDate: Sat Apr 27 19:25:32 2024 +0200
Commit: Xisco Fauli 
CommitDate: Thu May 2 19:14:20 2024 +0200

tdf#160329 update objects after row sort is finished

The problem was that when the object position was updated to the anchor
values by recalcPos() method, the document did not yet have the new
state of the hidden rows. As a result, incorrect positions were
calculated. Therefore, the update of the position is moved to a place
after the update of the visibility of the rows.

Sorting rows must not change the visibility of objects. However, updating
the visibility of rows sets all objects to visible. Now the visibility
state of an object is saved and restored later so that the recalcPos()
method receives the correct state for the object.

Change-Id: Ia32698c1d45cd81702e6d00c5dfc100f6f6f399c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166799
Reviewed-by: Noel Grandin 
Tested-by: Noel Grandin 
(cherry picked from commit f0a2969d15e3101d7f96a7fe77bca06a5d70f57a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166903
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/unit/data/ods/tdf160329_sortWithHiddenRows.ods 
b/sc/qa/unit/data/ods/tdf160329_sortWithHiddenRows.ods
new file mode 100644
index ..5ba746ad7baa
Binary files /dev/null and 
b/sc/qa/unit/data/ods/tdf160329_sortWithHiddenRows.ods differ
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index c5b4b098c80e..2e9ed6281ce7 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -66,6 +66,14 @@ static SdrObject* lcl_getSdrObjectWithAssert(ScDocument& 
rDoc, sal_uInt16 nObjNu
 return pObj;
 }
 
+static SdrObject* lcl_getSdrObjectbyName(ScDocument& rDoc, std::u16string_view 
rName)
+{
+ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
+const SdrPage* pPage = pDrawLayer->GetPage(0);
+SdrObject* pObj = pPage->GetObjByName(rName);
+return pObj;
+}
+
 CPPUNIT_TEST_FIXTURE(ScShapeTest, testTdf144242_OpenBezier_noSwapWH)
 {
 // Shapes, which have rotation incorporated in their points, got 
erroneously width-height
@@ -1299,6 +1307,35 @@ CPPUNIT_TEST_FIXTURE(ScShapeTest, 
testTdf160369_groupshape)
 CPPUNIT_ASSERT_RECTANGLE_EQUAL_WITH_TOLERANCE(aOrigRect, aAfterRect, 1);
 }
 
+CPPUNIT_TEST_FIXTURE(ScShapeTest, testTdf160329_sortWithHiddenRows)
+{
+// Load a document, which has images anchored to cell and rows hidden
+createScDoc("ods/tdf160329_sortWithHiddenRows.ods");
+ScDocument* pDoc = getScDoc();
+
+// Sort the rows
+uno::Sequence aArgs1
+= { comphelper::makePropertyValue("DbName", u"myRange"_ustr) };
+dispatchCommand(mxComponent, ".uno:SelectDB", aArgs1);
+uno::Sequence aArgs2
+= { comphelper::makePropertyValue("ByRows", true),
+comphelper::makePropertyValue("HasHeader", true),
+comphelper::makePropertyValue("Col1", sal_Int32(1)),
+comphelper::makePropertyValue("Ascending1", false),
+comphelper::makePropertyValue("IncludeImages", true) };
+dispatchCommand(mxComponent, ".uno:DataSort", aArgs2);
+
+// Make sure objects are on correct position
+SdrObject* pObj = lcl_getSdrObjectbyName(*pDoc, 
std::u16string_view(u"ImageD"));
+Point aPos = pObj->GetSnapRect().TopLeft();
+// The position was (3000|2899) without fix.
+CPPUNIT_ASSERT_POINT_EQUAL_WITH_TOLERANCE(Point(3000, 5898), aPos, 1);
+pObj = lcl_getSdrObjectbyName(*pDoc, std::u16string_view(u"ImageE"));
+aPos = pObj->GetSnapRect().TopLeft();
+// The position was (2600|2499) without fix.
+CPPUNIT_ASSERT_POINT_EQUAL_WITH_TOLERANCE(Point(2600, 4399), aPos, 1);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 359cc5dcc4f5..51212966615f 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1084,6 +1084,50 @@ void ScTable::SortReorderByColumn(
 }
 }
 
+static void backupObjectsVisibility(const 
std::vector>& rSortedCols,
+
std::vector>>& rBackup)
+{
+size_t nSortedCols = rSortedCols.size();
+for (size_t iCol = 0; iCol < nSortedCols; ++iCol)
+{
+std::vector>& rSingleColCellDrawObjects
+= rSortedCols[iCol]->maCellDrawObjects;
+size_t nSingleColCellDrawObjects = rSingleColCellDrawObjects.size();
+std::vector> aColBackup;
+for (size_t jRow = 0; jRow < nSingleColCellDrawObjects; ++jRow)
+{
+ 

core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-04-29 Thread Andreas Heinisch (via logerrit)
 sc/qa/uitest/pasteSpecial/tdf160765.py |   34 +
 sc/source/ui/miscdlgs/inscodlg.cxx |4 ++-
 2 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit 30524d5998d38b7e216b721859c72fbfc56a5b5a
Author: Andreas Heinisch 
AuthorDate: Fri Apr 26 20:29:53 2024 +0200
Commit: Xisco Fauli 
CommitDate: Mon Apr 29 21:12:47 2024 +0200

tdf#160765 - Paste Special Dialog: Remember comments checkbox

After the change of tdf#139858 the comments checkbox was not remembered 
anymore after closing the dialog. In order to fix this issue, additionally 
check not only the NOTE flag but also for the ADDNOTES one.

Change-Id: I8b24d231313b57a05b7e527c0865686762e5a2b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166762
Reviewed-by: Andreas Heinisch 
Tested-by: Jenkins
(cherry picked from commit 7e30434655754277bfa7ce7d8ec37b07181d2c92)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166838
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/uitest/pasteSpecial/tdf160765.py 
b/sc/qa/uitest/pasteSpecial/tdf160765.py
index 0b56be4c2dfa..c0c264432ef4 100755
--- a/sc/qa/uitest/pasteSpecial/tdf160765.py
+++ b/sc/qa/uitest/pasteSpecial/tdf160765.py
@@ -13,8 +13,42 @@ 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
+from uitest.uihelper.common import get_state_as_dict
 
 class tdf160765(UITestCase):
+def test_tdf160765_paste_special_comments_checked(self):
+with self.ui_test.create_doc_in_start_center("calc"):
+xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window")
+
+# Insert a comment in cell A1
+xGridWin.executeAction("SELECT", mkPropertyValues({"CELL":"A1"}))
+xArgs = mkPropertyValues({"Text": "Comment 1"})
+self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", 
xArgs)
+
+# Copy cell A1 to clipboard
+xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
+self.xUITest.executeCommand(".uno:Copy")
+
+# Paste data using special options (check only comments)
+xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"}))
+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())
+
+with 
self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") as 
xPasteSpecialDlg:
+xCommentsChkBox = xPasteSpecialDlg.getChild("comments")
+# Without the fix in place, this test would have failed with
+# AssertionError: 'true' != 'false'
+# i.e., the comments checkbox was not remembered
+
self.assertEqual(get_state_as_dict(xCommentsChkBox)["Selected"], "true")
+
 def test_tdf160765_undo_paste_comment(self):
 with self.ui_test.create_doc_in_start_center("calc") as document:
 xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window")
diff --git a/sc/source/ui/miscdlgs/inscodlg.cxx 
b/sc/source/ui/miscdlgs/inscodlg.cxx
index 84292dcd91c4..378b10f37fd0 100644
--- a/sc/source/ui/miscdlgs/inscodlg.cxx
+++ b/sc/source/ui/miscdlgs/inscodlg.cxx
@@ -231,7 +231,9 @@ void ScInsertContentsDlg::SetInsContentsCmdBits(const 
InsertDeleteFlags eFlags)
 mxBtnInsNumbers->set_active((InsertDeleteFlags::VALUE & eFlags) == 
InsertDeleteFlags::VALUE);
 mxBtnInsDateTime->set_active((InsertDeleteFlags::DATETIME & eFlags) == 
InsertDeleteFlags::DATETIME);
 mxBtnInsStrings->set_active((InsertDeleteFlags::STRING & eFlags) == 
InsertDeleteFlags::STRING);
-mxBtnInsNotes->set_active((InsertDeleteFlags::NOTE & eFlags) == 
InsertDeleteFlags::NOTE);
+// tdf#160765 - additionally check either NOTE or ADDNOTES
+mxBtnInsNotes->set_active(((InsertDeleteFlags::NOTE | 
InsertDeleteFlags::ADDNOTES) & eFlags)
+  != InsertDeleteFlags::NONE);
 mxBtnInsFormulas->set_active((InsertDeleteFlags::FORMULA & eFlags) == 
InsertDeleteFlags::FORMULA);
 mxBtnInsAttrs->set_active((InsertDeleteFlags::ATTRIB & eFlags) == 
InsertDeleteFlags::ATTRIB);
 mxBtnInsObjects->set_active((InsertDeleteFlags::OBJECTS & eFlags) == 

core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-04-25 Thread Andreas Heinisch (via logerrit)
 sc/qa/uitest/pasteSpecial/tdf160765.py |   75 +
 sc/source/ui/view/viewfun3.cxx |3 -
 2 files changed, 77 insertions(+), 1 deletion(-)

New commits:
commit 7e2e1d7fd4531f57bbc30a0a8e1cb8c40519a349
Author: Andreas Heinisch 
AuthorDate: Mon Apr 22 20:06:50 2024 +0200
Commit: Xisco Fauli 
CommitDate: Thu Apr 25 16:22:56 2024 +0200

tdf#160765 - Save content for undo when pasting notes

even if no content was changed after pasting special. Otherwise, the undo 
functionality crashes due to undoing a cell with no content where the 
annotation indicator will remain (unod/redo of note captions are handled via 
drawing undo).

Change-Id: I7007fce510d6e9896cbda11a1e14a61b5ccb34a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166469
Tested-by: Jenkins
Reviewed-by: Stéphane Guillou 
Reviewed-by: Andreas Heinisch 
(cherry picked from commit a1694b194c2b3e89250c5b79a69e7dd184b69976)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166523
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/uitest/pasteSpecial/tdf160765.py 
b/sc/qa/uitest/pasteSpecial/tdf160765.py
new file mode 100755
index ..0b56be4c2dfa
--- /dev/null
+++ b/sc/qa/uitest/pasteSpecial/tdf160765.py
@@ -0,0 +1,75 @@
+# -*- 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 tdf160765(UITestCase):
+def test_tdf160765_undo_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())
+
+# Undo both inserted comments
+self.xUITest.executeCommand(".uno:Undo")
+# Without the fix in place, this test would have failed with
+# AssertionError: 'Comment 1' != ''
+# i.e., the cell does not contain any comment
+self.assertEqual("Comment 1", get_cell_by_position(document, 0, 1, 
0).Annotation.String)
+self.xUITest.executeCommand(".uno:Undo")
+self.assertEqual("", get_cell_by_position(document, 0, 0, 
0).Annotation.String)
+
+# Redo both inserted comments
+self.xUITest.executeCommand(".uno:Redo")
+# Without the fix in place, this test would have failed with
+# AssertionError: 'Comment 2' != ''
+# i.e., the cell does not contain the restored comment
+self.assertEqual("Comment 2", get_cell_by_position(document, 0, 0, 
0).Annotation.String)
+self.xUITest.executeCommand(".uno:Redo")
+

core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-04-08 Thread Regina Henschel (via logerrit)
 sc/qa/unit/data/ods/tdf160369_groupshape.ods |binary
 sc/qa/unit/scshapetest.cxx   |   68 +++
 sc/source/core/data/drwlayer.cxx |4 +
 sc/source/filter/xml/xmlexprt.cxx|   41 +++-
 4 files changed, 100 insertions(+), 13 deletions(-)

New commits:
commit 4e04b442e037a2f679b4cfe26c3e6b1c66ee8642
Author: Regina Henschel 
AuthorDate: Sat Apr 6 14:59:38 2024 +0200
Commit: Xisco Fauli 
CommitDate: Mon Apr 8 17:31:42 2024 +0200

tdf#160369 Do not broadcast temporarily group change

The position and size of a group needs to be temporarily changed when
saving because ODF does not treat hidden rows/cols as zero, but LO does.
After saving, these changes have to be undone. The error was that the
restore was performed with GetGeoDate/SetGeoData. But SetGeoData
includes a broadcast that triggeres recalculations that should not be
performed here. Now the change and restore are both done with NbcMove
and NbcResize.

The import had set a 'logical rectangle', but that is nonsense for a
group, because a group does not have a 'logical rectangle'.
For a group, none of the special corrections in
ScDrawLayer::InitializeCellAnchoredObj are needed.

Change-Id: I00adf39e8302492822d2900e41242d188e84
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165872
Tested-by: Jenkins
Reviewed-by: Regina Henschel 
(cherry picked from commit 1e1b1d46155163380252093d9d2868351236ce0e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165839
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/unit/data/ods/tdf160369_groupshape.ods 
b/sc/qa/unit/data/ods/tdf160369_groupshape.ods
new file mode 100644
index ..8c26fe8ce582
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf160369_groupshape.ods differ
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index 5e4827005388..c5b4b098c80e 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -1231,6 +1231,74 @@ CPPUNIT_TEST_FIXTURE(ScShapeTest, 
testTdf160003_copy_page_anchored)
 CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount());
 }
 
+CPPUNIT_TEST_FIXTURE(ScShapeTest, testTdf160369_groupshape)
+{
+// The document contains a group spanning range C5:F12. It is currently 
anchored to page to
+// make sure its position does not change. When the group was anchored 'To 
Cell' and rows or
+// columns were hidden before the group, saving changed the anchor 
position and anchor
+// offset. This happened both with using 'resize with cell' and not.
+createScDoc("ods/tdf160369_groupshape.ods");
+
+// Get document and group object
+ScDocument* pDoc = getScDoc();
+SdrObject* pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
+
+// Anchor group 'To Cell (resize with cell)' to prepare the test.
+ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, 0 /*SCTAB*/, true 
/*bResizeWithCell*/);
+
+// Hide rows 3 and 4 (UI number), which are before the group
+// Hide column D, which is inside the group
+pDoc->SetRowHidden(2, 3, 0, true);
+pDoc->SetDrawPageSize(0); // trigger recalcpos, otherwise shapes are not 
changed
+pDoc->SetColHidden(3, 3, 0, true);
+pDoc->SetDrawPageSize(0);
+
+// Get geometry of the group
+ScDrawObjData* pObjData = ScDrawLayer::GetObjData(pObj);
+ScAddress aOrigStart = (*pObjData).maStart;
+ScAddress aOrigEnd = (*pObjData).maEnd;
+tools::Rectangle aOrigRect = pObj->GetSnapRect();
+
+// Save document but do not reload. Saving alone had already caused the 
error.
+save("calc8");
+
+// Get geometry of the group again
+ScDrawObjData* pAfterObjData = ScDrawLayer::GetObjData(pObj);
+ScAddress aAfterStart = (*pAfterObjData).maStart;
+ScAddress aAfterEnd = (*pAfterObjData).maEnd;
+tools::Rectangle aAfterRect = pObj->GetSnapRect();
+
+// verify Orig equals After
+CPPUNIT_ASSERT_EQUAL(aOrigStart, aAfterStart);
+CPPUNIT_ASSERT_EQUAL(aOrigEnd, aAfterEnd);
+CPPUNIT_ASSERT_RECTANGLE_EQUAL_WITH_TOLERANCE(aOrigRect, aAfterRect, 1);
+
+// The same but with saveAndReload.
+createScDoc("ods/tdf160369_groupshape.ods");
+pDoc = getScDoc();
+pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
+ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *pDoc, 0 /*SCTAB*/, true 
/*bResizeWithCell*/);
+pDoc->SetRowHidden(2, 3, 0, true);
+pDoc->SetDrawPageSize(0); // trigger recalcpos, otherwise shapes are not 
changed
+pDoc->SetColHidden(3, 3, 0, true);
+pDoc->SetDrawPageSize(0);
+
+saveAndReload("calc8");
+
+// Verify geometry is same as before save
+pDoc = getScDoc();
+pObj = lcl_getSdrObjectWithAssert(*pDoc, 0);
+pAfterObjData = ScDrawLayer::GetObjData(pObj);
+aAfterStart = (*pAfterObjData).maStart;
+aAfterEnd = (*pAfterObjData).maEnd;
+aAfterRect = pObj->GetSnapRect();
+
+// verify Orig equals After
+

core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-03-07 Thread Laurent Balland (via logerrit)
 sc/qa/uitest/data/tdf129701.ods|binary
 sc/qa/uitest/pasteSpecial/tdf129701-PasteUnformated.py |   70 +
 sc/source/ui/docshell/impex.cxx|   19 +++-
 3 files changed, 86 insertions(+), 3 deletions(-)

New commits:
commit 60e0ebe633b1dee8bb2a66b9d133f5303749d8d5
Author: Laurent Balland 
AuthorDate: Thu Dec 7 19:38:54 2023 +0100
Commit: Christian Lohmaier 
CommitDate: Thu Mar 7 11:59:46 2024 +0100

tdf#129701 Skip empty cell: treat last column

When pasting data as text, with "Skip empty cells" not checked, empty
cells in the last column of the source do not empty cells in
destination, because there is nothing anymore to paste and while loop
stops.
This commit adds a flag to check if the last cell of each line is empty,
and treat it if "Skip empty cells" is not checked.

Add UITest to Copy data with empty cells;
Paste Unformatted text, without "Skip empty cells";
Check data with empty cells in last column.

Change-Id: Idec823fb1c27b803f49c6d13d6c757ef0f41e437
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160951
Tested-by: Jenkins
Reviewed-by: Laurent Balland 
(cherry picked from commit e66ffda7c7f1e78dbca082ff7549ded121dc7356)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163536
Reviewed-by: Christian Lohmaier 

diff --git a/sc/qa/uitest/data/tdf129701.ods b/sc/qa/uitest/data/tdf129701.ods
new file mode 100644
index ..94407fcd566e
Binary files /dev/null and b/sc/qa/uitest/data/tdf129701.ods differ
diff --git a/sc/qa/uitest/pasteSpecial/tdf129701-PasteUnformated.py 
b/sc/qa/uitest/pasteSpecial/tdf129701-PasteUnformated.py
new file mode 100644
index ..596cd62f8bc1
--- /dev/null
+++ b/sc/qa/uitest/pasteSpecial/tdf129701-PasteUnformated.py
@@ -0,0 +1,70 @@
+# -*- 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
+from uitest.uihelper.common import get_state_as_dict
+from libreoffice.calc.document import get_cell_by_position
+
+class tdf129701(UITestCase):
+
+def test_tdf129701(self):
+
+with self.ui_test.load_file(get_url_for_data_file("tdf129701.ods")):
+xCalcDoc = self.xUITest.getTopFocusWindow()
+gridwin = xCalcDoc.getChild("grid_window")
+gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": 
"D21:F25"}))
+self.xUITest.executeCommand(".uno:Copy")
+
+gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "J4"}))
+with 
self.ui_test.execute_dialog_through_command(".uno:PasteUnformatted", 
close_button="ok") as xDialog:
+
+xSkipEmtyCells   = xDialog.getChild("skipemptycells")
+xSeparatedBy = xDialog.getChild("toseparatedby")
+xTab = xDialog.getChild("tab")
+xMergeDelimiters = xDialog.getChild("mergedelimiters")
+
+xSeparatedBy.executeAction("CLICK", tuple())
+if get_state_as_dict(xTab)['Selected'] == 'false':
+xTab.executeAction("CLICK", tuple())
+if get_state_as_dict(xMergeDelimiters)['Selected'] == 'true':
+xMergeDelimiters.executeAction("CLICK", tuple())
+if get_state_as_dict(xSkipEmtyCells)['Selected'] == 'true':
+xSkipEmtyCells.executeAction("CLICK", tuple())
+# Check wether Skip empty cells is unselected
+self.assertEqual('false', 
get_state_as_dict(xSkipEmtyCells)['Selected'])
+
+document = self.ui_test.get_component()
+# Without the fix in place, this test would have failed with
+# non empty cells in column 11
+
+self.assertEqual( "x1", get_cell_by_position(document, 0, 9, 
3).getString())
+self.assertEqual( ""  , get_cell_by_position(document, 0,10, 
3).getString())
+self.assertEqual( ""  , get_cell_by_position(document, 0,11, 
3).getString())
+self.assertEqual("A16", get_cell_by_position(document, 0,12, 
3).getString())
+self.assertEqual( ""  , get_cell_by_position(document, 0, 9, 
4).getString())
+self.assertEqual( "x2", get_cell_by_position(document, 0,10, 
4).getString())
+self.assertEqual( ""  , get_cell_by_position(document, 0,11, 
4).getString())
+self.assertEqual("A17", get_cell_by_position(document, 0,12, 
4).getString())
+self.assertEqual( ""  , get_cell_by_position(document, 0, 9, 
5).getString())
+

core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-03-05 Thread Miklos Vajna (via logerrit)
 sc/qa/filter/html/html.cxx|   26 ++
 sc/source/filter/html/htmlexp.cxx |9 +
 2 files changed, 35 insertions(+)

New commits:
commit 172931eccfc3469e3dc05737d6290fbdf2a957b4
Author: Miklos Vajna 
AuthorDate: Mon Mar 4 15:00:51 2024 +0100
Commit: Xisco Fauli 
CommitDate: Tue Mar 5 09:29:15 2024 +0100

tdf#159483 sc HTML copy: handle data-sheets-formula attribute

When a formula cell gets copied from Calc to google docs, only the
formula result was copied, not the formula.

There is a data-sheets-formula attribute on  that can describe the
formula we have.

Fix the problem by extending ScHTMLExport::WriteCell() to emit that.

This is more or less the export equivalent of commit
7812adb2ed11a3e08be24d3f2f94d14bfd740c55 (tdf#159483 sc HTML paste:
handle data-sheets-formula attribute, 2024-02-12).

Change-Id: Iab373ce8a028deb6a2874a8c690e928edf5d79f4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164363
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins
(cherry picked from commit 2efe362c99a9fa6e9a71b9b675b025c64b6c7f9d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164375
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/filter/html/html.cxx b/sc/qa/filter/html/html.cxx
index 916dd23981ec..391806be0333 100644
--- a/sc/qa/filter/html/html.cxx
+++ b/sc/qa/filter/html/html.cxx
@@ -276,6 +276,32 @@ CPPUNIT_TEST_FIXTURE(Test, testCopyFormattedNumber)
 assertXPath(pHtmlDoc, "(//td)[2]"_ostr, "data-sheets-numberformat"_ostr,
 "{ \"1\": 2, \"2\": \"#,##0.00\", \"3\": 1}");
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testCopyFormula)
+{
+// Given a document with a formula in A3:
+createScDoc();
+ScDocument* pDoc = getScDoc();
+ScAddress aCellPos1(/*nColP=*/0, /*nRowP=*/0, /*nTabP=*/0);
+pDoc->SetString(aCellPos1, "1000");
+ScAddress aCellPos2(/*nColP=*/0, /*nRowP=*/1, /*nTabP=*/0);
+pDoc->SetString(aCellPos2, "2000");
+ScAddress aCellPos3(/*nColP=*/0, /*nRowP=*/2, /*nTabP=*/0);
+pDoc->SetFormula(aCellPos3, "=SUM(A1:A2)", pDoc->GetGrammar());
+
+// When copying those cells:
+ScImportExport aExporter(*pDoc, ScRange(aCellPos1, aCellPos3));
+SvMemoryStream aStream;
+CPPUNIT_ASSERT(aExporter.ExportStream(aStream, OUString(), 
SotClipboardFormatId::HTML));
+
+// Then make sure the formula is exported in A3:
+aStream.Seek(0);
+htmlDocUniquePtr pHtmlDoc = parseHtmlStream();
+// Without the accompanying fix in place, this test would have failed with:
+// - XPath '(//td)[3]' no attribute 'data-sheets-formula' exist
+// i.e. only the formula result was exported, not the formula.
+assertXPath(pHtmlDoc, "(//td)[3]"_ostr, "data-sheets-formula"_ostr, 
"=SUM(R[-2]C:R[-1]C)");
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/html/htmlexp.cxx 
b/sc/source/filter/html/htmlexp.cxx
index c2554b7612f1..4413d668b428 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -1172,6 +1172,15 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& 
rBlockPos, SCCOL nCol, SC
 }
 }
 }
+
+if (aCell.getType() == CELLTYPE_FORMULA)
+{
+// If it's a formula, then also emit that, grammar is R1C1 
reference style.
+OUString aFormula = aCell.getFormula()->GetFormula(
+formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
+aStrTD.append(" " OOO_STRING_SVTOOLS_HTML_O_DSformula "=\""
++ HTMLOutFuncs::ConvertStringToHTML(aFormula) + "\"");
+}
 }
 else
 {


core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-03-04 Thread Regina Henschel (via logerrit)
 sc/qa/unit/data/ods/tdf160003_page_anchored_object.ods |binary
 sc/qa/unit/scshapetest.cxx |   24 +
 sc/source/core/data/drwlayer.cxx   |2 -
 3 files changed, 25 insertions(+), 1 deletion(-)

New commits:
commit 5ad993b4167fb93f565dc1bce6eb1057e60f62f3
Author: Regina Henschel 
AuthorDate: Sun Mar 3 17:19:49 2024 +0100
Commit: Xisco Fauli 
CommitDate: Mon Mar 4 22:02:55 2024 +0100

tdf#160003 use correct sheet in clipboard for test

..whether a page anchored object is contained in the to be copied area.

Change-Id: I816e342770332e6d751b57a38e5ebabe33feb16a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164307
Tested-by: Jenkins
Reviewed-by: Regina Henschel 
(cherry picked from commit 199523b553957936dc31b8c3556ef2e47c6bc3a1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164373
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/unit/data/ods/tdf160003_page_anchored_object.ods 
b/sc/qa/unit/data/ods/tdf160003_page_anchored_object.ods
new file mode 100644
index ..565eb1bf6a26
Binary files /dev/null and 
b/sc/qa/unit/data/ods/tdf160003_page_anchored_object.ods differ
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index b5083544f114..5e4827005388 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -1207,6 +1207,30 @@ CPPUNIT_TEST_FIXTURE(ScShapeTest, 
testTdf154821_shape_in_group)
 CPPUNIT_ASSERT_RECTANGLE_EQUAL_WITH_TOLERANCE(aRectOrig, aRectReload, 1);
 }
 
+CPPUNIT_TEST_FIXTURE(ScShapeTest, testTdf160003_copy_page_anchored)
+{
+// Load a document, which has a chart anchored to page on sheet2. 
Copy to other document
+// had lost the chart object.
+createScDoc("ods/tdf160003_page_anchored_object.ods");
+
+// copy range with chart
+goToCell("$Sheet2.$A$1:$L$24");
+dispatchCommand(mxComponent, ".uno:Copy", {});
+
+// close document and create new one
+createScDoc();
+
+// paste clipboard
+goToCell("$Sheet1.$A$1");
+dispatchCommand(mxComponent, ".uno:Paste", {});
+
+// Make sure the chart object exists.
+ScDocument* pDoc = getScDoc();
+ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+const SdrPage* pPage = pDrawLayer->GetPage(0);
+CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount());
+}
+
 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 3f98fc770a6b..25dfc5c7d6cc 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -1990,7 +1990,7 @@ void ScDrawLayer::CopyFromClip(ScDrawLayer* pClipModel, 
SCTAB nSourceTab,
 }
 else // Object is anchored to page.
 {
-aSrcObjStart = pClipDoc->GetRange(nClipTab, 
pOldObject->GetCurrentBoundRect()).aStart;
+aSrcObjStart = pClipDoc->GetRange(nSourceTab, 
pOldObject->GetCurrentBoundRect()).aStart;
 }
 if (!rSourceRange.Contains(aSrcObjStart))
 {


core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-03-04 Thread Miklos Vajna (via logerrit)
 sc/qa/filter/html/html.cxx|   37 +
 sc/source/filter/html/htmlexp.cxx |   22 ++
 2 files changed, 59 insertions(+)

New commits:
commit 69f4c84a5183d1a76ada9a8ed19de43b09130792
Author: Miklos Vajna 
AuthorDate: Fri Mar 1 14:14:33 2024 +0100
Commit: Xisco Fauli 
CommitDate: Mon Mar 4 16:08:45 2024 +0100

tdf#159483 sc HTML copy: handle data-sheets-value attribute for the num case

Type 1000 and 2000 into cells in Calc, format them as e.g. a HUF
currency, the resulting formatted strings can be copied to google
sheets, but the SUM() on them will be 0 (and not 3000).

Our own import knows how to read metadata to get the original float
value, but our exporter didn't emit these.

Fix the problem by adding support for non-boolean float values + number
formats in the HTML export.

This is more or less export equivalent of commit
789964785a61daab5f8065f006dd7aaf843c7236 (tdf#159483 sc HTML import:
handle data-sheets-value attribute for the num case, 2024-02-09).

Change-Id: I5acb3724367ce38bd96056dbe4f846cd7bbc5fe2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164213
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
(cherry picked from commit 17581e684ca701bfd96ed2bf16aa14c3903b74d4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164278
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/filter/html/html.cxx b/sc/qa/filter/html/html.cxx
index fb9a436c72a0..916dd23981ec 100644
--- a/sc/qa/filter/html/html.cxx
+++ b/sc/qa/filter/html/html.cxx
@@ -239,6 +239,43 @@ CPPUNIT_TEST_FIXTURE(Test, testCopyBoolean)
 assertXPath(pHtmlDoc, "(//td)[1]"_ostr, "data-sheets-value"_ostr, "{ 
\"1\": 4, \"4\": 1}");
 assertXPath(pHtmlDoc, "(//td)[2]"_ostr, "data-sheets-value"_ostr, "{ 
\"1\": 4, \"4\": 0}");
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testCopyFormattedNumber)
+{
+// Given a document with formatted numbers in A1-A2:
+createScDoc();
+ScDocument* pDoc = getScDoc();
+sal_Int32 nCheckPos;
+SvNumFormatType nType;
+sal_uInt32 nFormat;
+OUString aNumberFormat("#,##0.00");
+SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+pFormatter->PutEntry(aNumberFormat, nCheckPos, nType, nFormat);
+ScAddress aCellPos1(/*nColP=*/0, /*nRowP=*/0, /*nTabP=*/0);
+pDoc->SetNumberFormat(aCellPos1, nFormat);
+pDoc->SetString(aCellPos1, "1000");
+ScAddress aCellPos2(/*nColP=*/0, /*nRowP=*/1, /*nTabP=*/0);
+pDoc->SetNumberFormat(aCellPos2, nFormat);
+pDoc->SetString(aCellPos2, "2000");
+
+// When copying those values:
+ScImportExport aExporter(*pDoc, ScRange(aCellPos1, aCellPos2));
+SvMemoryStream aStream;
+CPPUNIT_ASSERT(aExporter.ExportStream(aStream, OUString(), 
SotClipboardFormatId::HTML));
+
+// Then make sure the values are numbers:
+aStream.Seek(0);
+htmlDocUniquePtr pHtmlDoc = parseHtmlStream();
+// Without the accompanying fix in place, this test would have failed with:
+// - XPath '(//td)[1]' no attribute 'data-sheets-value' exist
+// i.e. only a formatted number string was written, without a float value.
+assertXPath(pHtmlDoc, "(//td)[1]"_ostr, "data-sheets-value"_ostr, "{ 
\"1\": 3, \"3\": 1000}");
+assertXPath(pHtmlDoc, "(//td)[1]"_ostr, "data-sheets-numberformat"_ostr,
+"{ \"1\": 2, \"2\": \"#,##0.00\", \"3\": 1}");
+assertXPath(pHtmlDoc, "(//td)[2]"_ostr, "data-sheets-value"_ostr, "{ 
\"1\": 3, \"3\": 2000}");
+assertXPath(pHtmlDoc, "(//td)[2]"_ostr, "data-sheets-numberformat"_ostr,
+"{ \"1\": 2, \"2\": \"#,##0.00\", \"3\": 1}");
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/html/htmlexp.cxx 
b/sc/source/filter/html/htmlexp.cxx
index 1e5dcf24b6c5..c2554b7612f1 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -1146,6 +1146,7 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& 
rBlockPos, SCCOL nCol, SC
 nFormat, *pFormatter, ));
 
 std::optional oJson;
+const SvNumberformat* pNumberFormat = nullptr;
 if (bValueData)
 {
 if (nFormat)
@@ -1161,6 +1162,14 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& 
rBlockPos, SCCOL nCol, SC
 oJson->put("1", static_cast(4));
 oJson->put("4", static_cast(fVal));
 }
+else
+{
+// 3 is number.
+oJson.emplace();
+oJson->put("1", static_cast(3));
+oJson->put("3", static_cast(fVal));
+pNumberFormat = pFormatEntry;
+}
 }
 }
 }
@@ -1179,6 +1188,19 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& 
rBlockPos, SCCOL nCol, SC
   + HTMLOutFuncs::ConvertStringToHTML(aJsonString) + "\"");
 }
 
+if (pNumberFormat)
+{
+// 

core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-02-21 Thread Miklos Vajna (via logerrit)
 sc/qa/filter/html/html.cxx|   25 +
 sc/source/filter/html/htmlexp.cxx |   35 ++-
 2 files changed, 55 insertions(+), 5 deletions(-)

New commits:
commit fd83dcf65fdc3ad41781ee30cf6f0777feb7e3bf
Author: Miklos Vajna 
AuthorDate: Thu Feb 15 08:09:51 2024 +0100
Commit: Xisco Fauli 
CommitDate: Wed Feb 21 21:20:10 2024 +0100

tdf#159483 sc HTML copy: handle data-sheets-value attribute for the bool 
case

Similar to commit f8c95cf93ce9ab8b9b78f3af03411d0cc2e195ba (tdf#159483
sc HTML import: handle data-sheets-value attribute for the bool case,
2024-02-08).

Change-Id: I25ce8c81bd906ac0fb912e125e061516a604e786
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163419
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins
(cherry picked from commit 411158832462b1077a8f5dc6379f2056f2338249)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163405
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/filter/html/html.cxx b/sc/qa/filter/html/html.cxx
index e0d7977c8000..fb9a436c72a0 100644
--- a/sc/qa/filter/html/html.cxx
+++ b/sc/qa/filter/html/html.cxx
@@ -214,6 +214,31 @@ CPPUNIT_TEST_FIXTURE(Test, testCopyText)
 htmlDocUniquePtr pHtmlDoc = parseHtmlStream();
 assertXPath(pHtmlDoc, "//td"_ostr, "data-sheets-value"_ostr, "{ \"1\": 2, 
\"2\": \"01\"}");
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testCopyBoolean)
+{
+// Given a document with boolean values in A1-A2:
+createScDoc();
+ScDocument* pDoc = getScDoc();
+ScAddress aCellPos1(/*nColP=*/0, /*nRowP=*/0, /*nTabP=*/0);
+pDoc->SetString(aCellPos1, "TRUE");
+ScAddress aCellPos2(/*nColP=*/0, /*nRowP=*/1, /*nTabP=*/0);
+pDoc->SetString(aCellPos2, "FALSE");
+
+// When copying those values:
+ScImportExport aExporter(*pDoc, ScRange(aCellPos1, aCellPos2));
+SvMemoryStream aStream;
+CPPUNIT_ASSERT(aExporter.ExportStream(aStream, OUString(), 
SotClipboardFormatId::HTML));
+
+// Then make sure the values are booleans:
+aStream.Seek(0);
+htmlDocUniquePtr pHtmlDoc = parseHtmlStream();
+// Without the accompanying fix in place, this test would have failed with:
+// - XPath '//td' no attribute 'data-sheets-value' exist
+// i.e. metadata was missing to avoid converting TRUE to text.
+assertXPath(pHtmlDoc, "(//td)[1]"_ostr, "data-sheets-value"_ostr, "{ 
\"1\": 4, \"4\": 1}");
+assertXPath(pHtmlDoc, "(//td)[2]"_ostr, "data-sheets-value"_ostr, "{ 
\"1\": 4, \"4\": 0}");
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/html/htmlexp.cxx 
b/sc/source/filter/html/htmlexp.cxx
index a2f14f6eff43..1e5dcf24b6c5 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -88,6 +88,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 using ::editeng::SvxBorderLine;
 using namespace ::com::sun::star;
@@ -1143,13 +1145,36 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& 
rBlockPos, SCCOL nCol, SC
 aStrTD.append(HTMLOutFuncs::CreateTableDataOptionsValNum(bValueData, fVal,
 nFormat, *pFormatter, ));
 
-if (!bValueData)
+std::optional oJson;
+if (bValueData)
+{
+if (nFormat)
+{
+const SvNumberformat* pFormatEntry = pFormatter->GetEntry(nFormat);
+if (pFormatEntry)
+{
+OUString aNumStr = pFormatEntry->GetFormatstring();
+if (aNumStr == "BOOLEAN")
+{
+// 4 is boolean.
+oJson.emplace();
+oJson->put("1", static_cast(4));
+oJson->put("4", static_cast(fVal));
+}
+}
+}
+}
+else
 {
 // 2 is text.
-tools::JsonWriter aJson;
-aJson.put("1", static_cast(2));
-aJson.put("2", pDoc->GetString(aPos));
-OUString aJsonString = 
OUString::fromUtf8(aJson.finishAndGetAsOString());
+oJson.emplace();
+oJson->put("1", static_cast(2));
+oJson->put("2", pDoc->GetString(aPos));
+}
+
+if (oJson)
+{
+OUString aJsonString = 
OUString::fromUtf8(oJson->finishAndGetAsOString());
 aStrTD.append(" " OOO_STRING_SVTOOLS_HTML_O_DSval "=\""
   + HTMLOutFuncs::ConvertStringToHTML(aJsonString) + "\"");
 }


core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-02-15 Thread Miklos Vajna (via logerrit)
 sc/qa/filter/html/html.cxx|   22 ++
 sc/source/filter/html/htmlexp.cxx |   26 ++
 2 files changed, 48 insertions(+)

New commits:
commit 28cc9382de067f647e9dde59834b137816574c3a
Author: Miklos Vajna 
AuthorDate: Wed Feb 14 09:35:14 2024 +0100
Commit: Xisco Fauli 
CommitDate: Thu Feb 15 10:38:54 2024 +0100

tdf#159483 sc HTML export: handle data-sheets-value attribute for the text 
case

HTML pasting "'01" from google sheets to Calc worked already, but
HTML copying from Calc still converted 01 to 1.

What's required is to emit a general marker in the HTML output and then
the correct data-sheets-value attribute on the relevant  element.

Add a way to inject a marker in ScHTMLExport::WriteBody() (so
data-sheets-* is considered at all) and extend
ScHTMLExport::WriteCell() to write the data-sheets-value attribute for
the text case as a start.

Other types like booleans are not yet handled at export time.

Change-Id: Ib66e92c84235797cb4731e73d0a5b6286b6f3ab3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163328
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins
(cherry picked from commit 4e2a4fbeb7c44cc47b3cf803cbcc6cba63b3d481)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163347
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/filter/html/html.cxx b/sc/qa/filter/html/html.cxx
index c6112e357d80..e0d7977c8000 100644
--- a/sc/qa/filter/html/html.cxx
+++ b/sc/qa/filter/html/html.cxx
@@ -192,6 +192,28 @@ CPPUNIT_TEST_FIXTURE(Test, testPasteSingleCell)
  pDoc->GetFormula(/*col=*/2, /*row=*/0, /*tab=*/0));
 CPPUNIT_ASSERT_EQUAL(static_cast(3), pDoc->GetValue(/*col=*/2, 
/*row=*/0, /*tab=*/0));
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testCopyText)
+{
+// Given a document with 01 in A1:
+createScDoc();
+ScDocument* pDoc = getScDoc();
+ScAddress aCellPos(/*nColP=*/0, /*nRowP=*/0, /*nTabP=*/0);
+pDoc->SetString(aCellPos, "'01");
+
+// When copying that text from A1:
+ScImportExport aExporter(*pDoc, aCellPos);
+SvMemoryStream aStream;
+CPPUNIT_ASSERT(aExporter.ExportStream(aStream, OUString(), 
SotClipboardFormatId::HTML));
+
+// Then make sure A1 is text:
+// Without the accompanying fix in place, this test would have failed with:
+// - XPath '//td' no attribute 'data-sheets-value' exist
+// i.e. metadata was missing to avoid converting 01 to 1 (number).
+aStream.Seek(0);
+htmlDocUniquePtr pHtmlDoc = parseHtmlStream();
+assertXPath(pHtmlDoc, "//td"_ostr, "data-sheets-value"_ostr, "{ \"1\": 2, 
\"2\": \"01\"}");
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/html/htmlexp.cxx 
b/sc/source/filter/html/htmlexp.cxx
index 2a3cb6a4f8ae..a2f14f6eff43 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -87,6 +87,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using ::editeng::SvxBorderLine;
 using namespace ::com::sun::star;
@@ -671,6 +672,20 @@ void ScHTMLExport::WriteBody()
 }
 
 rStrm.WriteChar( '>' ); OUT_LF();
+
+// A marker right after  can be used, so that data-sheets-* 
attributes are considered
+// at all. This is disabled by default.
+OString aMarker;
+char* pEnv = getenv("SC_DEBUG_HTML_MARKER");
+if (pEnv)
+{
+aMarker = pEnv;
+}
+else if (comphelper::LibreOfficeKit::isActive())
+{
+aMarker = ""_ostr;
+}
+rStrm.WriteOString(aMarker);
 }
 
 if ( bAll )
@@ -1128,6 +1143,17 @@ void ScHTMLExport::WriteCell( sc::ColumnBlockPosition& 
rBlockPos, SCCOL nCol, SC
 aStrTD.append(HTMLOutFuncs::CreateTableDataOptionsValNum(bValueData, fVal,
 nFormat, *pFormatter, ));
 
+if (!bValueData)
+{
+// 2 is text.
+tools::JsonWriter aJson;
+aJson.put("1", static_cast(2));
+aJson.put("2", pDoc->GetString(aPos));
+OUString aJsonString = 
OUString::fromUtf8(aJson.finishAndGetAsOString());
+aStrTD.append(" " OOO_STRING_SVTOOLS_HTML_O_DSval "=\""
+  + HTMLOutFuncs::ConvertStringToHTML(aJsonString) + "\"");
+}
+
 TAG_ON(aStrTD.makeStringAndClear());
 
 //write the note for this as the first thing in the tag


core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-02-13 Thread Miklos Vajna (via logerrit)
 sc/qa/filter/html/data/single-cell.html |1 
 sc/qa/filter/html/html.cxx  |   24 +
 sc/source/filter/html/htmlpars.cxx  |   57 +++-
 sc/source/filter/inc/htmlpars.hxx   |4 ++
 4 files changed, 70 insertions(+), 16 deletions(-)

New commits:
commit 2ec403de8f74699130cc80e1eda7862cb123cbfd
Author: Miklos Vajna 
AuthorDate: Tue Feb 13 08:11:54 2024 +0100
Commit: Xisco Fauli 
CommitDate: Tue Feb 13 16:53:24 2024 +0100

tdf#159483 sc HTML paste: handle data-sheets- attributes on a span

Copy multiple cells, including a formula from google sheets to Calc, the
formula is handled as a formula by the HTML paste. Do the same for a
single cell, then only the result is pasted.

The trouble is that the data-sheets-* attributes appear on  elements
for multiple cells, but they appear on a  for a single cell.

Fix the problem by extending ScHTMLLayoutParser::ProcToken() to handle
the HtmlTokenId::SPAN_ON token and share the code between the  and
 handler, so this markup works in both cases.

Note that this is the paste handler, the no changes to the normal HTML
import are made for now.

Change-Id: Id749df9062d8fcb9a2f0acd928585a304efaae28
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163291
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins
(cherry picked from commit c0da56cb3e9f9678cae7142dee03fb706a2aebd9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163289
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/filter/html/data/single-cell.html 
b/sc/qa/filter/html/data/single-cell.html
new file mode 100644
index ..0b5613f7e2be
--- /dev/null
+++ b/sc/qa/filter/html/data/single-cell.html
@@ -0,0 +1 @@
+3
diff --git a/sc/qa/filter/html/html.cxx b/sc/qa/filter/html/html.cxx
index 83e35d9f8281..c6112e357d80 100644
--- a/sc/qa/filter/html/html.cxx
+++ b/sc/qa/filter/html/html.cxx
@@ -168,6 +168,30 @@ CPPUNIT_TEST_FIXTURE(Test, testPasteTdAsFormula)
  pDoc->GetFormula(/*col=*/2, /*row=*/0, /*tab=*/0));
 CPPUNIT_ASSERT_EQUAL(static_cast(3), pDoc->GetValue(/*col=*/2, 
/*row=*/0, /*tab=*/0));
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testPasteSingleCell)
+{
+// Given a document with '1' in A1 and '2' in B1:
+createScDoc();
+ScDocument* pDoc = getScDoc();
+pDoc->SetValue(ScAddress(0, 0, 0), 1.0);
+pDoc->SetValue(ScAddress(1, 0, 0), 2.0);
+
+// When pasting SUM(A1:B1) into C1:
+ScAddress aCellPos(/*nColP=*/2, /*nRowP=*/0, /*nTabP=*/0);
+ScImportExport aImporter(*pDoc, aCellPos);
+SvFileStream aFile(createFileURL(u"single-cell.html"), StreamMode::READ);
+CPPUNIT_ASSERT(aImporter.ImportStream(aFile, OUString(), 
SotClipboardFormatId::HTML));
+
+// Then make sure C1 is a sum and it evaluates to 3:
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: =SUM(A1:B1)
+// - Actual  :
+// i.e. data-sheets-* on  worked, but not on .
+CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A1:B1)"),
+ pDoc->GetFormula(/*col=*/2, /*row=*/0, /*tab=*/0));
+CPPUNIT_ASSERT_EQUAL(static_cast(3), pDoc->GetValue(/*col=*/2, 
/*row=*/0, /*tab=*/0));
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index 917a690c7090..c9d53d93bed7 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -989,6 +989,34 @@ IMPL_LINK( ScHTMLLayoutParser, HTMLImportHdl, 
HtmlImportInfo&, rInfo, void )
 }
 }
 
+void ScHTMLLayoutParser::HandleDataSheetsAttributes(const HTMLOptions& 
rOptions)
+{
+for (const auto& rOption : rOptions)
+{
+switch (rOption.GetToken())
+{
+case HtmlOptionId::DSVAL:
+{
+ParseDataSheetsValue(rOption.GetString(), mxActEntry->pValStr, 
mxActEntry->pNumStr);
+break;
+}
+case HtmlOptionId::DSNUM:
+{
+ParseDataSheetsNumberformat(rOption.GetString(), 
mxActEntry->pNumStr);
+break;
+}
+case HtmlOptionId::DSFORMULA:
+{
+ParseDataSheetsFormula(rOption.GetString(), 
mxActEntry->moFormulaStr,
+   mxActEntry->moFormulaGrammar);
+break;
+}
+default:
+break;
+}
+}
+}
+
 void ScHTMLLayoutParser::TableDataOn( HtmlImportInfo* pInfo )
 {
 if ( bInCell )
@@ -1069,26 +1097,12 @@ void ScHTMLLayoutParser::TableDataOn( HtmlImportInfo* 
pInfo )
 mxActEntry->pNumStr = rOption.GetString();
 }
 break;
-case HtmlOptionId::DSVAL:
-{
-ParseDataSheetsValue(rOption.GetString(), mxActEntry->pValStr, 
mxActEntry->pNumStr);
-}
-break;
-case 

core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-02-12 Thread Tomaž Vajngerl (via logerrit)
 sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataInSync.xlsx 
|binary
 
sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithCacheData.xlsx
|binary
 
sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithoutCacheData.xlsx
 |binary
 sc/qa/unit/pivottable_filters_test.cxx 
|   63 ++
 sc/source/filter/oox/pivottablebuffer.cxx  
|   18 ++
 5 files changed, 78 insertions(+), 3 deletions(-)

New commits:
commit 12c69942fb80fcd4cd4a5a4ca4c76f1e050ca20c
Author: Tomaž Vajngerl 
AuthorDate: Sat Feb 10 00:38:35 2024 +0900
Commit: Xisco Fauli 
CommitDate: Mon Feb 12 17:09:55 2024 +0100

sc: pivot table not correct when data and PT cache is not in sync

It can happen that the pivot table is not updated and the sheet
data is changed so much that it doesn't match the pivot table
cached definitions. This is a perfectly valid scenario and
nothing should be wrong (the pivot table can just be updated
once loaded).

At XLSX import we should always check the cached definitions,
because the pivot table description is made using the cached data,
not the actual data.

The issue can occur when looking up the name of a PT field we
however didn't check the cached definition but checked the
sheet data, so because the indices changed so much (many columns
were removed in the sheet data) we can not find the actual field
name. The solution is simple - get the field name from the cached
pivot table definition.

Change-Id: I3b5b33f33f3c484f0b66b97ac97200d9913edcfe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163197
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 9af4b5254cbe6a6770ebe78ba14074266b05471e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163178
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataInSync.xlsx 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataInSync.xlsx
new file mode 100644
index ..f425f978cb50
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataInSync.xlsx differ
diff --git 
a/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithCacheData.xlsx
 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithCacheData.xlsx
new file mode 100644
index ..0cb21cd3259c
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithCacheData.xlsx
 differ
diff --git 
a/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithoutCacheData.xlsx
 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithoutCacheData.xlsx
new file mode 100644
index ..91297320b985
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithoutCacheData.xlsx
 differ
diff --git a/sc/qa/unit/pivottable_filters_test.cxx 
b/sc/qa/unit/pivottable_filters_test.cxx
index 8d6b1ad5d39e..31fb49351c8c 100644
--- a/sc/qa/unit/pivottable_filters_test.cxx
+++ b/sc/qa/unit/pivottable_filters_test.cxx
@@ -2647,6 +2647,69 @@ CPPUNIT_TEST_FIXTURE(ScPivotTableFiltersTest, 
testPivotTableCompactLayoutXLSX)
 testThis(*getScDoc());
 }
 
+CPPUNIT_TEST_FIXTURE(ScPivotTableFiltersTest,
+ 
testPivotTableXLSX_OutOfSyncPivotTableCachedDefinitionImport)
+{
+// This tests that a out-of-sync sheet data and pivot table cached 
definitions
+// still get imported correctly as expected.
+
+// It is perfectly valid that the sheet data and pivot table are 
out-of-sync,
+// but even if the sheet data is heavily modified, the pivot table should 
still
+// be imported.
+
+// The test document has columns named A-K where only A and K are used in 
the
+// pivot table. The columns B-J were removed in the sheet data, but the 
pivot table
+// was not updated, so the cached data still has those and the pivot table
+// description still relies on those columns to be present.
+
+auto testThis = [](ScDocument& rDocument) {
+ScDPCollection* pDPs = rDocument.GetDPCollection();
+CPPUNIT_ASSERT_MESSAGE("Failed to get a live ScDPCollection 
instance.", pDPs);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one pivot table 
instance.", size_t(1),
+ pDPs->GetCount());
+
+const ScDPObject* pDPObj = &(*pDPs)[0];
+CPPUNIT_ASSERT(pDPObj);
+ScDPSaveData* pSaveData = pDPObj->GetSaveData();
+CPPUNIT_ASSERT(pSaveData);
+
+// Do we have a dim named "A"
+

core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-02-08 Thread Miklos Vajna (via logerrit)
 sc/qa/filter/html/data/bool.html   |8 
 sc/qa/filter/html/html.cxx |   33 +
 sc/source/filter/html/htmlpars.cxx |   33 +++--
 3 files changed, 64 insertions(+), 10 deletions(-)

New commits:
commit 80c5fe83bcbc7d7f6721890b3a42316b199f55a1
Author: Miklos Vajna 
AuthorDate: Thu Feb 8 08:20:53 2024 +0100
Commit: Xisco Fauli 
CommitDate: Thu Feb 8 23:29:30 2024 +0100

tdf#159483 sc HTML import: handle data-sheets-value attribute for the bool 
case

Copy a cell with boolean TRUE and FALSE from google docs to Calc, the
paste result is a TRUE and a FALSE string.

The problem is that boolean is meant to be a float 0 or 1 with custom
cell format, but we don't build this doc model.

Fix the problem by ParseDataSheetsValue() to write the properties of the
cell similar to what the normal HTML import would extract from our own
markup, like:

TRUE

This requires passing around both the value and the numbering
properties, since the cell format just decides it's a boolean, but the
cell value will decide if it's TRUE or FALSE.

Change-Id: Id558ced56e02bbe24330d82c3998b047dc8febdb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163108
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins
(cherry picked from commit f8c95cf93ce9ab8b9b78f3af03411d0cc2e195ba)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163144
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/filter/html/data/bool.html b/sc/qa/filter/html/data/bool.html
new file mode 100644
index ..8fe27993f1ec
--- /dev/null
+++ b/sc/qa/filter/html/data/bool.html
@@ -0,0 +1,8 @@
+
+  
+WAHR
+  
+  
+FALSCH
+  
+
diff --git a/sc/qa/filter/html/html.cxx b/sc/qa/filter/html/html.cxx
index ba50361e927e..6ab2cc7fb0b7 100644
--- a/sc/qa/filter/html/html.cxx
+++ b/sc/qa/filter/html/html.cxx
@@ -15,6 +15,8 @@
 #include 
 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -83,6 +85,37 @@ CPPUNIT_TEST_FIXTURE(Test, testPasteTdAsText)
 // i.e. data-sheets-value was ignored on paste.
 CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, eCellType);
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testPasteTdAsBools)
+{
+// Given an empty document:
+createScDoc();
+
+// When pasting HTML with bool cells:
+ScDocument* pDoc = getScDoc();
+ScAddress aCellPos(/*nColP=*/0, /*nRowP=*/0, /*nTabP=*/0);
+ScImportExport aImporter(*pDoc, aCellPos);
+SvFileStream aFile(createFileURL(u"bool.html"), StreamMode::READ);
+SvMemoryStream aMemory;
+aMemory.WriteStream(aFile);
+aMemory.Seek(0);
+CPPUNIT_ASSERT(aImporter.ImportStream(aMemory, OUString(), 
SotClipboardFormatId::HTML));
+
+// Then make sure A1's type is bool, value is true:
+sal_uInt32 nNumberFormat = pDoc->GetNumberFormat(/*col=*/0, /*row=*/0, 
/*tab=*/0);
+const SvNumberformat* pNumberFormat = 
pDoc->GetFormatTable()->GetEntry(nNumberFormat);
+// Without the accompanying fix in place, this test would have failed with:
+// - Expected: BOOLEAN
+// - Actual  : General
+// i.e. data-sheets-value's bool case was ignored.
+CPPUNIT_ASSERT_EQUAL(OUString("BOOLEAN"), 
pNumberFormat->GetFormatstring());
+CPPUNIT_ASSERT_EQUAL(static_cast(1), pDoc->GetValue(/*col=*/0, 
/*row=*/0, /*tab=*/0));
+// And make sure A2's type is bool, value is true:
+nNumberFormat = pDoc->GetNumberFormat(/*col=*/0, /*row=*/1, /*tab=*/0);
+pNumberFormat = pDoc->GetFormatTable()->GetEntry(nNumberFormat);
+CPPUNIT_ASSERT_EQUAL(OUString("BOOLEAN"), 
pNumberFormat->GetFormatstring());
+CPPUNIT_ASSERT_EQUAL(static_cast(0), pDoc->GetValue(/*col=*/0, 
/*row=*/1, /*tab=*/0));
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index c31e97c54621..be957b1851a5 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -75,7 +75,7 @@ using namespace ::com::sun::star;
 namespace
 {
 /// data-sheets-value from google sheets, value is a JSON.
-void ParseDataSheetsValue(const OUString& rDataSheetsValue, sal_uInt32& 
rNumberFormat)
+void ParseDataSheetsValue(const OUString& rDataSheetsValue, 
std::optional& rVal, std::optional& rNum)
 {
 // data-sheets-value from google sheets, value is a JSON.
 OString aEncodedOption = rDataSheetsValue.toUtf8();
@@ -88,10 +88,27 @@ void ParseDataSheetsValue(const OUString& rDataSheetsValue, 
sal_uInt32& rNumberF
 if (it != aTree.not_found())
 {
 int nValueType = std::stoi(it->second.get_value());
-// 2 is text.
-if (nValueType == 2)
+switch (nValueType)
 {
-rNumberFormat = NF_STANDARD_FORMAT_TEXT;
+case 2:
+{
+// 2 is text.
+// See SfxHTMLParser::GetTableDataOptionsValNum(), we leave 
the parse and a number
+// language 

core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-02-07 Thread Justin Luth (via logerrit)
 sc/qa/unit/data/xlsx/tdf159581_optimalRowHeight.xlsx |binary
 sc/qa/unit/subsequent_filters_test2.cxx  |   11 +++
 sc/source/core/data/dociter.cxx  |2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)

New commits:
commit c723758d0540bdb4846eefb4b50b4bde212f1985
Author: Justin Luth 
AuthorDate: Tue Feb 6 21:08:36 2024 -0500
Commit: Miklos Vajna 
CommitDate: Thu Feb 8 08:31:15 2024 +0100

tdf#159581 sc: fix multi-sheet ScDocRowHeightUpdater

Apparently it was caching the first sheet's
row height, and applying it to every other sheet.

AFAICS, the only time this ever ran against multiple sheets
was during import time, so that is why it wasn't easily noticed
before 24.2 when XLSX started using it on import.

make CppunitTest_sc_subsequent_filters_test2 \
CPPUNIT_TEST_NAME=testTdf159581_optimalRowHeight

Change-Id: Ic4e4dd335fa48d02acbc85cfad35feb8eca7597b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163066
Tested-by: Jenkins
Reviewed-by: Justin Luth 
(cherry picked from commit 9778d499df3d081314295ae099463870146b7a9c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163027

diff --git a/sc/qa/unit/data/xlsx/tdf159581_optimalRowHeight.xlsx 
b/sc/qa/unit/data/xlsx/tdf159581_optimalRowHeight.xlsx
new file mode 100644
index ..8df77208045f
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/tdf159581_optimalRowHeight.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx 
b/sc/qa/unit/subsequent_filters_test2.cxx
index dd63f0b8a973..2b8ff43962bb 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -159,6 +159,17 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest2, 
testTdf123026_optimalRowHeight)
 CPPUNIT_ASSERT_GREATER(2000, nHeight);
 }
 
+CPPUNIT_TEST_FIXTURE(ScFiltersTest2, testTdf159581_optimalRowHeight)
+{
+createScDoc("xlsx/tdf159581_optimalRowHeight.xlsx");
+SCTAB nTab = 1;
+SCROW nRow = 0; // row 1
+int nHeight = convertTwipToMm100(getScDoc()->GetRowHeight(nRow, nTab, 
false));
+
+// Without the fix, this was 2027. It should be 450.
+CPPUNIT_ASSERT_LESS(500, nHeight);
+}
+
 CPPUNIT_TEST_FIXTURE(ScFiltersTest2, testCustomNumFormatHybridCellODS)
 {
 createScDoc("ods/custom-numfmt-hybrid-cell.ods");
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index b1fca78c86be..1fe1f5344d0a 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1683,13 +1683,13 @@ void ScDocRowHeightUpdater::updateAll(const bool 
bOnlyUsedRows)
 ScProgress aProgress(mrDoc.GetDocumentShell(), 
ScResId(STR_PROGRESS_HEIGHTING), nCellCount, true);
 
 Fraction aZoom(1, 1);
-sc::RowHeightContext aCxt(mrDoc.MaxRow(), mfPPTX, mfPPTY, aZoom, aZoom, 
mpOutDev);
 sal_uInt64 nProgressStart = 0;
 for (SCTAB nTab = 0; nTab < mrDoc.GetTableCount(); ++nTab)
 {
 if (!ValidTab(nTab) || !mrDoc.maTabs[nTab])
 continue;
 
+sc::RowHeightContext aCxt(mrDoc.MaxRow(), mfPPTX, mfPPTY, aZoom, 
aZoom, mpOutDev);
 SCCOL nEndCol = 0;
 SCROW nEndRow = mrDoc.MaxRow();
 if (!bOnlyUsedRows || mrDoc.GetPrintArea(nTab, nEndCol, nEndRow))


core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-01-28 Thread Oliver Specht (via logerrit)
 sc/qa/uitest/calc_tests8/navigator.py |   27 +++
 sc/source/ui/navipi/navipi.cxx|1 +
 2 files changed, 28 insertions(+)

New commits:
commit 118e6cc0921849216e1fc3eb8d2f7dbb53463b26
Author: Oliver Specht 
AuthorDate: Tue Dec 12 15:51:42 2023 +0100
Commit: Caolán McNamara 
CommitDate: Sun Jan 28 20:58:05 2024 +0100

tdf#158652 notify navigator on insert/edit/delete comment

links changes of the drawing engine to comments as it was
done before with pictures, shapes and OLE objects
ui unit test included

Change-Id: I4fde3a82b80e73758fb3da94ed2553453d09e9ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160624
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens 
(cherry picked from commit 0097f8595791f4bbf499ebd423f4f80ec8e38dbe)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162381
Reviewed-by: Caolán McNamara 

diff --git a/sc/qa/uitest/calc_tests8/navigator.py 
b/sc/qa/uitest/calc_tests8/navigator.py
index ec8fa2ae9a2e..9c1769dcf49d 100644
--- a/sc/qa/uitest/calc_tests8/navigator.py
+++ b/sc/qa/uitest/calc_tests8/navigator.py
@@ -10,6 +10,7 @@
 from uitest.framework import UITestCase
 from libreoffice.uno.propertyvalue import mkPropertyValues
 from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
+from uitest.uihelper.calc import enter_text_to_cell
 
 class navigator(UITestCase):
 
@@ -181,4 +182,30 @@ class navigator(UITestCase):
 
 self.xUITest.executeCommand(".uno:Sidebar")
 
+
+def test_tdf158652(self):
+with self.ui_test.create_doc_in_start_center("calc"):
+xCalcDoc = self.xUITest.getTopFocusWindow()
+xGridWin = xCalcDoc.getChild("grid_window")
+
+self.xUITest.executeCommand(".uno:Sidebar")
+
+xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": 
"ScNavigatorPanel"}))
+
+xCalcDoc = self.xUITest.getTopFocusWindow()
+xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel")
+xContentBox = xNavigatorPanel.getChild('contentbox')
+enter_text_to_cell(xGridWin, "A1", "1")
+
+commentText = mkPropertyValues({"Text":"CommentText"})
+self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", 
commentText)
+xComments = xContentBox.getChild("6")
+self.assertEqual(len(xComments.getChildren()), 1)
+
+self.xUITest.executeCommand(".uno:DeleteNote")
+xComments = xContentBox.getChild("6")
+self.assertEqual(len(xComments.getChildren()), 0)
+
+self.xUITest.executeCommand(".uno:Sidebar")
+
 # vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/ui/navipi/navipi.cxx b/sc/source/ui/navipi/navipi.cxx
index 5fc6fee82122..ae95220eeffb 100644
--- a/sc/source/ui/navipi/navipi.cxx
+++ b/sc/source/ui/navipi/navipi.cxx
@@ -540,6 +540,7 @@ void ScNavigatorDlg::Notify( SfxBroadcaster&, const 
SfxHint& rHint )
 m_xLbEntries->Refresh( ScContentId::GRAPHIC );
 m_xLbEntries->Refresh( ScContentId::OLEOBJECT );
 m_xLbEntries->Refresh( ScContentId::DRAWING );
+m_xLbEntries->Refresh( ScContentId::NOTE );
 break;
 
 case SfxHintId::ScAreaLinksChanged:


core.git: Branch 'libreoffice-24-2' - sc/qa sc/source

2024-01-18 Thread Kevin Suo (via logerrit)
 sc/qa/uitest/autofilter2/tdf158314_EmptyError.py |   94 +++
 sc/source/core/data/column3.cxx  |4 
 sc/source/ui/view/gridwin.cxx|7 -
 3 files changed, 100 insertions(+), 5 deletions(-)

New commits:
commit f14e942e84942b42956a058e737742f5d19daa96
Author: Kevin Suo 
AuthorDate: Tue Jan 16 10:13:59 2024 +0800
Commit: Xisco Fauli 
CommitDate: Thu Jan 18 17:21:23 2024 +0100

tdf#158314: show Empty and Error entries as non-selected and inactive...

...when hidden by autofilter.

The "show hidden filter elements as inactive" feature was added and 
improved by:

commit 2d1df9f3dccc10f13b8585ad18afce1542ebc4d1
(tdf#117276 sc: Show hidden filter elements as inactive elements)

commit 2085e90fe8ac129bc4dbac4612d1ea7544335dae
(FilteredRow is not a property of the column, tdf#117276 follow-up)

commit 7321db3cadc8c0e4437ca04e5dcb652734ea9c26
(Related tdf#117276 sc: Show hidden filter elements as inactive elements)

commit 19533948370dc1ccd7334dbe1a8b7fc8330b10c0
(Name FilteredRow what it is, not hidden; tdf#117276 follow-up)

Those changes correctly made normal hidden filter elements as inactive,
but failed to do so for Empty and Error entries.

This patch shows the hidden Empty and Error entries as inactive and 
unselected.
Also, do not show the Empty entry at the top of the list in case it is 
inactive.

Change-Id: Ibcd758cebc0692b04b162cdfc3e06eceb86b17da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162166
Reviewed-by: Xisco Fauli 
Reviewed-by: Kevin Suo 
Tested-by: Kevin Suo 
(cherry picked from commit 2e844921083ee45a36454ea3f03c1796439e4d16)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162224
Tested-by: Jenkins

diff --git a/sc/qa/uitest/autofilter2/tdf158314_EmptyError.py 
b/sc/qa/uitest/autofilter2/tdf158314_EmptyError.py
new file mode 100644
index ..2ced88c80db3
--- /dev/null
+++ b/sc/qa/uitest/autofilter2/tdf158314_EmptyError.py
@@ -0,0 +1,94 @@
+# -*- 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
+from libreoffice.calc.document import is_row_hidden
+
+# Bug 158314 - Autofilter dropdown list always shows "Empty" entry as active
+
+class tdf158314_EmptyEntries(UITestCase):
+def testTdf158314(self):
+with self.ui_test.create_doc_in_start_center("calc") as calcDoc:
+xCalcDoc = self.xUITest.getTopFocusWindow()
+xGridWin = xCalcDoc.getChild("grid_window")
+
+# Fill the sheet with test data
+enter_text_to_cell(xGridWin, "A1", "a")
+enter_text_to_cell(xGridWin, "A2", "1")
+enter_text_to_cell(xGridWin, "A3", "2")
+enter_text_to_cell(xGridWin, "A4", "3")
+enter_text_to_cell(xGridWin, "A5", "4")
+
+enter_text_to_cell(xGridWin, "B1", "b")
+enter_text_to_cell(xGridWin, "B2", "5")
+enter_text_to_cell(xGridWin, "B3", "")
+enter_text_to_cell(xGridWin, "B4", "=1/0")
+enter_text_to_cell(xGridWin, "B5", "8")
+
+# Select the data range and set autofilter
+xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": 
"A1:B5"}))
+self.xUITest.executeCommand(".uno:DataFilterAutoFilter")
+
+# Click the autofilter dropdown in column A
+xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": 
"", "COL": "0", "ROW": "0"}))
+xFloatWindow = self.xUITest.getFloatWindow()
+xCheckListMenu = xFloatWindow.getChild("FilterDropDown")
+xTreeList = xCheckListMenu.getChild("check_list_box")
+
+#  Select the first entry only. Uncheck all other entries.
+for i in xTreeList.getChildren():
+if i != "0":
+xEntry = xTreeList.getChild(i)
+xEntry.executeAction("CLICK", tuple())
+
+xOkButton = xFloatWindow.getChild("ok")
+xOkButton.executeAction("CLICK", tuple())
+
+# Check that only row#2 is visible
+self.assertFalse(is_row_hidden(calcDoc, 1))
+self.assertTrue(is_row_hidden(calcDoc, 2))
+self.assertTrue(is_row_hidden(calcDoc, 3))
+self.assertTrue(is_row_hidden(calcDoc, 4))
+
+# Click the autofilter dropdown in column B
+xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": 
"", "COL": "1",