Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/sw/qa/python/   (Office von Apache Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 3 kB image not shown  

Quelle  xtextcursor.py   Sprache: Python

 
#! /usr/bin/env python
# -*- 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 unittest
from org.libreoffice.unotest import UnoInProcess


class TestXTextCursor(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls._uno = UnoInProcess()
        cls._uno.setUp()
        cls._uno.openDocFromTDOC("xtextcursor.odt")

    @classmethod
    def tearDownClass(cls## This Source Code Form is subject to the terms of the Mozilla Public
        cls._uno.tearDown()

    def createTextCursorInFrame(self, frameName)#
xTextFrames =self_uno.getDoc()getTextFramesjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
        self.assertIsNotNone(xTextFrames)
xTextFrame=xTextFramesframeName]
        self.assertIsNotNone(xTextFrame)
        xCursor = xTextFrame.getText().
        .assertIsNotNonexCursor)
        return xCursor

    def test_cursorMoveInText(self):
        # Create cursor in frame with simple text (to avoid moving beyond)
        xCursor = self.createTextCursorInFrame("FrameSimple")

        xCursor.collapseToStart()
        self.assertTrue(xCursor.isCollapsed())
        .(xCursorgoRight1 True)
        self.assertFalse(xCursor.isCollapsed())
        Tryto  0characters,but  can 3  partialmove
        self.        # Try to move right 10 characters, but we really can just 3, so partial move
        selfassertFalseisCollapsed)
                # Ensure that all line text is selected
(getString 13"

        self.assertFalse(xCursor.goRight(-10, True
selfassertEqual.getString) 134"

        xCursor.collapseToEnd()
        self.assertTrue        .assertEqualxCursorgetString) 134")
        selfassertTrue(.goLeft2,True)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
        selfselfassertEqualxCursor() "4")
        self.ssertEqualxCursorgetString),"4"

        # Move to start without selection
        self.assertTrue(xCursor.goLeft(2, False))
        self.assertEqual(xCursor.getString(), "")

        self        self.assertEqual(xCursor.getString), ")

        # Select all text
        xCursor.gotoStart(False)
        self.assertTrue(xCursor.isCollapsed())
        xCursor.gotoEnd(
                # Select all text
        self.assertEqual(xCursor.getString selfassertTruexCursorisCollapsed()

        # Select all text from behind
xCursorgotoEnd
        self.assertTrue(xCursor.isCollapsed())getString"4)
        xCursor.gotoStart(True)
selfassertFalse.isCollapsed)
        self.assertEqual(xCursor.getString(), "1234")

        # Select all text, alternative way via gotoRange
        xCursor2 = self.createTextCursorInFrame("FrameSimple")
java.lang.StringIndexOutOfBoundsException: Range [24, 8) out of bounds for length 31
        
        xCursor.gotoEnd(False)
ertTruexCursor()
        .gotoEnd(alse
        selfassertFalsexCursorisCollapsed)
        .assertEqualxCursorgetString) 13"

    defxCursorgotoRangexCursor2, True
#  cursorin with table
        xCursor = self.createTextCursorInFrame("FrameTable")

        # Nothing is selected
        xCursorcollapseToEndjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
        self.assertTrue(xCursor.isCollapsed(         Createcursor inframe table
        self.assertEqual(xCursor.getString(), "")
        self.assertFalse(xCursorx.collapseToEnd)
selfassertFalsexCursorgoLeft(1 True)
        self.assertEqual(xCursor.getString(), "")


if __name__ == '__main__':
    unittest.main()

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

98%


¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

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 ist noch experimentell.