xref: /AOO41X/main/sw/inc/pagedesc.hxx (revision 1d2dbeb0b7301723c6d13094e87a8714ef81a328)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _PAGEDESC_HXX
24 #define _PAGEDESC_HXX
25 
26 #include <tools/fract.hxx>
27 #include <tools/color.hxx>
28 #include <tools/string.hxx>
29 #include "swdllapi.h"
30 #include <swtypes.hxx>  //fuer SwTwips
31 #include <frmfmt.hxx>
32 //#ifndef _NUMRULE_HXX
33 //#include <numrule.hxx>
34 //#endif
35 #include <editeng/numitem.hxx>
36 
37 class SfxPoolItem;
38 class SwTxtFmtColl;
39 class SwNode;
40 
41 //Separator line adjustment
42 enum SwFtnAdj
43 {
44     FTNADJ_LEFT,
45     FTNADJ_CENTER,
46     FTNADJ_RIGHT
47 };
48 
49 //footnote information
50 class SW_DLLPUBLIC SwPageFtnInfo
51 {
52     SwTwips     nMaxHeight;     //maximum height of the footnote area.
53     sal_uLong       nLineWidth;     //width of separator line
54     Color       aLineColor;     //color of the separator line
55     Fraction    aWidth;         //percentage width of the separator line.
56     SwFtnAdj    eAdj;           //line adjustment.
57     SwTwips     nTopDist;       //distance between body and separator.
58     SwTwips     nBottomDist;    //distance between separator and first footnote
59 
60 public:
GetHeight() const61     SwTwips     GetHeight() const       { return nMaxHeight; }
GetLineWidth() const62     sal_uLong           GetLineWidth() const { return nLineWidth; }
GetLineColor() const63     const Color&    GetLineColor() const { return aLineColor;}
GetWidth() const64     const Fraction& GetWidth() const    { return aWidth; }
GetAdj() const65     SwFtnAdj    GetAdj()    const       { return eAdj; }
GetTopDist() const66     SwTwips     GetTopDist()const       { return nTopDist; }
GetBottomDist() const67     SwTwips     GetBottomDist() const   { return nBottomDist; }
68 
SetHeight(SwTwips nNew)69     void SetHeight( SwTwips  nNew )     { nMaxHeight = nNew; }
SetLineWidth(sal_uLong nSet)70     void SetLineWidth(sal_uLong nSet  )     { nLineWidth = nSet; }
SetLineColor(const Color & rCol)71     void SetLineColor(const Color& rCol )  { aLineColor = rCol;}
SetWidth(const Fraction & rNew)72     void SetWidth( const Fraction &rNew){ aWidth = rNew; }
SetAdj(SwFtnAdj eNew)73     void SetAdj   ( SwFtnAdj eNew )     { eAdj = eNew; }
SetTopDist(SwTwips nNew)74     void SetTopDist   ( SwTwips nNew )  { nTopDist = nNew; }
SetBottomDist(SwTwips nNew)75     void SetBottomDist( SwTwips nNew )  { nBottomDist = nNew; }
76 
77     SwPageFtnInfo();
78     SwPageFtnInfo( const SwPageFtnInfo& );
79     SwPageFtnInfo& operator=( const SwPageFtnInfo& );
80 
81     sal_Bool operator ==( const SwPageFtnInfo& ) const;
82 };
83 
84 /*
85  * Verwendung des UseOnPage (eUse) und der FrmFmt'e
86  *
87  *  RIGHT   - aMaster nur fuer rechte Seiten, linke  Seiten immer leer.
88  *  LEFT    - aLeft fuer linke  Seiten, rechte Seiten immer leer.
89  *            aLeft ist eine Kopie des Master.
90  *  ALL     - aMaster fuer rechte Seiten, aLeft fuer Linke Seiten.
91  *            aLeft ist eine Kopie des Master.
92  *  MIRROR  - aMaster fuer rechte Seiten, aLeft fuer linke Seiten.
93  *            aLeft ist eine Kopie des Master, Raender sind gespiegelt.
94  *
95  * UI dreht auschliesslich am Master! aLeft wird beim Chg am Dokument
96  * enstprechend dem eUse eingestellt.
97  *
98  * Damit es die Filter etwas einfacher haben werden weitere Werte im
99  * eUse untergebracht:
100  *
101  * HEADERSHARE - Headerinhalt auf beiden Seiten gleich
102  * FOOTERSHARE - Footerinhalt auf beiden Seiten gleich
103  *
104  * Die Werte werden bei den entsprechenden Get-/Set-Methden ausmaskiert.
105  * Zugriff auf das volle eUse inclusive der Header-Footer information
106  * per ReadUseOn(), WriteUseOn() (fuer Filter und CopyCTor)!
107  *
108  * Die FrmFormate fuer Header/Footer werden anhand der Attribute fuer
109  * Header/Footer vom UI am Master eingestellt (Hoehe, Raender, Hintergrund...);
110  * Header/Footer fuer die Linke Seite werden entsprechen kopiert bzw.
111  * gespielt (Chg am Dokument).
112  * Das jew. Attribut fuer den Inhalt wird automatisch beim Chg am
113  * Dokument versorgt (entsprechen den SHARE-informationen werden Inhalte
114  * erzeugt bzw. entfernt).
115  *
116  */
117 
118 typedef sal_uInt16 UseOnPage;
119 namespace nsUseOnPage
120 {
121     const UseOnPage PD_NONE           = 0x0000; //for internal use only.
122     const UseOnPage PD_LEFT           = 0x0001;
123     const UseOnPage PD_RIGHT          = 0x0002;
124     const UseOnPage PD_ALL            = 0x0003;
125     const UseOnPage PD_MIRROR         = 0x0007;
126     const UseOnPage PD_HEADERSHARE    = 0x0040;
127     const UseOnPage PD_FOOTERSHARE    = 0x0080;
128     const UseOnPage PD_NOHEADERSHARE  = 0x00BF; //for internal use only
129     const UseOnPage PD_NOFOOTERSHARE  = 0x007F; //for internal use only
130 }
131 
132 class SW_DLLPUBLIC SwPageDesc : public SwModify
133 {
134     friend class SwDoc;
135     friend class SwUndoPageDescExt;
136 
137     String      aDescName;
138     SvxNumberType   aNumType;
139     SwFrmFmt    aMaster;
140     SwFrmFmt    aLeft;
141     SwDepend    aDepend;    // wg. Registerhaltigkeit
142     SwPageDesc *pFollow;
143     sal_uInt16      nRegHeight; // Zeilenabstand und Fontascent der Vorlage
144     sal_uInt16      nRegAscent; // fuer die Registerhaltigkeit
145     UseOnPage   eUse;
146     sal_Bool        bLandscape;
147 
148     //Fussnoteninformationen
149     SwPageFtnInfo aFtnInfo;
150 
151     //Wird zum Spiegeln vom Chg (Doc) gerufen.
152     //Kein Abgleich an anderer Stelle.
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:
GetName() const163     const String &GetName() const { return aDescName; }
SetName(const String & rNewName)164           void    SetName( const String& rNewName ) { aDescName = rNewName; }
165 
GetLandscape() const166     sal_Bool GetLandscape() const { return bLandscape; }
SetLandscape(sal_Bool bNew)167     void SetLandscape( sal_Bool bNew ) { bLandscape = bNew; }
168 
GetNumType() const169     const SvxNumberType &GetNumType() const { return aNumType; }
SetNumType(const SvxNumberType & rNew)170           void          SetNumType( const SvxNumberType& rNew ) { aNumType = rNew; }
171 
GetFtnInfo() const172     const SwPageFtnInfo &GetFtnInfo() const { return aFtnInfo; }
GetFtnInfo()173           SwPageFtnInfo &GetFtnInfo()       { return aFtnInfo; }
SetFtnInfo(const SwPageFtnInfo & rNew)174     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 
181     inline void      SetUseOn( UseOnPage eNew );
182     inline UseOnPage GetUseOn() const;
183 
WriteUseOn(UseOnPage eNew)184     void      WriteUseOn( UseOnPage eNew ) { eUse = eNew; }
ReadUseOn() const185     UseOnPage ReadUseOn () const { return eUse; }
186 
GetMaster()187           SwFrmFmt &GetMaster() { return aMaster; }
GetLeft()188           SwFrmFmt &GetLeft()   { return aLeft; }
GetMaster() const189     const SwFrmFmt &GetMaster() const { return aMaster; }
GetLeft() const190     const SwFrmFmt &GetLeft()   const { return aLeft; }
191 
192     // Reset all attrs of the format but keep the ones a pagedesc
193     // cannot live without.
194     inline void ResetAllMasterAttr();
195     inline void ResetAllLeftAttr();
196 
197     //Mit den folgenden Methoden besorgt sich das Layout ein Format
198     //um eine Seite erzeugen zu koennen
199     inline SwFrmFmt *GetRightFmt();
200     inline const SwFrmFmt *GetRightFmt() const;
201     inline SwFrmFmt *GetLeftFmt();
202     inline const SwFrmFmt *GetLeftFmt() const;
203 
GetRegHeight() const204     sal_uInt16 GetRegHeight() const { return nRegHeight; }
GetRegAscent() const205     sal_uInt16 GetRegAscent() const { return nRegAscent; }
SetRegHeight(sal_uInt16 nNew)206     void SetRegHeight( sal_uInt16 nNew ){ nRegHeight = nNew; }
SetRegAscent(sal_uInt16 nNew)207     void SetRegAscent( sal_uInt16 nNew ){ nRegAscent = nNew; }
208 
209     inline void SetFollow( const SwPageDesc* pNew );
GetFollow() const210     const SwPageDesc* GetFollow() const { return pFollow; }
GetFollow()211           SwPageDesc* GetFollow() { return pFollow; }
212 
213     void SetRegisterFmtColl( const SwTxtFmtColl* rFmt );
214     const SwTxtFmtColl* GetRegisterFmtColl() const;
215     void RegisterChange();
216 
217     // erfragen und setzen der PoolFormat-Id
GetPoolFmtId() const218     sal_uInt16 GetPoolFmtId() const         { return aMaster.GetPoolFmtId(); }
SetPoolFmtId(sal_uInt16 nId)219     void SetPoolFmtId( sal_uInt16 nId )     { aMaster.SetPoolFmtId( nId ); }
GetPoolHelpId() const220     sal_uInt16 GetPoolHelpId() const        { return aMaster.GetPoolHelpId(); }
SetPoolHelpId(sal_uInt16 nId)221     void SetPoolHelpId( sal_uInt16 nId )    { aMaster.SetPoolHelpId( nId ); }
GetPoolHlpFileId() const222     sal_uInt8 GetPoolHlpFileId() const      { return aMaster.GetPoolHlpFileId(); }
SetPoolHlpFileId(sal_uInt8 nId)223     void SetPoolHlpFileId( sal_uInt8 nId )  { aMaster.SetPoolHlpFileId( nId ); }
224 
225         // erfrage vom Client Informationen
226     virtual sal_Bool GetInfo( SfxPoolItem& ) const;
227 
228     const SwFrmFmt* GetPageFmtOfNode( const SwNode& rNd,
229                                     sal_Bool bCheckForThisPgDc = sal_True ) const;
230     sal_Bool IsFollowNextPageOfNode( const SwNode& rNd ) const;
231 
232     //Given a SwNode return the pagedesc in use at that location.
233     static const SwPageDesc* GetPageDescOfNode(const SwNode& rNd);
234 
235     SwPageDesc& operator=( const SwPageDesc& );
236 
237     SwPageDesc( const SwPageDesc& );
238     ~SwPageDesc();
239 };
240 
SetFollow(const SwPageDesc * pNew)241 inline void SwPageDesc::SetFollow( const SwPageDesc* pNew )
242 {
243     pFollow = pNew ? (SwPageDesc*)pNew : this;
244 }
245 
IsHeaderShared() const246 inline sal_Bool SwPageDesc::IsHeaderShared() const
247 {
248     return eUse & nsUseOnPage::PD_HEADERSHARE ? sal_True : sal_False;
249 }
IsFooterShared() const250 inline sal_Bool SwPageDesc::IsFooterShared() const
251 {
252     return eUse & nsUseOnPage::PD_FOOTERSHARE ? sal_True : sal_False;
253 }
ChgHeaderShare(sal_Bool bNew)254 inline void SwPageDesc::ChgHeaderShare( sal_Bool bNew )
255 {
256     if ( bNew )
257         eUse = (UseOnPage) (eUse | nsUseOnPage::PD_HEADERSHARE);
258         // (sal_uInt16&)eUse |= (sal_uInt16)nsUseOnPage::PD_HEADERSHARE;
259     else
260         eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOHEADERSHARE);
261         // (sal_uInt16&)eUse &= (sal_uInt16)nsUseOnPage::PD_NOHEADERSHARE;
262 }
ChgFooterShare(sal_Bool bNew)263 inline void SwPageDesc::ChgFooterShare( sal_Bool bNew )
264 {
265     if ( bNew )
266         eUse = (UseOnPage) (eUse | nsUseOnPage::PD_FOOTERSHARE);
267         // (sal_uInt16&)eUse |= (sal_uInt16)nsUseOnPage::PD_FOOTERSHARE;
268     else
269         eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOFOOTERSHARE);
270         // (sal_uInt16&)eUse &= (sal_uInt16)nsUseOnPage::PD_NOFOOTERSHARE;
271 }
SetUseOn(UseOnPage eNew)272 inline void SwPageDesc::SetUseOn( UseOnPage eNew )
273 {
274     UseOnPage eTmp = nsUseOnPage::PD_NONE;
275     if ( eUse & nsUseOnPage::PD_HEADERSHARE )
276         eTmp = nsUseOnPage::PD_HEADERSHARE;
277         // (sal_uInt16&)eTmp |= (sal_uInt16)nsUseOnPage::PD_HEADERSHARE;
278     if ( eUse & nsUseOnPage::PD_FOOTERSHARE )
279         eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FOOTERSHARE);
280         // (sal_uInt16&)eTmp |= (sal_uInt16)nsUseOnPage::PD_FOOTERSHARE;
281     eUse = (UseOnPage) (eTmp | eNew);
282     // (sal_uInt16&)eUse = eTmp | eNew;
283 }
GetUseOn() const284 inline UseOnPage SwPageDesc::GetUseOn() const
285 {
286     UseOnPage eRet = eUse;
287     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOHEADERSHARE);
288     // (sal_uInt16&)eRet &= (sal_uInt16)nsUseOnPage::PD_NOHEADERSHARE;
289     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFOOTERSHARE);
290     // (sal_uInt16&)eRet &= (sal_uInt16)nsUseOnPage::PD_NOFOOTERSHARE;
291     return eRet;
292 }
293 
ResetAllMasterAttr()294 inline void SwPageDesc::ResetAllMasterAttr()
295 {
296     ResetAllAttr( sal_False );
297 }
298 
ResetAllLeftAttr()299 inline void SwPageDesc::ResetAllLeftAttr()
300 {
301     ResetAllAttr( sal_True );
302 }
303 
GetRightFmt()304 inline SwFrmFmt *SwPageDesc::GetRightFmt()
305 {
306     return nsUseOnPage::PD_RIGHT & eUse ? &aMaster : 0;
307 }
GetRightFmt() const308 inline const SwFrmFmt *SwPageDesc::GetRightFmt() const
309 {
310     return nsUseOnPage::PD_RIGHT & eUse ? &aMaster : 0;
311 }
GetLeftFmt()312 inline SwFrmFmt *SwPageDesc::GetLeftFmt()
313 {
314     return nsUseOnPage::PD_LEFT & eUse ? &aLeft : 0;
315 }
GetLeftFmt() const316 inline const SwFrmFmt *SwPageDesc::GetLeftFmt() const
317 {
318     return nsUseOnPage::PD_LEFT & eUse ? &aLeft : 0;
319 }
320 
321 class SwPageDescExt
322 {
323     SwPageDesc aPageDesc;
324     SwDoc * pDoc;
325     String sFollow;
326 
327     void SetPageDesc(const SwPageDesc & aPageDesc);
328 
329 public:
330     SwPageDescExt(const SwPageDesc & rPageDesc, SwDoc * pDoc);
331     SwPageDescExt(const SwPageDescExt & rSrc);
332     ~SwPageDescExt();
333 
334     SwPageDescExt & operator = (const SwPageDescExt & rSrc);
335     SwPageDescExt & operator = (const SwPageDesc & rSrc);
336 
337     const String & GetName() const;
338 
339     operator SwPageDesc() const; // #i7983#
340 };
341 
342 
343 SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName);
344 
345 #endif  //_PAGEDESC_HXX
346