summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-09-20 17:09:19 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-09-20 17:09:19 +0000
commitcf74f053a081f6f4b460da9cd72afaab23d54d13 (patch)
tree427aa22ba3dcad9b55edb90522b5ab0208074e06 /src/extension
parentUsing inkscape compact settings to save the icons.svg file (diff)
parentMerge from trunk. (diff)
downloadinkscape-cf74f053a081f6f4b460da9cd72afaab23d54d13.tar.gz
inkscape-cf74f053a081f6f4b460da9cd72afaab23d54d13.zip
Merge Google Summer of Code unit improvement.
(bzr r12554)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.cpp2
-rw-r--r--src/extension/internal/cairo-renderer.cpp8
-rw-r--r--src/extension/internal/emf-inout.cpp4
-rw-r--r--src/extension/internal/emf-print.cpp6
-rw-r--r--src/extension/internal/grid.cpp5
-rw-r--r--src/extension/internal/latex-pstricks.cpp8
-rw-r--r--src/extension/internal/latex-text-renderer.cpp4
-rw-r--r--src/extension/internal/odf.cpp3
-rw-r--r--src/extension/internal/pdfinput/pdf-parser.cpp6
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp2
-rw-r--r--src/extension/internal/wmf-inout.cpp4
-rw-r--r--src/extension/internal/wmf-print.cpp4
12 files changed, 29 insertions, 27 deletions
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index b9125582a..0c314a576 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 cace251cf..0a4c86f0b 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;
@@ -638,9 +638,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/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 770257978..0df643130 100644
--- a/src/extension/internal/emf-print.cpp
+++ b/src/extension/internal/emf-print.cpp
@@ -138,8 +138,8 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc)
// width and height in px
- _width = doc->getWidth();
- _height = doc->getHeight();
+ _width = doc->getWidth().value("px");
+ _height = doc->getHeight().value("px");
// initialize a few global variables
hbrush = hbrushOld = hpen = 0;
@@ -243,7 +243,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/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 7e6941232..398c9f061 100644
--- a/src/extension/internal/latex-text-renderer.cpp
+++ b/src/extension/internal/latex-text-renderer.cpp
@@ -633,7 +633,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;
@@ -642,7 +642,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 a7c14387f..fcabcc4b2 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;
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/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) += "<defs>"; // temporary end of header
diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp
index 99262b109..cf0302b38 100644
--- a/src/extension/internal/wmf-print.cpp
+++ b/src/extension/internal/wmf-print.cpp
@@ -138,8 +138,8 @@ unsigned int PrintWmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc)
// WMF header the only things that can be set are the page size in inches (w,h) and the dpi
// width and height in px
- _width = doc->getWidth();
- _height = doc->getHeight();
+ _width = doc->getWidth().value("px");
+ _height = doc->getHeight().value("px");
// initialize a few global variables
hbrush = hpen = 0;