Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / python / xstyleloader.py
blob92b901b9d52727553175f9a7094c308acf5cba87
1 #! /usr/bin/env python
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 import pathlib
12 import unittest
14 from org.libreoffice.unotest import UnoInProcess, makeCopyFromTDOC
15 from com.sun.star.beans import PropertyValue
18 class TestXStyleLoader(unittest.TestCase):
20 @classmethod
21 def setUpClass(cls):
22 cls._uno = UnoInProcess()
23 cls._uno.setUp()
25 @classmethod
26 def tearDownClass(cls):
27 cls._uno.tearDown()
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"))
47 xDoc.close(True)
50 if __name__ == '__main__':
51 unittest.main()
53 # vim: set shiftwidth=4 softtabstop=4 expandtab: