xref: /aoo42x/main/sw/inc/format.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _FORMAT_HXX
28 #define _FORMAT_HXX
29 
30 #include <tools/solar.h>
31 #include "swdllapi.h"
32 #include <errhdl.hxx>		// fuer ASSERT
33 #include <swatrset.hxx>		// fuer SfxItemPool/-Set, Attr forward decl.
34 #include <calbck.hxx>		// fuer 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 class SW_DLLPUBLIC SwFmt : public SwModify
46 {
47 	String aFmtName;
48 	SwAttrSet aSet;
49 
50 	sal_uInt16 nWhichId;
51 	sal_uInt16 nFmtId;			// Format-ID fuer Lesen/Schreiben
52 	sal_uInt16 nPoolFmtId;		// Id-fuer "automatich" erzeugte Formate
53 							// (ist keine harte Attributierung !!)
54 	sal_uInt16 nPoolHelpId;		// HelpId fuer diese Pool-Vorlage
55 	sal_uInt8 nPoolHlpFileId; 	// FilePos ans Doc auf die Vorlagen-Hilfen
56 	sal_Bool   bWritten : 1;	// sal_True: bereits geschrieben
57 	sal_Bool   bAutoFmt : 1;	// sal_False: es handelt sich um eine Vorlage
58 							// ist dflt immer auf sal_True !
59 	sal_Bool   bFmtInDTOR : 1;	// sal_True: das Format wird geloscht. Damit man in
60 							// der FmtChg-Message das erkennen kann!!!
61 	sal_Bool   bAutoUpdateFmt : 1;	// sal_True: am Format werden die Attribute
62 							// eines kompletten Absatzes gesetzt (UI-seitig!)
63 
64 protected:
65 	SwFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
66 			const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich );
67 	SwFmt( SwAttrPool& rPool, const String &rFmtNm, const sal_uInt16* pWhichRanges,
68 			SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich );
69 	SwFmt( const SwFmt& rFmt );
70    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue );
71 
72 public:
73 	TYPEINFO();		//Bereits in Basisklasse Client drin.
74 
75 	virtual ~SwFmt();
76 	SwFmt &operator=(const SwFmt&);
77 
78 	// fuer die Abfrage der Writer-Funktionen
79 	sal_uInt16 Which() const { return nWhichId; }
80 
81 		// erfrage vom Format Informationen
82 	virtual sal_Bool GetInfo( SfxPoolItem& ) const;
83 
84 	// kopiere Attribute; auch ueber Dokumentgrenzen hinweg
85 	void CopyAttrs( const SwFmt&, sal_Bool bReplace=sal_True );
86 
87 	// loesche alle Attribute, die nicht in rFmt stehen
88 	void DelDiffs( const SfxItemSet& rSet );
89 	void DelDiffs( const SwFmt& rFmt ) { DelDiffs( rFmt.GetAttrSet() ); }
90 
91 	// Umhaengen des Formats (0 = Default)
92 	sal_Bool SetDerivedFrom(SwFmt *pDerivedFrom = 0);
93 
94 	// Ist bInParents sal_False,
95 	// wird nur in diesem Format nach dem Attribut gesucht.
96     inline const SfxPoolItem& GetFmtAttr( sal_uInt16 nWhich,
97                                           sal_Bool bInParents = sal_True ) const;
98 	inline SfxItemState GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent = sal_True,
99 									const SfxPoolItem **ppItem = 0 ) const;
100     // --> OD 2008-03-03 #refactorlists#
101     // methods renamed and made virtual
102     virtual sal_Bool SetFmtAttr( const SfxPoolItem& rAttr );
103     virtual sal_Bool SetFmtAttr( const SfxItemSet& rSet );
104     virtual sal_Bool ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
105     // <--
106 
107     // --> OD 2007-01-24 #i73790#
108     // Method renamed and made virtual
109     // Nimmt alle Hints aus dem Delta-Array,
110     // liefert die Anzahl der geloeschten Hints
111     virtual sal_uInt16 ResetAllFmtAttr();
112     // <--
113 
114 	inline SwFmt* DerivedFrom() const { return (SwFmt*)GetRegisteredIn(); }
115 	inline sal_Bool IsDefault() const { return DerivedFrom() == 0; }
116 
117 	inline const String& GetName() const 		{ return aFmtName; }
118 	void SetName( const String& rNewName, sal_Bool bBroadcast=sal_False );
119 	inline void SetName( const sal_Char* pNewName,
120 						 sal_Bool bBroadcast=sal_False);
121 
122 	// zur Abfrage des Attribute Arrays
123 	inline const SwAttrSet& GetAttrSet() const { return aSet; }
124 
125 	// Das Doc wird jetzt am SwAttrPool gesetzt. Dadurch hat man es immer
126 	// im Zugriff.
127 	const SwDoc *GetDoc() const			{ return aSet.GetDoc(); }
128 		  SwDoc *GetDoc() 				{ return aSet.GetDoc(); }
129 
130     /** Provides access to the document settings interface
131      */
132     const IDocumentSettingAccess* getIDocumentSettingAccess() const;
133 
134     /** Provides access to the document draw model interface
135      */
136     const IDocumentDrawModelAccess* getIDocumentDrawModelAccess() const;
137           IDocumentDrawModelAccess* getIDocumentDrawModelAccess();
138 
139     /** Provides access to the document layout interface
140      */
141     const IDocumentLayoutAccess* getIDocumentLayoutAccess() const;
142           IDocumentLayoutAccess* getIDocumentLayoutAccess();
143 
144      /** Provides access to the document idle timer interface
145      */
146     IDocumentTimerAccess* getIDocumentTimerAccess();
147 
148      /** Provides access to the document idle timer interface
149      */
150     IDocumentFieldsAccess* getIDocumentFieldsAccess();
151 
152      /** gives access to the chart data-provider
153      */
154     IDocumentChartDataProviderAccess* getIDocumentChartDataProviderAccess();
155 
156     // erfragen und setzen der Poolvorlagen-Id's
157 	sal_uInt16 GetPoolFmtId() const { return nPoolFmtId; }
158 	void SetPoolFmtId( sal_uInt16 nId ) { nPoolFmtId = nId; }
159 
160 	// erfragen und setzen der Hilfe-Id's fuer die Document-Vorlagen
161 	sal_uInt16 GetPoolHelpId() const { return nPoolHelpId; }
162 	void SetPoolHelpId( sal_uInt16 nId ) { nPoolHelpId = nId; }
163 	sal_uInt8 GetPoolHlpFileId() const { return nPoolHlpFileId; }
164 	void SetPoolHlpFileId( sal_uInt8 nId ) { nPoolHlpFileId = nId; }
165 	// erfrage die Attribut-Beschreibung, returnt den reingereichten String
166 	void GetPresentation( SfxItemPresentation ePres,
167 		SfxMapUnit eCoreMetric,	SfxMapUnit ePresMetric,	String &rText ) const
168 		{ aSet.GetPresentation( ePres, eCoreMetric,	ePresMetric, rText ); }
169 	// Das Format-ID fuer Lesen/Schreiben:
170     void   ResetWritten()    { bWritten = sal_False; }
171 
172 	// Abfragen/Setzen vom AutoFmt-Flag
173 	sal_Bool IsAuto() const 				{ return bAutoFmt; }
174 	void SetAuto( sal_Bool bNew = sal_False )	{ bAutoFmt = bNew; }
175 
176 	// Abfragen/Setzen vom bAutoUpdateFmt-Flag
177 	sal_Bool IsAutoUpdateFmt() const 				{ return bAutoUpdateFmt; }
178 	void SetAutoUpdateFmt( sal_Bool bNew = sal_True )	{ bAutoUpdateFmt = bNew; }
179 
180 	sal_Bool IsFmtInDTOR() const { return bFmtInDTOR; }
181 
182     // GetMethoden: das Bool gibt an, ob nur im Set (sal_False) oder auch in
183 	//				den Parents gesucht werden soll. Wird nichts gefunden,
184 	//				wird das deflt. Attribut returnt.
185 	// Charakter-Attribute	- impl. steht im charatr.hxx
186 	// AMA 12.10.94: Umstellung von SwFmt... auf Svx...
187 	inline const SvxPostureItem      &GetPosture( sal_Bool = sal_True ) const;
188 	inline const SvxWeightItem       &GetWeight( sal_Bool = sal_True ) const;
189 	inline const SvxShadowedItem     &GetShadowed( sal_Bool = sal_True ) const;
190 	inline const SvxAutoKernItem     &GetAutoKern( sal_Bool = sal_True ) const;
191 	inline const SvxWordLineModeItem &GetWordLineMode( sal_Bool = sal_True ) const;
192 	inline const SvxContourItem      &GetContour( sal_Bool = sal_True ) const;
193 	inline const SvxKerningItem      &GetKerning( sal_Bool = sal_True ) const;
194 	inline const SvxUnderlineItem    &GetUnderline( sal_Bool = sal_True ) const;
195 	inline const SvxOverlineItem     &GetOverline( sal_Bool = sal_True ) const;
196 	inline const SvxCrossedOutItem   &GetCrossedOut( sal_Bool = sal_True ) const;
197 	inline const SvxFontHeightItem   &GetSize( sal_Bool = sal_True ) const;
198 	inline const SvxPropSizeItem     &GetPropSize( sal_Bool = sal_True ) const;
199     inline const SvxFontItem         &GetFont( sal_Bool = sal_True ) const;
200 	inline const SvxColorItem        &GetColor( sal_Bool = sal_True ) const;
201 	inline const SvxCharSetColorItem &GetCharSetColor( sal_Bool = sal_True ) const;
202 	inline const SvxLanguageItem     &GetLanguage( sal_Bool = sal_True ) const;
203 	inline const SvxEscapementItem   &GetEscapement( sal_Bool = sal_True ) const;
204 	inline const SvxCaseMapItem      &GetCaseMap( sal_Bool = sal_True ) const;
205 	inline const SvxNoHyphenItem     &GetNoHyphenHere( sal_Bool = sal_True ) const;
206 	inline const SvxBlinkItem		 &GetBlink( sal_Bool = sal_True ) const;
207 	inline const SvxBrushItem	 	 &GetChrBackground( sal_Bool = sal_True ) const;
208 
209     inline const SvxFontItem         &GetCJKFont( sal_Bool = sal_True ) const;
210     inline const SvxFontHeightItem   &GetCJKSize( sal_Bool = sal_True ) const;
211     inline const SvxLanguageItem     &GetCJKLanguage( sal_Bool = sal_True ) const;
212     inline const SvxPostureItem      &GetCJKPosture( sal_Bool = sal_True ) const;
213     inline const SvxWeightItem       &GetCJKWeight( sal_Bool = sal_True ) const;
214     inline const SvxFontItem         &GetCTLFont( sal_Bool = sal_True ) const;
215     inline const SvxFontHeightItem   &GetCTLSize( sal_Bool = sal_True ) const;
216     inline const SvxLanguageItem     &GetCTLLanguage( sal_Bool = sal_True ) const;
217     inline const SvxPostureItem      &GetCTLPosture( sal_Bool = sal_True ) const;
218     inline const SvxWeightItem       &GetCTLWeight( sal_Bool = sal_True ) const;
219     inline const SfxBoolItem           &GetWritingDirection( sal_Bool = sal_True ) const;
220     inline const SvxEmphasisMarkItem &GetEmphasisMark( sal_Bool = sal_True ) const;
221     inline const SvxTwoLinesItem   &Get2Lines( sal_Bool = sal_True ) const;
222     inline const SvxCharScaleWidthItem &GetCharScaleW( sal_Bool = sal_True ) const;
223     inline const SvxCharRotateItem     &GetCharRotate( sal_Bool = sal_True ) const;
224     inline const SvxCharReliefItem     &GetCharRelief( sal_Bool = sal_True ) const;
225     inline const SvxCharHiddenItem   &GetCharHidden( sal_Bool = sal_True ) const;
226 
227 	// Frame-Attribute	- impl. steht im frmatr.hxx,
228     inline const SwFmtFillOrder           &GetFillOrder( sal_Bool = sal_True ) const;
229     inline const SwFmtFrmSize             &GetFrmSize( sal_Bool = sal_True ) const;
230     inline const SwFmtHeader          &GetHeader( sal_Bool = sal_True ) const;
231     inline const SwFmtFooter          &GetFooter( sal_Bool = sal_True ) const;
232     inline const SwFmtSurround            &GetSurround( sal_Bool = sal_True ) const;
233     inline const SwFmtHoriOrient      &GetHoriOrient( sal_Bool = sal_True ) const;
234     inline const SwFmtAnchor          &GetAnchor( sal_Bool = sal_True ) const;
235     inline const SwFmtCol                 &GetCol( sal_Bool = sal_True ) const;
236     inline const SvxPaperBinItem      &GetPaperBin( sal_Bool = sal_True ) const;
237     inline const SvxLRSpaceItem           &GetLRSpace( sal_Bool = sal_True ) const;
238     inline const SvxULSpaceItem           &GetULSpace( sal_Bool = sal_True ) const;
239     inline const SwFmtCntnt           &GetCntnt( sal_Bool = sal_True ) const;
240     inline const SvxPrintItem             &GetPrint( sal_Bool = sal_True ) const;
241     inline const SvxOpaqueItem            &GetOpaque( sal_Bool = sal_True ) const;
242     inline const SvxProtectItem           &GetProtect( sal_Bool = sal_True ) const;
243     inline const SwFmtVertOrient      &GetVertOrient( sal_Bool = sal_True ) const;
244     inline const SvxBoxItem               &GetBox( sal_Bool = sal_True ) const;
245     inline const SvxFmtKeepItem         &GetKeep( sal_Bool = sal_True ) const;
246     inline const SvxBrushItem           &GetBackground( sal_Bool = sal_True ) const;
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     // OD 18.09.2003 #i18732#
264     inline const SwFmtFollowTextFlow    &GetFollowTextFlow(sal_Bool = sal_True) const;
265     // OD 2004-05-05 #i28701#
266     inline const SwFmtWrapInfluenceOnObjPos& GetWrapInfluenceOnObjPos(sal_Bool = sal_True) const;
267 
268 	// Grafik-Attribute	- impl. steht im grfatr.hxx
269     inline const SwMirrorGrf          &GetMirrorGrf( sal_Bool = sal_True ) const;
270     inline const SwCropGrf            &GetCropGrf( sal_Bool = sal_True ) const;
271     inline const SwRotationGrf            &GetRotationGrf(sal_Bool = sal_True ) const;
272     inline const SwLuminanceGrf       &GetLuminanceGrf(sal_Bool = sal_True ) const;
273     inline const SwContrastGrf            &GetContrastGrf(sal_Bool = sal_True ) const;
274     inline const SwChannelRGrf            &GetChannelRGrf(sal_Bool = sal_True ) const;
275     inline const SwChannelGGrf            &GetChannelGGrf(sal_Bool = sal_True ) const;
276     inline const SwChannelBGrf            &GetChannelBGrf(sal_Bool = sal_True ) const;
277     inline const SwGammaGrf           &GetGammaGrf(sal_Bool = sal_True ) const;
278     inline const SwInvertGrf          &GetInvertGrf(sal_Bool = sal_True ) const;
279     inline const SwTransparencyGrf        &GetTransparencyGrf(sal_Bool = sal_True ) const;
280     inline const SwDrawModeGrf            &GetDrawModeGrf(sal_Bool = sal_True ) const;
281 
282 	// Paragraph-Attribute	- impl. steht im paratr.hxx
283     inline const SvxLineSpacingItem       &GetLineSpacing( sal_Bool = sal_True ) const;
284     inline const SvxAdjustItem            &GetAdjust( sal_Bool = sal_True ) const;
285     inline const SvxFmtSplitItem      &GetSplit( sal_Bool = sal_True ) const;
286     inline const SwRegisterItem           &GetRegister( sal_Bool = sal_True ) const;
287     inline const SwNumRuleItem            &GetNumRule( sal_Bool = sal_True ) const;
288     inline const SvxWidowsItem            &GetWidows( sal_Bool = sal_True ) const;
289     inline const SvxOrphansItem           &GetOrphans( sal_Bool = sal_True ) const;
290     inline const SvxTabStopItem           &GetTabStops( sal_Bool = sal_True ) const;
291     inline const SvxHyphenZoneItem        &GetHyphenZone( sal_Bool = sal_True ) const;
292     inline const SwFmtDrop                &GetDrop( sal_Bool = sal_True ) const;
293     inline const SvxScriptSpaceItem       &GetScriptSpace(sal_Bool = sal_True) const;
294     inline const SvxHangingPunctuationItem &GetHangingPunctuation(sal_Bool = sal_True) const;
295     inline const SvxForbiddenRuleItem     &GetForbiddenRule(sal_Bool = sal_True) const;
296     inline const SvxParaVertAlignItem &GetParaVertAlign(sal_Bool = sal_True) const;
297     inline const SvxParaGridItem        &GetParaGrid(sal_Bool = sal_True) const;
298     inline const SwParaConnectBorderItem &GetParaConnectBorder(sal_Bool = sal_True ) const;
299 
300 	// TabellenBox-Attribute	- impl. steht im cellatr.hxx
301     inline  const SwTblBoxNumFormat     &GetTblBoxNumFmt( sal_Bool = sal_True ) const;
302     inline  const SwTblBoxFormula       &GetTblBoxFormula( sal_Bool = sal_True ) const;
303     inline  const SwTblBoxValue         &GetTblBoxValue( sal_Bool = sal_True ) const;
304 
305     /** SwFmt::IsBackgroundTransparent - for feature #99657#
306 
307         OD 22.08.2002
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 sal_Bool IsBackgroundTransparent() const;
317 
318     /** SwFmt::IsShadowTransparent - for feature #99657#
319 
320         OD 22.08.2002
321         Virtual method to determine, if shadow of format is transparent.
322         Default implementation returns false. Thus, subclasses have to overload
323         method, if the specific subclass can have a transparent shadow.
324 
325         @author OD
326 
327         @return false, default implementation
328     */
329     virtual sal_Bool IsShadowTransparent() const;
330 };
331 
332 // --------------- inline Implementierungen ------------------------
333 
334 inline const SfxPoolItem& SwFmt::GetFmtAttr( sal_uInt16 nWhich,
335                                              sal_Bool bInParents ) const
336 {
337 	return aSet.Get( nWhich, bInParents );
338 }
339 
340 inline void SwFmt::SetName( const sal_Char* pNewName,
341 						 	sal_Bool bBroadcast )
342 {
343 	String aTmp( String::CreateFromAscii( pNewName ) );
344 	SetName( aTmp, bBroadcast );
345 }
346 
347 inline SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent,
348 										const SfxPoolItem **ppItem ) const
349 {
350 	return aSet.GetItemState( nWhich, bSrchInParent, ppItem );
351 }
352 
353 #undef inline
354 
355 #endif // _FORMAT_HXX
356