[PATCH] Okular: support Poppler 0.8

View: New views
3 Messages — Rating Filter:   Alert me  

[PATCH] Okular: support Poppler 0.8

by Bugzilla from huntedhacker@tiscali.co.uk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

The attached patch makes okular compile when the installed version of poppler is 0.8.

It also fixes the 0.7 conditionals to use #ifdef rather than #if, so gcc doesn't generate warnings when 0.6 is installed.

OK to commit?

Alex

--

KDE: http://www.kde.org

Ubuntu/Kubuntu: http://www.ubuntu.org http://www.kubuntu.org


[okular-poppler-0.8.patch]

Index: generator_pdf.cpp
===================================================================
--- generator_pdf.cpp (revision 800167)
+++ generator_pdf.cpp (working copy)
@@ -46,6 +46,24 @@
 
 static const int PDFDebug = 4710;
 
+static inline double leftEdge(Poppler::TextBox *word, int pos)
+{
+#ifdef HAVE_POPPLER_0_8
+    return word->charBoundingBox(pos).left();
+#else
+    return word->edge(pos);
+#endif
+}
+
+static inline double rightEdge(Poppler::TextBox *word, int pos)
+{
+#ifdef HAVE_POPPLER_0_8
+    return word->charBoundingBox(pos).right();
+#else
+    return word->edge(pos+1);
+#endif
+}
+
 class PDFOptionsPage : public QWidget
 {
    public:
@@ -817,7 +835,7 @@ bool PDFGenerator::print( QPrinter& prin
 
     // TODO rotation
 
-#if HAVE_POPPLER_0_7
+#ifdef HAVE_POPPLER_0_7
     tf.setAutoRemove(false);
 #else
     tf.close();
@@ -833,7 +851,7 @@ bool PDFGenerator::print( QPrinter& prin
 
     Poppler::PSConverter *psConverter = pdfdoc->psConverter();
 
-#if HAVE_POPPLER_0_7
+#ifdef HAVE_POPPLER_0_7
     psConverter->setOutputDevice(&tf);
 #else
     psConverter->setOutputFileName(tempfilename);
@@ -1081,20 +1099,20 @@ Okular::TextPage * PDFGenerator::abstrac
                 s = word->text().at(j);
                 append(ktp, (j==charCount-1 && !next ) ? (s + '\n') : s,
                     // this letters boundary
-                    word->edge(j)/width,
+                    leftEdge(word, j)/width,
                     wordRect->bottom/height,
                     // next letters boundary
-                    word->edge(j+1)/width,
+                    rightEdge(word, j)/width,
                     wordRect->top/height);
             }
             
             if ( word->hasSpaceAfter() && next )
               append(ktp, " ",
                     // this letters boundary
-                     word->edge(charCount)/width,
+                     rightEdge(word, charCount-1)/width,
                      wordRect->bottom/height,
                     // next letters boundary
-                     next->edge(0)/width,
+                     leftEdge(next, 0)/width,
                      wordRect->top/height);
             break;
 
@@ -1106,19 +1124,19 @@ Okular::TextPage * PDFGenerator::abstrac
                 s=word->text().at(j);
                 append(ktp, (j==charCount-1 && !next ) ? (s + '\n') : s,
                     wordRect->left/width,
-                    word->edge(j)/height,
+                    leftEdge(word, j)/height,
                     wordRect->right/width,
-                    word->edge(j+1)/height);
+                    rightEdge(word, j)/height);
             }
             
             if ( word->hasSpaceAfter() && next )
               append(ktp, " ",
                     // this letters boundary
                      wordRect->left/width,
-                     word->edge(charCount)/height,
+                     rightEdge(word, charCount-1)/height,
                     // next letters boundary
                      wordRect->right/width,
-                     next->edge(0)/height);
+                     leftEdge(next, 0)/height);
             break;
 
             case 2:
@@ -1127,9 +1145,9 @@ Okular::TextPage * PDFGenerator::abstrac
             {
                 s=word->text().at(j);
                 append(ktp, (j==charCount-1 && !next ) ? (s + '\n') : s,
-                    word->edge(j+1)/width,
+                    rightEdge(word, j)/width,
                     wordRect->bottom/height,
-                    word->edge(j)/width,
+                    leftEdge(word, j)/width,
                     wordRect->top/height);
 
             }
@@ -1137,10 +1155,10 @@ Okular::TextPage * PDFGenerator::abstrac
             if ( word->hasSpaceAfter() && next )
               append(ktp, " ",
                     // this letters boundary
-                     next->edge(0)/width,
+                     leftEdge(next, 0)/width,
                      wordRect->bottom/height,
                     // next letters boundary
-                     word->edge(charCount)/width,
+                     rightEdge(word, charCount-1)/width,
                      wordRect->top/height);
           
             break;
@@ -1151,19 +1169,19 @@ Okular::TextPage * PDFGenerator::abstrac
                 s=word->text().at(j);
                 append(ktp, (j==charCount-1 && !next ) ? (s + '\n') : s,
                     wordRect->left/width,
-                    word->edge(j+1)/height,
+                    rightEdge(word, j)/height,
                     wordRect->right/width,
-                    word->edge(j)/height);
+                    leftEdge(word, j)/height);
             }
             
             if ( word->hasSpaceAfter() && next )
               append(ktp, " ",
                     // this letters boundary
                      wordRect->left/width,
-                     next->edge(0)/height,
+                     leftEdge(next, 0)/height,
                     // next letters boundary
                      wordRect->right/width,
-                     word->edge(charCount)/height);
+                     rightEdge(word, charCount-1)/height);
             break;
         }
     }
@@ -1505,7 +1523,7 @@ bool PDFGenerator::supportsOption( SaveO
 {
     switch ( option )
     {
-#if HAVE_POPPLER_0_7
+#ifdef HAVE_POPPLER_0_7
         case SaveChanges:
             return true;
 #endif
@@ -1516,7 +1534,7 @@ bool PDFGenerator::supportsOption( SaveO
 
 bool PDFGenerator::save( const QString &fileName, SaveOptions options )
 {
-#if HAVE_POPPLER_0_7
+#ifdef HAVE_POPPLER_0_7
     Poppler::PDFConverter *pdfConv = pdfdoc->pdfConverter();
 
     pdfConv->setOutputFileName( fileName );
Index: config-okular-poppler.h.cmake
===================================================================
--- config-okular-poppler.h.cmake (revision 800167)
+++ config-okular-poppler.h.cmake (working copy)
@@ -1,5 +1,8 @@
 /* Defined if we have the 0.7 version of the Poppler library */
 #cmakedefine HAVE_POPPLER_0_7 1
 
+/* Defined if we have the 0.8 version of the Poppler library */
+#cmakedefine HAVE_POPPLER_0_8 1
+
 /* Defined if we have the 0.9 version of the Poppler library */
 #cmakedefine HAVE_POPPLER_0_9 1
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 800167)
+++ CMakeLists.txt (working copy)
@@ -16,6 +16,15 @@ check_cxx_source_compiles("
 #include <poppler-qt4.h>
 int main()
 {
+  Poppler::TextBox * box = 0;
+  box->charBoundingBox(0);
+  return 0;
+}
+" HAVE_POPPLER_0_8)
+check_cxx_source_compiles("
+#include <poppler-qt4.h>
+int main()
+{
   Poppler::Document * doc = 0;
   (void)doc->scripts();
   return 0;


_______________________________________________
Kde-graphics-devel mailing list
Kde-graphics-devel@...
https://mail.kde.org/mailman/listinfo/kde-graphics-devel

Re: [PATCH] Okular: support Poppler 0.8

by Pino Toscano :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

> The attached patch makes okular compile when the installed version of
> poppler is 0.8.

It actually compiles even now, and the patch is not correct.
What is the real problem you get?

> It also fixes the 0.7 conditionals to use #ifdef rather than #if, so gcc
> doesn't generate warnings when 0.6 is installed.

A separate patch for that, please.

--
Pino Toscano


_______________________________________________
Kde-graphics-devel mailing list
Kde-graphics-devel@...
https://mail.kde.org/mailman/listinfo/kde-graphics-devel

signature.asc (196 bytes) Download Attachment

Re: [PATCH] Okular: support Poppler 0.8

by Bugzilla from huntedhacker@tiscali.co.uk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

On Wednesday 23 April 2008 17:17:47 Pino Toscano wrote:

> Hi,

>

> > The attached patch makes okular compile when the installed version of

> > poppler is 0.8.

>

> It actually compiles even now, and the patch is not correct.

> What is the real problem you get?

Oh, sorry, turns out my build was screwed - it didn't recognise my poppler as being at least 0.7. I cleaned it out and started again, and now it works.

>

> > It also fixes the 0.7 conditionals to use #ifdef rather than #if, so gcc

> > doesn't generate warnings when 0.6 is installed.

>

> A separate patch for that, please.

Attached (may as well have something to show for screwing up...)

Alex

--

KDE: http://www.kde.org

Ubuntu/Kubuntu: http://www.ubuntu.org http://www.kubuntu.org


[okular-poppler-if-ifdef.patch]

Index: generator_pdf.cpp
===================================================================
--- generator_pdf.cpp (revision 800186)
+++ generator_pdf.cpp (working copy)
@@ -817,7 +817,7 @@ bool PDFGenerator::print( QPrinter& prin
 
     // TODO rotation
 
-#if HAVE_POPPLER_0_7
+#ifdef HAVE_POPPLER_0_7
     tf.setAutoRemove(false);
 #else
     tf.close();
@@ -833,7 +833,7 @@ bool PDFGenerator::print( QPrinter& prin
 
     Poppler::PSConverter *psConverter = pdfdoc->psConverter();
 
-#if HAVE_POPPLER_0_7
+#ifdef HAVE_POPPLER_0_7
     psConverter->setOutputDevice(&tf);
 #else
     psConverter->setOutputFileName(tempfilename);
@@ -1505,7 +1505,7 @@ bool PDFGenerator::supportsOption( SaveO
 {
     switch ( option )
     {
-#if HAVE_POPPLER_0_7
+#ifdef HAVE_POPPLER_0_7
         case SaveChanges:
             return true;
 #endif
@@ -1516,7 +1516,7 @@ bool PDFGenerator::supportsOption( SaveO
 
 bool PDFGenerator::save( const QString &fileName, SaveOptions options )
 {
-#if HAVE_POPPLER_0_7
+#ifdef HAVE_POPPLER_0_7
     Poppler::PDFConverter *pdfConv = pdfdoc->pdfConverter();
 
     pdfConv->setOutputFileName( fileName );


_______________________________________________
Kde-graphics-devel mailing list
Kde-graphics-devel@...
https://mail.kde.org/mailman/listinfo/kde-graphics-devel