xref: /trunk/main/sw/inc/format.hxx (revision 28160478)
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 #ifndef _FORMAT_HXX
23 #define _FORMAT_HXX
24 
25 #include <tools/solar.h>
26 #include "swdllapi.h"
27 #include <errhdl.hxx>		// fuer ASSERT
28 #include <swatrset.hxx>		// fuer SfxItemPool/-Set, Attr forward decl.
29 #include <calbck.hxx>		// fuer SwModify
30 #include <hintids.hxx>
31 #include <boost/shared_ptr.hpp>
32 
33 class IDocumentSettingAccess;
34 class IDocumentDrawModelAccess;
35 class IDocumentLayoutAccess;
36 class IDocumentTimerAccess;
37 class IDocumentFieldsAccess;
38 class IDocumentChartDataProviderAccess;
39 class SwDoc;
40 
41 namespace drawinglayer { namespace attribute {
42     class SdrAllFillAttributesHelper;
43     typedef boost::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr;
44 }}
45 
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 fuer Lesen/Schreiben
53 	sal_uInt16 nPoolFmtId;		// Id-fuer "automatich" erzeugte Formate
54 							// (ist keine harte Attributierung !!)
55 	sal_uInt16 nPoolHelpId;		// HelpId fuer diese Pool-Vorlage
56 	sal_uInt8 nPoolHlpFileId; 	// FilePos ans Doc auf die Vorlagen-Hilfen
57 	sal_Bool   bWritten : 1;	// sal_True: bereits geschrieben
58 	sal_Bool   bAutoFmt : 1;	// sal_False: es handelt sich um eine Vorlage
59 							// ist dflt immer auf sal_True !
60 	sal_Bool   bFmtInDTOR : 1;	// sal_True: das Format wird geloscht. Damit man in
61 							// der FmtChg-Message das erkennen kann!!!
62 	sal_Bool   bAutoUpdateFmt : 1;	// sal_True: am Format werden die Attribute
63 							// eines kompletten Absatzes gesetzt (UI-seitig!)
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();		//Bereits in Basisklasse Client drin.
75 
76 	virtual ~SwFmt();
77 	SwFmt &operator=(const SwFmt&);
78 
79 	// fuer die Abfrage der Writer-Funktionen
Which() const80 	sal_uInt16 Which() const { return nWhichId; }
81 
82 		// erfrage vom Format Informationen
83 	virtual sal_Bool GetInfo( SfxPoolItem& ) const;
84 
85 	// kopiere Attribute; auch ueber Dokumentgrenzen hinweg
86 	void CopyAttrs( const SwFmt&, sal_Bool bReplace=sal_True );
87 
88 	// loesche alle Attribute, die nicht in rFmt stehen
89 	void DelDiffs( const SfxItemSet& rSet );
DelDiffs(const SwFmt & rFmt)90 	void DelDiffs( const SwFmt& rFmt ) { DelDiffs( rFmt.GetAttrSet() ); }
91 
92 	// Umhaengen des Formats (0 = Default)
93 	sal_Bool SetDerivedFrom(SwFmt *pDerivedFrom = 0);
94 
95 	// Ist bInParents sal_False,
96 	// wird nur in diesem Format nach dem Attribut gesucht.
97     //UUUUinline
98     const SfxPoolItem& GetFmtAttr( sal_uInt16 nWhich, sal_Bool bInParents = sal_True ) const;
99     //UUUUinline
100     SfxItemState GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent = sal_True, const SfxPoolItem **ppItem = 0 ) const;
101 
102     // --> OD 2008-03-03 #refactorlists#
103     // methods renamed and made virtual
104     virtual sal_Bool SetFmtAttr( const SfxPoolItem& rAttr );
105     virtual sal_Bool SetFmtAttr( const SfxItemSet& rSet );
106     virtual sal_Bool ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
107     // <--
108 
109     // --> OD 2007-01-24 #i73790#
110     // Method renamed and made virtual
111     // Nimmt alle Hints aus dem Delta-Array,
112     // liefert die Anzahl der geloeschten Hints
113     virtual sal_uInt16 ResetAllFmtAttr();
114     // <--
115 
DerivedFrom() const116 	inline SwFmt* DerivedFrom() const { return (SwFmt*)GetRegisteredIn(); }
IsDefault() const117 	inline sal_Bool IsDefault() const { return DerivedFrom() == 0; }
118 
GetName() const119 	inline const String& GetName() const 		{ return aFmtName; }
120 	void SetName( const String& rNewName, sal_Bool bBroadcast=sal_False );
121 	inline void SetName( const sal_Char* pNewName,
122 						 sal_Bool bBroadcast=sal_False);
123 
124 	// zur Abfrage des Attribute Arrays
GetAttrSet() const125 	inline const SwAttrSet& GetAttrSet() const { return aSet; }
126 
127 	// Das Doc wird jetzt am SwAttrPool gesetzt. Dadurch hat man es immer
128 	// im Zugriff.
GetDoc() const129 	const SwDoc *GetDoc() const			{ return aSet.GetDoc(); }
GetDoc()130 		  SwDoc *GetDoc() 				{ return aSet.GetDoc(); }
131 
132     /** Provides access to the document settings interface
133      */
134     const IDocumentSettingAccess* getIDocumentSettingAccess() const;
135 
136     /** Provides access to the document draw model interface
137      */
138     const IDocumentDrawModelAccess* getIDocumentDrawModelAccess() const;
139           IDocumentDrawModelAccess* getIDocumentDrawModelAccess();
140 
141     /** Provides access to the document layout interface
142      */
143     const IDocumentLayoutAccess* getIDocumentLayoutAccess() const;
144           IDocumentLayoutAccess* getIDocumentLayoutAccess();
145 
146      /** Provides access to the document idle timer interface
147      */
148     IDocumentTimerAccess* getIDocumentTimerAccess();
149 
150      /** Provides access to the document idle timer interface
151      */
152     IDocumentFieldsAccess* getIDocumentFieldsAccess();
153 
154      /** gives access to the chart data-provider
155      */
156     IDocumentChartDataProviderAccess* getIDocumentChartDataProviderAccess();
157 
158     // erfragen und setzen der Poolvorlagen-Id's
GetPoolFmtId() const159 	sal_uInt16 GetPoolFmtId() const { return nPoolFmtId; }
SetPoolFmtId(sal_uInt16 nId)160 	void SetPoolFmtId( sal_uInt16 nId ) { nPoolFmtId = nId; }
161 
162 	// erfragen und setzen der Hilfe-Id's fuer die Document-Vorlagen
GetPoolHelpId() const163 	sal_uInt16 GetPoolHelpId() const { return nPoolHelpId; }
SetPoolHelpId(sal_uInt16 nId)164 	void SetPoolHelpId( sal_uInt16 nId ) { nPoolHelpId = nId; }
GetPoolHlpFileId() const165 	sal_uInt8 GetPoolHlpFileId() const { return nPoolHlpFileId; }
SetPoolHlpFileId(sal_uInt8 nId)166 	void SetPoolHlpFileId( sal_uInt8 nId ) { nPoolHlpFileId = nId; }
167 	// erfrage die Attribut-Beschreibung, returnt den reingereichten String
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreMetric,SfxMapUnit ePresMetric,String & rText) const168 	void GetPresentation( SfxItemPresentation ePres,
169 		SfxMapUnit eCoreMetric,	SfxMapUnit ePresMetric,	String &rText ) const
170 		{ aSet.GetPresentation( ePres, eCoreMetric,	ePresMetric, rText ); }
171 	// Das Format-ID fuer Lesen/Schreiben:
ResetWritten()172     void   ResetWritten()    { bWritten = sal_False; }
173 
174 	// Abfragen/Setzen vom AutoFmt-Flag
IsAuto() const175 	sal_Bool IsAuto() const 				{ return bAutoFmt; }
SetAuto(sal_Bool bNew=sal_False)176 	void SetAuto( sal_Bool bNew = sal_False )	{ bAutoFmt = bNew; }
177 
178 	// Abfragen/Setzen vom bAutoUpdateFmt-Flag
IsAutoUpdateFmt() const179 	sal_Bool IsAutoUpdateFmt() const 				{ return bAutoUpdateFmt; }
SetAutoUpdateFmt(sal_Bool bNew=sal_True)180 	void SetAutoUpdateFmt( sal_Bool bNew = sal_True )	{ bAutoUpdateFmt = bNew; }
181 
IsFmtInDTOR() const182 	sal_Bool IsFmtInDTOR() const { return bFmtInDTOR; }
183 
184     // GetMethoden: das Bool gibt an, ob nur im Set (sal_False) oder auch in
185 	//				den Parents gesucht werden soll. Wird nichts gefunden,
186 	//				wird das deflt. Attribut returnt.
187 	// Charakter-Attribute	- impl. steht im charatr.hxx
188 	// AMA 12.10.94: Umstellung von SwFmt... auf Svx...
189 	inline const SvxPostureItem      &GetPosture( sal_Bool = sal_True ) const;
190 	inline const SvxWeightItem       &GetWeight( sal_Bool = sal_True ) const;
191 	inline const SvxShadowedItem     &GetShadowed( sal_Bool = sal_True ) const;
192 	inline const SvxAutoKernItem     &GetAutoKern( sal_Bool = sal_True ) const;
193 	inline const SvxWordLineModeItem &GetWordLineMode( sal_Bool = sal_True ) const;
194 	inline const SvxContourItem      &GetContour( sal_Bool = sal_True ) const;
195 	inline const SvxKerningItem      &GetKerning( sal_Bool = sal_True ) const;
196 	inline const SvxUnderlineItem    &GetUnderline( sal_Bool = sal_True ) const;
197 	inline const SvxOverlineItem     &GetOverline( sal_Bool = sal_True ) const;
198 	inline const SvxCrossedOutItem   &GetCrossedOut( sal_Bool = sal_True ) const;
199 	inline const SvxFontHeightItem   &GetSize( sal_Bool = sal_True ) const;
200 	inline const SvxPropSizeItem     &GetPropSize( sal_Bool = sal_True ) const;
201     inline const SvxFontItem         &GetFont( sal_Bool = sal_True ) const;
202 	inline const SvxColorItem        &GetColor( sal_Bool = sal_True ) const;
203 	inline const SvxCharSetColorItem &GetCharSetColor( sal_Bool = sal_True ) const;
204 	inline const SvxLanguageItem     &GetLanguage( sal_Bool = sal_True ) const;
205 	inline const SvxEscapementItem   &GetEscapement( sal_Bool = sal_True ) const;
206 	inline const SvxCaseMapItem      &GetCaseMap( sal_Bool = sal_True ) const;
207 	inline const SvxNoHyphenItem     &GetNoHyphenHere( sal_Bool = sal_True ) const;
208 	inline const SvxBlinkItem		 &GetBlink( sal_Bool = sal_True ) const;
209 	inline const SvxBrushItem	 	 &GetChrBackground( sal_Bool = sal_True ) const;
210 
211     inline const SvxFontItem         &GetCJKFont( sal_Bool = sal_True ) const;
212     inline const SvxFontHeightItem   &GetCJKSize( sal_Bool = sal_True ) const;
213     inline const SvxLanguageItem     &GetCJKLanguage( sal_Bool = sal_True ) const;
214     inline const SvxPostureItem      &GetCJKPosture( sal_Bool = sal_True ) const;
215     inline const SvxWeightItem       &GetCJKWeight( sal_Bool = sal_True ) const;
216     inline const SvxFontItem         &GetCTLFont( sal_Bool = sal_True ) const;
217     inline const SvxFontHeightItem   &GetCTLSize( sal_Bool = sal_True ) const;
218     inline const SvxLanguageItem     &GetCTLLanguage( sal_Bool = sal_True ) const;
219     inline const SvxPostureItem      &GetCTLPosture( sal_Bool = sal_True ) const;
220     inline const SvxWeightItem       &GetCTLWeight( sal_Bool = sal_True ) const;
221     inline const SfxBoolItem           &GetWritingDirection( sal_Bool = sal_True ) const;
222     inline const SvxEmphasisMarkItem &GetEmphasisMark( sal_Bool = sal_True ) const;
223     inline const SvxTwoLinesItem   &Get2Lines( sal_Bool = sal_True ) const;
224     inline const SvxCharScaleWidthItem &GetCharScaleW( sal_Bool = sal_True ) const;
225     inline const SvxCharRotateItem     &GetCharRotate( sal_Bool = sal_True ) const;
226     inline const SvxCharReliefItem     &GetCharRelief( sal_Bool = sal_True ) const;
227     inline const SvxCharHiddenItem   &GetCharHidden( sal_Bool = sal_True ) const;
228 
229 	// Frame-Attribute	- impl. steht im frmatr.hxx,
230     inline const SwFmtFillOrder           &GetFillOrder( sal_Bool = sal_True ) const;
231     inline const SwFmtFrmSize             &GetFrmSize( sal_Bool = sal_True ) const;
232     inline const SwFmtHeader          &GetHeader( sal_Bool = sal_True ) const;
233     inline const SwFmtFooter          &GetFooter( sal_Bool = sal_True ) const;
234     inline const SwFmtSurround            &GetSurround( sal_Bool = sal_True ) const;
235     inline const SwFmtHoriOrient      &GetHoriOrient( sal_Bool = sal_True ) const;
236     inline const SwFmtAnchor          &GetAnchor( sal_Bool = sal_True ) const;
237     inline const SwFmtCol                 &GetCol( sal_Bool = sal_True ) const;
238     inline const SvxPaperBinItem      &GetPaperBin( sal_Bool = sal_True ) const;
239     inline const SvxLRSpaceItem           &GetLRSpace( sal_Bool = sal_True ) const;
240     inline const SvxULSpaceItem           &GetULSpace( sal_Bool = sal_True ) const;
241     inline const SwFmtCntnt           &GetCntnt( sal_Bool = sal_True ) const;
242     inline const SvxPrintItem             &GetPrint( sal_Bool = sal_True ) const;
243     inline const SvxOpaqueItem            &GetOpaque( sal_Bool = sal_True ) const;
244     inline const SvxProtectItem           &GetProtect( sal_Bool = sal_True ) const;
245     inline const SwFmtVertOrient      &GetVertOrient( sal_Bool = sal_True ) const;
246     inline const SvxBoxItem               &GetBox( sal_Bool = sal_True ) const;
247     inline const SvxFmtKeepItem         &GetKeep( sal_Bool = sal_True ) const;
248 
249     //UUUU Get SvxBrushItem for Background fill (partially for backwards compatibility)
250     const SvxBrushItem& GetBackground( sal_Bool = sal_True ) const;
251 
252     inline const SvxShadowItem            &GetShadow( sal_Bool = sal_True ) const;
253     inline const SwFmtPageDesc            &GetPageDesc( sal_Bool = sal_True ) const;
254     inline const SvxFmtBreakItem      &GetBreak( sal_Bool = sal_True ) const;
255     inline const SvxMacroItem             &GetMacro( sal_Bool = sal_True ) const;
256     inline const SwFmtURL             &GetURL( sal_Bool = sal_True ) const;
257     inline const SwFmtEditInReadonly  &GetEditInReadonly( sal_Bool = sal_True ) const;
258     inline const SwFmtLayoutSplit     &GetLayoutSplit( sal_Bool = sal_True ) const;
259     inline const SwFmtRowSplit          &GetRowSplit( sal_Bool = sal_True ) const;
260     inline const SwFmtChain               &GetChain( sal_Bool = sal_True ) const;
261     inline const SwFmtLineNumber      &GetLineNumber( sal_Bool = sal_True ) const;
262     inline const SwFmtFtnAtTxtEnd     &GetFtnAtTxtEnd( sal_Bool = sal_True ) const;
263     inline const SwFmtEndAtTxtEnd     &GetEndAtTxtEnd( sal_Bool = sal_True ) const;
264     inline const SwFmtNoBalancedColumns &GetBalancedColumns( sal_Bool = sal_True ) const;
265     inline const SvxFrameDirectionItem    &GetFrmDir( sal_Bool = sal_True ) const;
266     inline const SwTextGridItem         &GetTextGrid( sal_Bool = sal_True ) const;
267     inline const SwHeaderAndFooterEatSpacingItem &GetHeaderAndFooterEatSpacing( sal_Bool = sal_True ) const;
268     // OD 18.09.2003 #i18732#
269     inline const SwFmtFollowTextFlow    &GetFollowTextFlow(sal_Bool = sal_True) const;
270     // OD 2004-05-05 #i28701#
271     inline const SwFmtWrapInfluenceOnObjPos& GetWrapInfluenceOnObjPos(sal_Bool = sal_True) const;
272 
273 	// Grafik-Attribute	- impl. steht im grfatr.hxx
274     inline const SwMirrorGrf          &GetMirrorGrf( sal_Bool = sal_True ) const;
275     inline const SwCropGrf            &GetCropGrf( sal_Bool = sal_True ) const;
276     inline const SwRotationGrf            &GetRotationGrf(sal_Bool = sal_True ) const;
277     inline const SwLuminanceGrf       &GetLuminanceGrf(sal_Bool = sal_True ) const;
278     inline const SwContrastGrf            &GetContrastGrf(sal_Bool = sal_True ) const;
279     inline const SwChannelRGrf            &GetChannelRGrf(sal_Bool = sal_True ) const;
280     inline const SwChannelGGrf            &GetChannelGGrf(sal_Bool = sal_True ) const;
281     inline const SwChannelBGrf            &GetChannelBGrf(sal_Bool = sal_True ) const;
282     inline const SwGammaGrf           &GetGammaGrf(sal_Bool = sal_True ) const;
283     inline const SwInvertGrf          &GetInvertGrf(sal_Bool = sal_True ) const;
284     inline const SwTransparencyGrf        &GetTransparencyGrf(sal_Bool = sal_True ) const;
285     inline const SwDrawModeGrf            &GetDrawModeGrf(sal_Bool = sal_True ) const;
286 
287 	// Paragraph-Attribute	- impl. steht im paratr.hxx
288     inline const SvxLineSpacingItem       &GetLineSpacing( sal_Bool = sal_True ) const;
289     inline const SvxAdjustItem            &GetAdjust( sal_Bool = sal_True ) const;
290     inline const SvxFmtSplitItem      &GetSplit( sal_Bool = sal_True ) const;
291     inline const SwRegisterItem           &GetRegister( sal_Bool = sal_True ) const;
292     inline const SwNumRuleItem            &GetNumRule( sal_Bool = sal_True ) const;
293     inline const SvxWidowsItem            &GetWidows( sal_Bool = sal_True ) const;
294     inline const SvxOrphansItem           &GetOrphans( sal_Bool = sal_True ) const;
295     inline const SvxTabStopItem           &GetTabStops( sal_Bool = sal_True ) const;
296     inline const SvxHyphenZoneItem        &GetHyphenZone( sal_Bool = sal_True ) const;
297     inline const SwFmtDrop                &GetDrop( sal_Bool = sal_True ) const;
298     inline const SvxScriptSpaceItem       &GetScriptSpace(sal_Bool = sal_True) const;
299     inline const SvxHangingPunctuationItem &GetHangingPunctuation(sal_Bool = sal_True) const;
300     inline const SvxForbiddenRuleItem     &GetForbiddenRule(sal_Bool = sal_True) const;
301     inline const SvxParaVertAlignItem &GetParaVertAlign(sal_Bool = sal_True) const;
302     inline const SvxParaGridItem        &GetParaGrid(sal_Bool = sal_True) const;
303     inline const SwParaConnectBorderItem &GetParaConnectBorder(sal_Bool = sal_True ) const;
304 
305 	// TabellenBox-Attribute	- impl. steht im cellatr.hxx
306     inline  const SwTblBoxNumFormat     &GetTblBoxNumFmt( sal_Bool = sal_True ) const;
307     inline  const SwTblBoxFormula       &GetTblBoxFormula( sal_Bool = sal_True ) const;
308     inline  const SwTblBoxValue         &GetTblBoxValue( sal_Bool = sal_True ) const;
309 
310     /** SwFmt::IsBackgroundTransparent - for feature #99657#
311 
312         OD 22.08.2002
313         Virtual method to determine, if background of format is transparent.
314         Default implementation returns false. Thus, subclasses have to overload
315         method, if the specific subclass can have a transparent background.
316 
317         @author OD
318 
319         @return false, default implementation
320     */
321     virtual sal_Bool IsBackgroundTransparent() const;
322 
323     /** SwFmt::IsShadowTransparent - for feature #99657#
324 
325         OD 22.08.2002
326         Virtual method to determine, if shadow of format is transparent.
327         Default implementation returns false. Thus, subclasses have to overload
328         method, if the specific subclass can have a transparent shadow.
329 
330         @author OD
331 
332         @return false, default implementation
333     */
334     virtual sal_Bool IsShadowTransparent() const;
335 
336     //UUUU decide if DrawingLayer FillAttributes are supported. If answering this with yes
337     // the full FillStyle ItemSet will be used to handle/visualize the element
338     virtual bool supportsFullDrawingLayerFillAttributeSet() const;
339 
340     //UUUU Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
341     virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const;
342 };
343 
344 // --------------- inline Implementierungen ------------------------
345 
SetName(const sal_Char * pNewName,sal_Bool bBroadcast)346 inline void SwFmt::SetName( const sal_Char* pNewName,
347 						 	sal_Bool bBroadcast )
348 {
349 	String aTmp( String::CreateFromAscii( pNewName ) );
350 	SetName( aTmp, bBroadcast );
351 }
352 
353 #undef inline
354 
355 #endif // _FORMAT_HXX
356