LibreOffice Module sw (master)  1
format.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef INCLUDED_SW_INC_FORMAT_HXX
20 #define INCLUDED_SW_INC_FORMAT_HXX
21 
22 #include "swdllapi.h"
23 #include "swatrset.hxx"
24 #include "calbck.hxx"
25 #include <memory>
26 
33 class SwDoc;
34 class SfxGrabBagItem;
35 class SwTextGridItem;
36 
37 namespace drawinglayer { namespace attribute {
39  typedef std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr;
40 }}
41 
44 {
45  friend class SwFrameFormat;
46 
47  OUString m_aFormatName;
49 
50  sal_uInt16 m_nWhichId;
51  sal_uInt16 m_nPoolFormatId;
53  sal_uInt16 m_nPoolHelpId;
55  bool m_bAutoFormat : 1;
57  bool m_bFormatInDTOR : 1;
61  bool m_bHidden : 1;
62  std::shared_ptr<SfxGrabBagItem> m_pGrabBagItem;
63 
64 protected:
65  SwFormat( SwAttrPool& rPool, const sal_Char* pFormatNm,
66  const sal_uInt16* pWhichRanges, SwFormat *pDrvdFrame, sal_uInt16 nFormatWhich );
67  SwFormat( SwAttrPool& rPool, const OUString &rFormatNm, const sal_uInt16* pWhichRanges,
68  SwFormat *pDrvdFrame, sal_uInt16 nFormatWhich );
69  SwFormat( const SwFormat& rFormat );
70  virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue ) override;
71 
72 public:
73 
74  virtual ~SwFormat() override;
75  SwFormat &operator=(const SwFormat&);
76 
78  sal_uInt16 Which() const { return m_nWhichId; }
79 
81  void CopyAttrs( const SwFormat& );
82 
84  void DelDiffs( const SfxItemSet& rSet );
85  void DelDiffs( const SwFormat& rFormat ) { DelDiffs( rFormat.GetAttrSet() ); }
86 
88  bool SetDerivedFrom(SwFormat *pDerivedFrom = nullptr);
89 
91  const SfxPoolItem& GetFormatAttr( sal_uInt16 nWhich,
92  bool bInParents = true ) const;
93  template<class T> const T& GetFormatAttr( TypedWhichId<T> nWhich, bool bInParents = true ) const
94  {
95  return static_cast<const T&>(GetFormatAttr(sal_uInt16(nWhich), bInParents));
96  }
97  SfxItemState GetItemState( sal_uInt16 nWhich, bool bSrchInParent = true,
98  const SfxPoolItem **ppItem = nullptr ) const;
99  SfxItemState GetBackgroundState(std::shared_ptr<SvxBrushItem>& rItem) const;
100  virtual bool SetFormatAttr( const SfxPoolItem& rAttr );
101  virtual bool SetFormatAttr( const SfxItemSet& rSet );
102  virtual bool ResetFormatAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
103 
106  virtual sal_uInt16 ResetAllFormatAttr();
107 
108  SwFormat* DerivedFrom() const { return const_cast<SwFormat*>(static_cast<const SwFormat*>(GetRegisteredIn())); }
109  bool IsDefault() const { return DerivedFrom() == nullptr; }
110 
111  const OUString& GetName() const { return m_aFormatName; }
112  bool HasName(const OUString &rName) const { return m_aFormatName == rName; }
113  virtual void SetName( const OUString& rNewName, bool bBroadcast=false );
114 
116  const SwAttrSet& GetAttrSet() const { return m_aSet; }
117 
119  const SwDoc *GetDoc() const { return m_aSet.GetDoc(); }
120  SwDoc *GetDoc() { return m_aSet.GetDoc(); }
121 
124 
128 
132 
135 
138 
141 
143  sal_uInt16 GetPoolFormatId() const { return m_nPoolFormatId; }
144  void SetPoolFormatId( sal_uInt16 nId ) { m_nPoolFormatId = nId; }
145 
147  sal_uInt16 GetPoolHelpId() const { return m_nPoolHelpId; }
148  void SetPoolHelpId( sal_uInt16 nId ) { m_nPoolHelpId = nId; }
150  void SetPoolHlpFileId( sal_uInt8 nId ) { m_nPoolHlpFileId = nId; }
151 
154  MapUnit eCoreMetric, MapUnit ePresMetric, OUString &rText ) const
155  { m_aSet.GetPresentation( ePres, eCoreMetric, ePresMetric, rText ); }
156 
158  bool IsAuto() const { return m_bAutoFormat; }
159  void SetAuto( bool bNew ) { m_bAutoFormat = bNew; }
160 
161  bool IsHidden() const { return m_bHidden; }
162  void SetHidden( bool bValue ) { m_bHidden = bValue; }
163 
164  void GetGrabBagItem(css::uno::Any& rVal) const;
165  void SetGrabBagItem(const css::uno::Any& rVal);
166 
168  bool IsAutoUpdateFormat() const { return m_bAutoUpdateFormat; }
169  void SetAutoUpdateFormat( bool bNew = true ) { m_bAutoUpdateFormat = bNew; }
170 
171  bool IsFormatInDTOR() const { return m_bFormatInDTOR; }
172 
177  inline const SvxUnderlineItem &GetUnderline( bool = true ) const;
179  inline const SvxFontHeightItem &GetSize( bool = true ) const;
180  inline const SvxFontItem &GetFont( bool = true ) const;
181  inline const SvxColorItem &GetColor( bool = true ) const;
182  inline const SvxFontItem &GetCJKFont( bool = true ) const;
183  inline const SvxFontItem &GetCTLFont( bool = true ) const;
184 
186  inline const SwFormatFillOrder &GetFillOrder( bool = true ) const;
187  inline const SwFormatFrameSize &GetFrameSize( bool = true ) const;
188  inline const SwFormatHeader &GetHeader( bool = true ) const;
189  inline const SwFormatFooter &GetFooter( bool = true ) const;
190  inline const SwFormatSurround &GetSurround( bool = true ) const;
191  inline const SwFormatHoriOrient &GetHoriOrient( bool = true ) const;
192  inline const SwFormatAnchor &GetAnchor( bool = true ) const;
193  inline const SwFormatCol &GetCol( bool = true ) const;
194  inline const SvxPaperBinItem &GetPaperBin( bool = true ) const;
195  inline const SvxLRSpaceItem &GetLRSpace( bool = true ) const;
196  inline const SvxULSpaceItem &GetULSpace( bool = true ) const;
197  inline const SwFormatContent &GetContent( bool = true ) const;
198  inline const SvxPrintItem &GetPrint( bool = true ) const;
199  inline const SvxOpaqueItem &GetOpaque( bool = true ) const;
200  inline const SvxProtectItem &GetProtect( bool = true ) const;
201  inline const SwFormatVertOrient &GetVertOrient( bool = true ) const;
202  inline const SvxBoxItem &GetBox( bool = true ) const;
203  inline const SvxFormatKeepItem &GetKeep( bool = true ) const;
204 
205  // Create SvxBrushItem for Background fill (partially for backwards compatibility)
206  std::shared_ptr<SvxBrushItem> makeBackgroundBrushItem( bool = true ) const;
207 
208  inline const SvxShadowItem &GetShadow( bool = true ) const;
209  inline const SwFormatPageDesc &GetPageDesc( bool = true ) const;
210  inline const SvxFormatBreakItem &GetBreak( bool = true ) const;
211  inline const SvxMacroItem &GetMacro( bool = true ) const;
212  inline const SwFormatURL &GetURL( bool = true ) const;
213  inline const SwFormatEditInReadonly &GetEditInReadonly( bool = true ) const;
214  inline const SwFormatLayoutSplit &GetLayoutSplit( bool = true ) const;
215  inline const SwFormatRowSplit &GetRowSplit( bool = true ) const;
216  inline const SwFormatChain &GetChain( bool = true ) const;
217  inline const SwFormatFootnoteAtTextEnd &GetFootnoteAtTextEnd( bool = true ) const;
218  inline const SwFormatEndAtTextEnd &GetEndAtTextEnd( bool = true ) const;
219  inline const SwFormatNoBalancedColumns &GetBalancedColumns( bool = true ) const;
220  inline const SvxFrameDirectionItem &GetFrameDir( bool = true ) const;
221  inline const SwTextGridItem &GetTextGrid( bool = true ) const;
222  inline const SwHeaderAndFooterEatSpacingItem &GetHeaderAndFooterEatSpacing( bool = true ) const;
223  // #i18732#
224  inline const SwFormatFollowTextFlow &GetFollowTextFlow(bool = true) const;
225  // #i28701#
226  inline const SwFormatWrapInfluenceOnObjPos& GetWrapInfluenceOnObjPos(bool = true) const;
227  inline const SdrTextVertAdjustItem& GetTextVertAdjust(bool = true) const;
228 
230  inline const SvxLineSpacingItem &GetLineSpacing( bool = true ) const;
231  inline const SwNumRuleItem &GetNumRule( bool = true ) const;
232  inline const SvxTabStopItem &GetTabStops( bool = true ) const;
233  inline const SwFormatDrop &GetDrop( bool = true ) const;
234 
236  inline const SwTableBoxNumFormat &GetTableBoxNumFormat( bool = true ) const;
237  inline const SwTableBoxFormula &GetTableBoxFormula( bool = true ) const;
238  inline const SwTableBoxValue &GetTableBoxValue( bool = true ) const;
239 
248  virtual bool IsBackgroundTransparent() const;
249 
250  // Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
252  virtual bool supportsFullDrawingLayerFillAttributeSet() const;
253 };
254 
255 #endif // INCLUDED_SW_INC_FORMAT_HXX
256 
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
BroadcasterMixin & operator=(const BroadcasterMixin &)
Definition: calbck.hxx:89
const SwTableBoxNumFormat & GetTableBoxNumFormat(bool=true) const
TableBox attributes - implemented in cellatr.hxx.
Definition: cellatr.hxx:105
const SvxColorItem & GetColor(bool=true) const
Definition: charatr.hxx:131
sal_uInt16 m_nPoolFormatId
Id for "automatically" created formats.
Definition: format.hxx:51
const SvxTabStopItem & GetTabStops(bool=true) const
Definition: paratr.hxx:214
const SwFormatCol & GetCol(bool=true) const
Definition: fmtclds.hxx:168
const SwFormatLayoutSplit & GetLayoutSplit(bool=true) const
Definition: fmtlsplt.hxx:46
void DelDiffs(const SwFormat &rFormat)
Definition: format.hxx:85
const SvxUnderlineItem & GetUnderline(bool=true) const
GetMethods: Bool indicates whether to search only in Set (FALSE) or also in Parents.
Definition: charatr.hxx:121
sal_uInt16 m_nWhichId
Definition: format.hxx:50
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
SwDoc * GetDoc()
Definition: format.hxx:120
const SwTextGridItem & GetTextGrid(bool=true) const
Definition: tgrditem.hxx:112
bool IsDefault() const
Definition: format.hxx:109
void SetPoolHelpId(sal_uInt16 nId)
Definition: format.hxx:148
const SwFormatHeader & GetHeader(bool=true) const
Definition: fmthdft.hxx:97
bool IsHidden() const
Definition: format.hxx:161
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
OUString m_aFormatName
Definition: format.hxx:47
const SvxFrameDirectionItem & GetFrameDir(bool=true) const
Definition: frmatr.hxx:94
Handle the background jobs of a Writer document.
const SvxFontItem & GetFont(bool=true) const
Definition: charatr.hxx:125
If text in multi-column sections should be evenly distributed.
Definition: fmtclbl.hxx:28
Definition: doc.hxx:185
void DelDiffs(const SfxItemSet &rSet)
Delete all attributes that are not in rFormat.
Definition: format.cxx:711
virtual ~SwFormat() override
Definition: format.cxx:214
const SdrTextVertAdjustItem & GetTextVertAdjust(bool=true) const
Definition: frmatr.hxx:96
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:31
const SvxLineSpacingItem & GetLineSpacing(bool=true) const
Paragraph-attributes - implemented in paratr.hxx.
Definition: paratr.hxx:212
SwAttrSet m_aSet
Definition: format.hxx:48
IDocumentChartDataProviderAccess & getIDocumentChartDataProviderAccess()
Gives access to the chart data-provider.
Definition: format.cxx:764
IDocumentTimerAccess & getIDocumentTimerAccess()
Provides access to the document idle timer interface.
Definition: format.cxx:762
const SvxFontItem & GetCJKFont(bool=true) const
Definition: charatr.hxx:127
const SvxBoxItem & GetBox(bool=true) const
Definition: frmatr.hxx:84
const SwFormatEditInReadonly & GetEditInReadonly(bool=true) const
Definition: fmteiro.hxx:48
const SwFormatNoBalancedColumns & GetBalancedColumns(bool=true) const
Definition: fmtclbl.hxx:42
void SetPoolFormatId(sal_uInt16 nId)
Definition: format.hxx:144
std::shared_ptr< SfxGrabBagItem > m_pGrabBagItem
Style InteropGrabBag.
Definition: format.hxx:62
sal_uInt16 m_nPoolHelpId
HelpId for this Pool-style.
Definition: format.hxx:53
char sal_Char
const OUString & GetName() const
Definition: format.hxx:111
Footer, for pageformats Client of FrameFormat describing the footer.
Definition: fmthdft.hxx:64
const SvxPrintItem & GetPrint(bool=true) const
Definition: frmatr.hxx:78
void SetPoolHlpFileId(sal_uInt8 nId)
Definition: format.hxx:150
virtual void SetName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2464
std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr
Definition: format.hxx:38
const SwFormatFootnoteAtTextEnd & GetFootnoteAtTextEnd(bool=true) const
Definition: fmtftntx.hxx:111
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
const SvxFormatKeepItem & GetKeep(bool=true) const
Definition: frmatr.hxx:86
const SvxMacroItem & GetMacro(bool=true) const
Definition: frmatr.hxx:92
sal_uInt8 m_nPoolHlpFileId
FilePos to Doc to these style helps.
Definition: format.hxx:54
const SwFormatFillOrder & GetFillOrder(bool=true) const
Frame-attributes - implemented in frmatr.hxx.
Definition: fmtfordr.hxx:49
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:326
const SvxFontHeightItem & GetSize(bool=true) const
Definition: charatr.hxx:123
sal_uInt16 GetPoolFormatId() const
Get and set Pool style IDs.
Definition: format.hxx:143
virtual sal_uInt16 ResetAllFormatAttr()
Takes all hints from Delta-Array,.
Definition: format.cxx:683
Base class for various Writer styles.
Definition: format.hxx:43
IDocumentFieldsAccess & getIDocumentFieldsAccess()
Provides access to the document idle timer interface.
Definition: format.cxx:763
SwFormat(SwAttrPool &rPool, const sal_Char *pFormatNm, const sal_uInt16 *pWhichRanges, SwFormat *pDrvdFrame, sal_uInt16 nFormatWhich)
Definition: format.cxx:39
bool IsFormatInDTOR() const
Definition: format.hxx:171
const SwFormatFollowTextFlow & GetFollowTextFlow(bool=true) const
Style of a layout element.
Definition: frmfmt.hxx:57
SfxItemPresentation
bool m_bHidden
Definition: format.hxx:61
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
const SwFormatDrop & GetDrop(bool=true) const
Definition: paratr.hxx:216
const IDocumentLayoutAccess & getIDocumentLayoutAccess() const
Provides access to the document layout interface.
Definition: format.cxx:760
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
void SetAuto(bool bNew)
Definition: format.hxx:159
Document fields related interfaces.
void SetHidden(bool bValue)
Definition: format.hxx:162
FlyAnchors.
Definition: fmtanchr.hxx:34
const SwFormatURL & GetURL(bool=true) const
Definition: fmturl.hxx:78
sal_uInt8 GetPoolHlpFileId() const
Definition: format.hxx:149
std::shared_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:782
const SwFormatFooter & GetFooter(bool=true) const
Definition: fmthdft.hxx:99
void GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString &rText) const
Get attribute-description. Returns passed string.
Definition: format.hxx:153
Provides access to settings of a document.
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:396
Connection (text flow) between two FlyFrames.
Definition: fmtcnct.hxx:31
const SvxFormatBreakItem & GetBreak(bool=true) const
Definition: frmatr.hxx:90
bool IsAutoUpdateFormat() const
Query / set bAutoUpdateFormat-flag.
Definition: format.hxx:168
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document settings interface.
Definition: format.cxx:757
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
const SwFormatEndAtTextEnd & GetEndAtTextEnd(bool=true) const
Definition: fmtftntx.hxx:113
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override
Definition: calbck.hxx:183
void SetGrabBagItem(const css::uno::Any &rVal)
Definition: format.cxx:774
SfxItemState GetBackgroundState(std::shared_ptr< SvxBrushItem > &rItem) const
Definition: format.cxx:430
virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const override
Definition: atrfrm.cxx:3495
void GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString &rText) const
Definition: attrdesc.cxx:65
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:458
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:78
const SwTableBoxValue & GetTableBoxValue(bool=true) const
Definition: cellatr.hxx:109
SwFormat * DerivedFrom() const
Definition: format.hxx:108
const SvxULSpaceItem & GetULSpace(bool=true) const
Definition: frmatr.hxx:76
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:650
bool m_bAutoUpdateFormat
TRUE: Set attributes of a whole paragraph at format (UI-side!).
Definition: format.hxx:59
SfxItemState
const SwFormatChain & GetChain(bool=true) const
Definition: fmtcnct.hxx:70
const SvxOpaqueItem & GetOpaque(bool=true) const
Definition: frmatr.hxx:80
sal_uInt16 GetPoolHelpId() const
Get and set Help-IDs for document templates.
Definition: format.hxx:147
void CopyAttrs(const SwFormat &)
Copy attributes even among documents.
Definition: format.cxx:178
unsigned char sal_uInt8
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: format.cxx:766
const SwDoc * GetDoc() const
Definition: swatrset.hxx:204
bool m_bFormatInDTOR
TRUE: Format becomes deleted.
Definition: format.hxx:57
const SvxPaperBinItem & GetPaperBin(bool=true) const
Definition: frmatr.hxx:72
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:157
const SfxPoolItem & GetFormatAttr(sal_uInt16 nWhich, bool bInParents=true) const
If bInParents is FALSE, search only in this format for attribute.
Definition: format.cxx:377
const SvxFontItem & GetCTLFont(bool=true) const
Definition: charatr.hxx:129
const SwFormatRowSplit & GetRowSplit(bool=true) const
Definition: fmtrowsplt.hxx:46
virtual bool supportsFullDrawingLayerFillAttributeSet() const override
Definition: atrfrm.cxx:2502
const SwFormatWrapInfluenceOnObjPos & GetWrapInfluenceOnObjPos(bool=true) const
Header, for PageFormats Client of FrameFormat describing the header.
Definition: fmthdft.hxx:33
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
bool HasName(const OUString &rName) const
Definition: format.hxx:112
const SwHeaderAndFooterEatSpacingItem & GetHeaderAndFooterEatSpacing(bool=true) const
Provides access to the layout of a document.
MapUnit
const SvxProtectItem & GetProtect(bool=true) const
Definition: frmatr.hxx:82
bool m_bAutoFormat
FALSE: it is a template.
Definition: format.hxx:55
Give access to the data-provider for chart.
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps...
Definition: paratr.hxx:50
const T & GetFormatAttr(TypedWhichId< T > nWhich, bool bInParents=true) const
Definition: format.hxx:93
const SwFormatPageDesc & GetPageDesc(bool=true) const
Definition: fmtpdsc.hxx:79
virtual bool IsBackgroundTransparent() const
SwFormat::IsBackgroundTransparent.
Definition: format.cxx:749
SwNumRule * GetNumRule(SwTextFormatColl &rTextFormatColl)
determines the list style, which directly set at the given paragraph style
Definition: fmtcol.cxx:75
bool IsAuto() const
Query / set AutoFormat-flag.
Definition: format.hxx:158
const IDocumentDrawModelAccess & getIDocumentDrawModelAccess() const
Provides access to the document draw model interface.
Definition: format.cxx:758
const SvxLRSpaceItem & GetLRSpace(bool=true) const
Definition: frmatr.hxx:74
const SwTableBoxFormula & GetTableBoxFormula(bool=true) const
Definition: cellatr.hxx:107
const SvxShadowItem & GetShadow(bool=true) const
Definition: frmatr.hxx:88
void SetAutoUpdateFormat(bool bNew=true)
Definition: format.hxx:169