summaryrefslogtreecommitdiff
path: root/binfilter/bf_sw/source/core/text/sw_porlin.cxx
blob: 04400d5db49daa5b02d704d44851b536d6916a2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */


#ifdef _MSC_VER
#pragma hdrstop
#endif

#include "txtcfg.hxx"
#include "pormulti.hxx"
#include "inftxt.hxx"
namespace binfilter {

#ifdef DBG_UTIL

/*N*/ sal_Bool ChkChain( SwLinePortion *pStart )
/*N*/ {
/*N*/   SwLinePortion *pPor = pStart->GetPortion();
/*N*/   MSHORT nCount = 0;
/*N*/   while( pPor )
/*N*/   {
/*N*/       ++nCount;
/*N*/       OSL_ENSURE( nCount < 200 && pPor != pStart,
/*N*/               "ChkChain(): lost in chains" );
/*N*/       if( nCount >= 200 || pPor == pStart )
/*N*/       {
/*N*/           // der Lebensretter
/*?*/           pPor = pStart->GetPortion();
/*?*/           pStart->SetPortion(0);
/*?*/           pPor->Truncate();
/*?*/           pStart->SetPortion( pPor );
/*?*/           return sal_False;
/*N*/       }
/*N*/       pPor = pPor->GetPortion();
/*N*/   }
/*N*/   return sal_True;
/*N*/ }
#endif

/*N*/ SwLinePortion::~SwLinePortion()
/*N*/ {
/*N*/ }

/*N*/ SwLinePortion *SwLinePortion::Compress()
/*N*/ {
/*N*/   return GetLen() || Width() ? this : 0;
/*N*/ }


/*************************************************************************
 *               SwLinePortion::SwLinePortion( )
 *************************************************************************/

/*N*/ SwLinePortion::SwLinePortion( )
/*N*/   : pPortion( NULL )
/*N*/   , nLineLength( 0 )
/*N*/   , nAscent( 0 )
/*N*/ {
/*N*/ }

/*************************************************************************
 *               SwLinePortion::PrePaint()
 *************************************************************************/


/*************************************************************************
 *                  SwLinePortion::CalcTxtSize()
 *************************************************************************/

/*N*/ void SwLinePortion::CalcTxtSize( const SwTxtSizeInfo &rInf )
/*N*/ {
/*N*/   if( GetLen() == rInf.GetLen()  )
/*N*/       *((SwPosSize*)this) = GetTxtSize( rInf );
/*N*/   else
/*N*/   {
/*?*/       SwTxtSizeInfo aInf( rInf );
/*?*/       aInf.SetLen( GetLen() );
/*?*/       *((SwPosSize*)this) = GetTxtSize( aInf );
/*N*/   }
/*N*/ }

/*************************************************************************
 *                  SwLinePortion::Truncate()
 *
 * Es werden alle nachfolgenden Portions geloescht.
 *************************************************************************/

/*N*/ void SwLinePortion::_Truncate()
/*N*/ {
/*N*/   SwLinePortion *pPos = pPortion;
/*N*/   do
/*N*/   {   OSL_ENSURE( pPos != this, "SwLinePortion::Truncate: loop" );
/*N*/       SwLinePortion *pLast = pPos;
/*N*/       pPos = pPos->GetPortion();
/*N*/       pLast->SetPortion( 0 );
/*N*/       delete pLast;
/*N*/
/*N*/   } while( pPos );
/*N*/
/*N*/   pPortion = 0;
/*N*/ }

/*************************************************************************
 *                virtual SwLinePortion::Insert()
 *
 * Es wird immer hinter uns eingefuegt.
 *************************************************************************/

/*N*/ SwLinePortion *SwLinePortion::Insert( SwLinePortion *pIns )
/*N*/ {
/*N*/   pIns->FindLastPortion()->SetPortion( pPortion );
/*N*/   SetPortion( pIns );
/*N*/ #ifdef DBG_UTIL
/*N*/   ChkChain( this );
/*N*/ #endif
/*N*/   return pIns;
/*N*/ }

/*************************************************************************
 *                  SwLinePortion::FindLastPortion()
 *************************************************************************/

/*N*/ SwLinePortion *SwLinePortion::FindLastPortion()
/*N*/ {
/*N*/   register SwLinePortion *pPos = this;
/*N*/   // An das Ende wandern und pLinPortion an den letzten haengen ...
/*N*/   while( pPos->GetPortion() )
/*N*/   {
///*N*/         DBG_LOOP;
/*N*/       pPos = pPos->GetPortion();
/*N*/   }
/*N*/   return pPos;
/*N*/ }

/*************************************************************************
 *                virtual SwLinePortion::Append()
 *************************************************************************/

/*N*/ SwLinePortion *SwLinePortion::Append( SwLinePortion *pIns )
/*N*/ {
/*N*/   SwLinePortion *pPos = FindLastPortion();
/*N*/   pPos->SetPortion( pIns );
/*N*/   pIns->SetPortion( 0 );
/*N*/ #ifdef DBG_UTIL
/*N*/   ChkChain( this );
/*N*/ #endif
/*N*/   return pIns;
/*N*/ }

/*************************************************************************
 *                virtual SwLinePortion::Cut()
 *************************************************************************/

/*N*/ SwLinePortion *SwLinePortion::Cut( SwLinePortion *pVictim )
/*N*/ {
/*N*/   SwLinePortion *pPrev = pVictim->FindPrevPortion( this );
/*N*/   OSL_ENSURE( pPrev, "SwLinePortion::Cut(): can't cut" );
/*N*/   pPrev->SetPortion( pVictim->GetPortion() );
/*N*/   pVictim->SetPortion(0);
/*N*/   return pVictim;
/*N*/ }

/*************************************************************************
 *                SwLinePortion::FindPrevPortion()
 *************************************************************************/

/*N*/ SwLinePortion *SwLinePortion::FindPrevPortion( const SwLinePortion *pRoot )
/*N*/ {
/*N*/   OSL_ENSURE( pRoot != this, "SwLinePortion::FindPrevPortion(): invalid root" );
/*N*/   SwLinePortion *pPos = (SwLinePortion*)pRoot;
/*N*/   while( pPos->GetPortion() && pPos->GetPortion() != this )
/*N*/   {
///*N*/         DBG_LOOP;
/*N*/       pPos = pPos->GetPortion();
/*N*/   }
/*N*/   OSL_ENSURE( pPos->GetPortion(),
/*N*/           "SwLinePortion::FindPrevPortion: blowing in the wind");
/*N*/   return pPos;
/*N*/ }

/*************************************************************************
 *                virtual SwLinePortion::GetCrsrOfst()
 *************************************************************************/


/*************************************************************************
 *                virtual SwLinePortion::GetTxtSize()
 *************************************************************************/
/*N*/
/*N*/ SwPosSize SwLinePortion::GetTxtSize( const SwTxtSizeInfo & ) const
/*N*/ {
/*N*/   OSL_ENSURE( !this, "SwLinePortion::GetTxtSize: don't ask me about sizes, "
/*N*/                  "I'm only a stupid SwLinePortion" );
/*N*/   return SwPosSize();
/*N*/ }

/*************************************************************************
 *                 virtual SwLinePortion::Format()
 *************************************************************************/

/*N*/ sal_Bool SwLinePortion::Format( SwTxtFormatInfo &rInf )
/*N*/ {
/*N*/   if( rInf.X() > rInf.Width() )
/*N*/   {
/*?*/       Truncate();
/*?*/       rInf.SetUnderFlow( this );
/*?*/       return sal_True;
/*N*/   }
/*N*/
/*N*/   register const SwLinePortion *pLast = rInf.GetLast();
/*N*/   Height( pLast->Height() );
/*N*/   SetAscent( pLast->GetAscent() );
/*N*/   const KSHORT nNewWidth = rInf.X() + PrtWidth();
/*N*/   // Nur Portions mit echter Breite koennen ein sal_True zurueckliefern
/*N*/   // Notizen beispielsweise setzen niemals bFull==sal_True
/*N*/     if( rInf.Width() <= nNewWidth && PrtWidth() && ! IsKernPortion() )
/*N*/   {
/*?*/       Truncate();
/*?*/       if( nNewWidth > rInf.Width() )
/*?*/           PrtWidth( nNewWidth - rInf.Width() );
/*?*/       rInf.GetLast()->FormatEOL( rInf );
/*?*/       return sal_True;
/*N*/   }
/*N*/   return sal_False;
/*N*/ }

/*************************************************************************
 *                 virtual SwLinePortion::FormatEOL()
 *************************************************************************/

// Format end of line

/*N*/ void SwLinePortion::FormatEOL( SwTxtFormatInfo & /*rInf*/ )
/*N*/ { }

/*************************************************************************
 *                      SwLinePortion::Move()
 *************************************************************************/

/*N*/ void SwLinePortion::Move( SwTxtPaintInfo &rInf )
/*N*/ {
/*N*/   BOOL bB2T = rInf.GetDirection() == DIR_BOTTOM2TOP;
/*N*/ #ifdef BIDI
/*N*/     const BOOL bFrmDir = rInf.GetTxtFrm()->IsRightToLeft();
/*N*/     BOOL bCounterDir = ( ! bFrmDir && DIR_RIGHT2LEFT == rInf.GetDirection() ) ||
/*N*/                        (   bFrmDir && DIR_LEFT2RIGHT == rInf.GetDirection() );
/*N*/ #endif
/*N*/
/*N*/     if ( InSpaceGrp() && rInf.GetSpaceAdd() )
/*N*/   {
/*?*/       SwTwips nTmp = PrtWidth() + CalcSpacing( rInf.GetSpaceAdd(), rInf );
/*?*/       if( rInf.IsRotated() )
/*?*/           rInf.Y( rInf.Y() + ( bB2T ? -nTmp : nTmp ) );
/*?*/ #ifdef BIDI
/*?*/         else if ( bCounterDir )
/*?*/             rInf.X( rInf.X() - nTmp );
/*?*/ #endif
/*?*/         else
/*?*/             rInf.X( rInf.X() + nTmp );
/*N*/   }
/*N*/   else
/*N*/   {
/*N*/         if( InFixMargGrp() && !IsMarginPortion() )
/*N*/       {
/*N*/           rInf.IncSpaceIdx();
/*N*/             rInf.IncKanaIdx();
/*N*/       }
/*N*/       if( rInf.IsRotated() )
/*?*/           rInf.Y( rInf.Y() + ( bB2T ? -PrtWidth() : PrtWidth() ) );
/*N*/ #ifdef BIDI
/*N*/         else if ( bCounterDir )
/*?*/             rInf.X( rInf.X() - PrtWidth() );
/*N*/ #endif
/*N*/         else
/*N*/           rInf.X( rInf.X() + PrtWidth() );
/*N*/   }
/*N*/   if( IsMultiPortion() && ((SwMultiPortion*)this)->HasTabulator() )
/*?*/       rInf.IncSpaceIdx();
/*N*/
/*N*/   rInf.SetIdx( rInf.GetIdx() + GetLen() );
/*N*/ }

/*************************************************************************
 *              virtual SwLinePortion::CalcSpacing()
 *************************************************************************/

/*N*/ long SwLinePortion::CalcSpacing( short /*nSpaceAdd*/, const SwTxtSizeInfo & /*rInf*/ ) const
/*N*/ {
/*N*/   return 0;
/*N*/ }

/*************************************************************************
 *              virtual SwLinePortion::GetExpTxt()
 *************************************************************************/

/*N*/ sal_Bool SwLinePortion::GetExpTxt( const SwTxtSizeInfo & /*rInf*/, XubString &/*rTxt*/ ) const
/*N*/ {
/*N*/   return sal_False;
/*N*/ }

/*************************************************************************
 *              virtual SwLinePortion::HandlePortion()
 *************************************************************************/


}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */