#! /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 import os
from org.libreoffice.unotest import UnoInProcess from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK
# 0. create text field
xField = xDoc.createInstance("com.sun.star.text.textfield.SetExpression")
# 1. fill it with properties
self.__class__._uno.setProperties(xField,
{"Content": "0", "IsVisible": True, "Hint": "trying to reproduce fdo#55814", "SubType": 0, # VAR "Value": 0.0})
# 2. create master field
xMaster = xDoc.createInstance("com.sun.star.text.fieldmaster.SetExpression")
# 3. set name of the master field to "foo"
xMaster.setPropertyValue("Name", "foo")
# 4. get Dependent Field # no op in python ;-)
# 5. connect real field to the master
xField.attachTextFieldMaster(xMaster)
# 6. insert text field into the document
xBodyText.insertTextContent(xCursor, xField, False)
# 12.1 insert new paragraph. Note: that's here the difference
xParagraphCursor.gotoEndOfParagraph(False) # not select
# TODO: how to leave the section now?
xBodyText.insertControlCharacter(xCursor, PARAGRAPH_BREAK, False)
xBodyText.insertString(xCursor, "new paragraph", False)
# 13. Access fields to refresh the document
xTextFields = xDoc.getTextFields()
# 14. refresh document to update the fields
xTextFields.refresh()
# 15. retrieve the field
xFieldEnum = xTextFields.createEnumeration()
# Note: we have only one field here, that why nextElement() is just fine here
xField = xFieldEnum.nextElement()
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.