xref: /aoo4110/main/sw/inc/format.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _FORMAT_HXX
24 #define _FORMAT_HXX
25 
26 #include <tools/solar.h>
27 #include "swdllapi.h"
28 #include <errhdl.hxx>		// fuer ASSERT
29 #include <swatrset.hxx>		// fuer SfxItemPool/-Set, Attr forward decl.
30 #include <calbck.hxx>		// fuer SwModify
31 #include <hintids.hxx>
32 
33 class IDocumentSettingAccess;
34 class IDocumentDrawModelAccess;
35 class IDocumentLayoutAccess;
36 class IDocumentTimerAccess;
37 class IDocumentFieldsAccess;
38 class IDocumentChartDataProviderAccess;
39 class SwDoc;
40 
41 class SW_DLLPUBLIC SwFmt : public SwModify
42 {
43 	String aFmtName;
44 	SwAttrSet aSet;
45 
46 	sal_uInt16 nWhichId;
47 	sal_uInt16 nFmtId;			// Format-ID fuer Lesen/Schreiben
48 	sal_uInt16 nPoolFmtId;		// Id-fuer "automatich" erzeugte Formate
49 							// (ist keine harte Attributierung !!)
50 	sal_uInt16 nPoolHelpId;		// HelpId fuer diese Pool-Vorlage
51 	sal_uInt8 nPoolHlpFileId; 	// FilePos ans Doc auf die Vorlagen-Hilfen
52 	sal_Bool   bWritten : 1;	// sal_True: bereits geschrieben
53 	sal_Bool   bAutoFmt : 1;	// sal_False: es handelt sich um eine Vorlage
54 							// ist dflt immer auf sal_True !
55 	sal_Bool   bFmtInDTOR : 1;	// sal_True: das Format wird geloscht. Damit man in
56 							// der FmtChg-Message das erkennen kann!!!
57 	sal_Bool   bAutoUpdateFmt : 1;	// sal_True: am Format werden die Attribute
58 							// eines kompletten Absatzes gesetzt (UI-seitig!)
59 
60 protected:
61 	SwFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
62 			const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich );
63 	SwFmt( SwAttrPool& rPool, const String &rFmtNm, const sal_uInt16* pWhichRanges,
64 			SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich );
65 	SwFmt( const SwFmt& rFmt );
66    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue );
67 
68 public:
69 	TYPEINFO();		//Bereits in Basisklasse Client drin.
70 
71 	virtual ~SwFmt();
72 	SwFmt &operator=(const SwFmt&);
73 
74 	// fuer die Abfrage der Writer-Funktionen
Which() const75 	sal_uInt16 Which() const { return nWhichId; }
76 
77 		// erfrage vom Format Informationen
78 	virtual sal_Bool GetInfo( SfxPoolItem& ) const;
79 
80 	// kopiere Attribute; auch ueber Dokumentgrenzen hinweg
81 	void CopyAttrs( const SwFmt&, sal_Bool bReplace=sal_True );
82 
83 	// loesche alle Attribute, die nicht in rFmt stehen
84 	void DelDiffs( const SfxItemSet& rSet );
DelDiffs(const SwFmt & rFmt)85 	void DelDiffs( const SwFmt& rFmt ) { DelDiffs( rFmt.GetAttrSet() ); }
86 
87 	// Umhaengen des Formats (0 = Default)
88 	sal_Bool SetDerivedFrom(SwFmt *pDerivedFrom = 0);
89 
90 	// Ist bInParents sal_False,
91 	// wird nur in diesem Format nach dem Attribut gesucht.
92     inline const SfxPoolItem& GetFmtAttr( sal_uInt16 nWhich,
93                                           sal_Bool bInParents = sal_True ) const;
94 	inline SfxItemState GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent = sal_True,
95 									const SfxPoolItem **ppItem = 0 ) const;
96     // --> OD 2008-03-03 #refactorlists#
97     // methods renamed and made virtual
98     virtual sal_Bool SetFmtAttr( const SfxPoolItem& rAttr );
99     virtual sal_Bool SetFmtAttr( const SfxItemSet& rSet );
100     virtual sal_Bool ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
101     // <--
102 
103     // --> OD 2007-01-24 #i73790#
104     // Method renamed and made virtual
105     // Nimmt alle Hints aus dem Delta-Array,
106     // liefert die Anzahl der geloeschten Hints
107     virtual sal_uInt16 ResetAllFmtAttr();
108     // <--
109 
DerivedFrom() const110 	inline SwFmt* DerivedFrom() const { return (SwFmt*)GetRegisteredIn(); }
IsDefault() const111 	inline sal_Bool IsDefault() const { return DerivedFrom() == 0; }
112 
GetName() const113 	inline const String& GetName() const 		{ return aFmtName; }
114 	void SetName( const String& rNewName, sal_Bool bBroadcast=sal_False );
115 	inline void SetName( const sal_Char* pNewName,
116 						 sal_Bool bBroadcast=sal_False);
117 
118 	// zur Abfrage des Attribute Arrays
GetAttrSet() const119 	inline const SwAttrSet& GetAttrSet() const { return aSet; }
120 
121 	// Das Doc wird jetzt am SwAttrPool gesetzt. Dadurch hat man es immer
122 	// im Zugriff.
GetDoc() const123 	const SwDoc *GetDoc() const			{ return aSet.GetDoc(); }
GetDoc()124 		  SwDoc *GetDoc() 				{ return aSet.GetDoc(); }
125 
126     /** Provides access to the document settings interface
127      */
128     const IDocumentSettingAccess* getIDocumentSettingAccess() const;
129 
130     /** Provides access to the document draw model interface
131      */
132     const IDocumentDrawModelAccess* getIDocumentDrawModelAccess() const;
133           IDocumentDrawModelAccess* getIDocumentDrawModelAccess();
134 
135     /** Provides access to the document layout interface
136      */
137     const IDocumentLayoutAccess* getIDocumentLayoutAccess() const;
138           IDocumentLayoutAccess* getIDocumentLayoutAccess();
139 
140      /** Provides access to the document idle timer interface
141      */
142     IDocumentTimerAccess* getIDocumentTimerAccess();
143 
144      /** Provides access to the document idle timer interface
145      */
146     IDocumentFieldsAccess* getIDocumentFieldsAccess();
147 
148      /** gives access to the chart data-provider
149      */
150     IDocumentChartDataProviderAccess* getIDocumentChartDataProviderAccess();
151 
152     // erfragen und setzen der Poolvorlagen-Id's
GetPoolFmtId() const153 	sal_uInt16 GetPoolFmtId() const { return nPoolFmtId; }
SetPoolFmtId(sal_uInt16 nId)154 	void SetPoolFmtId( sal_uInt16 nId ) { nPoolFmtId = nId; }
155 
156 	// erfragen und setzen der Hilfe-Id's fuer die Document-Vorlagen
GetPoolHelpId() const157 	sal_uInt16 GetPoolHelpId() const { return nPoolHelpId; }
SetPoolHelpId(sal_uInt16 nId)158 	void SetPoolHelpId( sal_uInt16 nId ) { nPoolHelpId = nId; }
GetPoolHlpFileId() const159 	sal_uInt8 GetPoolHlpFileId() const { return nPoolHlpFileId; }
SetPoolHlpFileId(sal_uInt8 nId)160 	void SetPoolHlpFileId( sal_uInt8 nId ) { nPoolHlpFileId = nId; }
161 	// erfrage die Attribut-Beschreibung, returnt den reingereichten String
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreMetric,SfxMapUnit ePresMetric,String & rText) const162 	void GetPresentation( SfxItemPresentation ePres,
163 		SfxMapUnit eCoreMetric,	SfxMapUnit ePresMetric,	String &rText ) const
164 		{ aSet.GetPresentation( ePres, eCoreMetric,	ePresMetric, rText ); }
165 	// Das Format-ID fuer Lesen/Schreiben:
ResetWritten()166     void   ResetWritten()    { bWritten = sal_False; }
167 
168 	// Abfragen/Setzen vom AutoFmt-Flag
IsAuto() const169 	sal_Bool IsAuto() const 				{ return bAutoFmt; }
SetAuto(sal_Bool bNew=sal_False)170 	void SetAuto( sal_Bool bNew = sal_False )	{ bAutoFmt = bNew; }
171 
172 	// Abfragen/Setzen vom bAutoUpdateFmt-Flag
IsAutoUpdateFmt() const173 	sal_Bool IsAutoUpdateFmt() const 				{ return bAutoUpdateFmt; }
SetAutoUpdateFmt(sal_Bool bNew=sal_True)174 	void SetAutoUpdateFmt( sal_Bool bNew = sal_True )	{ bAutoUpdateFmt = bNew; }
175 
IsFmtInDTOR() const176 	sal_Bool IsFmtInDTOR() const { return bFmtInDTOR; }
177 
178     // GetMethoden: das Bool gibt an, ob nur im Set (sal_False) oder auch in
179 	//				den Parents gesucht werden soll. Wird nichts gefunden,
180 	//				wird das deflt. Attribut returnt.
181 	// Charakter-Attribute	- impl. steht im charatr.hxx
182 	// AMA 12.10.94: Umstellung von SwFmt... auf Svx...
183 	inline const SvxPostureItem      &GetPosture( sal_Bool = sal_True ) const;
184 	inline const SvxWeightItem       &GetWeight( sal_Bool = sal_True ) const;
185 	inline const SvxShadowedItem     &GetShadowed( sal_Bool = sal_True ) const;
186 	inline const SvxAutoKernItem     &GetAutoKern( sal_Bool = sal_True ) const;
187 	inline const SvxWordLineModeItem &GetWordLineMode( sal_Bool = sal_True ) const;
188 	inline const SvxContourItem      &GetContour( sal_Bool = sal_True ) const;
189 	inline const SvxKerningItem      &GetKerning( sal_Bool = sal_True ) const;
190 	inline const SvxUnderlineItem    &GetUnderline( sal_Bool = sal_True ) const;
191 	inline const SvxOverlineItem     &GetOverline( sal_Bool = sal_True ) const;
192 	inline const SvxCrossedOutItem   &GetCrossedOut( sal_Bool = sal_True ) const;
193 	inline const SvxFontHeightItem   &GetSize( sal_Bool = sal_True ) const;
194 	inline const SvxPropSizeItem     &GetPropSize( sal_Bool = sal_True ) const;
195     inline const SvxFontItem         &GetFont( sal_Bool = sal_True ) const;
196 	inline const SvxColorItem        &GetColor( sal_Bool = sal_True ) const;
197 	inline const SvxCharSetColorItem &GetCharSetColor( sal_Bool = sal_True ) const;
198 	inline const SvxLanguageItem     &GetLanguage( sal_Bool = sal_True ) const;
199 	inline const SvxEscapementItem   &GetEscapement( sal_Bool = sal_True ) const;
200 	inline const SvxCaseMapItem      &GetCaseMap( sal_Bool = sal_True ) const;
201 	inline const SvxNoHyphenItem     &GetNoHyphenHere( sal_Bool = sal_True ) const;
202 	inline const SvxBlinkItem		 &GetBlink( sal_Bool = sal_True ) const;
203 	inline const SvxBrushItem	 	 &GetChrBackground( sal_Bool = sal_True ) const;
204 
205     inline const SvxFontItem         &GetCJKFont( sal_Bool = sal_True ) const;
206     inline const SvxFontHeightItem   &GetCJKSize( sal_Bool = sal_True ) const;
207     inline const SvxLanguageItem     &GetCJKLanguage( sal_Bool = sal_True ) const;
208     inline const SvxPostureItem      &GetCJKPosture( sal_Bool = sal_True ) const;
209     inline const SvxWeightItem       &GetCJKWeight( sal_Bool = sal_True ) const;
210     inline const SvxFontItem         &GetCTLFont( sal_Bool = sal_True ) const;
211     inline const SvxFontHeightItem   &GetCTLSize( sal_Bool = sal_True ) const;
212     inline const SvxLanguageItem     &GetCTLLanguage( sal_Bool = sal_True ) const;
213     inline const SvxPostureItem      &GetCTLPosture( sal_Bool = sal_True ) const;
214     inline const SvxWeightItem       &GetCTLWeight( sal_Bool = sal_True ) const;
215     inline const SfxBoolItem           &GetWritingDirection( sal_Bool = sal_True ) const;
216     inline const SvxEmphasisMarkItem &GetEmphasisMark( sal_Bool = sal_True ) const;
217     inline const SvxTwoLinesItem   &Get2Lines( sal_Bool = sal_True ) const;
218     inline const SvxCharScaleWidthItem &GetCharScaleW( sal_Bool = sal_True ) const;
219     inline const SvxCharRotateItem     &GetCharRotate( sal_Bool = sal_True ) const;
220     inline const SvxCharReliefItem     &GetCharRelief( sal_Bool = sal_True ) const;
221     inline const SvxCharHiddenItem   &GetCharHidden( sal_Bool = sal_True ) const;
222 
223 	// Frame-Attribute	- impl. steht im frmatr.hxx,
224     inline const SwFmtFillOrder           &GetFillOrder( sal_Bool = sal_True ) const;
225     inline const SwFmtFrmSize             &GetFrmSize( sal_Bool = sal_True ) const;
226     inline const SwFmtHeader          &GetHeader( sal_Bool = sal_True ) const;
227     inline const SwFmtFooter          &GetFooter( sal_Bool = sal_True ) const;
228     inline const SwFmtSurround            &GetSurround( sal_Bool = sal_True ) const;
229     inline const SwFmtHoriOrient      &GetHoriOrient( sal_Bool = sal_True ) const;
230     inline const SwFmtAnchor          &GetAnchor( sal_Bool = sal_True ) const;
231     inline const SwFmtCol                 &GetCol( sal_Bool = sal_True ) const;
232     inline const SvxPaperBinItem      &GetPaperBin( sal_Bool = sal_True ) const;
233     inline const SvxLRSpaceItem           &GetLRSpace( sal_Bool = sal_True ) const;
234     inline const SvxULSpaceItem           &GetULSpace( sal_Bool = sal_True ) const;
235     inline const SwFmtCntnt           &GetCntnt( sal_Bool = sal_True ) const;
236     inline const SvxPrintItem             &GetPrint( sal_Bool = sal_True ) const;
237     inline const SvxOpaqueItem            &GetOpaque( sal_Bool = sal_True ) const;
238     inline const SvxProtectItem           &GetProtect( sal_Bool = sal_True ) const;
239     inline const SwFmtVertOrient      &GetVertOrient( sal_Bool = sal_True ) const;
240     inline const SvxBoxItem               &GetBox( sal_Bool = sal_True ) const;
241     inline const SvxFmtKeepItem         &GetKeep( sal_Bool = sal_True ) const;
242     inline const SvxBrushItem           &GetBackground( sal_Bool = sal_True ) const;
243     inline const SvxShadowItem            &GetShadow( sal_Bool = sal_True ) const;
244     inline const SwFmtPageDesc            &GetPageDesc( sal_Bool = sal_True ) const;
245     inline const SvxFmtBreakItem      &GetBreak( sal_Bool = sal_True ) const;
246     inline const SvxMacroItem             &GetMacro( sal_Bool = sal_True ) const;
247     inline const SwFmtURL             &GetURL( sal_Bool = sal_True ) const;
248     inline const SwFmtEditInReadonly  &GetEditInReadonly( sal_Bool = sal_True ) const;
249     inline const SwFmtLayoutSplit     &GetLayoutSplit( sal_Bool = sal_True ) const;
250     inline const SwFmtRowSplit          &GetRowSplit( sal_Bool = sal_True ) const;
251     inline const SwFmtChain               &GetChain( sal_Bool = sal_True ) const;
252     inline const SwFmtLineNumber      &GetLineNumber( sal_Bool = sal_True ) const;
253     inline const SwFmtFtnAtTxtEnd     &GetFtnAtTxtEnd( sal_Bool = sal_True ) const;
254     inline const SwFmtEndAtTxtEnd     &GetEndAtTxtEnd( sal_Bool = sal_True ) const;
255     inline const SwFmtNoBalancedColumns &GetBalancedColumns( sal_Bool = sal_True ) const;
256     inline const SvxFrameDirectionItem    &GetFrmDir( sal_Bool = sal_True ) const;
257     inline const SwTextGridItem         &GetTextGrid( sal_Bool = sal_True ) const;
258     inline const SwHeaderAndFooterEatSpacingItem &GetHeaderAndFooterEatSpacing( sal_Bool = sal_True ) const;
259     // OD 18.09.2003 #i18732#
260     inline const SwFmtFollowTextFlow    &GetFollowTextFlow(sal_Bool = sal_True) const;
261     // OD 2004-05-05 #i28701#
262     inline const SwFmtWrapInfluenceOnObjPos& GetWrapInfluenceOnObjPos(sal_Bool = sal_True) const;
263 
264 	// Grafik-Attribute	- impl. steht im grfatr.hxx
265     inline const SwMirrorGrf          &GetMirrorGrf( sal_Bool = sal_True ) const;
266     inline const SwCropGrf            &GetCropGrf( sal_Bool = sal_True ) const;
267     inline const SwRotationGrf            &GetRotationGrf(sal_Bool = sal_True ) const;
268     inline const SwLuminanceGrf       &GetLuminanceGrf(sal_Bool = sal_True ) const;
269     inline const SwContrastGrf            &GetContrastGrf(sal_Bool = sal_True ) const;
270     inline const SwChannelRGrf            &GetChannelRGrf(sal_Bool = sal_True ) const;
271     inline const SwChannelGGrf            &GetChannelGGrf(sal_Bool = sal_True ) const;
272     inline const SwChannelBGrf            &GetChannelBGrf(sal_Bool = sal_True ) const;
273     inline const SwGammaGrf           &GetGammaGrf(sal_Bool = sal_True ) const;
274     inline const SwInvertGrf          &GetInvertGrf(sal_Bool = sal_True ) const;
275     inline const SwTransparencyGrf        &GetTransparencyGrf(sal_Bool = sal_True ) const;
276     inline const SwDrawModeGrf            &GetDrawModeGrf(sal_Bool = sal_True ) const;
277 
278 	// Paragraph-Attribute	- impl. steht im paratr.hxx
279     inline const SvxLineSpacingItem       &GetLineSpacing( sal_Bool = sal_True ) const;
280     inline const SvxAdjustItem            &GetAdjust( sal_Bool = sal_True ) const;
281     inline const SvxFmtSplitItem      &GetSplit( sal_Bool = sal_True ) const;
282     inline const SwRegisterItem           &GetRegister( sal_Bool = sal_True ) const;
283     inline const SwNumRuleItem            &GetNumRule( sal_Bool = sal_True ) const;
284     inline const SvxWidowsItem            &GetWidows( sal_Bool = sal_True ) const;
285     inline const SvxOrphansItem           &GetOrphans( sal_Bool = sal_True ) const;
286     inline const SvxTabStopItem           &GetTabStops( sal_Bool = sal_True ) const;
287     inline const SvxHyphenZoneItem        &GetHyphenZone( sal_Bool = sal_True ) const;
288     inline const SwFmtDrop                &GetDrop( sal_Bool = sal_True ) const;
289     inline const SvxScriptSpaceItem       &GetScriptSpace(sal_Bool = sal_True) const;
290     inline const SvxHangingPunctuationItem &GetHangingPunctuation(sal_Bool = sal_True) const;
291     inline const SvxForbiddenRuleItem     &GetForbiddenRule(sal_Bool = sal_True) const;
292     inline const SvxParaVertAlignItem &GetParaVertAlign(sal_Bool = sal_True) const;
293     inline const SvxParaGridItem        &GetParaGrid(sal_Bool = sal_True) const;
294     inline const SwParaConnectBorderItem &GetParaConnectBorder(sal_Bool = sal_True ) const;
295 
296 	// TabellenBox-Attribute	- impl. steht im cellatr.hxx
297     inline  const SwTblBoxNumFormat     &GetTblBoxNumFmt( sal_Bool = sal_True ) const;
298     inline  const SwTblBoxFormula       &GetTblBoxFormula( sal_Bool = sal_True ) const;
299     inline  const SwTblBoxValue         &GetTblBoxValue( sal_Bool = sal_True ) const;
300 
301     /** SwFmt::IsBackgroundTransparent - for feature #99657#
302 
303         OD 22.08.2002
304         Virtual method to determine, if background of format is transparent.
305         Default implementation returns false. Thus, subclasses have to overload
306         method, if the specific subclass can have a transparent background.
307 
308         @author OD
309 
310         @return false, default implementation
311     */
312     virtual sal_Bool IsBackgroundTransparent() const;
313 
314     /** SwFmt::IsShadowTransparent - for feature #99657#
315 
316         OD 22.08.2002
317         Virtual method to determine, if shadow of format is transparent.
318         Default implementation returns false. Thus, subclasses have to overload
319         method, if the specific subclass can have a transparent shadow.
320 
321         @author OD
322 
323         @return false, default implementation
324     */
325     virtual sal_Bool IsShadowTransparent() const;
326 };
327 
328 // --------------- inline Implementierungen ------------------------
329 
GetFmtAttr(sal_uInt16 nWhich,sal_Bool bInParents) const330 inline const SfxPoolItem& SwFmt::GetFmtAttr( sal_uInt16 nWhich,
331                                              sal_Bool bInParents ) const
332 {
333 	return aSet.Get( nWhich, bInParents );
334 }
335 
SetName(const sal_Char * pNewName,sal_Bool bBroadcast)336 inline void SwFmt::SetName( const sal_Char* pNewName,
337 						 	sal_Bool bBroadcast )
338 {
339 	String aTmp( String::CreateFromAscii( pNewName ) );
340 	SetName( aTmp, bBroadcast );
341 }
342 
GetItemState(sal_uInt16 nWhich,sal_Bool bSrchInParent,const SfxPoolItem ** ppItem) const343 inline SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent,
344 										const SfxPoolItem **ppItem ) const
345 {
346 	return aSet.GetItemState( nWhich, bSrchInParent, ppItem );
347 }
348 
349 #undef inline
350 
351 #endif // _FORMAT_HXX
352