summaryrefslogtreecommitdiff
path: root/test-bugzilla-files/test-bugzilla-files.py
diff options
context:
space:
mode:
Diffstat (limited to 'test-bugzilla-files/test-bugzilla-files.py')
-rw-r--r--test-bugzilla-files/test-bugzilla-files.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/test-bugzilla-files/test-bugzilla-files.py b/test-bugzilla-files/test-bugzilla-files.py
index 862933d..6e9a0ad 100644
--- a/test-bugzilla-files/test-bugzilla-files.py
+++ b/test-bugzilla-files/test-bugzilla-files.py
@@ -317,6 +317,51 @@ def handleCrash(file, disposed):
def alarm_handler(args):
args.kill()
+def exportDoc(xDoc, filterName, validationCommand, filename):
+ props = [ ("FilterName", filterName) ]
+ saveProps = tuple([mkPropertyValue(name, value) for (name, value) in props])
+ fileURL = file:///tmp/filename + extension
+ #xDoc.storeToURL(fileURL, saveProps)
+ print("xDoc.storeToURL " + fileURL + " " + filterName + "\n")
+ if validationCommand:
+ pass
+
+class ExportFileTest:
+ def __init__(self, xDoc, component, filename):
+ self.xDoc = xDoc
+ self.component = component
+ self.filename = filename
+ def run(self, connection):
+ formats = getExportFormats()
+ for format in formats:
+ filterName = getFilterName(format)
+ validation = getValidationCommand(filterName)
+ if filterName is not None
+ xExportedDoc = exportDoc(self.xDoc, filterName, validation, self.filename)
+ if xExportedDoc:
+ xExportedDoc.close(True)
+
+ def getExportFormats():
+ formats = { "calc": ["ods", "xls", "xlsx"],
+ "writer" : ["odt", "doc", "docx"],
+ "impress" : ["odp", "ppt", "pptx"],
+ "draw" : ["odg"],
+ "base" : [],
+ "math" : [],
+ "chart" : ["odc"] }
+ return formats[self.component]
+ def getValidationCommand():
+ return None
+
+ def getFilterName(format)
+ filterNames = { "ods": "calc8",
+ "xls": "MS Excel 97",
+ "xlsx": "Calc Office Open XML"
+ }
+ return filterNames[format]
+
+
+
class LoadFileTest:
def __init__(self, file, state, component):
self.file = file
@@ -336,6 +381,10 @@ class LoadFileTest:
t = threading.Timer(60, alarm_handler, args)
t.start()
xDoc = loadFromURL(xContext, url, t, self.component)
+ t.cancel()
+ if xDoc:
+ exportTest = ExportFileTest(xDoc, self.component, self.file)
+ exportTest.run()
self.state.goodFiles.append(self.file)
except pyuno.getClass("com.sun.star.beans.UnknownPropertyException"):
print("caught UnknownPropertyException " + self.file)