From bfc298d02ca6275588d5897d97ced9498a3e91aa Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 6 Aug 2020 12:47:09 +0200 Subject: loplugin:flatten in svx/svdraw Change-Id: I8379e5ebaee2090d2b4dbd05d55b55000915cd7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100233 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svx/source/svdraw/charthelper.cxx | 36 +- svx/source/svdraw/clonelist.cxx | 22 +- svx/source/svdraw/sdrpagewindow.cxx | 22 +- svx/source/svdraw/svdcrtv.cxx | 251 +++---- svx/source/svdraw/svddrgmt.cxx | 964 ++++++++++++------------ svx/source/svdraw/svddrgv.cxx | 164 ++-- svx/source/svdraw/svdedtv.cxx | 432 +++++------ svx/source/svdraw/svdedtv1.cxx | 92 +-- svx/source/svdraw/svdedtv2.cxx | 982 ++++++++++++------------ svx/source/svdraw/svdedxv.cxx | 737 +++++++++--------- svx/source/svdraw/svdfmtf.cxx | 538 +++++++------- svx/source/svdraw/svdglev.cxx | 29 +- svx/source/svdraw/svdglue.cxx | 28 +- svx/source/svdraw/svdhdl.cxx | 1071 +++++++++++++-------------- svx/source/svdraw/svdlayer.cxx | 28 +- svx/source/svdraw/svdmark.cxx | 204 ++--- svx/source/svdraw/svdmodel.cxx | 116 +-- svx/source/svdraw/svdmrkv.cxx | 202 ++--- svx/source/svdraw/svdoashp.cxx | 590 +++++++-------- svx/source/svdraw/svdobj.cxx | 277 +++---- svx/source/svdraw/svdocirc.cxx | 94 +-- svx/source/svdraw/svdoedge.cxx | 141 ++-- svx/source/svdraw/svdograf.cxx | 62 +- svx/source/svdraw/svdogrp.cxx | 134 ++-- svx/source/svdraw/svdomeas.cxx | 82 +- svx/source/svdraw/svdomedia.cxx | 62 +- svx/source/svdraw/svdoole2.cxx | 620 ++++++++-------- svx/source/svdraw/svdopage.cxx | 26 +- svx/source/svdraw/svdopath.cxx | 34 +- svx/source/svdraw/svdorect.cxx | 30 +- svx/source/svdraw/svdotext.cxx | 94 +-- svx/source/svdraw/svdotextdecomposition.cxx | 182 ++--- svx/source/svdraw/svdotxat.cxx | 116 +-- svx/source/svdraw/svdouno.cxx | 26 +- svx/source/svdraw/svdoutlinercache.cxx | 46 +- svx/source/svdraw/svdpage.cxx | 134 ++-- svx/source/svdraw/svdpagv.cxx | 258 +++---- svx/source/svdraw/svdpdf.cxx | 168 ++--- svx/source/svdraw/svdpntv.cxx | 76 +- svx/source/svdraw/svdpoev.cxx | 306 ++++---- svx/source/svdraw/svdsnpv.cxx | 72 +- svx/source/svdraw/svdtext.cxx | 54 +- svx/source/svdraw/svdundo.cxx | 156 ++-- svx/source/svdraw/svdview.cxx | 36 +- 44 files changed, 4900 insertions(+), 4894 deletions(-) (limited to 'svx') diff --git a/svx/source/svdraw/charthelper.cxx b/svx/source/svdraw/charthelper.cxx index 0c54a986a142..857eafa6f59c 100644 --- a/svx/source/svdraw/charthelper.cxx +++ b/svx/source/svdraw/charthelper.cxx @@ -112,28 +112,28 @@ drawinglayer::primitive2d::Primitive2DContainer ChartHelper::tryToGetChartConten void ChartHelper::AdaptDefaultsForChart( const uno::Reference < embed::XEmbeddedObject > & xEmbObj) { - if( xEmbObj.is()) - { - uno::Reference< chart2::XChartDocument > xChartDoc( xEmbObj->getComponent(), uno::UNO_QUERY ); - OSL_ENSURE( xChartDoc.is(), "Trying to set chart property to non-chart OLE" ); - if( !xChartDoc.is()) - return; + if( !xEmbObj.is()) + return; - try - { - if (uno::Reference< beans::XPropertySet > xPageProp = xChartDoc->getPageBackground()) - { - // set background to transparent (none) - xPageProp->setPropertyValue("FillStyle", uno::makeAny(drawing::FillStyle_NONE)); - // set no border - xPageProp->setPropertyValue("LineStyle", uno::makeAny(drawing::LineStyle_NONE)); - } - } - catch( const uno::Exception & ) + uno::Reference< chart2::XChartDocument > xChartDoc( xEmbObj->getComponent(), uno::UNO_QUERY ); + OSL_ENSURE( xChartDoc.is(), "Trying to set chart property to non-chart OLE" ); + if( !xChartDoc.is()) + return; + + try + { + if (uno::Reference< beans::XPropertySet > xPageProp = xChartDoc->getPageBackground()) { - OSL_FAIL( "Exception caught in AdaptDefaultsForChart" ); + // set background to transparent (none) + xPageProp->setPropertyValue("FillStyle", uno::makeAny(drawing::FillStyle_NONE)); + // set no border + xPageProp->setPropertyValue("LineStyle", uno::makeAny(drawing::LineStyle_NONE)); } } + catch( const uno::Exception & ) + { + OSL_FAIL( "Exception caught in AdaptDefaultsForChart" ); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/svdraw/clonelist.cxx b/svx/source/svdraw/clonelist.cxx index 22eabf103513..12f395ac1d4b 100644 --- a/svx/source/svdraw/clonelist.cxx +++ b/svx/source/svdraw/clonelist.cxx @@ -40,19 +40,19 @@ void CloneList::AddPair(const SdrObject* pOriginal, SdrObject* pClone) if(bCloneIsGroup && dynamic_cast(pClone) != nullptr && dynamic_cast(pClone) == nullptr) bCloneIsGroup = false; - if(bOriginalIsGroup && bCloneIsGroup) - { - const SdrObjList* pOriginalList = pOriginal->GetSubList(); - SdrObjList* pCloneList = pClone->GetSubList(); + if(!(bOriginalIsGroup && bCloneIsGroup)) + return; + + const SdrObjList* pOriginalList = pOriginal->GetSubList(); + SdrObjList* pCloneList = pClone->GetSubList(); - if(pOriginalList && pCloneList - && pOriginalList->GetObjCount() == pCloneList->GetObjCount()) + if(pOriginalList && pCloneList + && pOriginalList->GetObjCount() == pCloneList->GetObjCount()) + { + for(size_t a = 0; a < pOriginalList->GetObjCount(); ++a) { - for(size_t a = 0; a < pOriginalList->GetObjCount(); ++a) - { - // recursive call - AddPair(pOriginalList->GetObj(a), pCloneList->GetObj(a)); - } + // recursive call + AddPair(pOriginalList->GetObj(a), pCloneList->GetObj(a)); } } } diff --git a/svx/source/svdraw/sdrpagewindow.cxx b/svx/source/svdraw/sdrpagewindow.cxx index fb3155c0eb14..823205a22e65 100644 --- a/svx/source/svdraw/sdrpagewindow.cxx +++ b/svx/source/svdraw/sdrpagewindow.cxx @@ -127,19 +127,19 @@ SdrPageWindow::~SdrPageWindow() // #i26631# ResetObjectContact(); - if (mpImpl->mxControlContainer.is()) - { - auto & rView = static_cast(GetPageView().GetView()); + if (!mpImpl->mxControlContainer.is()) + return; - // notify derived views - FmFormView* pViewAsFormView = dynamic_cast< FmFormView* >( &rView ); - if ( pViewAsFormView ) - pViewAsFormView->RemoveControlContainer(mpImpl->mxControlContainer); + auto & rView = static_cast(GetPageView().GetView()); - // dispose the control container - uno::Reference< lang::XComponent > xComponent(mpImpl->mxControlContainer, uno::UNO_QUERY); - xComponent->dispose(); - } + // notify derived views + FmFormView* pViewAsFormView = dynamic_cast< FmFormView* >( &rView ); + if ( pViewAsFormView ) + pViewAsFormView->RemoveControlContainer(mpImpl->mxControlContainer); + + // dispose the control container + uno::Reference< lang::XComponent > xComponent(mpImpl->mxControlContainer, uno::UNO_QUERY); + xComponent->dispose(); } SdrPageView& SdrPageWindow::GetPageView() const diff --git a/svx/source/svdraw/svdcrtv.cxx b/svx/source/svdraw/svdcrtv.cxx index 3f36c0e8c5c0..7cb50a08f685 100644 --- a/svx/source/svdraw/svdcrtv.cxx +++ b/svx/source/svdraw/svdcrtv.cxx @@ -528,45 +528,46 @@ bool SdrCreateView::BegCreateCaptionObj(const Point& rPnt, const Size& rObjSiz, void SdrCreateView::MovCreateObj(const Point& rPnt) { - if (pCurrentCreate!=nullptr) { - Point aPnt(rPnt); - if (!maDragStat.IsNoSnap()) - { - aPnt=GetSnapPos(aPnt,pCreatePV); - } - if (IsOrtho()) - { - if (maDragStat.IsOrtho8Possible()) OrthoDistance8(maDragStat.GetPrev(),aPnt,IsBigOrtho()); - else if (maDragStat.IsOrtho4Possible()) OrthoDistance4(maDragStat.GetPrev(),aPnt,IsBigOrtho()); - } + if (pCurrentCreate==nullptr) + return; - // If the drag point was limited and Ortho is active, do - // the small ortho correction (reduction) -> last parameter to FALSE. - bool bDidLimit(ImpLimitToWorkArea(aPnt)); - if(bDidLimit && IsOrtho()) - { - if(maDragStat.IsOrtho8Possible()) - OrthoDistance8(maDragStat.GetPrev(), aPnt, false); - else if(maDragStat.IsOrtho4Possible()) - OrthoDistance4(maDragStat.GetPrev(), aPnt, false); - } + Point aPnt(rPnt); + if (!maDragStat.IsNoSnap()) + { + aPnt=GetSnapPos(aPnt,pCreatePV); + } + if (IsOrtho()) + { + if (maDragStat.IsOrtho8Possible()) OrthoDistance8(maDragStat.GetPrev(),aPnt,IsBigOrtho()); + else if (maDragStat.IsOrtho4Possible()) OrthoDistance4(maDragStat.GetPrev(),aPnt,IsBigOrtho()); + } - if (aPnt==maDragStat.GetNow()) return; - bool bIsMinMoved(maDragStat.IsMinMoved()); - if (maDragStat.CheckMinMoved(aPnt)) - { - if (!bIsMinMoved) maDragStat.NextPoint(); - maDragStat.NextMove(aPnt); - pCurrentCreate->MovCreate(maDragStat); + // If the drag point was limited and Ortho is active, do + // the small ortho correction (reduction) -> last parameter to FALSE. + bool bDidLimit(ImpLimitToWorkArea(aPnt)); + if(bDidLimit && IsOrtho()) + { + if(maDragStat.IsOrtho8Possible()) + OrthoDistance8(maDragStat.GetPrev(), aPnt, false); + else if(maDragStat.IsOrtho4Possible()) + OrthoDistance4(maDragStat.GetPrev(), aPnt, false); + } - // MovCreate changes the object, so use ActionChanged() on it - pCurrentCreate->ActionChanged(); + if (aPnt==maDragStat.GetNow()) return; + bool bIsMinMoved(maDragStat.IsMinMoved()); + if (!maDragStat.CheckMinMoved(aPnt)) + return; - // replace for DrawCreateObjDiff - HideCreateObj(); - ShowCreateObj(); - } - } + if (!bIsMinMoved) maDragStat.NextPoint(); + maDragStat.NextMove(aPnt); + pCurrentCreate->MovCreate(maDragStat); + + // MovCreate changes the object, so use ActionChanged() on it + pCurrentCreate->ActionChanged(); + + // replace for DrawCreateObjDiff + HideCreateObj(); + ShowCreateObj(); } void SdrCreateView::SetupObjLayer(const SdrPageView* pPageView, const OUString& aActiveLayer, SdrObject* pObj) @@ -705,24 +706,24 @@ bool SdrCreateView::EndCreateObj(SdrCreateCmd eCmd) void SdrCreateView::BckCreateObj() { - if (pCurrentCreate!=nullptr) + if (pCurrentCreate==nullptr) + return; + + if (maDragStat.GetPointCount()<=2 ) + { + BrkCreateObj(); + } + else { - if (maDragStat.GetPointCount()<=2 ) + HideCreateObj(); + maDragStat.PrevPoint(); + if (pCurrentCreate->BckCreate(maDragStat)) { - BrkCreateObj(); + ShowCreateObj(); } else { - HideCreateObj(); - maDragStat.PrevPoint(); - if (pCurrentCreate->BckCreate(maDragStat)) - { - ShowCreateObj(); - } - else - { - BrkCreateObj(); - } + BrkCreateObj(); } } } @@ -741,117 +742,117 @@ void SdrCreateView::BrkCreateObj() void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, sal_Bool bFull*/) { - if(IsCreateObj() && !maDragStat.IsShown()) + if(!(IsCreateObj() && !maDragStat.IsShown())) + return; + + if(pCurrentCreate) { - if(pCurrentCreate) + // for migration from XOR, replace DrawDragObj here to create + // overlay objects instead. + bool bUseSolidDragging(IsSolidDragging()); + + // #i101648# check if dragged object is a naked SdrObject (not + // a derivation). This is e.g. used in SW Frame construction + // as placeholder. Do not use SolidDragging for naked SdrObjects, + // they cannot have a valid optical representation + if(bUseSolidDragging && OBJ_NONE == pCurrentCreate->GetObjIdentifier()) { - // for migration from XOR, replace DrawDragObj here to create - // overlay objects instead. - bool bUseSolidDragging(IsSolidDragging()); - - // #i101648# check if dragged object is a naked SdrObject (not - // a derivation). This is e.g. used in SW Frame construction - // as placeholder. Do not use SolidDragging for naked SdrObjects, - // they cannot have a valid optical representation - if(bUseSolidDragging && OBJ_NONE == pCurrentCreate->GetObjIdentifier()) + bUseSolidDragging = false; + } + + // check for objects with no fill and no line + if(bUseSolidDragging) + { + const SfxItemSet& rSet = pCurrentCreate->GetMergedItemSet(); + const drawing::FillStyle eFill(rSet.Get(XATTR_FILLSTYLE).GetValue()); + const drawing::LineStyle eLine(rSet.Get(XATTR_LINESTYLE).GetValue()); + + if(drawing::LineStyle_NONE == eLine && drawing::FillStyle_NONE == eFill) { bUseSolidDragging = false; } + } - // check for objects with no fill and no line - if(bUseSolidDragging) + // check for form controls + if(bUseSolidDragging) + { + if(dynamic_cast( pCurrentCreate) != nullptr) { - const SfxItemSet& rSet = pCurrentCreate->GetMergedItemSet(); - const drawing::FillStyle eFill(rSet.Get(XATTR_FILLSTYLE).GetValue()); - const drawing::LineStyle eLine(rSet.Get(XATTR_LINESTYLE).GetValue()); - - if(drawing::LineStyle_NONE == eLine && drawing::FillStyle_NONE == eFill) - { - bUseSolidDragging = false; - } + bUseSolidDragging = false; } + } + + // #i101781# force to non-solid dragging when not creating a full circle + if(bUseSolidDragging) + { + SdrCircObj* pCircObj = dynamic_cast< SdrCircObj* >(pCurrentCreate); - // check for form controls - if(bUseSolidDragging) + if(pCircObj && OBJ_CIRC != pCircObj->GetObjIdentifier()) { - if(dynamic_cast( pCurrentCreate) != nullptr) + // #i103058# Allow SolidDragging with four points + if(maDragStat.GetPointCount() < 4) { bUseSolidDragging = false; } } + } + + if(bUseSolidDragging) + { + basegfx::B2DPolyPolygon aDragPolyPolygon; - // #i101781# force to non-solid dragging when not creating a full circle - if(bUseSolidDragging) + if(dynamic_cast( pCurrentCreate) != nullptr) { - SdrCircObj* pCircObj = dynamic_cast< SdrCircObj* >(pCurrentCreate); + // ensure object has some size, necessary for SdrTextObj because + // there are still untested divisions by that sizes + tools::Rectangle aCurrentSnapRect(pCurrentCreate->GetSnapRect()); - if(pCircObj && OBJ_CIRC != pCircObj->GetObjIdentifier()) + if(aCurrentSnapRect.GetWidth() <= 1 || aCurrentSnapRect.GetHeight() <= 1) { - // #i103058# Allow SolidDragging with four points - if(maDragStat.GetPointCount() < 4) - { - bUseSolidDragging = false; - } + tools::Rectangle aNewRect(maDragStat.GetStart(), maDragStat.GetStart() + Point(2, 2)); + pCurrentCreate->NbcSetSnapRect(aNewRect); } } - if(bUseSolidDragging) + if(dynamic_cast( pCurrentCreate) != nullptr) { - basegfx::B2DPolyPolygon aDragPolyPolygon; + // The up-to-now created path needs to be set at the object to have something + // that can be visualized + SdrPathObj& rPathObj(static_cast(*pCurrentCreate)); + const basegfx::B2DPolyPolygon aCurrentPolyPolygon(rPathObj.getObjectPolyPolygon(maDragStat)); - if(dynamic_cast( pCurrentCreate) != nullptr) + if(aCurrentPolyPolygon.count()) { - // ensure object has some size, necessary for SdrTextObj because - // there are still untested divisions by that sizes - tools::Rectangle aCurrentSnapRect(pCurrentCreate->GetSnapRect()); - - if(aCurrentSnapRect.GetWidth() <= 1 || aCurrentSnapRect.GetHeight() <= 1) - { - tools::Rectangle aNewRect(maDragStat.GetStart(), maDragStat.GetStart() + Point(2, 2)); - pCurrentCreate->NbcSetSnapRect(aNewRect); - } + rPathObj.NbcSetPathPoly(aCurrentPolyPolygon); } - if(dynamic_cast( pCurrentCreate) != nullptr) - { - // The up-to-now created path needs to be set at the object to have something - // that can be visualized - SdrPathObj& rPathObj(static_cast(*pCurrentCreate)); - const basegfx::B2DPolyPolygon aCurrentPolyPolygon(rPathObj.getObjectPolyPolygon(maDragStat)); - - if(aCurrentPolyPolygon.count()) - { - rPathObj.NbcSetPathPoly(aCurrentPolyPolygon); - } + aDragPolyPolygon = rPathObj.getDragPolyPolygon(maDragStat); + } - aDragPolyPolygon = rPathObj.getDragPolyPolygon(maDragStat); - } + // use the SdrObject directly for overlay + mpCreateViewExtraData->CreateAndShowOverlay(*this, pCurrentCreate, aDragPolyPolygon); + } + else + { + const ::basegfx::B2DPolyPolygon aPoly(pCurrentCreate->TakeCreatePoly(maDragStat)); - // use the SdrObject directly for overlay - mpCreateViewExtraData->CreateAndShowOverlay(*this, pCurrentCreate, aDragPolyPolygon); - } - else - { - const ::basegfx::B2DPolyPolygon aPoly(pCurrentCreate->TakeCreatePoly(maDragStat)); + mpCreateViewExtraData->CreateAndShowOverlay(*this, nullptr, aPoly); + } - mpCreateViewExtraData->CreateAndShowOverlay(*this, nullptr, aPoly); - } + // #i101679# Force changed overlay to be shown + for(sal_uInt32 a(0); a < PaintWindowCount(); a++) + { + SdrPaintWindow* pCandidate = GetPaintWindow(a); + const rtl::Reference& xOverlayManager = pCandidate->GetOverlayManager(); - // #i101679# Force changed overlay to be shown - for(sal_uInt32 a(0); a < PaintWindowCount(); a++) + if (xOverlayManager.is()) { - SdrPaintWindow* pCandidate = GetPaintWindow(a); - const rtl::Reference& xOverlayManager = pCandidate->GetOverlayManager(); - - if (xOverlayManager.is()) - { - xOverlayManager->flush(); - } + xOverlayManager->flush(); } } - - maDragStat.SetShown(true); } + + maDragStat.SetShown(true); } void SdrCreateView::HideCreateObj() diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index 53a1f072ee84..22c70944d2bd 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -295,26 +295,26 @@ void SdrDragMethod::addSdrDragEntry(std::unique_ptr pNew) void SdrDragMethod::createSdrDragEntries() { - if(getSdrDragView().GetSdrPageView() && getSdrDragView().GetSdrPageView()->HasMarkedObjPageView()) + if(!(getSdrDragView().GetSdrPageView() && getSdrDragView().GetSdrPageView()->HasMarkedObjPageView())) + return; + + if(getSdrDragView().IsDraggingPoints()) { - if(getSdrDragView().IsDraggingPoints()) - { - createSdrDragEntries_PointDrag(); - } - else if(getSdrDragView().IsDraggingGluePoints()) + createSdrDragEntries_PointDrag(); + } + else if(getSdrDragView().IsDraggingGluePoints()) + { + createSdrDragEntries_GlueDrag(); + } + else + { + if(getSolidDraggingActive()) { - createSdrDragEntries_GlueDrag(); + createSdrDragEntries_SolidDrag(); } else { - if(getSolidDraggingActive()) - { - createSdrDragEntries_SolidDrag(); - } - else - { - createSdrDragEntries_PolygonDrag(); - } + createSdrDragEntries_PolygonDrag(); } } } @@ -366,51 +366,51 @@ void SdrDragMethod::createSdrDragEntries_SolidDrag() const size_t nMarkCount(getSdrDragView().GetMarkedObjectCount()); SdrPageView* pPV = getSdrDragView().GetSdrPageView(); - if(pPV) + if(!pPV) + return; + + for(size_t a = 0; a < nMarkCount; ++a) { - for(size_t a = 0; a < nMarkCount; ++a) + SdrMark* pM = getSdrDragView().GetSdrMarkByIndex(a); + + if(pM->GetPageView() == pPV) { - SdrMark* pM = getSdrDragView().GetSdrMarkByIndex(a); + const SdrObject* pObject = pM->GetMarkedSdrObj(); - if(pM->GetPageView() == pPV) + if(pObject) { - const SdrObject* pObject = pM->GetMarkedSdrObj(); - - if(pObject) + if(pPV->PageWindowCount()) { - if(pPV->PageWindowCount()) + SdrObjListIter aIter(*pObject); + + while(aIter.IsMore()) { - SdrObjListIter aIter(*pObject); + SdrObject* pCandidate = aIter.Next(); - while(aIter.IsMore()) + if(pCandidate) { - SdrObject* pCandidate = aIter.Next(); + const bool bSuppressFullDrag(!pCandidate->supportsFullDrag()); + bool bAddWireframe(bSuppressFullDrag); - if(pCandidate) + if(!bAddWireframe && !pCandidate->HasLineStyle()) { - const bool bSuppressFullDrag(!pCandidate->supportsFullDrag()); - bool bAddWireframe(bSuppressFullDrag); - - if(!bAddWireframe && !pCandidate->HasLineStyle()) - { - // add wireframe for objects without outline - bAddWireframe = true; - } - - if(!bSuppressFullDrag) - { - // add full object drag; Clone() at the object has to work - // for this - createSdrDragEntryForSdrObject(*pCandidate); - } - - if(bAddWireframe) - { - // when dragging a 50% transparent copy of a filled or not filled object without - // outline, this is normally hard to see. Add extra wireframe in that case. This - // works nice e.g. with text frames etc. - addSdrDragEntry(std::unique_ptr(new SdrDragEntryPolyPolygon(pCandidate->TakeXorPoly()))); - } + // add wireframe for objects without outline + bAddWireframe = true; + } + + if(!bSuppressFullDrag) + { + // add full object drag; Clone() at the object has to work + // for this + createSdrDragEntryForSdrObject(*pCandidate); + } + + if(bAddWireframe) + { + // when dragging a 50% transparent copy of a filled or not filled object without + // outline, this is normally hard to see. Add extra wireframe in that case. This + // works nice e.g. with text frames etc. + addSdrDragEntry(std::unique_ptr(new SdrDragEntryPolyPolygon(pCandidate->TakeXorPoly()))); } } } @@ -809,25 +809,25 @@ void SdrDragMethod::CreateOverlayGeometry( } // add DragStripes if necessary (help lines cross the page when dragging) - if(getSdrDragView().IsDragStripes()) - { - tools::Rectangle aActionRectangle; - getSdrDragView().TakeActionRect(aActionRectangle); + if(!getSdrDragView().IsDragStripes()) + return; - const basegfx::B2DPoint aTopLeft(aActionRectangle.Left(), aActionRectangle.Top()); - const basegfx::B2DPoint aBottomRight(aActionRectangle.Right(), aActionRectangle.Bottom()); - std::unique_ptr pNew( - new sdr::overlay::OverlayRollingRectangleStriped( - aTopLeft, - aBottomRight, - true, - false)); + tools::Rectangle aActionRectangle; + getSdrDragView().TakeActionRect(aActionRectangle); - insertNewlyCreatedOverlayObjectForSdrDragMethod( - std::move(pNew), - rObjectContact, - rOverlayManager); - } + const basegfx::B2DPoint aTopLeft(aActionRectangle.Left(), aActionRectangle.Top()); + const basegfx::B2DPoint aBottomRight(aActionRectangle.Right(), aActionRectangle.Bottom()); + std::unique_ptr pNew( + new sdr::overlay::OverlayRollingRectangleStriped( + aTopLeft, + aBottomRight, + true, + false)); + + insertNewlyCreatedOverlayObjectForSdrDragMethod( + std::move(pNew), + rObjectContact, + rOverlayManager); } void SdrDragMethod::destroyOverlayGeometry() @@ -998,111 +998,111 @@ void SdrDragMovHdl::MoveSdrDrag(const Point& rNoSnapPnt) { Point aPnt(rNoSnapPnt); - if ( GetDragHdl() && DragStat().CheckMinMoved(rNoSnapPnt)) + if ( !(GetDragHdl() && DragStat().CheckMinMoved(rNoSnapPnt))) + return; + + if (GetDragHdl()->GetKind()==SdrHdlKind::MirrorAxis) { - if (GetDragHdl()->GetKind()==SdrHdlKind::MirrorAxis) - { - SdrHdl* pH1=GetHdlList().GetHdl(SdrHdlKind::Ref1); - SdrHdl* pH2=GetHdlList().GetHdl(SdrHdlKind::Ref2); + SdrHdl* pH1=GetHdlList().GetHdl(SdrHdlKind::Ref1); + SdrHdl* pH2=GetHdlList().GetHdl(SdrHdlKind::Ref2); - if (pH1==nullptr || pH2==nullptr) - return; + if (pH1==nullptr || pH2==nullptr) + return; - if (!DragStat().IsNoSnap()) - { - long nBestXSnap=0; - long nBestYSnap=0; - bool bXSnapped=false; - bool bYSnapped=false; - Point aDif(aPnt-DragStat().GetStart()); - getSdrDragView().CheckSnap(Ref1()+aDif,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped); - getSdrDragView().CheckSnap(Ref2()+aDif,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped); - aPnt.AdjustX(nBestXSnap ); - aPnt.AdjustY(nBestYSnap ); - } + if (!DragStat().IsNoSnap()) + { + long nBestXSnap=0; + long nBestYSnap=0; + bool bXSnapped=false; + bool bYSnapped=false; + Point aDif(aPnt-DragStat().GetStart()); + getSdrDragView().CheckSnap(Ref1()+aDif,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped); + getSdrDragView().CheckSnap(Ref2()+aDif,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped); + aPnt.AdjustX(nBestXSnap ); + aPnt.AdjustY(nBestYSnap ); + } - if (aPnt!=DragStat().GetNow()) - { - Hide(); - DragStat().NextMove(aPnt); - Point aDif(DragStat().GetNow()-DragStat().GetStart()); - pH1->SetPos(Ref1()+aDif); - pH2->SetPos(Ref2()+aDif); + if (aPnt!=DragStat().GetNow()) + { + Hide(); + DragStat().NextMove(aPnt); + Point aDif(DragStat().GetNow()-DragStat().GetStart()); + pH1->SetPos(Ref1()+aDif); + pH2->SetPos(Ref2()+aDif); - SdrHdl* pHM = GetHdlList().GetHdl(SdrHdlKind::MirrorAxis); + SdrHdl* pHM = GetHdlList().GetHdl(SdrHdlKind::MirrorAxis); - if(pHM) - pHM->Touch(); + if(pHM) + pHM->Touch(); - Show(); - DragStat().SetActionRect(tools::Rectangle(pH1->GetPos(),pH2->GetPos())); - } + Show(); + DragStat().SetActionRect(tools::Rectangle(pH1->GetPos(),pH2->GetPos())); } - else - { - if (!DragStat().IsNoSnap()) SnapPos(aPnt); - long nSA=0; + } + else + { + if (!DragStat().IsNoSnap()) SnapPos(aPnt); + long nSA=0; - if (getSdrDragView().IsAngleSnapEnabled()) - nSA=getSdrDragView().GetSnapAngle(); + if (getSdrDragView().IsAngleSnapEnabled()) + nSA=getSdrDragView().GetSnapAngle(); - if (getSdrDragView().IsMirrorAllowed(true,true)) - { // limited - if (!getSdrDragView().IsMirrorAllowed()) nSA=4500; - if (!getSdrDragView().IsMirrorAllowed(true)) nSA=9000; - } + if (getSdrDragView().IsMirrorAllowed(true,true)) + { // limited + if (!getSdrDragView().IsMirrorAllowed()) nSA=4500; + if (!getSdrDragView().IsMirrorAllowed(true)) nSA=9000; + } - if (getSdrDragView().IsOrtho() && nSA!=9000) - nSA=4500; + if (getSdrDragView().IsOrtho() && nSA!=9000) + nSA=4500; - if (nSA!=0) - { // angle snapping - SdrHdlKind eRef=SdrHdlKind::Ref1; + if (nSA!=0) + { // angle snapping + SdrHdlKind eRef=SdrHdlKind::Ref1; - if (GetDragHdl()->GetKind()==SdrHdlKind::Ref1) - eRef=SdrHdlKind::Ref2; + if (GetDragHdl()->GetKind()==SdrHdlKind::Ref1) + eRef=SdrHdlKind::Ref2; - SdrHdl* pH=GetHdlList().GetHdl(eRef); + SdrHdl* pH=GetHdlList().GetHdl(eRef); - if (pH!=nullptr) + if (pH!=nullptr) + { + Point aRef(pH->GetPos()); + long nAngle=NormAngle36000(GetAngle(aPnt-aRef)); + long nNewAngle=nAngle; + nNewAngle+=nSA/2; + nNewAngle/=nSA; + nNewAngle*=nSA; + nNewAngle=NormAngle36000(nNewAngle); + double a=(nNewAngle-nAngle)*F_PI18000; + double nSin=sin(a); + double nCos=cos(a); + RotatePoint(aPnt,aRef,nSin,nCos); + + // eliminate rounding errors for certain values + if (nSA==9000) { - Point aRef(pH->GetPos()); - long nAngle=NormAngle36000(GetAngle(aPnt-aRef)); - long nNewAngle=nAngle; - nNewAngle+=nSA/2; - nNewAngle/=nSA; - nNewAngle*=nSA; - nNewAngle=NormAngle36000(nNewAngle); - double a=(nNewAngle-nAngle)*F_PI18000; - double nSin=sin(a); - double nCos=cos(a); - RotatePoint(aPnt,aRef,nSin,nCos); - - // eliminate rounding errors for certain values - if (nSA==9000) - { - if (nNewAngle==0 || nNewAngle==18000) aPnt.setY(aRef.Y() ); - if (nNewAngle==9000 || nNewAngle==27000) aPnt.setX(aRef.X() ); - } - - if (nSA==4500) - OrthoDistance8(aRef,aPnt,true); + if (nNewAngle==0 || nNewAngle==18000) aPnt.setY(aRef.Y() ); + if (nNewAngle==9000 || nNewAngle==27000) aPnt.setX(aRef.X() ); } + + if (nSA==4500) + OrthoDistance8(aRef,aPnt,true); } + } - if (aPnt!=DragStat().GetNow()) - { - Hide(); - DragStat().NextMove(aPnt); - GetDragHdl()->SetPos(DragStat().GetNow()); - SdrHdl* pHM = GetHdlList().GetHdl(SdrHdlKind::MirrorAxis); + if (aPnt!=DragStat().GetNow()) + { + Hide(); + DragStat().NextMove(aPnt); + GetDragHdl()->SetPos(DragStat().GetNow()); + SdrHdl* pHM = GetHdlList().GetHdl(SdrHdlKind::MirrorAxis); - if(pHM) - pHM->Touch(); + if(pHM) + pHM->Touch(); - Show(); - DragStat().SetActionRect(tools::Rectangle(aPnt,aPnt)); - } + Show(); + DragStat().SetActionRect(tools::Rectangle(aPnt,aPnt)); } } } @@ -1178,52 +1178,52 @@ SdrDragObjOwn::~SdrDragObjOwn() void SdrDragObjOwn::createSdrDragEntries() { - if(mxClone) + if(!mxClone) + return; + + basegfx::B2DPolyPolygon aDragPolyPolygon; + bool bAddWireframe(true); + + if(getSolidDraggingActive()) { - basegfx::B2DPolyPolygon aDragPolyPolygon; - bool bAddWireframe(true); + SdrPageView* pPV = getSdrDragView().GetSdrPageView(); - if(getSolidDraggingActive()) + if(pPV && pPV->PageWindowCount()) { - SdrPageView* pPV = getSdrDragView().GetSdrPageView(); - - if(pPV && pPV->PageWindowCount()) - { - addSdrDragEntry(std::unique_ptr(new SdrDragEntrySdrObject(*mxClone, false))); + addSdrDragEntry(std::unique_ptr(new SdrDragEntrySdrObject(*mxClone, false))); - // potentially no wireframe needed, full drag works - bAddWireframe = false; - } + // potentially no wireframe needed, full drag works + bAddWireframe = false; } + } - if(!bAddWireframe) + if(!bAddWireframe) + { + // check for extra conditions for wireframe, e.g. no border at + // objects + if(!mxClone->HasLineStyle()) { - // check for extra conditions for wireframe, e.g. no border at - // objects - if(!mxClone->HasLineStyle()) - { - bAddWireframe = true; - } + bAddWireframe = true; } + } - if(bAddWireframe) - { - // use wireframe poly when full drag is off or did not work - aDragPolyPolygon = mxClone->TakeXorPoly(); - } + if(bAddWireframe) + { + // use wireframe poly when full drag is off or did not work + aDragPolyPolygon = mxClone->TakeXorPoly(); + } - // add evtl. extra DragPolyPolygon - const basegfx::B2DPolyPolygon aSpecialDragPolyPolygon(mxClone->getSpecialDragPoly(DragStat())); + // add evtl. extra DragPolyPolygon + const basegfx::B2DPolyPolygon aSpecialDragPolyPolygon(mxClone->getSpecialDragPoly(DragStat())); - if(aSpecialDragPolyPolygon.count()) - { - aDragPolyPolygon.append(aSpecialDragPolyPolygon); - } + if(aSpecialDragPolyPolygon.count()) + { + aDragPolyPolygon.append(aSpecialDragPolyPolygon); + } - if(aDragPolyPolygon.count()) - { - addSdrDragEntry(std::unique_ptr(new SdrDragEntryPolyPolygon(aDragPolyPolygon))); - } + if(aDragPolyPolygon.count()) + { + addSdrDragEntry(std::unique_ptr(new SdrDragEntryPolyPolygon(aDragPolyPolygon))); } } @@ -1525,21 +1525,21 @@ void SdrDragMove::ImpCheckSnap(const Point& rPt) } } - if (nRet & SdrSnap::YSNAPPED) + if (!(nRet & SdrSnap::YSNAPPED)) + return; + + if (bYSnapped) { - if (bYSnapped) - { - if (std::abs(aPt.Y())aLR.Left() || aSR2.Right()aLR.Left() || aSR2.Right()aLR.Right()) - { - aPt1.AdjustX( -(aSR2.Right()-aLR.Right()) ); - } + if (aSR2.Left()aLR.Right()) + { + aPt1.AdjustX( -(aSR2.Right()-aLR.Right()) ); + } + } + else + aPt1.setX(DragStat().GetStart().X() ); // no space to move to - if (aSR2.Top()>aLR.Top() || aSR2.Bottom()aLR.Top() || aSR2.Bottom()aLR.Bottom()) - { - aPt1.AdjustY( -(aSR2.Bottom()-aLR.Bottom()) ); - } + if (aSR2.Top()aLR.Bottom()) + { + aPt1.AdjustY( -(aSR2.Bottom()-aLR.Bottom()) ); } - else - aPt1.setY(DragStat().GetStart().Y() ); // no space to move to } + else + aPt1.setY(DragStat().GetStart().Y() ); // no space to move to + } + + if (getSdrDragView().IsDraggingGluePoints()) + { // restrict glue points to the BoundRect of the Obj + aPt1-=DragStat().GetStart(); + const SdrMarkList& rML=GetMarkedObjectList(); + const size_t nMarkCount=rML.GetMarkCount(); - if (getSdrDragView().IsDraggingGluePoints()) - { // restrict glue points to the BoundRect of the Obj - aPt1-=DragStat().GetStart(); - const SdrMarkList& rML=GetMarkedObjectList(); - const size_t nMarkCount=rML.GetMarkCount(); + for (size_t nMarkNum=0; nMarkNumGetMarkedGluePoints(); - for (size_t nMarkNum=0; nMarkNumGetMarkedGluePoints(); + const SdrObject* pObj=pM->GetMarkedSdrObj(); + const SdrGluePointList* pGPL=pObj->GetGluePointList(); + tools::Rectangle aBound(pObj->GetCurrentBoundRect()); - if (!rPts.empty()) + for (sal_uInt16 nId : rPts) { - const SdrObject* pObj=pM->GetMarkedSdrObj(); - const SdrGluePointList* pGPL=pObj->GetGluePointList(); - tools::Rectangle aBound(pObj->GetCurrentBoundRect()); + sal_uInt16 nGlueNum=pGPL->FindGluePoint(nId); - for (sal_uInt16 nId : rPts) + if (nGlueNum!=SDRGLUEPOINT_NOTFOUND) { - sal_uInt16 nGlueNum=pGPL->FindGluePoint(nId); - - if (nGlueNum!=SDRGLUEPOINT_NOTFOUND) - { - Point aPt((*pGPL)[nGlueNum].GetAbsolutePos(*pObj)); - aPt+=aPt1; // move by this much - if (aPt.X()aBound.Right() ) aPt1.AdjustX( -(aPt.X()-aBound.Right()) ) ; - if (aPt.Y()aBound.Bottom()) aPt1.AdjustY( -(aPt.Y()-aBound.Bottom()) ); - } + Point aPt((*pGPL)[nGlueNum].GetAbsolutePos(*pObj)); + aPt+=aPt1; // move by this much + if (aPt.X()aBound.Right() ) aPt1.AdjustX( -(aPt.X()-aBound.Right()) ) ; + if (aPt.Y()aBound.Bottom()) aPt1.AdjustY( -(aPt.Y()-aBound.Bottom()) ); } } } - - aPt1+=DragStat().GetStart(); } - if (bOrtho) - OrthoDistance8(DragStat().GetStart(),aPt1,false); + aPt1+=DragStat().GetStart(); + } - if (aPt1!=DragStat().GetNow()) - { - Hide(); - DragStat().NextMove(aPt1); - tools::Rectangle aAction(GetMarkedRect()); - aAction.Move(DragStat().GetDX(),DragStat().GetDY()); - DragStat().SetActionRect(aAction); - Show(); - } + if (bOrtho) + OrthoDistance8(DragStat().GetStart(),aPt1,false); + + if (aPt1!=DragStat().GetNow()) + { + Hide(); + DragStat().NextMove(aPt1); + tools::Rectangle aAction(GetMarkedRect()); + aAction.Move(DragStat().GetDX(),DragStat().GetDY()); + DragStat().SetActionRect(aAction); + Show(); } } @@ -2114,48 +2114,48 @@ basegfx::B2DHomMatrix SdrDragRotate::getCurrentTransformation() void SdrDragRotate::MoveSdrDrag(const Point& rPnt_) { Point aPnt(rPnt_); - if (DragStat().CheckMinMoved(aPnt)) - { - long nNewAngle=NormAngle36000(GetAngle(aPnt-DragStat().GetRef1())-nAngle0); - long nSA=0; + if (!DragStat().CheckMinMoved(aPnt)) + return; - if (getSdrDragView().IsAngleSnapEnabled()) - nSA=getSdrDragView().GetSnapAngle(); + long nNewAngle=NormAngle36000(GetAngle(aPnt-DragStat().GetRef1())-nAngle0); + long nSA=0; - if (!getSdrDragView().IsRotateAllowed()) - nSA=9000; + if (getSdrDragView().IsAngleSnapEnabled()) + nSA=getSdrDragView().GetSnapAngle(); - if (nSA!=0) - { // angle snapping - nNewAngle+=nSA/2; - nNewAngle/=nSA; - nNewAngle*=nSA; - } + if (!getSdrDragView().IsRotateAllowed()) + nSA=9000; - nNewAngle=NormAngle18000(nNewAngle); + if (nSA!=0) + { // angle snapping + nNewAngle+=nSA/2; + nNewAngle/=nSA; + nNewAngle*=nSA; + } - if (nAngle!=nNewAngle) - { - sal_uInt16 nSekt0=GetAngleSector(nAngle); - sal_uInt16 nSekt1=GetAngleSector(nNewAngle); + nNewAngle=NormAngle18000(nNewAngle); - if (nSekt0==0 && nSekt1==3) - bRight=true; + if (nAngle==nNewAngle) + return; - if (nSekt0==3 && nSekt1==0) - bRight=false; + sal_uInt16 nSekt0=GetAngleSector(nAngle); + sal_uInt16 nSekt1=GetAngleSector(nNewAngle); - nAngle=nNewAngle; - double a = nAngle * F_PI18000; - double nSin1=sin(a); // calculate now, so as little time as possible - double nCos1=cos(a); // passes between Hide() and Show() - Hide(); - nSin=nSin1; - nCos=nCos1; - DragStat().NextMove(aPnt); - Show(); - } - } + if (nSekt0==0 && nSekt1==3) + bRight=true; + + if (nSekt0==3 && nSekt1==0) + bRight=false; + + nAngle=nNewAngle; + double a = nAngle * F_PI18000; + double nSin1=sin(a); // calculate now, so as little time as possible + double nCos1=cos(a); // passes between Hide() and Show() + Hide(); + nSin=nSin1; + nCos=nCos1; + DragStat().NextMove(aPnt); + Show(); } bool SdrDragRotate::EndSdrDrag(bool bCopy) @@ -2559,18 +2559,18 @@ basegfx::B2DHomMatrix SdrDragMirror::getCurrentTransformation() void SdrDragMirror::MoveSdrDrag(const Point& rPnt) { - if (DragStat().CheckMinMoved(rPnt)) - { - bool bNewSide=ImpCheckSide(rPnt); - bool bNewMirrored=bSide0!=bNewSide; + if (!DragStat().CheckMinMoved(rPnt)) + return; - if (bMirrored!=bNewMirrored) - { - Hide(); - bMirrored=bNewMirrored; - DragStat().NextMove(rPnt); - Show(); - } + bool bNewSide=ImpCheckSide(rPnt); + bool bNewMirrored=bSide0!=bNewSide; + + if (bMirrored!=bNewMirrored) + { + Hide(); + bMirrored=bNewMirrored; + DragStat().NextMove(rPnt); + Show(); } } @@ -2678,43 +2678,43 @@ bool SdrDragGradient::BeginSdrDrag() void SdrDragGradient::MoveSdrDrag(const Point& rPnt) { - if(pIAOHandle && DragStat().CheckMinMoved(rPnt)) - { - DragStat().NextMove(rPnt); + if(!(pIAOHandle && DragStat().CheckMinMoved(rPnt))) + return; + + DragStat().NextMove(rPnt); - // Do the Move here!!! DragStat().GetStart() - Point aMoveDiff = rPnt - DragStat().GetStart(); + // Do the Move here!!! DragStat().GetStart() + Point aMoveDiff = rPnt - DragStat().GetStart(); - if(pIAOHandle->IsMoveSingleHandle()) + if(pIAOHandle->IsMoveSingleHandle()) + { + if(pIAOHandle->IsMoveFirstHandle()) { - if(pIAOHandle->IsMoveFirstHandle()) - { - pIAOHandle->SetPos(DragStat().GetRef1() + aMoveDiff); - if(pIAOHandle->GetColorHdl1()) - pIAOHandle->GetColorHdl1()->SetPos(DragStat().GetRef1() + aMoveDiff); - } - else - { - pIAOHandle->Set2ndPos(DragStat().GetRef2() + aMoveDiff); - if(pIAOHandle->GetColorHdl2()) - pIAOHandle->GetColorHdl2()->SetPos(DragStat().GetRef2() + aMoveDiff); - } + pIAOHandle->SetPos(DragStat().GetRef1() + aMoveDiff); + if(pIAOHandle->GetColorHdl1()) + pIAOHandle->GetColorHdl1()->SetPos(DragStat().GetRef1() + aMoveDiff); } else { - pIAOHandle->SetPos(DragStat().GetRef1() + aMoveDiff); pIAOHandle->Set2ndPos(DragStat().GetRef2() + aMoveDiff); - - if(pIAOHandle->GetColorHdl1()) - pIAOHandle->GetColorHdl1()->SetPos(DragStat().GetRef1() + aMoveDiff); - if(pIAOHandle->GetColorHdl2()) pIAOHandle->GetColorHdl2()->SetPos(DragStat().GetRef2() + aMoveDiff); } + } + else + { + pIAOHandle->SetPos(DragStat().GetRef1() + aMoveDiff); + pIAOHandle->Set2ndPos(DragStat().GetRef2() + aMoveDiff); + + if(pIAOHandle->GetColorHdl1()) + pIAOHandle->GetColorHdl1()->SetPos(DragStat().GetRef1() + aMoveDiff); - // new state - pIAOHandle->FromIAOToItem(getSdrDragView().GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(), false, false); + if(pIAOHandle->GetColorHdl2()) + pIAOHandle->GetColorHdl2()->SetPos(DragStat().GetRef2() + aMoveDiff); } + + // new state + pIAOHandle->FromIAOToItem(getSdrDragView().GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(), false, false); } bool SdrDragGradient::EndSdrDrag(bool /*bCopy*/) @@ -2918,117 +2918,117 @@ void SdrDragCrook::MovAllPoints(basegfx::B2DPolyPolygon& rTarget) { SdrPageView* pPV = getSdrDragView().GetSdrPageView(); - if(pPV) + if(!pPV) + return; + + XPolyPolygon aTempPolyPoly(rTarget); + + if (pPV->HasMarkedObjPageView()) { - XPolyPolygon aTempPolyPoly(rTarget); + sal_uInt16 nPolyCount=aTempPolyPoly.Count(); - if (pPV->HasMarkedObjPageView()) + if (!bContortion && !getSdrDragView().IsNoDragXorPolys()) { - sal_uInt16 nPolyCount=aTempPolyPoly.Count(); + sal_uInt16 n1st=0,nLast=0; + Point aC(aCenter); - if (!bContortion && !getSdrDragView().IsNoDragXorPolys()) + while (n1stHasMarkedObjPageView()) - { - basegfx::B2DPolyPolygon aDragPolygon(rTarget); - const basegfx::B2DRange aOriginalRange = vcl::unotools::b2DRectangleFromRectangle(aMarkRect); - const basegfx::B2DPoint aTopLeft(aDistortedRect[0].X(), aDistortedRect[0].Y()); - const basegfx::B2DPoint aTopRight(aDistortedRect[1].X(), aDistortedRect[1].Y()); - const basegfx::B2DPoint aBottomLeft(aDistortedRect[3].X(), aDistortedRect[3].Y()); - const basegfx::B2DPoint aBottomRight(aDistortedRect[2].X(), aDistortedRect[2].Y()); + SdrPageView* pPV = getSdrDragView().GetSdrPageView(); - aDragPolygon = basegfx::utils::distort(aDragPolygon, aOriginalRange, aTopLeft, aTopRight, aBottomLeft, aBottomRight); - rTarget = aDragPolygon; - } + if(pPV && pPV->HasMarkedObjPageView()) + { + basegfx::B2DPolyPolygon aDragPolygon(rTarget); + const basegfx::B2DRange aOriginalRange = vcl::unotools::b2DRectangleFromRectangle(aMarkRect); + const basegfx::B2DPoint aTopLeft(aDistortedRect[0].X(), aDistortedRect[0].Y()); + const basegfx::B2DPoint aTopRight(aDistortedRect[1].X(), aDistortedRect[1].Y()); + const basegfx::B2DPoint aBottomLeft(aDistortedRect[3].X(), aDistortedRect[3].Y()); + const basegfx::B2DPoint aBottomRight(aDistortedRect[2].X(), aDistortedRect[2].Y()); + + aDragPolygon = basegfx::utils::distort(aDragPolygon, aOriginalRange, aTopLeft, aTopRight, aBottomLeft, aBottomRight); + rTarget = aDragPolygon; } } void SdrDragDistort::MoveSdrDrag(const Point& rPnt) { - if (DragStat().CheckMinMoved(rPnt)) - { - Point aPnt(GetSnapPos(rPnt)); + if (!DragStat().CheckMinMoved(rPnt)) + return; - if (getSdrDragView().IsOrtho()) - OrthoDistance8(DragStat().GetStart(),aPnt,getSdrDragView().IsBigOrtho()); + Point aPnt(GetSnapPos(rPnt)); - bool bNewContortion=(bContortionAllowed && !getSdrDragView().IsCrookNoContortion()) || !bNoContortionAllowed; + if (getSdrDragView().IsOrtho()) + OrthoDistance8(DragStat().GetStart(),aPnt,getSdrDragView().IsBigOrtho()); - if (bNewContortion!=bContortion || aDistortedRect[nPolyPt]!=aPnt) - { - Hide(); - aDistortedRect[nPolyPt]=aPnt; - bContortion=bNewContortion; - DragStat().NextMove(aPnt); - Show(); - } + bool bNewContortion=(bContortionAllowed && !getSdrDragView().IsCrookNoContortion()) || !bNoContortionAllowed; + + if (bNewContortion!=bContortion || aDistortedRect[nPolyPt]!=aPnt) + { + Hide(); + aDistortedRect[nPolyPt]=aPnt; + bContortion=bNewContortion; + DragStat().NextMove(aPnt); + Show(); } } diff --git a/svx/source/svdraw/svddrgv.cxx b/svx/source/svdraw/svddrgv.cxx index 7002f9447d0d..0be9b5786cb7 100644 --- a/svx/source/svdraw/svddrgv.cxx +++ b/svx/source/svdraw/svddrgv.cxx @@ -513,25 +513,25 @@ bool SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl void SdrDragView::MovDragObj(const Point& rPnt) { - if (mpCurrentSdrDragMethod) + if (!mpCurrentSdrDragMethod) + return; + + Point aPnt(rPnt); + basegfx::B2DVector aGridOffset(0.0, 0.0); + + // Coordinate maybe affected by GridOffset, so we may need to + // adapt to Model-coordinates here + if(getPossibleGridOffsetForPosition( + aGridOffset, + basegfx::B2DPoint(aPnt.X(), aPnt.Y()), + GetSdrPageView())) { - Point aPnt(rPnt); - basegfx::B2DVector aGridOffset(0.0, 0.0); - - // Coordinate maybe affected by GridOffset, so we may need to - // adapt to Model-coordinates here - if(getPossibleGridOffsetForPosition( - aGridOffset, - basegfx::B2DPoint(aPnt.X(), aPnt.Y()), - GetSdrPageView())) - { - aPnt.AdjustX(basegfx::fround(-aGridOffset.getX())); - aPnt.AdjustY(basegfx::fround(-aGridOffset.getY())); - } - - ImpLimitToWorkArea(aPnt); - mpCurrentSdrDragMethod->MoveSdrDrag(aPnt); // this call already makes a Hide()/Show combination + aPnt.AdjustX(basegfx::fround(-aGridOffset.getX())); + aPnt.AdjustY(basegfx::fround(-aGridOffset.getY())); } + + ImpLimitToWorkArea(aPnt); + mpCurrentSdrDragMethod->MoveSdrDrag(aPnt); // this call already makes a Hide()/Show combination } bool SdrDragView::EndDragObj(bool bCopy) @@ -607,32 +607,32 @@ bool SdrDragView::EndDragObj(bool bCopy) void SdrDragView::BrkDragObj() { - if (mpCurrentSdrDragMethod) - { - mpCurrentSdrDragMethod->CancelSdrDrag(); + if (!mpCurrentSdrDragMethod) + return; - mpCurrentSdrDragMethod.reset(); + mpCurrentSdrDragMethod->CancelSdrDrag(); - if (mbInsPolyPoint) - { - mpInsPointUndo->Undo(); // delete inserted point again - delete mpInsPointUndo; - mpInsPointUndo=nullptr; - SetMarkHandles(nullptr); - mbInsPolyPoint=false; - } + mpCurrentSdrDragMethod.reset(); - if (IsInsertGluePoint()) - { - mpInsPointUndo->Undo(); // delete inserted glue point again - delete mpInsPointUndo; - mpInsPointUndo=nullptr; - SetInsertGluePoint(false); - } + if (mbInsPolyPoint) + { + mpInsPointUndo->Undo(); // delete inserted point again + delete mpInsPointUndo; + mpInsPointUndo=nullptr; + SetMarkHandles(nullptr); + mbInsPolyPoint=false; + } - meDragHdl=SdrHdlKind::Move; - mpDragHdl=nullptr; + if (IsInsertGluePoint()) + { + mpInsPointUndo->Undo(); // delete inserted glue point again + delete mpInsPointUndo; + mpInsPointUndo=nullptr; + SetInsertGluePoint(false); } + + meDragHdl=SdrHdlKind::Move; + mpDragHdl=nullptr; } bool SdrDragView::IsInsObjPointPossible() const @@ -799,42 +799,42 @@ bool SdrDragView::BegInsGluePoint(const Point& rPnt) void SdrDragView::ShowDragObj() { - if(mpCurrentSdrDragMethod && !maDragStat.IsShown()) + if(!(mpCurrentSdrDragMethod && !maDragStat.IsShown())) + return; + + // Changed for the GridOffset stuff: No longer iterate over + // SdrPaintWindow(s), but now over SdrPageWindow(s), so doing the + // same as the SdrHdl visualizations (see ::CreateB2dIAObject) do. + // This is needed to get access to an ObjectContact which is needed + // to evtl. process that GridOffset in CreateOverlayGeometry + SdrPageView* pPageView(GetSdrPageView()); + + if(nullptr != pPageView) { - // Changed for the GridOffset stuff: No longer iterate over - // SdrPaintWindow(s), but now over SdrPageWindow(s), so doing the - // same as the SdrHdl visualizations (see ::CreateB2dIAObject) do. - // This is needed to get access to an ObjectContact which is needed - // to evtl. process that GridOffset in CreateOverlayGeometry - SdrPageView* pPageView(GetSdrPageView()); - - if(nullptr != pPageView) + for(sal_uInt32 a(0); a < pPageView->PageWindowCount(); a++) { - for(sal_uInt32 a(0); a < pPageView->PageWindowCount(); a++) + const SdrPageWindow& rPageWindow(*pPageView->GetPageWindow(a)); + const SdrPaintWindow& rPaintWindow(rPageWindow.GetPaintWindow()); + + if(rPaintWindow.OutputToWindow()) { - const SdrPageWindow& rPageWindow(*pPageView->GetPageWindow(a)); - const SdrPaintWindow& rPaintWindow(rPageWindow.GetPaintWindow()); + const rtl::Reference& xOverlayManager( + rPaintWindow.GetOverlayManager()); - if(rPaintWindow.OutputToWindow()) + if(xOverlayManager.is()) { - const rtl::Reference& xOverlayManager( - rPaintWindow.GetOverlayManager()); - - if(xOverlayManager.is()) - { - mpCurrentSdrDragMethod->CreateOverlayGeometry( - *xOverlayManager, - rPageWindow.GetObjectContact()); + mpCurrentSdrDragMethod->CreateOverlayGeometry( + *xOverlayManager, + rPageWindow.GetObjectContact()); - // #i101679# Force changed overlay to be shown - xOverlayManager->flush(); - } + // #i101679# Force changed overlay to be shown + xOverlayManager->flush(); } } } - - maDragStat.SetShown(true); } + + maDragStat.SetShown(true); } void SdrDragView::HideDragObj() @@ -849,28 +849,28 @@ void SdrDragView::HideDragObj() void SdrDragView::SetNoDragXorPolys(bool bOn) { - if (IsNoDragXorPolys()!=bOn) - { - const bool bDragging(mpCurrentSdrDragMethod); - const bool bShown(bDragging && maDragStat.IsShown()); + if (IsNoDragXorPolys()==bOn) + return; - if(bShown) - { - HideDragObj(); - } + const bool bDragging(mpCurrentSdrDragMethod); + const bool bShown(bDragging && maDragStat.IsShown()); - mbNoDragXorPolys = bOn; + if(bShown) + { + HideDragObj(); + } - if(bDragging) - { - // force recreation of drag content - mpCurrentSdrDragMethod->resetSdrDragEntries(); - } + mbNoDragXorPolys = bOn; - if(bShown) - { - ShowDragObj(); - } + if(bDragging) + { + // force recreation of drag content + mpCurrentSdrDragMethod->resetSdrDragEntries(); + } + + if(bShown) + { + ShowDragObj(); } } diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx index 2e63c58d32b4..34b7c58c25b3 100644 --- a/svx/source/svdraw/svdedtv.cxx +++ b/svx/source/svdraw/svdedtv.cxx @@ -192,83 +192,83 @@ void SdrEditView::DeleteLayer(const OUString& rName) SdrLayerAdmin& rLA = mpModel->GetLayerAdmin(); SdrLayer* pLayer = rLA.GetLayer(rName); - if(pLayer) - { - sal_uInt16 nLayerNum(rLA.GetLayerPos(pLayer)); - SdrLayerID nDelID = pLayer->GetID(); + if(!pLayer) + return; - const bool bUndo = IsUndoEnabled(); - if( bUndo ) - BegUndo(SvxResId(STR_UndoDelLayer)); + sal_uInt16 nLayerNum(rLA.GetLayerPos(pLayer)); + SdrLayerID nDelID = pLayer->GetID(); + + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(SvxResId(STR_UndoDelLayer)); + + bool bMaPg(true); - bool bMaPg(true); + for(sal_uInt16 nPageKind(0); nPageKind < 2; nPageKind++) + { + // MasterPages and DrawPages + sal_uInt16 nPgCount(bMaPg ? mpModel->GetMasterPageCount() : mpModel->GetPageCount()); - for(sal_uInt16 nPageKind(0); nPageKind < 2; nPageKind++) + for(sal_uInt16 nPgNum(0); nPgNum < nPgCount; nPgNum++) { - // MasterPages and DrawPages - sal_uInt16 nPgCount(bMaPg ? mpModel->GetMasterPageCount() : mpModel->GetPageCount()); + // over all pages + SdrPage* pPage = bMaPg ? mpModel->GetMasterPage(nPgNum) : mpModel->GetPage(nPgNum); + const size_t nObjCount(pPage->GetObjCount()); - for(sal_uInt16 nPgNum(0); nPgNum < nPgCount; nPgNum++) - { - // over all pages - SdrPage* pPage = bMaPg ? mpModel->GetMasterPage(nPgNum) : mpModel->GetPage(nPgNum); - const size_t nObjCount(pPage->GetObjCount()); + // make sure OrdNums are correct + if(nObjCount) + pPage->GetObj(0)->GetOrdNum(); - // make sure OrdNums are correct - if(nObjCount) - pPage->GetObj(0)->GetOrdNum(); + for(size_t nObjNum(nObjCount); nObjNum > 0;) + { + nObjNum--; + SdrObject* pObj = pPage->GetObj(nObjNum); + SdrObjList* pSubOL = pObj->GetSubList(); - for(size_t nObjNum(nObjCount); nObjNum > 0;) + // explicitly test for group objects and 3d scenes + if(pSubOL && (dynamic_cast(pObj) != nullptr || dynamic_cast(pObj) != nullptr)) { - nObjNum--; - SdrObject* pObj = pPage->GetObj(nObjNum); - SdrObjList* pSubOL = pObj->GetSubList(); - - // explicitly test for group objects and 3d scenes - if(pSubOL && (dynamic_cast(pObj) != nullptr || dynamic_cast(pObj) != nullptr)) + if(ImpDelLayerCheck(pSubOL, nDelID)) { - if(ImpDelLayerCheck(pSubOL, nDelID)) - { - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); - pPage->RemoveObject(nObjNum); - if( !bUndo ) - SdrObject::Free(pObj); - } - else - { - ImpDelLayerDelObjs(pSubOL, nDelID); - } + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); + pPage->RemoveObject(nObjNum); + if( !bUndo ) + SdrObject::Free(pObj); } else { - if(pObj->GetLayer() == nDelID) - { - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); - pPage->RemoveObject(nObjNum); - if( !bUndo ) - SdrObject::Free(pObj); - } + ImpDelLayerDelObjs(pSubOL, nDelID); + } + } + else + { + if(pObj->GetLayer() == nDelID) + { + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true)); + pPage->RemoveObject(nObjNum); + if( !bUndo ) + SdrObject::Free(pObj); } } } - bMaPg = false; - } - - if( bUndo ) - { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteLayer(nLayerNum, rLA, *mpModel)); - rLA.RemoveLayer(nLayerNum).release(); - EndUndo(); - } - else - { - rLA.RemoveLayer(nLayerNum); } + bMaPg = false; + } - mpModel->SetChanged(); + if( bUndo ) + { + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteLayer(nLayerNum, rLA, *mpModel)); + rLA.RemoveLayer(nLayerNum).release(); + EndUndo(); + } + else + { + rLA.RemoveLayer(nLayerNum); } + + mpModel->SetChanged(); } @@ -464,189 +464,189 @@ void SdrEditView::CheckPossibilities() CheckMarked(); } - if (m_bPossibilitiesDirty) + if (!m_bPossibilitiesDirty) + return; + + ImpResetPossibilityFlags(); + SortMarkedObjects(); + const size_t nMarkCount = GetMarkedObjectCount(); + if (nMarkCount != 0) { - ImpResetPossibilityFlags(); - SortMarkedObjects(); - const size_t nMarkCount = GetMarkedObjectCount(); - if (nMarkCount != 0) - { - m_bReverseOrderPossible = (nMarkCount >= 2); + m_bReverseOrderPossible = (nMarkCount >= 2); - size_t nMovableCount=0; - m_bGroupPossible=nMarkCount>=2; - m_bCombinePossible=nMarkCount>=2; - if (nMarkCount==1) - { - // check bCombinePossible more thoroughly - // still missing ... - const SdrObject* pObj=GetMarkedObjectByIndex(0); - //const SdrPathObj* pPath=dynamic_cast( pObj ); - bool bGroup=pObj->GetSubList()!=nullptr; - bool bHasText=pObj->GetOutlinerParaObject()!=nullptr; - if (bGroup || bHasText) { - m_bCombinePossible=true; - } + size_t nMovableCount=0; + m_bGroupPossible=nMarkCount>=2; + m_bCombinePossible=nMarkCount>=2; + if (nMarkCount==1) + { + // check bCombinePossible more thoroughly + // still missing ... + const SdrObject* pObj=GetMarkedObjectByIndex(0); + //const SdrPathObj* pPath=dynamic_cast( pObj ); + bool bGroup=pObj->GetSubList()!=nullptr; + bool bHasText=pObj->GetOutlinerParaObject()!=nullptr; + if (bGroup || bHasText) { + m_bCombinePossible=true; } - m_bCombineNoPolyPolyPossible=m_bCombinePossible; - // accept transformations for now - m_bMoveAllowed =true; - m_bResizeFreeAllowed=true; - m_bResizePropAllowed=true; - m_bRotateFreeAllowed=true; - m_bRotate90Allowed =true; - m_bMirrorFreeAllowed=true; - m_bMirror45Allowed =true; - m_bMirror90Allowed =true; - m_bShearAllowed =true; - m_bEdgeRadiusAllowed=false; - m_bContortionPossible=true; - m_bCanConvToContour = true; - - // these ones are only allowed when single object is selected - m_bTransparenceAllowed = (nMarkCount == 1); - m_bGradientAllowed = (nMarkCount == 1); - m_bCropAllowed = (nMarkCount == 1); - if(m_bGradientAllowed) - { - // gradient depends on fill style - const SdrMark* pM = GetSdrMarkByIndex(0); - const SdrObject* pObj = pM->GetMarkedSdrObj(); + } + m_bCombineNoPolyPolyPossible=m_bCombinePossible; + // accept transformations for now + m_bMoveAllowed =true; + m_bResizeFreeAllowed=true; + m_bResizePropAllowed=true; + m_bRotateFreeAllowed=true; + m_bRotate90Allowed =true; + m_bMirrorFreeAllowed=true; + m_bMirror45Allowed =true; + m_bMirror90Allowed =true; + m_bShearAllowed =true; + m_bEdgeRadiusAllowed=false; + m_bContortionPossible=true; + m_bCanConvToContour = true; + + // these ones are only allowed when single object is selected + m_bTransparenceAllowed = (nMarkCount == 1); + m_bGradientAllowed = (nMarkCount == 1); + m_bCropAllowed = (nMarkCount == 1); + if(m_bGradientAllowed) + { + // gradient depends on fill style + const SdrMark* pM = GetSdrMarkByIndex(0); + const SdrObject* pObj = pM->GetMarkedSdrObj(); - // may be group object, so get merged ItemSet - const SfxItemSet& rSet = pObj->GetMergedItemSet(); - SfxItemState eState = rSet.GetItemState(XATTR_FILLSTYLE, false); + // may be group object, so get merged ItemSet + const SfxItemSet& rSet = pObj->GetMergedItemSet(); + SfxItemState eState = rSet.GetItemState(XATTR_FILLSTYLE, false); - if(SfxItemState::DONTCARE != eState) - { - // If state is not DONTCARE, test the item - drawing::FillStyle eFillStyle = rSet.Get(XATTR_FILLSTYLE).GetValue(); + if(SfxItemState::DONTCARE != eState) + { + // If state is not DONTCARE, test the item + drawing::FillStyle eFillStyle = rSet.Get(XATTR_FILLSTYLE).GetValue(); - if(eFillStyle != drawing::FillStyle_GRADIENT) - { - m_bGradientAllowed = false; - } + if(eFillStyle != drawing::FillStyle_GRADIENT) + { + m_bGradientAllowed = false; } } + } - bool bNoMovRotFound=false; - const SdrPageView* pPV0=nullptr; + bool bNoMovRotFound=false; + const SdrPageView* pPV0=nullptr; - for (size_t nm=0; nmGetMarkedSdrObj(); - const SdrPageView* pPV=pM->GetPageView(); - if (pPV!=pPV0) { - if (pPV->IsReadOnly()) m_bReadOnly=true; - pPV0=pPV; - } + for (size_t nm=0; nmGetMarkedSdrObj(); + const SdrPageView* pPV=pM->GetPageView(); + if (pPV!=pPV0) { + if (pPV->IsReadOnly()) m_bReadOnly=true; + pPV0=pPV; + } - SdrObjTransformInfoRec aInfo; - pObj->TakeObjInfo(aInfo); - bool bMovPrt=pObj->IsMoveProtect(); - bool bSizPrt=pObj->IsResizeProtect(); - if (!bMovPrt && aInfo.bMoveAllowed) nMovableCount++; // count MovableObjs - if (bMovPrt) m_bMoveProtect=true; - if (bSizPrt) m_bResizeProtect=true; - - // not allowed when not allowed at one object - if(!aInfo.bTransparenceAllowed) - m_bTransparenceAllowed = false; - - // If one of these can't do something, none can - if (!aInfo.bMoveAllowed ) m_bMoveAllowed =false; - if (!aInfo.bResizeFreeAllowed) m_bResizeFreeAllowed=false; - if (!aInfo.bResizePropAllowed) m_bResizePropAllowed=false; - if (!aInfo.bRotateFreeAllowed) m_bRotateFreeAllowed=false; - if (!aInfo.bRotate90Allowed ) m_bRotate90Allowed =false; - if (!aInfo.bMirrorFreeAllowed) m_bMirrorFreeAllowed=false; - if (!aInfo.bMirror45Allowed ) m_bMirror45Allowed =false; - if (!aInfo.bMirror90Allowed ) m_bMirror90Allowed =false; - if (!aInfo.bShearAllowed ) m_bShearAllowed =false; - if (aInfo.bEdgeRadiusAllowed) m_bEdgeRadiusAllowed=true; - if (aInfo.bNoContortion ) m_bContortionPossible=false; - // For Crook with Contortion: all objects have to be - // Movable and Rotatable, except for a maximum of 1 of them - if (!m_bMoreThanOneNoMovRot) { - if (!aInfo.bMoveAllowed || !aInfo.bResizeFreeAllowed) { - m_bMoreThanOneNoMovRot=bNoMovRotFound; - bNoMovRotFound=true; - } + SdrObjTransformInfoRec aInfo; + pObj->TakeObjInfo(aInfo); + bool bMovPrt=pObj->IsMoveProtect(); + bool bSizPrt=pObj->IsResizeProtect(); + if (!bMovPrt && aInfo.bMoveAllowed) nMovableCount++; // count MovableObjs + if (bMovPrt) m_bMoveProtect=true; + if (bSizPrt) m_bResizeProtect=true; + + // not allowed when not allowed at one object + if(!aInfo.bTransparenceAllowed) + m_bTransparenceAllowed = false; + + // If one of these can't do something, none can + if (!aInfo.bMoveAllowed ) m_bMoveAllowed =false; + if (!aInfo.bResizeFreeAllowed) m_bResizeFreeAllowed=false; + if (!aInfo.bResizePropAllowed) m_bResizePropAllowed=false; + if (!aInfo.bRotateFreeAllowed) m_bRotateFreeAllowed=false; + if (!aInfo.bRotate90Allowed ) m_bRotate90Allowed =false; + if (!aInfo.bMirrorFreeAllowed) m_bMirrorFreeAllowed=false; + if (!aInfo.bMirror45Allowed ) m_bMirror45Allowed =false; + if (!aInfo.bMirror90Allowed ) m_bMirror90Allowed =false; + if (!aInfo.bShearAllowed ) m_bShearAllowed =false; + if (aInfo.bEdgeRadiusAllowed) m_bEdgeRadiusAllowed=true; + if (aInfo.bNoContortion ) m_bContortionPossible=false; + // For Crook with Contortion: all objects have to be + // Movable and Rotatable, except for a maximum of 1 of them + if (!m_bMoreThanOneNoMovRot) { + if (!aInfo.bMoveAllowed || !aInfo.bResizeFreeAllowed) { + m_bMoreThanOneNoMovRot=bNoMovRotFound; + bNoMovRotFound=true; } + } - // Must be resizable to allow cropping - if (!aInfo.bResizeFreeAllowed && !aInfo.bResizePropAllowed) - m_bCropAllowed = false; + // Must be resizable to allow cropping + if (!aInfo.bResizeFreeAllowed && !aInfo.bResizePropAllowed) + m_bCropAllowed = false; - // if one member cannot be converted, no conversion is possible - if(!aInfo.bCanConvToContour) - m_bCanConvToContour = false; + // if one member cannot be converted, no conversion is possible + if(!aInfo.bCanConvToContour) + m_bCanConvToContour = false; - // Ungroup - if (!m_bUnGroupPossible) m_bUnGroupPossible=pObj->GetSubList()!=nullptr; - // ConvertToCurve: If at least one can be converted, that is fine. - if (aInfo.bCanConvToPath ) m_bCanConvToPath =true; - if (aInfo.bCanConvToPoly ) m_bCanConvToPoly =true; + // Ungroup + if (!m_bUnGroupPossible) m_bUnGroupPossible=pObj->GetSubList()!=nullptr; + // ConvertToCurve: If at least one can be converted, that is fine. + if (aInfo.bCanConvToPath ) m_bCanConvToPath =true; + if (aInfo.bCanConvToPoly ) m_bCanConvToPoly =true; - // Combine/Dismantle - if(m_bCombinePossible) - { - m_bCombinePossible = ImpCanConvertForCombine(pObj); - m_bCombineNoPolyPolyPossible = m_bCombinePossible; - } + // Combine/Dismantle + if(m_bCombinePossible) + { + m_bCombinePossible = ImpCanConvertForCombine(pObj); + m_bCombineNoPolyPolyPossible = m_bCombinePossible; + } - if (!m_bDismantlePossible) m_bDismantlePossible = ImpCanDismantle(pObj, false); - if (!m_bDismantleMakeLinesPossible) m_bDismantleMakeLinesPossible = ImpCanDismantle(pObj, true); - // check OrthoDesiredOnMarked - if (!m_bOrthoDesiredOnMarked && !aInfo.bNoOrthoDesired) m_bOrthoDesiredOnMarked=true; - // check ImportMtf + if (!m_bDismantlePossible) m_bDismantlePossible = ImpCanDismantle(pObj, false); + if (!m_bDismantleMakeLinesPossible) m_bDismantleMakeLinesPossible = ImpCanDismantle(pObj, true); + // check OrthoDesiredOnMarked + if (!m_bOrthoDesiredOnMarked && !aInfo.bNoOrthoDesired) m_bOrthoDesiredOnMarked=true; + // check ImportMtf - if (!m_bImportMtfPossible) + if (!m_bImportMtfPossible) + { + const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj); + if (pSdrGrafObj != nullptr) { - const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj); - if (pSdrGrafObj != nullptr) - { - if ((pSdrGrafObj->HasGDIMetaFile() && !pSdrGrafObj->IsEPS()) || - pSdrGrafObj->isEmbeddedVectorGraphicData()) - { - m_bImportMtfPossible = true; - } - } - - const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pObj); - if (pSdrOle2Obj) + if ((pSdrGrafObj->HasGDIMetaFile() && !pSdrGrafObj->IsEPS()) || + pSdrGrafObj->isEmbeddedVectorGraphicData()) { - m_bImportMtfPossible = pSdrOle2Obj->GetObjRef().is(); + m_bImportMtfPossible = true; } } - } - m_bOneOrMoreMovable=nMovableCount!=0; - m_bGrpEnterPossible=m_bUnGroupPossible; - } - ImpCheckToTopBtmPossible(); - static_cast(this)->ImpCheckPolyPossibilities(); - m_bPossibilitiesDirty=false; - - if (m_bReadOnly) { - bool bTemp=m_bGrpEnterPossible; - ImpResetPossibilityFlags(); - m_bReadOnly=true; - m_bGrpEnterPossible=bTemp; - } - if (m_bMoveAllowed) { - // Don't allow moving glued connectors. - // Currently only implemented for single selection. - if (nMarkCount==1) { - SdrObject* pObj=GetMarkedObjectByIndex(0); - SdrEdgeObj* pEdge=dynamic_cast( pObj ); - if (pEdge!=nullptr) { - SdrObject* pNode1=pEdge->GetConnectedNode(true); - SdrObject* pNode2=pEdge->GetConnectedNode(false); - if (pNode1!=nullptr || pNode2!=nullptr) m_bMoveAllowed=false; + const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pObj); + if (pSdrOle2Obj) + { + m_bImportMtfPossible = pSdrOle2Obj->GetObjRef().is(); } } } + + m_bOneOrMoreMovable=nMovableCount!=0; + m_bGrpEnterPossible=m_bUnGroupPossible; + } + ImpCheckToTopBtmPossible(); + static_cast(this)->ImpCheckPolyPossibilities(); + m_bPossibilitiesDirty=false; + + if (m_bReadOnly) { + bool bTemp=m_bGrpEnterPossible; + ImpResetPossibilityFlags(); + m_bReadOnly=true; + m_bGrpEnterPossible=bTemp; + } + if (!m_bMoveAllowed) return; + + // Don't allow moving glued connectors. + // Currently only implemented for single selection. + if (nMarkCount==1) { + SdrObject* pObj=GetMarkedObjectByIndex(0); + SdrEdgeObj* pEdge=dynamic_cast( pObj ); + if (pEdge!=nullptr) { + SdrObject* pNode1=pEdge->GetConnectedNode(true); + SdrObject* pNode2=pEdge->GetConnectedNode(false); + if (pNode1!=nullptr || pNode2!=nullptr) m_bMoveAllowed=false; + } } } diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx index 439dba1a6ebb..17311eb5ab6c 100644 --- a/svx/source/svdraw/svdedtv1.cxx +++ b/svx/source/svdraw/svdedtv1.cxx @@ -547,34 +547,34 @@ void SdrEditView::ImpCrookObj(SdrObject* pO, const Point& rRef, const Point& rRa bDone = true; } - if(!bDone) + if(bDone) + return; + + // for all others or if bNoContortion + Point aCtr0(pO->GetSnapRect().Center()); + Point aCtr1(aCtr0); + bool bRotOk(false); + double nSin(0.0), nCos(1.0); + double nAngle(0.0); + + if(0 != rRad.X() && 0 != rRad.Y()) { - // for all others or if bNoContortion - Point aCtr0(pO->GetSnapRect().Center()); - Point aCtr1(aCtr0); - bool bRotOk(false); - double nSin(0.0), nCos(1.0); - double nAngle(0.0); - - if(0 != rRad.X() && 0 != rRad.Y()) - { - bRotOk = bRotate; + bRotOk = bRotate; - switch (eMode) - { - case SdrCrookMode::Rotate : nAngle=CrookRotateXPoint (aCtr1,nullptr,nullptr,rRef,rRad,nSin,nCos,bVertical); bRotOk=bRotate; break; - case SdrCrookMode::Slant : nAngle=CrookSlantXPoint (aCtr1,nullptr,nullptr,rRef,rRad,nSin,nCos,bVertical); break; - case SdrCrookMode::Stretch: nAngle=CrookStretchXPoint(aCtr1,nullptr,nullptr,rRef,rRad,nSin,nCos,bVertical,rMarkRect); break; - } + switch (eMode) + { + case SdrCrookMode::Rotate : nAngle=CrookRotateXPoint (aCtr1,nullptr,nullptr,rRef,rRad,nSin,nCos,bVertical); bRotOk=bRotate; break; + case SdrCrookMode::Slant : nAngle=CrookSlantXPoint (aCtr1,nullptr,nullptr,rRef,rRad,nSin,nCos,bVertical); break; + case SdrCrookMode::Stretch: nAngle=CrookStretchXPoint(aCtr1,nullptr,nullptr,rRef,rRad,nSin,nCos,bVertical,rMarkRect); break; } + } - aCtr1 -= aCtr0; + aCtr1 -= aCtr0; - if(bRotOk) - pO->Rotate(aCtr0, FRound(nAngle / F_PI18000), nSin, nCos); + if(bRotOk) + pO->Rotate(aCtr0, FRound(nAngle / F_PI18000), nSin, nCos); - pO->Move(Size(aCtr1.X(),aCtr1.Y())); - } + pO->Move(Size(aCtr1.X(),aCtr1.Y())); } void SdrEditView::CrookMarkedObj(const Point& rRef, const Point& rRad, SdrCrookMode eMode, @@ -1279,36 +1279,36 @@ SfxStyleSheet* SdrEditView::GetStyleSheetFromMarked() const void SdrEditView::SetStyleSheetToMarked(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr) { - if (AreObjectsMarked()) + if (!AreObjectsMarked()) + return; + + const bool bUndo = IsUndoEnabled(); + + if( bUndo ) { - const bool bUndo = IsUndoEnabled(); + EndTextEditAllViews(); + OUString aStr; + if (pStyleSheet!=nullptr) + aStr = ImpGetDescriptionString(STR_EditSetStylesheet); + else + aStr = ImpGetDescriptionString(STR_EditDelStylesheet); + BegUndo(aStr); + } + const size_t nMarkCount=GetMarkedObjectCount(); + for (size_t nm=0; nmGetSdrUndoFactory().CreateUndoGeoObject(*pM->GetMarkedSdrObj())); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pM->GetMarkedSdrObj(),true,true)); } - - const size_t nMarkCount=GetMarkedObjectCount(); - for (size_t nm=0; nmGetSdrUndoFactory().CreateUndoGeoObject(*pM->GetMarkedSdrObj())); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pM->GetMarkedSdrObj(),true,true)); - } - pM->GetMarkedSdrObj()->SetStyleSheet(pStyleSheet,bDontRemoveHardAttr); - } - - if( bUndo ) - EndUndo(); + pM->GetMarkedSdrObj()->SetStyleSheet(pStyleSheet,bDontRemoveHardAttr); } + + if( bUndo ) + EndUndo(); } diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx index de8c521b3119..92bfe93fed56 100644 --- a/svx/source/svdraw/svdedtv2.cxx +++ b/svx/source/svdraw/svdedtv2.cxx @@ -70,178 +70,178 @@ void SdrEditView::ObjOrderChanged(SdrObject* /*pObj*/, size_t /*nOldPos*/, size_ void SdrEditView::MovMarkedToTop() { const size_t nCount=GetMarkedObjectCount(); - if (nCount!=0) - { - const bool bUndo = IsUndoEnabled(); + if (nCount==0) + return; - if( bUndo ) - BegUndo(SvxResId(STR_EditMovToTop),GetDescriptionOfMarkedObjects(),SdrRepeatFunc::MoveToTop); + const bool bUndo = IsUndoEnabled(); - SortMarkedObjects(); - for (size_t nm=0; nmGetOrdNum(); + if( bUndo ) + BegUndo(SvxResId(STR_EditMovToTop),GetDescriptionOfMarkedObjects(),SdrRepeatFunc::MoveToTop); + + SortMarkedObjects(); + for (size_t nm=0; nmGetOrdNum(); + } + bool bChg=false; + SdrObjList* pOL0=nullptr; + size_t nNewPos=0; + for (size_t nm=nCount; nm>0;) + { + --nm; + SdrMark* pM=GetSdrMarkByIndex(nm); + SdrObject* pObj=pM->GetMarkedSdrObj(); + SdrObjList* pOL=pObj->getParentSdrObjListFromSdrObject(); + if (pOL!=pOL0) + { + nNewPos = pOL->GetObjCount()-1; + pOL0=pOL; } - bool bChg=false; - SdrObjList* pOL0=nullptr; - size_t nNewPos=0; - for (size_t nm=nCount; nm>0;) + const size_t nNowPos = pObj->GetOrdNumDirect(); + const tools::Rectangle& rBR=pObj->GetCurrentBoundRect(); + size_t nCmpPos = nNowPos+1; + SdrObject* pMaxObj=GetMaxToTopObj(pObj); + if (pMaxObj!=nullptr) { - --nm; - SdrMark* pM=GetSdrMarkByIndex(nm); - SdrObject* pObj=pM->GetMarkedSdrObj(); - SdrObjList* pOL=pObj->getParentSdrObjListFromSdrObject(); - if (pOL!=pOL0) + size_t nMaxPos=pMaxObj->GetOrdNum(); + if (nMaxPos!=0) + nMaxPos--; + if (nNewPos>nMaxPos) + nNewPos=nMaxPos; // neither go faster... + if (nNewPosGetObj(nCmpPos); + if (pCmpObj==nullptr) { - nNewPos = pOL->GetObjCount()-1; - pOL0=pOL; + OSL_FAIL("MovMarkedToTop(): Reference object not found."); + bEnd=true; } - const size_t nNowPos = pObj->GetOrdNumDirect(); - const tools::Rectangle& rBR=pObj->GetCurrentBoundRect(); - size_t nCmpPos = nNowPos+1; - SdrObject* pMaxObj=GetMaxToTopObj(pObj); - if (pMaxObj!=nullptr) + else if (pCmpObj==pMaxObj) { - size_t nMaxPos=pMaxObj->GetOrdNum(); - if (nMaxPos!=0) - nMaxPos--; - if (nNewPos>nMaxPos) - nNewPos=nMaxPos; // neither go faster... - if (nNewPosGetCurrentBoundRect())) { - SdrObject* pCmpObj=pOL->GetObj(nCmpPos); - if (pCmpObj==nullptr) - { - OSL_FAIL("MovMarkedToTop(): Reference object not found."); - bEnd=true; - } - else if (pCmpObj==pMaxObj) - { - nNewPos=nCmpPos; - nNewPos--; - bEnd=true; - } - else if (rBR.IsOver(pCmpObj->GetCurrentBoundRect())) - { - nNewPos=nCmpPos; - bEnd=true; - } - else - { - nCmpPos++; - } + nNewPos=nCmpPos; + bEnd=true; } - if (nNowPos!=nNewPos) + else { - bChg=true; - pOL->SetObjectOrdNum(nNowPos,nNewPos); - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos)); - ObjOrderChanged(pObj,nNowPos,nNewPos); + nCmpPos++; } - nNewPos--; } + if (nNowPos!=nNewPos) + { + bChg=true; + pOL->SetObjectOrdNum(nNowPos,nNewPos); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos)); + ObjOrderChanged(pObj,nNowPos,nNewPos); + } + nNewPos--; + } - if( bUndo ) - EndUndo(); + if( bUndo ) + EndUndo(); - if (bChg) - MarkListHasChanged(); - } + if (bChg) + MarkListHasChanged(); } void SdrEditView::MovMarkedToBtm() { const size_t nCount=GetMarkedObjectCount(); - if (nCount!=0) - { - const bool bUndo = IsUndoEnabled(); + if (nCount==0) + return; - if( bUndo ) - BegUndo(SvxResId(STR_EditMovToBtm),GetDescriptionOfMarkedObjects(),SdrRepeatFunc::MoveToBottom); + const bool bUndo = IsUndoEnabled(); - SortMarkedObjects(); - for (size_t nm=0; nmGetOrdNum(); - } + if( bUndo ) + BegUndo(SvxResId(STR_EditMovToBtm),GetDescriptionOfMarkedObjects(),SdrRepeatFunc::MoveToBottom); - bool bChg=false; - SdrObjList* pOL0=nullptr; - size_t nNewPos=0; - for (size_t nm=0; nmGetOrdNum(); + } + + bool bChg=false; + SdrObjList* pOL0=nullptr; + size_t nNewPos=0; + for (size_t nm=0; nmGetMarkedSdrObj(); + SdrObjList* pOL=pObj->getParentSdrObjListFromSdrObject(); + if (pOL!=pOL0) { - SdrMark* pM=GetSdrMarkByIndex(nm); - SdrObject* pObj=pM->GetMarkedSdrObj(); - SdrObjList* pOL=pObj->getParentSdrObjListFromSdrObject(); - if (pOL!=pOL0) + nNewPos=0; + pOL0=pOL; + } + const size_t nNowPos = pObj->GetOrdNumDirect(); + const tools::Rectangle& rBR=pObj->GetCurrentBoundRect(); + size_t nCmpPos = nNowPos; + if (nCmpPos>0) + --nCmpPos; + SdrObject* pMaxObj=GetMaxToBtmObj(pObj); + if (pMaxObj!=nullptr) + { + const size_t nMinPos=pMaxObj->GetOrdNum()+1; + if (nNewPosnNowPos) + nNewPos=nNowPos; // nor go in the other direction + } + bool bEnd=false; + // nNewPos in this case is the "maximum" position + // the object may reach without going faster than the object before + // it (multiple selection). + while (nCmpPos>nNewPos && !bEnd) + { + SdrObject* pCmpObj=pOL->GetObj(nCmpPos); + if (pCmpObj==nullptr) { - nNewPos=0; - pOL0=pOL; + OSL_FAIL("MovMarkedToBtm(): Reference object not found."); + bEnd=true; } - const size_t nNowPos = pObj->GetOrdNumDirect(); - const tools::Rectangle& rBR=pObj->GetCurrentBoundRect(); - size_t nCmpPos = nNowPos; - if (nCmpPos>0) - --nCmpPos; - SdrObject* pMaxObj=GetMaxToBtmObj(pObj); - if (pMaxObj!=nullptr) + else if (pCmpObj==pMaxObj) { - const size_t nMinPos=pMaxObj->GetOrdNum()+1; - if (nNewPosnNowPos) - nNewPos=nNowPos; // nor go in the other direction + nNewPos=nCmpPos; + nNewPos++; + bEnd=true; } - bool bEnd=false; - // nNewPos in this case is the "maximum" position - // the object may reach without going faster than the object before - // it (multiple selection). - while (nCmpPos>nNewPos && !bEnd) + else if (rBR.IsOver(pCmpObj->GetCurrentBoundRect())) { - SdrObject* pCmpObj=pOL->GetObj(nCmpPos); - if (pCmpObj==nullptr) - { - OSL_FAIL("MovMarkedToBtm(): Reference object not found."); - bEnd=true; - } - else if (pCmpObj==pMaxObj) - { - nNewPos=nCmpPos; - nNewPos++; - bEnd=true; - } - else if (rBR.IsOver(pCmpObj->GetCurrentBoundRect())) - { - nNewPos=nCmpPos; - bEnd=true; - } - else - { - nCmpPos--; - } + nNewPos=nCmpPos; + bEnd=true; } - if (nNowPos!=nNewPos) + else { - bChg=true; - pOL->SetObjectOrdNum(nNowPos,nNewPos); - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos)); - ObjOrderChanged(pObj,nNowPos,nNewPos); + nCmpPos--; } - nNewPos++; } + if (nNowPos!=nNewPos) + { + bChg=true; + pOL->SetObjectOrdNum(nNowPos,nNewPos); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos)); + ObjOrderChanged(pObj,nNowPos,nNewPos); + } + nNewPos++; + } - if(bUndo) - EndUndo(); + if(bUndo) + EndUndo(); - if(bChg) - MarkListHasChanged(); - } + if(bChg) + MarkListHasChanged(); } void SdrEditView::PutMarkedToTop() @@ -434,52 +434,52 @@ void SdrEditView::ReverseOrderOfMarked() { SortMarkedObjects(); const size_t nMarkCount=GetMarkedObjectCount(); - if (nMarkCount>0) - { - bool bChg=false; + if (nMarkCount<=0) + return; - bool bUndo = IsUndoEnabled(); - if( bUndo ) - BegUndo(SvxResId(STR_EditRevOrder),GetDescriptionOfMarkedObjects(),SdrRepeatFunc::ReverseOrder); - - size_t a=0; - do { - // take into account selection across multiple PageViews - size_t b=a+1; - while (bGetObjList(); - size_t c=b; - if (aGetOrdNum(); - } - while (aGetOrdNumDirect(); - const size_t nOrd2=pObj2->GetOrdNumDirect(); - if( bUndo ) - { - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj1,nOrd1,nOrd2)); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj2,nOrd2-1,nOrd1)); - } - pOL->SetObjectOrdNum(nOrd1,nOrd2); - // Obj 2 has moved forward by one position, so now nOrd2-1 - pOL->SetObjectOrdNum(nOrd2-1,nOrd1); - // use Replace instead of SetOrdNum for performance reasons (recalculation of Ordnums) - ++a; - --c; - bChg=true; + bool bChg=false; + + bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(SvxResId(STR_EditRevOrder),GetDescriptionOfMarkedObjects(),SdrRepeatFunc::ReverseOrder); + + size_t a=0; + do { + // take into account selection across multiple PageViews + size_t b=a+1; + while (bGetObjList(); + size_t c=b; + if (aGetOrdNum(); + } + while (aGetOrdNumDirect(); + const size_t nOrd2=pObj2->GetOrdNumDirect(); + if( bUndo ) + { + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj1,nOrd1,nOrd2)); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj2,nOrd2-1,nOrd1)); } - a=b+1; - } while (aSetObjectOrdNum(nOrd1,nOrd2); + // Obj 2 has moved forward by one position, so now nOrd2-1 + pOL->SetObjectOrdNum(nOrd2-1,nOrd1); + // use Replace instead of SetOrdNum for performance reasons (recalculation of Ordnums) + ++a; + --c; + bChg=true; + } + a=b+1; + } while (aGetItemPool(), - svl::Items{}); + if(!(pSource && pDest)) + return; - aSet.Put(pSource->GetMergedItemSet()); + SfxItemSet aSet(mpModel->GetItemPool(), + svl::Items{}); - pDest->ClearMergedItem(); - pDest->SetMergedItemSet(aSet); + aSet.Put(pSource->GetMergedItemSet()); - pDest->NbcSetLayer(pSource->GetLayer()); - pDest->NbcSetStyleSheet(pSource->GetStyleSheet(), true); - } + pDest->ClearMergedItem(); + pDest->SetMergedItemSet(aSet); + + pDest->NbcSetLayer(pSource->GetLayer()); + pDest->NbcSetStyleSheet(pSource->GetStyleSheet(), true); } bool SdrEditView::ImpCanConvertForCombine1(const SdrObject* pObj) @@ -772,216 +772,216 @@ void SdrEditView::DistributeMarkedObjects(weld::Window* pParent) { const size_t nMark(GetMarkedObjectCount()); - if(nMark > 2) - { - SfxItemSet aNewAttr(mpModel->GetItemPool()); + if(nMark <= 2) + return; - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr pDlg(pFact->CreateSvxDistributeDialog(pParent, aNewAttr)); + SfxItemSet aNewAttr(mpModel->GetItemPool()); - sal_uInt16 nResult = pDlg->Execute(); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr pDlg(pFact->CreateSvxDistributeDialog(pParent, aNewAttr)); - if(nResult == RET_OK) - { - SvxDistributeHorizontal eHor = pDlg->GetDistributeHor(); - SvxDistributeVertical eVer = pDlg->GetDistributeVer(); - ImpDistributeEntryList aEntryList; - ImpDistributeEntryList::iterator itEntryList; - sal_uInt32 nFullLength; + sal_uInt16 nResult = pDlg->Execute(); - const bool bUndo = IsUndoEnabled(); - if( bUndo ) - BegUndo(); + if(nResult != RET_OK) + return; - if(eHor != SvxDistributeHorizontal::NONE) - { - // build sorted entry list - nFullLength = 0; + SvxDistributeHorizontal eHor = pDlg->GetDistributeHor(); + SvxDistributeVertical eVer = pDlg->GetDistributeVer(); + ImpDistributeEntryList aEntryList; + ImpDistributeEntryList::iterator itEntryList; + sal_uInt32 nFullLength; - for( size_t a = 0; a < nMark; ++a ) - { - SdrMark* pMark = GetSdrMarkByIndex(a); - ImpDistributeEntry aNew; + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(); - aNew.mpObj = pMark->GetMarkedSdrObj(); + if(eHor != SvxDistributeHorizontal::NONE) + { + // build sorted entry list + nFullLength = 0; - switch(eHor) - { - case SvxDistributeHorizontal::Left: - { - aNew.mnPos = aNew.mpObj->GetSnapRect().Left(); - break; - } - case SvxDistributeHorizontal::Center: - { - aNew.mnPos = (aNew.mpObj->GetSnapRect().Right() + aNew.mpObj->GetSnapRect().Left()) / 2; - break; - } - case SvxDistributeHorizontal::Distance: - { - aNew.mnLength = aNew.mpObj->GetSnapRect().GetWidth() + 1; - nFullLength += aNew.mnLength; - aNew.mnPos = (aNew.mpObj->GetSnapRect().Right() + aNew.mpObj->GetSnapRect().Left()) / 2; - break; - } - case SvxDistributeHorizontal::Right: - { - aNew.mnPos = aNew.mpObj->GetSnapRect().Right(); - break; - } - default: break; - } + for( size_t a = 0; a < nMark; ++a ) + { + SdrMark* pMark = GetSdrMarkByIndex(a); + ImpDistributeEntry aNew; - itEntryList = std::find_if(aEntryList.begin(), aEntryList.end(), - [&aNew](const ImpDistributeEntry& rEntry) { return rEntry.mnPos >= aNew.mnPos; }); - if ( itEntryList < aEntryList.end() ) - aEntryList.insert( itEntryList, aNew ); - else - aEntryList.push_back( aNew ); - } + aNew.mpObj = pMark->GetMarkedSdrObj(); - if(eHor == SvxDistributeHorizontal::Distance) + switch(eHor) + { + case SvxDistributeHorizontal::Left: { - // calculate room in-between - sal_Int32 nWidth = GetAllMarkedBoundRect().GetWidth() + 1; - double fStepWidth = (static_cast(nWidth) - static_cast(nFullLength)) / static_cast(aEntryList.size() - 1); - double fStepStart = static_cast(aEntryList[ 0 ].mnPos); - fStepStart += fStepWidth + static_cast((aEntryList[ 0 ].mnLength + aEntryList[ 1 ].mnLength) / 2); - - // move entries 1..n-1 - for( size_t i = 1, n = aEntryList.size()-1; i < n; ++i ) - { - ImpDistributeEntry& rCurr = aEntryList[ i ]; - ImpDistributeEntry& rNext = aEntryList[ i + 1]; - sal_Int32 nDelta = static_cast(fStepStart + 0.5) - rCurr.mnPos; - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*rCurr.mpObj)); - rCurr.mpObj->Move(Size(nDelta, 0)); - fStepStart += fStepWidth + static_cast((rCurr.mnLength + rNext.mnLength) / 2); - } + aNew.mnPos = aNew.mpObj->GetSnapRect().Left(); + break; } - else + case SvxDistributeHorizontal::Center: { - // calculate distances - sal_Int32 nWidth = aEntryList[ aEntryList.size() - 1 ].mnPos - aEntryList[ 0 ].mnPos; - double fStepWidth = static_cast(nWidth) / static_cast(aEntryList.size() - 1); - double fStepStart = static_cast(aEntryList[ 0 ].mnPos); - fStepStart += fStepWidth; - - // move entries 1..n-1 - for( size_t i = 1 ; i < aEntryList.size()-1 ; ++i ) - { - ImpDistributeEntry& rCurr = aEntryList[ i ]; - sal_Int32 nDelta = static_cast(fStepStart + 0.5) - rCurr.mnPos; - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*rCurr.mpObj)); - rCurr.mpObj->Move(Size(nDelta, 0)); - fStepStart += fStepWidth; - } + aNew.mnPos = (aNew.mpObj->GetSnapRect().Right() + aNew.mpObj->GetSnapRect().Left()) / 2; + break; } - - // clear list - aEntryList.clear(); + case SvxDistributeHorizontal::Distance: + { + aNew.mnLength = aNew.mpObj->GetSnapRect().GetWidth() + 1; + nFullLength += aNew.mnLength; + aNew.mnPos = (aNew.mpObj->GetSnapRect().Right() + aNew.mpObj->GetSnapRect().Left()) / 2; + break; + } + case SvxDistributeHorizontal::Right: + { + aNew.mnPos = aNew.mpObj->GetSnapRect().Right(); + break; + } + default: break; } - if(eVer != SvxDistributeVertical::NONE) + itEntryList = std::find_if(aEntryList.begin(), aEntryList.end(), + [&aNew](const ImpDistributeEntry& rEntry) { return rEntry.mnPos >= aNew.mnPos; }); + if ( itEntryList < aEntryList.end() ) + aEntryList.insert( itEntryList, aNew ); + else + aEntryList.push_back( aNew ); + } + + if(eHor == SvxDistributeHorizontal::Distance) + { + // calculate room in-between + sal_Int32 nWidth = GetAllMarkedBoundRect().GetWidth() + 1; + double fStepWidth = (static_cast(nWidth) - static_cast(nFullLength)) / static_cast(aEntryList.size() - 1); + double fStepStart = static_cast(aEntryList[ 0 ].mnPos); + fStepStart += fStepWidth + static_cast((aEntryList[ 0 ].mnLength + aEntryList[ 1 ].mnLength) / 2); + + // move entries 1..n-1 + for( size_t i = 1, n = aEntryList.size()-1; i < n; ++i ) { - // build sorted entry list - nFullLength = 0; + ImpDistributeEntry& rCurr = aEntryList[ i ]; + ImpDistributeEntry& rNext = aEntryList[ i + 1]; + sal_Int32 nDelta = static_cast(fStepStart + 0.5) - rCurr.mnPos; + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*rCurr.mpObj)); + rCurr.mpObj->Move(Size(nDelta, 0)); + fStepStart += fStepWidth + static_cast((rCurr.mnLength + rNext.mnLength) / 2); + } + } + else + { + // calculate distances + sal_Int32 nWidth = aEntryList[ aEntryList.size() - 1 ].mnPos - aEntryList[ 0 ].mnPos; + double fStepWidth = static_cast(nWidth) / static_cast(aEntryList.size() - 1); + double fStepStart = static_cast(aEntryList[ 0 ].mnPos); + fStepStart += fStepWidth; + + // move entries 1..n-1 + for( size_t i = 1 ; i < aEntryList.size()-1 ; ++i ) + { + ImpDistributeEntry& rCurr = aEntryList[ i ]; + sal_Int32 nDelta = static_cast(fStepStart + 0.5) - rCurr.mnPos; + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*rCurr.mpObj)); + rCurr.mpObj->Move(Size(nDelta, 0)); + fStepStart += fStepWidth; + } + } - for( size_t a = 0; a < nMark; ++a ) - { - SdrMark* pMark = GetSdrMarkByIndex(a); - ImpDistributeEntry aNew; + // clear list + aEntryList.clear(); + } - aNew.mpObj = pMark->GetMarkedSdrObj(); + if(eVer != SvxDistributeVertical::NONE) + { + // build sorted entry list + nFullLength = 0; - switch(eVer) - { - case SvxDistributeVertical::Top: - { - aNew.mnPos = aNew.mpObj->GetSnapRect().Top(); - break; - } - case SvxDistributeVertical::Center: - { - aNew.mnPos = (aNew.mpObj->GetSnapRect().Bottom() + aNew.mpObj->GetSnapRect().Top()) / 2; - break; - } - case SvxDistributeVertical::Distance: - { - aNew.mnLength = aNew.mpObj->GetSnapRect().GetHeight() + 1; - nFullLength += aNew.mnLength; - aNew.mnPos = (aNew.mpObj->GetSnapRect().Bottom() + aNew.mpObj->GetSnapRect().Top()) / 2; - break; - } - case SvxDistributeVertical::Bottom: - { - aNew.mnPos = aNew.mpObj->GetSnapRect().Bottom(); - break; - } - default: break; - } + for( size_t a = 0; a < nMark; ++a ) + { + SdrMark* pMark = GetSdrMarkByIndex(a); + ImpDistributeEntry aNew; - itEntryList = std::find_if(aEntryList.begin(), aEntryList.end(), - [&aNew](const ImpDistributeEntry& rEntry) { return rEntry.mnPos >= aNew.mnPos; }); - if ( itEntryList < aEntryList.end() ) - aEntryList.insert( itEntryList, aNew ); - else - aEntryList.push_back( aNew ); - } + aNew.mpObj = pMark->GetMarkedSdrObj(); - if(eVer == SvxDistributeVertical::Distance) + switch(eVer) + { + case SvxDistributeVertical::Top: { - // calculate room in-between - sal_Int32 nHeight = GetAllMarkedBoundRect().GetHeight() + 1; - double fStepWidth = (static_cast(nHeight) - static_cast(nFullLength)) / static_cast(aEntryList.size() - 1); - double fStepStart = static_cast(aEntryList[ 0 ].mnPos); - fStepStart += fStepWidth + static_cast((aEntryList[ 0 ].mnLength + aEntryList[ 1 ].mnLength) / 2); - - // move entries 1..n-1 - for( size_t i = 1, n = aEntryList.size()-1; i < n; ++i) - { - ImpDistributeEntry& rCurr = aEntryList[ i ]; - ImpDistributeEntry& rNext = aEntryList[ i + 1 ]; - sal_Int32 nDelta = static_cast(fStepStart + 0.5) - rCurr.mnPos; - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*rCurr.mpObj)); - rCurr.mpObj->Move(Size(0, nDelta)); - fStepStart += fStepWidth + static_cast((rCurr.mnLength + rNext.mnLength) / 2); - } + aNew.mnPos = aNew.mpObj->GetSnapRect().Top(); + break; } - else + case SvxDistributeVertical::Center: { - // calculate distances - sal_Int32 nHeight = aEntryList[ aEntryList.size() - 1 ].mnPos - aEntryList[ 0 ].mnPos; - double fStepWidth = static_cast(nHeight) / static_cast(aEntryList.size() - 1); - double fStepStart = static_cast(aEntryList[ 0 ].mnPos); - fStepStart += fStepWidth; - - // move entries 1..n-1 - for(size_t i = 1, n = aEntryList.size()-1; i < n; ++i) - { - ImpDistributeEntry& rCurr = aEntryList[ i ]; - sal_Int32 nDelta = static_cast(fStepStart + 0.5) - rCurr.mnPos; - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*rCurr.mpObj)); - rCurr.mpObj->Move(Size(0, nDelta)); - fStepStart += fStepWidth; - } + aNew.mnPos = (aNew.mpObj->GetSnapRect().Bottom() + aNew.mpObj->GetSnapRect().Top()) / 2; + break; } - - // clear list - aEntryList.clear(); + case SvxDistributeVertical::Distance: + { + aNew.mnLength = aNew.mpObj->GetSnapRect().GetHeight() + 1; + nFullLength += aNew.mnLength; + aNew.mnPos = (aNew.mpObj->GetSnapRect().Bottom() + aNew.mpObj->GetSnapRect().Top()) / 2; + break; + } + case SvxDistributeVertical::Bottom: + { + aNew.mnPos = aNew.mpObj->GetSnapRect().Bottom(); + break; + } + default: break; } - // UNDO-Comment and end of UNDO - mpModel->SetUndoComment(SvxResId(STR_DistributeMarkedObjects)); + itEntryList = std::find_if(aEntryList.begin(), aEntryList.end(), + [&aNew](const ImpDistributeEntry& rEntry) { return rEntry.mnPos >= aNew.mnPos; }); + if ( itEntryList < aEntryList.end() ) + aEntryList.insert( itEntryList, aNew ); + else + aEntryList.push_back( aNew ); + } - if( bUndo ) - EndUndo(); + if(eVer == SvxDistributeVertical::Distance) + { + // calculate room in-between + sal_Int32 nHeight = GetAllMarkedBoundRect().GetHeight() + 1; + double fStepWidth = (static_cast(nHeight) - static_cast(nFullLength)) / static_cast(aEntryList.size() - 1); + double fStepStart = static_cast(aEntryList[ 0 ].mnPos); + fStepStart += fStepWidth + static_cast((aEntryList[ 0 ].mnLength + aEntryList[ 1 ].mnLength) / 2); + + // move entries 1..n-1 + for( size_t i = 1, n = aEntryList.size()-1; i < n; ++i) + { + ImpDistributeEntry& rCurr = aEntryList[ i ]; + ImpDistributeEntry& rNext = aEntryList[ i + 1 ]; + sal_Int32 nDelta = static_cast(fStepStart + 0.5) - rCurr.mnPos; + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*rCurr.mpObj)); + rCurr.mpObj->Move(Size(0, nDelta)); + fStepStart += fStepWidth + static_cast((rCurr.mnLength + rNext.mnLength) / 2); + } + } + else + { + // calculate distances + sal_Int32 nHeight = aEntryList[ aEntryList.size() - 1 ].mnPos - aEntryList[ 0 ].mnPos; + double fStepWidth = static_cast(nHeight) / static_cast(aEntryList.size() - 1); + double fStepStart = static_cast(aEntryList[ 0 ].mnPos); + fStepStart += fStepWidth; + + // move entries 1..n-1 + for(size_t i = 1, n = aEntryList.size()-1; i < n; ++i) + { + ImpDistributeEntry& rCurr = aEntryList[ i ]; + sal_Int32 nDelta = static_cast(fStepStart + 0.5) - rCurr.mnPos; + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*rCurr.mpObj)); + rCurr.mpObj->Move(Size(0, nDelta)); + fStepStart += fStepWidth; + } } + + // clear list + aEntryList.clear(); } + + // UNDO-Comment and end of UNDO + mpModel->SetUndoComment(SvxResId(STR_DistributeMarkedObjects)); + + if( bUndo ) + EndUndo(); } void SdrEditView::MergeMarkedObjects(SdrMergeMode eMode) @@ -1771,98 +1771,98 @@ void SdrEditView::DismantleMarkedObjects(bool bMakeLines) void SdrEditView::GroupMarked() { - if (AreObjectsMarked()) + if (!AreObjectsMarked()) + return; + + SortMarkedObjects(); + + const bool bUndo = IsUndoEnabled(); + if( bUndo ) { - SortMarkedObjects(); + BegUndo(SvxResId(STR_EditGroup),GetDescriptionOfMarkedObjects(),SdrRepeatFunc::Group); - const bool bUndo = IsUndoEnabled(); - if( bUndo ) + for(size_t nm = GetMarkedObjectCount(); nm>0; ) { - BegUndo(SvxResId(STR_EditGroup),GetDescriptionOfMarkedObjects(),SdrRepeatFunc::Group); - - for(size_t nm = GetMarkedObjectCount(); nm>0; ) - { - // add UndoActions for all affected objects - --nm; - SdrMark* pM=GetSdrMarkByIndex(nm); - SdrObject* pObj = pM->GetMarkedSdrObj(); - AddUndoActions( CreateConnectorUndo( *pObj ) ); - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoRemoveObject( *pObj )); - } + // add UndoActions for all affected objects + --nm; + SdrMark* pM=GetSdrMarkByIndex(nm); + SdrObject* pObj = pM->GetMarkedSdrObj(); + AddUndoActions( CreateConnectorUndo( *pObj ) ); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoRemoveObject( *pObj )); } + } - SdrMarkList aNewMark; - SdrPageView* pPV = GetSdrPageView(); + SdrMarkList aNewMark; + SdrPageView* pPV = GetSdrPageView(); - if(pPV) + if(pPV) + { + SdrObjList* pCurrentLst=pPV->GetObjList(); + SdrObjList* pSrcLst=pCurrentLst; + SdrObjList* pSrcLst0=pSrcLst; + // make sure OrdNums are correct + if (pSrcLst->IsObjOrdNumsDirty()) + pSrcLst->RecalcObjOrdNums(); + SdrObject* pGrp=nullptr; + SdrObjList* pDstLst=nullptr; + // if all selected objects come from foreign object lists. + // the group object is the last one in the list. + size_t nInsPos=pSrcLst->GetObjCount(); + bool bNeedInsPos=true; + for (size_t nm=GetMarkedObjectCount(); nm>0;) { - SdrObjList* pCurrentLst=pPV->GetObjList(); - SdrObjList* pSrcLst=pCurrentLst; - SdrObjList* pSrcLst0=pSrcLst; - // make sure OrdNums are correct - if (pSrcLst->IsObjOrdNumsDirty()) - pSrcLst->RecalcObjOrdNums(); - SdrObject* pGrp=nullptr; - SdrObjList* pDstLst=nullptr; - // if all selected objects come from foreign object lists. - // the group object is the last one in the list. - size_t nInsPos=pSrcLst->GetObjCount(); - bool bNeedInsPos=true; - for (size_t nm=GetMarkedObjectCount(); nm>0;) + --nm; + SdrMark* pM=GetSdrMarkByIndex(nm); + if (pM->GetPageView()==pPV) { - --nm; - SdrMark* pM=GetSdrMarkByIndex(nm); - if (pM->GetPageView()==pPV) + SdrObject* pObj=pM->GetMarkedSdrObj(); + if (nullptr==pGrp) { - SdrObject* pObj=pM->GetMarkedSdrObj(); - if (nullptr==pGrp) - { - pGrp = new SdrObjGroup(pObj->getSdrModelFromSdrObject()); - pDstLst=pGrp->GetSubList(); - DBG_ASSERT(pDstLst!=nullptr,"Alleged group object doesn't return object list."); - } - pSrcLst=pObj->getParentSdrObjListFromSdrObject(); - if (pSrcLst!=pSrcLst0) - { - if (pSrcLst->IsObjOrdNumsDirty()) - pSrcLst->RecalcObjOrdNums(); - } - bool bForeignList=pSrcLst!=pCurrentLst; - if (!bForeignList && bNeedInsPos) - { - nInsPos=pObj->GetOrdNum(); // this way, all ObjOrdNum of the page are set - nInsPos++; - bNeedInsPos=false; - } - pSrcLst->RemoveObject(pObj->GetOrdNumDirect()); - if (!bForeignList) - nInsPos--; // correct InsertPos - pDstLst->InsertObject(pObj,0); - GetMarkedObjectListWriteAccess().DeleteMark(nm); - pSrcLst0=pSrcLst; + pGrp = new SdrObjGroup(pObj->getSdrModelFromSdrObject()); + pDstLst=pGrp->GetSubList(); + DBG_ASSERT(pDstLst!=nullptr,"Alleged group object doesn't return object list."); + } + pSrcLst=pObj->getParentSdrObjListFromSdrObject(); + if (pSrcLst!=pSrcLst0) + { + if (pSrcLst->IsObjOrdNumsDirty()) + pSrcLst->RecalcObjOrdNums(); + } + bool bForeignList=pSrcLst!=pCurrentLst; + if (!bForeignList && bNeedInsPos) + { + nInsPos=pObj->GetOrdNum(); // this way, all ObjOrdNum of the page are set + nInsPos++; + bNeedInsPos=false; } + pSrcLst->RemoveObject(pObj->GetOrdNumDirect()); + if (!bForeignList) + nInsPos--; // correct InsertPos + pDstLst->InsertObject(pObj,0); + GetMarkedObjectListWriteAccess().DeleteMark(nm); + pSrcLst0=pSrcLst; } - if (pGrp!=nullptr) + } + if (pGrp!=nullptr) + { + aNewMark.InsertEntry(SdrMark(pGrp,pPV)); + const size_t nCount=pDstLst->GetObjCount(); + pCurrentLst->InsertObject(pGrp,nInsPos); + if( bUndo ) { - aNewMark.InsertEntry(SdrMark(pGrp,pPV)); - const size_t nCount=pDstLst->GetObjCount(); - pCurrentLst->InsertObject(pGrp,nInsPos); - if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pGrp,true)); // no recalculation! + for (size_t no=0; noGetSdrUndoFactory().CreateUndoNewObject(*pGrp,true)); // no recalculation! - for (size_t no=0; noGetSdrUndoFactory().CreateUndoInsertObject(*pDstLst->GetObj(no))); - } + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoInsertObject(*pDstLst->GetObj(no))); } } } - GetMarkedObjectListWriteAccess().Merge(aNewMark); - MarkListHasChanged(); - - if( bUndo ) - EndUndo(); } + GetMarkedObjectListWriteAccess().Merge(aNewMark); + MarkListHasChanged(); + + if( bUndo ) + EndUndo(); } @@ -1987,57 +1987,57 @@ SdrObject* SdrEditView::ImpConvertOneObj(SdrObject* pObj, bool bPath, bool bLine void SdrEditView::ImpConvertTo(bool bPath, bool bLineToArea) { - if (AreObjectsMarked()) { - bool bMrkChg = false; - const size_t nMarkCount=GetMarkedObjectCount(); - const char* pDscrID = nullptr; - if(bLineToArea) - { - if(nMarkCount == 1) - pDscrID = STR_EditConvToContour; - else - pDscrID = STR_EditConvToContours; + if (!AreObjectsMarked()) return; - BegUndo(SvxResId(pDscrID), GetDescriptionOfMarkedObjects()); - } + bool bMrkChg = false; + const size_t nMarkCount=GetMarkedObjectCount(); + const char* pDscrID = nullptr; + if(bLineToArea) + { + if(nMarkCount == 1) + pDscrID = STR_EditConvToContour; else - { - if (bPath) { - if (nMarkCount==1) pDscrID=STR_EditConvToCurve; - else pDscrID=STR_EditConvToCurves; - BegUndo(SvxResId(pDscrID),GetDescriptionOfMarkedObjects(),SdrRepeatFunc::ConvertToPath); - } else { - if (nMarkCount==1) pDscrID=STR_EditConvToPoly; - else pDscrID=STR_EditConvToPolys; - BegUndo(SvxResId(pDscrID),GetDescriptionOfMarkedObjects(),SdrRepeatFunc::ConvertToPoly); - } + pDscrID = STR_EditConvToContours; + + BegUndo(SvxResId(pDscrID), GetDescriptionOfMarkedObjects()); + } + else + { + if (bPath) { + if (nMarkCount==1) pDscrID=STR_EditConvToCurve; + else pDscrID=STR_EditConvToCurves; + BegUndo(SvxResId(pDscrID),GetDescriptionOfMarkedObjects(),SdrRepeatFunc::ConvertToPath); + } else { + if (nMarkCount==1) pDscrID=STR_EditConvToPoly; + else pDscrID=STR_EditConvToPolys; + BegUndo(SvxResId(pDscrID),GetDescriptionOfMarkedObjects(),SdrRepeatFunc::ConvertToPoly); } - for (size_t nm=nMarkCount; nm>0;) { - --nm; - SdrMark* pM=GetSdrMarkByIndex(nm); - SdrObject* pObj=pM->GetMarkedSdrObj(); - SdrPageView* pPV=pM->GetPageView(); - if (pObj->IsGroupObject() && !pObj->Is3DObj()) { - SdrObject* pGrp=pObj; - SdrObjListIter aIter(*pGrp, SdrIterMode::DeepNoGroups); - while (aIter.IsMore()) { - pObj=aIter.Next(); - ImpConvertOneObj(pObj,bPath,bLineToArea); - } - } else { - SdrObject* pNewObj=ImpConvertOneObj(pObj,bPath,bLineToArea); - if (pNewObj!=nullptr) { - bMrkChg=true; - GetMarkedObjectListWriteAccess().ReplaceMark(SdrMark(pNewObj,pPV),nm); - } + } + for (size_t nm=nMarkCount; nm>0;) { + --nm; + SdrMark* pM=GetSdrMarkByIndex(nm); + SdrObject* pObj=pM->GetMarkedSdrObj(); + SdrPageView* pPV=pM->GetPageView(); + if (pObj->IsGroupObject() && !pObj->Is3DObj()) { + SdrObject* pGrp=pObj; + SdrObjListIter aIter(*pGrp, SdrIterMode::DeepNoGroups); + while (aIter.IsMore()) { + pObj=aIter.Next(); + ImpConvertOneObj(pObj,bPath,bLineToArea); + } + } else { + SdrObject* pNewObj=ImpConvertOneObj(pObj,bPath,bLineToArea); + if (pNewObj!=nullptr) { + bMrkChg=true; + GetMarkedObjectListWriteAccess().ReplaceMark(SdrMark(pNewObj,pPV),nm); } } - EndUndo(); - if (bMrkChg) - { - AdjustMarkHdl(); - MarkListHasChanged(); - } + } + EndUndo(); + if (bMrkChg) + { + AdjustMarkHdl(); + MarkListHasChanged(); } } diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index 9551cf985b03..eaf8a89922b5 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -218,22 +218,22 @@ void SdrObjEditView::TakeActionRect(tools::Rectangle& rRect) const void SdrObjEditView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) { SdrGlueEditView::Notify(rBC, rHint); - if (pTextEditOutliner != nullptr) + if (pTextEditOutliner == nullptr) + return; + + // change of printer while editing + if (rHint.GetId() != SfxHintId::ThisIsAnSdrHint) + return; + + const SdrHint* pSdrHint = static_cast(&rHint); + SdrHintKind eKind = pSdrHint->GetKind(); + if (eKind == SdrHintKind::RefDeviceChange) { - // change of printer while editing - if (rHint.GetId() == SfxHintId::ThisIsAnSdrHint) - { - const SdrHint* pSdrHint = static_cast(&rHint); - SdrHintKind eKind = pSdrHint->GetKind(); - if (eKind == SdrHintKind::RefDeviceChange) - { - pTextEditOutliner->SetRefDevice(mpModel->GetRefDevice()); - } - if (eKind == SdrHintKind::DefaultTabChange) - { - pTextEditOutliner->SetDefTab(mpModel->GetDefaultTabulator()); - } - } + pTextEditOutliner->SetRefDevice(mpModel->GetRefDevice()); + } + if (eKind == SdrHintKind::DefaultTabChange) + { + pTextEditOutliner->SetDefTab(mpModel->GetDefaultTabulator()); } } @@ -243,142 +243,141 @@ void SdrObjEditView::ModelHasChanged() if (mxTextEditObj.is() && !mxTextEditObj->IsInserted()) SdrEndTextEdit(); // object deleted // TextEditObj changed? - if (IsTextEdit()) + if (!IsTextEdit()) + return; + + SdrTextObj* pTextObj = mxTextEditObj.get(); + if (pTextObj != nullptr) { - SdrTextObj* pTextObj = mxTextEditObj.get(); - if (pTextObj != nullptr) - { - size_t nOutlViewCnt = pTextEditOutliner->GetViewCount(); - bool bAreaChg = false; - bool bAnchorChg = false; - bool bColorChg = false; - bool bContourFrame = pTextObj->IsContourTextFrame(); - EEAnchorMode eNewAnchor(EEAnchorMode::VCenterHCenter); - tools::Rectangle aOldArea(aMinTextEditArea); - aOldArea.Union(aTextEditArea); - Color aNewColor; - { // check area - Size aPaperMin1; - Size aPaperMax1; - tools::Rectangle aEditArea1; - tools::Rectangle aMinArea1; - pTextObj->TakeTextEditArea(&aPaperMin1, &aPaperMax1, &aEditArea1, &aMinArea1); - Point aPvOfs(pTextObj->GetTextEditOffset()); - - // add possible GridOffset to up-to-now view-independent EditAreas - basegfx::B2DVector aGridOffset(0.0, 0.0); - if (getPossibleGridOffsetForSdrObject(aGridOffset, pTextObj, GetSdrPageView())) - { - const Point aOffset(basegfx::fround(aGridOffset.getX()), - basegfx::fround(aGridOffset.getY())); + size_t nOutlViewCnt = pTextEditOutliner->GetViewCount(); + bool bAreaChg = false; + bool bAnchorChg = false; + bool bColorChg = false; + bool bContourFrame = pTextObj->IsContourTextFrame(); + EEAnchorMode eNewAnchor(EEAnchorMode::VCenterHCenter); + tools::Rectangle aOldArea(aMinTextEditArea); + aOldArea.Union(aTextEditArea); + Color aNewColor; + { // check area + Size aPaperMin1; + Size aPaperMax1; + tools::Rectangle aEditArea1; + tools::Rectangle aMinArea1; + pTextObj->TakeTextEditArea(&aPaperMin1, &aPaperMax1, &aEditArea1, &aMinArea1); + Point aPvOfs(pTextObj->GetTextEditOffset()); - aEditArea1 += aOffset; - aMinArea1 += aOffset; - } + // add possible GridOffset to up-to-now view-independent EditAreas + basegfx::B2DVector aGridOffset(0.0, 0.0); + if (getPossibleGridOffsetForSdrObject(aGridOffset, pTextObj, GetSdrPageView())) + { + const Point aOffset(basegfx::fround(aGridOffset.getX()), + basegfx::fround(aGridOffset.getY())); - aEditArea1.Move(aPvOfs.X(), aPvOfs.Y()); - aMinArea1.Move(aPvOfs.X(), aPvOfs.Y()); - tools::Rectangle aNewArea(aMinArea1); - aNewArea.Union(aEditArea1); + aEditArea1 += aOffset; + aMinArea1 += aOffset; + } - if (aNewArea != aOldArea || aEditArea1 != aTextEditArea - || aMinArea1 != aMinTextEditArea - || pTextEditOutliner->GetMinAutoPaperSize() != aPaperMin1 - || pTextEditOutliner->GetMaxAutoPaperSize() != aPaperMax1) + aEditArea1.Move(aPvOfs.X(), aPvOfs.Y()); + aMinArea1.Move(aPvOfs.X(), aPvOfs.Y()); + tools::Rectangle aNewArea(aMinArea1); + aNewArea.Union(aEditArea1); + + if (aNewArea != aOldArea || aEditArea1 != aTextEditArea || aMinArea1 != aMinTextEditArea + || pTextEditOutliner->GetMinAutoPaperSize() != aPaperMin1 + || pTextEditOutliner->GetMaxAutoPaperSize() != aPaperMax1) + { + aTextEditArea = aEditArea1; + aMinTextEditArea = aMinArea1; + pTextEditOutliner->SetUpdateMode(false); + pTextEditOutliner->SetMinAutoPaperSize(aPaperMin1); + pTextEditOutliner->SetMaxAutoPaperSize(aPaperMax1); + pTextEditOutliner->SetPaperSize(Size(0, 0)); // re-format Outliner + if (!bContourFrame) { - aTextEditArea = aEditArea1; - aMinTextEditArea = aMinArea1; - pTextEditOutliner->SetUpdateMode(false); - pTextEditOutliner->SetMinAutoPaperSize(aPaperMin1); - pTextEditOutliner->SetMaxAutoPaperSize(aPaperMax1); - pTextEditOutliner->SetPaperSize(Size(0, 0)); // re-format Outliner - if (!bContourFrame) - { - pTextEditOutliner->ClearPolygon(); - EEControlBits nStat = pTextEditOutliner->GetControlWord(); - nStat |= EEControlBits::AUTOPAGESIZE; - pTextEditOutliner->SetControlWord(nStat); - } - else - { - EEControlBits nStat = pTextEditOutliner->GetControlWord(); - nStat &= ~EEControlBits::AUTOPAGESIZE; - pTextEditOutliner->SetControlWord(nStat); - tools::Rectangle aAnchorRect; - pTextObj->TakeTextAnchorRect(aAnchorRect); - pTextObj->ImpSetContourPolygon(*pTextEditOutliner, aAnchorRect, true); - } - for (size_t nOV = 0; nOV < nOutlViewCnt; nOV++) - { - OutlinerView* pOLV = pTextEditOutliner->GetView(nOV); - EVControlBits nStat0 = pOLV->GetControlWord(); - EVControlBits nStat = nStat0; - // AutoViewSize only if not ContourFrame. - if (!bContourFrame) - nStat |= EVControlBits::AUTOSIZE; - else - nStat &= ~EVControlBits::AUTOSIZE; - if (nStat != nStat0) - pOLV->SetControlWord(nStat); - } - pTextEditOutliner->SetUpdateMode(true); - bAreaChg = true; + pTextEditOutliner->ClearPolygon(); + EEControlBits nStat = pTextEditOutliner->GetControlWord(); + nStat |= EEControlBits::AUTOPAGESIZE; + pTextEditOutliner->SetControlWord(nStat); + } + else + { + EEControlBits nStat = pTextEditOutliner->GetControlWord(); + nStat &= ~EEControlBits::AUTOPAGESIZE; + pTextEditOutliner->SetControlWord(nStat); + tools::Rectangle aAnchorRect; + pTextObj->TakeTextAnchorRect(aAnchorRect); + pTextObj->ImpSetContourPolygon(*pTextEditOutliner, aAnchorRect, true); } - } - if (pTextEditOutlinerView != nullptr) - { // check fill and anchor - EEAnchorMode eOldAnchor = pTextEditOutlinerView->GetAnchorMode(); - eNewAnchor = pTextObj->GetOutlinerViewAnchorMode(); - bAnchorChg = eOldAnchor != eNewAnchor; - Color aOldColor(pTextEditOutlinerView->GetBackgroundColor()); - aNewColor = GetTextEditBackgroundColor(*this); - bColorChg = aOldColor != aNewColor; - } - // refresh always when it's a contour frame. That - // refresh is necessary since it triggers the repaint - // which makes the Handles visible. Changes at TakeTextRect() - // seem to have resulted in a case where no refresh is executed. - // Before that, a refresh must have been always executed - // (else this error would have happened earlier), thus I - // even think here a refresh should be done always. - // Since follow-up problems cannot even be guessed I only - // add this one more case to the if below. - // BTW: It's VERY bad style that here, inside ModelHasChanged() - // the outliner is again massively changed for the text object - // in text edit mode. Normally, all necessary data should be - // set at SdrBeginTextEdit(). Some changes and value assigns in - // SdrBeginTextEdit() are completely useless since they are set here - // again on ModelHasChanged(). - if (bContourFrame || bAreaChg || bAnchorChg || bColorChg) - { for (size_t nOV = 0; nOV < nOutlViewCnt; nOV++) { OutlinerView* pOLV = pTextEditOutliner->GetView(nOV); - { // invalidate old OutlinerView area - vcl::Window* pWin = pOLV->GetWindow(); - tools::Rectangle aTmpRect(aOldArea); - sal_uInt16 nPixSiz = pOLV->GetInvalidateMore() + 1; - Size aMore(pWin->PixelToLogic(Size(nPixSiz, nPixSiz))); - aTmpRect.AdjustLeft(-(aMore.Width())); - aTmpRect.AdjustRight(aMore.Width()); - aTmpRect.AdjustTop(-(aMore.Height())); - aTmpRect.AdjustBottom(aMore.Height()); - InvalidateOneWin(*pWin, aTmpRect); - } - if (bAnchorChg) - pOLV->SetAnchorMode(eNewAnchor); - if (bColorChg) - pOLV->SetBackgroundColor(aNewColor); - - pOLV->SetOutputArea( - aTextEditArea); // because otherwise, we're not re-anchoring correctly - ImpInvalidateOutlinerView(*pOLV); + EVControlBits nStat0 = pOLV->GetControlWord(); + EVControlBits nStat = nStat0; + // AutoViewSize only if not ContourFrame. + if (!bContourFrame) + nStat |= EVControlBits::AUTOSIZE; + else + nStat &= ~EVControlBits::AUTOSIZE; + if (nStat != nStat0) + pOLV->SetControlWord(nStat); + } + pTextEditOutliner->SetUpdateMode(true); + bAreaChg = true; + } + } + if (pTextEditOutlinerView != nullptr) + { // check fill and anchor + EEAnchorMode eOldAnchor = pTextEditOutlinerView->GetAnchorMode(); + eNewAnchor = pTextObj->GetOutlinerViewAnchorMode(); + bAnchorChg = eOldAnchor != eNewAnchor; + Color aOldColor(pTextEditOutlinerView->GetBackgroundColor()); + aNewColor = GetTextEditBackgroundColor(*this); + bColorChg = aOldColor != aNewColor; + } + // refresh always when it's a contour frame. That + // refresh is necessary since it triggers the repaint + // which makes the Handles visible. Changes at TakeTextRect() + // seem to have resulted in a case where no refresh is executed. + // Before that, a refresh must have been always executed + // (else this error would have happened earlier), thus I + // even think here a refresh should be done always. + // Since follow-up problems cannot even be guessed I only + // add this one more case to the if below. + // BTW: It's VERY bad style that here, inside ModelHasChanged() + // the outliner is again massively changed for the text object + // in text edit mode. Normally, all necessary data should be + // set at SdrBeginTextEdit(). Some changes and value assigns in + // SdrBeginTextEdit() are completely useless since they are set here + // again on ModelHasChanged(). + if (bContourFrame || bAreaChg || bAnchorChg || bColorChg) + { + for (size_t nOV = 0; nOV < nOutlViewCnt; nOV++) + { + OutlinerView* pOLV = pTextEditOutliner->GetView(nOV); + { // invalidate old OutlinerView area + vcl::Window* pWin = pOLV->GetWindow(); + tools::Rectangle aTmpRect(aOldArea); + sal_uInt16 nPixSiz = pOLV->GetInvalidateMore() + 1; + Size aMore(pWin->PixelToLogic(Size(nPixSiz, nPixSiz))); + aTmpRect.AdjustLeft(-(aMore.Width())); + aTmpRect.AdjustRight(aMore.Width()); + aTmpRect.AdjustTop(-(aMore.Height())); + aTmpRect.AdjustBottom(aMore.Height()); + InvalidateOneWin(*pWin, aTmpRect); } - pTextEditOutlinerView->ShowCursor(); + if (bAnchorChg) + pOLV->SetAnchorMode(eNewAnchor); + if (bColorChg) + pOLV->SetBackgroundColor(aNewColor); + + pOLV->SetOutputArea( + aTextEditArea); // because otherwise, we're not re-anchoring correctly + ImpInvalidateOutlinerView(*pOLV); } + pTextEditOutlinerView->ShowCursor(); } - ImpMakeTextCursorAreaVisible(); } + ImpMakeTextCursorAreaVisible(); } namespace @@ -590,27 +589,27 @@ void TextEditOverlayObject::checkDataChange(const basegfx::B2DRange& rMinTextEdi void TextEditOverlayObject::checkSelectionChange() { - if (getOverlaySelection() && getOverlayManager()) - { - std::vector aLogicRects; - std::vector aLogicRanges; - const Size aLogicPixel(getOverlayManager()->getOutputDevice().PixelToLogic(Size(1, 1))); + if (!(getOverlaySelection() && getOverlayManager())) + return; - // get logic selection - getOutlinerView().GetSelectionRectangles(aLogicRects); + std::vector aLogicRects; + std::vector aLogicRanges; + const Size aLogicPixel(getOverlayManager()->getOutputDevice().PixelToLogic(Size(1, 1))); - aLogicRanges.reserve(aLogicRects.size()); - for (const auto& aRect : aLogicRects) - { - // convert from logic Rectangles to logic Ranges, do not forget to add - // one Unit (in this case logical units for one pixel, pre-calculated) - aLogicRanges.emplace_back( - aRect.Left() - aLogicPixel.Width(), aRect.Top() - aLogicPixel.Height(), - aRect.Right() + aLogicPixel.Width(), aRect.Bottom() + aLogicPixel.Height()); - } + // get logic selection + getOutlinerView().GetSelectionRectangles(aLogicRects); - mpOverlaySelection->setRanges(aLogicRanges); + aLogicRanges.reserve(aLogicRects.size()); + for (const auto& aRect : aLogicRects) + { + // convert from logic Rectangles to logic Ranges, do not forget to add + // one Unit (in this case logical units for one pixel, pre-calculated) + aLogicRanges.emplace_back( + aRect.Left() - aLogicPixel.Width(), aRect.Top() - aLogicPixel.Height(), + aRect.Right() + aLogicPixel.Width(), aRect.Bottom() + aLogicPixel.Height()); } + + mpOverlaySelection->setRanges(aLogicRanges); } } // end of anonymous namespace @@ -621,21 +620,21 @@ void TextEditOverlayObject::checkSelectionChange() // is an integral part of the text visualization void SdrObjEditView::EditViewInvalidate(const tools::Rectangle&) const { - if (IsTextEdit()) + if (!IsTextEdit()) + return; + + // MinTextRange may have changed. Forward it, too + const basegfx::B2DRange aMinTextRange + = vcl::unotools::b2DRectangleFromRectangle(aMinTextEditArea); + + for (sal_uInt32 a(0); a < maTEOverlayGroup.count(); a++) { - // MinTextRange may have changed. Forward it, too - const basegfx::B2DRange aMinTextRange - = vcl::unotools::b2DRectangleFromRectangle(aMinTextEditArea); + TextEditOverlayObject* pCandidate + = dynamic_cast(&maTEOverlayGroup.getOverlayObject(a)); - for (sal_uInt32 a(0); a < maTEOverlayGroup.count(); a++) + if (pCandidate) { - TextEditOverlayObject* pCandidate - = dynamic_cast(&maTEOverlayGroup.getOverlayObject(a)); - - if (pCandidate) - { - pCandidate->checkDataChange(aMinTextRange); - } + pCandidate->checkDataChange(aMinTextRange); } } } @@ -645,17 +644,17 @@ void SdrObjEditView::EditViewInvalidate(const tools::Rectangle&) const // which is e.g. used when only the selection is changed, but not the text void SdrObjEditView::EditViewSelectionChange() const { - if (IsTextEdit()) + if (!IsTextEdit()) + return; + + for (sal_uInt32 a(0); a < maTEOverlayGroup.count(); a++) { - for (sal_uInt32 a(0); a < maTEOverlayGroup.count(); a++) - { - TextEditOverlayObject* pCandidate - = dynamic_cast(&maTEOverlayGroup.getOverlayObject(a)); + TextEditOverlayObject* pCandidate + = dynamic_cast(&maTEOverlayGroup.getOverlayObject(a)); - if (pCandidate) - { - pCandidate->checkSelectionChange(); - } + if (pCandidate) + { + pCandidate->checkSelectionChange(); } } } @@ -777,53 +776,53 @@ void SdrObjEditView::ImpInvalidateOutlinerView(OutlinerView const& rOutlView) co { vcl::Window* pWin = rOutlView.GetWindow(); - if (pWin) - { - const SdrTextObj* pText = GetTextEditObject(); - bool bTextFrame(pText && pText->IsTextFrame()); - bool bFitToSize(pText && pText->IsFitToSize()); + if (!pWin) + return; - if (bTextFrame && !bFitToSize) - { - tools::Rectangle aBlankRect(rOutlView.GetOutputArea()); - aBlankRect.Union(aMinTextEditArea); - tools::Rectangle aPixRect(pWin->LogicToPixel(aBlankRect)); - sal_uInt16 nPixSiz(rOutlView.GetInvalidateMore() - 1); + const SdrTextObj* pText = GetTextEditObject(); + bool bTextFrame(pText && pText->IsTextFrame()); + bool bFitToSize(pText && pText->IsFitToSize()); - aPixRect.AdjustLeft(-1); - aPixRect.AdjustTop(-1); - aPixRect.AdjustRight(1); - aPixRect.AdjustBottom(1); + if (!(bTextFrame && !bFitToSize)) + return; - { - // limit xPixRect because of driver problems when pixel coordinates are too far out - Size aMaxXY(pWin->GetOutputSizePixel()); - long a(2 * nPixSiz); - long nMaxX(aMaxXY.Width() + a); - long nMaxY(aMaxXY.Height() + a); - - if (aPixRect.Left() < -a) - aPixRect.SetLeft(-a); - if (aPixRect.Top() < -a) - aPixRect.SetTop(-a); - if (aPixRect.Right() > nMaxX) - aPixRect.SetRight(nMaxX); - if (aPixRect.Bottom() > nMaxY) - aPixRect.SetBottom(nMaxY); - } + tools::Rectangle aBlankRect(rOutlView.GetOutputArea()); + aBlankRect.Union(aMinTextEditArea); + tools::Rectangle aPixRect(pWin->LogicToPixel(aBlankRect)); + sal_uInt16 nPixSiz(rOutlView.GetInvalidateMore() - 1); - tools::Rectangle aOuterPix(aPixRect); - aOuterPix.AdjustLeft(-nPixSiz); - aOuterPix.AdjustTop(-nPixSiz); - aOuterPix.AdjustRight(nPixSiz); - aOuterPix.AdjustBottom(nPixSiz); + aPixRect.AdjustLeft(-1); + aPixRect.AdjustTop(-1); + aPixRect.AdjustRight(1); + aPixRect.AdjustBottom(1); - bool bMapModeEnabled(pWin->IsMapModeEnabled()); - pWin->EnableMapMode(false); - pWin->Invalidate(aOuterPix); - pWin->EnableMapMode(bMapModeEnabled); - } + { + // limit xPixRect because of driver problems when pixel coordinates are too far out + Size aMaxXY(pWin->GetOutputSizePixel()); + long a(2 * nPixSiz); + long nMaxX(aMaxXY.Width() + a); + long nMaxY(aMaxXY.Height() + a); + + if (aPixRect.Left() < -a) + aPixRect.SetLeft(-a); + if (aPixRect.Top() < -a) + aPixRect.SetTop(-a); + if (aPixRect.Right() > nMaxX) + aPixRect.SetRight(nMaxX); + if (aPixRect.Bottom() > nMaxY) + aPixRect.SetBottom(nMaxY); } + + tools::Rectangle aOuterPix(aPixRect); + aOuterPix.AdjustLeft(-nPixSiz); + aOuterPix.AdjustTop(-nPixSiz); + aOuterPix.AdjustRight(nPixSiz); + aOuterPix.AdjustBottom(nPixSiz); + + bool bMapModeEnabled(pWin->IsMapModeEnabled()); + pWin->EnableMapMode(false); + pWin->Invalidate(aOuterPix); + pWin->EnableMapMode(bMapModeEnabled); } OutlinerView* SdrObjEditView::ImpMakeOutlinerView(vcl::Window* pWin, OutlinerView* pGivenView, @@ -896,70 +895,70 @@ IMPL_LINK(SdrObjEditView, ImpOutlinerStatusEventHdl, EditStatus&, rEditStat, voi void SdrObjEditView::ImpChainingEventHdl() { - if (pTextEditOutliner) + if (!pTextEditOutliner) + return; + + SdrTextObj* pTextObj = mxTextEditObj.get(); + OutlinerView* pOLV = GetTextEditOutlinerView(); + if (pTextObj && pOLV) { - SdrTextObj* pTextObj = mxTextEditObj.get(); - OutlinerView* pOLV = GetTextEditOutlinerView(); - if (pTextObj && pOLV) - { - TextChain* pTextChain = pTextObj->GetTextChain(); + TextChain* pTextChain = pTextObj->GetTextChain(); - // XXX: IsChainable and GetNilChainingEvent are a bit mixed up atm - if (!pTextObj->IsChainable()) - { - return; - } - // This is true during an underflow-caused overflow (with pEdtOutl->SetText()) - if (pTextChain->GetNilChainingEvent(pTextObj)) - { - return; - } + // XXX: IsChainable and GetNilChainingEvent are a bit mixed up atm + if (!pTextObj->IsChainable()) + { + return; + } + // This is true during an underflow-caused overflow (with pEdtOutl->SetText()) + if (pTextChain->GetNilChainingEvent(pTextObj)) + { + return; + } - // We prevent to trigger further handling of overflow/underflow for pTextObj - pTextChain->SetNilChainingEvent(pTextObj, true); // XXX + // We prevent to trigger further handling of overflow/underflow for pTextObj + pTextChain->SetNilChainingEvent(pTextObj, true); // XXX - // Save previous selection pos // NOTE: It must be done to have the right CursorEvent in KeyInput - pTextChain->SetPreChainingSel(pTextObj, pOLV->GetSelection()); - //maPreChainingSel = new ESelection(pOLV->GetSelection()); + // Save previous selection pos // NOTE: It must be done to have the right CursorEvent in KeyInput + pTextChain->SetPreChainingSel(pTextObj, pOLV->GetSelection()); + //maPreChainingSel = new ESelection(pOLV->GetSelection()); - // Handling Undo - const int nText = 0; // XXX: hardcoded index (SdrTextObj::getText handles only 0) + // Handling Undo + const int nText = 0; // XXX: hardcoded index (SdrTextObj::getText handles only 0) - const bool bUndoEnabled = GetModel() && IsUndoEnabled(); - std::unique_ptr pTxtUndo; - if (bUndoEnabled) - pTxtUndo.reset( - dynamic_cast(GetModel() - ->GetSdrUndoFactory() - .CreateUndoObjectSetText(*pTextObj, nText) - .release())); + const bool bUndoEnabled = GetModel() && IsUndoEnabled(); + std::unique_ptr pTxtUndo; + if (bUndoEnabled) + pTxtUndo.reset( + dynamic_cast(GetModel() + ->GetSdrUndoFactory() + .CreateUndoObjectSetText(*pTextObj, nText) + .release())); - // trigger actual chaining - pTextObj->onChainingEvent(); + // trigger actual chaining + pTextObj->onChainingEvent(); - if (pTxtUndo) + if (pTxtUndo) + { + pTxtUndo->AfterSetText(); + if (!pTxtUndo->IsDifferent()) { - pTxtUndo->AfterSetText(); - if (!pTxtUndo->IsDifferent()) - { - pTxtUndo.reset(); - } + pTxtUndo.reset(); } + } - if (pTxtUndo) - AddUndo(std::move(pTxtUndo)); + if (pTxtUndo) + AddUndo(std::move(pTxtUndo)); - //maCursorEvent = new CursorChainingEvent(pTextChain->GetCursorEvent(pTextObj)); - //SdrTextObj *pNextLink = pTextObj->GetNextLinkInChain(); + //maCursorEvent = new CursorChainingEvent(pTextChain->GetCursorEvent(pTextObj)); + //SdrTextObj *pNextLink = pTextObj->GetNextLinkInChain(); - // NOTE: Must be called. Don't let the function return if you set it to true and not reset it - pTextChain->SetNilChainingEvent(pTextObj, false); - } - else - { - // XXX - SAL_INFO("svx.chaining", "[OnChaining] No Edit Outliner View"); - } + // NOTE: Must be called. Don't let the function return if you set it to true and not reset it + pTextChain->SetNilChainingEvent(pTextObj, false); + } + else + { + // XXX + SAL_INFO("svx.chaining", "[OnChaining] No Edit Outliner View"); } } @@ -1677,21 +1676,21 @@ OutlinerView* SdrObjEditView::ImpFindOutlinerView(vcl::Window const* pWin) const void SdrObjEditView::SetTextEditWin(vcl::Window* pWin) { - if (mxTextEditObj.is() && pWin != nullptr && pWin != pTextEditWin) + if (!(mxTextEditObj.is() && pWin != nullptr && pWin != pTextEditWin)) + return; + + OutlinerView* pNewView = ImpFindOutlinerView(pWin); + if (pNewView != nullptr && pNewView != pTextEditOutlinerView) { - OutlinerView* pNewView = ImpFindOutlinerView(pWin); - if (pNewView != nullptr && pNewView != pTextEditOutlinerView) + if (pTextEditOutlinerView != nullptr) { - if (pTextEditOutlinerView != nullptr) - { - pTextEditOutlinerView->HideCursor(); - } - pTextEditOutlinerView = pNewView; - pTextEditWin = pWin; - pWin->GrabFocus(); // Make the cursor blink here as well - pNewView->ShowCursor(); - ImpMakeTextCursorAreaVisible(); + pTextEditOutlinerView->HideCursor(); } + pTextEditOutlinerView = pNewView; + pTextEditWin = pWin; + pWin->GrabFocus(); // Make the cursor blink here as well + pNewView->ShowCursor(); + ImpMakeTextCursorAreaVisible(); } } @@ -2386,19 +2385,19 @@ void SdrObjEditView::ImpMacroDown(const Point& rDownPos) void SdrObjEditView::MovMacroObj(const Point& rPnt) { - if (pMacroObj != nullptr) - { - SdrObjMacroHitRec aHitRec; - aHitRec.aPos = rPnt; - aHitRec.nTol = nMacroTol; - aHitRec.pVisiLayer = &pMacroPV->GetVisibleLayers(); - aHitRec.pPageView = pMacroPV; - bool bDown = pMacroObj->IsMacroHit(aHitRec); - if (bDown) - ImpMacroDown(rPnt); - else - ImpMacroUp(rPnt); - } + if (pMacroObj == nullptr) + return; + + SdrObjMacroHitRec aHitRec; + aHitRec.aPos = rPnt; + aHitRec.nTol = nMacroTol; + aHitRec.pVisiLayer = &pMacroPV->GetVisibleLayers(); + aHitRec.pPageView = pMacroPV; + bool bDown = pMacroObj->IsMacroHit(aHitRec); + if (bDown) + ImpMacroDown(rPnt); + else + ImpMacroUp(rPnt); } void SdrObjEditView::BrkMacroObj() @@ -2439,28 +2438,25 @@ bool SdrObjEditView::EndMacroObj() Leaves the any untouched if there currently is no text selected */ void SdrObjEditView::getTextSelection(css::uno::Any& rSelection) { - if (IsTextEdit()) + if (!IsTextEdit()) + return; + + OutlinerView* pOutlinerView = GetTextEditOutlinerView(); + if (!(pOutlinerView && pOutlinerView->HasSelection())) + return; + + SdrObject* pObj = GetTextEditObject(); + + if (!pObj) + return; + + css::uno::Reference xText(pObj->getUnoShape(), css::uno::UNO_QUERY); + if (xText.is()) { - OutlinerView* pOutlinerView = GetTextEditOutlinerView(); - if (pOutlinerView && pOutlinerView->HasSelection()) + SvxUnoTextBase* pRange = comphelper::getUnoTunnelImplementation(xText); + if (pRange) { - SdrObject* pObj = GetTextEditObject(); - - if (pObj) - { - css::uno::Reference xText(pObj->getUnoShape(), - css::uno::UNO_QUERY); - if (xText.is()) - { - SvxUnoTextBase* pRange - = comphelper::getUnoTunnelImplementation(xText); - if (pRange) - { - rSelection - <<= pRange->createTextCursorBySelection(pOutlinerView->GetSelection()); - } - } - } + rSelection <<= pRange->createTextCursorBySelection(pOutlinerView->GetSelection()); } } } @@ -2485,24 +2481,23 @@ void SdrObjEditView::MarkListHasChanged() mxSelectionController.clear(); const SdrMarkList& rMarkList = GetMarkedObjectList(); - if (rMarkList.GetMarkCount() == 1) + if (rMarkList.GetMarkCount() != 1) + return; + + const SdrObject* pObj(rMarkList.GetMark(0)->GetMarkedSdrObj()); + SdrView* pView(dynamic_cast(this)); + + // check for table + if (pObj && pView && (pObj->GetObjInventor() == SdrInventor::Default) + && (pObj->GetObjIdentifier() == OBJ_TABLE)) { - const SdrObject* pObj(rMarkList.GetMark(0)->GetMarkedSdrObj()); - SdrView* pView(dynamic_cast(this)); + mxSelectionController = sdr::table::CreateTableController( + *pView, static_cast(*pObj), mxLastSelectionController); - // check for table - if (pObj && pView && (pObj->GetObjInventor() == SdrInventor::Default) - && (pObj->GetObjIdentifier() == OBJ_TABLE)) + if (mxSelectionController.is()) { - mxSelectionController = sdr::table::CreateTableController( - *pView, static_cast(*pObj), - mxLastSelectionController); - - if (mxSelectionController.is()) - { - mxLastSelectionController.clear(); - mxSelectionController->onSelectionHasChanged(); - } + mxLastSelectionController.clear(); + mxSelectionController->onSelectionHasChanged(); } } } @@ -2637,32 +2632,32 @@ static const sal_uInt16* GetFormatRangeImpl(bool bTextOnly) void SdrObjEditView::TakeFormatPaintBrush(std::shared_ptr& rFormatSet) { const SdrMarkList& rMarkList = GetMarkedObjectList(); - if (rMarkList.GetMarkCount() > 0) - { - OutlinerView* pOLV = GetTextEditOutlinerView(); + if (rMarkList.GetMarkCount() <= 0) + return; - rFormatSet = std::make_shared(GetModel()->GetItemPool(), - GetFormatRangeImpl(pOLV != nullptr)); - if (pOLV) - { - rFormatSet->Put(pOLV->GetAttribs()); - } - else - { - const bool bOnlyHardAttr = false; - rFormatSet->Put(GetAttrFromMarked(bOnlyHardAttr)); - } + OutlinerView* pOLV = GetTextEditOutlinerView(); - // check for cloning from table cell, in which case we need to copy cell-specific formatting attributes - const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - if (pObj && (pObj->GetObjInventor() == SdrInventor::Default) - && (pObj->GetObjIdentifier() == OBJ_TABLE)) + rFormatSet = std::make_shared(GetModel()->GetItemPool(), + GetFormatRangeImpl(pOLV != nullptr)); + if (pOLV) + { + rFormatSet->Put(pOLV->GetAttribs()); + } + else + { + const bool bOnlyHardAttr = false; + rFormatSet->Put(GetAttrFromMarked(bOnlyHardAttr)); + } + + // check for cloning from table cell, in which case we need to copy cell-specific formatting attributes + const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + if (pObj && (pObj->GetObjInventor() == SdrInventor::Default) + && (pObj->GetObjIdentifier() == OBJ_TABLE)) + { + auto pTable = static_cast(pObj); + if (mxSelectionController.is() && pTable->getActiveCell().is()) { - auto pTable = static_cast(pObj); - if (mxSelectionController.is() && pTable->getActiveCell().is()) - { - mxSelectionController->GetAttributes(*rFormatSet, false); - } + mxSelectionController->GetAttributes(*rFormatSet, false); } } } @@ -2704,32 +2699,32 @@ void SdrObjEditView::ApplyFormatPaintBrushToText(SfxItemSet const& rFormatSet, S bool bNoParagraphFormats) { OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : nullptr; - if (pParaObj) - { - SdrOutliner& rOutliner = rTextObj.ImpGetDrawOutliner(); - rOutliner.SetText(*pParaObj); + if (!pParaObj) + return; - sal_Int32 nParaCount(rOutliner.GetParagraphCount()); + SdrOutliner& rOutliner = rTextObj.ImpGetDrawOutliner(); + rOutliner.SetText(*pParaObj); - if (nParaCount) - { - for (sal_Int32 nPara = 0; nPara < nParaCount; nPara++) - { - if (!bNoCharacterFormats) - rOutliner.RemoveCharAttribs(nPara); + sal_Int32 nParaCount(rOutliner.GetParagraphCount()); - SfxItemSet aSet(rOutliner.GetParaAttribs(nPara)); - aSet.Put(CreatePaintSet(GetFormatRangeImpl(true), *aSet.GetPool(), rFormatSet, aSet, - bNoCharacterFormats, bNoParagraphFormats)); - rOutliner.SetParaAttribs(nPara, aSet); - } + if (!nParaCount) + return; - std::unique_ptr pTemp = rOutliner.CreateParaObject(0, nParaCount); - rOutliner.Clear(); + for (sal_Int32 nPara = 0; nPara < nParaCount; nPara++) + { + if (!bNoCharacterFormats) + rOutliner.RemoveCharAttribs(nPara); - rTextObj.NbcSetOutlinerParaObjectForText(std::move(pTemp), pText); - } + SfxItemSet aSet(rOutliner.GetParaAttribs(nPara)); + aSet.Put(CreatePaintSet(GetFormatRangeImpl(true), *aSet.GetPool(), rFormatSet, aSet, + bNoCharacterFormats, bNoParagraphFormats)); + rOutliner.SetParaAttribs(nPara, aSet); } + + std::unique_ptr pTemp = rOutliner.CreateParaObject(0, nParaCount); + rOutliner.Clear(); + + rTextObj.NbcSetOutlinerParaObjectForText(std::move(pTemp), pText); } void SdrObjEditView::ApplyFormatPaintBrush(SfxItemSet& rFormatSet, bool bNoCharacterFormats, diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index 4adefe0cb096..1f62442af896 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -422,25 +422,25 @@ void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr mbFntDirty = false; } - if(pObj) - { - pObj->SetLayer(mnLayer); + if(!pObj) + return; - if(bLine) - { - pObj->SetMergedItemSet(*mpLineAttr); - } + pObj->SetLayer(mnLayer); - if(bFill) - { - pObj->SetMergedItemSet(*mpFillAttr); - } + if(bLine) + { + pObj->SetMergedItemSet(*mpLineAttr); + } - if(bText) - { - pObj->SetMergedItemSet(*mpTextAttr); - pObj->SetMergedItem(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); - } + if(bFill) + { + pObj->SetMergedItemSet(*mpFillAttr); + } + + if(bText) + { + pObj->SetMergedItemSet(*mpTextAttr); + pObj->SetMergedItem(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); } } @@ -596,65 +596,65 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale) } } - if(pObj) + if(!pObj) + return; + + // #i111954# check object for visibility + // used are SdrPathObj, SdrRectObj, SdrCircObj, SdrGrafObj + bool bVisible(false); + + if(pObj->HasLineStyle()) + { + bVisible = true; + } + + if(!bVisible && pObj->HasFillStyle()) + { + bVisible = true; + } + + if(!bVisible) { - // #i111954# check object for visibility - // used are SdrPathObj, SdrRectObj, SdrCircObj, SdrGrafObj - bool bVisible(false); + SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj); - if(pObj->HasLineStyle()) + if(pTextObj && pTextObj->HasText()) { bVisible = true; } + } + + if(!bVisible) + { + SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >(pObj); - if(!bVisible && pObj->HasFillStyle()) + if(pGrafObj) { + // this may be refined to check if the graphic really is visible. It + // is here to ensure that graphic objects without fill, line and text + // get created bVisible = true; } + } - if(!bVisible) - { - SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj); - - if(pTextObj && pTextObj->HasText()) - { - bVisible = true; - } - } + if(!bVisible) + { + SdrObject::Free(pObj); + } + else + { + maTmpList.push_back(pObj); - if(!bVisible) + if(dynamic_cast< SdrPathObj* >(pObj)) { - SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >(pObj); + const bool bClosed(pObj->IsClosedObj()); - if(pGrafObj) - { - // this may be refined to check if the graphic really is visible. It - // is here to ensure that graphic objects without fill, line and text - // get created - bVisible = true; - } - } - - if(!bVisible) - { - SdrObject::Free(pObj); + mbLastObjWasPolyWithoutLine = mbNoLine && bClosed; + mbLastObjWasLine = !bClosed; } else { - maTmpList.push_back(pObj); - - if(dynamic_cast< SdrPathObj* >(pObj)) - { - const bool bClosed(pObj->IsClosedObj()); - - mbLastObjWasPolyWithoutLine = mbNoLine && bClosed; - mbLastObjWasLine = !bClosed; - } - else - { - mbLastObjWasPolyWithoutLine = false; - mbLastObjWasLine = false; - } + mbLastObjWasPolyWithoutLine = false; + mbLastObjWasLine = false; } } } @@ -665,44 +665,44 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction const & rAct) const basegfx::B2DPoint aStart(rAct.GetStartPoint().X(), rAct.GetStartPoint().Y()); const basegfx::B2DPoint aEnd(rAct.GetEndPoint().X(), rAct.GetEndPoint().Y()); - if(!aStart.equal(aEnd)) - { - basegfx::B2DPolygon aLine; - const basegfx::B2DHomMatrix aTransform(basegfx::utils::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); + if(aStart.equal(aEnd)) + return; - aLine.append(aStart); - aLine.append(aEnd); - aLine.transform(aTransform); + basegfx::B2DPolygon aLine; + const basegfx::B2DHomMatrix aTransform(basegfx::utils::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); - const LineInfo& rLineInfo = rAct.GetLineInfo(); - const sal_Int32 nNewLineWidth(rLineInfo.GetWidth()); - bool bCreateLineObject(true); + aLine.append(aStart); + aLine.append(aEnd); + aLine.transform(aTransform); - if(mbLastObjWasLine && (nNewLineWidth == mnLineWidth) && CheckLastLineMerge(aLine)) - { - bCreateLineObject = false; - } + const LineInfo& rLineInfo = rAct.GetLineInfo(); + const sal_Int32 nNewLineWidth(rLineInfo.GetWidth()); + bool bCreateLineObject(true); - if(bCreateLineObject) - { - SdrPathObj* pPath = new SdrPathObj( - *mpModel, - OBJ_LINE, - basegfx::B2DPolyPolygon(aLine)); - mnLineWidth = nNewLineWidth; - maLineJoin = rLineInfo.GetLineJoin(); - maLineCap = rLineInfo.GetLineCap(); - maDash = XDash(css::drawing::DashStyle_RECT, - rLineInfo.GetDotCount(), rLineInfo.GetDotLen(), - rLineInfo.GetDashCount(), rLineInfo.GetDashLen(), - rLineInfo.GetDistance()); - SetAttributes(pPath); - mnLineWidth = 0; - maLineJoin = basegfx::B2DLineJoin::NONE; - maDash = XDash(); - InsertObj(pPath, false); - } + if(mbLastObjWasLine && (nNewLineWidth == mnLineWidth) && CheckLastLineMerge(aLine)) + { + bCreateLineObject = false; } + + if(!bCreateLineObject) + return; + + SdrPathObj* pPath = new SdrPathObj( + *mpModel, + OBJ_LINE, + basegfx::B2DPolyPolygon(aLine)); + mnLineWidth = nNewLineWidth; + maLineJoin = rLineInfo.GetLineJoin(); + maLineCap = rLineInfo.GetLineCap(); + maDash = XDash(css::drawing::DashStyle_RECT, + rLineInfo.GetDotCount(), rLineInfo.GetDotLen(), + rLineInfo.GetDashCount(), rLineInfo.GetDashLen(), + rLineInfo.GetDistance()); + SetAttributes(pPath); + mnLineWidth = 0; + maLineJoin = basegfx::B2DLineJoin::NONE; + maDash = XDash(); + InsertObj(pPath, false); } void ImpSdrGDIMetaFileImport::DoAction(MetaRectAction const & rAct) @@ -883,21 +883,21 @@ bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPo void ImpSdrGDIMetaFileImport::checkClip() { - if(mpVD->IsClipRegion()) - { - maClip = mpVD->GetClipRegion().GetAsB2DPolyPolygon(); + if(!mpVD->IsClipRegion()) + return; - if(isClip()) - { - const basegfx::B2DHomMatrix aTransform( - basegfx::utils::createScaleTranslateB2DHomMatrix( - mfScaleX, - mfScaleY, - maOfs.X(), - maOfs.Y())); - - maClip.transform(aTransform); - } + maClip = mpVD->GetClipRegion().GetAsB2DPolyPolygon(); + + if(isClip()) + { + const basegfx::B2DHomMatrix aTransform( + basegfx::utils::createScaleTranslateB2DHomMatrix( + mfScaleX, + mfScaleY, + maOfs.X(), + maOfs.Y())); + + maClip.transform(aTransform); } } @@ -930,25 +930,25 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction const & rAct ) bCreateLineObject = false; } - if(bCreateLineObject) - { - SdrPathObj* pPath = new SdrPathObj( - *mpModel, - aSource.isClosed() ? OBJ_POLY : OBJ_PLIN, - basegfx::B2DPolyPolygon(aSource)); - mnLineWidth = nNewLineWidth; - maLineJoin = rLineInfo.GetLineJoin(); - maLineCap = rLineInfo.GetLineCap(); - maDash = XDash(css::drawing::DashStyle_RECT, - rLineInfo.GetDotCount(), rLineInfo.GetDotLen(), - rLineInfo.GetDashCount(), rLineInfo.GetDashLen(), - rLineInfo.GetDistance()); - SetAttributes(pPath); - mnLineWidth = 0; - maLineJoin = basegfx::B2DLineJoin::NONE; - maDash = XDash(); - InsertObj(pPath, false); - } + if(!bCreateLineObject) + return; + + SdrPathObj* pPath = new SdrPathObj( + *mpModel, + aSource.isClosed() ? OBJ_POLY : OBJ_PLIN, + basegfx::B2DPolyPolygon(aSource)); + mnLineWidth = nNewLineWidth; + maLineJoin = rLineInfo.GetLineJoin(); + maLineCap = rLineInfo.GetLineCap(); + maDash = XDash(css::drawing::DashStyle_RECT, + rLineInfo.GetDotCount(), rLineInfo.GetDotLen(), + rLineInfo.GetDashCount(), rLineInfo.GetDashLen(), + rLineInfo.GetDistance()); + SetAttributes(pPath); + mnLineWidth = 0; + maLineJoin = basegfx::B2DLineJoin::NONE; + maDash = XDash(); + InsertObj(pPath, false); } void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction const & rAct ) @@ -956,22 +956,22 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction const & rAct ) // #i73407# reformulation to use new B2DPolygon classes basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon()); - if(aSource.count()) - { - const basegfx::B2DHomMatrix aTransform(basegfx::utils::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); - aSource.transform(aTransform); + if(!aSource.count()) + return; - if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource))) - { - // #i73407# make sure polygon is closed, it's a filled primitive - aSource.setClosed(true); - SdrPathObj* pPath = new SdrPathObj( - *mpModel, - OBJ_POLY, - basegfx::B2DPolyPolygon(aSource)); - SetAttributes(pPath); - InsertObj(pPath, false); - } + const basegfx::B2DHomMatrix aTransform(basegfx::utils::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); + aSource.transform(aTransform); + + if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource))) + { + // #i73407# make sure polygon is closed, it's a filled primitive + aSource.setClosed(true); + SdrPathObj* pPath = new SdrPathObj( + *mpModel, + OBJ_POLY, + basegfx::B2DPolyPolygon(aSource)); + SetAttributes(pPath); + InsertObj(pPath, false); } } @@ -980,22 +980,22 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaPolyPolygonAction const & rAct) // #i73407# reformulation to use new B2DPolygon classes basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon()); - if(aSource.count()) - { - const basegfx::B2DHomMatrix aTransform(basegfx::utils::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); - aSource.transform(aTransform); + if(!aSource.count()) + return; - if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource)) - { - // #i73407# make sure polygon is closed, it's a filled primitive - aSource.setClosed(true); - SdrPathObj* pPath = new SdrPathObj( - *mpModel, - OBJ_POLY, - aSource); - SetAttributes(pPath); - InsertObj(pPath, false); - } + const basegfx::B2DHomMatrix aTransform(basegfx::utils::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); + aSource.transform(aTransform); + + if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource)) + { + // #i73407# make sure polygon is closed, it's a filled primitive + aSource.setClosed(true); + SdrPathObj* pPath = new SdrPathObj( + *mpModel, + OBJ_POLY, + aSource); + SetAttributes(pPath); + InsertObj(pPath, false); } } @@ -1152,51 +1152,51 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction const & rAct ) // #i73407# reformulation to use new B2DPolygon classes basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon()); - if(aSource.count()) - { - const basegfx::B2DHomMatrix aTransform(basegfx::utils::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); - aSource.transform(aTransform); + if(!aSource.count()) + return; - if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource)) - { - const Hatch& rHatch = rAct.GetHatch(); - SdrPathObj* pPath = new SdrPathObj( - *mpModel, - OBJ_POLY, - aSource); - // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet - SfxItemSet aHatchAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges()); - css::drawing::HatchStyle eStyle; - - switch(rHatch.GetStyle()) - { - case HatchStyle::Triple : - { - eStyle = css::drawing::HatchStyle_TRIPLE; - break; - } + const basegfx::B2DHomMatrix aTransform(basegfx::utils::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); + aSource.transform(aTransform); - case HatchStyle::Double : - { - eStyle = css::drawing::HatchStyle_DOUBLE; - break; - } + if(mbLastObjWasPolyWithoutLine && CheckLastPolyLineAndFillMerge(aSource)) + return; - default: - { - eStyle = css::drawing::HatchStyle_SINGLE; - break; - } - } + const Hatch& rHatch = rAct.GetHatch(); + SdrPathObj* pPath = new SdrPathObj( + *mpModel, + OBJ_POLY, + aSource); + // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet + SfxItemSet aHatchAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges()); + css::drawing::HatchStyle eStyle; - SetAttributes(pPath); - aHatchAttr.Put(XFillStyleItem(drawing::FillStyle_HATCH)); - aHatchAttr.Put(XFillHatchItem(XHatch(rHatch.GetColor(), eStyle, rHatch.GetDistance(), rHatch.GetAngle()))); - pPath->SetMergedItemSet(aHatchAttr); + switch(rHatch.GetStyle()) + { + case HatchStyle::Triple : + { + eStyle = css::drawing::HatchStyle_TRIPLE; + break; + } + + case HatchStyle::Double : + { + eStyle = css::drawing::HatchStyle_DOUBLE; + break; + } - InsertObj(pPath, false); + default: + { + eStyle = css::drawing::HatchStyle_SINGLE; + break; } } + + SetAttributes(pPath); + aHatchAttr.Put(XFillStyleItem(drawing::FillStyle_HATCH)); + aHatchAttr.Put(XFillHatchItem(XHatch(rHatch.GetColor(), eStyle, rHatch.GetDistance(), rHatch.GetAngle()))); + pPath->SetMergedItemSet(aHatchAttr); + + InsertObj(pPath, false); } @@ -1479,62 +1479,62 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaTransparentAction const & rAct) { basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon()); - if(aSource.count()) - { - const basegfx::B2DHomMatrix aTransform(basegfx::utils::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); - aSource.transform(aTransform); - aSource.setClosed(true); + if(!aSource.count()) + return; - SdrPathObj* pPath = new SdrPathObj( - *mpModel, - OBJ_POLY, - aSource); - SetAttributes(pPath); - pPath->SetMergedItem(XFillTransparenceItem(rAct.GetTransparence())); - InsertObj(pPath, false); - } + const basegfx::B2DHomMatrix aTransform(basegfx::utils::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); + aSource.transform(aTransform); + aSource.setClosed(true); + + SdrPathObj* pPath = new SdrPathObj( + *mpModel, + OBJ_POLY, + aSource); + SetAttributes(pPath); + pPath->SetMergedItem(XFillTransparenceItem(rAct.GetTransparence())); + InsertObj(pPath, false); } void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction const & rAct) { basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon()); - if(aSource.count()) - { - const basegfx::B2DHomMatrix aTransform(basegfx::utils::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); - aSource.transform(aTransform); + if(!aSource.count()) + return; - if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource)) - { - const Gradient& rGradient = rAct.GetGradient(); - SdrPathObj* pPath = new SdrPathObj( - *mpModel, - OBJ_POLY, - aSource); - // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet - SfxItemSet aGradientAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges()); - const css::awt::GradientStyle aXGradientStyle(getXGradientStyleFromGradientStyle(rGradient.GetStyle())); - const XFillGradientItem aXFillGradientItem( - XGradient( - rGradient.GetStartColor(), - rGradient.GetEndColor(), - aXGradientStyle, - rGradient.GetAngle(), - rGradient.GetOfsX(), - rGradient.GetOfsY(), - rGradient.GetBorder(), - rGradient.GetStartIntensity(), - rGradient.GetEndIntensity(), - rGradient.GetSteps())); - - SetAttributes(pPath); - aGradientAttr.Put(XFillStyleItem(drawing::FillStyle_GRADIENT)); // #i125211# - aGradientAttr.Put(aXFillGradientItem); - pPath->SetMergedItemSet(aGradientAttr); - - InsertObj(pPath, false); - } - } + const basegfx::B2DHomMatrix aTransform(basegfx::utils::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y())); + aSource.transform(aTransform); + + if(mbLastObjWasPolyWithoutLine && CheckLastPolyLineAndFillMerge(aSource)) + return; + + const Gradient& rGradient = rAct.GetGradient(); + SdrPathObj* pPath = new SdrPathObj( + *mpModel, + OBJ_POLY, + aSource); + // #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet + SfxItemSet aGradientAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges()); + const css::awt::GradientStyle aXGradientStyle(getXGradientStyleFromGradientStyle(rGradient.GetStyle())); + const XFillGradientItem aXFillGradientItem( + XGradient( + rGradient.GetStartColor(), + rGradient.GetEndColor(), + aXGradientStyle, + rGradient.GetAngle(), + rGradient.GetOfsX(), + rGradient.GetOfsY(), + rGradient.GetBorder(), + rGradient.GetStartIntensity(), + rGradient.GetEndIntensity(), + rGradient.GetSteps())); + + SetAttributes(pPath); + aGradientAttr.Put(XFillStyleItem(drawing::FillStyle_GRADIENT)); // #i125211# + aGradientAttr.Put(aXFillGradientItem); + pPath->SetMergedItemSet(aGradientAttr); + + InsertObj(pPath, false); } void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction const & rAct) @@ -1609,41 +1609,41 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction const & rAct) bHasNewMask = true; } - if(bCreateObject) + if(!bCreateObject) + return; + + if(bHasNewMask || bFixedTransparence) { - if(bHasNewMask || bFixedTransparence) + if(!aBitmapEx.IsAlpha() && !aBitmapEx.IsTransparent()) { - if(!aBitmapEx.IsAlpha() && !aBitmapEx.IsTransparent()) + // no transparence yet, apply new one + if(bFixedTransparence) { - // no transparence yet, apply new one - if(bFixedTransparence) - { - sal_uInt8 aAlpha(basegfx::fround(fTransparence * 255.0)); - - aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &aAlpha); - } + sal_uInt8 aAlpha(basegfx::fround(fTransparence * 255.0)); - aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask); + aNewMask = AlphaMask(aBitmapEx.GetBitmap().GetSizePixel(), &aAlpha); } - else - { - vcl::bitmap::DrawAlphaBitmapAndAlphaGradient(aBitmapEx, bFixedTransparence, fTransparence, aNewMask); - } - } - // create and add object - SdrGrafObj* pGraf = new SdrGrafObj( - *mpModel, - aBitmapEx, - aRect); - - // for MetaFloatTransparentAction, do not use SetAttributes(...) - // since these metafile content is not used to draw line/fill - // dependent of these setting at the device content - pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE)); - pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE)); - InsertObj(pGraf); + aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aNewMask); + } + else + { + vcl::bitmap::DrawAlphaBitmapAndAlphaGradient(aBitmapEx, bFixedTransparence, fTransparence, aNewMask); + } } + + // create and add object + SdrGrafObj* pGraf = new SdrGrafObj( + *mpModel, + aBitmapEx, + aRect); + + // for MetaFloatTransparentAction, do not use SetAttributes(...) + // since these metafile content is not used to draw line/fill + // dependent of these setting at the device content + pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE)); + pGraf->SetMergedItem(XFillStyleItem(drawing::FillStyle_NONE)); + InsertObj(pGraf); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/svdraw/svdglev.cxx b/svx/source/svdraw/svdglev.cxx index 444517a97ca3..5f81d38575ab 100644 --- a/svx/source/svdraw/svdglev.cxx +++ b/svx/source/svdraw/svdglev.cxx @@ -169,23 +169,24 @@ static void ImpGetAlign(SdrGluePoint & rGP, const SdrObject* /*pObj*/, const voi SdrAlign& nRet=*const_cast(static_cast(pnRet)); bool& bDontCare=*const_cast(static_cast(pbDontCare)); bool bVert=*static_cast(pbVert); - if (!bDontCare) { - SdrAlign nAlg=SdrAlign::NONE; + if (bDontCare) + return; + + SdrAlign nAlg=SdrAlign::NONE; + if (bVert) { + nAlg=rGP.GetVertAlign(); + } else { + nAlg=rGP.GetHorzAlign(); + } + bool& bFirst=*const_cast(static_cast(pbFirst)); + if (bFirst) { nRet=nAlg; bFirst=false; } + else if (nRet!=nAlg) { if (bVert) { - nAlg=rGP.GetVertAlign(); + nRet=SdrAlign::VERT_DONTCARE; } else { - nAlg=rGP.GetHorzAlign(); - } - bool& bFirst=*const_cast(static_cast(pbFirst)); - if (bFirst) { nRet=nAlg; bFirst=false; } - else if (nRet!=nAlg) { - if (bVert) { - nRet=SdrAlign::VERT_DONTCARE; - } else { - nRet=SdrAlign::HORZ_DONTCARE; - } - bDontCare=true; + nRet=SdrAlign::HORZ_DONTCARE; } + bDontCare=true; } } diff --git a/svx/source/svdraw/svdglue.cxx b/svx/source/svdraw/svdglue.cxx index 784b3d8bfdc2..a662b99bfe0b 100644 --- a/svx/source/svdraw/svdglue.cxx +++ b/svx/source/svdraw/svdglue.cxx @@ -28,20 +28,20 @@ const Size aGlueHalfSize(4,4); void SdrGluePoint::SetReallyAbsolute(bool bOn, const SdrObject& rObj) { - if ( bReallyAbsolute != bOn ) - { - if ( bOn ) - { - aPos=GetAbsolutePos(rObj); - bReallyAbsolute=bOn; - } - else - { - bReallyAbsolute=bOn; - Point aPt(aPos); - SetAbsolutePos(aPt,rObj); - } - } + if ( bReallyAbsolute == bOn ) + return; + + if ( bOn ) + { + aPos=GetAbsolutePos(rObj); + bReallyAbsolute=bOn; + } + else + { + bReallyAbsolute=bOn; + Point aPt(aPos); + SetAbsolutePos(aPt,rObj); + } } Point SdrGluePoint::GetAbsolutePos(const SdrObject& rObj) const diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx index fab9f7b03d73..bbd2926d36ab 100644 --- a/svx/source/svdraw/svdhdl.cxx +++ b/svx/source/svdraw/svdhdl.cxx @@ -404,223 +404,223 @@ void SdrHdl::CreateB2dIAObject() // first throw away old one GetRidOfIAObject(); - if(pHdlList && pHdlList->GetView() && !pHdlList->GetView()->areMarkHandlesHidden()) + if(!pHdlList || !pHdlList->GetView() || pHdlList->GetView()->areMarkHandlesHidden()) + return; + + BitmapColorIndex eColIndex = BitmapColorIndex::LightGreen; + BitmapMarkerKind eKindOfMarker = BitmapMarkerKind::Rect_7x7; + + bool bRot = pHdlList->IsRotateShear(); + if(pObj) + eColIndex = bSelect ? BitmapColorIndex::Cyan : BitmapColorIndex::LightCyan; + if(bRot) { - BitmapColorIndex eColIndex = BitmapColorIndex::LightGreen; - BitmapMarkerKind eKindOfMarker = BitmapMarkerKind::Rect_7x7; + // red rotation handles + if(pObj && bSelect) + eColIndex = BitmapColorIndex::Red; + else + eColIndex = BitmapColorIndex::LightRed; + } - bool bRot = pHdlList->IsRotateShear(); - if(pObj) - eColIndex = bSelect ? BitmapColorIndex::Cyan : BitmapColorIndex::LightCyan; - if(bRot) + switch(eKind) + { + case SdrHdlKind::Move: { - // red rotation handles - if(pObj && bSelect) - eColIndex = BitmapColorIndex::Red; - else - eColIndex = BitmapColorIndex::LightRed; + eKindOfMarker = b1PixMore ? BitmapMarkerKind::Rect_9x9 : BitmapMarkerKind::Rect_7x7; + break; } - - switch(eKind) + case SdrHdlKind::UpperLeft: + case SdrHdlKind::UpperRight: + case SdrHdlKind::LowerLeft: + case SdrHdlKind::LowerRight: { - case SdrHdlKind::Move: - { - eKindOfMarker = b1PixMore ? BitmapMarkerKind::Rect_9x9 : BitmapMarkerKind::Rect_7x7; - break; - } - case SdrHdlKind::UpperLeft: - case SdrHdlKind::UpperRight: - case SdrHdlKind::LowerLeft: - case SdrHdlKind::LowerRight: - { - // corner handles - if(bRot) - { - eKindOfMarker = BitmapMarkerKind::Circ_7x7; - } - else - { - eKindOfMarker = BitmapMarkerKind::Rect_7x7; - } - break; - } - case SdrHdlKind::Upper: - case SdrHdlKind::Lower: - { - // Upper/Lower handles - if(bRot) - { - eKindOfMarker = BitmapMarkerKind::Elli_9x7; - } - else - { - eKindOfMarker = BitmapMarkerKind::Rect_7x7; - } - break; - } - case SdrHdlKind::Left: - case SdrHdlKind::Right: - { - // Left/Right handles - if(bRot) - { - eKindOfMarker = BitmapMarkerKind::Elli_7x9; - } - else - { - eKindOfMarker = BitmapMarkerKind::Rect_7x7; - } - break; - } - case SdrHdlKind::Poly: - { - if(bRot) - { - eKindOfMarker = b1PixMore ? BitmapMarkerKind::Circ_9x9 : BitmapMarkerKind::Circ_7x7; - } - else - { - eKindOfMarker = b1PixMore ? BitmapMarkerKind::Rect_9x9 : BitmapMarkerKind::Rect_7x7; - } - break; - } - case SdrHdlKind::BezierWeight: // weight at poly + // corner handles + if(bRot) { eKindOfMarker = BitmapMarkerKind::Circ_7x7; - break; } - case SdrHdlKind::Circle: + else { - eKindOfMarker = BitmapMarkerKind::Rect_11x11; - break; + eKindOfMarker = BitmapMarkerKind::Rect_7x7; } - case SdrHdlKind::Ref1: - case SdrHdlKind::Ref2: + break; + } + case SdrHdlKind::Upper: + case SdrHdlKind::Lower: + { + // Upper/Lower handles + if(bRot) { - eKindOfMarker = BitmapMarkerKind::Crosshair; - break; + eKindOfMarker = BitmapMarkerKind::Elli_9x7; } - case SdrHdlKind::Glue: + else { - eKindOfMarker = BitmapMarkerKind::Glue; - break; + eKindOfMarker = BitmapMarkerKind::Rect_7x7; } - case SdrHdlKind::Anchor: + break; + } + case SdrHdlKind::Left: + case SdrHdlKind::Right: + { + // Left/Right handles + if(bRot) { - eKindOfMarker = BitmapMarkerKind::Anchor; - break; + eKindOfMarker = BitmapMarkerKind::Elli_7x9; } - case SdrHdlKind::User: + else { - break; + eKindOfMarker = BitmapMarkerKind::Rect_7x7; } - // top right anchor for SW - case SdrHdlKind::Anchor_TR: + break; + } + case SdrHdlKind::Poly: + { + if(bRot) { - eKindOfMarker = BitmapMarkerKind::AnchorTR; - break; + eKindOfMarker = b1PixMore ? BitmapMarkerKind::Circ_9x9 : BitmapMarkerKind::Circ_7x7; } - - // for SJ and the CustomShapeHandles: - case SdrHdlKind::CustomShape1: + else { - eKindOfMarker = b1PixMore ? BitmapMarkerKind::Customshape_9x9 : BitmapMarkerKind::Customshape_7x7; - eColIndex = BitmapColorIndex::Yellow; - break; + eKindOfMarker = b1PixMore ? BitmapMarkerKind::Rect_9x9 : BitmapMarkerKind::Rect_7x7; } - default: - break; + break; + } + case SdrHdlKind::BezierWeight: // weight at poly + { + eKindOfMarker = BitmapMarkerKind::Circ_7x7; + break; + } + case SdrHdlKind::Circle: + { + eKindOfMarker = BitmapMarkerKind::Rect_11x11; + break; + } + case SdrHdlKind::Ref1: + case SdrHdlKind::Ref2: + { + eKindOfMarker = BitmapMarkerKind::Crosshair; + break; } + case SdrHdlKind::Glue: + { + eKindOfMarker = BitmapMarkerKind::Glue; + break; + } + case SdrHdlKind::Anchor: + { + eKindOfMarker = BitmapMarkerKind::Anchor; + break; + } + case SdrHdlKind::User: + { + break; + } + // top right anchor for SW + case SdrHdlKind::Anchor_TR: + { + eKindOfMarker = BitmapMarkerKind::AnchorTR; + break; + } + + // for SJ and the CustomShapeHandles: + case SdrHdlKind::CustomShape1: + { + eKindOfMarker = b1PixMore ? BitmapMarkerKind::Customshape_9x9 : BitmapMarkerKind::Customshape_7x7; + eColIndex = BitmapColorIndex::Yellow; + break; + } + default: + break; + } + + SdrMarkView* pView = pHdlList->GetView(); + SdrPageView* pPageView = pView->GetSdrPageView(); - SdrMarkView* pView = pHdlList->GetView(); - SdrPageView* pPageView = pView->GetSdrPageView(); + if(!pPageView) + return; + + for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) + { + // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b]; + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); - if(pPageView) + if(rPageWindow.GetPaintWindow().OutputToWindow()) { - for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) + Point aMoveOutsideOffset(0, 0); + OutputDevice& rOutDev = rPageWindow.GetPaintWindow().GetOutputDevice(); + + // add offset if necessary + if(pHdlList->IsMoveOutside() || mbMoveOutside) { - // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b]; - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); + Size aOffset = rOutDev.PixelToLogic(Size(4, 4)); + + if(eKind == SdrHdlKind::UpperLeft || eKind == SdrHdlKind::Upper || eKind == SdrHdlKind::UpperRight) + aMoveOutsideOffset.AdjustY( -(aOffset.Width()) ); + if(eKind == SdrHdlKind::LowerLeft || eKind == SdrHdlKind::Lower || eKind == SdrHdlKind::LowerRight) + aMoveOutsideOffset.AdjustY(aOffset.Height() ); + if(eKind == SdrHdlKind::UpperLeft || eKind == SdrHdlKind::Left || eKind == SdrHdlKind::LowerLeft) + aMoveOutsideOffset.AdjustX( -(aOffset.Width()) ); + if(eKind == SdrHdlKind::UpperRight || eKind == SdrHdlKind::Right || eKind == SdrHdlKind::LowerRight) + aMoveOutsideOffset.AdjustX(aOffset.Height() ); + } - if(rPageWindow.GetPaintWindow().OutputToWindow()) + const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); + if (xManager.is()) + { + basegfx::B2DPoint aPosition(aPos.X(), aPos.Y()); + std::unique_ptr pNewOverlayObject; + if (getenv ("SVX_DRAW_HANDLES") && (eKindOfMarker == BitmapMarkerKind::Rect_7x7 || eKindOfMarker == BitmapMarkerKind::Rect_9x9 || eKindOfMarker == BitmapMarkerKind::Rect_11x11)) { - Point aMoveOutsideOffset(0, 0); - OutputDevice& rOutDev = rPageWindow.GetPaintWindow().GetOutputDevice(); - - // add offset if necessary - if(pHdlList->IsMoveOutside() || mbMoveOutside) + double fSize = 7.0; + switch (eKindOfMarker) { - Size aOffset = rOutDev.PixelToLogic(Size(4, 4)); - - if(eKind == SdrHdlKind::UpperLeft || eKind == SdrHdlKind::Upper || eKind == SdrHdlKind::UpperRight) - aMoveOutsideOffset.AdjustY( -(aOffset.Width()) ); - if(eKind == SdrHdlKind::LowerLeft || eKind == SdrHdlKind::Lower || eKind == SdrHdlKind::LowerRight) - aMoveOutsideOffset.AdjustY(aOffset.Height() ); - if(eKind == SdrHdlKind::UpperLeft || eKind == SdrHdlKind::Left || eKind == SdrHdlKind::LowerLeft) - aMoveOutsideOffset.AdjustX( -(aOffset.Width()) ); - if(eKind == SdrHdlKind::UpperRight || eKind == SdrHdlKind::Right || eKind == SdrHdlKind::LowerRight) - aMoveOutsideOffset.AdjustX(aOffset.Height() ); + case BitmapMarkerKind::Rect_9x9: + fSize = 9.0; + break; + case BitmapMarkerKind::Rect_11x11: + fSize = 11.0; + break; + default: + break; } + float fScalingFactor = rOutDev.GetDPIScaleFactor(); + basegfx::B2DSize aB2DSize(fSize * fScalingFactor, fSize * fScalingFactor); - const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); - if (xManager.is()) + Color aHandleFillColor(COL_LIGHTGREEN); + switch (eColIndex) { - basegfx::B2DPoint aPosition(aPos.X(), aPos.Y()); - std::unique_ptr pNewOverlayObject; - if (getenv ("SVX_DRAW_HANDLES") && (eKindOfMarker == BitmapMarkerKind::Rect_7x7 || eKindOfMarker == BitmapMarkerKind::Rect_9x9 || eKindOfMarker == BitmapMarkerKind::Rect_11x11)) - { - double fSize = 7.0; - switch (eKindOfMarker) - { - case BitmapMarkerKind::Rect_9x9: - fSize = 9.0; - break; - case BitmapMarkerKind::Rect_11x11: - fSize = 11.0; - break; - default: - break; - } - float fScalingFactor = rOutDev.GetDPIScaleFactor(); - basegfx::B2DSize aB2DSize(fSize * fScalingFactor, fSize * fScalingFactor); - - Color aHandleFillColor(COL_LIGHTGREEN); - switch (eColIndex) - { - case BitmapColorIndex::Cyan: - aHandleFillColor = COL_CYAN; - break; - case BitmapColorIndex::LightCyan: - aHandleFillColor = COL_LIGHTCYAN; - break; - case BitmapColorIndex::Red: - aHandleFillColor = COL_RED; - break; - case BitmapColorIndex::LightRed: - aHandleFillColor = COL_LIGHTRED; - break; - case BitmapColorIndex::Yellow: - aHandleFillColor = COL_YELLOW; - break; - default: - break; - } - pNewOverlayObject.reset(new sdr::overlay::OverlayHandle(aPosition, aB2DSize, /*HandleStrokeColor*/COL_BLACK, aHandleFillColor)); - } - else - { - pNewOverlayObject = CreateOverlayObject( - aPosition, eColIndex, eKindOfMarker, - aMoveOutsideOffset); - } - - // OVERLAYMANAGER - insertNewlyCreatedOverlayObjectForSdrHdl( - std::move(pNewOverlayObject), - rPageWindow.GetObjectContact(), - *xManager); + case BitmapColorIndex::Cyan: + aHandleFillColor = COL_CYAN; + break; + case BitmapColorIndex::LightCyan: + aHandleFillColor = COL_LIGHTCYAN; + break; + case BitmapColorIndex::Red: + aHandleFillColor = COL_RED; + break; + case BitmapColorIndex::LightRed: + aHandleFillColor = COL_LIGHTRED; + break; + case BitmapColorIndex::Yellow: + aHandleFillColor = COL_YELLOW; + break; + default: + break; } + pNewOverlayObject.reset(new sdr::overlay::OverlayHandle(aPosition, aB2DSize, /*HandleStrokeColor*/COL_BLACK, aHandleFillColor)); } + else + { + pNewOverlayObject = CreateOverlayObject( + aPosition, eColIndex, eKindOfMarker, + aMoveOutsideOffset); + } + + // OVERLAYMANAGER + insertNewlyCreatedOverlayObjectForSdrHdl( + std::move(pNewOverlayObject), + rPageWindow.GetObjectContact(), + *xManager); } } } @@ -1129,43 +1129,43 @@ void SdrHdlColor::CreateB2dIAObject() // first throw away old one GetRidOfIAObject(); - if(pHdlList) + if(!pHdlList) + return; + + SdrMarkView* pView = pHdlList->GetView(); + + if(!(pView && !pView->areMarkHandlesHidden())) + return; + + SdrPageView* pPageView = pView->GetSdrPageView(); + + if(!pPageView) + return; + + for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) { - SdrMarkView* pView = pHdlList->GetView(); + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); - if(pView && !pView->areMarkHandlesHidden()) + if(rPageWindow.GetPaintWindow().OutputToWindow()) { - SdrPageView* pPageView = pView->GetSdrPageView(); - - if(pPageView) + const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); + if (xManager.is()) { - for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) - { - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); + BitmapEx aBmpCol(CreateColorDropper(aMarkerColor)); + basegfx::B2DPoint aPosition(aPos.X(), aPos.Y()); + std::unique_ptr pNewOverlayObject(new + sdr::overlay::OverlayBitmapEx( + aPosition, + aBmpCol, + static_cast(aBmpCol.GetSizePixel().Width() - 1) >> 1, + static_cast(aBmpCol.GetSizePixel().Height() - 1) >> 1 + )); - if(rPageWindow.GetPaintWindow().OutputToWindow()) - { - const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); - if (xManager.is()) - { - BitmapEx aBmpCol(CreateColorDropper(aMarkerColor)); - basegfx::B2DPoint aPosition(aPos.X(), aPos.Y()); - std::unique_ptr pNewOverlayObject(new - sdr::overlay::OverlayBitmapEx( - aPosition, - aBmpCol, - static_cast(aBmpCol.GetSizePixel().Width() - 1) >> 1, - static_cast(aBmpCol.GetSizePixel().Height() - 1) >> 1 - )); - - // OVERLAYMANAGER - insertNewlyCreatedOverlayObjectForSdrHdl( - std::move(pNewOverlayObject), - rPageWindow.GetObjectContact(), - *xManager); - } - } - } + // OVERLAYMANAGER + insertNewlyCreatedOverlayObjectForSdrHdl( + std::move(pNewOverlayObject), + rPageWindow.GetObjectContact(), + *xManager); } } } @@ -1281,78 +1281,78 @@ void SdrHdlGradient::CreateB2dIAObject() // first throw away old one GetRidOfIAObject(); - if(pHdlList) + if(!pHdlList) + return; + + SdrMarkView* pView = pHdlList->GetView(); + + if(!(pView && !pView->areMarkHandlesHidden())) + return; + + SdrPageView* pPageView = pView->GetSdrPageView(); + + if(!pPageView) + return; + + for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) { - SdrMarkView* pView = pHdlList->GetView(); + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); - if(pView && !pView->areMarkHandlesHidden()) + if(rPageWindow.GetPaintWindow().OutputToWindow()) { - SdrPageView* pPageView = pView->GetSdrPageView(); - - if(pPageView) + const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); + if (xManager.is()) { - for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) - { - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); + // striped line in between + basegfx::B2DVector aVec(a2ndPos.X() - aPos.X(), a2ndPos.Y() - aPos.Y()); + double fVecLen = aVec.getLength(); + double fLongPercentArrow = (1.0 - 0.05) * fVecLen; + double fHalfArrowWidth = (0.05 * 0.5) * fVecLen; + aVec.normalize(); + basegfx::B2DVector aPerpend(-aVec.getY(), aVec.getX()); + sal_Int32 nMidX = static_cast(aPos.X() + aVec.getX() * fLongPercentArrow); + sal_Int32 nMidY = static_cast(aPos.Y() + aVec.getY() * fLongPercentArrow); + Point aMidPoint(nMidX, nMidY); + + basegfx::B2DPoint aPosition(aPos.X(), aPos.Y()); + basegfx::B2DPoint aMidPos(aMidPoint.X(), aMidPoint.Y()); + + std::unique_ptr pNewOverlayObject(new + sdr::overlay::OverlayLineStriped( + aPosition, aMidPos + )); + + pNewOverlayObject->setBaseColor(IsGradient() ? COL_BLACK : COL_BLUE); - if(rPageWindow.GetPaintWindow().OutputToWindow()) - { - const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); - if (xManager.is()) - { - // striped line in between - basegfx::B2DVector aVec(a2ndPos.X() - aPos.X(), a2ndPos.Y() - aPos.Y()); - double fVecLen = aVec.getLength(); - double fLongPercentArrow = (1.0 - 0.05) * fVecLen; - double fHalfArrowWidth = (0.05 * 0.5) * fVecLen; - aVec.normalize(); - basegfx::B2DVector aPerpend(-aVec.getY(), aVec.getX()); - sal_Int32 nMidX = static_cast(aPos.X() + aVec.getX() * fLongPercentArrow); - sal_Int32 nMidY = static_cast(aPos.Y() + aVec.getY() * fLongPercentArrow); - Point aMidPoint(nMidX, nMidY); - - basegfx::B2DPoint aPosition(aPos.X(), aPos.Y()); - basegfx::B2DPoint aMidPos(aMidPoint.X(), aMidPoint.Y()); - - std::unique_ptr pNewOverlayObject(new - sdr::overlay::OverlayLineStriped( - aPosition, aMidPos - )); - - pNewOverlayObject->setBaseColor(IsGradient() ? COL_BLACK : COL_BLUE); - - // OVERLAYMANAGER - insertNewlyCreatedOverlayObjectForSdrHdl( - std::move(pNewOverlayObject), - rPageWindow.GetObjectContact(), - *xManager); - - // arrowhead - Point aLeft(aMidPoint.X() + static_cast(aPerpend.getX() * fHalfArrowWidth), - aMidPoint.Y() + static_cast(aPerpend.getY() * fHalfArrowWidth)); - Point aRight(aMidPoint.X() - static_cast(aPerpend.getX() * fHalfArrowWidth), - aMidPoint.Y() - static_cast(aPerpend.getY() * fHalfArrowWidth)); - - basegfx::B2DPoint aPositionLeft(aLeft.X(), aLeft.Y()); - basegfx::B2DPoint aPositionRight(aRight.X(), aRight.Y()); - basegfx::B2DPoint aPosition2(a2ndPos.X(), a2ndPos.Y()); - - pNewOverlayObject.reset(new - sdr::overlay::OverlayTriangle( - aPositionLeft, - aPosition2, - aPositionRight, - IsGradient() ? COL_BLACK : COL_BLUE - )); - - // OVERLAYMANAGER - insertNewlyCreatedOverlayObjectForSdrHdl( - std::move(pNewOverlayObject), - rPageWindow.GetObjectContact(), - *xManager); - } - } - } + // OVERLAYMANAGER + insertNewlyCreatedOverlayObjectForSdrHdl( + std::move(pNewOverlayObject), + rPageWindow.GetObjectContact(), + *xManager); + + // arrowhead + Point aLeft(aMidPoint.X() + static_cast(aPerpend.getX() * fHalfArrowWidth), + aMidPoint.Y() + static_cast(aPerpend.getY() * fHalfArrowWidth)); + Point aRight(aMidPoint.X() - static_cast(aPerpend.getX() * fHalfArrowWidth), + aMidPoint.Y() - static_cast(aPerpend.getY() * fHalfArrowWidth)); + + basegfx::B2DPoint aPositionLeft(aLeft.X(), aLeft.Y()); + basegfx::B2DPoint aPositionRight(aRight.X(), aRight.Y()); + basegfx::B2DPoint aPosition2(a2ndPos.X(), a2ndPos.Y()); + + pNewOverlayObject.reset(new + sdr::overlay::OverlayTriangle( + aPositionLeft, + aPosition2, + aPositionRight, + IsGradient() ? COL_BLACK : COL_BLUE + )); + + // OVERLAYMANAGER + insertNewlyCreatedOverlayObjectForSdrHdl( + std::move(pNewOverlayObject), + rPageWindow.GetObjectContact(), + *xManager); } } } @@ -1443,45 +1443,45 @@ void SdrHdlLine::CreateB2dIAObject() // first throw away old one GetRidOfIAObject(); - if(pHdlList) + if(!pHdlList) + return; + + SdrMarkView* pView = pHdlList->GetView(); + + if(!(pView && !pView->areMarkHandlesHidden() && pHdl1 && pHdl2)) + return; + + SdrPageView* pPageView = pView->GetSdrPageView(); + + if(!pPageView) + return; + + for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) { - SdrMarkView* pView = pHdlList->GetView(); + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); - if(pView && !pView->areMarkHandlesHidden() && pHdl1 && pHdl2) + if(rPageWindow.GetPaintWindow().OutputToWindow()) { - SdrPageView* pPageView = pView->GetSdrPageView(); - - if(pPageView) + const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); + if (xManager.is()) { - for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) - { - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); + basegfx::B2DPoint aPosition1(pHdl1->GetPos().X(), pHdl1->GetPos().Y()); + basegfx::B2DPoint aPosition2(pHdl2->GetPos().X(), pHdl2->GetPos().Y()); - if(rPageWindow.GetPaintWindow().OutputToWindow()) - { - const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); - if (xManager.is()) - { - basegfx::B2DPoint aPosition1(pHdl1->GetPos().X(), pHdl1->GetPos().Y()); - basegfx::B2DPoint aPosition2(pHdl2->GetPos().X(), pHdl2->GetPos().Y()); - - std::unique_ptr pNewOverlayObject(new - sdr::overlay::OverlayLineStriped( - aPosition1, - aPosition2 - )); - - // color(?) - pNewOverlayObject->setBaseColor(COL_LIGHTRED); - - // OVERLAYMANAGER - insertNewlyCreatedOverlayObjectForSdrHdl( - std::move(pNewOverlayObject), - rPageWindow.GetObjectContact(), - *xManager); - } - } - } + std::unique_ptr pNewOverlayObject(new + sdr::overlay::OverlayLineStriped( + aPosition1, + aPosition2 + )); + + // color(?) + pNewOverlayObject->setBaseColor(COL_LIGHTRED); + + // OVERLAYMANAGER + insertNewlyCreatedOverlayObjectForSdrHdl( + std::move(pNewOverlayObject), + rPageWindow.GetObjectContact(), + *xManager); } } } @@ -1501,50 +1501,50 @@ void SdrHdlBezWgt::CreateB2dIAObject() SdrHdl::CreateB2dIAObject(); // create lines - if(pHdlList) + if(!pHdlList) + return; + + SdrMarkView* pView = pHdlList->GetView(); + + if(!(pView && !pView->areMarkHandlesHidden())) + return; + + SdrPageView* pPageView = pView->GetSdrPageView(); + + if(!pPageView) + return; + + for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) { - SdrMarkView* pView = pHdlList->GetView(); + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); - if(pView && !pView->areMarkHandlesHidden()) + if(rPageWindow.GetPaintWindow().OutputToWindow()) { - SdrPageView* pPageView = pView->GetSdrPageView(); - - if(pPageView) + const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); + if (xManager.is()) { - for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) - { - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); - - if(rPageWindow.GetPaintWindow().OutputToWindow()) - { - const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); - if (xManager.is()) - { - basegfx::B2DPoint aPosition1(pHdl1->GetPos().X(), pHdl1->GetPos().Y()); - basegfx::B2DPoint aPosition2(aPos.X(), aPos.Y()); + basegfx::B2DPoint aPosition1(pHdl1->GetPos().X(), pHdl1->GetPos().Y()); + basegfx::B2DPoint aPosition2(aPos.X(), aPos.Y()); - if(!aPosition1.equal(aPosition2)) - { - std::unique_ptr pNewOverlayObject(new - sdr::overlay::OverlayLineStriped( - aPosition1, - aPosition2 - )); + if(!aPosition1.equal(aPosition2)) + { + std::unique_ptr pNewOverlayObject(new + sdr::overlay::OverlayLineStriped( + aPosition1, + aPosition2 + )); - // line part is not hittable - pNewOverlayObject->setHittable(false); + // line part is not hittable + pNewOverlayObject->setHittable(false); - // color(?) - pNewOverlayObject->setBaseColor(COL_LIGHTBLUE); + // color(?) + pNewOverlayObject->setBaseColor(COL_LIGHTBLUE); - // OVERLAYMANAGER - insertNewlyCreatedOverlayObjectForSdrHdl( - std::move(pNewOverlayObject), - rPageWindow.GetObjectContact(), - *xManager); - } - } - } + // OVERLAYMANAGER + insertNewlyCreatedOverlayObjectForSdrHdl( + std::move(pNewOverlayObject), + rPageWindow.GetObjectContact(), + *xManager); } } } @@ -1560,39 +1560,39 @@ E3dVolumeMarker::E3dVolumeMarker(const basegfx::B2DPolyPolygon& rWireframePoly) void E3dVolumeMarker::CreateB2dIAObject() { // create lines - if(pHdlList) + if(!pHdlList) + return; + + SdrMarkView* pView = pHdlList->GetView(); + + if(!(pView && !pView->areMarkHandlesHidden())) + return; + + SdrPageView* pPageView = pView->GetSdrPageView(); + + if(!pPageView) + return; + + for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) { - SdrMarkView* pView = pHdlList->GetView(); + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); - if(pView && !pView->areMarkHandlesHidden()) + if(rPageWindow.GetPaintWindow().OutputToWindow()) { - SdrPageView* pPageView = pView->GetSdrPageView(); - - if(pPageView) + const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); + if (xManager.is() && aWireframePoly.count()) { - for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) - { - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); - - if(rPageWindow.GetPaintWindow().OutputToWindow()) - { - const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); - if (xManager.is() && aWireframePoly.count()) - { - std::unique_ptr pNewOverlayObject(new - sdr::overlay::OverlayPolyPolygonStripedAndFilled( - aWireframePoly)); + std::unique_ptr pNewOverlayObject(new + sdr::overlay::OverlayPolyPolygonStripedAndFilled( + aWireframePoly)); - pNewOverlayObject->setBaseColor(COL_BLACK); + pNewOverlayObject->setBaseColor(COL_BLACK); - // OVERLAYMANAGER - insertNewlyCreatedOverlayObjectForSdrHdl( - std::move(pNewOverlayObject), - rPageWindow.GetObjectContact(), - *xManager); - } - } - } + // OVERLAYMANAGER + insertNewlyCreatedOverlayObjectForSdrHdl( + std::move(pNewOverlayObject), + rPageWindow.GetObjectContact(), + *xManager); } } } @@ -1726,52 +1726,52 @@ void ImpMeasureHdl::CreateB2dIAObject() // first throw away old one GetRidOfIAObject(); - if(pHdlList) + if(!pHdlList) + return; + + SdrMarkView* pView = pHdlList->GetView(); + + if(!(pView && !pView->areMarkHandlesHidden())) + return; + + BitmapColorIndex eColIndex = BitmapColorIndex::LightCyan; + BitmapMarkerKind eKindOfMarker = BitmapMarkerKind::Rect_9x9; + + if(nObjHdlNum > 1) { - SdrMarkView* pView = pHdlList->GetView(); + eKindOfMarker = BitmapMarkerKind::Rect_7x7; + } - if(pView && !pView->areMarkHandlesHidden()) - { - BitmapColorIndex eColIndex = BitmapColorIndex::LightCyan; - BitmapMarkerKind eKindOfMarker = BitmapMarkerKind::Rect_9x9; + if(bSelect) + { + eColIndex = BitmapColorIndex::Cyan; + } - if(nObjHdlNum > 1) - { - eKindOfMarker = BitmapMarkerKind::Rect_7x7; - } + SdrPageView* pPageView = pView->GetSdrPageView(); - if(bSelect) - { - eColIndex = BitmapColorIndex::Cyan; - } + if(!pPageView) + return; - SdrPageView* pPageView = pView->GetSdrPageView(); + for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) + { + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); - if(pPageView) + if(rPageWindow.GetPaintWindow().OutputToWindow()) + { + const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); + if (xManager.is()) { - for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) - { - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); + basegfx::B2DPoint aPosition(aPos.X(), aPos.Y()); + std::unique_ptr pNewOverlayObject(CreateOverlayObject( + aPosition, + eColIndex, + eKindOfMarker)); - if(rPageWindow.GetPaintWindow().OutputToWindow()) - { - const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); - if (xManager.is()) - { - basegfx::B2DPoint aPosition(aPos.X(), aPos.Y()); - std::unique_ptr pNewOverlayObject(CreateOverlayObject( - aPosition, - eColIndex, - eKindOfMarker)); - - // OVERLAYMANAGER - insertNewlyCreatedOverlayObjectForSdrHdl( - std::move(pNewOverlayObject), - rPageWindow.GetObjectContact(), - *xManager); - } - } - } + // OVERLAYMANAGER + insertNewlyCreatedOverlayObjectForSdrHdl( + std::move(pNewOverlayObject), + rPageWindow.GetObjectContact(), + *xManager); } } } @@ -1800,51 +1800,51 @@ void ImpTextframeHdl::CreateB2dIAObject() // first throw away old one GetRidOfIAObject(); - if(pHdlList) + if(!pHdlList) + return; + + SdrMarkView* pView = pHdlList->GetView(); + + if(!(pView && !pView->areMarkHandlesHidden())) + return; + + SdrPageView* pPageView = pView->GetSdrPageView(); + + if(!pPageView) + return; + + for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) { - SdrMarkView* pView = pHdlList->GetView(); + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); - if(pView && !pView->areMarkHandlesHidden()) + if(rPageWindow.GetPaintWindow().OutputToWindow()) { - SdrPageView* pPageView = pView->GetSdrPageView(); - - if(pPageView) + const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); + if (xManager.is()) { - for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) - { - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); + const basegfx::B2DPoint aTopLeft(maRect.Left(), maRect.Top()); + const basegfx::B2DPoint aBottomRight(maRect.Right(), maRect.Bottom()); + const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; + const Color aHilightColor(aSvtOptionsDrawinglayer.getHilightColor()); + const double fTransparence(aSvtOptionsDrawinglayer.GetTransparentSelectionPercent() * 0.01); + + std::unique_ptr pNewOverlayObject(new sdr::overlay::OverlayRectangle( + aTopLeft, + aBottomRight, + aHilightColor, + fTransparence, + 3.0, + 3.0, + nRotationAngle * -F_PI18000, + true)); // allow animation; the Handle is not shown at text edit time + + pNewOverlayObject->setHittable(false); - if(rPageWindow.GetPaintWindow().OutputToWindow()) - { - const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); - if (xManager.is()) - { - const basegfx::B2DPoint aTopLeft(maRect.Left(), maRect.Top()); - const basegfx::B2DPoint aBottomRight(maRect.Right(), maRect.Bottom()); - const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; - const Color aHilightColor(aSvtOptionsDrawinglayer.getHilightColor()); - const double fTransparence(aSvtOptionsDrawinglayer.GetTransparentSelectionPercent() * 0.01); - - std::unique_ptr pNewOverlayObject(new sdr::overlay::OverlayRectangle( - aTopLeft, - aBottomRight, - aHilightColor, - fTransparence, - 3.0, - 3.0, - nRotationAngle * -F_PI18000, - true)); // allow animation; the Handle is not shown at text edit time - - pNewOverlayObject->setHittable(false); - - // OVERLAYMANAGER - insertNewlyCreatedOverlayObjectForSdrHdl( - std::move(pNewOverlayObject), - rPageWindow.GetObjectContact(), - *xManager); - } - } - } + // OVERLAYMANAGER + insertNewlyCreatedOverlayObjectForSdrHdl( + std::move(pNewOverlayObject), + rPageWindow.GetObjectContact(), + *xManager); } } } @@ -2138,26 +2138,26 @@ SdrHdl* SdrHdlList::GetFocusHdl() const void SdrHdlList::SetFocusHdl(SdrHdl* pNew) { - if(pNew) - { - SdrHdl* pActual = GetFocusHdl(); + if(!pNew) + return; - if(!pActual || pActual != pNew) - { - const size_t nNewHdlNum = GetHdlNum(pNew); + SdrHdl* pActual = GetFocusHdl(); - if(nNewHdlNum != SAL_MAX_SIZE) - { - mnFocusIndex = nNewHdlNum; + if(pActual && pActual == pNew) + return; - if(pActual) - { - pActual->Touch(); - } + const size_t nNewHdlNum = GetHdlNum(pNew); - pNew->Touch(); - } + if(nNewHdlNum != SAL_MAX_SIZE) + { + mnFocusIndex = nNewHdlNum; + + if(pActual) + { + pActual->Touch(); } + + pNew->Touch(); } } @@ -2264,18 +2264,17 @@ void SdrHdlList::Sort() // get now and compare SdrHdl* pNow = GetFocusHdl(); - if(pPrev != pNow) - { + if(pPrev == pNow) + return; - if(pPrev) - { - pPrev->Touch(); - } + if(pPrev) + { + pPrev->Touch(); + } - if(pNow) - { - pNow->Touch(); - } + if(pNow) + { + pNow->Touch(); } } @@ -2395,68 +2394,68 @@ void SdrCropHdl::CreateB2dIAObject() SdrMarkView* pView = pHdlList ? pHdlList->GetView() : nullptr; SdrPageView* pPageView = pView ? pView->GetSdrPageView() : nullptr; - if( pPageView && !pView->areMarkHandlesHidden() ) - { - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - int nHdlSize = pHdlList->GetHdlSize(); + if( !(pPageView && !pView->areMarkHandlesHidden()) ) + return; - const BitmapEx aHandlesBitmap(SIP_SA_CROP_MARKERS); - BitmapEx aBmpEx1( GetBitmapForHandle( aHandlesBitmap, nHdlSize ) ); + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + int nHdlSize = pHdlList->GetHdlSize(); - for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) - { - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); + const BitmapEx aHandlesBitmap(SIP_SA_CROP_MARKERS); + BitmapEx aBmpEx1( GetBitmapForHandle( aHandlesBitmap, nHdlSize ) ); - if(rPageWindow.GetPaintWindow().OutputToWindow()) - { - const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); - if (xManager.is()) - { - basegfx::B2DPoint aPosition(aPos.X(), aPos.Y()); + for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) + { + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b); - std::unique_ptr pOverlayObject; + if(rPageWindow.GetPaintWindow().OutputToWindow()) + { + const rtl::Reference< sdr::overlay::OverlayManager >& xManager = rPageWindow.GetOverlayManager(); + if (xManager.is()) + { + basegfx::B2DPoint aPosition(aPos.X(), aPos.Y()); - // animate focused handles - if(IsFocusHdl() && (pHdlList->GetFocusHdl() == this)) - { - if( nHdlSize >= 2 ) - nHdlSize = 1; - - BitmapEx aBmpEx2( GetBitmapForHandle( aHandlesBitmap, nHdlSize + 1 ) ); - - const sal_uInt64 nBlinkTime = rStyleSettings.GetCursorBlinkTime(); - - pOverlayObject.reset(new sdr::overlay::OverlayAnimatedBitmapEx( - aPosition, - aBmpEx1, - aBmpEx2, - nBlinkTime, - static_cast(aBmpEx1.GetSizePixel().Width() - 1) >> 1, - static_cast(aBmpEx1.GetSizePixel().Height() - 1) >> 1, - static_cast(aBmpEx2.GetSizePixel().Width() - 1) >> 1, - static_cast(aBmpEx2.GetSizePixel().Height() - 1) >> 1, - mfShearX, - mfRotation)); - } - else - { - // create centered handle as default - pOverlayObject.reset(new sdr::overlay::OverlayBitmapEx( - aPosition, - aBmpEx1, - static_cast(aBmpEx1.GetSizePixel().Width() - 1) >> 1, - static_cast(aBmpEx1.GetSizePixel().Height() - 1) >> 1, - 0.0, - mfShearX, - mfRotation)); - } + std::unique_ptr pOverlayObject; - // OVERLAYMANAGER - insertNewlyCreatedOverlayObjectForSdrHdl( - std::move(pOverlayObject), - rPageWindow.GetObjectContact(), - *xManager); + // animate focused handles + if(IsFocusHdl() && (pHdlList->GetFocusHdl() == this)) + { + if( nHdlSize >= 2 ) + nHdlSize = 1; + + BitmapEx aBmpEx2( GetBitmapForHandle( aHandlesBitmap, nHdlSize + 1 ) ); + + const sal_uInt64 nBlinkTime = rStyleSettings.GetCursorBlinkTime(); + + pOverlayObject.reset(new sdr::overlay::OverlayAnimatedBitmapEx( + aPosition, + aBmpEx1, + aBmpEx2, + nBlinkTime, + static_cast(aBmpEx1.GetSizePixel().Width() - 1) >> 1, + static_cast(aBmpEx1.GetSizePixel().Height() - 1) >> 1, + static_cast(aBmpEx2.GetSizePixel().Width() - 1) >> 1, + static_cast(aBmpEx2.GetSizePixel().Height() - 1) >> 1, + mfShearX, + mfRotation)); + } + else + { + // create centered handle as default + pOverlayObject.reset(new sdr::overlay::OverlayBitmapEx( + aPosition, + aBmpEx1, + static_cast(aBmpEx1.GetSizePixel().Width() - 1) >> 1, + static_cast(aBmpEx1.GetSizePixel().Height() - 1) >> 1, + 0.0, + mfShearX, + mfRotation)); } + + // OVERLAYMANAGER + insertNewlyCreatedOverlayObjectForSdrHdl( + std::move(pOverlayObject), + rPageWindow.GetObjectContact(), + *xManager); } } } diff --git a/svx/source/svdraw/svdlayer.cxx b/svx/source/svdraw/svdlayer.cxx index d70b221ba626..c9ca7041f261 100644 --- a/svx/source/svdraw/svdlayer.cxx +++ b/svx/source/svdraw/svdlayer.cxx @@ -46,22 +46,22 @@ void SdrLayerIDSet::operator&=(const SdrLayerIDSet& r2ndSet) void SdrLayerIDSet::PutValue( const css::uno::Any & rAny ) { css::uno::Sequence< sal_Int8 > aSeq; - if( rAny >>= aSeq ) - { - sal_Int16 nCount = static_cast(aSeq.getLength()); - if( nCount > 32 ) - nCount = 32; + if( !(rAny >>= aSeq) ) + return; - sal_Int16 nIndex; - for( nIndex = 0; nIndex < nCount; nIndex++ ) - { - aData[nIndex] = static_cast(aSeq[nIndex]); - } + sal_Int16 nCount = static_cast(aSeq.getLength()); + if( nCount > 32 ) + nCount = 32; - for( ; nIndex < 32; nIndex++ ) - { - aData[nIndex] = 0; - } + sal_Int16 nIndex; + for( nIndex = 0; nIndex < nCount; nIndex++ ) + { + aData[nIndex] = static_cast(aSeq[nIndex]); + } + + for( ; nIndex < 32; nIndex++ ) + { + aData[nIndex] = 0; } } diff --git a/svx/source/svdraw/svdmark.cxx b/svx/source/svdraw/svdmark.cxx index 3b5988974d18..866de4920c15 100644 --- a/svx/source/svdraw/svdmark.cxx +++ b/svx/source/svdraw/svdmark.cxx @@ -148,51 +148,51 @@ void SdrMarkList::ForceSort() const void SdrMarkList::ImpForceSort() { - if(!mbSorted) + if(mbSorted) + return; + + mbSorted = true; + size_t nCount = maList.size(); + + // remove invalid + if(nCount > 0 ) { - mbSorted = true; - size_t nCount = maList.size(); + maList.erase(std::remove_if(maList.begin(), maList.end(), + [](std::unique_ptr& rItem) { return rItem->GetMarkedSdrObj() == nullptr; }), + maList.end()); + nCount = maList.size(); + } - // remove invalid - if(nCount > 0 ) - { - maList.erase(std::remove_if(maList.begin(), maList.end(), - [](std::unique_ptr& rItem) { return rItem->GetMarkedSdrObj() == nullptr; }), - maList.end()); - nCount = maList.size(); - } + if(nCount <= 1) + return; - if(nCount > 1) - { - std::sort(maList.begin(), maList.end(), ImpSdrMarkListSorter); + std::sort(maList.begin(), maList.end(), ImpSdrMarkListSorter); - // remove duplicates - if(maList.size() > 1) - { - SdrMark* pCurrent = maList.back().get(); - for (size_t count = maList.size() - 1; count; --count) - { - size_t i = count - 1; - SdrMark* pCmp = maList[i].get(); - assert(pCurrent->GetMarkedSdrObj()); - if(pCurrent->GetMarkedSdrObj() == pCmp->GetMarkedSdrObj()) - { - // Con1/Con2 Merging - if(pCmp->IsCon1()) - pCurrent->SetCon1(true); + // remove duplicates + if(maList.size() <= 1) + return; - if(pCmp->IsCon2()) - pCurrent->SetCon2(true); + SdrMark* pCurrent = maList.back().get(); + for (size_t count = maList.size() - 1; count; --count) + { + size_t i = count - 1; + SdrMark* pCmp = maList[i].get(); + assert(pCurrent->GetMarkedSdrObj()); + if(pCurrent->GetMarkedSdrObj() == pCmp->GetMarkedSdrObj()) + { + // Con1/Con2 Merging + if(pCmp->IsCon1()) + pCurrent->SetCon1(true); - // delete pCmp - maList.erase(maList.begin() + i); - } - else - { - pCurrent = pCmp; - } - } - } + if(pCmp->IsCon2()) + pCurrent->SetCon2(true); + + // delete pCmp + maList.erase(maList.begin() + i); + } + else + { + pCurrent = pCmp; } } } @@ -694,96 +694,96 @@ namespace sdr void ViewSelection::ImplCollectCompleteSelection(SdrObject* pObj) { - if(pObj) + if(!pObj) + return; + + bool bIsGroup(pObj->IsGroupObject()); + + if(bIsGroup && dynamic_cast< const E3dObject* >(pObj) != nullptr && dynamic_cast< const E3dScene* >(pObj) == nullptr) { - bool bIsGroup(pObj->IsGroupObject()); + bIsGroup = false; + } - if(bIsGroup && dynamic_cast< const E3dObject* >(pObj) != nullptr && dynamic_cast< const E3dScene* >(pObj) == nullptr) - { - bIsGroup = false; - } + if(bIsGroup) + { + SdrObjList* pList = pObj->GetSubList(); - if(bIsGroup) + for(size_t a = 0; a < pList->GetObjCount(); ++a) { - SdrObjList* pList = pObj->GetSubList(); - - for(size_t a = 0; a < pList->GetObjCount(); ++a) - { - SdrObject* pObj2 = pList->GetObj(a); - ImplCollectCompleteSelection(pObj2); - } + SdrObject* pObj2 = pList->GetObj(a); + ImplCollectCompleteSelection(pObj2); } - - maAllMarkedObjects.push_back(pObj); } + + maAllMarkedObjects.push_back(pObj); } void ViewSelection::ImpForceEdgesOfMarkedNodes() { - if(mbEdgesOfMarkedNodesDirty) - { - mbEdgesOfMarkedNodesDirty = false; - maMarkedObjectList.ForceSort(); - maEdgesOfMarkedNodes.Clear(); - maMarkedEdgesOfMarkedNodes.Clear(); - maAllMarkedObjects.clear(); + if(!mbEdgesOfMarkedNodesDirty) + return; + + mbEdgesOfMarkedNodesDirty = false; + maMarkedObjectList.ForceSort(); + maEdgesOfMarkedNodes.Clear(); + maMarkedEdgesOfMarkedNodes.Clear(); + maAllMarkedObjects.clear(); - // GetMarkCount after ForceSort - const size_t nMarkCount(maMarkedObjectList.GetMarkCount()); + // GetMarkCount after ForceSort + const size_t nMarkCount(maMarkedObjectList.GetMarkCount()); - for(size_t a = 0; a < nMarkCount; ++a) + for(size_t a = 0; a < nMarkCount; ++a) + { + SdrObject* pCandidate = maMarkedObjectList.GetMark(a)->GetMarkedSdrObj(); + + if(pCandidate) { - SdrObject* pCandidate = maMarkedObjectList.GetMark(a)->GetMarkedSdrObj(); + // build transitive hull + ImplCollectCompleteSelection(pCandidate); - if(pCandidate) - { - // build transitive hull - ImplCollectCompleteSelection(pCandidate); + // travel over broadcaster/listener to access edges connected to the selected object + const SfxBroadcaster* pBC = pCandidate->GetBroadcaster(); - // travel over broadcaster/listener to access edges connected to the selected object - const SfxBroadcaster* pBC = pCandidate->GetBroadcaster(); + if(pBC) + { + const size_t nLstCnt(pBC->GetSizeOfVector()); - if(pBC) + for(size_t nl=0; nl < nLstCnt; ++nl) { - const size_t nLstCnt(pBC->GetSizeOfVector()); + SfxListener* pLst = pBC->GetListener(nl); + SdrEdgeObj* pEdge = dynamic_cast( pLst ); - for(size_t nl=0; nl < nLstCnt; ++nl) + if(pEdge && pEdge->IsInserted() && pEdge->getSdrPageFromSdrObject() == pCandidate->getSdrPageFromSdrObject()) { - SfxListener* pLst = pBC->GetListener(nl); - SdrEdgeObj* pEdge = dynamic_cast( pLst ); + SdrMark aM(pEdge, maMarkedObjectList.GetMark(a)->GetPageView()); - if(pEdge && pEdge->IsInserted() && pEdge->getSdrPageFromSdrObject() == pCandidate->getSdrPageFromSdrObject()) + if(pEdge->GetConnectedNode(true) == pCandidate) { - SdrMark aM(pEdge, maMarkedObjectList.GetMark(a)->GetPageView()); - - if(pEdge->GetConnectedNode(true) == pCandidate) - { - aM.SetCon1(true); - } - - if(pEdge->GetConnectedNode(false) == pCandidate) - { - aM.SetCon2(true); - } - - if(SAL_MAX_SIZE == maMarkedObjectList.FindObject(pEdge)) - { - // check if it itself is selected - maEdgesOfMarkedNodes.InsertEntry(aM); - } - else - { - maMarkedEdgesOfMarkedNodes.InsertEntry(aM); - } + aM.SetCon1(true); + } + + if(pEdge->GetConnectedNode(false) == pCandidate) + { + aM.SetCon2(true); + } + + if(SAL_MAX_SIZE == maMarkedObjectList.FindObject(pEdge)) + { + // check if it itself is selected + maEdgesOfMarkedNodes.InsertEntry(aM); + } + else + { + maMarkedEdgesOfMarkedNodes.InsertEntry(aM); } } } } } - - maEdgesOfMarkedNodes.ForceSort(); - maMarkedEdgesOfMarkedNodes.ForceSort(); } + + maEdgesOfMarkedNodes.ForceSort(); + maMarkedEdgesOfMarkedNodes.ForceSort(); } } // end of namespace sdr diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index ccab4da45a4a..c3afe2ccb352 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -388,24 +388,24 @@ void SdrModel::Repeat(SfxRepeatTarget& rView) void SdrModel::ImpPostUndoAction(std::unique_ptr pUndo) { DBG_ASSERT( mpImpl->mpUndoManager == nullptr, "svx::SdrModel::ImpPostUndoAction(), method not supported with application undo manager!" ); - if( IsUndoEnabled() ) + if( !IsUndoEnabled() ) + return; + + if (m_aUndoLink) { - if (m_aUndoLink) - { - m_aUndoLink(std::move(pUndo)); - } - else + m_aUndoLink(std::move(pUndo)); + } + else + { + if (!m_pUndoStack) + m_pUndoStack.reset(new std::deque>); + m_pUndoStack->emplace_front(std::move(pUndo)); + while (m_pUndoStack->size()>m_nMaxUndoCount) { - if (!m_pUndoStack) - m_pUndoStack.reset(new std::deque>); - m_pUndoStack->emplace_front(std::move(pUndo)); - while (m_pUndoStack->size()>m_nMaxUndoCount) - { - m_pUndoStack->pop_back(); - } - if (m_pRedoStack!=nullptr) - m_pRedoStack->clear(); + m_pUndoStack->pop_back(); } + if (m_pRedoStack!=nullptr) + m_pRedoStack->clear(); } } @@ -1730,55 +1730,55 @@ void SdrModel::setLock( bool bLock ) void SdrModel::MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModelel ) { assert(pNewModelel != nullptr); - if( pSourceSet && pDestSet && (pSourceSet != pDestSet ) ) - { - SfxWhichIter aWhichIter(*pSourceSet); - sal_uInt16 nWhich(aWhichIter.FirstWhich()); - const SfxPoolItem *pPoolItem; + if( !(pSourceSet && pDestSet && (pSourceSet != pDestSet )) ) + return; + + SfxWhichIter aWhichIter(*pSourceSet); + sal_uInt16 nWhich(aWhichIter.FirstWhich()); + const SfxPoolItem *pPoolItem; - while(nWhich) + while(nWhich) + { + if(SfxItemState::SET == pSourceSet->GetItemState(nWhich, false, &pPoolItem)) { - if(SfxItemState::SET == pSourceSet->GetItemState(nWhich, false, &pPoolItem)) - { - std::unique_ptr pResultItem; + std::unique_ptr pResultItem; - switch( nWhich ) - { - case XATTR_FILLBITMAP: - pResultItem = static_cast(pPoolItem)->checkForUniqueItem( pNewModelel ); - break; - case XATTR_LINEDASH: - pResultItem = static_cast(pPoolItem)->checkForUniqueItem( pNewModelel ); - break; - case XATTR_LINESTART: - pResultItem = static_cast(pPoolItem)->checkForUniqueItem( pNewModelel ); - break; - case XATTR_LINEEND: - pResultItem = static_cast(pPoolItem)->checkForUniqueItem( pNewModelel ); - break; - case XATTR_FILLGRADIENT: - pResultItem = static_cast(pPoolItem)->checkForUniqueItem( pNewModelel ); - break; - case XATTR_FILLFLOATTRANSPARENCE: - // allow all kinds of XFillFloatTransparenceItem to be set - pResultItem = static_cast(pPoolItem)->checkForUniqueItem( pNewModelel ); - break; - case XATTR_FILLHATCH: - pResultItem = static_cast(pPoolItem)->checkForUniqueItem( pNewModelel ); - break; - } + switch( nWhich ) + { + case XATTR_FILLBITMAP: + pResultItem = static_cast(pPoolItem)->checkForUniqueItem( pNewModelel ); + break; + case XATTR_LINEDASH: + pResultItem = static_cast(pPoolItem)->checkForUniqueItem( pNewModelel ); + break; + case XATTR_LINESTART: + pResultItem = static_cast(pPoolItem)->checkForUniqueItem( pNewModelel ); + break; + case XATTR_LINEEND: + pResultItem = static_cast(pPoolItem)->checkForUniqueItem( pNewModelel ); + break; + case XATTR_FILLGRADIENT: + pResultItem = static_cast(pPoolItem)->checkForUniqueItem( pNewModelel ); + break; + case XATTR_FILLFLOATTRANSPARENCE: + // allow all kinds of XFillFloatTransparenceItem to be set + pResultItem = static_cast(pPoolItem)->checkForUniqueItem( pNewModelel ); + break; + case XATTR_FILLHATCH: + pResultItem = static_cast(pPoolItem)->checkForUniqueItem( pNewModelel ); + break; + } - // set item - if( pResultItem ) - { - pDestSet->Put(*pResultItem); - pResultItem.reset(); - } - else - pDestSet->Put(*pPoolItem); + // set item + if( pResultItem ) + { + pDestSet->Put(*pResultItem); + pResultItem.reset(); } - nWhich = aWhichIter.NextWhich(); + else + pDestSet->Put(*pPoolItem); } + nWhich = aWhichIter.NextWhich(); } } diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index b1472651875c..2c85e8be56c0 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -236,47 +236,47 @@ void SdrMarkView::ModelHasChanged() AdjustMarkHdl(); } - if (comphelper::LibreOfficeKit::isActive() && GetMarkedObjectCount() > 0) + if (!(comphelper::LibreOfficeKit::isActive() && GetMarkedObjectCount() > 0)) + return; + + //TODO: Is MarkedObjRect valid at this point? + tools::Rectangle aSelection(GetMarkedObjRect()); + OString sSelection; + if (aSelection.IsEmpty()) + sSelection = "EMPTY"; + else { - //TODO: Is MarkedObjRect valid at this point? - tools::Rectangle aSelection(GetMarkedObjRect()); - OString sSelection; - if (aSelection.IsEmpty()) - sSelection = "EMPTY"; - else + sal_uInt32 nTotalPaintWindows = this->PaintWindowCount(); + if (nTotalPaintWindows == 1) { - sal_uInt32 nTotalPaintWindows = this->PaintWindowCount(); - if (nTotalPaintWindows == 1) + const vcl::Window* pWin = dynamic_cast(this->GetFirstOutputDevice()); + if (pWin && pWin->IsChart()) { - const vcl::Window* pWin = dynamic_cast(this->GetFirstOutputDevice()); - if (pWin && pWin->IsChart()) + const vcl::Window* pViewShellWindow = GetSfxViewShell()->GetEditWindowForActiveOLEObj(); + if (pViewShellWindow && pViewShellWindow->IsAncestorOf(*pWin)) { - const vcl::Window* pViewShellWindow = GetSfxViewShell()->GetEditWindowForActiveOLEObj(); - if (pViewShellWindow && pViewShellWindow->IsAncestorOf(*pWin)) - { - Point aOffsetPx = pWin->GetOffsetPixelFrom(*pViewShellWindow); - Point aLogicOffset = pWin->PixelToLogic(aOffsetPx); - aSelection.Move(aLogicOffset.getX(), aLogicOffset.getY()); - } + Point aOffsetPx = pWin->GetOffsetPixelFrom(*pViewShellWindow); + Point aLogicOffset = pWin->PixelToLogic(aOffsetPx); + aSelection.Move(aLogicOffset.getX(), aLogicOffset.getY()); } } + } - // In case the map mode is in 100th MM, then need to convert the coordinates over to twips for LOK. - if (mpMarkedPV) + // In case the map mode is in 100th MM, then need to convert the coordinates over to twips for LOK. + if (mpMarkedPV) + { + if (OutputDevice* pOutputDevice = mpMarkedPV->GetView().GetFirstOutputDevice()) { - if (OutputDevice* pOutputDevice = mpMarkedPV->GetView().GetFirstOutputDevice()) - { - if (pOutputDevice->GetMapMode().GetMapUnit() == MapUnit::Map100thMM) - aSelection = OutputDevice::LogicToLogic(aSelection, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); - } + if (pOutputDevice->GetMapMode().GetMapUnit() == MapUnit::Map100thMM) + aSelection = OutputDevice::LogicToLogic(aSelection, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); } - - sSelection = aSelection.toString(); } - if(SfxViewShell* pViewShell = GetSfxViewShell()) - SfxLokHelper::notifyInvalidation(pViewShell, sSelection); + sSelection = aSelection.toString(); } + + if(SfxViewShell* pViewShell = GetSfxViewShell()) + SfxLokHelper::notifyInvalidation(pViewShell, sSelection); } @@ -1257,21 +1257,21 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell) AddCustomHdl(); // try to restore focus handle index from remembered values - if(bSaveOldFocus) + if(!bSaveOldFocus) + return; + + for(size_t a = 0; a < maHdlList.GetHdlCount(); ++a) { - for(size_t a = 0; a < maHdlList.GetHdlCount(); ++a) - { - SdrHdl* pCandidate = maHdlList.GetHdl(a); + SdrHdl* pCandidate = maHdlList.GetHdl(a); - if(pCandidate->GetObj() - && pCandidate->GetObj() == pSaveObj - && pCandidate->GetKind() == eSaveKind - && pCandidate->GetPolyNum() == nSavePolyNum - && pCandidate->GetPointNum() == nSavePointNum) - { - maHdlList.SetFocusHdl(pCandidate); - break; - } + if(pCandidate->GetObj() + && pCandidate->GetObj() == pSaveObj + && pCandidate->GetKind() == eSaveKind + && pCandidate->GetPolyNum() == nSavePolyNum + && pCandidate->GetPointNum() == nSavePointNum) + { + maHdlList.SetFocusHdl(pCandidate); + break; } } } @@ -1661,19 +1661,19 @@ void SdrMarkView::SetFrameHandles(bool bOn) void SdrMarkView::SetEditMode(SdrViewEditMode eMode) { - if (eMode!=meEditMode) { - bool bGlue0=meEditMode==SdrViewEditMode::GluePointEdit; - bool bEdge0=static_cast(this)->IsEdgeTool(); - meEditMode0=meEditMode; - meEditMode=eMode; - bool bGlue1=meEditMode==SdrViewEditMode::GluePointEdit; - bool bEdge1=static_cast(this)->IsEdgeTool(); - // avoid flickering when switching between GlueEdit and EdgeTool - if (bGlue1 && !bGlue0) ImpSetGlueVisible2(bGlue1); - if (bEdge1!=bEdge0) ImpSetGlueVisible3(bEdge1); - if (!bGlue1 && bGlue0) ImpSetGlueVisible2(bGlue1); - if (bGlue0 && !bGlue1) UnmarkAllGluePoints(); - } + if (eMode==meEditMode) return; + + bool bGlue0=meEditMode==SdrViewEditMode::GluePointEdit; + bool bEdge0=static_cast(this)->IsEdgeTool(); + meEditMode0=meEditMode; + meEditMode=eMode; + bool bGlue1=meEditMode==SdrViewEditMode::GluePointEdit; + bool bEdge1=static_cast(this)->IsEdgeTool(); + // avoid flickering when switching between GlueEdit and EdgeTool + if (bGlue1 && !bGlue0) ImpSetGlueVisible2(bGlue1); + if (bEdge1!=bEdge0) ImpSetGlueVisible3(bEdge1); + if (!bGlue1 && bGlue0) ImpSetGlueVisible2(bGlue1); + if (bGlue0 && !bGlue1) UnmarkAllGluePoints(); } @@ -1949,31 +1949,32 @@ void collectUIInformation(const SdrObject* pObj) } -void SdrMarkView::MarkObj(SdrObject* pObj, SdrPageView* pPV, bool bUnmark, bool bDoNoSetMarkHdl, + void SdrMarkView::MarkObj(SdrObject* pObj, SdrPageView* pPV, bool bUnmark, bool bDoNoSetMarkHdl, std::vector const & rSubSelections) { - if (pObj!=nullptr && pPV!=nullptr && IsObjMarkable(pObj, pPV)) { - BrkAction(); - if (!bUnmark) - { - GetMarkedObjectListWriteAccess().InsertEntry(SdrMark(pObj,pPV)); - collectUIInformation(pObj); - } - else + if (!(pObj!=nullptr && pPV!=nullptr && IsObjMarkable(pObj, pPV))) + return; + + BrkAction(); + if (!bUnmark) + { + GetMarkedObjectListWriteAccess().InsertEntry(SdrMark(pObj,pPV)); + collectUIInformation(pObj); + } + else + { + const size_t nPos=TryToFindMarkedObject(pObj); + if (nPos!=SAL_MAX_SIZE) { - const size_t nPos=TryToFindMarkedObject(pObj); - if (nPos!=SAL_MAX_SIZE) - { - GetMarkedObjectListWriteAccess().DeleteMark(nPos); - } + GetMarkedObjectListWriteAccess().DeleteMark(nPos); } + } - maSubSelectionList = rSubSelections; + maSubSelectionList = rSubSelections; - if (!bDoNoSetMarkHdl) { - MarkListHasChanged(); - AdjustMarkHdl(); - } + if (!bDoNoSetMarkHdl) { + MarkListHasChanged(); + AdjustMarkHdl(); } } @@ -2341,21 +2342,22 @@ bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageVie void SdrMarkView::UnmarkAllObj(SdrPageView const * pPV) { - if (GetMarkedObjectCount()!=0) { - BrkAction(); - if (pPV!=nullptr) - { - GetMarkedObjectListWriteAccess().DeletePageView(*pPV); - } - else - { - GetMarkedObjectListWriteAccess().Clear(); - } - mpMarkedObj=nullptr; - mpMarkedPV=nullptr; - MarkListHasChanged(); - AdjustMarkHdl(); + if (GetMarkedObjectCount()==0) + return; + + BrkAction(); + if (pPV!=nullptr) + { + GetMarkedObjectListWriteAccess().DeletePageView(*pPV); + } + else + { + GetMarkedObjectListWriteAccess().Clear(); } + mpMarkedObj=nullptr; + mpMarkedPV=nullptr; + MarkListHasChanged(); + AdjustMarkHdl(); } void SdrMarkView::MarkAllObj(SdrPageView* pPV) @@ -2459,19 +2461,19 @@ void SdrMarkView::EnterMarkedGroup() // TODO: I'll have to prevent that via a flag. SdrPageView* pPV = GetSdrPageView(); - if(pPV) + if(!pPV) + return; + + bool bEnter=false; + for (size_t nm = GetMarkedObjectCount(); nm > 0 && !bEnter;) { - bool bEnter=false; - for (size_t nm = GetMarkedObjectCount(); nm > 0 && !bEnter;) - { - --nm; - SdrMark* pM=GetSdrMarkByIndex(nm); - if (pM->GetPageView()==pPV) { - SdrObject* pObj=pM->GetMarkedSdrObj(); - if (pObj->IsGroupObject()) { - if (pPV->EnterGroup(pObj)) { - bEnter=true; - } + --nm; + SdrMark* pM=GetSdrMarkByIndex(nm); + if (pM->GetPageView()==pPV) { + SdrObject* pObj=pM->GetMarkedSdrObj(); + if (pObj->IsGroupObject()) { + if (pPV->EnterGroup(pObj)) { + bEnter=true; } } } diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 77c2d2d6ae51..ec4ecdff0165 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -1320,45 +1320,45 @@ void SdrObjCustomShape::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const rInfo.bNoContortion =true; // #i37011# - if ( mXRenderedCustomShape.is() ) + if ( !mXRenderedCustomShape.is() ) + return; + + const SdrObject* pRenderedCustomShape = GetSdrObjectFromXShape( mXRenderedCustomShape ); + if ( !pRenderedCustomShape ) + return; + + // #i37262# + // Iterate self over the contained objects, since there are combinations of + // polygon and curve objects. In that case, aInfo.bCanConvToPath and + // aInfo.bCanConvToPoly would be false. What is needed here is an or, not an and. + SdrObjListIter aIterator(*pRenderedCustomShape); + while(aIterator.IsMore()) { - const SdrObject* pRenderedCustomShape = GetSdrObjectFromXShape( mXRenderedCustomShape ); - if ( pRenderedCustomShape ) + SdrObject* pCandidate = aIterator.Next(); + SdrObjTransformInfoRec aInfo; + pCandidate->TakeObjInfo(aInfo); + + // set path and poly conversion if one is possible since + // this object will first be broken + const bool bCanConvToPathOrPoly(aInfo.bCanConvToPath || aInfo.bCanConvToPoly); + if(rInfo.bCanConvToPath != bCanConvToPathOrPoly) { - // #i37262# - // Iterate self over the contained objects, since there are combinations of - // polygon and curve objects. In that case, aInfo.bCanConvToPath and - // aInfo.bCanConvToPoly would be false. What is needed here is an or, not an and. - SdrObjListIter aIterator(*pRenderedCustomShape); - while(aIterator.IsMore()) - { - SdrObject* pCandidate = aIterator.Next(); - SdrObjTransformInfoRec aInfo; - pCandidate->TakeObjInfo(aInfo); - - // set path and poly conversion if one is possible since - // this object will first be broken - const bool bCanConvToPathOrPoly(aInfo.bCanConvToPath || aInfo.bCanConvToPoly); - if(rInfo.bCanConvToPath != bCanConvToPathOrPoly) - { - rInfo.bCanConvToPath = bCanConvToPathOrPoly; - } + rInfo.bCanConvToPath = bCanConvToPathOrPoly; + } - if(rInfo.bCanConvToPoly != bCanConvToPathOrPoly) - { - rInfo.bCanConvToPoly = bCanConvToPathOrPoly; - } + if(rInfo.bCanConvToPoly != bCanConvToPathOrPoly) + { + rInfo.bCanConvToPoly = bCanConvToPathOrPoly; + } - if(rInfo.bCanConvToContour != aInfo.bCanConvToContour) - { - rInfo.bCanConvToContour = aInfo.bCanConvToContour; - } + if(rInfo.bCanConvToContour != aInfo.bCanConvToContour) + { + rInfo.bCanConvToContour = aInfo.bCanConvToContour; + } - if(rInfo.bShearAllowed != aInfo.bShearAllowed) - { - rInfo.bShearAllowed = aInfo.bShearAllowed; - } - } + if(rInfo.bShearAllowed != aInfo.bShearAllowed) + { + rInfo.bShearAllowed = aInfo.bShearAllowed; } } } @@ -1372,44 +1372,44 @@ sal_uInt16 SdrObjCustomShape::GetObjIdentifier() const // state of the ResizeShapeToFitText flag to correctly set TextMinFrameWidth/Height void SdrObjCustomShape::AdaptTextMinSize() { - if (!getSdrModelFromSdrObject().IsCreatingDataObj() && !getSdrModelFromSdrObject().IsPasteResize()) + if (getSdrModelFromSdrObject().IsCreatingDataObj() || getSdrModelFromSdrObject().IsPasteResize()) + return; + + const bool bResizeShapeToFitText(GetObjectItem(SDRATTR_TEXT_AUTOGROWHEIGHT).GetValue()); + SfxItemSet aSet( + *GetObjectItemSet().GetPool(), + svl::Items{}); // contains SDRATTR_TEXT_MAXFRAMEWIDTH + bool bChanged(false); + + if(bResizeShapeToFitText) { - const bool bResizeShapeToFitText(GetObjectItem(SDRATTR_TEXT_AUTOGROWHEIGHT).GetValue()); - SfxItemSet aSet( - *GetObjectItemSet().GetPool(), - svl::Items{}); // contains SDRATTR_TEXT_MAXFRAMEWIDTH - bool bChanged(false); + // always reset MinWidthHeight to zero to only rely on text size and frame size + // to allow resizing being completely dependent on text size only + aSet.Put(makeSdrTextMinFrameWidthItem(0)); + aSet.Put(makeSdrTextMinFrameHeightItem(0)); + bChanged = true; + } + else + { + // recreate from CustomShape-specific TextBounds + tools::Rectangle aTextBound(maRect); - if(bResizeShapeToFitText) - { - // always reset MinWidthHeight to zero to only rely on text size and frame size - // to allow resizing being completely dependent on text size only - aSet.Put(makeSdrTextMinFrameWidthItem(0)); - aSet.Put(makeSdrTextMinFrameHeightItem(0)); - bChanged = true; - } - else + if(GetTextBounds(aTextBound)) { - // recreate from CustomShape-specific TextBounds - tools::Rectangle aTextBound(maRect); + const long nHDist(GetTextLeftDistance() + GetTextRightDistance()); + const long nVDist(GetTextUpperDistance() + GetTextLowerDistance()); + const long nTWdt(std::max(long(0), static_cast(aTextBound.GetWidth() - 1 - nHDist))); + const long nTHgt(std::max(long(0), static_cast(aTextBound.GetHeight() - 1 - nVDist))); - if(GetTextBounds(aTextBound)) - { - const long nHDist(GetTextLeftDistance() + GetTextRightDistance()); - const long nVDist(GetTextUpperDistance() + GetTextLowerDistance()); - const long nTWdt(std::max(long(0), static_cast(aTextBound.GetWidth() - 1 - nHDist))); - const long nTHgt(std::max(long(0), static_cast(aTextBound.GetHeight() - 1 - nVDist))); - - aSet.Put(makeSdrTextMinFrameWidthItem(nTWdt)); - aSet.Put(makeSdrTextMinFrameHeightItem(nTHgt)); - bChanged = true; - } + aSet.Put(makeSdrTextMinFrameWidthItem(nTWdt)); + aSet.Put(makeSdrTextMinFrameHeightItem(nTHgt)); + bChanged = true; } - - if(bChanged) - SetObjectItemSet(aSet); } + + if(bChanged) + SetObjectItemSet(aSet); } void SdrObjCustomShape::NbcSetSnapRect( const tools::Rectangle& rRect ) @@ -1697,100 +1697,100 @@ void SdrObjCustomShape::ImpCheckCustomGluePointsAreAdded() { const SdrObject* pSdrObject = GetSdrObjectFromCustomShape(); - if(pSdrObject) + if(!pSdrObject) + return; + + const SdrGluePointList* pSource = pSdrObject->GetGluePointList(); + + if(!(pSource && pSource->GetCount())) + return; + + if(!SdrTextObj::GetGluePointList()) { - const SdrGluePointList* pSource = pSdrObject->GetGluePointList(); + SdrTextObj::ForceGluePointList(); + } - if(pSource && pSource->GetCount()) - { - if(!SdrTextObj::GetGluePointList()) - { - SdrTextObj::ForceGluePointList(); - } + const SdrGluePointList* pList = SdrTextObj::GetGluePointList(); - const SdrGluePointList* pList = SdrTextObj::GetGluePointList(); + if(!pList) + return; - if(pList) - { - SdrGluePointList aNewList; - sal_uInt16 a; + SdrGluePointList aNewList; + sal_uInt16 a; - for(a = 0; a < pSource->GetCount(); a++) - { - SdrGluePoint aCopy((*pSource)[a]); - aCopy.SetUserDefined(false); - aNewList.Insert(aCopy); - } + for(a = 0; a < pSource->GetCount(); a++) + { + SdrGluePoint aCopy((*pSource)[a]); + aCopy.SetUserDefined(false); + aNewList.Insert(aCopy); + } - bool bMirroredX = IsMirroredX(); - bool bMirroredY = IsMirroredY(); + bool bMirroredX = IsMirroredX(); + bool bMirroredY = IsMirroredY(); - long nShearAngle = aGeo.nShearAngle; - double fTan = aGeo.nTan; + long nShearAngle = aGeo.nShearAngle; + double fTan = aGeo.nTan; - if ( aGeo.nRotationAngle || nShearAngle || bMirroredX || bMirroredY ) - { - tools::Polygon aPoly( maRect ); - if( nShearAngle ) - { - sal_uInt16 nPointCount=aPoly.GetSize(); - for (sal_uInt16 i=0; iGetCount(); a++) - { - const SdrGluePoint& rCandidate = (*pList)[a]; + RotatePoint(aGlue, aRef, sin(basegfx::deg2rad(fObjectRotation)), + cos(basegfx::deg2rad(fObjectRotation))); + if ( bMirroredX ) + aGlue.setX( maRect.GetWidth() - aGlue.X() ); + if ( bMirroredY ) + aGlue.setY( maRect.GetHeight() - aGlue.Y() ); + aGlue.AdjustX( -nXDiff ); + aGlue.AdjustY( -nYDiff ); + rPoint.SetPos( aGlue ); + } + } - if(rCandidate.IsUserDefined()) - { - aNewList.Insert(rCandidate); - } - } + for(a = 0; a < pList->GetCount(); a++) + { + const SdrGluePoint& rCandidate = (*pList)[a]; - // copy new list to local. This is NOT very convenient behavior, the local - // GluePointList should not be set, but we delivered by using GetGluePointList(), - // maybe on demand. Since the local object is changed here, this is assumed to - // be a result of GetGluePointList and thus the list is copied - if(pPlusData) - { - pPlusData->SetGluePoints(aNewList); - } - } + if(rCandidate.IsUserDefined()) + { + aNewList.Insert(rCandidate); } } + + // copy new list to local. This is NOT very convenient behavior, the local + // GluePointList should not be set, but we delivered by using GetGluePointList(), + // maybe on demand. Since the local object is changed here, this is assumed to + // be a result of GetGluePointList and thus the list is copied + if(pPlusData) + { + pPlusData->SetGluePoints(aNewList); + } } // #i38892# @@ -1909,81 +1909,81 @@ void SdrObjCustomShape::DragResizeCustomShape( const tools::Rectangle& rNewRect if ( aGeo.nRotationAngle ) RotatePoint(aNewPos, aOld.TopLeft(), aGeoStat.nSin, aGeoStat.nCos ); aNewRect.SetPos( aNewPos ); } - if ( aNewRect != maRect ) - { - SetLogicRect( aNewRect ); - InvalidateRenderGeometry(); + if ( aNewRect == maRect ) + return; - if ( rNewRect.Left() > rNewRect.Right() ) - { - Point aTop( ( GetSnapRect().Left() + GetSnapRect().Right() ) >> 1, GetSnapRect().Top() ); - Point aBottom( aTop.X(), aTop.Y() + 1000 ); - NbcMirror( aTop, aBottom ); - } - if ( rNewRect.Top() > rNewRect.Bottom() ) - { - Point aLeft( GetSnapRect().Left(), ( GetSnapRect().Top() + GetSnapRect().Bottom() ) >> 1 ); - Point aRight( aLeft.X() + 1000, aLeft.Y() ); - NbcMirror( aLeft, aRight ); - } + SetLogicRect( aNewRect ); + InvalidateRenderGeometry(); - for (const auto& rInteraction : aInteractionHandles) + if ( rNewRect.Left() > rNewRect.Right() ) + { + Point aTop( ( GetSnapRect().Left() + GetSnapRect().Right() ) >> 1, GetSnapRect().Top() ); + Point aBottom( aTop.X(), aTop.Y() + 1000 ); + NbcMirror( aTop, aBottom ); + } + if ( rNewRect.Top() > rNewRect.Bottom() ) + { + Point aLeft( GetSnapRect().Left(), ( GetSnapRect().Top() + GetSnapRect().Bottom() ) >> 1 ); + Point aRight( aLeft.X() + 1000, aLeft.Y() ); + NbcMirror( aLeft, aRight ); + } + + for (const auto& rInteraction : aInteractionHandles) + { + try { - try + if ( rInteraction.nMode & CustomShapeHandleModes::RESIZE_FIXED ) + rInteraction.xInteraction->setControllerPosition( rInteraction.aPosition ); + if ( rInteraction.nMode & CustomShapeHandleModes::RESIZE_ABSOLUTE_X || + rInteraction.nMode & CustomShapeHandleModes::RESIZE_ABSOLUTE_NEGX ) { - if ( rInteraction.nMode & CustomShapeHandleModes::RESIZE_FIXED ) - rInteraction.xInteraction->setControllerPosition( rInteraction.aPosition ); - if ( rInteraction.nMode & CustomShapeHandleModes::RESIZE_ABSOLUTE_X || - rInteraction.nMode & CustomShapeHandleModes::RESIZE_ABSOLUTE_NEGX ) - { - if (rInteraction.nMode & CustomShapeHandleModes::RESIZE_ABSOLUTE_NEGX) - bOldMirroredX = !bOldMirroredX; + if (rInteraction.nMode & CustomShapeHandleModes::RESIZE_ABSOLUTE_NEGX) + bOldMirroredX = !bOldMirroredX; - sal_Int32 nX; - if ( bOldMirroredX ) - { - nX = ( rInteraction.aPosition.X - aOld.Right() ); - if ( rNewRect.Left() > rNewRect.Right() ) - nX = maRect.Left() - nX; - else - nX += maRect.Right(); - } + sal_Int32 nX; + if ( bOldMirroredX ) + { + nX = ( rInteraction.aPosition.X - aOld.Right() ); + if ( rNewRect.Left() > rNewRect.Right() ) + nX = maRect.Left() - nX; else - { - nX = ( rInteraction.aPosition.X - aOld.Left() ); - if ( rNewRect.Left() > rNewRect.Right() ) - nX = maRect.Right() - nX; - else - nX += maRect.Left(); - } - rInteraction.xInteraction->setControllerPosition( css::awt::Point( nX, rInteraction.xInteraction->getPosition().Y ) ); + nX += maRect.Right(); } - if ( rInteraction.nMode & CustomShapeHandleModes::RESIZE_ABSOLUTE_Y ) + else { - sal_Int32 nY; - if ( bOldMirroredY ) - { - nY = ( rInteraction.aPosition.Y - aOld.Bottom() ); - if ( rNewRect.Top() > rNewRect.Bottom() ) - nY = maRect.Top() - nY; - else - nY += maRect.Bottom(); - } + nX = ( rInteraction.aPosition.X - aOld.Left() ); + if ( rNewRect.Left() > rNewRect.Right() ) + nX = maRect.Right() - nX; else - { - nY = ( rInteraction.aPosition.Y - aOld.Top() ); - if ( rNewRect.Top() > rNewRect.Bottom() ) - nY = maRect.Bottom() - nY; - else - nY += maRect.Top(); - } - rInteraction.xInteraction->setControllerPosition( css::awt::Point( rInteraction.xInteraction->getPosition().X, nY ) ); + nX += maRect.Left(); } + rInteraction.xInteraction->setControllerPosition( css::awt::Point( nX, rInteraction.xInteraction->getPosition().Y ) ); } - catch ( const uno::RuntimeException& ) + if ( rInteraction.nMode & CustomShapeHandleModes::RESIZE_ABSOLUTE_Y ) { + sal_Int32 nY; + if ( bOldMirroredY ) + { + nY = ( rInteraction.aPosition.Y - aOld.Bottom() ); + if ( rNewRect.Top() > rNewRect.Bottom() ) + nY = maRect.Top() - nY; + else + nY += maRect.Bottom(); + } + else + { + nY = ( rInteraction.aPosition.Y - aOld.Top() ); + if ( rNewRect.Top() > rNewRect.Bottom() ) + nY = maRect.Bottom() - nY; + else + nY += maRect.Top(); + } + rInteraction.xInteraction->setControllerPosition( css::awt::Point( rInteraction.xInteraction->getPosition().X, nY ) ); } } + catch ( const uno::RuntimeException& ) + { + } } } @@ -1991,40 +1991,40 @@ void SdrObjCustomShape::DragMoveCustomShapeHdl( const Point& rDestination, const sal_uInt16 nCustomShapeHdlNum, bool bMoveCalloutRectangle ) { std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles() ); - if ( nCustomShapeHdlNum < aInteractionHandles.size() ) + if ( nCustomShapeHdlNum >= aInteractionHandles.size() ) + return; + + SdrCustomShapeInteraction aInteractionHandle( aInteractionHandles[ nCustomShapeHdlNum ] ); + if ( !aInteractionHandle.xInteraction.is() ) + return; + + try { - SdrCustomShapeInteraction aInteractionHandle( aInteractionHandles[ nCustomShapeHdlNum ] ); - if ( aInteractionHandle.xInteraction.is() ) + css::awt::Point aPt( rDestination.X(), rDestination.Y() ); + if ( aInteractionHandle.nMode & CustomShapeHandleModes::MOVE_SHAPE && bMoveCalloutRectangle ) { - try - { - css::awt::Point aPt( rDestination.X(), rDestination.Y() ); - if ( aInteractionHandle.nMode & CustomShapeHandleModes::MOVE_SHAPE && bMoveCalloutRectangle ) - { - sal_Int32 nXDiff = aPt.X - aInteractionHandle.aPosition.X; - sal_Int32 nYDiff = aPt.Y - aInteractionHandle.aPosition.Y; + sal_Int32 nXDiff = aPt.X - aInteractionHandle.aPosition.X; + sal_Int32 nYDiff = aPt.Y - aInteractionHandle.aPosition.Y; - maRect.Move( nXDiff, nYDiff ); - aOutRect.Move( nXDiff, nYDiff ); - maSnapRect.Move( nXDiff, nYDiff ); - SetRectsDirty(true); - InvalidateRenderGeometry(); + maRect.Move( nXDiff, nYDiff ); + aOutRect.Move( nXDiff, nYDiff ); + maSnapRect.Move( nXDiff, nYDiff ); + SetRectsDirty(true); + InvalidateRenderGeometry(); - for (const auto& rInteraction : aInteractionHandles) - { - if ( rInteraction.nMode & CustomShapeHandleModes::RESIZE_FIXED ) - { - if ( rInteraction.xInteraction.is() ) - rInteraction.xInteraction->setControllerPosition( rInteraction.aPosition ); - } - } - } - aInteractionHandle.xInteraction->setControllerPosition( aPt ); - } - catch ( const uno::RuntimeException& ) + for (const auto& rInteraction : aInteractionHandles) { + if ( rInteraction.nMode & CustomShapeHandleModes::RESIZE_FIXED ) + { + if ( rInteraction.xInteraction.is() ) + rInteraction.xInteraction->setControllerPosition( rInteraction.aPosition ); + } } } + aInteractionHandle.xInteraction->setControllerPosition( aPt ); + } + catch ( const uno::RuntimeException& ) + { } } @@ -2171,55 +2171,55 @@ void SdrObjCustomShape::SetVerticalWriting( bool bVertical ) DBG_ASSERT( pOutlinerParaObject, "SdrTextObj::SetVerticalWriting() without OutlinerParaObject!" ); - if( pOutlinerParaObject ) - { - if(pOutlinerParaObject->IsVertical() != bVertical) - { - // get item settings - const SfxItemSet& rSet = GetObjectItemSet(); + if( !pOutlinerParaObject ) + return; - // Also exchange horizontal and vertical adjust items - SdrTextHorzAdjust eHorz = rSet.Get(SDRATTR_TEXT_HORZADJUST).GetValue(); - SdrTextVertAdjust eVert = rSet.Get(SDRATTR_TEXT_VERTADJUST).GetValue(); + if(pOutlinerParaObject->IsVertical() == bVertical) + return; - // rescue object size, SetSnapRect below expects logic rect, - // not snap rect. - tools::Rectangle aObjectRect = GetLogicRect(); + // get item settings + const SfxItemSet& rSet = GetObjectItemSet(); - // prepare ItemSet to set exchanged width and height items - SfxItemSet aNewSet(*rSet.GetPool(), - svl::Items{}); + // Also exchange horizontal and vertical adjust items + SdrTextHorzAdjust eHorz = rSet.Get(SDRATTR_TEXT_HORZADJUST).GetValue(); + SdrTextVertAdjust eVert = rSet.Get(SDRATTR_TEXT_VERTADJUST).GetValue(); - aNewSet.Put(rSet); + // rescue object size, SetSnapRect below expects logic rect, + // not snap rect. + tools::Rectangle aObjectRect = GetLogicRect(); - // Exchange horizontal and vertical adjusts - switch(eVert) - { - case SDRTEXTVERTADJUST_TOP: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); break; - case SDRTEXTVERTADJUST_CENTER: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); break; - case SDRTEXTVERTADJUST_BOTTOM: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); break; - case SDRTEXTVERTADJUST_BLOCK: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK)); break; - } - switch(eHorz) - { - case SDRTEXTHORZADJUST_LEFT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM)); break; - case SDRTEXTHORZADJUST_CENTER: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); break; - case SDRTEXTHORZADJUST_RIGHT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP)); break; - case SDRTEXTHORZADJUST_BLOCK: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK)); break; - } + // prepare ItemSet to set exchanged width and height items + SfxItemSet aNewSet(*rSet.GetPool(), + svl::Items{}); - pOutlinerParaObject = GetOutlinerParaObject(); - if ( pOutlinerParaObject ) - pOutlinerParaObject->SetVertical(bVertical); - SetObjectItemSet( aNewSet ); + aNewSet.Put(rSet); - // restore object size - SetSnapRect(aObjectRect); - } + // Exchange horizontal and vertical adjusts + switch(eVert) + { + case SDRTEXTVERTADJUST_TOP: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); break; + case SDRTEXTVERTADJUST_CENTER: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); break; + case SDRTEXTVERTADJUST_BOTTOM: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); break; + case SDRTEXTVERTADJUST_BLOCK: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK)); break; + } + switch(eHorz) + { + case SDRTEXTHORZADJUST_LEFT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM)); break; + case SDRTEXTHORZADJUST_CENTER: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); break; + case SDRTEXTHORZADJUST_RIGHT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP)); break; + case SDRTEXTHORZADJUST_BLOCK: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK)); break; } + + pOutlinerParaObject = GetOutlinerParaObject(); + if ( pOutlinerParaObject ) + pOutlinerParaObject->SetVertical(bVertical); + SetObjectItemSet( aNewSet ); + + // restore object size + SetSnapRect(aObjectRect); } void SdrObjCustomShape::SuggestTextFrameSize(Size aSuggestedTextFrameSize) @@ -3042,28 +3042,28 @@ void SdrObjCustomShape::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, } // Apply flipping from enhanced geometry at center of the shape. - if (bIsMirroredX || bIsMirroredY) - { - // create mathematically matrix for the applied transformations - // aScale was in most cases built from a rectangle including edge - // and is therefore mathematically too large by 1 - if (aScale.getX() > 2.0 && aScale.getY() > 2.0) - aScale -= basegfx::B2DTuple(1.0, 1.0); - basegfx::B2DHomMatrix aMathMat = basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix( - aScale, -fShearX, basegfx::fTools::equalZero(fRotate) ? 0.0 : fRotate, - aTranslate); - // Use matrix to get current center - basegfx::B2DPoint aCenter(0.5,0.5); - aCenter = aMathMat * aCenter; - double fCenterX = aCenter.getX(); - double fCenterY = aCenter.getY(); - if (bIsMirroredX) // vertical axis - Mirror(Point(FRound(fCenterX),FRound(fCenterY)), - Point(FRound(fCenterX), FRound(fCenterY + 1000.0))); - if (bIsMirroredY) // horizontal axis - Mirror(Point(FRound(fCenterX),FRound(fCenterY)), - Point(FRound(fCenterX + 1000.0), FRound(fCenterY))); - } + if (!(bIsMirroredX || bIsMirroredY)) + return; + + // create mathematically matrix for the applied transformations + // aScale was in most cases built from a rectangle including edge + // and is therefore mathematically too large by 1 + if (aScale.getX() > 2.0 && aScale.getY() > 2.0) + aScale -= basegfx::B2DTuple(1.0, 1.0); + basegfx::B2DHomMatrix aMathMat = basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix( + aScale, -fShearX, basegfx::fTools::equalZero(fRotate) ? 0.0 : fRotate, + aTranslate); + // Use matrix to get current center + basegfx::B2DPoint aCenter(0.5,0.5); + aCenter = aMathMat * aCenter; + double fCenterX = aCenter.getX(); + double fCenterY = aCenter.getY(); + if (bIsMirroredX) // vertical axis + Mirror(Point(FRound(fCenterX),FRound(fCenterY)), + Point(FRound(fCenterX), FRound(fCenterY + 1000.0))); + if (bIsMirroredY) // horizontal axis + Mirror(Point(FRound(fCenterX),FRound(fCenterY)), + Point(FRound(fCenterX + 1000.0), FRound(fCenterY))); } // taking fObjectRotation instead of aGeo.nAngle diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 90b41c7d7225..05cbd9ca3b88 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -277,22 +277,22 @@ SdrModel& SdrObject::getSdrModelFromSdrObject() const void SdrObject::setParentOfSdrObject(SdrObjList* pNewObjList) { - if(getParentSdrObjListFromSdrObject() != pNewObjList) - { - // remember current page - SdrPage* pOldPage(getSdrPageFromSdrObject()); + if(getParentSdrObjListFromSdrObject() == pNewObjList) + return; - // set new parent - mpParentOfSdrObject = pNewObjList; + // remember current page + SdrPage* pOldPage(getSdrPageFromSdrObject()); - // get new page - SdrPage* pNewPage(getSdrPageFromSdrObject()); + // set new parent + mpParentOfSdrObject = pNewObjList; - // broadcast page change over objects if needed - if(pOldPage != pNewPage) - { - handlePageChange(pOldPage, pNewPage); - } + // get new page + SdrPage* pNewPage(getSdrPageFromSdrObject()); + + // broadcast page change over objects if needed + if(pOldPage != pNewPage) + { + handlePageChange(pOldPage, pNewPage); } } @@ -668,31 +668,31 @@ void SdrObject::SetName(const OUString& rStr) ImpForcePlusData(); } - if(pPlusData && pPlusData->aObjName != rStr) + if(!(pPlusData && pPlusData->aObjName != rStr)) + return; + + // Undo/Redo for setting object's name (#i73249#) + bool bUndo( false ); + if ( getSdrModelFromSdrObject().IsUndoEnabled() ) { - // Undo/Redo for setting object's name (#i73249#) - bool bUndo( false ); - if ( getSdrModelFromSdrObject().IsUndoEnabled() ) - { - bUndo = true; - std::unique_ptr pUndoAction = - SdrUndoFactory::CreateUndoObjectStrAttr( - *this, - SdrUndoObjStrAttr::ObjStrAttrType::Name, - GetName(), - rStr ); - getSdrModelFromSdrObject().BegUndo( pUndoAction->GetComment() ); - getSdrModelFromSdrObject().AddUndo( std::move(pUndoAction) ); - } - pPlusData->aObjName = rStr; - // Undo/Redo for setting object's name (#i73249#) - if ( bUndo ) - { - getSdrModelFromSdrObject().EndUndo(); - } - SetChanged(); - BroadcastObjectChange(); + bUndo = true; + std::unique_ptr pUndoAction = + SdrUndoFactory::CreateUndoObjectStrAttr( + *this, + SdrUndoObjStrAttr::ObjStrAttrType::Name, + GetName(), + rStr ); + getSdrModelFromSdrObject().BegUndo( pUndoAction->GetComment() ); + getSdrModelFromSdrObject().AddUndo( std::move(pUndoAction) ); + } + pPlusData->aObjName = rStr; + // Undo/Redo for setting object's name (#i73249#) + if ( bUndo ) + { + getSdrModelFromSdrObject().EndUndo(); } + SetChanged(); + BroadcastObjectChange(); } OUString SdrObject::GetName() const @@ -712,31 +712,31 @@ void SdrObject::SetTitle(const OUString& rStr) ImpForcePlusData(); } - if(pPlusData && pPlusData->aObjTitle != rStr) + if(!(pPlusData && pPlusData->aObjTitle != rStr)) + return; + + // Undo/Redo for setting object's title (#i73249#) + bool bUndo( false ); + if ( getSdrModelFromSdrObject().IsUndoEnabled() ) { - // Undo/Redo for setting object's title (#i73249#) - bool bUndo( false ); - if ( getSdrModelFromSdrObject().IsUndoEnabled() ) - { - bUndo = true; - std::unique_ptr pUndoAction = - SdrUndoFactory::CreateUndoObjectStrAttr( - *this, - SdrUndoObjStrAttr::ObjStrAttrType::Title, - GetTitle(), - rStr ); - getSdrModelFromSdrObject().BegUndo( pUndoAction->GetComment() ); - getSdrModelFromSdrObject().AddUndo( std::move(pUndoAction) ); - } - pPlusData->aObjTitle = rStr; - // Undo/Redo for setting object's title (#i73249#) - if ( bUndo ) - { - getSdrModelFromSdrObject().EndUndo(); - } - SetChanged(); - BroadcastObjectChange(); + bUndo = true; + std::unique_ptr pUndoAction = + SdrUndoFactory::CreateUndoObjectStrAttr( + *this, + SdrUndoObjStrAttr::ObjStrAttrType::Title, + GetTitle(), + rStr ); + getSdrModelFromSdrObject().BegUndo( pUndoAction->GetComment() ); + getSdrModelFromSdrObject().AddUndo( std::move(pUndoAction) ); } + pPlusData->aObjTitle = rStr; + // Undo/Redo for setting object's title (#i73249#) + if ( bUndo ) + { + getSdrModelFromSdrObject().EndUndo(); + } + SetChanged(); + BroadcastObjectChange(); } OUString SdrObject::GetTitle() const @@ -756,31 +756,31 @@ void SdrObject::SetDescription(const OUString& rStr) ImpForcePlusData(); } - if(pPlusData && pPlusData->aObjDescription != rStr) + if(!(pPlusData && pPlusData->aObjDescription != rStr)) + return; + + // Undo/Redo for setting object's description (#i73249#) + bool bUndo( false ); + if ( getSdrModelFromSdrObject().IsUndoEnabled() ) { - // Undo/Redo for setting object's description (#i73249#) - bool bUndo( false ); - if ( getSdrModelFromSdrObject().IsUndoEnabled() ) - { - bUndo = true; - std::unique_ptr pUndoAction = - SdrUndoFactory::CreateUndoObjectStrAttr( - *this, - SdrUndoObjStrAttr::ObjStrAttrType::Description, - GetDescription(), - rStr ); - getSdrModelFromSdrObject().BegUndo( pUndoAction->GetComment() ); - getSdrModelFromSdrObject().AddUndo( std::move(pUndoAction) ); - } - pPlusData->aObjDescription = rStr; - // Undo/Redo for setting object's description (#i73249#) - if ( bUndo ) - { - getSdrModelFromSdrObject().EndUndo(); - } - SetChanged(); - BroadcastObjectChange(); + bUndo = true; + std::unique_ptr pUndoAction = + SdrUndoFactory::CreateUndoObjectStrAttr( + *this, + SdrUndoObjStrAttr::ObjStrAttrType::Description, + GetDescription(), + rStr ); + getSdrModelFromSdrObject().BegUndo( pUndoAction->GetComment() ); + getSdrModelFromSdrObject().AddUndo( std::move(pUndoAction) ); + } + pPlusData->aObjDescription = rStr; + // Undo/Redo for setting object's description (#i73249#) + if ( bUndo ) + { + getSdrModelFromSdrObject().EndUndo(); } + SetChanged(); + BroadcastObjectChange(); } OUString SdrObject::GetDescription() const @@ -877,28 +877,28 @@ void SdrObject::RecalcBoundRect() return; // central new method which will calculate the BoundRect using primitive geometry - if(aOutRect.IsEmpty()) - { - // Use view-independent data - we do not want any connections - // to e.g. GridOffset in SdrObject-level - const drawinglayer::primitive2d::Primitive2DContainer& xPrimitives(GetViewContact().getViewIndependentPrimitive2DContainer()); + if(!aOutRect.IsEmpty()) + return; - if(!xPrimitives.empty()) - { - // use neutral ViewInformation and get the range of the primitives - const drawinglayer::geometry::ViewInformation2D aViewInformation2D; - const basegfx::B2DRange aRange(xPrimitives.getB2DRange(aViewInformation2D)); + // Use view-independent data - we do not want any connections + // to e.g. GridOffset in SdrObject-level + const drawinglayer::primitive2d::Primitive2DContainer& xPrimitives(GetViewContact().getViewIndependentPrimitive2DContainer()); - if(!aRange.isEmpty()) - { - aOutRect = tools::Rectangle( - static_cast(floor(aRange.getMinX())), - static_cast(floor(aRange.getMinY())), - static_cast(ceil(aRange.getMaxX())), - static_cast(ceil(aRange.getMaxY()))); - return; - } - } + if(xPrimitives.empty()) + return; + + // use neutral ViewInformation and get the range of the primitives + const drawinglayer::geometry::ViewInformation2D aViewInformation2D; + const basegfx::B2DRange aRange(xPrimitives.getB2DRange(aViewInformation2D)); + + if(!aRange.isEmpty()) + { + aOutRect = tools::Rectangle( + static_cast(floor(aRange.getMinX())), + static_cast(floor(aRange.getMinY())), + static_cast(ceil(aRange.getMaxX())), + static_cast(ceil(aRange.getMaxY()))); + return; } } @@ -910,19 +910,19 @@ void SdrObject::BroadcastObjectChange() const bool bPlusDataBroadcast(pPlusData && pPlusData->pBroadcast); bool bObjectChange(IsInserted()); - if(bPlusDataBroadcast || bObjectChange) - { - SdrHint aHint(SdrHintKind::ObjectChange, *this); + if(!(bPlusDataBroadcast || bObjectChange)) + return; - if(bPlusDataBroadcast) - { - pPlusData->pBroadcast->Broadcast(aHint); - } + SdrHint aHint(SdrHintKind::ObjectChange, *this); - if(bObjectChange) - { - getSdrModelFromSdrObject().Broadcast(aHint); - } + if(bPlusDataBroadcast) + { + pPlusData->pBroadcast->Broadcast(aHint); + } + + if(bObjectChange) + { + getSdrModelFromSdrObject().Broadcast(aHint); } } @@ -1483,20 +1483,21 @@ void SdrObject::NbcCrop(const basegfx::B2DPoint& /*aRef*/, double /*fxFact*/, do void SdrObject::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative) { - if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) { - if (bUnsetRelative) - { - mpImpl->mnRelativeWidth.reset(); - mpImpl->meRelativeWidthRelation = text::RelOrientation::PAGE_FRAME; - mpImpl->meRelativeHeightRelation = text::RelOrientation::PAGE_FRAME; - mpImpl->mnRelativeHeight.reset(); - } - tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect(); - NbcResize(rRef,xFact,yFact); - SetChanged(); - BroadcastObjectChange(); - SendUserCall(SdrUserCallType::Resize,aBoundRect0); + if (xFact.GetNumerator() == xFact.GetDenominator() && yFact.GetNumerator() == yFact.GetDenominator()) + return; + + if (bUnsetRelative) + { + mpImpl->mnRelativeWidth.reset(); + mpImpl->meRelativeWidthRelation = text::RelOrientation::PAGE_FRAME; + mpImpl->meRelativeHeightRelation = text::RelOrientation::PAGE_FRAME; + mpImpl->mnRelativeHeight.reset(); } + tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect(); + NbcResize(rRef,xFact,yFact); + SetChanged(); + BroadcastObjectChange(); + SendUserCall(SdrUserCallType::Resize,aBoundRect0); } void SdrObject::Crop(const basegfx::B2DPoint& rRef, double fxFact, double fyFact) @@ -2278,21 +2279,21 @@ static void extractLineContourFromPrimitive2DSequence( rExtractedHairlines.clear(); rExtractedLineFills.clear(); - if(!rxSequence.empty()) - { - // use neutral ViewInformation - const drawinglayer::geometry::ViewInformation2D aViewInformation2D; + if(rxSequence.empty()) + return; - // create extractor, process and get result - drawinglayer::processor2d::LineGeometryExtractor2D aExtractor(aViewInformation2D); - aExtractor.process(rxSequence); + // use neutral ViewInformation + const drawinglayer::geometry::ViewInformation2D aViewInformation2D; - // copy line results - rExtractedHairlines = aExtractor.getExtractedHairlines(); + // create extractor, process and get result + drawinglayer::processor2d::LineGeometryExtractor2D aExtractor(aViewInformation2D); + aExtractor.process(rxSequence); - // copy fill rsults - rExtractedLineFills = aExtractor.getExtractedLineFills(); - } + // copy line results + rExtractedHairlines = aExtractor.getExtractedHairlines(); + + // copy fill rsults + rExtractedLineFills = aExtractor.getExtractedLineFills(); } diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx index 93978f1ef592..897b557077f0 100644 --- a/svx/source/svdraw/svdocirc.cxx +++ b/svx/source/svdraw/svdocirc.cxx @@ -672,22 +672,23 @@ void ImpCircUser::SetCreateParams(SdrDragStat const & rStat) aP1 = GetAnglePnt(aR,nStart); nEnd=nStart; } else aP1=aCenter; - if (rStat.GetPointCount()>3) { - Point aP(rStat.GetPoint(3)-aCenter); - if (nWdt>=nHgt) { - aP.setY(BigMulDiv(aP.Y(),nWdt,nHgt) ); - } else { - aP.setX(BigMulDiv(aP.X(),nHgt,nWdt) ); - } - nEnd=NormAngle36000(GetAngle(aP)); - if (rStat.GetView()!=nullptr && rStat.GetView()->IsAngleSnapEnabled()) { - long nSA=rStat.GetView()->GetSnapAngle(); - if (nSA!=0) { // angle snapping - nEnd+=nSA/2; - nEnd/=nSA; - nEnd*=nSA; - nEnd=NormAngle36000(nEnd); - } + if (rStat.GetPointCount()<=3) + return; + + Point aP(rStat.GetPoint(3)-aCenter); + if (nWdt>=nHgt) { + aP.setY(BigMulDiv(aP.Y(),nWdt,nHgt) ); + } else { + aP.setX(BigMulDiv(aP.X(),nHgt,nWdt) ); + } + nEnd=NormAngle36000(GetAngle(aP)); + if (rStat.GetView()!=nullptr && rStat.GetView()->IsAngleSnapEnabled()) { + long nSA=rStat.GetView()->GetSnapAngle(); + if (nSA!=0) { // angle snapping + nEnd+=nSA/2; + nEnd/=nSA; + nEnd*=nSA; + nEnd=NormAngle36000(nEnd); } } } @@ -1016,18 +1017,19 @@ void SdrCircObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const rRect.Move(aDst.X(),aDst.Y()); } } - if (aGeo.nShearAngle!=0) { - long nDst=FRound((rRect.Bottom()-rRect.Top())*aGeo.nTan); - if (aGeo.nShearAngle>0) { - Point aRef(rRect.TopLeft()); - rRect.AdjustLeft( -nDst ); - Point aTmpPt(rRect.TopLeft()); - RotatePoint(aTmpPt,aRef,aGeo.nSin,aGeo.nCos); - aTmpPt-=rRect.TopLeft(); - rRect.Move(aTmpPt.X(),aTmpPt.Y()); - } else { - rRect.AdjustRight( -nDst ); - } + if (aGeo.nShearAngle==0) + return; + + long nDst=FRound((rRect.Bottom()-rRect.Top())*aGeo.nTan); + if (aGeo.nShearAngle>0) { + Point aRef(rRect.TopLeft()); + rRect.AdjustLeft( -nDst ); + Point aTmpPt(rRect.TopLeft()); + RotatePoint(aTmpPt,aRef,aGeo.nSin,aGeo.nCos); + aTmpPt-=rRect.TopLeft(); + rRect.Move(aTmpPt.X(),aTmpPt.Y()); + } else { + rRect.AdjustRight( -nDst ); } } @@ -1118,28 +1120,28 @@ void SdrCircObj::ImpSetCircInfoToAttr() sal_Int32 nOldStartAngle = rSet.Get(SDRATTR_CIRCSTARTANGLE).GetValue(); sal_Int32 nOldEndAngle = rSet.Get(SDRATTR_CIRCENDANGLE).GetValue(); - if(meCircleKind != eOldKindA || nStartAngle != nOldStartAngle || nEndAngle != nOldEndAngle) - { - // since SetItem() implicitly calls ImpSetAttrToCircInfo() - // setting the item directly is necessary here. - if(meCircleKind != eOldKindA) - { - GetProperties().SetObjectItemDirect(SdrCircKindItem(meCircleKind)); - } + if(meCircleKind == eOldKindA && nStartAngle == nOldStartAngle && nEndAngle == nOldEndAngle) + return; - if(nStartAngle != nOldStartAngle) - { - GetProperties().SetObjectItemDirect(makeSdrCircStartAngleItem(nStartAngle)); - } + // since SetItem() implicitly calls ImpSetAttrToCircInfo() + // setting the item directly is necessary here. + if(meCircleKind != eOldKindA) + { + GetProperties().SetObjectItemDirect(SdrCircKindItem(meCircleKind)); + } - if(nEndAngle != nOldEndAngle) - { - GetProperties().SetObjectItemDirect(makeSdrCircEndAngleItem(nEndAngle)); - } + if(nStartAngle != nOldStartAngle) + { + GetProperties().SetObjectItemDirect(makeSdrCircStartAngleItem(nStartAngle)); + } - SetXPolyDirty(); - ImpSetAttrToCircInfo(); + if(nEndAngle != nOldEndAngle) + { + GetProperties().SetObjectItemDirect(makeSdrCircEndAngleItem(nEndAngle)); } + + SetXPolyDirty(); + ImpSetAttrToCircInfo(); } SdrObjectUniquePtr SdrCircObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx index f4dd1c994eca..757760a6fd88 100644 --- a/svx/source/svdraw/svdoedge.cxx +++ b/svx/source/svdraw/svdoedge.cxx @@ -310,43 +310,43 @@ void SdrEdgeObj::ImpSetEdgeInfoToAttr() nVals[1] = bHor2 ? aEdgeInfo.aObj2Line2.X() : aEdgeInfo.aObj2Line2.Y(); } - if(n != nValCnt || nVals[0] != nVal1 || nVals[1] != nVal2 || nVals[2] != nVal3) + if(!(n != nValCnt || nVals[0] != nVal1 || nVals[1] != nVal2 || nVals[2] != nVal3)) + return; + + // Here no more notifying is necessary, just local changes are OK. + if(n != nValCnt) { - // Here no more notifying is necessary, just local changes are OK. - if(n != nValCnt) - { - GetProperties().SetObjectItemDirect(SdrEdgeLineDeltaCountItem(n)); - } + GetProperties().SetObjectItemDirect(SdrEdgeLineDeltaCountItem(n)); + } - if(nVals[0] != nVal1) - { - GetProperties().SetObjectItemDirect(makeSdrEdgeLine1DeltaItem(nVals[0])); - } + if(nVals[0] != nVal1) + { + GetProperties().SetObjectItemDirect(makeSdrEdgeLine1DeltaItem(nVals[0])); + } - if(nVals[1] != nVal2) - { - GetProperties().SetObjectItemDirect(makeSdrEdgeLine2DeltaItem(nVals[1])); - } + if(nVals[1] != nVal2) + { + GetProperties().SetObjectItemDirect(makeSdrEdgeLine2DeltaItem(nVals[1])); + } - if(nVals[2] != nVal3) - { - GetProperties().SetObjectItemDirect(makeSdrEdgeLine3DeltaItem(nVals[2])); - } + if(nVals[2] != nVal3) + { + GetProperties().SetObjectItemDirect(makeSdrEdgeLine3DeltaItem(nVals[2])); + } - if(n < 3) - { - GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE3DELTA); - } + if(n < 3) + { + GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE3DELTA); + } - if(n < 2) - { - GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE2DELTA); - } + if(n < 2) + { + GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE2DELTA); + } - if(n < 1) - { - GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE1DELTA); - } + if(n < 1) + { + GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE1DELTA); } } @@ -1597,29 +1597,30 @@ void SdrEdgeObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) bEdgeTrackUserDefined = false; } SdrTextObj::Notify(rBC,rHint); - if (nNotifyingCount==0) { // a locking flag - nNotifyingCount++; - const SdrHint* pSdrHint = ( rHint.GetId() == SfxHintId::ThisIsAnSdrHint ? static_cast(&rHint) : nullptr ); + if (nNotifyingCount!=0)return; - if (bDataChg) { // StyleSheet changed - ImpSetAttrToEdgeInfo(); // when changing templates, copy values from Pool to aEdgeInfo - } - if (bDataChg || - (bObj1 && aCon1.pObj->getSdrPageFromSdrObject() == getSdrPageFromSdrObject()) || - (bObj2 && aCon2.pObj->getSdrPageFromSdrObject() == getSdrPageFromSdrObject()) || - (pSdrHint && pSdrHint->GetKind()==SdrHintKind::ObjectRemoved)) - { - // broadcasting only, if on the same page - tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetCurrentBoundRect(); - ImpDirtyEdgeTrack(); +// a locking flag + nNotifyingCount++; + const SdrHint* pSdrHint = ( rHint.GetId() == SfxHintId::ThisIsAnSdrHint ? static_cast(&rHint) : nullptr ); - // only redraw here, object hasn't actually changed - ActionChanged(); + if (bDataChg) { // StyleSheet changed + ImpSetAttrToEdgeInfo(); // when changing templates, copy values from Pool to aEdgeInfo + } + if (bDataChg || + (bObj1 && aCon1.pObj->getSdrPageFromSdrObject() == getSdrPageFromSdrObject()) || + (bObj2 && aCon2.pObj->getSdrPageFromSdrObject() == getSdrPageFromSdrObject()) || + (pSdrHint && pSdrHint->GetKind()==SdrHintKind::ObjectRemoved)) + { + // broadcasting only, if on the same page + tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetCurrentBoundRect(); + ImpDirtyEdgeTrack(); - SendUserCall(SdrUserCallType::Resize,aBoundRect0); - } - nNotifyingCount--; + // only redraw here, object hasn't actually changed + ActionChanged(); + + SendUserCall(SdrUserCallType::Resize,aBoundRect0); } + nNotifyingCount--; } /** updates edges that are connected to the edges of this object @@ -2243,28 +2244,28 @@ void SdrEdgeObj::NbcSetSnapRect(const tools::Rectangle& rRect) { const tools::Rectangle aOld(GetSnapRect()); - if(aOld != rRect) + if(aOld == rRect) + return; + + if (maRect.IsEmpty() && 0 == pEdgeTrack->GetPointCount()) { - if (maRect.IsEmpty() && 0 == pEdgeTrack->GetPointCount()) - { - // #i110629# When initializing, do not scale on empty Rectangle; this - // will mirror the underlying text object (!) - maRect = rRect; - maSnapRect = rRect; - } - else - { - long nMulX = rRect.Right() - rRect.Left(); - long nDivX = aOld.Right() - aOld.Left(); - long nMulY = rRect.Bottom() - rRect.Top(); - long nDivY = aOld.Bottom() - aOld.Top(); - if ( nDivX == 0 ) { nMulX = 1; nDivX = 1; } - if ( nDivY == 0 ) { nMulY = 1; nDivY = 1; } - Fraction aX(nMulX, nDivX); - Fraction aY(nMulY, nDivY); - NbcResize(aOld.TopLeft(), aX, aY); - NbcMove(Size(rRect.Left() - aOld.Left(), rRect.Top() - aOld.Top())); - } + // #i110629# When initializing, do not scale on empty Rectangle; this + // will mirror the underlying text object (!) + maRect = rRect; + maSnapRect = rRect; + } + else + { + long nMulX = rRect.Right() - rRect.Left(); + long nDivX = aOld.Right() - aOld.Left(); + long nMulY = rRect.Bottom() - rRect.Top(); + long nDivY = aOld.Bottom() - aOld.Top(); + if ( nDivX == 0 ) { nMulX = 1; nDivX = 1; } + if ( nDivY == 0 ) { nMulY = 1; nDivY = 1; } + Fraction aX(nMulX, nDivX); + Fraction aY(nMulY, nDivY); + NbcResize(aOld.TopLeft(), aX, aY); + NbcMove(Size(rRect.Left() - aOld.Left(), rRect.Top() - aOld.Top())); } } diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index beac686d733d..2f2c4886f86d 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -1059,43 +1059,43 @@ void SdrGrafObj::AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrink mpGraphicObject->GetPrefMapMode(), MapMode( MapUnit::Map100thMM ) ); - if( !aSize.IsEmpty() ) - { - Point aPos( rMaxRect.TopLeft() ); + if( aSize.IsEmpty() ) + return; - // if the graphic is too large, fit it to page - if ( (!bShrinkOnly || - ( aSize.Height() > aMaxSize.Height() ) || - ( aSize.Width() > aMaxSize.Width() ) )&& - aSize.Height() && aMaxSize.Height() ) - { - float fGrfWH = static_cast(aSize.Width()) / - static_cast(aSize.Height()); - float fWinWH = static_cast(aMaxSize.Width()) / - static_cast(aMaxSize.Height()); + Point aPos( rMaxRect.TopLeft() ); - // Scale graphic to page size - if ( fGrfWH < fWinWH ) - { - aSize.setWidth( static_cast(aMaxSize.Height() * fGrfWH) ); - aSize.setHeight( aMaxSize.Height() ); - } - else if ( fGrfWH > 0.F ) - { - aSize.setWidth( aMaxSize.Width() ); - aSize.setHeight( static_cast(aMaxSize.Width() / fGrfWH) ); - } + // if the graphic is too large, fit it to page + if ( (!bShrinkOnly || + ( aSize.Height() > aMaxSize.Height() ) || + ( aSize.Width() > aMaxSize.Width() ) )&& + aSize.Height() && aMaxSize.Height() ) + { + float fGrfWH = static_cast(aSize.Width()) / + static_cast(aSize.Height()); + float fWinWH = static_cast(aMaxSize.Width()) / + static_cast(aMaxSize.Height()); - aPos = rMaxRect.Center(); + // Scale graphic to page size + if ( fGrfWH < fWinWH ) + { + aSize.setWidth( static_cast(aMaxSize.Height() * fGrfWH) ); + aSize.setHeight( aMaxSize.Height() ); + } + else if ( fGrfWH > 0.F ) + { + aSize.setWidth( aMaxSize.Width() ); + aSize.setHeight( static_cast(aMaxSize.Width() / fGrfWH) ); } - if( bShrinkOnly ) - aPos = maRect.TopLeft(); - - aPos.AdjustX( -(aSize.Width() / 2) ); - aPos.AdjustY( -(aSize.Height() / 2) ); - SetLogicRect( tools::Rectangle( aPos, aSize ) ); + aPos = rMaxRect.Center(); } + + if( bShrinkOnly ) + aPos = maRect.TopLeft(); + + aPos.AdjustX( -(aSize.Width() / 2) ); + aPos.AdjustY( -(aSize.Height() / 2) ); + SetLogicRect( tools::Rectangle( aPos, aSize ) ); } void SdrGrafObj::SetGrafAnimationAllowed(bool bNew) diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx index 0ee6ef6a8fb6..75b548231df3 100644 --- a/svx/source/svdraw/svdogrp.cxx +++ b/svx/source/svdraw/svdogrp.cxx @@ -523,90 +523,92 @@ void SdrObjGroup::SetLogicRect(const tools::Rectangle& rRect) void SdrObjGroup::Move(const Size& rSiz) { - if (rSiz.Width()!=0 || rSiz.Height()!=0) { - tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect(); - aRefPoint.Move(rSiz); - const size_t nObjCount(GetObjCount()); + if (rSiz.Width()==0 && rSiz.Height()==0) + return; + + tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect(); + aRefPoint.Move(rSiz); + const size_t nObjCount(GetObjCount()); - if(0 != nObjCount) + if(0 != nObjCount) + { + // first move the connectors, then everything else + for (size_t i=0; iIsEdgeObj()) - pObj->Move(rSiz); - } - - for (size_t i=0; iIsEdgeObj()) - pObj->Move(rSiz); - } + SdrObject* pObj(GetObj(i)); + if (pObj->IsEdgeObj()) + pObj->Move(rSiz); } - else + + for (size_t i=0; iIsEdgeObj()) + pObj->Move(rSiz); } - - SetChanged(); - BroadcastObjectChange(); - SendUserCall(SdrUserCallType::MoveOnly,aBoundRect0); } + else + { + aOutRect.Move(rSiz); + SetRectsDirty(); + } + + SetChanged(); + BroadcastObjectChange(); + SendUserCall(SdrUserCallType::MoveOnly,aBoundRect0); } void SdrObjGroup::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative) { - if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) { - bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); - bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); - if (bXMirr || bYMirr) { - Point aRef1(GetSnapRect().Center()); - if (bXMirr) { - Point aRef2(aRef1); - aRef2.AdjustY( 1 ); - NbcMirrorGluePoints(aRef1,aRef2); - } - if (bYMirr) { - Point aRef2(aRef1); - aRef2.AdjustX( 1 ); - NbcMirrorGluePoints(aRef1,aRef2); - } + if (xFact.GetNumerator()==xFact.GetDenominator() && yFact.GetNumerator()==yFact.GetDenominator()) + return; + + bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0); + bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0); + if (bXMirr || bYMirr) { + Point aRef1(GetSnapRect().Center()); + if (bXMirr) { + Point aRef2(aRef1); + aRef2.AdjustY( 1 ); + NbcMirrorGluePoints(aRef1,aRef2); + } + if (bYMirr) { + Point aRef2(aRef1); + aRef2.AdjustX( 1 ); + NbcMirrorGluePoints(aRef1,aRef2); } - tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect(); - ResizePoint(aRefPoint,rRef,xFact,yFact); - const size_t nObjCount(GetObjCount()); + } + tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect(); + ResizePoint(aRefPoint,rRef,xFact,yFact); + const size_t nObjCount(GetObjCount()); - if(0 != nObjCount) + if(0 != nObjCount) + { + // move the connectors first, everything else afterwards + for (size_t i=0; iIsEdgeObj()) - pObj->Resize(rRef,xFact,yFact,bUnsetRelative); - } - - for (size_t i=0; iIsEdgeObj()) - pObj->Resize(rRef,xFact,yFact,bUnsetRelative); - } + SdrObject* pObj(GetObj(i)); + if (pObj->IsEdgeObj()) + pObj->Resize(rRef,xFact,yFact,bUnsetRelative); } - else + + for (size_t i=0; iIsEdgeObj()) + pObj->Resize(rRef,xFact,yFact,bUnsetRelative); } - - SetChanged(); - BroadcastObjectChange(); - SendUserCall(SdrUserCallType::Resize,aBoundRect0); } + else + { + ResizeRect(aOutRect,rRef,xFact,yFact); + SetRectsDirty(); + } + + SetChanged(); + BroadcastObjectChange(); + SendUserCall(SdrUserCallType::Resize,aBoundRect0); } diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx index af407f84be7b..04547ef87c16 100644 --- a/svx/source/svdraw/svdomeas.cxx +++ b/svx/source/svdraw/svdomeas.cxx @@ -564,40 +564,40 @@ bool SdrMeasureObj::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, void SdrMeasureObj::UndirtyText() const { - if (bTextDirty) - { - SdrOutliner& rOutliner=ImpGetDrawOutliner(); - OutlinerParaObject* pOutlinerParaObject = SdrTextObj::GetOutlinerParaObject(); - if(pOutlinerParaObject==nullptr) - { - rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SdrMeasureFieldKind::Rotate90Blanks), EE_FEATURE_FIELD), ESelection(0,0)); - rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SdrMeasureFieldKind::Value), EE_FEATURE_FIELD),ESelection(0,1)); - rOutliner.QuickInsertText(" ", ESelection(0,2)); - rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SdrMeasureFieldKind::Unit), EE_FEATURE_FIELD),ESelection(0,3)); - rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SdrMeasureFieldKind::Rotate90Blanks), EE_FEATURE_FIELD),ESelection(0,4)); + if (!bTextDirty) + return; - if(GetStyleSheet()) - rOutliner.SetStyleSheet(0, GetStyleSheet()); + SdrOutliner& rOutliner=ImpGetDrawOutliner(); + OutlinerParaObject* pOutlinerParaObject = SdrTextObj::GetOutlinerParaObject(); + if(pOutlinerParaObject==nullptr) + { + rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SdrMeasureFieldKind::Rotate90Blanks), EE_FEATURE_FIELD), ESelection(0,0)); + rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SdrMeasureFieldKind::Value), EE_FEATURE_FIELD),ESelection(0,1)); + rOutliner.QuickInsertText(" ", ESelection(0,2)); + rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SdrMeasureFieldKind::Unit), EE_FEATURE_FIELD),ESelection(0,3)); + rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SdrMeasureFieldKind::Rotate90Blanks), EE_FEATURE_FIELD),ESelection(0,4)); - rOutliner.SetParaAttribs(0, GetObjectItemSet()); + if(GetStyleSheet()) + rOutliner.SetStyleSheet(0, GetStyleSheet()); - // cast to nonconst - const_cast(this)->NbcSetOutlinerParaObject( rOutliner.CreateParaObject() ); - } - else - { - rOutliner.SetText(*pOutlinerParaObject); - } + rOutliner.SetParaAttribs(0, GetObjectItemSet()); - rOutliner.SetUpdateMode(true); - rOutliner.UpdateFields(); - Size aSiz(rOutliner.CalcTextSize()); - rOutliner.Clear(); - // cast to nonconst three times - const_cast(this)->aTextSize=aSiz; - const_cast(this)->bTextSizeDirty=false; - const_cast(this)->bTextDirty=false; + // cast to nonconst + const_cast(this)->NbcSetOutlinerParaObject( rOutliner.CreateParaObject() ); + } + else + { + rOutliner.SetText(*pOutlinerParaObject); } + + rOutliner.SetUpdateMode(true); + rOutliner.UpdateFields(); + Size aSiz(rOutliner.CalcTextSize()); + rOutliner.Clear(); + // cast to nonconst three times + const_cast(this)->aTextSize=aSiz; + const_cast(this)->bTextSizeDirty=false; + const_cast(this)->bTextDirty=false; } void SdrMeasureObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const @@ -1417,20 +1417,20 @@ void SdrMeasureObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, cons const Point aNewPt1(basegfx::fround(aPosA.getX()), basegfx::fround(aPosA.getY())); const Point aNewPt2(basegfx::fround(aPosB.getX()), basegfx::fround(aPosB.getY())); - if(aNewPt1 != aPt1 || aNewPt2 != aPt2) - { - // set model values and broadcast - tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect(); + if(aNewPt1 == aPt1 && aNewPt2 == aPt2) + return; - aPt1 = aNewPt1; - aPt2 = aNewPt2; + // set model values and broadcast + tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect(); - SetTextDirty(); - ActionChanged(); - SetChanged(); - BroadcastObjectChange(); - SendUserCall(SdrUserCallType::MoveOnly,aBoundRect0); - } + aPt1 = aNewPt1; + aPt2 = aNewPt2; + + SetTextDirty(); + ActionChanged(); + SetChanged(); + BroadcastObjectChange(); + SendUserCall(SdrUserCallType::MoveOnly,aBoundRect0); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx index 886ff96fd983..54ad20798a45 100644 --- a/svx/source/svdraw/svdomedia.cxx +++ b/svx/source/svdraw/svdomedia.cxx @@ -167,43 +167,43 @@ void SdrMediaObj::AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrin MapMode(MapUnit::Map100thMM)) ); Size aMaxSize( rMaxRect.GetSize() ); - if( !aSize.IsEmpty() ) - { - Point aPos( rMaxRect.TopLeft() ); + if( aSize.IsEmpty() ) + return; - // if graphic is too large, fit it to the page - if ( (!bShrinkOnly || - ( aSize.Height() > aMaxSize.Height() ) || - ( aSize.Width() > aMaxSize.Width() ) )&& - aSize.Height() && aMaxSize.Height() ) - { - float fGrfWH = static_cast(aSize.Width()) / - static_cast(aSize.Height()); - float fWinWH = static_cast(aMaxSize.Width()) / - static_cast(aMaxSize.Height()); + Point aPos( rMaxRect.TopLeft() ); - // scale graphic to page size - if ( fGrfWH < fWinWH ) - { - aSize.setWidth( static_cast(aMaxSize.Height() * fGrfWH) ); - aSize.setHeight( aMaxSize.Height() ); - } - else if ( fGrfWH > 0.F ) - { - aSize.setWidth( aMaxSize.Width() ); - aSize.setHeight( static_cast(aMaxSize.Width() / fGrfWH) ); - } + // if graphic is too large, fit it to the page + if ( (!bShrinkOnly || + ( aSize.Height() > aMaxSize.Height() ) || + ( aSize.Width() > aMaxSize.Width() ) )&& + aSize.Height() && aMaxSize.Height() ) + { + float fGrfWH = static_cast(aSize.Width()) / + static_cast(aSize.Height()); + float fWinWH = static_cast(aMaxSize.Width()) / + static_cast(aMaxSize.Height()); - aPos = rMaxRect.Center(); + // scale graphic to page size + if ( fGrfWH < fWinWH ) + { + aSize.setWidth( static_cast(aMaxSize.Height() * fGrfWH) ); + aSize.setHeight( aMaxSize.Height() ); + } + else if ( fGrfWH > 0.F ) + { + aSize.setWidth( aMaxSize.Width() ); + aSize.setHeight( static_cast(aMaxSize.Width() / fGrfWH) ); } - if( bShrinkOnly ) - aPos = maRect.TopLeft(); - - aPos.AdjustX( -(aSize.Width() / 2) ); - aPos.AdjustY( -(aSize.Height() / 2) ); - SetLogicRect( tools::Rectangle( aPos, aSize ) ); + aPos = rMaxRect.Center(); } + + if( bShrinkOnly ) + aPos = maRect.TopLeft(); + + aPos.AdjustX( -(aSize.Width() / 2) ); + aPos.AdjustY( -(aSize.Height() / 2) ); + SetLogicRect( tools::Rectangle( aPos, aSize ) ); } void SdrMediaObj::setURL( const OUString& rURL, const OUString& rReferer, const OUString& rMimeType ) diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index b70b7a669ed4..4528172a567b 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -225,61 +225,61 @@ void SAL_CALL SdrLightEmbeddedClient_Impl::notifyEvent( const document::EventObj SolarMutexGuard aGuard; // the code currently makes sense only in case there is no other client - if ( mpObj && mpObj->GetAspect() != embed::Aspects::MSOLE_ICON && aEvent.EventName == "OnVisAreaChanged" - && mpObj->GetObjRef().is() && mpObj->GetObjRef()->getClientSite() == uno::Reference< embed::XEmbeddedClient >( this ) ) - { - try - { - MapUnit aContainerMapUnit( MapUnit::Map100thMM ); - uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY ); - if ( xParentVis.is() ) - aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) ); + if ( !(mpObj && mpObj->GetAspect() != embed::Aspects::MSOLE_ICON && aEvent.EventName == "OnVisAreaChanged" + && mpObj->GetObjRef().is() && mpObj->GetObjRef()->getClientSite() == uno::Reference< embed::XEmbeddedClient >( this )) ) + return; - MapUnit aObjMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpObj->GetObjRef()->getMapUnit( mpObj->GetAspect() ) ); + try + { + MapUnit aContainerMapUnit( MapUnit::Map100thMM ); + uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY ); + if ( xParentVis.is() ) + aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) ); - tools::Rectangle aVisArea; - awt::Size aSz; - try - { - aSz = mpObj->GetObjRef()->getVisualAreaSize( mpObj->GetAspect() ); - } - catch( embed::NoVisualAreaSizeException& ) - { - OSL_FAIL( "No visual area size!" ); - aSz.Width = 5000; - aSz.Height = 5000; - } - catch( uno::Exception& ) - { - OSL_FAIL( "Unexpected exception!" ); - aSz.Width = 5000; - aSz.Height = 5000; - } + MapUnit aObjMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpObj->GetObjRef()->getMapUnit( mpObj->GetAspect() ) ); - aVisArea.SetSize( Size( aSz.Width, aSz.Height ) ); - aVisArea = OutputDevice::LogicToLogic(aVisArea, MapMode(aObjMapUnit), MapMode(aContainerMapUnit)); - Size aScaledSize( static_cast< long >( m_aScaleWidth * Fraction( aVisArea.GetWidth() ) ), - static_cast< long >( m_aScaleHeight * Fraction( aVisArea.GetHeight() ) ) ); - tools::Rectangle aLogicRect( mpObj->GetLogicRect() ); - - // react to the change if the difference is bigger than one pixel - Size aPixelDiff = - Application::GetDefaultDevice()->LogicToPixel( - Size( aLogicRect.GetWidth() - aScaledSize.Width(), - aLogicRect.GetHeight() - aScaledSize.Height() ), - MapMode(aContainerMapUnit)); - if( aPixelDiff.Width() || aPixelDiff.Height() ) - { - mpObj->SetLogicRect( tools::Rectangle( aLogicRect.TopLeft(), aScaledSize ) ); - mpObj->BroadcastObjectChange(); - } - else - mpObj->ActionChanged(); + tools::Rectangle aVisArea; + awt::Size aSz; + try + { + aSz = mpObj->GetObjRef()->getVisualAreaSize( mpObj->GetAspect() ); + } + catch( embed::NoVisualAreaSizeException& ) + { + OSL_FAIL( "No visual area size!" ); + aSz.Width = 5000; + aSz.Height = 5000; } catch( uno::Exception& ) { OSL_FAIL( "Unexpected exception!" ); + aSz.Width = 5000; + aSz.Height = 5000; + } + + aVisArea.SetSize( Size( aSz.Width, aSz.Height ) ); + aVisArea = OutputDevice::LogicToLogic(aVisArea, MapMode(aObjMapUnit), MapMode(aContainerMapUnit)); + Size aScaledSize( static_cast< long >( m_aScaleWidth * Fraction( aVisArea.GetWidth() ) ), + static_cast< long >( m_aScaleHeight * Fraction( aVisArea.GetHeight() ) ) ); + tools::Rectangle aLogicRect( mpObj->GetLogicRect() ); + + // react to the change if the difference is bigger than one pixel + Size aPixelDiff = + Application::GetDefaultDevice()->LogicToPixel( + Size( aLogicRect.GetWidth() - aScaledSize.Width(), + aLogicRect.GetHeight() - aScaledSize.Height() ), + MapMode(aContainerMapUnit)); + if( aPixelDiff.Width() || aPixelDiff.Height() ) + { + mpObj->SetLogicRect( tools::Rectangle( aLogicRect.TopLeft(), aScaledSize ) ); + mpObj->BroadcastObjectChange(); } + else + mpObj->ActionChanged(); + } + catch( uno::Exception& ) + { + OSL_FAIL( "Unexpected exception!" ); } } @@ -492,32 +492,32 @@ void SAL_CALL SdrLightEmbeddedClient_Impl::changedPlacement( const awt::Rectangl tools::Rectangle aNewLogicRect = Application::GetDefaultDevice()->PixelToLogic(aNewPixelRect, MapMode(aContainerMapUnit)); tools::Rectangle aLogicRect = impl_getScaledRect_nothrow(); - if ( aNewLogicRect != aLogicRect ) - { - // the calculation of the object area has not changed the object size - // it should be done here then - //SfxBooleanFlagGuard aGuard( m_bResizeNoScale, true ); - - // new size of the object area without scaling - Size aNewObjSize( long( aNewLogicRect.GetWidth() / m_aScaleWidth ), - long( aNewLogicRect.GetHeight() / m_aScaleHeight ) ); + if ( aNewLogicRect == aLogicRect ) + return; - // now remove scaling from new placement and keep this at the new object area - aNewLogicRect.SetSize( aNewObjSize ); - // react to the change if the difference is bigger than one pixel - Size aPixelDiff = - Application::GetDefaultDevice()->LogicToPixel( - Size( aLogicRect.GetWidth() - aNewObjSize.Width(), - aLogicRect.GetHeight() - aNewObjSize.Height() ), - MapMode(aContainerMapUnit)); - if( aPixelDiff.Width() || aPixelDiff.Height() ) - { - mpObj->SetLogicRect( tools::Rectangle( aLogicRect.TopLeft(), aNewObjSize ) ); - mpObj->BroadcastObjectChange(); - } - else - mpObj->ActionChanged(); + // the calculation of the object area has not changed the object size + // it should be done here then + //SfxBooleanFlagGuard aGuard( m_bResizeNoScale, true ); + + // new size of the object area without scaling + Size aNewObjSize( long( aNewLogicRect.GetWidth() / m_aScaleWidth ), + long( aNewLogicRect.GetHeight() / m_aScaleHeight ) ); + + // now remove scaling from new placement and keep this at the new object area + aNewLogicRect.SetSize( aNewObjSize ); + // react to the change if the difference is bigger than one pixel + Size aPixelDiff = + Application::GetDefaultDevice()->LogicToPixel( + Size( aLogicRect.GetWidth() - aNewObjSize.Width(), + aLogicRect.GetHeight() - aNewObjSize.Height() ), + MapMode(aContainerMapUnit)); + if( aPixelDiff.Width() || aPixelDiff.Height() ) + { + mpObj->SetLogicRect( tools::Rectangle( aLogicRect.TopLeft(), aNewObjSize ) ); + mpObj->BroadcastObjectChange(); } + else + mpObj->ActionChanged(); } // XWindowSupplier @@ -883,23 +883,23 @@ void SdrOle2Obj::BreakFileLink_Impl() { uno::Reference xDoc(getSdrModelFromSdrObject().getUnoModel(), uno::UNO_QUERY); - if ( xDoc.is() ) + if ( !xDoc.is() ) + return; + + uno::Reference< embed::XStorage > xStorage = xDoc->getDocumentStorage(); + if ( !xStorage.is() ) + return; + + try { - uno::Reference< embed::XStorage > xStorage = xDoc->getDocumentStorage(); - if ( xStorage.is() ) - { - try - { - uno::Reference< embed::XLinkageSupport > xLinkSupport( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY_THROW ); - xLinkSupport->breakLink( xStorage, mpImpl->aPersistName ); - DisconnectFileLink_Impl(); - mpImpl->maLinkURL.clear(); - } - catch( css::uno::Exception& ) - { - TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::BreakFileLink_Impl()" ); - } - } + uno::Reference< embed::XLinkageSupport > xLinkSupport( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY_THROW ); + xLinkSupport->breakLink( xStorage, mpImpl->aPersistName ); + DisconnectFileLink_Impl(); + mpImpl->maLinkURL.clear(); + } + catch( css::uno::Exception& ) + { + TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::BreakFileLink_Impl()" ); } } @@ -916,105 +916,105 @@ void SdrOle2Obj::DisconnectFileLink_Impl() void SdrOle2Obj::CheckFileLink_Impl() { - if (mpImpl->mxObjRef.GetObject().is() && !mpImpl->mpObjectLink) + if (!(mpImpl->mxObjRef.GetObject().is() && !mpImpl->mpObjectLink)) + return; + + try { - try + uno::Reference< embed::XLinkageSupport > xLinkSupport( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY ); + + if ( xLinkSupport.is() && xLinkSupport->isLink() ) { - uno::Reference< embed::XLinkageSupport > xLinkSupport( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY ); + OUString aLinkURL = xLinkSupport->getLinkURL(); - if ( xLinkSupport.is() && xLinkSupport->isLink() ) + if ( !aLinkURL.isEmpty() ) { - OUString aLinkURL = xLinkSupport->getLinkURL(); + // this is a file link so the model link manager should handle it + sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager()); - if ( !aLinkURL.isEmpty() ) + if ( pLinkManager ) { - // this is a file link so the model link manager should handle it - sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager()); - - if ( pLinkManager ) - { - mpImpl->mpObjectLink = new SdrEmbedObjectLink( this ); - mpImpl->maLinkURL = aLinkURL; - pLinkManager->InsertFileLink( *mpImpl->mpObjectLink, sfx2::SvBaseLinkObjectType::ClientOle, aLinkURL ); - mpImpl->mpObjectLink->Connect(); - } + mpImpl->mpObjectLink = new SdrEmbedObjectLink( this ); + mpImpl->maLinkURL = aLinkURL; + pLinkManager->InsertFileLink( *mpImpl->mpObjectLink, sfx2::SvBaseLinkObjectType::ClientOle, aLinkURL ); + mpImpl->mpObjectLink->Connect(); } } } - catch (const css::uno::Exception&) - { - TOOLS_WARN_EXCEPTION("svx", "SdrOle2Obj::CheckFileLink_Impl()"); - } + } + catch (const css::uno::Exception&) + { + TOOLS_WARN_EXCEPTION("svx", "SdrOle2Obj::CheckFileLink_Impl()"); } } void SdrOle2Obj::Connect_Impl() { - if(!mpImpl->aPersistName.isEmpty() ) + if(mpImpl->aPersistName.isEmpty() ) + return; + + try { - try + ::comphelper::IEmbeddedHelper* pPers(getSdrModelFromSdrObject().GetPersist()); + + if ( pPers ) { - ::comphelper::IEmbeddedHelper* pPers(getSdrModelFromSdrObject().GetPersist()); + comphelper::EmbeddedObjectContainer& rContainer = pPers->getEmbeddedObjectContainer(); - if ( pPers ) + if ( !rContainer.HasEmbeddedObject( mpImpl->aPersistName ) + || ( mpImpl->mxObjRef.is() && !rContainer.HasEmbeddedObject( mpImpl->mxObjRef.GetObject() ) ) ) { - comphelper::EmbeddedObjectContainer& rContainer = pPers->getEmbeddedObjectContainer(); - - if ( !rContainer.HasEmbeddedObject( mpImpl->aPersistName ) - || ( mpImpl->mxObjRef.is() && !rContainer.HasEmbeddedObject( mpImpl->mxObjRef.GetObject() ) ) ) - { - // object not known to container document - // No object -> disaster! - DBG_ASSERT( mpImpl->mxObjRef.is(), "No object in connect!"); - if ( mpImpl->mxObjRef.is() ) - { - // object came from the outside, now add it to the container - OUString aTmp; - rContainer.InsertEmbeddedObject( mpImpl->mxObjRef.GetObject(), aTmp ); - mpImpl->aPersistName = aTmp; - } - } - else if ( !mpImpl->mxObjRef.is() ) + // object not known to container document + // No object -> disaster! + DBG_ASSERT( mpImpl->mxObjRef.is(), "No object in connect!"); + if ( mpImpl->mxObjRef.is() ) { - mpImpl->mxObjRef.Assign( rContainer.GetEmbeddedObject( mpImpl->aPersistName ), mpImpl->mxObjRef.GetViewAspect() ); - mpImpl->mbTypeAsked = false; - } - - if ( mpImpl->mxObjRef.GetObject().is() ) - { - mpImpl->mxObjRef.AssignToContainer( &rContainer, mpImpl->aPersistName ); - mpImpl->mbConnected = true; - mpImpl->mxObjRef.Lock(); + // object came from the outside, now add it to the container + OUString aTmp; + rContainer.InsertEmbeddedObject( mpImpl->mxObjRef.GetObject(), aTmp ); + mpImpl->aPersistName = aTmp; } } + else if ( !mpImpl->mxObjRef.is() ) + { + mpImpl->mxObjRef.Assign( rContainer.GetEmbeddedObject( mpImpl->aPersistName ), mpImpl->mxObjRef.GetViewAspect() ); + mpImpl->mbTypeAsked = false; + } - if ( mpImpl->mxObjRef.is() ) + if ( mpImpl->mxObjRef.GetObject().is() ) { - if ( !mpImpl->mxLightClient.is() ) - mpImpl->mxLightClient = new SdrLightEmbeddedClient_Impl( this ); + mpImpl->mxObjRef.AssignToContainer( &rContainer, mpImpl->aPersistName ); + mpImpl->mbConnected = true; + mpImpl->mxObjRef.Lock(); + } + } - mpImpl->mxObjRef->addStateChangeListener( mpImpl->mxLightClient.get() ); - mpImpl->mxObjRef->addEventListener( uno::Reference< document::XEventListener >( mpImpl->mxLightClient.get() ) ); + if ( mpImpl->mxObjRef.is() ) + { + if ( !mpImpl->mxLightClient.is() ) + mpImpl->mxLightClient = new SdrLightEmbeddedClient_Impl( this ); - if ( mpImpl->mxObjRef->getCurrentState() != embed::EmbedStates::LOADED ) - GetSdrGlobalData().GetOLEObjCache().InsertObj(this); + mpImpl->mxObjRef->addStateChangeListener( mpImpl->mxLightClient.get() ); + mpImpl->mxObjRef->addEventListener( uno::Reference< document::XEventListener >( mpImpl->mxLightClient.get() ) ); - CheckFileLink_Impl(); + if ( mpImpl->mxObjRef->getCurrentState() != embed::EmbedStates::LOADED ) + GetSdrGlobalData().GetOLEObjCache().InsertObj(this); - uno::Reference< container::XChild > xChild( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY ); - if( xChild.is() ) - { - uno::Reference< uno::XInterface > xParent( getSdrModelFromSdrObject().getUnoModel()); - if( xParent.is()) - xChild->setParent( getSdrModelFromSdrObject().getUnoModel() ); - } + CheckFileLink_Impl(); + uno::Reference< container::XChild > xChild( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY ); + if( xChild.is() ) + { + uno::Reference< uno::XInterface > xParent( getSdrModelFromSdrObject().getUnoModel()); + if( xParent.is()) + xChild->setParent( getSdrModelFromSdrObject().getUnoModel() ); } + } - catch( css::uno::Exception& ) - { - TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::Connect_Impl()" ); - } + } + catch( css::uno::Exception& ) + { + TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::Connect_Impl()" ); } } @@ -1025,20 +1025,20 @@ void SdrOle2Obj::ObjectLoaded() void SdrOle2Obj::AddListeners_Impl() { - if( mpImpl->mxObjRef.is() && mpImpl->mxObjRef->getCurrentState() != embed::EmbedStates::LOADED ) + if( !(mpImpl->mxObjRef.is() && mpImpl->mxObjRef->getCurrentState() != embed::EmbedStates::LOADED) ) + return; + + // register modify listener + if (!mpImpl->mxModifyListener.is()) { - // register modify listener - if (!mpImpl->mxModifyListener.is()) - { - mpImpl->mxModifyListener = new SvxUnoShapeModifyListener(this); - } + mpImpl->mxModifyListener = new SvxUnoShapeModifyListener(this); + } - uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY ); - if (xBC.is()) - { - uno::Reference xListener(mpImpl->mxModifyListener.get()); - xBC->addModifyListener( xListener ); - } + uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY ); + if (xBC.is()) + { + uno::Reference xListener(mpImpl->mxModifyListener.get()); + xBC->addModifyListener( xListener ); } } @@ -1059,25 +1059,25 @@ void SdrOle2Obj::Disconnect() void SdrOle2Obj::RemoveListeners_Impl() { - if ( mpImpl->mxObjRef.is() && !mpImpl->aPersistName.isEmpty() ) + if ( !(mpImpl->mxObjRef.is() && !mpImpl->aPersistName.isEmpty()) ) + return; + + try { - try + sal_Int32 nState = mpImpl->mxObjRef->getCurrentState(); + if ( nState != embed::EmbedStates::LOADED ) { - sal_Int32 nState = mpImpl->mxObjRef->getCurrentState(); - if ( nState != embed::EmbedStates::LOADED ) + uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY ); + if (xBC.is() && mpImpl->mxModifyListener.is()) { - uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY ); - if (xBC.is() && mpImpl->mxModifyListener.is()) - { - uno::Reference xListener(mpImpl->mxModifyListener.get()); - xBC->removeModifyListener( xListener ); - } + uno::Reference xListener(mpImpl->mxModifyListener.get()); + xBC->removeModifyListener( xListener ); } } - catch( css::uno::Exception& ) - { - TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::RemoveListeners_Impl()" ); - } + } + catch( css::uno::Exception& ) + { + TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::RemoveListeners_Impl()" ); } } @@ -1446,149 +1446,149 @@ void SdrOle2Obj::ImpSetVisAreaSize() // the object area of an embedded object was changed, e.g. by user interaction an a selected object GetObjRef(); - if (mpImpl->mxObjRef.is()) + if (!mpImpl->mxObjRef.is()) + return; + + sal_Int64 nMiscStatus = mpImpl->mxObjRef->getStatus( GetAspect() ); + + // the client is required to get access to scaling + SfxInPlaceClient* pClient( + SfxInPlaceClient::GetClient( + dynamic_cast( + getSdrModelFromSdrObject().GetPersist()), + mpImpl->mxObjRef.GetObject())); + const bool bHasOwnClient( + mpImpl->mxLightClient.is() && + mpImpl->mxObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->mxLightClient.get() ) ); + + if ( pClient || bHasOwnClient ) { - sal_Int64 nMiscStatus = mpImpl->mxObjRef->getStatus( GetAspect() ); - - // the client is required to get access to scaling - SfxInPlaceClient* pClient( - SfxInPlaceClient::GetClient( - dynamic_cast( - getSdrModelFromSdrObject().GetPersist()), - mpImpl->mxObjRef.GetObject())); - const bool bHasOwnClient( - mpImpl->mxLightClient.is() && - mpImpl->mxObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->mxLightClient.get() ) ); - - if ( pClient || bHasOwnClient ) + // TODO: IMHO we need to do similar things when object is UIActive or OutplaceActive?! + if ( ((nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) && + svt::EmbeddedObjectRef::TryRunningState( mpImpl->mxObjRef.GetObject() )) + || mpImpl->mxObjRef->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE + ) { - // TODO: IMHO we need to do similar things when object is UIActive or OutplaceActive?! - if ( ((nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) && - svt::EmbeddedObjectRef::TryRunningState( mpImpl->mxObjRef.GetObject() )) - || mpImpl->mxObjRef->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE - ) + Fraction aScaleWidth; + Fraction aScaleHeight; + if ( pClient ) { - Fraction aScaleWidth; - Fraction aScaleHeight; - if ( pClient ) - { - aScaleWidth = pClient->GetScaleWidth(); - aScaleHeight = pClient->GetScaleHeight(); - } - else - { - aScaleWidth = mpImpl->mxLightClient->GetScaleWidth(); - aScaleHeight = mpImpl->mxLightClient->GetScaleHeight(); - } + aScaleWidth = pClient->GetScaleWidth(); + aScaleHeight = pClient->GetScaleHeight(); + } + else + { + aScaleWidth = mpImpl->mxLightClient->GetScaleWidth(); + aScaleHeight = mpImpl->mxLightClient->GetScaleHeight(); + } - // The object wants to resize itself (f.e. Chart wants to recalculate the layout) - // or object is inplace active and so has a window that must be resized also - // In these cases the change in the object area size will be reflected in a change of the - // objects' visual area. The scaling will not change, but it might exist already and must - // be used in calculations - MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl->mxObjRef->getMapUnit( GetAspect() ) ); - Size aVisSize( static_cast( Fraction( maRect.GetWidth() ) / aScaleWidth ), - static_cast( Fraction( maRect.GetHeight() ) / aScaleHeight ) ); - - aVisSize = OutputDevice::LogicToLogic( - aVisSize, - MapMode(getSdrModelFromSdrObject().GetScaleUnit()), - MapMode(aMapUnit)); - awt::Size aSz; - aSz.Width = aVisSize.Width(); - aSz.Height = aVisSize.Height(); - mpImpl->mxObjRef->setVisualAreaSize( GetAspect(), aSz ); + // The object wants to resize itself (f.e. Chart wants to recalculate the layout) + // or object is inplace active and so has a window that must be resized also + // In these cases the change in the object area size will be reflected in a change of the + // objects' visual area. The scaling will not change, but it might exist already and must + // be used in calculations + MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl->mxObjRef->getMapUnit( GetAspect() ) ); + Size aVisSize( static_cast( Fraction( maRect.GetWidth() ) / aScaleWidth ), + static_cast( Fraction( maRect.GetHeight() ) / aScaleHeight ) ); + + aVisSize = OutputDevice::LogicToLogic( + aVisSize, + MapMode(getSdrModelFromSdrObject().GetScaleUnit()), + MapMode(aMapUnit)); + awt::Size aSz; + aSz.Width = aVisSize.Width(); + aSz.Height = aVisSize.Height(); + mpImpl->mxObjRef->setVisualAreaSize( GetAspect(), aSz ); - try - { - aSz = mpImpl->mxObjRef->getVisualAreaSize( GetAspect() ); - } - catch( embed::NoVisualAreaSizeException& ) - {} + try + { + aSz = mpImpl->mxObjRef->getVisualAreaSize( GetAspect() ); + } + catch( embed::NoVisualAreaSizeException& ) + {} - tools::Rectangle aAcceptedVisArea; - aAcceptedVisArea.SetSize( Size( static_cast( Fraction( long( aSz.Width ) ) * aScaleWidth ), - static_cast( Fraction( long( aSz.Height ) ) * aScaleHeight ) ) ); - if (aVisSize != aAcceptedVisArea.GetSize()) - { - // server changed VisArea to its liking and the VisArea is different than the suggested one - // store the new value as given by the object - MapUnit aNewMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl->mxObjRef->getMapUnit( GetAspect() ) ); - maRect.SetSize( - OutputDevice::LogicToLogic( - aAcceptedVisArea.GetSize(), - MapMode(aNewMapUnit), - MapMode(getSdrModelFromSdrObject().GetScaleUnit()))); - } + tools::Rectangle aAcceptedVisArea; + aAcceptedVisArea.SetSize( Size( static_cast( Fraction( long( aSz.Width ) ) * aScaleWidth ), + static_cast( Fraction( long( aSz.Height ) ) * aScaleHeight ) ) ); + if (aVisSize != aAcceptedVisArea.GetSize()) + { + // server changed VisArea to its liking and the VisArea is different than the suggested one + // store the new value as given by the object + MapUnit aNewMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl->mxObjRef->getMapUnit( GetAspect() ) ); + maRect.SetSize( + OutputDevice::LogicToLogic( + aAcceptedVisArea.GetSize(), + MapMode(aNewMapUnit), + MapMode(getSdrModelFromSdrObject().GetScaleUnit()))); + } - // make the new object area known to the client - // compared to the "else" branch aRect might have been changed by the object and no additional scaling was applied - // WHY this -> OSL_ASSERT( pClient ); - if( pClient ) - pClient->SetObjArea(maRect); + // make the new object area known to the client + // compared to the "else" branch aRect might have been changed by the object and no additional scaling was applied + // WHY this -> OSL_ASSERT( pClient ); + if( pClient ) + pClient->SetObjArea(maRect); - // we need a new replacement image as the object has resized itself + // we need a new replacement image as the object has resized itself - //#i79578# don't request a new replacement image for charts to often - //a chart sends a modified call to the framework if it was changed - //thus the replacement update is already handled there - if( !IsChart() ) - mpImpl->mxObjRef.UpdateReplacement(); - } - else + //#i79578# don't request a new replacement image for charts to often + //a chart sends a modified call to the framework if it was changed + //thus the replacement update is already handled there + if( !IsChart() ) + mpImpl->mxObjRef.UpdateReplacement(); + } + else + { + // The object isn't active and does not want to resize itself so the changed object area size + // will be reflected in a changed object scaling + Fraction aScaleWidth; + Fraction aScaleHeight; + Size aObjAreaSize; + if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) ) { - // The object isn't active and does not want to resize itself so the changed object area size - // will be reflected in a changed object scaling - Fraction aScaleWidth; - Fraction aScaleHeight; - Size aObjAreaSize; - if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) ) + if ( pClient ) { - if ( pClient ) - { - tools::Rectangle aScaleRect(maRect.TopLeft(), aObjAreaSize); - pClient->SetObjAreaAndScale( aScaleRect, aScaleWidth, aScaleHeight); - } - else - { - mpImpl->mxLightClient->SetSizeScale( aScaleWidth, aScaleHeight ); - } + tools::Rectangle aScaleRect(maRect.TopLeft(), aObjAreaSize); + pClient->SetObjAreaAndScale( aScaleRect, aScaleWidth, aScaleHeight); + } + else + { + mpImpl->mxLightClient->SetSizeScale( aScaleWidth, aScaleHeight ); } } } - else if( (nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) && - svt::EmbeddedObjectRef::TryRunningState( mpImpl->mxObjRef.GetObject() ) ) + } + else if( (nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) && + svt::EmbeddedObjectRef::TryRunningState( mpImpl->mxObjRef.GetObject() ) ) + { + //also handle not sfx based ole objects e.g. charts + //#i83860# resizing charts in impress distorts fonts + uno::Reference< embed::XVisualObject > xVisualObject( getXModel(), uno::UNO_QUERY ); + if( xVisualObject.is() ) { - //also handle not sfx based ole objects e.g. charts - //#i83860# resizing charts in impress distorts fonts - uno::Reference< embed::XVisualObject > xVisualObject( getXModel(), uno::UNO_QUERY ); - if( xVisualObject.is() ) - { - const MapUnit aMapUnit( - VCLUnoHelper::UnoEmbed2VCLMapUnit( - mpImpl->mxObjRef->getMapUnit(GetAspect()))); - const Point aTL( maRect.TopLeft() ); - const Point aBR( maRect.BottomRight() ); - const Point aTL2( - OutputDevice::LogicToLogic( - aTL, - MapMode(getSdrModelFromSdrObject().GetScaleUnit()), - MapMode(aMapUnit))); - const Point aBR2( - OutputDevice::LogicToLogic( - aBR, - MapMode(getSdrModelFromSdrObject().GetScaleUnit()), - MapMode(aMapUnit))); - const tools::Rectangle aNewRect( - aTL2, - aBR2); - - xVisualObject->setVisualAreaSize( - GetAspect(), - awt::Size( - aNewRect.GetWidth(), - aNewRect.GetHeight())); - } + const MapUnit aMapUnit( + VCLUnoHelper::UnoEmbed2VCLMapUnit( + mpImpl->mxObjRef->getMapUnit(GetAspect()))); + const Point aTL( maRect.TopLeft() ); + const Point aBR( maRect.BottomRight() ); + const Point aTL2( + OutputDevice::LogicToLogic( + aTL, + MapMode(getSdrModelFromSdrObject().GetScaleUnit()), + MapMode(aMapUnit))); + const Point aBR2( + OutputDevice::LogicToLogic( + aBR, + MapMode(getSdrModelFromSdrObject().GetScaleUnit()), + MapMode(aMapUnit))); + const tools::Rectangle aNewRect( + aTL2, + aBR2); + + xVisualObject->setVisualAreaSize( + GetAspect(), + awt::Size( + aNewRect.GetWidth(), + aNewRect.GetHeight())); } } } diff --git a/svx/source/svdraw/svdopage.cxx b/svx/source/svdraw/svdopage.cxx index aa91331b5393..9b48e34436ef 100644 --- a/svx/source/svdraw/svdopage.cxx +++ b/svx/source/svdraw/svdopage.cxx @@ -97,23 +97,23 @@ SdrPageObj::~SdrPageObj() void SdrPageObj::SetReferencedPage(SdrPage* pNewPage) { - if(mpShownPage != pNewPage) - { - if(mpShownPage) - { - mpShownPage->RemovePageUser(*this); - } + if(mpShownPage == pNewPage) + return; - mpShownPage = pNewPage; + if(mpShownPage) + { + mpShownPage->RemovePageUser(*this); + } - if(mpShownPage) - { - mpShownPage->AddPageUser(*this); - } + mpShownPage = pNewPage; - SetChanged(); - BroadcastObjectChange(); + if(mpShownPage) + { + mpShownPage->AddPageUser(*this); } + + SetChanged(); + BroadcastObjectChange(); } // #i96598# diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index 93b08170fcb6..f197462c76ab 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -2454,27 +2454,27 @@ void SdrPathObj::NbcSetPoint(const Point& rPnt, sal_uInt32 nHdlNum) { sal_uInt32 nPoly,nPnt; - if(PolyPolygonEditor::GetRelativePolyPoint(GetPathPoly(), nHdlNum, nPoly, nPnt)) - { - basegfx::B2DPolygon aNewPolygon(GetPathPoly().getB2DPolygon(nPoly)); - aNewPolygon.setB2DPoint(nPnt, basegfx::B2DPoint(rPnt.X(), rPnt.Y())); - maPathPolygon.setB2DPolygon(nPoly, aNewPolygon); + if(!PolyPolygonEditor::GetRelativePolyPoint(GetPathPoly(), nHdlNum, nPoly, nPnt)) + return; - if(meKind==OBJ_LINE) - { - ImpForceLineAngle(); - } - else + basegfx::B2DPolygon aNewPolygon(GetPathPoly().getB2DPolygon(nPoly)); + aNewPolygon.setB2DPoint(nPnt, basegfx::B2DPoint(rPnt.X(), rPnt.Y())); + maPathPolygon.setB2DPolygon(nPoly, aNewPolygon); + + if(meKind==OBJ_LINE) + { + ImpForceLineAngle(); + } + else + { + if(GetPathPoly().count()) { - if(GetPathPoly().count()) - { - // #i10659# for SdrTextObj, keep aRect up to date - maRect = lcl_ImpGetBoundRect(GetPathPoly()); - } + // #i10659# for SdrTextObj, keep aRect up to date + maRect = lcl_ImpGetBoundRect(GetPathPoly()); } - - SetRectsDirty(); } + + SetRectsDirty(); } sal_uInt32 SdrPathObj::NbcInsPointOld(const Point& rPos, bool bNewObj) diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx index 0c648189317a..9093a4670ff3 100644 --- a/svx/source/svdraw/svdorect.cxx +++ b/svx/source/svdraw/svdorect.cxx @@ -170,22 +170,22 @@ sal_uInt16 SdrRectObj::GetObjIdentifier() const void SdrRectObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const { rRect = maRect; - if (aGeo.nShearAngle!=0) + if (aGeo.nShearAngle==0) + return; + + long nDst=FRound((maRect.Bottom()-maRect.Top())*aGeo.nTan); + if (aGeo.nShearAngle>0) { - long nDst=FRound((maRect.Bottom()-maRect.Top())*aGeo.nTan); - if (aGeo.nShearAngle>0) - { - Point aRef(rRect.TopLeft()); - rRect.AdjustLeft( -nDst ); - Point aTmpPt(rRect.TopLeft()); - RotatePoint(aTmpPt,aRef,aGeo.nSin,aGeo.nCos); - aTmpPt-=rRect.TopLeft(); - rRect.Move(aTmpPt.X(),aTmpPt.Y()); - } - else - { - rRect.AdjustRight( -nDst ); - } + Point aRef(rRect.TopLeft()); + rRect.AdjustLeft( -nDst ); + Point aTmpPt(rRect.TopLeft()); + RotatePoint(aTmpPt,aRef,aGeo.nSin,aGeo.nCos); + aTmpPt-=rRect.TopLeft(); + rRect.Move(aTmpPt.X(),aTmpPt.Y()); + } + else + { + rRect.AdjustRight( -nDst ); } } diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index e43fdedae0cf..1d4ae9094aa5 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -1173,18 +1173,18 @@ void SdrTextObj::ImpSetupDrawOutlinerForPaint( bool bContourFrame, TakeTextRect(rOutliner, rTextRect, false, &rAnchorRect); rPaintRect = rTextRect; - if (!bContourFrame) + if (bContourFrame) + return; + + // FitToSize can't be used together with ContourFrame for now + if (IsFitToSize()) { - // FitToSize can't be used together with ContourFrame for now - if (IsFitToSize()) - { - ImpSetCharStretching(rOutliner,rTextRect.GetSize(),rAnchorRect.GetSize(),rFitXCorrection); - rPaintRect=rAnchorRect; - } - else if (IsAutoFit()) - { - ImpAutoFitText(rOutliner); - } + ImpSetCharStretching(rOutliner,rTextRect.GetSize(),rAnchorRect.GetSize(),rFitXCorrection); + rPaintRect=rAnchorRect; + } + else if (IsAutoFit()) + { + ImpAutoFitText(rOutliner); } } @@ -1400,28 +1400,28 @@ void SdrTextObj::NbcSetOutlinerParaObjectForText( std::unique_ptrGetOutlinerParaObject() ) + if( !(pText && pText->GetOutlinerParaObject()) ) + return; + + pText->ReformatText(); + if (bTextFrame) { - pText->ReformatText(); - if (bTextFrame) - { - NbcAdjustTextFrameWidthAndHeight(); - } - else - { - // the SnapRect keeps its size - SetBoundRectDirty(); - SetRectsDirty(true); - } - SetTextSizeDirty(); - ActionChanged(); - // i22396 - // Necessary here since we have no compare operator at the outliner - // para object which may detect changes regarding the combination - // of outliner para data and configuration (e.g., change of - // formatting of text numerals) - GetViewContact().flushViewObjectContacts(false); + NbcAdjustTextFrameWidthAndHeight(); } + else + { + // the SnapRect keeps its size + SetBoundRectDirty(); + SetRectsDirty(true); + } + SetTextSizeDirty(); + ActionChanged(); + // i22396 + // Necessary here since we have no compare operator at the outliner + // para object which may detect changes regarding the combination + // of outliner para data and configuration (e.g., change of + // formatting of text numerals) + GetViewContact().flushViewObjectContacts(false); } SdrObjGeoData* SdrTextObj::NewGeoData() const @@ -1852,23 +1852,23 @@ void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus ) const EditStatusFlags nStat = pEditStatus->GetStatusWord(); const bool bGrowX = bool(nStat & EditStatusFlags::TEXTWIDTHCHANGED); const bool bGrowY = bool(nStat & EditStatusFlags::TextHeightChanged); - if(bTextFrame && (bGrowX || bGrowY)) + if(!(bTextFrame && (bGrowX || bGrowY))) + return; + + if ((bGrowX && IsAutoGrowWidth()) || (bGrowY && IsAutoGrowHeight())) { - if ((bGrowX && IsAutoGrowWidth()) || (bGrowY && IsAutoGrowHeight())) - { - AdjustTextFrameWidthAndHeight(); - } - else if ( (IsAutoFit() || IsFitToSize()) && !mbInDownScale) - { - assert(pEdtOutl); - mbInDownScale = true; - - // sucks that we cannot disable paints via - // pEdtOutl->SetUpdateMode(FALSE) - but EditEngine skips - // formatting as well, then. - ImpAutoFitText(*pEdtOutl); - mbInDownScale = false; - } + AdjustTextFrameWidthAndHeight(); + } + else if ( (IsAutoFit() || IsFitToSize()) && !mbInDownScale) + { + assert(pEdtOutl); + mbInDownScale = true; + + // sucks that we cannot disable paints via + // pEdtOutl->SetUpdateMode(FALSE) - but EditEngine skips + // formatting as well, then. + ImpAutoFitText(*pEdtOutl); + mbInDownScale = false; } } diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index 8769b16b8ddc..499585c7f5f5 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -380,63 +380,63 @@ namespace maTextPortionPrimitives.push_back(pNewPrimitive); // support for WrongSpellVector. Create WrongSpellPrimitives as needed - if(rInfo.mpWrongSpellVector && !aDXArray.empty()) + if(!rInfo.mpWrongSpellVector || aDXArray.empty()) + return; + + const sal_Int32 nSize(rInfo.mpWrongSpellVector->size()); + const sal_Int32 nDXCount(aDXArray.size()); + const basegfx::BColor aSpellColor(1.0, 0.0, 0.0); // red, hard coded + + for(sal_Int32 a(0); a < nSize; a++) { - const sal_Int32 nSize(rInfo.mpWrongSpellVector->size()); - const sal_Int32 nDXCount(aDXArray.size()); - const basegfx::BColor aSpellColor(1.0, 0.0, 0.0); // red, hard coded + const EEngineData::WrongSpellClass& rCandidate = (*rInfo.mpWrongSpellVector)[a]; - for(sal_Int32 a(0); a < nSize; a++) + if(rCandidate.nStart >= rInfo.mnTextStart && rCandidate.nEnd >= rInfo.mnTextStart && rCandidate.nEnd > rCandidate.nStart) { - const EEngineData::WrongSpellClass& rCandidate = (*rInfo.mpWrongSpellVector)[a]; + const sal_Int32 nStart(rCandidate.nStart - rInfo.mnTextStart); + const sal_Int32 nEnd(rCandidate.nEnd - rInfo.mnTextStart); + double fStart(0.0); + double fEnd(0.0); - if(rCandidate.nStart >= rInfo.mnTextStart && rCandidate.nEnd >= rInfo.mnTextStart && rCandidate.nEnd > rCandidate.nStart) + if(nStart > 0 && nStart - 1 < nDXCount) { - const sal_Int32 nStart(rCandidate.nStart - rInfo.mnTextStart); - const sal_Int32 nEnd(rCandidate.nEnd - rInfo.mnTextStart); - double fStart(0.0); - double fEnd(0.0); + fStart = aDXArray[nStart - 1]; + } - if(nStart > 0 && nStart - 1 < nDXCount) - { - fStart = aDXArray[nStart - 1]; - } + if(nEnd > 0 && nEnd - 1 < nDXCount) + { + fEnd = aDXArray[nEnd - 1]; + } - if(nEnd > 0 && nEnd - 1 < nDXCount) + if(!basegfx::fTools::equal(fStart, fEnd)) + { + if(rInfo.IsRTL()) { - fEnd = aDXArray[nEnd - 1]; + // #i98523# + // When the portion is RTL, mirror the redlining using the + // full portion width + const double fTextWidth(aDXArray[aDXArray.size() - 1]); + + fStart = fTextWidth - fStart; + fEnd = fTextWidth - fEnd; } - if(!basegfx::fTools::equal(fStart, fEnd)) + // need to take FontScaling out of values; it's already part of + // aNewTransform and would be double applied + const double fFontScaleX(aFontScaling.getX()); + + if(!basegfx::fTools::equal(fFontScaleX, 1.0) + && !basegfx::fTools::equalZero(fFontScaleX)) { - if(rInfo.IsRTL()) - { - // #i98523# - // When the portion is RTL, mirror the redlining using the - // full portion width - const double fTextWidth(aDXArray[aDXArray.size() - 1]); - - fStart = fTextWidth - fStart; - fEnd = fTextWidth - fEnd; - } - - // need to take FontScaling out of values; it's already part of - // aNewTransform and would be double applied - const double fFontScaleX(aFontScaling.getX()); - - if(!basegfx::fTools::equal(fFontScaleX, 1.0) - && !basegfx::fTools::equalZero(fFontScaleX)) - { - fStart /= fFontScaleX; - fEnd /= fFontScaleX; - } - - maTextPortionPrimitives.push_back(new drawinglayer::primitive2d::WrongSpellPrimitive2D( - aNewTransform, - fStart, - fEnd, - aSpellColor)); + fStart /= fFontScaleX; + fEnd /= fFontScaleX; } + + maTextPortionPrimitives.push_back(new drawinglayer::primitive2d::WrongSpellPrimitive2D( + aNewTransform, + fStart, + fEnd, + aSpellColor)); } } } @@ -573,47 +573,47 @@ namespace IMPL_LINK(impTextBreakupHandler, decomposeBlockTextPrimitive, DrawPortionInfo*, pInfo, void) { - if(pInfo) + if(!pInfo) + return; + + // Is clipping wanted? This is text clipping; only accept a portion + // if it's completely in the range + if(!maClipRange.isEmpty()) { - // Is clipping wanted? This is text clipping; only accept a portion - // if it's completely in the range - if(!maClipRange.isEmpty()) - { - // Test start position first; this allows to not get the text range at - // all if text is far outside - const basegfx::B2DPoint aStartPosition(pInfo->mrStartPos.X(), pInfo->mrStartPos.Y()); + // Test start position first; this allows to not get the text range at + // all if text is far outside + const basegfx::B2DPoint aStartPosition(pInfo->mrStartPos.X(), pInfo->mrStartPos.Y()); - if(!maClipRange.isInside(aStartPosition)) - { - return; - } + if(!maClipRange.isInside(aStartPosition)) + { + return; + } - // Start position is inside. Get TextBoundRect and TopLeft next - drawinglayer::primitive2d::TextLayouterDevice aTextLayouterDevice; - aTextLayouterDevice.setFont(pInfo->mrFont); + // Start position is inside. Get TextBoundRect and TopLeft next + drawinglayer::primitive2d::TextLayouterDevice aTextLayouterDevice; + aTextLayouterDevice.setFont(pInfo->mrFont); - const basegfx::B2DRange aTextBoundRect( - aTextLayouterDevice.getTextBoundRect( - pInfo->maText, pInfo->mnTextStart, pInfo->mnTextLen)); - const basegfx::B2DPoint aTopLeft(aTextBoundRect.getMinimum() + aStartPosition); + const basegfx::B2DRange aTextBoundRect( + aTextLayouterDevice.getTextBoundRect( + pInfo->maText, pInfo->mnTextStart, pInfo->mnTextLen)); + const basegfx::B2DPoint aTopLeft(aTextBoundRect.getMinimum() + aStartPosition); - if(!maClipRange.isInside(aTopLeft)) - { - return; - } + if(!maClipRange.isInside(aTopLeft)) + { + return; + } - // TopLeft is inside. Get BottomRight and check - const basegfx::B2DPoint aBottomRight(aTextBoundRect.getMaximum() + aStartPosition); + // TopLeft is inside. Get BottomRight and check + const basegfx::B2DPoint aBottomRight(aTextBoundRect.getMaximum() + aStartPosition); - if(!maClipRange.isInside(aBottomRight)) - { - return; - } - - // all inside, clip was successful + if(!maClipRange.isInside(aBottomRight)) + { + return; } - impHandleDrawPortionInfo(*pInfo); + + // all inside, clip was successful } + impHandleDrawPortionInfo(*pInfo); } IMPL_LINK(impTextBreakupHandler, decomposeStretchTextPrimitive, DrawPortionInfo*, pInfo, void) @@ -1318,21 +1318,21 @@ static void impCreateAlternateTiming(const SfxItemSet& rSet, drawinglayer::anima rAnimList.append(aTime1); } - if(0 != nRepeat) + if(0 == nRepeat) + return; + + bool bVisibleWhenStopped(rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE).GetValue()); + if(bVisibleWhenStopped) { - bool bVisibleWhenStopped(rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE).GetValue()); - if(bVisibleWhenStopped) - { - // add timing for staying at the end - drawinglayer::animation::AnimationEntryFixed aEnd(ENDLESS_TIME, 0.5); - rAnimList.append(aEnd); - } - else - { - // move from center to outside - drawinglayer::animation::AnimationEntryLinear aInOut(fTimeFullPath * 0.5, fFrequency, 0.5, bForward ? 1.0 : 0.0); - rAnimList.append(aInOut); - } + // add timing for staying at the end + drawinglayer::animation::AnimationEntryFixed aEnd(ENDLESS_TIME, 0.5); + rAnimList.append(aEnd); + } + else + { + // move from center to outside + drawinglayer::animation::AnimationEntryLinear aInOut(fTimeFullPath * 0.5, fFrequency, 0.5, bForward ? 1.0 : 0.0); + rAnimList.append(aInOut); } } diff --git a/svx/source/svdraw/svdotxat.cxx b/svx/source/svdraw/svdotxat.cxx index 6f4559fd33ca..7ede09f1a8f4 100644 --- a/svx/source/svdraw/svdotxat.cxx +++ b/svx/source/svdraw/svdotxat.cxx @@ -292,77 +292,77 @@ bool SdrTextObj::AdjustTextFrameWidthAndHeight() void SdrTextObj::ImpSetTextStyleSheetListeners() { SfxStyleSheetBasePool* pStylePool(getSdrModelFromSdrObject().GetStyleSheetPool()); - if (pStylePool!=nullptr) + if (pStylePool==nullptr) + return; + + std::vector aStyleNames; + OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject(); + if (pOutlinerParaObject!=nullptr) { - std::vector aStyleNames; - OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject(); - if (pOutlinerParaObject!=nullptr) - { - // First, we collect all stylesheets contained in the ParaObject in - // the container aStyles. The Family is always appended to the name - // of the stylesheet. - const EditTextObject& rTextObj=pOutlinerParaObject->GetTextObject(); - OUString aStyleName; - SfxStyleFamily eStyleFam; - sal_Int32 nParaCnt=rTextObj.GetParagraphCount(); + // First, we collect all stylesheets contained in the ParaObject in + // the container aStyles. The Family is always appended to the name + // of the stylesheet. + const EditTextObject& rTextObj=pOutlinerParaObject->GetTextObject(); + OUString aStyleName; + SfxStyleFamily eStyleFam; + sal_Int32 nParaCnt=rTextObj.GetParagraphCount(); + + for(sal_Int32 nParaNum(0); nParaNum < nParaCnt; nParaNum++) + { + rTextObj.GetStyleSheet(nParaNum, aStyleName, eStyleFam); - for(sal_Int32 nParaNum(0); nParaNum < nParaCnt; nParaNum++) + if (!aStyleName.isEmpty()) { - rTextObj.GetStyleSheet(nParaNum, aStyleName, eStyleFam); + AppendFamilyToStyleName(aStyleName, eStyleFam); + + bool bFnd(false); + sal_uInt32 nNum(aStyleNames.size()); - if (!aStyleName.isEmpty()) + while(!bFnd && nNum > 0) { - AppendFamilyToStyleName(aStyleName, eStyleFam); - - bool bFnd(false); - sal_uInt32 nNum(aStyleNames.size()); - - while(!bFnd && nNum > 0) - { - // we don't want duplicate stylesheets - nNum--; - bFnd = aStyleName == aStyleNames[nNum]; - } - - if(!bFnd) - { - aStyleNames.push_back(aStyleName); - } + // we don't want duplicate stylesheets + nNum--; + bFnd = aStyleName == aStyleNames[nNum]; + } + + if(!bFnd) + { + aStyleNames.push_back(aStyleName); } } } + } - // now convert the strings in the vector from names to StyleSheet* - o3tl::sorted_vector aStyleSheets; - while (!aStyleNames.empty()) { - OUString aName = aStyleNames.back(); - aStyleNames.pop_back(); - - SfxStyleFamily eFam = ReadFamilyFromStyleName(aName); - SfxStyleSheetBase* pStyleBase = pStylePool->Find(aName,eFam); - SfxStyleSheet* pStyle = dynamic_cast( pStyleBase ); - if (pStyle!=nullptr && pStyle!=GetStyleSheet()) { - aStyleSheets.insert(pStyle); - } + // now convert the strings in the vector from names to StyleSheet* + o3tl::sorted_vector aStyleSheets; + while (!aStyleNames.empty()) { + OUString aName = aStyleNames.back(); + aStyleNames.pop_back(); + + SfxStyleFamily eFam = ReadFamilyFromStyleName(aName); + SfxStyleSheetBase* pStyleBase = pStylePool->Find(aName,eFam); + SfxStyleSheet* pStyle = dynamic_cast( pStyleBase ); + if (pStyle!=nullptr && pStyle!=GetStyleSheet()) { + aStyleSheets.insert(pStyle); } - // now remove all superfluous stylesheets - sal_uInt16 nNum=GetBroadcasterCount(); - while (nNum>0) { - nNum--; - SfxBroadcaster* pBroadcast=GetBroadcasterJOE(nNum); - SfxStyleSheet* pStyle=dynamic_cast( pBroadcast ); - if (pStyle!=nullptr && pStyle!=GetStyleSheet()) { // special case for stylesheet of the object - if (aStyleSheets.find(pStyle)==aStyleSheets.end()) { - EndListening(*pStyle); - } + } + // now remove all superfluous stylesheets + sal_uInt16 nNum=GetBroadcasterCount(); + while (nNum>0) { + nNum--; + SfxBroadcaster* pBroadcast=GetBroadcasterJOE(nNum); + SfxStyleSheet* pStyle=dynamic_cast( pBroadcast ); + if (pStyle!=nullptr && pStyle!=GetStyleSheet()) { // special case for stylesheet of the object + if (aStyleSheets.find(pStyle)==aStyleSheets.end()) { + EndListening(*pStyle); } } - // and finally, merge all stylesheets that are contained in aStyles with previous broadcasters - for(SfxStyleSheet* pStyle : aStyleSheets) { - // let StartListening see for itself if there's already a listener registered - StartListening(*pStyle, DuplicateHandling::Prevent); - } + } + // and finally, merge all stylesheets that are contained in aStyles with previous broadcasters + for(SfxStyleSheet* pStyle : aStyleSheets) { + // let StartListening see for itself if there's already a listener registered + StartListening(*pStyle, DuplicateHandling::Prevent); } } diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx index 49cea290ae4c..0116ee8f3992 100644 --- a/svx/source/svdraw/svdouno.cxx +++ b/svx/source/svdraw/svdouno.cxx @@ -297,21 +297,21 @@ void SdrUnoObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fracti { SdrRectObj::NbcResize(rRef,xFact,yFact); - if (aGeo.nShearAngle!=0 || aGeo.nRotationAngle!=0) - { - // small correctors - if (aGeo.nRotationAngle>=9000 && aGeo.nRotationAngle<27000) - { - maRect.Move(maRect.Left()-maRect.Right(),maRect.Top()-maRect.Bottom()); - } + if (aGeo.nShearAngle==0 && aGeo.nRotationAngle==0) + return; - aGeo.nRotationAngle = 0; - aGeo.nShearAngle = 0; - aGeo.nSin = 0.0; - aGeo.nCos = 1.0; - aGeo.nTan = 0.0; - SetRectsDirty(); + // small correctors + if (aGeo.nRotationAngle>=9000 && aGeo.nRotationAngle<27000) + { + maRect.Move(maRect.Left()-maRect.Right(),maRect.Top()-maRect.Bottom()); } + + aGeo.nRotationAngle = 0; + aGeo.nShearAngle = 0; + aGeo.nSin = 0.0; + aGeo.nCos = 1.0; + aGeo.nTan = 0.0; + SetRectsDirty(); } diff --git a/svx/source/svdraw/svdoutlinercache.cxx b/svx/source/svdraw/svdoutlinercache.cxx index 1d9d75d81f08..78746639e1c8 100644 --- a/svx/source/svdraw/svdoutlinercache.cxx +++ b/svx/source/svdraw/svdoutlinercache.cxx @@ -61,32 +61,32 @@ SdrOutlinerCache::~SdrOutlinerCache() void SdrOutlinerCache::disposeOutliner( std::unique_ptr pOutliner ) { - if( pOutliner ) - { - OutlinerMode nOutlMode = pOutliner->GetOutlinerMode(); + if( !pOutliner ) + return; + + OutlinerMode nOutlMode = pOutliner->GetOutlinerMode(); - if( OutlinerMode::OutlineObject == nOutlMode ) - { - pOutliner->Clear(); - pOutliner->SetVertical( false ); + if( OutlinerMode::OutlineObject == nOutlMode ) + { + pOutliner->Clear(); + pOutliner->SetVertical( false ); - // Deregister on outliner, might be reused from outliner cache - pOutliner->SetNotifyHdl( Link() ); - maModeOutline.emplace_back(std::move(pOutliner)); - } - else if( OutlinerMode::TextObject == nOutlMode ) - { - pOutliner->Clear(); - pOutliner->SetVertical( false ); + // Deregister on outliner, might be reused from outliner cache + pOutliner->SetNotifyHdl( Link() ); + maModeOutline.emplace_back(std::move(pOutliner)); + } + else if( OutlinerMode::TextObject == nOutlMode ) + { + pOutliner->Clear(); + pOutliner->SetVertical( false ); - // Deregister on outliner, might be reused from outliner cache - pOutliner->SetNotifyHdl( Link() ); - maModeText.emplace_back(std::move(pOutliner)); - } - else - { - maActiveOutliners.erase(pOutliner.get()); - } + // Deregister on outliner, might be reused from outliner cache + pOutliner->SetNotifyHdl( Link() ); + maModeText.emplace_back(std::move(pOutliner)); + } + else + { + maActiveOutliners.erase(pOutliner.get()); } } diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index 901ba1a317cb..6ede6aa36108 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -323,19 +323,19 @@ void SdrObjList::InsertObjectThenMakeNameUnique(SdrObject* pObj) void SdrObjList::InsertObjectThenMakeNameUnique(SdrObject* pObj, std::unordered_set& rNameSet, size_t nPos) { InsertObject(pObj, nPos); - if (!pObj->GetName().isEmpty()) + if (pObj->GetName().isEmpty()) + return; + + pObj->MakeNameUnique(rNameSet); + SdrObjList* pSdrObjList = pObj->GetSubList(); // group + if (pSdrObjList) { - pObj->MakeNameUnique(rNameSet); - SdrObjList* pSdrObjList = pObj->GetSubList(); // group - if (pSdrObjList) + SdrObject* pListObj; + SdrObjListIter aIter(pSdrObjList, SdrIterMode::DeepWithGroups); + while (aIter.IsMore()) { - SdrObject* pListObj; - SdrObjListIter aIter(pSdrObjList, SdrIterMode::DeepWithGroups); - while (aIter.IsMore()) - { - pListObj = aIter.Next(); - pListObj->MakeNameUnique(rNameSet); - } + pListObj = aIter.Next(); + pListObj->MakeNameUnique(rNameSet); } } } @@ -344,39 +344,39 @@ void SdrObjList::InsertObject(SdrObject* pObj, size_t nPos) { DBG_ASSERT(pObj!=nullptr,"SdrObjList::InsertObject(NULL)"); - if(pObj) - { - // if anchor is used, reset it before grouping - if(getSdrObjectFromSdrObjList()) - { - const Point& rAnchorPos = pObj->GetAnchorPos(); - if(rAnchorPos.X() || rAnchorPos.Y()) - pObj->NbcSetAnchorPos(Point()); - } + if(!pObj) + return; - // do insert to new group - NbcInsertObject(pObj, nPos); + // if anchor is used, reset it before grouping + if(getSdrObjectFromSdrObjList()) + { + const Point& rAnchorPos = pObj->GetAnchorPos(); + if(rAnchorPos.X() || rAnchorPos.Y()) + pObj->NbcSetAnchorPos(Point()); + } - // In case the object is inserted into a group and doesn't overlap with - // the group's other members, it needs an own repaint. - SdrObject* pParentSdrObject(getSdrObjectFromSdrObjList()); + // do insert to new group + NbcInsertObject(pObj, nPos); - if(pParentSdrObject) - { - // only repaint here - pParentSdrObject->ActionChanged(); - } + // In case the object is inserted into a group and doesn't overlap with + // the group's other members, it needs an own repaint. + SdrObject* pParentSdrObject(getSdrObjectFromSdrObjList()); - // TODO: We need a different broadcast here! - // Repaint from object number ... (heads-up: GroupObj) - if(pObj->getSdrPageFromSdrObject()) - { - SdrHint aHint(SdrHintKind::ObjectInserted, *pObj); - pObj->getSdrModelFromSdrObject().Broadcast(aHint); - } + if(pParentSdrObject) + { + // only repaint here + pParentSdrObject->ActionChanged(); + } - pObj->getSdrModelFromSdrObject().SetChanged(); + // TODO: We need a different broadcast here! + // Repaint from object number ... (heads-up: GroupObj) + if(pObj->getSdrPageFromSdrObject()) + { + SdrHint aHint(SdrHintKind::ObjectInserted, *pObj); + pObj->getSdrModelFromSdrObject().Broadcast(aHint); } + + pObj->getSdrModelFromSdrObject().SetChanged(); } SdrObject* SdrObjList::NbcRemoveObject(size_t nObjNum) @@ -854,23 +854,23 @@ void SdrObjList::SetObjectNavigationPosition ( // Move the object to its new position. const sal_uInt32 nOldPosition = ::std::distance(mxNavigationOrder->begin(), iObject); - if (nOldPosition != nNewPosition) - { - mxNavigationOrder->erase(iObject); - sal_uInt32 nInsertPosition (nNewPosition); - // Adapt insertion position for the just erased object. - if (nNewPosition >= nOldPosition) - nInsertPosition -= 1; - if (nInsertPosition >= mxNavigationOrder->size()) - mxNavigationOrder->push_back(aReference); - else - mxNavigationOrder->insert(mxNavigationOrder->begin()+nInsertPosition, aReference); + if (nOldPosition == nNewPosition) + return; - mbIsNavigationOrderDirty = true; + mxNavigationOrder->erase(iObject); + sal_uInt32 nInsertPosition (nNewPosition); + // Adapt insertion position for the just erased object. + if (nNewPosition >= nOldPosition) + nInsertPosition -= 1; + if (nInsertPosition >= mxNavigationOrder->size()) + mxNavigationOrder->push_back(aReference); + else + mxNavigationOrder->insert(mxNavigationOrder->begin()+nInsertPosition, aReference); - // The navigation order is written out to file so mark the model as modified. - rObject.getSdrModelFromSdrObject().SetChanged(); - } + mbIsNavigationOrderDirty = true; + + // The navigation order is written out to file so mark the model as modified. + rObject.getSdrModelFromSdrObject().SetChanged(); } @@ -1638,23 +1638,23 @@ OUString SdrPage::GetLayoutName() const void SdrPage::SetInserted( bool bIns ) { - if( mbInserted != bIns ) - { - mbInserted = bIns; + if( mbInserted == bIns ) + return; - // #i120437# go over whole hierarchy, not only over object level null (seen from grouping) - SdrObjListIter aIter(this, SdrIterMode::DeepNoGroups); + mbInserted = bIns; + + // #i120437# go over whole hierarchy, not only over object level null (seen from grouping) + SdrObjListIter aIter(this, SdrIterMode::DeepNoGroups); - while ( aIter.IsMore() ) + while ( aIter.IsMore() ) + { + SdrObject* pObj = aIter.Next(); + if ( dynamic_cast(pObj) != nullptr ) { - SdrObject* pObj = aIter.Next(); - if ( dynamic_cast(pObj) != nullptr ) - { - if( mbInserted ) - static_cast(pObj)->Connect(); - else - static_cast(pObj)->Disconnect(); - } + if( mbInserted ) + static_cast(pObj)->Connect(); + else + static_cast(pObj)->Disconnect(); } } } diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx index 215e37bc7c94..b95109ed6886 100644 --- a/svx/source/svdraw/svdpagv.cxx +++ b/svx/source/svdraw/svdpagv.cxx @@ -219,22 +219,22 @@ void SdrPageView::PrePaint() void SdrPageView::CompleteRedraw( SdrPaintWindow& rPaintWindow, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector ) { - if(GetPage()) - { - SdrPageWindow* pPageWindow = FindPageWindow(rPaintWindow); - std::unique_ptr pTempPageWindow; + if(!GetPage()) + return; - if(!pPageWindow) - { - // create temp PageWindow - pTempPageWindow.reset(new SdrPageWindow(*this, rPaintWindow)); - pPageWindow = pTempPageWindow.get(); - } + SdrPageWindow* pPageWindow = FindPageWindow(rPaintWindow); + std::unique_ptr pTempPageWindow; - // do the redraw - pPageWindow->PrepareRedraw(rReg); - pPageWindow->RedrawAll(pRedirector); + if(!pPageWindow) + { + // create temp PageWindow + pTempPageWindow.reset(new SdrPageWindow(*this, rPaintWindow)); + pPageWindow = pTempPageWindow.get(); } + + // do the redraw + pPageWindow->PrepareRedraw(rReg); + pPageWindow->RedrawAll(pRedirector); } @@ -250,87 +250,87 @@ void SdrPageView::DrawLayer(SdrLayerID nID, OutputDevice* pGivenTarget, sdr::contact::ViewObjectContactRedirector* pRedirector, const tools::Rectangle& rRect, basegfx::B2IRectangle const*const pPageFrame) { - if(GetPage()) + if(!GetPage()) + return; + + if(pGivenTarget) { - if(pGivenTarget) + SdrPageWindow* pKnownTarget = FindPageWindow(*pGivenTarget); + + if(pKnownTarget) + { + // paint known target + pKnownTarget->RedrawLayer(&nID, pRedirector, nullptr); + } + else { - SdrPageWindow* pKnownTarget = FindPageWindow(*pGivenTarget); + // #i72752# DrawLayer() uses an OutputDevice different from BeginDrawLayer. This happens + // e.g. when SW paints a single text line in text edit mode. Try to use it + SdrPageWindow* pPreparedTarget = mpPreparedPageWindow; - if(pKnownTarget) + if(pPreparedTarget) { - // paint known target - pKnownTarget->RedrawLayer(&nID, pRedirector, nullptr); + // if we have a prepared target, do not use a new SdrPageWindow since this + // works but is expensive. Just use a temporary PaintWindow + SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget); + + // Copy existing paint region to use the same as prepared in BeginDrawLayer + SdrPaintWindow& rExistingPaintWindow = pPreparedTarget->GetPaintWindow(); + const vcl::Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion(); + bool bUseRect(false); + if (!rRect.IsEmpty()) + { + vcl::Region r(rExistingRegion); + r.Intersect(rRect); + // fdo#74435: FIXME: visibility check broken if empty + if (!r.IsEmpty()) + bUseRect = true; + } + if (!bUseRect) + aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion); + else + aTemporaryPaintWindow.SetRedrawRegion(vcl::Region(rRect)); + // patch the ExistingPageWindow + pPreparedTarget->patchPaintWindow(aTemporaryPaintWindow); + + // redraw the layer + pPreparedTarget->RedrawLayer(&nID, pRedirector, pPageFrame); + + // restore the ExistingPageWindow + pPreparedTarget->unpatchPaintWindow(); } else { - // #i72752# DrawLayer() uses an OutputDevice different from BeginDrawLayer. This happens - // e.g. when SW paints a single text line in text edit mode. Try to use it - SdrPageWindow* pPreparedTarget = mpPreparedPageWindow; - - if(pPreparedTarget) + OSL_FAIL("SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), this should never be needed (!)"); + + // None of the known OutputDevices is the target of this paint, use + // a temporary SdrPageWindow for this Redraw. + SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget); + SdrPageWindow aTemporaryPageWindow(*this, aTemporaryPaintWindow); + + // #i72752# + // Copy existing paint region if other PageWindows exist, this was created by + // PrepareRedraw() from BeginDrawLayer(). Needs to be used e.g. when suddenly SW + // paints into an unknown device other than the view was created for (e.g. VirtualDevice) + if(PageWindowCount()) { - // if we have a prepared target, do not use a new SdrPageWindow since this - // works but is expensive. Just use a temporary PaintWindow - SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget); - - // Copy existing paint region to use the same as prepared in BeginDrawLayer - SdrPaintWindow& rExistingPaintWindow = pPreparedTarget->GetPaintWindow(); + SdrPageWindow* pExistingPageWindow = GetPageWindow(0); + SdrPaintWindow& rExistingPaintWindow = pExistingPageWindow->GetPaintWindow(); const vcl::Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion(); - bool bUseRect(false); - if (!rRect.IsEmpty()) - { - vcl::Region r(rExistingRegion); - r.Intersect(rRect); - // fdo#74435: FIXME: visibility check broken if empty - if (!r.IsEmpty()) - bUseRect = true; - } - if (!bUseRect) - aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion); - else - aTemporaryPaintWindow.SetRedrawRegion(vcl::Region(rRect)); - // patch the ExistingPageWindow - pPreparedTarget->patchPaintWindow(aTemporaryPaintWindow); - - // redraw the layer - pPreparedTarget->RedrawLayer(&nID, pRedirector, pPageFrame); - - // restore the ExistingPageWindow - pPreparedTarget->unpatchPaintWindow(); + aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion); } - else - { - OSL_FAIL("SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), this should never be needed (!)"); - - // None of the known OutputDevices is the target of this paint, use - // a temporary SdrPageWindow for this Redraw. - SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget); - SdrPageWindow aTemporaryPageWindow(*this, aTemporaryPaintWindow); - - // #i72752# - // Copy existing paint region if other PageWindows exist, this was created by - // PrepareRedraw() from BeginDrawLayer(). Needs to be used e.g. when suddenly SW - // paints into an unknown device other than the view was created for (e.g. VirtualDevice) - if(PageWindowCount()) - { - SdrPageWindow* pExistingPageWindow = GetPageWindow(0); - SdrPaintWindow& rExistingPaintWindow = pExistingPageWindow->GetPaintWindow(); - const vcl::Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion(); - aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion); - } - aTemporaryPageWindow.RedrawLayer(&nID, pRedirector, nullptr); - } + aTemporaryPageWindow.RedrawLayer(&nID, pRedirector, nullptr); } } - else + } + else + { + // paint in all known windows + for(sal_uInt32 a(0); a < PageWindowCount(); a++) { - // paint in all known windows - for(sal_uInt32 a(0); a < PageWindowCount(); a++) - { - SdrPageWindow* pTarget = GetPageWindow(a); - pTarget->RedrawLayer(&nID, pRedirector, nullptr); - } + SdrPageWindow* pTarget = GetPageWindow(a); + pTarget->RedrawLayer(&nID, pRedirector, nullptr); } } } @@ -637,24 +637,24 @@ void SdrPageView::SetPageOrigin(const Point& rOrg) void SdrPageView::ImpInvalidateHelpLineArea(sal_uInt16 nNum) const { - if (GetView().IsHlplVisible() && nNumOutputToWindow()) - { - OutputDevice& rOutDev = pCandidate->GetOutputDevice(); - tools::Rectangle aR(rHL.GetBoundRect(rOutDev)); - Size aSiz(rOutDev.PixelToLogic(Size(1,1))); - aR.AdjustLeft( -(aSiz.Width()) ); - aR.AdjustRight(aSiz.Width() ); - aR.AdjustTop( -(aSiz.Height()) ); - aR.AdjustBottom(aSiz.Height() ); - const_cast(GetView()).InvalidateOneWin(rOutDev, aR); - } + for(sal_uInt32 a(0); a < GetView().PaintWindowCount(); a++) + { + SdrPaintWindow* pCandidate = GetView().GetPaintWindow(a); + + if(pCandidate->OutputToWindow()) + { + OutputDevice& rOutDev = pCandidate->GetOutputDevice(); + tools::Rectangle aR(rHL.GetBoundRect(rOutDev)); + Size aSiz(rOutDev.PixelToLogic(Size(1,1))); + aR.AdjustLeft( -(aSiz.Width()) ); + aR.AdjustRight(aSiz.Width() ); + aR.AdjustTop( -(aSiz.Height()) ); + aR.AdjustBottom(aSiz.Height() ); + const_cast(GetView()).InvalidateOneWin(rOutDev, aR); } } } @@ -667,19 +667,20 @@ void SdrPageView::SetHelpLines(const SdrHelpLineList& rHLL) void SdrPageView::SetHelpLine(sal_uInt16 nNum, const SdrHelpLine& rNewHelpLine) { - if (nNum= aHelpLines.GetCount() || aHelpLines[nNum] == rNewHelpLine) + return; + + bool bNeedRedraw = true; + if (aHelpLines[nNum].GetKind()==rNewHelpLine.GetKind()) { + switch (rNewHelpLine.GetKind()) { + case SdrHelpLineKind::Vertical : if (aHelpLines[nNum].GetPos().X()==rNewHelpLine.GetPos().X()) bNeedRedraw = false; break; + case SdrHelpLineKind::Horizontal: if (aHelpLines[nNum].GetPos().Y()==rNewHelpLine.GetPos().Y()) bNeedRedraw = false; break; + default: break; + } // switch } + if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum); + aHelpLines[nNum]=rNewHelpLine; + if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum); } void SdrPageView::DeleteHelpLine(sal_uInt16 nNum) @@ -798,34 +799,35 @@ void SdrPageView::LeaveOneGroup() void SdrPageView::LeaveAllGroup() { - if (SdrObject* pLastGroup = GetCurrentGroup()) - { - bool bGlueInvalidate = GetView().ImpIsGlueVisible(); + SdrObject* pLastGroup = GetCurrentGroup(); + if (!pLastGroup) + return; - if(bGlueInvalidate) - GetView().GlueInvalidate(); + bool bGlueInvalidate = GetView().ImpIsGlueVisible(); - // deselect everything - GetView().UnmarkAll(); + if(bGlueInvalidate) + GetView().GlueInvalidate(); - // allocations, pCurrentGroup and pCurrentList always need to be set - SetCurrentGroupAndList(nullptr, GetPage()); + // deselect everything + GetView().UnmarkAll(); - // find and select uppermost group - while (pLastGroup->getParentSdrObjectFromSdrObject()) - pLastGroup = pLastGroup->getParentSdrObjectFromSdrObject(); + // allocations, pCurrentGroup and pCurrentList always need to be set + SetCurrentGroupAndList(nullptr, GetPage()); - if (GetView().GetSdrPageView()) - GetView().MarkObj(pLastGroup, GetView().GetSdrPageView()); + // find and select uppermost group + while (pLastGroup->getParentSdrObjectFromSdrObject()) + pLastGroup = pLastGroup->getParentSdrObjectFromSdrObject(); - GetView().AdjustMarkHdl(); + if (GetView().GetSdrPageView()) + GetView().MarkObj(pLastGroup, GetView().GetSdrPageView()); - // invalidate only when view wants to visualize group entering - InvalidateAllWin(); + GetView().AdjustMarkHdl(); - if(bGlueInvalidate) - GetView().GlueInvalidate(); - } + // invalidate only when view wants to visualize group entering + InvalidateAllWin(); + + if(bGlueInvalidate) + GetView().GlueInvalidate(); } sal_uInt16 SdrPageView::GetEnteredLevel() const diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 8a48e0a9d9be..5c34b510301f 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -146,42 +146,42 @@ void ImpSdrPdfImport::DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pAction int nPageIndex) { const int nPageCount = mpPdfDocument->getPageCount(); - if (nPageCount > 0 && nPageIndex >= 0 && nPageIndex < nPageCount) - { - // Render next page. - auto pPdfPage = mpPdfDocument->openPage(nPageIndex); - if (!pPdfPage) - return; + if (!(nPageCount > 0 && nPageIndex >= 0 && nPageIndex < nPageCount)) + return; - basegfx::B2DSize dPageSize = mpPdfDocument->getPageSize(nPageIndex); + // Render next page. + auto pPdfPage = mpPdfDocument->openPage(nPageIndex); + if (!pPdfPage) + return; - const double dPageWidth = dPageSize.getX(); - const double dPageHeight = dPageSize.getY(); + basegfx::B2DSize dPageSize = mpPdfDocument->getPageSize(nPageIndex); - SetupPageScale(dPageWidth, dPageHeight); + const double dPageWidth = dPageSize.getX(); + const double dPageHeight = dPageSize.getY(); - // Load the page text to extract it when we get text elements. - auto pTextPage = pPdfPage->getTextPage(); + SetupPageScale(dPageWidth, dPageHeight); - const int nPageObjectCount = pPdfPage->getObjectCount(); - if (pProgrInfo) - pProgrInfo->SetActionCount(nPageObjectCount); + // Load the page text to extract it when we get text elements. + auto pTextPage = pPdfPage->getTextPage(); - for (int nPageObjectIndex = 0; nPageObjectIndex < nPageObjectCount; ++nPageObjectIndex) + const int nPageObjectCount = pPdfPage->getObjectCount(); + if (pProgrInfo) + pProgrInfo->SetActionCount(nPageObjectCount); + + for (int nPageObjectIndex = 0; nPageObjectIndex < nPageObjectCount; ++nPageObjectIndex) + { + auto pPageObject = pPdfPage->getObject(nPageObjectIndex); + ImportPdfObject(pPageObject, pTextPage, nPageObjectIndex); + if (pProgrInfo && pActionsToReport) { - auto pPageObject = pPdfPage->getObject(nPageObjectIndex); - ImportPdfObject(pPageObject, pTextPage, nPageObjectIndex); - if (pProgrInfo && pActionsToReport) - { - (*pActionsToReport)++; + (*pActionsToReport)++; - if (*pActionsToReport >= 16) - { - if (!pProgrInfo->ReportActions(*pActionsToReport)) - break; + if (*pActionsToReport >= 16) + { + if (!pProgrInfo->ReportActions(*pActionsToReport)) + break; - *pActionsToReport = 0; - } + *pActionsToReport = 0; } } } @@ -392,25 +392,25 @@ void ImpSdrPdfImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr) mbFntDirty = false; } - if (pObj) - { - pObj->SetLayer(mnLayer); + if (!pObj) + return; - if (bLine) - { - pObj->SetMergedItemSet(*mpLineAttr); - } + pObj->SetLayer(mnLayer); - if (bFill) - { - pObj->SetMergedItemSet(*mpFillAttr); - } + if (bLine) + { + pObj->SetMergedItemSet(*mpLineAttr); + } - if (bText) - { - pObj->SetMergedItemSet(*mpTextAttr); - pObj->SetMergedItem(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); - } + if (bFill) + { + pObj->SetMergedItemSet(*mpFillAttr); + } + + if (bText) + { + pObj->SetMergedItemSet(*mpTextAttr); + pObj->SetMergedItem(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); } } @@ -562,63 +562,63 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale) } } - if (pObj) + if (!pObj) + return; + + // #i111954# check object for visibility + // used are SdrPathObj, SdrRectObj, SdrCircObj, SdrGrafObj + bool bVisible(false); + + if (pObj->HasLineStyle()) + { + bVisible = true; + } + + if (!bVisible && pObj->HasFillStyle()) + { + bVisible = true; + } + + if (!bVisible) { - // #i111954# check object for visibility - // used are SdrPathObj, SdrRectObj, SdrCircObj, SdrGrafObj - bool bVisible(false); + SdrTextObj* pTextObj = dynamic_cast(pObj); - if (pObj->HasLineStyle()) + if (pTextObj && pTextObj->HasText()) { bVisible = true; } + } + + if (!bVisible) + { + SdrGrafObj* pGrafObj = dynamic_cast(pObj); - if (!bVisible && pObj->HasFillStyle()) + if (pGrafObj) { + // this may be refined to check if the graphic really is visible. It + // is here to ensure that graphic objects without fill, line and text + // get created bVisible = true; } + } - if (!bVisible) - { - SdrTextObj* pTextObj = dynamic_cast(pObj); - - if (pTextObj && pTextObj->HasText()) - { - bVisible = true; - } - } + if (!bVisible) + { + SdrObject::Free(pObj); + } + else + { + maTmpList.push_back(pObj); - if (!bVisible) + if (dynamic_cast(pObj)) { - SdrGrafObj* pGrafObj = dynamic_cast(pObj); + const bool bClosed(pObj->IsClosedObj()); - if (pGrafObj) - { - // this may be refined to check if the graphic really is visible. It - // is here to ensure that graphic objects without fill, line and text - // get created - bVisible = true; - } - } - - if (!bVisible) - { - SdrObject::Free(pObj); + mbLastObjWasPolyWithoutLine = mbNoLine && bClosed; } else { - maTmpList.push_back(pObj); - - if (dynamic_cast(pObj)) - { - const bool bClosed(pObj->IsClosedObj()); - - mbLastObjWasPolyWithoutLine = mbNoLine && bClosed; - } - else - { - mbLastObjWasPolyWithoutLine = false; - } + mbLastObjWasPolyWithoutLine = false; } } } diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index 6e931e7f4504..f34e7c10f942 100644 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -765,22 +765,22 @@ vcl::Region SdrPaintView::OptimizeDrawLayersRegion(OutputDevice* pOut, const vcl void SdrPaintView::ImpFormLayerDrawing( SdrPaintWindow& rPaintWindow ) { - if(mpPageView) - { - SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(rPaintWindow); + if(!mpPageView) + return; - if(pKnownTarget) - { - const SdrModel& rModel = *(GetModel()); - const SdrLayerAdmin& rLayerAdmin = rModel.GetLayerAdmin(); - const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID(rLayerAdmin.GetControlLayerName()); + SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(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->setPreparedPageWindow(nullptr); - } + if(pKnownTarget) + { + const SdrModel& rModel = *(GetModel()); + const SdrLayerAdmin& rLayerAdmin = rModel.GetLayerAdmin(); + const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID(rLayerAdmin.GetControlLayerName()); + + // 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->setPreparedPageWindow(nullptr); } } @@ -1076,23 +1076,23 @@ void SdrPaintView::SetAnimationEnabled( bool bEnable ) void SdrPaintView::SetAnimationPause( bool bSet ) { - if(mbAnimationPause != bSet) + if(mbAnimationPause == bSet) + return; + + mbAnimationPause = bSet; + + if(!mpPageView) + return; + + for(sal_uInt32 b(0); b < mpPageView->PageWindowCount(); b++) { - mbAnimationPause = bSet; + SdrPageWindow& rPageWindow = *(mpPageView->GetPageWindow(b)); + sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact(); + sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator(); - if(mpPageView) + if(rAnimator.IsPaused() != bSet) { - for(sal_uInt32 b(0); b < mpPageView->PageWindowCount(); b++) - { - SdrPageWindow& rPageWindow = *(mpPageView->GetPageWindow(b)); - sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact(); - sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator(); - - if(rAnimator.IsPaused() != bSet) - { - rAnimator.SetPaused(bSet); - } - } + rAnimator.SetPaused(bSet); } } } @@ -1104,22 +1104,22 @@ void SdrPaintView::SetAnimationMode( const SdrAnimationMode eMode ) void SdrPaintView::VisAreaChanged(const OutputDevice* pOut) { - if(mpPageView) + if(!mpPageView) + return; + + if (pOut) { - if (pOut) - { - SdrPageWindow* pWindow = mpPageView->FindPageWindow(*const_cast(pOut)); + SdrPageWindow* pWindow = mpPageView->FindPageWindow(*const_cast(pOut)); - if(pWindow) - { - VisAreaChanged(); - } - } - else + if(pWindow) { VisAreaChanged(); } } + else + { + VisAreaChanged(); + } } void SdrPaintView::VisAreaChanged() diff --git a/svx/source/svdraw/svdpoev.cxx b/svx/source/svdraw/svdpoev.cxx index 117aa71f701b..cd077e4eb8be 100644 --- a/svx/source/svdraw/svdpoev.cxx +++ b/svx/source/svdraw/svdpoev.cxx @@ -62,20 +62,20 @@ void SdrPolyEditView::ImpCheckPolyPossibilities() ImpResetPolyPossibilityFlags(); const size_t nMarkCount(GetMarkedObjectCount()); - if(nMarkCount && !ImpIsFrameHandles()) + if(!(nMarkCount && !ImpIsFrameHandles())) + return; + + bool b1stSmooth(true); + bool b1stSegm(true); + bool bCurve(false); + bool bSmoothFuz(false); + bool bSegmFuz(false); + basegfx::B2VectorContinuity eSmooth = basegfx::B2VectorContinuity::NONE; + + for(size_t nMarkNum = 0; nMarkNum < nMarkCount; ++nMarkNum) { - bool b1stSmooth(true); - bool b1stSegm(true); - bool bCurve(false); - bool bSmoothFuz(false); - bool bSegmFuz(false); - basegfx::B2VectorContinuity eSmooth = basegfx::B2VectorContinuity::NONE; - - for(size_t nMarkNum = 0; nMarkNum < nMarkCount; ++nMarkNum) - { - SdrMark* pM = GetSdrMarkByIndex(nMarkNum); - CheckPolyPossibilitiesHelper( pM, b1stSmooth, b1stSegm, bCurve, bSmoothFuz, bSegmFuz, eSmooth ); - } + SdrMark* pM = GetSdrMarkByIndex(nMarkNum); + CheckPolyPossibilitiesHelper( pM, b1stSmooth, b1stSegm, bCurve, bSmoothFuz, bSegmFuz, eSmooth ); } } @@ -189,69 +189,69 @@ void SdrPolyEditView::SetMarkedPointsSmooth(SdrPathSmoothKind eKind) return; } - if(HasMarkedPoints()) - { - SortMarkedObjects(); + if(!HasMarkedPoints()) + return; - const bool bUndo = IsUndoEnabled(); - if( bUndo ) - BegUndo(SvxResId(STR_EditSetPointsSmooth), GetDescriptionOfMarkedPoints()); - const size_t nMarkCount(GetMarkedObjectCount()); + SortMarkedObjects(); + + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(SvxResId(STR_EditSetPointsSmooth), GetDescriptionOfMarkedPoints()); + const size_t nMarkCount(GetMarkedObjectCount()); - for(size_t nMarkNum(nMarkCount); nMarkNum > 0;) + for(size_t nMarkNum(nMarkCount); nMarkNum > 0;) + { + --nMarkNum; + SdrMark* pM = GetSdrMarkByIndex(nMarkNum); + SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() ); + if (!pPath) + continue; + + SdrUShortCont& rPts = pM->GetMarkedPoints(); + PolyPolygonEditor aEditor(pPath->GetPathPoly()); + if (aEditor.SetPointsSmooth(eFlags, rPts)) { - --nMarkNum; - SdrMark* pM = GetSdrMarkByIndex(nMarkNum); - SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() ); - if (!pPath) - continue; - - SdrUShortCont& rPts = pM->GetMarkedPoints(); - PolyPolygonEditor aEditor(pPath->GetPathPoly()); - if (aEditor.SetPointsSmooth(eFlags, rPts)) - { - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath)); - pPath->SetPathPoly(aEditor.GetPolyPolygon()); - } + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath)); + pPath->SetPathPoly(aEditor.GetPolyPolygon()); } - - if( bUndo ) - EndUndo(); } + + if( bUndo ) + EndUndo(); } void SdrPolyEditView::SetMarkedSegmentsKind(SdrPathSegmentKind eKind) { - if(HasMarkedPoints()) - { - SortMarkedObjects(); + if(!HasMarkedPoints()) + return; - const bool bUndo = IsUndoEnabled(); - if( bUndo ) - BegUndo(SvxResId(STR_EditSetSegmentsKind), GetDescriptionOfMarkedPoints()); - const size_t nMarkCount(GetMarkedObjectCount()); + SortMarkedObjects(); + + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(SvxResId(STR_EditSetSegmentsKind), GetDescriptionOfMarkedPoints()); + const size_t nMarkCount(GetMarkedObjectCount()); - for(size_t nMarkNum=nMarkCount; nMarkNum > 0;) + for(size_t nMarkNum=nMarkCount; nMarkNum > 0;) + { + --nMarkNum; + SdrMark* pM = GetSdrMarkByIndex(nMarkNum); + SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() ); + if (!pPath) + continue; + SdrUShortCont& rPts = pM->GetMarkedPoints(); + PolyPolygonEditor aEditor( pPath->GetPathPoly()); + if (aEditor.SetSegmentsKind(eKind, rPts)) { - --nMarkNum; - SdrMark* pM = GetSdrMarkByIndex(nMarkNum); - SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() ); - if (!pPath) - continue; - SdrUShortCont& rPts = pM->GetMarkedPoints(); - PolyPolygonEditor aEditor( pPath->GetPathPoly()); - if (aEditor.SetSegmentsKind(eKind, rPts)) - { - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath)); - pPath->SetPathPoly(aEditor.GetPolyPolygon()); - } + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath)); + pPath->SetPathPoly(aEditor.GetPolyPolygon()); } - - if( bUndo ) - EndUndo(); } + + if( bUndo ) + EndUndo(); } bool SdrPolyEditView::IsSetMarkedPointsSmoothPossible() const @@ -285,131 +285,131 @@ bool SdrPolyEditView::IsDeleteMarkedPointsPossible() const void SdrPolyEditView::DeleteMarkedPoints() { - if (HasMarkedPoints()) + if (!HasMarkedPoints()) + return; + + BrkAction(); + SortMarkedObjects(); + const size_t nMarkCount=GetMarkedObjectCount(); + + const bool bUndo = IsUndoEnabled(); + if( bUndo ) { - BrkAction(); - SortMarkedObjects(); - const size_t nMarkCount=GetMarkedObjectCount(); + // Description + BegUndo(SvxResId(STR_EditDelete),GetDescriptionOfMarkedPoints(),SdrRepeatFunc::Delete); + } - const bool bUndo = IsUndoEnabled(); - if( bUndo ) - { - // Description - BegUndo(SvxResId(STR_EditDelete),GetDescriptionOfMarkedPoints(),SdrRepeatFunc::Delete); - } + for (size_t nMarkNum=nMarkCount; nMarkNum>0;) + { + --nMarkNum; + SdrMark* pM=GetSdrMarkByIndex(nMarkNum); + SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() ); + if (!pPath) + continue; - for (size_t nMarkNum=nMarkCount; nMarkNum>0;) + SdrUShortCont& rPts = pM->GetMarkedPoints(); + PolyPolygonEditor aEditor( pPath->GetPathPoly()); + if (aEditor.DeletePoints(rPts)) { - --nMarkNum; - SdrMark* pM=GetSdrMarkByIndex(nMarkNum); - SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() ); - if (!pPath) - continue; - - SdrUShortCont& rPts = pM->GetMarkedPoints(); - PolyPolygonEditor aEditor( pPath->GetPathPoly()); - if (aEditor.DeletePoints(rPts)) + if( aEditor.GetPolyPolygon().count() ) { - if( aEditor.GetPolyPolygon().count() ) - { - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath )); - pPath->SetPathPoly( aEditor.GetPolyPolygon() ); - } - else + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath )); + pPath->SetPathPoly( aEditor.GetPolyPolygon() ); + } + else + { + if( bUndo ) + AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pPath ) ); + pM->GetPageView()->GetObjList()->RemoveObject(pPath->GetOrdNum()); + if( !bUndo ) { - if( bUndo ) - AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pPath ) ); - pM->GetPageView()->GetObjList()->RemoveObject(pPath->GetOrdNum()); - if( !bUndo ) - { - SdrObject* pObj = pPath; - SdrObject::Free(pObj); - } + SdrObject* pObj = pPath; + SdrObject::Free(pObj); } } } - - if( bUndo ) - EndUndo(); - UnmarkAllPoints(); - MarkListHasChanged(); } + + if( bUndo ) + EndUndo(); + UnmarkAllPoints(); + MarkListHasChanged(); } void SdrPolyEditView::RipUpAtMarkedPoints() { - if(HasMarkedPoints()) + if(!HasMarkedPoints()) + return; + + SortMarkedObjects(); + const size_t nMarkCount(GetMarkedObjectCount()); + + const bool bUndo = IsUndoEnabled(); + if( bUndo ) + BegUndo(SvxResId(STR_EditRipUp), GetDescriptionOfMarkedPoints()); + + for(size_t nMarkNum = nMarkCount; nMarkNum > 0;) { - SortMarkedObjects(); - const size_t nMarkCount(GetMarkedObjectCount()); + --nMarkNum; + SdrMark* pM = GetSdrMarkByIndex(nMarkNum); + SdrPathObj* pObj = dynamic_cast( pM->GetMarkedSdrObj() ); + if (!pObj) + continue; + + SdrUShortCont& rPts = pM->GetMarkedPoints(); - const bool bUndo = IsUndoEnabled(); if( bUndo ) - BegUndo(SvxResId(STR_EditRipUp), GetDescriptionOfMarkedPoints()); + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + bool bCorrectionFlag(false); + sal_uInt32 nMax(pObj->GetHdlCount()); - for(size_t nMarkNum = nMarkCount; nMarkNum > 0;) + for(SdrUShortCont::const_reverse_iterator it = rPts.rbegin(); it != rPts.rend(); ++it) { - --nMarkNum; - SdrMark* pM = GetSdrMarkByIndex(nMarkNum); - SdrPathObj* pObj = dynamic_cast( pM->GetMarkedSdrObj() ); - if (!pObj) - continue; - - SdrUShortCont& rPts = pM->GetMarkedPoints(); + sal_uInt32 nNewPt0Idx(0); + SdrObject* pNewObj = pObj->RipPoint(*it, nNewPt0Idx); - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); - bool bCorrectionFlag(false); - sal_uInt32 nMax(pObj->GetHdlCount()); - - for(SdrUShortCont::const_reverse_iterator it = rPts.rbegin(); it != rPts.rend(); ++it) + if(pNewObj) { - sal_uInt32 nNewPt0Idx(0); - SdrObject* pNewObj = pObj->RipPoint(*it, nNewPt0Idx); + pM->GetPageView()->GetObjList()->InsertObject(pNewObj, pObj->GetOrdNum() + 1); + if( bUndo ) + AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNewObj)); + MarkObj(pNewObj, pM->GetPageView(), false, true); + } - if(pNewObj) + if(nNewPt0Idx) + { + // correction necessary? + DBG_ASSERT(!bCorrectionFlag,"Multiple index corrections at SdrPolyEditView::RipUp()."); + if(!bCorrectionFlag) { - pM->GetPageView()->GetObjList()->InsertObject(pNewObj, pObj->GetOrdNum() + 1); - if( bUndo ) - AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNewObj)); - MarkObj(pNewObj, pM->GetPageView(), false, true); - } + bCorrectionFlag = true; - if(nNewPt0Idx) - { - // correction necessary? - DBG_ASSERT(!bCorrectionFlag,"Multiple index corrections at SdrPolyEditView::RipUp()."); - if(!bCorrectionFlag) + SdrUShortCont aReplaceSet; + for(const auto& rPt : rPts) { - bCorrectionFlag = true; + sal_uInt32 nPntNum(rPt); + nPntNum += nNewPt0Idx; - SdrUShortCont aReplaceSet; - for(const auto& rPt : rPts) + if(nPntNum >= nMax) { - sal_uInt32 nPntNum(rPt); - nPntNum += nNewPt0Idx; - - if(nPntNum >= nMax) - { - nPntNum -= nMax; - } - - aReplaceSet.insert( static_cast(nPntNum) ); + nPntNum -= nMax; } - rPts.swap(aReplaceSet); - it = rPts.rbegin(); + aReplaceSet.insert( static_cast(nPntNum) ); } + rPts.swap(aReplaceSet); + + it = rPts.rbegin(); } } } - - UnmarkAllPoints(); - if( bUndo ) - EndUndo(); - MarkListHasChanged(); } + + UnmarkAllPoints(); + if( bUndo ) + EndUndo(); + MarkListHasChanged(); } bool SdrPolyEditView::IsRipUpAtMarkedPointsPossible() const diff --git a/svx/source/svdraw/svdsnpv.cxx b/svx/source/svdraw/svdsnpv.cxx index 1fd9ac204fbe..2bb9527b63b4 100644 --- a/svx/source/svdraw/svdsnpv.cxx +++ b/svx/source/svdraw/svdsnpv.cxx @@ -72,23 +72,23 @@ ImplPageOriginOverlay::ImplPageOriginOverlay(const SdrPaintView& rView, const ba void ImplPageOriginOverlay::SetPosition(const basegfx::B2DPoint& rNewPosition) { - if(rNewPosition != maPosition) + if(rNewPosition == maPosition) + return; + + // apply to OverlayObjects + for(sal_uInt32 a(0); a < maObjects.count(); a++) { - // apply to OverlayObjects - for(sal_uInt32 a(0); a < maObjects.count(); a++) - { - sdr::overlay::OverlayCrosshairStriped* pCandidate = - static_cast< sdr::overlay::OverlayCrosshairStriped* >(&maObjects.getOverlayObject(a)); + sdr::overlay::OverlayCrosshairStriped* pCandidate = + static_cast< sdr::overlay::OverlayCrosshairStriped* >(&maObjects.getOverlayObject(a)); - if(pCandidate) - { - pCandidate->setBasePosition(rNewPosition); - } + if(pCandidate) + { + pCandidate->setBasePosition(rNewPosition); } - - // remember new position - maPosition = rNewPosition; } + + // remember new position + maPosition = rNewPosition; } @@ -146,23 +146,23 @@ ImplHelpLineOverlay::ImplHelpLineOverlay( void ImplHelpLineOverlay::SetPosition(const basegfx::B2DPoint& rNewPosition) { - if(rNewPosition != maPosition) + if(rNewPosition == maPosition) + return; + + // apply to OverlayObjects + for(sal_uInt32 a(0); a < maObjects.count(); a++) { - // apply to OverlayObjects - for(sal_uInt32 a(0); a < maObjects.count(); a++) - { - sdr::overlay::OverlayHelplineStriped* pCandidate = - static_cast< sdr::overlay::OverlayHelplineStriped* >(&maObjects.getOverlayObject(a)); + sdr::overlay::OverlayHelplineStriped* pCandidate = + static_cast< sdr::overlay::OverlayHelplineStriped* >(&maObjects.getOverlayObject(a)); - if(pCandidate) - { - pCandidate->setBasePosition(rNewPosition); - } + if(pCandidate) + { + pCandidate->setBasePosition(rNewPosition); } - - // remember new position - maPosition = rNewPosition; } + + // remember new position + maPosition = rNewPosition; } SdrSnapView::SdrSnapView( @@ -460,19 +460,19 @@ void SdrSnapView::MovSetPageOrg(const Point& rPnt) void SdrSnapView::EndSetPageOrg() { - if(IsSetPageOrg()) - { - SdrPageView* pPV = GetSdrPageView(); + if(!IsSetPageOrg()) + return; - if(pPV) - { - Point aPnt(maDragStat.GetNow()); - pPV->SetPageOrigin(aPnt); - } + SdrPageView* pPV = GetSdrPageView(); - // cleanup - BrkSetPageOrg(); + if(pPV) + { + Point aPnt(maDragStat.GetNow()); + pPV->SetPageOrigin(aPnt); } + + // cleanup + BrkSetPageOrg(); } void SdrSnapView::BrkSetPageOrg() diff --git a/svx/source/svdraw/svdtext.cxx b/svx/source/svdraw/svdtext.cxx index 1d5b3be5b240..163453c0882f 100644 --- a/svx/source/svdraw/svdtext.cxx +++ b/svx/source/svdraw/svdtext.cxx @@ -40,21 +40,21 @@ SdrText::~SdrText() void SdrText::CheckPortionInfo( SdrOutliner& rOutliner ) { - if(!mbPortionInfoChecked) + if(mbPortionInfoChecked) + return; + + // #i102062# no action when the Outliner is the HitTestOutliner, + // this will remove WrongList info at the OPO + if(&rOutliner == &mrObject.getSdrModelFromSdrObject().GetHitTestOutliner()) + return; + + // TODO: optimization: we could create a BigTextObject + mbPortionInfoChecked=true; + + if(mpOutlinerParaObject!=nullptr && rOutliner.ShouldCreateBigTextObject()) { - // #i102062# no action when the Outliner is the HitTestOutliner, - // this will remove WrongList info at the OPO - if(&rOutliner == &mrObject.getSdrModelFromSdrObject().GetHitTestOutliner()) - return; - - // TODO: optimization: we could create a BigTextObject - mbPortionInfoChecked=true; - - if(mpOutlinerParaObject!=nullptr && rOutliner.ShouldCreateBigTextObject()) - { - // #i102062# MemoryLeak closed - mpOutlinerParaObject = rOutliner.CreateParaObject(); - } + // #i102062# MemoryLeak closed + mpOutlinerParaObject = rOutliner.CreateParaObject(); } } @@ -109,20 +109,20 @@ std::unique_ptr SdrText::RemoveOutlinerParaObject() void SdrText::ForceOutlinerParaObject( OutlinerMode nOutlMode ) { - if(!mpOutlinerParaObject) + if(mpOutlinerParaObject) + return; + + std::unique_ptr pOutliner( + SdrMakeOutliner( + nOutlMode, + mrObject.getSdrModelFromSdrObject())); + + if(pOutliner) { - std::unique_ptr pOutliner( - SdrMakeOutliner( - nOutlMode, - mrObject.getSdrModelFromSdrObject())); - - if(pOutliner) - { - Outliner& aDrawOutliner(mrObject.getSdrModelFromSdrObject().GetDrawOutliner()); - pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() ); - pOutliner->SetStyleSheet( 0, GetStyleSheet()); - SetOutlinerParaObject( pOutliner->CreateParaObject() ); - } + Outliner& aDrawOutliner(mrObject.getSdrModelFromSdrObject().GetDrawOutliner()); + pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() ); + pOutliner->SetStyleSheet( 0, GetStyleSheet()); + SetOutlinerParaObject( pOutliner->CreateParaObject() ); } } diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx index 980dbc970874..0cbb447f1a91 100644 --- a/svx/source/svdraw/svdundo.cxx +++ b/svx/source/svdraw/svdundo.cxx @@ -266,19 +266,19 @@ SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSave } } - if(!bIsGroup || bIs3DScene) - { - pUndoSet.reset( new SfxItemSet(pObj->GetMergedItemSet()) ); + if(bIsGroup && !bIs3DScene) + return; - if(bStyleSheet) - mxUndoStyleSheet = pObj->GetStyleSheet(); + pUndoSet.reset( new SfxItemSet(pObj->GetMergedItemSet()) ); - if(bSaveText) - { - auto p = pObj->GetOutlinerParaObject(); - if(p) - pTextUndo.reset( new OutlinerParaObject(*p) ); - } + if(bStyleSheet) + mxUndoStyleSheet = pObj->GetStyleSheet(); + + if(bSaveText) + { + auto p = pObj->GetOutlinerParaObject(); + if(p) + pTextUndo.reset( new OutlinerParaObject(*p) ); } } @@ -669,26 +669,26 @@ void SdrUndoRemoveObj::Undo() ImpShowPageOfThisObject(); DBG_ASSERT(!pObj->IsInserted(),"UndoRemoveObj: pObj has already been inserted."); - if (!pObj->IsInserted()) - { - // #i11426# - // For UNDOs in Calc/Writer it is necessary to adapt the anchor - // position of the target object. - Point aOwnerAnchorPos(0, 0); + if (pObj->IsInserted()) + return; - if (dynamic_cast< const SdrObjGroup* >(pObjList->getSdrObjectFromSdrObjList()) != nullptr) - { - aOwnerAnchorPos = pObjList->getSdrObjectFromSdrObjList()->GetAnchorPos(); - } + // #i11426# + // For UNDOs in Calc/Writer it is necessary to adapt the anchor + // position of the target object. + Point aOwnerAnchorPos(0, 0); - E3DModifySceneSnapRectUpdater aUpdater(pObjList->getSdrObjectFromSdrObjList()); - pObjList->InsertObject(pObj,nOrdNum); + if (dynamic_cast< const SdrObjGroup* >(pObjList->getSdrObjectFromSdrObjList()) != nullptr) + { + aOwnerAnchorPos = pObjList->getSdrObjectFromSdrObjList()->GetAnchorPos(); + } - // #i11426# - if(aOwnerAnchorPos.X() || aOwnerAnchorPos.Y()) - { - pObj->NbcSetAnchorPos(aOwnerAnchorPos); - } + E3DModifySceneSnapRectUpdater aUpdater(pObjList->getSdrObjectFromSdrObjList()); + pObjList->InsertObject(pObj,nOrdNum); + + // #i11426# + if(aOwnerAnchorPos.X() || aOwnerAnchorPos.Y()) + { + pObj->NbcSetAnchorPos(aOwnerAnchorPos); } } @@ -1093,37 +1093,37 @@ OUString SdrUndoObjSetText::GetSdrRepeatComment() const void SdrUndoObjSetText::SdrRepeat(SdrView& rView) { - if (bNewTextAvailable && rView.AreObjectsMarked()) - { - const SdrMarkList& rML=rView.GetMarkedObjectList(); + if (!(bNewTextAvailable && rView.AreObjectsMarked())) + return; - const bool bUndo = rView.IsUndoEnabled(); - if( bUndo ) - { - OUString aStr = ImpGetDescriptionStr(STR_UndoObjSetText); - rView.BegUndo(aStr); - } + const SdrMarkList& rML=rView.GetMarkedObjectList(); + + const bool bUndo = rView.IsUndoEnabled(); + if( bUndo ) + { + OUString aStr = ImpGetDescriptionStr(STR_UndoObjSetText); + rView.BegUndo(aStr); + } - const size_t nCount=rML.GetMarkCount(); - for (size_t nm=0; nmGetMarkedSdrObj(); + SdrTextObj* pTextObj=dynamic_cast( pObj2 ); + if (pTextObj!=nullptr) { - SdrObject* pObj2=rML.GetMark(nm)->GetMarkedSdrObj(); - SdrTextObj* pTextObj=dynamic_cast( pObj2 ); - if (pTextObj!=nullptr) - { - if( bUndo ) - rView.AddUndo(std::make_unique(*pTextObj,0)); + if( bUndo ) + rView.AddUndo(std::make_unique(*pTextObj,0)); - std::unique_ptr pText1; - if (pNewText) - pText1.reset(new OutlinerParaObject(*pNewText)); - pTextObj->SetOutlinerParaObject(std::move(pText1)); - } + std::unique_ptr pText1; + if (pNewText) + pText1.reset(new OutlinerParaObject(*pNewText)); + pTextObj->SetOutlinerParaObject(std::move(pText1)); } - - if( bUndo ) - rView.EndUndo(); } + + if( bUndo ) + rView.EndUndo(); } bool SdrUndoObjSetText::CanSdrRepeat(SdrView& rView) const @@ -1289,19 +1289,19 @@ void SdrUndoPage::ImpInsertPage(sal_uInt16 nNum) void SdrUndoPage::ImpRemovePage(sal_uInt16 nNum) { DBG_ASSERT(mrPage.IsInserted(),"SdrUndoPage::ImpRemovePage(): mrPage is not inserted."); - if (mrPage.IsInserted()) + if (!mrPage.IsInserted()) + return; + + SdrPage* pChkPg=nullptr; + if (mrPage.IsMasterPage()) { - SdrPage* pChkPg=nullptr; - if (mrPage.IsMasterPage()) - { - pChkPg=rMod.RemoveMasterPage(nNum); - } - else - { - pChkPg=rMod.RemovePage(nNum); - } - DBG_ASSERT(pChkPg==&mrPage,"SdrUndoPage::ImpRemovePage(): RemovePage!=&mrPage"); + pChkPg=rMod.RemoveMasterPage(nNum); } + else + { + pChkPg=rMod.RemovePage(nNum); + } + DBG_ASSERT(pChkPg==&mrPage,"SdrUndoPage::ImpRemovePage(): RemovePage!=&mrPage"); } void SdrUndoPage::ImpMovePage(sal_uInt16 nOldNum, sal_uInt16 nNewNum) @@ -1363,27 +1363,27 @@ SdrUndoDelPage::SdrUndoDelPage(SdrPage& rNewPg) clearFillBitmap(); // now remember the master page relationships - if(mrPage.IsMasterPage()) + if(!mrPage.IsMasterPage()) + return; + + sal_uInt16 nPageCnt(rMod.GetPageCount()); + + for(sal_uInt16 nPageNum2(0); nPageNum2 < nPageCnt; nPageNum2++) { - sal_uInt16 nPageCnt(rMod.GetPageCount()); + SdrPage* pDrawPage = rMod.GetPage(nPageNum2); - for(sal_uInt16 nPageNum2(0); nPageNum2 < nPageCnt; nPageNum2++) + if(pDrawPage->TRG_HasMasterPage()) { - SdrPage* pDrawPage = rMod.GetPage(nPageNum2); + SdrPage& rMasterPage = pDrawPage->TRG_GetMasterPage(); - if(pDrawPage->TRG_HasMasterPage()) + if(&mrPage == &rMasterPage) { - SdrPage& rMasterPage = pDrawPage->TRG_GetMasterPage(); - - if(&mrPage == &rMasterPage) + if(!pUndoGroup) { - if(!pUndoGroup) - { - pUndoGroup.reset( new SdrUndoGroup(rMod) ); - } - - pUndoGroup->AddAction(rMod.GetSdrUndoFactory().CreateUndoPageRemoveMasterPage(*pDrawPage)); + pUndoGroup.reset( new SdrUndoGroup(rMod) ); } + + pUndoGroup->AddAction(rMod.GetSdrUndoFactory().CreateUndoPageRemoveMasterPage(*pDrawPage)); } } } diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx index 33cf89ab82c8..95869b217b07 100644 --- a/svx/source/svdraw/svdview.cxx +++ b/svx/source/svdraw/svdview.cxx @@ -1424,29 +1424,29 @@ void SdrView::onAccessibilityOptionsChanged() void SdrView::SetMasterPagePaintCaching(bool bOn) { - if(mbMasterPagePaintCaching != bOn) - { - mbMasterPagePaintCaching = bOn; + if(mbMasterPagePaintCaching == bOn) + return; - // reset at all SdrPageWindows - SdrPageView* pPageView = GetSdrPageView(); + mbMasterPagePaintCaching = bOn; - if(pPageView) - { - for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) - { - SdrPageWindow* pPageWindow = pPageView->GetPageWindow(b); - assert(pPageWindow && "SdrView::SetMasterPagePaintCaching: Corrupt SdrPageWindow list (!)"); + // reset at all SdrPageWindows + SdrPageView* pPageView = GetSdrPageView(); - // force deletion of ObjectContact, so at re-display all VOCs - // will be re-created with updated flag setting - pPageWindow->ResetObjectContact(); - } + if(!pPageView) + return; - // force redraw of this view - pPageView->InvalidateAllWin(); - } + for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++) + { + SdrPageWindow* pPageWindow = pPageView->GetPageWindow(b); + assert(pPageWindow && "SdrView::SetMasterPagePaintCaching: Corrupt SdrPageWindow list (!)"); + + // force deletion of ObjectContact, so at re-display all VOCs + // will be re-created with updated flag setting + pPageWindow->ResetObjectContact(); } + + // force redraw of this view + pPageView->InvalidateAllWin(); } // Default ObjectContact is ObjectContactOfPageView -- cgit