[Python-modules-commits] [python-odf] 62/118: Fix a bug reported by Michel CARLUEC

Wolfgang Borgert debacle at moszumanska.debian.org
Fri Oct 3 21:27:23 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 1cc2f1808f1aad79c85123617b16124f1d94b90a
Author: Søren Roug <soren.roug at eea.europa.eu>
Date:   Mon Aug 31 18:54:37 2009 +0000

    Fix a bug reported by Michel CARLUEC
---
 odf/opendocument.py     |  2 +-
 tests/testdatastyles.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/odf/opendocument.py b/odf/opendocument.py
index 05688f4..9fd1622 100644
--- a/odf/opendocument.py
+++ b/odf/opendocument.py
@@ -185,7 +185,7 @@ class OpenDocument:
         if self.fontfacedecls.hasChildNodes():
             self.fontfacedecls.toXml(1, xml)
         a = AutomaticStyles()
-        stylelist = self._used_auto_styles([self.styles, self.body])
+        stylelist = self._used_auto_styles([self.styles, self.automaticstyles, self.body])
         if len(stylelist) > 0:
             a.write_open_tag(1, xml)
             for s in stylelist:
diff --git a/tests/testdatastyles.py b/tests/testdatastyles.py
new file mode 100644
index 0000000..711f643
--- /dev/null
+++ b/tests/testdatastyles.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2009 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, load
+from odf.style import Style,ParagraphProperties,TextProperties
+from odf.number import Text,PercentageStyle, Number
+from odf.table import Table,TableRow,TableCell
+
+
+class TestHeadings(unittest.TestCase):
+    
+    saved = False
+
+    def tearDown(self):
+        if self.saved:
+            os.unlink("TEST.odt")
+        
+    def test_percentage(self):
+        """ Test that an automatic style can refer to a PercentageStyle as a datastylename """
+        doc = OpenDocumentSpreadsheet()
+        nonze = PercentageStyle(name='N11')
+        nonze.addElement(Number(decimalplaces='2', minintegerdigits='1'))
+        nonze.addElement(Text(text='%'))
+        doc.automaticstyles.addElement(nonze)
+        pourcent = Style(name='pourcent', family='table-cell', datastylename='N11')
+        pourcent.addElement(ParagraphProperties(textalign='center'))
+        pourcent.addElement(TextProperties(attributes={'fontsize':"10pt",'fontweight':"bold", 'color':"#000000" }))
+        doc.automaticstyles.addElement(pourcent)
+
+        table = Table(name='sheet1')
+        tr = TableRow()
+        tc = TableCell(formula='=AVERAGE(C4:CB62)/2',stylename='pourcent', valuetype='percentage')
+        tr.addElement(tc)
+        table.addElement(tr)
+        doc.spreadsheet.addElement(table)
+        doc.save("TEST.odt")
+        self.saved = True
+        d = load("TEST.odt")
+        result = d.contentxml()
+        self.assertNotEqual(-1, result.find(u'''<number:percentage-style'''))
+        self.assertNotEqual(-1, result.find(u'''style:data-style-name="N11"'''))
+        self.assertNotEqual(-1, result.find(u'''style:name="pourcent"'''))
+
+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