diff options
Diffstat (limited to 'svx/source/sdr')
21 files changed, 162 insertions, 127 deletions
diff --git a/svx/source/sdr/contact/objectcontact.cxx b/svx/source/sdr/contact/objectcontact.cxx index a4d52073dfa1..33839d8c83f0 100644 --- a/svx/source/sdr/contact/objectcontact.cxx +++ b/svx/source/sdr/contact/objectcontact.cxx @@ -31,6 +31,26 @@ using namespace com::sun::star; namespace sdr { namespace contact { +bool ObjectContact::supportsGridOffsets() const +{ + // default does not support GridOffset + return false; +} + +void ObjectContact::calculateGridOffsetForViewOjectContact( + basegfx::B2DVector& /*rTarget*/, + const ViewObjectContact& /*rClient*/) const +{ + // default does not on-demand calculate GridOffset +} + +void ObjectContact::calculateGridOffsetForB2DRange( + basegfx::B2DVector& /*rTarget*/, + const basegfx::B2DRange& /*rB2DRange*/) const +{ + // default does not on-demand calculate GridOffset +} + ObjectContact::ObjectContact() : maViewObjectContactVector(), maPrimitiveAnimator(), @@ -209,6 +229,18 @@ void ObjectContact::resetViewPort() } } +void ObjectContact::resetAllGridOffsets() +{ + const sal_uInt32 nVOCCount(getViewObjectContactCount()); + + for(sal_uInt32 a(0); a < nVOCCount; a++) + { + ViewObjectContact* pVOC(getViewObjectContact(a)); + assert(pVOC && "ObjectContact: ViewObjectContact list Corrupt (!)"); + pVOC->resetGridOffset(); + } +} + }} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/contact/objectcontactofpageview.cxx b/svx/source/sdr/contact/objectcontactofpageview.cxx index 6a2247bcd6c2..0c6ecf0abc3a 100644 --- a/svx/source/sdr/contact/objectcontactofpageview.cxx +++ b/svx/source/sdr/contact/objectcontactofpageview.cxx @@ -19,7 +19,7 @@ #include <config_features.h> -#include <sdr/contact/objectcontactofpageview.hxx> +#include <svx/sdr/contact/objectcontactofpageview.hxx> #include <sdr/contact/viewobjectcontactofunocontrol.hxx> #include <svx/svdpagv.hxx> #include <svx/svdpage.hxx> diff --git a/svx/source/sdr/contact/viewcontact.cxx b/svx/source/sdr/contact/viewcontact.cxx index 0567ff65c473..178c50f22bc1 100644 --- a/svx/source/sdr/contact/viewcontact.cxx +++ b/svx/source/sdr/contact/viewcontact.cxx @@ -25,7 +25,7 @@ #include <basegfx/color/bcolor.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> -#include <sdr/contact/objectcontactofpageview.hxx> +#include <svx/sdr/contact/objectcontactofpageview.hxx> #include <tools/debug.hxx> namespace sdr { namespace contact { diff --git a/svx/source/sdr/contact/viewcontactofe3dscene.cxx b/svx/source/sdr/contact/viewcontactofe3dscene.cxx index 591db03619fb..86ca5f0ed09c 100644 --- a/svx/source/sdr/contact/viewcontactofe3dscene.cxx +++ b/svx/source/sdr/contact/viewcontactofe3dscene.cxx @@ -244,11 +244,8 @@ void ViewContactOfE3dScene::createViewInformation3D(const basegfx::B3DRange& rCo void ViewContactOfE3dScene::createObjectTransformation() { // create 2d Object Transformation from relative point in 2d scene to world - tools::Rectangle aRectangle = GetE3dScene().GetSnapRect(); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - aRectangle += GetE3dScene().GetGridOffset(); + const tools::Rectangle aRectangle(GetE3dScene().GetSnapRect()); + maObjectTransformation.set(0, 0, aRectangle.getWidth()); maObjectTransformation.set(1, 1, aRectangle.getHeight()); maObjectTransformation.set(0, 2, aRectangle.Left()); diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx index 15de4be75752..2892b3e63eff 100644 --- a/svx/source/sdr/contact/viewcontactofgraphic.cxx +++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx @@ -310,14 +310,10 @@ namespace sdr // take unrotated snap rect for position and size. Directly use model data, not getBoundRect() or getSnapRect() // which will use the primitive data we just create in the near future - tools::Rectangle rRectangle = GetGrafObject().GetGeoRect(); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - rRectangle += GetGrafObject().GetGridOffset(); + const tools::Rectangle aRectangle(GetGrafObject().GetGeoRect()); const ::basegfx::B2DRange aObjectRange( - rRectangle.Left(), rRectangle.Top(), - rRectangle.Right(), rRectangle.Bottom()); + aRectangle.Left(), aRectangle.Top(), + aRectangle.Right(), aRectangle.Bottom()); // look for mirroring const GeoStat& rGeoStat(GetGrafObject().GetGeoStat()); diff --git a/svx/source/sdr/contact/viewcontactofgroup.cxx b/svx/source/sdr/contact/viewcontactofgroup.cxx index d6a0e98dfcfe..38afca26ff65 100644 --- a/svx/source/sdr/contact/viewcontactofgroup.cxx +++ b/svx/source/sdr/contact/viewcontactofgroup.cxx @@ -71,11 +71,7 @@ namespace sdr else { // append an invisible outline for the cases where no visible content exists - tools::Rectangle aCurrentBoundRect(GetSdrObjGroup().GetLastBoundRect()); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - aCurrentBoundRect += GetSdrObjGroup().GetGridOffset(); + const tools::Rectangle aCurrentBoundRect(GetSdrObjGroup().GetLastBoundRect()); const basegfx::B2DRange aCurrentRange( aCurrentBoundRect.Left(), aCurrentBoundRect.Top(), aCurrentBoundRect.Right(), aCurrentBoundRect.Bottom()); diff --git a/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx b/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx index 7fc5effd6cf3..8fe42c1fa6de 100644 --- a/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx @@ -63,16 +63,10 @@ namespace sdr false)); // take unrotated snap rect (direct model data) for position and size - tools::Rectangle rRectangle = rCaptionObj.GetGeoRect(); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - Point aGridOff = rCaptionObj.GetGridOffset(); - rRectangle += aGridOff; - + const tools::Rectangle aRectangle(rCaptionObj.GetGeoRect()); const ::basegfx::B2DRange aObjectRange( - rRectangle.Left(), rRectangle.Top(), - rRectangle.Right(), rRectangle.Bottom()); + aRectangle.Left(), aRectangle.Top(), + aRectangle.Right(), aRectangle.Bottom()); const GeoStat& rGeoStat(rCaptionObj.GetGeoStat()); // fill object matrix @@ -87,11 +81,8 @@ namespace sdr double fCornerRadiusY; drawinglayer::primitive2d::calculateRelativeCornerRadius( rCaptionObj.GetEckenradius(), aObjectRange, fCornerRadiusX, fCornerRadiusY); - ::basegfx::B2DPolygon aTail = rCaptionObj.getTailPolygon(); - // Hack for calc, transform position of tail according - // to current zoom so as objects relative position to grid - // appears stable - aTail.transform( basegfx::utils::createTranslateB2DHomMatrix( aGridOff.X(), aGridOff.Y() ) ); + const basegfx::B2DPolygon aTail(rCaptionObj.getTailPolygon()); + // create primitive. Always create one (even if invisible) to let the decomposition // of SdrCaptionPrimitive2D create needed invisible elements for HitTest and BoundRect const drawinglayer::primitive2d::Primitive2DReference xReference( diff --git a/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx b/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx index 7104edcb227c..8d796643386d 100644 --- a/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx @@ -50,11 +50,7 @@ namespace sdr false)); // take unrotated snap rect (direct model data) for position and size - tools::Rectangle aRectangle = GetCircObj().GetGeoRect(); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - aRectangle += GetRectObj().GetGridOffset(); + const tools::Rectangle aRectangle(GetCircObj().GetGeoRect()); const basegfx::B2DRange aObjectRange( aRectangle.Left(), aRectangle.Top(), aRectangle.Right(), aRectangle.Bottom() ); diff --git a/svx/source/sdr/contact/viewcontactofsdredgeobj.cxx b/svx/source/sdr/contact/viewcontactofsdredgeobj.cxx index c22d14e18fa0..37eb5267cd5f 100644 --- a/svx/source/sdr/contact/viewcontactofsdredgeobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdredgeobj.cxx @@ -40,12 +40,7 @@ namespace sdr drawinglayer::primitive2d::Primitive2DContainer ViewContactOfSdrEdgeObj::createViewIndependentPrimitive2DSequence() const { - basegfx::B2DPolygon aEdgeTrack = GetEdgeObj().getEdgeTrack(); - Point aGridOff = GetEdgeObj().GetGridOffset(); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - aEdgeTrack.transform( basegfx::utils::createTranslateB2DHomMatrix( aGridOff.X(), aGridOff.Y() ) ); + const basegfx::B2DPolygon aEdgeTrack(GetEdgeObj().getEdgeTrack()); // what to do when no EdgeTrack is provided (HitTest and selectability) ? OSL_ENSURE(0 != aEdgeTrack.count(), "Connectors with no geometry are not allowed (!)"); diff --git a/svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx b/svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx index 90403799d53a..bda8a934109f 100644 --- a/svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx @@ -100,11 +100,7 @@ drawinglayer::primitive2d::Primitive2DContainer ViewContactOfSdrMediaObj::create { // create range using the model data directly. This is in SdrTextObj::aRect which i will access using // GetGeoRect() to not trigger any calculations. It's the unrotated geometry which is okay for MediaObjects ATM. - tools::Rectangle aRectangle(GetSdrMediaObj().GetGeoRect()); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - aRectangle += GetSdrMediaObj().GetGridOffset(); + const tools::Rectangle aRectangle(GetSdrMediaObj().GetGeoRect()); const basegfx::B2DRange aRange( aRectangle.Left(), aRectangle.Top(), aRectangle.Right(), aRectangle.Bottom()); diff --git a/svx/source/sdr/contact/viewcontactofsdrobj.cxx b/svx/source/sdr/contact/viewcontactofsdrobj.cxx index d042186c4d73..ca8abd63a8b4 100644 --- a/svx/source/sdr/contact/viewcontactofsdrobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrobj.cxx @@ -29,7 +29,7 @@ #include <basegfx/color/bcolor.hxx> #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx> #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx> -#include <sdr/contact/objectcontactofpageview.hxx> +#include <svx/sdr/contact/objectcontactofpageview.hxx> #include <svx/sdrpagewindow.hxx> #include <svx/sdrpaintwindow.hxx> #include <svx/svdhdl.hxx> diff --git a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx index c3f8666ad1d9..5c4bb784c515 100644 --- a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx @@ -45,13 +45,13 @@ namespace sdr basegfx::B2DRange ViewContactOfSdrObjCustomShape::getCorrectedTextBoundRect() const { - tools::Rectangle aObjectBound(GetCustomShapeObj().GetGeoRect()); - aObjectBound += GetCustomShapeObj().GetGridOffset(); + const tools::Rectangle aObjectBound(GetCustomShapeObj().GetGeoRect()); tools::Rectangle aTextBound(aObjectBound); GetCustomShapeObj().GetTextBounds(aTextBound); - aTextBound += GetCustomShapeObj().GetGridOffset(); basegfx::B2DRange aTextRange(aTextBound.Left(), aTextBound.Top(), aTextBound.Right(), aTextBound.Bottom()); - const basegfx::B2DRange aObjectRange(aObjectBound.Left(), aObjectBound.Top(), aObjectBound.Right(), aObjectBound.Bottom()); + const basegfx::B2DRange aObjectRange( + aObjectBound.Left(), aObjectBound.Top(), + aObjectBound.Right(), aObjectBound.Bottom()); // no need to correct if no extra text range if(aTextRange != aObjectRange) @@ -118,18 +118,8 @@ namespace sdr const SdrObject* pSdrObjRepresentation = GetCustomShapeObj().GetSdrObjectFromCustomShape(); bool b3DShape(false); - Point aGridOff = GetCustomShapeObj().GetGridOffset(); - if(pSdrObjRepresentation) { - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - // TTTT: Need to check what *exactly* this is doing - in it's current - // form it's indeed pretty much a 'hack' as mentioned above and massively - // in the way for future changes... - const_cast< SdrObject* >( pSdrObjRepresentation )->SetGridOffset( aGridOff ); - // tdf#118498 The processing of SdrObjListIter for SdrIterMode::DeepNoGroups // did change for 3D-Objects, it now correctly enters and iterates the // SdrObjects in the E3dScene (same as for SdrObjGroup). This is more correct @@ -160,10 +150,10 @@ namespace sdr { // take unrotated snap rect as default, then get the // unrotated text box. Rotation needs to be done centered - tools::Rectangle aObjectBound(GetCustomShapeObj().GetGeoRect()); - // hack for calc grid sync - aObjectBound += GetCustomShapeObj().GetGridOffset(); - const basegfx::B2DRange aObjectRange(aObjectBound.Left(), aObjectBound.Top(), aObjectBound.Right(), aObjectBound.Bottom()); + const tools::Rectangle aObjectBound(GetCustomShapeObj().GetGeoRect()); + const basegfx::B2DRange aObjectRange( + aObjectBound.Left(), aObjectBound.Top(), + aObjectBound.Right(), aObjectBound.Bottom()); // #i101684# get the text range unrotated and absolute to the object range const basegfx::B2DRange aTextRange(getCorrectedTextBoundRect()); diff --git a/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx b/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx index 9a538162779f..6a13aaef8682 100644 --- a/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx @@ -60,12 +60,10 @@ ViewContactOfSdrOle2Obj::~ViewContactOfSdrOle2Obj() basegfx::B2DHomMatrix ViewContactOfSdrOle2Obj::createObjectTransform() const { // take unrotated snap rect (direct model data) for position and size - tools::Rectangle rRectangle = GetOle2Obj().GetGeoRect(); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - rRectangle += GetOle2Obj().GetGridOffset(); - const basegfx::B2DRange aObjectRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom()); + const tools::Rectangle aRectangle(GetOle2Obj().GetGeoRect()); + const basegfx::B2DRange aObjectRange( + aRectangle.Left(), aRectangle.Top(), + aRectangle.Right(), aRectangle.Bottom()); // create object matrix const GeoStat& rGeoStat(GetOle2Obj().GetGeoStat()); @@ -100,17 +98,12 @@ drawinglayer::primitive2d::Primitive2DContainer ViewContactOfSdrOle2Obj::createP // #i123539# allow buffering and reuse of local chart data to not need to rebuild it // on every ViewObjectContact::getPrimitive2DSequence call. TTTT: Not needed for // aw080, there this mechanism already works differently - if(mxChartContent.is() - // check if we need to update the transformation primitive wrapping the chart - && maGridOffset == GetOle2Obj().GetGridOffset()) + if(mxChartContent.is()) { xContent = mxChartContent; } else { - // update grid offset - const_cast< ViewContactOfSdrOle2Obj* >(this)->maGridOffset = GetOle2Obj().GetGridOffset(); - // try to get chart primitives and chart range directly from xChartModel basegfx::B2DRange aChartContentRange; const drawinglayer::primitive2d::Primitive2DContainer aChartSequence( diff --git a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx index 9005b67a3fb4..28942f7b04de 100644 --- a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx @@ -74,11 +74,6 @@ namespace sdr GetPathObj().getText(0), false)); basegfx::B2DPolyPolygon aUnitPolyPolygon(GetPathObj().GetPathPoly()); - Point aGridOff = GetPathObj().GetGridOffset(); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - aUnitPolyPolygon.transform( basegfx::utils::createTranslateB2DHomMatrix( aGridOff.X(), aGridOff.Y() ) ); sal_uInt32 nPolyCount(ensureGeometry(aUnitPolyPolygon)); // prepare object transformation and unit polygon (direct model data) diff --git a/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx b/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx index f02ba917280c..34734f96e1cd 100644 --- a/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx @@ -47,14 +47,10 @@ drawinglayer::primitive2d::Primitive2DContainer ViewContactOfSdrRectObj::createV false)); // take unrotated snap rect (direct model data) for position and size - tools::Rectangle rRectangle = GetRectObj().GetGeoRect(); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - rRectangle += GetRectObj().GetGridOffset(); + const tools::Rectangle aRectangle(GetRectObj().GetGeoRect()); const ::basegfx::B2DRange aObjectRange( - rRectangle.Left(), rRectangle.Top(), - rRectangle.Right(), rRectangle.Bottom() ); + aRectangle.Left(), aRectangle.Top(), + aRectangle.Right(), aRectangle.Bottom() ); const GeoStat& rGeoStat(GetRectObj().GetGeoStat()); diff --git a/svx/source/sdr/contact/viewcontactofunocontrol.cxx b/svx/source/sdr/contact/viewcontactofunocontrol.cxx index 547e2ebc5339..78bdce4d6c2e 100644 --- a/svx/source/sdr/contact/viewcontactofunocontrol.cxx +++ b/svx/source/sdr/contact/viewcontactofunocontrol.cxx @@ -21,7 +21,7 @@ #include <sdr/contact/viewcontactofunocontrol.hxx> #include <sdr/contact/viewobjectcontactofunocontrol.hxx> -#include <sdr/contact/objectcontactofpageview.hxx> +#include <svx/sdr/contact/objectcontactofpageview.hxx> #include <svx/sdr/contact/displayinfo.hxx> #include <svx/svdouno.hxx> #include <svx/svdpagv.hxx> @@ -94,12 +94,7 @@ namespace sdr { namespace contact { // create range. Use model data directly, not getBoundRect()/getSnapRect; these will use // the primitive data themselves in the long run. Use SdrUnoObj's (which is a SdrRectObj) // call to GetGeoRect() to access SdrTextObj::aRect directly and without executing anything - tools::Rectangle aRectangle(GetSdrUnoObj().GetGeoRect()); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - Point aGridOffset = GetSdrUnoObj().GetGridOffset(); - aRectangle += aGridOffset; + const tools::Rectangle aRectangle(GetSdrUnoObj().GetGeoRect()); const basegfx::B2DRange aRange( aRectangle.Left(), aRectangle.Top(), aRectangle.Right(), aRectangle.Bottom()); diff --git a/svx/source/sdr/contact/viewobjectcontact.cxx b/svx/source/sdr/contact/viewobjectcontact.cxx index e300703bfd74..197113cda630 100644 --- a/svx/source/sdr/contact/viewobjectcontact.cxx +++ b/svx/source/sdr/contact/viewobjectcontact.cxx @@ -36,8 +36,8 @@ #include <drawinglayer/processor2d/baseprocessor2d.hxx> #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> #include <svx/svdoole2.hxx> - #include <sdr/contact/viewcontactofsdrole2obj.hxx> +#include <drawinglayer/primitive2d/transformprimitive2d.hxx> using namespace com::sun::star; @@ -159,6 +159,7 @@ ViewObjectContact::ViewObjectContact(ObjectContact& rObjectContact, ViewContact& mrViewContact(rViewContact), maObjectRange(), mxPrimitive2DSequence(), + maGridOffset(0.0, 0.0), mbLazyInvalidate(false) { // make the ViewContact remember me @@ -363,8 +364,36 @@ drawinglayer::primitive2d::Primitive2DContainer const & ViewObjectContact::getPr // always update object range when PrimitiveSequence changes const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D()); - const_cast< ViewObjectContact* >(this)->maObjectRange = - mxPrimitive2DSequence.getB2DRange(rViewInformation2D); + const_cast< ViewObjectContact* >(this)->maObjectRange = mxPrimitive2DSequence.getB2DRange(rViewInformation2D); + + // check and eventually embed to GridOffset transform primitive + if(GetObjectContact().supportsGridOffsets()) + { + const basegfx::B2DVector& rGridOffset(getGridOffset()); + + if(0.0 != rGridOffset.getX() || 0.0 != rGridOffset.getY()) + { + const basegfx::B2DHomMatrix aTranslateGridOffset( + basegfx::utils::createTranslateB2DHomMatrix( + rGridOffset)); + const drawinglayer::primitive2d::Primitive2DReference aEmbed( + new drawinglayer::primitive2d::TransformPrimitive2D( + aTranslateGridOffset, + mxPrimitive2DSequence)); + + // Set values at local data. So for now, the mechanism is to reset some of the + // defining things (mxPrimitive2DSequence, maGridOffset) and re-create the + // buffered data (including maObjectRange). It *could* be changed to keep + // the unmodified PrimitiveSequence and only update the GridOffset, but this + // would require a 2nd instance of maObjectRange and mxPrimitive2DSequence. I + // started doing so, but it just makes the code more complicated. For now, + // just allow re-creation of the PrimitiveSequence (and removing buffered + // decomposed content of it). May be optimized, though. OTOH it only happens + // in calc which traditionally does not have a huge amout of DrawObjects anyways. + const_cast< ViewObjectContact* >(this)->mxPrimitive2DSequence = drawinglayer::primitive2d::Primitive2DContainer { aEmbed }; + const_cast< ViewObjectContact* >(this)->maObjectRange.transform(aTranslateGridOffset); + } + } } // return current Primitive2DContainer @@ -427,6 +456,30 @@ drawinglayer::primitive2d::Primitive2DContainer ViewObjectContact::getPrimitive2 return xSeqRetval; } +// Support getting a GridOffset per object and view for non-linear ViewToDevice +// transformation (calc). On-demand created by delegating to the ObjectContact +// (->View) that has then all needed information +const basegfx::B2DVector& ViewObjectContact::getGridOffset() const +{ + if(0.0 == maGridOffset.getX() && 0.0 == maGridOffset.getY() && GetObjectContact().supportsGridOffsets()) + { + // create on-demand + GetObjectContact().calculateGridOffsetForViewOjectContact(const_cast<ViewObjectContact*>(this)->maGridOffset, *this); + } + + return maGridOffset; +} + +void ViewObjectContact::resetGridOffset() +{ + // reset buffered GridOffset itself + maGridOffset.setX(0.0); + maGridOffset.setY(0.0); + + // also reset sequence to get a re-calculation when GridOffset changes + mxPrimitive2DSequence.clear(); +} + }} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx b/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx index f0c545e7151b..c6183a2007ba 100644 --- a/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx @@ -22,7 +22,7 @@ #include <svx/sdr/contact/viewcontactofsdrobj.hxx> #include <svx/sdr/contact/objectcontact.hxx> #include <svx/sdr/contact/displayinfo.hxx> -#include <sdr/contact/objectcontactofpageview.hxx> +#include <svx/sdr/contact/objectcontactofpageview.hxx> #include <sdr/contact/viewcontactofsdrole2obj.hxx> #include <svx/sdrpagewindow.hxx> #include <svx/sdrpaintwindow.hxx> diff --git a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx index c785a6cdad13..50dcbd25e71e 100644 --- a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx @@ -22,7 +22,7 @@ #include <sdr/contact/viewcontactofunocontrol.hxx> #include <svx/sdr/contact/displayinfo.hxx> #include <svx/sdr/properties/properties.hxx> -#include <sdr/contact/objectcontactofpageview.hxx> +#include <svx/sdr/contact/objectcontactofpageview.hxx> #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> #include <svx/svdouno.hxx> #include <svx/svdpagv.hxx> @@ -918,12 +918,7 @@ namespace sdr { namespace contact { SdrUnoObj* pUnoObject( nullptr ); if ( getUnoObject( pUnoObject ) ) { - Point aGridOffset = pUnoObject->GetGridOffset(); - tools::Rectangle aRect( pUnoObject->GetLogicRect() ); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - aRect += aGridOffset; + const tools::Rectangle aRect( pUnoObject->GetLogicRect() ); UnoControlContactHelper::adjustControlGeometry_throw( m_aControl, aRect, _rViewTransformation, m_aZoomLevelNormalization ); } else @@ -1086,12 +1081,7 @@ namespace sdr { namespace contact { // knit the model and the control _out_rControl.setModel( xControlModel ); - Point aGridOffset = _rUnoObject.GetGridOffset(); - tools::Rectangle aRect( _rUnoObject.GetLogicRect() ); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - aRect += aGridOffset; + const tools::Rectangle aRect( _rUnoObject.GetLogicRect() ); // proper geometry UnoControlContactHelper::adjustControlGeometry_throw( @@ -1488,12 +1478,7 @@ namespace sdr { namespace contact { // Do use model data directly to create the correct geometry. Do NOT // use getBoundRect()/getSnapRect() here; these will use the sequence of // primitives themselves in the long run. - tools::Rectangle aSdrGeoData( _rVOC.GetSdrUnoObj().GetGeoRect() ); - Point aGridOffset = _rVOC.GetSdrUnoObj().GetGridOffset(); - // Hack for calc, transform position of object according - // to current zoom so as objects relative position to grid - // appears stable - aSdrGeoData += aGridOffset; + const tools::Rectangle aSdrGeoData( _rVOC.GetSdrUnoObj().GetGeoRect() ); const basegfx::B2DRange aRange( aSdrGeoData.Left(), aSdrGeoData.Top(), diff --git a/svx/source/sdr/overlay/overlayobject.cxx b/svx/source/sdr/overlay/overlayobject.cxx index aae05f9f0b96..d480007d4852 100644 --- a/svx/source/sdr/overlay/overlayobject.cxx +++ b/svx/source/sdr/overlay/overlayobject.cxx @@ -26,8 +26,9 @@ #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> - +#include <drawinglayer/primitive2d/transformprimitive2d.hxx> namespace sdr { @@ -37,7 +38,8 @@ namespace sdr { const basegfx::B2DRange aPreviousRange(maBaseRange); maBaseRange.reset(); - setPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DContainer()); + resetPrimitive2DSequence(); +// setPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DContainer()); if(getOverlayManager() && !aPreviousRange.isEmpty()) { @@ -91,6 +93,8 @@ namespace sdr OverlayObject::OverlayObject(Color aBaseColor) : Event(), mpOverlayManager(nullptr), + maPrimitive2DSequence(), + maOffset(0.0, 0.0), maBaseColor(aBaseColor), mbIsVisible(true), mbIsHittable(true), @@ -109,8 +113,21 @@ namespace sdr if(getPrimitive2DSequence().empty()) { // no existing sequence; create one - const_cast< OverlayObject* >(this)->setPrimitive2DSequence( - const_cast< OverlayObject* >(this)->createOverlayObjectPrimitive2DSequence()); + const_cast< OverlayObject* >(this)->maPrimitive2DSequence = const_cast< OverlayObject* >(this)->createOverlayObjectPrimitive2DSequence(); + + if(!getOffset().equalZero()) + { + // embed to offset transformation + const basegfx::B2DHomMatrix aTranslateGridOffset( + basegfx::utils::createTranslateB2DHomMatrix( + getOffset())); + const drawinglayer::primitive2d::Primitive2DReference aEmbed( + new drawinglayer::primitive2d::TransformPrimitive2D( + aTranslateGridOffset, + maPrimitive2DSequence)); + + const_cast< OverlayObject* >(this)->maPrimitive2DSequence = drawinglayer::primitive2d::Primitive2DContainer { aEmbed }; + } } return getPrimitive2DSequence(); @@ -170,6 +187,18 @@ namespace sdr } } + void OverlayObject::setOffset(const basegfx::B2DVector& rOffset) + { + if(rOffset != maOffset) + { + // remember new value + maOffset = rOffset; + + // register change (after change) + objectChange(); + } + } + void OverlayObject::Trigger(sal_uInt32 /*nTime*/) { // default does not register again diff --git a/svx/source/sdr/overlay/overlayselection.cxx b/svx/source/sdr/overlay/overlayselection.cxx index 5d22203a4e4e..a1fa52810eb2 100644 --- a/svx/source/sdr/overlay/overlayselection.cxx +++ b/svx/source/sdr/overlay/overlayselection.cxx @@ -196,7 +196,7 @@ namespace sdr || nNewTransparence != mnLastTransparence) { // conditions of last local decomposition have changed, delete - const_cast< OverlaySelection* >(this)->setPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DContainer()); + const_cast< OverlaySelection* >(this)->resetPrimitive2DSequence(); } } |