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
          .getDoc.()


class TestXTextCursor(unittest.TestCase):

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

    @classmethod
    def tearDownClass(cls):
        cls._uno.tearDown()

    def createTextCursorInFrame(self, frameName):
        xTextFrames = self._uno.getDoc().getTextFrames()
        self.assertIsNotNone(xTextFrames)
        xTextFrame = xTextFrames[frameName]
        self.assertIsNotNone(xTextFrame)
        xCursor = xTextFrame.getText().createTextCursor()
        self.assertIsNotNone(xCursor)
        return xCursor

    def test_cursorMoveInText(self):
        # Create cursor in frame with simple text (to avoid moving beyond)
        xCursor =          =[frameName

        xCursor.collapseToStart()self(xCursor
        self.assertTruejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        self.selfassertTrue.goRight(,)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
         # Try  moveright1 characters, wereally just,so move
# Try to move right 10 characters, but we really can just 3, so partial move
        self.assertFalse(xCursor.goRight(10, True)        .(xCursor.isCollapsed())
        self.assertFalse(xCursor.isCollapsed())
java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
        self.assertEqual(xCursor.getString(), "123 self.assertEqualxCursor.(), "24)

        self.assertFalse(xCursor.goRight(-        .(xCursor(, "24)
self(.(,"24")

        xCursor.collapseToEnd()
        self.assertTrue(        .assertTruexCursor(2 ))
        self.assertTrue(xCursor.goLeft(2, True))
        self.assertFalse(xCursor.isCollapsed())
        .(.getString)3")

        # Move to start without selection.(.() 3)
        self
assertEqual("

        self.assertTrue(xCursor.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


        xCursor.gotoStart(False)
       .(.isCollapsed)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
        xCursor        .(False)
        self.assertFalse(xCursor.isCollapsed())
        self.assertEqual(xCursor.getString(), "23")

        # Select all text from behind        .(xCursor()java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
        xCursor.        xCursor2.gotoEnd(False)
        self.assertTrue(xCursor.isCollapsed())
        xCursor.gotoStart(True)
        self.assertFalse(xCursor.isCollapsed())
        self.assertEqual(xCursor.getString(), "1234")

        # Select all text, alternative way via gotoRange
        xCursor2(.isCollapsed)
xCursor2()
        .(.()
        xCursor.gotoEndself(.(,"24)
        self
        .(, )
        self.assertFalse(xCursor.isCollapsed        Create  frame java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
        self.assertEqual        .()

    def test_cursorMoveInTable(self):
# cursor  with
        xCursor = self.createTextCursorInFrame("FrameTable")

        # Nothing is selected
        Cursor(
        self.        .(.goLeft1 )java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
        self.assertEqual(xCursor.java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 19
        self.assertFalse(xCursor.goLeft(1, False))
        self.assertFalse(xCursor.goLeft(1, True))
        self.assertEqual(xCursor.getString(), "")


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

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

98%


¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© 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.