summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-08-28 03:32:14 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-08-28 03:32:14 +0000
commit3bfb610bb7719d49821fe5381ae449789c3cb968 (patch)
treec6c221e0c7bfcc6399ee4aee360b7b1d4de3f896 /src
parentUse Quantity comparisons in PageSizer. (diff)
downloadinkscape-3bfb610bb7719d49821fe5381ae449789c3cb968.tar.gz
inkscape-3bfb610bb7719d49821fe5381ae449789c3cb968.zip
Improve code readability.
(bzr r12475.1.9)
Diffstat (limited to 'src')
-rw-r--r--src/document.cpp2
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.cpp2
-rw-r--r--src/extension/internal/cairo-renderer.cpp4
-rw-r--r--src/extension/internal/emf-win32-inout.cpp10
-rw-r--r--src/extension/internal/emf-win32-print.cpp68
-rw-r--r--src/extension/internal/pdfinput/pdf-parser.cpp6
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp2
-rw-r--r--src/helper/pixbuf-ops.cpp2
-rw-r--r--src/main.cpp8
-rw-r--r--src/selection-chemistry.cpp6
-rw-r--r--src/style.cpp30
-rw-r--r--src/text-editing.cpp10
-rw-r--r--src/ui/clipboard.cpp4
-rw-r--r--src/ui/dialog/print.cpp4
-rw-r--r--src/ui/dialog/text-edit.cpp2
15 files changed, 80 insertions, 80 deletions
diff --git a/src/document.cpp b/src/document.cpp
index 20c6fe331..a544c60c9 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -980,7 +980,7 @@ void SPDocument::setupViewport(SPItemCtx *ctx)
if (root->viewBox_set) { // if set, take from viewBox
ctx->viewport = root->viewBox;
} else { // as a last resort, set size to A4
- ctx->viewport = Geom::Rect::from_xywh(0, 0, 210 * Inkscape::Util::Quantity::convert(1, "mm", "px"), 297 * Inkscape::Util::Quantity::convert(1, "mm", "px"));
+ ctx->viewport = Geom::Rect::from_xywh(0, 0, Inkscape::Util::Quantity::convert(210, "mm", "px"), Inkscape::Util::Quantity::convert(297, "mm", "px"));
}
ctx->i2vp = Geom::identity();
}
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);
diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp
index db7b73e34..a53da5bba 100644
--- a/src/helper/pixbuf-ops.cpp
+++ b/src/helper/pixbuf-ops.cpp
@@ -121,7 +121,7 @@ GdkPixbuf *sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*
origin[Geom::X] = origin[Geom::X] + (screen[Geom::X].extent() * ((1 - padding) / 2));
origin[Geom::Y] = origin[Geom::Y] + (screen[Geom::Y].extent() * ((1 - padding) / 2));
- Geom::Scale scale( (xdpi / Inkscape::Util::Quantity::convert(1, "in", "px")), (ydpi / Inkscape::Util::Quantity::convert(1, "in", "px")));
+ Geom::Scale scale(Inkscape::Util::Quantity::convert(xdpi, "px", "in"), Inkscape::Util::Quantity::convert(ydpi, "px", "in"));
Geom::Affine affine = scale * Geom::Translate(-origin * scale);
/* Create ArenaItems and set transform */
diff --git a/src/main.cpp b/src/main.cpp
index 29f431aa8..dccf70889 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1536,7 +1536,7 @@ static int sp_do_export_png(SPDocument *doc)
g_warning("Export width %lu out of range (1 - %lu). Nothing exported.", width, (unsigned long int)PNG_UINT_31_MAX);
return 1;
}
- dpi = (gdouble) width * Inkscape::Util::Quantity::convert(1, "in", "px") / area.width();
+ dpi = (gdouble) Inkscape::Util::Quantity::convert(width, "in", "px") / area.width();
}
if (sp_export_height) {
@@ -1546,15 +1546,15 @@ static int sp_do_export_png(SPDocument *doc)
g_warning("Export height %lu out of range (1 - %lu). Nothing exported.", height, (unsigned long int)PNG_UINT_31_MAX);
return 1;
}
- dpi = (gdouble) height * Inkscape::Util::Quantity::convert(1, "in", "px") / area.height();
+ dpi = (gdouble) Inkscape::Util::Quantity::convert(height, "in", "px") / area.height();
}
if (!sp_export_width) {
- width = (unsigned long int) (area.width() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5);
+ width = (unsigned long int) (Inkscape::Util::Quantity::convert(area.width(), "px", "in") * dpi + 0.5);
}
if (!sp_export_height) {
- height = (unsigned long int) (area.height() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5);
+ height = (unsigned long int) (Inkscape::Util::Quantity::convert(area.height(), "px", "in") * dpi + 0.5);
}
guint32 bgcolor = 0x00000000;
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 3c12b78bd..14e3462d7 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -3397,7 +3397,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
res = prefs_res;
} else if (0 < prefs_min) {
// If minsize is given, look up minimum bitmap size (default 250 pixels) and calculate resolution from it
- res = Inkscape::Util::Quantity::convert(1, "in", "px") * prefs_min / MIN(bbox->width(), bbox->height());
+ res = Inkscape::Util::Quantity::convert(prefs_min, "in", "px") / MIN(bbox->width(), bbox->height());
} else {
float hint_xdpi = 0, hint_ydpi = 0;
Glib::ustring hint_filename;
@@ -3418,8 +3418,8 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
}
// The width and height of the bitmap in pixels
- unsigned width = (unsigned) floor(bbox->width() * res / Inkscape::Util::Quantity::convert(1, "in", "px"));
- unsigned height =(unsigned) floor(bbox->height() * res / Inkscape::Util::Quantity::convert(1, "in", "px"));
+ unsigned width = (unsigned) floor(bbox->width() * Inkscape::Util::Quantity::convert(res, "px", "in"));
+ unsigned height =(unsigned) floor(bbox->height() * Inkscape::Util::Quantity::convert(res, "px", "in"));
// Find out if we have to run an external filter
gchar const *run = NULL;
diff --git a/src/style.cpp b/src/style.cpp
index 4a808fac6..8c0000f3a 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -2483,11 +2483,11 @@ sp_style_css_size_px_to_units(double size, int unit)
case SP_CSS_UNIT_NONE: unit_size = size; break;
case SP_CSS_UNIT_PX: unit_size = size; break;
- case SP_CSS_UNIT_PT: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "pt"); break;
- case SP_CSS_UNIT_PC: unit_size = size * (Inkscape::Util::Quantity::convert(1, "px", "pt") / Inkscape::Util::Quantity::convert(1, "pc", "pt")); break;
- case SP_CSS_UNIT_MM: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "mm"); break;
- case SP_CSS_UNIT_CM: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "cm"); break;
- case SP_CSS_UNIT_IN: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "in"); break;
+ case SP_CSS_UNIT_PT: unit_size = Inkscape::Util::Quantity::convert(size, "px", "pt"); break;
+ case SP_CSS_UNIT_PC: unit_size = Inkscape::Util::Quantity::convert(size, "px", "pc"); break;
+ case SP_CSS_UNIT_MM: unit_size = Inkscape::Util::Quantity::convert(size, "px", "mm"); break;
+ case SP_CSS_UNIT_CM: unit_size = Inkscape::Util::Quantity::convert(size, "px", "cm"); break;
+ case SP_CSS_UNIT_IN: unit_size = Inkscape::Util::Quantity::convert(size, "px", "in"); break;
case SP_CSS_UNIT_EM: unit_size = size / SP_CSS_FONT_SIZE_DEFAULT; break;
case SP_CSS_UNIT_EX: unit_size = size * 2.0 / SP_CSS_FONT_SIZE_DEFAULT ; break;
case SP_CSS_UNIT_PERCENT: unit_size = size * 100.0 / SP_CSS_FONT_SIZE_DEFAULT; break;
@@ -3472,19 +3472,19 @@ sp_style_read_ilength(SPILength *val, gchar const *str)
} else if (!strcmp(e, "pt")) {
/* Userspace / DEVICESCALE */
val->unit = SP_CSS_UNIT_PT;
- val->computed = value * Inkscape::Util::Quantity::convert(1, "pt", "px");
+ val->computed = Inkscape::Util::Quantity::convert(value, "pt", "px");
} else if (!strcmp(e, "pc")) {
val->unit = SP_CSS_UNIT_PC;
- val->computed = value * Inkscape::Util::Quantity::convert(1, "pc", "px");
+ val->computed = Inkscape::Util::Quantity::convert(value, "pc", "px");
} else if (!strcmp(e, "mm")) {
val->unit = SP_CSS_UNIT_MM;
- val->computed = value * Inkscape::Util::Quantity::convert(1, "mm", "px");
+ val->computed = Inkscape::Util::Quantity::convert(value, "mm", "px");
} else if (!strcmp(e, "cm")) {
val->unit = SP_CSS_UNIT_CM;
- val->computed = value * Inkscape::Util::Quantity::convert(1, "cm", "px");
+ val->computed = Inkscape::Util::Quantity::convert(value, "cm", "px");
} else if (!strcmp(e, "in")) {
val->unit = SP_CSS_UNIT_IN;
- val->computed = value * Inkscape::Util::Quantity::convert(1, "in", "px");
+ val->computed = Inkscape::Util::Quantity::convert(value, "in", "px");
} else if (!strcmp(e, "em")) {
/* EM square */
val->unit = SP_CSS_UNIT_EM;
@@ -4043,23 +4043,23 @@ sp_style_write_ilength(gchar *p, gint const len, gchar const *const key,
return g_strlcpy(p, os.str().c_str(), len);
break;
case SP_CSS_UNIT_PT:
- os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "pt") << "pt;";
+ os << key << ":" << Inkscape::Util::Quantity::convert(val->computed, "px", "pt") << "pt;";
return g_strlcpy(p, os.str().c_str(), len);
break;
case SP_CSS_UNIT_PC:
- os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "pt") / 12.0 << "pc;";
+ os << key << ":" << Inkscape::Util::Quantity::convert(val->computed, "px", "pc") << "pc;";
return g_strlcpy(p, os.str().c_str(), len);
break;
case SP_CSS_UNIT_MM:
- os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "mm") << "mm;";
+ os << key << ":" << Inkscape::Util::Quantity::convert(val->computed, "px", "mm") << "mm;";
return g_strlcpy(p, os.str().c_str(), len);
break;
case SP_CSS_UNIT_CM:
- os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "cm") << "cm;";
+ os << key << ":" << Inkscape::Util::Quantity::convert(val->computed, "px", "cm") << "cm;";
return g_strlcpy(p, os.str().c_str(), len);
break;
case SP_CSS_UNIT_IN:
- os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "in") << "in;";
+ os << key << ":" << Inkscape::Util::Quantity::convert(val->computed, "px", "in") << "in;";
return g_strlcpy(p, os.str().c_str(), len);
break;
case SP_CSS_UNIT_EM:
diff --git a/src/text-editing.cpp b/src/text-editing.cpp
index 0d30863d9..cc59b0145 100644
--- a/src/text-editing.cpp
+++ b/src/text-editing.cpp
@@ -1278,23 +1278,23 @@ sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator
style->line_height.value = style->line_height.computed;
break;
case SP_CSS_UNIT_PT:
- style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "pt");
+ style->line_height.computed += Inkscape::Util::Quantity::convert(zby, "px", "pt");
style->line_height.value = style->line_height.computed;
break;
case SP_CSS_UNIT_PC:
- style->line_height.computed += zby * (Inkscape::Util::Quantity::convert(1, "px", "pt") / 12);
+ style->line_height.computed += (Inkscape::Util::Quantity::convert(zby, "px", "pt") / 12);
style->line_height.value = style->line_height.computed;
break;
case SP_CSS_UNIT_MM:
- style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "mm");
+ style->line_height.computed += Inkscape::Util::Quantity::convert(zby, "px", "mm");
style->line_height.value = style->line_height.computed;
break;
case SP_CSS_UNIT_CM:
- style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "cm");
+ style->line_height.computed += Inkscape::Util::Quantity::convert(zby, "px", "cm");
style->line_height.value = style->line_height.computed;
break;
case SP_CSS_UNIT_IN:
- style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "in");
+ style->line_height.computed += Inkscape::Util::Quantity::convert(zby, "px", "in");
style->line_height.value = style->line_height.computed;
break;
}
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 629960613..084b2ebd8 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -1084,8 +1084,8 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/)
Geom::Point origin (_clipboardSPDoc->getRoot()->x.computed, _clipboardSPDoc->getRoot()->y.computed);
Geom::Rect area = Geom::Rect(origin, origin + _clipboardSPDoc->getDimensions());
- unsigned long int width = (unsigned long int) (area.width() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5);
- unsigned long int height = (unsigned long int) (area.height() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5);
+ unsigned long int width = (unsigned long int) (Inkscape::Util::Quantity::convert(area.width(), "px", "in") * dpi + 0.5);
+ unsigned long int height = (unsigned long int) (Inkscape::Util::Quantity::convert(area.height(), "in", "px") * dpi + 0.5);
// read from namedview
Inkscape::XML::Node *nv = sp_repr_lookup_name (_clipboardSPDoc->rroot, "sodipodi:namedview");
diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp
index 3ce75327f..e6dae278b 100644
--- a/src/ui/dialog/print.cpp
+++ b/src/ui/dialog/print.cpp
@@ -72,8 +72,8 @@ static void draw_page(
sp_export_png_file(junk->_doc, tmp_png.c_str(), 0.0, 0.0,
width, height,
- (unsigned long)(width * dpi / Inkscape::Util::Quantity::convert(1, "in", "px")),
- (unsigned long)(height * dpi / Inkscape::Util::Quantity::convert(1, "in", "px")),
+ (unsigned long)(Inkscape::Util::Quantity::convert(width, "px", "in") * dpi),
+ (unsigned long)(Inkscape::Util::Quantity::convert(height, "px", "in") * dpi),
dpi, dpi, bgcolor, NULL, NULL, true, NULL);
// This doesn't seem to work:
diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp
index 4a25f723b..9124681a0 100644
--- a/src/ui/dialog/text-edit.cpp
+++ b/src/ui/dialog/text-edit.cpp
@@ -401,7 +401,7 @@ void TextEdit::setPreviewText (Glib::ustring font_spec, Glib::ustring phrase)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT);
- double pt_size = sp_style_css_size_units_to_px(sp_font_selector_get_size(fsel), unit) * Inkscape::Util::Quantity::convert(1, "px", "pt");
+ double pt_size = Inkscape::Util::Quantity::convert(sp_style_css_size_units_to_px(sp_font_selector_get_size(fsel), unit), "px", "pt");
// Pango font size is in 1024ths of a point
// C++11: Glib::ustring size = std::to_string( pt_size * PANGO_SCALE );