1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pagedesc.hxx,v $
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 ************************************************************************/
33 #include <tools/fract.hxx>
34 #include <tools/color.hxx>
35 #include <tools/string.hxx>
37 #include <swtypes.hxx> //fuer SwTwips
39 //#ifndef _NUMRULE_HXX
40 //#include <numrule.hxx>
42 #include <svx/numitem.hxx>
48 //Separator line adjustment
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
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
; }
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
142 friend class SwUndoPageDescExt
;
145 SvxNumberType aNumType
;
148 SwDepend aDepend
; // wg. Registerhaltigkeit
150 USHORT nRegHeight
; // Zeilenabstand und Fontascent der Vorlage
151 USHORT nRegAscent
; // fuer die Registerhaltigkeit
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
);
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
& );
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
)
262 eUse
= (UseOnPage
) (eUse
| nsUseOnPage::PD_HEADERSHARE
);
263 // (USHORT&)eUse |= (USHORT)nsUseOnPage::PD_HEADERSHARE;
265 eUse
= (UseOnPage
) (eUse
& nsUseOnPage::PD_NOHEADERSHARE
);
266 // (USHORT&)eUse &= (USHORT)nsUseOnPage::PD_NOHEADERSHARE;
268 inline void SwPageDesc::ChgFooterShare( BOOL bNew
)
271 eUse
= (UseOnPage
) (eUse
| nsUseOnPage::PD_FOOTERSHARE
);
272 // (USHORT&)eUse |= (USHORT)nsUseOnPage::PD_FOOTERSHARE;
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;
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;
328 SwPageDesc aPageDesc
;
332 void SetPageDesc(const SwPageDesc
& aPageDesc
);
335 SwPageDescExt(const SwPageDesc
& rPageDesc
, SwDoc
* pDoc
);
336 SwPageDescExt(const SwPageDescExt
& rSrc
);
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