main/sw/source/core/layout/paintfrm.cxx
/// OD 05.09.2002 #102912#
/// Do not paint background for fly frames without a background brush by
/// calling <PaintBaBo> at the page or at the fly frame its anchored
OD 05.09.2002 #102912
Do not paint background for fly frames without a background brush by
calling  at the page or at the fly frame its anchored
OD 05 . 09 . 2002 #102912 Do not paint background for fly frames without a background brush by calling at the page or at the fly frame its anchored
void SwFrm::PaintBackground( const SwRect &rRect, const SwPageFrm *pPage,
						 	 const SwBorderAttrs & rAttrs,
							 const sal_Bool bLowerMode,
							 const sal_Bool bLowerBorder ) const
{
    if( IsTabFrm() &&
        !pGlobalShell->GetViewOptions()->IsTable() )
    {
        return;
    }
	if( IsCellFrm() && IsCoveredCell() )
		return;
    ViewShell *pSh = pGlobalShell;
    SwTaggedPDFHelper aTaggedPDFHelper( 0, 0, 0, *pSh->GetOut() );
    const SvxBrushItem* pItem;
    SvxBrushItem* pTmpBackBrush = 0;
    const Color* pCol;
	SwRect aOrigBackRect;
	const sal_Bool bPageFrm = IsPageFrm();
	sal_Bool bLowMode = sal_True;
    drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFillAttributes;
    sal_Bool bBack = GetBackgroundBrush( aFillAttributes, pItem, pCol, aOrigBackRect, bLowerMode );
    bool bNoFlyBackground = !bFlyMetafile && !bBack && IsFlyFrm();
    if ( bNoFlyBackground )
    {
        if ( bLowerMode )
        {
            bBack = GetBackgroundBrush( aFillAttributes, pItem, pCol, aOrigBackRect, false );
        }
        if ( !bBack )
        {
            if ( pSh->GetOut()->GetOutDevType() == OUTDEV_PRINTER ||
                 pSh->GetViewOptions()->IsPDFExport() ||
                 ( pSh->GetDoc()->GetDocShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED &&
                   !pSh->GetDoc()->GetDocShell()->IsInPlaceActive()
                 )
               )
            {
                pTmpBackBrush = new SvxBrushItem( Color( COL_WHITE ), RES_BACKGROUND );
                aFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(Color( COL_WHITE )));
            }
            else
            {
                pTmpBackBrush = new SvxBrushItem( aGlobalRetoucheColor, RES_BACKGROUND);
                aFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aGlobalRetoucheColor));
            }
            pItem = pTmpBackBrush;
            bBack = true;
        }
    }
	SwRect aPaintRect( Frm() );
	if( IsTxtFrm() || IsSctFrm() )
		aPaintRect = UnionFrm( sal_True );
	if ( aPaintRect.IsOver( rRect ) )
	{
        if ( bBack || bPageFrm || !bLowerMode )
        {
            const sal_Bool bBrowse = pSh->GetViewOptions()->getBrowseMode();
            SwRect aRect;
            if ( (bPageFrm && bBrowse) ||
                 (IsTxtFrm() && Prt().SSize() == Frm().SSize()) )
            {
                aRect = Frm();
                ::SwAlignRect( aRect, pGlobalShell );
            }
            else
            {
                ::lcl_CalcBorderRect( aRect, this, rAttrs, sal_False );
                if ( (IsTxtFrm() || IsTabFrm()) && GetPrev() )
                {
                    if ( GetPrev()->GetAttrSet()->GetBackground() ==
                         GetAttrSet()->GetBackground() )
                    {
                        aRect.Top( Frm().Top() );
                    }
                }
            }
            aRect.Intersection( rRect );
            OutputDevice *pOut = pSh->GetOut();
            if ( aRect.HasArea() )
            {
                SvxBrushItem* pNewItem = 0;
                if( pCol )
                {
                    pNewItem = new SvxBrushItem( *pCol, RES_BACKGROUND );
                    pItem = pNewItem;
                    aFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(*pCol));
                }
                {
                    const sal_Bool bConsiderBackgroundTransparency = IsFlyFrm();
                    bool bDone(false);
                    if(pOut && aFillAttributes.get())
                    {
                        if(aFillAttributes->isUsed())
                        {
                            bDone = DrawFillAttributes(aFillAttributes, aOrigBackRect, aRect, *pOut);
                        }
                        if(!bDone)
                        {
                            const XFillStyle eFillStyle(static_cast< const XFillStyleItem& >(GetAttrSet()->Get(XATTR_FILLSTYLE)).GetValue());
                            if(XFILL_NONE != eFillStyle)
                            {
                                bDone = true;
                            }
                        }
                    }
                    if(!bDone)
                    {
                        ::DrawGraphic(
                                pItem,
                                pOut,
                                aOrigBackRect,
                                aRect, 
                                GRFNUM_NO,
                                bConsiderBackgroundTransparency );
                    }
                }
                if( pCol )
                    delete pNewItem;
            }
        }
        else
            bLowMode = bLowerMode ? sal_True : sal_False;
	}
    delete pTmpBackBrush;
	const SwFrm *pFrm = GetLower();
    if ( pFrm )
	{
		SwRect aFrmRect;
		SwRect aRect( PaintArea() );
		aRect._Intersection( rRect );
		SwRect aBorderRect( aRect );
        SwShortCut aShortCut( *pFrm, aBorderRect );
		do
		{   if ( pProgress )
				pProgress->Reschedule();
			aFrmRect = pFrm->PaintArea();
			if ( aFrmRect.IsOver( aBorderRect ) )
			{
				SwBorderAttrAccess aAccess( SwFrm::GetCache(), (SwFrm*)pFrm );
                const SwBorderAttrs &rTmpAttrs = *aAccess.Get();
                if ( bLowerBorder )
                    pFrm->PaintBorder( aBorderRect, pPage, rTmpAttrs );
				if ( ( pFrm->IsLayoutFrm() && bLowerBorder ) ||
					 aFrmRect.IsOver( aRect ) )
                    pFrm->PaintBackground( aRect, pPage, rTmpAttrs, bLowMode,
										   bLowerBorder );
			}
			pFrm = pFrm->GetNext();
		} while ( pFrm && pFrm->GetUpper() == this &&
                  !aShortCut.Stop( aFrmRect ) );
	}
}
void SwFrm :: PaintBackground ( const SwRect & rRect , const SwPageFrm * pPage , const SwBorderAttrs & rAttrs , const sal_Bool bLowerMode , const sal_Bool bLowerBorder ) const { if ( IsTabFrm ( ) && ! pGlobalShell -> GetViewOptions ( ) -> IsTable ( ) ) { return ; } if ( IsCellFrm ( ) && IsCoveredCell ( ) ) return ; ViewShell * pSh = pGlobalShell ; SwTaggedPDFHelper aTaggedPDFHelper ( 0 , 0 , 0 , * pSh -> GetOut ( ) ) ; const SvxBrushItem * pItem ; SvxBrushItem * pTmpBackBrush = 0 ; const Color * pCol ; SwRect aOrigBackRect ; const sal_Bool bPageFrm = IsPageFrm ( ) ; sal_Bool bLowMode = sal_True ; drawinglayer :: attribute :: SdrAllFillAttributesHelperPtr aFillAttributes ; sal_Bool bBack = GetBackgroundBrush ( aFillAttributes , pItem , pCol , aOrigBackRect , bLowerMode ) ; bool bNoFlyBackground = ! bFlyMetafile && ! bBack && IsFlyFrm ( ) ; if ( bNoFlyBackground ) { if ( bLowerMode ) { bBack = GetBackgroundBrush ( aFillAttributes , pItem , pCol , aOrigBackRect , false ) ; } if ( ! bBack ) { if ( pSh -> GetOut ( ) -> GetOutDevType ( ) == OUTDEV_PRINTER || pSh -> GetViewOptions ( ) -> IsPDFExport ( ) || ( pSh -> GetDoc ( ) -> GetDocShell ( ) -> GetCreateMode ( ) == SFX_CREATE_MODE_EMBEDDED && ! pSh -> GetDoc ( ) -> GetDocShell ( ) -> IsInPlaceActive ( ) ) ) { pTmpBackBrush = new SvxBrushItem ( Color ( COL_WHITE ) , RES_BACKGROUND ) ; aFillAttributes . reset ( new drawinglayer :: attribute :: SdrAllFillAttributesHelper ( Color ( COL_WHITE ) ) ) ; } else { pTmpBackBrush = new SvxBrushItem ( aGlobalRetoucheColor , RES_BACKGROUND ) ; aFillAttributes . reset ( new drawinglayer :: attribute :: SdrAllFillAttributesHelper ( aGlobalRetoucheColor ) ) ; } pItem = pTmpBackBrush ; bBack = true ; } } SwRect aPaintRect ( Frm ( ) ) ; if ( IsTxtFrm ( ) || IsSctFrm ( ) ) aPaintRect = UnionFrm ( sal_True ) ; if ( aPaintRect . IsOver ( rRect ) ) { if ( bBack || bPageFrm || ! bLowerMode ) { const sal_Bool bBrowse = pSh -> GetViewOptions ( ) -> getBrowseMode ( ) ; SwRect aRect ; if ( ( bPageFrm && bBrowse ) || ( IsTxtFrm ( ) && Prt ( ) . SSize ( ) == Frm ( ) . SSize ( ) ) ) { aRect = Frm ( ) ; :: SwAlignRect ( aRect , pGlobalShell ) ; } else { :: lcl_CalcBorderRect ( aRect , this , rAttrs , sal_False ) ; if ( ( IsTxtFrm ( ) || IsTabFrm ( ) ) && GetPrev ( ) ) { if ( GetPrev ( ) -> GetAttrSet ( ) -> GetBackground ( ) == GetAttrSet ( ) -> GetBackground ( ) ) { aRect . Top ( Frm ( ) . Top ( ) ) ; } } } aRect . Intersection ( rRect ) ; OutputDevice * pOut = pSh -> GetOut ( ) ; if ( aRect . HasArea ( ) ) { SvxBrushItem * pNewItem = 0 ; if ( pCol ) { pNewItem = new SvxBrushItem ( * pCol , RES_BACKGROUND ) ; pItem = pNewItem ; aFillAttributes . reset ( new drawinglayer :: attribute :: SdrAllFillAttributesHelper ( * pCol ) ) ; } { const sal_Bool bConsiderBackgroundTransparency = IsFlyFrm ( ) ; bool bDone ( false ) ; if ( pOut && aFillAttributes . get ( ) ) { if ( aFillAttributes -> isUsed ( ) ) { bDone = DrawFillAttributes ( aFillAttributes , aOrigBackRect , aRect , * pOut ) ; } if ( ! bDone ) { const XFillStyle eFillStyle ( static_cast < const XFillStyleItem & > ( GetAttrSet ( ) -> Get ( XATTR_FILLSTYLE ) ) . GetValue ( ) ) ; if ( XFILL_NONE != eFillStyle ) { bDone = true ; } } } if ( ! bDone ) { :: DrawGraphic ( pItem , pOut , aOrigBackRect , aRect , GRFNUM_NO , bConsiderBackgroundTransparency ) ; } } if ( pCol ) delete pNewItem ; } } else bLowMode = bLowerMode ? sal_True : sal_False ; } delete pTmpBackBrush ; const SwFrm * pFrm = GetLower ( ) ; if ( pFrm ) { SwRect aFrmRect ; SwRect aRect ( PaintArea ( ) ) ; aRect . _Intersection ( rRect ) ; SwRect aBorderRect ( aRect ) ; SwShortCut aShortCut ( * pFrm , aBorderRect ) ; do { if ( pProgress ) pProgress -> Reschedule ( ) ; aFrmRect = pFrm -> PaintArea ( ) ; if ( aFrmRect . IsOver ( aBorderRect ) ) { SwBorderAttrAccess aAccess ( SwFrm :: GetCache ( ) , ( SwFrm * ) pFrm ) ; const SwBorderAttrs & rTmpAttrs = * aAccess . Get ( ) ; if ( bLowerBorder ) pFrm -> PaintBorder ( aBorderRect , pPage , rTmpAttrs ) ; if ( ( pFrm -> IsLayoutFrm ( ) && bLowerBorder ) || aFrmRect . IsOver ( aRect ) ) pFrm -> PaintBackground ( aRect , pPage , rTmpAttrs , bLowMode , bLowerBorder ) ; } pFrm = pFrm -> GetNext ( ) ; } while ( pFrm && pFrm -> GetUpper ( ) == this && ! aShortCut . Stop ( aFrmRect ) ) ; } }
OD 05.09.2002 #102912
Do not paint background for fly frames without a background brush by
calling <PaintBaBo> at the page or at the fly frame its anchored
OD 05 . 09 . 2002 #102912 Do not paint background for fly frames without a background brush by calling <PaintBaBo > at the page or at the fly frame its anchored
// OD 20.01.2003 #i1837# - no paint of table background, if corresponding // option is *not* set. // nothing to do for covered table cells: // --> FME 2004-06-24 #i16816# tagged pdf support // <-- /// OD 05.09.2002 #102912# /// temporary background brush for a fly frame without a background brush //UUUU //- Ausgabe wenn ein eigener Hintergrund mitgebracht wird. // OD 05.09.2002 #102912# - Fly frame has no background. // Try to find background brush at parents, if previous call of // <GetBackgroundBrush> disabled this option with the parameter <bLowerMode> // If still no background found for the fly frame, initialize the // background brush <pItem> with global retouche color and set <bBack> // to sal_True, that fly frame will paint its background using this color. // OD 10.01.2003 #i6467# - on print output, pdf output and // in embedded mode not editing color COL_WHITE is used instead of // the global retouche color. //UUU //UUU //SwRegionRects aRegion( aRect ); //UUUU //if ( pPage->GetSortedObjs() ) //{ //    ::lcl_SubtractFlys( this, pPage, aRect, aRegion ); //} /// OD 06.08.2002 #99657# - determine, if background transparency ///     have to be considered for drawing. ///     --> Status Quo: background transparency have to be ///        considered for fly frames // #i125189# We are also done when the new DrawingLayer FillAttributes are used // or the FillStyle is set (different from XFILL_NONE) // check if really something is painted // if not, still a FillStyle could be set but the transparency is at 100%, // thus need to check the model data itself for FillStyle (do not rely on // SdrAllFillAttributesHelper since it already contains optimized information, // e.g. transparency leads to no fill) //for ( sal_uInt16 i = 0; i < aRegion.Count(); ++i ) //{ //    if ( 1 < aRegion.Count() ) //    { //        ::SwAlignRect( aRegion[i], pGlobalShell ); //        if( !aRegion[i].HasArea() ) //            continue; //    } /// OD 06.08.2002 #99657# - add 6th parameter to indicate, if ///     background transparency have to be considered ///     Set missing 5th parameter to the default value GRFNUM_NO ///         - see declaration in /core/inc/frmtool.hxx. // aRegion[i], //} /// OD 05.09.2002 #102912# /// delete temporary background brush. //Jetzt noch Lower und dessen Nachbarn. //Wenn ein Frn dabei die Kette verlaesst also nicht mehr Lower von mir ist //so hoert der Spass auf. /// OD 06.08.2002 #99657# - paint border before painting background