summaryrefslogtreecommitdiff
path: root/unotest
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-09-07 21:26:02 +0200
committerMichael Stahl <mstahl@redhat.com>2017-09-07 21:44:57 +0200
commit01b0d6da7ffdbd0eeea601020329c82fa1b37c11 (patch)
tree859274a562f3afdd43271a7804c3880f99b9a969 /unotest
parent01cc6e5107c706760939c2331ca57247bd02cb77 (diff)
unotest.py: refactor confusing mess of openDoc functions
Change-Id: I148332c639510c55dea2d09bc7aa695708fbf34c
Diffstat (limited to 'unotest')
-rw-r--r--unotest/source/python/org/libreoffice/unotest.py63
1 files changed, 18 insertions, 45 deletions
diff --git a/unotest/source/python/org/libreoffice/unotest.py b/unotest/source/python/org/libreoffice/unotest.py
index 0bb5212c9d4a..a6a927ca881c 100644
--- a/unotest/source/python/org/libreoffice/unotest.py
+++ b/unotest/source/python/org/libreoffice/unotest.py
@@ -195,72 +195,45 @@ class UnoInProcess:
if not(havePonies):
pyuno.private_initTestEnvironment()
havePonies = True
+
def openEmptyWriterDoc(self):
- assert(self.xContext)
- smgr = self.getContext().ServiceManager
- desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.getContext())
- props = [("Hidden", True), ("ReadOnly", False)]
- loadProps = tuple([mkPropertyValue(name, value) for (name, value) in props])
- self.xDoc = desktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, loadProps)
- assert(self.xDoc)
- return self.xDoc
+ return self.openEmptyDoc("private:factory/swriter")
def openEmptyCalcDoc(self):
- self.xDoc = self.openEmptyDoc("private:factory/scalc")
- return self.xDoc
+ return self.openEmptyDoc("private:factory/scalc")
def openEmptyDoc(self, url, bHidden = True, bReadOnly = False):
- assert(self.xContext)
- smgr = self.getContext().ServiceManager
- desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.getContext())
props = [("Hidden", bHidden), ("ReadOnly", bReadOnly)]
- loadProps = tuple([mkPropertyValue(name, value) for (name, value) in props])
- self.xDoc = desktop.loadComponentFromURL(url, "_blank", 0, loadProps)
- assert(self.xDoc)
- return self.xDoc
+ return self.__openDocFromURL(url, props)
- 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])
+ def openTemplateFromTDOC(self, file):
+ return self.openDocFromTDOC(file, True)
+
+ def openDocFromTDOC(self, file, asTemplate = False):
path = os.getenv("TDOC")
if os.name == "nt":
# do not quote drive letter - it must be "X:"
url = "file:///" + path + "/" + quote(file)
else:
url = "file://" + quote(path) + "/" + quote(file)
- self.xDoc = desktop.loadComponentFromURL(url, "_blank", 0, loadProps)
- assert(self.xDoc)
- return self.xDoc
+ return self.openDocFromURL(url, asTemplate)
- def openBaseDoc(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", False)]
- loadProps = tuple([mkPropertyValue(name, value) for (name, value) in props])
- path = os.getenv("TDOC")
+ def openDocFromAbsolutePath(self, file):
if os.name == "nt":
- #do not quote drive letter - it must be "X:"
- url = "file:///" + path + "/" + quote(file)
+ url = "file:///" + file
else:
- url = "file://" + quote(path) + "/" + quote(file)
- self.xDoc = desktop.loadComponentFromURL(url, "_blank", 0, loadProps)
- assert(self.xDoc)
- return self.xDoc
+ url = "file://" + file
+ return self.openDocFromURL(url)
- def openDoc(self, file):
+ def openDocFromURL(self, url, asTemplate = False):
+ props = [("Hidden", True), ("ReadOnly", False), ("AsTemplate", asTemplate)]
+ return self.__openDocFromURL(url, props)
+
+ def __openDocFromURL(self, url, props):
assert(self.xContext)
smgr = self.getContext().ServiceManager
desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.getContext())
- props = [("Hidden", True), ("ReadOnly", False), ("AsTemplate", False)]
loadProps = tuple([mkPropertyValue(name, value) for (name, value) in props])
- if os.name == "nt":
- url = "file:///" + file
- else:
- url = "file://" + file
self.xDoc = desktop.loadComponentFromURL(url, "_blank", 0, loadProps)
assert(self.xDoc)
return self.xDoc