diff --git a/core/area.cpp b/core/area.cpp index f29cf7fda..a27bff83d 100644 --- a/core/area.cpp +++ b/core/area.cpp @@ -122,6 +122,19 @@ NormalizedRect& NormalizedRect::operator|= (const NormalizedRect & r) return *this; } +NormalizedRect NormalizedRect::operator&( const NormalizedRect & r ) const +{ + if ( isNull() || r.isNull() ) + return NormalizedRect(); + + NormalizedRect ret; + ret.left = qMax( left, r.left ); + ret.top = qMax( top, r.top ); + ret.bottom = qMin( bottom, r.bottom ); + ret.right = qMin( right, r.right ); + return ret; +} + NormalizedRect & NormalizedRect::operator=( const NormalizedRect & r ) { left = r.left; diff --git a/core/area.h b/core/area.h index 4e3603494..d13c3cdf2 100644 --- a/core/area.h +++ b/core/area.h @@ -177,6 +177,14 @@ class OKULAR_EXPORT NormalizedRect */ NormalizedRect& operator|=( const NormalizedRect &other ); + /** + * Returns the intersection of this normalized rectangle with the specified + * @p other. If the rects do not intersect then the result is null. + * + * @since 0.7 (KDE 4.1) + */ + NormalizedRect operator&( const NormalizedRect &other ) const; + /** * Returns whether the normalized rectangle is equal to the @p other * normalized rectangle.