diff options
author | Oliver Specht <oliver.specht@cib.de> | 2024-08-15 14:17:05 +0200 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2024-12-02 07:36:20 +0100 |
commit | ef4452663d13d0d559356440e71e97a6c282b1ff (patch) | |
tree | c014328b0caeb13b242d0fa10783606c260e2bf3 /sw | |
parent | 55e86edcb37a37123a69ce3e1eb9e20758415fb6 (diff) |
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.extern@allotropia.de>
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/inc/viewimp.hxx | 19 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 59 | ||||
-rw-r--r-- | sw/source/core/view/viewimp.cxx | 24 | ||||
-rw-r--r-- | sw/source/core/view/viewsh.cxx | 3 |
4 files changed, 61 insertions, 44 deletions
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 8e2b97e7c045..e8188f77f7f5 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> @@ -3181,47 +3181,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 @@ -4135,6 +4094,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); @@ -4142,6 +4108,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 5b87730500dc..73ddbac03b84 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 124a7d940e15..2cf0e92b8192 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -256,7 +256,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; } } |