1 /* This file is part of the Calligra project 2 * Copyright (C) 2008 Sebastian Sauer <mail@dipe.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 KOTEXTPAGE_H 21 #define KOTEXTPAGE_H 22 23 #include "kritatext_export.h" 24 25 #include <QRectF> 26 #include <QMetaType> 27 28 class QString; 29 30 /** 31 * Interface for a single OpenDocumentText page. 32 * 33 * The Words KWPageTextInfo class does implement this interface to provide 34 * application specific functionality for single pages. 35 * @see KoTextShapeData::setPage(); 36 */ 37 class KRITATEXT_EXPORT KoTextPage 38 { 39 public: 40 /// Constructor. 41 explicit KoTextPage(); 42 /// Destructor. 43 virtual ~KoTextPage(); 44 45 enum PageSelection { 46 PreviousPage = -1, 47 CurrentPage = 0, 48 NextPage = 1 49 }; 50 51 /** 52 * Returns the unique number of this page for internal purposes. All pages 53 * are numbered consecutively starting by 1. 54 * 55 * This is used for example to anchor images to pages. The image then refers 56 * to the unique page-number. 57 */ 58 virtual int pageNumber() const = 0; 59 60 /** 61 * Returns the number of this page for display purposes. 62 * 63 * Example how the parameters are used within ODF to display the 64 * current page number on all pages except the first page; 65 * \code 66 * <text:page-number text:select-page="previous" text:page-adjust="1" /> 67 * \endcode 68 * 69 * \param select Defines the offset of the page to select for the 70 * resulting page number. If such a page does not exist, then -1 will be 71 * returned before the adjustment will be taken into account. This 72 * implements the ODF text:select-page attribute. 73 * \param adjustment The value of the page number will be adjusted by this 74 * specified number and if there exist a page with the resulting value it's 75 * page number gets returned, otherwise -1 will be returned. This implements the 76 * ODF text:page-adjust attribute. 77 * \return the user visible page number, or -1 if the page referenced does not 78 * exist. 79 */ 80 virtual int visiblePageNumber(PageSelection select = CurrentPage, int adjustment = 0) const = 0; 81 82 /** 83 * Returns the name of the master-page that should be used for this page or a null 84 * QString if this page does not explicit define a master-page in which case the 85 * default master-page will be used. 86 * 87 * Per default a null QString is returned. 88 */ 89 virtual QString masterPageName() const; 90 91 /** 92 * Returns the rect of the page in document coords 93 */ 94 virtual QRectF rect() const = 0; 95 96 /** 97 * Returns the (text) content rect of the page in document coords 98 */ contentRect()99 virtual QRectF contentRect() const {return rect();} 100 101 }; 102 103 Q_DECLARE_METATYPE(KoTextPage*) 104 105 #endif 106