[Python-modules-commits] [python-odf] 95/118: Fix the control-implementation attribute based on http://forge.osor.eu/forum/message.php?msg_id=1012
Wolfgang Borgert
debacle at moszumanska.debian.org
Fri Oct 3 21:27:28 UTC 2014
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to reference refs/remotes/upstream/master
in repository python-odf.
commit 5d0f6bd50b8e6811c1f700b33f7f8a7268b882de
Author: Søren Roug <soren.roug at eea.europa.eu>
Date: Sat Aug 14 15:56:57 2010 +0000
Fix the control-implementation attribute based on
http://forge.osor.eu/forum/message.php?msg_id=1012
---
odf/attrconverters.py | 22 ++++++++++-------
tests/testform.py | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 9 deletions(-)
diff --git a/odf/attrconverters.py b/odf/attrconverters.py
index a85d7af..3d56fcb 100644
--- a/odf/attrconverters.py
+++ b/odf/attrconverters.py
@@ -82,12 +82,7 @@ def cnv_family(attribute, arg, element):
raise ValueError, "'%s' not allowed" % str(arg)
return str(arg)
-def cnv_formula(attribute, arg, element):
- """ A string containing a formula. Formulas do not have a predefined syntax, but the string should
- begin with a namespace prefix, followed by a “:” (COLON, U+003A) separator, followed by the text
- of the formula. The namespace bound to the prefix determines the syntax and semantics of the
- formula.
- """
+def __save_prefix(attribute, arg, element):
prefix = arg.split(':',1)[0]
if prefix == arg:
return unicode(arg)
@@ -98,6 +93,14 @@ def cnv_formula(attribute, arg, element):
p = element.get_nsprefix(namespace)
return unicode(arg)
+def cnv_formula(attribute, arg, element):
+ """ A string containing a formula. Formulas do not have a predefined syntax, but the string should
+ begin with a namespace prefix, followed by a “:” (COLON, U+003A) separator, followed by the text
+ of the formula. The namespace bound to the prefix determines the syntax and semantics of the
+ formula.
+ """
+ return __save_prefix(attribute, arg, element)
+
def cnv_ID(attribute, arg, element):
return str(arg)
@@ -149,7 +152,7 @@ def cnv_namespacedToken(attribute, arg, element):
if not pattern_namespacedToken.match(arg):
raise ValueError, "'%s' is not a valid namespaced token" % arg
- return arg
+ return __save_prefix(attribute, arg, element)
def cnv_NCName(attribute, arg, element):
""" NCName is defined in http://www.w3.org/TR/REC-xml-names/#NT-NCName
@@ -255,6 +258,7 @@ attrconverters = {
((ANIMNS,u'name'), None): cnv_string,
((ANIMNS,u'sub-item'), None): cnv_string,
((ANIMNS,u'value'), None): cnv_string,
+# ((DBNS,u'type'), None): cnv_namespacedToken,
((CHARTNS,u'attached-axis'), None): cnv_string,
((CHARTNS,u'class'), (CHARTNS,u'grid')): cnv_major_minor,
((CHARTNS,u'class'), None): cnv_namespacedToken,
@@ -412,7 +416,7 @@ attrconverters = {
((DRAWNS,u'end-line-spacing-horizontal'), None): cnv_string,
((DRAWNS,u'end-line-spacing-vertical'), None): cnv_string,
((DRAWNS,u'end-shape'), None): cnv_IDREF,
- ((DRAWNS,u'engine'), None): cnv_string,
+ ((DRAWNS,u'engine'), None): cnv_namespacedToken,
((DRAWNS,u'enhanced-path'), None): cnv_string,
((DRAWNS,u'escape-direction'), None): cnv_string,
((DRAWNS,u'extrusion-allowed'), None): cnv_boolean,
@@ -633,7 +637,7 @@ attrconverters = {
((FORMNS,u'button-type'), None): cnv_string,
((FORMNS,u'command'), None): cnv_string,
((FORMNS,u'command-type'), None): cnv_string,
- ((FORMNS,u'control-implementation'), None): cnv_string,
+ ((FORMNS,u'control-implementation'), None): cnv_namespacedToken,
((FORMNS,u'convert-empty-to-null'), None): cnv_boolean,
((FORMNS,u'current-selected'), None): cnv_boolean,
((FORMNS,u'current-state'), None): cnv_string,
diff --git a/tests/testform.py b/tests/testform.py
new file mode 100644
index 0000000..d8fdd81
--- /dev/null
+++ b/tests/testform.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2008-2010 Søren Roug, European Environment Agency
+#
+# This is free software. You may redistribute it under the terms
+# of the Apache license and the GNU General Public License Version
+# 2 or at your option any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Contributor(s):
+#
+
+import unittest, os, os.path
+from odf.opendocument import OpenDocumentSpreadsheet
+import odf.table
+import odf.office
+import odf.form
+import odf.draw
+
+class TestForm(unittest.TestCase):
+ def test_ooo_ns(self):
+ """ Check that ooo exists in namespace declarations """
+ calcdoc = OpenDocumentSpreadsheet()
+ table = odf.table.Table(name="Costs")
+ forms = odf.office.Forms()
+ form = odf.form.Form(
+ controlimplementation="ooo:com.sun.star.form.component.Form")
+ lb = odf.form.Listbox(
+ controlimplementation="ooo:com.sun.star.form.component.ListBox", dropdown="true", id="control1")
+ form.addElement(lb)
+ forms.addElement(form)
+ table.addElement(forms)
+
+ # One empty line
+ tr = odf.table.TableRow()
+ table.addElement(tr)
+
+ tr = odf.table.TableRow()
+ # One empty cell
+ cell = odf.table.TableCell()
+ tr.addElement(cell)
+
+ cell = odf.table.TableCell()
+
+ draw = odf.draw.Control(
+ control="control1", height="0.1126in", width="0.798in",
+ x="0.0303in", y="0.0205in", endcelladdress="Costs.B2",
+ endx="0.8283in", endy="0.1331in")
+
+ cell.addElement(draw)
+ tr.addElement(cell)
+ table.addElement(tr)
+
+ calcdoc.spreadsheet.addElement(table)
+ result = unicode(calcdoc.contentxml(),'utf-8')
+ self.assertNotEqual(-1, result.find(u'''xmlns:ooo="http://openoffice.org/2004/office"'''))
+
+if __name__ == '__main__':
+ unittest.main()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-odf.git
More information about the Python-modules-commits
mailing list