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