[poppler] poppler/Gfx.cc

2023-07-03 Thread GitLab Mirror
 poppler/Gfx.cc |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 1b1036cf4ef1bfd70f300da3534375d02195fe32
Author: Albert Astals Cid 
Date:   Mon Jul 3 21:05:14 2023 +0200

Update (C)

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 15568ec0..00662256 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -46,6 +46,7 @@
 // Copyright (C) 2019 Volker Krause 
 // Copyright (C) 2020 Philipp Knechtges 
 // Copyright (C) 2021 Steve Rosenhamer 
+// Copyright (C) 2023 Anton Thomasson 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git


[poppler] poppler/Gfx.cc

2023-07-03 Thread GitLab Mirror
 poppler/Gfx.cc |1 -
 1 file changed, 1 deletion(-)

New commits:
commit c40bec5715075c12e7158639c638baa95bfcf2e8
Author: Anton Thomasson 
Date:   Mon Jun 19 22:04:38 2023 +0200

Don't abort command when restore runs in to a state guard

Fixes #1395

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 63e6c963..15568ec0 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -5368,7 +5368,6 @@ void Gfx::restoreState()
 {
 if (stackHeight <= bottomGuard() || !state->hasSaves()) {
 error(errSyntaxError, -1, "Restoring state when no valid states to 
pop");
-commandAborted = true;
 return;
 }
 state = state->restore();


[poppler] poppler/Gfx.cc

2022-12-30 Thread GitLab Mirror
 poppler/Gfx.cc |   23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

New commits:
commit f9d958ddee1e9a77d41c80793fd20ce5299f08ef
Author: Albert Astals Cid 
Date:   Tue Dec 27 09:38:55 2022 +0100

Gfx::opBeginMarkedContent: Support Span with Name

Issue #1327

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 17202a07..63e6c963 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -14,7 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2005 Jonathan Blandford 
-// Copyright (C) 2005-2013, 2015-2021 Albert Astals Cid 
+// Copyright (C) 2005-2013, 2015-2022 Albert Astals Cid 
 // Copyright (C) 2006 Thorkild Stray 
 // Copyright (C) 2006 Kristian Høgsberg 
 // Copyright (C) 2006-2011 Carlos Garcia Campos 
@@ -5049,12 +5049,21 @@ void Gfx::opBeginMarkedContent(Object args[], int 
numArgs)
 } else {
 error(errSyntaxError, getPos(), "insufficient arguments for Marked 
Content");
 }
-} else if (args[0].isName("Span") && numArgs == 2 && args[1].isDict()) {
-Object obj = args[1].dictLookup("ActualText");
-if (obj.isString()) {
-out->beginActualText(state, obj.getString());
-MarkedContentStack *mc = mcStack;
-mc->kind = gfxMCActualText;
+} else if (args[0].isName("Span") && numArgs == 2) {
+Object dictToUse;
+if (args[1].isDict()) {
+dictToUse = args[1].copy();
+} else if (args[1].isName()) {
+dictToUse = 
res->lookupMarkedContentNF(args[1].getName()).fetch(xref);
+}
+
+if (dictToUse.isDict()) {
+Object obj = dictToUse.dictLookup("ActualText");
+if (obj.isString()) {
+out->beginActualText(state, obj.getString());
+MarkedContentStack *mc = mcStack;
+mc->kind = gfxMCActualText;
+}
 }
 }
 


[poppler] poppler/Gfx.cc poppler/GfxFont.cc poppler/GfxFont.h

2021-10-22 Thread GitLab Mirror
 poppler/Gfx.cc |2 +-
 poppler/GfxFont.cc |4 +---
 poppler/GfxFont.h  |8 
 3 files changed, 6 insertions(+), 8 deletions(-)

New commits:
commit 4edef6b3de6e262852fda6423fbbe23a16f09389
Author: Albert Astals Cid 
Date:   Fri Oct 22 17:46:46 2021 +0200

Move GfxFont::tag to be a std::string

No need for it to be a GooString *

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 38088059..873fb287 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -3613,7 +3613,7 @@ void Gfx::opSetFont(Object args[], int numArgs)
 return;
 }
 if (printCommands) {
-printf("  font: tag=%s name='%s' %g\n", font->getTag()->c_str(), 
font->getName() ? font->getName()->c_str() : "???", args[1].getNum());
+printf("  font: tag=%s name='%s' %g\n", font->getTag().c_str(), 
font->getName() ? font->getName()->c_str() : "???", args[1].getNum());
 fflush(stdout);
 }
 
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 71798880..2596255e 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -220,10 +220,9 @@ GfxFont *GfxFont::makeFont(XRef *xref, const char *tagA, 
Ref idA, Dict *fontDict
 return font;
 }
 
-GfxFont::GfxFont(const char *tagA, Ref idA, const GooString *nameA, 
GfxFontType typeA, Ref embFontIDA)
+GfxFont::GfxFont(const char *tagA, Ref idA, const GooString *nameA, 
GfxFontType typeA, Ref embFontIDA) : tag(tagA)
 {
 ok = false;
-tag = new GooString(tagA);
 id = idA;
 name = nameA;
 type = typeA;
@@ -238,7 +237,6 @@ GfxFont::GfxFont(const char *tagA, Ref idA, const GooString 
*nameA, GfxFontType
 
 GfxFont::~GfxFont()
 {
-delete tag;
 delete family;
 if (name) {
 delete name;
diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h
index 398f4dea..add7f05e 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -13,7 +13,7 @@
 // All changes made under the Poppler project to this file are licensed
 // under GPL version 2 or later
 //
-// Copyright (C) 2005, 2008, 2015, 2017-2020 Albert Astals Cid 
+// Copyright (C) 2005, 2008, 2015, 2017-2021 Albert Astals Cid 
 // Copyright (C) 2006 Takashi Iwai 
 // Copyright (C) 2006 Kristian Høgsberg 
 // Copyright (C) 2007 Julien Rebetez 
@@ -193,13 +193,13 @@ public:
 void decRefCnt();
 
 // Get font tag.
-const GooString *getTag() const { return tag; }
+const std::string () const { return tag; }
 
 // Get font dictionary ID.
 const Ref *getID() const { return  }
 
 // Does this font match the tag?
-bool matches(const char *tagA) const { return !tag->cmp(tagA); }
+bool matches(const char *tagA) const { return tag == tagA; }
 
 // Get font family name.
 GooString *getFamily() const { return family; }
@@ -309,7 +309,7 @@ protected:
 CharCodeToUnicode *readToUnicodeCMap(Dict *fontDict, int nBits, 
CharCodeToUnicode *ctu);
 static GfxFontLoc *getExternalFont(GooString *path, bool cid);
 
-GooString *tag; // PDF font tag
+const std::string tag; // PDF font tag
 Ref id; // reference (used as unique ID)
 const GooString *name; // font name
 GooString *family; // font family


[poppler] poppler/Gfx.cc

2021-10-18 Thread GitLab Mirror
 poppler/Gfx.cc |7 +++
 1 file changed, 7 insertions(+)

New commits:
commit 24d0445aa4bf0795aff955dbaf1b585f090d3d2b
Author: Albert Astals Cid 
Date:   Mon Oct 18 17:51:37 2021 +0200

Support Type3 charprocs having Resources dicts

Doesn't seem to be standard but Adobe supports it so...

Fixes #1150

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 12b8ecd7..38088059 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -3915,6 +3915,10 @@ void Gfx::doShowText(const GooString *s)
 pushResources(resDict);
 }
 if (charProc.isStream()) {
+Object charProcResourcesObj = 
charProc.streamGetDict()->lookup("Resources");
+if (charProcResourcesObj.isDict()) {
+pushResources(charProcResourcesObj.getDict());
+}
 std::set::iterator charProcDrawingIt;
 bool displayCharProc = true;
 if (refNum != -1) {
@@ -3934,6 +3938,9 @@ void Gfx::doShowText(const GooString *s)
 charProcDrawing.erase(charProcDrawingIt);
 }
 }
+if (charProcResourcesObj.isDict()) {
+popResources();
+}
 } else {
 error(errSyntaxError, getPos(), "Missing or bad Type3 
CharProc entry");
 }


[poppler] poppler/Gfx.cc poppler/OutputDev.h

2021-10-11 Thread GitLab Mirror
 poppler/Gfx.cc  |5 +++--
 poppler/OutputDev.h |2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 3c265bb77f17abaf6031e09cb96833e5b3d128b8
Author: Adrian Johnson 
Date:   Mon Oct 11 07:04:36 2021 +1030

Form is not always a ref

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 27ac3173..12b8ecd7 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4120,9 +4120,10 @@ void Gfx::opXObject(Object args[], int numArgs)
 if (out->useDrawForm() && refObj.isRef()) {
 out->drawForm(refObj.getRef());
 } else {
-out->beginForm(refObj.getRef());
+Ref ref = refObj.isRef() ? refObj.getRef() : Ref::INVALID();
+out->beginForm(ref);
 doForm();
-out->endForm(refObj.getRef());
+out->endForm(ref);
 }
 }
 if (refObj.isRef() && shouldDoForm) {
diff --git a/poppler/OutputDev.h b/poppler/OutputDev.h
index 505891bf..67c21618 100644
--- a/poppler/OutputDev.h
+++ b/poppler/OutputDev.h
@@ -320,8 +320,8 @@ public:
 virtual void type3D1(GfxState * /*state*/, double /*wx*/, double /*wy*/, 
double /*llx*/, double /*lly*/, double /*urx*/, double /*ury*/) { }
 
 //- form XObjects
-virtual void drawForm(Ref /*id*/) { }
 virtual void beginForm(Ref /*id*/) { }
+virtual void drawForm(Ref /*id*/) { }
 virtual void endForm(Ref /*id*/) { }
 
 //- PostScript XObjects


[poppler] poppler/Gfx.cc poppler/MarkedContentOutputDev.cc poppler/MarkedContentOutputDev.h poppler/OutputDev.h poppler/StructElement.cc poppler/StructElement.h

2021-10-10 Thread GitLab Mirror
 poppler/Gfx.cc|2 +-
 poppler/MarkedContentOutputDev.cc |1 +
 poppler/MarkedContentOutputDev.h  |1 +
 poppler/OutputDev.h   |2 +-
 poppler/StructElement.cc  |2 +-
 poppler/StructElement.h   |1 +
 6 files changed, 6 insertions(+), 3 deletions(-)

New commits:
commit acd8b7c3bb6c3b35e7c79cc91b52dbb09e5ad9e3
Author: Albert Astals Cid 
Date:   Sun Oct 10 11:00:20 2021 +0200

Update (C)

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index c596b147..27ac3173 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -20,7 +20,7 @@
 // Copyright (C) 2006-2011 Carlos Garcia Campos 
 // Copyright (C) 2006, 2007 Jeff Muizelaar 
 // Copyright (C) 2007, 2008 Brad Hards 
-// Copyright (C) 2007, 2011, 2017 Adrian Johnson 
+// Copyright (C) 2007, 2011, 2017, 2021 Adrian Johnson 
 // Copyright (C) 2007, 2008 Iñigo Martínez 
 // Copyright (C) 2007 Koji Otani 
 // Copyright (C) 2007 Krzysztof Kowalczyk 
diff --git a/poppler/MarkedContentOutputDev.cc 
b/poppler/MarkedContentOutputDev.cc
index 558af589..3573adf2 100644
--- a/poppler/MarkedContentOutputDev.cc
+++ b/poppler/MarkedContentOutputDev.cc
@@ -6,6 +6,7 @@
 //
 // Copyright 2013 Igalia S.L.
 // Copyright 2018-2020 Albert Astals Cid 
+// Copyright 2021 Adrian Johnson 
 //
 //
 
diff --git a/poppler/MarkedContentOutputDev.h b/poppler/MarkedContentOutputDev.h
index ace886d0..8d46d1a2 100644
--- a/poppler/MarkedContentOutputDev.h
+++ b/poppler/MarkedContentOutputDev.h
@@ -6,6 +6,7 @@
 //
 // Copyright 2013 Igalia S.L.
 // Copyright 2018-2021 Albert Astals Cid 
+// Copyright 2021 Adrian Johnson 
 //
 //
 
diff --git a/poppler/OutputDev.h b/poppler/OutputDev.h
index 00b42e47..505891bf 100644
--- a/poppler/OutputDev.h
+++ b/poppler/OutputDev.h
@@ -16,7 +16,7 @@
 // Copyright (C) 2005 Jonathan Blandford 
 // Copyright (C) 2006 Thorkild Stray 
 // Copyright (C) 2007 Jeff Muizelaar 
-// Copyright (C) 2007, 2011, 2017 Adrian Johnson 
+// Copyright (C) 2007, 2011, 2017, 2021 Adrian Johnson 
 // Copyright (C) 2009-2013, 2015 Thomas Freitag 
 // Copyright (C) 2009, 2011 Carlos Garcia Campos 
 // Copyright (C) 2009, 2012, 2013, 2018, 2019, 2021 Albert Astals Cid 

diff --git a/poppler/StructElement.cc b/poppler/StructElement.cc
index 2c703668..e5521177 100644
--- a/poppler/StructElement.cc
+++ b/poppler/StructElement.cc
@@ -8,7 +8,7 @@
 // Copyright 2014 Luigi Scarso 
 // Copyright 2014, 2017-2019 Albert Astals Cid 
 // Copyright 2015 Dmytro Morgun 
-// Copyright 2018 Adrian Johnson 
+// Copyright 2018, 2021 Adrian Johnson 
 // Copyright 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
 // Copyright 2018 Adam Reichold 
 //
diff --git a/poppler/StructElement.h b/poppler/StructElement.h
index 933be643..66311b08 100644
--- a/poppler/StructElement.h
+++ b/poppler/StructElement.h
@@ -8,6 +8,7 @@
 // Copyright 2014 Luigi Scarso 
 // Copyright 2014, 2018, 2019, 2021 Albert Astals Cid 
 // Copyright 2018 Adam Reichold 
+// Copyright 2021 Adrian Johnson 
 //
 //
 


[poppler] poppler/Gfx.cc poppler/MarkedContentOutputDev.cc poppler/MarkedContentOutputDev.h poppler/OutputDev.h poppler/StructElement.cc poppler/StructElement.h

2021-10-09 Thread GitLab Mirror
 poppler/Gfx.cc|2 ++
 poppler/MarkedContentOutputDev.cc |   25 +++--
 poppler/MarkedContentOutputDev.h  |8 +++-
 poppler/OutputDev.h   |2 ++
 poppler/StructElement.cc  |   15 ---
 poppler/StructElement.h   |3 ++-
 6 files changed, 48 insertions(+), 7 deletions(-)

New commits:
commit 32f27b888d0e89cd40c086bd8d70381ee474078c
Author: Adrian Johnson 
Date:   Mon Oct 4 10:53:54 2021 +1030

StructElement: support MCID in XObjects

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index d389f90d..c596b147 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4120,7 +4120,9 @@ void Gfx::opXObject(Object args[], int numArgs)
 if (out->useDrawForm() && refObj.isRef()) {
 out->drawForm(refObj.getRef());
 } else {
+out->beginForm(refObj.getRef());
 doForm();
+out->endForm(refObj.getRef());
 }
 }
 if (refObj.isRef() && shouldDoForm) {
diff --git a/poppler/MarkedContentOutputDev.cc 
b/poppler/MarkedContentOutputDev.cc
index 164c5cea..558af589 100644
--- a/poppler/MarkedContentOutputDev.cc
+++ b/poppler/MarkedContentOutputDev.cc
@@ -17,8 +17,9 @@
 #include "Annot.h"
 #include 
 
-MarkedContentOutputDev::MarkedContentOutputDev(int mcidA) : 
currentFont(nullptr), currentText(nullptr), mcid(mcidA), pageWidth(0.0), 
pageHeight(0.0), unicodeMap(nullptr)
+MarkedContentOutputDev::MarkedContentOutputDev(int mcidA, const Object 
) : currentFont(nullptr), currentText(nullptr), mcid(mcidA), 
pageWidth(0.0), pageHeight(0.0), unicodeMap(nullptr)
 {
+stmRef = stmObj.copy();
 currentColor.r = currentColor.g = currentColor.b = 0;
 }
 
@@ -54,6 +55,26 @@ void MarkedContentOutputDev::endPage()
 pageWidth = pageHeight = 0.0;
 }
 
+void MarkedContentOutputDev::beginForm(Ref id)
+{
+formStack.push_back(id);
+}
+
+void MarkedContentOutputDev::endForm(Ref id)
+{
+formStack.pop_back();
+}
+
+bool MarkedContentOutputDev::contentStreamMatch()
+{
+if (stmRef.isRef()) {
+if (formStack.empty())
+return false;
+return formStack.back() == stmRef.getRef();
+}
+return formStack.empty();
+}
+
 void MarkedContentOutputDev::beginMarkedContent(const char *name, Dict 
*properties)
 {
 int id = -1;
@@ -64,7 +85,7 @@ void MarkedContentOutputDev::beginMarkedContent(const char 
*name, Dict *properti
 return;
 
 // The stack keep track of MCIDs of nested marked content.
-if (inMarkedContent() || id == mcid)
+if (inMarkedContent() || (id == mcid && contentStreamMatch()))
 mcidStack.push_back(id);
 }
 
diff --git a/poppler/MarkedContentOutputDev.h b/poppler/MarkedContentOutputDev.h
index 43351ae4..ace886d0 100644
--- a/poppler/MarkedContentOutputDev.h
+++ b/poppler/MarkedContentOutputDev.h
@@ -88,7 +88,7 @@ typedef std::vector TextSpanArray;
 class POPPLER_PRIVATE_EXPORT MarkedContentOutputDev : public OutputDev
 {
 public:
-explicit MarkedContentOutputDev(int mcidA);
+explicit MarkedContentOutputDev(int mcidA, const Object );
 ~MarkedContentOutputDev() override;
 
 virtual bool isOk() { return true; }
@@ -101,6 +101,9 @@ public:
 void startPage(int pageNum, GfxState *state, XRef *xref) override;
 void endPage() override;
 
+void beginForm(Ref id) override;
+void endForm(Ref id) override;
+
 void drawChar(GfxState *state, double xx, double yy, double dx, double dy, 
double ox, double oy, CharCode c, int nBytes, const Unicode *u, int uLen) 
override;
 
 void beginMarkedContent(const char *name, Dict *properties) override;
@@ -111,6 +114,7 @@ public:
 private:
 void endSpan();
 bool inMarkedContent() const { return mcidStack.size() > 0; }
+bool contentStreamMatch();
 bool needFontChange(const GfxFont *font) const;
 
 GfxFont *currentFont;
@@ -119,9 +123,11 @@ private:
 TextSpanArray textSpans;
 int mcid;
 std::vector mcidStack;
+std::vector formStack;
 double pageWidth;
 double pageHeight;
 const UnicodeMap *unicodeMap;
+Object stmRef;
 };
 
 #endif /* !MARKEDCONTENTOUTPUTDEV_H */
diff --git a/poppler/OutputDev.h b/poppler/OutputDev.h
index 3a8430c8..00b42e47 100644
--- a/poppler/OutputDev.h
+++ b/poppler/OutputDev.h
@@ -321,6 +321,8 @@ public:
 
 //- form XObjects
 virtual void drawForm(Ref /*id*/) { }
+virtual void beginForm(Ref /*id*/) { }
+virtual void endForm(Ref /*id*/) { }
 
 //- PostScript XObjects
 virtual void psXObject(Stream * /*psStream*/, Stream * /*level1Stream*/) { 
}
diff --git a/poppler/StructElement.cc b/poppler/StructElement.cc
index 0a0f744f..2c703668 100644
--- a/poppler/StructElement.cc
+++ b/poppler/StructElement.cc
@@ -813,7 +813,7 @@ const Attribute 
*StructElement::findAttribute(Attribute::Type attributeType, boo
 GooString *StructElement::appendSubTreeText(GooString *string, bool recursive) 
const
 {
 if 

[poppler] poppler/Gfx.cc

2021-07-28 Thread GitLab Mirror
 poppler/Gfx.cc |   27 ++-
 1 file changed, 26 insertions(+), 1 deletion(-)

New commits:
commit fc3afe21523b3fdc3a27254a3ef8139a82d35385
Author: Oliver Sander 
Date:   Thu Jul 15 11:01:33 2021 +0200

Use additional samples to test for constant parts of an axial gradient

The method doAxialShFill does adaptive sampling of gradients.
If the gradient color is found to be the same at two consecutive
sampling locations then the gradient is concluded to be constant
between the two locations.

Of course, this conclusion may be wrong; one instance of this
happening is

  https://gitlab.freedesktop.org/poppler/poppler/-/issues/938

This patch fixes rendering of the test file in issue 938 by doing
one more sampling when a part of the gradient is suspected to be
constant.  Of course it is easily possible to create gradients
also misrender with the additional sampling point.  Should such
gradients ever appear in actual non-synthetic documents the code
can now easily handle yet more sample points.

Fixes: https://gitlab.freedesktop.org/poppler/poppler/-/issues/938

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 4a6b21db..681fe2f7 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2688,6 +2688,7 @@ void Gfx::doAxialShFill(GfxAxialShading *shading)
 
 // bisect until color difference is small enough or we hit the
 // bisection limit
+const double previousStop = tt;
 j = next[i];
 while (j > i + 1) {
 if (ta[j] < 0) {
@@ -2697,8 +2698,32 @@ void Gfx::doAxialShFill(GfxAxialShading *shading)
 } else {
 tt = t0 + (t1 - t0) * ta[j];
 }
+
+// Try to determine whether the color map is constant between 
ta[i] and ta[j].
+// In the strict sense this question cannot be answered by 
sampling alone.
+// We try an educated guess in form of 2 samples.
+// See https://gitlab.freedesktop.org/poppler/poppler/issues/938 
for a file where one sample was not enough.
+
+// The first test sample at 1.0 (i.e., ta[j]) is coded separately, 
because we may
+// want to reuse the color later
 shading->getColor(tt, );
-if (isSameGfxColor(color1, color0, nComps, axialColorDelta)) {
+bool isPatchOfConstantColor = isSameGfxColor(color1, color0, 
nComps, axialColorDelta);
+
+if (isPatchOfConstantColor) {
+
+// Add more sample locations here if required
+for (double l : { 0.5 }) {
+GfxColor tmpColor;
+double x = previousStop + l * (tt - previousStop);
+shading->getColor(x, );
+if (!isSameGfxColor(tmpColor, color0, nComps, 
axialColorDelta)) {
+isPatchOfConstantColor = false;
+break;
+}
+}
+}
+
+if (isPatchOfConstantColor) {
 // in these two if what we guarantee is that if we are 
skipping lots of
 // positions because the colors are the same, we still create 
a region
 // with vertexs passing by bboxIntersections[1] and 
bboxIntersections[2]
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2021-07-17 Thread GitLab Mirror
 poppler/Gfx.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 87422fcfc35959235aea74e78bc58a1b1a5c116f
Author: Albert Astals Cid 
Date:   Sun Jul 18 00:43:22 2021 +0200

Update (C)

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index c30c2f5c..4a6b21db 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -42,7 +42,7 @@
 // Copyright (C) 2018, 2019 Adam Reichold 
 // Copyright (C) 2018 Denis Onishchenko 
 // Copyright (C) 2019 LE GARREC Vincent 
-// Copyright (C) 2019, 2020 Oliver Sander 
+// Copyright (C) 2019-2021 Oliver Sander 
 // Copyright (C) 2019 Volker Krause 
 // Copyright (C) 2020 Philipp Knechtges 
 // Copyright (C) 2021 Steve Rosenhamer 
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2021-07-17 Thread GitLab Mirror
 poppler/Gfx.cc |   21 +++--
 1 file changed, 3 insertions(+), 18 deletions(-)

New commits:
commit 9998ae596bd26cc7b61f176dda0fcee6e1dd346b
Author: Oliver Sander 
Date:   Thu Jul 15 15:46:43 2021 +0200

Replace a local bubble sort implementation by std::sort

This makes the code a bit shorter.

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 32144b3d..c30c2f5c 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2525,21 +2525,6 @@ void Gfx::doFunctionShFill1(GfxFunctionShading *shading, 
double x0, double y0, d
 }
 }
 
-static void bubbleSort(double array[])
-{
-for (int j = 0; j < 3; ++j) {
-int kk = j;
-for (int k = j + 1; k < 4; ++k) {
-if (array[k] < array[kk]) {
-kk = k;
-}
-}
-double tmp = array[j];
-array[j] = array[kk];
-array[kk] = tmp;
-}
-}
-
 void Gfx::doAxialShFill(GfxAxialShading *shading)
 {
 double xMin, yMin, xMax, yMax;
@@ -2576,7 +2561,7 @@ void Gfx::doAxialShFill(GfxAxialShading *shading)
 bboxIntersections[1] = ((xMin - x0) * dx + (yMax - y0) * dy) * mul;
 bboxIntersections[2] = ((xMax - x0) * dx + (yMin - y0) * dy) * mul;
 bboxIntersections[3] = ((xMax - x0) * dx + (yMax - y0) * dy) * mul;
-bubbleSort(bboxIntersections);
+std::sort(std::begin(bboxIntersections), std::end(bboxIntersections));
 tMin = bboxIntersections[0];
 tMax = bboxIntersections[3];
 if (tMin < 0 && !shading->getExtend0()) {
@@ -2677,7 +2662,7 @@ void Gfx::doAxialShFill(GfxAxialShading *shading)
 s[1] = (yMax - ty) / dx;
 s[2] = (xMin - tx) / -dy;
 s[3] = (xMax - tx) / -dy;
-bubbleSort(s);
+std::sort(std::begin(s), std::end(s));
 sMin = s[1];
 sMax = s[2];
 }
@@ -2791,7 +2776,7 @@ void Gfx::doAxialShFill(GfxAxialShading *shading)
 s[1] = (yMax - ty) / dx;
 s[2] = (xMin - tx) / -dy;
 s[3] = (xMax - tx) / -dy;
-bubbleSort(s);
+std::sort(std::begin(s), std::end(s));
 sMin = s[1];
 sMax = s[2];
 }
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2021-03-28 Thread GitLab Mirror
 poppler/Gfx.cc |1 +
 1 file changed, 1 insertion(+)

New commits:
commit c8d66bee757d7b0c8858115cd7772ed88bf1fe01
Author: Albert Astals Cid 
Date:   Sun Mar 28 16:25:51 2021 +0200

Update (C)

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 5179e436..32144b3d 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -45,6 +45,7 @@
 // Copyright (C) 2019, 2020 Oliver Sander 
 // Copyright (C) 2019 Volker Krause 
 // Copyright (C) 2020 Philipp Knechtges 
+// Copyright (C) 2021 Steve Rosenhamer 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2021-03-28 Thread GitLab Mirror
 poppler/Gfx.cc |   47 +--
 1 file changed, 41 insertions(+), 6 deletions(-)

New commits:
commit 12a47e31bfa7d00d04f1ef436fe19092feb34501
Author: Steve Rosenhamer 
Date:   Sun Mar 28 14:23:13 2021 +

Implement rendering of Masks of Image subtype.

Issue #1058

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 0cd7875d..5179e436 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4333,6 +4333,7 @@ void Gfx::doImage(Object *ref, Stream *str, bool 
inlineImg)
 }
 
 // get the mask
+bool haveMaskImage = false;
 haveColorKeyMask = haveExplicitMask = haveSoftMask = false;
 maskStr = nullptr; // make gcc happy
 maskWidth = maskHeight = 0; // make gcc happy
@@ -4340,13 +4341,41 @@ void Gfx::doImage(Object *ref, Stream *str, bool 
inlineImg)
 std::unique_ptr maskColorMap;
 Object maskObj = dict->lookup("Mask");
 Object smaskObj = dict->lookup("SMask");
-if (smaskObj.isStream()) {
+
+if (maskObj.isStream()) {
+maskStr = maskObj.getStream();
+maskDict = maskObj.streamGetDict();
+// if Type is XObject and Subtype is Image
+// then the way the softmask is drawn will draw
+// correctly, if it falls through to the explicit
+// mask code then you get an error and no image
+// drawn because it expects maskDict to have an entry
+// of Mask or IM that is boolean...
+Object tobj = maskDict->lookup("Type");
+if (!tobj.isNull() && tobj.isName() && tobj.isName("XObject")) {
+Object sobj = maskDict->lookup("Subtype");
+if (!sobj.isNull() && sobj.isName() && sobj.isName("Image")) {
+// ensure that this mask does not include an ImageMask 
entry
+// which signifies the explicit mask
+obj1 = maskDict->lookup("ImageMask");
+if (obj1.isNull()) {
+obj1 = maskDict->lookup("IM");
+}
+if (obj1.isNull() || !obj1.isBool())
+haveMaskImage = true;
+}
+}
+}
+
+if (smaskObj.isStream() || haveMaskImage) {
 // soft mask
 if (inlineImg) {
 goto err1;
 }
-maskStr = smaskObj.getStream();
-maskDict = smaskObj.streamGetDict();
+if (!haveMaskImage) {
+maskStr = smaskObj.getStream();
+maskDict = smaskObj.streamGetDict();
+}
 obj1 = maskDict->lookup("Width");
 if (obj1.isNull()) {
 obj1 = maskDict->lookup("W");
@@ -4447,8 +4476,11 @@ void Gfx::doImage(Object *ref, Stream *str, bool 
inlineImg)
 if (inlineImg) {
 goto err1;
 }
-maskStr = maskObj.getStream();
-maskDict = maskObj.streamGetDict();
+
+if (maskStr == nullptr) {
+maskStr = maskObj.getStream();
+maskDict = maskObj.streamGetDict();
+}
 obj1 = maskDict->lookup("Width");
 if (obj1.isNull()) {
 obj1 = maskDict->lookup("W");
@@ -4473,13 +4505,15 @@ void Gfx::doImage(Object *ref, Stream *str, bool 
inlineImg)
 maskInterpolate = obj1.getBool();
 else
 maskInterpolate = false;
+
 obj1 = maskDict->lookup("ImageMask");
 if (obj1.isNull()) {
 obj1 = maskDict->lookup("IM");
 }
-if (!obj1.isBool() || !obj1.getBool()) {
+if (!haveMaskImage && (!obj1.isBool() || !obj1.getBool())) {
 goto err1;
 }
+
 maskInvert = false;
 obj1 = maskDict->lookup("Decode");
 if (obj1.isNull()) {
@@ -4495,6 +4529,7 @@ void Gfx::doImage(Object *ref, Stream *str, bool 
inlineImg)
 } else if (!obj1.isNull()) {
 goto err1;
 }
+
 haveExplicitMask = true;
 }
 
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc poppler/Gfx.h

2021-01-02 Thread GitLab Mirror
 poppler/Gfx.cc |   31 ---
 poppler/Gfx.h  |4 ++--
 2 files changed, 14 insertions(+), 21 deletions(-)

New commits:
commit 0a1174ff7043cbdc7195a5df562a96bd0033cb95
Author: Albert Astals Cid 
Date:   Sat Jan 2 22:15:39 2021 +0100

Rework a bit the "infinite" recursion detection of Gfx

Instead of counting drawForm calls, count non toplevel display calls

Remove a check from Gfx::doSoftMask which doesn't seem like it would do
anything, let's hope the automatic fuzzer finds out if it does, git log
says it comes from the xpdf3.02 merge

This fixes issue #1021

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 78adcf79..20d450ed 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -14,7 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2005 Jonathan Blandford 
-// Copyright (C) 2005-2013, 2015-2020 Albert Astals Cid 
+// Copyright (C) 2005-2013, 2015-2021 Albert Astals Cid 
 // Copyright (C) 2006 Thorkild Stray 
 // Copyright (C) 2006 Kristian Høgsberg 
 // Copyright (C) 2006-2011 Carlos Garcia Campos 
@@ -483,7 +483,7 @@ Gfx::Gfx(PDFDoc *docA, OutputDev *outA, int pageNum, Dict 
*resDict, double hDPI,
 for (i = 0; i < 6; ++i) {
 baseMatrix[i] = state->getCTM()[i];
 }
-formDepth = 0;
+displayDepth = 0;
 ocState = true;
 parser = nullptr;
 abortCheckCbk = abortCheckCbkA;
@@ -544,7 +544,7 @@ Gfx::Gfx(PDFDoc *docA, OutputDev *outA, Dict *resDict, 
const PDFRectangle *box,
 for (i = 0; i < 6; ++i) {
 baseMatrix[i] = state->getCTM()[i];
 }
-formDepth = 0;
+displayDepth = 0;
 ocState = true;
 parser = nullptr;
 abortCheckCbk = abortCheckCbkA;
@@ -622,10 +622,13 @@ Gfx::~Gfx()
 
 void Gfx::display(Object *obj, bool topLevel)
 {
-int i;
+// check for excessive recursion
+if (displayDepth > 100) {
+return;
+}
 
 if (obj->isArray()) {
-for (i = 0; i < obj->arrayGetLength(); ++i) {
+for (int i = 0; i < obj->arrayGetLength(); ++i) {
 Object obj2 = obj->arrayGet(i);
 if (!obj2.isStream()) {
 error(errSyntaxError, -1, "Weird page contents");
@@ -1236,11 +1239,6 @@ void Gfx::doSoftMask(Object *str, bool alpha, 
GfxColorSpace *blendingColorSpace,
 Object obj1;
 int i;
 
-// check for excessive recursion
-if (formDepth > 20) {
-return;
-}
-
 // get stream dict
 dict = str->streamGetDict();
 
@@ -1290,9 +1288,7 @@ void Gfx::doSoftMask(Object *str, bool alpha, 
GfxColorSpace *blendingColorSpace,
 resDict = obj1.isDict() ? obj1.getDict() : nullptr;
 
 // draw it
-++formDepth;
 drawForm(str, resDict, m, bbox, true, true, blendingColorSpace, isolated, 
knockout, alpha, transferFunc, backdropColor);
---formDepth;
 }
 
 void Gfx::opSetRenderingIntent(Object args[], int numArgs)
@@ -3920,7 +3916,9 @@ void Gfx::doShowText(const GooString *s)
 }
 }
 if (displayCharProc) {
+++displayDepth;
 display(, false);
+--displayDepth;
 
 if (refNum != -1) {
 charProcDrawing.erase(charProcDrawingIt);
@@ -4604,11 +4602,6 @@ void Gfx::doForm(Object *str)
 Object obj1;
 int i;
 
-// check for excessive recursion
-if (formDepth > 100) {
-return;
-}
-
 // get stream dict
 dict = str->streamGetDict();
 
@@ -4693,9 +4686,7 @@ void Gfx::doForm(Object *str)
 }
 
 // draw it
-++formDepth;
 drawForm(str, resDict, m, bbox, transpGroup, false, blendingColorSpace, 
isolated, knockout);
---formDepth;
 
 if (blendingColorSpace) {
 delete blendingColorSpace;
@@ -4764,7 +4755,9 @@ void Gfx::drawForm(Object *str, Dict *resDict, const 
double *matrix, const doubl
 GfxState *stateBefore = state;
 
 // draw the form
+++displayDepth;
 display(str, false);
+--displayDepth;
 
 if (stateBefore != state) {
 if (state->isParentState(stateBefore)) {
diff --git a/poppler/Gfx.h b/poppler/Gfx.h
index 808f23c3..3539bd69 100644
--- a/poppler/Gfx.h
+++ b/poppler/Gfx.h
@@ -17,7 +17,7 @@
 // Copyright (C) 2007 Iñigo Martínez 
 // Copyright (C) 2008 Brad Hards 
 // Copyright (C) 2008, 2010 Carlos Garcia Campos 
-// Copyright (C) 2009-2013, 2017, 2018 Albert Astals Cid 
+// Copyright (C) 2009-2013, 2017, 2018, 2021 Albert Astals Cid 
 // Copyright (C) 2009, 2010, 2012, 2013 Thomas Freitag 
 // Copyright (C) 2010 David Benjamin 
 // Copyright (C) 2010 Christian Feuersänger 
@@ -217,7 +217,7 @@ private:
 int ignoreUndef; // current BX/EX nesting level
 double baseMatrix[6]; // default matrix for most recent
   //   page/form/pattern
-int formDepth;
+int displayDepth;
 bool ocState; // true if drawing is enabled, false if
   //   disabled
 

[poppler] poppler/Gfx.cc

2020-12-09 Thread GitLab Mirror
 poppler/Gfx.cc |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 4601e1d533a9c47e304b75435a104f5096a2b9a4
Author: Philipp Knechtges 
Date:   Tue Dec 8 23:06:43 2020 +0100

Gfx: specifically use DeviceGray instead of DefaultGray for softmasks

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index b8bf47ab..746703ab 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4392,11 +4392,12 @@ void Gfx::doImage(Object *ref, Stream *str, bool 
inlineImg)
 obj1 = std::move(obj2);
 }
 }
-maskColorSpace = GfxColorSpace::parse(nullptr, , out, state);
-if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) {
-delete maskColorSpace;
+// Here, we parse manually instead of using GfxColorSpace::parse,
+// since we explicitly need DeviceGray and not some DefaultGray 
color space
+if (!obj1.isName("DeviceGray") && !obj1.isName("G")) {
 goto err1;
 }
+maskColorSpace = new GfxDeviceGrayColorSpace();
 obj1 = maskDict->lookup("Decode");
 if (obj1.isNull()) {
 obj1 = maskDict->lookup("D");
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2020-11-23 Thread GitLab Mirror
 poppler/Gfx.cc |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit fb93776c423c166547d952bc199b14383a1d4d8d
Author: Albert Astals Cid 
Date:   Tue Nov 24 01:29:59 2020 +0100

Fix Annot border when C is present but empty -> transparent

Issue #993

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 04b81e65..b8bf47ab 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -5062,7 +5062,6 @@ void Gfx::drawAnnot(Object *str, AnnotBorder *border, 
AnnotColor *aColor, double
 double formXMin, formYMin, formXMax, formYMax;
 double x, y, sx, sy, tx, ty;
 double m[6], bbox[4];
-double r, g, b;
 GfxColor color;
 double *dash, *dash2;
 int dashLength;
@@ -5215,18 +5214,22 @@ void Gfx::drawAnnot(Object *str, AnnotBorder *border, 
AnnotColor *aColor, double
 }
 
 // draw the border
-if (border && border->getWidth() > 0) {
+if (border && border->getWidth() > 0 && (!aColor || aColor->getSpace() != 
AnnotColor::colorTransparent)) {
 if (state->getStrokeColorSpace()->getMode() != csDeviceRGB) {
 state->setStrokePattern(nullptr);
 state->setStrokeColorSpace(new GfxDeviceRGBColorSpace());
 out->updateStrokeColorSpace(state);
 }
-if (aColor && (aColor->getSpace() == AnnotColor::colorRGB)) {
+double r, g, b;
+if (!aColor) {
+r = g = b = 0;
+} else if ((aColor->getSpace() == AnnotColor::colorRGB)) {
 const double *values = aColor->getValues();
 r = values[0];
 g = values[1];
 b = values[2];
 } else {
+error(errUnimplemented, -1, "AnnotColor different than RGB and 
Transparent not supported");
 r = g = b = 0;
 };
 color.c[0] = dblToCol(r);
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2020-08-22 Thread GitLab Mirror
 poppler/Gfx.cc |   40 ++--
 1 file changed, 22 insertions(+), 18 deletions(-)

New commits:
commit 307d6db4247e3b934b5d26059fcd217517c4a187
Author: Albert Astals Cid 
Date:   Sat Aug 22 20:01:09 2020 +0200

Gfx::opSetExtGState: Fix memory leak on broken files

While at it move definitions of i and funcs down where used, also remove
the abuse of funcs[0] in one place and just declare a Function for it

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index dff71ed2..04b81e65 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -932,12 +932,10 @@ void Gfx::opSetExtGState(Object args[], int numArgs)
 Object obj1, obj2;
 GfxBlendMode mode;
 bool haveFillOP;
-Function *funcs[4];
 GfxColor backdropColor;
 bool haveBackdropColor;
 bool alpha;
 double opac;
-int i;
 
 obj1 = res->lookupGState(args[0].getName());
 if (obj1.isNull()) {
@@ -1055,22 +1053,28 @@ void Gfx::opSetExtGState(Object args[], int numArgs)
 obj2 = obj1.dictLookup("TR");
 }
 if (obj2.isName("Default") || obj2.isName("Identity")) {
-funcs[0] = funcs[1] = funcs[2] = funcs[3] = nullptr;
+Function *funcs[4] = { nullptr, nullptr, nullptr, nullptr };
 state->setTransfer(funcs);
 out->updateTransfer(state);
 } else if (obj2.isArray() && obj2.arrayGetLength() == 4) {
-for (i = 0; i < 4; ++i) {
+Function *funcs[4] = { nullptr, nullptr, nullptr, nullptr };
+for (int i = 0; i < 4; ++i) {
 Object obj3 = obj2.arrayGet(i);
 funcs[i] = Function::parse();
 if (!funcs[i]) {
 break;
 }
 }
-if (i == 4) {
+if (funcs[0] && funcs[1] && funcs[2] && funcs[3]) {
 state->setTransfer(funcs);
 out->updateTransfer(state);
+} else {
+for (Function *f : funcs) {
+delete f;
+}
 }
 } else if (obj2.isName() || obj2.isDict() || obj2.isStream()) {
+Function *funcs[4];
 if ((funcs[0] = Function::parse())) {
 funcs[1] = funcs[2] = funcs[3] = nullptr;
 state->setTransfer(funcs);
@@ -1106,26 +1110,26 @@ void Gfx::opSetExtGState(Object args[], int numArgs)
 } else { // "Luminosity"
 alpha = false;
 }
-funcs[0] = nullptr;
+Function *softMaskTransferFunc = nullptr;
 obj3 = obj2.dictLookup("TR");
 if (!obj3.isNull()) {
 if (obj3.isName("Default") || obj3.isName("Identity")) {
-funcs[0] = nullptr;
+// nothing
 } else {
-funcs[0] = Function::parse();
-if (funcs[0] == nullptr || funcs[0]->getInputSize() != 1 
|| funcs[0]->getOutputSize() != 1) {
+softMaskTransferFunc = Function::parse();
+if (softMaskTransferFunc == nullptr || 
softMaskTransferFunc->getInputSize() != 1 || 
softMaskTransferFunc->getOutputSize() != 1) {
 error(errSyntaxError, getPos(), "Invalid transfer 
function in soft mask in ExtGState");
-delete funcs[0];
-funcs[0] = nullptr;
+delete softMaskTransferFunc;
+softMaskTransferFunc = nullptr;
 }
 }
 }
 obj3 = obj2.dictLookup("BC");
 if ((haveBackdropColor = obj3.isArray())) {
-for (i = 0; i < gfxColorMaxComps; ++i) {
-backdropColor.c[i] = 0;
+for (int  : backdropColor.c) {
+c = 0;
 }
-for (i = 0; i < obj3.arrayGetLength() && i < gfxColorMaxComps; 
++i) {
+for (int i = 0; i < obj3.arrayGetLength() && i < 
gfxColorMaxComps; ++i) {
 Object obj4 = obj3.arrayGet(i);
 if (obj4.isNum()) {
 backdropColor.c[i] = dblToCol(obj4.getNum());
@@ -1148,12 +1152,12 @@ void Gfx::opSetExtGState(Object args[], int numArgs)
 
blendingColorSpace->getDefaultColor();
 } else {
 //~ need to get the parent or default color space 
(?)
-for (i = 0; i < gfxColorMaxComps; ++i) {
-backdropColor.c[i] = 0;
+for (int  : backdropColor.c) {
+c = 0;
 }
 }
 }
-doSoftMask(, alpha, blendingColorSpace, isolated, 
knockout, funcs[0], );
+doSoftMask(, alpha, blendingColorSpace, isolated, 
knockout, softMaskTransferFunc, );
 delete blendingColorSpace;
 } else {
 

[poppler] poppler/Gfx.cc

2020-07-16 Thread GitLab Mirror
 poppler/Gfx.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 39fe3635bd5bbbc15a1660dea2cbf85cb8517b6f
Author: Albert Astals Cid 
Date:   Thu Jul 16 19:14:13 2020 +0200

Update (C)

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 650cff83..dff71ed2 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -28,7 +28,7 @@
 // Copyright (C) 2008 Michael Vrable 
 // Copyright (C) 2008 Hib Eris 
 // Copyright (C) 2009 M Joonas Pihlaja 
-// Copyright (C) 2009-2016 Thomas Freitag 
+// Copyright (C) 2009-2016, 2020 Thomas Freitag 
 // Copyright (C) 2009 William Bader 
 // Copyright (C) 2009, 2010 David Benjamin 
 // Copyright (C) 2010 Nils Höglund 
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2020-07-16 Thread GitLab Mirror
 poppler/Gfx.cc |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 4411426325e05228c57ae05a3849443b4da16b21
Author: Thomas Freitag 
Date:   Thu Jul 16 16:57:27 2020 +

In case of sub-page objects: initialize clip max values considering the 
render resolution

Fixes #937

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 139261da..650cff83 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -529,7 +529,13 @@ Gfx::Gfx(PDFDoc *docA, OutputDev *outA, Dict *resDict, 
const PDFRectangle *box,
 
 // initialize
 out = outA;
-state = new GfxState(72, 72, box, 0, false);
+double hDPI = 72;
+double vDPI = 72;
+if (gfxA) {
+hDPI = gfxA->getState()->getHDPI();
+vDPI = gfxA->getState()->getVDPI();
+}
+state = new GfxState(hDPI, vDPI, box, 0, false);
 stackHeight = 1;
 pushStateGuard();
 fontChanged = false;
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc qt5/src utils/pdftocairo.cc

2020-05-23 Thread GitLab Mirror
 poppler/Gfx.cc  |1 +
 qt5/src/poppler-document.cc |1 +
 qt5/src/poppler-qt5.h   |1 +
 utils/pdftocairo.cc |1 +
 4 files changed, 4 insertions(+)

New commits:
commit 9429aac41fefdbb8b70d3c3233835875c78283ba
Author: Albert Astals Cid 
Date:   Sun May 24 00:33:20 2020 +0200

Update (C)

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index c1462c86..2a5b295c 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -44,6 +44,7 @@
 // Copyright (C) 2019 LE GARREC Vincent 
 // Copyright (C) 2019, 2020 Oliver Sander 
 // Copyright (C) 2019 Volker Krause 
+// Copyright (C) 2020 Philipp Knechtges 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc
index 901fc4e7..a40d4bac 100644
--- a/qt5/src/poppler-document.cc
+++ b/qt5/src/poppler-document.cc
@@ -15,6 +15,7 @@
  * Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
  * Copyright (C) 2019 Oliver Sander 
  * Copyright (C) 2019 Alexander Volkov 
+ * Copyright (C) 2020 Philipp Knechtges 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h
index e7d6ccb1..a5902859 100644
--- a/qt5/src/poppler-qt5.h
+++ b/qt5/src/poppler-qt5.h
@@ -21,6 +21,7 @@
  * Copyright (C) 2018 Nelson Benítez León 
  * Copyright (C) 2019 Jan Grulich 
  * Copyright (C) 2019 Alexander Volkov 
+ * Copyright (C) 2020 Philipp Knechtges 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/utils/pdftocairo.cc b/utils/pdftocairo.cc
index 553f14c4..4f51d427 100644
--- a/utils/pdftocairo.cc
+++ b/utils/pdftocairo.cc
@@ -35,6 +35,7 @@
 // Copyright (C) 2019, 2020 Oliver Sander 
 // Copyright (C) 2019 Kris Jurka 
 // Copyright (C) 2020 Oliver Sander 
+// Copyright (C) 2020 Philipp Knechtges 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc poppler/GfxState.cc poppler/GfxState.h qt5/src utils/pdftocairo.cc

2020-05-23 Thread GitLab Mirror
 poppler/Gfx.cc  |4 
 poppler/GfxState.cc |  314 
 poppler/GfxState.h  |   55 ---
 qt5/src/poppler-document.cc |6 
 qt5/src/poppler-qt5.h   |   11 +
 utils/pdftocairo.cc |9 -
 6 files changed, 195 insertions(+), 204 deletions(-)

New commits:
commit 5927e0b08f1ad6868d04cb209ee1e17b4ac07b70
Author: Philipp Knechtges 
Date:   Sat May 23 18:12:46 2020 +

GfxState: substitute manual ref counting in GfxColorTransform by a 
shared_ptr

This patch as said replaces the manual ref counting in GfxColorTransform. 
Along the lines
it also introduces another shared_ptr for cmsHPROFILEs, which is named 
GfxLCMSProfilePtr.

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index c248c576..c1462c86 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -654,8 +654,8 @@ void Gfx::initDisplayProfile() {
 Stream *iccStream = profile.getStream();
 int length = 0;
 unsigned char *profBuf = iccStream->toUnsignedChars(, 
65536, 65536);
-cmsHPROFILE hp = cmsOpenProfileFromMem(profBuf,length);
-if (hp == nullptr) {
+auto hp = 
make_GfxLCMSProfilePtr(cmsOpenProfileFromMem(profBuf,length));
+if (!hp) {
   error(errSyntaxWarning, -1, "read ICCBased color space 
profile error");
 } else {
   state->setDisplayProfile(hp);
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index bd0f0de5..fb8cb37a 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -192,15 +192,27 @@ static const std::map::size_type CMSCACHE_LIMIT = 20
 #define COLOR_PROFILE_DIR "/ColorProfiles/"
 #define GLOBAL_COLOR_PROFILE_DIR POPPLER_DATADIR COLOR_PROFILE_DIR
 
+static void lcmsprofiledeleter(void* profile)
+{
+cmsCloseProfile(profile);
+}
+
+GfxLCMSProfilePtr make_GfxLCMSProfilePtr(void* profile)
+{
+if (profile == nullptr) {
+return GfxLCMSProfilePtr();
+}
+return GfxLCMSProfilePtr(profile, lcmsprofiledeleter);
+}
+
 void GfxColorTransform::doTransform(void *in, void *out, unsigned int size) {
   cmsDoTransform(transform, in, out, size);
 }
 
 // transformA should be a cmsHTRANSFORM
-GfxColorTransform::GfxColorTransform(void *sourceProfileA, void *transformA, 
int cmsIntentA, unsigned int inputPixelTypeA, unsigned int transformPixelTypeA) 
{
+GfxColorTransform::GfxColorTransform(const GfxLCMSProfilePtr& sourceProfileA, 
void *transformA, int cmsIntentA, unsigned int inputPixelTypeA, unsigned int 
transformPixelTypeA) {
   sourceProfile = sourceProfileA;
   transform = transformA;
-  refCount = 1;
   cmsIntent = cmsIntentA;
   inputPixelType = inputPixelTypeA;
   transformPixelType = transformPixelTypeA;
@@ -208,21 +220,11 @@ GfxColorTransform::GfxColorTransform(void 
*sourceProfileA, void *transformA, int
 }
 
 GfxColorTransform::~GfxColorTransform() {
-  if (sourceProfile)
-cmsCloseProfile(sourceProfile);
   cmsDeleteTransform(transform);
   if (psCSA)
 gfree(psCSA);
 }
 
-void GfxColorTransform::ref() {
-  refCount++;
-}
-
-unsigned int GfxColorTransform::unref() {
-  return --refCount;
-}
-
 char *GfxColorTransform::getPostScriptCSA()
 {
 #if LCMS_VERSION>=2070
@@ -239,19 +241,20 @@ char *GfxColorTransform::getPostScriptCSA()
   if (psCSA)
 return psCSA;
 
-  if (sourceProfile == nullptr) {
+  if (!sourceProfile) {
 error(errSyntaxWarning, -1, "profile is nullptr");
 return nullptr;
   }
 
-  size = cmsGetPostScriptCSA(cmsGetProfileContextID(sourceProfile), 
sourceProfile, cmsIntent, 0, nullptr, 0);
+  void *rawprofile = sourceProfile.get();
+  size = cmsGetPostScriptCSA(cmsGetProfileContextID(rawprofile), rawprofile, 
cmsIntent, 0, nullptr, 0);
   if (size == 0) {
 error(errSyntaxWarning, -1, "PostScript CSA is nullptr");
 return nullptr;
   }
 
   psCSA = (char*)gmalloc(size+1);
-  cmsGetPostScriptCSA(cmsGetProfileContextID(sourceProfile), sourceProfile, 
cmsIntent, 0, psCSA, size);
+  cmsGetPostScriptCSA(cmsGetProfileContextID(rawprofile), rawprofile, 
cmsIntent, 0, psCSA, size);
   psCSA[size] = 0;
 
   return psCSA;
@@ -260,39 +263,39 @@ char *GfxColorTransform::getPostScriptCSA()
 #endif
 }
 
-static cmsHPROFILE RGBProfile = nullptr;
+static GfxLCMSProfilePtr RGBProfile = nullptr;
 static GooString *displayProfileName = nullptr; // display profile file Name
-static cmsHPROFILE displayProfile = nullptr; // display profile
+static GfxLCMSProfilePtr displayProfile = nullptr; // display profile
 static unsigned int displayPixelType = 0;
-static GfxColorTransform *XYZ2DisplayTransform = nullptr;
+static std::shared_ptr XYZ2DisplayTransform = nullptr;
 
 // convert color space signature to cmsColor type 
 static unsigned int getCMSColorSpaceType(cmsColorSpaceSignature cs);
 static unsigned int getCMSNChannels(cmsColorSpaceSignature cs);
-static cmsHPROFILE loadColorProfile(const char *fileName);
+static GfxLCMSProfilePtr 

[poppler] poppler/Gfx.cc

2020-05-03 Thread GitLab Mirror
 poppler/Gfx.cc |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 2c17c9ed7e50ea15255c905170ab1da30b62b3c6
Author: Oliver Sander 
Date:   Sat May 2 16:52:09 2020 +0200

Allow almost-singular tiling pattern matrices

Issue https://gitlab.freedesktop.org/poppler/poppler/issues/894
sports a file with a diagonal tiling pattern matrices with
diagonal entries in the range of 5e-4.  While entries of this
size are unusual but okay, the determinant is below the rather
arbitrary threshold of 1e-6.  Therefore, poppler decided that
the matrix is singular and aborts the rendering.

Fix this by really only aborting if inverting the determinant
(which is the first thing that is being done with it) results
in a non-finite number.

As a side effect the code now also allows pattern matrices
with a negative determinant.  This does not seem to appear
in the wild all that often, but I didn't find anything
in the spec that rules it out.

BUG: https://gitlab.freedesktop.org/poppler/poppler/issues/894

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 9773b60c..c248c576 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -42,7 +42,7 @@
 // Copyright (C) 2018, 2019 Adam Reichold 
 // Copyright (C) 2018 Denis Onishchenko 
 // Copyright (C) 2019 LE GARREC Vincent 
-// Copyright (C) 2019 Oliver Sander 
+// Copyright (C) 2019, 2020 Oliver Sander 
 // Copyright (C) 2019 Volker Krause 
 //
 // To see a description of the changes please see the Changelog file that
@@ -2061,11 +2061,11 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat,
 
   // construct a (device space) -> (pattern space) transform matrix
   det = m1[0] * m1[3] - m1[1] * m1[2];
-  if (fabs(det) < 0.01) {
+  det = 1 / det;
+  if (!std::isfinite(det)) {
 error(errSyntaxError, getPos(), "Singular matrix in tiling pattern fill");
 return;
   }
-  det = 1 / det;
   imb[0] = m1[3] * det;
   imb[1] = -m1[1] * det;
   imb[2] = -m1[2] * det;
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2019-07-18 Thread GitLab Mirror
 poppler/Gfx.cc |   13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

New commits:
commit f390d834ecbfe1350f82467d44291d0f567942ee
Author: Albert Astals Cid 
Date:   Wed Jul 17 17:34:15 2019 +0200

Simplify GfxResources::lookupPattern

by using the new Dict::lookup that returns the Ref if the object is a
Ref

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index a9b93b61..47627ad3 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -454,20 +454,13 @@ Object GfxResources::lookupColorSpace(const char *name) {
 
 GfxPattern *GfxResources::lookupPattern(const char *name, OutputDev *out, 
GfxState *state) {
   GfxResources *resPtr;
-  GfxPattern *pattern;
 
   for (resPtr = this; resPtr; resPtr = resPtr->next) {
 if (resPtr->patternDict.isDict()) {
-  Object obj = resPtr->patternDict.dictLookupNF(name).copy();
+  Ref patternRef = Ref::INVALID();
+  Object obj = resPtr->patternDict.getDict()->lookup(name, );
   if (!obj.isNull()) {
-   Ref patternRef = { -1, -1 };
-   if (obj.isRef()) {
- patternRef = obj.getRef();
- obj = obj.fetch(resPtr->patternDict.getDict()->getXRef());
-   }
-
-   pattern = GfxPattern::parse(resPtr, , out, state, patternRef.num);
-   return pattern;
+   return GfxPattern::parse(resPtr, , out, state, patternRef.num);
   }
 }
   }
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler

[poppler] poppler/Gfx.cc

2019-05-15 Thread GitLab Mirror
 poppler/Gfx.cc |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 0477707248bb62404961a08e75ecaf106529e7e1
Author: Oliver Sander 
Date:   Thu Apr 25 21:33:30 2019 +0200

Call updateCTM with the identity matrix instead of all zeros

The method Gfx::doShowText calls out->updateCTM once with the all-zero
matrix.  This was apparently implemented with the Splash output device
in mind: SplashOutputDev::updateCTM ignores its parameters, and
therefore calling it with a zero matrix is okay.  For other output
devices calling updateCTM with a zero matrix multiplies the CTM
with zero, which breaks further rendering.  See

  https://gitlab.freedesktop.org/poppler/poppler/issues/206

for an example.

This patch changes the argument to updateCTM in doShowText
from the zero matrix to an identity matrix.  That way, the CTM
is unchanged no matter how the output device implements its
updateCTM method.

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 5fba4c72..a9b93b61 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4007,7 +4007,10 @@ void Gfx::doShowText(const GooString *s) {
   curX += tdx;
   curY += tdy;
   state->moveTo(curX, curY);
-  out->updateCTM(state, 0, 0, 0, 0, 0, 0);
+  // Call updateCTM with the identity transformation.  That way, the CTM 
is unchanged,
+  // but any side effect that the method may have is triggered.  This is 
the case,
+  // in particular, for the Splash backend.
+  out->updateCTM(state, 1, 0, 0, 1, 0, 0);
   p += n;
   len -= n;
 }
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler

[poppler] poppler/Gfx.cc poppler/GlobalParamsWin.cc poppler/Hints.cc poppler/Lexer.h poppler/Linearization.cc poppler/Parser.cc poppler/Parser.h poppler/XRef.cc

2019-03-30 Thread GitLab Mirror
 poppler/Gfx.cc |2 -
 poppler/GlobalParamsWin.cc |3 --
 poppler/Hints.cc   |2 -
 poppler/Lexer.h|3 ++
 poppler/Linearization.cc   |2 -
 poppler/Parser.cc  |   61 +++--
 poppler/Parser.h   |   10 +++
 poppler/XRef.cc|   33 +---
 8 files changed, 57 insertions(+), 59 deletions(-)

New commits:
commit eb40274320381deca89898fb78b57091d2b804cc
Author: Adam Reichold 
Date:   Wed Nov 21 18:08:13 2018 +0100

Since a Parser cannot be used without a Lexer, make the Parser own the 
Lexer by value and construct it in place.

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 9244b044..eaeede53 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -709,7 +709,7 @@ void Gfx::display(Object *obj, bool topLevel) {
 error(errSyntaxError, -1, "Weird page contents");
 return;
   }
-  parser = new Parser(xref, new Lexer(xref, obj), false);
+  parser = new Parser(xref, obj, false);
   go(topLevel);
   delete parser;
   parser = nullptr;
diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
index e4fa6731..82f97e48 100644
--- a/poppler/GlobalParamsWin.cc
+++ b/poppler/GlobalParamsWin.cc
@@ -447,8 +447,7 @@ void GlobalParams::setupBaseFonts(char * dir)
 if (file != nullptr) {
   Parser *parser;
   parser = new Parser(nullptr,
- new Lexer(nullptr,
- new FileStream(file, 0, false, file->size(), Object(objNull))),
+  new FileStream(file, 0, false, file->size(), Object(objNull)),
  true);
   Object obj1 = parser->getObj();
   while (!obj1.isEOF()) {
diff --git a/poppler/Hints.cc b/poppler/Hints.cc
index e6039f4d..6adf10a0 100644
--- a/poppler/Hints.cc
+++ b/poppler/Hints.cc
@@ -202,7 +202,7 @@ void Hints::readTables(BaseStream *str, Linearization 
*linearization, XRef *xref
 
   MemStream *memStream = new MemStream ([0], 0, bufLength, 
Object(objNull));
 
-  parser = new Parser(xref, new Lexer(xref, memStream), true);
+  parser = new Parser(xref, memStream, true);
 
   int num, gen;
   Object obj;
diff --git a/poppler/Lexer.h b/poppler/Lexer.h
index bbc05a10..2666715d 100644
--- a/poppler/Lexer.h
+++ b/poppler/Lexer.h
@@ -91,6 +91,9 @@ public:
   static const int LOOK_VALUE_NOT_CACHED = -3;
   int lookCharLastValueCached;
 
+  XRef *getXRef() const { return xref; }
+  bool hasXRef() const { return xref != nullptr; }
+
 private:
 
   int getChar(bool comesFromLook = false);
diff --git a/poppler/Linearization.cc b/poppler/Linearization.cc
index 0e2d3aa7..550b9bff 100644
--- a/poppler/Linearization.cc
+++ b/poppler/Linearization.cc
@@ -24,7 +24,7 @@ Linearization::Linearization (BaseStream *str)
 
   str->reset();
   parser = new Parser(nullptr,
-  new Lexer(nullptr, str->makeSubStream(str->getStart(), false, 0, 
Object(objNull))),
+  str->makeSubStream(str->getStart(), false, 0, Object(objNull)),
   false);
   Object obj1 = parser->getObj();
   Object obj2 = parser->getObj();
diff --git a/poppler/Parser.cc b/poppler/Parser.cc
index 2c2f8718..cb9ebf93 100644
--- a/poppler/Parser.cc
+++ b/poppler/Parser.cc
@@ -44,19 +44,22 @@
 // lots of nested arrays that made us consume all the stack
 #define recursionLimit 500
 
-Parser::Parser(XRef *xrefA, Lexer *lexerA, bool allowStreamsA) {
-  xref = xrefA;
-  lexer = lexerA;
-  inlineImg = 0;
+Parser::Parser(XRef *xrefA, Stream *streamA, bool allowStreamsA) : 
lexer{xrefA, streamA} {
   allowStreams = allowStreamsA;
-  buf1 = lexer->getObj();
-  buf2 = lexer->getObj();
+  buf1 = lexer.getObj();
+  buf2 = lexer.getObj();
+  inlineImg = 0;
 }
 
-Parser::~Parser() {
-  delete lexer;
+Parser::Parser(XRef *xrefA, Object *objectA, bool allowStreamsA) : 
lexer{xrefA, objectA} {
+  allowStreams = allowStreamsA;
+  buf1 = lexer.getObj();
+  buf2 = lexer.getObj();
+  inlineImg = 0;
 }
 
+Parser::~Parser() = default;
+
 Object Parser::getObj(int recursion)
 {
   return getObj(false, nullptr, cryptRC4, 0, 0, 0, recursion);
@@ -76,8 +79,8 @@ Object Parser::getObj(bool simpleOnly,
 
   // refill buffer after inline image data
   if (inlineImg == 2) {
-buf1 = lexer->getObj();
-buf2 = lexer->getObj();
+buf1 = lexer.getObj();
+buf2 = lexer.getObj();
 inlineImg = 0;
   }
 
@@ -88,7 +91,7 @@ Object Parser::getObj(bool simpleOnly,
   // array
   if (!simpleOnly && buf1.isCmd("[")) {
 shift();
-obj = Object(new Array(xref));
+obj = Object(new Array(lexer.getXRef()));
 while (!buf1.isCmd("]") && !buf1.isEOF() && recursion + 1 < 
recursionLimit) {
   Object obj2 = getObj(false, fileKey, encAlgorithm, keyLength, objNum, 
objGen, recursion + 1);
   obj.arrayAdd(std::move(obj2));
@@ -103,7 +106,7 @@ Object Parser::getObj(bool simpleOnly,
   // dictionary or stream
   } else if (!simpleOnly && buf1.isCmd("<<")) {
 shift(objNum);
-obj = Object(new Dict(xref));
+obj = Object(new Dict(lexer.getXRef()));
 while 

[poppler] poppler/Gfx.cc

2018-12-22 Thread GitLab Mirror
 poppler/Gfx.cc |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 6e7cbc713ae584d195f77845d6cafcdc80fb64ab
Author: Albert Astals Cid 
Date:   Sat Dec 22 11:11:59 2018 +0100

Gfx::doTilingPatternFill: Fix undefined behaviour

oss-fuzz/8548

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 2b53ea07..8dc2dc93 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2187,6 +2187,9 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat,
   //~ edge instead of left/bottom (?)
   xstep = fabs(tPat->getXStep());
   ystep = fabs(tPat->getYStep());
+  if (unlikely(xstep == 0 || ystep == 0)) {
+  goto restore;
+  }
   if (tPat->getBBox()[0] < tPat->getBBox()[2]) {
 xi0 = (int)ceil((xMin - tPat->getBBox()[2]) / xstep);
 xi1 = (int)floor((xMax - tPat->getBBox()[0]) / xstep) + 1;
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2018-09-20 Thread GitLab Mirror
 poppler/Gfx.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit ab1b051a9f65b7f8e4dc9f8f9c28a0aff0c86596
Author: Albert Astals Cid 
Date:   Thu Sep 20 23:05:55 2018 +0200

Remove unused variable

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 4b8b1229..5b3b8f12 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -3893,7 +3893,7 @@ void Gfx::doShowText(const GooString *s) {
   const char *p;
   int render;
   GBool patternFill;
-  int len, n, uLen, nChars, nSpaces, i;
+  int len, n, uLen, nChars, nSpaces;
 
   font = state->getFont();
   wMode = font->getWMode();
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2018-09-20 Thread GitLab Mirror
 poppler/Gfx.cc |   28 +---
 1 file changed, 13 insertions(+), 15 deletions(-)

New commits:
commit d1a4c5a9faf95618fc302c358021a745afc0527c
Author: Denis Onishchenko 
Date:   Thu Sep 20 22:57:03 2018 +0200

Fix 2 errors in computation of type3 glyphs transformation matrix

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index df065b0d..4b8b1229 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -40,6 +40,7 @@
 // Copyright (C) 2014 Jason Crain 
 // Copyright (C) 2017, 2018 Klarälvdalens Datakonsult AB, a KDAB Group 
company, . Work sponsored by the LiMux project of the city of 
Munich
 // Copyright (C) 2018 Adam Reichold 
+// Copyright (C) 2018 Denis Onishchenko 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -3884,8 +3885,8 @@ void Gfx::doShowText(const GooString *s) {
   double x, y, dx, dy, dx2, dy2, curX, curY, tdx, tdy, ddx, ddy;
   double originX, originY, tOriginX, tOriginY;
   double x0, y0, x1, y1;
-  double oldCTM[6], newCTM[6];
-  double *mat;
+  double tmp[4], newCTM[6];
+  double *oldCTM, *mat;
   Dict *resDict;
   Parser *oldParser;
   GfxState *savedState;
@@ -3925,26 +3926,23 @@ void Gfx::doShowText(const GooString *s) {
 
   // handle a Type 3 char
   if (font->getType() == fontType3 && out->interpretType3Chars()) {
-mat = state->getCTM();
-for (i = 0; i < 6; ++i) {
-  oldCTM[i] = mat[i];
-}
+oldCTM = state->getCTM();
 mat = state->getTextMat();
-newCTM[0] = mat[0] * oldCTM[0] + mat[1] * oldCTM[2];
-newCTM[1] = mat[0] * oldCTM[1] + mat[1] * oldCTM[3];
-newCTM[2] = mat[2] * oldCTM[0] + mat[3] * oldCTM[2];
-newCTM[3] = mat[2] * oldCTM[1] + mat[3] * oldCTM[3];
+tmp[0] = mat[0] * oldCTM[0] + mat[1] * oldCTM[2];
+tmp[1] = mat[0] * oldCTM[1] + mat[1] * oldCTM[3];
+tmp[2] = mat[2] * oldCTM[0] + mat[3] * oldCTM[2];
+tmp[3] = mat[2] * oldCTM[1] + mat[3] * oldCTM[3];
 mat = font->getFontMatrix();
-newCTM[0] = mat[0] * newCTM[0] + mat[1] * newCTM[2];
-newCTM[1] = mat[0] * newCTM[1] + mat[1] * newCTM[3];
-newCTM[2] = mat[2] * newCTM[0] + mat[3] * newCTM[2];
-newCTM[3] = mat[2] * newCTM[1] + mat[3] * newCTM[3];
+newCTM[0] = mat[0] * tmp[0] + mat[1] * tmp[2];
+newCTM[1] = mat[0] * tmp[1] + mat[1] * tmp[3];
+newCTM[2] = mat[2] * tmp[0] + mat[3] * tmp[2];
+newCTM[3] = mat[2] * tmp[1] + mat[3] * tmp[3];
 newCTM[0] *= state->getFontSize();
 newCTM[1] *= state->getFontSize();
 newCTM[2] *= state->getFontSize();
 newCTM[3] *= state->getFontSize();
 newCTM[0] *= state->getHorizScaling();
-newCTM[2] *= state->getHorizScaling();
+newCTM[1] *= state->getHorizScaling();
 curX = state->getCurX();
 curY = state->getCurY();
 oldParser = parser;
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2018-07-02 Thread Albert Astals Cid
 poppler/Gfx.cc |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit d8346166d5150c1673379dcb3c658b9805f99764
Author: Albert Astals Cid 
Date:   Mon Jul 2 20:10:25 2018 +0200

Gfx::doRadialShFill: Don't divide by zero

fixes oss-fuzz/9133

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 0763e49f..8f2c62d2 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -3048,7 +3048,11 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) {
   if (t < 1) {
 n = 3;
   } else {
-n = (int)(M_PI / acos(1 - 0.1 / t));
+const double tmp = 1 - 0.1 / t;
+if (unlikely(tmp == 1))
+  n = 200;
+else
+  n = (int)(M_PI / acos(tmp));
 if (n < 3) {
   n = 3;
 } else if (n > 200) {
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2018-05-28 Thread Albert Astals Cid
 poppler/Gfx.cc |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

New commits:
commit bb25c0d46f1f0e037805f0c6dde07f3ea9c9320c
Author: Albert Astals Cid 
Date:   Tue May 29 00:55:28 2018 +0200

Gfx::doRadialShFill: Initialize colorA, colorB and colorC

fixes oss-fuzz/8587

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 4183e4f7..572f435c 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2903,7 +2903,7 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) {
   double xMin, yMin, xMax, yMax;
   double x0, y0, r0, x1, y1, r1, t0, t1;
   int nComps;
-  GfxColor colorA, colorB;
+  GfxColor colorA = {}, colorB = {}, colorC = {};
   double xa, ya, xb, yb, ra, rb;
   double ta, tb, sa, sb;
   double sz, xz, yz, sMin, sMax;
@@ -3079,7 +3079,6 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) {
 // same color does not mean all the areas in between have the same 
color too
 int ic = ia + 1;
 for (; ic <= ib; ic++) {
-  GfxColor colorC;
   const double sc = sMin + ((double)ic / (double)radialMaxSplits) * 
(sMax - sMin);
   const double tc = t0 + sc * (t1 - t0);
   getShadingColorRadialHelper(t0, t1, tc, shading, );
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2018-05-27 Thread Albert Astals Cid
 poppler/Gfx.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 9c0c538e8d1aa39cd136cfb8fe0fbfe1def5174d
Author: Albert Astals Cid 
Date:   Sun May 27 09:34:16 2018 +0200

Gfx::doAxialShFill: initialize color1

fixes oss-fuzz/8546

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 1190dcaf..4183e4f7 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2603,7 +2603,7 @@ void Gfx::doAxialShFill(GfxAxialShading *shading) {
   double t0, t1, tt;
   double ta[axialMaxSplits + 1];
   int next[axialMaxSplits + 1];
-  GfxColor color0 = {}, color1;
+  GfxColor color0 = {}, color1 = {};
   int nComps;
   int i, j, k;
   GBool needExtend = gTrue;
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2018-05-25 Thread Albert Astals Cid
 poppler/Gfx.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 71bb82bde235e15255635cab2c31cce58e0e
Author: Albert Astals Cid 
Date:   Fri May 25 22:52:31 2018 +0200

Gfx::doAxialShFill: initialize color0

fixes oss-fuzz/8470

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index f7cea495..1190dcaf 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2603,7 +2603,7 @@ void Gfx::doAxialShFill(GfxAxialShading *shading) {
   double t0, t1, tt;
   double ta[axialMaxSplits + 1];
   int next[axialMaxSplits + 1];
-  GfxColor color0, color1;
+  GfxColor color0 = {}, color1;
   int nComps;
   int i, j, k;
   GBool needExtend = gTrue;
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2018-05-23 Thread Albert Astals Cid
 poppler/Gfx.cc |8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

New commits:
commit e0fb18040378659c98fedb4bdaff6a903ddd095b
Author: Albert Astals Cid 
Date:   Wed May 23 19:40:50 2018 +0200

Gfx::opSetExtGState: Fix memory leak on broken files

doSoftMask was called just once, from opSetExtGState, but was
given the duty to delete blendingColorSpace that given doSoftMask
has various early returns is hard to do right, so i've moved
the deletion to opSetExtGState itself

fixes oss-fuzz/8431

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index af6fb9bd..f7cea495 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -989,7 +989,6 @@ void Gfx::opSetExtGState(Object args[], int numArgs) {
   Function *funcs[4];
   GfxColor backdropColor;
   GBool haveBackdropColor;
-  GfxColorSpace *blendingColorSpace;
   GBool alpha, isolated, knockout;
   double opac;
   int i;
@@ -1196,7 +1195,7 @@ void Gfx::opSetExtGState(Object args[], int numArgs) {
   if (obj3.isStream()) {
Object obj4 = obj3.streamGetDict()->lookup("Group");
if (obj4.isDict()) {
- blendingColorSpace = nullptr;
+ GfxColorSpace *blendingColorSpace = nullptr;
  isolated = knockout = gFalse;
  Object obj5 = obj4.dictLookup("CS");
  if (!obj5.isNull()) {
@@ -1222,6 +1221,7 @@ void Gfx::opSetExtGState(Object args[], int numArgs) {
  }
  doSoftMask(, alpha, blendingColorSpace,
 isolated, knockout, funcs[0], );
+ delete blendingColorSpace;
} else {
  error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - 
missing group");
}
@@ -1354,10 +1354,6 @@ void Gfx::doSoftMask(Object *str, GBool alpha,
  blendingColorSpace, isolated, knockout,
  alpha, transferFunc, backdropColor);
   --formDepth;
-
-  if (blendingColorSpace) {
-delete blendingColorSpace;
-  }
 }
 
 void Gfx::opSetRenderingIntent(Object args[], int numArgs) {
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2018-05-23 Thread Albert Astals Cid
 poppler/Gfx.cc |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 86991adb172fd55decdc72ec6fc34d41b19beafa
Author: Albert Astals Cid 
Date:   Wed May 23 19:35:27 2018 +0200

Gfx::doRadialShFill: Fix potential divide by zero

fixes oss-fuzz/8476

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 01ededcd..af6fb9bd 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2938,7 +2938,12 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) {
 xz = x0 + sz * (x1 - x0);
 yz = y0 + sz * (y1 - y0);
 enclosed = (xz - x0) * (xz - x0) + (yz - y0) * (yz - y0) <= r0 * r0;
-theta = asin(r0 / sqrt((x0 - xz) * (x0 - xz) + (y0 - yz) * (y0 - yz)));
+const double theta_aux = sqrt((x0 - xz) * (x0 - xz) + (y0 - yz) * (y0 - 
yz));
+if (likely(theta_aux != 0)) {
+  theta = asin(r0 / theta_aux);
+} else {
+  theta = 0;
+}
 if (r0 > r1) {
   theta = -theta;
 }
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2018-05-22 Thread Albert Astals Cid
 poppler/Gfx.cc |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

New commits:
commit a6c2eb671f08beb682e086d5f6791fdb78906a7c
Author: Albert Astals Cid 
Date:   Tue May 22 22:12:03 2018 +0200

Make sure dash[i] is intialized

even if obj is not a number

fixes oss-fuzz/8462

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index e0ccb4c2..01ededcd 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -947,11 +947,10 @@ void Gfx::opSetDash(Object args[], int numArgs) {
 dash = nullptr;
   } else {
 dash = (double *)gmallocn(length, sizeof(double));
+bool dummyOk;
 for (i = 0; i < length; ++i) {
-  Object obj = a->get(i);
-  if (obj.isNum()) {
-   dash[i] = obj.getNum();
-  }
+  const Object obj = a->get(i);
+  dash[i] = obj.getNum();
 }
   }
   state->setLineDash(dash, length, args[1].getNum());
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2018-05-22 Thread Albert Astals Cid
 poppler/Gfx.cc |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 2c0a0b07fdb2c76487ca4af7b2f50da9904c6c23
Author: Albert Astals Cid 
Date:   Tue May 22 20:15:39 2018 +0200

Gfx::doImage: Fix memory leak on malformed documents

fixes oss-fuzz/8452

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index bed1dc4b..e0ccb4c2 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4455,6 +4455,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
   }
   maskColorSpace = GfxColorSpace::parse(nullptr, , out, state);
   if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) {
+   delete maskColorSpace;
goto err1;
   }
   obj1 = maskDict->lookup("Decode");
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2018-05-22 Thread Albert Astals Cid
 poppler/Gfx.cc |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

New commits:
commit d1d8dea64db53fb151fede27efd5fd3308820a51
Author: Albert Astals Cid 
Date:   Tue May 22 18:13:19 2018 +0200

Fix memory leak on malformed files

fixes oss-fuzz/8430

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index a4d12a70..bed1dc4b 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -1223,15 +1223,13 @@ void Gfx::opSetExtGState(Object args[], int numArgs) {
  }
  doSoftMask(, alpha, blendingColorSpace,
 isolated, knockout, funcs[0], );
- if (funcs[0]) {
-   delete funcs[0];
- }
} else {
  error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - 
missing group");
}
   } else {
error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState - 
missing group");
   }
+  delete funcs[0];
 } else if (!obj2.isNull()) {
   error(errSyntaxError, getPos(), "Invalid soft mask in ExtGState");
 }
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc poppler/GfxFont.cc poppler/GfxFont.h poppler/Gfx.h

2018-04-05 Thread Albert Astals Cid
 poppler/Gfx.cc |   13 +++--
 poppler/Gfx.h  |5 -
 poppler/GfxFont.cc |2 +-
 poppler/GfxFont.h  |2 +-
 4 files changed, 17 insertions(+), 5 deletions(-)

New commits:
commit b60de1700d95d022ec0d1676886b0442cb763473
Author: Albert Astals Cid 
Date:   Thu Apr 5 16:03:54 2018 +0200

Introduce a const version of GfxResources::lookupFont

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 4f6c33f8..14600732 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -375,9 +375,10 @@ GfxResources::~GfxResources() {
   delete fonts;
 }
 
-GfxFont *GfxResources::lookupFont(char *name) {
+GfxFont *GfxResources::doLookupFont(const char *name) const
+{
   GfxFont *font;
-  GfxResources *resPtr;
+  const GfxResources *resPtr;
 
   for (resPtr = this; resPtr; resPtr = resPtr->next) {
 if (resPtr->fonts) {
@@ -389,6 +390,14 @@ GfxFont *GfxResources::lookupFont(char *name) {
   return nullptr;
 }
 
+GfxFont *GfxResources::lookupFont(const char *name) {
+  return doLookupFont(name);
+}
+
+const GfxFont *GfxResources::lookupFont(const char *name) const {
+  return doLookupFont(name);
+}
+
 Object GfxResources::lookupXObject(char *name) {
   GfxResources *resPtr;
 
diff --git a/poppler/Gfx.h b/poppler/Gfx.h
index 8e2f66cc..fb24dbac 100644
--- a/poppler/Gfx.h
+++ b/poppler/Gfx.h
@@ -22,6 +22,7 @@
 // Copyright (C) 2010 David Benjamin 
 // Copyright (C) 2010 Christian Feuersänger 
 // Copyright (C) 2013 Fabio D'Urso 
+// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -115,7 +116,8 @@ public:
   GfxResources(const GfxResources &) = delete;
   GfxResources& operator=(const GfxResources ) = delete;
 
-  GfxFont *lookupFont(char *name);
+  GfxFont *lookupFont(const char *name);
+  const GfxFont *lookupFont(const char *name) const;
   Object lookupXObject(char *name);
   Object lookupXObjectNF(char *name);
   Object lookupMarkedContentNF(char *name);
@@ -128,6 +130,7 @@ public:
   GfxResources *getNext() { return next; }
 
 private:
+  GfxFont *doLookupFont(const char *name) const;
 
   GfxFontDict *fonts;
   Object xObjDict;
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index 678510dc..02fee50c 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -2478,7 +2478,7 @@ GfxFontDict::~GfxFontDict() {
   gfree(fonts);
 }
 
-GfxFont *GfxFontDict::lookup(char *tag) {
+GfxFont *GfxFontDict::lookup(const char *tag) {
   int i;
 
   for (i = 0; i < numFonts; ++i) {
diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h
index 4719de69..ef02892b 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -452,7 +452,7 @@ public:
   GfxFontDict& operator=(const GfxFontDict &) = delete;
 
   // Get the specified font.
-  GfxFont *lookup(char *tag);
+  GfxFont *lookup(const char *tag);
 
   // Iterative access.
   int getNumFonts() { return numFonts; }
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2018-01-08 Thread Albert Astals Cid
 poppler/Gfx.cc |   23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

New commits:
commit cbd864b74fe368c1172974c7040c67ddfbc52cf6
Author: Albert Astals Cid 
Date:   Mon Jan 8 23:48:57 2018 +0100

Fix abort in Gfx::opBeginMarkedContent if args[1] is not a name

Bug #104468

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index ee8f3193..60fc98cc 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -5025,18 +5025,19 @@ void Gfx::opBeginMarkedContent(Object args[], int 
numArgs) {
   char* name0 = args[0].getName();
   if ( strncmp( name0, "OC", 2) == 0 && contentConfig) {
 if ( numArgs >= 2 ) {
-  if (!args[1].isName()) {
-   error(errSyntaxError, getPos(), "Unexpected MC Type: {0:d}", 
args[1].getType());
-  }
-  char* name1 = args[1].getName();
-  MarkedContentStack *mc = mcStack;
-  mc->kind = gfxMCOptionalContent;
-  Object markedContent = res->lookupMarkedContentNF( name1 );
-  if (!markedContent.isNull()) {
-bool visible = contentConfig->optContentIsVisible();
-mc->ocSuppressed = !(visible);
+  if (args[1].isName()) {
+char* name1 = args[1].getName();
+MarkedContentStack *mc = mcStack;
+mc->kind = gfxMCOptionalContent;
+Object markedContent = res->lookupMarkedContentNF( name1 );
+if (!markedContent.isNull()) {
+  bool visible = contentConfig->optContentIsVisible();
+  mc->ocSuppressed = !(visible);
+} else {
+  error(errSyntaxError, getPos(), "DID NOT find {0:s}", name1);
+}
   } else {
-   error(errSyntaxError, getPos(), "DID NOT find {0:s}", name1);
+   error(errSyntaxError, getPos(), "Unexpected MC Type: {0:d}", 
args[1].getType());
   }
 } else {
   error(errSyntaxError, getPos(), "insufficient arguments for Marked 
Content");
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2017-12-13 Thread Albert Astals Cid
 poppler/Gfx.cc |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 65dcc0b9c16c80e6718ada060d7ac0e2c0e39abf
Author: Albert Astals Cid 
Date:   Wed Dec 13 10:40:50 2017 +0100

Reset lastAbortCheck on updateLevel reset

Otherwise we get to a point that the
  if (updateLevel - lastAbortCheck > 10) {
branch is never executed because updateLevel got to 2 but 
lastAbortCheck is still at the last value

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 531acbd4..fd40dd97 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -38,6 +38,7 @@
 // Copyright (C) 2012, 2013 Fabio D'Urso 
 // Copyright (C) 2012 Lu Wang 
 // Copyright (C) 2014 Jason Crain 
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by the LiMux project of the city of Munich
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -764,6 +765,7 @@ void Gfx::go(GBool topLevel) {
   if (++updateLevel >= 2) {
out->dump();
updateLevel = 0;
+   lastAbortCheck = 0;
   }
 
   // did the command throw an exception
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc poppler/GfxState.cc poppler/GfxState.h

2017-09-25 Thread Albert Astals Cid
 poppler/Gfx.cc  |   46 ++
 poppler/GfxState.cc |   33 ++---
 poppler/GfxState.h  |   15 +--
 3 files changed, 61 insertions(+), 33 deletions(-)

New commits:
commit 2c92c7b6a828c9db8a38f079ea7a3d51c12a481d
Author: Albert Astals Cid 
Date:   Mon Sep 25 19:33:44 2017 +0200

Fix infinite recursion on broken files

Bug #102969

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 3eea6d2a..eaef798f 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -458,9 +458,15 @@ GfxPattern *GfxResources::lookupPattern(char *name, 
OutputDev *out, GfxState *st
 
   for (resPtr = this; resPtr; resPtr = resPtr->next) {
 if (resPtr->patternDict.isDict()) {
-  Object obj = resPtr->patternDict.dictLookup(name);
+  Object obj = resPtr->patternDict.dictLookupNF(name);
   if (!obj.isNull()) {
-   pattern = GfxPattern::parse(resPtr, , out, state);
+   Ref patternRef = { -1, -1 };
+   if (obj.isRef()) {
+ patternRef = obj.getRef();
+ obj = obj.fetch(resPtr->patternDict.getDict()->getXRef());
+   }
+
+   pattern = GfxPattern::parse(resPtr, , out, state, patternRef.num);
return pattern;
   }
 }
@@ -2224,18 +2230,34 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat,
   xi0, yi0, xi1, yi1, xstep, ystep)) {
 goto restore;
   } else {
-out->updatePatternOpacity(state);
-for (yi = yi0; yi < yi1; ++yi) {
-  for (xi = xi0; xi < xi1; ++xi) {
-x = xi * xstep;
-y = yi * ystep;
-m1[4] = x * m[0] + y * m[2] + m[4];
-m1[5] = x * m[1] + y * m[3] + m[5];
-drawForm(tPat->getContentStream(), tPat->getResDict(),
- m1, tPat->getBBox());
+bool shouldDrawForm = gTrue;
+std::set::iterator patternRefIt;
+const int patternRefNum = tPat->getPatternRefNum();
+if (patternRefNum != -1) {
+  if (formsDrawing.find(patternRefNum) == formsDrawing.end()) {
+   patternRefIt = formsDrawing.insert(patternRefNum).first;
+  } else {
+   shouldDrawForm = gFalse;
+  }
+}
+
+if (shouldDrawForm) {
+  out->updatePatternOpacity(state);
+  for (yi = yi0; yi < yi1; ++yi) {
+   for (xi = xi0; xi < xi1; ++xi) {
+ x = xi * xstep;
+ y = yi * ystep;
+ m1[4] = x * m[0] + y * m[2] + m[4];
+ m1[5] = x * m[1] + y * m[3] + m[5];
+ drawForm(tPat->getContentStream(), tPat->getResDict(),
+ m1, tPat->getBBox());
+   }
+  }
+  out->clearPatternOpacity(state);
+  if (patternRefNum != -1) {
+   formsDrawing.erase(patternRefIt);
   }
 }
-out->clearPatternOpacity(state);
   }
 
   // restore graphics state
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index b2971ec0..3e30edf0 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -3351,14 +3351,17 @@ void GfxPatternColorSpace::getDefaultColor(GfxColor 
*color) {
 // Pattern
 //
 
-GfxPattern::GfxPattern(int typeA) {
-  type = typeA;
+GfxPattern::GfxPattern(int typeA, int patternRefNumA)
+ : type(typeA)
+ , patternRefNum(patternRefNumA)
+{
+
 }
 
 GfxPattern::~GfxPattern() {
 }
 
-GfxPattern *GfxPattern::parse(GfxResources *res, Object *obj, OutputDev *out, 
GfxState *state) {
+GfxPattern *GfxPattern::parse(GfxResources *res, Object *obj, OutputDev *out, 
GfxState *state, int patternRefNum) {
   GfxPattern *pattern;
   Object obj1;
 
@@ -3371,9 +3374,9 @@ GfxPattern *GfxPattern::parse(GfxResources *res, Object 
*obj, OutputDev *out, Gf
   }
   pattern = NULL;
   if (obj1.isInt() && obj1.getInt() == 1) {
-pattern = GfxTilingPattern::parse(obj);
+pattern = GfxTilingPattern::parse(obj, patternRefNum);
   } else if (obj1.isInt() && obj1.getInt() == 2) {
-pattern = GfxShadingPattern::parse(res, obj, out, state);
+pattern = GfxShadingPattern::parse(res, obj, out, state, patternRefNum);
   }
   return pattern;
 }
@@ -3382,7 +3385,7 @@ GfxPattern *GfxPattern::parse(GfxResources *res, Object 
*obj, OutputDev *out, Gf
 // GfxTilingPattern
 //
 
-GfxTilingPattern *GfxTilingPattern::parse(Object *patObj) {
+GfxTilingPattern *GfxTilingPattern::parse(Object *patObj, int patternRefNum) {
   Dict *dict;
   int paintTypeA, tilingTypeA;
   double bboxA[4], matrixA[6];
@@ -3455,14 +3458,14 @@ GfxTilingPattern *GfxTilingPattern::parse(Object 
*patObj) {
   }
 
   return new GfxTilingPattern(paintTypeA, tilingTypeA, bboxA, xStepA, yStepA,
-, matrixA, patObj);
+, matrixA, patObj, patternRefNum);
 }
 
 GfxTilingPattern::GfxTilingPattern(int paintTypeA, int tilingTypeA,
   double *bboxA, double xStepA, double yStepA,
   Object *resDictA, double *matrixA,
-   

[poppler] poppler/Gfx.cc poppler/GfxFont.cc poppler/GfxFont.h poppler/Gfx.h

2017-09-13 Thread Albert Astals Cid
 poppler/Gfx.cc |   25 +++--
 poppler/Gfx.h  |1 +
 poppler/GfxFont.cc |8 
 poppler/GfxFont.h  |1 +
 4 files changed, 33 insertions(+), 2 deletions(-)

New commits:
commit aaf5327649e8f7371c9d3270e7813c43ddfd47ee
Author: Albert Astals Cid 
Date:   Wed Sep 13 23:01:03 2017 +0200

Gfx::doShowText: Fix infinite recursion on broken files

Bug #102701

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 6ffb7bcf..3eea6d2a 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -3953,12 +3953,33 @@ void Gfx::doShowText(GooString *s) {
   state->transformDelta(dx, dy, , );
   if (!out->beginType3Char(state, curX + riseX, curY + riseY, ddx, ddy,
   code, u, uLen)) {
-   Object charProc = ((Gfx8BitFont *)font)->getCharProc(code);
+   Object charProc = ((Gfx8BitFont *)font)->getCharProcNF(code);
+   int refNum = -1;
+   if (charProc.isRef()) {
+ refNum = charProc.getRef().num;
+ charProc = charProc.fetch(((Gfx8BitFont 
*)font)->getCharProcs()->getXRef());
+   }
if ((resDict = ((Gfx8BitFont *)font)->getResources())) {
  pushResources(resDict);
}
if (charProc.isStream()) {
- display(, gFalse);
+ std::set::iterator charProcDrawingIt;
+ bool displayCharProc = true;
+ if (refNum != -1) {
+   if (charProcDrawing.find(refNum) == charProcDrawing.end()) {
+ charProcDrawingIt = charProcDrawing.insert(refNum).first;
+   } else {
+ displayCharProc = false;
+ error(errSyntaxError, -1, "CharProc wants to draw a CharProc that 
is already beign drawn");
+   }
+ }
+ if (displayCharProc) {
+   display(, gFalse);
+
+   if (refNum != -1) {
+ charProcDrawing.erase(charProcDrawingIt);
+   }
+ }
} else {
  error(errSyntaxError, getPos(), "Missing or bad Type3 CharProc 
entry");
}
diff --git a/poppler/Gfx.h b/poppler/Gfx.h
index 00eaec49..293f4551 100644
--- a/poppler/Gfx.h
+++ b/poppler/Gfx.h
@@ -228,6 +228,7 @@ private:
   Parser *parser;  // parser for page content stream(s)
   
   std::set formsDrawing;  // the forms that are being drawn
+  std::set charProcDrawing;   // the charProc that are being drawn
 
   GBool// callback to check for an abort
 (*abortCheckCbk)(void *data);
diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc
index d95f8f7c..1c3d0b25 100644
--- a/poppler/GfxFont.cc
+++ b/poppler/GfxFont.cc
@@ -1759,6 +1759,14 @@ Object Gfx8BitFont::getCharProc(int code) {
   }
 }
 
+Object Gfx8BitFont::getCharProcNF(int code) {
+  if (enc[code] && charProcs.isDict()) {
+return charProcs.dictLookupNF(enc[code]);
+  } else {
+return Object(objNull);
+  }
+}
+
 Dict *Gfx8BitFont::getResources() {
   return resources.isDict() ? resources.getDict() : (Dict *)NULL;
 }
diff --git a/poppler/GfxFont.h b/poppler/GfxFont.h
index 06c1df6d..5985912a 100644
--- a/poppler/GfxFont.h
+++ b/poppler/GfxFont.h
@@ -353,6 +353,7 @@ public:
 
   // Return the Type 3 CharProc for the character associated with .
   Object getCharProc(int code);
+  Object getCharProcNF(int code);
 
   // Return the Type 3 Resources dictionary, or NULL if none.
   Dict *getResources();
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc poppler/Stream.cc poppler/Stream.h utils/ImageOutputDev.cc utils/ImageOutputDev.h

2017-08-16 Thread Adrian Johnson
 poppler/Gfx.cc  |2 -
 poppler/Stream.cc   |   96 ++--
 poppler/Stream.h|   14 ++-
 utils/ImageOutputDev.cc |   67 ++---
 utils/ImageOutputDev.h  |1 
 5 files changed, 159 insertions(+), 21 deletions(-)

New commits:
commit 488d28ec9507eb99c7cb4cd2cafb54995a8bc9f8
Author: Adrian Johnson 
Date:   Wed Aug 16 21:01:07 2017 +0930

pdfimages: support listing/extracting inline images

The difficulty with extracting inline images is that inline images do
not provide any way of determining the length or end of image data
without decoding the image. We can get the length by using ImageStream
to decode the data then check the stream position. But then we are
still unable to extract the undecoded image data because embedded
streams can only be read once.

Since inline images tend to be small the solution implemented is to
modify EmbedStream to keep a copy of the data read from it in memory
and then allow the data to be read again.

Two new functions have been added to EmbedStream. rewind() will cause
EmbedStream.getChar() to stop recording data and switch to replaying
the saved data, returning EOF when the end of the saved data is
reached. The restore() function will make getChar() switch back to
reading from the parent stream.

ImageOutputDev can now extract or get the image size by first using
ImageStream to read data from the embedded stream. After calling
rewind() the undecoded image data can be read from the embedded stream
until EOF is returned. Then restore() is called so that Gfx can read
the 'EI' from the end of the embedded stream.

Bug 25625

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index be9810e1..2bfc1ecd 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4901,7 +4901,7 @@ Stream *Gfx::buildImageStream() {
 
   // make stream
   if (parser->getStream()) {
-str = new EmbedStream(parser->getStream(), std::move(dict), gFalse, 0);
+str = new EmbedStream(parser->getStream(), std::move(dict), gFalse, 0, 
gTrue);
 str = str->addFilters(str->getDict());
   } else {
 str = NULL;
diff --git a/poppler/Stream.cc b/poppler/Stream.cc
index df767652..9cb48abc 100644
--- a/poppler/Stream.cc
+++ b/poppler/Stream.cc
@@ -1033,14 +1033,25 @@ void MemStream::moveStart(Goffset delta) {
 //
 
 EmbedStream::EmbedStream(Stream *strA, Object &,
-GBool limitedA, Goffset lengthA):
+GBool limitedA, Goffset lengthA, GBool reusableA):
 BaseStream(std::move(dictA), lengthA) {
   str = strA;
   limited = limitedA;
   length = lengthA;
+  reusable = reusableA;
+  record = gFalse;
+  replay = gFalse;
+  if (reusable) {
+bufData = (unsigned char*)gmalloc(16384);
+bufMax = 16384;
+bufLen = 0;
+record = gTrue;
+  }
 }
 
 EmbedStream::~EmbedStream() {
+  if (reusable)
+gfree(bufData);
 }
 
 BaseStream *EmbedStream::copy() {
@@ -1054,31 +1065,94 @@ Stream *EmbedStream::makeSubStream(Goffset start, GBool 
limitedA,
   return NULL;
 }
 
+void EmbedStream::rewind() {
+  record = gFalse;
+  replay = gTrue;
+  bufPos = 0;
+}
+
+void EmbedStream::restore() {
+  replay = gFalse;
+}
+
+Goffset EmbedStream::getPos() {
+  if (replay)
+return bufPos;
+  else
+return str->getPos();
+}
+
 int EmbedStream::getChar() {
-  if (limited && !length) {
-return EOF;
+  if (replay) {
+if (bufPos < bufLen)
+  return bufData[bufPos++];
+else
+  return EOF;
+  } else {
+if (limited && !length) {
+  return EOF;
+}
+int c = str->getChar();
+--length;
+if (record) {
+  bufData[bufLen] = c;
+  bufLen++;
+  if (bufLen >= bufMax) {
+bufMax *= 2;
+bufData = (unsigned char *)grealloc(bufData, bufMax);
+  }
+}
+return c;
   }
-  --length;
-  return str->getChar();
 }
 
 int EmbedStream::lookChar() {
-  if (limited && !length) {
-return EOF;
+  if (replay) {
+if (bufPos < bufLen)
+  return bufData[bufPos];
+else
+  return EOF;
+  } else {
+if (limited && !length) {
+  return EOF;
+}
+return str->lookChar();
   }
-  return str->lookChar();
 }
 
 int EmbedStream::getChars(int nChars, Guchar *buffer) {
+  int len;
+
   if (nChars <= 0) {
 return 0;
   }
-  if (limited && length < nChars) {
-nChars = length;
+  if (replay) {
+if (bufPos >= bufLen)
+  return EOF;
+len = bufLen - bufPos;
+if (nChars > len)
+  nChars = len;
+memcpy(buffer, bufData, len);
+return len;
+  } else {
+if (limited && length < nChars) {
+  nChars = length;
+}
+len = str->doGetChars(nChars, buffer);
+if (record) {
+  if (bufLen + len >= bufMax) {
+while (bufLen + len >= bufMax)
+  bufMax *= 2;
+bufData = 

[poppler] poppler/Gfx.cc

2017-07-31 Thread Albert Astals Cid
 poppler/Gfx.cc |   10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

New commits:
commit e5ff049c3d11e6ea24b624807730acd21a6ef4d5
Author: Albert Astals Cid 
Date:   Tue Aug 1 01:07:00 2017 +0200

Gfx::doImage: Simplify memory management

of maskColorMap by using a std::unique_ptr

Fixes a memory leak reported by Coverity

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 4a9aab5c..be9810e1 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -55,6 +55,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "goo/gmem.h"
 #include "goo/GooTimer.h"
 #include "goo/GooHash.h"
@@ -4175,7 +4176,6 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
   GBool mask;
   GBool invert;
   GfxColorSpace *colorSpace, *maskColorSpace;
-  GfxImageColorMap *maskColorMap;
   GBool haveColorKeyMask, haveExplicitMask, haveSoftMask;
   int maskColors[2*gfxColorMaxComps];
   int maskWidth, maskHeight;
@@ -4374,7 +4374,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
 maskStr = NULL; // make gcc happy
 maskWidth = maskHeight = 0; // make gcc happy
 maskInvert = gFalse; // make gcc happy
-maskColorMap = NULL; // make gcc happy
+std::unique_ptr maskColorMap;
 Object maskObj = dict->lookup("Mask");
 Object smaskObj = dict->lookup("SMask");
 if (smaskObj.isStream()) {
@@ -4434,9 +4434,8 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
   if (obj1.isNull()) {
obj1 = maskDict->lookup("D");
   }
-  maskColorMap = new GfxImageColorMap(maskBits, , maskColorSpace);
+  maskColorMap.reset(new GfxImageColorMap(maskBits, , 
maskColorSpace));
   if (!maskColorMap->isOk()) {
-   delete maskColorMap;
goto err1;
   }
   // handle the Matte entry
@@ -4552,8 +4551,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
 } else {
   if (haveSoftMask) {
out->drawSoftMaskedImage(state, ref, str, width, height, , 
interpolate,
-maskStr, maskWidth, maskHeight, maskColorMap, 
maskInterpolate);
-   delete maskColorMap;
+maskStr, maskWidth, maskHeight, 
maskColorMap.get(), maskInterpolate);
   } else if (haveExplicitMask) {
out->drawMaskedImage(state, ref, str, width, height, , 
interpolate,
 maskStr, maskWidth, maskHeight, maskInvert, 
maskInterpolate);
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2017-05-04 Thread Albert Astals Cid
 poppler/Gfx.cc |   18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

New commits:
commit 9ad9d92591a6389f84919ff2de3668c2b6158dc9
Author: Albert Astals Cid 
Date:   Fri May 5 00:57:35 2017 +0200

Fix memory leak in error condition

Coverity was complaining we missed one delete in one of the error
conditions, so just made colorMap not be newer, no need to care about
deletes ;)

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index a2d1db0c..37220280 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4264,7 +4264,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
   GBool mask;
   GBool invert;
   GfxColorSpace *colorSpace, *maskColorSpace;
-  GfxImageColorMap *colorMap, *maskColorMap;
+  GfxImageColorMap *maskColorMap;
   Object maskObj, smaskObj;
   GBool haveColorKeyMask, haveExplicitMask, haveSoftMask;
   int maskColors[2*gfxColorMaxComps];
@@ -4482,10 +4482,9 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
   obj1.free();
   dict->lookup("D", );
 }
-colorMap = new GfxImageColorMap(bits, , colorSpace);
+GfxImageColorMap colorMap(bits, , colorSpace);
 obj1.free();
-if (!colorMap->isOk()) {
-  delete colorMap;
+if (!colorMap.isOk()) {
   goto err1;
 }
 
@@ -4692,8 +4691,8 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
 // if drawing is disabled, skip over inline image data
 if (!ocState || !out->needNonText()) {
   str->reset();
-  n = height * ((width * colorMap->getNumPixelComps() *
-colorMap->getBits() + 7) / 8);
+  n = height * ((width * colorMap.getNumPixelComps() *
+colorMap.getBits() + 7) / 8);
   for (i = 0; i < n; ++i) {
str->getChar();
   }
@@ -4702,18 +4701,17 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
 // draw it
 } else {
   if (haveSoftMask) {
-   out->drawSoftMaskedImage(state, ref, str, width, height, colorMap, 
interpolate,
+   out->drawSoftMaskedImage(state, ref, str, width, height, , 
interpolate,
 maskStr, maskWidth, maskHeight, maskColorMap, 
maskInterpolate);
delete maskColorMap;
   } else if (haveExplicitMask) {
-   out->drawMaskedImage(state, ref, str, width, height, colorMap, 
interpolate,
+   out->drawMaskedImage(state, ref, str, width, height, , 
interpolate,
 maskStr, maskWidth, maskHeight, maskInvert, 
maskInterpolate);
   } else {
-   out->drawImage(state, ref, str, width, height, colorMap, interpolate,
+   out->drawImage(state, ref, str, width, height, , interpolate,
   haveColorKeyMask ? maskColors : (int *)NULL, inlineImg);
   }
 }
-delete colorMap;
 
 maskObj.free();
 smaskObj.free();
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2017-05-04 Thread Albert Astals Cid
 poppler/Gfx.cc |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

New commits:
commit cdab9a2dc27a10c84550db28fac8dbdcdcd4d29d
Author: Albert Astals Cid 
Date:   Fri May 5 00:47:45 2017 +0200

Move the bits sanity checking a bit higher in the function

Saves some time and makes the code simpler as we have to delete one
thing less

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 6f06f6ca..a2d1db0c 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4407,6 +4407,9 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
   }
 }
   } else {
+if (bits == 0) {
+  goto err1;
+}
 
 // get color space and color map
 dict->lookup("ColorSpace", );
@@ -4479,10 +4482,6 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
   obj1.free();
   dict->lookup("D", );
 }
-if (bits == 0) {
-  delete colorSpace;
-  goto err2;
-}
 colorMap = new GfxImageColorMap(bits, , colorSpace);
 obj1.free();
 if (!colorMap->isOk()) {
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2017-05-04 Thread Albert Astals Cid
 poppler/Gfx.cc |   13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 09000ce81397eba1eed383f730e48b92b932e0b4
Author: Albert Astals Cid 
Date:   Thu May 4 18:35:16 2017 +0200

Minor optimization

Do not create a timer for every single operation since we hardly run the
profileCommands if branch

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index a8f5be95..6f06f6ca 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -14,7 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2005 Jonathan Blandford 
-// Copyright (C) 2005-2013, 2015, 2016 Albert Astals Cid 
+// Copyright (C) 2005-2013, 2015-2017 Albert Astals Cid 
 // Copyright (C) 2006 Thorkild Stray 
 // Copyright (C) 2006 Kristian Høgsberg 
 // Copyright (C) 2006-2011 Carlos Garcia Campos 
@@ -757,13 +757,17 @@ void Gfx::go(GBool topLevel) {
printf("\n");
fflush(stdout);
   }
-  GooTimer timer;
+  GooTimer *timer = nullptr;
+
+  if (unlikely(profileCommands)) {
+  timer = new GooTimer();
+  }
 
   // Run the operation
   execOp(, args, numArgs);
 
   // Update the profile information
-  if (profileCommands) {
+  if (unlikely(profileCommands)) {
GooHash *hash;
 
hash = out->getProfileHash ();
@@ -778,8 +782,9 @@ void Gfx::go(GBool topLevel) {
hash->add (cmd_g, data_p);
  }
  
- data_p->addElement(timer.getElapsed ());
+ data_p->addElement(timer->getElapsed ());
}
+   delete timer;
   }
   obj.free();
   for (i = 0; i < numArgs; ++i)
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2016-11-09 Thread Albert Astals Cid
 poppler/Gfx.cc |1 +
 1 file changed, 1 insertion(+)

New commits:
commit b837ae3bc69c5c76f1a4e3abaeb22d0574d6b2c8
Author: Thomas Freitag 
Date:   Thu Nov 10 00:33:17 2016 +0100

Continue rendering in case of 'Singular matrix in shading pattern fill'

Bug #98623

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 7d748b9..a8f5be9 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2348,6 +2348,7 @@ void Gfx::doShadingPatternFill(GfxShadingPattern *sPat,
   det = ctm[0] * ctm[3] - ctm[1] * ctm[2];
   if (fabs(det) < 0.01) {
 error(errSyntaxError, getPos(), "Singular matrix in shading pattern fill");
+restoreStateStack(savedState);
 return;
   }
   det = 1 / det;
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2016-05-12 Thread Albert Astals Cid
 poppler/Gfx.cc |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 182abe4ed5c0773073c6751a26a7c4e40e99e02e
Author: Thomas Freitag 
Date:   Fri May 13 00:07:24 2016 +0200

Splash: type 3 chars. restore the current position also in output device

Bug #95344

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index cc6b66d..7d748b9 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4046,6 +4046,7 @@ void Gfx::doShowText(GooString *s) {
   curX += tdx;
   curY += tdy;
   state->moveTo(curX, curY);
+  out->updateCTM(state, 0, 0, 0, 0, 0, 0);
   p += n;
   len -= n;
 }
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc poppler/OutputDev.h poppler/SplashOutputDev.cc poppler/SplashOutputDev.h splash/Splash.cc splash/Splash.h splash/SplashState.cc splash/SplashState.h

2015-10-28 Thread Albert Astals Cid
 poppler/Gfx.cc |4 +++-
 poppler/OutputDev.h|4 +++-
 poppler/SplashOutputDev.cc |8 
 poppler/SplashOutputDev.h  |2 ++
 splash/Splash.cc   |   16 ++--
 splash/Splash.h|2 ++
 splash/SplashState.cc  |   11 ++-
 splash/SplashState.h   |5 -
 8 files changed, 46 insertions(+), 6 deletions(-)

New commits:
commit 3167964d70647d7b04e3ef8f415d5935990ecc9a
Author: Thomas Freitag 
Date:   Wed Oct 28 23:13:44 2015 +0100

Multiply opacity in case of pattern colorspace

Bug #92592

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 07d95b3..577c482 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -28,7 +28,7 @@
 // Copyright (C) 2008 Michael Vrable 
 // Copyright (C) 2008 Hib Eris 
 // Copyright (C) 2009 M Joonas Pihlaja 
-// Copyright (C) 2009-2014 Thomas Freitag 
+// Copyright (C) 2009-2015 Thomas Freitag 
 // Copyright (C) 2009 William Bader 
 // Copyright (C) 2009, 2010 David Benjamin 
 // Copyright (C) 2010 Nils Höglund 
@@ -2283,6 +2283,7 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat,
   xi0, yi0, xi1, yi1, xstep, ystep)) {
 goto restore;
   } else {
+out->updatePatternOpacity(state);
 for (yi = yi0; yi < yi1; ++yi) {
   for (xi = xi0; xi < xi1; ++xi) {
 x = xi * xstep;
@@ -2293,6 +2294,7 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat,
  m1, tPat->getBBox());
   }
 }
+out->clearPatternOpacity(state);
   }
 
   // restore graphics state
diff --git a/poppler/OutputDev.h b/poppler/OutputDev.h
index e8a7a47..a15d56b 100644
--- a/poppler/OutputDev.h
+++ b/poppler/OutputDev.h
@@ -17,7 +17,7 @@
 // Copyright (C) 2006 Thorkild Stray 
 // Copyright (C) 2007 Jeff Muizelaar 
 // Copyright (C) 2007, 2011 Adrian Johnson 
-// Copyright (C) 2009-2013 Thomas Freitag 
+// Copyright (C) 2009-2013, 2015 Thomas Freitag 
 // Copyright (C) 2009, 2011 Carlos Garcia Campos 
 // Copyright (C) 2009, 2012, 2013 Albert Astals Cid 
 // Copyright (C) 2010 Christian Feuersänger 
@@ -185,6 +185,8 @@ public:
   virtual void updateBlendMode(GfxState * /*state*/) {}
   virtual void updateFillOpacity(GfxState * /*state*/) {}
   virtual void updateStrokeOpacity(GfxState * /*state*/) {}
+  virtual void updatePatternOpacity(GfxState * /*state*/) {}
+  virtual void clearPatternOpacity(GfxState * /*state*/) {}
   virtual void updateFillOverprint(GfxState * /*state*/) {}
   virtual void updateStrokeOverprint(GfxState * /*state*/) {}
   virtual void updateOverprintMode(GfxState * /*state*/) {}
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 6d41616..d2827d1 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -1842,6 +1842,14 @@ void SplashOutputDev::updateStrokeOpacity(GfxState 
*state) {
   }
 }
 
+void SplashOutputDev::updatePatternOpacity(GfxState *state) {
+  splash->setPatternAlpha((SplashCoord)state->getStrokeOpacity(), 
(SplashCoord)state->getFillOpacity());
+}
+
+void SplashOutputDev::clearPatternOpacity(GfxState *state) {
+  splash->clearPatternAlpha();
+}
+
 void SplashOutputDev::updateFillOverprint(GfxState *state) {
   splash->setFillOverprint(state->getFillOverprint());
 }
diff --git a/poppler/SplashOutputDev.h b/poppler/SplashOutputDev.h
index d34426c..ce4082f 100644
--- a/poppler/SplashOutputDev.h
+++ b/poppler/SplashOutputDev.h
@@ -231,6 +231,8 @@ public:
   virtual void updateBlendMode(GfxState *state);
   virtual void updateFillOpacity(GfxState *state);
   virtual void updateStrokeOpacity(GfxState *state);
+  virtual void updatePatternOpacity(GfxState *state);
+  virtual void clearPatternOpacity(GfxState *state);
   virtual void updateFillOverprint(GfxState *state);
   virtual void updateStrokeOverprint(GfxState *state);
   virtual void updateOverprintMode(GfxState *state);
diff --git a/splash/Splash.cc b/splash/Splash.cc
index 7453822..5bc7767 100644
--- a/splash/Splash.cc
+++ b/splash/Splash.cc
@@ -1752,11 +1752,23 @@ void Splash::setBlendFunc(SplashBlendFunc func) {
 }
 
 void Splash::setStrokeAlpha(SplashCoord alpha) {
-  state->strokeAlpha = alpha;
+  state->strokeAlpha = (state->multiplyPatternAlpha) ? alpha *  
state->patternStrokeAlpha : alpha;
 }
 
 void Splash::setFillAlpha(SplashCoord alpha) {
-  state->fillAlpha = alpha;
+  state->fillAlpha = (state->multiplyPatternAlpha) ? alpha *  
state->patternFillAlpha : alpha;
+}
+
+void Splash::setPatternAlpha(SplashCoord strokeAlpha, SplashCoord fillAlpha) {
+  state->patternStrokeAlpha = strokeAlpha;
+  state->patternFillAlpha = fillAlpha;
+  

[poppler] poppler/Gfx.cc

2014-09-30 Thread Albert Astals Cid
 poppler/Gfx.cc |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit ce95ecda450361496aedd5d5cd0bf47fd2c66703
Author: Albert Astals Cid aa...@kde.org
Date:   Tue Sep 30 19:50:20 2014 +0200

Fix assert in 5068.asan.0.6052.pdf

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 90bf41e..6bf7ec5 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -980,7 +980,10 @@ void Gfx::opSetDash(Object args[], int numArgs) {
   } else {
 dash = (double *)gmallocn(length, sizeof(double));
 for (i = 0; i  length; ++i) {
-  dash[i] = a-get(i, obj)-getNum();
+  a-get(i, obj);
+  if (obj.isNum()) {
+   dash[i] = obj.getNum();
+  }
   obj.free();
 }
   }
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2012-12-13 Thread Albert Astals Cid
 poppler/Gfx.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 487f20d24830a97cad4773ae27f0c2cc58df2ed0
Author: Albert Astals Cid aa...@kde.org
Date:   Thu Dec 13 20:40:39 2012 +0100

Check obj1 is a dict before using it

Fixes bug #58257

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 99c326e..5c9ed35 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4601,7 +4601,7 @@ GBool Gfx::checkTransparencyGroup(Dict *resDict) {
   Object obj1, obj2;
   GfxBlendMode mode;
 
-  if (res-lookupGState(dict-getKey(i), obj1)) {
+  if (res-lookupGState(dict-getKey(i), obj1)  obj1.isDict()) {
 if (!obj1.dictLookup(BM, obj2)-isNull()) {
   if (state-parseBlendMode(obj2, mode)) {
 if (mode != gfxBlendNormal)
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2012-09-21 Thread Albert Astals Cid
 poppler/Gfx.cc |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit ca6afce24aac2ef9d88e215177b11760f7468a6d
Author: Lu Wang coolwan...@gmail.com
Date:   Fri Sep 21 21:33:05 2012 +0200

Do not call drawing routines if we don't need non text

Bug #54617

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 4e663b4..8ee2026 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -36,6 +36,7 @@
 // Copyright (C) 2011 Axel Strübing axel.strueb...@freenet.de
 // Copyright (C) 2012 Even Rouault even.roua...@mines-paris.org
 // Copyright (C) 2012 Fabio D'Urso fabiodu...@hotmail.it
+// Copyright (C) 2012 Lu Wang coolwan...@gmail.com
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -4285,7 +4286,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
 obj1.free();
 
 // if drawing is disabled, skip over inline image data
-if (!ocState) {
+if (!ocState || !out-needNonText()) {
   str-reset();
   n = height * ((width + 7) / 8);
   for (i = 0; i  n; ++i) {
@@ -4544,7 +4545,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
 }
 
 // if drawing is disabled, skip over inline image data
-if (!ocState) {
+if (!ocState || !out-needNonText()) {
   str-reset();
   n = height * ((width * colorMap-getNumPixelComps() *
 colorMap-getBits() + 7) / 8);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc poppler/Gfx.h poppler/GfxState.cc poppler/OutputDev.h poppler/SplashOutputDev.cc poppler/SplashOutputDev.h

2012-05-13 Thread Albert Astals Cid
 poppler/Gfx.cc |   64 -
 poppler/Gfx.h  |4 ++
 poppler/GfxState.cc|4 ++
 poppler/OutputDev.h|1 
 poppler/SplashOutputDev.cc |   11 +++
 poppler/SplashOutputDev.h  |1 
 6 files changed, 82 insertions(+), 3 deletions(-)

New commits:
commit b477443e8a4c52500529aaf3be76f01a61e85f28
Author: Thomas Freitag thomas.frei...@alfa.de
Date:   Sun May 13 17:25:15 2012 +0200

remove unnecesary transparency group handling in splash

Bug #13487

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 9c2a9d8..5c788fb 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4580,6 +4580,68 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
   error(errSyntaxError, getPos(), Bad image parameters);
 }
 
+GBool Gfx::checkTransparencyGroup(Dict *resDict) {
+  // check the effect of compositing objects as a group:
+  // look for ExtGState entries with ca != 1 or CA != 1 or BM != normal
+  Object extGStates;
+  GBool transpGroup = gFalse;
+  double opac;
+
+  if (resDict == NULL)
+return gFalse;
+  pushResources(resDict);
+  resDict-lookup(ExtGState, extGStates);
+  if (extGStates.isDict()) {
+Dict *dict = extGStates.getDict();
+for (int i = 0; i  dict-getLength()  !transpGroup; i++) {
+  Object obj1, obj2;
+  GfxBlendMode mode;
+
+  if (res-lookupGState(dict-getKey(i), obj1)) {
+if (!obj1.dictLookup(BM, obj2)-isNull()) {
+  if (state-parseBlendMode(obj2, mode)) {
+if (mode != gfxBlendNormal)
+  transpGroup = gTrue;
+  } else {
+error(errSyntaxError, getPos(), Invalid blend mode in ExtGState);
+  }
+}
+obj2.free();
+if (obj1.dictLookup(ca, obj2)-isNum()) {
+  opac = obj2.getNum();
+  opac = opac  0 ? 0 : opac  1 ? 1 : opac;
+  if (opac != 1)
+transpGroup = gTrue;
+}
+obj2.free();
+if (obj1.dictLookup(CA, obj2)-isNum()) {
+  opac = obj2.getNum();
+  opac = opac  0 ? 0 : opac  1 ? 1 : opac;
+  if (opac != 1)
+transpGroup = gTrue;
+}
+obj2.free();
+// alpha is shape
+if (!transpGroup  obj1.dictLookup(AIS, obj2)-isBool()) {
+  transpGroup = obj2.getBool();
+}
+obj2.free();
+// soft mask
+if (!transpGroup  !obj1.dictLookup(SMask, obj2)-isNull()) {
+  if (!obj2.isName(None)) {
+transpGroup = gTrue;
+  }
+}
+obj2.free();
+  }
+  obj1.free();
+}
+  }
+  extGStates.free();
+  popResources();
+  return transpGroup;
+}
+
 void Gfx::doForm(Object *str) {
   Dict *dict;
   GBool transpGroup, isolated, knockout;
@@ -4666,7 +4728,6 @@ void Gfx::doForm(Object *str) {
   blendingColorSpace = NULL;
   if (dict-lookup(Group, obj1)-isDict()) {
 if (obj1.dictLookup(S, obj2)-isName(Transparency)) {
-  transpGroup = gTrue;
   if (!obj1.dictLookup(CS, obj3)-isNull()) {
blendingColorSpace = GfxColorSpace::parse(obj3, this);
   }
@@ -4679,6 +4740,7 @@ void Gfx::doForm(Object *str) {
knockout = obj3.getBool();
   }
   obj3.free();
+  transpGroup = isolated || out-checkTransparencyGroup(state, knockout) 
|| checkTransparencyGroup(resDict);
 }
 obj2.free();
   }
diff --git a/poppler/Gfx.h b/poppler/Gfx.h
index 689d362..37022e0 100644
--- a/poppler/Gfx.h
+++ b/poppler/Gfx.h
@@ -18,7 +18,7 @@
 // Copyright (C) 2008 Brad Hards br...@kde.org
 // Copyright (C) 2008, 2010 Carlos Garcia Campos carlo...@gnome.org
 // Copyright (C) 2009-2011 Albert Astals Cid aa...@kde.org
-// Copyright (C) 2009, 2010 Thomas Freitag thomas.frei...@alfa.de
+// Copyright (C) 2009, 2010, 2012 Thomas Freitag thomas.frei...@alfa.de
 // Copyright (C) 2010 David Benjamin david...@mit.edu
 // Copyright (C) 2010 Christian Feuersänger cfeuersaen...@googlemail.com
 //
@@ -181,6 +181,8 @@ public:
   // Get the current graphics state object.
   GfxState *getState() { return state; }
 
+  GBool checkTransparencyGroup(Dict *resDict);
+
   void drawForm(Object *str, Dict *resDict, double *matrix, double *bbox,
   GBool transpGroup = gFalse, GBool softMask = gFalse,
   GfxColorSpace *blendingColorSpace = NULL,
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index f6fa5d0..e3413e5 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -18,7 +18,7 @@
 // Copyright (C) 2006, 2010 Carlos Garcia Campos carlo...@gnome.org
 // Copyright (C) 2006-2012 Albert Astals Cid aa...@kde.org
 // Copyright (C) 2009, 2012 Koji Otani s...@bbr.jp
-// Copyright (C) 2009, 2011 Thomas Freitag thomas.frei...@alfa.de
+// Copyright (C) 2009, 2011, 2012 Thomas Freitag thomas.frei...@alfa.de
 // Copyright (C) 2009 Christian Persch c...@gnome.org
 // Copyright (C) 2010 Paweł Wiejacha pawel.wieja...@gmail.com
 // Copyright (C) 2010 Christian Feuersänger cfeuersaen...@googlemail.com

[poppler] poppler/Gfx.cc poppler/OutputDev.cc poppler/OutputDev.h

2012-05-10 Thread Albert Astals Cid
 poppler/Gfx.cc   |8 
 poppler/OutputDev.cc |8 +++-
 poppler/OutputDev.h  |4 +++-
 3 files changed, 18 insertions(+), 2 deletions(-)

New commits:
commit df05d084cb26807c39695280cd8ea52d13aa1255
Author: Albert Astals Cid aa...@kde.org
Date:   Thu May 10 20:54:13 2012 +0200

Bring back the begin/endMarkedContent virtuals

For those evil people that keep using poppler internals

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 827bbed..9c2a9d8 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4996,6 +4996,12 @@ void Gfx::opBeginMarkedContent(Object args[], int 
numArgs) {
 fflush(stdout);
   }
   ocState = !contentIsHidden();
+  
+  if (numArgs == 2  args[1].isDict()) {
+out-beginMarkedContent(args[0].getName(), args[1].getDict());
+  } else if(numArgs == 1) {
+out-beginMarkedContent(args[0].getName(), NULL);
+  }
 }
 
 void Gfx::opEndMarkedContent(Object args[], int numArgs) {
@@ -5013,6 +5019,8 @@ void Gfx::opEndMarkedContent(Object args[], int numArgs) {
   if (mcKind == gfxMCActualText)
 out-endActualText(state);
   ocState = !contentIsHidden();
+  
+  out-endMarkedContent(state);
 }
 
 void Gfx::opMarkPoint(Object args[], int numArgs) {
diff --git a/poppler/OutputDev.cc b/poppler/OutputDev.cc
index c52f611..54580d0 100644
--- a/poppler/OutputDev.cc
+++ b/poppler/OutputDev.cc
@@ -17,7 +17,7 @@
 // Copyright (C) 2006 Thorkild Stray thork...@ifi.uio.no
 // Copyright (C) 2007 Adrian Johnson ajohn...@redneon.com
 // Copyright (C) 2009 Carlos Garcia Campos carlo...@gnome.org
-// Copyright (C) 2009 Albert Astals Cid aa...@kde.org
+// Copyright (C) 2009, 2012 Albert Astals Cid aa...@kde.org
 // Copyright (C) 2012 Thomas Freitag thomas.frei...@alfa.de
 //
 // To see a description of the changes please see the Changelog file that
@@ -157,6 +157,12 @@ void OutputDev::drawSoftMaskedImage(GfxState *state, 
Object *ref, Stream *str,
   drawImage(state, ref, str, width, height, colorMap, interpolate, NULL, 
gFalse);
 }
 
+void OutputDev::endMarkedContent(GfxState *state) {
+}
+
+void OutputDev::beginMarkedContent(char *name, Dict *properties) {
+}
+
 void OutputDev::markPoint(char *name) {
 }
 
diff --git a/poppler/OutputDev.h b/poppler/OutputDev.h
index 803d922..855dbaf 100644
--- a/poppler/OutputDev.h
+++ b/poppler/OutputDev.h
@@ -19,7 +19,7 @@
 // Copyright (C) 2007, 2011 Adrian Johnson ajohn...@redneon.com
 // Copyright (C) 2009-2012 Thomas Freitag thomas.frei...@alfa.de
 // Copyright (C) 2009, 2011 Carlos Garcia Campos carlo...@gnome.org
-// Copyright (C) 2009 Albert Astals Cid aa...@kde.org
+// Copyright (C) 2009, 2012 Albert Astals Cid aa...@kde.org
 // Copyright (C) 2010 Christian Feuersänger cfeuersaen...@googlemail.com
 // Copyright (C) 2012 Fabio D'Urso fabiodu...@hotmail.it
 //
@@ -272,6 +272,8 @@ public:
 
   //- grouping operators
 
+  virtual void endMarkedContent(GfxState *state);
+  virtual void beginMarkedContent(char *name, Dict *properties);
   virtual void markPoint(char *name);
   virtual void markPoint(char *name, Dict *properties);
 
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2011-11-24 Thread Albert Astals Cid
 poppler/Gfx.cc |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit bdb439ac5a751d6146204ae0d61fdbf7828c89c3
Author: Axel Strübing axel.strueb...@freenet.de
Date:   Thu Nov 24 22:32:57 2011 +0100

Fix typo/regression introduced in f6d026bfa18624ccd321e102bb39ba744998de1e

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 2f481f0..1667460 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -33,6 +33,7 @@
 // Copyright (C) 2009, 2010 David Benjamin david...@mit.edu
 // Copyright (C) 2010 Nils Höglund nils.hogl...@gmail.com
 // Copyright (C) 2010 Christian Feuersänger cfeuersaen...@googlemail.com
+// Copyright (C) 2011 Axel Strübing axel.strueb...@freenet.de
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -1453,7 +1454,7 @@ void Gfx::opSetFillRGBColor(Object args[], int numArgs) {
   }
   state-setFillPattern(NULL);
   res-lookupColorSpace(DefaultRGB, obj);
-  if (obj.isNull()) {
+  if (!obj.isNull()) {
 colorSpace = GfxColorSpace::parse(obj, this);
   }
   if (colorSpace == NULL) {
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2011-11-11 Thread Albert Astals Cid
 poppler/Gfx.cc |   52 +---
 1 file changed, 29 insertions(+), 23 deletions(-)

New commits:
commit f6d026bfa18624ccd321e102bb39ba744998de1e
Author: Albert Astals Cid aa...@kde.org
Date:   Fri Nov 11 16:37:27 2011 +0100

Do not crash if failing to parse the colorspace

Fixes bug 42793

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index bca60e2..2f481f0 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -1319,7 +1319,7 @@ void Gfx::opSetRenderingIntent(Object args[], int 
numArgs) {
 
 void Gfx::opSetFillGray(Object args[], int numArgs) {
   GfxColor color;
-  GfxColorSpace *colorSpace;
+  GfxColorSpace *colorSpace = NULL;
   Object obj;
 
   if (textHaveCSPattern  drawText) {
@@ -1332,11 +1332,12 @@ void Gfx::opSetFillGray(Object args[], int numArgs) {
   }
   state-setFillPattern(NULL);
   res-lookupColorSpace(DefaultGray, obj);
-  if (obj.isNull()) {
-colorSpace = new GfxDeviceGrayColorSpace();
-  } else {
+  if (!obj.isNull()) {
 colorSpace = GfxColorSpace::parse(obj, this);
   }
+  if (colorSpace == NULL) {
+colorSpace = new GfxDeviceGrayColorSpace();
+  }
   obj.free();
   state-setFillColorSpace(colorSpace);
   out-updateFillColorSpace(state);
@@ -1354,16 +1355,17 @@ void Gfx::opSetFillGray(Object args[], int numArgs) {
 
 void Gfx::opSetStrokeGray(Object args[], int numArgs) {
   GfxColor color;
-  GfxColorSpace *colorSpace;
+  GfxColorSpace *colorSpace = NULL;
   Object obj;
 
   state-setStrokePattern(NULL);
   res-lookupColorSpace(DefaultGray, obj);
-  if (obj.isNull()) {
-colorSpace = new GfxDeviceGrayColorSpace();
-  } else {
+  if (!obj.isNull()) {
 colorSpace = GfxColorSpace::parse(obj, this);
   }
+  if (colorSpace == NULL) {
+colorSpace = new GfxDeviceGrayColorSpace();
+  }
   obj.free();
   state-setStrokeColorSpace(colorSpace);
   out-updateStrokeColorSpace(state);
@@ -1374,7 +1376,7 @@ void Gfx::opSetStrokeGray(Object args[], int numArgs) {
 
 void Gfx::opSetFillCMYKColor(Object args[], int numArgs) {
   GfxColor color;
-  GfxColorSpace *colorSpace;
+  GfxColorSpace *colorSpace = NULL;
   Object obj;
   int i;
 
@@ -1387,11 +1389,12 @@ void Gfx::opSetFillCMYKColor(Object args[], int 
numArgs) {
 out-restoreState(state);
   }
   res-lookupColorSpace(DefaultCMYK, obj);
-  if (obj.isNull()) {
-colorSpace = new GfxDeviceCMYKColorSpace();
-  } else {
+  if (!obj.isNull()) {
 colorSpace = GfxColorSpace::parse(obj, this);
   }
+  if (colorSpace == NULL) {
+colorSpace = new GfxDeviceCMYKColorSpace();
+  }
   obj.free();
   state-setFillPattern(NULL);
   state-setFillColorSpace(colorSpace);
@@ -1412,17 +1415,18 @@ void Gfx::opSetFillCMYKColor(Object args[], int 
numArgs) {
 
 void Gfx::opSetStrokeCMYKColor(Object args[], int numArgs) {
   GfxColor color;
-  GfxColorSpace *colorSpace;
+  GfxColorSpace *colorSpace = NULL;
   Object obj;
   int i;
 
   state-setStrokePattern(NULL);
   res-lookupColorSpace(DefaultCMYK, obj);
-  if (obj.isNull()) {
-colorSpace = new GfxDeviceCMYKColorSpace();
-  } else {
+  if (!obj.isNull()) {
 colorSpace = GfxColorSpace::parse(obj, this);
   }
+  if (colorSpace == NULL) {
+colorSpace = new GfxDeviceCMYKColorSpace();
+  }
   obj.free();
   state-setStrokeColorSpace(colorSpace);
   out-updateStrokeColorSpace(state);
@@ -1435,7 +1439,7 @@ void Gfx::opSetStrokeCMYKColor(Object args[], int 
numArgs) {
 
 void Gfx::opSetFillRGBColor(Object args[], int numArgs) {
   Object obj;
-  GfxColorSpace *colorSpace;
+  GfxColorSpace *colorSpace = NULL;
   GfxColor color;
   int i;
 
@@ -1450,10 +1454,11 @@ void Gfx::opSetFillRGBColor(Object args[], int numArgs) 
{
   state-setFillPattern(NULL);
   res-lookupColorSpace(DefaultRGB, obj);
   if (obj.isNull()) {
-colorSpace = new GfxDeviceRGBColorSpace();
-  } else {
 colorSpace = GfxColorSpace::parse(obj, this);
   }
+  if (colorSpace == NULL) {
+colorSpace = new GfxDeviceRGBColorSpace();
+  }
   obj.free();
   state-setFillColorSpace(colorSpace);
   out-updateFillColorSpace(state);
@@ -1473,17 +1478,18 @@ void Gfx::opSetFillRGBColor(Object args[], int numArgs) 
{
 
 void Gfx::opSetStrokeRGBColor(Object args[], int numArgs) {
   Object obj;
-  GfxColorSpace *colorSpace;
+  GfxColorSpace *colorSpace = NULL;
   GfxColor color;
   int i;
 
   state-setStrokePattern(NULL);
   res-lookupColorSpace(DefaultRGB, obj);
-  if (obj.isNull()) {
-colorSpace = new GfxDeviceRGBColorSpace();
-  } else {
+  if (!obj.isNull()) {
 colorSpace = GfxColorSpace::parse(obj, this);
   }
+  if (colorSpace == NULL) {
+colorSpace = new GfxDeviceRGBColorSpace();
+  }
   obj.free();
   state-setStrokeColorSpace(colorSpace);
   out-updateStrokeColorSpace(state);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2011-09-26 Thread Albert Astals Cid
 poppler/Gfx.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 19f5db7acd64330d198f18695175df02141794d7
Author: Albert Astals Cid aa...@kde.org
Date:   Tue Sep 27 00:15:15 2011 +0200

Update Carlos (C) year

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 92c66a3..bca60e2 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -17,7 +17,7 @@
 // Copyright (C) 2005-2010 Albert Astals Cid aa...@kde.org
 // Copyright (C) 2006 Thorkild Stray thork...@ifi.uio.no
 // Copyright (C) 2006 Kristian Høgsberg k...@redhat.com
-// Copyright (C) 2006-2010 Carlos Garcia Campos carlo...@gnome.org
+// Copyright (C) 2006-2011 Carlos Garcia Campos carlo...@gnome.org
 // Copyright (C) 2006, 2007 Jeff Muizelaar j...@infidigm.net
 // Copyright (C) 2007, 2008 Brad Hards br...@kde.org
 // Copyright (C) 2007, 2011 Adrian Johnson ajohn...@redneon.com
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2010-12-23 Thread Albert Astals Cid
 poppler/Gfx.cc |   25 -
 1 file changed, 16 insertions(+), 9 deletions(-)

New commits:
commit 0294d6e50691a3e40fad0d6e4fa9056944a91efd
Author: Thomas Freitag thomas.frei...@alfa.de
Date:   Thu Dec 23 15:56:32 2010 +

Be more correct when drawing radial shadings

Fixes 32349

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 6b80e90..09c5381 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2924,17 +2924,24 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) {
 tb = t0 + sb * (t1 - t0);
 getShadingColorRadialHelper(t0, t1, tb, shading, colorB);
 while (ib - ia  1) {
-  if (isSameGfxColor(colorB, colorA, nComps, radialColorDelta)  ib  
radialMaxSplits) {
+  if (isSameGfxColor(colorB, colorA, nComps, radialColorDelta)) {
 // The shading is not necessarily lineal so having two points with the
 // same color does not mean all the areas in between have the same 
color too
-// Do another bisection to be a bit more sure we are not doing 
something wrong
-GfxColor colorC;
-int ic = (ia + ib) / 2;
-double sc = sMin + ((double)ic / (double)radialMaxSplits) * (sMax - 
sMin);
-double tc = t0 + sc * (t1 - t0);
-getShadingColorRadialHelper(t0, t1, tc, shading, colorC);
-if (isSameGfxColor(colorC, colorA, nComps, radialColorDelta))
-  break;
+int ic = ia + 1;
+for (; ic = ib; ic++) {
+  GfxColor colorC;
+  const double sc = sMin + ((double)ic / (double)radialMaxSplits) * 
(sMax - sMin);
+  const double tc = t0 + sc * (t1 - t0);
+  getShadingColorRadialHelper(t0, t1, tc, shading, colorC);
+  if (!isSameGfxColor(colorC, colorA, nComps, radialColorDelta)) {
+break;
+  }
+}
+ib = (ic  ia + 1) ? ic - 1 : ia + 1;
+sb = sMin + ((double)ib / (double)radialMaxSplits) * (sMax - sMin);
+tb = t0 + sb * (t1 - t0);
+getShadingColorRadialHelper(t0, t1, tb, shading, colorB);
+break;
   }
   ib = (ia + ib) / 2;
   sb = sMin + ((double)ib / (double)radialMaxSplits) * (sMax - sMin);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2010-10-23 Thread Albert Astals Cid
 poppler/Gfx.cc |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit bcb13ed5828e2a855efd5e38b2acd15ca37a9991
Author: Albert Astals Cid aa...@kde.org
Date:   Sat Oct 23 22:40:17 2010 +0100

Check obj2 is a num before reading it

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 12c0bd2..d11845c 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -1261,7 +1261,13 @@ void Gfx::doSoftMask(Object *str, GBool alpha,
   }
   for (i = 0; i  4; ++i) {
 obj1.arrayGet(i, obj2);
-bbox[i] = obj2.getNum();
+if (likely(obj2.isNum())) bbox[i] = obj2.getNum();
+else {
+  obj2.free();
+  obj1.free();
+  error(getPos(), Bad form bounding box (non number));
+  return;
+}
 obj2.free();
   }
   obj1.free();
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2010-10-13 Thread Albert Astals Cid
 poppler/Gfx.cc |   38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

New commits:
commit de1501d87549269f9214c9e3fba4cbf39960826e
Author: Albert Astals Cid aa...@kde.org
Date:   Wed Oct 13 19:18:36 2010 +0100

remove windows eol

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index ed9accc..4f4510a 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -1262,8 +1262,8 @@ void Gfx::doSoftMask(Object *str, GBool alpha,
   if (obj1.isArray()) {
 for (i = 0; i  6; ++i) {
   obj1.arrayGet(i, obj2);
-  if (likely(obj2.isNum())) m[i] = obj2.getNum();
-  else m[i] = 0;
+  if (likely(obj2.isNum())) m[i] = obj2.getNum();
+  else m[i] = 0;
   obj2.free();
 }
   } else {
@@ -3400,21 +3400,21 @@ void Gfx::opSetTextLeading(Object args[], int numArgs) {
 void Gfx::opSetTextRender(Object args[], int numArgs) {
   int rm = state-getRender();
   state-setRender(args[0].getInt());
-  if ((args[0].getInt()  4)  textHaveCSPattern  drawText) {
-GBool needFill = out-deviceHasTextClip(state);
-out-endTextObject(state);
-if (needFill) {
-  doPatternFill(gTrue);
-}
-out-restoreState(state);
-out-beginTextObject(state);
-out-updateTextMat(state);
-out-updateTextPos(state);
-textHaveCSPattern = gFalse;
-  } else if ((rm  4)  !(args[0].getInt()  4)  
out-supportTextCSPattern(state)  drawText) {
-   out-beginTextObject(state);
-textHaveCSPattern = gTrue;
-  }
+  if ((args[0].getInt()  4)  textHaveCSPattern  drawText) {
+GBool needFill = out-deviceHasTextClip(state);
+out-endTextObject(state);
+if (needFill) {
+  doPatternFill(gTrue);
+}
+out-restoreState(state);
+out-beginTextObject(state);
+out-updateTextMat(state);
+out-updateTextPos(state);
+textHaveCSPattern = gFalse;
+  } else if ((rm  4)  !(args[0].getInt()  4)  
out-supportTextCSPattern(state)  drawText) {
+   out-beginTextObject(state);
+textHaveCSPattern = gTrue;
+  }
   out-updateRender(state);
 }
 
@@ -4265,8 +4265,8 @@ void Gfx::doForm(Object *str) {
   if (matrixObj.isArray()) {
 for (i = 0; i  6; ++i) {
   matrixObj.arrayGet(i, obj1);
-  if (likely(obj1.isNum())) m[i] = obj1.getNum();
-  else m[i] = 0;
+  if (likely(obj1.isNum())) m[i] = obj1.getNum();
+  else m[i] = 0;
   obj1.free();
 }
   } else {
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2010-10-05 Thread Albert Astals Cid
 poppler/Gfx.cc |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit d690bea929553d1a4392d42d949843e9467ba8cb
Author: Albert Astals Cid aa...@kde.org
Date:   Tue Oct 5 22:18:22 2010 +0100

Make sure obj is a num before reading it

Not sure if using a 0 is correct otherwise, but if your matrix is
broken you're probably going to get a wrong rendering anyway, so who
cares. Bug #30590

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 7552fed..ed9accc 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -1262,7 +1262,8 @@ void Gfx::doSoftMask(Object *str, GBool alpha,
   if (obj1.isArray()) {
 for (i = 0; i  6; ++i) {
   obj1.arrayGet(i, obj2);
-  m[i] = obj2.getNum();
+  if (likely(obj2.isNum())) m[i] = obj2.getNum();
+  else m[i] = 0;
   obj2.free();
 }
   } else {
@@ -4264,7 +4265,8 @@ void Gfx::doForm(Object *str) {
   if (matrixObj.isArray()) {
 for (i = 0; i  6; ++i) {
   matrixObj.arrayGet(i, obj1);
-  m[i] = obj1.getNum();
+  if (likely(obj1.isNum())) m[i] = obj1.getNum();
+  else m[i] = 0;
   obj1.free();
 }
   } else {
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2010-04-29 Thread Carlos Garcia Campos
 poppler/Gfx.cc |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit e909219d8e92994bd52976f9676015fa6ca9fc91
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Thu Apr 29 18:34:22 2010 +0200

Set textHaveCSPattern=false again before filling the pattern in opEndText()

Fixes cairo backend regressions caused by commit
ccf238b32e236f69c0507a5421ac2649dfa8d865.

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 6259733..de4eb24 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -3341,13 +3341,13 @@ void Gfx::opEndText(Object args[], int numArgs) {
   GBool needFill = out-deviceHasTextClip(state);
   out-endTextObject(state);
   drawText = gFalse;
-  if (out-supportTextCSPattern(state)  textHaveCSPattern) {
+  if (textHaveCSPattern) {
+textHaveCSPattern = gFalse;
 if (needFill) {
   doPatternFill(gTrue);
 }
 out-restoreState(state);
   }
-  textHaveCSPattern = gFalse;
 }
 
 //
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2010-04-29 Thread Carlos Garcia Campos
 poppler/Gfx.cc |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 71063d51a45835b0267a7e3f823ef49689cfd06f
Author: Carlos Garcia Campos carlo...@gnome.org
Date:   Thu Apr 29 20:28:07 2010 +0200

Make sure we are drawing text before calling endTextObject()

This is actually the right fix for the previous commit.

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index de4eb24..221caef 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -1297,7 +1297,7 @@ void Gfx::opSetRenderingIntent(Object args[], int 
numArgs) {
 void Gfx::opSetFillGray(Object args[], int numArgs) {
   GfxColor color;
 
-  if (textHaveCSPattern) {
+  if (textHaveCSPattern  drawText) {
 GBool needFill = out-deviceHasTextClip(state);
 out-endTextObject(state);
 if (needFill) {
@@ -1335,7 +1335,7 @@ void Gfx::opSetFillCMYKColor(Object args[], int numArgs) {
   GfxColor color;
   int i;
 
-  if (textHaveCSPattern) {
+  if (textHaveCSPattern  drawText) {
 GBool needFill = out-deviceHasTextClip(state);
 out-endTextObject(state);
 if (needFill) {
@@ -1378,7 +1378,7 @@ void Gfx::opSetFillRGBColor(Object args[], int numArgs) {
   GfxColor color;
   int i;
 
-  if (textHaveCSPattern) {
+  if (textHaveCSPattern  drawText) {
 GBool needFill = out-deviceHasTextClip(state);
 out-endTextObject(state);
 if (needFill) {
@@ -1430,7 +1430,7 @@ void Gfx::opSetFillColorSpace(Object args[], int numArgs) 
{
   }
   obj.free();
   if (colorSpace) {
-if (textHaveCSPattern) {
+if (textHaveCSPattern  drawText) {
   GBool needFill = out-deviceHasTextClip(state);
   out-endTextObject(state);
   if (needFill) {
@@ -3342,12 +3342,12 @@ void Gfx::opEndText(Object args[], int numArgs) {
   out-endTextObject(state);
   drawText = gFalse;
   if (textHaveCSPattern) {
-textHaveCSPattern = gFalse;
 if (needFill) {
   doPatternFill(gTrue);
 }
 out-restoreState(state);
   }
+  textHaveCSPattern = gFalse;
 }
 
 //
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2010-02-24 Thread Albert Astals Cid
 poppler/Gfx.cc |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 8e354a15a1861719c00799937ad9f9bb1bb71e9f
Author: Thomas Freitag thomas.frei...@alfa.de
Date:   Wed Feb 24 18:58:11 2010 +

Fix remaining part of 26243

Thomas says: The gn is colored with a shading pattern, but the shading 
has a bbox,
so it is clipped to this bbox, too. But when coloring text or masks in
pattern colorspace, this is definely wrong.

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 9000237..85d657b 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2101,7 +2101,8 @@ void Gfx::doShadingPatternFill(GfxShadingPattern *sPat,
 state-lineTo(xMin, yMax);
 state-closePath();
 state-clip();
-out-clip(state);
+if (!textHaveCSPattern  !maskHaveCSPattern)
+  out-clip(state);
 state-setPath(savedPath-copy());
   }
 
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] 3 commits - goo/Makefile.am msvc/config.h msvc/poppler poppler/Gfx.cc poppler/PopplerCache.cc poppler/PopplerCache.h

2010-01-24 Thread Albert Astals Cid
 goo/Makefile.am   |1 
 msvc/config.h |   62 -
 msvc/poppler/poppler-config.h |   77 --
 poppler/Gfx.cc|   14 ---
 poppler/PopplerCache.cc   |   12 +++---
 poppler/PopplerCache.h|6 +--
 6 files changed, 18 insertions(+), 154 deletions(-)

New commits:
commit 8672217af4cf88d5506572c2b40fbb0d1d0dbd87
Author: Albert Astals Cid aa...@kde.org
Date:   Mon Jan 25 00:11:50 2010 +

Make the poppler object cache params be a ref

And make sure what we was is a ref, otherwise we abort

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index f6b23d5..a8713a4 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -14,7 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2005 Jonathan Blandford j...@redhat.com
-// Copyright (C) 2005-2009 Albert Astals Cid aa...@kde.org
+// Copyright (C) 2005-2010 Albert Astals Cid aa...@kde.org
 // Copyright (C) 2006 Thorkild Stray thork...@ifi.uio.no
 // Copyright (C) 2006 Kristian Høgsberg k...@redhat.com
 // Copyright (C) 2006-2010 Carlos Garcia Campos carlo...@gnome.org
@@ -481,16 +481,18 @@ GfxShading *GfxResources::lookupShading(char *name, Gfx 
*gfx) {
 }
 
 GBool GfxResources::lookupGState(char *name, Object *obj) {
-  Object objRef;
-
-  if (!lookupGStateNF(name, objRef))
+  if (!lookupGStateNF(name, obj))
 return gFalse;
 
-  if (!gStateCache.lookup(objRef, obj)-isNull())
+  if (!obj-isRef())
+return gTrue;
+  
+  const Ref ref = obj-getRef();
+  if (!gStateCache.lookup(ref, obj)-isNull())
 return gTrue;
   obj-free();
 
-  gStateCache.put(objRef)-copy(obj);
+  gStateCache.put(ref)-copy(obj);
   return gTrue;
 }
 
diff --git a/poppler/PopplerCache.cc b/poppler/PopplerCache.cc
index 01bd471..6018a77 100644
--- a/poppler/PopplerCache.cc
+++ b/poppler/PopplerCache.cc
@@ -5,13 +5,15 @@
 // This file is licensed under the GPLv2 or later
 //
 // Copyright (C) 2009 Koji Otani s...@bbr.jp
-// Copyright (C) 2009 Albert Astals Cid aa...@kde.org
+// Copyright (C) 2009, 2010 Albert Astals Cid aa...@kde.org
 // Copyright (C) 2010 Carlos Garcia Campos carlo...@gnome.org
 //
 //
 
 #include PopplerCache.h
 
+#include XRef.h
+
 PopplerCacheKey::~PopplerCacheKey()
 {
 }
@@ -141,10 +143,9 @@ PopplerObjectCache::~PopplerObjectCache() {
   delete cache;
 }
 
-Object *PopplerObjectCache::put(Object *objRef) {
-  Ref ref = objRef-getRef();
+Object *PopplerObjectCache::put(const Ref ref) {
   Object obj;
-  objRef-fetch(xref, obj);
+  xref-fetch(ref.num, ref.gen, obj);
 
   ObjectKey *key = new ObjectKey(ref.num, ref.gen);
   ObjectItem *item = new ObjectItem(obj);
@@ -154,8 +155,7 @@ Object *PopplerObjectCache::put(Object *objRef) {
   return item-item;
 }
 
-Object *PopplerObjectCache::lookup(Object *objRef, Object *obj) {
-  Ref ref = objRef-getRef();
+Object *PopplerObjectCache::lookup(const Ref ref, Object *obj) {
   ObjectKey key(ref.num, ref.gen);
   ObjectItem *item = static_castObjectItem *(cache-lookup(key));
 
diff --git a/poppler/PopplerCache.h b/poppler/PopplerCache.h
index d5cc9fb..74010a2 100644
--- a/poppler/PopplerCache.h
+++ b/poppler/PopplerCache.h
@@ -5,7 +5,7 @@
 // This file is licensed under the GPLv2 or later
 //
 // Copyright (C) 2009 Koji Otani s...@bbr.jp
-// Copyright (C) 2009 Albert Astals Cid aa...@kde.org
+// Copyright (C) 2009, 2010 Albert Astals Cid aa...@kde.org
 // Copyright (C) 2010 Carlos Garcia Campos carlo...@gnome.org
 //
 //
@@ -67,8 +67,8 @@ class PopplerObjectCache
 PopplerObjectCache (int cacheSizeA, XRef *xrefA);
 ~PopplerObjectCache();
 
-Object *put(Object *objRef);
-Object *lookup(Object *objRef, Object *obj);
+Object *put(const Ref ref);
+Object *lookup(const Ref ref, Object *obj);
 
   private:
 XRef *xref;
commit 9567fd8d3d905897d0abacd77885102ae86ba8a9
Author: Albert Astals Cid aa...@kde.org
Date:   Sun Jan 24 20:15:49 2010 +

ImgWriter is a header too

diff --git a/goo/Makefile.am b/goo/Makefile.am
index b8a81ed..aad1108 100644
--- a/goo/Makefile.am
+++ b/goo/Makefile.am
@@ -16,6 +16,7 @@ poppler_goo_include_HEADERS = \
FixedPoint.h\
PNGWriter.h \
JpegWriter.h\
+   ImgWriter.h \
gstrtod.h
 
 endif
commit 735e8a690d0bd3ab4bec90bdad975d19ac3d4689
Author: Albert Astals Cid aa...@kde.org
Date:   Sun Jan 24 19:51:19 2010 +

noone maintains this either

diff --git a/msvc/config.h b/msvc/config.h
deleted file mode 100644
index 8bc5ea0..000
--- a/msvc/config.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Use libjpeg instead of builtin jpeg decoder. */
-#define ENABLE_LIBJPEG 1
-
-/* Have FreeType2 include files */
-#define HAVE_FREETYPE_H 1
-
-/* 

[poppler] poppler/Gfx.cc

2009-09-09 Thread Albert Astals Cid
 poppler/Gfx.cc |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 68711d8494e2765c4a24ea59ce8d904981f0f917
Author: Albert Astals Cid aa...@kde.org
Date:   Wed Sep 9 23:24:22 2009 +0200

uint - Guint

some compilers don't know about uint

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 81a4ab8..ca9b513 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -293,8 +293,8 @@ Operator Gfx::opTab[] = {
 
 #define numOps (sizeof(opTab) / sizeof(Operator))
 
-static inline GBool isSameGfxColor(const GfxColor colorA, const GfxColor 
colorB, uint nComps, double delta) {
-  for (uint k = 0; k  nComps; ++k) {
+static inline GBool isSameGfxColor(const GfxColor colorA, const GfxColor 
colorB, Guint nComps, double delta) {
+  for (Guint k = 0; k  nComps; ++k) {
 if (abs(colorA.c[k] - colorB.c[k])  delta) {
   return false;
 }
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc poppler/GfxState.h

2009-08-01 Thread Albert Astals Cid
 poppler/Gfx.cc |   13 +
 poppler/GfxState.h |1 +
 2 files changed, 14 insertions(+)

New commits:
commit 173451730948c320f16a0f5924a58302603eca0b
Author: Albert Astals Cid aa...@kde.org
Date:   Sat Aug 1 15:13:35 2009 +0200

Try to workaround some incorrect PDF

Fixes rendering of PDF where forms/patterns have more q than Q. Fixes
rendering in splash of pdf in bugs #22835, #21899 and #16402

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index eeefcac..ccf818a 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4274,8 +4274,21 @@ void Gfx::doForm1(Object *str, Dict *resDict, double 
*matrix, double *bbox,
 baseMatrix[i] = state-getCTM()[i];
   }
 
+  GfxState *stateBefore = state;
+
   // draw the form
   display(str, gFalse);
+  
+  if (stateBefore != state) {
+if (state-isParentState(stateBefore)) {
+  error(-1, There's a form with more q than Q, trying to fix);
+  while (stateBefore != state) {
+restoreState();
+  }
+} else {
+  error(-1, There's a form with more Q than q);
+}
+  }
 
   if (softMask || transpGroup) {
 out-endTransparencyGroup(state);
diff --git a/poppler/GfxState.h b/poppler/GfxState.h
index 536c86a..51a317d 100644
--- a/poppler/GfxState.h
+++ b/poppler/GfxState.h
@@ -1269,6 +1269,7 @@ public:
   GfxState *save();
   GfxState *restore();
   GBool hasSaves() { return saved != NULL; }
+  GBool isParentState(GfxState *state) { return saved == state || (saved  
saved-isParentState(state)); }
 
   // Misc
   GBool parseBlendMode(Object *obj, GfxBlendMode *mode);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2009-07-30 Thread Albert Astals Cid
 poppler/Gfx.cc |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit bf8964726c9311e7e82b1faf49cc2272e5c1e339
Author: William Bader williamba...@hotmail.com
Date:   Thu Jul 30 22:08:43 2009 +0200

Fix some double to int warnings by explicit casting

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index c3f257f..e46f0e6 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -29,6 +29,7 @@
 // Copyright (C) 2008 Hib Eris h...@hiberis.nl
 // Copyright (C) 2009 M Joonas Pihlaja jpihl...@cc.helsinki.fi
 // Copyright (C) 2009 Thomas Freitag thomas.frei...@alfa.de
+// Copyright (C) 2009 William Bader williamba...@hotmail.com
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -2512,7 +2513,7 @@ void Gfx::doAxialShFill(GfxAxialShading *shading) {
  // What we do to ensure that we pass a line through this points
  // is making sure use the exact bboxIntersections[] value as one of 
the used ta[] values
  if (!doneBBox1  ta[i]  bboxIntersections[1]  ta[j]  
bboxIntersections[1]) {
-   int teoricalj = (bboxIntersections[1] - tMin) * axialMaxSplits / 
(tMax - tMin);
+   int teoricalj = (int) ((bboxIntersections[1] - tMin) * 
axialMaxSplits / (tMax - tMin));
if (teoricalj = i) teoricalj = i + 1;
if (teoricalj  j) {
  next[i] = teoricalj;
@@ -2526,7 +2527,7 @@ void Gfx::doAxialShFill(GfxAxialShading *shading) {
doneBBox1 = true;
  }
  if (!doneBBox2  ta[i]  bboxIntersections[2]  ta[j]  
bboxIntersections[2]) {
-   int teoricalj = (bboxIntersections[2] - tMin) * axialMaxSplits / 
(tMax - tMin);
+   int teoricalj = (int) ((bboxIntersections[2] - tMin) * 
axialMaxSplits / (tMax - tMin));
if (teoricalj = i) teoricalj = i + 1;
if (teoricalj  j) {
  next[i] = teoricalj;
@@ -3961,7 +3962,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
  maskColors[i] = obj1.getInt();
} else if (obj1.isReal()) {
  error(-1, Mask entry should be an integer but it's a real, trying to 
use it);
- maskColors[i] = obj1.getReal();
+ maskColors[i] = (int) obj1.getReal();
} else {
  error(-1, Mask entry should be an integer but it's of type %d, 
obj1.getType());
  obj1.free();
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2009-06-04 Thread Albert Astals Cid
 poppler/Gfx.cc |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 30fb7cb7e47cf6a8008c5083c8d0978fdfdf8e62
Author: Albert Astals Cid aa...@kde.org
Date:   Thu Jun 4 19:25:22 2009 +0200

Add missing { }

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index e907850..afd1d15 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -3778,7 +3778,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
 obj1.free();
 
 // draw it
-if (!contentIsHidden())
+if (!contentIsHidden()) {
   out-drawImageMask(state, ref, str, width, height, invert, inlineImg);
   if (out-fillMaskCSPattern(state)) {
 maskHaveCSPattern = gTrue;
@@ -3786,7 +3786,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
 out-endMaskClip(state);
 maskHaveCSPattern = gFalse;
   }
-
+}
   } else {
 
 // get color space and color map
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2009-05-10 Thread Albert Astals Cid
 poppler/Gfx.cc |   23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

New commits:
commit 829ed964374676ddfa4a9048c940dc20a309ca47
Author: M Joonas Pihlaja jpihl...@cc.helsinki.fi
Date:   Sun May 10 23:39:11 2009 +0200

Fix axial shading fix to ensure the painting passes by the four edges of 
the bbox

When j and teoricalj are the same, just change the value of ta[] not the 
next[] ones

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index b63d424..897b24b 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -27,6 +27,7 @@
 // Copyright (C) 2008 Pino Toscano p...@kde.org
 // Copyright (C) 2008 Michael Vrable mvra...@cs.ucsd.edu
 // Copyright (C) 2008 Hib Eris h...@hiberis.nl
+// Copyright (C) 2009 M Joonas Pihlaja jpihl...@cc.helsinki.fi
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -2447,9 +2448,13 @@ void Gfx::doAxialShFill(GfxAxialShading *shading) {
  if (!doneBBox1  ta[i]  bboxIntersections[1]  ta[j]  
bboxIntersections[1]) {
int teoricalj = (bboxIntersections[1] - tMin) * axialMaxSplits / 
(tMax - tMin);
if (teoricalj = i) teoricalj = i + 1;
-   if (j == teoricalj) j = teoricalj + 1;
-   next[i] = teoricalj;
-   next[teoricalj] = j;
+   if (teoricalj  j) {
+ next[i] = teoricalj;
+ next[teoricalj] = j;
+   }
+   else {
+ teoricalj = j;
+   }
ta[teoricalj] = bboxIntersections[1];
j = teoricalj;
doneBBox1 = true;
@@ -2457,14 +2462,18 @@ void Gfx::doAxialShFill(GfxAxialShading *shading) {
  if (!doneBBox2  ta[i]  bboxIntersections[2]  ta[j]  
bboxIntersections[2]) {
int teoricalj = (bboxIntersections[2] - tMin) * axialMaxSplits / 
(tMax - tMin);
if (teoricalj = i) teoricalj = i + 1;
-   if (j == teoricalj) j = teoricalj + 1;
-   next[i] = teoricalj;
-   next[teoricalj] = j;
+   if (teoricalj  j) {
+ next[i] = teoricalj;
+ next[teoricalj] = j;
+   }
+   else {
+ teoricalj = j;
+   }
ta[teoricalj] = bboxIntersections[2];
j = teoricalj;
doneBBox2 = true;
  }
-break;
+ break;
   }
   k = (i + j) / 2;
   ta[k] = 0.5 * (ta[i] + ta[j]);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2009-04-17 Thread Albert Astals Cid
 poppler/Gfx.cc |  102 ++---
 1 file changed, 62 insertions(+), 40 deletions(-)

New commits:
commit b760debea03380280d72cd39d792cbc1a380a87c
Author: Albert Astals Cid aa...@kde.org
Date:   Fri Apr 17 21:04:26 2009 +0200

Fix rendering of axial shadings

Fixes bug #19896

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 61bd046..0eef5d3 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2263,12 +2263,28 @@ void Gfx::doFunctionShFill1(GfxFunctionShading *shading,
   }
 }
 
+static void bubbleSort(double array[])
+{
+  for (int j = 0; j  3; ++j) {
+int kk = j;
+for (int k = j + 1; k  4; ++k) {
+  if (array[k]  array[kk]) {
+kk = k;
+  }
+}
+double tmp = array[j];
+array[j] = array[kk];
+array[kk] = tmp;
+  }
+}
+
 void Gfx::doAxialShFill(GfxAxialShading *shading) {
   double xMin, yMin, xMax, yMax;
   double x0, y0, x1, y1;
   double dx, dy, mul;
   GBool dxZero, dyZero;
-  double tMin, tMax, t, tx, ty;
+  double bboxIntersections[4];
+  double tMin, tMax, tx, ty;
   double s[4], sMin, sMax, tmp;
   double ux0, uy0, ux1, uy1, vx0, vy0, vx1, vy1;
   double t0, t1, tt;
@@ -2276,7 +2292,7 @@ void Gfx::doAxialShFill(GfxAxialShading *shading) {
   int next[axialMaxSplits + 1];
   GfxColor color0, color1;
   int nComps;
-  int i, j, k, kk;
+  int i, j, k;
 
   if (out-useShadedFills() 
   out-axialShadedFill(state, shading)) {
@@ -2297,25 +2313,13 @@ void Gfx::doAxialShFill(GfxAxialShading *shading) {
 tMin = tMax = 0;
   } else {
 mul = 1 / (dx * dx + dy * dy);
-tMin = tMax = ((xMin - x0) * dx + (yMin - y0) * dy) * mul;
-t = ((xMin - x0) * dx + (yMax - y0) * dy) * mul;
-if (t  tMin) {
-  tMin = t;
-} else if (t  tMax) {
-  tMax = t;
-}
-t = ((xMax - x0) * dx + (yMin - y0) * dy) * mul;
-if (t  tMin) {
-  tMin = t;
-} else if (t  tMax) {
-  tMax = t;
-}
-t = ((xMax - x0) * dx + (yMax - y0) * dy) * mul;
-if (t  tMin) {
-  tMin = t;
-} else if (t  tMax) {
-  tMax = t;
-}
+bboxIntersections[0] = ((xMin - x0) * dx + (yMin - y0) * dy) * mul;
+bboxIntersections[1] = ((xMin - x0) * dx + (yMax - y0) * dy) * mul;
+bboxIntersections[2] = ((xMax - x0) * dx + (yMin - y0) * dy) * mul;
+bboxIntersections[3] = ((xMax - x0) * dx + (yMax - y0) * dy) * mul;
+bubbleSort(bboxIntersections);
+tMin = bboxIntersections[0];
+tMax = bboxIntersections[3];
 if (tMin  0  !shading-getExtend0()) {
   tMin = 0;
 }
@@ -2396,15 +2400,7 @@ void Gfx::doAxialShFill(GfxAxialShading *shading) {
 s[1] = (yMax - ty) / dx;
 s[2] = (xMin - tx) / -dy;
 s[3] = (xMax - tx) / -dy;
-for (j = 0; j  3; ++j) {
-  kk = j;
-  for (k = j + 1; k  4; ++k) {
-   if (s[k]  s[kk]) {
- kk = k;
-   }
-  }
-  tmp = s[j]; s[j] = s[kk]; s[kk] = tmp;
-}
+bubbleSort(s);
 sMin = s[1];
 sMax = s[2];
   }
@@ -2414,6 +2410,13 @@ void Gfx::doAxialShFill(GfxAxialShading *shading) {
   vy0 = ty + sMax * dx;
 
   i = 0;
+  bool doneBBox1, doneBBox2;
+  if (dxZero  dyZero) {
+doneBBox1 = doneBBox2 = true;
+  } else {
+doneBBox1 = bboxIntersections[1]  tMin;
+doneBBox2 = bboxIntersections[2]  tMax;
+  }
   while (i  axialMaxSplits) {
 
 // bisect until color difference is small enough or we hit the
@@ -2434,7 +2437,34 @@ void Gfx::doAxialShFill(GfxAxialShading *shading) {
}
   }
   if (k == nComps) {
-   break;
+ // in these two if what we guarantee is that if we are skipping lots 
of 
+ // positions because the colors are the same, we still create a region
+ // with vertexs passing by bboxIntersections[1] and 
bboxIntersections[2]
+ // otherwise we can have empty regions that should really be painted 
+ // like happened in bug 19896
+ // What we do to ensure that we pass a line through this points
+ // is making sure use the exact bboxIntersections[] value as one of 
the used ta[] values
+ if (!doneBBox1  ta[i]  bboxIntersections[1]  ta[j]  
bboxIntersections[1]) {
+   int teoricalj = (bboxIntersections[1] - tMin) * axialMaxSplits / 
(tMax - tMin);
+   if (teoricalj = i) teoricalj = i + 1;
+   if (j == teoricalj) j = teoricalj + 1;
+   next[i] = teoricalj;
+   next[teoricalj] = j;
+   ta[teoricalj] = bboxIntersections[1];
+   j = teoricalj;
+   doneBBox1 = true;
+ }
+ if (!doneBBox2  ta[i]  bboxIntersections[2]  ta[j]  
bboxIntersections[2]) {
+   int teoricalj = (bboxIntersections[2] - tMin) * axialMaxSplits / 
(tMax - tMin);
+   if (teoricalj = i) teoricalj = i + 1;
+   if (j == teoricalj) j = teoricalj + 1;
+   next[i] = teoricalj;
+   next[teoricalj] = j;
+   ta[teoricalj] = bboxIntersections[2];
+   j = teoricalj;
+   doneBBox2 = true;
+ }

[poppler] poppler/Gfx.cc

2009-03-10 Thread Albert Astals Cid
 poppler/Gfx.cc |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit b3f569f9a6c117c097acac52ae6552209fcd2101
Author: Albert Astals Cid aa...@kde.org
Date:   Wed Mar 11 00:25:07 2009 +0100

Check there is an optional content config before using it

Fixes bug #20587

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index db06453..61bd046 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -14,7 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2005 Jonathan Blandford j...@redhat.com
-// Copyright (C) 2005-2008 Albert Astals Cid aa...@kde.org
+// Copyright (C) 2005-2009 Albert Astals Cid aa...@kde.org
 // Copyright (C) 2006 Thorkild Stray thork...@ifi.uio.no
 // Copyright (C) 2006 Kristian Høgsberg k...@redhat.com
 // Copyright (C) 2006-2008 Carlos Garcia Campos carlo...@gnome.org
@@ -3504,7 +3504,7 @@ void Gfx::opXObject(Object args[], int numArgs) {
   if (obj2.isNull()) {
 // No OC entry - so we proceed as normal
   } else if (obj2.isRef()) {
-if ( ! catalog-getOptContentConfig()-optContentIsVisible( obj2 ) ) {
+if ( catalog-getOptContentConfig()  ! 
catalog-getOptContentConfig()-optContentIsVisible( obj2 ) ) {
   obj2.free();
   obj1.free();
   return;
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2008-11-23 Thread Carlos Garcia Campos
 poppler/Gfx.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 12f6d6ba2052fbdc8ea4ba7c7c9277e75bf170a5
Author: Carlos Garcia Campos [EMAIL PROTECTED]
Date:   Sun Nov 23 18:20:14 2008 +0100

Fix a crash when the second argument of opMarkPoint is not a dictionary

According to the spec If any of the values are indirect references to
objects outside the content stream, the property list dictionary must
instead be defined as a named resource.

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 871feb3..20ec1bf 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4254,7 +4254,7 @@ void Gfx::opMarkPoint(Object args[], int numArgs) {
 fflush(stdout);
   }
 
-  if(numArgs == 2) {
+  if(numArgs == 2  args[1].isDict()) {
 out-markPoint(args[0].getName(),args[1].getDict());
   } else {
 out-markPoint(args[0].getName());
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc poppler/Gfx.h

2008-08-14 Thread Albert Astals Cid
 poppler/Gfx.cc |   14 ++
 poppler/Gfx.h  |3 ---
 2 files changed, 2 insertions(+), 15 deletions(-)

New commits:
commit 303249e5548bfbf6823e97850e498970d802b4a0
Author: Albert Astals Cid [EMAIL PROTECTED]
Date:   Fri Aug 15 01:52:52 2008 +0200

Revert 123a87aff2e35b10efe6a1d715585b427e4a9afa it creates problems with 
some pdf files

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index e1cd847..41ccdb7 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -465,7 +465,6 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict 
*resDict, Catalog *cata
 void *abortCheckCbkDataA) {
   int i;
 
-  lastResource = NULL;
   xref = xrefA;
   catalog = catalogA;
   subPage = gFalse;
@@ -510,7 +509,6 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, 
Catalog *catalogA,
 void *abortCheckCbkDataA) {
   int i;
 
-  lastResource = NULL;
   xref = xrefA;
   catalog = catalogA;
   subPage = gTrue;
@@ -558,7 +556,6 @@ Gfx::~Gfx() {
   if (state) {
 delete state;
   }
-  delete lastResource;
 }
 
 void Gfx::display(Object *obj, GBool topLevel) {
@@ -4382,20 +4379,13 @@ void Gfx::restoreState() {
 }
 
 void Gfx::pushResources(Dict *resDict) {
-  if (lastResource  resDict == lastResourceDict) res = lastResource;
-  else
-  {
-delete lastResource;
-res = new GfxResources(xref, resDict, res);
-lastResource = res;
-lastResourceDict = resDict;
-  }
+  res = new GfxResources(xref, resDict, res);
 }
 
 void Gfx::popResources() {
   GfxResources *resPtr;
 
   resPtr = res-getNext();
-  if (resPtr == NULL) delete res;
+  delete res;
   res = resPtr;
 }
diff --git a/poppler/Gfx.h b/poppler/Gfx.h
index c56558f..10be638 100644
--- a/poppler/Gfx.h
+++ b/poppler/Gfx.h
@@ -173,9 +173,6 @@ private:
 (*abortCheckCbk)(void *data);
   void *abortCheckCbkData;
 
-  GfxResources *lastResource;  // last used GfxResource
-  Dict *lastResourceDict;  // last used GfxResource Dict
-
   static Operator opTab[]; // table of operators
 
   void go(GBool topLevel);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc poppler/Gfx.h

2008-08-11 Thread Albert Astals Cid
 poppler/Gfx.cc |   14 --
 poppler/Gfx.h  |3 +++
 2 files changed, 15 insertions(+), 2 deletions(-)

New commits:
commit 123a87aff2e35b10efe6a1d715585b427e4a9afa
Author: Albert Astals Cid [EMAIL PROTECTED]
Date:   Tue Aug 12 00:37:09 2008 +0200

Cache the last created GfxResource, very useful because some pdf created by 
pstopdf push and pop the same GfxResource all the time

This brings us a speedup of 16 times (from 11 seconds to about 600 msec) in 
kde bug 168663

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 41ccdb7..e1cd847 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -465,6 +465,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict 
*resDict, Catalog *cata
 void *abortCheckCbkDataA) {
   int i;
 
+  lastResource = NULL;
   xref = xrefA;
   catalog = catalogA;
   subPage = gFalse;
@@ -509,6 +510,7 @@ Gfx::Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, 
Catalog *catalogA,
 void *abortCheckCbkDataA) {
   int i;
 
+  lastResource = NULL;
   xref = xrefA;
   catalog = catalogA;
   subPage = gTrue;
@@ -556,6 +558,7 @@ Gfx::~Gfx() {
   if (state) {
 delete state;
   }
+  delete lastResource;
 }
 
 void Gfx::display(Object *obj, GBool topLevel) {
@@ -4379,13 +4382,20 @@ void Gfx::restoreState() {
 }
 
 void Gfx::pushResources(Dict *resDict) {
-  res = new GfxResources(xref, resDict, res);
+  if (lastResource  resDict == lastResourceDict) res = lastResource;
+  else
+  {
+delete lastResource;
+res = new GfxResources(xref, resDict, res);
+lastResource = res;
+lastResourceDict = resDict;
+  }
 }
 
 void Gfx::popResources() {
   GfxResources *resPtr;
 
   resPtr = res-getNext();
-  delete res;
+  if (resPtr == NULL) delete res;
   res = resPtr;
 }
diff --git a/poppler/Gfx.h b/poppler/Gfx.h
index 10be638..c56558f 100644
--- a/poppler/Gfx.h
+++ b/poppler/Gfx.h
@@ -173,6 +173,9 @@ private:
 (*abortCheckCbk)(void *data);
   void *abortCheckCbkData;
 
+  GfxResources *lastResource;  // last used GfxResource
+  Dict *lastResourceDict;  // last used GfxResource Dict
+
   static Operator opTab[]; // table of operators
 
   void go(GBool topLevel);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2008-04-11 Thread Albert Astals Cid
 poppler/Gfx.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 464b171d0e9b989196c287f2ee4dfbbc14212aa9
Author: Albert Astals Cid [EMAIL PROTECTED]
Date:   Sat Apr 12 00:44:08 2008 +0200

Do not take into account Colorspace resource subdictionary for image 
XObjects

Fixes bug 15125
The motivation under that change is on section 4.5.2 of the spec:
 Certain objects, such as image XObjects, specify a
 color space as an explicit parameter, often associated with the key 
ColorSpace.
 In this case, the color space array or name is always defined directly as 
a PDF
 object, not by an entry in the ColorSpace resource subdictionary. This 
conven-
 tion also applies when color spaces are defined in terms of other color 
spaces.

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 0618ab0..6fc9b8d 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -3627,7 +3627,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool 
inlineImg) {
   obj1.free();
   dict-lookup(CS, obj1);
 }
-if (obj1.isName()) {
+if (obj1.isName()  inlineImg) {
   res-lookupColorSpace(obj1.getName(), obj2);
   if (!obj2.isNull()) {
obj1.free();
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc poppler/OptionalContent.cc

2008-02-27 Thread Pino Toscano
 poppler/Gfx.cc |2 ++
 poppler/OptionalContent.cc |2 ++
 2 files changed, 4 insertions(+)

New commits:
commit 4a324484b5c77ddc348746e7bcf6051ade28e389
Author: Pino Toscano [EMAIL PROTECTED]
Date:   Wed Feb 27 18:04:52 2008 +0100

free some objects (thus leak less)

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index e8d0b1c..0618ab0 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -3460,6 +3460,8 @@ void Gfx::opXObject(Object args[], int numArgs) {
 // No OC entry - so we proceed as normal
   } else if (obj2.isRef()) {
 if ( ! catalog-getOptContentConfig()-optContentIsVisible( obj2 ) ) {
+  obj2.free();
+  obj1.free();
   return;
 }
   } else {
diff --git a/poppler/OptionalContent.cc b/poppler/OptionalContent.cc
index 600c52b..b081add 100644
--- a/poppler/OptionalContent.cc
+++ b/poppler/OptionalContent.cc
@@ -174,6 +174,7 @@ bool OCGs::optContentIsVisible( Object *dictRef )
   dictRef-fetch( m_xref, dictObj );
   if ( ! dictObj.isDict() ) {
 printf( Unexpected oc reference target: %i\n, dictObj.getType() );
+dictObj.free();
 return result;
   }
   dict = dictObj.getDict();
@@ -216,6 +217,7 @@ bool OCGs::optContentIsVisible( Object *dictRef )
 }
   } 
   dictType.free();
+  dictObj.free();
   // printf(visibility: %s\n, result? on : off);
   return result;
 }
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2008-01-23 Thread Albert Astals Cid
 poppler/Gfx.cc |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 2335fb6034d2e9ec304abba400119b88302b3160
Author: Albert Astals Cid [EMAIL PROTECTED]
Date:   Wed Jan 23 23:26:20 2008 +0100

Draw underlined Links correctly

See http://bugs.kde.org/show_bug.cgi?id=151359 for an example

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 2f20183..f21ae6e 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4288,11 +4288,11 @@ void Gfx::drawAnnot(Object *str, AnnotBorder *border, 
AnnotColor *aColor,
 }
 //~ this doesn't currently handle the beveled and engraved styles
 state-clearPath();
-state-moveTo(annotX0, out-upsideDown() ? annotY1 : annotY0);
-state-lineTo(annotX1, out-upsideDown() ? annotY1 : annotY0);
+state-moveTo(annotX0, out-upsideDown() ? annotY0 : annotY1);
+state-lineTo(annotX1, out-upsideDown() ? annotY0 : annotY1);
 if (border-getStyle() != AnnotBorder::borderUnderlined) {
-  state-lineTo(annotX1, out-upsideDown() ? annotY0 : annotY1);
-  state-lineTo(annotX0, out-upsideDown() ? annotY0 : annotY1);
+  state-lineTo(annotX1, out-upsideDown() ? annotY1 : annotY0);
+  state-lineTo(annotX0, out-upsideDown() ? annotY1 : annotY0);
   state-closePath();
 }
 out-stroke(state);
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc

2007-12-10 Thread Carlos Garcia Campos
 poppler/Gfx.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 7cbabbf378cf5a9c0411558ff02b44dec2040ea1
Author: Carlos Garcia Campos [EMAIL PROTECTED]
Date:   Mon Dec 10 22:00:30 2007 +0100

Fix a crash when marked content properties operator is not a dict.

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index d2b3cb8..78bb640 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -4028,7 +4028,7 @@ void Gfx::opBeginMarkedContent(Object args[], int 
numArgs) {
 fflush(stdout);
   }
 
-  if(numArgs == 2) {
+  if(numArgs == 2  args[1].isDict ()) {
 out-beginMarkedContent(args[0].getName(),args[1].getDict());
   } else {
 out-beginMarkedContent(args[0].getName());
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc poppler/GfxState.h poppler/OutputDev.h

2007-11-11 Thread Jeff Muizelaar
 poppler/Gfx.cc  |   14 ++
 poppler/GfxState.h  |6 ++
 poppler/OutputDev.h |2 ++
 3 files changed, 22 insertions(+)

New commits:
commit b0fbfb0ac366434d7e4c0350a9be83ddda7b03cf
Author: Jeff Muizelaar [EMAIL PROTECTED]
Date:   Sun Nov 11 16:06:16 2007 -0500

Track the AlphaIsShape and TextKnockout state

Parse, store and notify the OutputDevices about these entries.

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 37c279e..eb0012e 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -929,6 +929,20 @@ void Gfx::opSetExtGState(Object args[], int numArgs) {
   }
   obj2.free();
 
+  // alpha is shape
+  if (obj1.dictLookup(AIS, obj2)-isBool()) {
+state-setAlphaIsShape(obj2.getBool());
+out-updateAlphaIsShape(state);
+  }
+  obj2.free();
+
+  // text knockout
+  if (obj1.dictLookup(TK, obj2)-isBool()) {
+state-setTextKnockout(obj2.getBool());
+out-updateTextKnockout(state);
+  }
+  obj2.free();
+
   // soft mask
   if (!obj1.dictLookup(SMask, obj2)-isNull()) {
 if (obj2.isName(None)) {
diff --git a/poppler/GfxState.h b/poppler/GfxState.h
index a36370e..c766858 100644
--- a/poppler/GfxState.h
+++ b/poppler/GfxState.h
@@ -1091,6 +1091,8 @@ public:
   int getLineCap() { return lineCap; }
   double getMiterLimit() { return miterLimit; }
   GBool getStrokeAdjust() { return strokeAdjust; }
+  GBool getAlphaIsShape() { return alphaIsShape; }
+  GBool getTextKnockout() { return textKnockout; }
   GfxFont *getFont() { return font; }
   double getFontSize() { return fontSize; }
   double *getTextMat() { return textMat; }
@@ -1158,6 +1160,8 @@ public:
   void setLineCap(int lineCap1) { lineCap = lineCap1; }
   void setMiterLimit(double limit) { miterLimit = limit; }
   void setStrokeAdjust(GBool sa) { strokeAdjust = sa; }
+  void setAlphaIsShape(GBool ais) { alphaIsShape = ais; }
+  void setTextKnockout(GBool tk) { textKnockout = tk; }
   void setFont(GfxFont *fontA, double fontSizeA);
   void setTextMat(double a, double b, double c,
  double d, double e, double f)
@@ -1240,6 +1244,8 @@ private:
   int lineCap; // line cap style
   double miterLimit;   // line miter limit
   GBool strokeAdjust;  // stroke adjustment
+  GBool alphaIsShape;  // alpha is shape
+  GBool textKnockout;  // text knockout
 
   GfxFont *font;   // font
   double fontSize; // font size
diff --git a/poppler/OutputDev.h b/poppler/OutputDev.h
index 71910ff..1e92b16 100644
--- a/poppler/OutputDev.h
+++ b/poppler/OutputDev.h
@@ -127,6 +127,8 @@ public:
   virtual void updateMiterLimit(GfxState * /*state*/) {}
   virtual void updateLineWidth(GfxState * /*state*/) {}
   virtual void updateStrokeAdjust(GfxState * /*state*/) {}
+  virtual void updateAlphaIsShape(GfxState * /*state*/) {}
+  virtual void updateTextKnockout(GfxState * /*state*/) {}
   virtual void updateFillColorSpace(GfxState * /*state*/) {}
   virtual void updateStrokeColorSpace(GfxState * /*state*/) {}
   virtual void updateFillColor(GfxState * /*state*/) {}
___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/poppler: Gfx.cc,1.14.2.1,1.14.2.2

2007-04-06 Thread Albert Astals Cid
Update of /cvs/poppler/poppler/poppler
In directory kemper:/tmp/cvs-serv7699

Modified Files:
  Tag: xpdf302merge
Gfx.cc 
Log Message:
Problems found by Jeff


Index: Gfx.cc
===
RCS file: /cvs/poppler/poppler/poppler/Gfx.cc,v
retrieving revision 1.14.2.1
retrieving revision 1.14.2.2
diff -u -d -r1.14.2.1 -r1.14.2.2
--- Gfx.cc  6 Apr 2007 14:22:23 -   1.14.2.1
+++ Gfx.cc  6 Apr 2007 16:49:41 -   1.14.2.2
@@ -1456,8 +1456,8 @@
 //error(getPos(), No path in closepath/stroke);
 return;
   }
+  state-closePath();
   if (state-isPath()) {
-state-closePath();
 if (state-getStrokeColorSpace()-getMode() == csPattern) {
   doPatternStroke();
 } else {
@@ -3953,7 +3953,6 @@
break;
   }
   dict.dictAdd(key, obj);
-  gfree(key);
 }
 parser-getObj(obj);
   }

___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/poppler: Gfx.cc,1.10,1.11

2006-07-19 Thread Jeff Muizelaar
Update of /cvs/poppler/poppler/poppler
In directory kemper:/tmp/cvs-serv4738/poppler

Modified Files:
Gfx.cc 
Log Message:
2006-07-18  Jeff Muizelaar  [EMAIL PROTECTED]

* poppler/Gfx.cc: fix opCloseStroke to match the behaviour of
a separate opClose and opStroke. Previously, opCloseStroke only
closes if there is a path however opClose closes unconditionally.


Index: Gfx.cc
===
RCS file: /cvs/poppler/poppler/poppler/Gfx.cc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- Gfx.cc  19 May 2006 19:21:59 -  1.10
+++ Gfx.cc  18 Jul 2006 21:32:11 -  1.11
@@ -1212,8 +1212,8 @@
 //error(getPos(), No path in closepath/stroke);
 return;
   }
+  state-closePath();
   if (state-isPath()) {
-state-closePath();
 out-stroke(state);
   }
   doEndPath();

___
poppler mailing list
poppler@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/poppler