/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
SwRect& SwRect::Union( const SwRect& rRect )
{ if( rRect.IsEmpty()) return *this; if( IsEmpty())
{
*this = rRect; return *this;
} if ( Top() > rRect.Top() )
Top( rRect.Top() ); if ( Left() > rRect.Left() )
Left( rRect.Left() );
tools::Long n = rRect.Right(); if ( Right() < n )
Right( n );
n = rRect.Bottom(); if ( Bottom() < n )
Bottom( n ); return *this;
}
SwRect& SwRect::Intersection( const SwRect& rRect )
{ // any similarity between me and given element? if ( Overlaps( rRect ) )
{ // get smaller right and lower, and greater left and upper edge if ( Left() < rRect.Left() )
Left( rRect.Left() ); if ( Top() < rRect.Top() )
Top( rRect.Top() );
tools::Long n = rRect.Right(); if ( Right() > n )
Right( n );
n = rRect.Bottom(); if ( Bottom() > n )
Bottom( n );
} else // Def.: if intersection is empty, set only SSize to 0
SSize(0, 0);
return *this;
}
SwRect& SwRect::Intersection_( const SwRect& rOther )
{ // get smaller right and lower, and greater left and upper edge auto left = std::max( m_Point.X(), rOther.m_Point.X() ); auto top = std::max( m_Point.Y(), rOther.m_Point.Y() );
tools::Long right = std::min( m_Point.X() + m_Size.Width(), rOther.m_Point.X() + rOther.m_Size.Width() ); auto bottom = std::min( m_Point.Y() + m_Size.Height(), rOther.m_Point.Y() + rOther.m_Size.Height() );
*this = SwRect( left, top, right - left, bottom - top );
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.