[cairo-commit] svgslides/src svgslides-4suite,1.5,1.6

Keith Packard commit at pdx.freedesktop.org
Tue Apr 19 18:58:29 PDT 2005


Committed by: keithp

Update of /cvs/cairo/svgslides/src
In directory gabe:/tmp/cvs-serv7959/src

Modified Files:
	svgslides-4suite 
Log Message:
2005-04-20  Keith Packard  <keithp at keithp.com>

	* src/svgslides-4suite:
	* example/example-title.svg:
	* example/example.xml:
	Use 'presentation' for presentation name so
	every slide has access to it.
	Search up tree for slide attributes.


Index: svgslides-4suite
===================================================================
RCS file: /cvs/cairo/svgslides/src/svgslides-4suite,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- svgslides-4suite	18 Apr 2005 00:07:08 -0000	1.5
+++ svgslides-4suite	20 Apr 2005 01:58:27 -0000	1.6
@@ -91,11 +91,14 @@
 
 # Generate HTML output
 file = open ('index.html', 'w')
-title = do_xpath (slides_doc, u'//ss:slides/@title')[0].nodeValue
+try:
+	presentation = do_xpath (slides_doc, u'//ss:slides/@presentation')[0].nodeValue
+except IndexError, exc:
+	presentation = ''
 print >> file, '<html>\n  <head>\n    <title>', 
-print >> file, title,
+print >> file, presentation,
 print >> file, '</title>\n  </head>\n  <body>'
-print >> file, '<h1>',title,'</h1>'
+print >> file, '<h1>',presentation,'</h1>'
 slide_num = 0
 for slide in slides:
     print >> file, '    <p><a href="'+slide_file_name (slide_num, '.html')+'">'+get_attr (slide, 'title')+'</a>'
@@ -119,11 +122,20 @@
     file.close ()
     slide_num += 1
 
+def slide_get_inherited_attribute (slide, attribute):
+    try:
+    	return do_xpath (slide, 
+			 u'ancestor-or-self::*[@' + attribute + u'][1]/@' + 
+			 attribute)[0].nodeValue
+    except IndexError, exc:
+	return ''
+
 def slide_generate_svg_from_template (slide, theme, variant = None):
 
     def substitute_variable (variable):
 	variable_name = variable.getAttributeNS (SS, 'variable')
-	value = slide.getAttributeNS (None, u''+variable_name)
+#	value = slide.getAttributeNS (None, u''+variable_name)
+	value = slide_get_inherited_attribute (slide, variable_name)
 	variable.replaceChild (doc.createTextNode (value), variable.firstChild)
 
     def substitute_region (region):
@@ -273,10 +285,18 @@
 
 	# Copy text style up from a mandatory text element
 	text_sample = do_xpath (region, u'svg:text[1]')[0]
-	font_size = float(text_sample.getAttributeNS (None, 'font-size'))
-	region.setAttributeNS (None, 'font-size', `font_size`)
-	region.setAttributeNS (None, 'font-family', text_sample.getAttributeNS (None, 'font-family'))
-	region.setAttributeNS (None, 'fill', text_sample.getAttributeNS (None, 'fill'))
+	font_size_string = text_sample.getAttributeNS (None, 'font-size')
+	if font_size_string:
+		region.setAttributeNS (None, 'font-size', font_size_string)
+	else:
+		font_size_string = slide_get_inherited_attribute (text_sample, 'font-size')
+	font_size = float(font_size_string)
+	font_family = text_sample.getAttributeNS (None, 'font-family')
+	if font_family:
+		region.setAttributeNS (None, 'font-family', font_family)
+	fill = text_sample.getAttributeNS (None, 'fill')
+	if fill:
+		region.setAttributeNS (None, 'fill', fill)
 
 	# Get bounds information from a mandatory rect within the region
 	rect = do_xpath (region, u'svg:rect[1]')[0]




More information about the cairo-commit mailing list