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 SwBulletPortion( const xub_Unicode cCh, 181 const XubString& rBulletFollowedBy, 182 SwFont *pFnt, 183 const sal_Bool bLeft, 184 const sal_Bool bCenter, 185 const KSHORT nMinDst, 186 const bool bLabelAlignmentPosAndSpaceModeActive ); 187 OUTPUT_OPERATOR 188 }; 189 190 /************************************************************************* 191 * class SwBmpBulletPortion 192 *************************************************************************/ 193 194 class SwGrfNumPortion : public SwNumberPortion 195 { 196 SvxBrushItem* pBrush; 197 long nId; //fuer StopAnimation 198 SwTwips nYPos; //Enthaelt _immer_ die aktuelle RelPos. 199 SwTwips nGrfHeight; 200 sal_Int16 eOrient; 201 public: 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 ~SwGrfNumPortion(); 212 virtual void Paint( const SwTxtPaintInfo &rInf ) const; 213 virtual sal_Bool Format( SwTxtFormatInfo &rInf ); 214 215 void SetBase( long nLnAscent, long nLnDescent, 216 long nFlyAscent, long nFlyDescent ); 217 218 void StopAnimation( OutputDevice* pOut ); 219 220 inline sal_Bool IsAnimated() const { return bAnimated; } 221 inline void SetAnimated( sal_Bool bNew ) { bAnimated = bNew; } 222 inline sal_Bool DontPaint() const { return bNoPaint; } 223 inline void SetNoPaint( sal_Bool bNew ) { bNoPaint = bNew; } 224 inline void SetRelPos( SwTwips nNew ) { nYPos = nNew; } 225 inline void SetId( long nNew ) const 226 { ((SwGrfNumPortion*)this)->nId = nNew; } 227 inline SwTwips GetRelPos() const { return nYPos; } 228 inline SwTwips GetGrfHeight() const { return nGrfHeight; } 229 inline SwTwips GetId() const { return nId; } 230 inline sal_Int16 GetOrient() const { return eOrient; } 231 232 OUTPUT_OPERATOR 233 }; 234 235 /************************************************************************* 236 * class SwCombinedPortion 237 * Used in for asian layout specialities to display up to six characters 238 * in 2 rows and 2-3 columns. 239 * e.g. 240 * 241 * A.. A.. A.B A.B A.B.C A.B.C 242 * ... ..B .C. C.D .D.E. D.E.F 243 *************************************************************************/ 244 245 class SwCombinedPortion : public SwFldPortion 246 { 247 sal_uInt16 aPos[6]; // up to six X positions 248 sal_uInt16 aWidth[3]; // one width for every scripttype 249 sal_uInt8 aScrType[6]; // scripttype of every character 250 sal_uInt16 nUpPos; // the Y position of the upper baseline 251 sal_uInt16 nLowPos; // the Y position of the lower baseline 252 sal_uInt8 nProportion; // relative font height 253 public: 254 SwCombinedPortion( const XubString &rExpand ); 255 virtual void Paint( const SwTxtPaintInfo &rInf ) const; 256 virtual sal_Bool Format( SwTxtFormatInfo &rInf ); 257 virtual KSHORT GetViewWidth( const SwTxtSizeInfo &rInf ) const; 258 OUTPUT_OPERATOR 259 }; 260 261 262 CLASSIO( SwHiddenPortion ) 263 CLASSIO( SwNumberPortion ) 264 CLASSIO( SwBulletPortion ) 265 CLASSIO( SwGrfNumPortion ) 266 CLASSIO( SwCombinedPortion ) 267 268 269 #endif 270