editeng/source/items/frmitems.cxx | 16 +++++++++++ include/editeng/brushitem.hxx | 2 + sw/source/core/doc/notxtfrm.cxx | 36 +++++++++++++++++++++++-- sw/source/core/layout/fly.cxx | 54 +++++++++++++++++++++----------------- sw/source/core/layout/flylay.cxx | 29 ++++++++++++++++++++ 5 files changed, 111 insertions(+), 26 deletions(-)
New commits: commit 09bbeba1df1f9951a0446d5806cba780d71a5c80 Author: Armin Le Grand <armin.le.gr...@cib.de> Date: Fri Nov 17 13:23:02 2017 +0100 RotateFlyFrame3: Enhancements to AutoContour Added several conditions for AutoContour, need to work on reaction on changes to these. Corrected needed transform adaptions to Countour(s) Change-Id: Ia3d7845fd5d50c8a413d592ae07ce2041ccc91b9 diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index c2bfc5e290fb..bb61ccaccc86 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -3157,6 +3157,22 @@ SvxBrushItem::~SvxBrushItem() { } +bool SvxBrushItem::isUsed() const +{ + if (GPOS_NONE != GetGraphicPos()) + { + // graphic used + return true; + } + else if (0xff != GetColor().GetTransparency()) + { + // color used + return true; + } + + return false; +} + sal_uInt16 SvxBrushItem::GetVersion( sal_uInt16 /*nFileVersion*/ ) const { return BRUSH_GRAPHIC_VERSION; diff --git a/include/editeng/brushitem.hxx b/include/editeng/brushitem.hxx index 516abdacd467..8aa177aa2adb 100644 --- a/include/editeng/brushitem.hxx +++ b/include/editeng/brushitem.hxx @@ -79,6 +79,8 @@ public: virtual ~SvxBrushItem() override; public: + // check if it's used + bool isUsed() const; virtual bool GetPresentation( SfxItemPresentation ePres, MapUnit eCoreMetric, diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 93103489af70..1ebb9aaf0944 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -1308,15 +1308,47 @@ void SwNoTextFrame::PaintPicture( vcl::RenderContext* pOut, const SwRect &rGrfAr bool SwNoTextFrame::IsTransparent() const { const SwViewShell* pSh = getRootFrame()->GetCurrShell(); + if ( !pSh || !pSh->GetViewOptions()->IsGraphic() ) + { return true; + } const SwGrfNode *pNd; + if( nullptr != (pNd = GetNode()->GetGrfNode()) ) - return pNd->IsTransparent(); + { + if(pNd->IsTransparent()) + { + return true; + } + } + + // RotateFlyFrame3: If we are transformed, there are 'free' areas between + // the Graphic and the Border/Padding stuff - at least as long as those + // (Border and Padding) are not transformed, too + if(isTransformableSwFrame()) + { + // we can be more specific - rotations of multiples of + // 90 degrees will leave no gaps. Go from [0.0 .. F_2PI] + // to [0 .. 360] and check modulo 90 + const long nRot(static_cast<long>(getLocalFrameRotation() / F_PI180)); + const bool bMultipleOf90(0 == (nRot % 90)); + + if(!bMultipleOf90) + { + return true; + } + } //#29381# OLE are always transparent - return true; + if(nullptr != GetNode()->GetOLENode()) + { + return true; + } + + // return false by default to avoid background paint + return false; } void SwNoTextFrame::StopAnimation( OutputDevice* pOut ) const diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 4e7639411062..569a0ec86282 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -2447,6 +2447,8 @@ bool SwFlyFrame::GetContour( tools::PolyPolygon& rContour, if(bIsCandidate) { + const SwFlyFreeFrame* pSwFlyFreeFrame(static_cast< const SwFlyFreeFrame* >(this)); + if(GetFormat()->GetSurround().IsContour()) { SwNoTextNode *pNd = const_cast<SwNoTextNode*>(static_cast<const SwNoTextNode*>(static_cast<const SwContentFrame*>(Lower())->GetNode())); @@ -2541,38 +2543,42 @@ bool SwFlyFrame::GetContour( tools::PolyPolygon& rContour, } else { - const SwFlyFreeFrame* pSwFlyFreeFrame(static_cast< const SwFlyFreeFrame* >(this)); - - if(nullptr != pSwFlyFreeFrame && pSwFlyFreeFrame->supportsAutoContour()) + if(nullptr != pSwFlyFreeFrame && + pSwFlyFreeFrame->supportsAutoContour() && + // isTransformableSwFrame already used in supportsAutoContour(), but + // better check twice when it may get changed there... + pSwFlyFreeFrame->isTransformableSwFrame()) { // RotateFlyFrame: use untransformed SwFrame to allow text floating around. // Will be transformed below const TransformableSwFrame* pTransformableSwFrame(pSwFlyFreeFrame->getTransformableSwFrame()); const SwRect aFrameArea(pTransformableSwFrame->getUntransformedFrameArea()); rContour = tools::PolyPolygon(tools::Polygon(aFrameArea.SVRect())); + bRet = (0 != rContour.Count()); + } + } - if(0 != rContour.Count()) - { - // Need to adapt contour to transformation - basegfx::B2DVector aScale, aTranslate; - double fRotate, fShearX; - getFrameAreaTransformation().decompose(aScale, aTranslate, fRotate, fShearX); - - if(!basegfx::fTools::equalZero(fRotate)) - { - basegfx::B2DPolyPolygon aSource(rContour.getB2DPolyPolygon()); - const basegfx::B2DPoint aCenter(getFrameAreaTransformation() * basegfx::B2DPoint(0.5, 0.5)); - const basegfx::B2DHomMatrix aRotateAroundCenter( - basegfx::utils::createRotateAroundPoint( - aCenter.getX(), - aCenter.getY(), - fRotate)); - aSource.transform(aRotateAroundCenter); - rContour = tools::PolyPolygon(aSource); - } + if(bRet && + 0 != rContour.Count() && + nullptr != pSwFlyFreeFrame && + pSwFlyFreeFrame->isTransformableSwFrame()) + { + // Need to adapt contour to transformation + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + getFrameAreaTransformation().decompose(aScale, aTranslate, fRotate, fShearX); - bRet = true; - } + if(!basegfx::fTools::equalZero(fRotate)) + { + basegfx::B2DPolyPolygon aSource(rContour.getB2DPolyPolygon()); + const basegfx::B2DPoint aCenter(getFrameAreaTransformation() * basegfx::B2DPoint(0.5, 0.5)); + const basegfx::B2DHomMatrix aRotateAroundCenter( + basegfx::utils::createRotateAroundPoint( + aCenter.getX(), + aCenter.getY(), + fRotate)); + aSource.transform(aRotateAroundCenter); + rContour = tools::PolyPolygon(aSource); } } } diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx index c3cf51baa343..8f6452b9b874 100644 --- a/sw/source/core/layout/flylay.cxx +++ b/sw/source/core/layout/flylay.cxx @@ -43,6 +43,7 @@ #include <IDocumentSettingAccess.hxx> #include <IDocumentDrawModelAccess.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <svx/sdr/attribute/sdrallfillattributeshelper.hxx> using namespace ::com::sun::star; @@ -316,10 +317,38 @@ bool SwFlyFreeFrame::supportsAutoContour() const // Check for Padding. Do not support when padding is used, this will // produce a covered space around the object (filled with fill defines) + const SfxPoolItem* pItem(nullptr); + if(GetFormat() && SfxItemState::SET == GetFormat()->GetItemState(RES_BOX, false, &pItem)) + { + const SvxBoxItem& rBox = *static_cast< const SvxBoxItem* >(pItem); + if(rBox.HasBorder(/*bTreatPaddingAsBorder*/true)) + { + return false; + } + } + // check for Fill - if we have fill, it will fill the gaps and we will not + // support AutoContour + if(GetFormat() && GetFormat()->supportsFullDrawingLayerFillAttributeSet()) + { + const drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFillAttributes(GetFormat()->getSdrAllFillAttributesHelper()); + + if(aFillAttributes.get() && aFillAttributes->isUsed()) + { + return false; + } + } + else + { + const SvxBrushItem aBack(GetFormat()->makeBackgroundBrushItem()); + if(aBack.isUsed()) + { + return false; + } + } // else, support return true; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits