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