diff options
| author | Kris De Gussem <kris.degussem@gmail.com> | 2012-02-15 07:25:29 +0000 |
|---|---|---|
| committer | Kris <Kris.De.Gussem@hotmail.com> | 2012-02-15 07:25:29 +0000 |
| commit | 8edcffdc305b2c09a4f9b886fee12ecfc48a0e24 (patch) | |
| tree | 2365a85f9cae27fb1f8053ff69f445b02304c12e /src | |
| parent | Snap to grid/guide lines perpendicularly (diff) | |
| download | inkscape-8edcffdc305b2c09a4f9b886fee12ecfc48a0e24.tar.gz inkscape-8edcffdc305b2c09a4f9b886fee12ecfc48a0e24.zip | |
cppcheck
(bzr r10977)
Diffstat (limited to 'src')
| -rw-r--r-- | src/dom/xpathparser.cpp | 16 | ||||
| -rw-r--r-- | src/extension/dbus/document-interface.cpp | 1 | ||||
| -rw-r--r-- | src/extension/dxf2svg/dxf2svg.cpp | 15 | ||||
| -rw-r--r-- | src/extension/dxf2svg/entities.cpp | 16 | ||||
| -rw-r--r-- | src/extension/dxf2svg/entities2elements.cpp | 15 | ||||
| -rw-r--r-- | src/extension/init.cpp | 6 | ||||
| -rw-r--r-- | src/extension/internal/filter/paint.h | 3 | ||||
| -rw-r--r-- | src/extension/internal/odf.cpp | 3 | ||||
| -rw-r--r-- | src/extension/internal/pdfinput/pdf-parser.cpp | 157 | ||||
| -rw-r--r-- | src/extension/param/bool.cpp | 2 | ||||
| -rw-r--r-- | src/ui/tool/transform-handle-set.cpp | 2 |
11 files changed, 100 insertions, 136 deletions
diff --git a/src/dom/xpathparser.cpp b/src/dom/xpathparser.cpp index f0e929687..393c12cda 100644 --- a/src/dom/xpathparser.cpp +++ b/src/dom/xpathparser.cpp @@ -228,16 +228,16 @@ int XPathParser::getNumber(int p0, double &dresult) { int p = p0; if (p >= parselen) + { return p0;/*need at least x*/ - + } + bool isdouble = false; - bool negative = false; int ch = parsebuf[p]; if (ch=='-') { p++; - negative = true; if (p >= parselen) return p0; } @@ -1189,18 +1189,20 @@ int XPathParser::getFunctionCall(int p0, int depth) int p = p0; if (lexTokType(p) != FUNCTION_NAME) + { return p0; - + } + DOMString name = lexTok(p).getStringValue(); p++; if (lexTokType(p) != LPAREN) //this makes a function + { return p0; + } p++; - int argCount = 0; - int p2 = getArgument(p, depth+1); if (p2 < 0) { @@ -1209,7 +1211,7 @@ int XPathParser::getFunctionCall(int p0, int depth) } if (p2 > p) { - argCount++; + int argCount = 1; p = p2; while (lexTokType(p) == COMMA) { diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 76f7d7608..dc1c8402d 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -610,7 +610,6 @@ document_interface_document_resize_to_fit_selection (DocumentInterface *object, GError **error) { return dbus_call_verb (object, SP_VERB_FIT_CANVAS_TO_SELECTION, error); - return TRUE; } gboolean diff --git a/src/extension/dxf2svg/dxf2svg.cpp b/src/extension/dxf2svg/dxf2svg.cpp index ce2419a95..4884ed3fe 100644 --- a/src/extension/dxf2svg/dxf2svg.cpp +++ b/src/extension/dxf2svg/dxf2svg.cpp @@ -18,15 +18,8 @@ #include"entities2elements.h" - - - - - - int main(int argc,char *argv[]){ // Later include options for different conversions like converting as much as possible into paths - int ink = 1; // Assume for now there is no inkscape stuff to add extra if(argc > 1){ double scaling = 90; // converstion from in to pt @@ -64,13 +57,14 @@ int main(int argc,char *argv[]){ char units[5] = "in"; char tmp_char[100000]; char layer_string[500]; + // int ink = 1; // Assume for now there is no inkscape stuff to add extra - if (ink < 1){ + /*if (ink < 1){ // Write a general svg header std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n\t\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns=\"http://www.w3.org/2000/svg\"\n\txmlns:xlink=\"http://www.w3.org/1999/xlink\">\n"; std::cout << "\tx=\"0.00000000\"\n\ty=\"0.00000000\"\n\twidth=\"744.09448\"\n\theight=\"-1052.3622\"" << std::endl; } - else{ + else{*/ std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << std::endl; std::cout << "<!-- Created with dxf2svg -->" << std::endl; std::cout << "<svg" << std::endl; @@ -82,8 +76,7 @@ int main(int argc,char *argv[]){ std::cout << "\txmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"" << std::endl; std::cout << "\txmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"" << std::endl; std::cout << "\t>" << std::endl; - - } + //} // Now write SVG elements to file diff --git a/src/extension/dxf2svg/entities.cpp b/src/extension/dxf2svg/entities.cpp index c94df06f3..0b18ab176 100644 --- a/src/extension/dxf2svg/entities.cpp +++ b/src/extension/dxf2svg/entities.cpp @@ -278,14 +278,10 @@ double polyline::bulge_start_angle(int point){ double a = fabs(bulge*l/2); double sb = bulge/fabs(bulge); //sign of bulge - double theta_p = 4*atan(bulge); double theta_c; dx != 0 ? theta_c = atan(dy/dx) : theta_c = 1.57079632679489661923; // Check to make sure that dx is not zero and will give a negative number if (dx > 0) sb *= -1; // Correct for different point ordering and bulge direction - double cx = xmid + sb*(r-a)*sin(theta_c); - double cy = ymid - sb*(r-a)*cos(theta_c); - // Now calculate the angle double theta = asin(points[point].ret_x()/r); if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi @@ -307,14 +303,10 @@ double polyline::bulge_end_angle(int point){ double a = fabs(bulge*l/2); double sb = bulge/fabs(bulge); //sign of bulge - double theta_p = 4*atan(bulge); double theta_c; dx != 0 ? theta_c = atan(dy/dx) : theta_c = 1.57079632679489661923; // Check to make sure that dx is not zero and will give a negative number if (dx > 0) sb *= -1; // Correct for different point ordering and bulge direction - double cx = xmid + sb*(r-a)*sin(theta_c); - double cy = ymid - sb*(r-a)*cos(theta_c); - // Now calculate the angle double theta = asin(points[point+1].ret_x()/r); if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi @@ -473,14 +465,10 @@ double lwpolyline::bulge_start_angle(int point){ double a = fabs(bulge*l/2); double sb = bulge/fabs(bulge); //sign of bulge - double theta_p = 4*atan(bulge); double theta_c; dx != 0 ? theta_c = atan(dy/dx) : theta_c = 1.57079632679489661923; // Check to make sure that dx is not zero and will give a negative number if (dx > 0) sb *= -1; // Correct for different point ordering and bulge direction - double cx = xmid + sb*(r-a)*sin(theta_c); - double cy = ymid - sb*(r-a)*cos(theta_c); - // Now calculate the angle double theta = asin(points[point].ret_x()/r); if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi @@ -502,14 +490,10 @@ double lwpolyline::bulge_end_angle(int point){ double a = fabs(bulge*l/2); double sb = bulge/fabs(bulge); //sign of bulge - double theta_p = 4*atan(bulge); double theta_c; dx != 0 ? theta_c = atan(dy/dx) : theta_c = 1.57079632679489661923; // Check to make sure that dx is not zero and will give a negative number if (dx > 0) sb *= -1; // Correct for different point ordering and bulge direction - double cx = xmid + sb*(r-a)*sin(theta_c); - double cy = ymid - sb*(r-a)*cos(theta_c); - // Now calculate the angle double theta = asin(points[point+1].ret_x()/r); if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi diff --git a/src/extension/dxf2svg/entities2elements.cpp b/src/extension/dxf2svg/entities2elements.cpp index f280bb2a8..8a17a0d84 100644 --- a/src/extension/dxf2svg/entities2elements.cpp +++ b/src/extension/dxf2svg/entities2elements.cpp @@ -60,7 +60,6 @@ char* to_arc(double bulge, double r, double start_ang, double end_ang, int preci } // Build Coordinate -void coord(entity *ent, int precision,char* delim, char * units, double scaling, char *out); // Pairs of coords with units will be used so often build a function void coord(entity *ent, int precision,char* delim, char * units, double scaling, char *out){ // Pairs of coords with units will be used so often build a function build a dedicated function for returning such @@ -75,7 +74,7 @@ void coord(entity *ent, int precision,char* delim, char * units, double scaling, } // DXF Polyline -> SVG -void pline2svg(polyline pline, int type, int precision, char * units, double scaling, tables plot_info, char *out); // General function for the conversion of a pline to a SVG element. Very similar functions just make accomidations for parts that may not be supported +// General function for the conversion of a pline to a SVG element. Very similar functions just make accomidations for parts that may not be supported void pline2svg(polyline pline, int type, int precision, char * units, double scaling, tables plot_info, char *out){ // 0 is pline2path // 1 is pline2pline @@ -83,8 +82,6 @@ void pline2svg(polyline pline, int type, int precision, char * units, double sca char delim[2]; - double mag_bulge = 0; - double prev_mag_bulge = 0; std::vector< vertex >::iterator vver_iter; std::vector< vertex > points = pline.ret_points(); @@ -94,7 +91,7 @@ void pline2svg(polyline pline, int type, int precision, char * units, double sca strcpy(delim," "); strcat(out, "M "); coord( &points[0], precision, delim, units, scaling, out ); - prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude + double prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude if ( prev_mag_bulge > pow(0.1,precision) ){ to_arc(pline.bulge(0), pline.bulge_r(0), pline.bulge_start_angle(0), pline.bulge_end_angle(0), precision, delim, units, scaling, out); } @@ -105,7 +102,7 @@ void pline2svg(polyline pline, int type, int precision, char * units, double sca } coord( &points[i], precision, delim, units, scaling, out ); // If bulge > some precsion then add bulge - mag_bulge = sqrt(pow(points[i].ret_bulge(),2)); + double mag_bulge = sqrt(pow(points[i].ret_bulge(),2)); if ( (mag_bulge > pow(0.1,precision)) && (i < (points.size() - 1) )){ to_arc(pline.bulge(i), pline.bulge_r(i), pline.bulge_start_angle(i), pline.bulge_end_angle(i), precision, delim, units, scaling, out); } @@ -188,8 +185,6 @@ void lwpline2svg(lwpolyline pline, int type, int precision, char * units, double char delim[2]; - double mag_bulge = 0; - double prev_mag_bulge = 0; std::vector< vertex >::iterator vver_iter; std::vector< vertex > points = pline.ret_points(); @@ -199,7 +194,7 @@ void lwpline2svg(lwpolyline pline, int type, int precision, char * units, double strcpy(delim," "); strcat(out, "M "); coord( &points[0], precision, delim, NULL, scaling, out ); - prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude + double prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude if ( prev_mag_bulge > pow(0.1,precision) ){ to_arc(pline.bulge(0),pline.bulge_r(0), pline.bulge_start_angle(0), pline.bulge_end_angle(0), precision, delim, NULL, scaling, out); } @@ -211,7 +206,7 @@ void lwpline2svg(lwpolyline pline, int type, int precision, char * units, double } coord( &points[i], precision, delim, NULL , scaling, out ); // If bulge > some precsion then add bulge - mag_bulge = sqrt(pow(points[i].ret_bulge(),2)); + double mag_bulge = sqrt(pow(points[i].ret_bulge(),2)); if ( ( mag_bulge > pow(0.1,precision) ) && (i < (points.size() - 1) )){ // Make sure the final point doesn't add a bulge on accident to_arc(pline.bulge(i), pline.bulge_r(i), pline.bulge_start_angle(i), pline.bulge_end_angle(i), precision, delim, units, scaling, out); } diff --git a/src/extension/init.cpp b/src/extension/init.cpp index 064a59700..ba6ef4b30 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -330,18 +330,14 @@ check_extensions_internal(Extension *in_plug, gpointer in_data) } } -static void -check_extensions() +static void check_extensions() { int count = 1; - bool anyfail = false; - // int pass = 0; Inkscape::Extension::Extension::error_file_open(); while (count != 0) { count = 0; db.foreach(check_extensions_internal, (gpointer)&count); - if (count != 0) anyfail = true; } Inkscape::Extension::Extension::error_file_close(); } diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index b7909a512..debdd7d79 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -918,7 +918,6 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) transf << "0"; int levels = ext->get_param_int("levels") + 1; const gchar *effecttype = ext->get_param_enum("type"); - float val = 0.0; if (levels == 1) { if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { transf << " 1 0 1"; @@ -927,7 +926,7 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) } } else { for ( int step = 1 ; step <= levels ; step++ ) { - val = (float) step / levels; + float val = (float) step / levels; transf << " " << val; if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { transf << " " << (val - ((float) 1 / (3 * levels))) << " " << (val + ((float) 1 / (2 * levels))); diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 3e0afdd8e..bb9fd3d85 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -569,7 +569,6 @@ void SingularValueDecomposition::calculate() // Main iteration loop for the singular values. int pp = p-1; - int iter = 0; //double eps = pow(2.0,-52.0); //double tiny = pow(2.0,-966.0); //let's just calculate these now @@ -749,7 +748,6 @@ void SingularValueDecomposition::calculate() } } e[p-2] = f; - iter = iter + 1; } break; @@ -789,7 +787,6 @@ void SingularValueDecomposition::calculate() } k++; } - iter = 0; p--; } break; diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp index 554822dea..1c21fbca3 100644 --- a/src/extension/internal/pdfinput/pdf-parser.cpp +++ b/src/extension/internal/pdfinput/pdf-parser.cpp @@ -363,10 +363,9 @@ PdfParser::~PdfParser() { void PdfParser::parse(Object *obj, GBool topLevel) { Object obj2; - int i; if (obj->isArray()) { - for (i = 0; i < obj->arrayGetLength(); ++i) { + for (int i = 0; i < obj->arrayGetLength(); ++i) { obj->arrayGet(i, &obj2); if (!obj2.isStream()) { error(-1, const_cast<char*>("Weird page contents")); @@ -2339,7 +2338,7 @@ void PdfParser::doShowText(GooString *s) { #else Unicode u[8]; #endif - double x, y, dx, dy, curX, curY, tdx, tdy, lineX, lineY; + double x, y, dx, dy, tdx, tdy; double originX, originY, tOriginX, tOriginY; double oldCTM[6], newCTM[6]; double *mat; @@ -2347,7 +2346,7 @@ void PdfParser::doShowText(GooString *s) { Dict *resDict; Parser *oldParser; char *p; - int len, n, uLen, i; + int len, n, uLen; font = state->getFont(); wMode = font->getWMode(); @@ -2357,7 +2356,7 @@ void PdfParser::doShowText(GooString *s) { // handle a Type 3 char if (font->getType() == fontType3 && 0) {//out->interpretType3Chars()) { mat = state->getCTM(); - for (i = 0; i < 6; ++i) { + for (int i = 0; i < 6; ++i) { oldCTM[i] = mat[i]; } mat = state->getTextMat(); @@ -2377,10 +2376,10 @@ void PdfParser::doShowText(GooString *s) { newCTM[0] *= state->getHorizScaling(); newCTM[2] *= state->getHorizScaling(); state->textTransformDelta(0, state->getRise(), &riseX, &riseY); - curX = state->getCurX(); - curY = state->getCurY(); - lineX = state->getLineX(); - lineY = state->getLineY(); + double curX = state->getCurX(); + double curY = state->getCurY(); + double lineX = state->getLineX(); + double lineY = state->getLineY(); oldParser = parser; p = s->getCString(); len = s->getLength(); @@ -2518,7 +2517,7 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg) { Dict *dict, *maskDict; int width, height; - int bits, maskBits; + int bits; StreamColorSpaceMode csMode; GBool mask; GBool invert; @@ -2679,78 +2678,78 @@ void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg) dict->lookup(const_cast<char*>("Mask"), &maskObj); dict->lookup(const_cast<char*>("SMask"), &smaskObj); if (smaskObj.isStream()) { - // soft mask - if (inlineImg) { - goto err1; - } - maskStr = smaskObj.getStream(); - maskDict = smaskObj.streamGetDict(); - maskDict->lookup(const_cast<char*>("Width"), &obj1); - if (obj1.isNull()) { - obj1.free(); - maskDict->lookup(const_cast<char*>("W"), &obj1); - } - if (!obj1.isInt()) { - goto err2; - } - maskWidth = obj1.getInt(); - obj1.free(); - maskDict->lookup(const_cast<char*>("Height"), &obj1); - if (obj1.isNull()) { - obj1.free(); - maskDict->lookup(const_cast<char*>("H"), &obj1); - } - if (!obj1.isInt()) { - goto err2; - } - maskHeight = obj1.getInt(); - obj1.free(); - maskDict->lookup(const_cast<char*>("BitsPerComponent"), &obj1); - if (obj1.isNull()) { - obj1.free(); - maskDict->lookup(const_cast<char*>("BPC"), &obj1); - } - if (!obj1.isInt()) { - goto err2; - } - maskBits = obj1.getInt(); - obj1.free(); - maskDict->lookup(const_cast<char*>("ColorSpace"), &obj1); - if (obj1.isNull()) { - obj1.free(); - maskDict->lookup(const_cast<char*>("CS"), &obj1); - } - if (obj1.isName()) { - res->lookupColorSpace(obj1.getName(), &obj2); - if (!obj2.isNull()) { - obj1.free(); - obj1 = obj2; - } else { - obj2.free(); - } - } + // soft mask + if (inlineImg) { + goto err1; + } + maskStr = smaskObj.getStream(); + maskDict = smaskObj.streamGetDict(); + maskDict->lookup(const_cast<char*>("Width"), &obj1); + if (obj1.isNull()) { + obj1.free(); + maskDict->lookup(const_cast<char*>("W"), &obj1); + } + if (!obj1.isInt()) { + goto err2; + } + maskWidth = obj1.getInt(); + obj1.free(); + maskDict->lookup(const_cast<char*>("Height"), &obj1); + if (obj1.isNull()) { + obj1.free(); + maskDict->lookup(const_cast<char*>("H"), &obj1); + } + if (!obj1.isInt()) { + goto err2; + } + maskHeight = obj1.getInt(); + obj1.free(); + maskDict->lookup(const_cast<char*>("BitsPerComponent"), &obj1); + if (obj1.isNull()) { + obj1.free(); + maskDict->lookup(const_cast<char*>("BPC"), &obj1); + } + if (!obj1.isInt()) { + goto err2; + } + int maskBits = obj1.getInt(); + obj1.free(); + maskDict->lookup(const_cast<char*>("ColorSpace"), &obj1); + if (obj1.isNull()) { + obj1.free(); + maskDict->lookup(const_cast<char*>("CS"), &obj1); + } + if (obj1.isName()) { + res->lookupColorSpace(obj1.getName(), &obj2); + if (!obj2.isNull()) { + obj1.free(); + obj1 = obj2; + } else { + obj2.free(); + } + } #ifdef POPPLER_NEW_COLOR_SPACE_API - maskColorSpace = GfxColorSpace::parse(&obj1, NULL); + maskColorSpace = GfxColorSpace::parse(&obj1, NULL); #else - maskColorSpace = GfxColorSpace::parse(&obj1); + maskColorSpace = GfxColorSpace::parse(&obj1); #endif - obj1.free(); - if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) { - goto err1; - } - maskDict->lookup(const_cast<char*>("Decode"), &obj1); - if (obj1.isNull()) { - obj1.free(); - maskDict->lookup(const_cast<char*>("D"), &obj1); - } - maskColorMap = new GfxImageColorMap(maskBits, &obj1, maskColorSpace); - obj1.free(); - if (!maskColorMap->isOk()) { - delete maskColorMap; - goto err1; - } - //~ handle the Matte entry - haveSoftMask = gTrue; + obj1.free(); + if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) { + goto err1; + } + maskDict->lookup(const_cast<char*>("Decode"), &obj1); + if (obj1.isNull()) { + obj1.free(); + maskDict->lookup(const_cast<char*>("D"), &obj1); + } + maskColorMap = new GfxImageColorMap(maskBits, &obj1, maskColorSpace); + obj1.free(); + if (!maskColorMap->isOk()) { + delete maskColorMap; + goto err1; + } + //~ handle the Matte entry + haveSoftMask = gTrue; } else if (maskObj.isArray()) { // color key mask for (i = 0; diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp index bc75e62fc..bcb5b6e5b 100644 --- a/src/extension/param/bool.cpp +++ b/src/extension/param/bool.cpp @@ -31,7 +31,7 @@ ParamBool::ParamBool(const gchar * name, const gchar * guitext, const gchar * de defaultval = xml->firstChild()->content(); } - if (defaultval != NULL && (!strcmp(defaultval, "true") || !strcmp(defaultval, "true") || !strcmp(defaultval, "1"))) { + if (defaultval != NULL && (!strcmp(defaultval, "true") || !strcmp(defaultval, "1"))) { _value = true; } else { _value = false; diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index 730a0934c..e44ae3f1b 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -547,7 +547,7 @@ protected: } virtual CommitEvent getCommitEvent() { - return _side % 2 + return (_side % 2) ? COMMIT_MOUSE_SKEW_Y : COMMIT_MOUSE_SKEW_X; } |
