1/* This file is part of the KDE project
2 Copyright 2008 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
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 CALLIGRA_SHEETS_PAGE_MANAGER
21#define CALLIGRA_SHEETS_PAGE_MANAGER
22
23#include "calligra_sheets_export.h"
24
25class QRect;
26class QSizeF;
27
28namespace Calligra
29{
30namespace Sheets
31{
32class PrintSettings;
33class Sheet;
34
35/**
36 * Manages the layouting of pages.
37 * Contains shared functionality between PrintManager, which layouts pages for
38 * printing, and TablePageManager, which does the same for the table shape in
39 * page based hosting apps.
40 */
41class CALLIGRA_SHEETS_COMMON_EXPORT PageManager
42{
43public:
44 /**
45 * Constructor.
46 */
47 explicit PageManager(Sheet *sheet);
48
49 /**
50 * Destructor.
51 */
52 virtual ~PageManager();
53
54 /**
55 * Layouts the pages.
56 * Splits the used cell range, so that it fits on several pages.
57 */
58 void layoutPages();
59
60 /**
61 * Sets the print settings.
62 * If the settings differ from the existing ones, the pages are recreated.
63 * \param settings the print settings
64 * \param force forces a recreation of the pages, if \c true
65 */
66 void setPrintSettings(const PrintSettings& settings, bool force = false);
67
68 /**
69 * Number of pages.
70 */
71 int pageCount() const;
72
73 /**
74 * Return the cell range of the requested page.
75 * \param page the page number
76 * \return the page's cell range
77 */
78 QRect cellRange(int page) const;
79
80 /**
81 * Return the visible size, the page size decreased by the borders, of the requested page.
82 * \param page the page number
83 * \return the page's visible size
84 */
85 virtual QSizeF size(int page) const;
86
87protected:
88 Sheet* sheet() const;
89 const PrintSettings& printSettings() const;
90 virtual void clearPages();
91 virtual bool pageNeedsPrinting(const QRect& cellRange) const;
92 virtual void insertPage(int page);
93 virtual void preparePage(int page);
94
95private:
96 Q_DISABLE_COPY(PageManager)
97
98 class Private;
99 Private * const d;
100};
101
102} // namespace Sheets
103} // namespace Calligra
104
105#endif // CALLIGRA_SHEETS_PAGE_MANAGER
106