File indexing completed on 2024-04-28 16:21:31

0001 /* This file is part of the KDE project
0002    Copyright 2007, 2009 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
0003    Copyright 2003 Philipp Müller <philipp.mueller@gmx.de>
0004    Copyright 1998, 1999 Torben Weis <weis@kde.org>,
0005 
0006    This library is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU Library General Public
0008    License as published by the Free Software Foundation; either
0009    version 2 of the License, or (at your option) any later version.
0010 
0011    This library is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014    Library General Public License for more details.
0015 
0016    You should have received a copy of the GNU Library General Public License
0017    along with this library; see the file COPYING.LIB.  If not, write to
0018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019    Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #ifndef CALLIGRA_SHEETS_SHEET_PRINT_P
0023 #define CALLIGRA_SHEETS_SHEET_PRINT_P
0024 
0025 #include "SheetPrint.h"
0026 #include <QList>
0027 
0028 namespace Calligra
0029 {
0030 namespace Sheets
0031 {
0032 class HeaderFooter;
0033 class Sheet;
0034 class SheetPrint;
0035 
0036 /**
0037  * Page parameters for both directions, horizontal and vertical
0038  * (or columns and rows).
0039  * Stores the start column/row, the end column/row, the document offset
0040  * and the dimension (width/height) of a page.
0041  */
0042 class PrintNewPageEntry
0043 {
0044 public:
0045     explicit PrintNewPageEntry(int startItem, int endItem = 0, double size = 0, double offset = 0)
0046             : m_iStartItem(startItem)
0047             , m_iEndItem(endItem)
0048             , m_dSize(size)
0049             , m_dOffset(offset) {}
0050 
0051     int startItem() const {
0052         return m_iStartItem;
0053     }
0054     void setStartItem(int startItem) {
0055         m_iStartItem = startItem;
0056     }
0057 
0058     int endItem() const {
0059         return m_iEndItem;
0060     }
0061     void setEndItem(int endItem) {
0062         m_iEndItem = endItem;
0063     }
0064 
0065     double size() const {
0066         return m_dSize;
0067     }
0068     void setSize(double size) {
0069         m_dSize = size;
0070     }
0071 
0072     double offset() const {
0073         return m_dOffset;
0074     }
0075     void setOffset(double offset) {
0076         m_dOffset = offset;
0077     }
0078 
0079     bool operator==(PrintNewPageEntry const & entry) const;
0080 
0081 
0082 private:
0083     int m_iStartItem;   // column or row index
0084     int m_iEndItem;     // column or row index
0085     double m_dSize;     // width or height
0086     double m_dOffset;   // horizontal or vertical offset
0087 };
0088 
0089 
0090 class Q_DECL_HIDDEN SheetPrint::Private
0091 {
0092 public:
0093     Private(SheetPrint *parent) : q(parent) {}
0094 
0095     /**
0096      * Calculates the zoom factor, so that the printout fits on pages in X direction.
0097      */
0098     void calculateZoomForPageLimitX();
0099 
0100     /**
0101      * Calculates the zoom factor, so that the printout fits on pages in Y direction.
0102      */
0103     void calculateZoomForPageLimitY();
0104 
0105     /**
0106      * Calculates the missing horizontal page parameters up to \p column.
0107      */
0108     void calculateHorizontalPageParameters(int column);
0109 
0110     /**
0111      * Calculates the missing vertical page parameters up to \p row.
0112      */
0113     void calculateVerticalPageParameters(int row);
0114 
0115     /**
0116      * Updates the pre-calculated width of the repeated columns.
0117      */
0118     void updateRepeatedColumnsWidth();
0119 
0120     /**
0121      * Updates the pre-calculated height of the repeated rows.
0122      */
0123     void updateRepeatedRowsHeight();
0124 
0125 public:
0126     SheetPrint *q;
0127     Sheet * m_pSheet;
0128 
0129     PrintSettings* m_settings;
0130     HeaderFooter *m_headerFooter;
0131 
0132     /**
0133      * Width of repeated columns in points, stored for performance reasons
0134      */
0135     double m_dPrintRepeatColumnsWidth;
0136 
0137     /**
0138      * Height of repeated rows in points, stored for performance reasons
0139      */
0140     double m_dPrintRepeatRowsHeight;
0141 
0142     /**
0143      * Stores the horizontal page parameters (for columns).
0144      */
0145     QList<PrintNewPageEntry> m_lnewPageListX;
0146 
0147     /**
0148      * Stores the vertical page parameters (for rows).
0149      */
0150     QList<PrintNewPageEntry> m_lnewPageListY;
0151 
0152     /**
0153      * Stores the column, up to which the horizontal page parameters got calculated.
0154      */
0155     int m_maxCheckedNewPageX;
0156 
0157     /**
0158      * Stores the row, up to which the vertical page parameters got calculated.
0159      */
0160     int m_maxCheckedNewPageY;
0161 };
0162 
0163 } // namespace Sheets
0164 } // namespace Calligra
0165 
0166 #endif // CALLIGRA_SHEETS_SHEET_PRINT_P