core.git: cui/qa pyuno/qa sc/qa sd/qa svx/qa sw/qa uitest/impress_tests uitest/libreoffice

2024-01-23 Thread Chenxiong Qi (via logerrit)
 cui/qa/uitest/dialogs/chardlg.py  |6 -
 cui/qa/uitest/tabpages/tpcolor.py |4 
 pyuno/qa/pytests/testcollections_XIndexContainer.py   |8 -
 sc/qa/uitest/calc_tests/calcSheetDelete.py|   40 +++---
 sc/qa/uitest/calc_tests2/tdf114992.py |4 
 sc/qa/uitest/calc_tests6/moveCopySheet.py |8 -
 sc/qa/uitest/calc_tests7/tdf124896.py |2 
 sc/qa/uitest/calc_tests8/tdf124829.py |2 
 sc/qa/uitest/calc_tests8/tdf54768.py  |4 
 sc/qa/uitest/calc_tests9/tdf148437.py |4 
 sc/qa/uitest/calc_tests9/tdf156611_hyperlink_interoper.py |6 -
 sc/qa/uitest/calc_tests9/tdf80043.py  |   26 ++--
 sc/qa/uitest/chart/tdf43175.py|2 
 sc/qa/uitest/pasteSpecial/tdf114710.py|2 
 sc/qa/uitest/signatureLine/insertSignatureLine.py |2 
 sc/qa/uitest/validity/tdf138134.py|4 
 sd/qa/uitest/findReplace/findReplace.py   |   32 ++---
 sd/qa/uitest/impress_tests/exportToPDF.py |8 -
 sd/qa/uitest/impress_tests/insertSlide.py |   12 +-
 sd/qa/uitest/impress_tests/tdf134734.py   |   54 +++--
 sd/qa/uitest/impress_tests/tdf137729.py   |   10 -
 sd/qa/uitest/impress_tests/tdf155863.py   |4 
 sd/qa/uitest/impress_tests2/tdf125449.py  |   18 +--
 sd/qa/uitest/impress_tests2/tdf127900.py  |8 -
 sd/qa/uitest/impress_tests2/tdf133713.py  |4 
 sd/qa/uitest/impress_tests2/tdf139511.py  |8 -
 sd/qa/uitest/impress_tests2/tdf146019.py  |3 
 sd/qa/uitest/impress_tests2/tdf91762.py   |   12 +-
 svx/qa/uitest/table/tablecontroller.py|3 
 sw/qa/python/check_styles.py  |4 
 sw/qa/python/xtextrange.py|6 -
 sw/qa/uitest/librelogo/run.py |   24 ++--
 sw/qa/uitest/navigator/tdf154521.py   |2 
 sw/qa/uitest/table/sheetToTable.py|   10 -
 sw/qa/uitest/table/splitTable.py  |   12 +-
 sw/qa/uitest/table/tableToText.py |   16 +-
 sw/qa/uitest/table/tdf51352.py|8 -
 sw/qa/uitest/table/tdf53460.py|2 
 sw/qa/uitest/table/textToTable.py |8 -
 sw/qa/uitest/ui/frmdlg/frmdlg.py  |2 
 sw/qa/uitest/writer_tests/insertCaption.py|2 
 sw/qa/uitest/writer_tests2/insertFootnote.py  |6 -
 sw/qa/uitest/writer_tests2/tdf116474.py   |4 
 sw/qa/uitest/writer_tests2/tdf133299.py   |2 
 sw/qa/uitest/writer_tests3/insertEndnote.py   |6 -
 sw/qa/uitest/writer_tests3/insertFootEndnote.py   |   16 +-
 sw/qa/uitest/writer_tests3/insertQrCodeGen.py |2 
 sw/qa/uitest/writer_tests3/insertSignatureLine.py |2 
 sw/qa/uitest/writer_tests3/tdf79236.py|   54 -
 sw/qa/uitest/writer_tests4/exportToPDF.py |2 
 sw/qa/uitest/writer_tests5/tdf106899.py   |2 
 sw/qa/uitest/writer_tests5/tdf138531.py   |2 
 sw/qa/uitest/writer_tests5/tdf142847.py   |2 
 sw/qa/uitest/writer_tests5/tdf145326.py   |2 
 sw/qa/uitest/writer_tests5/tdf147935.py   |2 
 sw/qa/uitest/writer_tests5/tdf150151.py   |2 
 sw/qa/uitest/writer_tests6/tdf107847.py   |4 
 sw/qa/uitest/writer_tests6/tdf118883.py   |4 
 sw/qa/uitest/writer_tests6/tdf126168.py   |4 
 sw/qa/uitest/writer_tests7/forms.py   |3 
 sw/qa/uitest/writer_tests7/tdf132169.py   |3 
 sw/qa/uitest/writer_tests7/tdf132714.py   |8 -
 sw/qa/uitest/writer_tests7/tdf137802.py   |   18 +--
 sw/qa/uitest/writer_tests7/tdf137803.py   |3 
 sw/qa/uitest/writer_tests7/tdf140117.py   |8 -
 sw/qa/uitest/writer_tests7/tdf141158.py   |4 
 sw/qa/uitest/writer_tests7/tdf141557.py   |4 
 sw/qa/uitest/writer_tests7/tdf46561.py|   10 -
 uitest/impress_tests/backgrounds.py   |   82 +++---
 uitest/libreoffice/calc/document.py   |6 -
 70 files changed, 320 insertions(+), 343 deletions(-)

New commits:
commit 74de0ebb810f3e13c45f01c63067cb8de794ce3c
Author: Chenxiong Qi 
AuthorDate: Wed Dec 20 20:54:05 2023 +0800
Commit: Hossein 
CommitDate: Tue 

core.git: cui/qa dbaccess/qa pyuno/demo pyuno/qa sc/qa sc/workben sfx2/qa sw/qa uitest/ui_logger_dsl uitest/uitest unotest/source

2023-12-27 Thread Chenxiong Qi (via logerrit)
 cui/qa/uitest/dialogs/chardlg.py   |1 
 cui/qa/uitest/dialogs/shortcuts.py |1 
 dbaccess/qa/python/fdo84315.py |3 -
 pyuno/demo/ooextract.py|1 
 pyuno/qa/pytests/testcollections_XCellRange.py |4 +-
 pyuno/qa/pytests/testcollections_XEnumerationAccess.py |4 +-
 pyuno/qa/pytests/testcollections_XIndexAccess.py   |2 -
 pyuno/qa/pytests/testcollections_XIndexReplace.py  |2 -
 pyuno/qa/pytests/testcollections_XNameAccess.py|   12 +++---
 pyuno/qa/pytests/testcollections_XNameReplace.py   |4 +-
 pyuno/qa/pytests/testcollections_misc.py   |2 -
 pyuno/qa/pytests/testssl.py|5 ++
 sc/qa/uitest/calc_tests4/trackedChanges.py |2 -
 sc/workben/cache.py|3 +
 sfx2/qa/python/check_sidebar.py|8 
 sfx2/qa/python/check_sidebar_registry.py   |2 -
 sfx2/qa/uitest/doc/objserv.py  |2 -
 sw/qa/python/check_xtextrangecompare.py|2 -
 sw/qa/python/text_portion_enumeration_test.py  |   31 +
 sw/qa/uitest/librelogo/run.py  |1 
 sw/qa/uitest/navigator/tdf154521.py|4 +-
 sw/qa/uitest/table/splitTable.py   |2 -
 sw/qa/uitest/ui/frmdlg/frmdlg.py   |2 -
 sw/qa/uitest/writer_tests7/tdf132714.py|4 +-
 sw/qa/uitest/writer_tests7/tdf156783.py|2 -
 sw/qa/uitest/writer_tests7/tdf156784.py|2 -
 sw/qa/uitest/writer_tests7/tdf156900.py|2 -
 sw/qa/uitest/writer_tests8/tdf156243.py|2 -
 uitest/ui_logger_dsl/dsl_core.py   |3 +
 uitest/uitest/test.py  |2 -
 unotest/source/python/org/libreoffice/unotest.py   |6 ---
 31 files changed, 53 insertions(+), 70 deletions(-)

New commits:
commit 8b6e0dd9e47c20a79fd194f6d530d1c868911bda
Author: Chenxiong Qi 
AuthorDate: Sun Dec 17 22:14:09 2023 +0800
Commit: Hossein 
CommitDate: Wed Dec 27 13:48:47 2023 +0100

tdf#158803 Fix issues detected by pyflakes

Change-Id: Iaa329dff61db894e7d5fecd840e785a53a48b26f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160889
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/cui/qa/uitest/dialogs/chardlg.py b/cui/qa/uitest/dialogs/chardlg.py
index d6ebffac3e1e..6da1e21e2162 100644
--- a/cui/qa/uitest/dialogs/chardlg.py
+++ b/cui/qa/uitest/dialogs/chardlg.py
@@ -150,7 +150,6 @@ class Test(UITestCase):
 # Start Writer.
 with self.ui_test.create_doc_in_start_center("writer"):
 doc = self.xUITest.getTopFocusWindow()
-editWin = doc.getChild("writer_edit")
 
 # Use Format -> Character.
 with 
self.ui_test.execute_dialog_through_command(".uno:FontDialog") as xDialog:
diff --git a/cui/qa/uitest/dialogs/shortcuts.py 
b/cui/qa/uitest/dialogs/shortcuts.py
index 99d2bd1ccedc..ac8a0a791496 100644
--- a/cui/qa/uitest/dialogs/shortcuts.py
+++ b/cui/qa/uitest/dialogs/shortcuts.py
@@ -15,7 +15,6 @@ class Test(UITestCase):
 def test_tab_navigation(self):
 with self.ui_test.create_doc_in_start_center("writer"):
 xWriterDoc = self.xUITest.getTopFocusWindow()
-xWriterEdit = xWriterDoc.getChild("writer_edit")
 
 with self.ui_test.execute_dialog_through_command(".uno:EditStyle") 
as xDialog:
 
diff --git a/dbaccess/qa/python/fdo84315.py b/dbaccess/qa/python/fdo84315.py
index f58b16f51309..680ba7495c3b 100644
--- a/dbaccess/qa/python/fdo84315.py
+++ b/dbaccess/qa/python/fdo84315.py
@@ -10,7 +10,6 @@
 import os
 import unittest
 from collections import deque
-import unohelper
 from org.libreoffice.unotest import UnoInProcess
 
 class Fdo84315(unittest.TestCase):
@@ -67,7 +66,7 @@ class Fdo84315(unittest.TestCase):
 
 xResultset = xStatement.executeQuery('SELECT "id" FROM "test_table"')
 expected_values = deque([0, 1])
-xMeta = self.__test_Query('id', INTEGER, xResultset)
+self.__test_Query('id', INTEGER, xResultset)
 self.__test_ResultSetInteger(xResultset, expected_values)
 
 xCon.dispose()
diff --git a/pyuno/demo/ooextract.py b/pyuno/demo/ooextract.py
index a5699548ce22..0aec00f43a47 100644
--- a/pyuno/demo/ooextract.py
+++ b/pyuno/demo/ooextract.py
@@ -45,7 +45,6 @@ def main():
 
 try:
 opts, args = getopt.getopt(sys.argv[1:], "hc:", ["help", 
"connection-string=", "html"])
-format = None
 url = 
"uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"
 filterName = "Text (Encoded)"
 for o, a in opts:
diff --git a/pyuno/qa/pytests/testcollections_XCellRange.py 

[Libreoffice-commits] core.git: odk/examples

2023-04-18 Thread Chenxiong Qi (via logerrit)
 odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape.py |  243 
++
 1 file changed, 243 insertions(+)

New commits:
commit 10fac0f7f7cdc66d9d1ee5e5bffbeb82973b733a
Author: Chenxiong Qi 
AuthorDate: Sat Feb 11 12:06:45 2023 +0800
Commit: Hossein 
CommitDate: Tue Apr 18 14:33:09 2023 +0200

tdf#143123 Port DevelopersGuide/FirstSteps/HelloTextTableShape to Python

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

diff --git a/odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape.py 
b/odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape.py
new file mode 100644
index ..a0a101e618cc
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape.py
@@ -0,0 +1,243 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import sys
+import traceback
+
+import uno
+import officehelper
+
+from com.sun.star.lang import DisposedException
+from com.sun.star.awt.FontSlant import ITALIC
+from com.sun.star.awt.FontWeight import BOLD
+from com.sun.star.table import BorderLine
+from com.sun.star.table import TableBorder
+from com.sun.star.awt import Size
+from com.sun.star.awt import Point
+
+
+class HelloTextTableShape:
+
+def __init__(self):
+self.remote_context = None
+self.remote_service_manager = None
+
+def use_documents(self) -> None:
+self.use_writer()
+self.use_calc()
+self.use_draw()
+
+def get_remote_service_manager(self) -> None:
+try:
+self.remote_context = officehelper.bootstrap()
+print("Connected to a running office ...")
+return self.remote_context.ServiceManager
+except Exception as e:
+traceback.print_exc()
+sys.exit(1)
+
+def new_doc_component(self, doc_type: str) -> None:
+load_url = "private:factory/" + doc_type
+self.remote_service_manager = self.get_remote_service_manager()
+desktop = self.remote_service_manager.createInstanceWithContext(
+"com.sun.star.frame.Desktop", self.remote_context
+)
+return desktop.loadComponentFromURL(load_url, "_blank", 0, tuple([]))
+
+def use_writer(self) -> None:
+try:
+doc = self.new_doc_component("swriter")
+xtext = doc.Text
+self.manipulateText(xtext)
+
+# insert TextTable and get cell text, then manipulate text in cell
+table = doc.createInstance("com.sun.star.text.TextTable")
+xtext.insertTextContent(xtext.End, table, False)
+
+xcell = table[1, 0]
+self.manipulateText(xcell)
+self.manipulateTable(table)
+
+# insert RectangleShape and get shape text, then manipulate text
+writer_shape = 
doc.createInstance("com.sun.star.drawing.RectangleShape")
+writer_shape.setSize(Size(1, 1))
+xtext.insertTextContent(xtext.End, writer_shape, False)
+# wrap text inside shape
+writer_shape.TextContourFrame = True
+
+self.manipulateText(writer_shape)
+self.manipulateShape(writer_shape)
+
+bookmark = doc.createInstance("com.sun.star.text.Bookmark")
+bookmark.Name = "MyUniqueBookmarkName"
+# insert the bookmark at the end of the document
+xtext.insertTextContent(xtext.End, bookmark, False)
+
+# Query the added bookmark and set a string
+found_bookmark = doc.Bookmarks.getByName("MyUniqueBookmarkName")
+found_bookmark.Anchor.String = (
+"The throat mike, glued to her neck, "
+"looked as much as possible like an analgesic dermadisk."
+)
+
+for text_table in doc.TextTables:
+text_table.BackColor = 0xC8FFB9
+except DisposedException:
+self.remote_context = None
+raise
+
+def use_calc(self) -> None:
+try:
+doc = self.new_doc_component("scalc")
+sheet = doc.Sheets[0]
+
+# get cell A2 in first sheet
+cell = sheet[1, 0]
+cell.IsTextWrapped = True
+
+self.manipulateText(cell)
+self.manipulateTable(sheet)
+
+# create and insert RectangleShape and get shape text,
+# then manipulate text
+shape = doc.createInstance("com.sun.star.drawing.RectangleShape")
+shape.Size = Size(1, 1)
+shape.Position = Point(7000, 3000)
+shape.TextContourFrame = True
+ 

[Libreoffice-commits] core.git: comphelper/JunitTest_comphelper_complex.mk comphelper/Module_comphelper.mk comphelper/PythonTest_comphelper_python.mk comphelper/qa

2023-01-31 Thread Chenxiong Qi (via logerrit)
 comphelper/JunitTest_comphelper_complex.mk |2 
 comphelper/Module_comphelper.mk|1 
 comphelper/PythonTest_comphelper_python.mk |   13 
 comphelper/qa/complex/comphelper/SequenceOutputStreamUnitTest.java |  132 
--
 comphelper/qa/complex/comphelper_all.sce   |1 
 comphelper/qa/python/test_sequence_output_stream.py|   84 
++
 6 files changed, 98 insertions(+), 135 deletions(-)

New commits:
commit 6f112bd40fe78141de865934145d81b1258b36de
Author: Chenxiong Qi 
AuthorDate: Tue Dec 20 22:20:23 2022 +0800
Commit: Hossein 
CommitDate: Tue Jan 31 12:18:47 2023 +

tdf#97362 Convert comphelper SequenceOutputStreamUnitTest to Python

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

diff --git a/comphelper/JunitTest_comphelper_complex.mk 
b/comphelper/JunitTest_comphelper_complex.mk
index 1171eb1cd232..e35857b35b07 100644
--- a/comphelper/JunitTest_comphelper_complex.mk
+++ b/comphelper/JunitTest_comphelper_complex.mk
@@ -23,11 +23,9 @@ $(eval $(call 
gb_JunitTest_use_unoapi_jars,comphelper_complex))
 
 $(eval $(call gb_JunitTest_add_sourcefiles,comphelper_complex,\
 comphelper/qa/complex/comphelper/Map \
-comphelper/qa/complex/comphelper/SequenceOutputStreamUnitTest \
 ))
 
 $(eval $(call gb_JunitTest_add_classes,comphelper_complex,\
-complex.comphelper.SequenceOutputStreamUnitTest \
 complex.comphelper.Map \
 ))
 
diff --git a/comphelper/Module_comphelper.mk b/comphelper/Module_comphelper.mk
index 7541a59f1641..c483e50b0cc6 100644
--- a/comphelper/Module_comphelper.mk
+++ b/comphelper/Module_comphelper.mk
@@ -27,6 +27,7 @@ $(eval $(call gb_Module_add_targets,comphelper,\
 
 $(eval $(call gb_Module_add_subsequentcheck_targets,comphelper,\
 JunitTest_comphelper_complex \
+PythonTest_comphelper_python \
 ))
 
 $(eval $(call gb_Module_add_check_targets,comphelper,\
diff --git a/comphelper/PythonTest_comphelper_python.mk 
b/comphelper/PythonTest_comphelper_python.mk
new file mode 100644
index ..e020deb9899c
--- /dev/null
+++ b/comphelper/PythonTest_comphelper_python.mk
@@ -0,0 +1,13 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+$(eval $(call gb_PythonTest_PythonTest,comphelper_python))
+$(eval $(call 
gb_PythonTest_add_modules,comphelper_python,$(SRCDIR)/comphelper/qa/python,\
+   test_sequence_output_stream \
+))
+# vim: set noet sw=4 ts=4:
diff --git a/comphelper/qa/complex/comphelper/SequenceOutputStreamUnitTest.java 
b/comphelper/qa/complex/comphelper/SequenceOutputStreamUnitTest.java
deleted file mode 100644
index 03906134b9f7..
--- a/comphelper/qa/complex/comphelper/SequenceOutputStreamUnitTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-package complex.comphelper;
-
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.uno.UnoRuntime;
-
-import com.sun.star.io.XSequenceOutputStream;
-import com.sun.star.io.XSeekableInputStream;
-
-import java.util.Random;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openoffice.test.OfficeConnection;
-import static org.junit.Assert.*;
-
-/* Document.
- */
-
-public class SequenceOutputStreamUnitTest
-{
-private XMultiServiceFactory m_xMSF = null;
-
-@Before public void before() {
-try {
-m_xMSF = getMSF();
-} catch (Exception e) {
-fail ("Cannot create service factory!");
-}
-if (m_xMSF==null) {
-fail ("Cannot create service factory!");
-}
-}
-
-@After public void after() {
-m_xMSF = null;
-}
-
-

[Libreoffice-commits] core.git: odk/examples

2023-01-19 Thread Chenxiong Qi (via logerrit)
 odk/examples/examples.html |   47 +++-
 odk/examples/python/Spreadsheet/ChartTypeChange.py |  101 +
 odk/examples/python/Spreadsheet/EuroAdaption.py|  164 +++
 odk/examples/python/Spreadsheet/SCalc.py   |  225 +
 4 files changed, 530 insertions(+), 7 deletions(-)

New commits:
commit 9753aa4a776af24c1bfb9cd41867ee2078438934
Author: Chenxiong Qi 
AuthorDate: Thu Dec 8 18:47:13 2022 +0800
Commit: Hossein 
CommitDate: Thu Jan 19 21:39:01 2023 +

tdf#143123 Port some Spreadsheet Java examples to Python

Some examples inside odk/examples/java/Spreadsheet are ported to
Python:

ChartTypeChange.java-> ChartTypeChange.py
EuroAdaption.java   -> EuroAdaption.py
SCalc.java  -> SCalc.py

Code format is checked with 'pycodestyle':

pycodestyle --ignore=E501,E722 odk/examples/python/Spreadsheet/*.py

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

diff --git a/odk/examples/examples.html b/odk/examples/examples.html
index 86589c3624a0..f50dffbc79e8 100644
--- a/odk/examples/examples.html
+++ b/odk/examples/examples.html
@@ -509,13 +509,46 @@
 
 
   
-  
- 
- 
- No Additional information
- 
- 
- 
+
+  
+
+  Spreadsheet Document Examples
+  Description
+
+
+  ChartTypeChange
+  This class loads a LibreOffice 
%PRODUCT_RELEASE% Calc document and changes the type of the embedded chart.
+
+
+  EuroAdaption
+  The application connects to the office 
server and gets
+the  multi component factory, opens 
an empty Calc document, enters an
+example text, sets the number format to DM, changes the 
number format to
+EUR (Euro), and uses the DM/EUR factor on each cell with 
content.
+  
+
+
+  SCalc
+  The program connects to the office server 
and gets the
+ multi component factory. Then an 
empty calc document will be opened,
+cell styles will be created, some data will be inserted 
into the sheets,
+and the created cell styles will be applied. Finally, a 3D 
chart will be
+inserted.
+  
+
+  
+
+  
+
+
+  
+
+  
+
+ No Additional information
+
+  
+
   
 
   
diff --git a/odk/examples/python/Spreadsheet/ChartTypeChange.py 
b/odk/examples/python/Spreadsheet/ChartTypeChange.py
new file mode 100644
index ..6ee2c31d6766
--- /dev/null
+++ b/odk/examples/python/Spreadsheet/ChartTypeChange.py
@@ -0,0 +1,101 @@
+# -*- 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/.
+#
+
+import sys
+import time
+import traceback
+from typing import Union
+
+import officehelper
+from com.sun.star.awt import Rectangle
+
+
+def main():
+try:
+remote_context = officehelper.bootstrap()
+srv_mgr = remote_context.getServiceManager()
+desktop = srv_mgr.createInstanceWithContext(
+"com.sun.star.frame.Desktop", remote_context
+)
+doc = desktop.loadComponentFromURL("private:factory/scalc", "_blank", 
0, tuple())
+sheet = doc.Sheets[0]
+
+cell_values = (
+("", "Jan", "Feb", "Mar", "Apr", "Mai"),
+("Profit", 12.3, 43.2, 5.1, 76, 56.8),
+("Rival in business", 12.2, 12.6, 17.7, 20.4, 100),
+)
+
+# Write the data into spreadsheet.
+for row, row_data in enumerate(cell_values):
+for column, cell_value in enumerate(row_data):
+insert_into_cell(column, row, cell_value, sheet)
+
+# Create a rectangle, which holds the size of the chart.
+rect = Rectangle()
+rect.X, rect.Y, rect.Width, rect.Height = 500, 3000, 25000, 11000
+
+# Create the Unicode of the character for the column name.
+char_rect = chr(65 + len(cell_values[0]) - 1)
+# Get the cell range of the written values.
+chart_cell_range = sheet[f"A1:{char_rect}{len(cell_values)}"]

[Libreoffice-commits] core.git: unotools/Module_unotools.mk unotools/PythonTest_unotools_python.mk unotools/qa

2023-01-16 Thread Chenxiong Qi (via logerrit)
 unotools/Module_unotools.mk|2 
 unotools/PythonTest_unotools_python.mk |   16 ++
 unotools/qa/complex/tempfile/TempFileUnitTest.java |   91 
 unotools/qa/complex/tempfile/Test01.java   |   92 
 unotools/qa/complex/tempfile/Test02.java   |   75 --
 unotools/qa/complex/tempfile/TestHelper.java   |  123 -
 unotools/qa/python/test_tempfile.py|  149 +
 7 files changed, 166 insertions(+), 382 deletions(-)

New commits:
commit be7f3df701e4d94b64af6626d53e03d9336a09cf
Author: Chenxiong Qi 
AuthorDate: Sun Dec 18 15:32:40 2022 +0800
Commit: Hossein 
CommitDate: Tue Jan 17 06:20:58 2023 +

tdf#97362 Convert unotools tempfile tests to Python

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

diff --git a/unotools/Module_unotools.mk b/unotools/Module_unotools.mk
index d2e13a8520d8..5d8b786be527 100644
--- a/unotools/Module_unotools.mk
+++ b/unotools/Module_unotools.mk
@@ -14,7 +14,7 @@ $(eval $(call gb_Module_add_targets,unotools,\
 ))
 
 $(eval $(call gb_Module_add_subsequentcheck_targets,unotools,\
-JunitTest_unotools_complex \
+PythonTest_unotools_python \
 ))
 $(eval $(call gb_Module_add_check_targets,unotools,\
 CppunitTest_unotools_configpaths \
diff --git a/unotools/PythonTest_unotools_python.mk 
b/unotools/PythonTest_unotools_python.mk
new file mode 100644
index ..5201cad4c219
--- /dev/null
+++ b/unotools/PythonTest_unotools_python.mk
@@ -0,0 +1,16 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_PythonTest_PythonTest,unotools_python))
+
+$(eval $(call 
gb_PythonTest_add_modules,unotools_python,$(SRCDIR)/unotools/qa/python,\
+   test_tempfile \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/unotools/qa/complex/tempfile/TempFileUnitTest.java 
b/unotools/qa/complex/tempfile/TempFileUnitTest.java
deleted file mode 100644
index c737deaed70a..
--- a/unotools/qa/complex/tempfile/TempFileUnitTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-package complex.tempfile;
-
-import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.ucb.XSimpleFileAccess;
-import com.sun.star.uno.UnoRuntime;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openoffice.test.OfficeConnection;
-import static org.junit.Assert.*;
-
-public class TempFileUnitTest
-{
-private XMultiServiceFactory m_xMSF = null;
-private XSimpleFileAccess m_xSFA = null;
-
-@Before public void before() {
-m_xMSF = getMSF();
-if ( m_xMSF == null ) {
-fail ( "Cannot create service factory!" );
-}
-try
-{
-Object oSFA = m_xMSF.createInstance( 
"com.sun.star.ucb.SimpleFileAccess" );
-m_xSFA = UnoRuntime.queryInterface( XSimpleFileAccess.class, oSFA 
);
-}
-catch ( Exception e )
-{
-fail ( "Cannot get simple file access!" + e);
-}
-if ( m_xSFA == null ) {
-fail ( "Cannot get simple file access!" );
-}
-}
-
-@After public void after() {
-m_xMSF = null;
-m_xSFA = null;
-}
-
-@Test public void ExecuteTest01() throws Exception {
-Test01 aTest = new Test01( m_xMSF, m_xSFA );
-assertTrue( "Test01 failed!", aTest.test() );
-}
-
-@Test public void ExecuteTest02() throws Exception {
-Test02 aTest = new Test02( m_xMSF, m_xSFA );
-assertTrue( "Test02 failed!", aTest.test() );
-}
-
-private XMultiServiceFactory getMSF()
-{
-return 

[Libreoffice-commits] core.git: odk/examples

2022-12-02 Thread Chenxiong Qi (via logerrit)
 odk/examples/examples.html|   48 +
 odk/examples/python/Text/BookmarkInsertion.py |  160 
 odk/examples/python/Text/GraphicsInserter.py  |  100 ++
 odk/examples/python/Text/HardFormatting.py|  110 +++
 odk/examples/python/Text/SWriter.py   |  210 ++
 odk/examples/python/Text/StyleCreation.py |   94 +
 odk/examples/python/Text/StyleInitialization.py   |  109 +++
 odk/examples/python/Text/TextDocumentStructure.py |   79 
 odk/examples/python/Text/TextReplace.py   |  106 +++
 odk/examples/python/Text/WriterSelector.py|   67 +++
 10 files changed, 1083 insertions(+)

New commits:
commit 8f34b0d40e149b7274a1aa4ce0b33ddbf825ee52
Author: Chenxiong Qi 
AuthorDate: Sun Sep 18 15:27:31 2022 +0800
Commit: Hossein 
CommitDate: Sat Dec 3 01:48:39 2022 +

tdf#143123 Port Text Java examples to Python

The examples inside odk/examples/java/Text are ported to Python:

BookmarkInsertion.java -> BookmarkInsertion.py
GraphicsInserter.java  -> GraphicsInserter.py
HardFormatting.java-> HardFormatting.py
StyleCreation.java -> StyleCreation.py
SWriter.java   -> SWriter.py
StyleInitialization.java   -> StyleInitialization.py
TextDocumentStructure.java -> TextDocumentStructure.py
TextReplace.java   -> TextReplace.py
WriterSelector.java-> WriterSelector.py

Code format is checked with 'pycodestyle':

pycodestyle --ignore=E501,E722 odk/examples/python/Text/*.py

Some Java methods are merged when ported to Python.

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

diff --git a/odk/examples/examples.html b/odk/examples/examples.html
index 2b23080961fb..6cfcc045ad1f 100644
--- a/odk/examples/examples.html
+++ b/odk/examples/examples.html
@@ -459,6 +459,54 @@
 
   
 
+
+  
+
+  
+
+  Text Document Examples
+  Description
+
+
+  BookmarkInsertion
+  This application opens an empty text 
document and enters an example text. Afterwards, some bookmarks will be 
inserted.
+
+
+  HardFormatting
+  This program opens an empty text document 
and enters an example text, some text attributes will be inspected, and the PropertyState will be checked from the 
selection.
+
+
+  SWriter
+  This program opens an empty text document 
and enters some text, and a text table, a colored text, and text frame will be 
inserted.
+
+
+  StyleCreation
+  This program opens an empty text 
document. Then a new paragraph style will be created, and applied.
+
+
+  StyleInitialization
+  This program opens an empty text document 
and enters an example text. The paragraph collection will be used, in order to 
apply a different paragraph style on the paragraphs.
+
+
+  TextDocumentStructure
+  This program opens an empty text document 
and enters an example text. Document structure will be printed out. Looping 
through the paragraphs and their portions in a more Pythonic way instead of 
calling the methods of XEnumeration interface.
+
+
+  TextReplace
+  The program opens an empty text document 
and enters an example text, and some English spelled words will be replaced 
with US spelled words.
+
+
+  GraphicsInserter
+  The GraphicsInserter creates a graphics 
object on an empty text document by setting its position, width, height, and 
URL.
+
+
+  WriterSelector
+  This program gives you information on the 
selected objects, e.g. text range, text frame or graphics.
+
+  
+
+  
+
 
   
   
diff --git a/odk/examples/python/Text/BookmarkInsertion.py 
b/odk/examples/python/Text/BookmarkInsertion.py
new file mode 100644
index ..5b801f6121ea
--- /dev/null
+++ b/odk/examples/python/Text/BookmarkInsertion.py
@@ -0,0 +1,160 @@
+# -*- 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 

[Libreoffice-commits] core.git: odk/examples odk/Package_examples.mk

2022-10-13 Thread Chenxiong Qi (via logerrit)
 odk/Package_examples.mk   |6 
 odk/examples/examples.html|   36 +
 odk/examples/python/DocumentHandling/DocumentConverter.py |   91 ++
 odk/examples/python/DocumentHandling/DocumentLoader.py|   42 +-
 odk/examples/python/DocumentHandling/DocumentPrinter.py   |   71 ++
 odk/examples/python/DocumentHandling/DocumentSaver.py |   81 
 odk/examples/python/DocumentHandling/README.md|   56 
 odk/examples/python/DocumentHandling/tests/hello.odt  |binary
 odk/examples/python/DocumentLoader/README.md  |   12 -
 9 files changed, 374 insertions(+), 21 deletions(-)

New commits:
commit 665d1633c9e08da85fae179e62923211bc07c480
Author: Chenxiong Qi 
AuthorDate: Wed Sep 14 09:29:25 2022 +0800
Commit: Hossein 
CommitDate: Thu Oct 13 15:41:40 2022 +0200

tdf#143123 port DocumentHandling examples to Python

This port keeps the similarity with Java ones as much as possible.

examples.html is also updated by adding the Python examples.

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

diff --git a/odk/Package_examples.mk b/odk/Package_examples.mk
index 6749bcdcc798..457aea37e166 100644
--- a/odk/Package_examples.mk
+++ b/odk/Package_examples.mk
@@ -541,6 +541,12 @@ $(eval $(call 
gb_Package_add_files_with_dir,odk_examples,$(SDKDIRNAME)/examples,
 python/toolpanel/toolpanel.component \
 python/toolpanel/toolpanel.py \
 python/toolpanel/toolpanels/poc.xdl \
+python/DocumentHandling/DocumentConverter.py \
+python/DocumentHandling/DocumentLoader.py \
+python/DocumentHandling/DocumentPrinter.py \
+python/DocumentHandling/DocumentSaver.py \
+python/DocumentHandling/README.md \
+python/DocumentHandling/tests/hello.odt \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/odk/examples/examples.html b/odk/examples/examples.html
index 9a1bf3de6b3a..2b23080961fb 100644
--- a/odk/examples/examples.html
+++ b/odk/examples/examples.html
@@ -423,6 +423,42 @@
  
  

+
+  
+
+  
+
+  Document Handling Examples
+  Description
+
+
+  
+DocumentConverter
+  
+  The program offers a service that converts 
arbitrary documents to a favored document type.
+
+
+  
+DocumentLoader
+  
+  The DocumentLoader can open a new or an 
existing document.
+
+
+  
+DocumentPrinter
+  
+  The DocumentPrinter allows you to print the 
favored pages of a specified document on your favored printer.
+
+
+  
+DocumentSaver
+  
+  The DocumentSaver shows how to save a 
document and how you can change the type of your document.
+
+  
+
+  
+
 
   
   
diff --git a/odk/examples/python/DocumentHandling/DocumentConverter.py 
b/odk/examples/python/DocumentHandling/DocumentConverter.py
new file mode 100644
index ..a1f54fca9102
--- /dev/null
+++ b/odk/examples/python/DocumentHandling/DocumentConverter.py
@@ -0,0 +1,91 @@
+# -*- 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/.
+#
+
+import argparse
+import os
+import sys
+from os.path import abspath, basename, isdir, join, splitext
+
+import uno
+import unohelper
+from com.sun.star.beans import PropertyValue
+from com.sun.star.connection import NoConnectException
+
+PROG = "$OFFICE_PROGRAM_PATH/python {}".format(basename(sys.argv[0]))
+SOFFICE_CONNECTION_URI = 
"uno:socket,host=localhost,port=2083;urp;StarOffice.ComponentContext"
+
+
+def connect_soffice():
+"""Connect to remote running LibreOffice"""
+local_context = uno.getComponentContext()
+resolver = local_context.ServiceManager.createInstanceWithContext(
+"com.sun.star.bridge.UnoUrlResolver", local_context
+)
+try:
+remote_context = resolver.resolve(SOFFICE_CONNECTION_URI)
+except NoConnectException:
+raise Exception("Cannot establish a connection to LibreOffice.")
+
+return remote_context.ServiceManager.createInstanceWithContext(
+"com.sun.star.frame.Desktop", remote_context
+)
+
+
+def convert(src_file, dest_file, to_type):
+src_url = "file://{}".format(src_file).replace("\\", "/")
+dest_url = 

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

2022-09-05 Thread Chenxiong Qi (via logerrit)
 sc/qa/unit/data/ods/pivottable_restore_query_filter.ods |binary
 sc/qa/unit/pivottable_filters_test.cxx  |   41 
 sc/source/filter/xml/xmlfilti.cxx   |2 
 3 files changed, 42 insertions(+), 1 deletion(-)

New commits:
commit 20c7fbad7d929df335b0610a748b6e1d694dafaf
Author: Chenxiong Qi 
AuthorDate: Sat Aug 27 16:00:19 2022 +0800
Commit: Xisco Fauli 
CommitDate: Mon Sep 5 21:53:40 2022 +0200

tdf#73845 restore Empty and NonEmpty query filter after FILEOPEN

Signed-off-by: Chenxiong Qi 
Change-Id: I659e0d97c44bf189f457ca04eb49248121278c10
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138919
Tested-by: Jenkins
Reviewed-by: Hossein 
(cherry picked from commit 26e3bfa02c4d582fd430171d509fa570ca364d35)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139427
Reviewed-by: Xisco Fauli 

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


[Libreoffice-commits] core.git: pyuno/qa uitest/libreoffice

2022-09-05 Thread Chenxiong Qi (via logerrit)
 pyuno/qa/pytests/insertremovecells.py |   12 ++--
 uitest/libreoffice/calc/document.py   |2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 9928f139e858768047b8dea0405720395beb18cd
Author: Chenxiong Qi 
AuthorDate: Thu Sep 1 08:44:20 2022 +0800
Commit: Noel Grandin 
CommitDate: Mon Sep 5 16:05:56 2022 +0200

tdf#97361 replace getCellByPosition with access by subscript

Signed-off-by: Chenxiong Qi 
Change-Id: I50d6e29c34e3cf72cdf0afc9f118fafc3c144eaf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139141
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/pyuno/qa/pytests/insertremovecells.py 
b/pyuno/qa/pytests/insertremovecells.py
index f1c0fa176113..1d850a65d9fd 100644
--- a/pyuno/qa/pytests/insertremovecells.py
+++ b/pyuno/qa/pytests/insertremovecells.py
@@ -57,19 +57,19 @@ class InsertRemoveCells(unittest.TestCase):
   (3, 3, '6', 6.0),
   (5, 1, '1', 1.0),
 )
-for pos in empty_cells:
-cell = sheet.getCellByPosition(*pos)
+for col, row in empty_cells:
+cell = sheet[row,col]
 self.assertEqual('EMPTY', cell.Type.value)
 
-for x, y, f, s, val in formula_cells:
-cell = sheet.getCellByPosition(x, y)
+for col, row, f, s, val in formula_cells:
+cell = sheet[row,col]
 self.assertEqual('FORMULA', cell.Type.value)
 self.assertEqual(f, cell.getFormula())
 self.assertEqual(s, cell.String)
 self.assertEqual(val, cell.Value)
 
-for x, y, s, val in value_cells:
-cell = sheet.getCellByPosition(x, y)
+for col, row, s, val in value_cells:
+cell = sheet[row,col]
 self.assertEqual(s, cell.String)
 self.assertEqual(val, cell.Value)
 
diff --git a/uitest/libreoffice/calc/document.py 
b/uitest/libreoffice/calc/document.py
index 40a2ec635e3c..b837bda72521 100644
--- a/uitest/libreoffice/calc/document.py
+++ b/uitest/libreoffice/calc/document.py
@@ -24,7 +24,7 @@ def get_cell_by_position(document, tab, column, row):
 row -- The 0-based row number
 """
 sheet = get_sheet_from_doc(document, tab)
-return sheet.getCellByPosition(column, row)
+return sheet[row,column]
 
 def get_column(document, column, tab = 0):
 """ Get the column object through the column index


[Libreoffice-commits] core.git: pyuno/qa

2022-09-05 Thread Chenxiong Qi (via logerrit)
 pyuno/qa/pytests/testcollections_XNameContainer.py |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 14cff82b314709db488d929b75c254fbb0355419
Author: Chenxiong Qi 
AuthorDate: Wed Aug 31 21:59:20 2022 +0800
Commit: Noel Grandin 
CommitDate: Mon Sep 5 16:05:28 2022 +0200

tdf#97361 replace getCellRangeByPosition with slices

Signed-off-by: Chenxiong Qi 
Change-Id: I4368adca1e9500c6f926ea1f28b0790b06fae739
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139140
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/pyuno/qa/pytests/testcollections_XNameContainer.py 
b/pyuno/qa/pytests/testcollections_XNameContainer.py
index c544ca9dd181..ac34049a79df 100644
--- a/pyuno/qa/pytests/testcollections_XNameContainer.py
+++ b/pyuno/qa/pytests/testcollections_XNameContainer.py
@@ -33,7 +33,7 @@ class TestXNameContainer(CollectionsTestBase):
 # Given
 spr = self.createBlankSpreadsheet()
 ranges = getSheetCellRangesInstance(spr)
-new_range = spr.Sheets[0].getCellRangeByPosition(1, 2, 1, 2)
+new_range = spr.Sheets[0][2:3,1:2]
 
 # When
 ranges['foo'] = new_range
@@ -51,7 +51,7 @@ class TestXNameContainer(CollectionsTestBase):
 # Given
 spr = self.createBlankSpreadsheet()
 ranges = getSheetCellRangesInstance(spr)
-new_range = spr.Sheets[0].getCellRangeByPosition(1, 2, 1, 2)
+new_range = spr.Sheets[0][2:3,1:2]
 
 # When / Then
 with self.assertRaises(TypeError):
@@ -65,8 +65,8 @@ class TestXNameContainer(CollectionsTestBase):
 # Given
 spr = self.createBlankSpreadsheet()
 ranges = getSheetCellRangesInstance(spr)
-new_range1 = spr.Sheets[0].getCellRangeByPosition(1, 2, 1, 2)
-new_range2 = spr.Sheets[0].getCellRangeByPosition(6, 6, 6, 6)
+new_range1 = spr.Sheets[0][2:3,1:2]
+new_range2 = spr.Sheets[0][6:7,6:7]
 
 # When
 ranges['foo'] = new_range1


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

2022-09-05 Thread Chenxiong Qi (via logerrit)
 sc/qa/unit/data/ods/pivottable_restore_query_filter.ods |binary
 sc/qa/unit/pivottable_filters_test.cxx  |   41 
 sc/source/filter/xml/xmlfilti.cxx   |2 
 3 files changed, 42 insertions(+), 1 deletion(-)

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

tdf#73845 restore Empty and NonEmpty query filter after FILEOPEN

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

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