|
|
@ -99,6 +99,65 @@ |
|
|
|
#include <macros.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function XmlEsc |
|
|
|
* translates '<' to "<", '>' to ">" and so on, according to the spec: |
|
|
|
* http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping
|
|
|
|
* May be moved to a library if needed generally, but not expecting that. |
|
|
|
*/ |
|
|
|
static wxString XmlEsc( const wxString& aStr, bool isAttribute = false ) |
|
|
|
{ |
|
|
|
wxString escaped; |
|
|
|
|
|
|
|
escaped.reserve( aStr.length() ); |
|
|
|
|
|
|
|
for( wxString::const_iterator it = aStr.begin(); it != aStr.end(); ++it ) |
|
|
|
{ |
|
|
|
const wxChar c = *it; |
|
|
|
|
|
|
|
switch( c ) |
|
|
|
{ |
|
|
|
case wxS( '<' ): |
|
|
|
escaped.append( wxS( "<" ) ); |
|
|
|
break; |
|
|
|
case wxS( '>' ): |
|
|
|
escaped.append( wxS( ">" ) ); |
|
|
|
break; |
|
|
|
case wxS( '&' ): |
|
|
|
escaped.append( wxS( "&" ) ); |
|
|
|
break; |
|
|
|
case wxS( '\r' ): |
|
|
|
escaped.append( wxS( "
" ) ); |
|
|
|
break; |
|
|
|
default: |
|
|
|
if( isAttribute ) |
|
|
|
{ |
|
|
|
switch( c ) |
|
|
|
{ |
|
|
|
case wxS( '"' ): |
|
|
|
escaped.append( wxS( """ ) ); |
|
|
|
break; |
|
|
|
case wxS( '\t' ): |
|
|
|
escaped.append( wxS( "	" ) ); |
|
|
|
break; |
|
|
|
case wxS( '\n' ): |
|
|
|
escaped.append( wxS( "
" )); |
|
|
|
break; |
|
|
|
default: |
|
|
|
escaped.append(c); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
escaped.append(c); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return escaped; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SVG_PLOTTER::SVG_PLOTTER() |
|
|
|
{ |
|
|
|
m_graphics_changed = true; |
|
|
@ -460,10 +519,10 @@ bool SVG_PLOTTER::StartPlot() |
|
|
|
|
|
|
|
fprintf( outputFile, |
|
|
|
"<title>SVG Picture created as %s date %s </title>\n", |
|
|
|
TO_UTF8( wxFileName( filename ).GetFullName() ), date_buf ); |
|
|
|
TO_UTF8( XmlEsc( wxFileName( filename ).GetFullName() ) ), date_buf ); |
|
|
|
// End of header
|
|
|
|
fprintf( outputFile, " <desc>Picture generated by %s </desc>\n", |
|
|
|
TO_UTF8( creator ) ); |
|
|
|
TO_UTF8( XmlEsc( creator ) ) ); |
|
|
|
|
|
|
|
// output the pen and brush color (RVB values in hex) and opacity
|
|
|
|
double opacity = 1.0; // 0.0 (transparent to 1.0 (solid)
|
|
|
|