main/sw/source/core/layout/paintfrm.cxx
// OD 20.02.2003 - Note: function <SwAlignRect(..)> also used outside this file.
// OD 29.04.2003 #107169# - correction: adjust rectangle on pixel level in order
//          to assure, that the border 'leaves its original pixel', if it has to.
//          No prior adjustments for odd relation between pixel and twip.
OD 20.02.2003 - Note: function  also used outside this file.
OD 29.04.2003 #107169# - correction: adjust rectangle on pixel level in order
to assure, that the border 'leaves its original pixel', if it has to.
No prior adjustments for odd relation between pixel and twip.
OD 20 . 02 . 2003 - Note : function also used outside this file . OD 29 . 04 . 2003 #107169# - correction : adjust rectangle on pixel level in order to assure that the border ' leaves its original pixel ' if it has to . No prior adjustments for odd relation between pixel and twip .
void MA_FASTCALL SwAlignRect( SwRect &rRect, ViewShell *pSh )
{
    if( !rRect.HasArea() )
        return;
    if ( !bFlyMetafile && !pSh )
    {
        return;
    }
    const OutputDevice *pOut = bFlyMetafile ?
						pFlyMetafileOut : pSh->GetOut();
    const Rectangle aOrgPxRect = pOut->LogicToPixel( rRect.SVRect() );
    const SwRect aPxCenterRect( pOut->PixelToLogic( aOrgPxRect ) );
    SwRect aAlignedPxRect( aOrgPxRect );
    if ( rRect.Top() > aPxCenterRect.Top() )
    {
        aAlignedPxRect.Top( aAlignedPxRect.Top() + 1 );
    }
    if ( rRect.Bottom() < aPxCenterRect.Bottom() )
    {
        aAlignedPxRect.Bottom( aAlignedPxRect.Bottom() - 1 );
    }
    if ( rRect.Left() > aPxCenterRect.Left() )
    {
        aAlignedPxRect.Left( aAlignedPxRect.Left() + 1 );
    }
    if ( rRect.Right() < aPxCenterRect.Right() )
    {
        aAlignedPxRect.Right( aAlignedPxRect.Right() - 1 );
    }
    if ( aAlignedPxRect.Width() < 0 )
    {
        aAlignedPxRect.Width(0);
    }
    if ( aAlignedPxRect.Height() < 0 )
    {
        aAlignedPxRect.Height(0);
    }
    sal_Bool bZeroWidth = sal_False;
    if ( aAlignedPxRect.Width() == 0 )
    {
        aAlignedPxRect.Width(1);
        bZeroWidth = sal_True;
    }
    sal_Bool bZeroHeight = sal_False;
    if ( aAlignedPxRect.Height() == 0 )
    {
        aAlignedPxRect.Height(1);
        bZeroHeight = sal_True;
    }
    rRect = pOut->PixelToLogic( aAlignedPxRect.SVRect() );
     and adjust calculated
    if ( bZeroWidth )
    {
        rRect.Width(0);
    }
    if ( bZeroHeight )
    {
        rRect.Height(0);
    }
}
void MA_FASTCALL SwAlignRect ( SwRect & rRect , ViewShell * pSh ) { if ( ! rRect . HasArea ( ) ) return ; if ( ! bFlyMetafile && ! pSh ) { return ; } const OutputDevice * pOut = bFlyMetafile ? pFlyMetafileOut : pSh -> GetOut ( ) ; const Rectangle aOrgPxRect = pOut -> LogicToPixel ( rRect . SVRect ( ) ) ; const SwRect aPxCenterRect ( pOut -> PixelToLogic ( aOrgPxRect ) ) ; SwRect aAlignedPxRect ( aOrgPxRect ) ; if ( rRect . Top ( ) > aPxCenterRect . Top ( ) ) { aAlignedPxRect . Top ( aAlignedPxRect . Top ( ) + 1 ) ; } if ( rRect . Bottom ( ) < aPxCenterRect . Bottom ( ) ) { aAlignedPxRect . Bottom ( aAlignedPxRect . Bottom ( ) - 1 ) ; } if ( rRect . Left ( ) > aPxCenterRect . Left ( ) ) { aAlignedPxRect . Left ( aAlignedPxRect . Left ( ) + 1 ) ; } if ( rRect . Right ( ) < aPxCenterRect . Right ( ) ) { aAlignedPxRect . Right ( aAlignedPxRect . Right ( ) - 1 ) ; } if ( aAlignedPxRect . Width ( ) < 0 ) { aAlignedPxRect . Width ( 0 ) ; } if ( aAlignedPxRect . Height ( ) < 0 ) { aAlignedPxRect . Height ( 0 ) ; } sal_Bool bZeroWidth = sal_False ; if ( aAlignedPxRect . Width ( ) == 0 ) { aAlignedPxRect . Width ( 1 ) ; bZeroWidth = sal_True ; } sal_Bool bZeroHeight = sal_False ; if ( aAlignedPxRect . Height ( ) == 0 ) { aAlignedPxRect . Height ( 1 ) ; bZeroHeight = sal_True ; } rRect = pOut -> PixelToLogic ( aAlignedPxRect . SVRect ( ) ) ; if ( bZeroWidth ) { rRect . Width ( 0 ) ; } if ( bZeroHeight ) { rRect . Height ( 0 ) ; } }
OD 20.02.2003 - Note: function <SwAlignRect(..)> also used outside this file.
OD 20 . 02 . 2003 - Note : function <SwAlignRect ( .. ) > also used outside this file .
// OD 03.09.2002 #102450# // Assure that view shell (parameter <pSh>) exists, if the output device // is taken from this view shell --> no output device, no alignment. // Output device taken from view shell <pSh>, if <bFlyMetafile> not set. // OD 28.04.2003 #107169# - hold original rectangle in pixel // OD 29.04.2003 #107169# - determine pixel-center rectangle in twip // OD 06.05.2003 #107169# - perform adjustments on pixel level. // 'leave pixel overlapping on top' // 'leave pixel overlapping on bottom' // 'leave pixel overlapping on left' // 'leave pixel overlapping on right' // OD 11.10.2002 #103636# - consider negative width/height // check, if aligned SwRect has negative width/height. // If Yes, adjust it to width/height = 0 twip. // NOTE: A SwRect with negative width/height can occur, if the width/height //     of the given SwRect in twip was less than a pixel in twip and that //     the alignment calculates that the aligned SwRect should not contain //     the pixels the width/height is on. // OD 30.04.2003 #107169# - consider zero width/height // For converting a rectangle from pixel to logic it needs a width/height. // Thus, set width/height to one, if it's zero and correct this on the twip // level after the conversion. // OD 30.04.2003 #107169# - consider zero width/height and adjust calculated // aligned twip rectangle. // OD 19.05.2003 #109667# - reset width/height to zero; previous negative // width/height haven't to be considered.