From f10048be170a45921ae8fc65ccd2588a9ad2897d Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 27 Aug 2013 12:32:55 -0400 Subject: Added viewBox implement document unit support. (bzr r12475.1.2) --- src/extension/internal/cairo-renderer.cpp | 4 ++-- src/extension/internal/grid.cpp | 5 +++-- src/extension/internal/latex-pstricks.cpp | 8 ++++---- src/extension/internal/latex-text-renderer.cpp | 4 ++-- src/extension/internal/odf.cpp | 3 ++- 5 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index f7ab63c98..eddc5ba23 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -645,9 +645,9 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page Geom::Affine tp( Geom::Translate( bleedmargin_px, bleedmargin_px ) ); ctx->transform(tp); } else { - double high = doc->getHeight(); + double high = doc->getHeight().value("px"); if (ctx->_vector_based_target) - high *= Inkscape::Util::Quantity::convert(1, "px", "pt"); + high = Inkscape::Util::Quantity::convert(high, "px", "pt"); // this transform translates the export drawing to a virtual page (0,0)-(width,height) Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? Inkscape::Util::Quantity::convert(1, "pt", "px") : 1.0), diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 820d1c9d3..2f9d0ff25 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -35,6 +35,7 @@ #include "extension/effect.h" #include "extension/system.h" +#include "util/units.h" #include "grid.h" @@ -97,14 +98,14 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc /* get page size */ SPDocument * doc = document->doc(); bounding_area = Geom::Rect( Geom::Point(0,0), - Geom::Point(doc->getWidth(), doc->getHeight()) ); + Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px")) ); } else { Geom::OptRect bounds = selection->visualBounds(); if (bounds) { bounding_area = *bounds; } - gdouble doc_height = (document->doc())->getHeight(); + gdouble doc_height = (document->doc())->getHeight().value("px"); Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]), Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y])); diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp index 2ece1ba87..c8e8e2f2e 100644 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@ -117,8 +117,8 @@ unsigned int PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc } // width and height in pt - _width = doc->getWidth() * Inkscape::Util::Quantity::convert(1, "px", "pt"); - _height = doc->getHeight() * Inkscape::Util::Quantity::convert(1, "px", "pt"); + _width = doc->getWidth().value("pt"); + _height = doc->getHeight().value("pt"); if (res >= 0) { @@ -128,10 +128,10 @@ unsigned int PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc os << "\\psset{xunit=.5pt,yunit=.5pt,runit=.5pt}\n"; // from now on we can output px, but they will be treated as pt - os << "\\begin{pspicture}(" << doc->getWidth() << "," << doc->getHeight() << ")\n"; + os << "\\begin{pspicture}(" << doc->getWidth().value("px") << "," << doc->getHeight().value("px") << ")\n"; } - m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight())); /// @fixme hardcoded doc2dt transform + m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight().value("px"))); /// @fixme hardcoded doc2dt transform return fprintf(_stream, "%s", os.str().c_str()); } diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 57a71b467..b1c67aa81 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -602,7 +602,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, float bl } // flip y-axis - push_transform( Geom::Scale(1,-1) * Geom::Translate(0, doc->getHeight()) ); /// @fixme hardcoded desktop transform! + push_transform( Geom::Scale(1,-1) * Geom::Translate(0, doc->getHeight().value("px")) ); /// @fixme hardcoded desktop transform! // write the info to LaTeX Inkscape::SVGOStringStream os; @@ -611,7 +611,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, float bl // scaling of the image when including it in LaTeX os << " \\ifx\\svgwidth\\undefined%\n"; - os << " \\setlength{\\unitlength}{" << d.width() * Inkscape::Util::Quantity::convert(1, "px", "pt") << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384 + os << " \\setlength{\\unitlength}{" << Inkscape::Util::Quantity::convert(d.width(), "px", "pt") << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384 os << " \\ifx\\svgscale\\undefined%\n"; os << " \\relax%\n"; os << " \\else%\n"; diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 9f745cdea..a4dbd1428 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -75,6 +75,7 @@ #include "sp-flowtext.h" #include "svg/svg.h" #include "text-editing.h" +#include "util/units.h" //# DOM-specific includes @@ -945,7 +946,7 @@ static Geom::Affine getODFTransform(const SPItem *item) //### Get SVG-to-ODF transform Geom::Affine tf (item->i2dt_affine()); //Flip Y into document coordinates - double doc_height = SP_ACTIVE_DOCUMENT->getHeight(); + double doc_height = SP_ACTIVE_DOCUMENT->getHeight().value("px"); Geom::Affine doc2dt_tf = Geom::Affine(Geom::Scale(1.0, -1.0)); /// @fixme hardcoded desktop transform doc2dt_tf = doc2dt_tf * Geom::Affine(Geom::Translate(0, doc_height)); tf = tf * doc2dt_tf; -- cgit v1.2.3 From 7dc2527975e5af02aa0b737d9a67e70bda62bfae Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 27 Aug 2013 21:26:29 -0400 Subject: Fix Windows build. (bzr r12475.1.5) --- src/extension/internal/emf-win32-print.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 621954f68..467260a92 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -113,8 +113,8 @@ unsigned int PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument * WCHAR *unicode_uri = (WCHAR *) unicode_fn; // width and height in px - _width = doc->getWidth(); - _height = doc->getHeight(); + _width = doc->getWidth().value("px"); + _height = doc->getHeight().value("px"); bool pageBoundingBox; pageBoundingBox = mod->get_param_bool("pageBoundingBox"); @@ -204,7 +204,7 @@ unsigned int PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument * g_free(local_fn); g_free(unicode_fn); - m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight())); /// @fixme hardcoded doc2dt transform + m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight().value("px"))); /// @fixme hardcoded doc2dt transform return 0; } -- cgit v1.2.3 From 3bfb610bb7719d49821fe5381ae449789c3cb968 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 27 Aug 2013 23:32:14 -0400 Subject: Improve code readability. (bzr r12475.1.9) --- src/extension/internal/cairo-renderer-pdf-out.cpp | 2 +- src/extension/internal/cairo-renderer.cpp | 4 +- src/extension/internal/emf-win32-inout.cpp | 10 ++-- src/extension/internal/emf-win32-print.cpp | 68 +++++++++++------------ src/extension/internal/pdfinput/pdf-parser.cpp | 6 +- src/extension/internal/pdfinput/svg-builder.cpp | 2 +- 6 files changed, 46 insertions(+), 46 deletions(-) (limited to 'src/extension') 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 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); -- cgit v1.2.3 From 25e63ea5e5cd74220b51d3946808573bd3b4b3bf Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 15 Sep 2013 15:52:57 -0400 Subject: Improved code readability. (bzr r12475.1.21) --- src/extension/internal/emf-inout.cpp | 4 ++-- src/extension/internal/emf-print.cpp | 2 +- src/extension/internal/wmf-inout.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index b185d3348..ab8a1ab64 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -1799,8 +1799,8 @@ std::cout << "BEFORE DRAW" d->MMX = d->MM100InX / 100.0; d->MMY = d->MM100InY / 100.0; - d->PixelsOutX = d->MMX * Inkscape::Util::Quantity::convert(1, "mm", "px"); - d->PixelsOutY = d->MMY * Inkscape::Util::Quantity::convert(1, "mm", "px"); + d->PixelsOutX = Inkscape::Util::Quantity::convert(d->MMX, "mm", "px"); + d->PixelsOutY = Inkscape::Util::Quantity::convert(d->MMY, "mm", "px"); // Upper left corner, from header rclBounds, in device units, usually both 0, but not always d->ulCornerInX = pEmr->rclBounds.left; diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index bb5625ef3..7fb24a317 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -242,7 +242,7 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) g_error("Fatal programming error in PrintEmf::begin at textcomment_set 1"); } - 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")); rec = textcomment_set(buff); if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { g_error("Fatal programming error in PrintEmf::begin at textcomment_set 1"); diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index 451d94c0e..373138187 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -1742,8 +1742,8 @@ int Wmf::myMetaFileProc(const char *contents, unsigned int length, PWMF_CALLBACK tmp_outdef << " version=\"1.0\"\n"; tmp_outdef << - " width=\"" << d->PixelsOutX/ Inkscape::Util::Quantity::convert(1, "mm", "px") << "mm\"\n" << - " height=\"" << d->PixelsOutY/ Inkscape::Util::Quantity::convert(1, "mm", "px") << "mm\">\n"; + " width=\"" << Inkscape::Util::Quantity::convert(d->PixelsOutX, "px", "mm") << "mm\"\n" << + " height=\"" << Inkscape::Util::Quantity::convert(d->PixelsOutY, "px", "mm") << "mm\">\n"; *(d->outdef) += tmp_outdef.str().c_str(); *(d->outdef) += ""; // temporary end of header -- cgit v1.2.3