[poppler] poppler/qt4/src: poppler-document.cc, 1.30, 1.31 poppler-page.cc, 1.34, 1.35 poppler-private.h, 1.19, 1.20 poppler-qt4.h, 1.44, 1.45

Albert Astals Cid aacid at kemper.freedesktop.org
Sun Jan 21 14:35:25 PST 2007


Update of /cvs/poppler/poppler/qt4/src
In directory kemper:/tmp/cvs-serv31964/qt4/src

Modified Files:
	poppler-document.cc poppler-page.cc poppler-private.h 
	poppler-qt4.h 
Log Message:
       * poppler-document.cc:
       * poppler-page.cc:
       * poppler-private.h:
       * poppler-qt4.h:
       No need to destroy the Splash output device to change its paper color.
       Add the possibility to set flags that affect the rendering (some
       backends supports only some of them, though).
       Add a Page::label to get the label associated with a page.
       Patches by Pino Toscano <pino at kde.org>.


Index: poppler-document.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-document.cc,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- poppler-document.cc	13 Jan 2007 23:19:21 -0000	1.30
+++ poppler-document.cc	21 Jan 2007 22:35:23 -0000	1.31
@@ -478,6 +478,26 @@
         return ret;
     }
 
+    void Document::setRenderHint( Document::RenderHint hint, bool on )
+    {
+        if ( on )
+            m_doc->m_hints |= hint;
+        else
+            m_doc->m_hints &= ~(int)hint;
+
+        // the only way to set the textAA for Splash is on creation
+        if ( m_doc->m_backend == Document::SplashBackend && hint == Document::TextAntialiasing )
+        {
+            delete m_doc->m_outputDev;
+            m_doc->m_outputDev = NULL;
+        }
+    }
+
+    Document::RenderHints Document::renderHints() const
+    {
+        return Document::RenderHints() & m_doc->m_hints;
+    }
+
     QDateTime convertDate( char *dateString )
     {
         int year;

Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-page.cc,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- poppler-page.cc	13 Jan 2007 23:19:21 -0000	1.34
+++ poppler-page.cc	21 Jan 2007 22:35:23 -0000	1.35
@@ -215,7 +215,10 @@
       QImage tmpimg(w == -1 ? size.width() : w, h == -1 ? size.height() : h, QImage::Format_ARGB32);
 
       QPainter painter(&tmpimg);
-      painter.setRenderHint(QPainter::Antialiasing);
+      if (m_page->parentDoc->m_doc->m_hints & Document::Antialiasing)
+          painter.setRenderHint(QPainter::Antialiasing);
+      if (m_page->parentDoc->m_doc->m_hints & Document::TextAntialiasing)
+          painter.setRenderHint(QPainter::TextAntialiasing);
       painter.save();
       painter.translate(x == -1 ? 0 : -x, y == -1 ? 0 : -y);
       if (w == -1 && h == -1)
@@ -1242,5 +1245,14 @@
   else return -1;
 }
 
+QString Page::label() const
+{
+  GooString goo;
+  if (!m_page->parentDoc->m_doc->doc->getCatalog()->indexToLabel(m_page->index, &goo))
+    return QString();
+
+  return QString(goo.getCString());
+}
+
 
 }

Index: poppler-private.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-private.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- poppler-private.h	13 Jan 2007 23:19:21 -0000	1.19
+++ poppler-private.h	21 Jan 2007 22:35:23 -0000	1.20
@@ -125,7 +125,8 @@
 			bgColor[0] = paperColor.red();
 			bgColor[1] = paperColor.green();
 			bgColor[2] = paperColor.blue();
-			SplashOutputDev * splashOutputDev = new SplashOutputDev(splashModeRGB8Qt, 4, gFalse, bgColor);
+			GBool AA = m_hints & Document::TextAntialiasing ? gTrue : gFalse;
+			SplashOutputDev * splashOutputDev = new SplashOutputDev(splashModeRGB8Qt, 4, gFalse, bgColor, gTrue, AA);
 			splashOutputDev->startDoc(doc->getXRef());
 			m_outputDev = splashOutputDev;
 #endif
@@ -193,11 +194,28 @@
 	
 	void setPaperColor(const QColor &color)
 	{
-		if (color != paperColor)
+		if (color == paperColor)
+			return;
+
+		paperColor = color;
+		if ( m_outputDev == NULL )
+			return;
+
+		switch ( m_backend )
 		{
-			paperColor = color;
-			delete m_outputDev;
-			m_outputDev = NULL;
+			case Document::SplashBackend:
+			{
+#if defined(HAVE_SPLASH)
+				SplashOutputDev *splash_output = static_cast<SplashOutputDev *>( m_outputDev );
+				SplashColor bgColor;
+				bgColor[0] = paperColor.red();
+				bgColor[1] = paperColor.green();
+				bgColor[2] = paperColor.blue();
+				splash_output->setPaperColor(bgColor);
+#endif
+				break;
+			}
+			default: ;
 		}
 	}
 	
@@ -223,6 +241,7 @@
 	OutputDev *m_outputDev;
 	QList<EmbeddedFile*> m_embeddedFiles;
 	QColor paperColor;
+	int m_hints;
 	static int count;
     };
 

Index: poppler-qt4.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-qt4.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- poppler-qt4.h	13 Jan 2007 18:29:39 -0000	1.44
+++ poppler-qt4.h	21 Jan 2007 22:35:23 -0000	1.45
@@ -382,6 +382,11 @@
 	*/
 	double duration() const;
 	
+	/**
+	   Returns the label of the page, or a null string is the page has no label.
+	**/
+	QString label() const;
+	
     private:
 	Page(const Document *doc, int index);
 	PageData *m_page;
@@ -432,6 +437,15 @@
 	};
 
 	/**
+	   The render hints available
+	*/
+	enum RenderHint {
+	    Antialiasing = 0x00000001,      ///< Antialiasing for graphics
+	    TextAntialiasing = 0x00000002   ///< Antialiasing for text
+	};
+	Q_DECLARE_FLAGS( RenderHints, RenderHint )
+
+	/**
 	   Load the document from a file on disk
 
 	   \param filePath the name (and path, if required) of the file to load
@@ -737,6 +751,17 @@
 	 */
 	static QSet<RenderBackend> availableRenderBackends();
 
+	/**
+	 Sets the render \p hint .
+
+	 \param on whether the flag should be added or removed.
+	 */
+	void setRenderHint( RenderHint hint, bool on = true );
+	/**
+	  The currently set render hints.
+	 */
+	RenderHints renderHints() const;
+
 	~Document();
   
     private:



More information about the poppler mailing list