1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: porlin.hxx,v $
10 * $Revision: 1.17.214.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 #include "possiz.hxx" // SwPosSize
38 class SwTxtFormatInfo
;
39 class SwPortionHandler
;
41 // Die Ausgabeoperatoren der Portions sind virtuelle Methoden der Portion.
42 // Das CLASSIO-Makro implementiert die 'freischwebende' Funktion.
43 // Auf diese Weise erhaelt man beide Vorteile: virtuelle Ausgabeoperatoren
44 // und allgemeine Verwendbarkeit.
46 #define OUTPUT_OPERATOR virtual SvStream &operator<<( SvStream & aOs ) const;
48 #define OUTPUT_OPERATOR
52 #define PORGRP_TXT 0x8000
53 #define PORGRP_EXP 0x4000
54 #define PORGRP_FLD 0x2000
55 #define PORGRP_HYPH 0x1000
56 #define PORGRP_NUMBER 0x0800
57 #define PORGRP_GLUE 0x0400
58 #define PORGRP_FIX 0x0200
59 #define PORGRP_TAB 0x0100
60 #define PORGRP_NOTRECY 0x0080
61 // kleine Spezialgruppen
62 #define PORGRP_FIXMARG 0x0040
63 //#define PORGRP_? 0x0020
64 #define PORGRP_TABNOTLFT 0x0010
65 #define PORGRP_TOXREF 0x0008
67 /*************************************************************************
69 *************************************************************************/
71 class SwLinePortion
: public SwPosSize
74 // Hier gibt es Bereiche mit unterschiedlichen Attributen.
75 SwLinePortion
*pPortion
;
76 // Anzahl der Zeichen und Spaces auf der Zeile
77 xub_StrLen nLineLength
;
78 KSHORT nAscent
; // Maximaler Ascender
82 MSHORT nWhichPor
; // Who's who?
87 inline SwLinePortion(const SwLinePortion
&rPortion
);
88 virtual ~SwLinePortion();
91 inline SwLinePortion
*GetPortion() const { return( pPortion
); }
92 inline SwLinePortion
&operator=(const SwLinePortion
&rPortion
);
93 inline sal_Bool
operator==( const SwLinePortion
&rPortion
) const;
94 inline xub_StrLen
GetLen() const { return nLineLength
; }
95 inline void SetLen( const xub_StrLen nLen
) { nLineLength
= nLen
; }
96 inline void SetPortion( SwLinePortion
*pNew
){ pPortion
= pNew
; }
97 inline KSHORT
&GetAscent() { return nAscent
; }
98 inline KSHORT
GetAscent() const { return nAscent
; }
99 inline void SetAscent( const KSHORT nNewAsc
) { nAscent
= nNewAsc
; }
100 inline void PrtWidth( KSHORT nNewWidth
) { Width( nNewWidth
); }
101 inline KSHORT
PrtWidth() const { return Width(); }
102 inline void AddPrtWidth( const KSHORT nNew
) { Width( Width() + nNew
); }
103 inline void SubPrtWidth( const KSHORT nNew
) { Width( Width() - nNew
); }
105 inline const SwPosSize
&PrtSize() const { return *this; }
107 // Einfuegeoperationen:
108 virtual SwLinePortion
*Insert( SwLinePortion
*pPortion
);
109 virtual SwLinePortion
*Append( SwLinePortion
*pPortion
);
110 SwLinePortion
*Cut( SwLinePortion
*pVictim
);
111 inline void Truncate();
113 // liefert 0 zurueck, wenn keine Nutzdaten enthalten sind.
114 virtual SwLinePortion
*Compress();
116 inline void SetWhichPor( const MSHORT nNew
) { nWhichPor
= nNew
; }
117 inline MSHORT
GetWhichPor( ) const { return nWhichPor
; }
120 inline sal_Bool
InTxtGrp( ) const { return nWhichPor
& PORGRP_TXT
? sal_True
: sal_False
; }
121 inline sal_Bool
InGlueGrp( ) const { return nWhichPor
& PORGRP_GLUE
? sal_True
: sal_False
;}
122 inline sal_Bool
InTabGrp( ) const { return nWhichPor
& PORGRP_TAB
? sal_True
: sal_False
; }
123 inline sal_Bool
InHyphGrp( ) const { return nWhichPor
& PORGRP_HYPH
? sal_True
: sal_False
;}
124 inline sal_Bool
InNumberGrp( )const { return nWhichPor
& PORGRP_NUMBER
? sal_True
: sal_False
;}
125 inline sal_Bool
InFixGrp( ) const { return nWhichPor
& PORGRP_FIX
? sal_True
: sal_False
; }
126 inline sal_Bool
InFldGrp( ) const { return nWhichPor
& PORGRP_FLD
? sal_True
: sal_False
; }
127 inline sal_Bool
InToxRefGrp( ) const { return nWhichPor
& PORGRP_TOXREF
? sal_True
: sal_False
; }
128 inline sal_Bool
InToxRefOrFldGrp( ) const { return nWhichPor
&
129 ( PORGRP_FLD
| PORGRP_TOXREF
) ? sal_True
: sal_False
; }
130 inline sal_Bool
InExpGrp( ) const { return nWhichPor
& PORGRP_EXP
? sal_True
: sal_False
; }
131 inline sal_Bool
InTabnLftGrp( ) const
132 { return nWhichPor
& PORGRP_TABNOTLFT
? sal_True
: sal_False
; }
133 inline sal_Bool
InFixMargGrp( )const
134 { return nWhichPor
& PORGRP_FIXMARG
? sal_True
: sal_False
; }
135 inline sal_Bool
InSpaceGrp( )const
136 { return InTxtGrp() || IsMultiPortion(); }
137 // Individuelle Abfragen:
138 inline sal_Bool
IsGrfNumPortion( )const{ return nWhichPor
== POR_GRFNUM
; }
139 inline sal_Bool
IsFlyCntPortion( )const{ return nWhichPor
== POR_FLYCNT
; }
140 inline sal_Bool
IsBlankPortion( ) const{ return nWhichPor
== POR_BLANK
; }
141 inline sal_Bool
IsBreakPortion( ) const{ return nWhichPor
== POR_BRK
; }
142 inline sal_Bool
IsErgoSumPortion()const{ return nWhichPor
== POR_ERGOSUM
;}
143 inline sal_Bool
IsQuoVadisPortion()const{ return nWhichPor
==POR_QUOVADIS
;}
144 inline sal_Bool
IsTabCntPortion( )const{ return nWhichPor
==POR_TABCENTER
;}
145 inline sal_Bool
IsTabDecimalPortion() const { return nWhichPor
== POR_TABDECIMAL
;}
146 inline sal_Bool
IsTabLeftPortion()const{ return nWhichPor
== POR_TABLEFT
;}
147 inline sal_Bool
IsFtnNumPortion( )const{ return nWhichPor
== POR_FTNNUM
; }
148 inline sal_Bool
IsFtnPortion( ) const{ return nWhichPor
== POR_FTN
; }
149 inline sal_Bool
IsTmpEndPortion( )const{ return nWhichPor
== POR_TMPEND
; }
150 inline sal_Bool
IsDropPortion( ) const{ return nWhichPor
== POR_DROP
; }
151 inline sal_Bool
IsLayPortion( ) const{ return nWhichPor
== POR_LAY
; }
152 inline sal_Bool
IsParaPortion( ) const{ return nWhichPor
== POR_PARA
; }
153 inline sal_Bool
IsMarginPortion( )const{ return nWhichPor
== POR_MARGIN
; }
154 inline sal_Bool
IsFlyPortion( ) const{ return nWhichPor
== POR_FLY
; }
155 inline sal_Bool
IsHolePortion( ) const{ return nWhichPor
== POR_HOLE
; }
156 inline sal_Bool
IsSoftHyphPortion()const{ return nWhichPor
==POR_SOFTHYPH
;}
157 inline sal_Bool
IsPostItsPortion()const{ return nWhichPor
== POR_POSTITS
;}
158 inline sal_Bool
IsCombinedPortion()const{ return nWhichPor
==POR_COMBINED
;}
159 inline sal_Bool
IsTextPortion( ) const{ return nWhichPor
== POR_TXT
; }
160 inline sal_Bool
IsURLPortion( ) const{ return nWhichPor
== POR_URL
; }
161 inline sal_Bool
IsHangingPortion( ) const{ return nWhichPor
== POR_HNG
; }
162 inline sal_Bool
IsKernPortion( ) const{ return nWhichPor
== POR_KERN
; }
163 inline sal_Bool
IsArrowPortion( ) const{ return nWhichPor
== POR_ARROW
; }
164 inline sal_Bool
IsMultiPortion( ) const{ return nWhichPor
== POR_MULTI
; }
165 inline sal_Bool
IsNumberPortion( ) const{ return nWhichPor
== POR_NUMBER
; } // #i23726#
166 inline sal_Bool
IsControlCharPortion() const { return nWhichPor
== POR_CONTROLCHAR
; }
169 SwLinePortion
*FindPrevPortion( const SwLinePortion
*pRoot
);
170 SwLinePortion
*FindLastPortion();
172 virtual xub_StrLen
GetCrsrOfst( const KSHORT nOfst
) const;
173 virtual SwPosSize
GetTxtSize( const SwTxtSizeInfo
&rInfo
) const;
174 void CalcTxtSize( const SwTxtSizeInfo
&rInfo
);
177 virtual void Paint( const SwTxtPaintInfo
&rInf
) const = 0;
178 void PrePaint( const SwTxtPaintInfo
&rInf
, const SwLinePortion
*pLast
) const;
181 virtual sal_Bool
Check( SvStream
&rOs
, SwTxtSizeInfo
&rInfo
); //$ ostream
184 virtual sal_Bool
Format( SwTxtFormatInfo
&rInf
);
185 // wird fuer die letzte Portion der Zeile extra gerufen
186 virtual void FormatEOL( SwTxtFormatInfo
&rInf
);
187 void Move( SwTxtPaintInfo
&rInf
);
190 virtual sal_Bool
GetExpTxt( const SwTxtSizeInfo
&rInf
, XubString
&rTxt
) const;
192 // fuer SwFldPortion, SwSoftHyphPortion
193 virtual KSHORT
GetViewWidth( const SwTxtSizeInfo
&rInf
) const;
195 // for text- and multi-portions
196 virtual long CalcSpacing( long nSpaceAdd
, const SwTxtSizeInfo
&rInf
) const;
198 // Accessibility: pass information about this portion to the PortionHandler
199 virtual void HandlePortion( SwPortionHandler
& rPH
) const;
205 /*************************************************************************
206 * inline - Implementations
207 *************************************************************************/
209 inline SwLinePortion
&SwLinePortion::operator=(const SwLinePortion
&rPortion
)
211 *(SwPosSize
*)this = rPortion
;
212 nLineLength
= rPortion
.nLineLength
;
213 nAscent
= rPortion
.nAscent
;
214 nWhichPor
= rPortion
.nWhichPor
;
218 inline sal_Bool
SwLinePortion::operator==(const SwLinePortion
&rPortion
) const
220 return( Height() == rPortion
.Height() &&
221 Width() == rPortion
.Width() &&
222 nLineLength
== rPortion
.GetLen() &&
223 nAscent
== rPortion
.GetAscent() );
226 inline SwLinePortion::SwLinePortion(const SwLinePortion
&rPortion
) :
227 SwPosSize( rPortion
),
229 nLineLength( rPortion
.nLineLength
),
230 nAscent( rPortion
.nAscent
),
231 nWhichPor( rPortion
.nWhichPor
)
235 inline void SwLinePortion::Truncate()
244 #define CLASSIO( class ) \
245 inline SvStream &operator<<( SvStream &rOs, const class &rClass ) {\
246 return rClass.operator<<( rOs );\
249 #define CLASSIO( class )
252 CLASSIO( SwLinePortion
)