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