Kaydet (Commit) 084e7668 authored tarafından Javier Fernandez's avatar Javier Fernandez

PyWebWizard: Fixing bugs and implementation of mising features.

Additional files ported to python for the Web.Export module.

Change-Id: I77c062e2d349992b9b42632537c8f2ee4ec26b57
üst 7a7e30a4
...@@ -57,6 +57,9 @@ $(eval $(call gb_Pyuno_add_files,web,wizards/web,\ ...@@ -57,6 +57,9 @@ $(eval $(call gb_Pyuno_add_files,web,wizards/web,\
export/Exporter.py \ export/Exporter.py \
export/AbstractExporter.py \ export/AbstractExporter.py \
export/CopyExporter.py \ export/CopyExporter.py \
export/FilterExporter.py \
export/ConfiguredExporter.py \
export/ImpressHTMLExporter.py \
export/__init__.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)) $(eval $(call gb_Pyuno_set_componentfile_full,web,wizards/com/sun/star/wizards/web/web,vnd.openoffice.pymodule:wizards.web,.CallWizard))
#
# 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
#
# 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
#
# 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment