Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/sc/qa/uitest/calc_tests6/   (LibreOffice Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 6 kB image not shown  

Quelle  multipleOperations.py

  Sprache: Python
 

rahmenlose Ansicht.py DruckansichtUnknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

from uitest.framework import UITestCase
from libreoffice.uno.propertyvalue import mkPropertyValues
from libreoffice.calc.document import get_cell_by_position
from uitest.uihelper.calc import enter_text_to_cell

#https://www.linuxtopia.org/online_books/office_guides/openoffice_3_calc_user_guide/openoffice_calc_Multiple_operations_Multiple_operations_in_columns_or_rows.html

class multipleOperations(UITestCase):

   def test_multiple_operations_one_variable(self):
        with self.ui_test.create_doc_in_start_center("calc") as document:
            xCalcDoc = self.xUITest.getTopFocusWindow()
            xGridWindow = xCalcDoc.getChild("grid_window")

            #enter data
            enter_text_to_cell(xGridWindow, "B1", "10")
            enter_text_to_cell(xGridWindow, "B2", "2")
            enter_text_to_cell(xGridWindow, "B3", "10000")
            enter_text_to_cell(xGridWindow, "B4", "2000")
            enter_text_to_cell(xGridWindow, "B5", "=B4*(B1-B2)-B3")

            enter_text_to_cell(xGridWindow, "D2", "500")
            enter_text_to_cell(xGridWindow, "D3", "1000")
            enter_text_to_cell(xGridWindow, "D4", "1500")
            enter_text_to_cell(xGridWindow, "D5", "2000")
            enter_text_to_cell(xGridWindow, "D6", "2500")
            enter_text_to_cell(xGridWindow, "D7", "3000")
            enter_text_to_cell(xGridWindow, "D8", "3500")
            enter_text_to_cell(xGridWindow, "D9", "4000")
            enter_text_to_cell(xGridWindow, "D10", "4500")
            enter_text_to_cell(xGridWindow, "D11", "5000")
            #Select the range D2:E11
            xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "D2:E11"}))
            #Choose Data > Multiple Operations.
            with self.ui_test.execute_modeless_dialog_through_command(".uno:TableOperationDialog") as xDialog:
                #Formulas = B5 ; Column input cell = B4
                formulas = xDialog.getChild("formulas")
                col = xDialog.getChild("col")
                formulas.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$5"}))
                col.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$4"}))
            #verify
            self.assertEqual(get_cell_by_position(document, 041).getValue(), -6000)
            self.assertEqual(get_cell_by_position(document, 042).getValue(), -2000)
            self.assertEqual(get_cell_by_position(document, 043).getValue(), 2000)
            self.assertEqual(get_cell_by_position(document, 044).getValue(), 6000)
            self.assertEqual(get_cell_by_position(document, 045).getValue(), 10000)
            self.assertEqual(get_cell_by_position(document, 046).getValue(), 14000)
            self.assertEqual(get_cell_by_position(document, 047).getValue(), 18000)
            self.assertEqual(get_cell_by_position(document, 048).getValue(), 22000)
            self.assertEqual(get_cell_by_position(document, 049).getValue(), 26000)
            self.assertEqual(get_cell_by_position(document, 0410).getValue(), 30000)

   def test_multiple_operations_several_formulas(self):
        with self.ui_test.create_doc_in_start_center("calc") as document:
            xCalcDoc = self.xUITest.getTopFocusWindow()
            xGridWindow = xCalcDoc.getChild("grid_window")

            #enter data
            enter_text_to_cell(xGridWindow, "B1", "10")
            enter_text_to_cell(xGridWindow, "B2", "2")
            enter_text_to_cell(xGridWindow, "B3", "10000")
            enter_text_to_cell(xGridWindow, "B4", "2000")
            enter_text_to_cell(xGridWindow, "B5", "=B4*(B1-B2)-B3")
            enter_text_to_cell(xGridWindow, "C5", "=B5/B4")

            enter_text_to_cell(xGridWindow, "D2", "500")
            enter_text_to_cell(xGridWindow, "D3", "1000")
            enter_text_to_cell(xGridWindow, "D4", "1500")
            enter_text_to_cell(xGridWindow, "D5", "2000")
            enter_text_to_cell(xGridWindow, "D6", "2500")
            enter_text_to_cell(xGridWindow, "D7", "3000")
            enter_text_to_cell(xGridWindow, "D8", "3500")
            enter_text_to_cell(xGridWindow, "D9", "4000")
            enter_text_to_cell(xGridWindow, "D10", "4500")
            enter_text_to_cell(xGridWindow, "D11", "5000")
            #Select the range D2:F11
            xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "D2:F11"}))
            #Choose Data > Multiple Operations.
            with self.ui_test.execute_modeless_dialog_through_command(".uno:TableOperationDialog") as xDialog:
                #Formulas = B5 ; Column input cell = B4
                formulas = xDialog.getChild("formulas")
                col = xDialog.getChild("col")
                formulas.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$5:$C$5"}))
                col.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$4"}))
            #verify
            self.assertEqual(get_cell_by_position(document, 041).getValue(), -6000)
            self.assertEqual(get_cell_by_position(document, 042).getValue(), -2000)
            self.assertEqual(get_cell_by_position(document, 043).getValue(), 2000)
            self.assertEqual(get_cell_by_position(document, 044).getValue(), 6000)
            self.assertEqual(get_cell_by_position(document, 045).getValue(), 10000)
            self.assertEqual(get_cell_by_position(document, 046).getValue(), 14000)
            self.assertEqual(get_cell_by_position(document, 047).getValue(), 18000)
            self.assertEqual(get_cell_by_position(document, 048).getValue(), 22000)
            self.assertEqual(get_cell_by_position(document, 049).getValue(), 26000)
            self.assertEqual(get_cell_by_position(document, 0410).getValue(), 30000)

            self.assertEqual(get_cell_by_position(document, 051).getValue(), -12)
            self.assertEqual(get_cell_by_position(document, 052).getValue(), -2)
            self.assertEqual(round(get_cell_by_position(document, 053).getValue(),2), 1.33)
            self.assertEqual(get_cell_by_position(document, 054).getValue(), 3)
            self.assertEqual(get_cell_by_position(document, 055).getValue(), 4)
            self.assertEqual(round(get_cell_by_position(document, 056).getValue(),2), 4.67)
            self.assertEqual(round(get_cell_by_position(document, 057).getValue(),2), 5.14)
            self.assertEqual(get_cell_by_position(document, 058).getValue(), 5.5)
            self.assertEqual(round(get_cell_by_position(document, 059).getValue(),2), 5.78)
            self.assertEqual(get_cell_by_position(document, 0510).getValue(), 6)


# vim: set shiftwidth=4 softtabstop=4 expandtab:

¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet am  2026-06-11) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.