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 _PORLIN_HXX 24 #define _PORLIN_HXX 25 26 #include "possiz.hxx" // SwPosSize 27 28 class XubString; 29 class SwTxtSizeInfo; 30 class SwTxtPaintInfo; 31 class SwTxtFormatInfo; 32 class SwPortionHandler; 33 34 // Die Ausgabeoperatoren der Portions sind virtuelle Methoden der Portion. 35 // Das CLASSIO-Makro implementiert die 'freischwebende' Funktion. 36 // Auf diese Weise erhaelt man beide Vorteile: virtuelle Ausgabeoperatoren 37 // und allgemeine Verwendbarkeit. 38 #ifdef DBG_UTIL 39 #define OUTPUT_OPERATOR virtual SvStream &operator<<( SvStream & aOs ) const; 40 #else 41 #define OUTPUT_OPERATOR 42 #endif 43 44 // Portiongruppen 45 #define PORGRP_TXT 0x8000 46 #define PORGRP_EXP 0x4000 47 #define PORGRP_FLD 0x2000 48 #define PORGRP_HYPH 0x1000 49 #define PORGRP_NUMBER 0x0800 50 #define PORGRP_GLUE 0x0400 51 #define PORGRP_FIX 0x0200 52 #define PORGRP_TAB 0x0100 53 #define PORGRP_NOTRECY 0x0080 54 // kleine Spezialgruppen 55 #define PORGRP_FIXMARG 0x0040 56 //#define PORGRP_? 0x0020 57 #define PORGRP_TABNOTLFT 0x0010 58 #define PORGRP_TOXREF 0x0008 59 60 /************************************************************************* 61 * class SwLinePortion 62 *************************************************************************/ 63 64 class SwLinePortion: public SwPosSize 65 { 66 protected: 67 // Hier gibt es Bereiche mit unterschiedlichen Attributen. 68 SwLinePortion *pPortion; 69 // Anzahl der Zeichen und Spaces auf der Zeile 70 xub_StrLen nLineLength; 71 KSHORT nAscent; // Maximaler Ascender 72 73 SwLinePortion(); 74 private: 75 MSHORT nWhichPor; // Who's who? 76 77 void _Truncate(); 78 79 public: 80 inline SwLinePortion(const SwLinePortion &rPortion); 81 virtual ~SwLinePortion(); 82 83 // Zugriffsmethoden 84 inline SwLinePortion *GetPortion() const { return( pPortion ); } 85 inline SwLinePortion &operator=(const SwLinePortion &rPortion); 86 inline sal_Bool operator==( const SwLinePortion &rPortion ) const; 87 inline xub_StrLen GetLen() const { return nLineLength; } 88 inline void SetLen( const xub_StrLen nLen ) { nLineLength = nLen; } 89 inline void SetPortion( SwLinePortion *pNew ){ pPortion = pNew; } 90 inline KSHORT &GetAscent() { return nAscent; } 91 inline KSHORT GetAscent() const { return nAscent; } 92 inline void SetAscent( const KSHORT nNewAsc ) { nAscent = nNewAsc; } 93 inline void PrtWidth( KSHORT nNewWidth ) { Width( nNewWidth ); } 94 inline KSHORT PrtWidth() const { return Width(); } 95 inline void AddPrtWidth( const KSHORT nNew ) { Width( Width() + nNew ); } 96 inline void SubPrtWidth( const KSHORT nNew ) { Width( Width() - nNew ); } 97 98 inline const SwPosSize &PrtSize() const { return *this; } 99 100 // Einfuegeoperationen: 101 virtual SwLinePortion *Insert( SwLinePortion *pPortion ); 102 virtual SwLinePortion *Append( SwLinePortion *pPortion ); 103 SwLinePortion *Cut( SwLinePortion *pVictim ); 104 inline void Truncate(); 105 106 // liefert 0 zurueck, wenn keine Nutzdaten enthalten sind. 107 virtual SwLinePortion *Compress(); 108 109 inline void SetWhichPor( const MSHORT nNew ) { nWhichPor = nNew; } 110 inline MSHORT GetWhichPor( ) const { return nWhichPor; } 111 112 // Gruppenabfragen: 113 inline sal_Bool InTxtGrp( ) const { return nWhichPor & PORGRP_TXT ? sal_True : sal_False; } 114 inline sal_Bool InGlueGrp( ) const { return nWhichPor & PORGRP_GLUE ? sal_True : sal_False;} 115 inline sal_Bool InTabGrp( ) const { return nWhichPor & PORGRP_TAB ? sal_True : sal_False; } 116 inline sal_Bool InHyphGrp( ) const { return nWhichPor & PORGRP_HYPH ? sal_True : sal_False;} 117 inline sal_Bool InNumberGrp( )const { return nWhichPor & PORGRP_NUMBER ? sal_True : sal_False;} 118 inline sal_Bool InFixGrp( ) const { return nWhichPor & PORGRP_FIX ? sal_True : sal_False; } 119 inline sal_Bool InFldGrp( ) const { return nWhichPor & PORGRP_FLD ? sal_True : sal_False; } 120 inline sal_Bool InToxRefGrp( ) const { return nWhichPor & PORGRP_TOXREF ? sal_True : sal_False; } 121 inline sal_Bool InToxRefOrFldGrp( ) const { return nWhichPor & 122 ( PORGRP_FLD | PORGRP_TOXREF ) ? sal_True : sal_False; } 123 inline sal_Bool InExpGrp( ) const { return nWhichPor & PORGRP_EXP ? sal_True : sal_False; } 124 inline sal_Bool InTabnLftGrp( ) const 125 { return nWhichPor & PORGRP_TABNOTLFT ? sal_True : sal_False; } 126 inline sal_Bool InFixMargGrp( )const 127 { return nWhichPor & PORGRP_FIXMARG ? sal_True : sal_False; } 128 inline sal_Bool InSpaceGrp( )const 129 { return InTxtGrp() || IsMultiPortion(); } 130 // Individuelle Abfragen: 131 inline sal_Bool IsGrfNumPortion( )const{ return nWhichPor == POR_GRFNUM; } 132 inline sal_Bool IsFlyCntPortion( )const{ return nWhichPor == POR_FLYCNT; } 133 inline sal_Bool IsBlankPortion( ) const{ return nWhichPor == POR_BLANK; } 134 inline sal_Bool IsBreakPortion( ) const{ return nWhichPor == POR_BRK; } 135 inline sal_Bool IsErgoSumPortion()const{ return nWhichPor == POR_ERGOSUM;} 136 inline sal_Bool IsQuoVadisPortion()const{ return nWhichPor==POR_QUOVADIS;} 137 inline sal_Bool IsTabCntPortion( )const{ return nWhichPor==POR_TABCENTER;} 138 inline sal_Bool IsTabDecimalPortion() const { return nWhichPor == POR_TABDECIMAL;} 139 inline sal_Bool IsTabLeftPortion()const{ return nWhichPor == POR_TABLEFT;} 140 inline sal_Bool IsFtnNumPortion( )const{ return nWhichPor == POR_FTNNUM; } 141 inline sal_Bool IsFtnPortion( ) const{ return nWhichPor == POR_FTN; } 142 inline sal_Bool IsTmpEndPortion( )const{ return nWhichPor == POR_TMPEND; } 143 inline sal_Bool IsDropPortion( ) const{ return nWhichPor == POR_DROP; } 144 inline sal_Bool IsLayPortion( ) const{ return nWhichPor == POR_LAY; } 145 inline sal_Bool IsParaPortion( ) const{ return nWhichPor == POR_PARA; } 146 inline sal_Bool IsMarginPortion( )const{ return nWhichPor == POR_MARGIN; } 147 inline sal_Bool IsFlyPortion( ) const{ return nWhichPor == POR_FLY; } 148 inline sal_Bool IsHolePortion( ) const{ return nWhichPor == POR_HOLE; } 149 inline sal_Bool IsSoftHyphPortion()const{ return nWhichPor==POR_SOFTHYPH;} 150 inline sal_Bool IsPostItsPortion()const{ return nWhichPor == POR_POSTITS;} 151 inline sal_Bool IsCombinedPortion()const{ return nWhichPor==POR_COMBINED;} 152 inline sal_Bool IsTextPortion( ) const{ return nWhichPor == POR_TXT; } 153 inline sal_Bool IsURLPortion( ) const{ return nWhichPor == POR_URL; } 154 inline sal_Bool IsHangingPortion( ) const{ return nWhichPor == POR_HNG; } 155 inline sal_Bool IsKernPortion( ) const{ return nWhichPor == POR_KERN; } 156 inline sal_Bool IsArrowPortion( ) const{ return nWhichPor == POR_ARROW; } 157 inline sal_Bool IsMultiPortion( ) const{ return nWhichPor == POR_MULTI; } 158 inline sal_Bool IsNumberPortion( ) const{ return nWhichPor == POR_NUMBER; } // #i23726# 159 inline sal_Bool IsControlCharPortion() const { return nWhichPor == POR_CONTROLCHAR; } 160 161 // Positionierung 162 SwLinePortion *FindPrevPortion( const SwLinePortion *pRoot ); 163 SwLinePortion *FindLastPortion(); 164 165 virtual xub_StrLen GetCrsrOfst( const KSHORT nOfst ) const; 166 virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const; 167 void CalcTxtSize( const SwTxtSizeInfo &rInfo ); 168 169 // Ausgabe 170 virtual void Paint( const SwTxtPaintInfo &rInf ) const = 0; 171 void PrePaint( const SwTxtPaintInfo &rInf, const SwLinePortion *pLast ) const; 172 173 #ifdef DBG_UTIL 174 virtual sal_Bool Check( SvStream &rOs, SwTxtSizeInfo &rInfo ); //$ ostream 175 #endif 176 177 virtual sal_Bool Format( SwTxtFormatInfo &rInf ); 178 // wird fuer die letzte Portion der Zeile extra gerufen 179 virtual void FormatEOL( SwTxtFormatInfo &rInf ); 180 void Move( SwTxtPaintInfo &rInf ); 181 182 // Fuer SwTxtSlot 183 virtual sal_Bool GetExpTxt( const SwTxtSizeInfo &rInf, XubString &rTxt ) const; 184 185 // fuer SwFldPortion, SwSoftHyphPortion 186 virtual KSHORT GetViewWidth( const SwTxtSizeInfo &rInf ) const; 187 188 // for text- and multi-portions 189 virtual long CalcSpacing( long nSpaceAdd, const SwTxtSizeInfo &rInf ) const; 190 191 // Accessibility: pass information about this portion to the PortionHandler 192 virtual void HandlePortion( SwPortionHandler& rPH ) const; 193 194 OUTPUT_OPERATOR 195 }; 196 197 198 /************************************************************************* 199 * inline - Implementations 200 *************************************************************************/ 201 202 inline SwLinePortion &SwLinePortion::operator=(const SwLinePortion &rPortion) 203 { 204 *(SwPosSize*)this = rPortion; 205 nLineLength = rPortion.nLineLength; 206 nAscent = rPortion.nAscent; 207 nWhichPor = rPortion.nWhichPor; 208 return *this; 209 } 210 211 inline sal_Bool SwLinePortion::operator==(const SwLinePortion &rPortion ) const 212 { 213 return( Height() == rPortion.Height() && 214 Width() == rPortion.Width() && 215 nLineLength == rPortion.GetLen() && 216 nAscent == rPortion.GetAscent() ); 217 } 218 219 inline SwLinePortion::SwLinePortion(const SwLinePortion &rPortion) : 220 SwPosSize( rPortion ), 221 pPortion( 0 ), 222 nLineLength( rPortion.nLineLength ), 223 nAscent( rPortion.nAscent ), 224 nWhichPor( rPortion.nWhichPor ) 225 { 226 } 227 228 inline void SwLinePortion::Truncate() 229 { 230 if ( pPortion ) 231 _Truncate(); 232 } 233 234 235 //$ ostream 236 #ifdef DBGTXT 237 #define CLASSIO( class ) \ 238 inline SvStream &operator<<( SvStream &rOs, const class &rClass ) {\ 239 return rClass.operator<<( rOs );\ 240 } 241 #else 242 #define CLASSIO( class ) 243 #endif 244 245 CLASSIO( SwLinePortion ) 246 247 #endif 248