diff options
Diffstat (limited to 'unotest/source/python/org/libreoffice/unotest.py')
-rw-r--r-- | unotest/source/python/org/libreoffice/unotest.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/unotest/source/python/org/libreoffice/unotest.py b/unotest/source/python/org/libreoffice/unotest.py index 3ec016adfda4..883d3a40e47e 100644 --- a/unotest/source/python/org/libreoffice/unotest.py +++ b/unotest/source/python/org/libreoffice/unotest.py @@ -31,6 +31,11 @@ except ImportError: print(" URE_BOOTSTRAP=file:///installation/opt/program/fundamentalrc") raise +try: + from urllib.parse import quote +except ImportError: + from urllib import quote + ### utilities ### def mkPropertyValue(name, value): @@ -181,6 +186,18 @@ class UnoInProcess: assert(self.xDoc) return self.xDoc + def openWriterTemplateDoc(self, file): + assert(self.xContext) + smgr = self.getContext().ServiceManager + desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.getContext()) + props = [("Hidden", True), ("ReadOnly", False), ("AsTemplate", True)] + loadProps = tuple([mkPropertyValue(name, value) for (name, value) in props]) + path = os.getenv("TDOC") + url = "file://" + quote(path) + "/" + quote(file) + self.xDoc = desktop.loadComponentFromURL(url, "_blank", 0, loadProps) + assert(self.xDoc) + return self.xDoc + def checkProperties(self, obj, dict, test): for k,v in dict.items(): obj.setPropertyValue(k, v) |