summaryrefslogtreecommitdiffstats
path: root/src/extension/internal
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-08-09 11:47:56 +0000
committerJaviertxo <jtx@jtx.marker.es>2013-08-09 11:47:56 +0000
commit4e358f420a7a1512c722d9eccd864416bc4c075b (patch)
tree223e826158e09ab2c864abf0214fe1e6a714ab61 /src/extension/internal
parentUpdate to trunk (diff)
parentRemove missing files from POTFILES.in (diff)
downloadinkscape-4e358f420a7a1512c722d9eccd864416bc4c075b.tar.gz
inkscape-4e358f420a7a1512c722d9eccd864416bc4c075b.zip
update to trunk
(bzr r11950.1.127)
Diffstat (limited to 'src/extension/internal')
-rw-r--r--src/extension/internal/cairo-ps-out.cpp12
-rw-r--r--src/extension/internal/cairo-render-context.cpp7
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.cpp10
-rw-r--r--src/extension/internal/cairo-renderer.cpp18
-rw-r--r--src/extension/internal/emf-win32-inout.cpp18
-rw-r--r--src/extension/internal/emf-win32-print.cpp76
-rw-r--r--src/extension/internal/filter/paint.h3
-rw-r--r--src/extension/internal/gdkpixbuf-input.cpp4
-rw-r--r--src/extension/internal/latex-pstricks.cpp6
-rw-r--r--src/extension/internal/latex-text-renderer.cpp4
-rw-r--r--src/extension/internal/pdfinput/pdf-parser.cpp19
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp32
12 files changed, 112 insertions, 97 deletions
diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp
index 5ce9a21f3..bfbdd8149 100644
--- a/src/extension/internal/cairo-ps-out.cpp
+++ b/src/extension/internal/cairo-ps-out.cpp
@@ -136,12 +136,12 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con
if (ext == NULL)
return;
- const gchar *new_level = NULL;
int level = CAIRO_PS_LEVEL_2;
try {
- new_level = mod->get_param_enum("PSlevel");
- if((new_level != NULL) && (g_ascii_strcasecmp("PS3", new_level) == 0))
+ const gchar *new_level = mod->get_param_enum("PSlevel");
+ if((new_level != NULL) && (g_ascii_strcasecmp("PS3", new_level) == 0)) {
level = CAIRO_PS_LEVEL_3;
+ }
} catch(...) {}
bool new_textToPath = FALSE;
@@ -225,12 +225,12 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co
if (ext == NULL)
return;
- const gchar *new_level = NULL;
int level = CAIRO_PS_LEVEL_2;
try {
- new_level = mod->get_param_enum("PSlevel");
- if((new_level != NULL) && (g_ascii_strcasecmp("PS3", new_level) == 0))
+ const gchar *new_level = mod->get_param_enum("PSlevel");
+ if((new_level != NULL) && (g_ascii_strcasecmp("PS3", new_level) == 0)) {
level = CAIRO_PS_LEVEL_3;
+ }
} catch(...) {}
bool new_textToPath = FALSE;
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index d7a560f04..0ea1fd591 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -44,12 +44,11 @@
#include "sp-pattern.h"
#include "sp-mask.h"
#include "sp-clippath.h"
+#include "util/units.h"
#ifdef WIN32
#include "libnrtype/FontFactory.h" // USE_PANGO_WIN32
#endif
-#include <unit-constants.h>
-
#include "cairo-render-context.h"
#include "cairo-renderer.h"
#include "extension/system.h"
@@ -855,7 +854,7 @@ CairoRenderContext::_finishSurfaceSetup(cairo_surface_t *surface, cairo_matrix_t
_surface = surface;
if (_vector_based_target) {
- cairo_scale(_cr, PT_PER_PX, PT_PER_PX);
+ cairo_scale(_cr, Inkscape::Util::Quantity::convert(1, "px", "pt"), Inkscape::Util::Quantity::convert(1, "px", "pt"));
} else if (cairo_surface_get_content(_surface) != CAIRO_CONTENT_ALPHA) {
// set background color on non-alpha surfaces
// TODO: bgcolor should be derived from SPDocument
@@ -1492,7 +1491,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const &font_ma
std::vector<CairoGlyphInfo> const &glyphtext, SPStyle const *style)
{
// create a cairo_font_face from PangoFont
- double size = style->font_size.computed;
+ double size = style->font_size.computed; /// \fixme why is this variable never used?
gpointer fonthash = (gpointer)font;
cairo_font_face_t *font_face = (cairo_font_face_t *)g_hash_table_lookup(font_table, fonthash);
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index 6f641fd36..0a0c3f44a 100644
--- a/src/extension/internal/cairo-renderer-pdf-out.cpp
+++ b/src/extension/internal/cairo-renderer-pdf-out.cpp
@@ -39,7 +39,7 @@
#include <2geom/affine.h>
#include "document.h"
-#include "unit-constants.h"
+#include "util/units.h"
namespace Inkscape {
namespace Extension {
@@ -136,12 +136,12 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
if (ext == NULL)
return;
- const gchar *new_level = NULL;
int level = 0;
try {
- new_level = mod->get_param_enum("PDFversion");
- if((new_level != NULL) && (g_ascii_strcasecmp("PDF-1.5", new_level) == 0))
+ const gchar *new_level = mod->get_param_enum("PDFversion");
+ if((new_level != NULL) && (g_ascii_strcasecmp("PDF-1.5", new_level) == 0)) {
level = 1;
+ }
}
catch(...) {
g_warning("Parameter <PDFversion> might not exist");
@@ -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") * PX_PER_MM;
+ new_bleedmargin_px = mod->get_param_float("bleed") * Inkscape::Util::Quantity::convert(1, "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 0a3cff26a..f7ab63c98 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -55,7 +55,7 @@
#include "sp-mask.h"
#include "sp-clippath.h"
-#include <unit-constants.h>
+#include "util/units.h"
#include "helper/png-write.h"
#include "helper/pixbuf-ops.h"
@@ -442,7 +442,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
*/
res = ctx->getBitmapResolution();
if(res == 0) {
- res = PX_PER_IN;
+ res = Inkscape::Util::Quantity::convert(1, "in", "px");
}
TRACE(("sp_asbitmap_render: resolution: %f\n", res ));
@@ -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 / PX_PER_IN));
- unsigned height = ceil(bbox->height() * (res / PX_PER_IN));
+ 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")));
if (width == 0 || height == 0) return;
@@ -477,7 +477,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
double shift_y = bbox->max()[Geom::Y];
// For default 90 dpi, snap bitmap to pixel grid
- if (res == PX_PER_IN) {
+ if (res == Inkscape::Util::Quantity::convert(1, "in", "px")) {
shift_x = round (shift_x);
shift_y = -round (-shift_y); // Correct rounding despite coordinate inversion.
// Remove the negations when the inversion is gone.
@@ -629,7 +629,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
if (ctx->_vector_based_target) {
// convert from px to pt
- d *= Geom::Scale(PT_PER_PX);
+ d *= Geom::Scale(Inkscape::Util::Quantity::convert(1, "px", "pt"));
}
ctx->_width = d.width();
@@ -647,11 +647,11 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
} else {
double high = doc->getHeight();
if (ctx->_vector_based_target)
- high *= PT_PER_PX;
+ high *= Inkscape::Util::Quantity::convert(1, "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 ? PX_PER_PT : 1.0),
- (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
+ Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? Inkscape::Util::Quantity::convert(1, "pt", "px") : 1.0),
+ (d.bottom() - high) * (ctx->_vector_based_target ? Inkscape::Util::Quantity::convert(1, "pt", "px") : 1.0)));
ctx->transform(tp);
}
}
diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp
index e9360a0ea..60385f455 100644
--- a/src/extension/internal/emf-win32-inout.cpp
+++ b/src/extension/internal/emf-win32-inout.cpp
@@ -37,9 +37,9 @@
#include "extension/output.h"
#include "display/drawing.h"
#include "display/drawing-item.h"
-#include "unit-constants.h"
#include "clear-n_.h"
#include "document.h"
+#include "util/units.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -60,7 +60,7 @@ namespace Inkscape {
namespace Extension {
namespace Internal {
-static float device_scale = DEVICESCALE;
+static float device_scale = Inkscape::Util::Quantity::convert(1, "px", "pt");
static float device_x;
static float device_y;
static RECTL rc_old;
@@ -120,6 +120,10 @@ emf_print_document_to_file(SPDocument *doc, gchar const *filename)
}
mod->base->invoke_print(&context);
ret = mod->finish();
+ if (ret) {
+ g_free(oldoutput);
+ throw Inkscape::Extension::Output::save_failed();
+ }
/* Release arena */
mod->base->invoke_hide(mod->dkey);
mod->base = NULL;
@@ -777,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*PX_PER_MM;
- device_y = pEmr->rclFrame.top/100.0*PX_PER_MM;
+ 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");
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 * PX_PER_MM;
- d->dc[d->level].PixelsOutY = d->MMY * PX_PER_MM;
+ 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");
// calculate ratio of Inkscape dpi/device dpi
if (pEmr->szlMillimeters.cx && pEmr->szlDevice.cx)
- device_scale = PX_PER_MM*pEmr->szlMillimeters.cx/pEmr->szlDevice.cx;
+ device_scale = Inkscape::Util::Quantity::convert(1, "mm", "px")*pEmr->szlMillimeters.cx/pEmr->szlDevice.cx;
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 2b79fd5a4..621954f68 100644
--- a/src/extension/internal/emf-win32-print.cpp
+++ b/src/extension/internal/emf-win32-print.cpp
@@ -36,6 +36,7 @@
#include "helper/geom.h"
#include "helper/geom-curves.h"
#include "sp-item.h"
+#include "util/units.h"
#include "style.h"
#include "inkscape-version.h"
@@ -43,8 +44,6 @@
#include "emf-win32-print.h"
-#include "unit-constants.h"
-
#include "extension/system.h"
#include "extension/print.h"
#include "document.h"
@@ -129,7 +128,7 @@ unsigned int PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *
if (bbox) d = *bbox;
}
- d *= Geom::Scale(IN_PER_PX);
+ d *= Geom::Scale(Inkscape::Util::Quantity::convert(1, "px", "in"));
float dwInchesX = d.width();
float dwInchesY = d.height();
@@ -196,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 * MM_PER_IN, dwInchesY * MM_PER_IN);
+ 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"));
GdiComment(hdc, strlen(buff), (BYTE*) buff);
}
@@ -242,13 +241,12 @@ unsigned int PrintEmfWin32::comment (Inkscape::Extension::Print * /*module*/,
int PrintEmfWin32::create_brush(SPStyle const *style)
{
- float rgb[3];
-
if (style) {
float opacity = SP_SCALE24_TO_FLOAT(style->fill_opacity.value);
if (opacity <= 0.0)
return 1;
+ float rgb[3];
sp_color_get_rgb_floatv( &style->fill.value.color, rgb );
hbrush = CreateSolidBrush( RGB(255*rgb[0], 255*rgb[1], 255*rgb[2]) );
hbrushOld = (HBRUSH) SelectObject( hdc, hbrush );
@@ -305,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 * IN_PER_PX * dwDPI) );
+ DWORD linewidth = MAX( 1, (DWORD) (scale * style->stroke_width.computed * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI) );
if (style->stroke_linecap.computed == 0) {
linecap = PS_ENDCAP_FLAT;
@@ -342,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] * IN_PER_PX * dwDPI);
+ dash[i] = (DWORD) (style->stroke_dash.dash[i] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI);
}
}
}
@@ -545,8 +543,8 @@ bool PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom
Geom::Point p0 = pit->initialPoint();
- p0[X] = (p0[X] * IN_PER_PX * dwDPI);
- p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
+ p0[X] = (p0[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI);
+ p0[Y] = (p0[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI);
LONG const x0 = (LONG) round(p0[X]);
LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
@@ -565,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] * IN_PER_PX * dwDPI);
- p1[X] = (p1[X] * IN_PER_PX * dwDPI);
- //p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
- p1[Y] = (p1[Y] * IN_PER_PX * dwDPI);
+ //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);
//LONG const x0 = (LONG) round(p0[X]);
//LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
@@ -587,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] * IN_PER_PX * dwDPI);
- p1[X] = (p1[X] * IN_PER_PX * dwDPI);
- p2[X] = (p2[X] * IN_PER_PX * dwDPI);
- p3[X] = (p3[X] * IN_PER_PX * dwDPI);
- //p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
- p1[Y] = (p1[Y] * IN_PER_PX * dwDPI);
- p2[Y] = (p2[Y] * IN_PER_PX * dwDPI);
- p3[Y] = (p3[Y] * IN_PER_PX * dwDPI);
+ //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);
//LONG const x0 = (LONG) round(p0[X]);
//LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
@@ -717,8 +715,8 @@ unsigned int PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geo
Geom::Point p0 = pit->initialPoint();
- p0[X] = (p0[X] * IN_PER_PX * dwDPI);
- p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
+ p0[X] = (p0[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI);
+ p0[Y] = (p0[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI);
LONG const x0 = (LONG) round(p0[X]);
LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
@@ -735,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] * IN_PER_PX * dwDPI);
- p1[X] = (p1[X] * IN_PER_PX * dwDPI);
- //p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
- p1[Y] = (p1[Y] * IN_PER_PX * dwDPI);
+ //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);
//LONG const x0 = (LONG) round(p0[X]);
//LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
@@ -755,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] * IN_PER_PX * dwDPI);
- p1[X] = (p1[X] * IN_PER_PX * dwDPI);
- p2[X] = (p2[X] * IN_PER_PX * dwDPI);
- p3[X] = (p3[X] * IN_PER_PX * dwDPI);
- //p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
- p1[Y] = (p1[Y] * IN_PER_PX * dwDPI);
- p2[Y] = (p2[Y] * IN_PER_PX * dwDPI);
- p3[Y] = (p3[Y] * IN_PER_PX * dwDPI);
+ //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);
//LONG const x0 = (LONG) round(p0[X]);
//LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
@@ -830,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 * IN_PER_PX * dwDPI;
+ lf->lfHeight = -style->font_size.computed * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI;
lf->lfWidth = 0;
lf->lfEscapement = rot;
lf->lfOrientation = rot;
@@ -879,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] * IN_PER_PX * dwDPI);
- p2[Geom::Y] = (p2[Geom::Y] * IN_PER_PX * dwDPI);
+ 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);
LONG const xpos = (LONG) round(p2[Geom::X]);
LONG const ypos = (LONG) round(rc.bottom - p2[Geom::Y]);
diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h
index d99d1e0e2..941177f39 100644
--- a/src/extension/internal/filter/paint.h
+++ b/src/extension/internal/filter/paint.h
@@ -999,9 +999,8 @@ PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext)
transf << "0";
int levels = ext->get_param_int("levels") + 1;
- float val = 0.0;
for ( int step = 1 ; step <= levels ; step++ ) {
- val = (float) step / levels;
+ const float val = (float) step / levels;
transf << " " << val;
}
transf << " 1";
diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp
index abfad518f..994258ccc 100644
--- a/src/extension/internal/gdkpixbuf-input.cpp
+++ b/src/extension/internal/gdkpixbuf-input.cpp
@@ -12,7 +12,7 @@
#include "selection-chemistry.h"
#include "sp-image.h"
#include "document-undo.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include "image-resolution.h"
#include <set>
@@ -79,7 +79,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
double width = gdk_pixbuf_get_width(pb);
double height = gdk_pixbuf_get_height(pb);
- double defaultxdpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", PX_PER_IN);
+ double defaultxdpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", Inkscape::Util::Quantity::convert(1, "in", "px"));
bool forcexdpi = prefs->getBool("/dialogs/import/forcexdpi");
ImageResolution *ir = 0;
double xscale = 1;
diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp
index c1eddf539..2ece1ba87 100644
--- a/src/extension/internal/latex-pstricks.cpp
+++ b/src/extension/internal/latex-pstricks.cpp
@@ -21,7 +21,7 @@
#include <2geom/hvlinesegment.h>
#include <errno.h>
#include <signal.h>
-#include <unit-constants.h>
+#include "util/units.h"
#include "helper/geom-curves.h"
#include "extension/print.h"
@@ -117,8 +117,8 @@ unsigned int PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc
}
// width and height in pt
- _width = doc->getWidth() * PT_PER_PX;
- _height = doc->getHeight() * PT_PER_PX;
+ _width = doc->getWidth() * Inkscape::Util::Quantity::convert(1, "px", "pt");
+ _height = doc->getHeight() * Inkscape::Util::Quantity::convert(1, "px", "pt");
if (res >= 0) {
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp
index ecc201733..57a71b467 100644
--- a/src/extension/internal/latex-text-renderer.cpp
+++ b/src/extension/internal/latex-text-renderer.cpp
@@ -39,7 +39,7 @@
#include "sp-rect.h"
#include "text-editing.h"
-#include <unit-constants.h>
+#include "util/units.h"
#include "extension/system.h"
@@ -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() * PT_PER_PX << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384
+ 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 << " \\ifx\\svgscale\\undefined%\n";
os << " \\relax%\n";
os << " \\else%\n";
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index 3be7af34f..6e57f6278 100644
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
@@ -34,7 +34,7 @@ extern "C" {
#include "svg-builder.h"
#include "Gfx.h"
#include "pdf-parser.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include "goo/gmem.h"
#include "goo/GooTimer.h"
@@ -279,14 +279,14 @@ PdfParser::PdfParser(XRef *xrefA, Inkscape::Extension::Internal::SvgBuilder *bui
ignoreUndef = 0;
operatorHistory = NULL;
builder = builderA;
- builder->setDocumentSize(state->getPageWidth()*PX_PER_PT,
- state->getPageHeight()*PX_PER_PT);
+ builder->setDocumentSize(state->getPageWidth()*Inkscape::Util::Quantity::convert(1, "pt", "px"),
+ state->getPageHeight()*Inkscape::Util::Quantity::convert(1, "pt", "px"));
double *ctm = state->getCTM();
double scaledCTM[6];
for (int i = 0; i < 6; ++i) {
baseMatrix[i] = ctm[i];
- scaledCTM[i] = PX_PER_PT * ctm[i];
+ scaledCTM[i] = Inkscape::Util::Quantity::convert(1, "pt", "px") * ctm[i];
}
saveState();
builder->setTransform((double*)&scaledCTM);
@@ -579,14 +579,13 @@ void PdfParser::execOp(Object *cmd, Object args[], int numArgs) {
(this->*op->func)(argPtr, numArgs);
}
-PdfOperator *PdfParser::findOp(char *name) {
- int a, b, m, cmp;
-
- a = -1;
- b = numOps;
+PdfOperator* PdfParser::findOp(char *name) {
+ int a = -1;
+ int b = numOps;
+ int cmp = -1;
// invariant: opTab[a] < name < opTab[b]
while (b - a > 1) {
- m = (a + b) / 2;
+ const int m = (a + b) / 2;
cmp = strcmp(opTab[m].name, name);
if (cmp < 0)
a = m;
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index 75849f6cc..a1a309a87 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -33,7 +33,7 @@
#include "svg/css-ostringstream.h"
#include "svg/svg-color.h"
#include "color.h"
-#include "unit-constants.h"
+#include "util/units.h"
#include "io/stringstream.h"
#include "io/base64stream.h"
#include "display/nr-filter-utils.h"
@@ -266,14 +266,12 @@ static void svgSetTransform(Inkscape::XML::Node *node, double c0, double c1,
* \brief Generates a SVG path string from poppler's data structure
*/
static gchar *svgInterpretPath(GfxPath *path) {
- GfxSubpath *subpath;
Inkscape::SVG::PathString pathString;
- int i, j;
- for ( i = 0 ; i < path->getNumSubpaths() ; ++i ) {
- subpath = path->getSubpath(i);
+ for (int i = 0 ; i < path->getNumSubpaths() ; ++i ) {
+ GfxSubpath *subpath = path->getSubpath(i);
if (subpath->getNumPoints() > 0) {
pathString.moveTo(subpath->getX(0), subpath->getY(0));
- j = 1;
+ int j = 1;
while (j < subpath->getNumPoints()) {
if (subpath->getCurve(j)) {
pathString.curveTo(subpath->getX(j), subpath->getY(j),
@@ -676,7 +674,25 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern,
Inkscape::XML::Node *pattern_node = _xml_doc->createElement("svg:pattern");
// Set pattern transform matrix
double *p2u = tiling_pattern->getMatrix();
- Geom::Affine pat_matrix(p2u[0], p2u[1], p2u[2], p2u[3], p2u[4], p2u[5]);
+ double m[6] = {1, 0, 0, 1, 0, 0};
+ double det;
+ det = ttm[0] * ttm[3] - ttm[1] * ttm[2]; // see LP Bug 1168908
+ if (det) {
+ double ittm[6]; // invert ttm
+ ittm[0] = ttm[3] / det;
+ ittm[1] = -ttm[1] / det;
+ ittm[2] = -ttm[2] / det;
+ ittm[3] = ttm[0] / det;
+ ittm[4] = (ttm[2] * ttm[5] - ttm[3] * ttm[4]) / det;
+ ittm[5] = (ttm[1] * ttm[4] - ttm[0] * ttm[5]) / det;
+ m[0] = p2u[0] * ittm[0] + p2u[1] * ittm[2];
+ m[1] = p2u[0] * ittm[1] + p2u[1] * ittm[3];
+ m[2] = p2u[2] * ittm[0] + p2u[3] * ittm[2];
+ m[3] = p2u[2] * ittm[1] + p2u[3] * ittm[3];
+ m[4] = p2u[4] * ittm[0] + p2u[5] * ittm[2] + ittm[4];
+ m[5] = p2u[4] * ittm[1] + p2u[5] * ittm[3] + ittm[5];
+ }
+ Geom::Affine pat_matrix(m[0], m[1], m[2], m[3], m[4], m[5]);
gchar *transform_text = sp_svg_transform_write(pat_matrix);
pattern_node->setAttribute("patternTransform", transform_text);
g_free(transform_text);
@@ -777,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 * PT_PER_PX);
+ Geom::Affine flip(1.0, 0.0, 0.0, -1.0, 0.0, _height * Inkscape::Util::Quantity::convert(1, "px", "pt"));
pat_matrix *= flip;
}
gchar *transform_text = sp_svg_transform_write(pat_matrix);