[poppler] poppler/qt4/tests: test-poppler-qt4.cpp,1.3,1.4

Albert Astals Cid aacid at freedesktop.org
Mon Nov 28 14:50:22 PST 2005


Update of /cvs/poppler/poppler/qt4/tests
In directory gabe:/tmp/cvs-serv21107/qt4/tests

Modified Files:
	test-poppler-qt4.cpp 
Log Message:
Fix QPixmap contents generation messed when doing the xpdf 3.01 transition in qt4 frontend
Use Splash backend by default in the qt4 test, added -arthur option to use the Arthur backend


Index: test-poppler-qt4.cpp
===================================================================
RCS file: /cvs/poppler/poppler/qt4/tests/test-poppler-qt4.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- test-poppler-qt4.cpp	3 Aug 2005 11:44:55 -0000	1.3
+++ test-poppler-qt4.cpp	28 Nov 2005 22:50:20 -0000	1.4
@@ -9,7 +9,7 @@
 class PDFDisplay : public QWidget           // picture display widget
 {
 public:
-    PDFDisplay( Poppler::Document *d );
+    PDFDisplay( Poppler::Document *d, bool arthur );
     ~PDFDisplay();
 protected:
     void paintEvent( QPaintEvent * );
@@ -17,30 +17,40 @@
 private:
     void display();
     int m_currentPage;
-    QPixmap	*pixmap;
+    QPixmap *pixmap;
     Poppler::Document *doc;
+    bool useArthur;
 };
 
-PDFDisplay::PDFDisplay( Poppler::Document *d )
+PDFDisplay::PDFDisplay( Poppler::Document *d, bool arthur )
 {
     doc = d;
     m_currentPage = 0;
+    useArthur = arthur;
     display();
 }
 
 void PDFDisplay::display()
 {
     if (doc) {
-	Poppler::Page *page = doc->page(m_currentPage);
-	if (page) {
-	    qDebug() << "Displaying page: " << m_currentPage;
-	    pixmap = new QPixmap(page->pageSize());
-	    page->renderToPixmap(pixmap);
-	    update();
-	    delete page;
-	}
+        Poppler::Page *page = doc->page(m_currentPage);
+        if (page) {
+            pixmap = new QPixmap(page->pageSize());
+            if (useArthur)
+            {
+                qDebug() << "Displaying page using Arthur backend: " << m_currentPage;
+                page->renderToPixmap(pixmap);
+            }
+            else
+            {
+                qDebug() << "Displaying page using Splash backend: " << m_currentPage;
+                page->splashRenderToPixmap(&pixmap, -1, -1, 0, 0);
+            }
+            update();
+            delete page;
+        }
     } else {
-	qWarning() << "doc not loaded";
+        qWarning() << "doc not loaded";
     }
 }
 
@@ -88,10 +98,12 @@
 {
     QApplication a( argc, argv );               // QApplication required!
 
-    if ( argc < 2  || (argc == 3 && strcmp(argv[2], "-extract") != 0) || argc > 3)
+    if ( argc < 2 ||
+        (argc == 3 && strcmp(argv[2], "-extract") != 0 && strcmp(argv[2], "-arthur") != 0) ||
+        argc > 3)
     {
 	// use argument as file name
-	qWarning() << "usage: test-poppler-qt filename [-extract]";
+	qWarning() << "usage: test-poppler-qt filename [-extract|-arthur]";
 	exit(1);
     }
   
@@ -128,13 +140,14 @@
     Poppler::Page *page = doc->page(0);
     qDebug() << "    Page 1 size: " << page->pageSize().width()/72 << "inches x " << page->pageSize().height()/72 << "inches";
 
-    if (argc == 2)
-    {  
-	PDFDisplay test( doc );        // create picture display
-	test.setWindowTitle("Poppler-Qt4 Test");
-	test.show();                            // show it
+    if (argc == 2 || (argc == 3 && strcmp(argv[2], "-arthur") == 0))
+    {
+        bool useArthur = (argc == 3 && strcmp(argv[2], "-arthur") == 0);
+        PDFDisplay test( doc, useArthur );        // create picture display
+        test.setWindowTitle("Poppler-Qt4 Test");
+        test.show();                            // show it
 
-	return a.exec();                        // start event loop
+        return a.exec();                        // start event loop
     }
     else
     {



More information about the poppler mailing list