[poppler] qt4/src

Pino Toscano pino at kemper.freedesktop.org
Wed Mar 14 08:28:56 PDT 2012


 qt4/src/CMakeLists.txt               |    1 
 qt4/src/poppler-annotation-private.h |    4 -
 qt4/src/poppler-annotation.cc        |    1 
 qt4/src/poppler-link.cc              |   16 +++---
 qt4/src/poppler-link.h               |    5 +
 qt4/src/poppler-objectreference.cc   |   89 -----------------------------------
 qt4/src/poppler-objectreference_p.h  |   77 ------------------------------
 qt4/src/poppler-page.cc              |    7 +-
 8 files changed, 21 insertions(+), 179 deletions(-)

New commits:
commit aa2b5ffa7961aac0aea33ae9a42bf1f38a756b1b
Author: Pino Toscano <pino at kde.org>
Date:   Wed Mar 14 16:25:35 2012 +0100

    qt4: replace ObjectReference with simplier Ref
    
    instead of roll out a new (still private) version of Ref, just use it for private annotation and link data;
    this needed a couple of explicit initializations of Ref (since it's a simple struct with no methods) and a private operator== for it

diff --git a/qt4/src/CMakeLists.txt b/qt4/src/CMakeLists.txt
index c958379..99dce58 100644
--- a/qt4/src/CMakeLists.txt
+++ b/qt4/src/CMakeLists.txt
@@ -15,7 +15,6 @@ set(poppler_qt4_SRCS
   poppler-link.cc
   poppler-link-extractor.cc
   poppler-movie.cc
-  poppler-objectreference.cc
   poppler-optcontent.cc
   poppler-page.cc
   poppler-base-converter.cc
diff --git a/qt4/src/poppler-annotation-private.h b/qt4/src/poppler-annotation-private.h
index 5040da0..80e93d3 100644
--- a/qt4/src/poppler-annotation-private.h
+++ b/qt4/src/poppler-annotation-private.h
@@ -22,7 +22,7 @@
 
 #include "poppler-annotation.h"
 
-#include "poppler-objectreference_p.h"
+#include <Object.h>
 
 namespace Poppler
 {
@@ -45,7 +45,7 @@ class AnnotationPrivate
         QRectF boundary;
 
         QLinkedList< Annotation::Revision > revisions;
-        ObjectReference pdfObjectReference;
+        Ref pdfObjectReference;
 };
 
 }
diff --git a/qt4/src/poppler-annotation.cc b/qt4/src/poppler-annotation.cc
index 0905ee3..907c3ba 100644
--- a/qt4/src/poppler-annotation.cc
+++ b/qt4/src/poppler-annotation.cc
@@ -106,6 +106,7 @@ QDomElement AnnotationUtils::findChildElement( const QDomNode & parentNode,
 AnnotationPrivate::AnnotationPrivate()
     : flags( 0 )
 {
+    pdfObjectReference.num = pdfObjectReference.gen = -1;
 }
 
 AnnotationPrivate::~AnnotationPrivate()
diff --git a/qt4/src/poppler-link.cc b/qt4/src/poppler-link.cc
index 81ba39f..bbfd39f 100644
--- a/qt4/src/poppler-link.cc
+++ b/qt4/src/poppler-link.cc
@@ -27,10 +27,14 @@
 #include <QtCore/QStringList>
 
 #include "poppler-annotation-private.h"
-#include "poppler-objectreference_p.h"
 
 #include "Link.h"
 
+bool operator==( const Ref &r1, const Ref &r2 )
+{
+	return r1.num == r2.num && r1.gen == r2.gen;
+}
+
 namespace Poppler {
 
 class LinkDestinationPrivate : public QSharedData
@@ -174,14 +178,14 @@ class LinkJavaScriptPrivate : public LinkPrivate
 class LinkMoviePrivate : public LinkPrivate
 {
 	public:
-		LinkMoviePrivate( const QRectF &area, LinkMovie::Operation operation, const QString &title, const ObjectReference &reference );
+		LinkMoviePrivate( const QRectF &area, LinkMovie::Operation operation, const QString &title, const Ref &reference );
 
 		LinkMovie::Operation operation;
 		QString annotationTitle;
-		ObjectReference annotationReference;
+		Ref annotationReference;
 };
 
-	LinkMoviePrivate::LinkMoviePrivate( const QRectF &area, LinkMovie::Operation _operation, const QString &title, const ObjectReference &reference  )
+	LinkMoviePrivate::LinkMoviePrivate( const QRectF &area, LinkMovie::Operation _operation, const QString &title, const Ref &reference  )
 		: LinkPrivate( area ), operation( _operation ), annotationTitle( title ), annotationReference( reference )
 	{
 	}
@@ -574,7 +578,7 @@ class LinkMoviePrivate : public LinkPrivate
 	}
 
 	// LinkMovie
-	LinkMovie::LinkMovie( const QRectF &linkArea, Operation operation, const QString &annotationTitle, const ObjectReference &annotationReference )
+	LinkMovie::LinkMovie( const QRectF &linkArea, Operation operation, const QString &annotationTitle, const Ref &annotationReference )
 		: Link( *new LinkMoviePrivate( linkArea, operation, annotationTitle, annotationReference ) )
 	{
 	}
@@ -597,7 +601,7 @@ class LinkMoviePrivate : public LinkPrivate
 	bool LinkMovie::isReferencedAnnotation( const MovieAnnotation *annotation ) const
 	{
 		Q_D( const LinkMovie );
-		if ( d->annotationReference.isValid() && d->annotationReference == annotation->d_ptr->pdfObjectReference )
+		if ( d->annotationReference.num != -1 && d->annotationReference == annotation->d_ptr->pdfObjectReference )
 		{
 			return true;
 		}
diff --git a/qt4/src/poppler-link.h b/qt4/src/poppler-link.h
index b12ce8b..37a2ef5 100644
--- a/qt4/src/poppler-link.h
+++ b/qt4/src/poppler-link.h
@@ -29,6 +29,8 @@
 #include <QtCore/QSharedDataPointer>
 #include "poppler-export.h"
 
+struct Ref;
+
 namespace Poppler {
 
 class LinkPrivate;
@@ -41,7 +43,6 @@ class LinkJavaScriptPrivate;
 class LinkMoviePrivate;
 class LinkDestinationData;
 class LinkDestinationPrivate;
-class ObjectReference;
 class SoundObject;
 
 /**
@@ -500,7 +501,7 @@ class POPPLER_QT4_EXPORT LinkMovie : public Link
 		 *
 		 * Note: This constructor is supposed to be used by Poppler::Page only.
 		 */
-		LinkMovie( const QRectF &linkArea, Operation operation, const QString &annotationTitle, const ObjectReference &annotationReference );
+		LinkMovie( const QRectF &linkArea, Operation operation, const QString &annotationTitle, const Ref &annotationReference );
 		/**
 		 * Destructor.
 		 */
diff --git a/qt4/src/poppler-objectreference.cc b/qt4/src/poppler-objectreference.cc
deleted file mode 100644
index cb32314..0000000
--- a/qt4/src/poppler-objectreference.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-/* poppler-objectreference.h: qt interface to poppler
- *
- * Copyright (C) 2012, Tobias Koenig <tokoe at kdab.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "poppler-objectreference_p.h"
-
-namespace Poppler {
-
-  class ObjectReferencePrivate
-  {
-    public:
-      ObjectReferencePrivate()
-        : m_number( -1 ), m_generation( -1 )
-      {
-      }
-
-      ObjectReferencePrivate( int number, int generation )
-        : m_number( number ), m_generation( generation )
-      {
-      }
-
-      int m_number;
-      int m_generation;
-  };
-
-}
-
-using namespace Poppler;
-
-ObjectReference::ObjectReference()
-  : d( new ObjectReferencePrivate() )
-{
-}
-
-ObjectReference::ObjectReference( int number, int generation )
-  : d( new ObjectReferencePrivate( number, generation ) )
-{
-}
-
-ObjectReference::ObjectReference( const ObjectReference &other )
-  : d( new ObjectReferencePrivate( other.d->m_number, other.d->m_generation ) )
-{
-}
-
-ObjectReference::~ObjectReference()
-{
-  delete d;
-}
-
-ObjectReference& ObjectReference::operator=( const ObjectReference &other )
-{
-  if ( this != &other )
-  {
-    d->m_number = other.d->m_number;
-    d->m_generation = other.d->m_generation;
-  }
-
-  return *this;
-}
-
-bool ObjectReference::isValid() const
-{
-  return ( d->m_number != -1 );
-}
-
-bool ObjectReference::operator==( const ObjectReference &other ) const
-{
-  return ( ( d->m_number == other.d->m_number ) && ( d->m_generation == other.d->m_generation ) );
-}
-
-bool ObjectReference::operator!=( const ObjectReference &other ) const
-{
-  return !operator==( other );
-}
diff --git a/qt4/src/poppler-objectreference_p.h b/qt4/src/poppler-objectreference_p.h
deleted file mode 100644
index 52af958..0000000
--- a/qt4/src/poppler-objectreference_p.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* poppler-objectreference.h: qt interface to poppler
- *
- * Copyright (C) 2012, Tobias Koenig <tokoe at kdab.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef POPPLER_OBJECTREFERENCE_H
-#define POPPLER_OBJECTREFERENCE_H
-
-#include "poppler-export.h"
-
-namespace Poppler
-{
-  class ObjectReferencePrivate;
-
-  /**
-   * \brief Reference of a PDF object
-   *
-   * ObjectReference is a class that encapsulates a reference to a PDF object.
-   * It is needed to store (and later on resolve) references between various PDF entities.
-   */
-  class POPPLER_QT4_EXPORT ObjectReference
-  {
-    public:
-      /**
-       * Creates a new, invalid ObjectReference.
-       */
-      ObjectReference();
-
-      /**
-       * Creates a new ObjectReference.
-       *
-       * @param number The number of the PDF object.
-       * @param generation The generation of the PDF object.
-       */
-      ObjectReference( int number, int generation );
-
-      /**
-       * Creates a new ObjectReference from an @p other one.
-       */
-      ObjectReference( const ObjectReference &other );
-
-      /**
-       * Destroys the ObjectReference.
-       */
-      ~ObjectReference();
-
-      ObjectReference& operator=( const ObjectReference &other );
-
-      /**
-       * Returns whether the object reference is valid.
-       */
-      bool isValid() const;
-
-      bool operator==( const ObjectReference &other ) const;
-
-      bool operator!=( const ObjectReference &other ) const;
-
-    private:
-      ObjectReferencePrivate * const d;
-  };
-}
-
-#endif
diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc
index 34d8e5e..01d6787 100644
--- a/qt4/src/poppler-page.cc
+++ b/qt4/src/poppler-page.cc
@@ -177,7 +177,10 @@ Link* PageData::convertLinkActionToLink(::LinkAction * a, DocumentData *parentDo
 
       const QString title = ( lm->hasAnnotTitle() ? UnicodeParsedString( lm->getAnnotTitle() ) : QString() );
 
-      const ObjectReference reference = ( lm->hasAnnotRef() ? ObjectReference( lm->getAnnotRef()->num, lm->getAnnotRef()->gen ) : ObjectReference() );
+      Ref reference;
+      reference.num = reference.gen = -1;
+      if ( lm->hasAnnotRef() )
+        reference = *lm->getAnnotRef();
 
       LinkMovie::Operation operation = LinkMovie::Play;
       switch ( lm->getOperation() )
@@ -1049,7 +1052,7 @@ QList<Annotation*> Page::annotations() const
         }
         annotation->setBoundary( boundaryRect );
         // -> PDF object reference
-        annotation->d_ptr->pdfObjectReference = ObjectReference( ann->getRef().num, ann->getRef().gen );
+        annotation->d_ptr->pdfObjectReference = ann->getRef();
         // -> contents
         annotation->setContents( UnicodeParsedString( ann->getContents() ) );
         // -> uniqueName


More information about the poppler mailing list