1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <tools/fract.hxx>
23 #include <tools/color.hxx>
24 #include <tools/string.hxx>
26 #include <swtypes.hxx> ///< For SwTwips.
28 #include <editeng/numitem.hxx>
29 #include <editeng/borderline.hxx>
35 /// Separator line adjustment.
43 /// Footnote information.
44 class SW_DLLPUBLIC SwPageFtnInfo
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
56 SwTwips
GetHeight() const { return nMaxHeight
; }
57 sal_uLong
GetLineWidth() const { return nLineWidth
; }
58 const Color
& GetLineColor() const { return aLineColor
;}
59 editeng::SvxBorderStyle
GetLineStyle() const { return eLineStyle
; }
60 const Fraction
& GetWidth() const { return aWidth
; }
61 SwFtnAdj
GetAdj() const { return eAdj
; }
62 SwTwips
GetTopDist()const { return nTopDist
; }
63 SwTwips
GetBottomDist() const { return nBottomDist
; }
65 void SetHeight( SwTwips nNew
) { nMaxHeight
= nNew
; }
66 void SetLineWidth(sal_uLong nSet
) { nLineWidth
= nSet
; }
67 void SetLineStyle( editeng::SvxBorderStyle eSet
) { eLineStyle
= eSet
; }
68 void SetLineColor(const Color
& rCol
) { aLineColor
= rCol
;}
69 void SetWidth( const Fraction
&rNew
){ aWidth
= rNew
; }
70 void SetAdj ( SwFtnAdj eNew
) { eAdj
= eNew
; }
71 void SetTopDist ( SwTwips nNew
) { nTopDist
= nNew
; }
72 void SetBottomDist( SwTwips nNew
) { nBottomDist
= nNew
; }
75 SwPageFtnInfo( const SwPageFtnInfo
& );
76 SwPageFtnInfo
& operator=( const SwPageFtnInfo
& );
78 sal_Bool
operator ==( const SwPageFtnInfo
& ) const;
82 * Use of UseOnPage (eUse) and of FrmFmts
84 * RIGHT - aMaster only for right hand (odd) pages, left hand (even) pages
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.
93 * UI works exclusively on master! aLeft is adjusted on Chg at document
96 * In order to simplify the work of the filters some more values are placed
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.
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)!
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-
109 * Header/footer for left hand pages are copied or mirrored (Chg at
111 * The respective attribute for content is cared for automatically on Chg at
112 * document (contents are created or removed according to SHARE-information).
115 typedef sal_uInt16 UseOnPage
;
116 namespace nsUseOnPage
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;
131 class SW_DLLPUBLIC SwPageDesc
: public SwModify
136 SvxNumberType aNumType
;
139 // FIXME epicycles growing here - page margins need to be stored differently
140 SwFrmFmt m_FirstMaster
;
141 SwFrmFmt m_FirstLeft
;
142 SwDepend aDepend
; ///< Because of grid alignment (Registerhaltigkeit).
144 sal_uInt16 nRegHeight
; ///< Sentence spacing and fontascent of style.
145 sal_uInt16 nRegAscent
; ///< For grid alignment (Registerhaltigkeit).
150 /// Footnote information.
151 SwPageFtnInfo aFtnInfo
;
153 /** Called for mirroring of Chg (doc).
154 No adjustment at any other place. */
155 SW_DLLPRIVATE
void Mirror();
157 SW_DLLPRIVATE
void ResetAllAttr( sal_Bool bLeft
);
159 SW_DLLPRIVATE
SwPageDesc(const String
&, SwFrmFmt
*, SwDoc
*pDc
);
162 virtual void Modify( const SfxPoolItem
* pOld
, const SfxPoolItem
*pNewValue
);
165 const String
&GetName() const { return aDescName
; }
166 void SetName( const String
& rNewName
) { aDescName
= rNewName
; }
168 sal_Bool
GetLandscape() const { return bLandscape
; }
169 void SetLandscape( sal_Bool bNew
) { bLandscape
= bNew
; }
171 const SvxNumberType
&GetNumType() const { return aNumType
; }
172 void SetNumType( const SvxNumberType
& rNew
) { aNumType
= rNew
; }
174 const SwPageFtnInfo
&GetFtnInfo() const { return aFtnInfo
; }
175 SwPageFtnInfo
&GetFtnInfo() { return aFtnInfo
; }
176 void SetFtnInfo( const SwPageFtnInfo
&rNew
) { aFtnInfo
= rNew
; }
178 inline sal_Bool
IsHeaderShared() const;
179 inline sal_Bool
IsFooterShared() const;
180 inline void ChgHeaderShare( sal_Bool bNew
);
181 inline void ChgFooterShare( sal_Bool bNew
);
182 sal_Bool
IsFirstShared() const;
183 void ChgFirstShare( sal_Bool bNew
);
185 sal_Bool
IsHidden( ) const { return bHidden
; }
186 void SetHidden( sal_Bool bValue
) { bHidden
= bValue
; }
188 inline void SetUseOn( UseOnPage eNew
);
189 inline UseOnPage
GetUseOn() const;
191 void WriteUseOn( UseOnPage eNew
) { eUse
= eNew
; }
192 UseOnPage
ReadUseOn () const { return eUse
; }
194 SwFrmFmt
&GetMaster() { return aMaster
; }
195 SwFrmFmt
&GetLeft() { return aLeft
; }
196 SwFrmFmt
&GetFirstMaster() { return m_FirstMaster
; }
197 SwFrmFmt
&GetFirstLeft() { return m_FirstLeft
; }
198 const SwFrmFmt
&GetMaster() const { return aMaster
; }
199 const SwFrmFmt
&GetLeft() const { return aLeft
; }
200 const SwFrmFmt
&GetFirstMaster() const { return m_FirstMaster
; }
201 const SwFrmFmt
&GetFirstLeft() const { return m_FirstLeft
; }
203 /** Reset all attrs of the format but keep the ones a pagedesc
204 cannot live without. */
205 inline void ResetAllMasterAttr();
206 inline void ResetAllLeftAttr();
208 /** Layout uses the following methods to obtain a format in order
209 to be able to create a page. */
210 SwFrmFmt
*GetRightFmt(bool const bFirst
= false);
211 inline const SwFrmFmt
*GetRightFmt(bool const bFirst
= false) const;
212 SwFrmFmt
*GetLeftFmt(bool const bFirst
= false);
213 inline const SwFrmFmt
*GetLeftFmt(bool const bFirst
= false) const;
215 sal_uInt16
GetRegHeight() const { return nRegHeight
; }
216 sal_uInt16
GetRegAscent() const { return nRegAscent
; }
217 void SetRegHeight( sal_uInt16 nNew
){ nRegHeight
= nNew
; }
218 void SetRegAscent( sal_uInt16 nNew
){ nRegAscent
= nNew
; }
220 inline void SetFollow( const SwPageDesc
* pNew
);
221 const SwPageDesc
* GetFollow() const { return pFollow
; }
222 SwPageDesc
* GetFollow() { return pFollow
; }
224 void SetRegisterFmtColl( const SwTxtFmtColl
* rFmt
);
225 const SwTxtFmtColl
* GetRegisterFmtColl() const;
226 void RegisterChange();
228 /// Query and set PoolFormat-Id.
229 sal_uInt16
GetPoolFmtId() const { return aMaster
.GetPoolFmtId(); }
230 void SetPoolFmtId( sal_uInt16 nId
) { aMaster
.SetPoolFmtId( nId
); }
231 sal_uInt16
GetPoolHelpId() const { return aMaster
.GetPoolHelpId(); }
232 void SetPoolHelpId( sal_uInt16 nId
) { aMaster
.SetPoolHelpId( nId
); }
233 sal_uInt8
GetPoolHlpFileId() const { return aMaster
.GetPoolHlpFileId(); }
234 void SetPoolHlpFileId( sal_uInt8 nId
) { aMaster
.SetPoolHlpFileId( nId
); }
236 /// Query information from Client.
237 virtual bool GetInfo( SfxPoolItem
& ) const;
239 const SwFrmFmt
* GetPageFmtOfNode( const SwNode
& rNd
,
240 sal_Bool bCheckForThisPgDc
= sal_True
) const;
241 sal_Bool
IsFollowNextPageOfNode( const SwNode
& rNd
) const;
243 /// Given a SwNode return the pagedesc in use at that location.
244 static const SwPageDesc
* GetPageDescOfNode(const SwNode
& rNd
);
246 SwPageDesc
& operator=( const SwPageDesc
& );
248 SwPageDesc( const SwPageDesc
& );
252 inline void SwPageDesc::SetFollow( const SwPageDesc
* pNew
)
254 pFollow
= pNew
? (SwPageDesc
*)pNew
: this;
257 inline sal_Bool
SwPageDesc::IsHeaderShared() const
259 return eUse
& nsUseOnPage::PD_HEADERSHARE
? sal_True
: sal_False
;
261 inline sal_Bool
SwPageDesc::IsFooterShared() const
263 return eUse
& nsUseOnPage::PD_FOOTERSHARE
? sal_True
: sal_False
;
265 inline void SwPageDesc::ChgHeaderShare( sal_Bool bNew
)
268 eUse
= (UseOnPage
) (eUse
| nsUseOnPage::PD_HEADERSHARE
);
270 eUse
= (UseOnPage
) (eUse
& nsUseOnPage::PD_NOHEADERSHARE
);
272 inline void SwPageDesc::ChgFooterShare( sal_Bool bNew
)
275 eUse
= (UseOnPage
) (eUse
| nsUseOnPage::PD_FOOTERSHARE
);
277 eUse
= (UseOnPage
) (eUse
& nsUseOnPage::PD_NOFOOTERSHARE
);
279 inline void SwPageDesc::SetUseOn( UseOnPage eNew
)
281 UseOnPage eTmp
= nsUseOnPage::PD_NONE
;
282 if ( eUse
& nsUseOnPage::PD_HEADERSHARE
)
283 eTmp
= nsUseOnPage::PD_HEADERSHARE
;
284 if ( eUse
& nsUseOnPage::PD_FOOTERSHARE
)
285 eTmp
= (UseOnPage
) (eTmp
| nsUseOnPage::PD_FOOTERSHARE
);
286 if ( eUse
& nsUseOnPage::PD_FIRSTSHARE
)
287 eTmp
= (UseOnPage
) (eTmp
| nsUseOnPage::PD_FIRSTSHARE
);
288 eUse
= (UseOnPage
) (eTmp
| eNew
);
291 inline UseOnPage
SwPageDesc::GetUseOn() const
293 UseOnPage eRet
= eUse
;
294 eRet
= (UseOnPage
) (eRet
& nsUseOnPage::PD_NOHEADERSHARE
);
295 eRet
= (UseOnPage
) (eRet
& nsUseOnPage::PD_NOFOOTERSHARE
);
296 eRet
= (UseOnPage
) (eRet
& nsUseOnPage::PD_NOFIRSTSHARE
);
300 inline void SwPageDesc::ResetAllMasterAttr()
302 ResetAllAttr( sal_False
);
305 inline void SwPageDesc::ResetAllLeftAttr()
307 ResetAllAttr( sal_True
);
310 inline const SwFrmFmt
*SwPageDesc::GetRightFmt(bool const bFirst
) const
312 return const_cast<SwPageDesc
*>(this)->GetRightFmt(bFirst
);
314 inline const SwFrmFmt
*SwPageDesc::GetLeftFmt(bool const bFirst
) const
316 return const_cast<SwPageDesc
*>(this)->GetLeftFmt(bFirst
);
321 SwPageDesc aPageDesc
;
325 void SetPageDesc(const SwPageDesc
& aPageDesc
);
328 SwPageDescExt(const SwPageDesc
& rPageDesc
, SwDoc
* pDoc
);
329 SwPageDescExt(const SwPageDescExt
& rSrc
);
332 SwPageDescExt
& operator = (const SwPageDescExt
& rSrc
);
333 SwPageDescExt
& operator = (const SwPageDesc
& rSrc
);
335 const String
& GetName() const;
337 operator SwPageDesc() const; // #i7983#
341 SwPageDesc
* GetPageDescByName_Impl(SwDoc
& rDoc
, const String
& rName
);
343 #endif //_PAGEDESC_HXX
345 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */