Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_SW_SOURCE_CORE_TEXT_PORLIN_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_TEXT_PORLIN_HXX
21 :
22 : #include "possiz.hxx"
23 :
24 : #ifdef DBG_UTIL
25 : #include <libxml/xmlwriter.h>
26 : #endif
27 :
28 : class SwTxtSizeInfo;
29 : class SwTxtPaintInfo;
30 : class SwTxtFormatInfo;
31 : class SwPortionHandler;
32 :
33 : // The portions output operators are virtual methods of the portion.
34 : #ifdef DBG_UTIL
35 : #define OUTPUT_OPERATOR virtual SvStream & operator<<( SvStream & aOs ) const;
36 : #define OUTPUT_OPERATOR_OVERRIDE virtual SvStream & operator<<( SvStream & aOs ) const SAL_OVERRIDE;
37 : #else
38 : #define OUTPUT_OPERATOR
39 : #define OUTPUT_OPERATOR_OVERRIDE
40 : #endif
41 :
42 : // Portion groups
43 : #define PORGRP_TXT 0x8000
44 : #define PORGRP_EXP 0x4000
45 : #define PORGRP_FLD 0x2000
46 : #define PORGRP_HYPH 0x1000
47 : #define PORGRP_NUMBER 0x0800
48 : #define PORGRP_GLUE 0x0400
49 : #define PORGRP_FIX 0x0200
50 : #define PORGRP_TAB 0x0100
51 : #define PORGRP_NOTRECY 0x0080
52 : // Small special groups
53 : #define PORGRP_FIXMARG 0x0040
54 : //#define PORGRP_? 0x0020
55 : #define PORGRP_TABNOTLFT 0x0010
56 : #define PORGRP_TOXREF 0x0008
57 :
58 : /*************************************************************************
59 : * class SwLinePortion
60 : *************************************************************************/
61 :
62 : /// Base class for anything that can be part of a line in the Writer layout.
63 : class SwLinePortion: public SwPosSize
64 : {
65 : protected:
66 : // Here we have areas with different attributes
67 : SwLinePortion *pPortion;
68 : // Count of chars and spaces on the line
69 : sal_Int32 nLineLength;
70 : KSHORT nAscent; // Maximum ascender
71 :
72 : SwLinePortion();
73 : private:
74 : MSHORT nWhichPor; // Who's who?
75 : bool m_bJoinBorderWithPrev;
76 : bool m_bJoinBorderWithNext;
77 :
78 : void _Truncate();
79 :
80 : public:
81 : inline SwLinePortion(const SwLinePortion &rPortion);
82 : virtual ~SwLinePortion();
83 :
84 : // Access methods
85 0 : inline SwLinePortion *GetPortion() const { return( pPortion ); }
86 : inline SwLinePortion &operator=(const SwLinePortion &rPortion);
87 : inline bool operator==( const SwLinePortion &rPortion ) const;
88 0 : inline sal_Int32 GetLen() const { return nLineLength; }
89 0 : inline void SetLen( const sal_Int32 nLen ) { nLineLength = nLen; }
90 0 : inline void SetPortion( SwLinePortion *pNew ){ pPortion = pNew; }
91 0 : inline KSHORT &GetAscent() { return nAscent; }
92 0 : inline KSHORT GetAscent() const { return nAscent; }
93 0 : inline void SetAscent( const KSHORT nNewAsc ) { nAscent = nNewAsc; }
94 0 : inline void PrtWidth( KSHORT nNewWidth ) { Width( nNewWidth ); }
95 0 : inline KSHORT PrtWidth() const { return Width(); }
96 0 : inline void AddPrtWidth( const KSHORT nNew ) { Width( Width() + nNew ); }
97 0 : inline void SubPrtWidth( const KSHORT nNew ) { Width( Width() - nNew ); }
98 :
99 : inline const SwPosSize &PrtSize() const { return *this; }
100 :
101 : // Insert methods
102 : virtual SwLinePortion *Insert( SwLinePortion *pPortion );
103 : virtual SwLinePortion *Append( SwLinePortion *pPortion );
104 : SwLinePortion *Cut( SwLinePortion *pVictim );
105 : inline void Truncate();
106 :
107 : // Returns 0, if there's no payload
108 : virtual SwLinePortion *Compress();
109 :
110 0 : inline void SetWhichPor( const MSHORT nNew ) { nWhichPor = nNew; }
111 0 : inline MSHORT GetWhichPor( ) const { return nWhichPor; }
112 :
113 : // Group queries
114 0 : inline bool InTxtGrp() const { return nWhichPor & PORGRP_TXT; }
115 0 : inline bool InGlueGrp() const { return nWhichPor & PORGRP_GLUE; }
116 0 : inline bool InTabGrp() const { return nWhichPor & PORGRP_TAB; }
117 0 : inline bool InHyphGrp() const { return nWhichPor & PORGRP_HYPH; }
118 0 : inline bool InNumberGrp() const { return nWhichPor & PORGRP_NUMBER; }
119 0 : inline bool InFixGrp() const { return nWhichPor & PORGRP_FIX; }
120 0 : inline bool InFldGrp() const { return nWhichPor & PORGRP_FLD; }
121 0 : inline bool InToxRefGrp() const { return nWhichPor & PORGRP_TOXREF; }
122 0 : inline bool InToxRefOrFldGrp() const { return nWhichPor & ( PORGRP_FLD | PORGRP_TOXREF ); }
123 0 : inline bool InExpGrp() const { return nWhichPor & PORGRP_EXP; }
124 : inline bool InTabnLftGrp() const { return nWhichPor & PORGRP_TABNOTLFT; }
125 0 : inline bool InFixMargGrp() const { return nWhichPor & PORGRP_FIXMARG; }
126 0 : inline bool InSpaceGrp() const { return InTxtGrp() || IsMultiPortion(); }
127 : // Individual queries
128 0 : inline bool IsGrfNumPortion() const { return nWhichPor == POR_GRFNUM; }
129 0 : inline bool IsFlyCntPortion() const { return nWhichPor == POR_FLYCNT; }
130 0 : inline bool IsBlankPortion() const { return nWhichPor == POR_BLANK; }
131 0 : inline bool IsBreakPortion() const { return nWhichPor == POR_BRK; }
132 0 : inline bool IsErgoSumPortion() const { return nWhichPor == POR_ERGOSUM; }
133 0 : inline bool IsQuoVadisPortion() const { return nWhichPor == POR_QUOVADIS; }
134 : inline bool IsTabCntPortion() const { return nWhichPor == POR_TABCENTER; }
135 : inline bool IsTabDecimalPortion() const { return nWhichPor == POR_TABDECIMAL; }
136 0 : inline bool IsTabLeftPortion() const { return nWhichPor == POR_TABLEFT; }
137 0 : inline bool IsFtnNumPortion() const { return nWhichPor == POR_FTNNUM; }
138 0 : inline bool IsFtnPortion() const { return nWhichPor == POR_FTN; }
139 : inline bool IsTmpEndPortion() const { return nWhichPor == POR_TMPEND; }
140 0 : inline bool IsDropPortion() const { return nWhichPor == POR_DROP; }
141 0 : inline bool IsLayPortion() const { return nWhichPor == POR_LAY; }
142 0 : inline bool IsParaPortion() const { return nWhichPor == POR_PARA; }
143 0 : inline bool IsMarginPortion() const { return nWhichPor == POR_MARGIN; }
144 0 : inline bool IsFlyPortion() const { return nWhichPor == POR_FLY; }
145 0 : inline bool IsHolePortion() const { return nWhichPor == POR_HOLE; }
146 0 : inline bool IsSoftHyphPortion() const { return nWhichPor == POR_SOFTHYPH; }
147 0 : inline bool IsPostItsPortion() const { return nWhichPor == POR_POSTITS; }
148 0 : inline bool IsCombinedPortion() const { return nWhichPor == POR_COMBINED; }
149 0 : inline bool IsTextPortion() const { return nWhichPor == POR_TXT; }
150 : inline bool IsURLPortion() const { return nWhichPor == POR_URL; }
151 0 : inline bool IsHangingPortion() const { return nWhichPor == POR_HNG; }
152 0 : inline bool IsKernPortion() const { return nWhichPor == POR_KERN; }
153 0 : inline bool IsArrowPortion() const { return nWhichPor == POR_ARROW; }
154 0 : inline bool IsMultiPortion() const { return nWhichPor == POR_MULTI; }
155 0 : inline bool IsNumberPortion() const { return nWhichPor == POR_NUMBER; } // #i23726#
156 0 : inline bool IsControlCharPortion() const { return nWhichPor == POR_CONTROLCHAR; }
157 :
158 : // Positioning
159 : SwLinePortion *FindPrevPortion( const SwLinePortion *pRoot );
160 : SwLinePortion *FindLastPortion();
161 :
162 : virtual sal_Int32 GetCrsrOfst( const KSHORT nOfst ) const;
163 : virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const;
164 : void CalcTxtSize( const SwTxtSizeInfo &rInfo );
165 :
166 : // Output
167 : virtual void Paint( const SwTxtPaintInfo &rInf ) const = 0;
168 : void PrePaint( const SwTxtPaintInfo &rInf, const SwLinePortion *pLast ) const;
169 :
170 : virtual bool Format( SwTxtFormatInfo &rInf );
171 : // Is called for the line's last portion
172 : virtual void FormatEOL( SwTxtFormatInfo &rInf );
173 : void Move( SwTxtPaintInfo &rInf );
174 :
175 : // For SwTxtSlot
176 : virtual bool GetExpTxt( const SwTxtSizeInfo &rInf, OUString &rTxt ) const;
177 :
178 : // For SwFldPortion, SwSoftHyphPortion
179 : virtual KSHORT GetViewWidth( const SwTxtSizeInfo &rInf ) const;
180 :
181 : // for text- and multi-portions
182 : virtual long CalcSpacing( long nSpaceAdd, const SwTxtSizeInfo &rInf ) const;
183 :
184 : // Accessibility: pass information about this portion to the PortionHandler
185 : virtual void HandlePortion( SwPortionHandler& rPH ) const;
186 :
187 0 : bool GetJoinBorderWithPrev() const { return m_bJoinBorderWithPrev; }
188 0 : bool GetJoinBorderWithNext() const { return m_bJoinBorderWithNext; }
189 0 : void SetJoinBorderWithPrev( const bool bJoinPrev ) { m_bJoinBorderWithPrev = bJoinPrev; }
190 0 : void SetJoinBorderWithNext( const bool bJoinNext ) { m_bJoinBorderWithNext = bJoinNext; }
191 :
192 : OUTPUT_OPERATOR
193 : };
194 :
195 : /*************************************************************************
196 : * inline - Implementations
197 : *************************************************************************/
198 :
199 0 : inline SwLinePortion &SwLinePortion::operator=(const SwLinePortion &rPortion)
200 : {
201 0 : *(SwPosSize*)this = rPortion;
202 0 : nLineLength = rPortion.nLineLength;
203 0 : nAscent = rPortion.nAscent;
204 0 : nWhichPor = rPortion.nWhichPor;
205 0 : m_bJoinBorderWithPrev = rPortion.m_bJoinBorderWithPrev;
206 0 : m_bJoinBorderWithNext = rPortion.m_bJoinBorderWithNext;
207 0 : return *this;
208 : }
209 :
210 : inline bool SwLinePortion::operator==(const SwLinePortion &rPortion ) const
211 : {
212 : return( Height() == rPortion.Height() &&
213 : Width() == rPortion.Width() &&
214 : nLineLength == rPortion.GetLen() &&
215 : nAscent == rPortion.GetAscent() );
216 : }
217 :
218 0 : inline SwLinePortion::SwLinePortion(const SwLinePortion &rPortion) :
219 : SwPosSize( rPortion ),
220 : pPortion( 0 ),
221 : nLineLength( rPortion.nLineLength ),
222 : nAscent( rPortion.nAscent ),
223 : nWhichPor( rPortion.nWhichPor ),
224 : m_bJoinBorderWithPrev( rPortion.m_bJoinBorderWithPrev ),
225 0 : m_bJoinBorderWithNext( rPortion.m_bJoinBorderWithNext )
226 : {
227 0 : }
228 :
229 0 : inline void SwLinePortion::Truncate()
230 : {
231 0 : if ( pPortion )
232 0 : _Truncate();
233 0 : }
234 :
235 : #endif
236 :
237 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|