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 _PAGEDESC_HXX
20 : #define _PAGEDESC_HXX
21 :
22 : #include <tools/fract.hxx>
23 : #include <tools/color.hxx>
24 : #include <tools/string.hxx>
25 : #include "swdllapi.h"
26 : #include <swtypes.hxx> ///< For SwTwips.
27 : #include <frmfmt.hxx>
28 : #include <editeng/numitem.hxx>
29 : #include <editeng/borderline.hxx>
30 :
31 : class SfxPoolItem;
32 : class SwTxtFmtColl;
33 : class SwNode;
34 :
35 : /// Separator line adjustment.
36 : enum SwFtnAdj
37 : {
38 : FTNADJ_LEFT,
39 : FTNADJ_CENTER,
40 : FTNADJ_RIGHT
41 : };
42 :
43 : /// Footnote information.
44 : class SW_DLLPUBLIC SwPageFtnInfo
45 : {
46 : SwTwips nMaxHeight; ///< maximum height of the footnote area.
47 : sal_uLong nLineWidth; ///< width of separator line
48 : editeng::SvxBorderStyle eLineStyle; ///< Style of the separator line
49 : Color aLineColor; ///< color of the separator line
50 : Fraction aWidth; ///< percentage width of the separator line.
51 : SwFtnAdj eAdj; ///< line adjustment.
52 : SwTwips nTopDist; ///< distance between body and separator.
53 : SwTwips nBottomDist; ///< distance between separator and first footnote
54 :
55 : public:
56 11341 : SwTwips GetHeight() const { return nMaxHeight; }
57 109 : sal_uLong GetLineWidth() const { return nLineWidth; }
58 21 : const Color& GetLineColor() const { return aLineColor;}
59 21 : editeng::SvxBorderStyle GetLineStyle() const { return eLineStyle; }
60 10255 : const Fraction& GetWidth() const { return aWidth; }
61 10255 : SwFtnAdj GetAdj() const { return eAdj; }
62 10356 : SwTwips GetTopDist()const { return nTopDist; }
63 10352 : SwTwips GetBottomDist() const { return nBottomDist; }
64 :
65 75 : void SetHeight( SwTwips nNew ) { nMaxHeight = nNew; }
66 87 : void SetLineWidth(sal_uLong nSet ) { nLineWidth = nSet; }
67 150 : void SetLineStyle( editeng::SvxBorderStyle eSet ) { eLineStyle = eSet; }
68 75 : void SetLineColor(const Color& rCol ) { aLineColor = rCol;}
69 75 : void SetWidth( const Fraction &rNew){ aWidth = rNew; }
70 75 : void SetAdj ( SwFtnAdj eNew ) { eAdj = eNew; }
71 87 : void SetTopDist ( SwTwips nNew ) { nTopDist = nNew; }
72 87 : void SetBottomDist( SwTwips nNew ) { nBottomDist = nNew; }
73 :
74 : SwPageFtnInfo();
75 : SwPageFtnInfo( const SwPageFtnInfo& );
76 : SwPageFtnInfo& operator=( const SwPageFtnInfo& );
77 :
78 : sal_Bool operator ==( const SwPageFtnInfo& ) const;
79 : };
80 :
81 : /*
82 : * Use of UseOnPage (eUse) and of FrmFmts
83 : *
84 : * RIGHT - aMaster only for right hand (odd) pages, left hand (even) pages
85 : * always empty.
86 : * LEFT - aLeft for left-hand pages, right-hand pages always empty.
87 : * aLeft is a copy of master.
88 : * ALL - aMaster for right hand pages, aLeft for left hand pages.
89 : * - aLeft is a copy of master.
90 : * MIRROR - aMaster for right hand pages, aLeft for left hand pagers.
91 : * aLeft is a copy of master, margins are mirrored.
92 : *
93 : * UI works exclusively on master! aLeft is adjusted on Chg at document
94 : * according to eUse.
95 : *
96 : * In order to simplify the work of the filters some more values are placed
97 : * into 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 eUse including the information on header and footer
104 : * via ReadUseOn(), WriteUseOn() (fuer Filter und 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 : String aDescName;
136 : SvxNumberType aNumType;
137 : SwFrmFmt aMaster;
138 : SwFrmFmt aLeft;
139 : SwFrmFmt aFirst;
140 : SwDepend aDepend; ///< Because of grid alignment (Registerhaltigkeit).
141 : SwPageDesc *pFollow;
142 : sal_uInt16 nRegHeight; ///< Sentence spacing and fontascent of style.
143 : sal_uInt16 nRegAscent; ///< For grid alignment (Registerhaltigkeit).
144 : UseOnPage eUse;
145 : sal_Bool bLandscape;
146 : sal_Bool bHidden;
147 :
148 : /// Footnote information.
149 : SwPageFtnInfo aFtnInfo;
150 :
151 : /** Called for mirroring of Chg (doc).
152 : No adjustment at any other place. */
153 : SW_DLLPRIVATE void Mirror();
154 :
155 : SW_DLLPRIVATE void ResetAllAttr( sal_Bool bLeft );
156 :
157 : SW_DLLPRIVATE SwPageDesc(const String&, SwFrmFmt*, SwDoc *pDc );
158 :
159 : protected:
160 : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNewValue );
161 :
162 : public:
163 27874 : const String &GetName() const { return aDescName; }
164 4 : void SetName( const String& rNewName ) { aDescName = rNewName; }
165 :
166 4832 : sal_Bool GetLandscape() const { return bLandscape; }
167 2409 : void SetLandscape( sal_Bool bNew ) { bLandscape = bNew; }
168 :
169 6295 : const SvxNumberType &GetNumType() const { return aNumType; }
170 1530 : void SetNumType( const SvxNumberType& rNew ) { aNumType = rNew; }
171 :
172 4642 : const SwPageFtnInfo &GetFtnInfo() const { return aFtnInfo; }
173 2541 : SwPageFtnInfo &GetFtnInfo() { return aFtnInfo; }
174 786 : void SetFtnInfo( const SwPageFtnInfo &rNew ) { aFtnInfo = rNew; }
175 :
176 : inline sal_Bool IsHeaderShared() const;
177 : inline sal_Bool IsFooterShared() const;
178 : inline void ChgHeaderShare( sal_Bool bNew );
179 : inline void ChgFooterShare( sal_Bool bNew );
180 : sal_Bool IsFirstShared() const;
181 : void ChgFirstShare( sal_Bool bNew );
182 :
183 1026 : sal_Bool IsHidden( ) const { return bHidden; }
184 76 : void SetHidden( sal_Bool bValue ) { bHidden = bValue; }
185 :
186 : inline void SetUseOn( UseOnPage eNew );
187 : inline UseOnPage GetUseOn() const;
188 :
189 58 : void WriteUseOn( UseOnPage eNew ) { eUse = eNew; }
190 2418 : UseOnPage ReadUseOn () const { return eUse; }
191 :
192 21728 : SwFrmFmt &GetMaster() { return aMaster; }
193 10915 : SwFrmFmt &GetLeft() { return aLeft; }
194 10596 : SwFrmFmt &GetFirst() { return aFirst; }
195 11289 : const SwFrmFmt &GetMaster() const { return aMaster; }
196 2671 : const SwFrmFmt &GetLeft() const { return aLeft; }
197 1753 : const SwFrmFmt &GetFirst() const { return aFirst; }
198 :
199 : /** Reset all attrs of the format but keep the ones a pagedesc
200 : cannot live without. */
201 : inline void ResetAllMasterAttr();
202 : inline void ResetAllLeftAttr();
203 :
204 : /** Layout uses the following methods to obtain a format in order
205 : to be able to create a page. */
206 : SwFrmFmt *GetRightFmt(bool const bFirst = false);
207 : inline const SwFrmFmt *GetRightFmt(bool const bFirst = false) const;
208 : SwFrmFmt *GetLeftFmt(bool const bFirst = false);
209 : inline const SwFrmFmt *GetLeftFmt(bool const bFirst = false) const;
210 :
211 751 : sal_uInt16 GetRegHeight() const { return nRegHeight; }
212 751 : sal_uInt16 GetRegAscent() const { return nRegAscent; }
213 0 : void SetRegHeight( sal_uInt16 nNew ){ nRegHeight = nNew; }
214 0 : void SetRegAscent( sal_uInt16 nNew ){ nRegAscent = nNew; }
215 :
216 : inline void SetFollow( const SwPageDesc* pNew );
217 15069 : const SwPageDesc* GetFollow() const { return pFollow; }
218 2473 : SwPageDesc* GetFollow() { return pFollow; }
219 :
220 : void SetRegisterFmtColl( const SwTxtFmtColl* rFmt );
221 : const SwTxtFmtColl* GetRegisterFmtColl() const;
222 : void RegisterChange();
223 :
224 : /// Query and set PoolFormat-Id.
225 14919 : sal_uInt16 GetPoolFmtId() const { return aMaster.GetPoolFmtId(); }
226 1706 : void SetPoolFmtId( sal_uInt16 nId ) { aMaster.SetPoolFmtId( nId ); }
227 5053 : sal_uInt16 GetPoolHelpId() const { return aMaster.GetPoolHelpId(); }
228 739 : void SetPoolHelpId( sal_uInt16 nId ) { aMaster.SetPoolHelpId( nId ); }
229 4314 : sal_uInt8 GetPoolHlpFileId() const { return aMaster.GetPoolHlpFileId(); }
230 739 : void SetPoolHlpFileId( sal_uInt8 nId ) { aMaster.SetPoolHlpFileId( nId ); }
231 :
232 : /// Query information from Client.
233 : virtual bool GetInfo( SfxPoolItem& ) const;
234 :
235 : const SwFrmFmt* GetPageFmtOfNode( const SwNode& rNd,
236 : sal_Bool bCheckForThisPgDc = sal_True ) const;
237 : sal_Bool IsFollowNextPageOfNode( const SwNode& rNd ) const;
238 :
239 : /// Given a SwNode return the pagedesc in use at that location.
240 : static const SwPageDesc* GetPageDescOfNode(const SwNode& rNd);
241 :
242 : SwPageDesc& operator=( const SwPageDesc& );
243 :
244 : SwPageDesc( const SwPageDesc& );
245 : ~SwPageDesc();
246 : };
247 :
248 203 : inline void SwPageDesc::SetFollow( const SwPageDesc* pNew )
249 : {
250 203 : pFollow = pNew ? (SwPageDesc*)pNew : this;
251 203 : }
252 :
253 3041 : inline sal_Bool SwPageDesc::IsHeaderShared() const
254 : {
255 3041 : return eUse & nsUseOnPage::PD_HEADERSHARE ? sal_True : sal_False;
256 : }
257 2966 : inline sal_Bool SwPageDesc::IsFooterShared() const
258 : {
259 2966 : return eUse & nsUseOnPage::PD_FOOTERSHARE ? sal_True : sal_False;
260 : }
261 1022 : inline void SwPageDesc::ChgHeaderShare( sal_Bool bNew )
262 : {
263 1022 : if ( bNew )
264 966 : eUse = (UseOnPage) (eUse | nsUseOnPage::PD_HEADERSHARE);
265 : else
266 56 : eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOHEADERSHARE);
267 1022 : }
268 980 : inline void SwPageDesc::ChgFooterShare( sal_Bool bNew )
269 : {
270 980 : if ( bNew )
271 928 : eUse = (UseOnPage) (eUse | nsUseOnPage::PD_FOOTERSHARE);
272 : else
273 52 : eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOFOOTERSHARE);
274 980 : }
275 1804 : inline void SwPageDesc::SetUseOn( UseOnPage eNew )
276 : {
277 1804 : UseOnPage eTmp = nsUseOnPage::PD_NONE;
278 1804 : if ( eUse & nsUseOnPage::PD_HEADERSHARE )
279 1780 : eTmp = nsUseOnPage::PD_HEADERSHARE;
280 1804 : if ( eUse & nsUseOnPage::PD_FOOTERSHARE )
281 1784 : eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FOOTERSHARE);
282 1804 : if ( eUse & nsUseOnPage::PD_FIRSTSHARE )
283 1776 : eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FIRSTSHARE);
284 1804 : eUse = (UseOnPage) (eTmp | eNew);
285 :
286 1804 : }
287 5082 : inline UseOnPage SwPageDesc::GetUseOn() const
288 : {
289 5082 : UseOnPage eRet = eUse;
290 5082 : eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOHEADERSHARE);
291 5082 : eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFOOTERSHARE);
292 5082 : eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFIRSTSHARE);
293 5082 : return eRet;
294 : }
295 :
296 77 : inline void SwPageDesc::ResetAllMasterAttr()
297 : {
298 77 : ResetAllAttr( sal_False );
299 77 : }
300 :
301 : inline void SwPageDesc::ResetAllLeftAttr()
302 : {
303 : ResetAllAttr( sal_True );
304 : }
305 :
306 107 : inline const SwFrmFmt *SwPageDesc::GetRightFmt(bool const bFirst) const
307 : {
308 107 : return const_cast<SwPageDesc*>(this)->GetRightFmt(bFirst);
309 : }
310 103 : inline const SwFrmFmt *SwPageDesc::GetLeftFmt(bool const bFirst) const
311 : {
312 103 : return const_cast<SwPageDesc*>(this)->GetLeftFmt(bFirst);
313 : }
314 :
315 : class SwPageDescExt
316 : {
317 : SwPageDesc aPageDesc;
318 : SwDoc * pDoc;
319 : String sFollow;
320 :
321 : void SetPageDesc(const SwPageDesc & aPageDesc);
322 :
323 : public:
324 : SwPageDescExt(const SwPageDesc & rPageDesc, SwDoc * pDoc);
325 : SwPageDescExt(const SwPageDescExt & rSrc);
326 : ~SwPageDescExt();
327 :
328 : SwPageDescExt & operator = (const SwPageDescExt & rSrc);
329 : SwPageDescExt & operator = (const SwPageDesc & rSrc);
330 :
331 : const String & GetName() const;
332 :
333 : operator SwPageDesc() const; // #i7983#
334 : };
335 :
336 :
337 : SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName);
338 :
339 : #endif //_PAGEDESC_HXX
340 :
341 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|