On 16.10.2012 22:57, Albert Astals Cid wrote:
El Dilluns, 15 d'octubre de 2012, a les 07:15:51, Thomas Freitag va escriure:
On 14.10.2012 22:58, Albert Astals Cid wrote:
El Diumenge, 14 d'octubre de 2012, a les 19:41:26, Thomas Freitag va
escriure:
On 14.10.2012 17:21, Albert Astals Cid wrote:
El Diumenge, 14 d'octubre de 2012, a les 13:47:29, Thomas Freitag va
escriure:
Hi folks!

Is there anybody in the community who wants the possibility to simulate
overprint in qt library?
With the implementation of DeviceN support in splash this is quite easy
now, so I can upload a patch.
Sure, why not? Let's see the patch :-)
Okay, here it is.
The two new methods are missing @since markers (and also i think the
documentation of the two methods could be a bit more explanatory)
@since: I thought that You insert it when You commit it. If I would
insert 0.22.0 You have to change it if You will not have the time to
commit it :-) or I need to change it and have to upload a new patch if
You will not have the time :-(
Well, if you do it, it's less work i have to do and thus it's easier i'll have
time ;-)
Because I removed these two new methods now there is no need to comment them anymore :-) But I introduced a new (static) method "okToUseOverprint" which just proofs if poppler is compiled with SPLASH_CMYK, and there I add the @since comment now.

Explanatory: Okay, but this will be hard. For those who know what
overprint is the documentation is self-explanatory, for others I need to
write reams. What's about to insert the link to
http://en.wikipedia.org/wiki/Overprinting?
To be honest doesn't seem to make things much clearer to me :D
Okay, let me try to explain it in my own words:
First of all, in the normal behaviour, if something is painted everything previously painted at this place is knocked out. This is rather simplified, because we ignore functionality like transparency, blending modes etc. Now let us have a look at the printing process with 4 different colour plates Cyan, Magenta, Yellow and Black. Without setting the overprint mode, the behaviour is the same: if something is painted everything previously painted on every plate is knocked out. But when overprint mode is enabled, and i.e. in a DeviceN colorspace with only one process colour, let us assume Cyan, the Magenta, Yellow and Black plates kept untouched and only previously painted objects on the Cyan plate at this position are knocked out. But when You paint in DeviceCMYK, the behaviour remains the same (all is knocked out) even with overprint on, unless You set overprint mode to true in addition. With overprint mode true You need to look at the colour components You use for painting: if the a component is 0 the corresponding colour plate is left untouched again, if it is not 0 it will be knocked out again on this colour plate. If there is a additional spot colour plate, it is similar: overprint false: everything is knocked out, overprint true: if You paint with process colours only this spot colour plate is left untouched, if You paint with this spot colour, the process colour plates remain untouched but on this spot colour plate previously painted objects are knocked out. As I said, this is rather simplified, there are special rules for images, blending modes and so on and so on. A complete explanation can be found in the PDF specification. As overprint just works on colour plates, You'll see no effects when You print in RGB as on a monitor, therefore You have to simulate the effects (overprint preview :-) ) if You want to see them on a monitor.
Ok, let's leave the docu as it is

Also why are you calling it "overprint preview"? How is it a preview?
To be honest, I haven't really thought about that. Probably I choose
that name because it is also introduced in GlobalParams with that name.
But also in the acrobat reader preferences it is called "Use overprint
preview". And because not all RIPs support it (i.e. RGB printers) it is
indeed something like a preview (for RIPs which support it).
Ok, let's leave it with that name (but maybe make it a RenderingHint as Adam
suggests?).
I tried to understand what You meant with RenderingHint and made it, hopefully it is what You meant. I attach the changed patches (poppler and okular).

Cheers,
Thomas

Cheers,
   Albert

Given that overprint only works if defined(SPLASH_CMYK) you should make
the
setter return a boolean that says if the set worked or not (i.e. make it
fail if !defined(SPLASH_CMYK))
Gotcha. I thought about that and disable / enable the option in okular
if the format generator doesn't support it. But because I'm not familiar
enough with okular I defered it and then forgot it...
I'll insert it in QT when I get answers to the other points.

Cheers,
Thomas

Cheers,

    Albert
In a few places it has already a similar
implementation than in bug 50992 (thread safe), because changing the
overprint option also meant that we need a different SplashOutputDev
instance. But You probably also want to test it in okular? Even if we
are here not on an okular list, I attach the okular patch here, too.
Also here, it has already the changes from bug 50992. But because
POPPLER_QT_THREADSAFE is not defined here, it doesn't make any
difference, so I let these changes as they are. BTW, I'm not really
familiar with qt programming, so most changes in okular are more or less
a (hopefully) best guess.

Cheers,
Thomas

Cheers,

     Albert
For everybody who doesn't know anything about overprint I attach three
screenshots which shows the implementation in okular.
(This is not fake, I made a small apprentice piece today morning :-) )

Cheers,
Thomas
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

.
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

.
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

.


diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc
index 550e706..947dca8 100644
--- a/qt4/src/poppler-document.cc
+++ b/qt4/src/poppler-document.cc
@@ -493,7 +493,15 @@ namespace Poppler {
     	return m_doc->paperColor;
     }
 
-    void Document::setRenderBackend( Document::RenderBackend backend )
+    bool Document::okToUseOverprint() {
+#if defined(SPLASH_CMYK)
+          return true;
+#else
+          return false;
+#endif
+   }
+
+   void Document::setRenderBackend( Document::RenderBackend backend )
     {
         // no need to delete the outputdev as for the moment we always create a splash one
         // as the arthur one does not allow "precaching" due to it's signature
@@ -523,14 +531,6 @@ namespace Poppler {
             m_doc->m_hints |= hint;
         else
             m_doc->m_hints &= ~(int)hint;
-
-        // the only way to set antialiasing for Splash is on creation
-        if ( m_doc->m_backend == Document::SplashBackend &&
-             ( hint & ( Document::Antialiasing || Document::TextAntialiasing || Document::TextHinting ) ) )
-        {
-            delete m_doc->m_outputDev;
-            m_doc->m_outputDev = NULL;
-        }
     }
 
     Document::RenderHints Document::renderHints() const
diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc
index 03aa1bb..fb32ace 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.cc
@@ -257,7 +257,53 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h,
     case Poppler::Document::SplashBackend:
     {
 #if defined(HAVE_SPLASH)
-      SplashOutputDev *splash_output = static_cast<SplashOutputDev *>(m_page->parentDoc->getOutputDev());
+      SplashColor bgColor;
+      GBool overprint = m_page->parentDoc->m_hints & Document::OverprintPreview ? gTrue : gFalse;
+      globalParams->setOverprintPreview(overprint);
+#if defined(SPLASH_CMYK)
+      if (overprint)
+      {
+        Guchar c, m, y, k;
+
+        c = 255 - m_page->parentDoc->paperColor.blue();
+        m = 255 - m_page->parentDoc->paperColor.red();
+        y = 255 - m_page->parentDoc->paperColor.green();
+        k = c;
+        if (m < k) {
+          k = m;
+        }
+        if (y < k) {
+          k = y;
+        }
+        bgColor[0] = c - k;
+        bgColor[1] = m - k;
+        bgColor[2] = y - k;
+        bgColor[3] = k;
+        for (int i = 4; i < SPOT_NCOMPS + 4; i++) {
+          bgColor[i] = 0;
+        }
+      }
+      else
+#endif
+      {
+        bgColor[0] = m_page->parentDoc->paperColor.blue();
+        bgColor[1] = m_page->parentDoc->paperColor.green();
+        bgColor[2] = m_page->parentDoc->paperColor.red();
+      }
+ 
+      GBool AA = m_page->parentDoc->m_hints & Document::TextAntialiasing ? gTrue : gFalse;
+
+      SplashOutputDev * splash_output = new SplashOutputDev(
+#if defined(SPLASH_CMYK)
+	(overprint) ? splashModeDeviceN8 :
+#endif 
+	splashModeXBGR8, 4, gFalse, bgColor, gTrue, AA);
+
+      splash_output->setVectorAntialias(m_page->parentDoc->m_hints & Document::Antialiasing ? gTrue : gFalse);
+      splash_output->setFreeTypeHinting(m_page->parentDoc->m_hints & Document::TextHinting ? gTrue : gFalse, 
+        m_page->parentDoc->m_hints & Document::TextSlightHinting ? gTrue : gFalse);
+	
+      splash_output->startDoc(m_page->parentDoc->doc);      
 
       m_page->parentDoc->doc->displayPageSlice(splash_output, m_page->index + 1, xres, yres,
 						 rotation, false, true, false, x, y, w, h);
@@ -266,7 +312,7 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h,
       int bw = bitmap->getWidth();
       int bh = bitmap->getHeight();
 
-      SplashColorPtr dataPtr = splash_output->getBitmap()->getDataPtr();
+      SplashColorPtr dataPtr = splash_output->getBitmap()->getXBGRPrt();
 
       if (QSysInfo::BigEndian == QSysInfo::ByteOrder)
       {
@@ -287,8 +333,8 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h,
       // construct a qimage SHARING the raw bitmap data in memory
       QImage tmpimg( dataPtr, bw, bh, QImage::Format_ARGB32 );
       img = tmpimg.copy();
-      // unload underlying xpdf bitmap
-      splash_output->startPage( 0, NULL );
+
+      delete splash_output;
 #endif
       break;
     }
diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc
index ffb5b92..2d63b3a 100644
--- a/qt4/src/poppler-private.cc
+++ b/qt4/src/poppler-private.cc
@@ -226,7 +226,6 @@ namespace Debug {
         qDeleteAll(m_embeddedFiles);
         delete (OptContentModel *)m_optContentModel;
         delete doc;
-        delete m_outputDev;
         delete m_fontInfoIterator;
     
         count --;
@@ -241,7 +240,6 @@ namespace Debug {
     {
         m_fontInfoIterator = 0;
         m_backend = Document::SplashBackend;
-        m_outputDev = 0;
         paperColor = Qt::white;
         m_hints = 0;
         m_optContentModel = 0;
diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h
index 6d2ef2a..49c33f0 100644
--- a/qt4/src/poppler-private.h
+++ b/qt4/src/poppler-private.h
@@ -112,62 +112,11 @@ namespace Poppler {
 	
 	~DocumentData();
 	
-	OutputDev *getOutputDev()
-	{
-		if (!m_outputDev)
-		{
-			switch (m_backend)
-			{
-			case Document::ArthurBackend:
-			// create a splash backend even in case of the Arthur Backend
-			case Document::SplashBackend:
-			{
-#if defined(HAVE_SPLASH)
-			SplashColor bgColor;
-			bgColor[0] = paperColor.blue();
-			bgColor[1] = paperColor.green();
-			bgColor[2] = paperColor.red();
-			GBool AA = m_hints & Document::TextAntialiasing ? gTrue : gFalse;
-			SplashOutputDev * splashOutputDev = new SplashOutputDev(splashModeXBGR8, 4, gFalse, bgColor, gTrue, AA);
-			splashOutputDev->setVectorAntialias(m_hints & Document::Antialiasing ? gTrue : gFalse);
-			splashOutputDev->setFreeTypeHinting(m_hints & Document::TextHinting ? gTrue : gFalse, m_hints & Document::TextSlightHinting ? gTrue : gFalse);
-			splashOutputDev->startDoc(doc);
-			m_outputDev = splashOutputDev;
-#endif
-			break;
-			}
-			}
-		}
-		return m_outputDev;
-	}
-	
 	void addTocChildren( QDomDocument * docSyn, QDomNode * parent, GooList * items );
 	
 	void setPaperColor(const QColor &color)
 	{
-		if (color == paperColor)
-			return;
-
 		paperColor = color;
-		if ( m_outputDev == NULL )
-			return;
-
-		switch ( m_backend )
-		{
-			case Document::SplashBackend:
-			{
-#if defined(HAVE_SPLASH)
-				SplashOutputDev *splash_output = static_cast<SplashOutputDev *>( m_outputDev );
-				SplashColor bgColor;
-				bgColor[0] = paperColor.blue();
-				bgColor[1] = paperColor.green();
-				bgColor[2] = paperColor.red();
-				splash_output->setPaperColor(bgColor);
-#endif
-				break;
-			}
-			default: ;
-		}
 	}
 	
 	void fillMembers()
@@ -191,7 +140,6 @@ namespace Poppler {
 	bool locked;
 	FontIterator *m_fontInfoIterator;
 	Document::RenderBackend m_backend;
-	OutputDev *m_outputDev;
 	QList<EmbeddedFile*> m_embeddedFiles;
 	QPointer<OptContentModel> m_optContentModel;
 	QColor paperColor;
diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h
index 425b1e0..d3340d9 100644
--- a/qt4/src/poppler-qt4.h
+++ b/qt4/src/poppler-qt4.h
@@ -846,7 +846,8 @@ delete it;
 	    Antialiasing = 0x00000001,      ///< Antialiasing for graphics
 	    TextAntialiasing = 0x00000002,  ///< Antialiasing for text
 	    TextHinting = 0x00000004,       ///< Hinting for text \since 0.12.1
-	    TextSlightHinting = 0x00000008  ///< Lighter hinting for text when combined with TextHinting \since 0.18
+	    TextSlightHinting = 0x00000008, ///< Lighter hinting for text when combined with TextHinting \since 0.18
+	    OverprintPreview = 0x00000010   ///< Overprint preview \since 0.22
 	};
 	Q_DECLARE_FLAGS( RenderHints, RenderHint )
 
@@ -1249,6 +1250,13 @@ QString subject = m_doc->info("Subject");
 	QColor paperColor() const;
 
 	/**
+	  Okay to use overprint preview
+
+          \since 0.22.0
+	 */
+	static bool okToUseOverprint();
+
+	/**
 	 Sets the backend used to render the pages.
 
 	 \param backend the new rendering backend
diff --git a/splash/SplashBitmap.cc b/splash/SplashBitmap.cc
index 5fe61a2..824f764 100644
--- a/splash/SplashBitmap.cc
+++ b/splash/SplashBitmap.cc
@@ -441,6 +441,76 @@ void SplashBitmap::getRGBLine(int yl, SplashColorPtr line) {
   }
 }
 
+void SplashBitmap::getXBGRLine(int yl, SplashColorPtr line) {
+  SplashColor col;
+  double c, m, y, k, c1, m1, y1, k1, r, g, b;
+
+  for (int x = 0; x < width; x++) {
+    getPixel(x, yl, col);
+    c = byteToDbl(col[0]);
+    m = byteToDbl(col[1]);
+    y = byteToDbl(col[2]);
+    k = byteToDbl(col[3]);
+#if SPLASH_CMYK
+    if (separationList->getLength() > 0) {
+      for (int i = 0; i < separationList->getLength(); i++) {
+        if (col[i+4] > 0) {
+          GfxCMYK cmyk;
+          GfxColor input;
+          input.c[0] = byteToCol(col[i+4]);
+          GfxSeparationColorSpace *sepCS = (GfxSeparationColorSpace *)separationList->get(i);
+          sepCS->getCMYK(&input, &cmyk);
+          col[0] = colToByte(cmyk.c);
+          col[1] = colToByte(cmyk.m);
+          col[2] = colToByte(cmyk.y);
+          col[3] = colToByte(cmyk.k);
+          c += byteToDbl(col[0]);
+          m += byteToDbl(col[1]);
+          y += byteToDbl(col[2]);
+          k += byteToDbl(col[3]);
+        }
+      }
+      if (c > 1) c = 1;
+      if (m > 1) m = 1;
+      if (y > 1) y = 1;
+      if (k > 1) k = 1;
+    }
+#endif
+    c1 = 1 - c;
+    m1 = 1 - m;
+    y1 = 1 - y;
+    k1 = 1 - k;
+    cmykToRGBMatrixMultiplication(c, m, y, k, c1, m1, y1, k1, r, g, b);
+    *line++ = dblToByte(clip01(b));
+    *line++ = dblToByte(clip01(g));
+    *line++ = dblToByte(clip01(r));
+    *line++ = 255;
+  }
+}
+
+SplashColorPtr SplashBitmap::getXBGRPrt() {
+  if (mode == splashModeXBGR8)
+    return data;
+  
+  int newrowSize = width * 4;
+  SplashColorPtr newdata = (SplashColorPtr)gmallocn_checkoverflow(newrowSize, height);
+  if (newdata != NULL) {
+    for (int y = 0; y < height; y++) {
+      unsigned char *row = newdata + y * newrowSize;
+      getXBGRLine(y, row);
+    }
+    if (rowSize < 0) {
+      gfree(data + (height - 1) * rowSize);
+    } else {
+      gfree(data);
+    }
+    data = newdata;
+    rowSize = newrowSize;
+    mode = splashModeXBGR8;
+  }
+  return newdata;
+}
+
 #if SPLASH_CMYK
 void SplashBitmap::getCMYKLine(int yl, SplashColorPtr line) {
   SplashColor col;
diff --git a/splash/SplashBitmap.h b/splash/SplashBitmap.h
index 0bff205..64a9f67 100644
--- a/splash/SplashBitmap.h
+++ b/splash/SplashBitmap.h
@@ -64,6 +64,7 @@ public:
   int getRowPad() { return rowPad; }
   SplashColorMode getMode() { return mode; }
   SplashColorPtr getDataPtr() { return data; }
+  SplashColorPtr getXBGRPrt();
   Guchar *getAlphaPtr() { return alpha; }
   GooList *getSeparationList() { return separationList; }
 
@@ -77,6 +78,7 @@ public:
 
   void getPixel(int x, int y, SplashColorPtr pixel);
   void getRGBLine(int y, SplashColorPtr line);
+  void getXBGRLine(int y, SplashColorPtr line);
 #if SPLASH_CMYK
   void getCMYKLine(int y, SplashColorPtr line);
 #endif
diff --git a/cmake/modules/FindPoppler.cmake b/cmake/modules/FindPoppler.cmake
index 1763ee9..31e4558 100644
--- a/cmake/modules/FindPoppler.cmake
+++ b/cmake/modules/FindPoppler.cmake
@@ -112,6 +112,15 @@ int main()
 }
 " HAVE_POPPLER_0_22)
 
+check_cxx_source_compiles("
+#include <poppler-qt4.h>
+int main()
+{
+  Poppler::Document::RenderHint hint = Poppler::Document::OverprintPreview;
+  return 0;
+}
+" HAVE_POPPLER_0_22_CMYK)
+
   set(CMAKE_REQUIRED_INCLUDES)
   set(CMAKE_REQUIRED_LIBRARIES)
   if (HAVE_POPPLER_0_22)
diff --git a/conf/dlgaccessibilitybase.ui b/conf/dlgaccessibilitybase.ui
index 9e76a75..e69f1e1 100644
--- a/conf/dlgaccessibilitybase.ui
+++ b/conf/dlgaccessibilitybase.ui
@@ -37,6 +37,13 @@
     </widget>
    </item>
    <item>
+    <widget class="QCheckBox" name="kcfg_OverprintPreview" >
+     <property name="text" >
+      <string>Simulate &amp;Overprint</string>
+     </property>
+    </widget>
+   </item>
+   <item>
     <widget class="QGroupBox" name="kcfg_ChangeColors" >
      <property name="enabled" >
       <bool>true</bool>
diff --git a/conf/okular.kcfg b/conf/okular.kcfg
index 22783c7..bfab496 100644
--- a/conf/okular.kcfg
+++ b/conf/okular.kcfg
@@ -23,6 +23,9 @@
   <entry key="HighlightLinks" type="Bool" >
    <default>false</default>
   </entry>
+  <entry key="OverprintPreview" type="Bool" >
+   <default>false</default>
+  </entry>
   <entry key="ChangeColors" type="Bool" >
    <default>false</default>
   </entry>
diff --git a/core/document.cpp b/core/document.cpp
index 9d6b25c..b2ef271 100644
--- a/core/document.cpp
+++ b/core/document.cpp
@@ -1571,6 +1571,10 @@ QVariant DocumentPrivate::documentMetaData( const QString &key, const QVariant &
         }
         return color;
     }
+    else if ( key == QLatin1String( "OverprintPreview" ) )
+    {
+        return Settings::overprintPreview();
+    }
     else if ( key == QLatin1String( "ZoomFactor" ) )
     {
         return Settings::zoomFactor();
diff --git a/generators/poppler/annots.cpp b/generators/poppler/annots.cpp
index 02813a1..8eb9a9a 100644
--- a/generators/poppler/annots.cpp
+++ b/generators/poppler/annots.cpp
@@ -90,7 +90,9 @@ void PopplerAnnotationProxy::notifyAddition( Okular::Annotation *okl_ann, int pa
     QDomElement dom_ann = doc.createElement( "root" );
     Okular::AnnotationUtils::storeAnnotation( okl_ann, dom_ann, doc );
 
+#ifndef POPPLER_QT4_THREADSAFE
     QMutexLocker ml(mutex);
+#endif
 
     // Create poppler annotation
     Poppler::Annotation *ppl_ann = Poppler::AnnotationUtils::createAnnotation( dom_ann );
@@ -143,7 +145,9 @@ void PopplerAnnotationProxy::notifyModification( const Okular::Annotation *okl_a
     if ( !ppl_ann ) // Ignore non-native annotations
         return;
 
+#ifndef POPPLER_QT4_THREADSAFE
     QMutexLocker ml(mutex);
+#endif
 
     if ( okl_ann->flags() & Okular::Annotation::BeingMoved )
     {
@@ -253,7 +257,9 @@ void PopplerAnnotationProxy::notifyRemoval( Okular::Annotation *okl_ann, int pag
     if ( !ppl_ann ) // Ignore non-native annotations
         return;
 
+#ifndef POPPLER_QT4_THREADSAFE
     QMutexLocker ml(mutex);
+#endif
 
     Poppler::Page *ppl_page = ppl_doc->page( page );
     ppl_page->removeAnnotation( ppl_ann ); // Also destroys ppl_ann
diff --git a/generators/poppler/config-okular-poppler.h.cmake b/generators/poppler/config-okular-poppler.h.cmake
index 2ce6a4a..f0cd2f4 100644
--- a/generators/poppler/config-okular-poppler.h.cmake
+++ b/generators/poppler/config-okular-poppler.h.cmake
@@ -9,3 +9,6 @@
 
 /* Defined if we have the 0.22 version of the Poppler library */
 #cmakedefine HAVE_POPPLER_0_22 1
+
+/* Defined if we have the 0.22 version of the Poppler library with overprint */
+#cmakedefine HAVE_POPPLER_0_22_CMYK 1
diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp
index 9462195..52d096f 100644
--- a/generators/poppler/generator_pdf.cpp
+++ b/generators/poppler/generator_pdf.cpp
@@ -545,12 +545,16 @@ bool PDFGenerator::init(QVector<Okular::Page*> & pagesVector, const QString &wal
 bool PDFGenerator::doCloseDocument()
 {
     // remove internal objects
+#ifndef POPPLER_QT4_THREADSAFE
     userMutex()->lock();
+#endif
     delete annotProxy;
     annotProxy = 0;
     delete pdfdoc;
     pdfdoc = 0;
+#ifndef POPPLER_QT4_THREADSAFE
     userMutex()->unlock();
+#endif
     docInfoDirty = true;
     docSynopsisDirty = true;
     docSyn.clear();
@@ -635,7 +639,9 @@ const Okular::DocumentInfo * PDFGenerator::generateDocumentInfo()
 {
     if ( docInfoDirty )
     {
+#ifndef POPPLER_QT4_THREADSAFE
         userMutex()->lock();
+#endif
 
         docInfo.set( Okular::DocumentInfo::MimeType, "application/pdf" );
 
@@ -682,7 +688,9 @@ const Okular::DocumentInfo * PDFGenerator::generateDocumentInfo()
 
             docInfo.set( Okular::DocumentInfo::Pages, i18n("Unknown") );
         }
+#ifndef POPPLER_QT4_THREADSAFE
         userMutex()->unlock();
+#endif
 
         // if pdfdoc is valid then we cached good info -> don't cache them again
         if ( pdfdoc )
@@ -699,9 +707,13 @@ const Okular::DocumentSynopsis * PDFGenerator::generateDocumentSynopsis()
     if ( !pdfdoc )
         return NULL;
 
+#ifndef POPPLER_QT4_THREADSAFE
     userMutex()->lock();
+#endif
     QDomDocument *toc = pdfdoc->toc();
+#ifndef POPPLER_QT4_THREADSAFE
     userMutex()->unlock();
+#endif
     if ( !toc )
         return NULL;
 
@@ -780,9 +792,13 @@ Okular::FontInfo::List PDFGenerator::fontsForPage( int page )
         return list;
 
     QList<Poppler::FontInfo> fonts;
+#ifndef POPPLER_QT4_THREADSAFE
     userMutex()->lock();
+#endif
     pdfdoc->scanForFonts( 1, &fonts );
+#ifndef POPPLER_QT4_THREADSAFE
     userMutex()->unlock();
+#endif
 
     foreach (const Poppler::FontInfo &font, fonts)
     {
@@ -809,13 +825,17 @@ const QList<Okular::EmbeddedFile*> *PDFGenerator::embeddedFiles() const
 {
     if (docEmbeddedFilesDirty)
     {
+#ifndef POPPLER_QT4_THREADSAFE
         userMutex()->lock();
+#endif
         const QList<Poppler::EmbeddedFile*> &popplerFiles = pdfdoc->embeddedFiles();
         foreach(Poppler::EmbeddedFile* pef, popplerFiles)
         {
             docEmbeddedFiles.append(new PDFEmbeddedFile(pef));
         }
+#ifndef POPPLER_QT4_THREADSAFE
         userMutex()->unlock();
+#endif
 
         docEmbeddedFilesDirty = false;
     }
@@ -869,7 +889,9 @@ QImage PDFGenerator::image( Okular::PixmapRequest * request )
     bool genObjectRects = !rectsGenerated.at( page->number() );
 
     // 0. LOCK [waits for the thread end]
+#ifndef POPPLER_QT4_THREADSAFE
     userMutex()->lock();
+#endif
 
     // 1. Set OutputDev parameters and Generate contents
     // note: thread safety is set on 'false' for the GUI (this) thread
@@ -899,7 +921,9 @@ QImage PDFGenerator::image( Okular::PixmapRequest * request )
     }
 
     // 3. UNLOCK [re-enables shared access]
+#ifndef POPPLER_QT4_THREADSAFE
     userMutex()->unlock();
+#endif
 
     delete p;
 
@@ -977,9 +1001,13 @@ Okular::TextPage* PDFGenerator::textPage( Okular::Page *page )
     Poppler::Page *pp = pdfdoc->page( page->number() );
     if (pp)
     {
+#ifndef POPPLER_QT4_THREADSAFE
         userMutex()->lock();
+#endif
         textList = pp->textList();
+#ifndef POPPLER_QT4_THREADSAFE
         userMutex()->unlock();
+#endif
 
         QSizeF s = pp->pageSizeF();
         pageWidth = s.width();
@@ -1020,7 +1048,9 @@ bool PDFGenerator::print( QPrinter& printer )
             printer.newPage();
 
         const int page = pageList.at( i ) - 1;
+#ifndef POPPLER_QT4_THREADSAFE
         userMutex()->lock();
+#endif
         Poppler::Page *pp = pdfdoc->page( page );
         if (pp)
         {
@@ -1028,7 +1058,9 @@ bool PDFGenerator::print( QPrinter& printer )
             painter.drawImage( painter.window(), img, QRectF(0, 0, img.width(), img.height()) );
             delete pp;
         }
+#ifndef POPPLER_QT4_THREADSAFE
         userMutex()->unlock();
+#endif
     }
     painter.end();
     return true;
@@ -1100,10 +1132,14 @@ bool PDFGenerator::print( QPrinter& printer )
         psConverter->setPSOptions(psConverter->psOptions() | Poppler::PSConverter::HideAnnotations );
 #endif
 
+#ifndef POPPLER_QT4_THREADSAFE
     userMutex()->lock();
+#endif
     if (psConverter->convert())
     {
+#ifndef POPPLER_QT4_THREADSAFE
         userMutex()->unlock();
+#endif
         delete psConverter;
         tf.close();
         int ret = Okular::FilePrinter::printFile( printer, tempfilename,
@@ -1120,7 +1156,9 @@ bool PDFGenerator::print( QPrinter& printer )
     {
         lastPrintError = FileConversionPrintError;
         delete psConverter;
+#ifndef POPPLER_QT4_THREADSAFE
         userMutex()->unlock();
+#endif
     }
 
     tf.close();
@@ -1133,7 +1171,9 @@ QVariant PDFGenerator::metaData( const QString & key, const QVariant & option )
 {
     if ( key == "StartFullScreen" )
     {
+#ifndef POPPLER_QT4_THREADSAFE
         QMutexLocker ml(userMutex());
+#endif
         // asking for the 'start in fullscreen mode' (pdf property)
         if ( pdfdoc->pageMode() == Poppler::Document::FullScreen )
             return true;
@@ -1153,9 +1193,13 @@ QVariant PDFGenerator::metaData( const QString & key, const QVariant & option )
         {
             // asking for the page related to a 'named link destination'. the
             // option is the link name. @see addSynopsisChildren.
+#ifndef POPPLER_QT4_THREADSAFE
             userMutex()->lock();
+#endif
             Poppler::LinkDestination *ld = pdfdoc->linkDestination( optionString );
+#ifndef POPPLER_QT4_THREADSAFE
             userMutex()->unlock();
+#endif
             if ( ld )
             {
                 fillViewportFromLinkDestination( viewport, *ld );
@@ -1167,20 +1211,28 @@ QVariant PDFGenerator::metaData( const QString & key, const QVariant & option )
     }
     else if ( key == "DocumentTitle" )
     {
+#ifndef POPPLER_QT4_THREADSAFE
         userMutex()->lock();
+#endif
         QString title = pdfdoc->info( "Title" );
+#ifndef POPPLER_QT4_THREADSAFE
         userMutex()->unlock();
+#endif
         return title;
     }
     else if ( key == "OpenTOC" )
     {
+#ifndef POPPLER_QT4_THREADSAFE
         QMutexLocker ml(userMutex());
+#endif
         if ( pdfdoc->pageMode() == Poppler::Document::UseOutlines )
             return true;
     }
     else if ( key == "DocumentScripts" && option.toString() == "JavaScript" )
     {
+#ifndef POPPLER_QT4_THREADSAFE
         QMutexLocker ml(userMutex());
+#endif
         return pdfdoc->scripts();
     }
     return QVariant();
@@ -1199,9 +1251,13 @@ bool PDFGenerator::reparseConfig()
     // over the page rendered on 'standard' white background.
     if ( color != pdfdoc->paperColor() )
     {
+#ifndef POPPLER_QT4_THREADSAFE
         userMutex()->lock();
+#endif
         pdfdoc->setPaperColor(color);
+#ifndef POPPLER_QT4_THREADSAFE
         userMutex()->unlock();
+#endif
         somethingchanged = true;
     }
     bool aaChanged = setDocumentRenderHints();
@@ -1231,6 +1287,11 @@ bool PDFGenerator::setDocumentRenderHints()
 #ifdef HAVE_POPPLER_0_12_1
     SET_HINT("TextHinting", false, Poppler::Document::TextHinting)
 #endif
+#ifdef HAVE_POPPLER_0_22_CMYK
+    if (Poppler::Document::okToUseOverprint()) {
+      SET_HINT("OverprintPreview", false, Poppler::Document::OverprintPreview)
+    }
+#endif
 #undef SET_HINT
     return changed;
 }
@@ -1257,13 +1318,17 @@ bool PDFGenerator::exportTo( const QString &fileName, const Okular::ExportFormat
         for ( int i = 0; i < num; ++i )
         {
             QString text;
+#ifndef POPPLER_QT4_THREADSAFE
             userMutex()->lock();
+#endif
             Poppler::Page *pp = pdfdoc->page(i);
             if (pp)
             {
                 text = pp->text(QRect()).normalized(QString::NormalizationForm_KC);
             }
+#ifndef POPPLER_QT4_THREADSAFE
             userMutex()->unlock();
+#endif
             ts << text;
             delete pp;
         }
@@ -1789,7 +1854,9 @@ bool PDFGenerator::save( const QString &fileName, SaveOptions options, QString *
     if ( options & SaveChanges )
         pdfConv->setPDFOptions( pdfConv->pdfOptions() | Poppler::PDFConverter::WithChanges );
 
+#ifndef POPPLER_QT4_THREADSAFE
     QMutexLocker locker( userMutex() );
+#endif
     bool success = pdfConv->convert();
 #ifdef HAVE_POPPLER_0_12_1
     if (!success)
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to