#! /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
@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"
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
# 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(), "")
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.