From: Vadim Zeitlin Date: Sat, 2 Apr 2011 16:37:58 +0000 (+0000) Subject: Clean up of string operations in wxSVGFileDC code. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/85675f10197e20f227b9e4277401f3623fed2895 Clean up of string operations in wxSVGFileDC code. Use operator+=() instead of "s = s + ...". See #13086. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67374 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index 21798cffab..1cac125fc7 100644 --- a/src/common/dcsvg.cpp +++ b/src/common/dcsvg.cpp @@ -56,17 +56,17 @@ wxString wxPenString(wxColour c, int style = wxPENSTYLE_SOLID) // Note that a transparent pen will override the alpha value. if (c.Alpha() != wxALPHA_OPAQUE && style != wxPENSTYLE_TRANSPARENT) { - s = s + wxString::Format(wxT("stroke-opacity:%s; "), NumStr(c.Alpha()/255.)); + s += wxString::Format(wxT("stroke-opacity:%s; "), NumStr(c.Alpha()/255.)); } else { switch ( style ) { case wxPENSTYLE_SOLID: - s = s + wxT("stroke-opacity:1.0; "); + s += wxT("stroke-opacity:1.0; "); break; case wxPENSTYLE_TRANSPARENT: - s = s + wxT("stroke-opacity:0.0; "); + s += wxT("stroke-opacity:0.0; "); break; default : wxASSERT_MSG(false, wxT("wxSVGFileDC::Requested Pen Style not available")); @@ -82,17 +82,17 @@ wxString wxBrushString(wxColour c, int style = wxBRUSHSTYLE_SOLID) // Note that a transparent brush will override the alpha value. if (c.Alpha() != wxALPHA_OPAQUE && style != wxBRUSHSTYLE_TRANSPARENT) { - s = s + wxString::Format(wxT("fill-opacity:%s; "), NumStr(c.Alpha()/255.)); + s += wxString::Format(wxT("fill-opacity:%s; "), NumStr(c.Alpha()/255.)); } else { switch ( style ) { case wxBRUSHSTYLE_SOLID: - s = s + wxT("fill-opacity:1.0; "); + s += wxT("fill-opacity:1.0; "); break; case wxBRUSHSTYLE_TRANSPARENT: - s = s + wxT("fill-opacity:0.0; "); + s += wxT("fill-opacity:0.0; "); break; default : wxASSERT_MSG(false, wxT("wxSVGFileDC::Requested Brush Style not available")); @@ -264,30 +264,30 @@ void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoor wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::Draw Rotated Text Call plotting text background")); sTmp.Printf ( wxT(" "), NumStr(-angle), x,y ); - s = s + sTmp + wxT("\n"); + s += sTmp + wxT("\n"); write(s); } //now do the text itself s.Printf (wxT(" 0) s = s + wxT("style=\"font-family:") + sTmp + wxT("; "); - else s = s + wxT("style=\" "); + if (sTmp.Len () > 0) s += wxT("style=\"font-family:") + sTmp + wxT("; "); + else s += wxT("style=\" "); wxString fontweights [3] = { wxT("normal"), wxT("lighter"), wxT("bold") }; - s = s + wxT("font-weight:") + fontweights[m_font.GetWeight() - wxNORMAL] + wxT("; "); + s += wxT("font-weight:") + fontweights[m_font.GetWeight() - wxNORMAL] + wxT("; "); wxString fontstyles [5] = { wxT("normal"), wxT("style error"), wxT("style error"), wxT("italic"), wxT("oblique") }; - s = s + wxT("font-style:") + fontstyles[m_font.GetStyle() - wxNORMAL] + wxT("; "); + s += wxT("font-style:") + fontstyles[m_font.GetStyle() - wxNORMAL] + wxT("; "); sTmp.Printf (wxT("font-size:%dpt; "), m_font.GetPointSize () ); - s = s + sTmp; + s += sTmp; //text will be solid, unless alpha value isn't opaque in the foreground colour - s = s + wxBrushString(m_textForegroundColour) + wxPenString(m_textForegroundColour); + s += wxBrushString(m_textForegroundColour) + wxPenString(m_textForegroundColour); sTmp.Printf ( wxT("stroke-width:0;\" transform=\"rotate( %s %d %d ) \" >"), NumStr(-angle), x,y ); - s = s + sTmp + sText + wxT(" ") + wxT("\n"); + s += sTmp + sText + wxT(" ") + wxT("\n"); if (m_OK) { write(s); @@ -309,7 +309,7 @@ void wxSVGFileDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width s.Printf ( wxT(" \n"); + s += wxT(" /> \n"); write(s); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawRoundedRectangle Call executed")); @@ -325,19 +325,19 @@ void wxSVGFileDCImpl::DoDrawPolygon(int n, wxPoint points[], wxString s, sTmp; s = wxT(" \n"); + s += wxT("\" /> \n"); write(s); wxASSERT_MSG(!wxSVG_DEBUG, wxT("wxSVGFileDC::DoDrawPolygon Call executed")); @@ -353,7 +353,7 @@ void wxSVGFileDCImpl::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoor wxString s; s.Printf ( wxT(" \n"); + s += wxT(" /> \n"); write(s); @@ -402,7 +402,7 @@ void wxSVGFileDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, x1,y1, NumStr(r1), NumStr(r2), fArc, fSweep, x2, y2, xc, yc ); // the z means close the path and fill - s = s + wxT(" \" /> \n"); + s += wxT(" \" /> \n"); if (m_OK) @@ -465,7 +465,7 @@ void wxSVGFileDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h, int(xs), int(ys), int(rx), int(ry), fArc, fSweep, int(xe), int(ye), int(xc), int(yc) ); - s = s + wxT(" \" /> \n"); + s += wxT(" \" /> \n"); if (m_OK) { @@ -666,9 +666,9 @@ void wxSVGFileDCImpl::DoDrawBitmap(const class wxBitmap & bmp, wxCoord x, wxCoor int w = myBitmap.GetWidth(); int h = myBitmap.GetHeight(); sTmp.Printf ( wxT(" \n"), sPNG.c_str() ); - s = s + sTmp + wxT("Image from wxSVG ") + wxT("\n"); + s += sTmp + wxT("Image from wxSVG ") + wxT("\n"); if (m_OK && bPNG_OK) {