Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_SW_INC_PAGEDESC_HXX
20 : #define INCLUDED_SW_INC_PAGEDESC_HXX
21 :
22 : #include <tools/fract.hxx>
23 : #include <tools/color.hxx>
24 : #include "swdllapi.h"
25 : #include <swtypes.hxx>
26 : #include <frmfmt.hxx>
27 : #include <editeng/numitem.hxx>
28 : #include <editeng/borderline.hxx>
29 :
30 : class SfxPoolItem;
31 : class SwTextFormatColl;
32 : class SwNode;
33 :
34 : /// Separator line adjustment.
35 : enum SwFootnoteAdj
36 : {
37 : FTNADJ_LEFT,
38 : FTNADJ_CENTER,
39 : FTNADJ_RIGHT
40 : };
41 :
42 : /// Footnote information.
43 145251 : class SW_DLLPUBLIC SwPageFootnoteInfo
44 : {
45 : private:
46 : SwTwips m_nMaxHeight; ///< maximum height of the footnote area.
47 : sal_uLong m_nLineWidth; ///< width of separator line
48 : editeng::SvxBorderStyle m_eLineStyle; ///< Style of the separator line
49 : Color m_LineColor; ///< color of the separator line
50 : Fraction m_Width; ///< percentage width of the separator line.
51 : SwFootnoteAdj m_eAdjust; ///< line adjustment.
52 : SwTwips m_nTopDist; ///< distance between body and separator.
53 : SwTwips m_nBottomDist; ///< distance between separator and first footnote
54 :
55 : public:
56 113338 : SwTwips GetHeight() const { return m_nMaxHeight; }
57 361 : sal_uLong GetLineWidth() const { return m_nLineWidth; }
58 99 : const Color& GetLineColor() const { return m_LineColor;}
59 99 : editeng::SvxBorderStyle GetLineStyle() const { return m_eLineStyle; }
60 107928 : const Fraction& GetWidth() const { return m_Width; }
61 103440 : SwFootnoteAdj GetAdj() const { return m_eAdjust; }
62 103688 : SwTwips GetTopDist() const { return m_nTopDist; }
63 103619 : SwTwips GetBottomDist() const { return m_nBottomDist; }
64 :
65 546 : void SetHeight(SwTwips const nNew) { m_nMaxHeight = nNew; }
66 584 : void SetLineWidth(sal_uLong const nSet) { m_nLineWidth = nSet; }
67 545 : void SetLineStyle(editeng::SvxBorderStyle const eSet) {m_eLineStyle = eSet;}
68 545 : void SetLineColor(const Color& rCol) { m_LineColor = rCol;}
69 2704 : void SetWidth(const Fraction & rNew) { m_Width = rNew; }
70 545 : void SetAdj(SwFootnoteAdj const eNew) { m_eAdjust = eNew; }
71 584 : void SetTopDist (SwTwips const nNew) { m_nTopDist = nNew; }
72 584 : void SetBottomDist(SwTwips const nNew) { m_nBottomDist = nNew; }
73 :
74 : SwPageFootnoteInfo();
75 : SwPageFootnoteInfo( const SwPageFootnoteInfo& );
76 : SwPageFootnoteInfo& operator=( const SwPageFootnoteInfo& );
77 :
78 : bool operator ==( const SwPageFootnoteInfo& ) const;
79 : };
80 :
81 : /*
82 : * Use of UseOnPage (m_eUse) and of FrameFormats
83 : *
84 : * RIGHT - m_Master only for right hand (odd) pages, left hand (even) pages
85 : * always empty.
86 : * LEFT - m_Left for left-hand pages, right-hand pages always empty.
87 : * m_Left is a copy of master.
88 : * ALL - m_Master for right hand pages, m_Left for left hand pages.
89 : * - m_Left is a copy of master.
90 : * MIRROR - m_Master for right hand pages, m_Left for left hand pagers.
91 : * m_Left is a copy of master, margins are mirrored.
92 : *
93 : * UI works exclusively on master! m_Left is adjusted on Chg at document
94 : * according to m_eUse.
95 : *
96 : * In order to simplify the work of the filters some more values are placed
97 : * into m_eUse:
98 : *
99 : * HEADERSHARE - Content of header is equal on left and right hand pages.
100 : * FOOTERSHARE - Content of footer is equal on left and right hand pages.
101 : *
102 : * The values are masked out in the respective getter and setter methods.
103 : * Access to complete m_eUse including the information on header and footer
104 : * via ReadUseOn(), WriteUseOn() (for Filter and CopyCTor)!
105 : *
106 : * The Frmformats for header/footer are adjusted by the UI according to
107 : * the attributes for header and footer at master (height, margin, back-
108 : * ground ...)
109 : * Header/footer for left hand pages are copied or mirrored (Chg at
110 : * document).
111 : * The respective attribute for content is cared for automatically on Chg at
112 : * document (contents are created or removed according to SHARE-information).
113 : */
114 :
115 : typedef sal_uInt16 UseOnPage;
116 : namespace nsUseOnPage
117 : {
118 : const UseOnPage PD_NONE = 0x0000; ///< For internal use only.
119 : const UseOnPage PD_LEFT = 0x0001;
120 : const UseOnPage PD_RIGHT = 0x0002;
121 : const UseOnPage PD_ALL = 0x0003;
122 : const UseOnPage PD_MIRROR = 0x0007;
123 : const UseOnPage PD_HEADERSHARE = 0x0040;
124 : const UseOnPage PD_FOOTERSHARE = 0x0080;
125 : const UseOnPage PD_NOHEADERSHARE = 0xFFBF; ///< For internal use only.
126 : const UseOnPage PD_NOFOOTERSHARE = 0xFF7F; ///< For internal use only.
127 : const UseOnPage PD_FIRSTSHARE = 0x0100;
128 : const UseOnPage PD_NOFIRSTSHARE = 0xFEFF;
129 : }
130 :
131 : class SW_DLLPUBLIC SwPageDesc : public SwModify
132 : {
133 : friend class SwDoc;
134 :
135 : OUString m_StyleName;
136 : SvxNumberType m_NumType;
137 : SwFrameFormat m_Master;
138 : SwFrameFormat m_Left;
139 : // FIXME epicycles growing here - page margins need to be stored differently
140 : SwFrameFormat m_FirstMaster;
141 : SwFrameFormat m_FirstLeft;
142 : SwDepend m_Depend; ///< Because of grid alignment (Registerhaltigkeit).
143 : SwPageDesc *m_pFollow;
144 : sal_uInt16 m_nRegHeight; ///< Sentence spacing and fontascent of style.
145 : sal_uInt16 m_nRegAscent; ///< For grid alignment (Registerhaltigkeit).
146 : UseOnPage m_eUse;
147 : bool m_IsLandscape;
148 : bool m_IsHidden;
149 :
150 : /// Footnote information.
151 : SwPageFootnoteInfo m_IsFootnoteInfo;
152 :
153 : /** Called for mirroring of Chg (doc).
154 : No adjustment at any other place. */
155 : SAL_DLLPRIVATE void Mirror();
156 :
157 : SAL_DLLPRIVATE void ResetAllAttr( bool bLeft );
158 :
159 : SAL_DLLPRIVATE SwPageDesc(const OUString&, SwFrameFormat*, SwDoc *pDc );
160 :
161 : protected:
162 : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNewValue ) SAL_OVERRIDE;
163 :
164 : public:
165 472983 : OUString GetName() const { return m_StyleName; }
166 : bool HasName(const OUString& rThisName) const { return m_StyleName == rThisName; }
167 6 : void SetName(const OUString& rNewName) { m_StyleName = rNewName; }
168 :
169 44609 : bool GetLandscape() const { return m_IsLandscape; }
170 23090 : void SetLandscape( bool bNew ) { m_IsLandscape = bNew; }
171 :
172 55077 : const SvxNumberType &GetNumType() const { return m_NumType; }
173 14972 : void SetNumType(const SvxNumberType& rNew) { m_NumType = rNew; }
174 :
175 45639 : const SwPageFootnoteInfo &GetFootnoteInfo() const { return m_IsFootnoteInfo; }
176 20440 : SwPageFootnoteInfo &GetFootnoteInfo() { return m_IsFootnoteInfo; }
177 9994 : void SetFootnoteInfo(const SwPageFootnoteInfo &rNew) { m_IsFootnoteInfo = rNew; }
178 :
179 : inline bool IsHeaderShared() const;
180 : inline bool IsFooterShared() const;
181 : inline void ChgHeaderShare( bool bNew );
182 : inline void ChgFooterShare( bool bNew );
183 : bool IsFirstShared() const;
184 : void ChgFirstShare( bool bNew );
185 :
186 8356 : bool IsHidden() const { return m_IsHidden; }
187 547 : void SetHidden(bool const bValue) { m_IsHidden = bValue; }
188 :
189 : inline void SetUseOn( UseOnPage eNew );
190 : inline UseOnPage GetUseOn() const;
191 :
192 142 : void WriteUseOn(UseOnPage const eNew) { m_eUse = eNew; }
193 26106 : UseOnPage ReadUseOn() const { return m_eUse; }
194 :
195 294792 : SwFrameFormat &GetMaster() { return m_Master; }
196 244378 : SwFrameFormat &GetLeft() { return m_Left; }
197 216495 : SwFrameFormat &GetFirstMaster() { return m_FirstMaster; }
198 207348 : SwFrameFormat &GetFirstLeft() { return m_FirstLeft; }
199 123909 : const SwFrameFormat &GetMaster() const { return m_Master; }
200 34760 : const SwFrameFormat &GetLeft() const { return m_Left; }
201 24090 : const SwFrameFormat &GetFirstMaster() const { return m_FirstMaster; }
202 23359 : const SwFrameFormat &GetFirstLeft() const { return m_FirstLeft; }
203 :
204 : /** Reset all attrs of the format but keep the ones a pagedesc
205 : cannot live without. */
206 : inline void ResetAllMasterAttr();
207 : inline void ResetAllLeftAttr();
208 :
209 : /** Layout uses the following methods to obtain a format in order
210 : to be able to create a page. */
211 : SwFrameFormat *GetRightFormat(bool const bFirst = false);
212 : inline const SwFrameFormat *GetRightFormat(bool const bFirst = false) const;
213 : SwFrameFormat *GetLeftFormat(bool const bFirst = false);
214 : inline const SwFrameFormat *GetLeftFormat(bool const bFirst = false) const;
215 :
216 7783 : sal_uInt16 GetRegHeight() const { return m_nRegHeight; }
217 7783 : sal_uInt16 GetRegAscent() const { return m_nRegAscent; }
218 0 : void SetRegHeight(sal_uInt16 const nNew) { m_nRegHeight = nNew; }
219 0 : void SetRegAscent(sal_uInt16 const nNew) { m_nRegAscent = nNew; }
220 :
221 : inline void SetFollow( const SwPageDesc* pNew );
222 108968 : const SwPageDesc* GetFollow() const { return m_pFollow; }
223 101999 : SwPageDesc* GetFollow() { return m_pFollow; }
224 :
225 : void SetRegisterFormatColl( const SwTextFormatColl* rFormat );
226 : const SwTextFormatColl* GetRegisterFormatColl() const;
227 : void RegisterChange();
228 :
229 : /// Query and set PoolFormat-Id.
230 144833 : sal_uInt16 GetPoolFormatId() const { return m_Master.GetPoolFormatId(); }
231 10803 : void SetPoolFormatId(sal_uInt16 const nId) { m_Master.SetPoolFormatId(nId); }
232 32477 : sal_uInt16 GetPoolHelpId() const { return m_Master.GetPoolHelpId(); }
233 7459 : void SetPoolHelpId(sal_uInt16 const nId){ m_Master.SetPoolHelpId(nId); }
234 25018 : sal_uInt8 GetPoolHlpFileId() const { return m_Master.GetPoolHlpFileId(); }
235 7459 : void SetPoolHlpFileId(sal_uInt8 const nId) { m_Master.SetPoolHlpFileId(nId); }
236 :
237 : /// Query information from Client.
238 : virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE;
239 :
240 : const SwFrameFormat* GetPageFormatOfNode( const SwNode& rNd,
241 : bool bCheckForThisPgDc = true ) const;
242 : bool IsFollowNextPageOfNode( const SwNode& rNd ) const;
243 :
244 : /// Given a SwNode return the pagedesc in use at that location.
245 : static const SwPageDesc* GetPageDescOfNode(const SwNode& rNd);
246 :
247 : static SwPageDesc* GetByName(SwDoc& rDoc, const OUString& rName);
248 :
249 : SwPageDesc& operator=( const SwPageDesc& );
250 :
251 : SwPageDesc( const SwPageDesc& );
252 : virtual ~SwPageDesc();
253 : };
254 :
255 1574 : inline void SwPageDesc::SetFollow( const SwPageDesc* pNew )
256 : {
257 1574 : m_pFollow = pNew ? const_cast<SwPageDesc*>(pNew) : this;
258 1574 : }
259 :
260 31019 : inline bool SwPageDesc::IsHeaderShared() const
261 : {
262 31019 : return (m_eUse & nsUseOnPage::PD_HEADERSHARE) != 0;
263 : }
264 29468 : inline bool SwPageDesc::IsFooterShared() const
265 : {
266 29468 : return (m_eUse & nsUseOnPage::PD_FOOTERSHARE) != 0;
267 : }
268 11161 : inline void SwPageDesc::ChgHeaderShare( bool bNew )
269 : {
270 11161 : if ( bNew )
271 10500 : m_eUse = (UseOnPage) (m_eUse | nsUseOnPage::PD_HEADERSHARE);
272 : else
273 661 : m_eUse = (UseOnPage) (m_eUse & nsUseOnPage::PD_NOHEADERSHARE);
274 11161 : }
275 10150 : inline void SwPageDesc::ChgFooterShare( bool bNew )
276 : {
277 10150 : if ( bNew )
278 9700 : m_eUse = (UseOnPage) (m_eUse | nsUseOnPage::PD_FOOTERSHARE);
279 : else
280 450 : m_eUse = (UseOnPage) (m_eUse & nsUseOnPage::PD_NOFOOTERSHARE);
281 10150 : }
282 11336 : inline void SwPageDesc::SetUseOn( UseOnPage eNew )
283 : {
284 11336 : UseOnPage eTmp = nsUseOnPage::PD_NONE;
285 11336 : if (m_eUse & nsUseOnPage::PD_HEADERSHARE)
286 11052 : eTmp = nsUseOnPage::PD_HEADERSHARE;
287 11336 : if (m_eUse & nsUseOnPage::PD_FOOTERSHARE)
288 11152 : eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FOOTERSHARE);
289 11336 : if (m_eUse & nsUseOnPage::PD_FIRSTSHARE)
290 11290 : eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FIRSTSHARE);
291 11336 : m_eUse = (UseOnPage) (eTmp | eNew);
292 :
293 11336 : }
294 46510 : inline UseOnPage SwPageDesc::GetUseOn() const
295 : {
296 46510 : UseOnPage eRet = m_eUse;
297 46510 : eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOHEADERSHARE);
298 46510 : eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFOOTERSHARE);
299 46510 : eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFIRSTSHARE);
300 46510 : return eRet;
301 : }
302 :
303 540 : inline void SwPageDesc::ResetAllMasterAttr()
304 : {
305 540 : ResetAllAttr( false );
306 540 : }
307 :
308 : inline void SwPageDesc::ResetAllLeftAttr()
309 : {
310 : ResetAllAttr( true );
311 : }
312 :
313 2975 : inline const SwFrameFormat *SwPageDesc::GetRightFormat(bool const bFirst) const
314 : {
315 2975 : return const_cast<SwPageDesc*>(this)->GetRightFormat(bFirst);
316 : }
317 2971 : inline const SwFrameFormat *SwPageDesc::GetLeftFormat(bool const bFirst) const
318 : {
319 2971 : return const_cast<SwPageDesc*>(this)->GetLeftFormat(bFirst);
320 : }
321 :
322 : class SwPageDescExt
323 : {
324 : public:
325 : SwPageDesc m_PageDesc;
326 : private:
327 : SwDoc * m_pDoc;
328 : OUString m_sFollow;
329 :
330 : void SetPageDesc(const SwPageDesc & rPageDesc);
331 :
332 : public:
333 : SwPageDescExt(const SwPageDesc & rPageDesc, SwDoc * pDoc);
334 : SwPageDescExt(const SwPageDescExt & rSrc);
335 : ~SwPageDescExt();
336 :
337 : SwPageDescExt & operator = (const SwPageDescExt & rSrc);
338 : SwPageDescExt & operator = (const SwPageDesc & rSrc);
339 :
340 : OUString GetName() const;
341 :
342 : operator SwPageDesc() const; // #i7983#
343 : };
344 :
345 : namespace sw {
346 2590 : class PageFootnoteHint SAL_FINAL : public SfxHint {};
347 : }
348 :
349 : #endif // INCLUDED_SW_INC_PAGEDESC_HXX
350 :
351 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|