#! /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 from com.sun.star.lang import IllegalArgumentException
# getAnchor for both text frames and ensure we receive ranges we expect
x_frame_1 = self.get_text_frame("Frame1")
x_range_1 = x_frame_1.getAnchor()
self.assertIsNotNone(x_range_1)
self.compare_range(x_range_1, "String1")
# Check how XTextContent::attach works. Try to exchange anchors
x_frame_1.attach(x_range_2)
x_frame_2.attach(x_range_1)
self.compare_range(x_frame_1.getAnchor(), "String2")
self.compare_range(x_frame_2.getAnchor(), "String1")
# Try to attach to None with self.assertRaises(IllegalArgumentException):
x_frame_1.attach(None)
# Trying to attach frame to range from other document
x_doc_2 = self._uno.openDocFromTDOC("xcontrolshape.odt") with self.assertRaises(IllegalArgumentException):
x_frame_1.attach(x_doc_2.getText())
# Helper to extract text content from range and compare to expected string def compare_range(self, x_range, expected_content):
x_cursor = x_range.getText().createTextCursor()
self.assertIsNotNone(x_cursor)
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.