Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _PORFLD_HXX
29 : : #define _PORFLD_HXX
30 : :
31 : : #include "swtypes.hxx"
32 : : #include "porexp.hxx"
33 : : #include <fmtornt.hxx>
34 : :
35 : : class SwFont;
36 : : class SvxBrushItem;
37 : : class SwFmtVertOrient;
38 : : class SwFrm;
39 : :
40 : : /*************************************************************************
41 : : * class SwFldPortion
42 : : *************************************************************************/
43 : :
44 : : class SwFldPortion : public SwExpandPortion
45 : : {
46 : : friend class SwTxtFormatter;
47 : : protected:
48 : : XubString aExpand; // The expanded field
49 : : SwFont *pFnt; // For multi-line fields
50 : : xub_StrLen nNextOffset; // Offset of the follow in the original string
51 : : xub_StrLen nNextScriptChg;
52 : : KSHORT nViewWidth; // Screen width for empty fields
53 : : sal_Bool bFollow : 1; // 2nd or later part of a field
54 : : sal_Bool bLeft : 1; // Used by SwNumberPortion
55 : : sal_Bool bHide : 1; // Used by SwNumberPortion
56 : : sal_Bool bCenter : 1; // Used by SwNumberPortion
57 : : sal_Bool bHasFollow : 1; // Continues on the next line
58 : : sal_Bool bAnimated : 1; // Used by SwGrfNumPortion
59 : : sal_Bool bNoPaint : 1; // Used by SwGrfNumPortion
60 : : sal_Bool bReplace : 1; // Used by SwGrfNumPortion
61 : : const sal_Bool bPlaceHolder : 1;
62 : : sal_Bool m_bNoLength : 1; // HACK for meta suffix (no CH_TXTATR)
63 : :
64 : 0 : inline void SetFont( SwFont *pNew ) { pFnt = pNew; }
65 : 0 : inline bool IsNoLength() const { return m_bNoLength; }
66 : 40 : inline void SetNoLength() { m_bNoLength = sal_True; }
67 : :
68 : : public:
69 : : SwFldPortion( const SwFldPortion& rFld );
70 : : SwFldPortion( const XubString &rExpand, SwFont *pFnt = 0, sal_Bool bPlaceHolder = sal_False );
71 : : ~SwFldPortion();
72 : :
73 : : void TakeNextOffset( const SwFldPortion* pFld );
74 : : void CheckScript( const SwTxtSizeInfo &rInf );
75 : 712 : inline sal_Bool HasFont() const { return 0 != pFnt; }
76 : : // #i89179# - made public
77 : 2983 : inline const SwFont *GetFont() const { return pFnt; }
78 : :
79 : 336 : 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 : : // Empty fields are also allowed
85 : : virtual SwLinePortion *Compress();
86 : :
87 : : virtual KSHORT GetViewWidth( const SwTxtSizeInfo &rInf ) const;
88 : :
89 : 5347 : inline sal_Bool IsFollow() const { return bFollow; }
90 : 846 : inline void SetFollow( sal_Bool bNew ) { bFollow = bNew; }
91 : :
92 : 279 : inline sal_Bool IsLeft() const { return bLeft; }
93 : 664 : inline void SetLeft( sal_Bool bNew ) { bLeft = bNew; }
94 : :
95 : 467 : inline sal_Bool IsHide() const { return bHide; }
96 : 1072 : inline void SetHide( sal_Bool bNew ) { bHide = bNew; }
97 : :
98 : 174 : inline sal_Bool IsCenter() const { return bCenter; }
99 : 536 : inline void SetCenter( sal_Bool bNew ) { bCenter = bNew; }
100 : :
101 : 1478 : inline sal_Bool HasFollow() const { return bHasFollow; }
102 : 174 : inline void SetHasFollow( sal_Bool bNew ) { bHasFollow = bNew; }
103 : :
104 : 0 : inline xub_StrLen GetNextOffset() const { return nNextOffset; }
105 : 846 : inline void SetNextOffset( xub_StrLen nNew ) { nNextOffset = nNew; }
106 : :
107 : 0 : inline xub_StrLen GetNextScriptChg() const { return nNextScriptChg; }
108 : : inline void SetNextScriptChg( xub_StrLen nNew ) { nNextScriptChg = nNew; }
109 : :
110 : : // Field cloner for SplitGlue
111 : : virtual SwFldPortion *Clone( const XubString &rExpand ) const;
112 : :
113 : : // Extra GetTxtSize because of 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 : : // Distinguish only for painting/hide
126 : :
127 [ # # ]: 0 : class SwHiddenPortion : public SwFldPortion
128 : : {
129 : : public:
130 : 0 : inline SwHiddenPortion( const XubString &rExpand, SwFont *pFntL = 0 )
131 : 0 : : SwFldPortion( rExpand, pFntL )
132 : 0 : { 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 : : // Field cloner for SplitGlue
137 : : virtual SwFldPortion *Clone( const XubString &rExpand ) const;
138 : : OUTPUT_OPERATOR
139 : : };
140 : :
141 : : /*************************************************************************
142 : : * class SwNumberPortion
143 : : *************************************************************************/
144 : :
145 [ - + ]: 908 : class SwNumberPortion : public SwFldPortion
146 : : {
147 : : protected:
148 : : KSHORT nFixWidth; // See Glues
149 : : KSHORT nMinDist; // Minimal distance to the text
150 : : bool mbLabelAlignmentPosAndSpaceModeActive;
151 : :
152 : : public:
153 : : SwNumberPortion( const XubString &rExpand,
154 : : SwFont *pFnt,
155 : : const sal_Bool bLeft,
156 : : const sal_Bool bCenter,
157 : : const KSHORT nMinDst,
158 : : const bool bLabelAlignmentPosAndSpaceModeActive );
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 : : // Field cloner for 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 [ - + ]: 72 : class SwBulletPortion : public SwNumberPortion
175 : : {
176 : : public:
177 : : SwBulletPortion( const xub_Unicode cCh,
178 : : const XubString& rBulletFollowedBy,
179 : : SwFont *pFnt,
180 : : const sal_Bool bLeft,
181 : : const sal_Bool bCenter,
182 : : const KSHORT nMinDst,
183 : : const bool bLabelAlignmentPosAndSpaceModeActive );
184 : : OUTPUT_OPERATOR
185 : : };
186 : :
187 : : /*************************************************************************
188 : : * class SwBmpBulletPortion
189 : : *************************************************************************/
190 : :
191 : : class SwGrfNumPortion : public SwNumberPortion
192 : : {
193 : : SvxBrushItem* pBrush;
194 : : long nId; // For StopAnimation
195 : : SwTwips nYPos; // _Always_ contains the current RelPos
196 : : SwTwips nGrfHeight;
197 : : sal_Int16 eOrient;
198 : : public:
199 : : SwGrfNumPortion( SwFrm *pFrm,
200 : : const XubString& rGraphicFollowedBy,
201 : : const SvxBrushItem* pGrfBrush,
202 : : const SwFmtVertOrient* pGrfOrient,
203 : : const Size& rGrfSize,
204 : : const sal_Bool bLeft,
205 : : const sal_Bool bCenter,
206 : : const KSHORT nMinDst,
207 : : const bool bLabelAlignmentPosAndSpaceModeActive );
208 : : ~SwGrfNumPortion();
209 : : virtual void Paint( const SwTxtPaintInfo &rInf ) const;
210 : : virtual sal_Bool Format( SwTxtFormatInfo &rInf );
211 : :
212 : : void SetBase( long nLnAscent, long nLnDescent,
213 : : long nFlyAscent, long nFlyDescent );
214 : :
215 : : void StopAnimation( OutputDevice* pOut );
216 : :
217 : 0 : inline sal_Bool IsAnimated() const { return bAnimated; }
218 : 0 : inline void SetAnimated( sal_Bool bNew ) { bAnimated = bNew; }
219 : 0 : inline sal_Bool DontPaint() const { return bNoPaint; }
220 : 0 : inline void SetNoPaint( sal_Bool bNew ) { bNoPaint = bNew; }
221 : 0 : inline void SetRelPos( SwTwips nNew ) { nYPos = nNew; }
222 : 0 : inline void SetId( long nNew ) const
223 : 0 : { ((SwGrfNumPortion*)this)->nId = nNew; }
224 : 0 : inline SwTwips GetRelPos() const { return nYPos; }
225 : 0 : inline SwTwips GetGrfHeight() const { return nGrfHeight; }
226 : : inline SwTwips GetId() const { return nId; }
227 : 0 : inline sal_Int16 GetOrient() const { return eOrient; }
228 : :
229 : : OUTPUT_OPERATOR
230 : : };
231 : :
232 : : /*************************************************************************
233 : : * class SwCombinedPortion
234 : : * Used in for asian layout specialities to display up to six characters
235 : : * in 2 rows and 2-3 columns.
236 : : * e.g.
237 : : *
238 : : * A.. A.. A.B A.B A.B.C A.B.C
239 : : * ... ..B .C. C.D .D.E. D.E.F
240 : : *************************************************************************/
241 : :
242 [ # # ]: 0 : class SwCombinedPortion : public SwFldPortion
243 : : {
244 : : sal_uInt16 aPos[6]; // up to six X positions
245 : : sal_uInt16 aWidth[3]; // one width for every scripttype
246 : : sal_uInt8 aScrType[6]; // scripttype of every character
247 : : sal_uInt16 nUpPos; // the Y position of the upper baseline
248 : : sal_uInt16 nLowPos; // the Y position of the lower baseline
249 : : sal_uInt8 nProportion; // relative font height
250 : : public:
251 : : SwCombinedPortion( const XubString &rExpand );
252 : : virtual void Paint( const SwTxtPaintInfo &rInf ) const;
253 : : virtual sal_Bool Format( SwTxtFormatInfo &rInf );
254 : : virtual KSHORT GetViewWidth( const SwTxtSizeInfo &rInf ) const;
255 : : OUTPUT_OPERATOR
256 : : };
257 : :
258 : :
259 : : CLASSIO( SwHiddenPortion )
260 : : CLASSIO( SwNumberPortion )
261 : : CLASSIO( SwBulletPortion )
262 : : CLASSIO( SwGrfNumPortion )
263 : : CLASSIO( SwCombinedPortion )
264 : :
265 : :
266 : : #endif
267 : :
268 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|