Warning, file /office/calligra/libs/pageapp/KoPAPageBase.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002    Copyright (C) 2006-2009 Thorsten Zachmann <zachmann@kde.org>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef KOPAPAGEBASE_H
0021 #define KOPAPAGEBASE_H
0022 
0023 #include <KoShapeContainer.h>
0024 
0025 #include "KoPageApp.h"
0026 #include "kopageapp_export.h"
0027 
0028 #include <QSize>
0029 
0030 #define CACHE_PAGE_THUMBNAILS
0031 
0032 struct KoPageLayout;
0033 class KoGenStyle;
0034 class KoPALoadingContext;
0035 class KoShapeManagerPaintingStrategy;
0036 class KoZoomHandler;
0037 class KoPASavingContext;
0038 
0039 class QPixmap;
0040 class QString;
0041 
0042 /**
0043  * Base class used for KoPAMasterPage and KoPAPage
0044  *
0045  * A Page contains KoShapeLayer shapes as direct children. The layers than can
0046  * contain all the different shapes.
0047  */
0048 class KOPAGEAPP_EXPORT KoPAPageBase : public KoShapeContainer
0049 {
0050 public:
0051     explicit KoPAPageBase();
0052     ~KoPAPageBase() override;
0053 
0054     /**
0055      * @brief Save a page
0056      *
0057      * See ODF 9.1.4 Drawing Pages
0058      *
0059      * @param context the pageapp saving context
0060      * @return true on success, false otherwise
0061      */
0062     void saveOdf( KoShapeSavingContext & context ) const override = 0;
0063 
0064     /// reimplemented
0065     bool loadOdf( const KoXmlElement & element, KoShapeLoadingContext & context ) override;
0066 
0067 
0068     /// @return the layout of the page
0069     virtual KoPageLayout & pageLayout() = 0;
0070     virtual const KoPageLayout & pageLayout() const = 0;
0071 
0072     void paintComponent(QPainter& painter, const KoViewConverter& converter, KoShapePaintingContext &paintcontext) override;
0073 
0074     /**
0075      * @brief Paint background
0076      *
0077      * @param painter used to paint the background
0078      * @param converter to convert between internal and view coordinates
0079      * @param paintContext the painting context
0080      */
0081     virtual void paintBackground( QPainter & painter, const KoViewConverter & converter, KoShapePaintingContext &paintContext );
0082 
0083     /**
0084      * Get if master shapes should be displayed
0085      *
0086      * For master pages this always returns false
0087      *
0088      * @return true if master shapes should be displayed
0089      */
0090     virtual bool displayMasterShapes() = 0;
0091 
0092     /**
0093      * Set if the master shapes should be displayed
0094      *
0095      * For master pages this does nothing
0096      */
0097     virtual void setDisplayMasterShapes( bool display ) = 0;
0098 
0099     /**
0100      * Get if master page background should be used
0101      *
0102      * For master pages this always returns false
0103      *
0104      * @return true if master page background should be used
0105      */
0106     virtual bool displayMasterBackground() = 0;
0107 
0108     virtual void setDisplayMasterBackground( bool display ) = 0;
0109 
0110     /**
0111      * Get if the shape should be displayed or not
0112      * 
0113      * This is used for hiding special objects e.g. presentation:display-page-number="false"
0114      * 
0115      * @param shape for which to check if it should be shown or not.
0116      * @return true if the shape should be shown, otherwise false. 
0117      */
0118     virtual bool displayShape(KoShape *shape) const = 0;
0119 
0120     virtual QPixmap thumbnail( const QSize& size = QSize( 512, 512 ) );
0121 
0122     virtual QImage thumbImage(const QSize &size = QSize(512, 512));
0123 
0124     /**
0125      * This function is called when the content of the page changes
0126      *
0127      * It invalidates the pages thumbnail cache.
0128      */
0129     virtual void pageUpdated();
0130 
0131     /// reimplemented
0132     QSizeF size() const override;
0133 
0134     // reimplemented
0135     QRectF boundingRect() const override;
0136 
0137     /**
0138      * Returns the bounding rectangle of the pages content
0139      */
0140     virtual QRectF contentRect() const;
0141 
0142     /**
0143      * This function is called after a shape is added to the document on this page
0144      * The default implementation is empty.
0145      *
0146      * @param shape The shape that was added
0147      */
0148     virtual void shapeAdded( KoShape * shape );
0149 
0150     /**
0151      * This function is called after a shape is removed from the document off this page
0152      * The default implementation is empty.
0153      *
0154      * @param shape The shape that was removed
0155      */
0156     virtual void shapeRemoved( KoShape * shape );
0157 
0158     /**
0159      * Get the page type used in the document
0160      *
0161      * The default page type KoPageApp::Page is returned
0162      */
0163     virtual KoPageApp::PageType pageType() const;
0164 
0165     /**
0166      * Paint to content of the page to the painter
0167      *
0168      * @param painter The painter used to paint the page
0169      * @param zoomHandler The zoomHandler used to paint the page
0170      */
0171     virtual void paintPage( QPainter & painter, KoZoomHandler & zoomHandler ) = 0;
0172 
0173 protected:
0174     /**
0175      * @param paContext the pageapp saving context
0176      */
0177     virtual void saveOdfPageContent( KoPASavingContext & paContext ) const;
0178 
0179     /**
0180      * @brief Save the layers of a page
0181      */
0182     void saveOdfLayers(KoPASavingContext &paContext) const;
0183 
0184     /**
0185      * @brief Save the shapes of a page
0186      *
0187      * See ODF 9.2 Drawing Shapes
0188      *
0189      * @param context the pageapp saving context
0190      * @return true on success, false otherwise
0191      */
0192     void saveOdfShapes( KoShapeSavingContext & context ) const;
0193 
0194     /**
0195      * @brief Save animations
0196      *
0197      * Here is a empty implementation as not all page apps need animations.
0198      *
0199      * @param paContext the pageapp saving context
0200      * @return true on success, false otherwise
0201      */
0202     virtual bool saveOdfAnimations( KoPASavingContext & paContext ) const;
0203 
0204     /**
0205      * @brief Save presentation notes
0206      *
0207      * Here is a empty implementation as not all page apps presentations notes.
0208      *
0209      * @param paContext the pageapp saving context
0210      * @return true on success, false otherwise
0211      */
0212     virtual bool saveOdfPresentationNotes(KoPASavingContext &paContext) const;
0213 
0214     /**
0215      * @brief Save the style of the page
0216      *
0217      * See ODF 14.13.2 Drawing Page Style
0218      *
0219      * @return name of the page style
0220      */
0221     QString saveOdfPageStyle( KoPASavingContext & paContext ) const;
0222 
0223     /**
0224      * @brief Save special data of a style
0225      *
0226      * @param style the page style
0227      * @param paContext the pageapp saving context
0228      *
0229      * @see saveOdfPageStyle
0230      */
0231     virtual void saveOdfPageStyleData( KoGenStyle &style, KoPASavingContext &paContext ) const;
0232 
0233     /**
0234      * @brief Load page data
0235      *
0236      * @param element the page element
0237      * @param loadingContext the pageapp loading context
0238      */
0239     virtual void loadOdfPageTag( const KoXmlElement &element, KoPALoadingContext &loadingContext );
0240 
0241     /**
0242      * @brief Load extra page data
0243      *
0244      * This method gets called after all shapes of the page are loaded. 
0245      * The default implementation is empty
0246      *
0247      * @param element the page element
0248      * @param loadingContext the pageapp loading context
0249      */
0250     virtual void loadOdfPageExtra( const KoXmlElement &element, KoPALoadingContext & loadingContext );
0251 
0252     /**
0253      * Create thumbnail for the page
0254      */
0255     QPixmap generateThumbnail(const QSize &size = QSize(512,512));
0256 
0257     /**
0258      * Get the key used for caching the thumbnail pixmap
0259      */
0260     QString thumbnailKey() const;
0261 
0262     /**
0263      * Get the painting strategy used for generating thumbnails
0264      *
0265      * The returned strategy needs to be alloced by new
0266      *
0267      * @return 0 which mean use the default strategy
0268      */
0269     virtual KoShapeManagerPaintingStrategy * getPaintingStrategy() const;
0270 };
0271 
0272 #endif /* KOPAPAGEBASE_H */