[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kpdf/annotations/kdegraphics/kpdf/core/generator_pdf
From:       Enrico Ros <rosenric () dei ! unipd ! it>
Date:       2005-07-26 16:34:39
Message-ID: 1122395679.726306.20874.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 438936 by eros:

Removed the only 2 (wrong) assumptions in the code, regarding the
maximum number of rects per highlight and the points in a polyline :-)

Albert: this fixes completely the 109516, but only in _annotations, of
course.
Ben Smith: I'm going to attach a screenshot showing the redendering we
have now.

CCMAIL:109516@bugs.kde.org


 M  +19 -4     generator_pdf.cpp  


--- branches/kpdf/annotations/kdegraphics/kpdf/core/generator_pdf/generator_pdf.cpp \
#438935:438936 @@ -823,6 +823,7 @@
         static void lookupBool( Dict *, const char *, bool & dest );
         static void lookupInt( Dict *, const char *, int & dest );
         static void lookupNum( Dict *, const char *, double & dest );
+        static int lookupArraySize( Dict *, const char * );
         static int lookupNumArray( Dict *, const char *, double * dest, int len );
         static void lookupColor( Dict *, const char *, QColor & color );
         static void lookupIntRef( Dict *, const char *, int & dest );
@@ -896,6 +897,18 @@
     numObj.free();
 }
 
+int XPDFReader::lookupArraySize( Dict * dict, const char * type )
+{
+    int size = 0;
+    Object arrObj;
+    dict->lookup( type, &arrObj );
+    if ( arrObj.isArray() )
+        size = arrObj.arrayGetLength();
+    if ( !arrObj.isNull() )
+        arrObj.free();
+    return size;
+}
+
 int XPDFReader::lookupNumArray( Dict * dict, const char * type, double * dest, int \
len )  {
     Object arrObj;
@@ -1126,8 +1139,9 @@
             annotation = l;
 
             // -> linePoints
-            double c[100];
-            int num = XPDFReader::lookupNumArray( annotDict, (subType == "Line") ? \
"L" : "Vertices", c, 100 ); +            int num = XPDFReader::lookupArraySize( \
annotDict, (subType == "Line") ? "L" : "Vertices" ); +            double c[ num ];   \
// its size is a multiple of 8 (2coords per every point) +            num = \
XPDFReader::lookupNumArray( annotDict, (subType == "Line") ? "L" : "Vertices", c, num \
);  if ( num < 4 || (num % 2) != 0 )
             {
                 kdDebug() << "L/Vertices wrong fol Line/Poly." << endl;
@@ -1256,8 +1270,9 @@
                 h->highlightType = HighlightAnnotation::StrikeOut;
 
             // -> highlightQuads
-            double c[80];
-            int num = XPDFReader::lookupNumArray( annotDict, "QuadPoints", c, 80 );
+            int num = XPDFReader::lookupArraySize( annotDict, "QuadPoints" );
+            double c[ num ];   // its size is a multiple of 8 (2coords per 4points \
per Highlight rect) +            num = XPDFReader::lookupNumArray( annotDict, \
"QuadPoints", c, num );  if ( num < 8 || (num % 8) != 0 )
             {
                 kdDebug() << "Wrong QuadPoints for a Highlight annotation." << endl;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic