~ubuntu-branches/ubuntu/natty/luatex/natty

« back to all changes in this revision

Viewing changes to source/libs/poppler/poppler-0.12.4/qt/poppler-qt.h

  • Committer: Package Import Robot
  • Author(s): Norbert Preining
  • Date: 2010-12-13 23:22:59 UTC
  • mfrom: (0.2.1) (1.5.4) (4.3.12 experimental)
  • Revision ID: package-import@ubuntu.com-20101213232259-nqq2mq5z5x6qldw3
Tags: 0.65.0-1
* new upstream release
* ship two source packages as they are distributed by upstream, only
  renamed to match source package requirements. Fix debian/rules
  to install the manual pdf from the right place

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* poppler-qt.h: qt interface to poppler
 
2
 * Copyright (C) 2005, Net Integration Technologies, Inc.
 
3
 * Copyright (C) 2005, Tobias Koening <tokoe@kde.org>
 
4
 * Copyright (C) 2005-2007, Albert Astals Cid <aacid@kde.org>
 
5
 * Copyright (C) 2005-2006, Stefan Kebekus <stefan.kebekus@math.uni-koeln.de>
 
6
 * Copyright (C) 2006, Wilfried Huss <Wilfried.Huss@gmx.at>
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2, or (at your option)
 
11
 * any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 
21
 */
 
22
 
 
23
#ifndef __POPPLER_QT_H__
 
24
#define __POPPLER_QT_H__
 
25
 
 
26
#include "poppler-link-qt3.h"
 
27
#include "poppler-page-transition.h"
 
28
 
 
29
#include <qcstring.h>
 
30
#include <qdatetime.h>
 
31
#include <qdom.h>
 
32
#include <qpixmap.h>
 
33
 
 
34
namespace Poppler {
 
35
 
 
36
class Document;
 
37
class Page;
 
38
 
 
39
/* A rectangle on a page, with coordinates in PDF points. */
 
40
class Rectangle
 
41
{
 
42
  public:
 
43
    Rectangle(double x1 = 0, double y1 = 0, double x2 = 0, double y2 = 0) : 
 
44
      m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2) {}
 
45
    bool isNull() const { return m_x1 == 0 && m_y1 == 0 && m_x2 == 0 && m_y2 == 0; }
 
46
  
 
47
    double m_x1;
 
48
    double m_y1;
 
49
    double m_x2;
 
50
    double m_y2;
 
51
};
 
52
 
 
53
class TextBox
 
54
{
 
55
 public:
 
56
    TextBox(const QString& text, const Rectangle &bBox) :
 
57
    m_text(text), m_bBox(bBox) {};
 
58
 
 
59
    QString getText() const { return m_text; };
 
60
    Rectangle getBoundingBox() const { return m_bBox; };
 
61
 
 
62
  private:
 
63
    QString m_text;
 
64
    Rectangle m_bBox;
 
65
};
 
66
 
 
67
 
 
68
/**
 
69
  Container class for information about a font within a PDF document
 
70
*/
 
71
class FontInfoData;
 
72
class FontInfo {
 
73
public:
 
74
  enum Type {
 
75
    unknown,
 
76
    Type1,
 
77
    Type1C,
 
78
    Type1COT,
 
79
    Type3,
 
80
    TrueType,
 
81
    TrueTypeOT,
 
82
    CIDType0,
 
83
    CIDType0C,
 
84
    CIDType0COT,
 
85
    CIDTrueType,
 
86
    CIDTrueTypeOT
 
87
  };
 
88
 
 
89
  /**
 
90
    Create a new font information container
 
91
  */
 
92
  FontInfo( const QString &fontName, const bool isEmbedded,
 
93
            const bool isSubset, Type type );
 
94
 
 
95
  FontInfo();
 
96
  
 
97
  FontInfo( const FontInfo &fi );
 
98
 
 
99
  ~FontInfo();
 
100
 
 
101
  /**
 
102
    The name of the font. Can be QString::null if the font has no name
 
103
  */
 
104
  const QString &name() const;
 
105
 
 
106
  /**
 
107
    Whether the font is embedded in the file, or not
 
108
 
 
109
    \return true if the font is embedded
 
110
  */
 
111
  bool isEmbedded() const;
 
112
 
 
113
  /**
 
114
    Whether the font provided is only a subset of the full
 
115
    font or not. This only has meaning if the font is embedded.
 
116
 
 
117
    \return true if the font is only a subset
 
118
  */
 
119
  bool isSubset() const;
 
120
 
 
121
  /**
 
122
    The type of font encoding
 
123
  */
 
124
  Type type() const;
 
125
 
 
126
  const QString &typeName() const;
 
127
 
 
128
private:
 
129
  FontInfoData *data;
 
130
};
 
131
 
 
132
class PageData;
 
133
class Page {
 
134
  friend class Document;
 
135
  public:
 
136
    ~Page();
 
137
    void renderToPixmap(QPixmap **q, int x, int y, int w, int h, double xres, double yres, bool doLinks = false) const;
 
138
 
 
139
    /**
 
140
      This is a convenience function that is equivalent to
 
141
      renderToPixmap() with xres and yres set to 72.0. We keep it
 
142
      only for binary compatibility
 
143
 
 
144
      \sa renderToImage()
 
145
     */
 
146
    void renderToPixmap(QPixmap **q, int x, int y, int w, int h, bool doLinks = false) const;
 
147
 
 
148
    /**
 
149
      \brief Render the page to a QImage using the Splash renderer
 
150
 
 
151
     This method can be used to render the page to a QImage. It
 
152
     uses the "Splash" rendering engine.
 
153
 
 
154
     \param xres horizontal resolution of the graphics device,
 
155
     in dots per inch (defaults to 72 dpi)
 
156
 
 
157
     \param yres vertical resolution of the graphics device, in
 
158
     dots per inch (defaults to 72 dpi)
 
159
 
 
160
     \returns a QImage of the page.
 
161
 
 
162
     \sa renderToPixmap()
 
163
    */
 
164
    QImage renderToImage(double xres = 72.0, double yres = 72.0, bool doLinks = false) const;
 
165
 
 
166
    /**
 
167
     * Returns the size of the page in points
 
168
     **/
 
169
    QSize pageSize() const;
 
170
 
 
171
    /**
 
172
    * Returns the text that is inside the Rectangle r
 
173
    * If r is a null Rectangle all text of the page is given
 
174
    **/
 
175
    QString getText(const Rectangle &r) const;
 
176
 
 
177
    QValueList<TextBox*> textList() const;
 
178
 
 
179
    /**
 
180
    * Returns the transition of this page
 
181
    **/
 
182
    PageTransition *getTransition() const;
 
183
 
 
184
    enum Orientation {
 
185
      Landscape,
 
186
      Portrait,
 
187
      Seascape,
 
188
      UpsideDown
 
189
    };
 
190
 
 
191
    /**
 
192
    *  The orientation of the page
 
193
    **/
 
194
    Orientation orientation() const;
 
195
    
 
196
    /**
 
197
      Gets the links of the page once it has been rendered if doLinks was true
 
198
    */
 
199
    QValueList<Link*> links() const;
 
200
 
 
201
  private:
 
202
    Page(const Document *doc, int index);
 
203
    PageData *data;
 
204
};
 
205
 
 
206
class DocumentData;
 
207
 
 
208
class Document {
 
209
  friend class Page;
 
210
  
 
211
public:
 
212
  enum PageMode {
 
213
    UseNone,
 
214
    UseOutlines,
 
215
    UseThumbs,
 
216
    FullScreen,
 
217
    UseOC
 
218
  };
 
219
  
 
220
  static Document *load(const QString & filePath);
 
221
  
 
222
  Page *getPage(int index) const{ return new Page(this, index); }
 
223
  
 
224
  int getNumPages() const;
 
225
  
 
226
  PageMode getPageMode() const;
 
227
  
 
228
  bool unlock(const QCString &password);
 
229
  
 
230
  bool isLocked() const;
 
231
  
 
232
  QDateTime getDate( const QString & data ) const;
 
233
  QString getInfo( const QString & data ) const;
 
234
  bool isEncrypted() const;
 
235
  bool isLinearized() const;
 
236
  bool okToPrint() const;
 
237
  bool okToChange() const;
 
238
  bool okToCopy() const;
 
239
  bool okToAddNotes() const;
 
240
  double getPDFVersion() const;
 
241
  /**
 
242
    The version of the PDF specification that the document
 
243
    conforms to
 
244
 
 
245
    \param major an optional pointer to a variable where store the
 
246
    "major" number of the version
 
247
    \param minor an optional pointer to a variable where store the
 
248
    "minor" number of the version
 
249
 
 
250
    \since 0.12
 
251
  */
 
252
  void getPdfVersion(int *major, int *minor) const;
 
253
 
 
254
  bool print(const QString &fileName, QValueList<int> pageList, double hDPI, double vDPI, int rotate);
 
255
 
 
256
  // If you are using QPrinter you can get paper size doing
 
257
  // QPrinter dummy(QPrinter::PrinterResolution);
 
258
  // dummy.setFullPage(true);
 
259
  // dummy.setPageSize(thePageSizeYouWant);
 
260
  // QPaintDeviceMetrics metrics(&dummy);
 
261
  // int width = metrics.width();
 
262
  // int height = metrics.height();
 
263
  bool print(const QString &fileName, QValueList<int> pageList, double hDPI, double vDPI, int rotate, int paperWidth, int paperHeight);
 
264
 
 
265
  /**
 
266
    The fonts within the PDF document.
 
267
 
 
268
    \note this can take a very long time to run with a large
 
269
    document. You may wish to use the call below if you have more
 
270
    than say 20 pages
 
271
  */
 
272
  QValueList<FontInfo> fonts() const;
 
273
 
 
274
  /**
 
275
    \overload
 
276
 
 
277
    \param numPages the number of pages to scan
 
278
    \param fontList pointer to the list where the font information
 
279
    should be placed
 
280
 
 
281
    \return false if the end of the document has been reached
 
282
  */
 
283
  bool scanForFonts( int numPages, QValueList<FontInfo> *fontList ) const;
 
284
 
 
285
  /**
 
286
    Gets the TOC of the Document, it is application responsabiliy to delete
 
287
    it when no longer needed
 
288
 
 
289
    * In the tree the tag name is the 'screen' name of the entry. A tag can have
 
290
    * attributes. Here follows the list of tag attributes with meaning:
 
291
    * - Destination: A string description of the referred destination
 
292
    * - DestinationName: A 'named reference' to the viewport that must be converted
 
293
    *      using linkDestination( *destination_name* )
 
294
    * - ExternalFileName: A link to a external filename
 
295
 
 
296
     \returns NULL if the Document does not have TOC
 
297
  */
 
298
  QDomDocument *toc() const;
 
299
 
 
300
  LinkDestination *linkDestination( const QString &name );
 
301
 
 
302
  ~Document();
 
303
  
 
304
private:
 
305
  DocumentData *data;
 
306
  Document(DocumentData *dataA);
 
307
};
 
308
 
 
309
}
 
310
#endif