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. 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

.


diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc
index 550e706..5d34239 100644
--- a/qt4/src/poppler-document.cc
+++ b/qt4/src/poppler-document.cc
@@ -450,6 +450,11 @@ namespace Poppler {
         m_doc->setPaperColor(color);
     }
     
+    void Document::setOverprintPreview(bool overprint)
+    {
+        m_doc->setOverprintPreview(overprint);
+    }
+    
     void Document::setColorDisplayProfile(void* outputProfileA)
     {
 #if defined(USE_CMS)
@@ -493,6 +498,11 @@ namespace Poppler {
     	return m_doc->paperColor;
     }
 
+    bool Document::overprintPreview() const
+    {
+    	return m_doc->overprintPreview;
+    }
+
     void Document::setRenderBackend( Document::RenderBackend backend )
     {
         // no need to delete the outputdev as for the moment we always create a splash one
@@ -523,14 +533,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..b51afca 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.cc
@@ -257,7 +257,51 @@ 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;
+#if defined(SPLASH_CMYK)
+      if (m_page->parentDoc->overprintPreview)
+      {
+        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)
+	(m_page->parentDoc->overprintPreview) ? 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 +310,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 +331,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..2baa0a4 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;
@@ -252,6 +250,7 @@ namespace Debug {
             globalParams = new GlobalParams();
             setErrorCallback(qt4ErrorFunction, NULL);
         }
+        overprintPreview = globalParams->getOverprintPreview();
         count ++;
     }
 
diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h
index 6d2ef2a..3b487ca 100644
--- a/qt4/src/poppler-private.h
+++ b/qt4/src/poppler-private.h
@@ -112,64 +112,19 @@ 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 setOverprintPreview( bool overprint)
+        {
+                overprintPreview = overprint;
+                globalParams->setOverprintPreview(overprintPreview);
+        }
+	
 	void fillMembers()
 	{
 		m_fontInfoIterator = new FontIterator(0, this);
@@ -191,10 +146,10 @@ namespace Poppler {
 	bool locked;
 	FontIterator *m_fontInfoIterator;
 	Document::RenderBackend m_backend;
-	OutputDev *m_outputDev;
 	QList<EmbeddedFile*> m_embeddedFiles;
 	QPointer<OptContentModel> m_optContentModel;
 	QColor paperColor;
+        bool overprintPreview;
 	int m_hints;
 	static int count;
     };
diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h
index 425b1e0..a63734e 100644
--- a/qt4/src/poppler-qt4.h
+++ b/qt4/src/poppler-qt4.h
@@ -1249,6 +1249,19 @@ QString subject = m_doc->info("Subject");
 	QColor paperColor() const;
 
 	/**
+	  Sets the overprint preview
+
+	  \param overprintPreview the new overprint mode
+	 */
+	void setOverprintPreview(const bool overprintPreview);
+	/**
+	  The overprint preview
+
+	  The overprint preview is false.
+	 */
+	bool overprintPreview() const;
+
+	/**
 	 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/conf/dlgaccessibilitybase.ui b/conf/dlgaccessibilitybase.ui
index 9e76a75..a9f374f 100644
--- a/conf/dlgaccessibilitybase.ui
+++ b/conf/dlgaccessibilitybase.ui
@@ -37,6 +37,13 @@
     </widget>
    </item>
    <item>
+    <widget class="QCheckBox" name="kcfg_Overprint" >
+     <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..0449873 100644
--- a/conf/okular.kcfg
+++ b/conf/okular.kcfg
@@ -23,6 +23,9 @@
   <entry key="HighlightLinks" type="Bool" >
    <default>false</default>
   </entry>
+  <entry key="Overprint" 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..e930461 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( "Overprint" ) )
+    {
+        return Settings::overprint();
+    }
     else if ( key == QLatin1String( "ZoomFactor" ) )
     {
         return Settings::zoomFactor();
diff --git a/generators/poppler/annots.cpp b/generators/poppler/annots.cpp
index 02813a1..612d72f 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_QT_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_QT_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_QT_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/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp
index 9462195..47eacc2 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_QT_THREADSAFE
     userMutex()->lock();
+#endif
     delete annotProxy;
     annotProxy = 0;
     delete pdfdoc;
     pdfdoc = 0;
+#ifndef POPPLER_QT_THREADSAFE
     userMutex()->unlock();
+#endif
     docInfoDirty = true;
     docSynopsisDirty = true;
     docSyn.clear();
@@ -635,7 +639,9 @@ const Okular::DocumentInfo * PDFGenerator::generateDocumentInfo()
 {
     if ( docInfoDirty )
     {
+#ifndef POPPLER_QT_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_QT_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_QT_THREADSAFE
     userMutex()->lock();
+#endif
     QDomDocument *toc = pdfdoc->toc();
+#ifndef POPPLER_QT_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_QT_THREADSAFE
     userMutex()->lock();
+#endif
     pdfdoc->scanForFonts( 1, &fonts );
+#ifndef POPPLER_QT_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_QT_THREADSAFE
         userMutex()->lock();
+#endif
         const QList<Poppler::EmbeddedFile*> &popplerFiles = pdfdoc->embeddedFiles();
         foreach(Poppler::EmbeddedFile* pef, popplerFiles)
         {
             docEmbeddedFiles.append(new PDFEmbeddedFile(pef));
         }
+#ifndef POPPLER_QT_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_QT_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_QT_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_QT_THREADSAFE
         userMutex()->lock();
+#endif
         textList = pp->textList();
+#ifndef POPPLER_QT_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_QT_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_QT_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_QT_THREADSAFE
     userMutex()->lock();
+#endif
     if (psConverter->convert())
     {
+#ifndef POPPLER_QT_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_QT_THREADSAFE
         userMutex()->unlock();
+#endif
     }
 
     tf.close();
@@ -1133,7 +1171,9 @@ QVariant PDFGenerator::metaData( const QString & key, const QVariant & option )
 {
     if ( key == "StartFullScreen" )
     {
+#ifndef POPPLER_QT_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_QT_THREADSAFE
             userMutex()->lock();
+#endif
             Poppler::LinkDestination *ld = pdfdoc->linkDestination( optionString );
+#ifndef POPPLER_QT_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_QT_THREADSAFE
         userMutex()->lock();
+#endif
         QString title = pdfdoc->info( "Title" );
+#ifndef POPPLER_QT_THREADSAFE
         userMutex()->unlock();
+#endif
         return title;
     }
     else if ( key == "OpenTOC" )
     {
+#ifndef POPPLER_QT_THREADSAFE
         QMutexLocker ml(userMutex());
+#endif
         if ( pdfdoc->pageMode() == Poppler::Document::UseOutlines )
             return true;
     }
     else if ( key == "DocumentScripts" && option.toString() == "JavaScript" )
     {
+#ifndef POPPLER_QT_THREADSAFE
         QMutexLocker ml(userMutex());
+#endif
         return pdfdoc->scripts();
     }
     return QVariant();
@@ -1199,9 +1251,25 @@ bool PDFGenerator::reparseConfig()
     // over the page rendered on 'standard' white background.
     if ( color != pdfdoc->paperColor() )
     {
+#ifndef POPPLER_QT_THREADSAFE
         userMutex()->lock();
+#endif
         pdfdoc->setPaperColor(color);
+#ifndef POPPLER_QT_THREADSAFE
         userMutex()->unlock();
+#endif
+        somethingchanged = true;
+    }
+    bool overprintPreview = documentMetaData("Overprint").toBool();
+    if (overprintPreview != pdfdoc->overprintPreview()) 
+    {
+#ifndef POPPLER_QT_THREADSAFE
+        userMutex()->lock();
+#endif
+        pdfdoc->setOverprintPreview(overprintPreview);
+#ifndef POPPLER_QT_THREADSAFE
+        userMutex()->unlock();
+#endif
         somethingchanged = true;
     }
     bool aaChanged = setDocumentRenderHints();
@@ -1257,13 +1325,17 @@ bool PDFGenerator::exportTo( const QString &fileName, const Okular::ExportFormat
         for ( int i = 0; i < num; ++i )
         {
             QString text;
+#ifndef POPPLER_QT_THREADSAFE
             userMutex()->lock();
+#endif
             Poppler::Page *pp = pdfdoc->page(i);
             if (pp)
             {
                 text = pp->text(QRect()).normalized(QString::NormalizationForm_KC);
             }
+#ifndef POPPLER_QT_THREADSAFE
             userMutex()->unlock();
+#endif
             ts << text;
             delete pp;
         }
@@ -1789,7 +1861,9 @@ bool PDFGenerator::save( const QString &fileName, SaveOptions options, QString *
     if ( options & SaveChanges )
         pdfConv->setPDFOptions( pdfConv->pdfOptions() | Poppler::PDFConverter::WithChanges );
 
+#ifndef POPPLER_QT_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