poppler-qt.h 4.86 KB
Newer Older
1 2
/* poppler-qt.h: qt interface to poppler
 * Copyright (C) 2005, Net Integration Technologies, Inc.
3
 * Copyright (C) 2005, Tobias Koening
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef __POPPLER_QT_H__
#define __POPPLER_QT_H__

#include <qcstring.h>
#include <qdatetime.h>
#include <qpixmap.h>

namespace Poppler {

29
class Document;
30
class Page;
31

32 33 34 35 36 37 38 39 40 41 42 43 44 45
/* A rectangle on a page, with coordinates in PDF points. */
class Rectangle
{
  public:
    Rectangle(double x1 = 0, double y1 = 0, double x2 = 0, double y2 = 0) : 
      m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2) {}
    bool isNull() const { return m_x1 == 0 && m_y1 == 0 && m_x2 == 0 && m_y2 == 0; }
  
    double m_x1;
    double m_y1;
    double m_x2;
    double m_y2;
};

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
class TextBox
{
 public:
    TextBox(const QString& text, const Rectangle &bBox) :
    m_text(text), m_bBox(bBox) {};

    QString getText() const { return m_text; };
    Rectangle getBoundingBox() const { return m_bBox; };

  private:
    QString m_text;
    Rectangle m_bBox;
};


61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
class PageTransitionData;
class PageTransition
{
friend class Page;
public:
  enum Type {
    Replace,
    Split,
    Blinds,
    Box,
    Wipe,
    Dissolve,
    Glitter,
    Fly,
    Push,
    Cover,
    Uncover,
    Fade
  };

  enum Alignment {
    Horizontal,
    Vertical
  };

  enum Direction {
    Inward,
    Outward
  };


  // Destructor
  ~PageTransition();

  // Get type of the transition.
  Type getType() const { return type; }

  // Get duration of the transition in seconds.
  int getDuration() const { return duration; }

  // Get dimension in which the transition effect
  // occurs.
  Alignment getAlignment() const { return alignment; }

  // Get direction of motion of the transition effect.
  Direction getDirection() const { return direction; }

  // Get direction in which the transition effect moves.
  int getAngle() const { return angle; }

  // Get starting or ending scale.
  double getScale() const { return scale; }

  // Returns true if the area to be flown is rectangular and
  // opaque.
  bool isRectangular() const { return rectangular; }

private:
  // Construct a new PageTransition object from a page dictionary.
  PageTransition( const PageTransitionData &data );

  Type type;
  int duration;
  Alignment alignment;
  Direction direction;
  int angle;
  double scale;
  bool rectangular;
};

131 132 133 134
class PageData;
class Page {
  friend class Document;
  public:
135
    ~Page();
136 137 138 139 140 141 142
    void renderToPixmap(QPixmap **q, int x, int y, int w, int h, double xres, double yres) const;

    /**
     * This is a convenience function that is equivalent to
     * renderToPixmap() with xres and yres set to 72.0. We keep it
     * only for binary compatibility
     **/
143
    void renderToPixmap(QPixmap **q, int x, int y, int w, int h) const;
144
    
145 146 147 148 149
    /**
     * Returns the size of the page in points
     **/
    QSize pageSize() const;

150 151 152 153 154
    /**
    * Returns the text that is inside the Rectangle r
    * If r is a null Rectangle all text of the page is given
    **/
    QString getText(const Rectangle &r) const;
155

156 157
    QValueList<TextBox*> textList() const;

158 159 160 161
    /**
    * Returns the transition of this page
    **/
    PageTransition *getTransition() const;
162 163 164 165 166 167 168 169 170 171 172 173

    enum Orientation {
      Landscape,
      Portrait,
      Seascape,
      UpsideDown
    };

    /**
    *  The orientation of the page
    **/
    Orientation orientation() const;
174
    
175
  private:
176
    Page(const Document *doc, int index);
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
    PageData *data;
};

class DocumentData;

class Document {
  friend class Page;
  
public:
  enum PageMode {
    UseNone,
    UseOutlines,
    UseThumbs,
    FullScreen,
    UseOC
  };
  
  static Document *Document::load(const QString & filePath);
  
196
  Page *getPage(int index) const{ return new Page(this, index); }
197
  
198
  int getNumPages() const;
199
  
200
  PageMode getPageMode() const;
201
  
202
  bool unlock(const QCString &password);
203
  
204
  bool isLocked() const;
205 206 207
  
  QDateTime getDate( const QString & data ) const;
  QString getInfo( const QString & data ) const;
208 209
  bool isEncrypted() const;
  bool isLinearized() const;
210 211 212 213
  bool okToPrint() const;
  bool okToChange() const;
  bool okToCopy() const;
  bool okToAddNotes() const;
214
  double getPDFVersion() const;
215 216 217 218 219 220 221 222 223 224
  
  Document::~Document();
  
private:
  DocumentData *data;
  Document::Document(DocumentData *dataA);
};

}
#endif