core.git: Branch 'libreoffice-7-6' - sc/qa sc/source

2024-05-06 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 a4f679ed901923046e4fee3e11a9fc236c4ff506
Author: Andreas Heinisch 
AuthorDate: Fri Apr 26 20:29:53 2024 +0200
Commit: Xisco Fauli 
CommitDate: Mon May 6 15:47:18 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 
(cherry picked from commit 30524d5998d38b7e216b721859c72fbfc56a5b5a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166890

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);
 

core.git: Branch 'libreoffice-7-6' - sc/qa sc/source

2024-04-29 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 4d744d94cc4ee114a7e5d5373b2b599baed31ee5
Author: Andreas Heinisch 
AuthorDate: Mon Apr 22 20:06:50 2024 +0200
Commit: Xisco Fauli 
CommitDate: Mon Apr 29 21:01:47 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/+/166524
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-7-6' - sc/qa sc/source

2024-04-17 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|   17 +++-
 3 files changed, 85 insertions(+), 2 deletions(-)

New commits:
commit ed0165f6cbd1f3f9e47be26fe5d60c29eb946030
Author: Laurent Balland 
AuthorDate: Thu Dec 7 19:38:54 2023 +0100
Commit: Laurent Balland 
CommitDate: Wed Apr 17 19:25:25 2024 +0200

tdf#129701 Skip empty cell: treat last column

 This is a combination of 2 commits.

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.

xChange-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 
(cherry picked from commit 60e0ebe633b1dee8bb2a66b9d133f5303749d8d5)

tdf#129701 Follow-up of previous change

According to comments in https://gerrit.libreoffice.org/c/core/+/163536
Follow-up of previous change

xChange-Id: Icd7b6798d6ef35ca9574125cd3d4c4d89044569c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166133
Tested-by: Jenkins
Reviewed-by: Eike Rathke 
(cherry picked from commit 47187acee758680cda8086b6e295ef7beea3491b)

Change-Id: Idec823fb1c27b803f49c6d13d6c757ef0f41e437
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164493
Reviewed-by: Eike Rathke 
Tested-by: Jenkins
Reviewed-by: Laurent Balland 

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", 

core.git: Branch 'libreoffice-7-6' - 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 45fb563b6e93833a4dbe31bf0b0cc0a51e83f791
Author: Regina Henschel 
AuthorDate: Sun Mar 3 17:19:49 2024 +0100
Commit: Xisco Fauli 
CommitDate: Mon Mar 4 22:02:49 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/+/164374
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 8e989012b4e8..23837e357203 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -1993,7 +1993,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-7-6' - sc/qa sc/source

2024-01-19 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 94b9579b25fe60d8c4c34a3379f06068a1fe6167
Author: Kevin Suo 
AuthorDate: Tue Jan 16 10:13:59 2024 +0800
Commit: Xisco Fauli 
CommitDate: Fri Jan 19 09:47:28 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 89e032e9c4c51f52680c7d8bacf59ab2a34f2180)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162226
Tested-by: Xisco Fauli 

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": 

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

2023-11-01 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|   19 +++
 sc/source/core/data/documen2.cxx|2 ++
 4 files changed, 21 insertions(+)

New commits:
commit e61f8a36220d6e8800dd0decf2a680db97c371c9
Author: Andreas Heinisch 
AuthorDate: Mon Oct 23 23:13:51 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Nov 2 00:51:24 2023 +0100

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 
(cherry picked from commit 96b91357fb93028d35d70bdb52b4bac3ecbfbf57)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158534
Reviewed-by: Xisco Fauli 

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 d96b78b87136..a2b96bfda52c 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -1380,6 +1380,25 @@ 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);
+ScDocShell* pDocSh = getScDocShell();
+pDocSh->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 e5d5df5a94cb..7766d54aba99 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1042,6 +1042,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: Branch 'libreoffice-7-6' - sc/qa sc/source xmloff/Library_xo.mk xmloff/source

2023-08-03 Thread Tomaž Vajngerl (via logerrit)
 sc/qa/unit/ThemeImportExportTest.cxx   |   10 +
 sc/source/filter/xml/xmlstyle.cxx  |5 --
 xmloff/Library_xo.mk   |1 
 xmloff/source/style/StylePropertiesContext.cxx |   44 +
 xmloff/source/style/StylePropertiesContext.hxx |   31 +
 xmloff/source/style/prhdlfac.cxx   |5 ++
 xmloff/source/style/prstylei.cxx   |   11 ++
 7 files changed, 95 insertions(+), 12 deletions(-)

New commits:
commit 0828e1fe9d999d1ccb0e755fac1553c5c4bc124f
Author: Tomaž Vajngerl 
AuthorDate: Fri Jul 28 09:03:50 2023 +0200
Commit: Miklos Vajna 
CommitDate: Thu Aug 3 16:43:48 2023 +0200

xmloff: fix import of CharComplexColor - add StylePropertiesContext

Import of CharComplexColor in Calc didn't work because the class
XMLComplexColorContext wasn't used.

This introduces a new class StylePropertiesContext, because the
plain SvXMLPropertySetContext is not enough as we can't define to
use XMLComplexColorContext when XML_CHAR_COMPLEX_COLOR is used on
that class.

Also adds a import/export test for CharComplexColor.

Change-Id: I765ac71a801a5e9bcb105aaea73637df5e601b85
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155008
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit b543463f639ecee793484e8b419147d565a53d52)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155176
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sc/qa/unit/ThemeImportExportTest.cxx 
b/sc/qa/unit/ThemeImportExportTest.cxx
index 9164d41668f1..09e4288b8a4f 100644
--- a/sc/qa/unit/ThemeImportExportTest.cxx
+++ b/sc/qa/unit/ThemeImportExportTest.cxx
@@ -213,6 +213,16 @@ CPPUNIT_TEST_FIXTURE(ThemeImportExportTest, 
testCellTextThemeColor)
 checkCellTextThemeColor(getScDoc());
 }
 
+CPPUNIT_TEST_FIXTURE(ThemeImportExportTest, testCellTextThemeColorODF)
+{
+// Open the OOXML source
+loadFromURL(u"xlsx/Test_ThemeColor_Text_Background_Border.xlsx");
+// Save as ODF and load again - checks import / export cycle
+saveAndReload("calc8");
+// Check the values and show that the document is unchanged and all the 
data preserved
+checkCellTextThemeColor(getScDoc());
+}
+
 void checkCellBorderThemeColor(ScDocument* pDoc)
 {
 // C1
diff --git a/sc/source/filter/xml/xmlstyle.cxx 
b/sc/source/filter/xml/xmlstyle.cxx
index bb38d305b9a3..9e5fb1598308 100644
--- a/sc/source/filter/xml/xmlstyle.cxx
+++ b/sc/source/filter/xml/xmlstyle.cxx
@@ -908,11 +908,6 @@ const XMLPropertyHandler* 
XMLScPropHdlFactory::GetPropertyHandler( sal_Int32 nTy
 pHdl = new XmlScPropHdl_Vertical;
 }
 break;
-case XML_TYPE_COMPLEX_COLOR:
-{
-pHdl = new XMLComplexColorHandler;
-}
-break;
 }
 
 if(pHdl)
diff --git a/xmloff/Library_xo.mk b/xmloff/Library_xo.mk
index 8e7f3208bfe9..2bad53c2130a 100644
--- a/xmloff/Library_xo.mk
+++ b/xmloff/Library_xo.mk
@@ -234,6 +234,7 @@ $(eval $(call gb_Library_add_exception_objects,xo,\
 xmloff/source/style/PagePropertySetContext \
 xmloff/source/style/SinglePropertySetInfoCache \
 xmloff/source/style/StyleMap \
+xmloff/source/style/StylePropertiesContext \
 xmloff/source/style/TransGradientStyle \
 xmloff/source/style/WordWrapPropertyHdl \
 xmloff/source/style/XMLBackgroundImageContext \
diff --git a/xmloff/source/style/StylePropertiesContext.cxx 
b/xmloff/source/style/StylePropertiesContext.cxx
new file mode 100644
index ..1bda191485e6
--- /dev/null
+++ b/xmloff/source/style/StylePropertiesContext.cxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ */
+
+#include "StylePropertiesContext.hxx"
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+using namespace xmloff::token;
+
+StylePropertiesContext::StylePropertiesContext(
+SvXMLImport& rImport, sal_Int32 nElement,
+const css::uno::Reference& xAttrList, 
sal_uInt32 nFamily,
+std::vector& rProps, const 
rtl::Reference& rMap)
+: SvXMLPropertySetContext(rImport, nElement, xAttrList, nFamily, rProps, 
rMap)
+{
+}
+
+StylePropertiesContext::~StylePropertiesContext() {}
+
+css::uno::Reference
+StylePropertiesContext::createFastChildContext(
+sal_Int32 nElement, const 
css::uno::Reference& xAttrList,
+std::vector& rProperties, const XMLPropertyState& 
rProperty)
+{
+if (nElement == XML_ELEMENT(LO_EXT, XML_CHAR_COMPLEX_COLOR))
+{
+return new XMLComplexColorContext(GetImport(), nElement, xAttrList, 
rProperty, rProperties);
+

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

2023-08-03 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 39aa1f6424390821579bfb6b6ba14e9ce11040ce
Author: Jaume Pujantell 
AuthorDate: Thu Jul 6 09:22:15 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Aug 3 10:31:14 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 
(cherry picked from commit 341029de72cf957b7bc7775e51544070d4a49874)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154126

diff --git a/sc/qa/unit/uicalc/uicalc2.cxx b/sc/qa/unit/uicalc/uicalc2.cxx
index 1ec77ad7ad37..ea5956c2bf81 100644
--- a/sc/qa/unit/uicalc/uicalc2.cxx
+++ b/sc/qa/unit/uicalc/uicalc2.cxx
@@ -1445,6 +1445,33 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf156174)
 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);
+   

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

2023-08-01 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 04098a535bf25494379678b9539c4987cb33431f
Author: Tünde Tóth 
AuthorDate: Tue Jul 18 15:20:47 2023 +0200
Commit: László Németh 
CommitDate: Tue Aug 1 12:16:11 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 
(cherry picked from commit 94ca402cd1fe2fd9776d08448f7216b7f638e69a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155041

diff --git a/sc/qa/unit/uicalc/uicalc2.cxx b/sc/qa/unit/uicalc/uicalc2.cxx
index 3be123de219d..1ec77ad7ad37 100644
--- a/sc/qa/unit/uicalc/uicalc2.cxx
+++ b/sc/qa/unit/uicalc/uicalc2.cxx
@@ -1419,6 +1419,32 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf152577)
 CPPUNIT_ASSERT(!pDBs->empty());
 }
 
+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: Branch 'libreoffice-7-6' - sc/qa sc/source

2023-07-26 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 77720a8f4338f2b6e393387e6fb683339618e826
Author: Tibor Nagy 
AuthorDate: Thu Jul 13 14:54:55 2023 +0200
Commit: László Németh 
CommitDate: Wed Jul 26 11:04:42 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 
(cherry picked from commit e384be0f6ea6453e57cd4a7c4402d26b49debc41)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154867
Tested-by: Jenkins

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: Branch 'libreoffice-7-6' - sc/qa sc/source

2023-07-26 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 83ead6e42f82c03f807cb4b003fcac35135de459
Author: Tibor Nagy 
AuthorDate: Wed Jul 12 17:17:10 2023 +0200
Commit: László Németh 
CommitDate: Wed Jul 26 11:04:27 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 
(cherry picked from commit ee4bd745be5dee15b68ca483f7f7771957ae3b3e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154865

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 7c95701e9705..db9eadc671ad 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: Branch 'libreoffice-7-6' - sc/qa sc/source

2023-07-26 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 15e8278144a7326e9587a665e9e1068562309295
Author: Czeber László Ádám 
AuthorDate: Thu Jul 20 13:14:21 2023 +0200
Commit: László Németh 
CommitDate: Wed Jul 26 11:02:57 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 
(cherry picked from commit 864e5cdb0cc91b9bf2ea0428590094a8901b33ed)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154914
Tested-by: Jenkins

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: Branch 'libreoffice-7-6' - sc/qa sc/source

2023-07-25 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 830f501147f830d5d1eeac601d97f9720d7b80f9
Author: Tibor Nagy 
AuthorDate: Mon Jul 10 17:53:49 2023 +0200
Commit: László Németh 
CommitDate: Tue Jul 25 10:29:45 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 
(cherry picked from commit fdbea1f65e9f30f0d6cb4bade181ed2386a7c568)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154853
Tested-by: Jenkins

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 1358fb8ec56d..6ca01319a0b0 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: Branch 'libreoffice-7-6' - 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 ad341c969f7fe31590d80f795caeb5ecd2eb3983
Author: Tomaž Vajngerl 
AuthorDate: Sat Jul 1 14:26:08 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Jul 4 16:43:31 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 
(cherry picked from commit 563ef3bf8db881223201fbacbc4f3c565b8fac0f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153922

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();
  

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

2023-06-28 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 d41456c2aa86ecbc70b45e11eb6e411e33b3ac06
Author: Tibor Nagy 
AuthorDate: Thu Jun 22 09:53:59 2023 +0200
Commit: Xisco Fauli 
CommitDate: Wed Jun 28 13:11:07 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 
(cherry picked from commit 54550800bf0d0208ea5085a2170100100d0da2d4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153660
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

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: Branch 'libreoffice-7-6' - 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 09d0898b358b368fbe644eb5acbcfdab4af58751
Author: luigiiucci 
AuthorDate: Wed May 17 11:02:37 2023 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 28 06:46:05 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 
(cherry picked from commit 3551d18404cb19cdaa8edb170a549f5c5405d0cb)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153692

diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index efb2e68c4fbc..82227ec12006 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: Branch 'libreoffice-7-6' - 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 4c4d56f94b8f9598bd3d7cd60d38e18bf1e42857
Author: Tibor Nagy 
AuthorDate: Mon Jun 26 11:35:38 2023 +0200
Commit: Xisco Fauli 
CommitDate: Tue Jun 27 22:39:29 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 
(cherry picked from commit 7b7a86dce26f2719edeca5fb6ae0cdcbd3956c13)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153659
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

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: Branch 'libreoffice-7-6' - sc/qa sc/source

2023-06-20 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 6af0508592ea7d62e5452b88953c3aa7ddb0b281
Author: Balazs Varga 
AuthorDate: Wed Jun 14 23:01:26 2023 +0200
Commit: Balazs Varga 
CommitDate: Tue Jun 20 16:56:48 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 
(cherry picked from commit 5c7196acbdd949005c1b52aeab34b5448e09011e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153217

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 ==