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()
20 cls
._xDoc
= cls
._uno
.openTemplateFromTDOC("fdo39694.ott")
21 cls
._xEmptyDoc
= cls
._uno
.openEmptyWriterDoc()
24 def tearDownClass(cls
):
27 def test_fdo39694_load(self
):
28 placeholders
= ["<Kadr1>", "<Kadr2>", "<Kadr3>", "<Kadr4>", "<Pnname>", "<Pvname>", "<Pgeboren>"]
29 xDoc
= self
.__class
__._xDoc
30 xEnumerationAccess
= xDoc
.getTextFields()
31 xFieldEnum
= xEnumerationAccess
.createEnumeration()
32 for xField
in xFieldEnum
:
33 if xField
.supportsService("com.sun.star.text.TextField.JumpEdit"):
34 xAnchor
= xField
.getAnchor()
35 read_content
= xAnchor
.getString()
36 self
.assertTrue(read_content
in placeholders
,
37 "field %s is not contained: " % read_content
)
39 def test_fdo42073(self
):
40 xDoc
= self
.__class
__._xEmptyDoc
41 xBodyText
= xDoc
.getText()
42 xCursor
= xBodyText
.createTextCursor()
43 xTextField
= xDoc
.createInstance("com.sun.star.text.TextField.Input")
44 xBodyText
.insertTextContent(xCursor
, xTextField
, True)
45 read_content
= xTextField
.getPropertyValue("Content")
46 self
.assertEqual("", read_content
)
47 content
= "this is not surprising"
48 xTextField
.setPropertyValue("Content", content
)
49 read_content
= xTextField
.getPropertyValue("Content")
50 self
.assertEqual(content
, read_content
)
52 if __name__
== '__main__':