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