summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJavier Fernandez <jfernandez@igalia.com>2013-05-04 11:53:36 +0000
committerJavier Fernandez <jfernandez@igalia.com>2013-05-08 09:36:41 +0000
commit9c54d77fffc9b6fda1af3020c5d1d2212b8e96c2 (patch)
tree5460cd8391cb1658a6f51237ae5c6067619ee91a /wizards
parentccd34249719614146e2f581e6c3826524745b425 (diff)
PyWebWizard: Fixing bugs and implementation of mising features.
Using the com.sun.star.xml.dom.DocumentBuilder service to create the DOM. Change-Id: I71232dda112f7049b901c3495d024334503e078d
Diffstat (limited to 'wizards')
-rw-r--r--wizards/com/sun/star/wizards/common/XMLHelper.py4
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGDocument.py19
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGSession.py26
3 files changed, 38 insertions, 11 deletions
diff --git a/wizards/com/sun/star/wizards/common/XMLHelper.py b/wizards/com/sun/star/wizards/common/XMLHelper.py
index 7ea3de338370..0af198cf3e0b 100644
--- a/wizards/com/sun/star/wizards/common/XMLHelper.py
+++ b/wizards/com/sun/star/wizards/common/XMLHelper.py
@@ -19,8 +19,8 @@ class XMLHelper:
@classmethod
def addElement(self, parent, name, attNames, attValues):
- doc = parent.ownerDocument
- if (doc == None):
+ doc = parent.getOwnerDocument()
+ if (doc is None):
doc = parent
e = doc.createElement(name)
for i in range(len(attNames)):
diff --git a/wizards/com/sun/star/wizards/web/data/CGDocument.py b/wizards/com/sun/star/wizards/web/data/CGDocument.py
index 4221188f502a..c359faf86d66 100644
--- a/wizards/com/sun/star/wizards/web/data/CGDocument.py
+++ b/wizards/com/sun/star/wizards/web/data/CGDocument.py
@@ -23,6 +23,7 @@ from ...document.OfficeDocument import OfficeDocument
from ...common.Properties import Properties
from ...common.PropertyNames import PropertyNames
from ...common.FileAccess import FileAccess
+from ...common.XMLHelper import XMLHelper
from ..TypeDetection import *
from ...common.Desktop import Desktop
@@ -209,9 +210,21 @@ class CGDocument(ConfigGroup):
def createDOM(self, parent):
d = self.getSettings().cp_DefaultSession.cp_Design
exp = self.getSettings().cp_Exporters.getElement(self.cp_Exporter)
- '''return XMLHelper.addElement(parent, "document", ["title", "description", "author", "format", "filename", "create-date", "update-date", "pages", "size", "icon", "dir", "fn"], [d.cp_DisplayTitle ? self.cp_Title : "", d.cp_DisplayDescription ? self.cp_Description : "", d.cp_DisplayAuthor ? self.cp_Author : "", d.cp_DisplayFileFormat ? getTargetTypeName(exp) : "", d.cp_DisplayFilename ? self.localFilename : "", d.cp_DisplayCreateDate ? self.createDate() : "", d.cp_DisplayUpdateDate ? self.updateDate() : "", d.cp_DisplayPages and (self.pages > -1) ? "" + self.pages() : "", #TODO when do i calculate pages?
- d.cp_DisplaySize ? sizeKB() : "", #TODO when do i calculate size?
- d.cp_DisplayFormatIcon ? getIcon(exp) : "", self.dirName, self.urlFilename])'''
+ return XMLHelper.addElement(parent, "document",
+ ["title", "description", "author", "format", "filename",
+ "create-date", "update-date", "pages", "size", "icon",
+ "dir", "fn"],
+ [self.cp_Title if (d.cp_DisplayTitle) else "",
+ self.cp_Description if (d.cp_DisplayDescription) else "",
+ self.cp_Author if (d.cp_DisplayAuthor) else "",
+ self.getTargetTypeName(exp) if (d.cp_DisplayFileFormat) else "",
+ self.localFilename if (d.cp_DisplayFilename) else "",
+ self.createDate() if (d.cp_DisplayCreateDate) else "",
+ self.updateDate() if (d.cp_DisplayUpdateDate) else "",
+ "" + self.getPages() if (d.cp_DisplayPages and (self.pages > -1)) else "", #TODO when do i calculate pages?
+ self.sizeKB() if (d.cp_DisplaySize) else "", #TODO when do i calculate size?
+ self.getIcon(exp) if (d.cp_DisplayFormatIcon) else "",
+ self.dirName, self.urlFilename])
def updateDate(self):
if self.updatedDate is None:
diff --git a/wizards/com/sun/star/wizards/web/data/CGSession.py b/wizards/com/sun/star/wizards/web/data/CGSession.py
index c0fdf004e7c6..bc1c9848d42d 100644
--- a/wizards/com/sun/star/wizards/web/data/CGSession.py
+++ b/wizards/com/sun/star/wizards/web/data/CGSession.py
@@ -25,7 +25,7 @@ from .CGDesign import CGDesign
from .CGGeneralInfo import CGGeneralInfo
from .CGPublish import CGPublish
-from xml.dom.minidom import Document
+from com.sun.star.beans import StringPair
class CGSession(ConfigGroup):
@@ -40,14 +40,27 @@ class CGSession(ConfigGroup):
self.cp_Publishing = WebConfigSet(CGPublish)
self.valid = False
- def createDOM(self, parent):
- root = XMLHelper.addElement(
- parent, "session", ["name", "screen-size"],
- [self.cp_Name, self.getScreenSize()])
+ def createDOM(self, doc):
+ root = XMLHelper.addElement(doc, "session",
+ ["name", "screen-size"],
+ [self.cp_Name, self.getScreenSize()])
self.cp_GeneralInfo.createDOM(root)
self.cp_Content.createDOM(root)
return root
+ def serializeNode(self, node):
+ xBuffer = self.root.xmsf.createInstance("com.sun.star.io.Pipe")
+ xTextInputStream = self.root.xmsf.createInstance("com.sun.star.io.TextInputStream")
+ xSaxWriter = self.root.xmsf.createInstance( "com.sun.star.xml.sax.Writer" )
+ xSaxWriter.setOutputStream(xBuffer)
+ xTextInputStream.setInputStream(xBuffer)
+ node.serialize(xSaxWriter, tuple([StringPair()]))
+ result = ""
+ while (not xTextInputStream.isEOF()):
+ sLine = xTextInputStream.readLine()
+ if (not sLine == "") and (not sLine.startswith("<?xml")):
+ result = result + sLine + "\n"
+
def getScreenSize(self):
tmp_switch_var1 = self.cp_Design.cp_OptimizeDisplaySize
if tmp_switch_var1 == 0:
@@ -66,6 +79,7 @@ class CGSession(ConfigGroup):
return self.root.cp_Styles.getElement(self.cp_Design.cp_Style)
def createDOM1(self):
- doc = Document()
+ factory = self.root.xmsf.createInstance("com.sun.star.xml.dom.DocumentBuilder")
+ doc = factory.newDocument()
self.createDOM(doc)
return doc