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
0023 #define CALLIGRA_SHEETS_SHEET_PRINT
0024 
0025 #include <QRectF>
0026 
0027 #include "sheets_odf_export.h"
0028 
0029 
0030 namespace Calligra
0031 {
0032 namespace Sheets
0033 {
0034 class HeaderFooter;
0035 class PrintSettings;
0036 class Sheet;
0037 
0038 /**
0039  * \class SheetPrint
0040  * Manages the layout of pages for printing.
0041  * Supports next to the obligatory page dimensions
0042  * zooming, page limits and column/row repetitions.
0043  * \ingroup Printing
0044  */
0045 class CALLIGRA_SHEETS_ODF_EXPORT SheetPrint
0046 {
0047 public:
0048     explicit SheetPrint(Sheet * sheet = 0);
0049     SheetPrint(const SheetPrint &other);
0050     ~SheetPrint();
0051 
0052     /**
0053      * \return the print settings
0054      */
0055     PrintSettings *settings() const;
0056 
0057     /**
0058      * Sets the print \p settings.
0059      * \param settings the print settings.
0060      * \param force Forces a relayout of the pages, if \c true.
0061      */
0062     void setSettings(const PrintSettings &settings, bool force = false);
0063 
0064     /**
0065      * \return the header & footer object
0066      */
0067     HeaderFooter *headerFooter() const;
0068 
0069     /**
0070      * Tests whether @p column is the first column of a new page. In this
0071      * case the left border of this column may be drawn highlighted to show
0072      * that this is a page break.
0073      */
0074     bool isColumnOnNewPage(int column);
0075 
0076     /**
0077      * Tests whether \p row is the first row of a new page. In this
0078      * case the top border of this row may be drawn highlighted to show
0079      * that this is a page break.
0080      */
0081     bool isRowOnNewPage(int row);
0082 
0083     /**
0084      * Updates the page parameters in horizontal direction (for columns)
0085      * starting at \p column.
0086      * Actually, only removes them and they get calculated on demand.
0087      * Triggers an update of the repeated columns' pre-calculated width,
0088      * if \p column is not beyond the repetition.
0089      */
0090     void updateHorizontalPageParameters(int column);
0091 
0092     /**
0093      * Updates the page parameters in vertical direction (for rows)
0094      * starting at \p row.
0095      * Actually, only removes them and they get calculated on demand.
0096      * Triggers an update of the repeated rows' pre-calculated height,
0097      * if \p row is not beyond the repetition.
0098      */
0099     void updateVerticalPageParameters(int row);
0100 
0101     /**
0102      * Updates the print range, according to the inserted columns
0103      * \param col the column index
0104      * \param nbCol number of inserted columns
0105      */
0106     void insertColumn(int col, int nbCol);
0107 
0108     /**
0109      * Updates the print range, according to the removed columns
0110      * \param col the column index
0111      * \param nbCol number of removed columns
0112      */
0113     void removeColumn(int col, int nbCol);
0114 
0115     /**
0116      * Updates the print range, according to the inserted rows
0117      * \param row the row index
0118      * \param nbRow number of inserted rows
0119      */
0120     void insertRow(int row, int nbRow);
0121 
0122     /**
0123      * Updates the print range, according to the removed rows
0124      * \param row the row index
0125      * \param nbRow number of removed rows
0126      */
0127     void removeRow(int row, int nbRow);
0128 
0129     /**
0130      * The number of pages.
0131      */
0132     int pageCount() const;
0133 
0134     /**
0135      * Return the cell range of the requested page.
0136      * \param page the page number
0137      * \return the page's cell range
0138      */
0139     QRect cellRange(int page) const;
0140 
0141     /**
0142      * Return the document area of the requested page.
0143      * \param page the page number
0144      * \return the page's document area
0145      */
0146     QRectF documentArea(int page) const;
0147 
0148     /**
0149      * Assignment operator.
0150      */
0151     void operator=(const SheetPrint &);
0152 
0153 
0154 private:
0155     class Private;
0156     Private *const d;
0157 };
0158 
0159 } // namespace Sheets
0160 } // namespace Calligra
0161 
0162 #endif // CALLIGRA_SHEETS_SHEET_PRINT