xref: /trunk/main/sw/source/core/text/porlin.hxx (revision 1d2dbeb0)
1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1d2dbeb0SAndrew Rist  * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist  *
11*1d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist  *
13*1d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist  * under the License.
19*1d2dbeb0SAndrew Rist  *
20*1d2dbeb0SAndrew Rist  *************************************************************/
21*1d2dbeb0SAndrew Rist 
22*1d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef _PORLIN_HXX
24cdf0e10cSrcweir #define _PORLIN_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "possiz.hxx"		// SwPosSize
27cdf0e10cSrcweir 
28cdf0e10cSrcweir class XubString;
29cdf0e10cSrcweir class SwTxtSizeInfo;
30cdf0e10cSrcweir class SwTxtPaintInfo;
31cdf0e10cSrcweir class SwTxtFormatInfo;
32cdf0e10cSrcweir class SwPortionHandler;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir // Die Ausgabeoperatoren der Portions sind virtuelle Methoden der Portion.
35cdf0e10cSrcweir // Das CLASSIO-Makro implementiert die 'freischwebende' Funktion.
36cdf0e10cSrcweir // Auf diese Weise erhaelt man beide Vorteile: virtuelle Ausgabeoperatoren
37cdf0e10cSrcweir // und allgemeine Verwendbarkeit.
38cdf0e10cSrcweir #ifdef DBG_UTIL
39cdf0e10cSrcweir #define OUTPUT_OPERATOR  virtual SvStream &operator<<( SvStream & aOs ) const;
40cdf0e10cSrcweir #else
41cdf0e10cSrcweir #define OUTPUT_OPERATOR
42cdf0e10cSrcweir #endif
43cdf0e10cSrcweir 
44cdf0e10cSrcweir // Portiongruppen
45cdf0e10cSrcweir #define PORGRP_TXT		0x8000
46cdf0e10cSrcweir #define PORGRP_EXP		0x4000
47cdf0e10cSrcweir #define PORGRP_FLD		0x2000
48cdf0e10cSrcweir #define PORGRP_HYPH		0x1000
49cdf0e10cSrcweir #define PORGRP_NUMBER	0x0800
50cdf0e10cSrcweir #define PORGRP_GLUE		0x0400
51cdf0e10cSrcweir #define PORGRP_FIX		0x0200
52cdf0e10cSrcweir #define PORGRP_TAB		0x0100
53cdf0e10cSrcweir #define PORGRP_NOTRECY	0x0080
54cdf0e10cSrcweir // kleine Spezialgruppen
55cdf0e10cSrcweir #define PORGRP_FIXMARG	0x0040
56cdf0e10cSrcweir //#define PORGRP_?	0x0020
57cdf0e10cSrcweir #define PORGRP_TABNOTLFT 0x0010
58cdf0e10cSrcweir #define PORGRP_TOXREF	0x0008
59cdf0e10cSrcweir 
60cdf0e10cSrcweir /*************************************************************************
61cdf0e10cSrcweir  *						class SwLinePortion
62cdf0e10cSrcweir  *************************************************************************/
63cdf0e10cSrcweir 
64cdf0e10cSrcweir class SwLinePortion: public SwPosSize
65cdf0e10cSrcweir {
66cdf0e10cSrcweir protected:
67cdf0e10cSrcweir 	// Hier gibt es Bereiche mit unterschiedlichen Attributen.
68cdf0e10cSrcweir 	SwLinePortion *pPortion;
69cdf0e10cSrcweir 	// Anzahl der Zeichen und Spaces auf der Zeile
70cdf0e10cSrcweir 	xub_StrLen nLineLength;
71cdf0e10cSrcweir 	KSHORT nAscent; 	 // Maximaler Ascender
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	SwLinePortion();
74cdf0e10cSrcweir private:
75cdf0e10cSrcweir 	MSHORT nWhichPor;		// Who's who?
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	void _Truncate();
78cdf0e10cSrcweir 
79cdf0e10cSrcweir public:
80cdf0e10cSrcweir 	inline 			SwLinePortion(const SwLinePortion &rPortion);
81cdf0e10cSrcweir 		   virtual ~SwLinePortion();
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	// Zugriffsmethoden
GetPortion() const84cdf0e10cSrcweir 	inline SwLinePortion *GetPortion() const { return( pPortion ); }
85cdf0e10cSrcweir 	inline SwLinePortion &operator=(const SwLinePortion &rPortion);
86cdf0e10cSrcweir 	inline sal_Bool operator==( const SwLinePortion &rPortion ) const;
GetLen() const87cdf0e10cSrcweir 	inline xub_StrLen GetLen() const { return nLineLength; }
SetLen(const xub_StrLen nLen)88cdf0e10cSrcweir 	inline void SetLen( const xub_StrLen nLen ) { nLineLength = nLen; }
SetPortion(SwLinePortion * pNew)89cdf0e10cSrcweir 	inline void SetPortion( SwLinePortion *pNew ){ pPortion = pNew; }
GetAscent()90cdf0e10cSrcweir 	inline KSHORT &GetAscent() { return nAscent; }
GetAscent() const91cdf0e10cSrcweir 	inline KSHORT GetAscent() const { return nAscent; }
SetAscent(const KSHORT nNewAsc)92cdf0e10cSrcweir 	inline void SetAscent( const KSHORT nNewAsc ) { nAscent = nNewAsc; }
PrtWidth(KSHORT nNewWidth)93cdf0e10cSrcweir 	inline void  PrtWidth( KSHORT nNewWidth ) { Width( nNewWidth ); }
PrtWidth() const94cdf0e10cSrcweir 	inline KSHORT PrtWidth() const { return Width(); }
AddPrtWidth(const KSHORT nNew)95cdf0e10cSrcweir 	inline void AddPrtWidth( const KSHORT nNew ) { Width( Width() + nNew ); }
SubPrtWidth(const KSHORT nNew)96cdf0e10cSrcweir 	inline void SubPrtWidth( const KSHORT nNew ) { Width( Width() - nNew ); }
97cdf0e10cSrcweir 
PrtSize() const98cdf0e10cSrcweir 	inline const SwPosSize &PrtSize() const { return *this; }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	// Einfuegeoperationen:
101cdf0e10cSrcweir 	virtual SwLinePortion *Insert( SwLinePortion *pPortion );
102cdf0e10cSrcweir 	virtual SwLinePortion *Append( SwLinePortion *pPortion );
103cdf0e10cSrcweir 			SwLinePortion *Cut( SwLinePortion *pVictim );
104cdf0e10cSrcweir 	inline	void Truncate();
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	// liefert 0 zurueck, wenn keine Nutzdaten enthalten sind.
107cdf0e10cSrcweir 	virtual SwLinePortion *Compress();
108cdf0e10cSrcweir 
SetWhichPor(const MSHORT nNew)109cdf0e10cSrcweir 	inline void SetWhichPor( const MSHORT nNew )	{ nWhichPor = nNew; }
GetWhichPor() const110cdf0e10cSrcweir 	inline MSHORT GetWhichPor( ) const        { return nWhichPor; }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir // Gruppenabfragen:
InTxtGrp() const113cdf0e10cSrcweir 	inline sal_Bool InTxtGrp( )	const { return nWhichPor & PORGRP_TXT ? sal_True : sal_False; }
InGlueGrp() const114cdf0e10cSrcweir 	inline sal_Bool InGlueGrp( )	const { return nWhichPor & PORGRP_GLUE ? sal_True : sal_False;}
InTabGrp() const115cdf0e10cSrcweir 	inline sal_Bool InTabGrp( )	const { return nWhichPor & PORGRP_TAB ? sal_True : sal_False; }
InHyphGrp() const116cdf0e10cSrcweir 	inline sal_Bool InHyphGrp( )	const { return nWhichPor & PORGRP_HYPH ? sal_True : sal_False;}
InNumberGrp() const117cdf0e10cSrcweir 	inline sal_Bool InNumberGrp( )const { return nWhichPor & PORGRP_NUMBER ? sal_True : sal_False;}
InFixGrp() const118cdf0e10cSrcweir 	inline sal_Bool InFixGrp( )	const { return nWhichPor & PORGRP_FIX ? sal_True : sal_False;  }
InFldGrp() const119cdf0e10cSrcweir 	inline sal_Bool InFldGrp( )	const { return nWhichPor & PORGRP_FLD ? sal_True : sal_False;  }
InToxRefGrp() const120cdf0e10cSrcweir 	inline sal_Bool InToxRefGrp( ) const { return nWhichPor &	PORGRP_TOXREF ? sal_True : sal_False;  }
InToxRefOrFldGrp() const121cdf0e10cSrcweir 	inline sal_Bool InToxRefOrFldGrp( )	const { return nWhichPor &
122cdf0e10cSrcweir 								( PORGRP_FLD | PORGRP_TOXREF ) ? sal_True : sal_False;  }
InExpGrp() const123cdf0e10cSrcweir 	inline sal_Bool InExpGrp( )	const { return nWhichPor & PORGRP_EXP ? sal_True : sal_False;  }
InTabnLftGrp() const124cdf0e10cSrcweir 	inline sal_Bool InTabnLftGrp( ) const
125cdf0e10cSrcweir 		{ return nWhichPor & PORGRP_TABNOTLFT ? sal_True : sal_False;  }
InFixMargGrp() const126cdf0e10cSrcweir 	inline sal_Bool InFixMargGrp( )const
127cdf0e10cSrcweir 		{ return nWhichPor & PORGRP_FIXMARG ? sal_True : sal_False;  }
InSpaceGrp() const128cdf0e10cSrcweir 	inline sal_Bool InSpaceGrp( )const
129cdf0e10cSrcweir 		{ return InTxtGrp() || IsMultiPortion();  }
130cdf0e10cSrcweir // Individuelle Abfragen:
IsGrfNumPortion() const131cdf0e10cSrcweir 	inline sal_Bool IsGrfNumPortion( )const{ return nWhichPor == POR_GRFNUM; }
IsFlyCntPortion() const132cdf0e10cSrcweir 	inline sal_Bool IsFlyCntPortion( )const{ return nWhichPor == POR_FLYCNT; }
IsBlankPortion() const133cdf0e10cSrcweir 	inline sal_Bool IsBlankPortion( )	const{ return nWhichPor == POR_BLANK; }
IsBreakPortion() const134cdf0e10cSrcweir 	inline sal_Bool IsBreakPortion( )	const{ return nWhichPor == POR_BRK; }
IsErgoSumPortion() const135cdf0e10cSrcweir 	inline sal_Bool IsErgoSumPortion()const{ return nWhichPor == POR_ERGOSUM;}
IsQuoVadisPortion() const136cdf0e10cSrcweir 	inline sal_Bool IsQuoVadisPortion()const{ return nWhichPor==POR_QUOVADIS;}
IsTabCntPortion() const137cdf0e10cSrcweir 	inline sal_Bool IsTabCntPortion( )const{ return nWhichPor==POR_TABCENTER;}
IsTabDecimalPortion() const138cdf0e10cSrcweir 	inline sal_Bool IsTabDecimalPortion() const { return nWhichPor == POR_TABDECIMAL;}
IsTabLeftPortion() const139cdf0e10cSrcweir 	inline sal_Bool IsTabLeftPortion()const{ return nWhichPor == POR_TABLEFT;}
IsFtnNumPortion() const140cdf0e10cSrcweir 	inline sal_Bool IsFtnNumPortion( )const{ return nWhichPor == POR_FTNNUM; }
IsFtnPortion() const141cdf0e10cSrcweir 	inline sal_Bool IsFtnPortion( )	const{ return nWhichPor == POR_FTN; }
IsTmpEndPortion() const142cdf0e10cSrcweir 	inline sal_Bool IsTmpEndPortion( )const{ return nWhichPor == POR_TMPEND; }
IsDropPortion() const143cdf0e10cSrcweir 	inline sal_Bool IsDropPortion( )	const{ return nWhichPor == POR_DROP; }
IsLayPortion() const144cdf0e10cSrcweir 	inline sal_Bool IsLayPortion( )	const{ return nWhichPor == POR_LAY; }
IsParaPortion() const145cdf0e10cSrcweir 	inline sal_Bool IsParaPortion( )	const{ return nWhichPor == POR_PARA; }
IsMarginPortion() const146cdf0e10cSrcweir 	inline sal_Bool IsMarginPortion( )const{ return nWhichPor == POR_MARGIN; }
IsFlyPortion() const147cdf0e10cSrcweir 	inline sal_Bool IsFlyPortion( )	const{ return nWhichPor == POR_FLY; }
IsHolePortion() const148cdf0e10cSrcweir 	inline sal_Bool IsHolePortion( )	const{ return nWhichPor == POR_HOLE; }
IsSoftHyphPortion() const149cdf0e10cSrcweir 	inline sal_Bool IsSoftHyphPortion()const{ return nWhichPor==POR_SOFTHYPH;}
IsPostItsPortion() const150cdf0e10cSrcweir 	inline sal_Bool IsPostItsPortion()const{ return nWhichPor == POR_POSTITS;}
IsCombinedPortion() const151cdf0e10cSrcweir 	inline sal_Bool IsCombinedPortion()const{ return nWhichPor==POR_COMBINED;}
IsTextPortion() const152cdf0e10cSrcweir 	inline sal_Bool IsTextPortion( ) const{ return nWhichPor == POR_TXT; }
IsURLPortion() const153cdf0e10cSrcweir 	inline sal_Bool IsURLPortion( ) const{ return nWhichPor == POR_URL; }
IsHangingPortion() const154cdf0e10cSrcweir 	inline sal_Bool IsHangingPortion( ) const{ return nWhichPor == POR_HNG; }
IsKernPortion() const155cdf0e10cSrcweir 	inline sal_Bool IsKernPortion( ) const{ return nWhichPor == POR_KERN; }
IsArrowPortion() const156cdf0e10cSrcweir 	inline sal_Bool IsArrowPortion( ) const{ return nWhichPor == POR_ARROW; }
IsMultiPortion() const157cdf0e10cSrcweir 	inline sal_Bool IsMultiPortion( ) const{ return nWhichPor == POR_MULTI; }
IsNumberPortion() const158cdf0e10cSrcweir 	inline sal_Bool IsNumberPortion( ) const{ return nWhichPor == POR_NUMBER; } // #i23726#
IsControlCharPortion() const159cdf0e10cSrcweir 	inline sal_Bool IsControlCharPortion() const { return nWhichPor == POR_CONTROLCHAR; }
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 	// Positionierung
162cdf0e10cSrcweir 	SwLinePortion *FindPrevPortion( const SwLinePortion *pRoot );
163cdf0e10cSrcweir 	SwLinePortion *FindLastPortion();
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 	virtual xub_StrLen GetCrsrOfst( const KSHORT nOfst ) const;
166cdf0e10cSrcweir 	virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const;
167cdf0e10cSrcweir 	void CalcTxtSize( const SwTxtSizeInfo &rInfo );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	// Ausgabe
170cdf0e10cSrcweir 	virtual void Paint( const SwTxtPaintInfo &rInf ) const = 0;
171cdf0e10cSrcweir     void PrePaint( const SwTxtPaintInfo &rInf, const SwLinePortion *pLast ) const;
172cdf0e10cSrcweir 
173cdf0e10cSrcweir #ifdef DBG_UTIL
174cdf0e10cSrcweir 	virtual sal_Bool Check( SvStream &rOs, SwTxtSizeInfo &rInfo ); //$ ostream
175cdf0e10cSrcweir #endif
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	virtual sal_Bool Format( SwTxtFormatInfo &rInf );
178cdf0e10cSrcweir 	// wird fuer die letzte Portion der Zeile extra gerufen
179cdf0e10cSrcweir 	virtual void FormatEOL( SwTxtFormatInfo &rInf );
180cdf0e10cSrcweir 			void Move( SwTxtPaintInfo &rInf );
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 	// Fuer SwTxtSlot
183cdf0e10cSrcweir 	virtual sal_Bool GetExpTxt( const SwTxtSizeInfo &rInf, XubString &rTxt ) const;
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	// fuer SwFldPortion, SwSoftHyphPortion
186cdf0e10cSrcweir 	virtual KSHORT GetViewWidth( const SwTxtSizeInfo &rInf ) const;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 	// for text- and multi-portions
189cdf0e10cSrcweir     virtual long CalcSpacing( long nSpaceAdd, const SwTxtSizeInfo &rInf ) const;
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     // Accessibility: pass information about this portion to the PortionHandler
192cdf0e10cSrcweir     virtual void HandlePortion( SwPortionHandler& rPH ) const;
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 	OUTPUT_OPERATOR
195cdf0e10cSrcweir };
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 
198cdf0e10cSrcweir /*************************************************************************
199cdf0e10cSrcweir  *					inline - Implementations
200cdf0e10cSrcweir  *************************************************************************/
201cdf0e10cSrcweir 
operator =(const SwLinePortion & rPortion)202cdf0e10cSrcweir inline SwLinePortion &SwLinePortion::operator=(const SwLinePortion &rPortion)
203cdf0e10cSrcweir {
204cdf0e10cSrcweir 	*(SwPosSize*)this = rPortion;
205cdf0e10cSrcweir 	nLineLength = rPortion.nLineLength;
206cdf0e10cSrcweir 	nAscent = rPortion.nAscent;
207cdf0e10cSrcweir 	nWhichPor = rPortion.nWhichPor;
208cdf0e10cSrcweir 	return *this;
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
operator ==(const SwLinePortion & rPortion) const211cdf0e10cSrcweir inline sal_Bool SwLinePortion::operator==(const SwLinePortion &rPortion ) const
212cdf0e10cSrcweir {
213cdf0e10cSrcweir 	return( Height() == rPortion.Height() &&
214cdf0e10cSrcweir             Width() == rPortion.Width() &&
215cdf0e10cSrcweir 			nLineLength == rPortion.GetLen() &&
216cdf0e10cSrcweir 			nAscent == rPortion.GetAscent() );
217cdf0e10cSrcweir }
218cdf0e10cSrcweir 
SwLinePortion(const SwLinePortion & rPortion)219cdf0e10cSrcweir inline SwLinePortion::SwLinePortion(const SwLinePortion &rPortion) :
220cdf0e10cSrcweir 	SwPosSize( rPortion ),
221cdf0e10cSrcweir 	pPortion( 0 ),
222cdf0e10cSrcweir 	nLineLength( rPortion.nLineLength ),
223cdf0e10cSrcweir 	nAscent( rPortion.nAscent ),
224cdf0e10cSrcweir 	nWhichPor( rPortion.nWhichPor )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir }
227cdf0e10cSrcweir 
Truncate()228cdf0e10cSrcweir inline void SwLinePortion::Truncate()
229cdf0e10cSrcweir {
230cdf0e10cSrcweir 	if ( pPortion )
231cdf0e10cSrcweir 		_Truncate();
232cdf0e10cSrcweir }
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 
235cdf0e10cSrcweir //$ ostream
236cdf0e10cSrcweir #ifdef DBGTXT
237cdf0e10cSrcweir #define CLASSIO( class ) \
238cdf0e10cSrcweir 	inline SvStream &operator<<( SvStream &rOs, const class &rClass ) {\
239cdf0e10cSrcweir 			return rClass.operator<<( rOs );\
240cdf0e10cSrcweir 	}
241cdf0e10cSrcweir #else
242cdf0e10cSrcweir #define CLASSIO( class )
243cdf0e10cSrcweir #endif
244cdf0e10cSrcweir 
245cdf0e10cSrcweir CLASSIO( SwLinePortion )
246cdf0e10cSrcweir 
247cdf0e10cSrcweir #endif
248