Branch libreoffice-5-0-4
[LibreOffice.git] / sw / inc / format.hxx
blob11ed94319e817798b551baf072cf16a678f71f30
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_FORMAT_HXX
20 #define INCLUDED_SW_INC_FORMAT_HXX
22 #include <tools/solar.h>
23 #include "swdllapi.h"
24 #include <swatrset.hxx>
25 #include <calbck.hxx>
26 #include <hintids.hxx>
27 #include <memory>
29 class IDocumentSettingAccess;
30 class IDocumentDrawModelAccess;
31 class IDocumentLayoutAccess;
32 class IDocumentTimerAccess;
33 class IDocumentFieldsAccess;
34 class IDocumentChartDataProviderAccess;
35 class SwDoc;
36 class SfxGrabBagItem;
38 namespace drawinglayer { namespace attribute {
39 class SdrAllFillAttributesHelper;
40 typedef std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr;
43 /// Base class for various Writer styles.
44 class SW_DLLPUBLIC SwFormat : public SwModify
46 OUString m_aFormatName;
47 SwAttrSet m_aSet;
49 sal_uInt16 m_nWhichId;
50 sal_uInt16 m_nPoolFormatId; /**< Id for "automatically" created formats.
51 (is not hard attribution!!!) */
52 sal_uInt16 m_nPoolHelpId; ///< HelpId for this Pool-style.
53 sal_uInt8 m_nPoolHlpFileId; ///< FilePos to Doc to these style helps.
54 bool m_bWritten : 1; ///< TRUE: already written.
55 bool m_bAutoFormat : 1; /**< FALSE: it is a template.
56 default is true! */
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!). */
61 bool m_bHidden : 1;
62 std::shared_ptr<SfxGrabBagItem> m_pGrabBagItem; ///< Style InteropGrabBag.
64 protected:
65 SwFormat( SwAttrPool& rPool, const sal_Char* pFormatNm,
66 const sal_uInt16* pWhichRanges, SwFormat *pDrvdFrm, sal_uInt16 nFormatWhich );
67 SwFormat( SwAttrPool& rPool, const OUString &rFormatNm, const sal_uInt16* pWhichRanges,
68 SwFormat *pDrvdFrm, sal_uInt16 nFormatWhich );
69 SwFormat( const SwFormat& rFormat );
70 virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue ) SAL_OVERRIDE;
72 public:
73 TYPEINFO_OVERRIDE(); ///< Already in base class Client.
75 virtual ~SwFormat();
76 SwFormat &operator=(const SwFormat&);
78 /// for Querying of Writer-functions.
79 sal_uInt16 Which() const { return m_nWhichId; }
81 /// Query format information.
82 virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE;
84 /// Copy attributes even among documents.
85 void CopyAttrs( const SwFormat&, bool bReplace=true );
87 /// Delete all attributes that are not in rFormat.
88 void DelDiffs( const SfxItemSet& rSet );
89 void DelDiffs( const SwFormat& rFormat ) { DelDiffs( rFormat.GetAttrSet() ); }
91 /// 0 is Default.
92 bool SetDerivedFrom(SwFormat *pDerivedFrom = 0);
94 /// If bInParents is FALSE, search only in this format for attribute.
95 //UUUUinline
96 const SfxPoolItem& GetFormatAttr( sal_uInt16 nWhich,
97 bool bInParents = true ) const;
98 //UUUUinline
99 SfxItemState GetItemState( sal_uInt16 nWhich, bool bSrchInParent = true,
100 const SfxPoolItem **ppItem = 0 ) const;
101 SfxItemState GetBackgroundState(SvxBrushItem &rItem,
102 bool bSrchInParent = true) const;
103 virtual bool SetFormatAttr( const SfxPoolItem& rAttr );
104 virtual bool SetFormatAttr( const SfxItemSet& rSet );
105 virtual bool ResetFormatAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
107 /** Takes all hints from Delta-Array,
108 @return count of deleted hints. */
109 virtual sal_uInt16 ResetAllFormatAttr();
111 inline SwFormat* DerivedFrom() const { return const_cast<SwFormat*>(static_cast<const SwFormat*>(GetRegisteredIn())); }
112 inline bool IsDefault() const { return DerivedFrom() == 0; }
114 inline OUString GetName() const { return m_aFormatName; }
115 void SetName( const OUString& rNewName, bool bBroadcast=false );
116 inline void SetName( const sal_Char* pNewName,
117 bool bBroadcast=false);
119 /// For querying the attribute array.
120 inline const SwAttrSet& GetAttrSet() const { return m_aSet; }
122 /** Das Doc wird jetzt am SwAttrPool gesetzt. Dadurch hat man es immer
123 im Zugriff. */
124 const SwDoc *GetDoc() const { return m_aSet.GetDoc(); }
125 SwDoc *GetDoc() { return m_aSet.GetDoc(); }
127 /// Provides access to the document settings interface.
128 const IDocumentSettingAccess* getIDocumentSettingAccess() const;
130 /// Provides access to the document draw model interface.
131 const IDocumentDrawModelAccess* getIDocumentDrawModelAccess() const;
132 IDocumentDrawModelAccess* getIDocumentDrawModelAccess();
134 /// Provides access to the document layout interface.
135 const IDocumentLayoutAccess* getIDocumentLayoutAccess() const;
136 IDocumentLayoutAccess* getIDocumentLayoutAccess();
138 /// Provides access to the document idle timer interface.
139 IDocumentTimerAccess* getIDocumentTimerAccess();
141 /// Provides access to the document idle timer interface.
142 IDocumentFieldsAccess* getIDocumentFieldsAccess();
144 /// Gives access to the chart data-provider.
145 IDocumentChartDataProviderAccess* getIDocumentChartDataProviderAccess();
147 /// Get and set Pool style IDs.
148 sal_uInt16 GetPoolFormatId() const { return m_nPoolFormatId; }
149 void SetPoolFormatId( sal_uInt16 nId ) { m_nPoolFormatId = nId; }
151 /// Get and set Help-IDs for document templates.
152 sal_uInt16 GetPoolHelpId() const { return m_nPoolHelpId; }
153 void SetPoolHelpId( sal_uInt16 nId ) { m_nPoolHelpId = nId; }
154 sal_uInt8 GetPoolHlpFileId() const { return m_nPoolHlpFileId; }
155 void SetPoolHlpFileId( sal_uInt8 nId ) { m_nPoolHlpFileId = nId; }
157 /// Get attribute-description. Returns passed string.
158 void GetPresentation( SfxItemPresentation ePres,
159 SfxMapUnit eCoreMetric, SfxMapUnit ePresMetric, OUString &rText ) const
160 { m_aSet.GetPresentation( ePres, eCoreMetric, ePresMetric, rText ); }
162 /// Format-ID for reading/writing:
163 void ResetWritten() { m_bWritten = false; }
165 /// Query / set AutoFormat-flag.
166 bool IsAuto() const { return m_bAutoFormat; }
167 void SetAuto( bool bNew = false ) { m_bAutoFormat = bNew; }
169 bool IsHidden() const { return m_bHidden; }
170 void SetHidden( bool bValue = false ) { m_bHidden = bValue; }
172 void GetGrabBagItem(com::sun::star::uno::Any& rVal) const;
173 void SetGrabBagItem(const com::sun::star::uno::Any& rVal);
175 /// Query / set bAutoUpdateFormat-flag.
176 bool IsAutoUpdateFormat() const { return m_bAutoUpdateFormat; }
177 void SetAutoUpdateFormat( bool bNew = true ) { m_bAutoUpdateFormat = bNew; }
179 bool IsFormatInDTOR() const { return m_bFormatInDTOR; }
181 /** GetMethods: Bool indicates whether to search only in Set (FALSE)
182 or also in Parents.
183 If nothing is found the defaulted attribute is returned. */
185 /// Character-attributes - implemented in charatr.hxx
186 inline const SvxPostureItem &GetPosture( bool = true ) const;
187 inline const SvxWeightItem &GetWeight( bool = true ) const;
188 inline const SvxShadowedItem &GetShadowed( bool = true ) const;
189 inline const SvxAutoKernItem &GetAutoKern( bool = true ) const;
190 inline const SvxWordLineModeItem &GetWordLineMode( bool = true ) const;
191 inline const SvxContourItem &GetContour( bool = true ) const;
192 inline const SvxKerningItem &GetKerning( bool = true ) const;
193 inline const SvxUnderlineItem &GetUnderline( bool = true ) const;
194 inline const SvxOverlineItem &GetOverline( bool = true ) const;
195 inline const SvxCrossedOutItem &GetCrossedOut( bool = true ) const;
196 inline const SvxFontHeightItem &GetSize( bool = true ) const;
197 inline const SvxPropSizeItem &GetPropSize( bool = true ) const;
198 inline const SvxFontItem &GetFont( bool = true ) const;
199 inline const SvxColorItem &GetColor( bool = true ) const;
200 inline const SvxCharSetColorItem &GetCharSetColor( bool = true ) const;
201 inline const SvxLanguageItem &GetLanguage( bool = true ) const;
202 inline const SvxEscapementItem &GetEscapement( bool = true ) const;
203 inline const SvxCaseMapItem &GetCaseMap( bool = true ) const;
204 inline const SvxNoHyphenItem &GetNoHyphenHere( bool = true ) const;
205 inline const SvxBlinkItem &GetBlink( bool = true ) const;
206 inline const SvxBrushItem &GetChrBackground( bool = true ) const;
207 inline const SvxBrushItem &GetChrHighlight( bool = true ) const;
209 inline const SvxFontItem &GetCJKFont( bool = true ) const;
210 inline const SvxFontHeightItem &GetCJKSize( bool = true ) const;
211 inline const SvxLanguageItem &GetCJKLanguage( bool = true ) const;
212 inline const SvxPostureItem &GetCJKPosture( bool = true ) const;
213 inline const SvxWeightItem &GetCJKWeight( bool = true ) const;
214 inline const SvxFontItem &GetCTLFont( bool = true ) const;
215 inline const SvxFontHeightItem &GetCTLSize( bool = true ) const;
216 inline const SvxLanguageItem &GetCTLLanguage( bool = true ) const;
217 inline const SvxPostureItem &GetCTLPosture( bool = true ) const;
218 inline const SvxWeightItem &GetCTLWeight( bool = true ) const;
219 inline const SfxBoolItem &GetWritingDirection( bool = true ) const;
220 inline const SvxEmphasisMarkItem &GetEmphasisMark( bool = true ) const;
221 inline const SvxTwoLinesItem &Get2Lines( bool = true ) const;
222 inline const SvxCharScaleWidthItem &GetCharScaleW( bool = true ) const;
223 inline const SvxCharRotateItem &GetCharRotate( bool = true ) const;
224 inline const SvxCharReliefItem &GetCharRelief( bool = true ) const;
225 inline const SvxCharHiddenItem &GetCharHidden( bool = true ) const;
226 inline const SvxBoxItem &GetCharBorder( bool = true ) const;
227 inline const SvxShadowItem &GetCharShadow( bool = true ) const;
229 /// Frame-attributes - implemented in frmatr.hxx.
230 inline const SwFormatFillOrder &GetFillOrder( bool = true ) const;
231 inline const SwFormatFrmSize &GetFrmSize( bool = true ) const;
232 inline const SwFormatHeader &GetHeader( bool = true ) const;
233 inline const SwFormatFooter &GetFooter( bool = true ) const;
234 inline const SwFormatSurround &GetSurround( bool = true ) const;
235 inline const SwFormatHoriOrient &GetHoriOrient( bool = true ) const;
236 inline const SwFormatAnchor &GetAnchor( bool = true ) const;
237 inline const SwFormatCol &GetCol( bool = true ) const;
238 inline const SvxPaperBinItem &GetPaperBin( bool = true ) const;
239 inline const SvxLRSpaceItem &GetLRSpace( bool = true ) const;
240 inline const SvxULSpaceItem &GetULSpace( bool = true ) const;
241 inline const SwFormatContent &GetContent( bool = true ) const;
242 inline const SvxPrintItem &GetPrint( bool = true ) const;
243 inline const SvxOpaqueItem &GetOpaque( bool = true ) const;
244 inline const SvxProtectItem &GetProtect( bool = true ) const;
245 inline const SwFormatVertOrient &GetVertOrient( bool = true ) const;
246 inline const SvxBoxItem &GetBox( bool = true ) const;
247 inline const SvxFormatKeepItem &GetKeep( bool = true ) const;
249 //UUUU Create SvxBrushItem for Background fill (partially for backwards compatibility)
250 SvxBrushItem makeBackgroundBrushItem( bool = true ) const;
252 inline const SvxShadowItem &GetShadow( bool = true ) const;
253 inline const SwFormatPageDesc &GetPageDesc( bool = true ) const;
254 inline const SvxFormatBreakItem &GetBreak( bool = true ) const;
255 inline const SvxMacroItem &GetMacro( bool = true ) const;
256 inline const SwFormatURL &GetURL( bool = true ) const;
257 inline const SwFormatEditInReadonly &GetEditInReadonly( bool = true ) const;
258 inline const SwFormatLayoutSplit &GetLayoutSplit( bool = true ) const;
259 inline const SwFormatRowSplit &GetRowSplit( bool = true ) const;
260 inline const SwFormatChain &GetChain( bool = true ) const;
261 inline const SwFormatLineNumber &GetLineNumber( bool = true ) const;
262 inline const SwFormatFootnoteAtTextEnd &GetFootnoteAtTextEnd( bool = true ) const;
263 inline const SwFormatEndAtTextEnd &GetEndAtTextEnd( bool = true ) const;
264 inline const SwFormatNoBalancedColumns &GetBalancedColumns( bool = true ) const;
265 inline const SvxFrameDirectionItem &GetFrmDir( bool = true ) const;
266 inline const SwTextGridItem &GetTextGrid( bool = true ) const;
267 inline const SwHeaderAndFooterEatSpacingItem &GetHeaderAndFooterEatSpacing( bool = true ) const;
268 // #i18732#
269 inline const SwFormatFollowTextFlow &GetFollowTextFlow(bool = true) const;
270 // #i28701#
271 inline const SwFormatWrapInfluenceOnObjPos& GetWrapInfluenceOnObjPos(bool = true) const;
272 inline const SdrTextVertAdjustItem& GetTextVertAdjust(bool = true) const;
274 /// Graphics-attributes - implemented in grfatr.hxx
275 inline const SwMirrorGrf &GetMirrorGrf( bool = true ) const;
276 inline const SwCropGrf &GetCropGrf( bool = true ) const;
277 inline const SwRotationGrf &GetRotationGrf(bool = true ) const;
278 inline const SwLuminanceGrf &GetLuminanceGrf(bool = true ) const;
279 inline const SwContrastGrf &GetContrastGrf(bool = true ) const;
280 inline const SwChannelRGrf &GetChannelRGrf(bool = true ) const;
281 inline const SwChannelGGrf &GetChannelGGrf(bool = true ) const;
282 inline const SwChannelBGrf &GetChannelBGrf(bool = true ) const;
283 inline const SwGammaGrf &GetGammaGrf(bool = true ) const;
284 inline const SwInvertGrf &GetInvertGrf(bool = true ) const;
285 inline const SwTransparencyGrf &GetTransparencyGrf(bool = true ) const;
286 inline const SwDrawModeGrf &GetDrawModeGrf(bool = true ) const;
288 /// Paragraph-attributes - implemented in paratr.hxx.
289 inline const SvxLineSpacingItem &GetLineSpacing( bool = true ) const;
290 inline const SvxAdjustItem &GetAdjust( bool = true ) const;
291 inline const SvxFormatSplitItem &GetSplit( bool = true ) const;
292 inline const SwRegisterItem &GetRegister( bool = true ) const;
293 inline const SwNumRuleItem &GetNumRule( bool = true ) const;
294 inline const SvxWidowsItem &GetWidows( bool = true ) const;
295 inline const SvxOrphansItem &GetOrphans( bool = true ) const;
296 inline const SvxTabStopItem &GetTabStops( bool = true ) const;
297 inline const SvxHyphenZoneItem &GetHyphenZone( bool = true ) const;
298 inline const SwFormatDrop &GetDrop( bool = true ) const;
299 inline const SvxScriptSpaceItem &GetScriptSpace(bool = true) const;
300 inline const SvxHangingPunctuationItem &GetHangingPunctuation(bool = true) const;
301 inline const SvxForbiddenRuleItem &GetForbiddenRule(bool = true) const;
302 inline const SvxParaVertAlignItem &GetParaVertAlign(bool = true) const;
303 inline const SvxParaGridItem &GetParaGrid(bool = true) const;
304 inline const SwParaConnectBorderItem &GetParaConnectBorder(bool = true ) const;
306 /// TableBox attributes - implemented in cellatr.hxx.
307 inline const SwTableBoxNumFormat &GetTableBoxNumFormat( bool = true ) const;
308 inline const SwTableBoxFormula &GetTableBoxFormula( bool = true ) const;
309 inline const SwTableBoxValue &GetTableBoxValue( bool = true ) const;
311 /** SwFormat::IsBackgroundTransparent
313 Virtual method to determine, if background of format is transparent.
314 Default implementation returns false. Thus, subclasses have to override
315 method, if the specific subclass can have a transparent background.
317 @author OD
319 @return false, default implementation
321 virtual bool IsBackgroundTransparent() const;
323 //UUUU Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
324 virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const;
325 virtual bool supportsFullDrawingLayerFillAttributeSet() const;
328 inline void SwFormat::SetName( const sal_Char* pNewName,
329 bool bBroadcast )
331 SetName(OUString::createFromAscii(pNewName), bBroadcast);
334 #endif // INCLUDED_SW_INC_FORMAT_HXX
336 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */