32 sal_uInt16 nCacheSz, sal_uInt16 nLft, sal_uInt16 nRght,
33 bool bSimpl,
bool bInnr,
bool bVert ) :
54 if( pLinePolyPolygon )
95 std::vector<bool> aBoolArr;
96 std::deque<tools::Long>* pLongArr;
118 void NoteRange(
bool bToggle );
123 {
if( nDiff ) NoteFarPoint_( nPx, nPyDiff, nDiff ); }
125 void CheckCut(
const Point& rLst,
const Point& rNxt );
129 SvxBoundArgs(
TextRanger* pRanger, std::deque<tools::Long>* pLong,
const Range& rRange );
130 void NotePoint(
const tools::Long nA ) { NoteMargin( nA - nStart, nA + nEnd ); }
132 {
if( nMin > nL ) nMin = nL;
if( nMax < nR ) nMax = nR; }
138 void NoteLast() {
if( bMultiple ) NoteRange( nAct == nFirst ); }
139 void SetConcat(
const bool bNew ){ bConcat = bNew; }
140 bool IsConcat()
const {
return bConcat; }
145SvxBoundArgs::SvxBoundArgs(
TextRanger* pRanger, std::deque<tools::Long>* pLong,
146 const Range& rRange )
148 , pTextRanger(pRanger)
152 , nBottom(rRange.
Max())
159 , bInner(pRanger->IsInner())
160 , bMultiple(bInner || !pRanger->IsSimple())
162 , bRotate(pRanger->IsVertical())
179 nLower = nBottom + nLowDiff;
186 double nDa =
Cut( nRange, rPt1, rPt2 ) -
Cut( nFarRange, rPt1, rPt2 );
196 nB = std::hypot(nB, nDa);
201 nB = nRange + nDa * ( nFarRange - nRange ) / nB;
205 bNote = nB >
B(rPt1);
207 bNote = nB <
B(rPt1);
213void SvxBoundArgs::CheckCut(
const Point& rLst,
const Point& rNxt )
216 NotePoint(
Cut( nBottom, rLst, rNxt ) );
218 NotePoint(
Cut( nTop, rLst, rNxt ) );
219 if( rLst.
X() == rNxt.
X() || rLst.
Y() == rNxt.
Y() )
223 if( nLowDiff && ( ( nCut & 1 ) || nLast == 1 || nNext == 1 ) )
225 nYps = CalcMax( rLst, rNxt, nBottom, nLower );
227 NoteFarPoint_(
Cut( nYps, rLst, rNxt ), nLower-nYps, nLowDiff );
229 if( nUpDiff && ( ( nCut & 2 ) || nLast == 2 || nNext == 2 ) )
231 nYps = CalcMax( rLst, rNxt, nTop, nUpper );
233 NoteFarPoint_(
Cut( nYps, rLst, rNxt ), nYps-nUpper, nUpDiff );
240 double nQuot = 2 * nDiff - nPbDiff;
242 nQuot = sqrt( nQuot );
246 NoteMargin( nTmpA, nPbDiff );
249void SvxBoundArgs::NoteRange(
bool bToggle )
251 DBG_ASSERT( nMax >= nMin || bInner,
"NoteRange: Min > Max?");
257 sal_uInt16
nCount = pLongArr->size();
258 DBG_ASSERT( nCount == 2 * aBoolArr.size(),
"NoteRange: Incompatible Sizes" );
259 while( nIdx < nCount && (*pLongArr)[ nIdx ] < nMin )
261 bool bOdd = (nIdx % 2) != 0;
263 if( nIdx == nCount || ( !bOdd && nMax < (*pLongArr)[ nIdx ] ) )
265 pLongArr->insert( pLongArr->begin() + nIdx, nMin );
266 pLongArr->insert( pLongArr->begin() + nIdx + 1, nMax );
267 aBoolArr.insert( aBoolArr.begin() + (nIdx/2), bToggle );
271 sal_uInt16 nMaxIdx = nIdx;
276 (*pLongArr)[ nIdx ] = nMin;
277 while( nMaxIdx < nCount && (*pLongArr)[ nMaxIdx ] < nMax )
279 DBG_ASSERT( nMaxIdx > nIdx || nMin == nMax,
"NoteRange: Funny Situation." );
286 (*pLongArr)[ nMaxIdx-- ] = nMax;
288 sal_uInt16 nDiff = nMaxIdx - nIdx;
292 pLongArr->erase( pLongArr->begin() + nIdx + 1, pLongArr->begin() + nIdx + 1 + nDiff );
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) );
299 DBG_ASSERT( nMaxIdx < aBoolArr.size(),
"NoteRange: Too much deleted" );
300 aBoolArr[ nMaxIdx ] = aBoolArr[ nMaxIdx ] != bToggle;
308 for( sal_uInt16 i = 0;
i < rPoly.
Count(); ++
i )
314 const Point& rNull = rPol[ 0 ];
315 bClosed = IsConcat() || ( rNull == rPol[
nCount - 1 ] );
316 nLast =
Area( rNull );
328 if( bMultiple || !nAct )
334 NoteFarPoint(
A(rNull), nLower -
B(rNull), nLowDiff );
336 NoteFarPoint(
A(rNull),
B(rNull) - nUpper, nUpDiff );
340 if( bMultiple || !nAct )
347 NotePoint(
A(rNull) );
357 const Point& rLast = rPol[ nIdx - 1 ];
360 const Point& rNext = rPol[ nIdx ];
361 nNext =
Area( rNext );
362 nCut = nNext ^ nLast;
363 sal_uInt16 nOldAct = nAct;
365 CheckCut( rLast, rNext );
368 NoteUpLow(
Cut( nLower, rLast, rNext ), 2 );
369 if( nAct && nAct != nOldAct )
372 CheckCut( rLast, rNext );
377 NoteUpLow(
Cut( nUpper, rLast, rNext ), 1 );
378 if( nAct && nAct != nOldAct )
379 CheckCut( rLast, rNext );
383 if( !( nNext & 12 ) )
387 if( !( nNext & 12 ) )
390 NotePoint(
A(rNext) );
392 NoteFarPoint(
A(rNext), nLower-
B(rNext), nLowDiff );
394 NoteFarPoint(
A(rNext),
B(rNext)-nUpper, nUpDiff );
397 if( ++nIdx == nCount && !bClosed )
399 if( !( nNext & 12 ) )
405 if( bMultiple && IsConcat() )
414 DBG_ASSERT( pLongArr->empty(),
"I said: Simple!" );
421 if( nTmpMin <= nTmpMax )
423 pLongArr->push_front(nTmpMax);
424 pLongArr->push_front(nTmpMin);
429 pLongArr->push_front(nMax);
430 pLongArr->push_front(nMin);
434 else if( !IsConcat() )
438void SvxBoundArgs::Add()
440 size_t nCount = aBoolArr.size();
441 if( nCount && ( !bInner || !pTextRanger->
IsSimple() ) )
443 bool bDelete = aBoolArr.front();
446 sal_uInt16 nLongIdx = 1;
447 for(
size_t nBoolIdx = 1; nBoolIdx <
nCount; ++nBoolIdx )
452 while( nBoolIdx < nCount && !aBoolArr[ nBoolIdx++ ] &&
453 (!bInner || nBoolIdx < nCount ) )
455 pLongArr->erase( pLongArr->begin() + nLongIdx, pLongArr->begin() + nLongIdx + next );
457 nBoolIdx = nBoolIdx - next;
459 aBoolArr.erase( aBoolArr.begin() + nBoolIdx, aBoolArr.begin() + (nBoolIdx + next) );
461 aBoolArr[ nBoolIdx - 1 ] =
false;
462#if OSL_DEBUG_LEVEL > 1
467 bDelete = nBoolIdx <
nCount && aBoolArr[ nBoolIdx ];
469 DBG_ASSERT( nLongIdx == 2*nBoolIdx+1,
"BoundArgs: Array-Idx Confusion" );
470 DBG_ASSERT( aBoolArr.size()*2 == pLongArr->size(),
471 "BoundArgs: Array-Count: Confusion" );
474 if( pLongArr->empty() )
480 pLongArr->pop_front();
481 pLongArr->pop_back();
487 if( pTextRanger->
IsSimple() && pLongArr->size() > 2 )
488 pLongArr->erase( pLongArr->begin() + 1, pLongArr->end() - 1 );
495 std::deque<tools::Long>* pOld = pLongArr;
496 pLongArr =
new std::deque<tools::Long>;
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();
506 std::deque<tools::Long>::size_type nOldCount = pOld->size();
507 if( nIdx == nOldCount )
510 pOld->insert( pOld->begin() + nIdx, pLongArr->begin() + i, pLongArr->end() );
515 std::deque<tools::Long>::size_type nLeftPos = nIdx + 1;
516 while( nLeftPos < nOldCount && nLeft > (*pOld)[ nLeftPos ] )
518 if( nLeftPos >= nOldCount )
521 pOld->insert( pOld->begin() + nOldCount, pLongArr->begin() + i - 2, pLongArr->end() );
524 std::deque<tools::Long>::size_type nRightPos = nLeftPos - 1;
525 while( nRightPos < nOldCount && nRight >= (*pOld)[ nRightPos ] )
527 if( nRightPos < nLeftPos )
530 pOld->insert( pOld->begin() + nRightPos, pLongArr->begin() + i - 2, pLongArr->begin() + i );
537 if( nLeft - 1 > nOld )
539 pOld->insert( pOld->begin() + nLeftPos - 1, nOld );
540 pOld->insert( pOld->begin() + nLeftPos, nLeft - 1 );
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 );
550 (*pOld)[ nLeftPos - 1 ] = nRight;
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 );
576sal_uInt16 SvxBoundArgs::Area(
const Point& rPt )
605 double nQuot = nB - rPt1.
X();
606 nQuot /= ( rPt2.
X() - rPt1.
X() );
607 nQuot *= ( rPt2.
Y() - rPt1.
Y() );
610 double nQuot = nB - rPt1.
Y();
611 nQuot /= ( rPt2.
Y() - rPt1.
Y() );
612 nQuot *= ( rPt2.
X() - rPt1.
X() );
620 NoteMargin( nA, nA );
623 NoteRange( nArea != nAct );
639 DBG_ASSERT( rRange.
Min() || rRange.
Max(),
"Zero-Range not allowed, Bye Bye" );
643 if (elem.range == rRange)
644 return &(elem.results);
648 SvxBoundArgs aArg(
this, &(rngCache.
results), rRange );
constexpr tools::Long Y() const
constexpr tools::Long X() const
B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const
B2DPolygon const & getDefaultAdaptiveSubdivision() const
#define DBG_ASSERT(sCon, aError)
constexpr auto nCacheSize