File: KoPAPageBase.h

package info (click to toggle)
calligra 1%3A2.9.11%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 189,332 kB
  • sloc: cpp: 919,806; xml: 27,759; ansic: 10,472; python: 8,190; perl: 2,724; yacc: 2,557; sh: 1,675; lex: 1,431; java: 1,304; sql: 903; ruby: 734; makefile: 48
file content (271 lines) | stat: -rw-r--r-- 7,929 bytes parent folder | download | duplicates (2)
1
2
3
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/* This file is part of the KDE project
   Copyright (C) 2006-2009 Thorsten Zachmann <zachmann@kde.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef KOPAPAGEBASE_H
#define KOPAPAGEBASE_H

#include <KoShapeContainer.h>

#include "KoPageApp.h"
#include "kopageapp_export.h"

#include <QSize>

#define CACHE_PAGE_THUMBNAILS

struct KoPageLayout;
class KoGenStyle;
class KoPALoadingContext;
class KoShapeManagerPaintingStrategy;
class KoZoomHandler;
class KoPASavingContext;

class QPixmap;
class QString;

/**
 * Base class used for KoPAMasterPage and KoPAPage
 *
 * A Page contains KoShapeLayer shapes as direct children. The layers than can
 * contain all the different shapes.
 */
class KOPAGEAPP_EXPORT KoPAPageBase : public KoShapeContainer
{
public:
    explicit KoPAPageBase();
    virtual ~KoPAPageBase();

    /**
     * @brief Save a page
     *
     * See ODF 9.1.4 Drawing Pages
     *
     * @param context the pageapp saving context
     * @return true on success, false otherwise
     */
    virtual void saveOdf( KoShapeSavingContext & context ) const = 0;

    /// reimplemented
    virtual bool loadOdf( const KoXmlElement & element, KoShapeLoadingContext & context );


    /// @return the layout of the page
    virtual KoPageLayout & pageLayout() = 0;
    virtual const KoPageLayout & pageLayout() const = 0;

    virtual void paintComponent(QPainter& painter, const KoViewConverter& converter, KoShapePaintingContext &paintcontext);

    /**
     * @brief Paint background
     *
     * @param painter used to paint the background
     * @param converter to convert between internal and view coordinates
     */
    virtual void paintBackground( QPainter & painter, const KoViewConverter & converter, KoShapePaintingContext &paintContext );

    /**
     * Get if master shapes should be displayed
     *
     * For master pages this always returns false
     *
     * @return true if master shapes should be displayed
     */
    virtual bool displayMasterShapes() = 0;

    /**
     * Set if the master shapes should be displayed
     *
     * For master pages this does nothing
     */
    virtual void setDisplayMasterShapes( bool display ) = 0;

    /**
     * Get if master page background should be used
     *
     * For master pages this always returns false
     *
     * @return true if master page background should be used
     */
    virtual bool displayMasterBackground() = 0;

    virtual void setDisplayMasterBackground( bool display ) = 0;

    /**
     * Get if the shape should be displayed or not
     * 
     * This is used for hiding special objects e.g. presentation:display-page-number="false"
     * 
     * @param shape for which to check if it should be shown or not.
     * @return true if the shape should be shown, otherwise false. 
     */
    virtual bool displayShape(KoShape *shape) const = 0;

    virtual QPixmap thumbnail( const QSize& size = QSize( 512, 512 ) );

    virtual QImage thumbImage(const QSize &size = QSize(512, 512));

    /**
     * This function is called when the content of the page changes
     *
     * It invalidates the pages thumbnail cache.
     */
    virtual void pageUpdated();

    /// reimplemented
    virtual QSizeF size() const;

    // reimplemented
    virtual QRectF boundingRect() const;

    /**
     * Returns the bounding rectangle of the pages content
     */
    virtual QRectF contentRect() const;

    /**
     * This function is called after a shape is added to the document on this page
     * The default implementation is empty.
     *
     * @param shape The shape that was added
     */
    virtual void shapeAdded( KoShape * shape );

    /**
     * This function is called after a shape is removed from the document off this page
     * The default implementation is empty.
     *
     * @param shape The shape that was removed
     */
    virtual void shapeRemoved( KoShape * shape );

    /**
     * Get the page type used in the document
     *
     * The default page type KoPageApp::Page is returned
     */
    virtual KoPageApp::PageType pageType() const;

    /**
     * Paint to content of the page to the painter
     *
     * @param painter The painter used to paint the page
     * @param zoomHandler The zoomHandler used to paint the page
     */
    virtual void paintPage( QPainter & painter, KoZoomHandler & zoomHandler ) = 0;

protected:
    /**
     * @param paContext the pageapp saving context
     */
    virtual void saveOdfPageContent( KoPASavingContext & paContext ) const;

    /**
     * @brief Save the layers of a page
     */
    void saveOdfLayers(KoPASavingContext &paContext) const;

    /**
     * @brief Save the shapes of a page
     *
     * See ODF 9.2 Drawing Shapes
     *
     * @param paContext the pageapp saving context
     * @return true on success, false otherwise
     */
    void saveOdfShapes( KoShapeSavingContext & context ) const;

    /**
     * @brief Save animations
     *
     * Here is a empty implementation as not all page apps need animations.
     *
     * @param paContext the pageapp saving context
     * @return true on success, false otherwise
     */
    virtual bool saveOdfAnimations( KoPASavingContext & paContext ) const;

    /**
     * @brief Save presentation notes
     *
     * Here is a empty implementation as not all page apps presentations notes.
     *
     * @param paContext the pageapp saving context
     * @return true on success, false otherwise
     */
    virtual bool saveOdfPresentationNotes(KoPASavingContext &paContext) const;

    /**
     * @brief Save the style of the page
     *
     * See ODF 14.13.2 Drawing Page Style
     *
     * @return name of the page style
     */
    QString saveOdfPageStyle( KoPASavingContext & paContext ) const;

    /**
     * @brief Save special data of a style
     *
     * @param style the page style
     * @param paContext the pageapp saving context
     *
     * @see saveOdfPageStyle
     */
    virtual void saveOdfPageStyleData( KoGenStyle &style, KoPASavingContext &paContext ) const;

    /**
     * @brief Load page data
     *
     * @param element the page element
     * @param paContext the pageapp loading context
     */
    virtual void loadOdfPageTag( const KoXmlElement &element, KoPALoadingContext &loadingContext );

    /**
     * @brief Load extra page data
     *
     * This method gets called after all shapes of the page are loaded. 
     * The default implentation is empty
     *
     * @param element the page element
     * @param paContext the pageapp loading context
     */
    virtual void loadOdfPageExtra( const KoXmlElement &element, KoPALoadingContext & loadingContext );

    /**
     * Create thumbnail for the page
     */
    QPixmap generateThumbnail(const QSize &size = QSize(512,512));

    /**
     * Get the key used for caching the thumbnail pixmap
     */
    QString thumbnailKey() const;

    /**
     * Get the painting strategy used for generating thumbnails
     *
     * The returned strategy needs to be alloced by new
     *
     * @return 0 which mean use the default strategy
     */
    virtual KoShapeManagerPaintingStrategy * getPaintingStrategy() const;
};

#endif /* KOPAPAGEBASE_H */