summaryrefslogtreecommitdiff
path: root/wizards/com/sun/star
diff options
context:
space:
mode:
Diffstat (limited to 'wizards/com/sun/star')
-rw-r--r--wizards/com/sun/star/wizards/ui/event/CommonListener.py25
-rw-r--r--wizards/com/sun/star/wizards/web/Process.py89
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGLayout.py20
3 files changed, 110 insertions, 24 deletions
diff --git a/wizards/com/sun/star/wizards/ui/event/CommonListener.py b/wizards/com/sun/star/wizards/ui/event/CommonListener.py
index 78c4f2a5bbfa..ad15ac2d6c0f 100644
--- a/wizards/com/sun/star/wizards/ui/event/CommonListener.py
+++ b/wizards/com/sun/star/wizards/ui/event/CommonListener.py
@@ -150,3 +150,28 @@ class OMouseListenerProcAdapter( unohelper.Base, XMouseListener ):
def disposing(self, Event):
# TODO: Implement ?
pass
+
+from com.sun.star.io import XStreamListener
+class StreamListenerProcAdapter( unohelper.Base, XStreamListener ):
+ def __init__(self, parent, terminatedCall, startedCall, closedCall, errorCall):
+ self.parent = parent
+ self.terminatedCall = terminatedCall
+ self.startedCall = startedCall
+ self.closedCall = closedCall
+ self.errorCall = errorCall
+
+ def terminated(self):
+ if callable( self. terminatedCall):
+ self.terminatedCall(self, self.parent)
+
+ def started(self):
+ if callable( self.startedCall ):
+ self.startedCall(self, self.parent)
+
+ def closed(self):
+ if callable( self.closedCall ):
+ self.closedCall(self, self.parent)
+
+ def error(self, aException):
+ if callable( self.errorCall ):
+ self.errorCall(self, aException)
diff --git a/wizards/com/sun/star/wizards/web/Process.py b/wizards/com/sun/star/wizards/web/Process.py
index 1516cad9fdfd..bfe4286447ff 100644
--- a/wizards/com/sun/star/wizards/web/Process.py
+++ b/wizards/com/sun/star/wizards/web/Process.py
@@ -21,6 +21,7 @@ from .WebWizardConst import *
from ..common.UCB import UCB
from ..common.FileAccess import FileAccess
from ..ui.event.Task import Task
+from ..ui.event.CommonListener import StreamListenerProcAdapter
from .ProcessErrors import ProcessErrors
from .ExtensionVerifier import ExtensionVerifier
from .ErrorHandler import ErrorHandler
@@ -36,6 +37,8 @@ from .data.CGSettings import CGSettings
from com.sun.star.io import IOException
from com.sun.star.uno import SecurityException
+from com.sun.star.beans import NamedValue
+from com.sun.star.beans import StringPair
# This class is used to process a CGSession object
# and generate a site. </br>
@@ -345,31 +348,85 @@ class Process(ProcessErrors):
@classmethod
def generate1(self, xmsf, layout, doc, fileAccess, targetPath, task):
# a map that contains xsl templates. the keys are the xsl file names.
- #templates = layout.getTemplates(xmsf)
- templates = {}
+ templates = layout.getTemplates(xmsf)
+ self.node = doc
task.advance1(True, TASK_GENERATE_XSL)
# each template generates a page.
- for key,temp in templates:
- transformer = temp.newTransformer()
-
- doc.normalize()
- task.advance(True)
+ for key in templates:
+ temp = templates[key]
# The target file name is like the xsl template filename
# without the .xsl extension.
- #fn = fileAccess.getPath(targetPath, key[:key.length() - 4])
- #f = File(fn)
- #oStream = FileOutputStream(f)
- # Due to a problem occuring when using Xalan-Java 2.6.0 and
- # Java 1.5.0, wrap f in a FileOutputStream here (otherwise, the
- # StreamResult's getSystemId would return a "file:/..." URL while
- # the Xalan code expects a "file:///..." URL):
- #transformer.transform(DOMSource(doc), StreamResult(oStream))
- #oStream.close()
+ fn = fileAccess.getPath(targetPath, key[:len(key) - 4])
+
+ args = list(range(1))
+ nv = NamedValue()
+ nv.Name = "StylesheetURL"
+ nv.Value = temp
+ args[0] = nv
+ arguments = list(range(1))
+ arguments[0] = tuple(args)
+
+ self.tf = Process.createTransformer(xmsf, arguments)
+
+ self.node.normalize()
task.advance(True)
+ # we want to be notfied when the processing is done...
+ self.tf.addListener(StreamListenerProcAdapter(self,
+ self.streamTerminatedHandler,
+ self.streamStartedHandler,
+ self.streamClosedHandler,
+ self.streamErrorHandler))
+
+ # create pipe
+ pipeout = xmsf.createInstance("com.sun.star.io.Pipe")
+ pipein = pipeout
+
+ # connect sax writer to pipe
+ self.xSaxWriter = xmsf.createInstance( "com.sun.star.xml.sax.Writer" )
+ self.xSaxWriter.setOutputStream(pipeout)
+
+ # connect pipe to transformer
+ self.tf.setInputStream(pipein)
+
+ # connect transformer to output
+ xOutputStream = fileAccess.xInterface.openFileWrite(fn)
+ self.tf.setOutputStream(xOutputStream)
+
+ self.tf.start()
+ while (not self.tfCompleted):
+ pass
+ task.advance(True)
+
+
+ @classmethod
+ def createTransformer(self, xmsf, args):
+ tf = xmsf.createInstanceWithArguments("com.sun.star.xml.xslt.XSLT2Transformer",
+ tuple(args))
+ if (tf is None):
+ # TODO: put a dialog telling about the need to install
+ # xslt2-transformer extension here
+ tf = xmsf.createInstanceWithArguments("com.sun.star.xml.xslt.XSLTTransformer",
+ tuple(args))
+ return tf
+
+ def streamTerminatedHandler(self):
+ parent.isTerminated = True
+
+ def streamStartedHandler(self, parent):
+ parent.tfCompleted = False
+ parent.node.serialize(parent.xSaxWriter, tuple([StringPair()]))
+
+ def streamErrorHandler(self, aException):
+ print ("DEBUG !!! Stream 'error' event handler")
+
+ def streamClosedHandler(self, parent):
+ parent.tf.terminate()
+ parent.tfCompleted = True
+
# I broke the export method to two methods
# in a time where a tree with more than one contents was planned.
# I left it that way, because it may be used in the future.
diff --git a/wizards/com/sun/star/wizards/web/data/CGLayout.py b/wizards/com/sun/star/wizards/web/data/CGLayout.py
index 9830664cb98c..5bc919bfb6c6 100644
--- a/wizards/com/sun/star/wizards/web/data/CGLayout.py
+++ b/wizards/com/sun/star/wizards/web/data/CGLayout.py
@@ -16,6 +16,7 @@
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
from ...common.ConfigGroup import ConfigGroup
+from ...common.FileAccess import FileAccess
from ...ui.UIConsts import UIConsts
class CGLayout(ConfigGroup):
@@ -24,20 +25,23 @@ class CGLayout(ConfigGroup):
cp_Name = str()
cp_FSName = str()
+ def getSettings(self):
+ return self.root
+
def createTemplates(self, xmsf):
self.templates = {}
- tf = TransformerFactory.newInstance()
- workPath = getSettings().workPath
+
+ workPath = self.getSettings().workPath
fa = FileAccess(xmsf)
stylesheetPath = fa.getURL(
- getSettings().workPath, "layouts/" + self.cp_FSName)
+ self.getSettings().workPath, "layouts/" + self.cp_FSName)
files = fa.listFiles(stylesheetPath, False)
i = 0
- while i < files.length:
- if FileAccess.getExtension(files[i]).equals("xsl"):
- self.templates.put(
- FileAccess.getFilename(files[i]),
- tf.newTemplates(StreamSource (files[i])))
+ while i < len(files):
+ ext = FileAccess.getExtension(files[i])
+ fileName = FileAccess.getFilename(files[i])
+ if ext == "xsl":
+ self.templates[fileName] = files[i]
i += 1
def getImageUrls(self):