27#include <osl/diagnose.h>
31: mpFirstBand(nullptr),
32 mpLastCheckedBand(nullptr)
37: mpFirstBand(nullptr),
38 mpLastCheckedBand(nullptr)
72: mpFirstBand(nullptr),
73 mpLastCheckedBand(nullptr)
117 while ( pOwnRectBandSep && pSecondRectBandSep )
123 if ( nOwnXLeft != nSecondXLeft )
131 if ( nOwnYTop != nSecondYTop )
139 if ( nOwnXRight != nSecondXRight )
147 if ( nOwnYBottom != nSecondYBottom )
153 pOwnRectBandSep = pOwnRectBandSep->
mpNextSep;
156 if ( !pOwnRectBandSep )
169 pSecondRectBandSep = pSecondRectBandSep->
mpNextSep;
172 if ( !pSecondRectBandSep )
175 pSecondRectBand = pSecondRectBand->
mpNextBand;
178 if( pSecondRectBand )
180 pSecondRectBandSep = pSecondRectBand->
mpFirstSep;
184 if ( pOwnRectBandSep && !pSecondRectBandSep )
189 if ( !pOwnRectBandSep && pSecondRectBandSep )
200enum StreamEntryType { STREAMENTRY_BANDHEADER, STREAMENTRY_SEPARATION, STREAMENTRY_END };
213 sal_uInt16 nTmp16(STREAMENTRY_END);
216 if (STREAMENTRY_END ==
static_cast<StreamEntryType
>(nTmp16))
219 size_t nRecordsPossible = rIStrm.
remainingSize() / (2*
sizeof(sal_Int32));
220 if (!nRecordsPossible)
222 OSL_ENSURE(
false,
"premature end of region stream" );
230 if(STREAMENTRY_BANDHEADER ==
static_cast<StreamEntryType
>(nTmp16))
233 sal_Int32 nYBottom(0);
252 pCurrBand = pNewBand;
257 sal_Int32 nXRight(0);
265 pCurrBand->
Union( nXLeft, nXRight );
271 OSL_ENSURE(
false,
"premature end of region stream" );
279 while (STREAMENTRY_END !=
static_cast<StreamEntryType
>(nTmp16) && rIStrm.
good());
337 OSL_ASSERT(pBandToInsert!=
nullptr);
385 while (pBand !=
nullptr && nCurrentTop<nBottom)
387 if (nCurrentTop < pBand->mnYTop)
392 ::std::min(nBottom,pBand->
mnYTop-1));
397 nCurrentTop = ::std::max(nTop, pBand->
mnYBottom+1);
400 pPreviousBand = pBand;
407 if (nCurrentTop <= nBottom
408 && (pBand==
nullptr || nBottom>pBand->
mnYBottom))
451 if ( rStartPt == rEndPt )
457 if ( rStartPt.
X() == rEndPt.
X() )
467 for ( ; nY <= nEndY; nY++ )
469 Point aNewPoint( nX, nY );
471 (aNewPoint == rEndPt) || (aNewPoint == rStartPt),
477 for ( ; nY >= nEndY; nY-- )
479 Point aNewPoint( nX, nY );
481 (aNewPoint == rEndPt) || (aNewPoint == rStartPt),
486 else if ( rStartPt.
Y() != rEndPt.
Y() )
488 const tools::Long nDX = std::abs( rEndPt.
X() - rStartPt.
X() );
489 const tools::Long nDY = std::abs( rEndPt.
Y() - rStartPt.
Y() );
494 const tools::Long nXInc = ( nStartX < nEndX ) ? 1 : -1;
495 const tools::Long nYInc = ( nStartY < nEndY ) ? 1 : -1;
503 for ( nX = nStartX, nY = nStartY; nX != nEndX; nX += nXInc )
522 for ( nX = nStartX, nY = nStartY; nY != nEndY; nY += nYInc )
566 OSL_ENSURE(
false,
"RegionBand::InsertPoint reached the end of the list!" );
583 OSL_ENSURE(
false,
"RegionBand::InsertPoint reached the beginning of the list!" );
586 OSL_ENSURE(
false,
"RegionBand::InsertPoint point not inserted!" );
656 SAL_WARN_IF( pBand->
mpFirstSep ==
nullptr,
"vcl",
"Exiting RegionBand::OptimizeBandList(): empty band in region!" );
659 OSL_ENSURE(
false,
"RegionBand::OptimizeBandList(): YBottomBoundary < YTopBoundary" );
662 OSL_ENSURE(
false,
"RegionBand::OptimizeBandList(): overlapping bands in region!" );
687 pBand->
MoveX(nHorzMove);
730 bool bTopBoundaryInserted =
false;
731 bool bTop2BoundaryInserted =
false;
732 bool bBottomBoundaryInserted =
false;
737 if ( nTop < mpFirstBand->mnYTop )
742 if ( nBottom < mpFirstBand->mnYTop )
751 bTopBoundaryInserted =
true;
760 if ( !bTopBoundaryInserted )
765 if ( !bTop2BoundaryInserted )
770 if ( !bBottomBoundaryInserted && (nTop != nBottom) )
776 if ( bTopBoundaryInserted && bTop2BoundaryInserted && bBottomBoundaryInserted )
811 if ( nYBandPosition == pBand->
mnYTop )
815 pNewBand->
mnYTop = nYBandPosition+1;
826 if ( (nYBandPosition > pBand->
mnYTop) && (nYBandPosition < pBand->mnYBottom) )
830 pNewBand->
mnYTop = nYBandPosition;
839 pNewBand->
mnYTop = nYBandPosition;
854 if ( nYBandPosition == pBand->
mnYBottom )
884 SAL_WARN_IF( nLeft > nRight,
"vcl",
"RegionBand::Union() - nLeft > nRight" );
885 SAL_WARN_IF( nTop > nBottom,
"vcl",
"RegionBand::Union() - nTop > nBottom" );
891 if ( pBand->
mnYTop >= nTop )
894 pBand->
Union( nLeft, nRight );
904 OSL_ENSURE(
false,
"RegionBand::Union() - Bands not sorted!" );
980 SAL_WARN_IF( nLeft > nRight,
"vcl",
"RegionBand::Exclude() - nLeft > nRight" );
981 SAL_WARN_IF( nTop > nBottom,
"vcl",
"RegionBand::Exclude() - nTop > nBottom" );
1004 OSL_ENSURE(
false,
"RegionBand::Exclude() - Bands not sorted!" );
1021 SAL_WARN_IF( nLeft > nRight,
"vcl",
"RegionBand::Exclude() - nLeft > nRight" );
1022 SAL_WARN_IF( nTop > nBottom,
"vcl",
"RegionBand::Exclude() - nTop > nBottom" );
1029 if(pBand->
mnYTop >= nTop)
1033 pBand->
XOr(nLeft, nRight);
1045 OSL_ENSURE(
false,
"RegionBand::XOr() - Bands not sorted!" );
1263 while(pCurrRectBand)
1270 while(pCurrRectBandSep)
1274 rTarget.push_back(aRectangle);
1275 pCurrRectBandSep = pCurrRectBandSep->
mpNextSep;
1316 return "YBottom < YTop";
1323 return "overlapping bands in region";
1329 return "Band-mbTouched overwrite";
1338 return "XLeft < XRight";
1345 return "overlapping separations in region";
1351 return "Sep-mbRemoved overwrite";
void Union(tools::Long nXLeft, tools::Long nXRight)
void Intersect(tools::Long nXLeft, tools::Long nXRight)
ImplRegionBand * mpPrevBand
tools::Long GetXRightBoundary() const
bool InsertPoint(tools::Long nX, tools::Long nLineID, bool bEndPoint, LineType eLineType)
void XOr(tools::Long nXLeft, tools::Long nXRight)
void Exclude(tools::Long nXLeft, tools::Long nXRight)
bool Contains(tools::Long nX)
tools::Long GetXLeftBoundary() const
void MoveX(tools::Long nHorzMove)
ImplRegionBand * mpNextBand
void ScaleX(double fHorzScale)
ImplRegionBandSep * mpFirstSep
constexpr tools::Long Y() const
constexpr tools::Long X() const
void InsertLine(const Point &rStartPt, const Point &rEndPt, tools::Long nLineId)
bool load(SvStream &rIStrm)
void Move(tools::Long nHorzMove, tools::Long nVertMove)
bool Contains(const Point &rPoint) const
void Scale(double fScaleX, double fScaleY)
void save(SvStream &rIStrm) const
ImplRegionBand * mpLastCheckedBand
void Union(tools::Long nLeft, tools::Long nTop, tools::Long nRight, tools::Long nBottom)
void GetRegionRectangles(RectangleVector &rTarget) const
ImplRegionBand * mpFirstBand
void InsertBand(ImplRegionBand *pPreviousBand, ImplRegionBand *pBandToInsert)
void InsertPoint(const Point &rPoint, tools::Long nLineID, bool bEndPoint, LineType eLineType)
tools::Rectangle GetBoundRect() const
bool CheckConsistency() const
ImplRegionBand * ImplGetFirstRegionBand() const
void InsertBands(tools::Long nTop, tools::Long nBottom)
void ImplAddMissingBands(const tools::Long nTop, const tools::Long nBottom)
This function is similar to the RegionBand::InsertBands() method.
RegionBand & operator=(const RegionBand &)
sal_uInt32 getRectangleCount() const
void XOr(tools::Long nLeft, tools::Long nTop, tools::Long nRight, tools::Long nBottom)
void CreateBandRange(tools::Long nYTop, tools::Long nYBottom)
void Exclude(tools::Long nLeft, tools::Long nTop, tools::Long nRight, tools::Long nBottom)
bool isSingleRectangle() const
void Intersect(tools::Long nLeft, tools::Long nTop, tools::Long nRight, tools::Long nBottom)
static bool InsertSingleBand(ImplRegionBand *pBand, tools::Long nYBandPosition)
bool operator==(const RegionBand &rRegionBand) const
SvStream & WriteInt32(sal_Int32 nInt32)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & ReadInt32(sal_Int32 &rInt32)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_uInt64 remainingSize()
#define SAL_WARN_IF(condition, area, stream)
B2IRange fround(const B2DRange &rRange)
constexpr T saturating_add(T a, T b)
std::vector< tools::Rectangle > RectangleVector
const char * ImplDbgTestRegionBand(const void *pObj)
ImplRegionBandSep * mpNextSep