sw/source/core/doc/notxtfrm.cxx | 249 ++++++++++++++++++++-------------------- sw/source/core/inc/notxtfrm.hxx | 4 2 files changed, 133 insertions(+), 120 deletions(-)
New commits: commit acc083480abf506c9ff620ddbc722da467db9e3e Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Nov 16 16:17:11 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Nov 17 08:35:13 2022 +0100 split the paint method a little more it has to be smaller to fit into my mental working-RAM Change-Id: If2225359591a070373e3a9ca0459e5c64bef7526 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142776 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 6d11624da3b1..709128f677fa 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -1214,139 +1214,148 @@ void SwNoTextFrame::ImplPaintPictureGraphic( vcl::RenderContext* pOut, if( !bContinue ) return; - if( rGrfObj.GetGraphic().IsSupportedGraphic()) + if( !rGrfObj.GetGraphic().IsSupportedGraphic()) { - const bool bAnimate = rGrfObj.IsAnimated() && - !pShell->IsPreview() && - !pShell->GetAccessibilityOptions()->IsStopAnimatedGraphics() && - // #i9684# Stop animation during printing/pdf export - pShell->GetWin(); + ImplPaintPictureReplacement(rGrfObj, pGrfNd, rAlignedGrfArea, pShell); + return; + } - if( bAnimate && - FindFlyFrame() != ::GetFlyFromMarked( nullptr, pShell )) + const bool bAnimate = rGrfObj.IsAnimated() && + !pShell->IsPreview() && + !pShell->GetAccessibilityOptions()->IsStopAnimatedGraphics() && + // #i9684# Stop animation during printing/pdf export + pShell->GetWin(); + if( bAnimate && + FindFlyFrame() != ::GetFlyFromMarked( nullptr, pShell )) + { + ImplPaintPictureAnimate(pOut, pShell, pGrfNd, rAlignedGrfArea); + return; + } + + // MM02 To allow system-dependent buffering of the involved + // bitmaps it is necessary to re-use the involved primitives + // and their already executed decomposition (also for + // performance reasons). This is usually done in DrawingLayer + // by using the VOC-Mechanism (see descriptions elsewhere). + // To get that here, make the involved SwNoTextFrame (this) + // a sdr::contact::ViewContact supplier by supporting + // a GetViewContact() - call. For ObjectContact we can use + // the already existing ObjectContact from the involved + // DrawingLayer. For this, the helper classes + // ViewObjectContactOfSwNoTextFrame + // ViewContactOfSwNoTextFrame + // are created which support the VOC-mechanism in its minimal + // form. This allows automatic and view-dependent (multiple edit + // windows, print, etc.) re-use of the created primitives. + // Also: Will be very useful when completely changing the Writer + // repaint to VOC and Primitives, too. + static const char* pDisableMM02Goodies(getenv("SAL_DISABLE_MM02_GOODIES")); + static bool bUseViewObjectContactMechanism(nullptr == pDisableMM02Goodies); + // tdf#130951 for safety reasons use fallback if ViewObjectContactMechanism + // fails for some reason - usually could only be not to find the correct + // SdrPageWindow + bool bSucceeded(false); + + if(bUseViewObjectContactMechanism) + { + // MM02 use VOC-mechanism and buffer primitives + SwViewShellImp* pImp(pShell->Imp()); + SdrPageView* pPageView(nullptr != pImp + ? pImp->GetPageView() + : nullptr); + // tdf#130951 caution - target may be Window, use the correct OutputDevice + OutputDevice* pTarget(pShell->isOutputToWindow() + ? pShell->GetWin()->GetOutDev() + : pShell->GetOut()); + SdrPageWindow* pPageWindow(nullptr != pPageView && nullptr != pTarget + ? pPageView->FindPageWindow(*pTarget) + : nullptr); + + if(nullptr != pPageWindow) { - OutputDevice* pVout; - if( pOut == pShell->GetOut() && SwRootFrame::FlushVout() ) - { - pVout = pOut; - pOut = pShell->GetOut(); - } - else if( pShell->GetWin() && pOut->IsVirtual() ) - { - pVout = pOut; - pOut = pShell->GetWin()->GetOutDev(); - } - else - pVout = nullptr; + sdr::contact::ObjectContact& rOC(pPageWindow->GetObjectContact()); + sdr::contact::ViewContact& rVC(GetViewContact()); + sdr::contact::ViewObjectContact& rVOC(rVC.GetViewObjectContact(rOC)); + sdr::contact::DisplayInfo aDisplayInfo; - OSL_ENSURE( !pOut->IsVirtual() || - pShell->GetViewOptions()->IsPDFExport() || pShell->isOutputToWindow(), - "pOut should not be a virtual device" ); + drawinglayer::primitive2d::Primitive2DContainer aPrimitives(rVOC.getPrimitive2DSequence(aDisplayInfo)); + const basegfx::B2DHomMatrix aGraphicTransform(getFrameAreaTransformation()); - pGrfNd->StartGraphicAnimation(pOut, rAlignedGrfArea.Pos(), - rAlignedGrfArea.SSize(), reinterpret_cast<sal_IntPtr>(this), - pVout ); + paintGraphicUsingPrimitivesHelper( + *pOut, + aPrimitives, + aGraphicTransform, + nullptr == pGrfNd->GetFlyFormat() ? OUString() : pGrfNd->GetFlyFormat()->GetName(), + rNoTNd.GetTitle(), + rNoTNd.GetDescription()); + bSucceeded = true; } - else - { - // MM02 To allow system-dependent buffering of the involved - // bitmaps it is necessary to re-use the involved primitives - // and their already executed decomposition (also for - // performance reasons). This is usually done in DrawingLayer - // by using the VOC-Mechanism (see descriptions elsewhere). - // To get that here, make the involved SwNoTextFrame (this) - // a sdr::contact::ViewContact supplier by supporting - // a GetViewContact() - call. For ObjectContact we can use - // the already existing ObjectContact from the involved - // DrawingLayer. For this, the helper classes - // ViewObjectContactOfSwNoTextFrame - // ViewContactOfSwNoTextFrame - // are created which support the VOC-mechanism in its minimal - // form. This allows automatic and view-dependent (multiple edit - // windows, print, etc.) re-use of the created primitives. - // Also: Will be very useful when completely changing the Writer - // repaint to VOC and Primitives, too. - static const char* pDisableMM02Goodies(getenv("SAL_DISABLE_MM02_GOODIES")); - static bool bUseViewObjectContactMechanism(nullptr == pDisableMM02Goodies); - // tdf#130951 for safety reasons use fallback if ViewObjectContactMechanism - // fails for some reason - usually could only be not to find the correct - // SdrPageWindow - bool bSucceeded(false); - - if(bUseViewObjectContactMechanism) - { - // MM02 use VOC-mechanism and buffer primitives - SwViewShellImp* pImp(pShell->Imp()); - SdrPageView* pPageView(nullptr != pImp - ? pImp->GetPageView() - : nullptr); - // tdf#130951 caution - target may be Window, use the correct OutputDevice - OutputDevice* pTarget(pShell->isOutputToWindow() - ? pShell->GetWin()->GetOutDev() - : pShell->GetOut()); - SdrPageWindow* pPageWindow(nullptr != pPageView && nullptr != pTarget - ? pPageView->FindPageWindow(*pTarget) - : nullptr); - - if(nullptr != pPageWindow) - { - sdr::contact::ObjectContact& rOC(pPageWindow->GetObjectContact()); - sdr::contact::ViewContact& rVC(GetViewContact()); - sdr::contact::ViewObjectContact& rVOC(rVC.GetViewObjectContact(rOC)); - sdr::contact::DisplayInfo aDisplayInfo; - - drawinglayer::primitive2d::Primitive2DContainer aPrimitives(rVOC.getPrimitive2DSequence(aDisplayInfo)); - const basegfx::B2DHomMatrix aGraphicTransform(getFrameAreaTransformation()); - - paintGraphicUsingPrimitivesHelper( - *pOut, - aPrimitives, - aGraphicTransform, - nullptr == pGrfNd->GetFlyFormat() ? OUString() : pGrfNd->GetFlyFormat()->GetName(), - rNoTNd.GetTitle(), - rNoTNd.GetDescription()); - bSucceeded = true; - } - } + } - if(!bSucceeded) - { - // MM02 fallback to direct paint with primitive-recreation - // which will block reusage of system-dependent bitmap data - const basegfx::B2DHomMatrix aGraphicTransform(getFrameAreaTransformation()); - - paintGraphicUsingPrimitivesHelper( - *pOut, - rGrfObj, - aGrfAttr, - aGraphicTransform, - nullptr == pGrfNd->GetFlyFormat() ? OUString() : pGrfNd->GetFlyFormat()->GetName(), - rNoTNd.GetTitle(), - rNoTNd.GetDescription()); - } - } + if(!bSucceeded) + { + // MM02 fallback to direct paint with primitive-recreation + // which will block reusage of system-dependent bitmap data + const basegfx::B2DHomMatrix aGraphicTransform(getFrameAreaTransformation()); + + paintGraphicUsingPrimitivesHelper( + *pOut, + rGrfObj, + aGrfAttr, + aGraphicTransform, + nullptr == pGrfNd->GetFlyFormat() ? OUString() : pGrfNd->GetFlyFormat()->GetName(), + rNoTNd.GetTitle(), + rNoTNd.GetDescription()); } - else +} + +void SwNoTextFrame::ImplPaintPictureAnimate(vcl::RenderContext* pOut, SwViewShell* pShell, + SwGrfNode* pGrfNd, const SwRect& rAlignedGrfArea) const +{ + OutputDevice* pVout; + if( pOut == pShell->GetOut() && SwRootFrame::FlushVout() ) + { + pVout = pOut; + pOut = pShell->GetOut(); + } + else if( pShell->GetWin() && pOut->IsVirtual() ) { - TranslateId pResId; + pVout = pOut; + pOut = pShell->GetWin()->GetOutDev(); + } + else + pVout = nullptr; - if( GraphicType::NONE == rGrfObj.GetType() ) - pResId = STR_COMCORE_READERROR; - else if ( !rGrfObj.GetGraphic().IsSupportedGraphic() ) - pResId = STR_COMCORE_CANT_SHOW; + OSL_ENSURE( !pOut->IsVirtual() || + pShell->GetViewOptions()->IsPDFExport() || pShell->isOutputToWindow(), + "pOut should not be a virtual device" ); - OUString aText; - if ( !pResId && - (aText = pGrfNd->GetTitle()).isEmpty() && - (!GetRealURL( *pGrfNd, aText ) || aText.isEmpty())) - { - pResId = STR_COMCORE_READERROR; - } - if (pResId) - aText = SwResId(pResId); + pGrfNd->StartGraphicAnimation(pOut, rAlignedGrfArea.Pos(), + rAlignedGrfArea.SSize(), reinterpret_cast<sal_IntPtr>(this), + pVout ); +} - ::lcl_PaintReplacement( rAlignedGrfArea, aText, *pShell, this, true ); +void SwNoTextFrame::ImplPaintPictureReplacement(const GraphicObject& rGrfObj, SwGrfNode* pGrfNd, + const SwRect& rAlignedGrfArea, SwViewShell* pShell) const +{ + TranslateId pResId; + + if( GraphicType::NONE == rGrfObj.GetType() ) + pResId = STR_COMCORE_READERROR; + else if ( !rGrfObj.GetGraphic().IsSupportedGraphic() ) + pResId = STR_COMCORE_CANT_SHOW; + + OUString aText; + if ( !pResId && + (aText = pGrfNd->GetTitle()).isEmpty() && + (!GetRealURL( *pGrfNd, aText ) || aText.isEmpty())) + { + pResId = STR_COMCORE_READERROR; } + if (pResId) + aText = SwResId(pResId); + + ::lcl_PaintReplacement( rAlignedGrfArea, aText, *pShell, this, true ); } void SwNoTextFrame::ImplPaintPictureBitmap( vcl::RenderContext* pOut, diff --git a/sw/source/core/inc/notxtfrm.hxx b/sw/source/core/inc/notxtfrm.hxx index 10c6ad070963..a3870c86150c 100644 --- a/sw/source/core/inc/notxtfrm.hxx +++ b/sw/source/core/inc/notxtfrm.hxx @@ -66,6 +66,10 @@ private: void ImplPaintPictureBitmap( vcl::RenderContext* pOut, SwOLENode* pOLENd, bool bIsChart, bool bPrn, const SwRect& rAlignedGrfArea, SwViewShell* pShell ) const; + void ImplPaintPictureAnimate(vcl::RenderContext* pOut, SwViewShell* pShell, + SwGrfNode* pGrfNd, const SwRect& rAlignedGrfArea) const; + void ImplPaintPictureReplacement(const GraphicObject& rGrfObj, SwGrfNode* pGrfNd, + const SwRect& rAlignedGrfArea, SwViewShell* pShell) const; public: SwNoTextFrame( SwNoTextNode * const, SwFrame* );