2 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 from org
.libreoffice
.unotest
import UnoInProcess
14 class CheckFields(unittest
.TestCase
):
18 cls
._uno
= UnoInProcess()
22 def tearDownClass(cls
):
25 def test_fdo39694_load(self
):
26 placeholders
= ["<Kadr1>", "<Kadr2>", "<Kadr3>", "<Kadr4>", "<Pnname>", "<Pvname>", "<Pgeboren>"]
27 xDoc
= self
.__class
__._uno
.openTemplateFromTDOC("fdo39694.ott")
28 xEnumerationAccess
= xDoc
.getTextFields()
29 xFieldEnum
= xEnumerationAccess
.createEnumeration()
30 for xField
in xFieldEnum
:
31 if xField
.supportsService("com.sun.star.text.TextField.JumpEdit"):
32 xAnchor
= xField
.getAnchor()
33 read_content
= xAnchor
.getString()
34 self
.assertTrue(read_content
in placeholders
,
35 "field %s is not contained: " % read_content
)
38 def test_fdo42073(self
):
39 xDoc
= self
.__class
__._uno
.openEmptyWriterDoc()
40 xBodyText
= xDoc
.getText()
41 xCursor
= xBodyText
.createTextCursor()
42 xTextField
= xDoc
.createInstance("com.sun.star.text.TextField.Input")
43 xBodyText
.insertTextContent(xCursor
, xTextField
, True)
44 read_content
= xTextField
.getPropertyValue("Content")
45 self
.assertEqual("", read_content
)
46 content
= "this is not surprising"
47 xTextField
.setPropertyValue("Content", content
)
48 read_content
= xTextField
.getPropertyValue("Content")
49 self
.assertEqual(content
, read_content
)
52 if __name__
== '__main__':