Author: alg
Date: Mon Jan 27 17:14:55 2014
New Revision: 1561756
URL: http://svn.apache.org/r1561756
Log:
i123950 Corrected/extended interactive crop feature to work in all situations
Modified:
openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlayanimatedbitmapex.hxx
openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlaybitmapex.hxx
openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlaytools.hxx
openoffice/trunk/main/svx/inc/svx/svdhdl.hxx
openoffice/trunk/main/svx/inc/svx/svdograf.hxx
openoffice/trunk/main/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx
openoffice/trunk/main/svx/source/sdr/overlay/overlaybitmapex.cxx
openoffice/trunk/main/svx/source/sdr/overlay/overlaytools.cxx
openoffice/trunk/main/svx/source/svdraw/svddrgm1.hxx
openoffice/trunk/main/svx/source/svdraw/svddrgmt.cxx
openoffice/trunk/main/svx/source/svdraw/svdhdl.cxx
openoffice/trunk/main/svx/source/svdraw/svdmrkv.cxx
openoffice/trunk/main/svx/source/svdraw/svdograf.cxx
Modified:
openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlayanimatedbitmapex.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlayanimatedbitmapex.hxx?rev=1561756&r1=1561755&r2=1561756&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlayanimatedbitmapex.hxx
(original)
+++ openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlayanimatedbitmapex.hxx
Mon Jan 27 17:14:55 2014
@@ -49,7 +49,11 @@ namespace sdr
// #i53216# added CursorBlinkTime (in ms)
sal_uInt32
mnBlinkTime;
- /// bitfield
+ // optional shear and rotation
+ double mfShearX;
+ double mfRotation;
+
+ /// bitfield
// Flag to remember which state to draw. Inited with
false (0)
bool mbOverlayState
: 1;
@@ -65,7 +69,9 @@ namespace sdr
sal_uInt16 nCenX1 = 0,
sal_uInt16 nCenY1 = 0,
sal_uInt16 nCenX2 = 0,
- sal_uInt16 nCenY2 = 0);
+ sal_uInt16 nCenY2 = 0,
+ double fShearX = 0.0,
+ double fRotation = 0.0);
virtual ~OverlayAnimatedBitmapEx();
const BitmapEx& getBitmapEx1() const { return
maBitmapEx1; }
@@ -87,6 +93,10 @@ namespace sdr
// execute event from base class
::sdr::animation::Event. Default
// implementation does nothing and does not create a
new event.
virtual void Trigger(sal_uInt32 nTime);
+
+ // get shearX and rotation
+ double getShearX() const { return mfShearX; }
+ double getRotation() const { return mfRotation; }
};
} // end of namespace overlay
} // end of namespace sdr
Modified: openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlaybitmapex.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlaybitmapex.hxx?rev=1561756&r1=1561755&r2=1561756&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlaybitmapex.hxx (original)
+++ openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlaybitmapex.hxx Mon Jan
27 17:14:55 2014
@@ -42,9 +42,11 @@ namespace sdr
// position of the basePosition inside the Bitmap, in
pixels
sal_uInt16
mnCenterX;
sal_uInt16
mnCenterY;
-
- // optional transparency
- double mfAlpha;
+
+ // optional transparency, shear and rotation
+ double mfAlpha;
+ double mfShearX;
+ double mfRotation;
virtual drawinglayer::primitive2d::Primitive2DSequence
createOverlayObjectPrimitive2DSequence();
@@ -52,7 +54,11 @@ namespace sdr
OverlayBitmapEx(
const basegfx::B2DPoint& rBasePos,
const BitmapEx& rBitmapEx,
- sal_uInt16 nCenX = 0, sal_uInt16 nCenY = 0,
double fAlpha = 0.0 );
+ sal_uInt16 nCenX = 0,
+ sal_uInt16 nCenY = 0,
+ double fAlpha = 0.0,
+ double fShearX = 0.0,
+ double fRotation = 0.0);
virtual ~OverlayBitmapEx();
const BitmapEx& getBitmapEx() const { return
maBitmapEx; }
@@ -61,6 +67,10 @@ namespace sdr
sal_uInt16 getCenterX() const { return mnCenterX; }
sal_uInt16 getCenterY() const { return mnCenterY; }
void setCenterXY(sal_uInt16 nNewX, sal_uInt16 nNewY);
+
+ // get shearX and rotation
+ double getShearX() const { return mfShearX; }
+ double getRotation() const { return mfRotation; }
};
} // end of namespace overlay
} // end of namespace sdr
Modified: openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlaytools.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlaytools.hxx?rev=1561756&r1=1561755&r2=1561756&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlaytools.hxx (original)
+++ openoffice/trunk/main/svx/inc/svx/sdr/overlay/overlaytools.hxx Mon Jan 27
17:14:55 2014
@@ -49,8 +49,12 @@ namespace drawinglayer
// the target position (offset in the bitmap)
sal_uInt16
mnCenterX;
sal_uInt16
mnCenterY;
-
- protected:
+
+ // evtl. rotation and shear around center
+ double mfShearX;
+ double mfRotation;
+
+ protected:
virtual Primitive2DSequence create2DDecomposition(const
geometry::ViewInformation2D& rViewInformation) const;
public:
@@ -58,13 +62,17 @@ namespace drawinglayer
const BitmapEx& rBitmapEx,
const basegfx::B2DPoint& rBasePosition,
sal_uInt16 nCenterX,
- sal_uInt16 nCenterY);
+ sal_uInt16 nCenterY,
+ double fShearX = 0.0,
+ double fRotation = 0.0);
// data access
const BitmapEx& getBitmapEx() const { return
maBitmapEx; }
const basegfx::B2DPoint& getBasePosition() const {
return maBasePosition; }
sal_uInt16 getCenterX() const { return mnCenterX; }
sal_uInt16 getCenterY() const { return mnCenterY; }
+ double getShearX() const { return mfShearX; }
+ double getRotation() const { return mfRotation; }
// compare operator
virtual bool operator==( const BasePrimitive2D&
rPrimitive ) const;
Modified: openoffice/trunk/main/svx/inc/svx/svdhdl.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/svdhdl.hxx?rev=1561756&r1=1561755&r2=1561756&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/svdhdl.hxx (original)
+++ openoffice/trunk/main/svx/inc/svx/svdhdl.hxx Mon Jan 27 17:14:55 2014
@@ -518,8 +518,18 @@ public:
class SVX_DLLPUBLIC SdrCropHdl : public SdrHdl
{
+private:
+ // evtl. shear and rotation, equal to the object's one to allow adaption of
+ // the visualization handles
+ double mfShearX;
+ double mfRotation;
+
public:
- SdrCropHdl(const Point& rPnt, SdrHdlKind eNewKind);
+ SdrCropHdl(
+ const Point& rPnt,
+ SdrHdlKind eNewKind,
+ double fShearX,
+ double fRotation);
protected:
// create marker for this kind
@@ -542,11 +552,6 @@ private:
double mfCropRight;
double mfCropBottom;
- // Argh! The old geometry stuff expresses Y-Mirror using 180 degree rotaton
- // and the bMirrored bool at the SdrGrafObj, so for now I have to give
- // this info here. I am sooo looking forward to aw080 and real
transformations :-(
- bool mbExtraMirrorXFromGraphic;
-
public:
SdrCropViewHdl(
const basegfx::B2DHomMatrix& rObjectTransform,
@@ -554,8 +559,7 @@ public:
double fCropLeft,
double fCropTop,
double fCropRight,
- double fCropBottom,
- bool bExtraMirrorXFromGraphic);
+ double fCropBottom);
protected:
// create marker for this kind
Modified: openoffice/trunk/main/svx/inc/svx/svdograf.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/svdograf.hxx?rev=1561756&r1=1561755&r2=1561756&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/svdograf.hxx (original)
+++ openoffice/trunk/main/svx/inc/svx/svdograf.hxx Mon Jan 27 17:14:55 2014
@@ -224,6 +224,9 @@ public:
// #i103116# FullDrag support
virtual SdrObject* getFullDragClone() const;
+
+ // add handles for crop mode when selected
+ void addCropHandles(SdrHdlList& rTarget) const;
};
#endif //_SVDOGRAF_HXX
Modified:
openoffice/trunk/main/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx?rev=1561756&r1=1561755&r2=1561756&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx
(original)
+++ openoffice/trunk/main/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx
Mon Jan 27 17:14:55 2014
@@ -45,7 +45,9 @@ namespace sdr
getBitmapEx1(),
getBasePosition(),
getCenterX1(),
- getCenterY1()));
+ getCenterY1(),
+ getShearX(),
+ getRotation()));
return
drawinglayer::primitive2d::Primitive2DSequence(&aPrimitive, 1);
}
@@ -56,35 +58,41 @@ namespace sdr
getBitmapEx2(),
getBasePosition(),
getCenterX2(),
- getCenterY2()));
+ getCenterY2(),
+ getShearX(),
+ getRotation()));
return
drawinglayer::primitive2d::Primitive2DSequence(&aPrimitive, 1);
}
}
- OverlayAnimatedBitmapEx::OverlayAnimatedBitmapEx(
- const basegfx::B2DPoint& rBasePos,
- const BitmapEx& rBitmapEx1,
- const BitmapEx& rBitmapEx2,
- sal_uInt32 nBlinkTime,
- sal_uInt16 nCenX1,
- sal_uInt16 nCenY1,
- sal_uInt16 nCenX2,
- sal_uInt16 nCenY2)
- : OverlayObjectWithBasePosition(rBasePos,
Color(COL_WHITE)),
- maBitmapEx1(rBitmapEx1),
- maBitmapEx2(rBitmapEx2),
- mnCenterX1(nCenX1), mnCenterY1(nCenY1),
- mnCenterX2(nCenX2), mnCenterY2(nCenY2),
- mnBlinkTime(nBlinkTime),
- mbOverlayState(false)
+ OverlayAnimatedBitmapEx::OverlayAnimatedBitmapEx(
+ const basegfx::B2DPoint& rBasePos,
+ const BitmapEx& rBitmapEx1,
+ const BitmapEx& rBitmapEx2,
+ sal_uInt32 nBlinkTime,
+ sal_uInt16 nCenX1,
+ sal_uInt16 nCenY1,
+ sal_uInt16 nCenX2,
+ sal_uInt16 nCenY2,
+ double fShearX,
+ double fRotation)
+ : OverlayObjectWithBasePosition(rBasePos, Color(COL_WHITE)),
+ maBitmapEx1(rBitmapEx1),
+ maBitmapEx2(rBitmapEx2),
+ mnCenterX1(nCenX1), mnCenterY1(nCenY1),
+ mnCenterX2(nCenX2), mnCenterY2(nCenY2),
+ mnBlinkTime(nBlinkTime),
+ mfShearX(fShearX),
+ mfRotation(fRotation),
+ mbOverlayState(false)
{
- // set AllowsAnimation flag to mark this object as
animation capable
- mbAllowsAnimation = true;
+ // set AllowsAnimation flag to mark this object as animation
capable
+ mbAllowsAnimation = true;
- // #i53216# check blink time value range
- mnBlinkTime = impCheckBlinkTimeValueRange(mnBlinkTime);
- }
+ // #i53216# check blink time value range
+ mnBlinkTime = impCheckBlinkTimeValueRange(mnBlinkTime);
+ }
OverlayAnimatedBitmapEx::~OverlayAnimatedBitmapEx()
{
Modified: openoffice/trunk/main/svx/source/sdr/overlay/overlaybitmapex.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/sdr/overlay/overlaybitmapex.cxx?rev=1561756&r1=1561755&r2=1561756&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/sdr/overlay/overlaybitmapex.cxx (original)
+++ openoffice/trunk/main/svx/source/sdr/overlay/overlaybitmapex.cxx Mon Jan 27
17:14:55 2014
@@ -43,7 +43,9 @@ namespace sdr
getBitmapEx(),
getBasePosition(),
getCenterX(),
- getCenterY()));
+ getCenterY(),
+ getShearX(),
+ getRotation()));
if(basegfx::fTools::more(mfAlpha, 0.0))
{
@@ -55,17 +57,23 @@ namespace sdr
return drawinglayer::primitive2d::Primitive2DSequence(&aReference,
1);
}
- OverlayBitmapEx::OverlayBitmapEx(
- const basegfx::B2DPoint& rBasePos,
- const BitmapEx& rBitmapEx,
- sal_uInt16 nCenX, sal_uInt16 nCenY, double fAlpha)
- : OverlayObjectWithBasePosition(rBasePos,
Color(COL_WHITE)),
- maBitmapEx(rBitmapEx),
- mnCenterX(nCenX),
- mnCenterY(nCenY),
- mfAlpha(fAlpha)
- {
- }
+ OverlayBitmapEx::OverlayBitmapEx(
+ const basegfx::B2DPoint& rBasePos,
+ const BitmapEx& rBitmapEx,
+ sal_uInt16 nCenX,
+ sal_uInt16 nCenY,
+ double fAlpha,
+ double fShearX,
+ double fRotation)
+ : OverlayObjectWithBasePosition(rBasePos, Color(COL_WHITE)),
+ maBitmapEx(rBitmapEx),
+ mnCenterX(nCenX),
+ mnCenterY(nCenY),
+ mfAlpha(fAlpha),
+ mfShearX(fShearX),
+ mfRotation(fRotation)
+ {
+ }
OverlayBitmapEx::~OverlayBitmapEx()
{
Modified: openoffice/trunk/main/svx/source/sdr/overlay/overlaytools.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/sdr/overlay/overlaytools.cxx?rev=1561756&r1=1561755&r2=1561756&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/sdr/overlay/overlaytools.cxx (original)
+++ openoffice/trunk/main/svx/source/sdr/overlay/overlaytools.cxx Mon Jan 27
17:14:55 2014
@@ -47,12 +47,16 @@ namespace drawinglayer
const BitmapEx& rBitmapEx,
const basegfx::B2DPoint& rBasePosition,
sal_uInt16 nCenterX,
- sal_uInt16 nCenterY)
+ sal_uInt16 nCenterY,
+ double fShearX,
+ double fRotation)
: DiscreteMetricDependentPrimitive2D(),
maBitmapEx(rBitmapEx),
maBasePosition(rBasePosition),
mnCenterX(nCenterX),
- mnCenterY(nCenterY)
+ mnCenterY(nCenterY),
+ mfShearX(fShearX),
+ mfRotation(fRotation)
{}
Primitive2DSequence
OverlayBitmapExPrimitive::create2DDecomposition(const
geometry::ViewInformation2D& /*rViewInformation*/) const
@@ -67,18 +71,33 @@ namespace drawinglayer
// the prepared one which expresses how many logic units form
a discrete unit)
// for this step. This primitive is to be displayed always
unscaled (in it's pixel size)
// and unrotated, more like a marker
- const double fLeft(((0.0 - getCenterX()) * getDiscreteUnit())
+ getBasePosition().getX());
- const double fTop(((0.0 - getCenterY()) * getDiscreteUnit()) +
getBasePosition().getY());
- const double fRight(((aBitmapSize.getWidth() - getCenterX()) *
getDiscreteUnit()) + getBasePosition().getX());
- const double fBottom(((aBitmapSize.getHeight() - getCenterY())
* getDiscreteUnit()) + getBasePosition().getY());
+ const double fLeft((0.0 - getCenterX()) * getDiscreteUnit());
+ const double fTop((0.0 - getCenterY()) * getDiscreteUnit());
+ const double fRight((aBitmapSize.getWidth() - getCenterX()) *
getDiscreteUnit());
+ const double fBottom((aBitmapSize.getHeight() - getCenterY())
* getDiscreteUnit());
// create a BitmapPrimitive2D using those positions
- basegfx::B2DHomMatrix aTransform;
+ basegfx::B2DHomMatrix aTransform;
+
+ aTransform.set(0, 0, fRight - fLeft);
+ aTransform.set(1, 1, fBottom - fTop);
+ aTransform.set(0, 2, fLeft);
+ aTransform.set(1, 2, fTop);
+
+ // if shearX is used, apply it, too
+ if(!basegfx::fTools::equalZero(getShearX()))
+ {
+ aTransform.shearX(getShearX());
+ }
+
+ // if rotation is used, apply it, too
+ if(!basegfx::fTools::equalZero(getRotation()))
+ {
+ aTransform.rotate(getRotation());
+ }
- aTransform.set(0, 0, fRight - fLeft);
- aTransform.set(1, 1, fBottom - fTop);
- aTransform.set(0, 2, fLeft);
- aTransform.set(1, 2, fTop);
+ // add BasePosition
+ aTransform.translate(getBasePosition().getX(),
getBasePosition().getY());
const Primitive2DReference aPrimitive(new
BitmapPrimitive2D(getBitmapEx(), aTransform));
aRetval = Primitive2DSequence(&aPrimitive, 1);
@@ -96,7 +115,9 @@ namespace drawinglayer
return (getBitmapEx() == rCompare.getBitmapEx()
&& getBasePosition() ==
rCompare.getBasePosition()
&& getCenterX() == rCompare.getCenterX()
- && getCenterY() ==
rCompare.getCenterY());
+ && getCenterY() == rCompare.getCenterY()
+ && getShearX() == rCompare.getShearX()
+ && getRotation() == rCompare.getRotation());
}
return false;
Modified: openoffice/trunk/main/svx/source/svdraw/svddrgm1.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/svdraw/svddrgm1.hxx?rev=1561756&r1=1561755&r2=1561756&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/svdraw/svddrgm1.hxx (original)
+++ openoffice/trunk/main/svx/source/svdraw/svddrgm1.hxx Mon Jan 27 17:14:55
2014
@@ -256,15 +256,18 @@ public:
////////////////////////////////////////////////////////////////////////////////////////////////////
// SdrDragCrop
-class SdrDragCrop : public SdrDragResize
+// derive from SdrDragObjOwn to have handles aligned to object when it
+// is sheared or rotated
+class SdrDragCrop : public SdrDragObjOwn
{
public:
- TYPEINFO();
- SdrDragCrop(SdrDragView& rNewView);
+ TYPEINFO();
+ SdrDragCrop(SdrDragView& rNewView);
- virtual void TakeSdrDragComment(String& rStr) const;
- virtual bool EndSdrDrag(bool bCopy);
- virtual Pointer GetSdrDragPointer() const;
+ virtual void TakeSdrDragComment(String& rStr) const;
+ virtual bool BeginSdrDrag();
+ virtual bool EndSdrDrag(bool bCopy);
+ virtual Pointer GetSdrDragPointer() const;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
Modified: openoffice/trunk/main/svx/source/svdraw/svddrgmt.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/svdraw/svddrgmt.cxx?rev=1561756&r1=1561755&r2=1561756&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/svdraw/svddrgmt.cxx (original)
+++ openoffice/trunk/main/svx/source/svdraw/svddrgmt.cxx Mon Jan 27 17:14:55
2014
@@ -3682,7 +3682,7 @@ void SdrDragDistort::applyCurrentTransfo
TYPEINIT1(SdrDragCrop,SdrDragResize);
SdrDragCrop::SdrDragCrop(SdrDragView& rNewView)
-: SdrDragResize(rNewView)
+: SdrDragObjOwn(rNewView)
{
// switch off solid dragging for crop; it just makes no sense since
showing
// a 50% transparent object above the original will not be visible
@@ -3707,7 +3707,21 @@ void SdrDragCrop::TakeSdrDragComment(Xub
rStr += ImpGetResStr(STR_EditWithCopy);
}
-bool SdrDragCrop::EndSdrDrag(bool bCopy)
+bool SdrDragCrop::BeginSdrDrag()
+{
+ // call parent
+ bool bRetval(SdrDragObjOwn::BeginSdrDrag());
+
+ if(!GetDragHdl())
+ {
+ // we need the DragHdl, break if not there
+ bRetval = false;
+ }
+
+ return bRetval;
+}
+
+bool SdrDragCrop::EndSdrDrag(bool /*bCopy*/)
{
Hide();
@@ -3746,34 +3760,204 @@ bool SdrDragCrop::EndSdrDrag(bool bCopy)
ImpTakeDescriptionStr(STR_DragMethCrop, aUndoStr);
getSdrDragView().BegUndo( aUndoStr );
- getSdrDragView().AddUndo(
getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
+ getSdrDragView().AddUndo(
getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
+ // also need attr undo, the SdrGrafCropItem will be changed
+ getSdrDragView().AddUndo(
getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
}
- Rectangle aOldRect( pObj->GetLogicRect() );
- getSdrDragView().ResizeMarkedObj(DragStat().Ref1(),aXFact,aYFact,bCopy);
- Rectangle aNewRect( pObj->GetLogicRect() );
+ // new part to comute the user's drag activities
+ // get the original objects transformation
+ basegfx::B2DHomMatrix aOriginalMatrix;
+ basegfx::B2DPolyPolygon aPolyPolygon;
+ bool bShearCorrected(false);
+
+ // get transformation from object
+ pObj->TRGetBaseGeometry(aOriginalMatrix, aPolyPolygon);
+
+ { // TTTT correct shear, it comes currently mirrored from
TRGetBaseGeometry, can be removed with aw080
+ basegfx::B2DTuple aScale;
+ basegfx::B2DTuple aTranslate;
+ double fRotate(0.0), fShearX(0.0);
+
+ aOriginalMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ if(!basegfx::fTools::equalZero(fShearX))
+ {
+ bShearCorrected = true;
+ aOriginalMatrix =
basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aScale,
+ -fShearX,
+ fRotate,
+ aTranslate);
+ }
+ }
+
+ // invert it to be able to work on unit coordinates
+ basegfx::B2DHomMatrix aInverse(aOriginalMatrix);
+
+ aInverse.invert();
+
+ // gererate start point of original drag vector in unit coordinates (the
+ // vis-a-vis of the drag point)
+ basegfx::B2DPoint aLocalStart(0.0, 0.0);
+ bool bOnAxis(false);
+
+ switch(GetDragHdlKind())
+ {
+ case HDL_UPLFT: aLocalStart.setX(1.0); aLocalStart.setY(1.0); break;
+ case HDL_UPPER: aLocalStart.setX(0.5); aLocalStart.setY(1.0); bOnAxis
= true; break;
+ case HDL_UPRGT: aLocalStart.setX(0.0); aLocalStart.setY(1.0); break;
+ case HDL_LEFT : aLocalStart.setX(1.0); aLocalStart.setY(0.5); bOnAxis
= true; break;
+ case HDL_RIGHT: aLocalStart.setX(0.0); aLocalStart.setY(0.5); bOnAxis
= true; break;
+ case HDL_LWLFT: aLocalStart.setX(1.0); aLocalStart.setY(0.0); break;
+ case HDL_LOWER: aLocalStart.setX(0.5); aLocalStart.setY(0.0); bOnAxis
= true; break;
+ case HDL_LWRGT: aLocalStart.setX(0.0); aLocalStart.setY(0.0); break;
+ default: break;
+ }
+
+ // create the current drag position in unit coordinates
+ basegfx::B2DPoint aLocalCurrent(aInverse *
basegfx::B2DPoint(DragStat().GetNow().X(), DragStat().GetNow().Y()));
+
+ // if one of the edge handles is used, limit to X or Y drag only
+ if(bOnAxis)
+ {
+ if(basegfx::fTools::equal(aLocalStart.getX(), 0.5))
+ {
+ aLocalCurrent.setX(aLocalStart.getX());
+ }
+ else
+ {
+ aLocalCurrent.setY(aLocalStart.getY());
+ }
+ }
+
+ // create internal change in unit coordinates
+ basegfx::B2DHomMatrix aDiscreteChangeMatrix;
+
+ if(!basegfx::fTools::equal(aLocalCurrent.getX(), aLocalStart.getX()))
+ {
+ if(aLocalStart.getX() < 0.5)
+ {
+ aDiscreteChangeMatrix.scale(aLocalCurrent.getX(), 1.0);
+ }
+ else
+ {
+ aDiscreteChangeMatrix.scale(1.0 - aLocalCurrent.getX(), 1.0);
+ aDiscreteChangeMatrix.translate(aLocalCurrent.getX(), 0.0);
+ }
+ }
+
+ if(!basegfx::fTools::equal(aLocalCurrent.getY(), aLocalStart.getY()))
+ {
+ if(aLocalStart.getY() < 0.5)
+ {
+ aDiscreteChangeMatrix.scale(1.0, aLocalCurrent.getY());
+ }
+ else
+ {
+ aDiscreteChangeMatrix.scale(1.0, 1.0 - aLocalCurrent.getY());
+ aDiscreteChangeMatrix.translate(0.0, aLocalCurrent.getY());
+ }
+ }
+
+ // preparematrix to apply to object; evtl. back-correct shear
+ basegfx::B2DHomMatrix aNewObjectMatrix(aOriginalMatrix *
aDiscreteChangeMatrix);
+ if(bShearCorrected)
+ {
+ // TTTT back-correct shear
+ basegfx::B2DTuple aScale;
+ basegfx::B2DTuple aTranslate;
+ double fRotate(0.0), fShearX(0.0);
+
+ aNewObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+ aNewObjectMatrix =
basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aScale,
+ -fShearX,
+ fRotate,
+ aTranslate);
+ }
+
+ // apply change to object by applying the unit coordinate change followed
+ // by the original change
+ pObj->TRSetBaseGeometry(aNewObjectMatrix, aPolyPolygon);
+
+ // the following old code uses aOldRect/aNewRect to calculate the crop
change for
+ // the crop item. It implies unrotated objects, so create the unrotated
original
+ // erctangle and the unrotated modified rectangle. Latter can in case of
shear and/or
+ // rotation not be fetched by using
+ //
+ //Rectangle aNewRect( pObj->GetLogicRect() );
+ //
+ // as it was done before because the top-left of that new rect *will* have
an offset
+ // caused by the evtl. existing shear and/or rotation, so calculate a
unrotated
+ // rectangle how it would be as a result when appling the unit coordinate
change
+ // to the unrotated original transformation.
+ basegfx::B2DTuple aScale;
+ basegfx::B2DTuple aTranslate;
+ double fRotate, fShearX;
+
+ // get access to scale and translate
+ aOriginalMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // prepare unsheared/unrotated versions of the old and new transformation
+ const basegfx::B2DHomMatrix aMatrixOriginalNoShearNoRotate(
+ basegfx::tools::createScaleTranslateB2DHomMatrix(
+ basegfx::absolute(aScale),
+ aTranslate));
+
+ // create the ranges for these
+ basegfx::B2DRange aRangeOriginalNoShearNoRotate(0.0, 0.0, 1.0, 1.0);
+ basegfx::B2DRange aRangeNewNoShearNoRotate(0.0, 0.0, 1.0, 1.0);
+
+ aRangeOriginalNoShearNoRotate.transform(aMatrixOriginalNoShearNoRotate);
+ aRangeNewNoShearNoRotate.transform(aMatrixOriginalNoShearNoRotate *
aDiscreteChangeMatrix);
+
+ // extract the old Rectangle structures
+ Rectangle aOldRect(
+ basegfx::fround(aRangeOriginalNoShearNoRotate.getMinX()),
+ basegfx::fround(aRangeOriginalNoShearNoRotate.getMinY()),
+ basegfx::fround(aRangeOriginalNoShearNoRotate.getMaxX()),
+ basegfx::fround(aRangeOriginalNoShearNoRotate.getMaxY()));
+ Rectangle aNewRect(
+ basegfx::fround(aRangeNewNoShearNoRotate.getMinX()),
+ basegfx::fround(aRangeNewNoShearNoRotate.getMinY()),
+ basegfx::fround(aRangeNewNoShearNoRotate.getMaxX()),
+ basegfx::fround(aRangeNewNoShearNoRotate.getMaxY()));
+
+ // continue with the old original stuff
double fScaleX = ( aGraphicSize.Width() - rOldCrop.GetLeft() -
rOldCrop.GetRight() ) / (double)aOldRect.GetWidth();
double fScaleY = ( aGraphicSize.Height() - rOldCrop.GetTop() -
rOldCrop.GetBottom() ) / (double)aOldRect.GetHeight();
- // to correct the never working combination of cropped images and mirroring
- // I have to correct the rectangles the calculation is based on here. In
the current
- // core geometry stuff a vertical mirror is expressed as 180 degree
rotation. All
- // this can be removed again when aw080 will have cleaned up the old
- // (non-)transformation mess in the core.
- if(18000 == pObj->GetGeoStat().nDrehWink)
- {
- // old notation of vertical mirror, need to correct diffs since both
rects
- // are rotated by 180 degrees
- aOldRect = Rectangle(aOldRect.TopLeft() - (aOldRect.BottomRight() -
aOldRect.TopLeft()), aOldRect.TopLeft());
- aNewRect = Rectangle(aNewRect.TopLeft() - (aNewRect.BottomRight() -
aNewRect.TopLeft()), aNewRect.TopLeft());
- }
+ // not needed since the modification is done in unit coordinates, free
from shear/rotate and mirror
+ // // TTTT may be removed or exhanged by other stuff in aw080
+ // // to correct the never working combination of cropped images and
mirroring
+ // // I have to correct the rectangles the calculation is based on here.
In the current
+ // // core geometry stuff a vertical mirror is expressed as 180 degree
rotation. All
+ // // this can be removed again when aw080 will have cleaned up the old
+ // // (non-)transformation mess in the core.
+ // if(18000 == pObj->GetGeoStat().nDrehWink)
+ // {
+ // // old notation of vertical mirror, need to correct diffs since
both rects
+ // // are rotated by 180 degrees
+ // aOldRect = Rectangle(aOldRect.TopLeft() - (aOldRect.BottomRight() -
aOldRect.TopLeft()), aOldRect.TopLeft());
+ // aNewRect = Rectangle(aNewRect.TopLeft() - (aNewRect.BottomRight() -
aNewRect.TopLeft()), aNewRect.TopLeft());
+ // }
sal_Int32 nDiffLeft = aNewRect.nLeft - aOldRect.nLeft;
sal_Int32 nDiffTop = aNewRect.nTop - aOldRect.nTop;
sal_Int32 nDiffRight = aNewRect.nRight - aOldRect.nRight;
sal_Int32 nDiffBottom = aNewRect.nBottom - aOldRect.nBottom;
+ if(pObj->IsMirrored())
+ {
+ // mirrored X or Y, for old stuff, exchange X
+ // TTTT: check for aw080
+ sal_Int32 nTmp(nDiffLeft);
+ nDiffLeft = -nDiffRight;
+ nDiffRight = -nTmp;
+ }
+
sal_Int32 nLeftCrop = static_cast<sal_Int32>( rOldCrop.GetLeft() +
nDiffLeft * fScaleX );
sal_Int32 nTopCrop = static_cast<sal_Int32>( rOldCrop.GetTop() +
nDiffTop * fScaleY );
sal_Int32 nRightCrop = static_cast<sal_Int32>( rOldCrop.GetRight() -
nDiffRight * fScaleX );
Modified: openoffice/trunk/main/svx/source/svdraw/svdhdl.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/svdraw/svdhdl.cxx?rev=1561756&r1=1561755&r2=1561756&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/svdraw/svdhdl.cxx (original)
+++ openoffice/trunk/main/svx/source/svdraw/svdhdl.cxx Mon Jan 27 17:14:55 2014
@@ -2296,8 +2296,14 @@ SdrHdl* SdrHdlList::GetHdl(SdrHdlKind eK
// SdrCropHdl
// --------------------------------------------------------------------
-SdrCropHdl::SdrCropHdl(const Point& rPnt, SdrHdlKind eNewKind)
-: SdrHdl( rPnt, eNewKind )
+SdrCropHdl::SdrCropHdl(
+ const Point& rPnt,
+ SdrHdlKind eNewKind,
+ double fShearX,
+ double fRotation)
+: SdrHdl(rPnt, eNewKind),
+ mfShearX(fShearX),
+ mfRotation(fRotation)
{
}
@@ -2405,29 +2411,40 @@ void SdrCropHdl::CreateB2dIAObject()
::sdr::overlay::OverlayObject*
pOverlayObject = 0L;
- // animate focused handles
- if(IsFocusHdl() &&
(pHdlList->GetFocusHdl() == this))
- {
- if( nHdlSize >= 2 )
- nHdlSize = 1;
-
- BitmapEx aBmpEx2(
GetBitmapForHandle( aHandlesBitmap, nHdlSize + 1 ) );
-
- const sal_uInt32 nBlinkTime =
sal::static_int_cast<sal_uInt32>(rStyleSettings.GetCursorBlinkTime());
-
- pOverlayObject = new
::sdr::overlay::OverlayAnimatedBitmapEx(aPosition, aBmpEx1, aBmpEx2, nBlinkTime,
-
(sal_uInt16)(aBmpEx1.GetSizePixel().Width() - 1) >> 1,
-
(sal_uInt16)(aBmpEx1.GetSizePixel().Height() - 1) >> 1,
-
(sal_uInt16)(aBmpEx2.GetSizePixel().Width() - 1) >> 1,
-
(sal_uInt16)(aBmpEx2.GetSizePixel().Height() - 1) >> 1);
- }
- else
- {
- // create centered handle as
default
- pOverlayObject = new
::sdr::overlay::OverlayBitmapEx(aPosition, aBmpEx1,
-
(sal_uInt16)(aBmpEx1.GetSizePixel().Width() - 1) >> 1,
-
(sal_uInt16)(aBmpEx1.GetSizePixel().Height() - 1) >> 1);
- }
+ // animate focused handles
+ if(IsFocusHdl() && (pHdlList->GetFocusHdl() == this))
+ {
+ if( nHdlSize >= 2 )
+ nHdlSize = 1;
+
+ BitmapEx aBmpEx2( GetBitmapForHandle( aHandlesBitmap,
nHdlSize + 1 ) );
+
+ const sal_uInt32 nBlinkTime =
sal::static_int_cast<sal_uInt32>(rStyleSettings.GetCursorBlinkTime());
+
+ pOverlayObject = new
::sdr::overlay::OverlayAnimatedBitmapEx(
+ aPosition,
+ aBmpEx1,
+ aBmpEx2,
+ nBlinkTime,
+ (sal_uInt16)(aBmpEx1.GetSizePixel().Width() - 1)
>> 1,
+ (sal_uInt16)(aBmpEx1.GetSizePixel().Height() - 1)
>> 1,
+ (sal_uInt16)(aBmpEx2.GetSizePixel().Width() - 1)
>> 1,
+ (sal_uInt16)(aBmpEx2.GetSizePixel().Height() - 1)
>> 1,
+ mfShearX,
+ mfRotation);
+ }
+ else
+ {
+ // create centered handle as default
+ pOverlayObject = new ::sdr::overlay::OverlayBitmapEx(
+ aPosition,
+ aBmpEx1,
+ (sal_uInt16)(aBmpEx1.GetSizePixel().Width() - 1)
>> 1,
+ (sal_uInt16)(aBmpEx1.GetSizePixel().Height() - 1)
>> 1,
+ 0.0,
+ mfShearX,
+ mfRotation);
+ }
// OVERLAYMANAGER
if(pOverlayObject)
@@ -2442,6 +2459,8 @@ void SdrCropHdl::CreateB2dIAObject()
}
////////////////////////////////////////////////////////////////////////////////////////////////////
+// with the correction of crop handling I could get rid of the extra mirroring
flag, adapted stuff
+// accordingly
SdrCropViewHdl::SdrCropViewHdl(
const basegfx::B2DHomMatrix& rObjectTransform,
@@ -2449,16 +2468,14 @@ SdrCropViewHdl::SdrCropViewHdl(
double fCropLeft,
double fCropTop,
double fCropRight,
- double fCropBottom,
- bool bExtraMirrorXFromGraphic)
+ double fCropBottom)
: SdrHdl(Point(), HDL_USER),
maObjectTransform(rObjectTransform),
maGraphic(rGraphic),
mfCropLeft(fCropLeft),
mfCropTop(fCropTop),
mfCropRight(fCropRight),
- mfCropBottom(fCropBottom),
- mbExtraMirrorXFromGraphic(bExtraMirrorXFromGraphic)
+ mfCropBottom(fCropBottom)
{
}
@@ -2510,15 +2527,11 @@ void SdrCropViewHdl::CreateB2dIAObject()
if(bMirroredX)
{
aScale.setX(-aScale.getX());
- fCropLeft = mfCropRight;
- fCropRight = mfCropLeft;
}
if(bMirroredY)
{
aScale.setY(-aScale.getY());
- fCropTop = mfCropBottom;
- fCropBottom = mfCropTop;
}
// create target translate and scale
@@ -2583,14 +2596,14 @@ void SdrCropViewHdl::CreateB2dIAObject()
// create cropped transformation
basegfx::B2DHomMatrix aCroppedTransform;
- const bool bCombinedMirrorX(mbExtraMirrorXFromGraphic || bMirroredX);
+ const bool bCombinedMirrorX(bMirroredX);
aCroppedTransform.scale(
- bCombinedMirrorX ? -aCropped.getWidth() : aCropped.getWidth(),
- bMirroredY ? -aCropped.getHeight() : aCropped.getHeight());
+ aCropped.getWidth(),
+ aCropped.getHeight());
aCroppedTransform.translate(
- bCombinedMirrorX ? aCropped.getMaxX() : aCropped.getMinX(),
- bMirroredY ? aCropped.getMaxY() : aCropped.getMinY());
+ aCropped.getMinX(),
+ aCropped.getMinY());
aCroppedTransform = maObjectTransform * aCroppedTransform;
// prepare graphic primitive (tranformed)
Modified: openoffice/trunk/main/svx/source/svdraw/svdmrkv.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/svdraw/svdmrkv.cxx?rev=1561756&r1=1561755&r2=1561756&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/svdraw/svdmrkv.cxx (original)
+++ openoffice/trunk/main/svx/source/svdraw/svdmrkv.cxx Mon Jan 27 17:14:55 2014
@@ -654,6 +654,13 @@ sal_Bool SdrMarkView::ImpIsFrameHandles(
bFrmHdl=!pObj->hasSpecialDrag();
}
}
+
+ // no FrameHdl for crop
+ if(bFrmHdl && SDRDRAG_CROP == eDragMode)
+ {
+ bFrmHdl = sal_False;
+ }
+
return bFrmHdl;
}
@@ -767,136 +774,92 @@ void SdrMarkView::SetMarkHandles()
pHdl->SetObjHdlNum(sal_uInt16(i-nSiz0));
}
}
- else if( eDragMode==SDRDRAG_CROP )
- {
- const SdrGrafObj* pSdrGrafObj = dynamic_cast< const
SdrGrafObj* >(pMarkedObj);
-
- if(pSdrGrafObj)
+ else
+ {
+ sal_Bool bWdt0=aRect.Left()==aRect.Right();
+ sal_Bool bHgt0=aRect.Top()==aRect.Bottom();
+ if (bWdt0 && bHgt0)
{
- const SdrGrafCropItem& rCrop = static_cast< const
SdrGrafCropItem& >(pSdrGrafObj->GetMergedItem(SDRATTR_GRAFCROP));
-
- if(rCrop.GetLeft() || rCrop.GetTop() ||
rCrop.GetRight() ||rCrop.GetBottom())
- {
- basegfx::B2DHomMatrix aMatrix;
- basegfx::B2DPolyPolygon aPolyPolygon;
-
- pSdrGrafObj->TRGetBaseGeometry(aMatrix,
aPolyPolygon);
+ aHdl.AddHdl(new SdrHdl(aRect.TopLeft(),HDL_UPLFT));
+ }
+ else if (!bStdDrag && (bWdt0 || bHgt0))
+ {
+ aHdl.AddHdl(new SdrHdl(aRect.TopLeft() ,HDL_UPLFT));
+ aHdl.AddHdl(new SdrHdl(aRect.BottomRight(),HDL_LWRGT));
+ }
+ else
+ {
+ if (!bWdt0 && !bHgt0) aHdl.AddHdl(new
SdrHdl(aRect.TopLeft() ,HDL_UPLFT));
+ if ( !bHgt0) aHdl.AddHdl(new
SdrHdl(aRect.TopCenter() ,HDL_UPPER));
+ if (!bWdt0 && !bHgt0) aHdl.AddHdl(new
SdrHdl(aRect.TopRight() ,HDL_UPRGT));
+ if (!bWdt0 ) aHdl.AddHdl(new
SdrHdl(aRect.LeftCenter() ,HDL_LEFT ));
+ if (!bWdt0 ) aHdl.AddHdl(new
SdrHdl(aRect.RightCenter() ,HDL_RIGHT));
+ if (!bWdt0 && !bHgt0) aHdl.AddHdl(new
SdrHdl(aRect.BottomLeft() ,HDL_LWLFT));
+ if ( !bHgt0) aHdl.AddHdl(new
SdrHdl(aRect.BottomCenter(),HDL_LOWER));
+ if (!bWdt0 && !bHgt0) aHdl.AddHdl(new
SdrHdl(aRect.BottomRight() ,HDL_LWRGT));
+ }
+ }
+ }
+ }
+ else
+ {
+ bool bDone(false);
- // decompose to have current translate and scale
- basegfx::B2DVector aScale, aTranslate;
- double fRotate, fShearX;
+ // moved crop handling to non-frame part and the handle creation
to SdrGrafObj
+ if(1 == nMarkAnz && pMarkedObj && SDRDRAG_CROP == eDragMode)
+ {
+ const SdrGrafObj* pSdrGrafObj = dynamic_cast< const
SdrGrafObj* >(pMarkedObj);
- aMatrix.decompose(aScale, aTranslate, fRotate,
fShearX);
+ if(pSdrGrafObj)
+ {
+ pSdrGrafObj->addCropHandles(aHdl);
+ bDone = true;
+ }
+ }
- if(!aScale.equalZero())
+ if(!bDone)
+ {
+ for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++)
+ {
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ SdrPageView* pPV=pM->GetPageView();
+ const sal_uIntPtr nSiz0=aHdl.GetHdlCount();
+ pObj->AddToHdlList(aHdl);
+ const sal_uIntPtr nSiz1=aHdl.GetHdlCount();
+ bool bPoly=pObj->IsPolyObj();
+ const SdrUShortCont* pMrkPnts=pM->GetMarkedPoints();
+ for (sal_uIntPtr i=nSiz0; i<nSiz1; i++)
+ {
+ SdrHdl* pHdl=aHdl.GetHdl(i);
+ pHdl->SetObj(pObj);
+ pHdl->SetPageView(pPV);
+ pHdl->SetObjHdlNum(sal_uInt16(i-nSiz0));
+ if (bPoly)
+ {
+ sal_Bool bSelected=pMrkPnts!=NULL &&
pMrkPnts->Exist(sal_uInt16(i-nSiz0));
+ pHdl->SetSelected(bSelected);
+ //sal_Bool bPlus=bPlusHdlAlways;
+ if (bPlusHdlAlways || bSelected)
{
- // get crop scale
- const basegfx::B2DVector aCropScaleFactor(
-
pSdrGrafObj->GetGraphicObject().calculateCropScaling(
- aScale.getX(),
- aScale.getY(),
- rCrop.GetLeft(),
- rCrop.GetTop(),
- rCrop.GetRight(),
- rCrop.GetBottom()));
-
- // apply crop scale
- const double fCropLeft(rCrop.GetLeft() *
aCropScaleFactor.getX());
- const double fCropTop(rCrop.GetTop() *
aCropScaleFactor.getY());
- const double fCropRight(rCrop.GetRight() *
aCropScaleFactor.getX());
- const double fCropBottom(rCrop.GetBottom() *
aCropScaleFactor.getY());
-
- aHdl.AddHdl(
- new SdrCropViewHdl(
- aMatrix,
-
pSdrGrafObj->GetGraphicObject().GetGraphic(),
- fCropLeft,
- fCropTop,
- fCropRight,
- fCropBottom,
- pSdrGrafObj->IsMirrored()));
+ sal_uInt32
nPlusAnz=pObj->GetPlusHdlCount(*pHdl);
+ for (sal_uInt32 nPlusNum=0; nPlusNum<nPlusAnz;
nPlusNum++)
+ {
+ SdrHdl*
pPlusHdl=pObj->GetPlusHdl(*pHdl,nPlusNum);
+ if (pPlusHdl!=NULL)
+ {
+ pPlusHdl->SetObj(pObj);
+ pPlusHdl->SetPageView(pPV);
+ pPlusHdl->SetPlusHdl(sal_True);
+ aHdl.AddHdl(pPlusHdl);
+ }
+ }
}
}
}
-
- aHdl.AddHdl(new
SdrCropHdl(aRect.TopLeft() ,HDL_UPLFT));
- aHdl.AddHdl(new
SdrCropHdl(aRect.TopCenter() ,HDL_UPPER));
- aHdl.AddHdl(new
SdrCropHdl(aRect.TopRight() ,HDL_UPRGT));
- aHdl.AddHdl(new
SdrCropHdl(aRect.LeftCenter() ,HDL_LEFT ));
- aHdl.AddHdl(new
SdrCropHdl(aRect.RightCenter() ,HDL_RIGHT));
- aHdl.AddHdl(new
SdrCropHdl(aRect.BottomLeft() ,HDL_LWLFT));
- aHdl.AddHdl(new
SdrCropHdl(aRect.BottomCenter(),HDL_LOWER));
- aHdl.AddHdl(new
SdrCropHdl(aRect.BottomRight() ,HDL_LWRGT));
- }
- else
- {
- sal_Bool
bWdt0=aRect.Left()==aRect.Right();
- sal_Bool
bHgt0=aRect.Top()==aRect.Bottom();
- if (bWdt0 && bHgt0)
- {
- aHdl.AddHdl(new
SdrHdl(aRect.TopLeft(),HDL_UPLFT));
- }
- else if (!bStdDrag && (bWdt0 || bHgt0))
- {
- aHdl.AddHdl(new
SdrHdl(aRect.TopLeft() ,HDL_UPLFT));
- aHdl.AddHdl(new
SdrHdl(aRect.BottomRight(),HDL_LWRGT));
- }
- else
- {
- if (!bWdt0 && !bHgt0)
aHdl.AddHdl(new SdrHdl(aRect.TopLeft() ,HDL_UPLFT));
- if ( !bHgt0)
aHdl.AddHdl(new SdrHdl(aRect.TopCenter() ,HDL_UPPER));
- if (!bWdt0 && !bHgt0)
aHdl.AddHdl(new SdrHdl(aRect.TopRight() ,HDL_UPRGT));
- if (!bWdt0 )
aHdl.AddHdl(new SdrHdl(aRect.LeftCenter() ,HDL_LEFT ));
- if (!bWdt0 )
aHdl.AddHdl(new SdrHdl(aRect.RightCenter() ,HDL_RIGHT));
- if (!bWdt0 && !bHgt0)
aHdl.AddHdl(new SdrHdl(aRect.BottomLeft() ,HDL_LWLFT));
- if ( !bHgt0)
aHdl.AddHdl(new SdrHdl(aRect.BottomCenter(),HDL_LOWER));
- if (!bWdt0 && !bHgt0)
aHdl.AddHdl(new SdrHdl(aRect.BottomRight() ,HDL_LWRGT));
- }
- }
- }
- }
- else
- {
- for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz;
nMarkNum++)
- {
- const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
- SdrObject* pObj=pM->GetMarkedSdrObj();
- SdrPageView* pPV=pM->GetPageView();
- const sal_uIntPtr nSiz0=aHdl.GetHdlCount();
- pObj->AddToHdlList(aHdl);
- const sal_uIntPtr nSiz1=aHdl.GetHdlCount();
- bool bPoly=pObj->IsPolyObj();
- const SdrUShortCont*
pMrkPnts=pM->GetMarkedPoints();
- for (sal_uIntPtr i=nSiz0; i<nSiz1; i++)
- {
- SdrHdl* pHdl=aHdl.GetHdl(i);
- pHdl->SetObj(pObj);
- pHdl->SetPageView(pPV);
- pHdl->SetObjHdlNum(sal_uInt16(i-nSiz0));
- if (bPoly)
- {
- sal_Bool
bSelected=pMrkPnts!=NULL && pMrkPnts->Exist(sal_uInt16(i-nSiz0));
- pHdl->SetSelected(bSelected);
- //sal_Bool bPlus=bPlusHdlAlways;
- if (bPlusHdlAlways ||
bSelected)
- {
- sal_uInt32
nPlusAnz=pObj->GetPlusHdlCount(*pHdl);
- for (sal_uInt32
nPlusNum=0; nPlusNum<nPlusAnz; nPlusNum++)
- {
- SdrHdl*
pPlusHdl=pObj->GetPlusHdl(*pHdl,nPlusNum);
- if
(pPlusHdl!=NULL)
- {
-
pPlusHdl->SetObj(pObj);
-
pPlusHdl->SetPageView(pPV);
-
pPlusHdl->SetPlusHdl(sal_True);
-
aHdl.AddHdl(pPlusHdl);
- }
- }
- }
- }
- }
- } // for nMarkNum
- } // if bFrmHdl else
+ }
+ }
+ }
// GluePoint-Handles
for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++)
Modified: openoffice/trunk/main/svx/source/svdraw/svdograf.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/svdraw/svdograf.cxx?rev=1561756&r1=1561755&r2=1561756&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/svdraw/svdograf.cxx (original)
+++ openoffice/trunk/main/svx/source/svdraw/svdograf.cxx Mon Jan 27 17:14:55
2014
@@ -70,6 +70,7 @@
#include <drawinglayer/processor2d/objectinfoextractor2d.hxx>
#include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
#include <unotools/cacheoptions.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::io;
@@ -1676,4 +1677,116 @@ Reference< XInputStream > SdrGrafObj::ge
return xStream;
}
+// moved crop handle creation here; this is the object type using them
+void SdrGrafObj::addCropHandles(SdrHdlList& rTarget) const
+{
+ basegfx::B2DHomMatrix aMatrix;
+ basegfx::B2DPolyPolygon aPolyPolygon;
+
+ // get object transformation
+ TRGetBaseGeometry(aMatrix, aPolyPolygon);
+
+ // part of object transformation correction, but used later, so defined
outside next scope
+ double fShearX(0.0), fRotate(0.0);
+
+ { // TTTT correct shear, it comes currently mirrored from
TRGetBaseGeometry, can be removed with aw080
+ basegfx::B2DTuple aScale;
+ basegfx::B2DTuple aTranslate;
+
+ aMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ if(!basegfx::fTools::equalZero(fShearX))
+ {
+ // shearX is used, correct it
+ fShearX = -fShearX;
+ }
+
+ aMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aScale,
+ fShearX,
+ fRotate,
+ aTranslate);
+ }
+
+ // get crop values
+ const SdrGrafCropItem& rCrop = static_cast< const SdrGrafCropItem&
>(GetMergedItem(SDRATTR_GRAFCROP));
+
+ if(rCrop.GetLeft() || rCrop.GetTop() || rCrop.GetRight()
||rCrop.GetBottom())
+ {
+ // decompose object transformation to have current translate and scale
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+
+ aMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ if(!aScale.equalZero())
+ {
+ // get crop scale
+ const basegfx::B2DVector aCropScaleFactor(
+ GetGraphicObject().calculateCropScaling(
+ aScale.getX(),
+ aScale.getY(),
+ rCrop.GetLeft(),
+ rCrop.GetTop(),
+ rCrop.GetRight(),
+ rCrop.GetBottom()));
+
+ // apply crop scale
+ const double fCropLeft(rCrop.GetLeft() * aCropScaleFactor.getX());
+ const double fCropTop(rCrop.GetTop() * aCropScaleFactor.getY());
+ const double fCropRight(rCrop.GetRight() *
aCropScaleFactor.getX());
+ const double fCropBottom(rCrop.GetBottom() *
aCropScaleFactor.getY());
+ basegfx::B2DHomMatrix aMatrixForCropViewHdl(aMatrix);
+
+ if(IsMirrored())
+ {
+ // create corrected new matrix, TTTT can be removed with aw080
+ // the old mirror only can mirror horizontally; the vertical
mirror
+ // is faked by using the horizontal and 180 degree rotation.
Since
+ // the object can be rotated differently from 180 degree, this
is
+ // not safe to detect. Just correct horizontal mirror (which is
+ // in IsMirrored()) and keep the rotation angle
+ // caution: Do not modify aMatrix, it is used below to
calculate
+ // the exact handle positions
+ basegfx::B2DHomMatrix aPreMultiply;
+
+ // mirrored X, apply
+ aPreMultiply.translate(-0.5, 0.0);
+ aPreMultiply.scale(-1.0, 1.0);
+ aPreMultiply.translate(0.5, 0.0);
+
+ aMatrixForCropViewHdl = aMatrixForCropViewHdl * aPreMultiply;
+ }
+
+ rTarget.AddHdl(
+ new SdrCropViewHdl(
+ aMatrixForCropViewHdl,
+ GetGraphicObject().GetGraphic(),
+ fCropLeft,
+ fCropTop,
+ fCropRight,
+ fCropBottom));
+ }
+ }
+
+ basegfx::B2DPoint aPos;
+
+ aPos = aMatrix * basegfx::B2DPoint(0.0, 0.0);
+ rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()),
basegfx::fround(aPos.getY())), HDL_UPLFT, fShearX, fRotate));
+ aPos = aMatrix * basegfx::B2DPoint(0.5, 0.0);
+ rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()),
basegfx::fround(aPos.getY())), HDL_UPPER, fShearX, fRotate));
+ aPos = aMatrix * basegfx::B2DPoint(1.0, 0.0);
+ rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()),
basegfx::fround(aPos.getY())), HDL_UPRGT, fShearX, fRotate));
+ aPos = aMatrix * basegfx::B2DPoint(0.0, 0.5);
+ rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()),
basegfx::fround(aPos.getY())), HDL_LEFT , fShearX, fRotate));
+ aPos = aMatrix * basegfx::B2DPoint(1.0, 0.5);
+ rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()),
basegfx::fround(aPos.getY())), HDL_RIGHT, fShearX, fRotate));
+ aPos = aMatrix * basegfx::B2DPoint(0.0, 1.0);
+ rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()),
basegfx::fround(aPos.getY())), HDL_LWLFT, fShearX, fRotate));
+ aPos = aMatrix * basegfx::B2DPoint(0.5, 1.0);
+ rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()),
basegfx::fround(aPos.getY())), HDL_LOWER, fShearX, fRotate));
+ aPos = aMatrix * basegfx::B2DPoint(1.0, 1.0);
+ rTarget.AddHdl(new SdrCropHdl(Point(basegfx::fround(aPos.getX()),
basegfx::fround(aPos.getY())), HDL_LWRGT, fShearX, fRotate));
+}
+
// eof