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