[Python-modules-commits] [python-odf] 102/118: Fixed bug report http://forge.osor.eu/forum/message.php?msg_id=1920
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 ac34385110c79ffb546b23fd3cdac5d7eda3d9fa
Author: Søren Roug <soren.roug at eea.europa.eu>
Date: Sun Mar 6 17:03:33 2011 +0000
Fixed bug report http://forge.osor.eu/forum/message.php?msg_id=1920
---
odf/opendocument.py | 4 ++-
tests/testdatastyles.py | 82 ++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 81 insertions(+), 5 deletions(-)
diff --git a/odf/opendocument.py b/odf/opendocument.py
index 6319638..69ada21 100644
--- a/odf/opendocument.py
+++ b/odf/opendocument.py
@@ -232,7 +232,9 @@ class OpenDocument:
"""
for e in top.childNodes:
if e.nodeType == element.Node.ELEMENT_NODE:
- for styleref in ( (DRAWNS,u'style-name'),
+ for styleref in (
+ (CHARTNS,u'style-name'),
+ (DRAWNS,u'style-name'),
(DRAWNS,u'text-style-name'),
(PRESENTATIONNS,u'style-name'),
(STYLENS,u'data-style-name'),
diff --git a/tests/testdatastyles.py b/tests/testdatastyles.py
index 9085170..ac9c018 100644
--- a/tests/testdatastyles.py
+++ b/tests/testdatastyles.py
@@ -19,10 +19,12 @@
#
import unittest, os, os.path
-from odf.opendocument import OpenDocumentSpreadsheet, load
-from odf.style import Style,ParagraphProperties,TextProperties
+from odf.opendocument import OpenDocumentSpreadsheet, OpenDocumentChart, load
+from odf.style import Style, ParagraphProperties, TextProperties, GraphicProperties, \
+ ChartProperties
from odf.number import Text,PercentageStyle, Number
from odf.table import Table,TableRow,TableCell
+from odf import text, chart
class TestDatastyles(unittest.TestCase):
@@ -59,8 +61,80 @@ class TestDatastyles(unittest.TestCase):
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()
+ def test_chart_style(self):
+ """ Test that chart:style-name reference is seen in content.xml """
+ doc = OpenDocumentChart()
+ chartstyle = Style(name="chartstyle", family="chart")
+ chartstyle.addElement( GraphicProperties(stroke="none", fillcolor="#ffffff"))
+ doc.automaticstyles.addElement(chartstyle)
+
+ mychart = chart.Chart( width="576pt", height="504pt", stylename=chartstyle, attributes={'class':'chart:bar'})
+ doc.chart.addElement(mychart)
+
+ # Add title
+ titlestyle = Style(name="titlestyle", family="chart")
+ titlestyle.addElement( GraphicProperties(stroke="none", fill="none"))
+ titlestyle.addElement( TextProperties(fontfamily="'Nimbus Sans L'",
+ fontfamilygeneric="swiss", fontpitch="variable", fontsize="13pt"))
+ doc.automaticstyles.addElement(titlestyle)
+
+ mytitle = chart.Title(x="385pt", y="27pt", stylename=titlestyle)
+ mytitle.addElement( text.P(text="Title"))
+ mychart.addElement(mytitle)
+
+ # Add subtitle
+ subtitlestyle = Style(name="subtitlestyle", family="chart")
+ subtitlestyle.addElement( GraphicProperties(stroke="none", fill="none"))
+ subtitlestyle.addElement( TextProperties(fontfamily="'Nimbus Sans L'",
+ fontfamilygeneric="swiss", fontpitch="variable", fontsize="10pt"))
+ doc.automaticstyles.addElement(subtitlestyle)
+
+ subtitle = chart.Subtitle(x="0pt", y="123pt", stylename=subtitlestyle)
+ subtitle.addElement( text.P(text="my subtitle"))
+ mychart.addElement(subtitle)
+
+ # Legend
+ legendstyle = Style(name="legendstyle", family="chart")
+ legendstyle.addElement( GraphicProperties(fill="none"))
+ legendstyle.addElement( TextProperties(fontfamily="'Nimbus Sans L'",
+ fontfamilygeneric="swiss", fontpitch="variable", fontsize="6pt"))
+ doc.automaticstyles.addElement(legendstyle)
+ mylegend = chart.Legend(legendposition="end", legendalign="center", stylename=legendstyle)
+ mychart.addElement(mylegend)
+ # Plot area
+ plotstyle = Style(name="plotstyle", family="chart")
+ plotstyle.addElement( ChartProperties(seriessource="columns",
+ percentage="false", stacked="false",
+ threedimensional="true"))
+ doc.automaticstyles.addElement(plotstyle)
+
+ plotarea = chart.PlotArea(datasourcehaslabels="both", stylename=plotstyle)
+ mychart.addElement(plotarea)
+
+ # Style for the X,Y axes
+ axisstyle = Style(name="axisstyle", family="chart")
+ axisstyle.addElement( ChartProperties(displaylabel="true"))
+ doc.automaticstyles.addElement(axisstyle)
+
+ # Title for the X axis
+ xaxis = chart.Axis(dimension="x", name="primary-x", stylename=axisstyle)
+ plotarea.addElement(xaxis)
+ xt = chart.Title()
+ xaxis.addElement(xt)
+ xt.addElement(text.P(text="x_axis"))
+
+ # Title for the Y axis
+ yaxis = chart.Axis(dimension="y", name="primary-y", stylename=axisstyle)
+ plotarea.addElement(yaxis)
+ yt = chart.Title()
+ yaxis.addElement(yt)
+ yt.addElement(text.P(text="y_axis"))
+
+ result = doc.contentxml()
+ self.assertNotEqual(-1, result.find(u'''style:family="chart"'''))
+
+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