LibreOffice Module editeng (master) 1
txtrange.cxx
Go to the documentation of this file.
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
20
21#include <editeng/txtrange.hxx>
22#include <math.h>
23#include <tools/poly.hxx>
24#include <tools/debug.hxx>
27
28#include <vector>
29
31 const basegfx::B2DPolyPolygon* pLinePolyPolygon,
32 sal_uInt16 nCacheSz, sal_uInt16 nLft, sal_uInt16 nRght,
33 bool bSimpl, bool bInnr, bool bVert ) :
34 maPolyPolygon( rPolyPolygon.count() ),
35 nCacheSize( nCacheSz ),
36 nRight( nRght ),
37 nLeft( nLft ),
38 nUpper( 0 ),
39 nLower( 0 ),
40 nPointCount( 0 ),
41 bSimple( bSimpl ),
42 bInner( bInnr ),
43 bVertical( bVert )
44{
45 sal_uInt32 nCount(rPolyPolygon.count());
46
47 for(sal_uInt32 i(0); i < nCount; i++)
48 {
49 const basegfx::B2DPolygon aCandidate(rPolyPolygon.getB2DPolygon(i).getDefaultAdaptiveSubdivision());
50 nPointCount += aCandidate.count();
51 maPolyPolygon.Insert( tools::Polygon(aCandidate), static_cast<sal_uInt16>(i) );
52 }
53
54 if( pLinePolyPolygon )
55 {
56 nCount = pLinePolyPolygon->count();
58
59 for(sal_uInt32 i(0); i < nCount; i++)
60 {
61 const basegfx::B2DPolygon aCandidate(pLinePolyPolygon->getB2DPolygon(i).getDefaultAdaptiveSubdivision());
62 nPointCount += aCandidate.count();
63 mpLinePolyPolygon->Insert( tools::Polygon(aCandidate), static_cast<sal_uInt16>(i) );
64 }
65 }
66 else
67 mpLinePolyPolygon.reset();
68}
69
70
72{
73 mRangeCache.clear();
74}
75
76/* TextRanger::SetVertical(..)
77 If there's is a change in the writing direction,
78 the cache has to be cleared.
79*/
80void TextRanger::SetVertical( bool bNew )
81{
82 if( IsVertical() != bNew )
83 {
84 bVertical = bNew;
85 mRangeCache.clear();
86 }
87}
88
89namespace {
90
93class SvxBoundArgs
94{
95 std::vector<bool> aBoolArr;
96 std::deque<tools::Long>* pLongArr;
97 TextRanger *pTextRanger;
98 tools::Long nMin;
99 tools::Long nMax;
100 tools::Long nTop;
101 tools::Long nBottom;
102 tools::Long nUpDiff;
103 tools::Long nLowDiff;
104 tools::Long nUpper;
105 tools::Long nLower;
106 tools::Long nStart;
107 tools::Long nEnd;
108 sal_uInt16 nCut;
109 sal_uInt16 nLast;
110 sal_uInt16 nNext;
111 sal_uInt8 nAct;
112 sal_uInt8 nFirst;
113 bool bClosed : 1;
114 bool bInner : 1;
115 bool bMultiple : 1;
116 bool bConcat : 1;
117 bool bRotate : 1;
118 void NoteRange( bool bToggle );
119 tools::Long Cut( tools::Long nY, const Point& rPt1, const Point& rPt2 );
120 void Add();
121 void NoteFarPoint_( tools::Long nPx, tools::Long nPyDiff, tools::Long nDiff );
122 void NoteFarPoint( tools::Long nPx, tools::Long nPyDiff, tools::Long nDiff )
123 { if( nDiff ) NoteFarPoint_( nPx, nPyDiff, nDiff ); }
124 tools::Long CalcMax( const Point& rPt1, const Point& rPt2, tools::Long nRange, tools::Long nFar );
125 void CheckCut( const Point& rLst, const Point& rNxt );
126 tools::Long A( const Point& rP ) const { return bRotate ? rP.Y() : rP.X(); }
127 tools::Long B( const Point& rP ) const { return bRotate ? rP.X() : rP.Y(); }
128public:
129 SvxBoundArgs( TextRanger* pRanger, std::deque<tools::Long>* pLong, const Range& rRange );
130 void NotePoint( const tools::Long nA ) { NoteMargin( nA - nStart, nA + nEnd ); }
131 void NoteMargin( const tools::Long nL, const tools::Long nR )
132 { if( nMin > nL ) nMin = nL; if( nMax < nR ) nMax = nR; }
133 sal_uInt16 Area( const Point& rPt );
134 void NoteUpLow( tools::Long nA, const sal_uInt8 nArea );
135 void Calc( const tools::PolyPolygon& rPoly );
136 void Concat( const tools::PolyPolygon* pPoly );
137 // inlines
138 void NoteLast() { if( bMultiple ) NoteRange( nAct == nFirst ); }
139 void SetConcat( const bool bNew ){ bConcat = bNew; }
140 bool IsConcat() const { return bConcat; }
141};
142
143}
144
145SvxBoundArgs::SvxBoundArgs( TextRanger* pRanger, std::deque<tools::Long>* pLong,
146 const Range& rRange )
147 : pLongArr(pLong)
148 , pTextRanger(pRanger)
149 , nMin(0)
150 , nMax(0)
151 , nTop(rRange.Min())
152 , nBottom(rRange.Max())
153 , nCut(0)
154 , nLast(0)
155 , nNext(0)
156 , nAct(0)
157 , nFirst(0)
158 , bClosed(false)
159 , bInner(pRanger->IsInner())
160 , bMultiple(bInner || !pRanger->IsSimple())
161 , bConcat(false)
162 , bRotate(pRanger->IsVertical())
163{
164 if( bRotate )
165 {
166 nStart = pRanger->GetUpper();
167 nEnd = pRanger->GetLower();
168 nLowDiff = pRanger->GetLeft();
169 nUpDiff = pRanger->GetRight();
170 }
171 else
172 {
173 nStart = pRanger->GetLeft();
174 nEnd = pRanger->GetRight();
175 nLowDiff = pRanger->GetUpper();
176 nUpDiff = pRanger->GetLower();
177 }
178 nUpper = nTop - nUpDiff;
179 nLower = nBottom + nLowDiff;
180 pLongArr->clear();
181}
182
183tools::Long SvxBoundArgs::CalcMax( const Point& rPt1, const Point& rPt2,
184 tools::Long nRange, tools::Long nFarRange )
185{
186 double nDa = Cut( nRange, rPt1, rPt2 ) - Cut( nFarRange, rPt1, rPt2 );
187 double nB;
188 if( nDa < 0 )
189 {
190 nDa = -nDa;
191 nB = nEnd;
192 }
193 else
194 nB = nStart;
195
196 nB = std::hypot(nB, nDa);
197
198 if (nB == 0) // avoid div / 0
199 return 0;
200
201 nB = nRange + nDa * ( nFarRange - nRange ) / nB;
202
203 bool bNote;
204 if( nB < B(rPt2) )
205 bNote = nB > B(rPt1);
206 else
207 bNote = nB < B(rPt1);
208 if( bNote )
209 return( tools::Long( nB ) );
210 return 0;
211}
212
213void SvxBoundArgs::CheckCut( const Point& rLst, const Point& rNxt )
214{
215 if( nCut & 1 )
216 NotePoint( Cut( nBottom, rLst, rNxt ) );
217 if( nCut & 2 )
218 NotePoint( Cut( nTop, rLst, rNxt ) );
219 if( rLst.X() == rNxt.X() || rLst.Y() == rNxt.Y() )
220 return;
221
222 tools::Long nYps;
223 if( nLowDiff && ( ( nCut & 1 ) || nLast == 1 || nNext == 1 ) )
224 {
225 nYps = CalcMax( rLst, rNxt, nBottom, nLower );
226 if( nYps )
227 NoteFarPoint_( Cut( nYps, rLst, rNxt ), nLower-nYps, nLowDiff );
228 }
229 if( nUpDiff && ( ( nCut & 2 ) || nLast == 2 || nNext == 2 ) )
230 {
231 nYps = CalcMax( rLst, rNxt, nTop, nUpper );
232 if( nYps )
233 NoteFarPoint_( Cut( nYps, rLst, rNxt ), nYps-nUpper, nUpDiff );
234 }
235}
236
237void SvxBoundArgs::NoteFarPoint_( tools::Long nPa, tools::Long nPbDiff, tools::Long nDiff )
238{
239 tools::Long nTmpA;
240 double nQuot = 2 * nDiff - nPbDiff;
241 nQuot *= nPbDiff;
242 nQuot = sqrt( nQuot );
243 nQuot /= nDiff;
244 nTmpA = nPa - tools::Long( nStart * nQuot );
245 nPbDiff = nPa + tools::Long( nEnd * nQuot );
246 NoteMargin( nTmpA, nPbDiff );
247}
248
249void SvxBoundArgs::NoteRange( bool bToggle )
250{
251 DBG_ASSERT( nMax >= nMin || bInner, "NoteRange: Min > Max?");
252 if( nMax < nMin )
253 return;
254 if( !bClosed )
255 bToggle = false;
256 sal_uInt16 nIdx = 0;
257 sal_uInt16 nCount = pLongArr->size();
258 DBG_ASSERT( nCount == 2 * aBoolArr.size(), "NoteRange: Incompatible Sizes" );
259 while( nIdx < nCount && (*pLongArr)[ nIdx ] < nMin )
260 ++nIdx;
261 bool bOdd = (nIdx % 2) != 0;
262 // No overlap with existing intervals?
263 if( nIdx == nCount || ( !bOdd && nMax < (*pLongArr)[ nIdx ] ) )
264 { // Then a new one is inserted ...
265 pLongArr->insert( pLongArr->begin() + nIdx, nMin );
266 pLongArr->insert( pLongArr->begin() + nIdx + 1, nMax );
267 aBoolArr.insert( aBoolArr.begin() + (nIdx/2), bToggle );
268 }
269 else
270 { // expand an existing interval ...
271 sal_uInt16 nMaxIdx = nIdx;
272 // If we end up on a left interval boundary, it must be reduced to nMin.
273 if( bOdd )
274 --nIdx;
275 else
276 (*pLongArr)[ nIdx ] = nMin;
277 while( nMaxIdx < nCount && (*pLongArr)[ nMaxIdx ] < nMax )
278 ++nMaxIdx;
279 DBG_ASSERT( nMaxIdx > nIdx || nMin == nMax, "NoteRange: Funny Situation." );
280 if( nMaxIdx )
281 --nMaxIdx;
282 if( nMaxIdx < nIdx )
283 nMaxIdx = nIdx;
284 // If we end up on a right interval boundary, it must be raised to nMax.
285 if( nMaxIdx % 2 )
286 (*pLongArr)[ nMaxIdx-- ] = nMax;
287 // Possible merge of intervals.
288 sal_uInt16 nDiff = nMaxIdx - nIdx;
289 nMaxIdx = nIdx / 2; // From here on is nMaxIdx the Index in BoolArray.
290 if( nDiff )
291 {
292 pLongArr->erase( pLongArr->begin() + nIdx + 1, pLongArr->begin() + nIdx + 1 + nDiff );
293 nDiff /= 2;
294 sal_uInt16 nStop = nMaxIdx + nDiff;
295 for( sal_uInt16 i = nMaxIdx; i < nStop; ++i )
296 bToggle ^= aBoolArr[ i ];
297 aBoolArr.erase( aBoolArr.begin() + nMaxIdx, aBoolArr.begin() + (nMaxIdx + nDiff) );
298 }
299 DBG_ASSERT( nMaxIdx < aBoolArr.size(), "NoteRange: Too much deleted" );
300 aBoolArr[ nMaxIdx ] = aBoolArr[ nMaxIdx ] != bToggle;
301 }
302}
303
304void SvxBoundArgs::Calc( const tools::PolyPolygon& rPoly )
305{
306 sal_uInt16 nCount;
307 nAct = 0;
308 for( sal_uInt16 i = 0; i < rPoly.Count(); ++i )
309 {
310 const tools::Polygon& rPol = rPoly[ i ];
311 nCount = rPol.GetSize();
312 if( nCount )
313 {
314 const Point& rNull = rPol[ 0 ];
315 bClosed = IsConcat() || ( rNull == rPol[ nCount - 1 ] );
316 nLast = Area( rNull );
317 if( nLast & 12 )
318 {
319 nFirst = 3;
320 if( bMultiple )
321 nAct = 0;
322 }
323 else
324 {
325 // The first point of the polygon is within the line.
326 if( nLast )
327 {
328 if( bMultiple || !nAct )
329 {
330 nMin = USHRT_MAX;
331 nMax = 0;
332 }
333 if( nLast & 1 )
334 NoteFarPoint( A(rNull), nLower - B(rNull), nLowDiff );
335 else
336 NoteFarPoint( A(rNull), B(rNull) - nUpper, nUpDiff );
337 }
338 else
339 {
340 if( bMultiple || !nAct )
341 {
342 nMin = A(rNull);
343 nMax = nMin + nEnd;
344 nMin -= nStart;
345 }
346 else
347 NotePoint( A(rNull) );
348 }
349 nFirst = 0; // leaving the line in which direction?
350 nAct = 3; // we are within the line at the moment.
351 }
352 if( nCount > 1 )
353 {
354 sal_uInt16 nIdx = 1;
355 while( true )
356 {
357 const Point& rLast = rPol[ nIdx - 1 ];
358 if( nIdx == nCount )
359 nIdx = 0;
360 const Point& rNext = rPol[ nIdx ];
361 nNext = Area( rNext );
362 nCut = nNext ^ nLast;
363 sal_uInt16 nOldAct = nAct;
364 if( nAct )
365 CheckCut( rLast, rNext );
366 if( nCut & 4 )
367 {
368 NoteUpLow( Cut( nLower, rLast, rNext ), 2 );
369 if( nAct && nAct != nOldAct )
370 {
371 nOldAct = nAct;
372 CheckCut( rLast, rNext );
373 }
374 }
375 if( nCut & 8 )
376 {
377 NoteUpLow( Cut( nUpper, rLast, rNext ), 1 );
378 if( nAct && nAct != nOldAct )
379 CheckCut( rLast, rNext );
380 }
381 if( !nIdx )
382 {
383 if( !( nNext & 12 ) )
384 NoteLast();
385 break;
386 }
387 if( !( nNext & 12 ) )
388 {
389 if( !nNext )
390 NotePoint( A(rNext) );
391 else if( nNext & 1 )
392 NoteFarPoint( A(rNext), nLower-B(rNext), nLowDiff );
393 else
394 NoteFarPoint( A(rNext), B(rNext)-nUpper, nUpDiff );
395 }
396 nLast = nNext;
397 if( ++nIdx == nCount && !bClosed )
398 {
399 if( !( nNext & 12 ) )
400 NoteLast();
401 break;
402 }
403 }
404 }
405 if( bMultiple && IsConcat() )
406 {
407 Add();
408 nAct = 0;
409 }
410 }
411 }
412 if( !bMultiple )
413 {
414 DBG_ASSERT( pLongArr->empty(), "I said: Simple!" );
415 if( nAct )
416 {
417 if( bInner )
418 {
419 tools::Long nTmpMin = nMin + 2 * nStart;
420 tools::Long nTmpMax = nMax - 2 * nEnd;
421 if( nTmpMin <= nTmpMax )
422 {
423 pLongArr->push_front(nTmpMax);
424 pLongArr->push_front(nTmpMin);
425 }
426 }
427 else
428 {
429 pLongArr->push_front(nMax);
430 pLongArr->push_front(nMin);
431 }
432 }
433 }
434 else if( !IsConcat() )
435 Add();
436}
437
438void SvxBoundArgs::Add()
439{
440 size_t nCount = aBoolArr.size();
441 if( nCount && ( !bInner || !pTextRanger->IsSimple() ) )
442 {
443 bool bDelete = aBoolArr.front();
444 if( bInner )
445 bDelete = !bDelete;
446 sal_uInt16 nLongIdx = 1;
447 for( size_t nBoolIdx = 1; nBoolIdx < nCount; ++nBoolIdx )
448 {
449 if( bDelete )
450 {
451 sal_uInt16 next = 2;
452 while( nBoolIdx < nCount && !aBoolArr[ nBoolIdx++ ] &&
453 (!bInner || nBoolIdx < nCount ) )
454 next += 2;
455 pLongArr->erase( pLongArr->begin() + nLongIdx, pLongArr->begin() + nLongIdx + next );
456 next /= 2;
457 nBoolIdx = nBoolIdx - next;
458 nCount = nCount - next;
459 aBoolArr.erase( aBoolArr.begin() + nBoolIdx, aBoolArr.begin() + (nBoolIdx + next) );
460 if( nBoolIdx )
461 aBoolArr[ nBoolIdx - 1 ] = false;
462#if OSL_DEBUG_LEVEL > 1
463 else
464 ++next;
465#endif
466 }
467 bDelete = nBoolIdx < nCount && aBoolArr[ nBoolIdx ];
468 nLongIdx += 2;
469 DBG_ASSERT( nLongIdx == 2*nBoolIdx+1, "BoundArgs: Array-Idx Confusion" );
470 DBG_ASSERT( aBoolArr.size()*2 == pLongArr->size(),
471 "BoundArgs: Array-Count: Confusion" );
472 }
473 }
474 if( pLongArr->empty() )
475 return;
476
477 if( !bInner )
478 return;
479
480 pLongArr->pop_front();
481 pLongArr->pop_back();
482
483 // Here the line is held inside a large rectangle for "simple"
484 // contour wrap. Currently (April 1999) the EditEngine evaluates
485 // only the first rectangle. If it one day is able to output a line
486 // in several parts, it may be advisable to delete the following lines.
487 if( pTextRanger->IsSimple() && pLongArr->size() > 2 )
488 pLongArr->erase( pLongArr->begin() + 1, pLongArr->end() - 1 );
489}
490
491void SvxBoundArgs::Concat( const tools::PolyPolygon* pPoly )
492{
493 SetConcat( true );
494 DBG_ASSERT( pPoly, "Nothing to do?" );
495 std::deque<tools::Long>* pOld = pLongArr;
496 pLongArr = new std::deque<tools::Long>;
497 aBoolArr.clear();
498 bInner = false;
499 Calc( *pPoly ); // Note that this updates pLongArr, which is why we swapped it out earlier.
500 std::deque<tools::Long>::size_type nCount = pLongArr->size();
501 std::deque<tools::Long>::size_type nIdx = 0;
502 std::deque<tools::Long>::size_type i = 0;
503 bool bSubtract = pTextRanger->IsInner();
504 while( i < nCount )
505 {
506 std::deque<tools::Long>::size_type nOldCount = pOld->size();
507 if( nIdx == nOldCount )
508 { // Reached the end of the old Array...
509 if( !bSubtract )
510 pOld->insert( pOld->begin() + nIdx, pLongArr->begin() + i, pLongArr->end() );
511 break;
512 }
513 tools::Long nLeft = (*pLongArr)[ i++ ];
514 tools::Long nRight = (*pLongArr)[ i++ ];
515 std::deque<tools::Long>::size_type nLeftPos = nIdx + 1;
516 while( nLeftPos < nOldCount && nLeft > (*pOld)[ nLeftPos ] )
517 nLeftPos += 2;
518 if( nLeftPos >= nOldCount )
519 { // The current interval belongs to the end of the old array ...
520 if( !bSubtract )
521 pOld->insert( pOld->begin() + nOldCount, pLongArr->begin() + i - 2, pLongArr->end() );
522 break;
523 }
524 std::deque<tools::Long>::size_type nRightPos = nLeftPos - 1;
525 while( nRightPos < nOldCount && nRight >= (*pOld)[ nRightPos ] )
526 nRightPos += 2;
527 if( nRightPos < nLeftPos )
528 { // The current interval belongs between two old intervals
529 if( !bSubtract )
530 pOld->insert( pOld->begin() + nRightPos, pLongArr->begin() + i - 2, pLongArr->begin() + i );
531 }
532 else if( bSubtract ) // Subtract, if necessary separate
533 {
534 const tools::Long nOld = (*pOld)[nLeftPos - 1];
535 if (nLeft > nOld)
536 { // Now we split the left part...
537 if( nLeft - 1 > nOld )
538 {
539 pOld->insert( pOld->begin() + nLeftPos - 1, nOld );
540 pOld->insert( pOld->begin() + nLeftPos, nLeft - 1 );
541 nLeftPos += 2;
542 nRightPos += 2;
543 }
544 }
545 if( nRightPos - nLeftPos > 1 )
546 pOld->erase( pOld->begin() + nLeftPos, pOld->begin() + nRightPos - 1 );
547 if (++nRight >= (*pOld)[nLeftPos])
548 pOld->erase( pOld->begin() + nLeftPos - 1, pOld->begin() + nLeftPos + 1 );
549 else
550 (*pOld)[ nLeftPos - 1 ] = nRight;
551 }
552 else // Merge
553 {
554 if( nLeft < (*pOld)[ nLeftPos - 1 ] )
555 (*pOld)[ nLeftPos - 1 ] = nLeft;
556 if( nRight > (*pOld)[ nRightPos - 1 ] )
557 (*pOld)[ nRightPos - 1 ] = nRight;
558 if( nRightPos - nLeftPos > 1 )
559 pOld->erase( pOld->begin() + nLeftPos, pOld->begin() + nRightPos - 1 );
560
561 }
562 nIdx = nLeftPos - 1;
563 }
564 delete pLongArr;
565}
566
567/*************************************************************************
568 * SvxBoundArgs::Area returns the area in which the point is located.
569 * 0 = within the line
570 * 1 = below, but within the upper edge
571 * 2 = above, but within the lower edge
572 * 5 = below the upper edge
573 *10 = above the lower edge
574 *************************************************************************/
575
576sal_uInt16 SvxBoundArgs::Area( const Point& rPt )
577{
578 tools::Long nB = B( rPt );
579 if( nB >= nBottom )
580 {
581 if( nB >= nLower )
582 return 5;
583 return 1;
584 }
585 if( nB <= nTop )
586 {
587 if( nB <= nUpper )
588 return 10;
589 return 2;
590 }
591 return 0;
592}
593
594/*************************************************************************
595 * lcl_Cut calculates the X-Coordinate of the distance (Pt1-Pt2) at the
596 * Y-Coordinate nY.
597 * It is assumed that the one of the points are located above and the other
598 * one below the Y-Coordinate.
599 *************************************************************************/
600
601tools::Long SvxBoundArgs::Cut( tools::Long nB, const Point& rPt1, const Point& rPt2 )
602{
603 if( pTextRanger->IsVertical() )
604 {
605 double nQuot = nB - rPt1.X();
606 nQuot /= ( rPt2.X() - rPt1.X() );
607 nQuot *= ( rPt2.Y() - rPt1.Y() );
608 return tools::Long( rPt1.Y() + nQuot );
609 }
610 double nQuot = nB - rPt1.Y();
611 nQuot /= ( rPt2.Y() - rPt1.Y() );
612 nQuot *= ( rPt2.X() - rPt1.X() );
613 return tools::Long( rPt1.X() + nQuot );
614}
615
616void SvxBoundArgs::NoteUpLow( tools::Long nA, const sal_uInt8 nArea )
617{
618 if( nAct )
619 {
620 NoteMargin( nA, nA );
621 if( bMultiple )
622 {
623 NoteRange( nArea != nAct );
624 nAct = 0;
625 }
626 if( !nFirst )
627 nFirst = nArea;
628 }
629 else
630 {
631 nAct = nArea;
632 nMin = nA;
633 nMax = nA;
634 }
635}
636
637std::deque<tools::Long>* TextRanger::GetTextRanges( const Range& rRange )
638{
639 DBG_ASSERT( rRange.Min() || rRange.Max(), "Zero-Range not allowed, Bye Bye" );
640 //Can we find the result we need in the cache?
641 for (auto & elem : mRangeCache)
642 {
643 if (elem.range == rRange)
644 return &(elem.results);
645 }
646 //Calculate a new result
647 RangeCacheItem rngCache(rRange);
648 SvxBoundArgs aArg( this, &(rngCache.results), rRange );
649 aArg.Calc( maPolyPolygon );
651 aArg.Concat( &*mpLinePolyPolygon );
652 //Add new result to the cache
653 mRangeCache.push_back(std::move(rngCache));
654 if (mRangeCache.size() > nCacheSize)
655 mRangeCache.pop_front();
656 return &(mRangeCache.back().results);
657}
658
660{
661 DBG_ASSERT( !mxBound, "Don't call twice." );
663 return *mxBound;
664}
665
666
667/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr tools::Long Y() const
constexpr tools::Long X() const
tools::Long Max() const
tools::Long Min() const
std::deque< RangeCacheItem > mRangeCache
Cached range calculations.
Definition: txtrange.hxx:42
sal_uInt16 GetUpper() const
Definition: txtrange.hxx:68
sal_uInt16 nUpper
Definition: txtrange.hxx:49
TextRanger(const TextRanger &)=delete
sal_uInt16 nLower
Definition: txtrange.hxx:50
sal_uInt16 GetRight() const
Definition: txtrange.hxx:66
void SetVertical(bool bNew)
Definition: txtrange.cxx:80
bool IsInner() const
Definition: txtrange.hxx:72
bool IsVertical() const
Definition: txtrange.hxx:73
tools::PolyPolygon maPolyPolygon
Definition: txtrange.hxx:43
std::deque< tools::Long > * GetTextRanges(const Range &rRange)
Definition: txtrange.cxx:637
sal_uInt16 GetLeft() const
Definition: txtrange.hxx:67
const tools::Rectangle & GetBoundRect_() const
Definition: txtrange.cxx:659
std::optional< tools::Rectangle > mxBound
Definition: txtrange.hxx:45
sal_uInt16 nCacheSize
Definition: txtrange.hxx:46
std::optional< tools::PolyPolygon > mpLinePolyPolygon
Definition: txtrange.hxx:44
sal_uInt32 nPointCount
Definition: txtrange.hxx:51
sal_uInt16 GetLower() const
Definition: txtrange.hxx:69
bool bVertical
Definition: txtrange.hxx:55
bool IsSimple() const
Definition: txtrange.hxx:71
B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const
sal_uInt32 count() const
sal_uInt32 count() const
B2DPolygon const & getDefaultAdaptiveSubdivision() const
sal_uInt16 Count() const
void Insert(const tools::Polygon &rPoly, sal_uInt16 nPos=POLYPOLY_APPEND)
tools::Rectangle GetBoundRect() const
sal_uInt16 GetSize() const
@ Area
int nCount
#define DBG_ASSERT(sCon, aError)
int i
long Long
basegfx::B2DPolyPolygon maPolyPolygon
The RangeCache class is used to cache the result of a single range calculation.
Definition: txtrange.hxx:37
std::deque< tools::Long > results
Calculated results for the range.
Definition: txtrange.hxx:39
constexpr auto nCacheSize
unsigned char sal_uInt8
const sal_uInt8 A