include/svx/fmview.hxx | 3 + include/svx/svdpntv.hxx | 9 +++-- svx/source/form/fmview.cxx | 5 +-- svx/source/svdraw/svdpntv.cxx | 16 ++++++---- sw/source/core/inc/viewimp.hxx | 19 +++++++++++ sw/source/core/layout/paintfrm.cxx | 59 ++++++++++--------------------------- sw/source/core/view/viewimp.cxx | 24 +++++++++++++++ sw/source/core/view/viewsh.cxx | 3 + 8 files changed, 82 insertions(+), 56 deletions(-)
New commits: commit f367783ed89739cfbd6d55103638e40134f429e2 Author: Oliver Specht <oliver.spe...@cib.de> AuthorDate: Thu Aug 15 14:17:05 2024 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Mon Dec 2 13:19:39 2024 +0100 tdf#161341 show/hide controls/shapes/pictures in view/print Controls/shapes and images/objects have a display option in tools/options/ Writer/View and in print dialog there is "Form controls" and "Images and other graphic objects". With this change the options will actually be applied again. Change-Id: I52389a8519d863792a7cd126a95a389c90c05a5e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171905 Tested-by: Jenkins Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177649 Tested-by: allotropia jenkins <jenk...@allotropia.de> diff --git a/include/svx/fmview.hxx b/include/svx/fmview.hxx index e601047eff00..0dfc5628b810 100644 --- a/include/svx/fmview.hxx +++ b/include/svx/fmview.hxx @@ -140,7 +140,8 @@ public: void RemoveControlContainer(const css::uno::Reference< css::awt::XControlContainer >& xCC); virtual SdrPaintWindow* BeginCompleteRedraw(OutputDevice* pOut) override; - virtual void EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer) override; + virtual void EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer, + sdr::contact::ViewObjectContactRedirector* pRedirector = nullptr) override; SVX_DLLPRIVATE const OutputDevice* GetActualOutDev() const {return mpActualOutDev;} SVX_DLLPRIVATE bool checkUnMarkAll(const css::uno::Reference< css::uno::XInterface >& _xSource); diff --git a/include/svx/svdpntv.hxx b/include/svx/svdpntv.hxx index 8665262f0508..c3c866fbeeb9 100644 --- a/include/svx/svdpntv.hxx +++ b/include/svx/svdpntv.hxx @@ -354,7 +354,8 @@ public: // This means: the SdrPaintWindow is no longer safe after this closing call. virtual SdrPaintWindow* BeginCompleteRedraw(OutputDevice* pOut); void DoCompleteRedraw(SdrPaintWindow& rPaintWindow, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector = nullptr); - virtual void EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer); + virtual void EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer, + sdr::contact::ViewObjectContactRedirector* pRedirector = nullptr); // Used for the other applications basctl/sc/sw which call DrawLayer at PageViews @@ -364,12 +365,14 @@ public: // Used when the region passed to BeginDrawLayers needs to be changed void UpdateDrawLayersRegion(const OutputDevice* pOut, const vcl::Region& rReg); - void EndDrawLayers(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer); + void EndDrawLayers(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer, + sdr::contact::ViewObjectContactRedirector* pRedirector = nullptr); protected: // Used to paint the form layer after the PreRender device is flushed (painted) to the window. - void ImpFormLayerDrawing( SdrPaintWindow& rPaintWindow ); + void ImpFormLayerDrawing( SdrPaintWindow& rPaintWindow, + sdr::contact::ViewObjectContactRedirector* pRedirector = nullptr ); static vcl::Region OptimizeDrawLayersRegion(const OutputDevice* pOut, const vcl::Region& rReg, bool bDisableIntersect); diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx index a26895653833..3f878a3fed05 100644 --- a/svx/source/form/fmview.cxx +++ b/svx/source/form/fmview.cxx @@ -437,9 +437,10 @@ SdrPaintWindow* FmFormView::BeginCompleteRedraw(OutputDevice* pOut) } -void FmFormView::EndCompleteRedraw( SdrPaintWindow& rPaintWindow, bool bPaintFormLayer ) +void FmFormView::EndCompleteRedraw( SdrPaintWindow& rPaintWindow, bool bPaintFormLayer, + sdr::contact::ViewObjectContactRedirector* pRedirector ) { - E3dView::EndCompleteRedraw( rPaintWindow, bPaintFormLayer ); + E3dView::EndCompleteRedraw( rPaintWindow, bPaintFormLayer, pRedirector ); m_pImpl->resumeTabOrderUpdate(); } diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index ea8af4045878..058f26d60e4e 100644 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -606,7 +606,8 @@ void SdrPaintView::DoCompleteRedraw(SdrPaintWindow& rPaintWindow, const vcl::Reg } } -void SdrPaintView::EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer) +void SdrPaintView::EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer, + sdr::contact::ViewObjectContactRedirector* pRedirector) { std::unique_ptr<SdrPaintWindow> pPaintWindow; if (comphelper::LibreOfficeKit::isActive() && rPaintWindow.getTemporaryTarget()) @@ -628,7 +629,7 @@ void SdrPaintView::EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFo // In the LOK case control rendering is performed through LokControlHandler if(!comphelper::LibreOfficeKit::isActive() && bPaintFormLayer) { - ImpFormLayerDrawing(rPaintWindow); + ImpFormLayerDrawing(rPaintWindow, pRedirector); } // look for active TextEdit. As long as this cannot be painted to a VDev, @@ -697,10 +698,11 @@ SdrPaintWindow* SdrPaintView::BeginDrawLayers(OutputDevice* pOut, const vcl::Reg return pPaintWindow; } -void SdrPaintView::EndDrawLayers(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer) +void SdrPaintView::EndDrawLayers(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer, + sdr::contact::ViewObjectContactRedirector* pRedirector) { // #i74769# use EndCompleteRedraw() as common base - EndCompleteRedraw(rPaintWindow, bPaintFormLayer); + EndCompleteRedraw(rPaintWindow, bPaintFormLayer, pRedirector); if(mpPageView) { @@ -755,7 +757,8 @@ vcl::Region SdrPaintView::OptimizeDrawLayersRegion(const OutputDevice* pOut, con } -void SdrPaintView::ImpFormLayerDrawing( SdrPaintWindow& rPaintWindow ) +void SdrPaintView::ImpFormLayerDrawing( SdrPaintWindow& rPaintWindow, + sdr::contact::ViewObjectContactRedirector* pRedirector ) { if(!mpPageView) return; @@ -771,7 +774,8 @@ void SdrPaintView::ImpFormLayerDrawing( SdrPaintWindow& rPaintWindow ) // BUFFERED use GetTargetOutputDevice() now, it may be targeted to VDevs, too // need to set PreparedPageWindow to make DrawLayer use the correct ObjectContact mpPageView->setPreparedPageWindow(pKnownTarget); - mpPageView->DrawLayer(nControlLayerId, &rPaintWindow.GetTargetOutputDevice()); + mpPageView->DrawLayer(nControlLayerId, &rPaintWindow.GetTargetOutputDevice(), + pRedirector); mpPageView->setPreparedPageWindow(nullptr); } } diff --git a/sw/source/core/inc/viewimp.hxx b/sw/source/core/inc/viewimp.hxx index 1c30fe6b9ad9..b3bae4b0000a 100644 --- a/sw/source/core/inc/viewimp.hxx +++ b/sw/source/core/inc/viewimp.hxx @@ -21,6 +21,7 @@ #include <tools/color.hxx> #include <svx/svdtypes.hxx> +#include <svx/sdr/contact/viewobjectcontactredirector.hxx> #include <swrect.hxx> #include <swregion.hxx> #include <memory> @@ -45,8 +46,24 @@ class SwPagePreviewLayout; struct PreviewPage; class SwTextFrame; // --> OD #i76669# -namespace sdr::contact { class ViewObjectContactRedirector; } +//namespace sdr::contact { class ViewObjectContactRedirector; } // <-- +class SwViewObjectContactRedirector : public sdr::contact::ViewObjectContactRedirector +{ + private: + const SwViewShell& mrViewShell; + + public: + explicit SwViewObjectContactRedirector( const SwViewShell& rSh ) + : mrViewShell( rSh ) + {}; + + virtual void createRedirectedPrimitive2DSequence( + const sdr::contact::ViewObjectContact& rOriginal, + const sdr::contact::DisplayInfo& rDisplayInfo, + drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) override; +}; + class SwViewShellImp { diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index abe0a0c41ba6..a041b413ba16 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -29,6 +29,7 @@ #include <editeng/shaditem.hxx> #include <svx/ctredlin.hxx> #include <svx/framelink.hxx> +#include <svx/svdouno.hxx> #include <drawdoc.hxx> #include <tgrditem.hxx> #include <calbck.hxx> @@ -73,7 +74,6 @@ #include <swfont.hxx> #include <svx/sdr/primitive2d/sdrframeborderprimitive2d.hxx> -#include <svx/sdr/contact/viewobjectcontactredirector.hxx> #include <svx/sdr/contact/viewobjectcontact.hxx> #include <svx/sdr/contact/viewcontact.hxx> #include <DocumentSettingManager.hxx> @@ -3217,47 +3217,6 @@ void SwTabFramePainter::Insert( SwLineEntry& rNew, bool bHori ) pLineSet->insert( rNew ); } -/** - * FUNCTIONS USED FOR COLLAPSING TABLE BORDER LINES END - * --> OD #i76669# - */ -namespace -{ - class SwViewObjectContactRedirector : public sdr::contact::ViewObjectContactRedirector - { - private: - const SwViewShell& mrViewShell; - - public: - explicit SwViewObjectContactRedirector( const SwViewShell& rSh ) - : mrViewShell( rSh ) - {}; - - virtual void createRedirectedPrimitive2DSequence( - const sdr::contact::ViewObjectContact& rOriginal, - const sdr::contact::DisplayInfo& rDisplayInfo, - drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) override - { - bool bPaint( true ); - - SdrObject* pObj = rOriginal.GetViewContact().TryToGetSdrObject(); - if ( pObj ) - { - bPaint = SwFlyFrame::IsPaint( pObj, &mrViewShell ); - } - - if ( !bPaint ) - { - return; - } - - sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence( - rOriginal, rDisplayInfo, rVisitor ); - } - }; - -} // end of anonymous namespace -// <-- /** * Paint once for every visible page which is touched by Rect @@ -4170,6 +4129,13 @@ bool SwFlyFrame::IsBackgroundTransparent() const return bBackgroundTransparent; }; +static void lcl_PaintReplacement( const SwRect &rRect, const SwViewShell &rSh ) +{ + const BitmapEx& rBmp = const_cast<SwViewShell&>(rSh).GetReplacementBitmap(false); + vcl::Font aFont(rSh.GetOut()->GetFont() ); + Graphic::DrawEx(*rSh.GetOut(), OUString(), aFont, rBmp, rRect.Pos(), rRect.SSize()); +} + bool SwFlyFrame::IsPaint( SdrObject *pObj, const SwViewShell *pSh ) { SdrObjUserCall *pUserCall = GetUserCall(pObj); @@ -4177,6 +4143,15 @@ bool SwFlyFrame::IsPaint( SdrObject *pObj, const SwViewShell *pSh ) if ( nullptr == pUserCall ) return true; + if ( pSh && ((!pSh->GetViewOptions()->IsDraw() + && (dynamic_cast<SdrUnoObj*>(pObj) || dynamic_cast<SdrAttrObj*>(pObj) || dynamic_cast<SwFlyDrawObj*>(pObj))) + || (!pSh->GetViewOptions()->IsGraphic() && dynamic_cast<SwVirtFlyDrawObj*>(pObj)) ) + ) + { + SwRect rBoundRect = GetBoundRectOfAnchoredObj( pObj ); + lcl_PaintReplacement( rBoundRect, *pSh ); + return false; + } assert(pObj); //Attribute dependent, don't paint for printer or Preview diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx index 3f427ed77316..ee9f8028c7a1 100644 --- a/sw/source/core/view/viewimp.cxx +++ b/sw/source/core/view/viewimp.cxx @@ -38,6 +38,8 @@ #include <drawdoc.hxx> #include <prevwpage.hxx> #include <sfx2/viewsh.hxx> +#include <svx/sdr/contact/viewobjectcontact.hxx> +#include <svx/sdr/contact/viewcontact.hxx> void SwViewShellImp::Init( const SwViewOption *pNewOpt ) { @@ -525,4 +527,26 @@ void SwViewShellImp::FireAccessibleEvents() } #endif // ENABLE_WASM_STRIP_ACCESSIBILITY +void SwViewObjectContactRedirector::createRedirectedPrimitive2DSequence( + const sdr::contact::ViewObjectContact& rOriginal, + const sdr::contact::DisplayInfo& rDisplayInfo, + drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) +{ + bool bPaint( true ); + + SdrObject* pObj = rOriginal.GetViewContact().TryToGetSdrObject(); + if ( pObj ) + { + bPaint = SwFlyFrame::IsPaint( pObj, &mrViewShell ); + } + + if ( !bPaint ) + { + return; + } + + sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence( + rOriginal, rDisplayInfo, rVisitor ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index c4d9a551807c..ec1242781921 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -251,7 +251,8 @@ void SwViewShell::DLPostPaint2(bool bPaintFormLayer) } // #i74769# use SdrPaintWindow now direct - Imp()->GetDrawView()->EndDrawLayers(*mpTargetPaintWindow, bPaintFormLayer); + SwViewObjectContactRedirector aSwRedirector(*this); + Imp()->GetDrawView()->EndDrawLayers(*mpTargetPaintWindow, bPaintFormLayer, &aSwRedirector); mpTargetPaintWindow = nullptr; } }