26 #include <osl/diagnose.h>
30 : mpFirstBand(nullptr),
31 mpLastCheckedBand(nullptr)
36 : mpFirstBand(nullptr),
37 mpLastCheckedBand(nullptr)
71 : mpFirstBand(nullptr),
72 mpLastCheckedBand(nullptr)
116 while ( pOwnRectBandSep && pSecondRectBandSep )
122 if ( nOwnXLeft != nSecondXLeft )
130 if ( nOwnYTop != nSecondYTop )
138 if ( nOwnXRight != nSecondXRight )
146 if ( nOwnYBottom != nSecondYBottom )
152 pOwnRectBandSep = pOwnRectBandSep->
mpNextSep;
155 if ( !pOwnRectBandSep )
168 pSecondRectBandSep = pSecondRectBandSep->
mpNextSep;
171 if ( !pSecondRectBandSep )
174 pSecondRectBand = pSecondRectBand->
mpNextBand;
177 if( pSecondRectBand )
179 pSecondRectBandSep = pSecondRectBand->
mpFirstSep;
183 if ( pOwnRectBandSep && !pSecondRectBandSep )
188 if ( !pOwnRectBandSep && pSecondRectBandSep )
199 enum StreamEntryType { STREAMENTRY_BANDHEADER, STREAMENTRY_SEPARATION, STREAMENTRY_END };
212 sal_uInt16 nTmp16(STREAMENTRY_END);
215 if (STREAMENTRY_END == static_cast<StreamEntryType>(nTmp16))
218 size_t nRecordsPossible = rIStrm.
remainingSize() / (2*
sizeof(sal_Int32));
219 if (!nRecordsPossible)
221 OSL_ENSURE(
false,
"premature end of region stream" );
229 if(STREAMENTRY_BANDHEADER == static_cast<StreamEntryType>(nTmp16))
232 sal_Int32 nYBottom(0);
251 pCurrBand = pNewBand;
256 sal_Int32 nXRight(0);
264 pCurrBand->
Union( nXLeft, nXRight );
270 OSL_ENSURE(
false,
"premature end of region stream" );
278 while (STREAMENTRY_END != static_cast<StreamEntryType>(nTmp16) && rIStrm.
good());
336 OSL_ASSERT(pBandToInsert!=
nullptr);
384 while (pBand !=
nullptr && nCurrentTop<nBottom)
386 if (nCurrentTop < pBand->mnYTop)
391 ::std::min(nBottom,pBand->
mnYTop-1));
396 nCurrentTop = ::std::max(nTop, pBand->
mnYBottom+1);
399 pPreviousBand = pBand;
406 if (nCurrentTop <= nBottom
407 && (pBand==
nullptr || nBottom>pBand->
mnYBottom))
450 if ( rStartPt == rEndPt )
456 if ( rStartPt.X() == rEndPt.X() )
466 for ( ; nY <= nEndY; nY++ )
468 Point aNewPoint( nX, nY );
470 (aNewPoint == rEndPt) || (aNewPoint == rStartPt),
476 for ( ; nY >= nEndY; nY-- )
478 Point aNewPoint( nX, nY );
480 (aNewPoint == rEndPt) || (aNewPoint == rStartPt),
485 else if ( rStartPt.Y() != rEndPt.Y() )
487 const tools::Long nDX = std::abs( rEndPt.X() - rStartPt.X() );
488 const tools::Long nDY = std::abs( rEndPt.Y() - rStartPt.Y() );
493 const tools::Long nXInc = ( nStartX < nEndX ) ? 1 : -1;
494 const tools::Long nYInc = ( nStartY < nEndY ) ? 1 : -1;
502 for ( nX = nStartX, nY = nStartY; nX != nEndX; nX += nXInc )
521 for ( nX = nStartX, nY = nStartY; nY != nEndY; nY += nYInc )
565 OSL_ENSURE(
false,
"RegionBand::InsertPoint reached the end of the list!" );
582 OSL_ENSURE(
false,
"RegionBand::InsertPoint reached the beginning of the list!" );
585 OSL_ENSURE(
false,
"RegionBand::InsertPoint point not inserted!" );
655 SAL_WARN_IF( pBand->
mpFirstSep ==
nullptr,
"vcl",
"Exiting RegionBand::OptimizeBandList(): empty band in region!" );
658 OSL_ENSURE(
false,
"RegionBand::OptimizeBandList(): YBottomBoundary < YTopBoundary" );
661 OSL_ENSURE(
false,
"RegionBand::OptimizeBandList(): overlapping bands in region!" );
686 pBand->
MoveX(nHorzMove);
729 bool bTopBoundaryInserted =
false;
730 bool bTop2BoundaryInserted =
false;
731 bool bBottomBoundaryInserted =
false;
736 if ( nTop < mpFirstBand->mnYTop )
741 if ( nBottom < mpFirstBand->mnYTop )
750 bTopBoundaryInserted =
true;
759 if ( !bTopBoundaryInserted )
764 if ( !bTop2BoundaryInserted )
769 if ( !bBottomBoundaryInserted && (nTop != nBottom) )
775 if ( bTopBoundaryInserted && bTop2BoundaryInserted && bBottomBoundaryInserted )
810 if ( nYBandPosition == pBand->
mnYTop )
814 pNewBand->
mnYTop = nYBandPosition+1;
825 if ( (nYBandPosition > pBand->
mnYTop) && (nYBandPosition < pBand->mnYBottom) )
829 pNewBand->
mnYTop = nYBandPosition;
838 pNewBand->
mnYTop = nYBandPosition;
853 if ( nYBandPosition == pBand->
mnYBottom )
883 SAL_WARN_IF( nLeft > nRight,
"vcl",
"RegionBand::Union() - nLeft > nRight" );
884 SAL_WARN_IF( nTop > nBottom,
"vcl",
"RegionBand::Union() - nTop > nBottom" );
890 if ( pBand->
mnYTop >= nTop )
893 pBand->
Union( nLeft, nRight );
903 OSL_ENSURE(
false,
"RegionBand::Union() - Bands not sorted!" );
979 SAL_WARN_IF( nLeft > nRight,
"vcl",
"RegionBand::Exclude() - nLeft > nRight" );
980 SAL_WARN_IF( nTop > nBottom,
"vcl",
"RegionBand::Exclude() - nTop > nBottom" );
1003 OSL_ENSURE(
false,
"RegionBand::Exclude() - Bands not sorted!" );
1020 SAL_WARN_IF( nLeft > nRight,
"vcl",
"RegionBand::Exclude() - nLeft > nRight" );
1021 SAL_WARN_IF( nTop > nBottom,
"vcl",
"RegionBand::Exclude() - nTop > nBottom" );
1028 if(pBand->
mnYTop >= nTop)
1032 pBand->
XOr(nLeft, nRight);
1044 OSL_ENSURE(
false,
"RegionBand::XOr() - Bands not sorted!" );
1201 nXLeft = std::min( nXLeft, pBand->GetXLeftBoundary() );
1202 nXRight = std::max( nXRight, pBand->GetXRightBoundary() );
1204 pBand = pBand->mpNextBand;
1244 return pBand->
Contains(rPoint.X());
1260 while(pCurrRectBand)
1267 while(pCurrRectBandSep)
1271 rTarget.push_back(aRectangle);
1272 pCurrRectBandSep = pCurrRectBandSep->
mpNextSep;
1313 return "YBottom < YTop";
1320 return "overlapping bands in region";
1326 return "Band-mbTouched overwrite";
1335 return "XLeft < XRight";
1342 return "overlapping separations in region";
1348 return "Sep-mbRemoved overwrite";
void ImplAddMissingBands(const tools::Long nTop, const tools::Long nBottom)
This function is similar to the RegionBand::InsertBands() method.
ImplRegionBand * mpFirstBand
void Intersect(tools::Long nLeft, tools::Long nTop, tools::Long nRight, tools::Long nBottom)
void Intersect(tools::Long nXLeft, tools::Long nXRight)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
ImplRegionBandSep * mpFirstSep
SvStream & WriteInt32(sal_Int32 nInt32)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
ImplRegionBand * mpPrevBand
void InsertBand(ImplRegionBand *pPreviousBand, ImplRegionBand *pBandToInsert)
void MoveX(tools::Long nHorzMove)
void Union(tools::Long nLeft, tools::Long nTop, tools::Long nRight, tools::Long nBottom)
std::vector< tools::Rectangle > RectangleVector
sal_uInt32 getRectangleCount() const
void CreateBandRange(tools::Long nYTop, tools::Long nYBottom)
void XOr(tools::Long nLeft, tools::Long nTop, tools::Long nRight, tools::Long nBottom)
void save(SvStream &rIStrm) const
bool isSingleRectangle() const
sal_uInt64 remainingSize()
bool load(SvStream &rIStrm)
B2IRange fround(const B2DRange &rRange)
void ScaleX(double fHorzScale)
void Move(tools::Long nHorzMove, tools::Long nVertMove)
bool CheckConsistency() const
void Exclude(tools::Long nLeft, tools::Long nTop, tools::Long nRight, tools::Long nBottom)
RegionBand & operator=(const RegionBand &)
void Exclude(tools::Long nXLeft, tools::Long nXRight)
static bool InsertSingleBand(ImplRegionBand *pBand, tools::Long nYBandPosition)
void InsertBands(tools::Long nTop, tools::Long nBottom)
bool Contains(const Point &rPoint) const
ImplRegionBandSep * mpNextSep
void InsertPoint(const Point &rPoint, tools::Long nLineID, bool bEndPoint, LineType eLineType)
SvStream & ReadInt32(sal_Int32 &rInt32)
void GetRegionRectangles(RectangleVector &rTarget) const
void Scale(double fScaleX, double fScaleY)
tools::Rectangle GetBoundRect() const
void InsertLine(const Point &rStartPt, const Point &rEndPt, tools::Long nLineId)
void XOr(tools::Long nXLeft, tools::Long nXRight)
#define SAL_WARN_IF(condition, area, stream)
tools::Long GetXRightBoundary() const
tools::Long GetXLeftBoundary() const
const char * ImplDbgTestRegionBand(const void *pObj)
bool operator==(const RegionBand &rRegionBand) const
ImplRegionBand * mpLastCheckedBand
bool InsertPoint(tools::Long nX, tools::Long nLineID, bool bEndPoint, LineType eLineType)
void Union(tools::Long nXLeft, tools::Long nXRight)
bool Contains(tools::Long nX)
ImplRegionBand * ImplGetFirstRegionBand() const
ImplRegionBand * mpNextBand