merge the formfield patch from ooo-build
[ooovba.git] / sw / inc / pagedesc.hxx
blobdd80b7f94f45254ece576b4ce9a79b0df52c7b7c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pagedesc.hxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _PAGEDESC_HXX
31 #define _PAGEDESC_HXX
33 #include <tools/fract.hxx>
34 #include <tools/color.hxx>
35 #include <tools/string.hxx>
36 #include "swdllapi.h"
37 #include <swtypes.hxx> //fuer SwTwips
38 #include <frmfmt.hxx>
39 //#ifndef _NUMRULE_HXX
40 //#include <numrule.hxx>
41 //#endif
42 #include <svx/numitem.hxx>
44 class SfxPoolItem;
45 class SwTxtFmtColl;
46 class SwNode;
48 //Separator line adjustment
49 enum SwFtnAdj
51 FTNADJ_LEFT,
52 FTNADJ_CENTER,
53 FTNADJ_RIGHT
56 //footnote information
57 class SW_DLLPUBLIC SwPageFtnInfo
59 SwTwips nMaxHeight; //maximum height of the footnote area.
60 ULONG nLineWidth; //width of separator line
61 Color aLineColor; //color of the separator line
62 Fraction aWidth; //percentage width of the separator line.
63 SwFtnAdj eAdj; //line adjustment.
64 SwTwips nTopDist; //distance between body and separator.
65 SwTwips nBottomDist; //distance between separator and first footnote
67 public:
68 SwTwips GetHeight() const { return nMaxHeight; }
69 ULONG GetLineWidth() const { return nLineWidth; }
70 const Color& GetLineColor() const { return aLineColor;}
71 const Fraction& GetWidth() const { return aWidth; }
72 SwFtnAdj GetAdj() const { return eAdj; }
73 SwTwips GetTopDist()const { return nTopDist; }
74 SwTwips GetBottomDist() const { return nBottomDist; }
76 void SetHeight( SwTwips nNew ) { nMaxHeight = nNew; }
77 void SetLineWidth(ULONG nSet ) { nLineWidth = nSet; }
78 void SetLineColor(const Color& rCol ) { aLineColor = rCol;}
79 void SetWidth( const Fraction &rNew){ aWidth = rNew; }
80 void SetAdj ( SwFtnAdj eNew ) { eAdj = eNew; }
81 void SetTopDist ( SwTwips nNew ) { nTopDist = nNew; }
82 void SetBottomDist( SwTwips nNew ) { nBottomDist = nNew; }
84 SwPageFtnInfo();
85 SwPageFtnInfo( const SwPageFtnInfo& );
86 SwPageFtnInfo& operator=( const SwPageFtnInfo& );
88 BOOL operator ==( const SwPageFtnInfo& ) const;
92 * Verwendung des UseOnPage (eUse) und der FrmFmt'e
94 * RIGHT - aMaster nur fuer rechte Seiten, linke Seiten immer leer.
95 * LEFT - aLeft fuer linke Seiten, rechte Seiten immer leer.
96 * aLeft ist eine Kopie des Master.
97 * ALL - aMaster fuer rechte Seiten, aLeft fuer Linke Seiten.
98 * aLeft ist eine Kopie des Master.
99 * MIRROR - aMaster fuer rechte Seiten, aLeft fuer linke Seiten.
100 * aLeft ist eine Kopie des Master, Raender sind gespiegelt.
102 * UI dreht auschliesslich am Master! aLeft wird beim Chg am Dokument
103 * enstprechend dem eUse eingestellt.
105 * Damit es die Filter etwas einfacher haben werden weitere Werte im
106 * eUse untergebracht:
108 * HEADERSHARE - Headerinhalt auf beiden Seiten gleich
109 * FOOTERSHARE - Footerinhalt auf beiden Seiten gleich
111 * Die Werte werden bei den entsprechenden Get-/Set-Methden ausmaskiert.
112 * Zugriff auf das volle eUse inclusive der Header-Footer information
113 * per ReadUseOn(), WriteUseOn() (fuer Filter und CopyCTor)!
115 * Die FrmFormate fuer Header/Footer werden anhand der Attribute fuer
116 * Header/Footer vom UI am Master eingestellt (Hoehe, Raender, Hintergrund...);
117 * Header/Footer fuer die Linke Seite werden entsprechen kopiert bzw.
118 * gespielt (Chg am Dokument).
119 * Das jew. Attribut fuer den Inhalt wird automatisch beim Chg am
120 * Dokument versorgt (entsprechen den SHARE-informationen werden Inhalte
121 * erzeugt bzw. entfernt).
125 typedef USHORT UseOnPage;
126 namespace nsUseOnPage
128 const UseOnPage PD_NONE = 0x0000; //for internal use only.
129 const UseOnPage PD_LEFT = 0x0001;
130 const UseOnPage PD_RIGHT = 0x0002;
131 const UseOnPage PD_ALL = 0x0003;
132 const UseOnPage PD_MIRROR = 0x0007;
133 const UseOnPage PD_HEADERSHARE = 0x0040;
134 const UseOnPage PD_FOOTERSHARE = 0x0080;
135 const UseOnPage PD_NOHEADERSHARE = 0x00BF; //for internal use only
136 const UseOnPage PD_NOFOOTERSHARE = 0x007F; //for internal use only
139 class SW_DLLPUBLIC SwPageDesc : public SwModify
141 friend class SwDoc;
142 friend class SwUndoPageDescExt;
144 String aDescName;
145 SvxNumberType aNumType;
146 SwFrmFmt aMaster;
147 SwFrmFmt aLeft;
148 SwDepend aDepend; // wg. Registerhaltigkeit
149 SwPageDesc *pFollow;
150 USHORT nRegHeight; // Zeilenabstand und Fontascent der Vorlage
151 USHORT nRegAscent; // fuer die Registerhaltigkeit
152 UseOnPage eUse;
153 BOOL bLandscape;
155 //Fussnoteninformationen
156 SwPageFtnInfo aFtnInfo;
158 //Wird zum Spiegeln vom Chg (Doc) gerufen.
159 //Kein Abgleich an anderer Stelle.
160 SW_DLLPRIVATE void Mirror();
162 SW_DLLPRIVATE void ResetAllAttr( sal_Bool bLeft );
164 SW_DLLPRIVATE SwPageDesc(const String&, SwFrmFmt*, SwDoc *pDc );
166 public:
167 const String &GetName() const { return aDescName; }
168 void SetName( const String& rNewName ) { aDescName = rNewName; }
170 BOOL GetLandscape() const { return bLandscape; }
171 void SetLandscape( BOOL bNew ) { bLandscape = bNew; }
173 const SvxNumberType &GetNumType() const { return aNumType; }
174 void SetNumType( const SvxNumberType& rNew ) { aNumType = rNew; }
176 const SwPageFtnInfo &GetFtnInfo() const { return aFtnInfo; }
177 SwPageFtnInfo &GetFtnInfo() { return aFtnInfo; }
178 void SetFtnInfo( const SwPageFtnInfo &rNew ) { aFtnInfo = rNew; }
180 inline BOOL IsHeaderShared() const;
181 inline BOOL IsFooterShared() const;
182 inline void ChgHeaderShare( BOOL bNew );
183 inline void ChgFooterShare( BOOL bNew );
185 inline void SetUseOn( UseOnPage eNew );
186 inline UseOnPage GetUseOn() const;
188 void WriteUseOn( UseOnPage eNew ) { eUse = eNew; }
189 UseOnPage ReadUseOn () const { return eUse; }
191 SwFrmFmt &GetMaster() { return aMaster; }
192 SwFrmFmt &GetLeft() { return aLeft; }
193 const SwFrmFmt &GetMaster() const { return aMaster; }
194 const SwFrmFmt &GetLeft() const { return aLeft; }
196 // Reset all attrs of the format but keep the ones a pagedesc
197 // cannot live without.
198 inline void ResetAllMasterAttr();
199 inline void ResetAllLeftAttr();
201 //Mit den folgenden Methoden besorgt sich das Layout ein Format
202 //um eine Seite erzeugen zu koennen
203 inline SwFrmFmt *GetRightFmt();
204 inline const SwFrmFmt *GetRightFmt() const;
205 inline SwFrmFmt *GetLeftFmt();
206 inline const SwFrmFmt *GetLeftFmt() const;
208 USHORT GetRegHeight() const { return nRegHeight; }
209 USHORT GetRegAscent() const { return nRegAscent; }
210 void SetRegHeight( USHORT nNew ){ nRegHeight = nNew; }
211 void SetRegAscent( USHORT nNew ){ nRegAscent = nNew; }
213 inline void SetFollow( const SwPageDesc* pNew );
214 const SwPageDesc* GetFollow() const { return pFollow; }
215 SwPageDesc* GetFollow() { return pFollow; }
217 void SetRegisterFmtColl( const SwTxtFmtColl* rFmt );
218 const SwTxtFmtColl* GetRegisterFmtColl() const;
219 virtual void Modify( SfxPoolItem *pOldValue, SfxPoolItem *pNewValue );
220 void RegisterChange();
222 // erfragen und setzen der PoolFormat-Id
223 USHORT GetPoolFmtId() const { return aMaster.GetPoolFmtId(); }
224 void SetPoolFmtId( USHORT nId ) { aMaster.SetPoolFmtId( nId ); }
225 USHORT GetPoolHelpId() const { return aMaster.GetPoolHelpId(); }
226 void SetPoolHelpId( USHORT nId ) { aMaster.SetPoolHelpId( nId ); }
227 BYTE GetPoolHlpFileId() const { return aMaster.GetPoolHlpFileId(); }
228 void SetPoolHlpFileId( BYTE nId ) { aMaster.SetPoolHlpFileId( nId ); }
230 // erfrage vom Client Informationen
231 virtual BOOL GetInfo( SfxPoolItem& ) const;
233 const SwFrmFmt* GetPageFmtOfNode( const SwNode& rNd,
234 BOOL bCheckForThisPgDc = TRUE ) const;
235 BOOL IsFollowNextPageOfNode( const SwNode& rNd ) const;
237 //Given a SwNode return the pagedesc in use at that location.
238 static const SwPageDesc* GetPageDescOfNode(const SwNode& rNd);
240 SwPageDesc& operator=( const SwPageDesc& );
242 SwPageDesc( const SwPageDesc& );
243 ~SwPageDesc();
246 inline void SwPageDesc::SetFollow( const SwPageDesc* pNew )
248 pFollow = pNew ? (SwPageDesc*)pNew : this;
251 inline BOOL SwPageDesc::IsHeaderShared() const
253 return eUse & nsUseOnPage::PD_HEADERSHARE ? TRUE : FALSE;
255 inline BOOL SwPageDesc::IsFooterShared() const
257 return eUse & nsUseOnPage::PD_FOOTERSHARE ? TRUE : FALSE;
259 inline void SwPageDesc::ChgHeaderShare( BOOL bNew )
261 if ( bNew )
262 eUse = (UseOnPage) (eUse | nsUseOnPage::PD_HEADERSHARE);
263 // (USHORT&)eUse |= (USHORT)nsUseOnPage::PD_HEADERSHARE;
264 else
265 eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOHEADERSHARE);
266 // (USHORT&)eUse &= (USHORT)nsUseOnPage::PD_NOHEADERSHARE;
268 inline void SwPageDesc::ChgFooterShare( BOOL bNew )
270 if ( bNew )
271 eUse = (UseOnPage) (eUse | nsUseOnPage::PD_FOOTERSHARE);
272 // (USHORT&)eUse |= (USHORT)nsUseOnPage::PD_FOOTERSHARE;
273 else
274 eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOFOOTERSHARE);
275 // (USHORT&)eUse &= (USHORT)nsUseOnPage::PD_NOFOOTERSHARE;
277 inline void SwPageDesc::SetUseOn( UseOnPage eNew )
279 UseOnPage eTmp = nsUseOnPage::PD_NONE;
280 if ( eUse & nsUseOnPage::PD_HEADERSHARE )
281 eTmp = nsUseOnPage::PD_HEADERSHARE;
282 // (USHORT&)eTmp |= (USHORT)nsUseOnPage::PD_HEADERSHARE;
283 if ( eUse & nsUseOnPage::PD_FOOTERSHARE )
284 eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FOOTERSHARE);
285 // (USHORT&)eTmp |= (USHORT)nsUseOnPage::PD_FOOTERSHARE;
286 eUse = (UseOnPage) (eTmp | eNew);
287 // (USHORT&)eUse = eTmp | eNew;
289 inline UseOnPage SwPageDesc::GetUseOn() const
291 UseOnPage eRet = eUse;
292 eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOHEADERSHARE);
293 // (USHORT&)eRet &= (USHORT)nsUseOnPage::PD_NOHEADERSHARE;
294 eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFOOTERSHARE);
295 // (USHORT&)eRet &= (USHORT)nsUseOnPage::PD_NOFOOTERSHARE;
296 return eRet;
299 inline void SwPageDesc::ResetAllMasterAttr()
301 ResetAllAttr( sal_False );
304 inline void SwPageDesc::ResetAllLeftAttr()
306 ResetAllAttr( sal_True );
309 inline SwFrmFmt *SwPageDesc::GetRightFmt()
311 return nsUseOnPage::PD_RIGHT & eUse ? &aMaster : 0;
313 inline const SwFrmFmt *SwPageDesc::GetRightFmt() const
315 return nsUseOnPage::PD_RIGHT & eUse ? &aMaster : 0;
317 inline SwFrmFmt *SwPageDesc::GetLeftFmt()
319 return nsUseOnPage::PD_LEFT & eUse ? &aLeft : 0;
321 inline const SwFrmFmt *SwPageDesc::GetLeftFmt() const
323 return nsUseOnPage::PD_LEFT & eUse ? &aLeft : 0;
326 class SwPageDescExt
328 SwPageDesc aPageDesc;
329 SwDoc * pDoc;
330 String sFollow;
332 void SetPageDesc(const SwPageDesc & aPageDesc);
334 public:
335 SwPageDescExt(const SwPageDesc & rPageDesc, SwDoc * pDoc);
336 SwPageDescExt(const SwPageDescExt & rSrc);
337 ~SwPageDescExt();
339 SwPageDescExt & operator = (const SwPageDescExt & rSrc);
340 SwPageDescExt & operator = (const SwPageDesc & rSrc);
342 const String & GetName() const;
344 operator SwPageDesc() const; // #i7983#
347 #endif //_PAGEDESC_HXX