xref: /AOO41X/main/sw/source/core/text/porfld.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 _PORFLD_HXX
28 #define _PORFLD_HXX
29 
30 #include "swtypes.hxx"
31 #include "porexp.hxx"
32 #include <fmtornt.hxx>
33 
34 class SwFont;
35 class SvxBrushItem;
36 class SwFmtVertOrient;
37 class SwFrm;
38 
39 /*************************************************************************
40  *                      class SwFldPortion
41  *************************************************************************/
42 
43 class SwFldPortion : public SwExpandPortion
44 {
45 	friend class SwTxtFormatter;
46 protected:
47 	XubString  aExpand;            // das expandierte Feld
48 	SwFont  *pFnt;              // Fuer mehrzeilige Felder
49 	xub_StrLen nNextOffset;		// Offset des Follows im Originalstring
50     xub_StrLen nNextScriptChg;
51 	KSHORT  nViewWidth;         // Screenbreite fuer leere Felder
52 	sal_Bool bFollow : 1;           // 2. oder weiterer Teil eines Feldes
53 	sal_Bool bLeft : 1;				// wird von SwNumberPortion benutzt
54 	sal_Bool bHide : 1;             // wird von SwNumberPortion benutzt
55 	sal_Bool bCenter : 1; 			// wird von SwNumberPortion benutzt
56 	sal_Bool bHasFollow : 1; 		// geht in der naechsten Zeile weiter
57 	sal_Bool bAnimated : 1; 		// wird von SwGrfNumPortion benutzt
58 	sal_Bool bNoPaint : 1; 			// wird von SwGrfNumPortion benutzt
59 	sal_Bool bReplace : 1; 			// wird von SwGrfNumPortion benutzt
60     const sal_Bool bPlaceHolder : 1;
61     sal_Bool m_bNoLength : 1;       // HACK for meta suffix (no CH_TXTATR)
62 
63 	inline void SetFont( SwFont *pNew ) { pFnt = pNew; }
64     inline bool IsNoLength() const  { return m_bNoLength; }
65     inline void SetNoLength()       { m_bNoLength = sal_True; }
66 
67 public:
68     SwFldPortion( const SwFldPortion& rFld );
69     SwFldPortion( const XubString &rExpand, SwFont *pFnt = 0, sal_Bool bPlaceHolder = sal_False );
70 	~SwFldPortion();
71 
72 	void TakeNextOffset( const SwFldPortion* pFld );
73 	void CheckScript( const SwTxtSizeInfo &rInf );
74 	inline sal_Bool HasFont() const { return 0 != pFnt; }
75     // --> OD 2008-06-05 #i89179# - made public
76     inline const SwFont *GetFont() const { return pFnt; }
77     // <--
78 
79 	inline const XubString &GetExp() const { return aExpand; }
80 	virtual sal_Bool GetExpTxt( const SwTxtSizeInfo &rInf, XubString &rTxt ) const;
81 	virtual sal_Bool Format( SwTxtFormatInfo &rInf );
82 	virtual void Paint( const SwTxtPaintInfo &rInf ) const;
83 
84 	// leere Felder sind auch erlaubt
85 	virtual SwLinePortion *Compress();
86 
87 	virtual KSHORT GetViewWidth( const SwTxtSizeInfo &rInf ) const;
88 
89 	inline sal_Bool IsFollow() const { return bFollow; }
90 	inline void SetFollow( sal_Bool bNew ) { bFollow = bNew; }
91 
92 	inline sal_Bool IsLeft() const { return bLeft; }
93 	inline void SetLeft( sal_Bool bNew ) { bLeft = bNew; }
94 
95 	inline sal_Bool IsHide() const { return bHide; }
96 	inline void SetHide( sal_Bool bNew ) { bHide = bNew; }
97 
98 	inline sal_Bool IsCenter() const { return bCenter; }
99 	inline void SetCenter( sal_Bool bNew ) { bCenter = bNew; }
100 
101 	inline sal_Bool HasFollow() const { return bHasFollow; }
102 	inline void SetHasFollow( sal_Bool bNew ) { bHasFollow = bNew; }
103 
104 	inline xub_StrLen GetNextOffset() const { return nNextOffset; }
105 	inline void SetNextOffset( xub_StrLen nNew ) { nNextOffset = nNew; }
106 
107     inline xub_StrLen GetNextScriptChg() const { return nNextScriptChg; }
108     inline void SetNextScriptChg( xub_StrLen nNew ) { nNextScriptChg = nNew; }
109 
110     // Felder-Cloner fuer SplitGlue
111 	virtual SwFldPortion *Clone( const XubString &rExpand ) const;
112 
113 	// Extra-GetTxtSize wegen pFnt
114 	virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const;
115 
116     // Accessibility: pass information about this portion to the PortionHandler
117     virtual void HandlePortion( SwPortionHandler& rPH ) const;
118 
119 	OUTPUT_OPERATOR
120 };
121 
122 /*************************************************************************
123  *                      class SwHiddenPortion
124  *************************************************************************/
125 // Unterscheidung nur fuer's Painten/verstecken.
126 
127 class SwHiddenPortion : public SwFldPortion
128 {
129 public:
130     inline SwHiddenPortion( const XubString &rExpand, SwFont *pFntL = 0 )
131          : SwFldPortion( rExpand, pFntL )
132 		{ SetLen(1); SetWhichPor( POR_HIDDEN ); }
133 	virtual void Paint( const SwTxtPaintInfo &rInf ) const;
134 	virtual sal_Bool GetExpTxt( const SwTxtSizeInfo &rInf, XubString &rTxt ) const;
135 
136 	// Felder-Cloner fuer SplitGlue
137 	virtual SwFldPortion *Clone( const XubString &rExpand ) const;
138 	OUTPUT_OPERATOR
139 };
140 
141 /*************************************************************************
142  *                      class SwNumberPortion
143  *************************************************************************/
144 
145 class SwNumberPortion : public SwFldPortion
146 {
147 protected:
148 	KSHORT  nFixWidth;      // vgl. Glues
149 	KSHORT  nMinDist;		// minimaler Abstand zum Text
150     // --> OD 2008-01-23 #newlistlevelattrs#
151     bool    mbLabelAlignmentPosAndSpaceModeActive;
152     // <--
153 
154 public:
155     // --> OD 2008-01-23 #newlistlevelattrs#
156     SwNumberPortion( const XubString &rExpand,
157                      SwFont *pFnt,
158                      const sal_Bool bLeft,
159                      const sal_Bool bCenter,
160                      const KSHORT nMinDst,
161                      const bool bLabelAlignmentPosAndSpaceModeActive );
162     // <--
163 	virtual void Paint( const SwTxtPaintInfo &rInf ) const;
164 	virtual xub_StrLen GetCrsrOfst( const MSHORT nOfst ) const;
165 	virtual sal_Bool Format( SwTxtFormatInfo &rInf );
166 
167 	// Felder-Cloner fuer SplitGlue
168 	virtual SwFldPortion *Clone( const XubString &rExpand ) const;
169 	virtual void FormatEOL( SwTxtFormatInfo &rInf );
170 
171 	OUTPUT_OPERATOR
172 };
173 
174 /*************************************************************************
175  *                      class SwBulletPortion
176  *************************************************************************/
177 
178 class SwBulletPortion : public SwNumberPortion
179 {
180 public:
181     // --> OD 2008-01-23 #newlistlevelattrs#
182     SwBulletPortion( const xub_Unicode cCh,
183                      const XubString& rBulletFollowedBy,
184                      SwFont *pFnt,
185                      const sal_Bool bLeft,
186                      const sal_Bool bCenter,
187                      const KSHORT nMinDst,
188                      const bool bLabelAlignmentPosAndSpaceModeActive );
189     // <--
190 	OUTPUT_OPERATOR
191 };
192 
193 /*************************************************************************
194  *                      class SwBmpBulletPortion
195  *************************************************************************/
196 
197 class SwGrfNumPortion : public SwNumberPortion
198 {
199 	SvxBrushItem* pBrush;
200 	long			nId;	//fuer StopAnimation
201 	SwTwips			nYPos;	//Enthaelt _immer_ die aktuelle RelPos.
202 	SwTwips			nGrfHeight;
203     sal_Int16       eOrient;
204 public:
205     // --> OD 2008-01-23 #newlistlevelattrs#
206     SwGrfNumPortion( SwFrm *pFrm,
207                      const XubString& rGraphicFollowedBy,
208                      const SvxBrushItem* pGrfBrush,
209                      const SwFmtVertOrient* pGrfOrient,
210                      const Size& rGrfSize,
211                      const sal_Bool bLeft,
212                      const sal_Bool bCenter,
213                      const KSHORT nMinDst,
214                      const bool bLabelAlignmentPosAndSpaceModeActive );
215     // <--
216 	~SwGrfNumPortion();
217 	virtual void Paint( const SwTxtPaintInfo &rInf ) const;
218 	virtual sal_Bool Format( SwTxtFormatInfo &rInf );
219 
220 	void SetBase( long nLnAscent, long nLnDescent,
221 		long nFlyAscent, long nFlyDescent );
222 
223     void StopAnimation( OutputDevice* pOut );
224 
225 	inline sal_Bool IsAnimated() const { return bAnimated; }
226 	inline void SetAnimated( sal_Bool bNew ) { bAnimated = bNew; }
227 	inline sal_Bool DontPaint() const { return bNoPaint; }
228 	inline void SetNoPaint( sal_Bool bNew ) { bNoPaint = bNew; }
229 	inline void SetRelPos( SwTwips nNew ) { nYPos = nNew; }
230 	inline void SetId( long nNew ) const
231 		{ ((SwGrfNumPortion*)this)->nId = nNew; }
232 	inline SwTwips GetRelPos() const { return nYPos; }
233 	inline SwTwips GetGrfHeight() const { return nGrfHeight; }
234 	inline SwTwips GetId() const { return nId; }
235     inline sal_Int16 GetOrient() const { return eOrient; }
236 
237 	OUTPUT_OPERATOR
238 };
239 
240 /*************************************************************************
241  *                      class SwCombinedPortion
242  * Used in for asian layout specialities to display up to six characters
243  * in 2 rows and 2-3 columns.
244  * e.g.
245  *
246  *       A..  A..  A.B  A.B   A.B.C   A.B.C
247  *       ...  ..B  .C.  C.D   .D.E.   D.E.F
248  *************************************************************************/
249 
250 class SwCombinedPortion : public SwFldPortion
251 {
252 	sal_uInt16 aPos[6];		// up to six X positions
253 	sal_uInt16 aWidth[3];	// one width for every scripttype
254 	sal_uInt8 aScrType[6];	// scripttype of every character
255 	sal_uInt16 nUpPos;		// the Y position of the upper baseline
256 	sal_uInt16 nLowPos;		// the Y position of the lower baseline
257 	sal_uInt8 nProportion;	// relative font height
258 public:
259 	SwCombinedPortion( const XubString &rExpand );
260 	virtual void Paint( const SwTxtPaintInfo &rInf ) const;
261 	virtual sal_Bool Format( SwTxtFormatInfo &rInf );
262 	virtual KSHORT GetViewWidth( const SwTxtSizeInfo &rInf ) const;
263 	OUTPUT_OPERATOR
264 };
265 
266 
267 CLASSIO( SwHiddenPortion )
268 CLASSIO( SwNumberPortion )
269 CLASSIO( SwBulletPortion )
270 CLASSIO( SwGrfNumPortion )
271 CLASSIO( SwCombinedPortion )
272 
273 
274 #endif
275