1/* This file is part of the KDE project
2 Copyright 2007, 2009 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
3 Copyright 2003 Philipp Müller <philipp.mueller@gmx.de>
4 Copyright 1998, 1999 Torben Weis <weis@kde.org>,
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#ifndef CALLIGRA_SHEETS_SHEET_PRINT_P
23#define CALLIGRA_SHEETS_SHEET_PRINT_P
24
25#include "SheetPrint.h"
26#include <QList>
27
28namespace Calligra
29{
30namespace Sheets
31{
32class HeaderFooter;
33class Sheet;
34class SheetPrint;
35
36/**
37 * Page parameters for both directions, horizontal and vertical
38 * (or columns and rows).
39 * Stores the start column/row, the end column/row, the document offset
40 * and the dimension (width/height) of a page.
41 */
42class PrintNewPageEntry
43{
44public:
45 explicit PrintNewPageEntry(int startItem, int endItem = 0, double size = 0, double offset = 0)
46 : m_iStartItem(startItem)
47 , m_iEndItem(endItem)
48 , m_dSize(size)
49 , m_dOffset(offset) {}
50
51 int startItem() const {
52 return m_iStartItem;
53 }
54 void setStartItem(int startItem) {
55 m_iStartItem = startItem;
56 }
57
58 int endItem() const {
59 return m_iEndItem;
60 }
61 void setEndItem(int endItem) {
62 m_iEndItem = endItem;
63 }
64
65 double size() const {
66 return m_dSize;
67 }
68 void setSize(double size) {
69 m_dSize = size;
70 }
71
72 double offset() const {
73 return m_dOffset;
74 }
75 void setOffset(double offset) {
76 m_dOffset = offset;
77 }
78
79 bool operator==(PrintNewPageEntry const & entry) const;
80
81
82private:
83 int m_iStartItem; // column or row index
84 int m_iEndItem; // column or row index
85 double m_dSize; // width or height
86 double m_dOffset; // horizontal or vertical offset
87};
88
89
90class SheetPrint::Private
91{
92public:
93 Private(SheetPrint *parent) : q(parent) {}
94
95 /**
96 * Calculates the zoom factor, so that the printout fits on pages in X direction.
97 */
98 void calculateZoomForPageLimitX();
99
100 /**
101 * Calculates the zoom factor, so that the printout fits on pages in Y direction.
102 */
103 void calculateZoomForPageLimitY();
104
105 /**
106 * Calculates the missing horizontal page parameters up to \p column.
107 */
108 void calculateHorizontalPageParameters(int column);
109
110 /**
111 * Calculates the missing vertical page parameters up to \p row.
112 */
113 void calculateVerticalPageParameters(int row);
114
115 /**
116 * Updates the pre-calculated width of the repeated columns.
117 */
118 void updateRepeatedColumnsWidth();
119
120 /**
121 * Updates the pre-calculated height of the repeated rows.
122 */
123 void updateRepeatedRowsHeight();
124
125public:
126 SheetPrint *q;
127 Sheet * m_pSheet;
128
129 PrintSettings* m_settings;
130 HeaderFooter *m_headerFooter;
131
132 /**
133 * Width of repeated columns in points, stored for performance reasons
134 */
135 double m_dPrintRepeatColumnsWidth;
136
137 /**
138 * Height of repeated rows in points, stored for performance reasons
139 */
140 double m_dPrintRepeatRowsHeight;
141
142 /**
143 * Stores the horizontal page parameters (for columns).
144 */
145 QList<PrintNewPageEntry> m_lnewPageListX;
146
147 /**
148 * Stores the vertical page parameters (for rows).
149 */
150 QList<PrintNewPageEntry> m_lnewPageListY;
151
152 /**
153 * Stores the column, up to which the horizontal page parameters got calculated.
154 */
155 int m_maxCheckedNewPageX;
156
157 /**
158 * Stores the row, up to which the vertical page parameters got calculated.
159 */
160 int m_maxCheckedNewPageY;
161};
162
163} // namespace Sheets
164} // namespace Calligra
165
166#endif // CALLIGRA_SHEETS_SHEET_PRINT_P
167