diff options
| author | Matthew Petroff <matthew@mpetroff.net> | 2013-08-28 03:32:14 +0000 |
|---|---|---|
| committer | Matthew Petroff <matthew@mpetroff.net> | 2013-08-28 03:32:14 +0000 |
| commit | 3bfb610bb7719d49821fe5381ae449789c3cb968 (patch) | |
| tree | c6c221e0c7bfcc6399ee4aee360b7b1d4de3f896 /src/extension | |
| parent | Use Quantity comparisons in PageSizer. (diff) | |
| download | inkscape-3bfb610bb7719d49821fe5381ae449789c3cb968.tar.gz inkscape-3bfb610bb7719d49821fe5381ae449789c3cb968.zip | |
Improve code readability.
(bzr r12475.1.9)
Diffstat (limited to 'src/extension')
| -rw-r--r-- | src/extension/internal/cairo-renderer-pdf-out.cpp | 2 | ||||
| -rw-r--r-- | src/extension/internal/cairo-renderer.cpp | 4 | ||||
| -rw-r--r-- | src/extension/internal/emf-win32-inout.cpp | 10 | ||||
| -rw-r--r-- | src/extension/internal/emf-win32-print.cpp | 68 | ||||
| -rw-r--r-- | src/extension/internal/pdfinput/pdf-parser.cpp | 6 | ||||
| -rw-r--r-- | src/extension/internal/pdfinput/svg-builder.cpp | 2 |
6 files changed, 46 insertions, 46 deletions
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index 0a0c3f44a..f4eed1c57 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -197,7 +197,7 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, float new_bleedmargin_px = 0.; try { - new_bleedmargin_px = mod->get_param_float("bleed") * Inkscape::Util::Quantity::convert(1, "mm", "px"); + new_bleedmargin_px = Inkscape::Util::Quantity::convert(mod->get_param_float("bleed"), "mm", "px"); } catch(...) { g_warning("Parameter <bleed> might not exist"); diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index eddc5ba23..84f090745 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -463,8 +463,8 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) } // The width and height of the bitmap in pixels - unsigned width = ceil(bbox->width() * (res / Inkscape::Util::Quantity::convert(1, "in", "px"))); - unsigned height = ceil(bbox->height() * (res / Inkscape::Util::Quantity::convert(1, "in", "px"))); + unsigned width = ceil(bbox->width() * Inkscape::Util::Quantity::convert(res, "px", "in")); + unsigned height = ceil(bbox->height() * Inkscape::Util::Quantity::convert(res, "px", "in")); if (width == 0 || height == 0) return; diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 60385f455..b9ab2e385 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -781,18 +781,18 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const * d->dc[d->level].PixelsInX = pEmr->rclFrame.right - pEmr->rclFrame.left; d->dc[d->level].PixelsInY = pEmr->rclFrame.bottom - pEmr->rclFrame.top; - device_x = pEmr->rclFrame.left/100.0*Inkscape::Util::Quantity::convert(1, "mm", "px"); - device_y = pEmr->rclFrame.top/100.0*Inkscape::Util::Quantity::convert(1, "mm", "px"); + device_x = Inkscape::Util::Quantity::convert(pEmr->rclFrame.left/100.0, "mm", "px"); + device_y = Inkscape::Util::Quantity::convert(pEmr->rclFrame.top/100.0, "mm", "px"); d->MMX = d->dc[d->level].PixelsInX / 100.0; d->MMY = d->dc[d->level].PixelsInY / 100.0; - d->dc[d->level].PixelsOutX = d->MMX * Inkscape::Util::Quantity::convert(1, "mm", "px"); - d->dc[d->level].PixelsOutY = d->MMY * Inkscape::Util::Quantity::convert(1, "mm", "px"); + d->dc[d->level].PixelsOutX = Inkscape::Util::Quantity::convert(d->MMX, "mm", "px"); + d->dc[d->level].PixelsOutY = Inkscape::Util::Quantity::convert(d->MMY, "mm", "px"); // calculate ratio of Inkscape dpi/device dpi if (pEmr->szlMillimeters.cx && pEmr->szlDevice.cx) - device_scale = Inkscape::Util::Quantity::convert(1, "mm", "px")*pEmr->szlMillimeters.cx/pEmr->szlDevice.cx; + device_scale = Inkscape::Util::Quantity::convert(pEmr->szlMillimeters.cx/pEmr->szlDevice.cx, "mm", "px"); tmp_outdef << " width=\"" << d->MMX << "mm\"\n" << diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 467260a92..e01782257 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -195,7 +195,7 @@ unsigned int PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument * snprintf(buff, sizeof(buff)-1, "Screen=%dx%dpx, %dx%dmm", PixelsX, PixelsY, MMX, MMY); GdiComment(hdc, strlen(buff), (BYTE*) buff); - snprintf(buff, sizeof(buff)-1, "Drawing=%.1lfx%.1lfpx, %.1lfx%.1lfmm", _width, _height, dwInchesX * Inkscape::Util::Quantity::convert(1, "in", "mm"), dwInchesY * Inkscape::Util::Quantity::convert(1, "in", "mm")); + snprintf(buff, sizeof(buff)-1, "Drawing=%.1lfx%.1lfpx, %.1lfx%.1lfmm", _width, _height, Inkscape::Util::Quantity::convert(dwInchesX, "in", "mm"), Inkscape::Util::Quantity::convert(dwInchesY, "in", "mm")); GdiComment(hdc, strlen(buff), (BYTE*) buff); } @@ -303,7 +303,7 @@ void PrintEmfWin32::create_pen(SPStyle const *style, const Geom::Affine &transfo double scale = sqrt( (p[X]*p[X]) + (p[Y]*p[Y]) ) / sqrt(2); - DWORD linewidth = MAX( 1, (DWORD) (scale * style->stroke_width.computed * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI) ); + DWORD linewidth = MAX( 1, (DWORD) (scale * Inkscape::Util::Quantity::convert(style->stroke_width.computed, "px", "in") * dwDPI) ); if (style->stroke_linecap.computed == 0) { linecap = PS_ENDCAP_FLAT; @@ -340,7 +340,7 @@ void PrintEmfWin32::create_pen(SPStyle const *style, const Geom::Affine &transfo n_dash = style->stroke_dash.n_dash; dash = new DWORD[n_dash]; for (i = 0; i < style->stroke_dash.n_dash; i++) { - dash[i] = (DWORD) (style->stroke_dash.dash[i] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); + dash[i] = (DWORD) (Inkscape::Util::Quantity::convert(style->stroke_dash.dash[i], "px", "in") * dwDPI); } } } @@ -543,8 +543,8 @@ bool PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom Geom::Point p0 = pit->initialPoint(); - p0[X] = (p0[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p0[Y] = (p0[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); + p0[X] = (Inkscape::Util::Quantity::convert(p0[X], "px", "in") * dwDPI); + p0[Y] = (Inkscape::Util::Quantity::convert(p0[Y], "px", "in") * dwDPI); LONG const x0 = (LONG) round(p0[X]); LONG const y0 = (LONG) round(rc.bottom-p0[Y]); @@ -563,10 +563,10 @@ bool PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom //Geom::Point p0 = cit->initialPoint(); Geom::Point p1 = cit->finalPoint(); - //p0[X] = (p0[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p1[X] = (p1[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - //p0[Y] = (p0[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p1[Y] = (p1[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); + //p0[X] = (Inkscape::Util::Quantity::convert(p0[X], "px", "in") * dwDPI); + p1[X] = (Inkscape::Util::Quantity::convert(p1[X], "px", "in") * dwDPI); + //p0[Y] = (Inkscape::Util::Quantity::convert(p0[Y], "px", "in") * dwDPI); + p1[Y] = (Inkscape::Util::Quantity::convert(p1[Y], "px", "in") * dwDPI); //LONG const x0 = (LONG) round(p0[X]); //LONG const y0 = (LONG) round(rc.bottom-p0[Y]); @@ -585,14 +585,14 @@ bool PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom Geom::Point p2 = points[2]; Geom::Point p3 = points[3]; - //p0[X] = (p0[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p1[X] = (p1[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p2[X] = (p2[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p3[X] = (p3[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - //p0[Y] = (p0[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p1[Y] = (p1[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p2[Y] = (p2[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p3[Y] = (p3[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); + //p0[X] = (Inkscape::Util::Quantity::convert(p0[X], "px", "in") * dwDPI); + p1[X] = (Inkscape::Util::Quantity::convert(p1[X], "px", "in") * dwDPI); + p2[X] = (Inkscape::Util::Quantity::convert(p2[X], "px", "in") * dwDPI); + p3[X] = (Inkscape::Util::Quantity::convert(p3[X], "px", "in") * dwDPI); + //p0[Y] = (Inkscape::Util::Quantity::convert(p0[Y], "px", "in") * dwDPI); + p1[Y] = (Inkscape::Util::Quantity::convert(p1[Y], "px", "in") * dwDPI); + p2[Y] = (Inkscape::Util::Quantity::convert(p2[Y], "px", "in") * dwDPI); + p3[Y] = (Inkscape::Util::Quantity::convert(p3[Y], "px", "in") * dwDPI); //LONG const x0 = (LONG) round(p0[X]); //LONG const y0 = (LONG) round(rc.bottom-p0[Y]); @@ -715,8 +715,8 @@ unsigned int PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geo Geom::Point p0 = pit->initialPoint(); - p0[X] = (p0[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p0[Y] = (p0[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); + p0[X] = (Inkscape::Util::Quantity::convert(p0[X], "px", "in") * dwDPI); + p0[Y] = (Inkscape::Util::Quantity::convert(p0[Y], "px", "in") * dwDPI); LONG const x0 = (LONG) round(p0[X]); LONG const y0 = (LONG) round(rc.bottom-p0[Y]); @@ -733,10 +733,10 @@ unsigned int PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geo //Geom::Point p0 = cit->initialPoint(); Geom::Point p1 = cit->finalPoint(); - //p0[X] = (p0[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p1[X] = (p1[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - //p0[Y] = (p0[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p1[Y] = (p1[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); + //p0[X] = (Inkscape::Util::Quantity::convert(p0[X], "px", "in") * dwDPI); + p1[X] = (Inkscape::Util::Quantity::convert(p1[X], "px", "in") * dwDPI); + //p0[Y] = (Inkscape::Util::Quantity::convert(p0[Y], "px", "in") * dwDPI); + p1[Y] = (Inkscape::Util::Quantity::convert(p1[Y], "px", "in") * dwDPI); //LONG const x0 = (LONG) round(p0[X]); //LONG const y0 = (LONG) round(rc.bottom-p0[Y]); @@ -753,14 +753,14 @@ unsigned int PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geo Geom::Point p2 = points[2]; Geom::Point p3 = points[3]; - //p0[X] = (p0[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p1[X] = (p1[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p2[X] = (p2[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p3[X] = (p3[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - //p0[Y] = (p0[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p1[Y] = (p1[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p2[Y] = (p2[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p3[Y] = (p3[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); + //p0[X] = (Inkscape::Util::Quantity::convert(p0[X], "px", "in") * dwDPI); + p1[X] = (Inkscape::Util::Quantity::convert(p1[X], "px", "in") * dwDPI); + p2[X] = (Inkscape::Util::Quantity::convert(p2[X], "px", "in") * dwDPI); + p3[X] = (Inkscape::Util::Quantity::convert(p3[X], "px", "in") * dwDPI); + //p0[Y] = (Inkscape::Util::Quantity::convert(p0[Y], "px", "in") * dwDPI); + p1[Y] = (Inkscape::Util::Quantity::convert(p1[Y], "px", "in") * dwDPI); + p2[Y] = (Inkscape::Util::Quantity::convert(p2[Y], "px", "in") * dwDPI); + p3[Y] = (Inkscape::Util::Quantity::convert(p3[Y], "px", "in") * dwDPI); //LONG const x0 = (LONG) round(p0[X]); //LONG const y0 = (LONG) round(rc.bottom-p0[Y]); @@ -828,7 +828,7 @@ unsigned int PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char cons LOGFONTW *lf = (LOGFONTW*)g_malloc(sizeof(LOGFONTW)); g_assert(lf != NULL); - lf->lfHeight = -style->font_size.computed * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI; + lf->lfHeight = Inkscape::Util::Quantity::convert(-style->font_size.computed, "px", "in") * dwDPI; lf->lfWidth = 0; lf->lfEscapement = rot; lf->lfOrientation = rot; @@ -877,8 +877,8 @@ unsigned int PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char cons SetBkMode(hdc, TRANSPARENT); Geom::Point p2 = p * tf; - p2[Geom::X] = (p2[Geom::X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); - p2[Geom::Y] = (p2[Geom::Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); + p2[Geom::X] = (Inkscape::Util::Quantity::convert(p2[Geom::X], "px", "in") * dwDPI); + p2[Geom::Y] = (Inkscape::Util::Quantity::convert(p2[Geom::Y], "px", "in") * dwDPI); LONG const xpos = (LONG) round(p2[Geom::X]); LONG const ypos = (LONG) round(rc.bottom - p2[Geom::Y]); diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp index 6e57f6278..7edb758fd 100644 --- a/src/extension/internal/pdfinput/pdf-parser.cpp +++ b/src/extension/internal/pdfinput/pdf-parser.cpp @@ -279,14 +279,14 @@ PdfParser::PdfParser(XRef *xrefA, Inkscape::Extension::Internal::SvgBuilder *bui ignoreUndef = 0; operatorHistory = NULL; builder = builderA; - builder->setDocumentSize(state->getPageWidth()*Inkscape::Util::Quantity::convert(1, "pt", "px"), - state->getPageHeight()*Inkscape::Util::Quantity::convert(1, "pt", "px")); + builder->setDocumentSize(Inkscape::Util::Quantity::convert(state->getPageWidth(), "pt", "px"), + Inkscape::Util::Quantity::convert(state->getPageHeight(), "pt", "px")); double *ctm = state->getCTM(); double scaledCTM[6]; for (int i = 0; i < 6; ++i) { baseMatrix[i] = ctm[i]; - scaledCTM[i] = Inkscape::Util::Quantity::convert(1, "pt", "px") * ctm[i]; + scaledCTM[i] = Inkscape::Util::Quantity::convert(ctm[i], "pt", "px"); } saveState(); builder->setTransform((double*)&scaledCTM); diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index a1a309a87..b3f15bbff 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -793,7 +793,7 @@ gchar *SvgBuilder::_createGradient(GfxShading *shading, double *matrix, bool for Geom::Affine pat_matrix(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); if ( !for_shading && _is_top_level ) { - Geom::Affine flip(1.0, 0.0, 0.0, -1.0, 0.0, _height * Inkscape::Util::Quantity::convert(1, "px", "pt")); + Geom::Affine flip(1.0, 0.0, 0.0, -1.0, 0.0, Inkscape::Util::Quantity::convert(_height, "px", "pt")); pat_matrix *= flip; } gchar *transform_text = sp_svg_transform_write(pat_matrix); |
