Changeset View
Changeset View
Standalone View
Standalone View
src/part/KgvPageLayout.h
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 43 | enum KgvFormat { | |||
---|---|---|---|---|---|
72 | PG_US_TABLOID = 28, | 72 | PG_US_TABLOID = 28, | ||
73 | // update the number below and the static arrays if you add more values to the enum | 73 | // update the number below and the static arrays if you add more values to the enum | ||
74 | PG_LAST_FORMAT = PG_US_TABLOID // used by koPageLayout.cpp | 74 | PG_LAST_FORMAT = PG_US_TABLOID // used by koPageLayout.cpp | ||
75 | }; | 75 | }; | ||
76 | 76 | | |||
77 | /** | 77 | /** | ||
78 | * Represents the orientation of a printed document. | 78 | * Represents the orientation of a printed document. | ||
79 | */ | 79 | */ | ||
80 | enum KgvOrientation { | 80 | enum KgvOrientation { PG_PORTRAIT = 0, PG_LANDSCAPE = 1 }; | ||
81 | PG_PORTRAIT = 0, | | |||
82 | PG_LANDSCAPE = 1 | | |||
83 | }; | | |||
84 | 81 | | |||
85 | namespace KgvPageFormat | 82 | namespace KgvPageFormat | ||
86 | { | 83 | { | ||
87 | /** | 84 | /** | ||
88 | * @brief Convert a KgvFormat into a QPageSize::PageSizeId. | 85 | * @brief Convert a KgvFormat into a QPageSize::PageSizeId. | ||
89 | * | 86 | * | ||
90 | * If format is 'screen' it will use A4 landscape. | 87 | * If format is 'screen' it will use A4 landscape. | ||
91 | * If format is 'custom' it will use A4 portrait. | 88 | * If format is 'custom' it will use A4 portrait. | ||
92 | * (you may want to take care of those cases separately). | 89 | * (you may want to take care of those cases separately). | ||
93 | * Usually passed to QPrinter::setPageSize(). | 90 | * Usually passed to QPrinter::setPageSize(). | ||
94 | * | 91 | * | ||
95 | * @note We return int instead of the enum to avoid including QPageSize | 92 | * @note We return int instead of the enum to avoid including QPageSize | ||
96 | */ | 93 | */ | ||
97 | int /*QPageSize::PageSizeId*/ printerPageSize( KgvFormat format ); | 94 | int /*QPageSize::PageSizeId*/ printerPageSize(KgvFormat format); | ||
98 | 95 | | |||
99 | /** | 96 | /** | ||
100 | * Returns the width (in mm) for a given page format and orientation | 97 | * Returns the width (in mm) for a given page format and orientation | ||
101 | * 'Custom' isn't supported by this function, obviously. | 98 | * 'Custom' isn't supported by this function, obviously. | ||
102 | */ | 99 | */ | ||
103 | double width( KgvFormat format, KgvOrientation orientation ); | 100 | double width(KgvFormat format, KgvOrientation orientation); | ||
104 | 101 | | |||
105 | /** | 102 | /** | ||
106 | * Returns the height (in mm) for a given page format and orientation | 103 | * Returns the height (in mm) for a given page format and orientation | ||
107 | * 'Custom' isn't supported by this function, obviously. | 104 | * 'Custom' isn't supported by this function, obviously. | ||
108 | */ | 105 | */ | ||
109 | double height( KgvFormat format, KgvOrientation orientation ); | 106 | double height(KgvFormat format, KgvOrientation orientation); | ||
110 | 107 | | |||
111 | /** | 108 | /** | ||
112 | * Returns the internal name of the given page format. | 109 | * Returns the internal name of the given page format. | ||
113 | * Use for saving. | 110 | * Use for saving. | ||
114 | */ | 111 | */ | ||
115 | QString formatString( KgvFormat format ); | 112 | QString formatString(KgvFormat format); | ||
116 | 113 | | |||
117 | /** | 114 | /** | ||
118 | * Convert a format string (internal name) to a page format value. | 115 | * Convert a format string (internal name) to a page format value. | ||
119 | * Use for loading. | 116 | * Use for loading. | ||
120 | */ | 117 | */ | ||
121 | KgvFormat formatFromString( const QString & string ); | 118 | KgvFormat formatFromString(const QString &string); | ||
122 | 119 | | |||
123 | /** | 120 | /** | ||
124 | * Returns the default format (based on the KControl settings) | 121 | * Returns the default format (based on the KControl settings) | ||
125 | */ | 122 | */ | ||
126 | KgvFormat defaultFormat(); | 123 | KgvFormat defaultFormat(); | ||
127 | 124 | | |||
128 | /** | 125 | /** | ||
129 | * Returns the translated name of the given page format. | 126 | * Returns the translated name of the given page format. | ||
130 | * Use for showing the user. | 127 | * Use for showing the user. | ||
131 | */ | 128 | */ | ||
132 | QString name( KgvFormat format ); | 129 | QString name(KgvFormat format); | ||
133 | 130 | | |||
134 | /** | 131 | /** | ||
135 | * Lists the translated names of all the available formats | 132 | * Lists the translated names of all the available formats | ||
136 | */ | 133 | */ | ||
137 | QStringList allFormats(); | 134 | QStringList allFormats(); | ||
138 | 135 | | |||
139 | /** | 136 | /** | ||
140 | * Try to find the paper format for the given width and height (in mm). | 137 | * Try to find the paper format for the given width and height (in mm). | ||
141 | * Useful to some import filters. | 138 | * Useful to some import filters. | ||
142 | */ | 139 | */ | ||
143 | KgvFormat guessFormat( double width, double height ); | 140 | KgvFormat guessFormat(double width, double height); | ||
144 | } | 141 | } | ||
145 | 142 | | |||
146 | | ||||
147 | /** | 143 | /** | ||
148 | * @brief Header/Footer type. | 144 | * @brief Header/Footer type. | ||
149 | * | 145 | * | ||
150 | * @note Yes, this should have been a bitfield, but there was only 0, 2, 3 in koffice-1.0. Don't ask why. | 146 | * @note Yes, this should have been a bitfield, but there was only 0, 2, 3 in koffice-1.0. Don't ask why. | ||
151 | * In the long run this should be replaced with a more flexible repetition/section concept. | 147 | * In the long run this should be replaced with a more flexible repetition/section concept. | ||
152 | */ | 148 | */ | ||
153 | enum KgvHFType { | 149 | enum KgvHFType { | ||
154 | HF_SAME = 0, ///< 0: Header/Footer is the same on all pages | 150 | HF_SAME = 0, ///< 0: Header/Footer is the same on all pages | ||
155 | HF_FIRST_EO_DIFF = 1, ///< 1: Header/Footer is different on first, even and odd pages (2&3) | 151 | HF_FIRST_EO_DIFF = 1, ///< 1: Header/Footer is different on first, even and odd pages (2&3) | ||
156 | HF_FIRST_DIFF = 2, ///< 2: Header/Footer for the first page differs | 152 | HF_FIRST_DIFF = 2, ///< 2: Header/Footer for the first page differs | ||
157 | HF_EO_DIFF = 3 ///< 3: Header/Footer for even - odd pages are different | 153 | HF_EO_DIFF = 3 ///< 3: Header/Footer for even - odd pages are different | ||
158 | }; | 154 | }; | ||
159 | 155 | | |||
160 | /** | 156 | /** | ||
161 | * This structure defines the page layout, including | 157 | * This structure defines the page layout, including | ||
162 | * its size in pt, its format (e.g. A4), orientation, unit, margins etc. | 158 | * its size in pt, its format (e.g. A4), orientation, unit, margins etc. | ||
163 | */ | 159 | */ | ||
164 | struct KgvPageLayout | 160 | struct KgvPageLayout { | ||
165 | { | | |||
166 | /** Page format */ | 161 | /** Page format */ | ||
167 | KgvFormat format; | 162 | KgvFormat format; | ||
168 | /** Page orientation */ | 163 | /** Page orientation */ | ||
169 | KgvOrientation orientation; | 164 | KgvOrientation orientation; | ||
170 | 165 | | |||
171 | /** Page width in pt */ | 166 | /** Page width in pt */ | ||
172 | double ptWidth; | 167 | double ptWidth; | ||
173 | /** Page height in pt */ | 168 | /** Page height in pt */ | ||
174 | double ptHeight; | 169 | double ptHeight; | ||
175 | /** Left margin in pt */ | 170 | /** Left margin in pt */ | ||
176 | double ptLeft; | 171 | double ptLeft; | ||
177 | /** Right margin in pt */ | 172 | /** Right margin in pt */ | ||
178 | double ptRight; | 173 | double ptRight; | ||
179 | /** Top margin in pt */ | 174 | /** Top margin in pt */ | ||
180 | double ptTop; | 175 | double ptTop; | ||
181 | /** Bottom margin in pt */ | 176 | /** Bottom margin in pt */ | ||
182 | double ptBottom; | 177 | double ptBottom; | ||
183 | double ptPageEdge; | 178 | double ptPageEdge; | ||
184 | double ptBindingSide; | 179 | double ptBindingSide; | ||
185 | 180 | | |||
186 | bool operator==( const KgvPageLayout& l ) const { | 181 | bool operator==(const KgvPageLayout &l) const | ||
187 | return ( ptWidth == l.ptWidth && | 182 | { | ||
188 | ptHeight == l.ptHeight && | 183 | return (ptWidth == l.ptWidth && ptHeight == l.ptHeight && ptLeft == l.ptLeft && ptRight == l.ptRight && ptTop == l.ptTop && ptBottom == l.ptBottom && ptPageEdge == l.ptPageEdge && ptBindingSide == l.ptBindingSide); | ||
189 | ptLeft == l.ptLeft && | | |||
190 | ptRight == l.ptRight && | | |||
191 | ptTop == l.ptTop && | | |||
192 | ptBottom == l.ptBottom && | | |||
193 | ptPageEdge == l.ptPageEdge && | | |||
194 | ptBindingSide == l.ptBindingSide); | | |||
195 | } | 184 | } | ||
196 | bool operator!=( const KgvPageLayout& l ) const { | 185 | bool operator!=(const KgvPageLayout &l) const | ||
186 | { | ||||
197 | return !( (*this) == l ); | 187 | return !((*this) == l); | ||
198 | } | 188 | } | ||
199 | 189 | | |||
200 | /** | 190 | /** | ||
201 | * @return a page layout with the default page size depending on the locale settings, | 191 | * @return a page layout with the default page size depending on the locale settings, | ||
202 | * default margins (2 cm), and portrait orientation. | 192 | * default margins (2 cm), and portrait orientation. | ||
203 | * @since 1.4 | 193 | * @since 1.4 | ||
204 | */ | 194 | */ | ||
205 | static KgvPageLayout standardLayout(); | 195 | static KgvPageLayout standardLayout(); | ||
206 | }; | 196 | }; | ||
207 | 197 | | |||
208 | /** structure for header-footer */ | 198 | /** structure for header-footer */ | ||
209 | struct KgvHeadFoot | 199 | struct KgvHeadFoot { | ||
210 | { | | |||
211 | QString headLeft; | 200 | QString headLeft; | ||
212 | QString headMid; | 201 | QString headMid; | ||
213 | QString headRight; | 202 | QString headRight; | ||
214 | QString footLeft; | 203 | QString footLeft; | ||
215 | QString footMid; | 204 | QString footMid; | ||
216 | QString footRight; | 205 | QString footRight; | ||
217 | }; | 206 | }; | ||
218 | 207 | | |||
219 | /** structure for columns */ | 208 | /** structure for columns */ | ||
220 | struct KgvColumns | 209 | struct KgvColumns { | ||
221 | { | | |||
222 | int columns; | 210 | int columns; | ||
223 | double ptColumnSpacing; | 211 | double ptColumnSpacing; | ||
224 | bool operator==( const KgvColumns& rhs ) const { | 212 | bool operator==(const KgvColumns &rhs) const | ||
225 | return columns == rhs.columns && | 213 | { | ||
226 | qAbs(ptColumnSpacing - rhs.ptColumnSpacing) <= 1E-10; | 214 | return columns == rhs.columns && qAbs(ptColumnSpacing - rhs.ptColumnSpacing) <= 1E-10; | ||
227 | } | 215 | } | ||
228 | bool operator!=( const KgvColumns& rhs ) const { | 216 | bool operator!=(const KgvColumns &rhs) const | ||
229 | return columns != rhs.columns || | 217 | { | ||
230 | qAbs(ptColumnSpacing - rhs.ptColumnSpacing) > 1E-10; | 218 | return columns != rhs.columns || qAbs(ptColumnSpacing - rhs.ptColumnSpacing) > 1E-10; | ||
231 | } | 219 | } | ||
232 | }; | 220 | }; | ||
233 | 221 | | |||
234 | /** structure for KWord header-footer */ | 222 | /** structure for KWord header-footer */ | ||
235 | struct KgvKWHeaderFooter | 223 | struct KgvKWHeaderFooter { | ||
236 | { | | |||
237 | KgvHFType header; | 224 | KgvHFType header; | ||
238 | KgvHFType footer; | 225 | KgvHFType footer; | ||
239 | double ptHeaderBodySpacing; | 226 | double ptHeaderBodySpacing; | ||
240 | double ptFooterBodySpacing; | 227 | double ptFooterBodySpacing; | ||
241 | double ptFootNoteBodySpacing; | 228 | double ptFootNoteBodySpacing; | ||
242 | bool operator==( const KgvKWHeaderFooter& rhs ) const { | 229 | bool operator==(const KgvKWHeaderFooter &rhs) const | ||
243 | return header == rhs.header && footer == rhs.footer && | 230 | { | ||
244 | qAbs(ptHeaderBodySpacing - rhs.ptHeaderBodySpacing) <= 1E-10 && | 231 | return header == rhs.header && footer == rhs.footer && qAbs(ptHeaderBodySpacing - rhs.ptHeaderBodySpacing) <= 1E-10 && qAbs(ptFooterBodySpacing - rhs.ptFooterBodySpacing) <= 1E-10 && | ||
245 | qAbs(ptFooterBodySpacing - rhs.ptFooterBodySpacing) <= 1E-10 && | | |||
246 | qAbs(ptFootNoteBodySpacing - rhs.ptFootNoteBodySpacing) <= 1E-10; | 232 | qAbs(ptFootNoteBodySpacing - rhs.ptFootNoteBodySpacing) <= 1E-10; | ||
247 | } | 233 | } | ||
248 | bool operator!=( const KgvKWHeaderFooter& rhs ) const { | 234 | bool operator!=(const KgvKWHeaderFooter &rhs) const | ||
235 | { | ||||
249 | return !( *this == rhs ); | 236 | return !(*this == rhs); | ||
250 | } | 237 | } | ||
251 | }; | 238 | }; | ||
252 | 239 | | |||
253 | #endif /* KOPAGELAYOUT_H */ | 240 | #endif /* KOPAGELAYOUT_H */ | ||
254 | |