diff options
author | Noel Power <noel.power@suse.com> | 2012-11-27 17:56:33 +0000 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2012-11-28 14:50:25 +0000 |
commit | c4e649f0cd013e86adbd794859bcc3cb9ee3aa61 (patch) | |
tree | 41038de6c78c01a15e730d218ea5a61a28de8fdd /svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx | |
parent | 24c0e7ed9971663dfcaf9c4c1182dd6da9df005f (diff) |
Sync draw object to calc grid for better alignment when zooming
There can be some serious rounding errors involved when calculating where to
draw the grid lines for the various row heights in a document. This can be
especially true for a document that has many different row heights.
This results in draw objects appearing to move relative to the grid line at
different zoom levels. This patch attempts to fix this problem adjusting
the position of the shapes as they are drawn to ensure their position
relative to grid appears to be stable. We do this by translating the position
of the shape to the corrosponding position of it's cell anchor. Of course not
all shapes are cell anchored and in this case we position the shape relative
a temporary synthesized cell anchor.
The patch essentially does the following
a) calculates the offset to be applied for each shape at the current zoom level
to ensure that the shape will be drawn relative to the correct cell grid
see drwlayer.cxx, drawview.cxx & gridwin3.cxx, svdobj.[ch]xx
b) apply the offset in the drawing layer for each of the different drawing
primitives see svx/source/sdr/contact/*
c) making sure the position and size of the newly created shape ( at any zoom
level ) are still as expected when zoom level is changed.
see. sc/source/ui/drawfunc/fuco*.cxx &
d) making sure that overlays and handles are displayed at the correct position
see svx/source/svdraw/*
it could also be that a full blown transform might be needed to additionally
scale the object ( to ensure that the edges of the object stay stable relative
to ajacent grid lines ) If necessary we could do that in a later step.
Change-Id: I02232f8ba192d58dbf96b80adf66c281cd0f65e8
Diffstat (limited to 'svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx')
-rw-r--r-- | svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx index 7fe688bf3350..654ed86cbaca 100644 --- a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx @@ -117,14 +117,21 @@ 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 + const_cast< SdrObject* >( pSdrObjRepresentation )->SetGridOffset( aGridOff ); SdrObjListIter aIterator(*pSdrObjRepresentation); while(aIterator.IsMore()) { SdrObject& rCandidate = *aIterator.Next(); - + // apply offset to each part + rCandidate.SetGridOffset( aGridOff ); if(!b3DShape && dynamic_cast< E3dObject* >(&rCandidate)) { b3DShape = true; @@ -145,7 +152,9 @@ namespace sdr { // take unrotated snap rect as default, then get the // unrotated text box. Rotation needs to be done centered - const Rectangle aObjectBound(GetCustomShapeObj().GetGeoRect()); + Rectangle aObjectBound(GetCustomShapeObj().GetGeoRect()); + // hack for calc grid sync + aObjectBound += GetCustomShapeObj().GetGridOffset(); const basegfx::B2DRange aObjectRange(aObjectBound.Left(), aObjectBound.Top(), aObjectBound.Right(), aObjectBound.Bottom()); // #i101684# get the text range unrotated and absolute to the object range |