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/.
14 from org
.libreoffice
.unotest
import UnoInProcess
, makeCopyFromTDOC
15 from com
.sun
.star
.beans
import PropertyValue
18 class TestXStyleLoader(unittest
.TestCase
):
22 cls
._uno
= UnoInProcess()
26 def tearDownClass(cls
):
29 def test_loadStyleFromStream(self
):
30 xDoc
= self
.__class
__._uno
.openEmptyWriterDoc()
31 self
.assertIsNotNone(xDoc
)
33 xServiceManager
= self
.__class
__._uno
.xContext
.ServiceManager
34 simpleFileAccess
= xServiceManager
.createInstance(
35 "com.sun.star.ucb.SimpleFileAccess")
36 xInputStream
= simpleFileAccess
.openFileRead(
37 pathlib
.Path(makeCopyFromTDOC("xstyleloader.odt")).as_uri())
39 p1
= PropertyValue(Name
="InputStream", Value
=xInputStream
)
40 p2
= PropertyValue(Name
="LoadTextStyles", Value
=True)
42 styles
= xDoc
.getStyleFamilies()
43 styles
.loadStylesFromURL("private:stream", [p1
, p2
])
44 textStyles
= styles
.getByName("ParagraphStyles")
45 self
.assertTrue(textStyles
.hasByName("Test_Template"))
50 if __name__
== '__main__':
53 # vim: set shiftwidth=4 softtabstop=4 expandtab: