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