File indexing completed on 2024-05-12 16:36:43

0001 /* This file is part of the KDE project
0002    Copyright (C) 2006-2008 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 KPRDOCUMENT_H
0021 #define KPRDOCUMENT_H
0022 
0023 #include <QObject>
0024 
0025 #include <KoPADocument.h>
0026 #include "KPrCustomSlideShows.h"
0027 
0028 class KPrDeclarations;
0029 class KPrShapeAnimation;
0030 class KPrShapeAnimations;
0031 
0032 #define STAGE_MIME_TYPE "application/vnd.oasis.opendocument.presentation"
0033 
0034 class STAGE_EXPORT KPrDocument : public KoPADocument
0035 {
0036     Q_OBJECT
0037 public:
0038     explicit KPrDocument(KoPart *part=0);
0039     ~KPrDocument() override;
0040 
0041     /// reimplemented
0042     KoPAPage *newPage(KoPAMasterPage *masterPage) override;
0043     /// reimplemented
0044     KoPAMasterPage * newMasterPage() override;
0045 
0046     /// reimplemented
0047     KoOdf::DocumentType documentType() const override;
0048 
0049     /// reimplemented from KoDocument
0050     QByteArray nativeFormatMimeType() const override { return STAGE_MIME_TYPE; }
0051     /// reimplemented from KoDocument
0052     QByteArray nativeOasisMimeType() const override {return STAGE_MIME_TYPE;}
0053     /// reimplemented from KoDocument
0054     QStringList extraNativeMimeTypes() const override
0055     {
0056         return QStringList() << "application/vnd.oasis.opendocument.presentation-template";
0057     }
0058 
0059     /**
0060      * @brief Add animation to shape
0061      *
0062      * @param animation animation to add to shape
0063      */
0064     void addAnimation( KPrShapeAnimation * animation );
0065 
0066     /**
0067      * @brief Remove animation from shape
0068      *
0069      * @param animation animation to remove from shape
0070      * @param removeFromApplicationData if true the animation will also be removed from the
0071      *        application data
0072      */
0073     void removeAnimation( KPrShapeAnimation * animation, bool removeFromApplicationData = true );
0074 
0075     void replaceAnimation(KPrShapeAnimation *oldAnimation, KPrShapeAnimation *newAnimation);
0076 
0077     /**
0078      * @brief get the slideShows defined for this document
0079      */
0080     KPrCustomSlideShows* customSlideShows();
0081     void setCustomSlideShows( KPrCustomSlideShows* replacement );
0082 
0083     /**
0084      * Get the presentation monitor (screen) used for presentation
0085      *
0086      * @return the screen used for presentation, starting from screen 0
0087      */
0088     int presentationMonitor();
0089 
0090     /**
0091      * Set the presentation monitor (screen) used for presentation
0092      *
0093      * @param monitor the new screen number used for presentation
0094      */
0095     Q_INVOKABLE void setPresentationMonitor( int monitor );
0096 
0097     /**
0098      * Check whether the presenter view feature is enabled for presentation
0099      *
0100      * @return true if presenter view is enabled, false otherwise
0101      */
0102     bool isPresenterViewEnabled();
0103 
0104     /**
0105      * Enable / disable the presenter view features
0106      *
0107      * @param enabled whether the presenter view should be enabled or disabled
0108      */
0109     Q_INVOKABLE void setPresenterViewEnabled( bool enabled );
0110 
0111     /**
0112      * Get the list of pages for slide show. It is possible that the pages for
0113      * slideshow are different from KoPADocument::pages() due to custom slide show
0114      *
0115      * @return the list of pages for slide show
0116      */
0117     QList<KoPAPageBase*> slideShow() const;
0118 
0119     /**
0120      * Get the name of currently active custom slide show, or an empty string
0121      * if "all slides" is used for the slide show and no active custom slide show
0122      *
0123      * @return the name of currently active custom slide show, or empty string if none
0124      */
0125     QString activeCustomSlideShow() const;
0126 
0127     /**
0128      * Set the currently active custom slide show. The custom slide show name should
0129      * be valid, i.e. KPrCustomSlideShow::names() contains the name
0130      *
0131      * @param customSlideShow the new active custom slide show
0132      */
0133     void setActiveCustomSlideShow( const QString &customSlideShow );
0134 
0135     /// reimplemented
0136     void saveOdfDocumentStyles( KoPASavingContext & context ) override;
0137 
0138     /// reimplemented
0139     bool loadOdfDocumentStyles( KoPALoadingContext & context ) override;
0140 
0141     /// reimplemented
0142     bool loadOdfProlog( const KoXmlElement & body, KoPALoadingContext & context ) override;
0143 
0144     /**
0145      * Get the page type used in the document
0146      *
0147      * The default page type KoPageApp::Page is returned
0148      */
0149     KoPageApp::PageType pageType() const override;
0150 
0151     /**
0152      * Get the KPrDeclarations pointer
0153      */
0154     KPrDeclarations * declarations() const;
0155 
0156 public Q_SLOTS:
0157     void initEmpty() override;
0158 
0159 Q_SIGNALS:
0160     /**
0161      * Emitted when the active custom slide show changes.
0162      * This is to allow for signalling dbus interfaces.
0163      *
0164      * @param customSlideShow the new active custom slide show
0165      */
0166     void activeCustomSlideShowChanged( const QString &customSlideShow );
0167 
0168     /**
0169      * Emitted when the custom slide shows have been modified.
0170      * This is to allow for signalling dbus interfaces.
0171      */
0172     void customSlideShowsModified();
0173 
0174 protected:
0175     /// reimplemented
0176     const char *odfTagName( bool withNamespace ) override;
0177 
0178     /// reimplemented
0179     bool loadOdfEpilogue( const KoXmlElement & body, KoPALoadingContext & context ) override;
0180 
0181     /// reimplemented
0182     bool saveOdfProlog( KoPASavingContext & paContext ) override;
0183 
0184     /// reimplemented
0185     bool saveOdfEpilogue( KoPASavingContext & context ) override;
0186 
0187     /// reimplemented
0188     void postAddShape( KoPAPageBase * page, KoShape * shape ) override;
0189     /// reimplemented
0190     void postRemoveShape( KoPAPageBase * page, KoShape * shape ) override;
0191 
0192     /// reimplemented
0193     void removePages(QList<KoPAPageBase*> &pages) override;
0194 
0195     /// load configuration specific to Stage
0196     void loadKPrConfig();
0197 
0198     /// save configuration specific to Stage
0199     void saveKPrConfig();
0200 
0201     /**
0202      * @brief get the animations of the page
0203      */
0204     KPrShapeAnimations & animationsByPage( KoPAPageBase * page );
0205 
0206     KPrCustomSlideShows *m_customSlideShows;
0207 
0208 private:
0209     int m_presentationMonitor;
0210     bool m_presenterViewEnabled;
0211     QString m_activeCustomSlideShow;
0212     /// Message shown before Stage quits with an error if something is wrong
0213     KPrDeclarations *m_declarations;
0214 };
0215 
0216 #endif /* KPRDOCUMENT_H */