File indexing completed on 2024-04-28 16:21:24
0001 /* This file is part of the KDE project 0002 Copyright 2007 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_HEADER_FOOTER 0023 #define CALLIGRA_SHEETS_HEADER_FOOTER 0024 0025 #include <KoPageLayout.h> 0026 0027 #include <QString> 0028 0029 #include "sheets_odf_export.h" 0030 0031 namespace Calligra 0032 { 0033 namespace Sheets 0034 { 0035 class Sheet; 0036 0037 class CALLIGRA_SHEETS_ODF_EXPORT HeaderFooter 0038 { 0039 public: 0040 explicit HeaderFooter(Sheet* sheet); 0041 ~HeaderFooter(); 0042 0043 QString headLeft(int _p, const QString &_t)const { 0044 if (m_headLeft.isNull()) return ""; 0045 return completeHeading(m_headLeft, _p, _t); 0046 } 0047 QString headMid(int _p, const QString &_t)const { 0048 if (m_headMid.isNull()) return ""; 0049 return completeHeading(m_headMid, _p, _t); 0050 } 0051 QString headRight(int _p, const QString &_t)const { 0052 if (m_headRight.isNull()) return ""; 0053 return completeHeading(m_headRight, _p, _t); 0054 } 0055 QString footLeft(int _p, const QString &_t)const { 0056 if (m_footLeft.isNull()) return ""; 0057 return completeHeading(m_footLeft, _p, _t); 0058 } 0059 QString footMid(int _p, const QString &_t)const { 0060 if (m_footMid.isNull()) return ""; 0061 return completeHeading(m_footMid, _p, _t); 0062 } 0063 QString footRight(int _p, const QString &_t)const { 0064 if (m_footRight.isNull()) return ""; 0065 return completeHeading(m_footRight, _p, _t); 0066 } 0067 0068 QString headLeft()const { 0069 if (m_headLeft.isNull()) return ""; 0070 return m_headLeft; 0071 } 0072 QString headMid()const { 0073 if (m_headMid.isNull()) return ""; 0074 return m_headMid; 0075 } 0076 QString headRight()const { 0077 if (m_headRight.isNull()) return ""; 0078 return m_headRight; 0079 } 0080 QString footLeft()const { 0081 if (m_footLeft.isNull()) return ""; 0082 return m_footLeft; 0083 } 0084 QString footMid()const { 0085 if (m_footMid.isNull()) return ""; 0086 return m_footMid; 0087 } 0088 QString footRight()const { 0089 if (m_footRight.isNull()) return ""; 0090 return m_footRight; 0091 } 0092 0093 /** 0094 * Replaces in _text all _search text parts by _replace text parts. 0095 * Included is a test to not change if _search == _replace. 0096 * The arguments should not include neither the beginning "<" nor the leading ">", this is already 0097 * included internally. 0098 */ 0099 void replaceHeadFootLineMacro(QString &_text, const QString &_search, const QString &_replace) const; 0100 0101 /** 0102 * Replaces in _text all page macros by the i18n-version of the macros 0103 */ 0104 QString localizeHeadFootLine(const QString &_text) const; 0105 0106 /** 0107 * Replaces in _text all i18n-versions of the page macros by the internal version of the macros 0108 */ 0109 QString delocalizeHeadFootLine(const QString &_text) const; 0110 0111 /** 0112 * Sets the head and foot line of the print out 0113 */ 0114 void setHeadFootLine(const QString &_headl, const QString &_headm, const QString &_headr, 0115 const QString &_footl, const QString &_footm, const QString &_footr); 0116 0117 private: 0118 /** 0119 * Replaces macros like <name>, <file>, <date> etc. in the string and 0120 * returns the modified one. 0121 * 0122 * @param _page is the page number for which the heading is produced. 0123 * @param _Sheet is the name of the Sheet for which we generate the headings. 0124 */ 0125 QString completeHeading(const QString &_data, int _page, const QString &_sheet) const ; 0126 0127 Sheet *m_pSheet; 0128 0129 /** 0130 * Header string. The string may contains makros. That means 0131 * it has to be processed before printing. 0132 */ 0133 QString m_headLeft; 0134 0135 /** 0136 * Header string. The string may contains makros. That means 0137 * it has to be processed before printing. 0138 */ 0139 QString m_headRight; 0140 0141 /** 0142 * Header string. The string may contains makros. That means 0143 * it has to be processed before printing. 0144 */ 0145 QString m_headMid; 0146 0147 /** 0148 * Footer string. The string may contains makros. That means 0149 * it has to be processed before printing. 0150 */ 0151 QString m_footLeft; 0152 0153 /** 0154 * Footer string. The string may contains makros. That means 0155 * it has to be processed before printing. 0156 */ 0157 QString m_footRight; 0158 0159 /** 0160 * Footer string. The string may contains makros. That means 0161 * it has to be processed before printing. 0162 */ 0163 QString m_footMid; 0164 }; 0165 0166 } // namespace Sheets 0167 } // namespace Calligra 0168 0169 #endif // CALLIGRA_SHEETS_HEADER_FOOTER