White-space only changes in wxSVGFileDC code

This commit is contained in:
Maarten Bent
2019-04-10 23:37:34 +02:00
parent b0ad9ccffd
commit 19c66c780d
2 changed files with 132 additions and 134 deletions

View File

@@ -62,9 +62,9 @@ public:
class WXDLLIMPEXP_CORE wxSVGFileDCImpl : public wxDCImpl
{
public:
wxSVGFileDCImpl( wxSVGFileDC *owner, const wxString &filename,
int width = 320, int height = 240, double dpi = 72.0,
const wxString &title = wxString() );
wxSVGFileDCImpl(wxSVGFileDC *owner, const wxString &filename,
int width = 320, int height = 240, double dpi = 72.0,
const wxString &title = wxString());
virtual ~wxSVGFileDCImpl();
@@ -122,8 +122,8 @@ public:
m_graphics_changed = true;
}
virtual void SetBackground( const wxBrush &brush ) wxOVERRIDE;
virtual void SetBackgroundMode( int mode ) wxOVERRIDE;
virtual void SetBackground(const wxBrush &brush) wxOVERRIDE;
virtual void SetBackgroundMode(int mode) wxOVERRIDE;
virtual void SetBrush(const wxBrush& brush) wxOVERRIDE;
virtual void SetFont(const wxFont& font) wxOVERRIDE;
virtual void SetPen(const wxPen& pen) wxOVERRIDE;
@@ -133,125 +133,125 @@ public:
void SetBitmapHandler(wxSVGBitmapHandler* handler);
private:
virtual bool DoGetPixel(wxCoord, wxCoord, wxColour *) const wxOVERRIDE
{
wxFAIL_MSG(wxT("wxSVGFILEDC::DoGetPixel Call not implemented"));
return true;
}
virtual bool DoGetPixel(wxCoord, wxCoord, wxColour *) const wxOVERRIDE
{
wxFAIL_MSG(wxT("wxSVGFILEDC::DoGetPixel Call not implemented"));
return true;
}
virtual bool DoBlit(wxCoord, wxCoord, wxCoord, wxCoord, wxDC *,
wxCoord, wxCoord, wxRasterOperationMode = wxCOPY,
bool = 0, int = -1, int = -1) wxOVERRIDE;
virtual bool DoBlit(wxCoord, wxCoord, wxCoord, wxCoord, wxDC *,
wxCoord, wxCoord, wxRasterOperationMode = wxCOPY,
bool = 0, int = -1, int = -1) wxOVERRIDE;
virtual void DoCrossHair(wxCoord, wxCoord) wxOVERRIDE
{
wxFAIL_MSG(wxT("wxSVGFILEDC::CrossHair Call not implemented"));
}
virtual void DoCrossHair(wxCoord, wxCoord) wxOVERRIDE
{
wxFAIL_MSG(wxT("wxSVGFILEDC::CrossHair Call not implemented"));
}
virtual void DoDrawArc(wxCoord, wxCoord, wxCoord, wxCoord, wxCoord, wxCoord) wxOVERRIDE;
virtual void DoDrawArc(wxCoord, wxCoord, wxCoord, wxCoord, wxCoord, wxCoord) wxOVERRIDE;
virtual void DoDrawBitmap(const wxBitmap &, wxCoord, wxCoord, bool = false) wxOVERRIDE;
virtual void DoDrawBitmap(const wxBitmap &, wxCoord, wxCoord, bool = false) wxOVERRIDE;
virtual void DoDrawCheckMark(wxCoord x, wxCoord y, wxCoord w, wxCoord h) wxOVERRIDE;
virtual void DoDrawCheckMark(wxCoord x, wxCoord y, wxCoord w, wxCoord h) wxOVERRIDE;
virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h) wxOVERRIDE;
virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h) wxOVERRIDE;
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
double sa, double ea) wxOVERRIDE;
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
double sa, double ea) wxOVERRIDE;
virtual void DoDrawIcon(const wxIcon &, wxCoord, wxCoord) wxOVERRIDE;
virtual void DoDrawIcon(const wxIcon &, wxCoord, wxCoord) wxOVERRIDE;
virtual void DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) wxOVERRIDE;
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) wxOVERRIDE;
virtual void DoDrawLines(int n, const wxPoint points[],
wxCoord xoffset = 0, wxCoord yoffset = 0) wxOVERRIDE;
virtual void DoDrawLines(int n, const wxPoint points[],
wxCoord xoffset = 0, wxCoord yoffset = 0) wxOVERRIDE;
virtual void DoDrawPoint(wxCoord, wxCoord) wxOVERRIDE;
virtual void DoDrawPoint(wxCoord, wxCoord) wxOVERRIDE;
virtual void DoDrawPolygon(int n, const wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
wxPolygonFillMode fillStyle) wxOVERRIDE;
virtual void DoDrawPolygon(int n, const wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
wxPolygonFillMode fillStyle) wxOVERRIDE;
virtual void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
wxPolygonFillMode fillStyle) wxOVERRIDE;
virtual void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
wxPolygonFillMode fillStyle) wxOVERRIDE;
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h) wxOVERRIDE;
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h) wxOVERRIDE;
virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
double angle) wxOVERRIDE;
virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
double angle) wxOVERRIDE;
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
wxCoord w, wxCoord h,
double radius = 20) wxOVERRIDE ;
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
wxCoord w, wxCoord h,
double radius = 20) wxOVERRIDE;
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) wxOVERRIDE;
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y) wxOVERRIDE;
virtual bool DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
const wxColour& WXUNUSED(col),
wxFloodFillStyle WXUNUSED(style) = wxFLOOD_SURFACE) wxOVERRIDE
{
wxFAIL_MSG(wxT("wxSVGFILEDC::DoFloodFill Call not implemented"));
return false;
}
virtual bool DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
const wxColour& WXUNUSED(col),
wxFloodFillStyle WXUNUSED(style) = wxFLOOD_SURFACE) wxOVERRIDE
{
wxFAIL_MSG(wxT("wxSVGFILEDC::DoFloodFill Call not implemented"));
return false;
}
virtual void DoGetSize(int * x, int *y) const wxOVERRIDE
{
if ( x )
*x = m_width;
if ( y )
*y = m_height;
}
virtual void DoGetSize(int * x, int *y) const wxOVERRIDE
{
if ( x )
*x = m_width;
if ( y )
*y = m_height;
}
virtual void DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
const wxFont *font = NULL) const wxOVERRIDE;
virtual void DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
const wxFont *font = NULL) const wxOVERRIDE;
virtual void DoSetDeviceClippingRegion(const wxRegion& region) wxOVERRIDE
{
virtual void DoSetDeviceClippingRegion(const wxRegion& region) wxOVERRIDE
{
DoSetClippingRegion(region.GetBox().x, region.GetBox().y,
region.GetBox().width, region.GetBox().height);
}
}
virtual void DoSetClippingRegion(int x, int y, int width, int height) wxOVERRIDE;
virtual void DoSetClippingRegion(int x, int y, int width, int height) wxOVERRIDE;
virtual void DoGetSizeMM( int *width, int *height ) const wxOVERRIDE;
virtual void DoGetSizeMM(int *width, int *height) const wxOVERRIDE;
virtual wxSize GetPPI() const wxOVERRIDE;
virtual wxSize GetPPI() const wxOVERRIDE;
void Init (const wxString &filename, int width, int height,
void Init(const wxString &filename, int width, int height,
double dpi, const wxString &title);
void write( const wxString &s );
void write(const wxString &s);
private:
// If m_graphics_changed is true, close the current <g> element and start a
// new one for the last pen/brush change.
void NewGraphicsIfNeeded();
// If m_graphics_changed is true, close the current <g> element and start a
// new one for the last pen/brush change.
void NewGraphicsIfNeeded();
// Open a new graphics group setting up all the attributes according to
// their current values in wxDC.
void DoStartNewGraphics();
// Open a new graphics group setting up all the attributes according to
// their current values in wxDC.
void DoStartNewGraphics();
wxString m_filename;
int m_sub_images; // number of png format images we have
bool m_OK;
bool m_graphics_changed; // set by Set{Brush,Pen}()
int m_width, m_height;
double m_dpi;
wxScopedPtr<wxFileOutputStream> m_outfile;
wxScopedPtr<wxSVGBitmapHandler> m_bmp_handler; // class to handle bitmaps
wxString m_filename;
int m_sub_images; // number of png format images we have
bool m_OK;
bool m_graphics_changed; // set by Set{Brush,Pen}()
int m_width, m_height;
double m_dpi;
wxScopedPtr<wxFileOutputStream> m_outfile;
wxScopedPtr<wxSVGBitmapHandler> m_bmp_handler; // class to handle bitmaps
// The clipping nesting level is incremented by every call to
// SetClippingRegion() and reset when DestroyClippingRegion() is called.
size_t m_clipNestingLevel;
// The clipping nesting level is incremented by every call to
// SetClippingRegion() and reset when DestroyClippingRegion() is called.
size_t m_clipNestingLevel;
// Unique ID for every clipping graphics group: this is simply always
// incremented in each SetClippingRegion() call.
size_t m_clipUniqueId;
// Unique ID for every clipping graphics group: this is simply always
// incremented in each SetClippingRegion() call.
size_t m_clipUniqueId;
wxDECLARE_ABSTRACT_CLASS(wxSVGFileDCImpl);
wxDECLARE_ABSTRACT_CLASS(wxSVGFileDCImpl);
};

View File

@@ -74,7 +74,7 @@ wxString Col2SVG(wxColour c, float *opacity)
wxString wxPenString(wxColour c, int style = wxPENSTYLE_SOLID)
{
float opacity;
wxString s = wxS("stroke:") + Col2SVG(c, &opacity) + wxS("; ");
wxString s = wxS("stroke:") + Col2SVG(c, &opacity) + wxS("; ");
switch ( style )
{
@@ -89,7 +89,7 @@ wxString wxPenString(wxColour c, int style = wxPENSTYLE_SOLID)
case wxPENSTYLE_TRANSPARENT:
s += wxS("stroke-opacity:0.0; ");
break;
default :
default:
wxASSERT_MSG(false, wxS("wxSVGFileDC::Requested Pen Style not available"));
}
@@ -99,7 +99,7 @@ wxString wxPenString(wxColour c, int style = wxPENSTYLE_SOLID)
wxString wxBrushString(wxColour c, int style = wxBRUSHSTYLE_SOLID)
{
float opacity;
wxString s = wxS("fill:") + Col2SVG(c, &opacity) + wxS("; ");
wxString s = wxS("fill:") + Col2SVG(c, &opacity) + wxS("; ");
switch ( style )
{
@@ -114,7 +114,7 @@ wxString wxBrushString(wxColour c, int style = wxBRUSHSTYLE_SOLID)
case wxBRUSHSTYLE_TRANSPARENT:
s += wxS("fill-opacity:0.0; ");
break;
default :
default:
wxASSERT_MSG(false, wxS("wxSVGFileDC::Requested Brush Style not available"));
}
@@ -356,7 +356,7 @@ wxSVGBitmapFileHandler::ProcessBitmap(const wxBitmap& bmp,
// write to the SVG file
const wxCharBuffer buf = s.utf8_str();
stream.Write(buf, strlen((const char *)buf));
stream.Write(buf, strlen((const char*)buf));
return stream.IsOk();
}
@@ -403,8 +403,8 @@ void wxSVGFileDCImpl::Init(const wxString &filename, int Width, int Height,
m_textForegroundColour = *wxBLACK;
m_textBackgroundColour = *wxWHITE;
m_pen = *wxBLACK_PEN;
m_font = *wxNORMAL_FONT;
m_pen = *wxBLACK_PEN;
m_font = *wxNORMAL_FONT;
m_brush = *wxWHITE_BRUSH;
m_filename = filename;
@@ -420,7 +420,7 @@ void wxSVGFileDCImpl::Init(const wxString &filename, int Width, int Height,
s += wxS("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
s += wxS("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n\n");
s += wxS("<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"");
s += wxString::Format(wxS(" width=\"%scm\" height=\"%scm\" viewBox=\"0 0 %d %d\">\n"), NumStr(float(Width) / dpi*2.54), NumStr(float(Height) / dpi*2.54), Width, Height);
s += wxString::Format(wxS(" width=\"%scm\" height=\"%scm\" viewBox=\"0 0 %d %d\">\n"), NumStr(float(Width) / dpi * 2.54), NumStr(float(Height) / dpi * 2.54), Width, Height);
s += wxString::Format(wxS("<title>%s</title>\n"), title);
s += wxString(wxS("<desc>Picture generated by wxSVG ")) + wxSVGVersion + wxS("</desc>\n\n");
s += wxS("<g style=\"fill:black; stroke:black; stroke-width:1\">\n");
@@ -538,11 +538,11 @@ void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoor
// wxS("upper left") and wxS("upper right")
CalcBoundingBox(x, y);
CalcBoundingBox((wxCoord)(x + w*cos(rad)), (wxCoord)(y - h*sin(rad)));
CalcBoundingBox((wxCoord)(x + w * cos(rad)), (wxCoord)(y - h * sin(rad)));
// wxS("bottom left") and wxS("bottom right")
CalcBoundingBox((wxCoord)(x + h*sin(rad)), (wxCoord)(y + h*cos(rad)));
CalcBoundingBox((wxCoord)(x + h*sin(rad) + w*cos(rad)), (wxCoord)(y + h*cos(rad) - w*sin(rad)));
CalcBoundingBox((wxCoord)(x + h * sin(rad)), (wxCoord)(y + h * cos(rad)));
CalcBoundingBox((wxCoord)(x + h * sin(rad) + w * cos(rad)), (wxCoord)(y + h * cos(rad) - w * sin(rad)));
if (m_backgroundMode == wxBRUSHSTYLE_SOLID)
{
@@ -575,7 +575,7 @@ void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoor
else
s += wxS("style=\" ");
wxString fontweight = wxString::Format(wxS("%d"),m_font.GetWeight());
wxString fontweight = wxString::Format(wxS("%d"), m_font.GetWeight());
s += wxS("font-weight:") + fontweight + wxS("; ");
@@ -618,11 +618,11 @@ void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoor
s += wxBrushString(m_textForegroundColour) + wxPenString(m_textForegroundColour);
s += wxString::Format(wxS("stroke-width:0;\" transform=\"rotate(%s %d %d)\""), NumStr(-angle), xx, yy);
s += wxS(" xml:space=\"preserve\">");
#if wxUSE_MARKUP
s += wxMarkupParser::Quote(lines[lineNum]) + wxS("</text>\n");
#else
s += lines[lineNum] + wxS("</text>\n");
#endif
#if wxUSE_MARKUP
s += wxMarkupParser::Quote(lines[lineNum]) + wxS("</text>\n");
#else
s += lines[lineNum] + wxS("</text>\n");
#endif
write(s);
}
@@ -746,11 +746,11 @@ void wxSVGFileDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
wxString s;
// we need the radius of the circle which has two estimates
double r1 = sqrt ( double( (x1-xc)*(x1-xc) ) + double( (y1-yc)*(y1-yc) ) );
double r2 = sqrt ( double( (x2-xc)*(x2-xc) ) + double( (y2-yc)*(y2-yc) ) );
double r1 = sqrt( double( (x1 - xc)*(x1 - xc) ) + double( (y1 - yc)*(y1 - yc) ) );
double r2 = sqrt( double( (x2 - xc)*(x2 - xc) ) + double( (y2 - yc)*(y2 - yc) ) );
wxASSERT_MSG( (fabs ( r2-r1 ) <= 3), wxS("wxSVGFileDC::DoDrawArc Error in getting radii of circle"));
if ( fabs ( r2-r1 ) > 3 ) //pixels
wxASSERT_MSG((fabs( r2 - r1 ) <= 3), wxS("wxSVGFileDC::DoDrawArc Error in getting radii of circle"));
if ( fabs( r2 - r1 ) > 3 ) //pixels
{
s = wxS("<!--- wxSVGFileDC::DoDrawArc Error in getting radii of circle -->\n");
write(s);
@@ -822,10 +822,10 @@ void wxSVGFileDCImpl::DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord
// start and end coords
double xs, ys, xe, ye;
xs = xc + rx * cos (wxDegToRad(sa));
xe = xc + rx * cos (wxDegToRad(ea));
ys = yc - ry * sin (wxDegToRad(sa));
ye = yc - ry * sin (wxDegToRad(ea));
xs = xc + rx * cos(wxDegToRad(sa));
xe = xc + rx * cos(wxDegToRad(ea));
ys = yc - ry * sin(wxDegToRad(sa));
ye = yc - ry * sin(wxDegToRad(ea));
// svg arcs have 0 degrees at 12-o'clock instead of 3-o'clock
double start = (sa - 90);
@@ -1004,8 +1004,6 @@ void wxSVGFileDCImpl::SetBrush(const wxBrush& brush)
void wxSVGFileDCImpl::SetPen(const wxPen& pen)
{
// width, color, ends, joins : currently implemented
// dashes, stipple : not implemented
m_pen = pen;
m_graphics_changed = true;
@@ -1028,40 +1026,40 @@ void wxSVGFileDCImpl::DoStartNewGraphics()
wxString s, sBrush, sPenCap, sPenJoin, sPenStyle, sLast;
sBrush = wxS("<g style=\"") + wxBrushString(m_brush.GetColour(), m_brush.GetStyle())
+ wxPenString(m_pen.GetColour(), m_pen.GetStyle());
+ wxPenString(m_pen.GetColour(), m_pen.GetStyle());
switch ( m_pen.GetCap() )
{
case wxCAP_PROJECTING :
case wxCAP_PROJECTING:
sPenCap = wxS("stroke-linecap:square; ");
break;
case wxCAP_BUTT :
case wxCAP_BUTT:
sPenCap = wxS("stroke-linecap:butt; ");
break;
case wxCAP_ROUND :
default :
case wxCAP_ROUND:
default:
sPenCap = wxS("stroke-linecap:round; ");
}
switch ( m_pen.GetJoin() )
switch (m_pen.GetJoin())
{
case wxJOIN_BEVEL :
case wxJOIN_BEVEL:
sPenJoin = wxS("stroke-linejoin:bevel; ");
break;
case wxJOIN_MITER :
case wxJOIN_MITER:
sPenJoin = wxS("stroke-linejoin:miter; ");
break;
case wxJOIN_ROUND :
default :
case wxJOIN_ROUND:
default:
sPenJoin = wxS("stroke-linejoin:round; ");
}
sLast = wxString::Format(wxS("stroke-width:%d\" transform=\"translate(%s %s) scale(%s %s)\">"),
m_pen.GetWidth(),
NumStr((m_deviceOriginX - m_logicalOriginX)* m_signX),
NumStr((m_deviceOriginY - m_logicalOriginY)* m_signY),
NumStr(m_scaleX * m_signX),
NumStr(m_scaleY * m_signY));
m_pen.GetWidth(),
NumStr((m_deviceOriginX - m_logicalOriginX)* m_signX),
NumStr((m_deviceOriginY - m_logicalOriginY)* m_signY),
NumStr(m_scaleX * m_signX),
NumStr(m_scaleY * m_signY));
s = sBrush + sPenCap + sPenJoin + sPenStyle + sLast + wxS("\n");
write(s);
@@ -1074,9 +1072,9 @@ void wxSVGFileDCImpl::SetFont(const wxFont& font)
// export a bitmap as a raster image in png
bool wxSVGFileDCImpl::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC* source, wxCoord xsrc, wxCoord ysrc,
wxRasterOperationMode logicalFunc /*= wxCOPY*/, bool useMask /*= false*/,
wxCoord /*xsrcMask = -1*/, wxCoord /*ysrcMask = -1*/)
wxDC* source, wxCoord xsrc, wxCoord ysrc,
wxRasterOperationMode logicalFunc /*= wxCOPY*/, bool useMask /*= false*/,
wxCoord /*xsrcMask = -1*/, wxCoord /*ysrcMask = -1*/)
{
if (logicalFunc != wxCOPY)
{
@@ -1107,7 +1105,7 @@ void wxSVGFileDCImpl::DoDrawIcon(const class wxIcon & myIcon, wxCoord x, wxCoord
DoDrawBitmap(myBitmap, x, y);
}
void wxSVGFileDCImpl::DoDrawBitmap(const class wxBitmap & bmp, wxCoord x, wxCoord y, bool WXUNUSED(bTransparent) /*=0*/)
void wxSVGFileDCImpl::DoDrawBitmap(const class wxBitmap & bmp, wxCoord x, wxCoord y, bool WXUNUSED(bTransparent) /*=0*/)
{
NewGraphicsIfNeeded();