1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_FORMAT_HXX
20 #define INCLUDED_SW_INC_FORMAT_HXX
23 #include "swatrset.hxx"
27 class IDocumentSettingAccess
;
28 class IDocumentDrawModelAccess
;
29 class IDocumentLayoutAccess
;
30 class IDocumentTimerAccess
;
31 class IDocumentFieldsAccess
;
32 class IDocumentChartDataProviderAccess
;
37 namespace drawinglayer
{ namespace attribute
{
38 class SdrAllFillAttributesHelper
;
39 typedef std::shared_ptr
< SdrAllFillAttributesHelper
> SdrAllFillAttributesHelperPtr
;
42 /// Base class for various Writer styles.
43 class SW_DLLPUBLIC SwFormat
: public sw::BroadcastingModify
45 friend class SwFrameFormat
;
47 OUString m_aFormatName
;
50 sal_uInt16 m_nWhichId
;
51 sal_uInt16 m_nPoolFormatId
; /**< Id for "automatically" created formats.
52 (is not hard attribution!!!) */
53 sal_uInt16 m_nPoolHelpId
; ///< HelpId for this Pool-style.
54 sal_uInt8 m_nPoolHlpFileId
; ///< FilePos to Doc to these style helps.
55 bool m_bAutoFormat
: 1; /**< FALSE: it is a template.
57 bool m_bFormatInDTOR
: 1; /**< TRUE: Format becomes deleted. In order to be able
58 to recognize this in FormatChg-message!! */
59 bool m_bAutoUpdateFormat
: 1;/**< TRUE: Set attributes of a whole paragraph
60 at format (UI-side!). */
62 std::shared_ptr
<SfxGrabBagItem
> m_pGrabBagItem
; ///< Style InteropGrabBag.
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
;
74 virtual ~SwFormat() override
;
75 SwFormat
&operator=(const SwFormat
&);
77 /// for Querying of Writer-functions.
78 sal_uInt16
Which() const { return m_nWhichId
; }
80 /// Copy attributes even among documents.
81 void CopyAttrs( const SwFormat
& );
83 /// Delete all attributes that are not in rFormat.
84 void DelDiffs( const SfxItemSet
& rSet
);
85 void DelDiffs( const SwFormat
& rFormat
) { DelDiffs( rFormat
.GetAttrSet() ); }
88 bool SetDerivedFrom(SwFormat
*pDerivedFrom
= nullptr);
90 /// If bInParents is FALSE, search only in this format for attribute.
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
95 return static_cast<const T
&>(GetFormatAttr(sal_uInt16(nWhich
), bInParents
));
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 );
104 /** Takes all hints from Delta-Array,
105 @return count of deleted hints. */
106 virtual sal_uInt16
ResetAllFormatAttr();
108 SwFormat
* DerivedFrom() const { return const_cast<SwFormat
*>(static_cast<const SwFormat
*>(GetRegisteredIn())); }
109 bool IsDefault() const { return DerivedFrom() == nullptr; }
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 );
115 /// For querying the attribute array.
116 const SwAttrSet
& GetAttrSet() const { return m_aSet
; }
118 /** The document is set in SwAttrPool now, therefore you always can access it. */
119 const SwDoc
*GetDoc() const { return m_aSet
.GetDoc(); }
120 SwDoc
*GetDoc() { return m_aSet
.GetDoc(); }
122 /// Provides access to the document settings interface.
123 const IDocumentSettingAccess
& getIDocumentSettingAccess() const;
125 /// Provides access to the document draw model interface.
126 const IDocumentDrawModelAccess
& getIDocumentDrawModelAccess() const;
127 IDocumentDrawModelAccess
& getIDocumentDrawModelAccess();
129 /// Provides access to the document layout interface.
130 const IDocumentLayoutAccess
& getIDocumentLayoutAccess() const;
131 IDocumentLayoutAccess
& getIDocumentLayoutAccess();
133 /// Provides access to the document idle timer interface.
134 IDocumentTimerAccess
& getIDocumentTimerAccess();
136 /// Provides access to the document idle timer interface.
137 IDocumentFieldsAccess
& getIDocumentFieldsAccess();
139 /// Gives access to the chart data-provider.
140 IDocumentChartDataProviderAccess
& getIDocumentChartDataProviderAccess();
142 /// Get and set Pool style IDs.
143 sal_uInt16
GetPoolFormatId() const { return m_nPoolFormatId
; }
144 void SetPoolFormatId( sal_uInt16 nId
) { m_nPoolFormatId
= nId
; }
146 /// Get and set Help-IDs for document templates.
147 sal_uInt16
GetPoolHelpId() const { return m_nPoolHelpId
; }
148 void SetPoolHelpId( sal_uInt16 nId
) { m_nPoolHelpId
= nId
; }
149 sal_uInt8
GetPoolHlpFileId() const { return m_nPoolHlpFileId
; }
150 void SetPoolHlpFileId( sal_uInt8 nId
) { m_nPoolHlpFileId
= nId
; }
152 /// Get attribute-description. Returns passed string.
153 void GetPresentation( SfxItemPresentation ePres
,
154 MapUnit eCoreMetric
, MapUnit ePresMetric
, OUString
&rText
) const
155 { m_aSet
.GetPresentation( ePres
, eCoreMetric
, ePresMetric
, rText
); }
157 /// Query / set AutoFormat-flag.
158 bool IsAuto() const { return m_bAutoFormat
; }
159 void SetAuto( bool bNew
) { m_bAutoFormat
= bNew
; }
161 bool IsHidden() const { return m_bHidden
; }
162 void SetHidden( bool bValue
) { m_bHidden
= bValue
; }
164 void GetGrabBagItem(css::uno::Any
& rVal
) const;
165 void SetGrabBagItem(const css::uno::Any
& rVal
);
167 /// Query / set bAutoUpdateFormat-flag.
168 bool IsAutoUpdateFormat() const { return m_bAutoUpdateFormat
; }
169 void SetAutoUpdateFormat( bool bNew
= true ) { m_bAutoUpdateFormat
= bNew
; }
171 bool IsFormatInDTOR() const { return m_bFormatInDTOR
; }
173 /** GetMethods: Bool indicates whether to search only in Set (FALSE)
175 If nothing is found the defaulted attribute is returned. */
177 /// Character-attributes - implemented in charatr.hxx
178 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;
185 /// Frame-attributes - implemented in frmatr.hxx.
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;
205 // Create SvxBrushItem for Background fill (partially for backwards compatibility)
206 std::shared_ptr
<SvxBrushItem
> makeBackgroundBrushItem( bool = true ) const;
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;
224 inline const SwFormatFollowTextFlow
&GetFollowTextFlow(bool = true) const;
226 inline const SwFormatWrapInfluenceOnObjPos
& GetWrapInfluenceOnObjPos(bool = true) const;
227 inline const SdrTextVertAdjustItem
& GetTextVertAdjust(bool = true) const;
229 /// Paragraph-attributes - implemented in paratr.hxx.
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;
235 /// TableBox attributes - implemented in cellatr.hxx.
236 inline const SwTableBoxNumFormat
&GetTableBoxNumFormat( bool = true ) const;
237 inline const SwTableBoxFormula
&GetTableBoxFormula( bool = true ) const;
238 inline const SwTableBoxValue
&GetTableBoxValue( bool = true ) const;
240 /** SwFormat::IsBackgroundTransparent
242 Virtual method to determine, if background of format is transparent.
243 Default implementation returns false. Thus, subclasses have to override
244 method, if the specific subclass can have a transparent background.
246 @return false, default implementation
248 virtual bool IsBackgroundTransparent() const;
250 // Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
251 virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr
getSdrAllFillAttributesHelper() const;
252 virtual bool supportsFullDrawingLayerFillAttributeSet() const;
255 #endif // INCLUDED_SW_INC_FORMAT_HXX
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */