summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJavier Fernandez <jfernandez@igalia.com>2013-05-03 13:03:48 +0000
committerJavier Fernandez <jfernandez@igalia.com>2013-05-08 09:36:37 +0000
commit084e766844fb53482a447d85d471fb1e0f55c063 (patch)
treebc836a40bdd19061dc92d10975bb63d8679af01c /wizards
parent7a7e30a44ba86cfc5246fcdc0990c587f71e9259 (diff)
PyWebWizard: Fixing bugs and implementation of mising features.
Additional files ported to python for the Web.Export module. Change-Id: I77c062e2d349992b9b42632537c8f2ee4ec26b57
Diffstat (limited to 'wizards')
-rw-r--r--wizards/Pyuno_web.mk3
-rw-r--r--wizards/com/sun/star/wizards/web/export/ConfiguredExporter.py51
-rw-r--r--wizards/com/sun/star/wizards/web/export/FilterExporter.py57
-rw-r--r--wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.py70
4 files changed, 181 insertions, 0 deletions
diff --git a/wizards/Pyuno_web.mk b/wizards/Pyuno_web.mk
index a6dbeb74c79c..3933b2745bbf 100644
--- a/wizards/Pyuno_web.mk
+++ b/wizards/Pyuno_web.mk
@@ -57,6 +57,9 @@ $(eval $(call gb_Pyuno_add_files,web,wizards/web,\
export/Exporter.py \
export/AbstractExporter.py \
export/CopyExporter.py \
+ export/FilterExporter.py \
+ export/ConfiguredExporter.py \
+ export/ImpressHTMLExporter.py \
export/__init__.py \
))
$(eval $(call gb_Pyuno_set_componentfile_full,web,wizards/com/sun/star/wizards/web/web,vnd.openoffice.pymodule:wizards.web,.CallWizard))
diff --git a/wizards/com/sun/star/wizards/web/export/ConfiguredExporter.py b/wizards/com/sun/star/wizards/web/export/ConfiguredExporter.py
new file mode 100644
index 000000000000..9a0f1eda59d7
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/export/ConfiguredExporter.py
@@ -0,0 +1,51 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+from ..data.CGArgument import CGArgument
+from ..data.CGExporter import CGExporter
+from .FilterExporter import FilterExporter
+
+class ConfiguredExporter(FilterExporter):
+
+ # (non-Javadoc)
+ # @see com.sun.star.wizards.web.export.Exporter#init(com.sun.star.wizards.web.data.CGExporter)
+ def __init(exporter):
+ super(ConfiguredExporter, self).__init__(exporter)
+ for key in exporter.cp_Arguments.childrenMap.keys():
+ if (not key == "Filter"):
+ value = exporter.cp_Arguments.getElement(key)
+ self.props[key] = self.cast(value.cp_Value)
+
+ def cast(s):
+ s1 = s[1]
+ c = s[0]
+ if (c == "$"):
+ return s1
+ elif (c == "%"):
+ return int(s1)
+ elif (c == "#"):
+ return int(s1)
+ elif (c == "&"):
+ return float(s1)
+ elif (c == "f"):
+ if (s == "false"):
+ return False
+ elif (c == "t"):
+ if (s == "true"):
+ return True
+ return None
+
diff --git a/wizards/com/sun/star/wizards/web/export/FilterExporter.py b/wizards/com/sun/star/wizards/web/export/FilterExporter.py
new file mode 100644
index 000000000000..86266ab7a28c
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/export/FilterExporter.py
@@ -0,0 +1,57 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+
+from .AbstractExporter import AbstractExporter
+from ...common.Properties import Properties
+from ...ui.event.Task import Task
+
+from com.sun.star.io import IOException
+
+# An exporter which is configured with a filter name, and
+# uses the specified filter to export documents.
+class FilterExporter(AbstractExporter):
+
+ filterName = ""
+ props = Properties()
+
+ def __init__(self, exporter_):
+ print ("DEBUG !!! FilterExporter.init - exporter: ", exporter_)
+ super(FilterExporter, self).__init__(exporter_)
+ self.filterName = self.getArgument("Filter", exporter_)
+
+ # (non-Javadoc)
+ # @see com.sun.star.wizards.web.export.Exporter#export(java.lang.Object, java.io.File, com.sun.star.wizards.web.data.CGSettings, com.sun.star.lang.XMultiServiceFactory)
+ def export(self, source, target, xmsf, task):
+ print ("DEBUG !!! FilterExporter.export")
+ result = True
+ document = None
+
+ try:
+ document = self.openDocument(source, xmsf)
+ task.advance(True)
+ self.storeToURL1(document, target, self.filterName, self.props.getProperties1())
+ task.advance(True)
+ except IOException as iox:
+ iox.printStackTrace(System.err)
+ result = False
+ raise iox
+ finally:
+ self.closeDocument(document, xmsf)
+ self.calcFileSize(source, target, xmsf)
+ task.advance(True);
+ return result
diff --git a/wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.py b/wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.py
new file mode 100644
index 000000000000..c60a6ddf55ec
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.py
@@ -0,0 +1,70 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+import com.sun.star.io.IOException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.PropertyNames;
+import com.sun.star.wizards.ui.event.Task;
+import com.sun.star.wizards.web.data.CGDocument;
+import com.sun.star.wizards.web.data.CGSession;
+
+from .ConfiguredExporter import ConfiguredExporter
+
+class ImpressHTMLExporter(ConfiguredExporter):
+
+ SMALL_IMAGE = 512
+ MEDIUM_IMAGE = 640
+ LARGE_IMAGE = 800
+
+ def export(source, targetDirectory, xmsf, task):
+
+ # here set some filter specific properties.
+ # other properties, which are not dependant on
+ # user input are set through the exporter
+ # configuration.
+
+ session = self.getSession(source)
+
+ self.props["Author"] = source.cp_Author
+ self.props["Email"] = session.cp_GeneralInfo.cp_Email
+ self.props["HomepageURL"] = self.getHomepageURL(session)
+ self.props["UserText"] = self.source.cp_Title
+
+ props[PropertyNames.PROPERTY_WIDTH] = self.getImageWidth(session)
+
+ props["UseButtonSet"] = int(session.cp_Design.cp_IconSet)
+
+
+ # now export
+ return super(ImpressHTMLExporter, self).export(source, targetDirectory, xmsf, task)
+
+
+ def getHomepageURL(session):
+ return "../" + "../index.html" if (exporter.cp_OwnDirectory) else "index.html"
+
+ def getImageWidth(session):
+ size = session.cp_Design.cp_OptimizeDisplaySize
+ if (size == 0):
+ return self.SMALL_IMAGE
+ elif (size == 1)
+ return self.MEDIUM_IMAGE
+ elif (size == 2)
+ return self.LARGE_IMAGE
+ return self.MEDIUM_IMAGE
+
+ def getSession(doc)
+ return doc.getSettings().cp_DefaultSession