2004-09-08 12:41:14 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2004 by Enrico Ros <eros.kde@email.it> *
|
|
|
|
* *
|
|
|
|
* 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_PAGE_H_
|
|
|
|
#define _KPDF_PAGE_H_
|
|
|
|
|
2004-10-02 14:30:30 +00:00
|
|
|
#include <qmap.h>
|
|
|
|
#include <qvaluelist.h>
|
|
|
|
|
2004-09-15 20:45:00 +00:00
|
|
|
class QPixmap;
|
2005-01-02 20:32:58 +00:00
|
|
|
class QRect;
|
2004-09-16 21:04:49 +00:00
|
|
|
class TextPage;
|
2004-12-10 16:04:45 +00:00
|
|
|
class KPDFPageRect;
|
2005-01-02 20:32:58 +00:00
|
|
|
class KPDFPageTransition;
|
2005-02-01 18:26:56 +00:00
|
|
|
class HighlightRect;
|
2004-09-08 12:41:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @short Collector for all the data belonging to a page.
|
|
|
|
*
|
2005-01-07 13:03:10 +00:00
|
|
|
* The KPDFPage class contains pixmaps (referenced using observers id as key),
|
|
|
|
* a search page (a class used internally for retrieving text), rect classes
|
|
|
|
* (that describe links or other active areas in the current page) and more.
|
2004-09-15 20:45:00 +00:00
|
|
|
*
|
2005-01-07 13:03:10 +00:00
|
|
|
* Note: All objects are reparented to this class.
|
2004-09-08 12:41:14 +00:00
|
|
|
*/
|
2004-09-10 17:44:05 +00:00
|
|
|
class KPDFPage
|
2004-09-08 12:41:14 +00:00
|
|
|
{
|
2004-11-06 00:56:55 +00:00
|
|
|
public:
|
|
|
|
KPDFPage( uint number, float width, float height, int rotation );
|
|
|
|
~KPDFPage();
|
|
|
|
|
2005-02-01 18:26:56 +00:00
|
|
|
enum KPDFPageAttributes { Bookmark = 1, Highlights = 2 };
|
2004-11-06 00:56:55 +00:00
|
|
|
|
|
|
|
// query properties (const read-only methods)
|
|
|
|
inline int number() const { return m_number; }
|
|
|
|
inline int rotation() const { return m_rotation; }
|
|
|
|
inline float width() const { return m_width; }
|
|
|
|
inline float height() const { return m_height; }
|
|
|
|
inline float ratio() const { return m_height / m_width; }
|
2005-02-01 18:26:56 +00:00
|
|
|
inline bool hasBookmark() const { return m_bookmarked; }
|
|
|
|
inline bool hasHighlights() const { return !m_highlights.isEmpty(); }
|
2004-11-06 00:56:55 +00:00
|
|
|
|
2004-12-21 12:38:52 +00:00
|
|
|
bool hasPixmap( int id, int width = -1, int height = -1 ) const;
|
2004-12-10 16:04:45 +00:00
|
|
|
bool hasSearchPage() const;
|
|
|
|
bool hasRect( int mouseX, int mouseY ) const;
|
2004-12-26 21:20:17 +00:00
|
|
|
bool hasLink( int mouseX, int mouseY ) const;
|
2005-02-01 18:26:56 +00:00
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
const KPDFPageRect * getRect( int mouseX, int mouseY ) const;
|
2005-02-01 18:26:56 +00:00
|
|
|
// - HL? .. -
|
2005-01-02 20:32:58 +00:00
|
|
|
const KPDFPageTransition * getTransition() const;
|
2005-02-01 18:26:56 +00:00
|
|
|
|
2005-01-10 13:43:44 +00:00
|
|
|
const QString getTextInRect( const QRect & rect, double zoom /*= 1.0*/ ) const;
|
2004-11-06 00:56:55 +00:00
|
|
|
|
2004-11-12 10:58:33 +00:00
|
|
|
// operations (by KPDFDocument)
|
2005-02-01 18:26:56 +00:00
|
|
|
inline void setBookmark( bool state ) { m_bookmarked = state; }
|
|
|
|
HighlightRect * searchText( const QString & text,
|
|
|
|
bool strictCase, HighlightRect * lastPosition = 0 );
|
2004-11-06 00:56:55 +00:00
|
|
|
|
2005-02-01 18:26:56 +00:00
|
|
|
// oprations: set/delete contents (by KPDFDocument)
|
2004-11-06 00:56:55 +00:00
|
|
|
void setPixmap( int id, QPixmap * pixmap );
|
|
|
|
void setSearchPage( TextPage * text );
|
2004-12-10 16:04:45 +00:00
|
|
|
void setRects( const QValueList< KPDFPageRect * > rects );
|
2005-02-01 18:26:56 +00:00
|
|
|
void setHighlight( HighlightRect * hr, bool add = true );
|
2005-01-02 20:32:58 +00:00
|
|
|
void setTransition( const KPDFPageTransition * transition );
|
2004-12-21 12:38:52 +00:00
|
|
|
void deletePixmap( int id );
|
2004-12-10 16:04:45 +00:00
|
|
|
void deletePixmapsAndRects();
|
2005-02-01 18:26:56 +00:00
|
|
|
void deleteHighlights( int id = -1 );
|
2004-11-06 00:56:55 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class PagePainter;
|
2005-02-01 18:26:56 +00:00
|
|
|
int m_number, m_rotation;
|
2004-11-06 00:56:55 +00:00
|
|
|
float m_width, m_height;
|
2005-02-01 18:26:56 +00:00
|
|
|
bool m_bookmarked;
|
2004-11-06 00:56:55 +00:00
|
|
|
|
|
|
|
QMap< int, QPixmap * > m_pixmaps;
|
|
|
|
TextPage * m_text;
|
2004-12-10 16:04:45 +00:00
|
|
|
QValueList< KPDFPageRect * > m_rects;
|
2005-02-01 18:26:56 +00:00
|
|
|
QValueList< HighlightRect * > m_highlights;
|
2005-01-02 20:32:58 +00:00
|
|
|
const KPDFPageTransition * m_transition;
|
2004-09-08 12:41:14 +00:00
|
|
|
};
|
2004-10-02 14:30:30 +00:00
|
|
|
|
2004-12-10 16:04:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @short A rect on the page that may contain an object.
|
|
|
|
*
|
|
|
|
* This class describes a rect (geometrical coordinates) and may hold a
|
|
|
|
* pointer to an associated object. An object is reparented to this class
|
|
|
|
* and deleted when this class is deleted.
|
|
|
|
*
|
|
|
|
* Objects are stored and read as 'void pointers' so you have to perform
|
|
|
|
* the cast on the code that handles the object using information provided
|
|
|
|
* by pointerType().
|
|
|
|
*
|
|
|
|
* Type / Class correspondency tab:
|
|
|
|
* - NoPointer : '' : no object is stored
|
|
|
|
* - Link : class KPDFLink : description of a link
|
|
|
|
* - Image : class KPDFImage : description of an image
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class KPDFPageRect
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
KPDFPageRect( int left, int top, int right, int bottom );
|
|
|
|
~KPDFPageRect();
|
|
|
|
|
|
|
|
// query geometric properties
|
|
|
|
bool contains( int x, int y ) const;
|
2005-01-07 13:03:10 +00:00
|
|
|
QRect geometry() const;
|
2004-12-10 16:04:45 +00:00
|
|
|
|
|
|
|
// set a pointer to data associated to this rect
|
|
|
|
enum PointerType { NoPointer, Link, Image };
|
|
|
|
void setPointer( void * object, enum PointerType pType );
|
|
|
|
|
|
|
|
// query type and get a const pointer to the stored object
|
|
|
|
PointerType pointerType() const;
|
|
|
|
const void * pointer() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void deletePointer();
|
|
|
|
int m_xMin, m_xMax, m_yMin, m_yMax;
|
|
|
|
PointerType m_pointerType;
|
|
|
|
void * m_pointer;
|
|
|
|
};
|
|
|
|
|
2005-02-01 18:26:56 +00:00
|
|
|
// TODO: comment this
|
|
|
|
struct HighlightRect
|
|
|
|
{
|
|
|
|
// publicly accessed fields
|
|
|
|
int id;
|
|
|
|
double left, top, right, bottom;
|
|
|
|
QColor color;
|
|
|
|
|
|
|
|
// initialize default values
|
|
|
|
HighlightRect();
|
|
|
|
HighlightRect( double l, double t, double r, double b );
|
|
|
|
};
|
|
|
|
|
2004-09-08 12:41:14 +00:00
|
|
|
#endif
|