summaryrefslogtreecommitdiffstats
path: root/src/extension/internal
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-10-26 12:27:05 +0000
committerJabiertxof <jtx@jtx.marker.es>2013-10-26 12:27:05 +0000
commit9b2d4924cf0f30df461236c7850c8e38480d8ad3 (patch)
tree560ebd4e32dc9c9645287e8f5a8470bde91d7817 /src/extension/internal
parentUpdate to trunk (diff)
parentFix memleak in reference counting introduced in r12532. (diff)
downloadinkscape-9b2d4924cf0f30df461236c7850c8e38480d8ad3.tar.gz
inkscape-9b2d4924cf0f30df461236c7850c8e38480d8ad3.zip
Update to trunk
(bzr r11950.1.189)
Diffstat (limited to 'src/extension/internal')
-rw-r--r--src/extension/internal/cdr-input.cpp2
-rw-r--r--src/extension/internal/emf-inout.cpp25
-rw-r--r--src/extension/internal/gdkpixbuf-input.cpp2
-rw-r--r--src/extension/internal/image-resolution.cpp11
-rw-r--r--src/extension/internal/pdf-input-cairo.cpp2
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp2
-rw-r--r--src/extension/internal/vsd-input.cpp2
-rw-r--r--src/extension/internal/wmf-inout.cpp12
-rw-r--r--src/extension/internal/wmf-print.cpp5
-rw-r--r--src/extension/internal/wpg-input.cpp2
10 files changed, 45 insertions, 20 deletions
diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp
index 517d6fb9c..04087e268 100644
--- a/src/extension/internal/cdr-input.cpp
+++ b/src/extension/internal/cdr-input.cpp
@@ -258,7 +258,7 @@ SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
return doc;
}
diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp
index f1876c687..36d7ca145 100644
--- a/src/extension/internal/emf-inout.cpp
+++ b/src/extension/internal/emf-inout.cpp
@@ -789,8 +789,12 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType)
// Assume src color is "white"
if(d->dwRop3){
switch(d->dwRop3){
- case U_PATINVERT: // treat all of these as black
- case U_SRCINVERT:
+ case U_PATINVERT: // invert pattern
+ fill_rgb[0] = 1.0 - fill_rgb[0];
+ fill_rgb[1] = 1.0 - fill_rgb[1];
+ fill_rgb[2] = 1.0 - fill_rgb[2];
+ break;
+ case U_SRCINVERT: // treat all of these as black
case U_DSTINVERT:
case U_BLACKNESS:
case U_SRCERASE:
@@ -799,7 +803,6 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType)
break;
case U_SRCCOPY: // treat all of these as white
case U_NOTSRCERASE:
- case U_PATCOPY:
case U_WHITENESS:
fill_rgb[0]=fill_rgb[1]=fill_rgb[2]=1.0;
break;
@@ -808,6 +811,7 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType)
case U_MERGECOPY:
case U_MERGEPAINT:
case U_PATPAINT:
+ case U_PATCOPY:
default:
break;
}
@@ -2747,7 +2751,10 @@ std::cout << "BEFORE DRAW"
{
dbg_str << "<!-- U_EMR_BEGINPATH -->\n";
// The next line should never be needed, should have been handled before main switch
- *(d->path) = "";
+ // qualifier added because EMF's encountered where moveto preceded beginpath followed by lineto
+ if(d->mask & U_DRAW_VISIBLE){
+ *(d->path) = "";
+ }
d->mask |= emr_mask;
break;
}
@@ -2859,6 +2866,7 @@ std::cout << "BEFORE DRAW"
if (!pEmr->cbBmiSrc) {
// should be an application of a DIBPATTERNBRUSHPT, use a solid color instead
+ if(pEmr->dwRop == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */
int32_t dx = pEmr->Dest.x;
int32_t dy = pEmr->Dest.y;
int32_t dw = pEmr->cDest.x;
@@ -3497,12 +3505,13 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
// Set document unit
Inkscape::XML::Node *repr = sp_document_namedview(doc, 0)->getRepr();
Inkscape::SVGOStringStream os;
- os << doc->getWidth().unit->abbr;
+ Inkscape::Util::Unit const* doc_unit = doc->getWidth().unit;
+ os << doc_unit->abbr;
repr->setAttribute("inkscape:document-units", os.str().c_str());
-
+
// Set viewBox
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
-
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc_unit), doc->getHeight().value(doc_unit)));
+
// Scale and translate objects
double scale = Inkscape::Util::Quantity::convert(1, "px", doc->getWidth().unit);
ShapeEditor::blockSetItem(true);
diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp
index 13267ee2b..6d159d265 100644
--- a/src/extension/internal/gdkpixbuf-input.cpp
+++ b/src/extension/internal/gdkpixbuf-input.cpp
@@ -105,7 +105,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
// restore undo, as now this document may be shown to the user if a bitmap was opened
diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp
index b38b0ddc7..865e86698 100644
--- a/src/extension/internal/image-resolution.cpp
+++ b/src/extension/internal/image-resolution.cpp
@@ -342,9 +342,16 @@ void ImageResolution::readmagick(char const *fn) {
image.read(fn);
} catch (...) {}
Magick::Geometry geo = image.density();
+ std::string type = image.magick();
+
+ if (type == "PNG") { // PNG only supports pixelspercentimeter
+ x_ = Inkscape::Util::Quantity::convert((double)geo.width(), "in", "cm");
+ y_ = Inkscape::Util::Quantity::convert((double)geo.height(), "in", "cm");
+ } else {
+ x_ = (double)geo.width();
+ y_ = (double)geo.height();
+ }
- x_ = Inkscape::Util::Quantity::convert((double)geo.width(), "pt", "px");
- y_ = Inkscape::Util::Quantity::convert((double)geo.height(), "pt", "px");
ok_ = true;
}
diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp
index adac0d6c9..f47fbaf87 100644
--- a/src/extension/internal/pdf-input-cairo.cpp
+++ b/src/extension/internal/pdf-input-cairo.cpp
@@ -626,7 +626,7 @@ PdfInputCairo::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
delete output;
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 213550688..3155ac098 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -750,7 +750,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
// Restore undo
diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp
index 42a9e3d41..6fc79237b 100644
--- a/src/extension/internal/vsd-input.cpp
+++ b/src/extension/internal/vsd-input.cpp
@@ -258,7 +258,7 @@ SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
return doc;
diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp
index d69d46f20..2e55dcb1e 100644
--- a/src/extension/internal/wmf-inout.cpp
+++ b/src/extension/internal/wmf-inout.cpp
@@ -1970,7 +1970,9 @@ std::cout << "BEFORE DRAW"
}
if (!d->dc[d->level].sizeView.x || !d->dc[d->level].sizeView.y) {
- d->dc[d->level].sizeView = d->dc[d->level].sizeWnd;
+ /* Previously it used sizeWnd, but that always resulted in scale = 1 if no viewport ever appeared, and in most files, it did not */
+ d->dc[d->level].sizeView.x = d->PixelsInX - 1;
+ d->dc[d->level].sizeView.y = d->PixelsInY - 1;
}
/* scales logical to WMF pixels, transfer a negative sign on Y, if any */
@@ -2284,6 +2286,7 @@ std::cout << "BEFORE DRAW"
dbg_str << "<!-- U_WMR_BITBLT -->\n";
nSize = U_WMRBITBLT_get(contents,&Dst,&cwh,&Src,&dwRop3,&Bm16,&px);
if(!px){
+ if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */
int32_t dx = Dst.x;
int32_t dy = Dst.y;
int32_t dw = cwh.x;
@@ -2321,6 +2324,7 @@ std::cout << "BEFORE DRAW"
dbg_str << "<!-- U_WMR_STRETCHBLT -->\n";
nSize = U_WMRSTRETCHBLT_get(contents,&Dst,&cDst,&Src,&cSrc,&dwRop3,&Bm16,&px);
if(!px){
+ if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */
int32_t dx = Dst.x;
int32_t dy = Dst.y;
int32_t dw = cDst.x;
@@ -2715,6 +2719,7 @@ std::cout << "BEFORE DRAW"
if (!dib) {
// should be an application of a DIBPATTERNBRUSHPT, use a solid color instead
+ if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */
int32_t dx = Dst.x;
int32_t dy = Dst.y;
int32_t dw = cwh.x;
@@ -3185,11 +3190,12 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
// Set document unit
Inkscape::XML::Node *repr = sp_document_namedview(doc, 0)->getRepr();
Inkscape::SVGOStringStream os;
- os << doc->getWidth().unit->abbr;
+ Inkscape::Util::Unit const* doc_unit = doc->getWidth().unit;
+ os << doc_unit->abbr;
repr->setAttribute("inkscape:document-units", os.str().c_str());
// Set viewBox
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc_unit), doc->getHeight().value(doc_unit)));
// Scale and translate objects
double scale = Inkscape::Util::Quantity::convert(1, "px", doc->getWidth().unit);
diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp
index cf0302b38..3bb17146c 100644
--- a/src/extension/internal/wmf-print.cpp
+++ b/src/extension/internal/wmf-print.cpp
@@ -1120,6 +1120,9 @@ unsigned int PrintWmf::image(
Geom::Point pLL(x1, y1);
Geom::Point pLL2 = pLL * tf; //location of LL corner in Inkscape coordinates
+ Geom::Point pWH(dw, dh);
+ Geom::Point pWH2 = pWH * tf.withoutTranslation(); //adjust scale
+
char *px;
uint32_t cbPx;
uint32_t colortype;
@@ -1133,7 +1136,7 @@ unsigned int PrintWmf::image(
Bmi = bitmapinfo_set(Bmih, ct);
U_POINT16 Dest = point16_set(round(pLL2[Geom::X] * PX2WORLD), round(pLL2[Geom::Y] * PX2WORLD));
- U_POINT16 cDest = point16_set(round(dw * PX2WORLD), round(dh * PX2WORLD));
+ U_POINT16 cDest = point16_set(round(pWH2[Geom::X] * PX2WORLD), round(pWH2[Geom::Y] * PX2WORLD));
U_POINT16 Src = point16_set(0, 0);
U_POINT16 cSrc = point16_set(w, h);
rec = U_WMRSTRETCHDIB_set(
diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp
index ac86a6171..b5eb3ce8f 100644
--- a/src/extension/internal/wpg-input.cpp
+++ b/src/extension/internal/wpg-input.cpp
@@ -114,7 +114,7 @@ SPDocument *WpgInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u
// Set viewBox if it doesn't exist
if (!doc->getRoot()->viewBox_set) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity));
+ doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
delete input;