2004-09-08 12:41:14 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2004 by Enrico Ros <eros.kde@email.it> *
|
2004-09-23 21:33:53 +00:00
|
|
|
* Copyright (C) 2004 by Albert Astals Cid <tsdgeos@terra.es> *
|
2004-09-08 12:41:14 +00:00
|
|
|
* *
|
|
|
|
* 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 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _KPDF_DOCUMENT_H_
|
|
|
|
#define _KPDF_DOCUMENT_H_
|
|
|
|
|
2004-09-17 17:58:42 +00:00
|
|
|
#include <qvaluevector.h>
|
2004-12-10 16:04:45 +00:00
|
|
|
#include <qstring.h>
|
2004-12-11 17:25:03 +00:00
|
|
|
#include <qdom.h>
|
2004-09-08 12:41:14 +00:00
|
|
|
|
|
|
|
class KPDFPage;
|
2004-10-09 08:10:56 +00:00
|
|
|
class KPDFLink;
|
2005-01-02 14:55:14 +00:00
|
|
|
class KPDFDocumentObserver;
|
2004-12-10 16:04:45 +00:00
|
|
|
class DocumentInfo;
|
2004-12-11 17:25:03 +00:00
|
|
|
class DocumentSynopsis;
|
2005-01-02 14:55:14 +00:00
|
|
|
class Generator;
|
2004-12-22 18:21:36 +00:00
|
|
|
class PixmapRequest;
|
2005-01-02 14:55:14 +00:00
|
|
|
class KPrinter;
|
2004-09-08 12:41:14 +00:00
|
|
|
|
|
|
|
/**
|
2004-12-11 17:25:03 +00:00
|
|
|
* @short The Document. Heart of everything. Actions take place here.
|
2004-09-08 12:41:14 +00:00
|
|
|
*
|
2004-12-11 17:25:03 +00:00
|
|
|
* The Document is the main object in KPDF. All views query the Document to
|
|
|
|
* get data/properties or even for accessing pages (in a 'const' way).
|
|
|
|
*
|
|
|
|
* It is designed to keep it detached from the document type (pdf, ps, you
|
|
|
|
* name it..) so whenever you want to get some data, it asks its internals
|
|
|
|
* generator to do the job and return results in a format-indepedent way.
|
|
|
|
*
|
|
|
|
* Apart from the generator (the currently running one) the document stores
|
|
|
|
* all the Pages ('KPDFPage' class) of the current document in a vector and
|
|
|
|
* notifies all the registered DocumentObservers when some content changes.
|
|
|
|
*
|
|
|
|
* For a better understanding of hieracies @see README.internals.png
|
|
|
|
* @see KPDFDocumentObserver, KPDFPage
|
2004-09-08 12:41:14 +00:00
|
|
|
*/
|
2004-12-22 18:21:36 +00:00
|
|
|
class KPDFDocument : public QObject // only for a private slot..
|
2004-09-08 12:41:14 +00:00
|
|
|
{
|
2004-12-22 18:21:36 +00:00
|
|
|
Q_OBJECT
|
2004-11-09 17:20:19 +00:00
|
|
|
public:
|
|
|
|
KPDFDocument();
|
|
|
|
~KPDFDocument();
|
|
|
|
|
|
|
|
// document handling
|
|
|
|
bool openDocument( const QString & docFile );
|
|
|
|
void closeDocument();
|
|
|
|
|
|
|
|
// misc methods
|
|
|
|
void addObserver( KPDFDocumentObserver * pObserver );
|
2004-12-17 17:14:46 +00:00
|
|
|
void removeObserver( KPDFDocumentObserver * pObserver );
|
2004-11-09 17:20:19 +00:00
|
|
|
void reparseConfig();
|
|
|
|
|
|
|
|
// query methods (const ones)
|
2004-12-11 17:25:03 +00:00
|
|
|
const DocumentInfo * documentInfo() const;
|
|
|
|
const DocumentSynopsis * documentSynopsis() const;
|
2004-12-10 16:04:45 +00:00
|
|
|
const KPDFPage * page( uint page ) const;
|
2004-11-09 17:20:19 +00:00
|
|
|
uint currentPage() const;
|
|
|
|
uint pages() const;
|
|
|
|
bool okToPrint() const;
|
2005-01-01 15:44:44 +00:00
|
|
|
QString getMetaData( const QString &key ) const;
|
2004-11-09 17:20:19 +00:00
|
|
|
|
|
|
|
// perform actions on document / pages
|
2004-12-28 18:50:11 +00:00
|
|
|
void requestPixmaps( const QValueList< PixmapRequest * > & requests, bool asyncronous );
|
2004-11-09 17:20:19 +00:00
|
|
|
void requestTextPage( uint page );
|
|
|
|
void setCurrentPage( int page, const QRect & viewport = QRect() );
|
|
|
|
void findText( const QString & text = "", bool caseSensitive = false );
|
|
|
|
void findTextAll( const QString & pattern, bool caseSensitive );
|
|
|
|
void toggleBookmark( int page );
|
|
|
|
void processLink( const KPDFLink * link );
|
|
|
|
bool print( KPrinter &printer );
|
|
|
|
|
2005-01-01 21:50:34 +00:00
|
|
|
signals:
|
|
|
|
void linkFind();
|
|
|
|
void linkGoToPage();
|
|
|
|
|
2004-11-09 17:20:19 +00:00
|
|
|
private:
|
2004-12-21 12:38:52 +00:00
|
|
|
// memory management related functions
|
2004-12-22 18:21:36 +00:00
|
|
|
void mCleanupMemory( int observerId );
|
2004-12-21 12:38:52 +00:00
|
|
|
int mTotalMemory();
|
|
|
|
int mFreeMemory();
|
|
|
|
// more private functions
|
2004-11-09 17:20:19 +00:00
|
|
|
QString giveAbsolutePath( const QString & fileName );
|
|
|
|
bool openRelativeFile( const QString & fileName );
|
|
|
|
void processPageList( bool documentChanged );
|
|
|
|
void unHilightPages();
|
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
Generator * generator;
|
|
|
|
QString documentFileName;
|
|
|
|
QValueVector< KPDFPage * > pages_vector;
|
2004-11-09 17:20:19 +00:00
|
|
|
class KPDFDocumentPrivate * d;
|
2004-12-22 18:21:36 +00:00
|
|
|
|
|
|
|
private slots:
|
2004-12-24 10:24:10 +00:00
|
|
|
void slotCheckMemory();
|
2004-12-22 18:21:36 +00:00
|
|
|
void slotGeneratedContents( int id, int pageNumber );
|
2004-09-08 12:41:14 +00:00
|
|
|
};
|
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
/**
|
2004-12-11 17:25:03 +00:00
|
|
|
* @short Metadata that describes the document.
|
|
|
|
*
|
|
|
|
* The Info structure can be filled in by generators to display metadata
|
|
|
|
* about the currently opened file.
|
|
|
|
* FUTURE: use a Dom tree so every generator can have different fields for
|
|
|
|
* its metadata and renew the display widget to use the dynamic format.
|
2004-12-10 16:04:45 +00:00
|
|
|
*/
|
|
|
|
struct DocumentInfo
|
|
|
|
{
|
|
|
|
QString author,
|
|
|
|
creationDate,
|
|
|
|
modificationDate,
|
|
|
|
creator,
|
|
|
|
keywords,
|
|
|
|
producer,
|
|
|
|
subject,
|
|
|
|
title,
|
2004-12-21 12:38:52 +00:00
|
|
|
mimeType,
|
2004-12-10 16:04:45 +00:00
|
|
|
format,
|
|
|
|
formatVersion,
|
|
|
|
encryption,
|
|
|
|
optimization;
|
|
|
|
};
|
|
|
|
|
2004-12-12 17:10:59 +00:00
|
|
|
/**
|
2004-12-13 18:21:37 +00:00
|
|
|
* @short A window on the document.
|
|
|
|
*
|
|
|
|
* TODO HACK OVER ME AND FIXME WITH A CHAINSAW
|
2004-12-12 17:10:59 +00:00
|
|
|
*/
|
|
|
|
struct DocumentViewport
|
|
|
|
{
|
|
|
|
int lastPage;
|
|
|
|
};
|
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
/**
|
2004-12-11 17:25:03 +00:00
|
|
|
* @short A Dom tree that describes the Table of Contents.
|
|
|
|
*
|
|
|
|
* The Synopsis (TOC or Table Of Contents for friends) is represented via
|
|
|
|
* a dom tree where each nod has an internal name (displayed in the listview)
|
|
|
|
* and one or more attributes.
|
|
|
|
*
|
|
|
|
* To fill in a valid synopsis tree just add domElements where the tag name
|
|
|
|
* is the screen name of the entry.
|
|
|
|
*
|
|
|
|
* The following attributes are valid [more may be added in future]:
|
|
|
|
* - Page: The page to which the node refers.
|
|
|
|
* - Position: The position inside the page, where 0 means top and 100 is
|
|
|
|
* the bottom.
|
2004-12-10 16:04:45 +00:00
|
|
|
*/
|
2004-12-11 17:25:03 +00:00
|
|
|
class DocumentSynopsis : public QDomDocument
|
2004-12-10 16:04:45 +00:00
|
|
|
{
|
|
|
|
public:
|
2004-12-11 17:25:03 +00:00
|
|
|
// void implementation, only subclassed for naming!
|
|
|
|
DocumentSynopsis() : QDomDocument() {};
|
2004-12-10 16:04:45 +00:00
|
|
|
};
|
|
|
|
|
2004-09-08 12:41:14 +00:00
|
|
|
#endif
|