~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to libs/odf/kopicture/KoPictureEps.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* This file is part of the KDE project
2
 
   Copyright (c) 2001 Simon Hausmann <hausmann@kde.org>
3
 
   Copyright (C) 2002, 2003, 2004 Nicolas GOUTTE <goutte@kde.org>
4
 
 
5
 
   This library is free software; you can redistribute it and/or
6
 
   modify it under the terms of the GNU Library General Public
7
 
   License as published by the Free Software Foundation; either
8
 
   version 2 of the License, or (at your option) any later version.
9
 
 
10
 
   This library is distributed in the hope that it will be useful,
11
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 
   Library General Public License for more details.
14
 
 
15
 
   You should have received a copy of the GNU Library General Public License
16
 
   along with this library; see the file COPYING.LIB.  If not, write to
17
 
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
 
 * Boston, MA 02110-1301, USA.
19
 
*/
20
 
#ifndef __koPictureEps_h__
21
 
#define __koPictureEps_h__
22
 
 
23
 
#include <QString>
24
 
//Added by qt3to4:
25
 
#include <QPixmap>
26
 
 
27
 
#include "KoPictureBase.h"
28
 
 
29
 
class QPainter;
30
 
class QSize;
31
 
 
32
 
 
33
 
// TODO: fix documentation
34
 
 
35
 
/**
36
 
 * @internal
37
 
 * KoPictureEps is a container class for a EPS picture
38
 
 */
39
 
class KoPictureEps : public KoPictureBase
40
 
{
41
 
public:
42
 
    /**
43
 
     * Default constructor.
44
 
     */
45
 
    KoPictureEps();
46
 
 
47
 
    /**
48
 
     * Destructor.
49
 
     */
50
 
    virtual ~KoPictureEps();
51
 
 
52
 
    KoPictureType::Type getType(void) const;
53
 
 
54
 
    KoPictureBase* newCopy(void) const;
55
 
 
56
 
    /**
57
 
     * Returns true if the picture is null.
58
 
     */
59
 
    virtual bool isNull(void) const;
60
 
 
61
 
    /**
62
 
     * @brief Draw the image in a painter.
63
 
     *
64
 
     * No, this isn't as simple as painter.drawPixmap().
65
 
     * This method ensures that the best quality is used when printing, scaling the painter.
66
 
     *
67
 
     * The parameter @p fastMode allows the picture to be re-sized and drawn quicker if possible
68
 
     *
69
 
     * The parameters @p width, @p height define the desired size for the image
70
 
     * Note that the image is being scaled to that size using scale() - except when printing.
71
 
     * This avoids scaling the image at each paint event.
72
 
     *
73
 
     * The other parameters are very similar to QPainter::drawPixmap :
74
 
     * (@p x, @p y) define the position in the painter,
75
 
     * (@p sx, @p sy) specify the top-left point in pixmap that is to be drawn. The default is (0, 0).
76
 
     * (@p sw, @p sh) specify the size of the pixmap that is to be drawn. The default, (-1, -1), means all the way to the bottom
77
 
     * right of the pixmap.
78
 
     */
79
 
    virtual void draw(QPainter& painter, int x, int y, int width, int height, int sx = 0, int sy = 0, int sw = -1, int sh = -1, bool fastMode = false);
80
 
 
81
 
    virtual bool loadData(const QByteArray& array, const QString& extension);
82
 
 
83
 
    virtual bool save(QIODevice* io) const;
84
 
 
85
 
    virtual QSize getOriginalSize(void) const;
86
 
 
87
 
    virtual QPixmap generatePixmap(const QSize& size, bool smoothScale = false);
88
 
 
89
 
    virtual QString getMimeType(const QString& extension) const;
90
 
 
91
 
    /**
92
 
     * Generate a QImage
93
 
     * (always in slow mode)
94
 
     */
95
 
    virtual QImage generateImage(const QSize& size);
96
 
 
97
 
    virtual void clearCache(void);
98
 
protected:
99
 
    QPixmap getPixmap(QImage& image);
100
 
    void scaleAndCreatePixmap(const QSize& size, bool fastMode, const int resolutionx, const int resolutiony);
101
 
    QImage scaleWithGhostScript(const QSize& size, const int resolutionx, const int resolutiony);
102
 
    bool extractPostScriptStream(void);
103
 
 
104
 
private:
105
 
    int tryScaleWithGhostScript(QImage &image, const QSize& size, const int resolutionx, const int resolutiony, const char* device);
106
 
    /**
107
 
     * @brief Read a line from a PostScript stream in a QByteArray
108
 
     *
109
 
     * The PostScript stream is somewhere in the QByteArray and therefore has to be
110
 
     * determined by the start and length of this stream and the current position
111
 
     *
112
 
     * @param array the array which is read
113
 
     * @param start start position of the PostScript stream
114
 
     * @param length length of the PostScript stream
115
 
     * @param pos current position (which is also returned)
116
 
     * @param lastCharWasCr defines if the previous line ended with a Carriage Return,
117
 
     *   to skip an eventual Line Feed at the start of this line
118
 
     * @return the read line
119
 
     */
120
 
    QString readLine(const QByteArray& array, const uint start, const uint length, uint& pos, bool& lastCharWasCr);
121
 
 
122
 
private:
123
 
    /**
124
 
     * Copy of the loaded EPS file
125
 
     */
126
 
    QByteArray m_rawData;
127
 
    QPixmap m_cachedPixmap; ///< Cached pixmap
128
 
    QSize m_originalSize; ///< Original size of the EPS picture
129
 
    QSize m_cachedSize; ///< size of the currently cached pixmap @see m_cachedPixmap
130
 
    QRect m_boundingBox; ///< Bounding box, as read from the EPS file
131
 
    uint m_psStreamStart; ///< Start position of the PostScript stream (like if it was a MS-DOS EPS file)
132
 
    uint m_psStreamLength; ///< Length of the PostScript stream (like if it was a MS-DOS EPS file)
133
 
    /**
134
 
     * true, if the last cached image was done using fast mode.
135
 
     * false, if the last cached image was done using slow mode.
136
 
     */
137
 
    bool m_cacheIsInFastMode;
138
 
};
139
 
 
140
 
#endif /* __koPictureEps_h__ */