xref: /aoo42x/main/sw/source/core/text/porlin.hxx (revision 1d2dbeb0)
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
GetPortion() const84 	inline SwLinePortion *GetPortion() const { return( pPortion ); }
85 	inline SwLinePortion &operator=(const SwLinePortion &rPortion);
86 	inline sal_Bool operator==( const SwLinePortion &rPortion ) const;
GetLen() const87 	inline xub_StrLen GetLen() const { return nLineLength; }
SetLen(const xub_StrLen nLen)88 	inline void SetLen( const xub_StrLen nLen ) { nLineLength = nLen; }
SetPortion(SwLinePortion * pNew)89 	inline void SetPortion( SwLinePortion *pNew ){ pPortion = pNew; }
GetAscent()90 	inline KSHORT &GetAscent() { return nAscent; }
GetAscent() const91 	inline KSHORT GetAscent() const { return nAscent; }
SetAscent(const KSHORT nNewAsc)92 	inline void SetAscent( const KSHORT nNewAsc ) { nAscent = nNewAsc; }
PrtWidth(KSHORT nNewWidth)93 	inline void  PrtWidth( KSHORT nNewWidth ) { Width( nNewWidth ); }
PrtWidth() const94 	inline KSHORT PrtWidth() const { return Width(); }
AddPrtWidth(const KSHORT nNew)95 	inline void AddPrtWidth( const KSHORT nNew ) { Width( Width() + nNew ); }
SubPrtWidth(const KSHORT nNew)96 	inline void SubPrtWidth( const KSHORT nNew ) { Width( Width() - nNew ); }
97 
PrtSize() const98 	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 
SetWhichPor(const MSHORT nNew)109 	inline void SetWhichPor( const MSHORT nNew )	{ nWhichPor = nNew; }
GetWhichPor() const110 	inline MSHORT GetWhichPor( ) const        { return nWhichPor; }
111 
112 // Gruppenabfragen:
InTxtGrp() const113 	inline sal_Bool InTxtGrp( )	const { return nWhichPor & PORGRP_TXT ? sal_True : sal_False; }
InGlueGrp() const114 	inline sal_Bool InGlueGrp( )	const { return nWhichPor & PORGRP_GLUE ? sal_True : sal_False;}
InTabGrp() const115 	inline sal_Bool InTabGrp( )	const { return nWhichPor & PORGRP_TAB ? sal_True : sal_False; }
InHyphGrp() const116 	inline sal_Bool InHyphGrp( )	const { return nWhichPor & PORGRP_HYPH ? sal_True : sal_False;}
InNumberGrp() const117 	inline sal_Bool InNumberGrp( )const { return nWhichPor & PORGRP_NUMBER ? sal_True : sal_False;}
InFixGrp() const118 	inline sal_Bool InFixGrp( )	const { return nWhichPor & PORGRP_FIX ? sal_True : sal_False;  }
InFldGrp() const119 	inline sal_Bool InFldGrp( )	const { return nWhichPor & PORGRP_FLD ? sal_True : sal_False;  }
InToxRefGrp() const120 	inline sal_Bool InToxRefGrp( ) const { return nWhichPor &	PORGRP_TOXREF ? sal_True : sal_False;  }
InToxRefOrFldGrp() const121 	inline sal_Bool InToxRefOrFldGrp( )	const { return nWhichPor &
122 								( PORGRP_FLD | PORGRP_TOXREF ) ? sal_True : sal_False;  }
InExpGrp() const123 	inline sal_Bool InExpGrp( )	const { return nWhichPor & PORGRP_EXP ? sal_True : sal_False;  }
InTabnLftGrp() const124 	inline sal_Bool InTabnLftGrp( ) const
125 		{ return nWhichPor & PORGRP_TABNOTLFT ? sal_True : sal_False;  }
InFixMargGrp() const126 	inline sal_Bool InFixMargGrp( )const
127 		{ return nWhichPor & PORGRP_FIXMARG ? sal_True : sal_False;  }
InSpaceGrp() const128 	inline sal_Bool InSpaceGrp( )const
129 		{ return InTxtGrp() || IsMultiPortion();  }
130 // Individuelle Abfragen:
IsGrfNumPortion() const131 	inline sal_Bool IsGrfNumPortion( )const{ return nWhichPor == POR_GRFNUM; }
IsFlyCntPortion() const132 	inline sal_Bool IsFlyCntPortion( )const{ return nWhichPor == POR_FLYCNT; }
IsBlankPortion() const133 	inline sal_Bool IsBlankPortion( )	const{ return nWhichPor == POR_BLANK; }
IsBreakPortion() const134 	inline sal_Bool IsBreakPortion( )	const{ return nWhichPor == POR_BRK; }
IsErgoSumPortion() const135 	inline sal_Bool IsErgoSumPortion()const{ return nWhichPor == POR_ERGOSUM;}
IsQuoVadisPortion() const136 	inline sal_Bool IsQuoVadisPortion()const{ return nWhichPor==POR_QUOVADIS;}
IsTabCntPortion() const137 	inline sal_Bool IsTabCntPortion( )const{ return nWhichPor==POR_TABCENTER;}
IsTabDecimalPortion() const138 	inline sal_Bool IsTabDecimalPortion() const { return nWhichPor == POR_TABDECIMAL;}
IsTabLeftPortion() const139 	inline sal_Bool IsTabLeftPortion()const{ return nWhichPor == POR_TABLEFT;}
IsFtnNumPortion() const140 	inline sal_Bool IsFtnNumPortion( )const{ return nWhichPor == POR_FTNNUM; }
IsFtnPortion() const141 	inline sal_Bool IsFtnPortion( )	const{ return nWhichPor == POR_FTN; }
IsTmpEndPortion() const142 	inline sal_Bool IsTmpEndPortion( )const{ return nWhichPor == POR_TMPEND; }
IsDropPortion() const143 	inline sal_Bool IsDropPortion( )	const{ return nWhichPor == POR_DROP; }
IsLayPortion() const144 	inline sal_Bool IsLayPortion( )	const{ return nWhichPor == POR_LAY; }
IsParaPortion() const145 	inline sal_Bool IsParaPortion( )	const{ return nWhichPor == POR_PARA; }
IsMarginPortion() const146 	inline sal_Bool IsMarginPortion( )const{ return nWhichPor == POR_MARGIN; }
IsFlyPortion() const147 	inline sal_Bool IsFlyPortion( )	const{ return nWhichPor == POR_FLY; }
IsHolePortion() const148 	inline sal_Bool IsHolePortion( )	const{ return nWhichPor == POR_HOLE; }
IsSoftHyphPortion() const149 	inline sal_Bool IsSoftHyphPortion()const{ return nWhichPor==POR_SOFTHYPH;}
IsPostItsPortion() const150 	inline sal_Bool IsPostItsPortion()const{ return nWhichPor == POR_POSTITS;}
IsCombinedPortion() const151 	inline sal_Bool IsCombinedPortion()const{ return nWhichPor==POR_COMBINED;}
IsTextPortion() const152 	inline sal_Bool IsTextPortion( ) const{ return nWhichPor == POR_TXT; }
IsURLPortion() const153 	inline sal_Bool IsURLPortion( ) const{ return nWhichPor == POR_URL; }
IsHangingPortion() const154 	inline sal_Bool IsHangingPortion( ) const{ return nWhichPor == POR_HNG; }
IsKernPortion() const155 	inline sal_Bool IsKernPortion( ) const{ return nWhichPor == POR_KERN; }
IsArrowPortion() const156 	inline sal_Bool IsArrowPortion( ) const{ return nWhichPor == POR_ARROW; }
IsMultiPortion() const157 	inline sal_Bool IsMultiPortion( ) const{ return nWhichPor == POR_MULTI; }
IsNumberPortion() const158 	inline sal_Bool IsNumberPortion( ) const{ return nWhichPor == POR_NUMBER; } // #i23726#
IsControlCharPortion() const159 	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 
operator =(const SwLinePortion & rPortion)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 
operator ==(const SwLinePortion & rPortion) const211 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 
SwLinePortion(const SwLinePortion & rPortion)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 
Truncate()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