update emoji autocorrect entries from po-files
[LibreOffice.git] / sw / inc / pagedesc.hxx
blob5bdb73884dbf64f0a10ab976ba6cd81e8bb97925
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #ifndef INCLUDED_SW_INC_PAGEDESC_HXX
20 #define INCLUDED_SW_INC_PAGEDESC_HXX
22 #include <tools/fract.hxx>
23 #include <tools/color.hxx>
24 #include "swdllapi.h"
25 #include <swtypes.hxx>
26 #include <frmfmt.hxx>
27 #include <editeng/numitem.hxx>
28 #include <editeng/borderline.hxx>
30 class SfxPoolItem;
31 class SwTextFormatColl;
32 class SwNode;
34 /// Separator line adjustment.
35 enum SwFootnoteAdj
37 FTNADJ_LEFT,
38 FTNADJ_CENTER,
39 FTNADJ_RIGHT
42 /// Footnote information.
43 class SW_DLLPUBLIC SwPageFootnoteInfo
45 private:
46 SwTwips m_nMaxHeight; ///< maximum height of the footnote area.
47 sal_uLong m_nLineWidth; ///< width of separator line
48 editeng::SvxBorderStyle m_eLineStyle; ///< Style of the separator line
49 Color m_LineColor; ///< color of the separator line
50 Fraction m_Width; ///< percentage width of the separator line.
51 SwFootnoteAdj m_eAdjust; ///< line adjustment.
52 SwTwips m_nTopDist; ///< distance between body and separator.
53 SwTwips m_nBottomDist; ///< distance between separator and first footnote
55 public:
56 SwTwips GetHeight() const { return m_nMaxHeight; }
57 sal_uLong GetLineWidth() const { return m_nLineWidth; }
58 const Color& GetLineColor() const { return m_LineColor;}
59 editeng::SvxBorderStyle GetLineStyle() const { return m_eLineStyle; }
60 const Fraction& GetWidth() const { return m_Width; }
61 SwFootnoteAdj GetAdj() const { return m_eAdjust; }
62 SwTwips GetTopDist() const { return m_nTopDist; }
63 SwTwips GetBottomDist() const { return m_nBottomDist; }
65 void SetHeight(SwTwips const nNew) { m_nMaxHeight = nNew; }
66 void SetLineWidth(sal_uLong const nSet) { m_nLineWidth = nSet; }
67 void SetLineStyle(editeng::SvxBorderStyle const eSet) {m_eLineStyle = eSet;}
68 void SetLineColor(const Color& rCol) { m_LineColor = rCol;}
69 void SetWidth(const Fraction & rNew) { m_Width = rNew; }
70 void SetAdj(SwFootnoteAdj const eNew) { m_eAdjust = eNew; }
71 void SetTopDist (SwTwips const nNew) { m_nTopDist = nNew; }
72 void SetBottomDist(SwTwips const nNew) { m_nBottomDist = nNew; }
74 SwPageFootnoteInfo();
75 SwPageFootnoteInfo( const SwPageFootnoteInfo& );
76 SwPageFootnoteInfo& operator=( const SwPageFootnoteInfo& );
78 bool operator ==( const SwPageFootnoteInfo& ) const;
82 * Use of UseOnPage (m_eUse) and of FrameFormats
84 * RIGHT - m_Master only for right hand (odd) pages, left hand (even) pages
85 * always empty.
86 * LEFT - m_Left for left-hand pages, right-hand pages always empty.
87 * m_Left is a copy of master.
88 * ALL - m_Master for right hand pages, m_Left for left hand pages.
89 * - m_Left is a copy of master.
90 * MIRROR - m_Master for right hand pages, m_Left for left hand pagers.
91 * m_Left is a copy of master, margins are mirrored.
93 * UI works exclusively on master! m_Left is adjusted on Chg at document
94 * according to m_eUse.
96 * In order to simplify the work of the filters some more values are placed
97 * into m_eUse:
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 m_eUse including the information on header and footer
104 * via ReadUseOn(), WriteUseOn() (for Filter and 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-
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).
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
133 friend class SwDoc;
135 OUString m_StyleName;
136 SvxNumberType m_NumType;
137 SwFrameFormat m_Master;
138 SwFrameFormat m_Left;
139 // FIXME epicycles growing here - page margins need to be stored differently
140 SwFrameFormat m_FirstMaster;
141 SwFrameFormat m_FirstLeft;
142 SwDepend m_Depend; ///< Because of grid alignment (Registerhaltigkeit).
143 SwPageDesc *m_pFollow;
144 sal_uInt16 m_nRegHeight; ///< Sentence spacing and fontascent of style.
145 sal_uInt16 m_nRegAscent; ///< For grid alignment (Registerhaltigkeit).
146 UseOnPage m_eUse;
147 bool m_IsLandscape;
148 bool m_IsHidden;
150 /// Footnote information.
151 SwPageFootnoteInfo m_IsFootnoteInfo;
153 /** Called for mirroring of Chg (doc).
154 No adjustment at any other place. */
155 SAL_DLLPRIVATE void Mirror();
157 SAL_DLLPRIVATE void ResetAllAttr( bool bLeft );
159 SAL_DLLPRIVATE SwPageDesc(const OUString&, SwFrameFormat*, SwDoc *pDc );
161 protected:
162 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNewValue ) SAL_OVERRIDE;
164 public:
165 OUString GetName() const { return m_StyleName; }
166 bool HasName(const OUString& rThisName) const { return m_StyleName == rThisName; }
167 void SetName(const OUString& rNewName) { m_StyleName = rNewName; }
169 bool GetLandscape() const { return m_IsLandscape; }
170 void SetLandscape( bool bNew ) { m_IsLandscape = bNew; }
172 const SvxNumberType &GetNumType() const { return m_NumType; }
173 void SetNumType(const SvxNumberType& rNew) { m_NumType = rNew; }
175 const SwPageFootnoteInfo &GetFootnoteInfo() const { return m_IsFootnoteInfo; }
176 SwPageFootnoteInfo &GetFootnoteInfo() { return m_IsFootnoteInfo; }
177 void SetFootnoteInfo(const SwPageFootnoteInfo &rNew) { m_IsFootnoteInfo = rNew; }
179 inline bool IsHeaderShared() const;
180 inline bool IsFooterShared() const;
181 inline void ChgHeaderShare( bool bNew );
182 inline void ChgFooterShare( bool bNew );
183 bool IsFirstShared() const;
184 void ChgFirstShare( bool bNew );
186 bool IsHidden() const { return m_IsHidden; }
187 void SetHidden(bool const bValue) { m_IsHidden = bValue; }
189 inline void SetUseOn( UseOnPage eNew );
190 inline UseOnPage GetUseOn() const;
192 void WriteUseOn(UseOnPage const eNew) { m_eUse = eNew; }
193 UseOnPage ReadUseOn() const { return m_eUse; }
195 SwFrameFormat &GetMaster() { return m_Master; }
196 SwFrameFormat &GetLeft() { return m_Left; }
197 SwFrameFormat &GetFirstMaster() { return m_FirstMaster; }
198 SwFrameFormat &GetFirstLeft() { return m_FirstLeft; }
199 const SwFrameFormat &GetMaster() const { return m_Master; }
200 const SwFrameFormat &GetLeft() const { return m_Left; }
201 const SwFrameFormat &GetFirstMaster() const { return m_FirstMaster; }
202 const SwFrameFormat &GetFirstLeft() const { return m_FirstLeft; }
204 /** Reset all attrs of the format but keep the ones a pagedesc
205 cannot live without. */
206 inline void ResetAllMasterAttr();
207 inline void ResetAllLeftAttr();
209 /** Layout uses the following methods to obtain a format in order
210 to be able to create a page. */
211 SwFrameFormat *GetRightFormat(bool const bFirst = false);
212 inline const SwFrameFormat *GetRightFormat(bool const bFirst = false) const;
213 SwFrameFormat *GetLeftFormat(bool const bFirst = false);
214 inline const SwFrameFormat *GetLeftFormat(bool const bFirst = false) const;
216 sal_uInt16 GetRegHeight() const { return m_nRegHeight; }
217 sal_uInt16 GetRegAscent() const { return m_nRegAscent; }
218 void SetRegHeight(sal_uInt16 const nNew) { m_nRegHeight = nNew; }
219 void SetRegAscent(sal_uInt16 const nNew) { m_nRegAscent = nNew; }
221 inline void SetFollow( const SwPageDesc* pNew );
222 const SwPageDesc* GetFollow() const { return m_pFollow; }
223 SwPageDesc* GetFollow() { return m_pFollow; }
225 void SetRegisterFormatColl( const SwTextFormatColl* rFormat );
226 const SwTextFormatColl* GetRegisterFormatColl() const;
227 void RegisterChange();
229 /// Query and set PoolFormat-Id.
230 sal_uInt16 GetPoolFormatId() const { return m_Master.GetPoolFormatId(); }
231 void SetPoolFormatId(sal_uInt16 const nId) { m_Master.SetPoolFormatId(nId); }
232 sal_uInt16 GetPoolHelpId() const { return m_Master.GetPoolHelpId(); }
233 void SetPoolHelpId(sal_uInt16 const nId){ m_Master.SetPoolHelpId(nId); }
234 sal_uInt8 GetPoolHlpFileId() const { return m_Master.GetPoolHlpFileId(); }
235 void SetPoolHlpFileId(sal_uInt8 const nId) { m_Master.SetPoolHlpFileId(nId); }
237 /// Query information from Client.
238 virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE;
240 const SwFrameFormat* GetPageFormatOfNode( const SwNode& rNd,
241 bool bCheckForThisPgDc = true ) const;
242 bool IsFollowNextPageOfNode( const SwNode& rNd ) const;
244 /// Given a SwNode return the pagedesc in use at that location.
245 static const SwPageDesc* GetPageDescOfNode(const SwNode& rNd);
247 static SwPageDesc* GetByName(SwDoc& rDoc, const OUString& rName);
249 SwPageDesc& operator=( const SwPageDesc& );
251 SwPageDesc( const SwPageDesc& );
252 virtual ~SwPageDesc();
255 inline void SwPageDesc::SetFollow( const SwPageDesc* pNew )
257 m_pFollow = pNew ? const_cast<SwPageDesc*>(pNew) : this;
260 inline bool SwPageDesc::IsHeaderShared() const
262 return (m_eUse & nsUseOnPage::PD_HEADERSHARE) != 0;
264 inline bool SwPageDesc::IsFooterShared() const
266 return (m_eUse & nsUseOnPage::PD_FOOTERSHARE) != 0;
268 inline void SwPageDesc::ChgHeaderShare( bool bNew )
270 if ( bNew )
271 m_eUse = (UseOnPage) (m_eUse | nsUseOnPage::PD_HEADERSHARE);
272 else
273 m_eUse = (UseOnPage) (m_eUse & nsUseOnPage::PD_NOHEADERSHARE);
275 inline void SwPageDesc::ChgFooterShare( bool bNew )
277 if ( bNew )
278 m_eUse = (UseOnPage) (m_eUse | nsUseOnPage::PD_FOOTERSHARE);
279 else
280 m_eUse = (UseOnPage) (m_eUse & nsUseOnPage::PD_NOFOOTERSHARE);
282 inline void SwPageDesc::SetUseOn( UseOnPage eNew )
284 UseOnPage eTmp = nsUseOnPage::PD_NONE;
285 if (m_eUse & nsUseOnPage::PD_HEADERSHARE)
286 eTmp = nsUseOnPage::PD_HEADERSHARE;
287 if (m_eUse & nsUseOnPage::PD_FOOTERSHARE)
288 eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FOOTERSHARE);
289 if (m_eUse & nsUseOnPage::PD_FIRSTSHARE)
290 eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FIRSTSHARE);
291 m_eUse = (UseOnPage) (eTmp | eNew);
294 inline UseOnPage SwPageDesc::GetUseOn() const
296 UseOnPage eRet = m_eUse;
297 eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOHEADERSHARE);
298 eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFOOTERSHARE);
299 eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFIRSTSHARE);
300 return eRet;
303 inline void SwPageDesc::ResetAllMasterAttr()
305 ResetAllAttr( false );
308 inline void SwPageDesc::ResetAllLeftAttr()
310 ResetAllAttr( true );
313 inline const SwFrameFormat *SwPageDesc::GetRightFormat(bool const bFirst) const
315 return const_cast<SwPageDesc*>(this)->GetRightFormat(bFirst);
317 inline const SwFrameFormat *SwPageDesc::GetLeftFormat(bool const bFirst) const
319 return const_cast<SwPageDesc*>(this)->GetLeftFormat(bFirst);
322 class SwPageDescExt
324 public:
325 SwPageDesc m_PageDesc;
326 private:
327 SwDoc * m_pDoc;
328 OUString m_sFollow;
330 void SetPageDesc(const SwPageDesc & rPageDesc);
332 public:
333 SwPageDescExt(const SwPageDesc & rPageDesc, SwDoc * pDoc);
334 SwPageDescExt(const SwPageDescExt & rSrc);
335 ~SwPageDescExt();
337 SwPageDescExt & operator = (const SwPageDescExt & rSrc);
338 SwPageDescExt & operator = (const SwPageDesc & rSrc);
340 OUString GetName() const;
342 operator SwPageDesc() const; // #i7983#
345 namespace sw {
346 class PageFootnoteHint SAL_FINAL : public SfxHint {};
349 #endif // INCLUDED_SW_INC_PAGEDESC_HXX
351 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */