You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

113 lines
3.8 KiB

/***************************************************************************
* Copyright (C) 2005 by Piotr Szymański <niedakh@gmail.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 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef _KPDF_TGENERATOR_H_
#define _KPDF_TGENERATOR_H_
#include "core/generator.h"
#include <qsize.h>
#include <qmutex.h>
#include "dom/dom_node.h"
#define CHM_DATAREADY_ID 6990
class CHMFile;
class KHTMLPart;
class PixmapThreader;
class QCustomEvent;
class KPDFTextPage;
class TGenerator : public Generator
{
Q_OBJECT
public:
TGenerator(KPDFDocument * doc );
bool loadDocument( const QString & fileName, QVector< KPDFPage * > & pagesVector );
const DocumentInfo * generateDocumentInfo();
const DocumentSynopsis * generateDocumentSynopsis();
const DocumentFonts * generateDocumentFonts();
bool isAllowed( int /*Document::Permisison(s)*/ );
bool canGeneratePixmap( bool async );
void generatePixmap( PixmapRequest * request );
bool canGenerateTextPage();
void generateSyncTextPage( KPDFPage * page );
QString getXMLFile();
void setupGUI(KActionCollection * ac , QToolBox * tBox );
bool supportsSearching();
bool prefersInternalSearching();
bool supportsRotation();
RegularAreaRect * findText( const QString & text, SearchDir dir, const bool strictCase,
const RegularAreaRect * lastRect, KPDFPage * page);
QString* getText( const RegularAreaRect * area, KPDFPage * page );
void setOrientation(QVector<KPDFPage*> & pagesVector, int orientation);
bool canConfigurePrinter( ) ;
bool print( KPrinter& /*printer*/ ) ;
QString getMetaData( const QString &/*key*/, const QString &/*option*/ );
bool reparseConfig() ;
void addPages( KConfigDialog* /*dlg*/) ;
bool handleEvent (QEvent * /*event*/ ) ;
public slots:
void slotCompleted();
signals:
void error(QString & string, int duration);
void warning(QString & string, int duration);
void notice(QString & string, int duration);
private:
void additionalRequestData ();
void recursiveExploreNodes(DOM::Node node,KPDFTextPage *tp);
void preparePageForSyncOperation( int zoom , const QString & url);
// void customEvent( QCustomEvent * e );
DocumentSynopsis m_docSyn;
CHMFile* m_file;
KHTMLPart *m_syncGen;
// KHTMLPart *m_asyncGen;
// QSize m_size;
QMutex syncLock;
QString m_fileName;
// QMutex asyncLock;
QMutex pageLock;
// friend class PixmapThreader;
// PixmapThreader * px;
// 0 is loading document
// 1 is requesting pixmaps
// -1 is internal error :)
int m_state;
PixmapRequest* m_request;
volatile bool m_doneFlagSet;
};
// for now impossible to use KHTMLPart outside the main app, maybe in KDE4
// no async therefore
/*
class PixmapThreader : public QObject, public QThread
{
Q_OBJECT
public:
PixmapThreader (TGenerator* gen) : m_gen(gen) {;} ;
QPixmap * takePixmap() { return m_pix; };
void startGeneration(PixmapRequest * req) { m_req=req; start(); };
private:
void run();
PixmapRequest* m_req;
QString page;
QPixmap * m_pix;
TGenerator * m_gen;
};*/
#endif