summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorroot <root@jtx.marker.es>2013-03-11 23:49:54 +0000
committerroot <root@jtx.marker.es>2013-03-11 23:49:54 +0000
commit71b9a4b54c026c0fb8c73ef6cac4ae4c1ea82e7f (patch)
tree2f2c808a23fc507f9c813104415236573f25bb9a /src/extension
parent~sub fix, double click to reset default handles and control to 10% step (diff)
parentreadding entries in Cmake and make include lists that were not removed after ... (diff)
downloadinkscape-71b9a4b54c026c0fb8c73ef6cac4ae4c1ea82e7f.tar.gz
inkscape-71b9a4b54c026c0fb8c73ef6cac4ae4c1ea82e7f.zip
update to trunk
(bzr r11950.1.52)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/dependency.cpp4
-rw-r--r--src/extension/internal/filter/paint.h1
-rw-r--r--src/extension/internal/odf.cpp94
-rw-r--r--src/extension/internal/odf.h7
-rw-r--r--src/extension/internal/pdfinput/pdf-parser.cpp565
5 files changed, 338 insertions, 333 deletions
diff --git a/src/extension/dependency.cpp b/src/extension/dependency.cpp
index 7c358d871..78012ccc8 100644
--- a/src/extension/dependency.cpp
+++ b/src/extension/dependency.cpp
@@ -122,8 +122,7 @@ Dependency::~Dependency (void)
found then a TRUE is returned. If we get all the way through the
path then a FALSE is returned, the command could not be found.
*/
-bool
-Dependency::check (void) const
+bool Dependency::check (void) const
{
// std::cout << "Checking: " << *this << std::endl;
@@ -216,7 +215,6 @@ Dependency::check (void) const
g_free(orig_path);
return FALSE; /* Reverse logic in this one */
- break;
}
} /* switch _location */
break;
diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h
index f04dd92f9..4052f4391 100644
--- a/src/extension/internal/filter/paint.h
+++ b/src/extension/internal/filter/paint.h
@@ -133,7 +133,6 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream noise;
std::ostringstream dblend;
std::ostringstream smooth;
- std::ostringstream grain;
std::ostringstream grainxf;
std::ostringstream grainyf;
std::ostringstream grainc;
diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp
index 7634c7aa1..4c27925ae 100644
--- a/src/extension/internal/odf.cpp
+++ b/src/extension/internal/odf.cpp
@@ -4,7 +4,7 @@
* This is an an entry in the extensions mechanism to begin to enable
* the inputting and outputting of OpenDocument Format (ODF) files from
* within Inkscape. Although the initial implementations will be very lossy
- * do to the differences in the models of SVG and ODF, they will hopefully
+ * due to the differences in the models of SVG and ODF, they will hopefully
* improve greatly with time. People should consider this to be a framework
* that can be continously upgraded for ever improving fidelity. Potential
* developers should especially look in preprocess() and writeTree() to see how
@@ -80,16 +80,15 @@
//# DOM-specific includes
#include "dom/dom.h"
#include "dom/util/ziptool.h"
-#include "dom/io/domstream.h"
-#include "dom/io/bufferstream.h"
-#include "dom/io/stringstream.h"
+//#include "dom/io/domstream.h"
#include "inkscape-version.h"
#include "document.h"
#include "extension/extension.h"
-
+#include "io/inkscapestream.h"
+#include "io/bufferstream.h"
namespace Inkscape
{
@@ -97,15 +96,12 @@ namespace Extension
{
namespace Internal
{
-
-
-
//# Shorthand notation
typedef org::w3c::dom::DOMString DOMString;
-typedef org::w3c::dom::XMLCh XMLCh;
-typedef org::w3c::dom::io::OutputStreamWriter OutputStreamWriter;
-typedef org::w3c::dom::io::BufferOutputStream BufferOutputStream;
-typedef org::w3c::dom::io::StringOutputStream StringOutputStream;
+typedef Inkscape::IO::BufferOutputStream BufferOutputStream;
+typedef Inkscape::IO::OutputStreamWriter OutputStreamWriter;
+typedef Inkscape::IO::StringOutputStream StringOutputStream;
+
//########################################################################
//# C L A S S SingularValueDecomposition
@@ -295,11 +291,13 @@ public:
@return Structure to access U, S and V.
*/
- SingularValueDecomposition (const SVDMatrix &mat)
+ SingularValueDecomposition (const SVDMatrix &mat) :
+ A (mat),
+ U (),
+ s (NULL),
+ s_size (0),
+ V ()
{
- A = mat;
- s = NULL;
- s_size = 0;
calculate();
}
@@ -1080,14 +1078,16 @@ OdfOutput::preprocess(ZipFile &zf, Inkscape::XML::Node *node)
//Now consider items.
SPObject *reprobj = SP_ACTIVE_DOCUMENT->getObjectByRepr(node);
if (!reprobj)
+ {
return;
+ }
if (!SP_IS_ITEM(reprobj))
- {
+ {
return;
- }
- SPItem *item = SP_ITEM(reprobj);
+ }
+ //SPItem *item = SP_ITEM(reprobj);
//### Get SVG-to-ODF transform
- Geom::Affine tf = getODFTransform(item);
+ //Geom::Affine tf = getODFTransform(item);
if (nodeName == "image" || nodeName == "svg:image")
{
@@ -1210,14 +1210,19 @@ bool OdfOutput::writeMeta(ZipFile &zf)
time(&tim);
std::map<Glib::ustring, Glib::ustring>::iterator iter;
- Glib::ustring creator = "unknown";
+ Glib::ustring InkscapeVersion = Glib::ustring("Inkscape.org - ") + Inkscape::version_string;
+ Glib::ustring creator = InkscapeVersion;
iter = metadata.find("dc:creator");
if (iter != metadata.end())
+ {
creator = iter->second;
+ }
Glib::ustring date = "";
iter = metadata.find("dc:date");
if (iter != metadata.end())
+ {
date = iter->second;
+ }
outs.printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
outs.printf("\n");
@@ -1242,21 +1247,20 @@ bool OdfOutput::writeMeta(ZipFile &zf)
outs.printf("xmlns:anim=\"urn:oasis:names:tc:opendocument:xmlns:animation:1.0\"\n");
outs.printf("office:version=\"1.0\">\n");
outs.printf("<office:meta>\n");
- Glib::ustring tmp = Glib::ustring(" <meta:generator>Inkscape.org - ") + Inkscape::version_string + "</meta:generator>\n";
+ Glib::ustring tmp = Glib::ustring(" <meta:generator>") + InkscapeVersion + "</meta:generator>\n";
outs.writeUString(tmp);
- outs.printf(" <meta:initial-creator>%#s</meta:initial-creator>\n",
- creator.c_str());
- outs.printf(" <meta:creation-date>%#s</meta:creation-date>\n", date.c_str());
+ outs.printf(" <meta:initial-creator>%s</meta:initial-creator>\n", creator.c_str());
+ outs.printf(" <meta:creation-date>%s</meta:creation-date>\n", date.c_str());
for (iter = metadata.begin() ; iter != metadata.end() ; ++iter)
- {
+ {
Glib::ustring name = iter->first;
Glib::ustring value = iter->second;
- if (name.size() > 0 && value.size()>0)
- {
- outs.printf(" <%#s>%#s</%#s>\n",
- name.c_str(), value.c_str(), name.c_str());
- }
+ if (!name.empty() && !value.empty())
+ {
+ tmp = Glib::ustring::compose(" <%1>%2</%3>\n", name, value, name);
+ outs.writeUString(tmp);
}
+ }
outs.printf(" <meta:editing-cycles>2</meta:editing-cycles>\n");
outs.printf(" <meta:editing-duration>PT56S</meta:editing-duration>\n");
outs.printf(" <meta:user-defined meta:name=\"Info 1\"/>\n");
@@ -1333,7 +1337,7 @@ bool OdfOutput::writeStyle(ZipFile &zf)
}
//## Dump our gradient table
- int gradientCount = 0;
+ unsigned int gradientCount = 0;
outs.printf("\n");
outs.printf("<!-- ####### Gradients from Inkscape document ####### -->\n");
std::vector<GradientInfo>::iterator giter;
@@ -1359,8 +1363,8 @@ bool OdfOutput::writeStyle(ZipFile &zf)
continue;
}
outs.printf("<svg:linearGradient ");
- outs.printf("id=\"%#s_g\" ", gi.name.c_str());
- outs.printf("draw:name=\"%#s_g\"\n", gi.name.c_str());
+ outs.printf("id=\"%s\" ", gi.name.c_str());
+ outs.printf("draw:name=\"%s\"\n", gi.name.c_str());
outs.printf(" draw:display-name=\"imported linear %u\"\n",
gradientCount);
outs.printf(" svg:x1=\"%05.3fcm\" svg:y1=\"%05.3fcm\"\n",
@@ -1402,9 +1406,9 @@ bool OdfOutput::writeStyle(ZipFile &zf)
continue;
}
outs.printf("<svg:radialGradient ");
- outs.printf("id=\"%#s_g\" ", gi.name.c_str());
- outs.printf("draw:name=\"%#s_g\"\n", gi.name.c_str());
- outs.printf(" draw:display-name=\"imported radial %d\"\n",
+ outs.printf("id=\"%s\" ", gi.name.c_str());
+ outs.printf("draw:name=\"%s\"\n", gi.name.c_str());
+ outs.printf(" draw:display-name=\"imported radial %u\"\n",
gradientCount);
outs.printf(" svg:cx=\"%05.3f\" svg:cy=\"%05.3f\"\n",
gi.cx, gi.cy);
@@ -1431,11 +1435,11 @@ bool OdfOutput::writeStyle(ZipFile &zf)
{
g_warning("unsupported gradient style '%s'", gi.style.c_str());
}
- outs.printf("<style:style style:name=\"%#s\" style:family=\"graphic\" ",
+ outs.printf("<style:style style:name=\"%s\" style:family=\"graphic\" ",
gi.name.c_str());
outs.printf("style:parent-style-name=\"standard\">\n");
outs.printf(" <style:graphic-properties draw:fill=\"gradient\" ");
- outs.printf("draw:fill-gradient-name=\"%#s_g\"\n",
+ outs.printf("draw:fill-gradient-name=\"%s\"\n",
gi.name.c_str());
outs.printf(" draw:textarea-horizontal-align=\"center\" ");
outs.printf("draw:textarea-vertical-align=\"middle\"/>\n");
@@ -1752,8 +1756,8 @@ bool OdfOutput::processGradient(Writer &outs, SPItem *item,
return false;;
}
outs.printf("<svg:linearGradient ");
- outs.printf("id=\"%#s_g\" ", gi.name.c_str());
- outs.printf("draw:name=\"%#s_g\"\n", gi.name.c_str());
+ outs.printf("id=\"%s\" ", gi.name.c_str());
+ outs.printf("draw:name=\"%s\"\n", gi.name.c_str());
outs.printf(" draw:display-name=\"imported linear %d\"\n",
gradientCount);
outs.printf(" svg:gradientUnits=\"objectBoundingBox\"\n");
@@ -1795,8 +1799,8 @@ bool OdfOutput::processGradient(Writer &outs, SPItem *item,
return false;
}
outs.printf("<svg:radialGradient ");
- outs.printf("id=\"%#s_g\" ", gi.name.c_str());
- outs.printf("draw:name=\"%#s_g\"\n", gi.name.c_str());
+ outs.printf("id=\"%s\" ", gi.name.c_str());
+ outs.printf("draw:name=\"%s\"\n", gi.name.c_str());
outs.printf(" draw:display-name=\"imported radial %d\"\n",
gradientCount);
outs.printf(" svg:gradientUnits=\"objectBoundingBox\"\n");
@@ -1825,11 +1829,11 @@ bool OdfOutput::processGradient(Writer &outs, SPItem *item,
g_warning("unsupported gradient style '%s'", gi.style.c_str());
return false;
}
- outs.printf("<style:style style:name=\"%#s\" style:family=\"graphic\" ",
+ outs.printf("<style:style style:name=\"%s\" style:family=\"graphic\" ",
gi.name.c_str());
outs.printf("style:parent-style-name=\"standard\">\n");
outs.printf(" <style:graphic-properties draw:fill=\"gradient\" ");
- outs.printf("draw:fill-gradient-name=\"%#s_g\"\n",
+ outs.printf("draw:fill-gradient-name=\"%s\"\n",
gi.name.c_str());
outs.printf(" draw:textarea-horizontal-align=\"center\" ");
outs.printf("draw:textarea-vertical-align=\"middle\"/>\n");
diff --git a/src/extension/internal/odf.h b/src/extension/internal/odf.h
index 6b8883134..219a99a4f 100644
--- a/src/extension/internal/odf.h
+++ b/src/extension/internal/odf.h
@@ -24,7 +24,7 @@
#define EXTENSION_INTERNAL_ODG_OUT_H
#include <dom/dom.h>
-#include <dom/io/stringstream.h>
+#include <io/stringstream.h>
#include <dom/uri.h>
#include <glibmm.h>
@@ -37,7 +37,7 @@
#include <map>
#include <dom/util/ziptool.h>
-#include <dom/io/domstream.h>
+//#include <io/domstream.h>
#include "sp-item.h"
namespace Inkscape
@@ -48,8 +48,7 @@ namespace Internal
{
typedef org::w3c::dom::URI URI;
-typedef org::w3c::dom::io::Writer Writer;
-
+typedef Inkscape::IO::Writer Writer;
class StyleInfo
{
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index e57161e5a..3be7af34f 100644
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
@@ -1220,7 +1220,6 @@ void PdfParser::opSetStrokeColor(Object args[], int numArgs) {
void PdfParser::opSetFillColorN(Object args[], int numArgs) {
GfxColor color;
- GfxPattern *pattern;
int i;
if (state->getFillColorSpace()->getMode() == csPattern) {
@@ -1243,6 +1242,7 @@ void PdfParser::opSetFillColorN(Object args[], int numArgs) {
state->setFillColor(&color);
builder->updateStyle(state);
}
+ GfxPattern *pattern;
#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
if (args[numArgs-1].isName() &&
(pattern = res->lookupPattern(args[numArgs-1].getName(), NULL))) {
@@ -1279,7 +1279,6 @@ void PdfParser::opSetFillColorN(Object args[], int numArgs) {
void PdfParser::opSetStrokeColorN(Object args[], int numArgs) {
GfxColor color;
- GfxPattern *pattern;
int i;
if (state->getStrokeColorSpace()->getMode() == csPattern) {
@@ -1303,6 +1302,7 @@ void PdfParser::opSetStrokeColorN(Object args[], int numArgs) {
state->setStrokeColor(&color);
builder->updateStyle(state);
}
+ GfxPattern *pattern;
#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
if (args[numArgs-1].isName() &&
(pattern = res->lookupPattern(args[numArgs-1].getName(), NULL))) {
@@ -2702,333 +2702,338 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
{
- Dict *dict, *maskDict;
- int width, height;
- int bits;
- StreamColorSpaceMode csMode;
- GBool mask;
- GBool invert;
- GfxColorSpace *colorSpace, *maskColorSpace;
- GfxImageColorMap *colorMap, *maskColorMap;
- Object maskObj, smaskObj;
- GBool haveColorKeyMask, haveExplicitMask, haveSoftMask;
- int maskColors[2*gfxColorMaxComps];
- int maskWidth, maskHeight;
- GBool maskInvert;
- Stream *maskStr;
- Object obj1, obj2;
- int i;
-
- // get info from the stream
- bits = 0;
- csMode = streamCSNone;
- str->getImageParams(&bits, &csMode);
-
- // get stream dict
- dict = str->getDict();
-
- // get size
- dict->lookup(const_cast<char*>("Width"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- dict->lookup(const_cast<char*>("W"), &obj1);
- }
- if (obj1.isInt())
- width = obj1.getInt();
- else if (obj1.isReal())
- width = (int)obj1.getReal();
- else
- goto err2;
- obj1.free();
- dict->lookup(const_cast<char*>("Height"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- dict->lookup(const_cast<char*>("H"), &obj1);
- }
- if (obj1.isInt())
- height = obj1.getInt();
- else if (obj1.isReal())
- height = (int)obj1.getReal();
- else
- goto err2;
- obj1.free();
-
- // image or mask?
- dict->lookup(const_cast<char*>("ImageMask"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- dict->lookup(const_cast<char*>("IM"), &obj1);
- }
- mask = gFalse;
- if (obj1.isBool())
- mask = obj1.getBool();
- else if (!obj1.isNull())
- goto err2;
- obj1.free();
-
- // bit depth
- if (bits == 0) {
- dict->lookup(const_cast<char*>("BitsPerComponent"), &obj1);
+ Dict *dict;
+ int width, height;
+ int bits;
+ StreamColorSpaceMode csMode;
+ GBool mask;
+ GBool invert;
+ Object maskObj, smaskObj;
+ GBool haveColorKeyMask, haveExplicitMask, haveSoftMask;
+ GBool maskInvert;
+ Object obj1, obj2;
+
+ // get info from the stream
+ bits = 0;
+ csMode = streamCSNone;
+ str->getImageParams(&bits, &csMode);
+
+ // get stream dict
+ dict = str->getDict();
+
+ // get size
+ dict->lookup(const_cast<char*>("Width"), &obj1);
if (obj1.isNull()) {
- obj1.free();
- dict->lookup(const_cast<char*>("BPC"), &obj1);
+ obj1.free();
+ dict->lookup(const_cast<char*>("W"), &obj1);
}
- if (obj1.isInt()) {
- bits = obj1.getInt();
- } else if (mask) {
- bits = 1;
- } else {
- goto err2;
+ if (obj1.isInt()){
+ width = obj1.getInt();
}
- obj1.free();
- }
-
- // display a mask
- if (mask) {
-
- // check for inverted mask
- if (bits != 1)
- goto err1;
- invert = gFalse;
- dict->lookup(const_cast<char*>("Decode"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- dict->lookup(const_cast<char*>("D"), &obj1);
+ else if (obj1.isReal()) {
+ width = (int)obj1.getReal();
}
- if (obj1.isArray()) {
- obj1.arrayGet(0, &obj2);
- if (obj2.isInt() && obj2.getInt() == 1)
- invert = gTrue;
- obj2.free();
- } else if (!obj1.isNull()) {
- goto err2;
+ else {
+ goto err2;
}
obj1.free();
-
- // draw it
- builder->addImageMask(state, str, width, height, invert);
-
- } else {
-
- // get color space and color map
- dict->lookup(const_cast<char*>("ColorSpace"), &obj1);
+ dict->lookup(const_cast<char*>("Height"), &obj1);
if (obj1.isNull()) {
- obj1.free();
- dict->lookup(const_cast<char*>("CS"), &obj1);
+ obj1.free();
+ dict->lookup(const_cast<char*>("H"), &obj1);
}
- if (obj1.isName()) {
- res->lookupColorSpace(obj1.getName(), &obj2);
- if (!obj2.isNull()) {
- obj1.free();
- obj1 = obj2;
- } else {
- obj2.free();
- }
+ if (obj1.isInt()) {
+ height = obj1.getInt();
}
- if (!obj1.isNull()) {
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
- colorSpace = GfxColorSpace::parse(&obj1, NULL);
-#else
- colorSpace = GfxColorSpace::parse(&obj1);
-#endif
- } else if (csMode == streamCSDeviceGray) {
- colorSpace = new GfxDeviceGrayColorSpace();
- } else if (csMode == streamCSDeviceRGB) {
- colorSpace = new GfxDeviceRGBColorSpace();
- } else if (csMode == streamCSDeviceCMYK) {
- colorSpace = new GfxDeviceCMYKColorSpace();
- } else {
- colorSpace = NULL;
+ else if (obj1.isReal()){
+ height = static_cast<int>(obj1.getReal());
}
- obj1.free();
- if (!colorSpace) {
- goto err1;
+ else {
+ goto err2;
}
- dict->lookup(const_cast<char*>("Decode"), &obj1);
+ obj1.free();
+
+ // image or mask?
+ dict->lookup(const_cast<char*>("ImageMask"), &obj1);
if (obj1.isNull()) {
- obj1.free();
- dict->lookup(const_cast<char*>("D"), &obj1);
+ obj1.free();
+ dict->lookup(const_cast<char*>("IM"), &obj1);
+ }
+ mask = gFalse;
+ if (obj1.isBool()) {
+ mask = obj1.getBool();
+ }
+ else if (!obj1.isNull()) {
+ goto err2;
}
- colorMap = new GfxImageColorMap(bits, &obj1, colorSpace);
obj1.free();
- if (!colorMap->isOk()) {
- delete colorMap;
- goto err1;
- }
-
- // get the mask
- haveColorKeyMask = haveExplicitMask = haveSoftMask = gFalse;
- maskStr = NULL; // make gcc happy
- maskWidth = maskHeight = 0; // make gcc happy
- maskInvert = gFalse; // make gcc happy
- maskColorMap = NULL; // make gcc happy
- dict->lookup(const_cast<char*>("Mask"), &maskObj);
- dict->lookup(const_cast<char*>("SMask"), &smaskObj);
- if (smaskObj.isStream()) {
- // soft mask
- if (inlineImg) {
- goto err1;
- }
- maskStr = smaskObj.getStream();
- maskDict = smaskObj.streamGetDict();
- maskDict->lookup(const_cast<char*>("Width"), &obj1);
+
+ // bit depth
+ if (bits == 0) {
+ dict->lookup(const_cast<char*>("BitsPerComponent"), &obj1);
if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("W"), &obj1);
+ obj1.free();
+ dict->lookup(const_cast<char*>("BPC"), &obj1);
}
- if (!obj1.isInt()) {
- goto err2;
+ if (obj1.isInt()) {
+ bits = obj1.getInt();
+ } else if (mask) {
+ bits = 1;
+ } else {
+ goto err2;
}
- maskWidth = obj1.getInt();
obj1.free();
- maskDict->lookup(const_cast<char*>("Height"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("H"), &obj1);
- }
- if (!obj1.isInt()) {
- goto err2;
+ }
+
+ // display a mask
+ if (mask) {
+ // check for inverted mask
+ if (bits != 1) {
+ goto err1;
}
- maskHeight = obj1.getInt();
- obj1.free();
- maskDict->lookup(const_cast<char*>("BitsPerComponent"), &obj1);
+ invert = gFalse;
+ dict->lookup(const_cast<char*>("Decode"), &obj1);
if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("BPC"), &obj1);
+ obj1.free();
+ dict->lookup(const_cast<char*>("D"), &obj1);
}
- if (!obj1.isInt()) {
- goto err2;
+ if (obj1.isArray()) {
+ obj1.arrayGet(0, &obj2);
+ if (obj2.isInt() && obj2.getInt() == 1) {
+ invert = gTrue;
+ }
+ obj2.free();
+ } else if (!obj1.isNull()) {
+ goto err2;
}
- int maskBits = obj1.getInt();
obj1.free();
- maskDict->lookup(const_cast<char*>("ColorSpace"), &obj1);
+
+ // draw it
+ builder->addImageMask(state, str, width, height, invert);
+
+ } else {
+ // get color space and color map
+ GfxColorSpace *colorSpace;
+ dict->lookup(const_cast<char*>("ColorSpace"), &obj1);
if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("CS"), &obj1);
+ obj1.free();
+ dict->lookup(const_cast<char*>("CS"), &obj1);
}
if (obj1.isName()) {
- res->lookupColorSpace(obj1.getName(), &obj2);
- if (!obj2.isNull()) {
+ res->lookupColorSpace(obj1.getName(), &obj2);
+ if (!obj2.isNull()) {
obj1.free();
obj1 = obj2;
- } else {
+ } else {
obj2.free();
- }
+ }
}
+ if (!obj1.isNull()) {
#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
- maskColorSpace = GfxColorSpace::parse(&obj1, NULL);
+ colorSpace = GfxColorSpace::parse(&obj1, NULL);
#else
- maskColorSpace = GfxColorSpace::parse(&obj1);
-#endif
+ colorSpace = GfxColorSpace::parse(&obj1);
+#endif
+ } else if (csMode == streamCSDeviceGray) {
+ colorSpace = new GfxDeviceGrayColorSpace();
+ } else if (csMode == streamCSDeviceRGB) {
+ colorSpace = new GfxDeviceRGBColorSpace();
+ } else if (csMode == streamCSDeviceCMYK) {
+ colorSpace = new GfxDeviceCMYKColorSpace();
+ } else {
+ colorSpace = NULL;
+ }
obj1.free();
- if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) {
+ if (!colorSpace) {
goto err1;
}
- maskDict->lookup(const_cast<char*>("Decode"), &obj1);
+ dict->lookup(const_cast<char*>("Decode"), &obj1);
if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("D"), &obj1);
+ obj1.free();
+ dict->lookup(const_cast<char*>("D"), &obj1);
}
- maskColorMap = new GfxImageColorMap(maskBits, &obj1, maskColorSpace);
+ GfxImageColorMap *colorMap = new GfxImageColorMap(bits, &obj1, colorSpace);
obj1.free();
- if (!maskColorMap->isOk()) {
- delete maskColorMap;
+ if (!colorMap->isOk()) {
+ delete colorMap;
goto err1;
}
- //~ handle the Matte entry
- haveSoftMask = gTrue;
- } else if (maskObj.isArray()) {
- // color key mask
- for (i = 0;
- i < maskObj.arrayGetLength() && i < 2*gfxColorMaxComps;
- ++i) {
- maskObj.arrayGet(i, &obj1);
- maskColors[i] = obj1.getInt();
- obj1.free();
- }
- haveColorKeyMask = gTrue;
- } else if (maskObj.isStream()) {
- // explicit mask
- if (inlineImg) {
- goto err1;
- }
- maskStr = maskObj.getStream();
- maskDict = maskObj.streamGetDict();
- maskDict->lookup(const_cast<char*>("Width"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("W"), &obj1);
- }
- if (!obj1.isInt()) {
- goto err2;
- }
- maskWidth = obj1.getInt();
- obj1.free();
- maskDict->lookup(const_cast<char*>("Height"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("H"), &obj1);
- }
- if (!obj1.isInt()) {
- goto err2;
- }
- maskHeight = obj1.getInt();
- obj1.free();
- maskDict->lookup(const_cast<char*>("ImageMask"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("IM"), &obj1);
- }
- if (!obj1.isBool() || !obj1.getBool()) {
- goto err2;
- }
- obj1.free();
- maskInvert = gFalse;
- maskDict->lookup(const_cast<char*>("Decode"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("D"), &obj1);
- }
- if (obj1.isArray()) {
- obj1.arrayGet(0, &obj2);
- if (obj2.isInt() && obj2.getInt() == 1) {
- maskInvert = gTrue;
- }
- obj2.free();
- } else if (!obj1.isNull()) {
- goto err2;
- }
- obj1.free();
- haveExplicitMask = gTrue;
- }
-
- // draw it
- if (haveSoftMask) {
- builder->addSoftMaskedImage(state, str, width, height, colorMap,
+
+ // get the mask
+ int maskColors[2*gfxColorMaxComps];
+ haveColorKeyMask = haveExplicitMask = haveSoftMask = gFalse;
+ Stream *maskStr = NULL;
+ int maskWidth = 0;
+ int maskHeight = 0;
+ maskInvert = gFalse;
+ GfxImageColorMap *maskColorMap = NULL;
+ dict->lookup(const_cast<char*>("Mask"), &maskObj);
+ dict->lookup(const_cast<char*>("SMask"), &smaskObj);
+ Dict* maskDict;
+ if (smaskObj.isStream()) {
+ // soft mask
+ if (inlineImg) {
+ goto err1;
+ }
+ maskStr = smaskObj.getStream();
+ maskDict = smaskObj.streamGetDict();
+ maskDict->lookup(const_cast<char*>("Width"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("W"), &obj1);
+ }
+ if (!obj1.isInt()) {
+ goto err2;
+ }
+ maskWidth = obj1.getInt();
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("Height"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("H"), &obj1);
+ }
+ if (!obj1.isInt()) {
+ goto err2;
+ }
+ maskHeight = obj1.getInt();
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("BitsPerComponent"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("BPC"), &obj1);
+ }
+ if (!obj1.isInt()) {
+ goto err2;
+ }
+ int maskBits = obj1.getInt();
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("ColorSpace"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("CS"), &obj1);
+ }
+ if (obj1.isName()) {
+ res->lookupColorSpace(obj1.getName(), &obj2);
+ if (!obj2.isNull()) {
+ obj1.free();
+ obj1 = obj2;
+ } else {
+ obj2.free();
+ }
+ }
+#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
+ GfxColorSpace *maskColorSpace = GfxColorSpace::parse(&obj1, NULL);
+#else
+ GfxColorSpace *maskColorSpace = GfxColorSpace::parse(&obj1);
+#endif
+ obj1.free();
+ if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) {
+ goto err1;
+ }
+ maskDict->lookup(const_cast<char*>("Decode"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("D"), &obj1);
+ }
+ maskColorMap = new GfxImageColorMap(maskBits, &obj1, maskColorSpace);
+ obj1.free();
+ if (!maskColorMap->isOk()) {
+ delete maskColorMap;
+ goto err1;
+ }
+ //~ handle the Matte entry
+ haveSoftMask = gTrue;
+ } else if (maskObj.isArray()) {
+ // color key mask
+ int i;
+ for (i = 0; i < maskObj.arrayGetLength() && i < 2*gfxColorMaxComps; ++i) {
+ maskObj.arrayGet(i, &obj1);
+ maskColors[i] = obj1.getInt();
+ obj1.free();
+ }
+ haveColorKeyMask = gTrue;
+ } else if (maskObj.isStream()) {
+ // explicit mask
+ if (inlineImg) {
+ goto err1;
+ }
+ maskStr = maskObj.getStream();
+ maskDict = maskObj.streamGetDict();
+ maskDict->lookup(const_cast<char*>("Width"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("W"), &obj1);
+ }
+ if (!obj1.isInt()) {
+ goto err2;
+ }
+ maskWidth = obj1.getInt();
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("Height"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("H"), &obj1);
+ }
+ if (!obj1.isInt()) {
+ goto err2;
+ }
+ maskHeight = obj1.getInt();
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("ImageMask"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("IM"), &obj1);
+ }
+ if (!obj1.isBool() || !obj1.getBool()) {
+ goto err2;
+ }
+ obj1.free();
+ maskInvert = gFalse;
+ maskDict->lookup(const_cast<char*>("Decode"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("D"), &obj1);
+ }
+ if (obj1.isArray()) {
+ obj1.arrayGet(0, &obj2);
+ if (obj2.isInt() && obj2.getInt() == 1) {
+ maskInvert = gTrue;
+ }
+ obj2.free();
+ } else if (!obj1.isNull()) {
+ goto err2;
+ }
+ obj1.free();
+ haveExplicitMask = gTrue;
+ }
+
+ // draw it
+ if (haveSoftMask) {
+ builder->addSoftMaskedImage(state, str, width, height, colorMap,
maskStr, maskWidth, maskHeight, maskColorMap);
- delete maskColorMap;
- } else if (haveExplicitMask) {
- builder->addMaskedImage(state, str, width, height, colorMap,
+ delete maskColorMap;
+ } else if (haveExplicitMask) {
+ builder->addMaskedImage(state, str, width, height, colorMap,
maskStr, maskWidth, maskHeight, maskInvert);
- } else {
- builder->addImage(state, str, width, height, colorMap,
- haveColorKeyMask ? maskColors : (int *)NULL);
+ } else {
+ builder->addImage(state, str, width, height, colorMap,
+ haveColorKeyMask ? maskColors : static_cast<int *>(NULL));
+ }
+ delete colorMap;
+
+ maskObj.free();
+ smaskObj.free();
}
- delete colorMap;
- maskObj.free();
- smaskObj.free();
- }
-
- return;
+ return;
err2:
- obj1.free();
+ obj1.free();
err1:
#ifdef POPPLER_NEW_ERRORAPI
- error(errSyntaxError, getPos(), "Bad image parameters");
+ error(errSyntaxError, getPos(), "Bad image parameters");
#else
- error(getPos(), const_cast<char*>("Bad image parameters"));
+ error(getPos(), const_cast<char*>("Bad image parameters"));
#endif
}