[poppler] poppler/qt4/src: Makefile.am, 1.5, 1.6 poppler-document.cc, 1.13, 1.14 poppler-private.h, 1.3, 1.4 poppler-qt4.h, 1.23, 1.24

Albert Astals Cid aacid at freedesktop.org
Wed Jan 18 14:32:15 PST 2006


Update of /cvs/poppler/poppler/qt4/src
In directory gabe:/tmp/cvs-serv28869/qt4/src

Modified Files:
	Makefile.am poppler-document.cc poppler-private.h 
	poppler-qt4.h 
Log Message:
Brad patch for embedded document extraction, only has Qt4 bindings for now, needs Qt3 and glib work


Index: Makefile.am
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile.am	10 Jan 2006 21:57:28 -0000	1.5
+++ Makefile.am	18 Jan 2006 22:32:13 -0000	1.6
@@ -17,6 +17,7 @@
 	poppler-document.cc			\
 	poppler-page.cc				\
 	poppler-fontinfo.cc			\
+	poppler-embeddedfile.cc			\
 	poppler-textbox.cc			\
 	../../qt/poppler-page-transition.cc	\
 	poppler-private.h

Index: poppler-document.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-document.cc,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- poppler-document.cc	1 Jan 2006 22:35:48 -0000	1.13
+++ poppler-document.cc	18 Jan 2006 22:32:13 -0000	1.14
@@ -25,10 +25,13 @@
 #include <GlobalParams.h>
 #include <PDFDoc.h>
 #include <Catalog.h>
+#include "UGooString.h"
 #include <ErrorCodes.h>
 #include <SplashOutputDev.h>
 #include <splash/SplashBitmap.h>
 #include "poppler-private.h"
+#include <Stream.h>
+#include <QtCore/QDebug>
 
 namespace Poppler {
 
@@ -50,6 +53,15 @@
 	    else
 		pdoc->m_doc->locked = false;
 	    pdoc->m_doc->m_fontInfoScanner = new FontInfoScanner(&(doc->doc));
+	    int numEmb = doc->doc.getCatalog()->numEmbeddedFiles();
+	    if (!(0 == numEmb)) {
+		// we have some embedded documents, build the list
+		for (int yalv = 0; yalv < numEmb; ++yalv) {
+		    EmbFile *ef = doc->doc.getCatalog()->embeddedFile(yalv);
+		    pdoc->m_doc->m_embeddedFiles.append(new EmbeddedFile(ef));
+		    delete ef;
+		}
+	    }
 	    return pdoc;
 	}
 	else
@@ -150,6 +162,11 @@
 	return ourList;
     }
 
+    const QList<EmbeddedFile*> &Document::embeddedFiles() const
+    {
+	return m_doc->m_embeddedFiles;
+    }
+
     bool Document::scanForFonts( int numPages, QList<FontInfo> *fontList ) const
     {
 	GooList *items = m_doc->m_fontInfoScanner->scan( numPages );
@@ -257,7 +274,7 @@
 	Dict *infoDict = info.getDict();
 	// somehow iterate over keys in infoDict
 	for( int i=0; i < infoDict->getLength(); ++i ) {
-	    keys.append( QString::fromAscii(infoDict->getKey(i)) );
+	    keys.append( QString::fromAscii(infoDict->getKey(i)->getCString()) );
 	}
 
 	info.free();
@@ -279,8 +296,6 @@
 	}
 
 	Object obj;
-	char *s;
-	int year, mon, day, hour, min, sec;
 	Dict *infoDict = info.getDict();
 	QDateTime result;
 
@@ -364,6 +379,11 @@
 	return page(index);
     }
 
+    bool Document::hasEmbeddedFiles() const
+    {
+	return (!(0 == m_doc->doc.getCatalog()->numEmbeddedFiles()));
+    }
+
     QDateTime convertDate( char *dateString )
     {
         int year;

Index: poppler-private.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-private.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- poppler-private.h	1 Jan 2006 22:35:48 -0000	1.3
+++ poppler-private.h	18 Jan 2006 22:32:13 -0000	1.4
@@ -34,6 +34,7 @@
 	
 	~DocumentData()
 	{
+		qDeleteAll(m_embeddedFiles);
 		delete m_splashOutputDev;
 		delete m_fontInfoScanner;
 	}
@@ -56,6 +57,7 @@
 	bool locked;
 	FontInfoScanner *m_fontInfoScanner;
 	SplashOutputDev *m_splashOutputDev;
+	QList<EmbeddedFile*> m_embeddedFiles;
     };
 
 }

Index: poppler-qt4.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-qt4.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- poppler-qt4.h	10 Jan 2006 21:57:28 -0000	1.23
+++ poppler-qt4.h	18 Jan 2006 22:32:13 -0000	1.24
@@ -28,6 +28,8 @@
 
 #include <poppler-page-transition.h>
 
+class EmbFile;
+
 /**
    The Poppler Qt bindings
 */
@@ -146,6 +148,58 @@
 
 
     /**
+       Container class for an embedded file with a PDF document
+    */
+    class EmbeddedFileData;
+    class EmbeddedFile {
+    public:
+	/**
+	   Create a new embedded file container
+	*/
+	EmbeddedFile(EmbFile *embfile);
+	
+	EmbeddedFile(const EmbeddedFile &ef);
+	
+	~EmbeddedFile();
+
+	/**
+	   The name associated with the file
+	*/
+	QString name() const;
+
+	/**
+	   The description associated with the file, if any.
+
+	   This will return an empty QString if there is no description element
+	*/
+	QString description() const;
+
+	/**
+	   The modification date for the embedded file, if known.
+	*/
+	QDateTime modDate() const;
+
+	/**
+	   The creation date for the embedded file, if known.
+	*/
+	QDateTime createDate() const;
+
+	/**
+	   The data as an array
+	*/
+	QByteArray data();
+
+	/**
+	   A QDataStream for the actual data?
+	*/
+	//QDataStream dataStream() const;
+
+    private:
+	EmbeddedFileData *m_embeddedFile;
+    };
+
+
+    /**
        Page within a PDF document
     */
     class Page {
@@ -544,6 +598,20 @@
 	*/
 	bool scanForFonts( int numPages, QList<FontInfo> *fontList ) const; 
 
+
+	/**
+	   The documents embedded within the PDF document.
+
+	   \note there are two types of embedded document - this call
+	   only accesses documents that are embedded at the document level.
+	*/
+	const QList<EmbeddedFile*> &embeddedFiles() const;
+
+	/**
+	   Whether there are any documents embedded in this PDF document.
+	*/
+	bool hasEmbeddedFiles() const;
+
 	Document::~Document();
   
     private:



More information about the poppler mailing list