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

List:       kde-commits
Subject:    playground/graphics/okular/generators/dvi
From:       Pino Toscano <toscano.pino () tiscali ! it>
Date:       2006-07-01 21:17:49
Message-ID: 1151788669.396001.13036.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 556901 by pino:

Port the recent changes to kdv, and remove some debug code
(Luigi Toscano)


 M  +5 -5      dviPageInfo.h  
 M  +46 -10    dviRenderer.cpp  
 M  +8 -8      dviRenderer.h  
 M  +6 -5      generator_dvi.cpp  
 M  +1 -1      special.cpp  


--- trunk/playground/graphics/okular/generators/dvi/dviPageInfo.h #556900:556901
@@ -13,8 +13,8 @@
 #include "pageNumber.h"
 #include "hyperlink.h"
 #include "textBox.h"
-#include <Q3ValueVector>
-#include <QPixmap>
+#include <qvector.h>
+#include <qpixmap.h>
 
 class dviPageInfo
 {
@@ -34,12 +34,12 @@
 
    /** \brief List of source hyperlinks
     */
-   Q3ValueVector<Hyperlink> sourceHyperLinkList;
+   QVector<Hyperlink> sourceHyperLinkList;
 
    /** \brief Hyperlinks on the document page
     */
-    Q3ValueVector<Hyperlink> hyperLinkList;
-    Q3ValueVector<TextBox> textBoxList;
+   QVector<Hyperlink> hyperLinkList;
+   QVector<TextBox> textBoxList;
 };
 
 /* quick&dirty hack to cheat the dviRenderer class... */
--- trunk/playground/graphics/okular/generators/dvi/dviRenderer.cpp #556900:556901
@@ -182,6 +182,48 @@
   page->img = img;
 //page->setImage(img);
  
+  // Postprocess hyperlinks
+  // Without that, based on the way TeX draws certain characters like german \
"Umlaute", +  // some hyperlinks would be broken into two overlapping parts, in the \
middle of a word. +  QVector<Hyperlink>::iterator i = page->hyperLinkList.begin();
+  QVector<Hyperlink>::iterator j;
+  while (i != page->hyperLinkList.end())
+  {
+    // Iterator j always points to the element after i.
+    j = i;
+    j++;
+
+    if (j == page->hyperLinkList.end())
+      break;
+
+    Hyperlink& hi = *i;
+    Hyperlink& hj = *j;
+
+    bool merged = false;
+
+    // Merge all hyperlinks that point to the same target, and have the same \
baseline. +    while (hi.linkText == hj.linkText && hi.baseline == hj.baseline)
+    {
+      merged = true;
+      hi.box = hi.box.unite(hj.box);
+
+      j++;
+      if (j == page->hyperLinkList.end())
+        break;
+
+      hj = *j;
+    }
+
+    if (merged)
+    {
+      i = page->hyperLinkList.erase(++i, j);
+    }
+    else
+    {
+      i++;
+    }
+  }
+
 #if 0
   page->isEmpty = false;
   if (errorMsg.isEmpty() != true) {
@@ -518,17 +560,11 @@
   PostScriptOutPutString = NULL;
 
 #if 0
-  Q3ValueVector<PreBookmark>::iterator it;
-  for( it = prebookmarks.begin(); it != prebookmarks.end(); ++it ) {
-     kDebug() << "preb:" << (*it).title << " - " << (*it).anchorName << " - " << \
                (*it).noOfChildren << endl;
-  }
-#endif
-#if 0
   // Generate the list of bookmarks
   bookmarks.clear();
   Q3PtrStack<Bookmark> stack;
   stack.setAutoDelete (false);
-  Q3ValueVector<PreBookmark>::iterator it;
+  QVector<PreBookmark>::iterator it;
   for( it = prebookmarks.begin(); it != prebookmarks.end(); ++it ) {
     Bookmark *bmk = new Bookmark((*it).title, findAnchor((*it).anchorName));
     if (stack.isEmpty())
@@ -552,7 +588,7 @@
   pageSizes.resize(0);
   if (dviFile->suggestedPageSize != 0) {
     // Fill the vector pageSizes with total_pages identical entries
-    pageSizes.resize(dviFile->total_pages, *(dviFile->suggestedPageSize));
+    pageSizes.fill(*(dviFile->suggestedPageSize), dviFile->total_pages);
   }
   QApplication::restoreOverrideCursor();
   return true;
@@ -620,8 +656,8 @@
     // document.
     bool anchorForRefFileFound = false; // Flag that is set if source file anchors \
for the refFileName could be found at all  
-    Q3ValueVector<DVI_SourceFileAnchor>::iterator bestMatch = \
                sourceHyperLinkAnchors.end();
-    Q3ValueVector<DVI_SourceFileAnchor>::iterator it;
+    QVector<DVI_SourceFileAnchor>::iterator bestMatch = \
sourceHyperLinkAnchors.end(); +    QVector<DVI_SourceFileAnchor>::iterator it;
     for( it = sourceHyperLinkAnchors.begin(); it != sourceHyperLinkAnchors.end(); \
++it )  if (refFileName.trimmed() == it->fileName.trimmed()
       || refFileName.trimmed() == it->fileName.trimmed() + ".tex"
--- trunk/playground/graphics/okular/generators/dvi/dviRenderer.h #556900:556901
@@ -29,8 +29,8 @@
 #include <kprogressdialog.h>
 #include <Q3IntDict>
 #include <Q3PointArray>
-#include <Q3ValueStack>
-#include <Q3ValueVector>
+#include <QStack>
+#include <QVector>
 #include <QTimer>
 #include <QMutex>
 
@@ -170,7 +170,7 @@
 
   SimplePageSize sizeOfPage(const PageNumber& page);
 
-  Q3ValueVector<PreBookmark> getPrebookmarks() const { return prebookmarks; }
+  QVector<PreBookmark> getPrebookmarks() const { return prebookmarks; }
 
 private slots:
   /** This method shows a dialog that tells the user that source
@@ -226,7 +226,7 @@
   void          prescan_setChar(unsigned int ch);
 
   /* */
-  Q3ValueVector<PreBookmark> prebookmarks;
+  QVector<PreBookmark> prebookmarks;
 
 
 
@@ -258,7 +258,7 @@
   // List of source-hyperlinks on all pages. This vector is generated
   // when the DVI-file is first loaded, i.e. when draw_part is called
   // with PostScriptOutPutString != NULL
-  Q3ValueVector<DVI_SourceFileAnchor>  sourceHyperLinkAnchors;
+  QVector<DVI_SourceFileAnchor>  sourceHyperLinkAnchors;
 
   // If not NULL, the text currently drawn represents a source
   // hyperlink to the (relative) URL given in the string;
@@ -273,11 +273,11 @@
   /** Stack for register compounds, used for the DVI-commands PUSH/POP
       as explained in section 2.5 and 2.6.2 of the DVI driver standard,
       Level 0, published by the TUG DVI driver standards committee. */
-  Q3ValueStack<struct framedata> stack;
+  QStack<framedata> stack;
 
   /** A stack where color are stored, according to the documentation of
       DVIPS */
-  Q3ValueStack<QColor> colorStack;
+  QStack<QColor> colorStack;
 
   /** The global color is to be used when the color stack is empty */
   QColor              globalColor;
@@ -325,7 +325,7 @@
   quint16  numPages;
 
   //TODO: merge into dviPageInfo
-  Q3ValueVector<SimplePageSize> pageSizes;
+  QVector<SimplePageSize> pageSizes;
 
   QMap<QString, Anchor> anchorList;
 };
--- trunk/playground/graphics/okular/generators/dvi/generator_dvi.cpp #556900:556901
@@ -20,6 +20,7 @@
 #include <QX11Info>
 #include <qstring.h>
 #include <qurl.h>
+#include <qvector.h>
 #include <qstack.h>
 
 #include <kdebug.h>
@@ -268,8 +269,8 @@
 {
     QList<KPDFTextEntity*> textOfThePage;
 
-    Q3ValueVector<TextBox>::ConstIterator it = pageInfo->textBoxList.constBegin();
-    Q3ValueVector<TextBox>::ConstIterator itEnd = pageInfo->textBoxList.constEnd();
+    QVector<TextBox>::ConstIterator it = pageInfo->textBoxList.constBegin();
+    QVector<TextBox>::ConstIterator itEnd = pageInfo->textBoxList.constEnd();
     QRect tmpRect;
 
     int pageWidth = 0, pageHeight = 0;
@@ -331,13 +332,13 @@
  
     QStack<QDomElement*> stack;
 
-    Q3ValueVector<PreBookmark> prebookmarks = m_dviRenderer->getPrebookmarks();
+    QVector<PreBookmark> prebookmarks = m_dviRenderer->getPrebookmarks();
 
     if ( prebookmarks.isEmpty() ) 
         return m_docSynopsis;
 
-    Q3ValueVector<PreBookmark>::ConstIterator it = prebookmarks.begin();
-    Q3ValueVector<PreBookmark>::ConstIterator itEnd = prebookmarks.end();
+    QVector<PreBookmark>::ConstIterator it = prebookmarks.begin();
+    QVector<PreBookmark>::ConstIterator itEnd = prebookmarks.end();
     for( ; it != itEnd; ++it ) 
     {
         QDomElement *domel = new QDomElement; 
--- trunk/playground/graphics/okular/generators/dvi/special.cpp #556900:556901
@@ -646,7 +646,7 @@
     if (special_command.startsWith("ps:SDict begin [") && special_command.endsWith(" \
pdfmark end")) {  if (!currentlyDrawnPage->hyperLinkList.isEmpty()) {
         QString targetName = special_command.section('(', 1, 1).section(')', 0, 0);
-        Q3ValueVector<Hyperlink>::iterator it;
+        QVector<Hyperlink>::iterator it;
         for( it = currentlyDrawnPage->hyperLinkList.begin(); it != \
currentlyDrawnPage->hyperLinkList.end(); ++it )  if (it->linkText == "glopglyph")
             it->linkText = targetName;


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

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