update credits
[LibreOffice.git] / sw / source / core / text / porlin.hxx
blob12f275bd8b21c2dba4fe3da0c73cf9ce9538a286
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _PORLIN_HXX
20 #define _PORLIN_HXX
22 #include "possiz.hxx" // SwPosSize
24 #ifdef DBG_UTIL
25 #include <libxml/xmlwriter.h>
26 #endif
28 class XubString;
29 class SwTxtSizeInfo;
30 class SwTxtPaintInfo;
31 class SwTxtFormatInfo;
32 class SwPortionHandler;
34 // The portions output operators are virtual methods of the portion.
35 // The CLASSIO macro implements the 'levitating' function.
36 // In doing so we end up with both benefits: virtual output operators and general utility
37 #ifdef DBG_UTIL
38 #define OUTPUT_OPERATOR virtual SvStream &operator<<( SvStream & aOs ) const;
39 #else
40 #define OUTPUT_OPERATOR
41 #endif
43 // Portion groups
44 #define PORGRP_TXT 0x8000
45 #define PORGRP_EXP 0x4000
46 #define PORGRP_FLD 0x2000
47 #define PORGRP_HYPH 0x1000
48 #define PORGRP_NUMBER 0x0800
49 #define PORGRP_GLUE 0x0400
50 #define PORGRP_FIX 0x0200
51 #define PORGRP_TAB 0x0100
52 #define PORGRP_NOTRECY 0x0080
53 // Small special groups
54 #define PORGRP_FIXMARG 0x0040
55 //#define PORGRP_? 0x0020
56 #define PORGRP_TABNOTLFT 0x0010
57 #define PORGRP_TOXREF 0x0008
59 /*************************************************************************
60 * class SwLinePortion
61 *************************************************************************/
63 /// Base class for anything that can be part of a line in the Writer layout.
64 class SwLinePortion: public SwPosSize
66 protected:
67 // Here we have areas with different attributes
68 SwLinePortion *pPortion;
69 // Count of chars and spaces on the line
70 xub_StrLen nLineLength;
71 KSHORT nAscent; // Maximum ascender
73 SwLinePortion();
74 private:
75 MSHORT nWhichPor; // Who's who?
77 void _Truncate();
79 public:
80 inline SwLinePortion(const SwLinePortion &rPortion);
81 virtual ~SwLinePortion();
83 // Access methods
84 inline SwLinePortion *GetPortion() const { return( pPortion ); }
85 inline SwLinePortion &operator=(const SwLinePortion &rPortion);
86 inline 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 ); }
98 inline const SwPosSize &PrtSize() const { return *this; }
100 // Insert methods
101 virtual SwLinePortion *Insert( SwLinePortion *pPortion );
102 virtual SwLinePortion *Append( SwLinePortion *pPortion );
103 SwLinePortion *Cut( SwLinePortion *pVictim );
104 inline void Truncate();
106 // Returns 0, if there's no payload
107 virtual SwLinePortion *Compress();
109 inline void SetWhichPor( const MSHORT nNew ) { nWhichPor = nNew; }
110 inline MSHORT GetWhichPor( ) const { return nWhichPor; }
112 // Group queries
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 // Individual queries
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; }
161 // Positioning
162 SwLinePortion *FindPrevPortion( const SwLinePortion *pRoot );
163 SwLinePortion *FindLastPortion();
165 virtual xub_StrLen GetCrsrOfst( const KSHORT nOfst ) const;
166 virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const;
167 void CalcTxtSize( const SwTxtSizeInfo &rInfo );
169 // Output
170 virtual void Paint( const SwTxtPaintInfo &rInf ) const = 0;
171 void PrePaint( const SwTxtPaintInfo &rInf, const SwLinePortion *pLast ) const;
173 virtual sal_Bool Format( SwTxtFormatInfo &rInf );
174 // Is called for the line's last portion
175 virtual void FormatEOL( SwTxtFormatInfo &rInf );
176 void Move( SwTxtPaintInfo &rInf );
178 // For SwTxtSlot
179 virtual sal_Bool GetExpTxt( const SwTxtSizeInfo &rInf, OUString &rTxt ) const;
181 // For SwFldPortion, SwSoftHyphPortion
182 virtual KSHORT GetViewWidth( const SwTxtSizeInfo &rInf ) const;
184 // for text- and multi-portions
185 virtual long CalcSpacing( long nSpaceAdd, const SwTxtSizeInfo &rInf ) const;
187 // Accessibility: pass information about this portion to the PortionHandler
188 virtual void HandlePortion( SwPortionHandler& rPH ) const;
190 OUTPUT_OPERATOR
194 /*************************************************************************
195 * inline - Implementations
196 *************************************************************************/
198 inline SwLinePortion &SwLinePortion::operator=(const SwLinePortion &rPortion)
200 *(SwPosSize*)this = rPortion;
201 nLineLength = rPortion.nLineLength;
202 nAscent = rPortion.nAscent;
203 nWhichPor = rPortion.nWhichPor;
204 return *this;
207 inline bool SwLinePortion::operator==(const SwLinePortion &rPortion ) const
209 return( Height() == rPortion.Height() &&
210 Width() == rPortion.Width() &&
211 nLineLength == rPortion.GetLen() &&
212 nAscent == rPortion.GetAscent() );
215 inline SwLinePortion::SwLinePortion(const SwLinePortion &rPortion) :
216 SwPosSize( rPortion ),
217 pPortion( 0 ),
218 nLineLength( rPortion.nLineLength ),
219 nAscent( rPortion.nAscent ),
220 nWhichPor( rPortion.nWhichPor )
224 inline void SwLinePortion::Truncate()
226 if ( pPortion )
227 _Truncate();
231 //$ ostream
232 #define CLASSIO( class )
234 CLASSIO( SwLinePortion )
236 #endif
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */