1 /* This file is part of the KDE project 2 Copyright (C) 2006-2008 Thorsten Zachmann <zachmann@kde.org> 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License as published by the Free Software Foundation; either 7 version 2 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public License 15 along with this library; see the file COPYING.LIB. If not, write to 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef KPRDOCUMENT_H 21 #define KPRDOCUMENT_H 22 23 #include <QObject> 24 25 #include <KoPADocument.h> 26 #include "KPrCustomSlideShows.h" 27 28 class KPrDeclarations; 29 class KPrShapeAnimation; 30 class KPrShapeAnimations; 31 32 #define STAGE_MIME_TYPE "application/vnd.oasis.opendocument.presentation" 33 34 class STAGE_EXPORT KPrDocument : public KoPADocument 35 { 36 Q_OBJECT 37 public: 38 explicit KPrDocument(KoPart *part=0); 39 ~KPrDocument() override; 40 41 /// reimplemented 42 KoPAPage *newPage(KoPAMasterPage *masterPage) override; 43 /// reimplemented 44 KoPAMasterPage * newMasterPage() override; 45 46 /// reimplemented 47 KoOdf::DocumentType documentType() const override; 48 49 /// reimplemented from KoDocument nativeFormatMimeType()50 QByteArray nativeFormatMimeType() const override { return STAGE_MIME_TYPE; } 51 /// reimplemented from KoDocument nativeOasisMimeType()52 QByteArray nativeOasisMimeType() const override {return STAGE_MIME_TYPE;} 53 /// reimplemented from KoDocument extraNativeMimeTypes()54 QStringList extraNativeMimeTypes() const override 55 { 56 return QStringList() << "application/vnd.oasis.opendocument.presentation-template"; 57 } 58 59 /** 60 * @brief Add animation to shape 61 * 62 * @param animation animation to add to shape 63 */ 64 void addAnimation( KPrShapeAnimation * animation ); 65 66 /** 67 * @brief Remove animation from shape 68 * 69 * @param animation animation to remove from shape 70 * @param removeFromApplicationData if true the animation will also be removed from the 71 * application data 72 */ 73 void removeAnimation( KPrShapeAnimation * animation, bool removeFromApplicationData = true ); 74 75 void replaceAnimation(KPrShapeAnimation *oldAnimation, KPrShapeAnimation *newAnimation); 76 77 /** 78 * @brief get the slideShows defined for this document 79 */ 80 KPrCustomSlideShows* customSlideShows(); 81 void setCustomSlideShows( KPrCustomSlideShows* replacement ); 82 83 /** 84 * Get the presentation monitor (screen) used for presentation 85 * 86 * @return the screen used for presentation, starting from screen 0 87 */ 88 int presentationMonitor(); 89 90 /** 91 * Set the presentation monitor (screen) used for presentation 92 * 93 * @param monitor the new screen number used for presentation 94 */ 95 Q_INVOKABLE void setPresentationMonitor( int monitor ); 96 97 /** 98 * Check whether the presenter view feature is enabled for presentation 99 * 100 * @return true if presenter view is enabled, false otherwise 101 */ 102 bool isPresenterViewEnabled(); 103 104 /** 105 * Enable / disable the presenter view features 106 * 107 * @param enabled whether the presenter view should be enabled or disabled 108 */ 109 Q_INVOKABLE void setPresenterViewEnabled( bool enabled ); 110 111 /** 112 * Get the list of pages for slide show. It is possible that the pages for 113 * slideshow are different from KoPADocument::pages() due to custom slide show 114 * 115 * @return the list of pages for slide show 116 */ 117 QList<KoPAPageBase*> slideShow() const; 118 119 /** 120 * Get the name of currently active custom slide show, or an empty string 121 * if "all slides" is used for the slide show and no active custom slide show 122 * 123 * @return the name of currently active custom slide show, or empty string if none 124 */ 125 QString activeCustomSlideShow() const; 126 127 /** 128 * Set the currently active custom slide show. The custom slide show name should 129 * be valid, i.e. KPrCustomSlideShow::names() contains the name 130 * 131 * @param customSlideShow the new active custom slide show 132 */ 133 void setActiveCustomSlideShow( const QString &customSlideShow ); 134 135 /// reimplemented 136 void saveOdfDocumentStyles( KoPASavingContext & context ) override; 137 138 /// reimplemented 139 bool loadOdfDocumentStyles( KoPALoadingContext & context ) override; 140 141 /// reimplemented 142 bool loadOdfProlog( const KoXmlElement & body, KoPALoadingContext & context ) override; 143 144 /** 145 * Get the page type used in the document 146 * 147 * The default page type KoPageApp::Page is returned 148 */ 149 KoPageApp::PageType pageType() const override; 150 151 /** 152 * Get the KPrDeclarations pointer 153 */ 154 KPrDeclarations * declarations() const; 155 156 public Q_SLOTS: 157 void initEmpty() override; 158 159 Q_SIGNALS: 160 /** 161 * Emitted when the active custom slide show changes. 162 * This is to allow for signalling dbus interfaces. 163 * 164 * @param customSlideShow the new active custom slide show 165 */ 166 void activeCustomSlideShowChanged( const QString &customSlideShow ); 167 168 /** 169 * Emitted when the custom slide shows have been modified. 170 * This is to allow for signalling dbus interfaces. 171 */ 172 void customSlideShowsModified(); 173 174 protected: 175 /// reimplemented 176 const char *odfTagName( bool withNamespace ) override; 177 178 /// reimplemented 179 bool loadOdfEpilogue( const KoXmlElement & body, KoPALoadingContext & context ) override; 180 181 /// reimplemented 182 bool saveOdfProlog( KoPASavingContext & paContext ) override; 183 184 /// reimplemented 185 bool saveOdfEpilogue( KoPASavingContext & context ) override; 186 187 /// reimplemented 188 void postAddShape( KoPAPageBase * page, KoShape * shape ) override; 189 /// reimplemented 190 void postRemoveShape( KoPAPageBase * page, KoShape * shape ) override; 191 192 /// reimplemented 193 void removePages(QList<KoPAPageBase*> &pages) override; 194 195 /// load configuration specific to Stage 196 void loadKPrConfig(); 197 198 /// save configuration specific to Stage 199 void saveKPrConfig(); 200 201 /** 202 * @brief get the animations of the page 203 */ 204 KPrShapeAnimations & animationsByPage( KoPAPageBase * page ); 205 206 KPrCustomSlideShows *m_customSlideShows; 207 208 private: 209 int m_presentationMonitor; 210 bool m_presenterViewEnabled; 211 QString m_activeCustomSlideShow; 212 /// Message shown before Stage quits with an error if something is wrong 213 KPrDeclarations *m_declarations; 214 }; 215 216 #endif /* KPRDOCUMENT_H */ 217