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 <boost/shared_ptr.hpp>
28 : //UUUU
29 : #include <fillattributes.hxx>
30 :
31 : class IDocumentSettingAccess;
32 : class IDocumentDrawModelAccess;
33 : class IDocumentLayoutAccess;
34 : class IDocumentTimerAccess;
35 : class IDocumentFieldsAccess;
36 : class IDocumentChartDataProviderAccess;
37 : class SwDoc;
38 : class SfxGrabBagItem;
39 :
40 : /// Base class for various Writer styles.
41 : class SW_DLLPUBLIC SwFmt : public SwModify
42 : {
43 : OUString aFmtName;
44 : SwAttrSet aSet;
45 :
46 : sal_uInt16 nWhichId;
47 : sal_uInt16 nPoolFmtId; /**< Id for "automatically" created formats.
48 : (is not hard attribution!!!) */
49 : sal_uInt16 nPoolHelpId; ///< HelpId for this Pool-style.
50 : sal_uInt8 nPoolHlpFileId; ///< FilePos to Doc to these style helps.
51 : bool bWritten : 1; ///< TRUE: already written.
52 : bool bAutoFmt : 1; /**< FALSE: it is a template.
53 : default is true! */
54 : bool bFmtInDTOR : 1; /**< TRUE: Format becomes deleted. In order to be able
55 : to recognize this in FmtChg-message!! */
56 : sal_Bool bAutoUpdateFmt : 1;/**< TRUE: Set attributes of a whole paragraph
57 : at format (UI-side!). */
58 : bool bHidden : 1;
59 : boost::shared_ptr<SfxGrabBagItem> m_pGrabBagItem; ///< Style InteropGrabBag.
60 :
61 : protected:
62 : SwFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
63 : const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich );
64 : SwFmt( SwAttrPool& rPool, const OUString &rFmtNm, const sal_uInt16* pWhichRanges,
65 : SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich );
66 : SwFmt( const SwFmt& rFmt );
67 : virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue ) SAL_OVERRIDE;
68 :
69 : public:
70 : TYPEINFO_OVERRIDE(); ///< Already in base class Client.
71 :
72 : virtual ~SwFmt();
73 : SwFmt &operator=(const SwFmt&);
74 :
75 : /// for Querying of Writer-functions.
76 0 : sal_uInt16 Which() const { return nWhichId; }
77 :
78 : /// Query format information.
79 : virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE;
80 :
81 : /// Copy attributes even among documents.
82 : void CopyAttrs( const SwFmt&, sal_Bool bReplace=sal_True );
83 :
84 : /// Delete all attributes that are not in rFmt.
85 : void DelDiffs( const SfxItemSet& rSet );
86 0 : void DelDiffs( const SwFmt& rFmt ) { DelDiffs( rFmt.GetAttrSet() ); }
87 :
88 : /// 0 is Default.
89 : sal_Bool SetDerivedFrom(SwFmt *pDerivedFrom = 0);
90 :
91 : /// If bInParents is FALSE, search only in this format for attribute.
92 : //UUUUinline
93 : const SfxPoolItem& GetFmtAttr( sal_uInt16 nWhich,
94 : sal_Bool bInParents = sal_True ) const;
95 : //UUUUinline
96 : SfxItemState GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent = sal_True,
97 : const SfxPoolItem **ppItem = 0 ) const;
98 : virtual bool SetFmtAttr( const SfxPoolItem& rAttr );
99 : virtual bool SetFmtAttr( const SfxItemSet& rSet );
100 : virtual bool ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
101 :
102 : /** Takes all hints from Delta-Array,
103 : @return count of deleted hints. */
104 : virtual sal_uInt16 ResetAllFmtAttr();
105 :
106 0 : inline SwFmt* DerivedFrom() const { return (SwFmt*)GetRegisteredIn(); }
107 0 : inline bool IsDefault() const { return DerivedFrom() == 0; }
108 :
109 0 : inline OUString GetName() const { return aFmtName; }
110 : void SetName( const OUString& rNewName, sal_Bool bBroadcast=sal_False );
111 : inline void SetName( const sal_Char* pNewName,
112 : sal_Bool bBroadcast=sal_False);
113 :
114 : /// For querying the attribute array.
115 0 : inline const SwAttrSet& GetAttrSet() const { return aSet; }
116 :
117 : /** Das Doc wird jetzt am SwAttrPool gesetzt. Dadurch hat man es immer
118 : im Zugriff. */
119 0 : const SwDoc *GetDoc() const { return aSet.GetDoc(); }
120 0 : SwDoc *GetDoc() { return aSet.GetDoc(); }
121 :
122 : /// Provides access to the document settings interface.
123 : const IDocumentSettingAccess* getIDocumentSettingAccess() const;
124 :
125 : /// Provides access to the document draw model interface.
126 : const IDocumentDrawModelAccess* getIDocumentDrawModelAccess() const;
127 : IDocumentDrawModelAccess* getIDocumentDrawModelAccess();
128 :
129 : /// Provides access to the document layout interface.
130 : const IDocumentLayoutAccess* getIDocumentLayoutAccess() const;
131 : IDocumentLayoutAccess* getIDocumentLayoutAccess();
132 :
133 : /// Provides access to the document idle timer interface.
134 : IDocumentTimerAccess* getIDocumentTimerAccess();
135 :
136 : /// Provides access to the document idle timer interface.
137 : IDocumentFieldsAccess* getIDocumentFieldsAccess();
138 :
139 : /// Gives access to the chart data-provider.
140 : IDocumentChartDataProviderAccess* getIDocumentChartDataProviderAccess();
141 :
142 : /// Get and set Pool style IDs.
143 0 : sal_uInt16 GetPoolFmtId() const { return nPoolFmtId; }
144 0 : void SetPoolFmtId( sal_uInt16 nId ) { nPoolFmtId = nId; }
145 :
146 : /// Get and set Help-IDs for document templates.
147 0 : sal_uInt16 GetPoolHelpId() const { return nPoolHelpId; }
148 0 : void SetPoolHelpId( sal_uInt16 nId ) { nPoolHelpId = nId; }
149 0 : sal_uInt8 GetPoolHlpFileId() const { return nPoolHlpFileId; }
150 0 : void SetPoolHlpFileId( sal_uInt8 nId ) { nPoolHlpFileId = nId; }
151 :
152 : /// Get attribute-description. Returns passed string.
153 0 : void GetPresentation( SfxItemPresentation ePres,
154 : SfxMapUnit eCoreMetric, SfxMapUnit ePresMetric, OUString &rText ) const
155 0 : { aSet.GetPresentation( ePres, eCoreMetric, ePresMetric, rText ); }
156 :
157 : /// Format-ID for reading/writing:
158 0 : void ResetWritten() { bWritten = false; }
159 :
160 : /// Query / set AutoFmt-flag.
161 0 : bool IsAuto() const { return bAutoFmt; }
162 0 : void SetAuto( bool bNew = false ) { bAutoFmt = bNew; }
163 :
164 0 : bool IsHidden() const { return bHidden; }
165 0 : void SetHidden( bool bValue = false ) { bHidden = bValue; }
166 :
167 : void GetGrabBagItem(com::sun::star::uno::Any& rVal) const;
168 : void SetGrabBagItem(const com::sun::star::uno::Any& rVal);
169 :
170 : /// Query / set bAutoUpdateFmt-flag.
171 0 : sal_Bool IsAutoUpdateFmt() const { return bAutoUpdateFmt; }
172 0 : void SetAutoUpdateFmt( sal_Bool bNew = sal_True ) { bAutoUpdateFmt = bNew; }
173 :
174 0 : bool IsFmtInDTOR() const { return bFmtInDTOR; }
175 :
176 : /** GetMethods: Bool indicates whether to search only in Set (FALSE)
177 : or also in Parents.
178 : If nothing is found the defaulted attribute is returned. */
179 :
180 : /// Character-attributes - implemented in charatr.hxx
181 : inline const SvxPostureItem &GetPosture( sal_Bool = sal_True ) const;
182 : inline const SvxWeightItem &GetWeight( sal_Bool = sal_True ) const;
183 : inline const SvxShadowedItem &GetShadowed( sal_Bool = sal_True ) const;
184 : inline const SvxAutoKernItem &GetAutoKern( sal_Bool = sal_True ) const;
185 : inline const SvxWordLineModeItem &GetWordLineMode( sal_Bool = sal_True ) const;
186 : inline const SvxContourItem &GetContour( sal_Bool = sal_True ) const;
187 : inline const SvxKerningItem &GetKerning( sal_Bool = sal_True ) const;
188 : inline const SvxUnderlineItem &GetUnderline( sal_Bool = sal_True ) const;
189 : inline const SvxOverlineItem &GetOverline( sal_Bool = sal_True ) const;
190 : inline const SvxCrossedOutItem &GetCrossedOut( sal_Bool = sal_True ) const;
191 : inline const SvxFontHeightItem &GetSize( sal_Bool = sal_True ) const;
192 : inline const SvxPropSizeItem &GetPropSize( sal_Bool = sal_True ) const;
193 : inline const SvxFontItem &GetFont( sal_Bool = sal_True ) const;
194 : inline const SvxColorItem &GetColor( sal_Bool = sal_True ) const;
195 : inline const SvxCharSetColorItem &GetCharSetColor( sal_Bool = sal_True ) const;
196 : inline const SvxLanguageItem &GetLanguage( sal_Bool = sal_True ) const;
197 : inline const SvxEscapementItem &GetEscapement( sal_Bool = sal_True ) const;
198 : inline const SvxCaseMapItem &GetCaseMap( sal_Bool = sal_True ) const;
199 : inline const SvxNoHyphenItem &GetNoHyphenHere( sal_Bool = sal_True ) const;
200 : inline const SvxBlinkItem &GetBlink( sal_Bool = sal_True ) const;
201 : inline const SvxBrushItem &GetChrBackground( sal_Bool = sal_True ) const;
202 : inline const SvxBrushItem &GetChrHighlight( sal_Bool = sal_True ) const;
203 :
204 : inline const SvxFontItem &GetCJKFont( sal_Bool = sal_True ) const;
205 : inline const SvxFontHeightItem &GetCJKSize( sal_Bool = sal_True ) const;
206 : inline const SvxLanguageItem &GetCJKLanguage( sal_Bool = sal_True ) const;
207 : inline const SvxPostureItem &GetCJKPosture( sal_Bool = sal_True ) const;
208 : inline const SvxWeightItem &GetCJKWeight( sal_Bool = sal_True ) const;
209 : inline const SvxFontItem &GetCTLFont( sal_Bool = sal_True ) const;
210 : inline const SvxFontHeightItem &GetCTLSize( sal_Bool = sal_True ) const;
211 : inline const SvxLanguageItem &GetCTLLanguage( sal_Bool = sal_True ) const;
212 : inline const SvxPostureItem &GetCTLPosture( sal_Bool = sal_True ) const;
213 : inline const SvxWeightItem &GetCTLWeight( sal_Bool = sal_True ) const;
214 : inline const SfxBoolItem &GetWritingDirection( sal_Bool = sal_True ) const;
215 : inline const SvxEmphasisMarkItem &GetEmphasisMark( sal_Bool = sal_True ) const;
216 : inline const SvxTwoLinesItem &Get2Lines( sal_Bool = sal_True ) const;
217 : inline const SvxCharScaleWidthItem &GetCharScaleW( sal_Bool = sal_True ) const;
218 : inline const SvxCharRotateItem &GetCharRotate( sal_Bool = sal_True ) const;
219 : inline const SvxCharReliefItem &GetCharRelief( sal_Bool = sal_True ) const;
220 : inline const SvxCharHiddenItem &GetCharHidden( sal_Bool = sal_True ) const;
221 : inline const SvxBoxItem &GetCharBorder( sal_Bool = sal_True ) const;
222 : inline const SvxShadowItem &GetCharShadow( sal_Bool = sal_True ) const;
223 :
224 : /// Frame-attributes - implemented in frmatr.hxx.
225 : inline const SwFmtFillOrder &GetFillOrder( sal_Bool = sal_True ) const;
226 : inline const SwFmtFrmSize &GetFrmSize( sal_Bool = sal_True ) const;
227 : inline const SwFmtHeader &GetHeader( sal_Bool = sal_True ) const;
228 : inline const SwFmtFooter &GetFooter( sal_Bool = sal_True ) const;
229 : inline const SwFmtSurround &GetSurround( sal_Bool = sal_True ) const;
230 : inline const SwFmtHoriOrient &GetHoriOrient( sal_Bool = sal_True ) const;
231 : inline const SwFmtAnchor &GetAnchor( sal_Bool = sal_True ) const;
232 : inline const SwFmtCol &GetCol( sal_Bool = sal_True ) const;
233 : inline const SvxPaperBinItem &GetPaperBin( sal_Bool = sal_True ) const;
234 : inline const SvxLRSpaceItem &GetLRSpace( sal_Bool = sal_True ) const;
235 : inline const SvxULSpaceItem &GetULSpace( sal_Bool = sal_True ) const;
236 : inline const SwFmtCntnt &GetCntnt( sal_Bool = sal_True ) const;
237 : inline const SvxPrintItem &GetPrint( sal_Bool = sal_True ) const;
238 : inline const SvxOpaqueItem &GetOpaque( sal_Bool = sal_True ) const;
239 : inline const SvxProtectItem &GetProtect( sal_Bool = sal_True ) const;
240 : inline const SwFmtVertOrient &GetVertOrient( sal_Bool = sal_True ) const;
241 : inline const SvxBoxItem &GetBox( sal_Bool = sal_True ) const;
242 : inline const SvxFmtKeepItem &GetKeep( sal_Bool = sal_True ) const;
243 :
244 : //UUUU
245 : const SvxBrushItem& GetBackground( sal_Bool = sal_True ) const;
246 :
247 : inline const SvxShadowItem &GetShadow( sal_Bool = sal_True ) const;
248 : inline const SwFmtPageDesc &GetPageDesc( sal_Bool = sal_True ) const;
249 : inline const SvxFmtBreakItem &GetBreak( sal_Bool = sal_True ) const;
250 : inline const SvxMacroItem &GetMacro( sal_Bool = sal_True ) const;
251 : inline const SwFmtURL &GetURL( sal_Bool = sal_True ) const;
252 : inline const SwFmtEditInReadonly &GetEditInReadonly( sal_Bool = sal_True ) const;
253 : inline const SwFmtLayoutSplit &GetLayoutSplit( sal_Bool = sal_True ) const;
254 : inline const SwFmtRowSplit &GetRowSplit( sal_Bool = sal_True ) const;
255 : inline const SwFmtChain &GetChain( sal_Bool = sal_True ) const;
256 : inline const SwFmtLineNumber &GetLineNumber( sal_Bool = sal_True ) const;
257 : inline const SwFmtFtnAtTxtEnd &GetFtnAtTxtEnd( sal_Bool = sal_True ) const;
258 : inline const SwFmtEndAtTxtEnd &GetEndAtTxtEnd( sal_Bool = sal_True ) const;
259 : inline const SwFmtNoBalancedColumns &GetBalancedColumns( sal_Bool = sal_True ) const;
260 : inline const SvxFrameDirectionItem &GetFrmDir( sal_Bool = sal_True ) const;
261 : inline const SwTextGridItem &GetTextGrid( sal_Bool = sal_True ) const;
262 : inline const SwHeaderAndFooterEatSpacingItem &GetHeaderAndFooterEatSpacing( sal_Bool = sal_True ) const;
263 : // #i18732#
264 : inline const SwFmtFollowTextFlow &GetFollowTextFlow(sal_Bool = sal_True) const;
265 : // #i28701#
266 : inline const SwFmtWrapInfluenceOnObjPos& GetWrapInfluenceOnObjPos(sal_Bool = sal_True) const;
267 : inline const SdrTextVertAdjustItem& GetTextVertAdjust(sal_Bool = sal_True) const;
268 :
269 : /// Graphics-attributes - implemented in grfatr.hxx
270 : inline const SwMirrorGrf &GetMirrorGrf( sal_Bool = sal_True ) const;
271 : inline const SwCropGrf &GetCropGrf( sal_Bool = sal_True ) const;
272 : inline const SwRotationGrf &GetRotationGrf(sal_Bool = sal_True ) const;
273 : inline const SwLuminanceGrf &GetLuminanceGrf(sal_Bool = sal_True ) const;
274 : inline const SwContrastGrf &GetContrastGrf(sal_Bool = sal_True ) const;
275 : inline const SwChannelRGrf &GetChannelRGrf(sal_Bool = sal_True ) const;
276 : inline const SwChannelGGrf &GetChannelGGrf(sal_Bool = sal_True ) const;
277 : inline const SwChannelBGrf &GetChannelBGrf(sal_Bool = sal_True ) const;
278 : inline const SwGammaGrf &GetGammaGrf(sal_Bool = sal_True ) const;
279 : inline const SwInvertGrf &GetInvertGrf(sal_Bool = sal_True ) const;
280 : inline const SwTransparencyGrf &GetTransparencyGrf(sal_Bool = sal_True ) const;
281 : inline const SwDrawModeGrf &GetDrawModeGrf(sal_Bool = sal_True ) const;
282 :
283 : /// Paragraph-attributes - implemented in paratr.hxx.
284 : inline const SvxLineSpacingItem &GetLineSpacing( sal_Bool = sal_True ) const;
285 : inline const SvxAdjustItem &GetAdjust( sal_Bool = sal_True ) const;
286 : inline const SvxFmtSplitItem &GetSplit( sal_Bool = sal_True ) const;
287 : inline const SwRegisterItem &GetRegister( sal_Bool = sal_True ) const;
288 : inline const SwNumRuleItem &GetNumRule( sal_Bool = sal_True ) const;
289 : inline const SvxWidowsItem &GetWidows( sal_Bool = sal_True ) const;
290 : inline const SvxOrphansItem &GetOrphans( sal_Bool = sal_True ) const;
291 : inline const SvxTabStopItem &GetTabStops( sal_Bool = sal_True ) const;
292 : inline const SvxHyphenZoneItem &GetHyphenZone( sal_Bool = sal_True ) const;
293 : inline const SwFmtDrop &GetDrop( sal_Bool = sal_True ) const;
294 : inline const SvxScriptSpaceItem &GetScriptSpace(sal_Bool = sal_True) const;
295 : inline const SvxHangingPunctuationItem &GetHangingPunctuation(sal_Bool = sal_True) const;
296 : inline const SvxForbiddenRuleItem &GetForbiddenRule(sal_Bool = sal_True) const;
297 : inline const SvxParaVertAlignItem &GetParaVertAlign(sal_Bool = sal_True) const;
298 : inline const SvxParaGridItem &GetParaGrid(sal_Bool = sal_True) const;
299 : inline const SwParaConnectBorderItem &GetParaConnectBorder(sal_Bool = sal_True ) const;
300 :
301 : /// TableBox attributes - implemented in cellatr.hxx.
302 : inline const SwTblBoxNumFormat &GetTblBoxNumFmt( sal_Bool = sal_True ) const;
303 : inline const SwTblBoxFormula &GetTblBoxFormula( sal_Bool = sal_True ) const;
304 : inline const SwTblBoxValue &GetTblBoxValue( sal_Bool = sal_True ) const;
305 :
306 : /** SwFmt::IsBackgroundTransparent
307 :
308 : Virtual method to determine, if background of format is transparent.
309 : Default implementation returns false. Thus, subclasses have to overload
310 : method, if the specific subclass can have a transparent background.
311 :
312 : @author OD
313 :
314 : @return false, default implementation
315 : */
316 : virtual bool IsBackgroundTransparent() const;
317 :
318 : /** SwFmt::IsShadowTransparent
319 :
320 : Virtual method to determine, if shadow of format is transparent.
321 : Default implementation returns false. Thus, subclasses have to overload
322 : method, if the specific subclass can have a transparent shadow.
323 :
324 : @author OD
325 :
326 : @return false, default implementation
327 : */
328 : virtual bool IsShadowTransparent() const;
329 :
330 : //UUUU
331 : virtual FillAttributesPtr getFillAttributes() const;
332 : };
333 :
334 : // --------------- inline Implementations ------------------------
335 :
336 : //UUUUinline const SfxPoolItem& SwFmt::GetFmtAttr( sal_uInt16 nWhich,
337 : //UUUU sal_Bool bInParents ) const
338 : //UUUU{
339 : //UUUU return aSet.Get( nWhich, bInParents );
340 : //UUUU}
341 :
342 : inline void SwFmt::SetName( const sal_Char* pNewName,
343 : sal_Bool bBroadcast )
344 : {
345 : SetName(OUString::createFromAscii(pNewName), bBroadcast);
346 : }
347 :
348 : //UUUUinline SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent,
349 : //UUUU const SfxPoolItem **ppItem ) const
350 : //UUUU{
351 : //UUUU return aSet.GetItemState( nWhich, bSrchInParent, ppItem );
352 : //UUUU}
353 :
354 : #endif // INCLUDED_SW_INC_FORMAT_HXX
355 :
356 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|