PyWebWizard: Fixing bugs and implementation of mising features.
Using the com.sun.star.xml.dom.DocumentBuilder service to create the DOM. Change-Id: I71232dda112f7049b901c3495d024334503e078d
This commit is contained in:
@@ -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)):
|
||||
|
@@ -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:
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user