diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-01-05 13:44:12 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-01-05 13:44:12 +0000 |
commit | db75fe5503d06675e3c57349c2201ea42daab83a (patch) | |
tree | eae8d4dcba9c37c7f725462e3fc6fc9bfa7efb16 | |
parent | ab9bee4720820ebd1a2d851bcb4f7db79145931e (diff) |
CWS-TOOLING: integrate CWS aw059
2008-12-16 16:15:40 +0100 aw r265557 : #i95645# avoid expensive tries to stream in graphic data when stream is at end anyways
2008-12-15 16:49:58 +0100 wg r265512 : i97278
2008-12-12 16:02:15 +0100 aw r265427 : #i95645# new formulation was wrong in two places; thanks go to THB. Thanks!
2008-12-12 15:49:06 +0100 aw r265425 : #i95645# refined formulation of AA on/off constraints for VCLCanvas
2008-12-12 14:51:26 +0100 aw r265420 : #i95645# workaround for DrawTransparent of button hilighting when remote displayed; somehow GDI+ does bad dithering in that case
2008-12-12 13:23:00 +0100 aw r265414 : removed temporary build hack; it made it's way in using the rebase; with SVN the rebase is not based on pure checkouts, but uses local changes.
2008-12-11 19:35:59 +0100 aw r265352 : #i95645# need to switch off AA for WNT and UNX, the VCLCanvas is currently not able to handle AA correctly
2008-12-11 16:05:17 +0100 thb r265327 : #i95645# Changed defaults to on; as for the while svx dialog is not changed
2008-12-10 13:40:38 +0100 aw r265180 : #i95645# changed pixel snap to basegfx::fround
2008-12-10 13:25:45 +0100 aw r265177 : corrected linux warning
2008-12-10 12:28:02 +0100 aw r265167 : #i95645# added support for pixel snap/linux resp. no AA for mac (also pixel snap) when AA is switched off to the basegfx::B2DPolyPolygon painting VCL methods; needed for e.g. selection in SC and SW
2008-12-09 18:44:39 +0100 aw r265136 : #i95645# corrected filled path construction
2008-12-09 18:12:40 +0100 aw r265133 : #i95645# added support for non-AAd transparent paints
2008-12-09 18:11:58 +0100 aw r265132 : #i95645# forced selection without AA
2008-12-09 18:11:29 +0100 aw r265131 : #i88893# smoothed/corrected SW selection rects for transparent selection, forced selection without AA
2008-12-09 15:21:39 +0100 aw r265094 : #i95645# corrected FormControl full drag
2008-12-09 15:11:26 +0100 aw r265093 : #i95645# make gdiplus usages more safe when no line or fill color is selected
2008-12-09 14:30:09 +0100 aw r265085 : #i95645# added GDIPlus support
2008-12-09 13:41:06 +0100 aw r265081 : #i95645# added simple AA using GDIPlis to VCL
2008-12-09 13:40:46 +0100 aw r265080 : #i95645# added simple AA using GDIPlis to VCL
2008-12-09 13:40:29 +0100 aw r265079 : #i95645# added simple AA using GDIPlis to VCL
2008-12-09 13:33:16 +0100 aw r265078 : #i95645# changes to requirements, discussed with FPE
2008-12-08 14:11:39 +0100 aw r264995 : #i95646# added missing extra-wireframe for SdrDragObjOwn implementations when object has no border
2008-12-08 14:11:00 +0100 aw r264994 : #i95646# corrected RenderMarkerArrayPrimitive2D OutDev usage in VclProcessor2D
2008-12-08 12:15:10 +0100 ufi r264987 : aw059
2008-12-08 12:14:40 +0100 ufi r264986 : aw059
2008-12-05 13:16:18 +0100 aw r264905 : CWS-TOOLING: rebase CWS aw059 to trunk@264807 (milestone: DEV300:m37)
2008-12-04 11:29:48 +0100 aw r264827 : #i95645# corrected warning
2008-12-03 14:43:39 +0100 aw r264783 : #i95645# simplified overlay manager and objects to stl vector; added stuff to render some more overlay to primitive renderer to get AA support for WIN32
2008-12-03 14:42:43 +0100 aw r264782 : #i95645# added test for WIN32 for AA if cairo canvas is available
2008-12-03 14:42:13 +0100 aw r264781 : #i95645# removed unused options for writer selection overlay
2008-12-03 14:41:51 +0100 aw r264780 : #i95645# removed unused options for calc overlay
2008-12-03 14:41:21 +0100 aw r264779 : #i95645# small corrections in canvas renderer
2008-12-02 18:32:31 +0100 aw r264730 : #i95646# merged cairo version from THB's CWS cairosource01
2008-12-02 15:25:45 +0100 aw r264705 : #i95645# added helpers for the MarkerArrayPrimitive2D change which support buffered creation of the most used markers
2008-12-02 12:50:01 +0100 aw r264690 : #i95645# added a non-saved method IsAAPossibleOnThisSystem to SvtOptionsDrawinglayer to quickly test if AA can be offered on the system, added buffering of that check.
2008-12-02 12:48:51 +0100 aw r264689 : #i95645# unified MarkerArrayPrimitive2D to work bitmap-orientated, adapted usages. Added buffered preparation for needed markers. Minor adaptions for AA
2008-12-02 12:47:53 +0100 aw r264688 : #i95645# unified MarkerArrayPrimitive2D to no longer work on a enum and types of markers, but to use a BitmapEx (or any other Bitmap object) which will be displayed centerd and in discrete coordinates at positions. Adapted decomposition and all usages. Corrected minor stuff with grid primitive
2008-11-28 17:11:12 +0100 thb r264565 : #i95645# Added two more lists to config; to be able to differentiate canvas capabilities
2008-11-28 17:03:27 +0100 thb r264563 : #i95645# Added two more lists to config; to be able to differentiate canvas capabilities
2008-11-28 17:00:07 +0100 thb r264562 : #i95645# Added two more lists to config; to be able to differentiate canvas capabilities
2008-11-28 16:59:51 +0100 thb r264561 : #i95645# Added two more lists to config; to be able to differentiate canvas capabilities
2008-11-27 19:13:42 +0100 aw r264519 : #i95646# optimized getLength() a little bit
2008-11-27 19:12:50 +0100 aw r264518 : #i95646# corrected AA expansion of invalidate frame; buffered discrete distance at OM
2008-11-27 18:50:05 +0100 aw r264516 : #i95646# corrected fit to frame texts for WIN32
2008-11-27 15:32:15 +0100 aw r264496 : #i95646# helplines corrected
2008-11-27 15:32:05 +0100 aw r264495 : #i95646# helplines corrected
2008-11-27 15:01:30 +0100 aw r264492 : #i95646# enable AA support for old polygons, especially to get support for MetaFile output
2008-11-27 14:33:28 +0100 aw r264489 : #i95646# AA support for wireframe overlays
2008-11-27 13:40:54 +0100 aw r264485 : #i95646# added full repaint when AA option changes
2008-11-27 13:29:19 +0100 aw r264482 : #i95646# corrected handling of bSolidDragging config entries
2008-11-27 13:29:08 +0100 aw r264481 : #i95646# corrected handling of bSolidDragging config entries
2008-11-27 11:30:12 +0100 aw r264469 : #i95646# corrected IsAAPossibleOnThisSystem implementation
2008-11-26 16:33:04 +0100 aw r264420 : #i95646# adapted OfaViewTabPage to use disable mechanism for AA and HWAccel
2008-11-26 15:49:19 +0100 aw r264406 : #i95646# added DlgEdObj::getFullDragClone() to create specialized simple SdrUnoObj clones for solid dragging
2008-11-26 15:48:11 +0100 aw r264405 : #i95646# changed derivation of ViewObjectContactOfUnoControl to get a valid isPrimitiveVisible() implementation
2008-11-26 14:11:37 +0100 aw r264385 : #i88893# added new look for selection in sw
2008-11-26 11:32:33 +0100 aw r264360 : corrected compiler warning
2008-11-25 18:46:29 +0100 aw r264328 : #i95646# snapshot with FullDrag clones
2008-11-25 18:46:07 +0100 aw r264327 : #i95646# snapshot with FullDrag clones
2008-11-25 18:45:43 +0100 aw r264326 : #i95646# snapshot with FullDrag clones
2008-11-25 18:19:04 +0100 thb r264324 : #i96585# Added missing inline specifier
2008-11-25 13:16:25 +0100 aw r264285 : #i95646# next snapshot
2008-11-25 13:15:33 +0100 aw r264284 : #i95646# next snapshot
2008-11-25 13:15:12 +0100 aw r264283 : #i95646# next snapshot
2008-11-25 13:14:51 +0100 aw r264282 : #i95646# next snapshot
2008-11-20 13:40:49 +0100 aw r264045 : #i95646# stable snapshot
2008-11-20 13:40:29 +0100 aw r264044 : #i95646# stable snapshot
2008-11-20 13:40:06 +0100 aw r264043 : #i95646# stable snapshot
2008-11-20 13:39:45 +0100 aw r264042 : #i95646# stable snapshot
2008-11-18 11:53:39 +0100 aw r263758 : #i95646# snapshot for linux test build
2008-11-18 11:52:54 +0100 aw r263757 : #i95646# snapshot for linux test build
2008-11-18 11:52:02 +0100 aw r263756 : #i95646# snapshot for linux test build
2008-11-14 18:17:49 +0100 aw r263692 : #i95646# snapshot with most stuff working
2008-11-14 18:14:26 +0100 aw r263691 : #i95646# snapshot with most stuff working
2008-11-14 18:12:50 +0100 aw r263690 : #i95646# snapshot with most stuff working
2008-11-14 18:12:16 +0100 aw r263689 : #i95646# snapshot with most stuff working
2008-11-14 18:11:41 +0100 aw r263688 : #i95646# snapshot with most stuff working
2008-11-07 18:44:22 +0100 aw r263479 : #i95968# better support PrefMapMode; special for MAP_PIXEL was missing
2008-11-05 17:39:15 +0100 aw r263356 : #i95644# #i95645# #i95646# bigger change done, saving for another experiment
2008-11-05 17:39:02 +0100 aw r263355 : #i95644# #i95645# #i95646# bigger change done, saving for another experiment
2008-11-05 12:28:32 +0100 aw r263350 : #i95644# #i95645# #i95646# in-between state before bigger change
2008-11-05 12:27:51 +0100 aw r263349 : #i95644# #i95645# #i95646# in-between state before bigger change
2008-11-05 12:26:58 +0100 aw r263348 : #i95644# #i95645# #i95646# in-between state before bigger change
2008-11-05 12:26:17 +0100 aw r263347 : #i95644# #i95645# #i95646# in-between state before bigger change
2008-11-05 12:25:55 +0100 aw r263346 : #i95644# #i95645# #i95646# in-between state before bigger change
108 files changed, 5371 insertions, 3855 deletions
diff --git a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx index 926ecfe96137..9e3e322a3ac4 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx @@ -99,6 +99,7 @@ #define PRIMITIVE2D_ID_CHARTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 48) #define PRIMITIVE2D_ID_STRUCTURETAGRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 49) #define PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 50) +#define PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 51) #define PRIMITIVE2D_ID_HITTESTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 51) ////////////////////////////////////////////////////////////////////////////// diff --git a/drawinglayer/inc/drawinglayer/primitive2d/gridprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/gridprimitive2d.hxx index ff0356f07988..f0aad415bfce 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/gridprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/gridprimitive2d.hxx @@ -39,6 +39,7 @@ #include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/color/bcolor.hxx> +#include <vcl/bitmapex.hxx> ////////////////////////////////////////////////////////////////////////////// // GridPrimitive2D class @@ -58,6 +59,7 @@ namespace drawinglayer sal_uInt32 mnSubdivisionsX; sal_uInt32 mnSubdivisionsY; basegfx::BColor maBColor; + BitmapEx maCrossMarker; // the last used object to view transformtion and the last Viewport, // used from getDecomposition for decide buffering @@ -77,7 +79,8 @@ namespace drawinglayer double fSmallestSubdivisionViewDistance, sal_uInt32 nSubdivisionsX, sal_uInt32 nSubdivisionsY, - const basegfx::BColor& rBColor); + const basegfx::BColor& rBColor, + const BitmapEx& rCrossMarker); // get data const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } @@ -88,6 +91,7 @@ namespace drawinglayer sal_uInt32 getSubdivisionsX() const { return mnSubdivisionsX; } sal_uInt32 getSubdivisionsY() const { return mnSubdivisionsY; } const basegfx::BColor& getBColor() const { return maBColor; } + const BitmapEx& getCrossMarker() const { return maCrossMarker; } // compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; diff --git a/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx index a5927d41b3a6..4e8357a3eac1 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx @@ -61,7 +61,7 @@ namespace drawinglayer HelplineStyle2D meStyle; basegfx::BColor maRGBColA; basegfx::BColor maRGBColB; - double mfViewDashLength; + double mfDiscreteDashLength; // the last used object to view transformtion and the last Viewport, // used from getDecomposition for decide buffering @@ -79,7 +79,7 @@ namespace drawinglayer HelplineStyle2D eStyle, const basegfx::BColor& rRGBColA, const basegfx::BColor& aRGBColB, - double fViewDashLength); + double fDiscreteDashLength); // get data const basegfx::B2DPoint getPosition() const { return maPosition; } @@ -87,7 +87,7 @@ namespace drawinglayer HelplineStyle2D getStyle() const { return meStyle; } const basegfx::BColor& getRGBColA() const { return maRGBColA; } const basegfx::BColor& getRGBColB() const { return maRGBColB; } - double getViewDashLength() const { return mfViewDashLength; } + double getDiscreteDashLength() const { return mfDiscreteDashLength; } // compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; diff --git a/drawinglayer/inc/drawinglayer/primitive2d/markerarrayprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/markerarrayprimitive2d.hxx index f19b2562e547..350471f4aff3 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/markerarrayprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/markerarrayprimitive2d.hxx @@ -38,6 +38,7 @@ #include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <basegfx/color/bcolor.hxx> +#include <vcl/bitmapex.hxx> ////////////////////////////////////////////////////////////////////////////// // MarkerPrimitive2D class @@ -46,25 +47,11 @@ namespace drawinglayer { namespace primitive2d { - enum MarkerStyle2D - { - /// Point: Uses RGBColor, 1x1 pixel - MARKERSTYLE2D_POINT, - - /// Cross: Uses RGBColor, 3x3 pixel, centered, form of a plus sign - MARKERSTYLE2D_CROSS, - - /// Gluepoint: Uses RGBColor as outline and hardcoded COL_LIGHTBLUE as inner - /// line pen, 7x7 pixel, centered, looks like a x with thee pixel lines - MARKERSTYLE2D_GLUEPOINT - }; - class MarkerArrayPrimitive2D : public BasePrimitive2D { private: std::vector< basegfx::B2DPoint > maPositions; - basegfx::BColor maRGBColor; - MarkerStyle2D meStyle; + BitmapEx maMarker; protected: // create local decomposition @@ -73,13 +60,11 @@ namespace drawinglayer public: MarkerArrayPrimitive2D( const std::vector< basegfx::B2DPoint >& rPositions, - MarkerStyle2D eStyle, - const basegfx::BColor& rRGBColor); + const BitmapEx& rMarker); // get data const std::vector< basegfx::B2DPoint >& getPositions() const { return maPositions; } - const basegfx::BColor& getRGBColor() const { return maRGBColor; } - MarkerStyle2D getStyle() const { return meStyle; } + const BitmapEx& getMarker() const { return maMarker; } // compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; diff --git a/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx index bbe382219f49..48ec5e80aa09 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx @@ -40,6 +40,7 @@ #include <drawinglayer/attribute/lineattribute.hxx> #include <drawinglayer/attribute/strokeattribute.hxx> #include <drawinglayer/attribute/linestartendattribute.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> ////////////////////////////////////////////////////////////////////////////// // PolygonHairlinePrimitive2D class @@ -86,7 +87,10 @@ namespace drawinglayer basegfx::B2DPolygon maPolygon; basegfx::BColor maRGBColorA; basegfx::BColor maRGBColorB; - double mfDashLength; + double mfDiscreteDashLength; + + // decomposition is view-dependent, remember last InverseObjectToViewTransformation + basegfx::B2DHomMatrix maLastInverseObjectToViewTransformation; protected: // local decomposition. @@ -97,13 +101,13 @@ namespace drawinglayer const basegfx::B2DPolygon& rPolygon, const basegfx::BColor& rRGBColorA, const basegfx::BColor& rRGBColorB, - double fDashLength); + double fDiscreteDashLength); // get data const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; } const basegfx::BColor& getRGBColorA() const { return maRGBColorA; } const basegfx::BColor& getRGBColorB() const { return maRGBColorB; } - double getDashLength() const { return mfDashLength; } + double getDiscreteDashLength() const { return mfDiscreteDashLength; } // compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; @@ -111,6 +115,9 @@ namespace drawinglayer // get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; + // get local decomposition. Overloaded since this decomposition is view-dependent + virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + // provide unique ID DeclPrimitrive2DIDBlock() }; diff --git a/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx index a2e103cd6831..9991a3109e10 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx @@ -45,7 +45,7 @@ #include <drawinglayer/attribute/linestartendattribute.hxx> ////////////////////////////////////////////////////////////////////////////// -// PolyPolygonStrokePrimitive2D class +// PolyPolygonHairlinePrimitive2D class namespace drawinglayer { @@ -81,6 +81,50 @@ namespace drawinglayer } // end of namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// +// PolyPolygonMarkerPrimitive2D class + +namespace drawinglayer +{ + namespace primitive2d + { + class PolyPolygonMarkerPrimitive2D : public BasePrimitive2D + { + private: + basegfx::B2DPolyPolygon maPolyPolygon; + basegfx::BColor maRGBColorA; + basegfx::BColor maRGBColorB; + double mfDiscreteDashLength; + + protected: + // local decomposition. + virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + public: + PolyPolygonMarkerPrimitive2D( + const basegfx::B2DPolyPolygon& rPolyPolygon, + const basegfx::BColor& rRGBColorA, + const basegfx::BColor& rRGBColorB, + double fDiscreteDashLength); + + // get data + basegfx::B2DPolyPolygon getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::BColor& getRGBColorA() const { return maRGBColorA; } + const basegfx::BColor& getRGBColorB() const { return maRGBColorB; } + double getDiscreteDashLength() const { return mfDiscreteDashLength; } + + // compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const; + + // get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; + + // provide unique ID + DeclPrimitrive2DIDBlock() + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// // PolyPolygonStrokePrimitive2D class namespace drawinglayer diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx index acac9fa01956..d322ee87b48c 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx @@ -82,6 +82,9 @@ namespace drawinglayer double getUnderlineHeight() const; double getUnderlineOffset() const; double getStrikeoutOffset() const; +#ifdef WIN32 + double getCurrentFontRelation() const; +#endif double getTextWidth( const String& rText, diff --git a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx index b8461ae90607..ffceaf8ce04a 100644 --- a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx @@ -297,7 +297,18 @@ namespace drawinglayer { const MapMode aMapMode100thmm(MAP_100TH_MM); - const Size aBitmapSize(Application::GetDefaultDevice()->LogicToLogic(getGraphicObject().GetPrefSize(), getGraphicObject().GetPrefMapMode(), aMapMode100thmm)); + Size aBitmapSize(getGraphicObject().GetPrefSize()); + + // #i95968# better support PrefMapMode; special for MAP_PIXEL was missing + if(MAP_PIXEL == getGraphicObject().GetPrefMapMode().GetMapUnit()) + { + aBitmapSize = Application::GetDefaultDevice()->PixelToLogic(aBitmapSize, aMapMode100thmm); + } + else + { + aBitmapSize = Application::GetDefaultDevice()->LogicToLogic(aBitmapSize, getGraphicObject().GetPrefMapMode(), aMapMode100thmm); + } + const double fDivX(aBitmapSize.Width() - getGraphicAttr().GetLeftCrop() - getGraphicAttr().GetRightCrop()); const double fDivY(aBitmapSize.Height() - getGraphicAttr().GetTopCrop() - getGraphicAttr().GetBottomCrop()); diff --git a/drawinglayer/source/primitive2d/gridprimitive2d.cxx b/drawinglayer/source/primitive2d/gridprimitive2d.cxx index c122b123fa7b..df4171309389 100644 --- a/drawinglayer/source/primitive2d/gridprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/gridprimitive2d.cxx @@ -175,7 +175,7 @@ namespace drawinglayer { double fF(fX + fSmallStepX); - for(sal_uInt32 a(0L); a < nSmallStepsX && fF < aScale.getX(); a++, fF += fSmallStepX) + for(sal_uInt32 a(1L); a < nSmallStepsX && fF < aScale.getX(); a++, fF += fSmallStepX) { const basegfx::B2DPoint aViewPos(aRST * basegfx::B2DPoint(fF, fY)); @@ -191,7 +191,7 @@ namespace drawinglayer { double fF(fY + fSmallStepY); - for(sal_uInt32 a(0L); a < nSmallStepsY && fF < aScale.getY(); a++, fF += fSmallStepY) + for(sal_uInt32 a(1L); a < nSmallStepsY && fF < aScale.getY(); a++, fF += fSmallStepY) { const basegfx::B2DPoint aViewPos(aRST * basegfx::B2DPoint(fX, fF)); @@ -222,7 +222,16 @@ namespace drawinglayer // add MarkerArrayPrimitive2D if cross markers were added if(nCountCross) { - aRetval[nInsertCounter++] = Primitive2DReference(new MarkerArrayPrimitive2D(aPositionsCross, MARKERSTYLE2D_CROSS, getBColor())); + if(!getSubdivisionsX() && !getSubdivisionsY()) + { + // no subdivisions, so fall back to points at grid positions, no need to + // visualize a difference between divisions and sub-divisions + aRetval[nInsertCounter++] = Primitive2DReference(new PointArrayPrimitive2D(aPositionsCross, getBColor())); + } + else + { + aRetval[nInsertCounter++] = Primitive2DReference(new MarkerArrayPrimitive2D(aPositionsCross, getCrossMarker())); + } } } @@ -237,7 +246,8 @@ namespace drawinglayer double fSmallestSubdivisionViewDistance, sal_uInt32 nSubdivisionsX, sal_uInt32 nSubdivisionsY, - const basegfx::BColor& rBColor) + const basegfx::BColor& rBColor, + const BitmapEx& rCrossMarker) : BasePrimitive2D(), maTransform(rTransform), mfWidth(fWidth), @@ -247,6 +257,7 @@ namespace drawinglayer mnSubdivisionsX(nSubdivisionsX), mnSubdivisionsY(nSubdivisionsY), maBColor(rBColor), + maCrossMarker(rCrossMarker), maLastObjectToViewTransformation(), maLastViewport() { @@ -265,7 +276,8 @@ namespace drawinglayer && getSmallestSubdivisionViewDistance() == rCompare.getSmallestSubdivisionViewDistance() && getSubdivisionsX() == rCompare.getSubdivisionsX() && getSubdivisionsY() == rCompare.getSubdivisionsY() - && getBColor() == rCompare.getBColor()); + && getBColor() == rCompare.getBColor() + && getCrossMarker() == rCompare.getCrossMarker()); } return false; diff --git a/drawinglayer/source/primitive2d/helplineprimitive2d.cxx b/drawinglayer/source/primitive2d/helplineprimitive2d.cxx index 510d55d8337c..3232e635b561 100644 --- a/drawinglayer/source/primitive2d/helplineprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/helplineprimitive2d.cxx @@ -62,8 +62,6 @@ namespace drawinglayer { // position to view coordinates, DashLen and DashLen in logic const basegfx::B2DPoint aViewPosition(rViewInformation.getObjectToViewTransformation() * getPosition()); - const double fLogicDashLen((rViewInformation.getInverseObjectToViewTransformation() * - basegfx::B2DVector(getViewDashLength(), 0.0)).getLength()); switch(getStyle()) { @@ -79,7 +77,7 @@ namespace drawinglayer aLineA.append(aStartA); aLineA.append(aEndA); aLineA.transform(rViewInformation.getInverseObjectToViewTransformation()); - PolygonMarkerPrimitive2D* pNewA = new PolygonMarkerPrimitive2D(aLineA, getRGBColA(), getRGBColB(), fLogicDashLen); + PolygonMarkerPrimitive2D* pNewA = new PolygonMarkerPrimitive2D(aLineA, getRGBColA(), getRGBColB(), getDiscreteDashLength()); aTempPrimitiveTarget.push_back(pNewA); const basegfx::B2DVector aPerpendicularNormalizedDirection(basegfx::getPerpendicular(aNormalizedDirection)); @@ -89,7 +87,7 @@ namespace drawinglayer aLineB.append(aStartB); aLineB.append(aEndB); aLineB.transform(rViewInformation.getInverseObjectToViewTransformation()); - PolygonMarkerPrimitive2D* pNewB = new PolygonMarkerPrimitive2D(aLineB, getRGBColA(), getRGBColB(), fLogicDashLen); + PolygonMarkerPrimitive2D* pNewB = new PolygonMarkerPrimitive2D(aLineB, getRGBColA(), getRGBColB(), getDiscreteDashLength()); aTempPrimitiveTarget.push_back(pNewB); break; @@ -140,7 +138,7 @@ namespace drawinglayer { basegfx::B2DPolygon aPart(aResult.getB2DPolygon(a)); aPart.transform(rViewInformation.getInverseObjectToViewTransformation()); - PolygonMarkerPrimitive2D* pNew = new PolygonMarkerPrimitive2D(aPart, getRGBColA(), getRGBColB(), fLogicDashLen); + PolygonMarkerPrimitive2D* pNew = new PolygonMarkerPrimitive2D(aPart, getRGBColA(), getRGBColB(), getDiscreteDashLength()); aTempPrimitiveTarget.push_back(pNew); } } @@ -168,14 +166,14 @@ namespace drawinglayer HelplineStyle2D eStyle, const basegfx::BColor& rRGBColA, const basegfx::BColor& rRGBColB, - double fViewDashLength) + double fDiscreteDashLength) : BasePrimitive2D(), maPosition(rPosition), maDirection(rDirection), meStyle(eStyle), maRGBColA(rRGBColA), maRGBColB(rRGBColB), - mfViewDashLength(fViewDashLength), + mfDiscreteDashLength(fDiscreteDashLength), maLastObjectToViewTransformation(), maLastViewport() { @@ -192,7 +190,7 @@ namespace drawinglayer && getStyle() == rCompare.getStyle() && getRGBColA() == rCompare.getRGBColA() && getRGBColB() == rCompare.getRGBColB() - && getViewDashLength() == rCompare.getViewDashLength()); + && getDiscreteDashLength() == rCompare.getDiscreteDashLength()); } return false; diff --git a/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx b/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx index 78aa04d85a03..5737b9ef6cec 100644 --- a/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx @@ -38,12 +38,12 @@ #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> -#include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> +#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -58,121 +58,39 @@ namespace drawinglayer Primitive2DSequence MarkerArrayPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const { Primitive2DSequence xRetval; + const std::vector< basegfx::B2DPoint >& rPositions = getPositions(); + const sal_uInt32 nMarkerCount(rPositions.size()); - switch(getStyle()) + if(nMarkerCount && !getMarker().IsEmpty()) { - default : // MARKERSTYLE2D_POINT - { - // the default produces single points in given color, thus it is a good fallback for - // all evtl. non-implented decompositions, too - const Primitive2DReference xReference(new PointArrayPrimitive2D(getPositions(), getRGBColor())); - xRetval = Primitive2DSequence(&xReference, 1); - break; - } - case MARKERSTYLE2D_CROSS : - case MARKERSTYLE2D_GLUEPOINT : + // get pixel size + Size aBitmapSize(getMarker().GetSizePixel()); + + if(aBitmapSize.Width() && aBitmapSize.Height()) { - // schema to use here: create one ZeroPoint-centered template incarnation of the marker using other primitives - // and multiply it using a seuence of TransformPrimitive2D containing it - const std::vector< basegfx::B2DPoint >& rPositions = getPositions(); - const sal_uInt32 nMarkerCount(rPositions.size()); + // get logic half pixel size + basegfx::B2DVector aLogicHalfSize(rViewInformation.getInverseObjectToViewTransformation() * + basegfx::B2DVector(aBitmapSize.getWidth() - 1.0, aBitmapSize.getHeight() - 1.0)); + + // use half size for expand + aLogicHalfSize *= 0.5; + + // number of primitives is known; realloc accordingly + xRetval.realloc(nMarkerCount); - if(nMarkerCount) + for(sal_uInt32 a(0); a < nMarkerCount; a++) { - // get the size of one dicscrete display unit in logic size - const basegfx::B2DVector aDist(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 1.0)); - Primitive2DSequence aTemplate; - - switch(getStyle()) - { - case MARKERSTYLE2D_CROSS : - { - // two lines forming the intended cross. Prefer vector decompose - // over also possible bitmap/PointArrayPrimitive decompose for better quality. - // Also make the discrete unit based lines one pixel longer since non-closed - // polygon primitives will be rendered without the last point by convention - aTemplate.realloc(2); - basegfx::B2DPolygon aPolygon; - - aPolygon.append(basegfx::B2DPoint(aDist.getX() * -1.0, 0.0)); - aPolygon.append(basegfx::B2DPoint(aDist.getX() * 2.0, 0.0)); - aTemplate[0] = Primitive2DReference(new PolygonHairlinePrimitive2D(aPolygon, getRGBColor())); - - aPolygon.clear(); - aPolygon.append(basegfx::B2DPoint(0.0, aDist.getY() * -1.0)); - aPolygon.append(basegfx::B2DPoint(0.0, aDist.getY() * 2.0)); - aTemplate[1] = Primitive2DReference(new PolygonHairlinePrimitive2D(aPolygon, getRGBColor())); - - break; - } - case MARKERSTYLE2D_GLUEPOINT : - { - // six lines forming the intended gluepoint cross. Prefer vector decompose - // over also possible bitmap/PointArrayPrimitive decompose for better quality - // Also make the discrete unit based lines one pixel longer since non-closed - // polygon primitives will be rendered without the last point by convention - aTemplate.realloc(6); - basegfx::B2DPolygon aPolygon; - - aPolygon.append(basegfx::B2DPoint(aDist.getX() * -2.0, aDist.getY() * -3.0)); - aPolygon.append(basegfx::B2DPoint(aDist.getX() * 4.0, aDist.getY() * 3.0)); - aTemplate[0] = Primitive2DReference(new PolygonHairlinePrimitive2D(aPolygon, getRGBColor())); - - aPolygon.clear(); - aPolygon.append(basegfx::B2DPoint(aDist.getX() * -3.0, aDist.getY() * -2.0)); - aPolygon.append(basegfx::B2DPoint(aDist.getX() * 3.0, aDist.getY() * 4.0)); - aTemplate[1] = Primitive2DReference(new PolygonHairlinePrimitive2D(aPolygon, getRGBColor())); - - aPolygon.clear(); - aPolygon.append(basegfx::B2DPoint(aDist.getX() * -3.0, aDist.getY() * 2.0)); - aPolygon.append(basegfx::B2DPoint(aDist.getX() * 3.0, aDist.getY() * -4.0)); - aTemplate[2] = Primitive2DReference(new PolygonHairlinePrimitive2D(aPolygon, getRGBColor())); - - aPolygon.clear(); - aPolygon.append(basegfx::B2DPoint(aDist.getX() * -2.0, aDist.getY() * 3.0)); - aPolygon.append(basegfx::B2DPoint(aDist.getX() * 4.0, aDist.getY() * -3.0)); - aTemplate[3] = Primitive2DReference(new PolygonHairlinePrimitive2D(aPolygon, getRGBColor())); - - const basegfx::BColor aRGBFrontColor(0.0, 0.0, 1.0); // COL_LIGHTBLUE - - aPolygon.clear(); - aPolygon.append(basegfx::B2DPoint(aDist.getX() * -2.0, aDist.getY() * -2.0)); - aPolygon.append(basegfx::B2DPoint(aDist.getX() * 3.0, aDist.getY() * 3.0)); - aTemplate[4] = Primitive2DReference(new PolygonHairlinePrimitive2D(aPolygon, aRGBFrontColor)); - - aPolygon.clear(); - aPolygon.append(basegfx::B2DPoint(aDist.getX() * -2.0, aDist.getY() * 2.0)); - aPolygon.append(basegfx::B2DPoint(aDist.getX() * 3.0, aDist.getY() * -3.0)); - aTemplate[5] = Primitive2DReference(new PolygonHairlinePrimitive2D(aPolygon, aRGBFrontColor)); - - break; - } - default : - { - // nothing to do, keep template empty - break; - } - } - - if(aTemplate.hasElements()) - { - xRetval.realloc(nMarkerCount); - - for(sal_uInt32 a(0); a < nMarkerCount; a++) - { - const basegfx::B2DPoint& rPosition(rPositions[a]); - basegfx::B2DHomMatrix aTransform; - - aTransform.set(0, 2, rPosition.getX()); - aTransform.set(1, 2, rPosition.getY()); - - xRetval[a] = Primitive2DReference(new TransformPrimitive2D(aTransform, aTemplate)); - } - } - - return xRetval; + const basegfx::B2DPoint& rPosition(rPositions[a]); + const basegfx::B2DRange aRange(rPosition - aLogicHalfSize, rPosition + aLogicHalfSize); + basegfx::B2DHomMatrix aTransform; + + aTransform.set(0, 0, aRange.getWidth()); + aTransform.set(1, 1, aRange.getHeight()); + aTransform.set(0, 2, aRange.getMinX()); + aTransform.set(1, 2, aRange.getMinY()); + + xRetval[a] = Primitive2DReference(new BitmapPrimitive2D(getMarker(), aTransform)); } - break; } } @@ -181,12 +99,10 @@ namespace drawinglayer MarkerArrayPrimitive2D::MarkerArrayPrimitive2D( const std::vector< basegfx::B2DPoint >& rPositions, - MarkerStyle2D eStyle, - const basegfx::BColor& rRGBColor) + const BitmapEx& rMarker) : BasePrimitive2D(), maPositions(rPositions), - maRGBColor(rRGBColor), - meStyle(eStyle) + maMarker(rMarker) { } @@ -197,8 +113,7 @@ namespace drawinglayer const MarkerArrayPrimitive2D& rCompare = (MarkerArrayPrimitive2D&)rPrimitive; return (getPositions() == rCompare.getPositions() - && getRGBColor() == rCompare.getRGBColor() - && getStyle() == rCompare.getStyle()); + && getMarker() == rCompare.getMarker()); } return false; @@ -208,34 +123,32 @@ namespace drawinglayer { basegfx::B2DRange aRetval; - // get the basic range from the position vector - for(std::vector< basegfx::B2DPoint >::const_iterator aIter(getPositions().begin()); aIter != getPositions().end(); aIter++) - { - aRetval.expand(*aIter); - } - - switch(getStyle()) + if(getPositions().size()) { - default : // MARKERSTYLE2D_POINT - { - // nothing to do; aRetval is already valid - break; - } - case MARKERSTYLE2D_CROSS : + // get the basic range from the position vector + for(std::vector< basegfx::B2DPoint >::const_iterator aIter(getPositions().begin()); aIter != getPositions().end(); aIter++) { - // size is 3x3 centered, expand - const basegfx::B2DVector aDiscreteVector(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.5, 1.5)); - aRetval.expand(aRetval.getMinimum() - aDiscreteVector); - aRetval.expand(aRetval.getMinimum() + aDiscreteVector); - break; + aRetval.expand(*aIter); } - case MARKERSTYLE2D_GLUEPOINT : + + if(!getMarker().IsEmpty()) { - // size is 7x7 centered, expand - const basegfx::B2DVector aDiscreteVector(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(3.5, 3.5)); - aRetval.expand(aRetval.getMinimum() - aDiscreteVector); - aRetval.expand(aRetval.getMinimum() + aDiscreteVector); - break; + // get pixel size + const Size aBitmapSize(getMarker().GetSizePixel()); + + if(aBitmapSize.Width() && aBitmapSize.Height()) + { + // get logic half size + basegfx::B2DVector aLogicHalfSize(rViewInformation.getInverseObjectToViewTransformation() * + basegfx::B2DVector(aBitmapSize.getWidth(), aBitmapSize.getHeight())); + + // use half size for expand + aLogicHalfSize *= 0.5; + + // apply aLogicHalfSize + aRetval.expand(aRetval.getMinimum() - aLogicHalfSize); + aRetval.expand(aRetval.getMaximum() + aLogicHalfSize); + } } } diff --git a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx index 958f11bf81ca..a795e84ed433 100644 --- a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx @@ -110,18 +110,22 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence PolygonMarkerPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence PolygonMarkerPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const { - if(getDashLength() > 0.0) + // calculate logic DashLength + const basegfx::B2DVector aDashVector(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(getDiscreteDashLength(), 0.0)); + const double fLogicDashLength(aDashVector.getX()); + + if(fLogicDashLength > 0.0) { // apply dashing; get line and gap snippets ::std::vector< double > aDash; basegfx::B2DPolyPolygon aDashedPolyPolyA; basegfx::B2DPolyPolygon aDashedPolyPolyB; - aDash.push_back(getDashLength()); - aDash.push_back(getDashLength()); - basegfx::tools::applyLineDashing(getB2DPolygon(), aDash, &aDashedPolyPolyA, &aDashedPolyPolyB, 2.0 * getDashLength()); + aDash.push_back(fLogicDashLength); + aDash.push_back(fLogicDashLength); + basegfx::tools::applyLineDashing(getB2DPolygon(), aDash, &aDashedPolyPolyA, &aDashedPolyPolyB, 2.0 * fLogicDashLength); // prepare return value Primitive2DSequence aRetval(2); @@ -142,12 +146,13 @@ namespace drawinglayer const basegfx::B2DPolygon& rPolygon, const basegfx::BColor& rRGBColorA, const basegfx::BColor& rRGBColorB, - double fDashLength) + double fDiscreteDashLength) : BasePrimitive2D(), maPolygon(rPolygon), maRGBColorA(rRGBColorA), maRGBColorB(rRGBColorB), - mfDashLength(fDashLength) + mfDiscreteDashLength(fDiscreteDashLength), + maLastInverseObjectToViewTransformation() { } @@ -160,16 +165,62 @@ namespace drawinglayer return (getB2DPolygon() == rCompare.getB2DPolygon() && getRGBColorA() == rCompare.getRGBColorA() && getRGBColorB() == rCompare.getRGBColorB() - && getDashLength() == rCompare.getDashLength()); + && getDiscreteDashLength() == rCompare.getDiscreteDashLength()); } return false; } - basegfx::B2DRange PolygonMarkerPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + basegfx::B2DRange PolygonMarkerPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const { + // this is a hairline, thus the line width is view-dependent. Get range of polygon + // as base size + basegfx::B2DRange aRetval(getB2DPolygon().getB2DRange()); + + if(!aRetval.isEmpty()) + { + // Calculate view-dependent hairline width + const basegfx::B2DVector aDiscreteSize(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)); + const double fDiscreteHalfLineWidth(aDiscreteSize.getLength() * 0.5); + + if(basegfx::fTools::more(fDiscreteHalfLineWidth, 0.0)) + { + aRetval.grow(fDiscreteHalfLineWidth); + } + } + // return range - return basegfx::tools::getRange(getB2DPolygon()); + return aRetval; + } + + Primitive2DSequence PolygonMarkerPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + bool bNeedNewDecomposition(false); + + if(getLocalDecomposition().hasElements()) + { + if(rViewInformation.getInverseObjectToViewTransformation() != maLastInverseObjectToViewTransformation) + { + bNeedNewDecomposition = true; + } + } + + if(bNeedNewDecomposition) + { + // conditions of last local decomposition have changed, delete + const_cast< PolygonMarkerPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + } + + if(!getLocalDecomposition().hasElements()) + { + // remember last used InverseObjectToViewTransformation + PolygonMarkerPrimitive2D* pThat = const_cast< PolygonMarkerPrimitive2D* >(this); + pThat->maLastInverseObjectToViewTransformation = rViewInformation.getInverseObjectToViewTransformation(); + } + + // use parent implementation + return BasePrimitive2D::get2DDecomposition(rViewInformation); } // provide unique ID diff --git a/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx index edb8752d57ba..9dd14aeb11e3 100644 --- a/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx @@ -117,6 +117,74 @@ namespace drawinglayer { namespace primitive2d { + Primitive2DSequence PolyPolygonMarkerPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon()); + const sal_uInt32 nCount(aPolyPolygon.count()); + + if(nCount) + { + Primitive2DSequence aRetval(nCount); + + for(sal_uInt32 a(0L); a < nCount; a++) + { + aRetval[a] = Primitive2DReference(new PolygonMarkerPrimitive2D(aPolyPolygon.getB2DPolygon(a), getRGBColorA(), getRGBColorB(), getDiscreteDashLength())); + } + + return aRetval; + } + else + { + return Primitive2DSequence(); + } + } + + PolyPolygonMarkerPrimitive2D::PolyPolygonMarkerPrimitive2D( + const basegfx::B2DPolyPolygon& rPolyPolygon, + const basegfx::BColor& rRGBColorA, + const basegfx::BColor& rRGBColorB, + double fDiscreteDashLength) + : BasePrimitive2D(), + maPolyPolygon(rPolyPolygon), + maRGBColorA(rRGBColorA), + maRGBColorB(rRGBColorB), + mfDiscreteDashLength(fDiscreteDashLength) + { + } + + bool PolyPolygonMarkerPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const PolyPolygonMarkerPrimitive2D& rCompare = (PolyPolygonMarkerPrimitive2D&)rPrimitive; + + return (getB2DPolyPolygon() == rCompare.getB2DPolyPolygon() + && getRGBColorA() == rCompare.getRGBColorA() + && getRGBColorB() == rCompare.getRGBColorB() + && getDiscreteDashLength() == rCompare.getDiscreteDashLength()); + } + + return false; + } + + basegfx::B2DRange PolyPolygonMarkerPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // return range + return basegfx::tools::getRange(getB2DPolyPolygon()); + } + + // provide unique ID + ImplPrimitrive2DIDBlock(PolyPolygonMarkerPrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D) + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { Primitive2DSequence PolyPolygonStrokePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon()); diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx index 8725323c6bf5..a788416725d9 100644 --- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx +++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx @@ -189,6 +189,18 @@ namespace drawinglayer return fRet; } +#ifdef WIN32 + double TextLayouterDevice::getCurrentFontRelation() const + { + const Font aFont(mrDevice.GetFont()); + const FontMetric aFontMetric(mrDevice.GetFontMetric(aFont)); + const double fWidth(aFontMetric.GetWidth()); + const double fHeight(aFont.GetHeight()); + + return basegfx::fTools::equalZero(fWidth) ? 1.0 : fHeight / fWidth; + } +#endif + double TextLayouterDevice::getUnderlineHeight() const { const ::FontMetric& rMetric = mrDevice.GetFontMetric(); diff --git a/drawinglayer/source/primitive2d/textprimitive2d.cxx b/drawinglayer/source/primitive2d/textprimitive2d.cxx index eade0b56addc..c845289dd4f8 100644 --- a/drawinglayer/source/primitive2d/textprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textprimitive2d.cxx @@ -137,13 +137,22 @@ namespace drawinglayer // the font size. Since we want to extract polygons here, it is okay to // work just with scaling and to ignore shear, rotation and translation, // all that can be applied to the polygons later +#ifdef WIN32 + const bool bCorrectScale(!basegfx::fTools::equal(fabs(aScale.getX()), fabs(aScale.getY()))); +#endif basegfx::B2DVector aFontScale; getCorrectedScaleAndFontScale(aScale, aFontScale); // prepare textlayoutdevice TextLayouterDevice aTextLayouter; aTextLayouter.setFontAttributes(getFontAttributes(), aFontScale.getX(), aFontScale.getY()); - +#ifdef WIN32 + // when under Windows and the font is unequally scaled, need to correct font X-Scaling factor + if(bCorrectScale) + { + aScale.setX(aScale.getX() * aTextLayouter.getCurrentFontRelation()); + } +#endif // get the text outlines. No DXArray is given (would contain integers equal to unit vector // transformed by object's transformation), let VCL do the job aTextLayouter.getTextOutlines(rTarget, getText(), getTextPosition(), getTextLength()); @@ -284,6 +293,9 @@ namespace drawinglayer // the font size. Since we want to extract polygons here, it is okay to // work just with scaling and to ignore shear, rotation and translation, // all that can be applied to the polygons later +#ifdef WIN32 + const bool bCorrectScale(!basegfx::fTools::equal(fabs(aScale.getX()), fabs(aScale.getY()))); +#endif basegfx::B2DVector aFontScale; getCorrectedScaleAndFontScale(aScale, aFontScale); @@ -293,7 +305,13 @@ namespace drawinglayer // get basic text range aRetval = aTextLayouter.getTextBoundRect(getText(), getTextPosition(), getTextLength()); - +#ifdef WIN32 + // when under Windows and the font is unequally scaled, need to correct font X-Scaling factor + if(bCorrectScale) + { + aScale.setX(aScale.getX() * aTextLayouter.getCurrentFontRelation()); + } +#endif // prepare object transformation for range basegfx::B2DHomMatrix aRangeTransformation; diff --git a/drawinglayer/source/primitive2d/unifiedalphaprimitive2d.cxx b/drawinglayer/source/primitive2d/unifiedalphaprimitive2d.cxx index 7506309967bc..49039e1a6e5c 100644 --- a/drawinglayer/source/primitive2d/unifiedalphaprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/unifiedalphaprimitive2d.cxx @@ -43,6 +43,7 @@ #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/primitive2d/alphaprimitive2d.hxx> #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -63,11 +64,29 @@ namespace drawinglayer } else if(getAlpha() > 0.0 && getAlpha() < 1.0) { - // create fill polygon for TransparenceList - const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(getB2DRangeFromPrimitive2DSequence(getChildren(), rViewInformation))); + // The idea is to create a AlphaPrimitive2D with alpha content using a fill color + // corresponding to the alpha value. Problem is that in most systems, the right + // and bottom pixel array is not filled when filling polygons, thus this would not + // always produce a complete alpha bitmap. There are some solutions: + // + // - Grow the used polygon range by one discrete unit in X and Y. This + // will make the decomposition view-dependent. + // + // - For all filled polygon renderings, dra wthe polygon outline extra. This + // would lead to unwanted side effects when using concatenated polygons. + // + // - At this decomposition, add a filled polygon and a hairline polygon. This + // solution stays view-independent. + // + // I will take the last one here. The small overhead of two primitives will only be + // used when UnifiedAlphaPrimitive2D is not handled directly. + const basegfx::B2DRange aPolygonRange(getB2DRangeFromPrimitive2DSequence(getChildren(), rViewInformation)); + const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(aPolygonRange)); const basegfx::BColor aGray(getAlpha(), getAlpha(), getAlpha()); - const Primitive2DReference xRefA(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPolygon), aGray)); - const Primitive2DSequence aAlphaContent(&xRefA, 1L); + Primitive2DSequence aAlphaContent(2); + + aAlphaContent[0] = Primitive2DReference(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPolygon), aGray)); + aAlphaContent[1] = Primitive2DReference(new PolygonHairlinePrimitive2D(aPolygon, aGray)); // create sub-transparence group with a gray-colored rectangular fill polygon const Primitive2DReference xRefB(new AlphaPrimitive2D(getChildren(), aAlphaContent)); diff --git a/drawinglayer/source/processor2d/canvasprocessor.cxx b/drawinglayer/source/processor2d/canvasprocessor.cxx index 0fe629545900..4214d9f866c3 100644 --- a/drawinglayer/source/processor2d/canvasprocessor.cxx +++ b/drawinglayer/source/processor2d/canvasprocessor.cxx @@ -1313,7 +1313,11 @@ namespace drawinglayer { // get logic range of transparent part, clip with ViewRange basegfx::B2DRange aLogicRange(aMask.getB2DRange()); - aLogicRange.intersect(getViewInformation2D().getViewport()); + + if(!getViewInformation2D().getViewport().isEmpty()) + { + aLogicRange.intersect(getViewInformation2D().getViewport()); + } if(!aLogicRange.isEmpty()) { @@ -1335,9 +1339,12 @@ namespace drawinglayer uno::Reference< rendering::XCanvas > xLastCanvas(mxCanvas); const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D()); - // prepare discrete offset for XBitmap + // prepare discrete offset for XBitmap, do not forget that the buffer bitmap + // may be truncated to discrete visible pixels basegfx::B2DHomMatrix aDiscreteOffset; - aDiscreteOffset.translate(-aDiscreteRange.getMinX(), -aDiscreteRange.getMinY()); + aDiscreteOffset.translate( + aDiscreteRange.getMinX() > 0.0 ? -aDiscreteRange.getMinX() : 0.0, + aDiscreteRange.getMinY() > 0.0 ? -aDiscreteRange.getMinY() : 0.0); // create new local ViewInformation2D with new transformation const geometry::ViewInformation2D aViewInformation2D( @@ -1623,7 +1630,11 @@ namespace drawinglayer { // get logic range of transparent part and clip with ViewRange basegfx::B2DRange aLogicRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rChildren, getViewInformation2D())); - aLogicRange.intersect(getViewInformation2D().getViewport()); + + if(!getViewInformation2D().getViewport().isEmpty()) + { + aLogicRange.intersect(getViewInformation2D().getViewport()); + } if(!aLogicRange.isEmpty()) { @@ -1645,9 +1656,12 @@ namespace drawinglayer uno::Reference< rendering::XCanvas > xLastCanvas(mxCanvas); const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D()); - // prepare discrete offset for XBitmap + // prepare discrete offset for XBitmap, do not forget that the buffer bitmap + // may be truncated to discrete visible pixels basegfx::B2DHomMatrix aDiscreteOffset; - aDiscreteOffset.translate(-aDiscreteRange.getMinX(), -aDiscreteRange.getMinY()); + aDiscreteOffset.translate( + aDiscreteRange.getMinX() > 0.0 ? -aDiscreteRange.getMinX() : 0.0, + aDiscreteRange.getMinY() > 0.0 ? -aDiscreteRange.getMinY() : 0.0); // create new local ViewInformation2D with new transformation const geometry::ViewInformation2D aViewInformation2D( diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx index 629ad681a41f..9d63bd5c7df6 100644 --- a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx +++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx @@ -40,6 +40,7 @@ #include <basegfx/range/b2drange.hxx> #include <vcl/bitmapex.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <tools/stream.hxx> ////////////////////////////////////////////////////////////////////////////// // support for rendering Bitmap and BitmapEx contents @@ -103,27 +104,48 @@ namespace drawinglayer const Point aEmptyPoint; const Size aSizePixel(maContent.GetOutputSizePixel()); const bool bWasEnabledDst(mrOutDev.IsMapModeEnabled()); + static bool bDoSaveForVisualControl(false); mrOutDev.EnableMapMode(false); maContent.EnableMapMode(false); Bitmap aContent(maContent.GetBitmap(aEmptyPoint, aSizePixel)); + if(bDoSaveForVisualControl) + { + SvFileStream aNew((const String&)String(ByteString( "c:\\content.bmp" ), RTL_TEXTENCODING_UTF8), STREAM_WRITE|STREAM_TRUNC); + aNew << aContent; + } + if(mpAlpha) { mpAlpha->EnableMapMode(false); - AlphaMask aAlphaMask(mpAlpha->GetBitmap(aEmptyPoint, aSizePixel)); + const AlphaMask aAlphaMask(mpAlpha->GetBitmap(aEmptyPoint, aSizePixel)); + + if(bDoSaveForVisualControl) + { + SvFileStream aNew((const String&)String(ByteString( "c:\\alpha.bmp" ), RTL_TEXTENCODING_UTF8), STREAM_WRITE|STREAM_TRUNC); + aNew << aAlphaMask.GetBitmap(); + } + mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask)); } else if(mpMask) { mpMask->EnableMapMode(false); - Bitmap aMask(mpMask->GetBitmap(aEmptyPoint, aSizePixel)); + const Bitmap aMask(mpMask->GetBitmap(aEmptyPoint, aSizePixel)); + + if(bDoSaveForVisualControl) + { + SvFileStream aNew((const String&)String(ByteString( "c:\\mask.bmp" ), RTL_TEXTENCODING_UTF8), STREAM_WRITE|STREAM_TRUNC); + aNew << aMask; + } + mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aMask)); } else if(0.0 != fTrans) { sal_uInt8 nMaskValue((sal_uInt8)basegfx::fround(fTrans * 255.0)); - AlphaMask aAlphaMask(aSizePixel, &nMaskValue); + const AlphaMask aAlphaMask(aSizePixel, &nMaskValue); mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask)); } else diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index cebc2d484889..70cb4dcb4b43 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -339,8 +339,12 @@ namespace drawinglayer if(!bControlIsVisibleAsChildWindow) { - // draw it - xControlView->draw(basegfx::fround(aTopLeftPixel.getX()), basegfx::fround(aTopLeftPixel.getY())); + // draw it. Do not forget to use the evtl. offsetted origin of the target device, + // e.g. when used with mask/transparence buffer device + const Point aOrigin(mpOutputDevice->GetMapMode().GetOrigin()); + xControlView->draw( + aOrigin.X() + basegfx::fround(aTopLeftPixel.getX()), + aOrigin.Y() + basegfx::fround(aTopLeftPixel.getY())); } // restore original graphics @@ -466,7 +470,7 @@ namespace drawinglayer // create hatch const basegfx::B2DVector aDiscreteDistance(maCurrentTransformation * basegfx::B2DVector(rFillHatchAttributes.getDistance(), 0.0)); - const sal_uInt32 nDistance(basegfx::fround(aDiscreteDistance.getX())); + const sal_uInt32 nDistance(basegfx::fround(aDiscreteDistance.getLength())); const sal_uInt16 nAngle10((sal_uInt16)basegfx::fround(rFillHatchAttributes.getAngle() / F_PI1800)); ::Hatch aVCLHatch(eHatchStyle, Color(rFillHatchAttributes.getColor()), nDistance, nAngle10); diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 96ea516ff8e9..9e397e7c36b0 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -246,11 +246,11 @@ namespace drawinglayer { aTransformedDXArray.reserve(rTextCandidate.getDXArray().size()); const basegfx::B2DVector aPixelVector(aLocalTransform * basegfx::B2DVector(1.0, 0.0)); - const double fPixelVectorLength(aPixelVector.getLength()); + const double fPixelVectorFactor(aPixelVector.getLength()); for(::std::vector< double >::const_iterator aStart(rTextCandidate.getDXArray().begin()); aStart != rTextCandidate.getDXArray().end(); aStart++) { - aTransformedDXArray.push_back(basegfx::fround((*aStart) * fPixelVectorLength)); + aTransformedDXArray.push_back(basegfx::fround((*aStart) * fPixelVectorFactor)); } } @@ -421,82 +421,70 @@ namespace drawinglayer sal_Int32 nOWidth(aObjBR.X() - aObjTL.X()); sal_Int32 nOHeight(aObjBR.Y() - aObjTL.Y()); - if(nOWidth < 0L) + // only do something when object has a size in discrete units + if(nOWidth > 0 && nOHeight > 0) { - nOWidth = 1L; - } - - if(nOHeight < 0L) - { - nOHeight = 1L; - } - - sal_Int32 nBWidth(aBmpBR.X() - aBmpTL.X()); - sal_Int32 nBHeight(aBmpBR.Y() - aBmpTL.Y()); - - if(nBWidth < 0L) - { - nBWidth = 1L; - } - - if(nBHeight < 0L) - { - nBHeight = 1L; - } + sal_Int32 nBWidth(aBmpBR.X() - aBmpTL.X()); + sal_Int32 nBHeight(aBmpBR.Y() - aBmpTL.Y()); - sal_Int32 nBLeft(aBmpTL.X()); - sal_Int32 nBTop(aBmpTL.Y()); - - if(nBLeft > aObjTL.X()) - { - nBLeft -= ((nBLeft / nBWidth) + 1L) * nBWidth; - } + // only do something when bitmap fill has a size in discrete units + if(nBWidth > 0 && nBHeight > 0) + { + sal_Int32 nBLeft(aBmpTL.X()); + sal_Int32 nBTop(aBmpTL.Y()); - if(nBLeft + nBWidth <= aObjTL.X()) - { - nBLeft -= (nBLeft / nBWidth) * nBWidth; - } + if(nBLeft > aObjTL.X()) + { + nBLeft -= ((nBLeft / nBWidth) + 1L) * nBWidth; + } - if(nBTop > aObjTL.Y()) - { - nBTop -= ((nBTop / nBHeight) + 1L) * nBHeight; - } + if(nBLeft + nBWidth <= aObjTL.X()) + { + nBLeft -= (nBLeft / nBWidth) * nBWidth; + } - if(nBTop + nBHeight <= aObjTL.Y()) - { - nBTop -= (nBTop / nBHeight) * nBHeight; - } + if(nBTop > aObjTL.Y()) + { + nBTop -= ((nBTop / nBHeight) + 1L) * nBHeight; + } - // nBWidth, nBHeight is the pixel size of the neede bitmap. To not need to scale it - // in vcl many times, create a size-optimized version - const Size aNeededBitmapSizePixel(nBWidth, nBHeight); + if(nBTop + nBHeight <= aObjTL.Y()) + { + nBTop -= (nBTop / nBHeight) * nBHeight; + } - if(aNeededBitmapSizePixel != aBitmapEx.GetSizePixel()) - { - aBitmapEx.Scale(aNeededBitmapSizePixel); - } + // nBWidth, nBHeight is the pixel size of the neede bitmap. To not need to scale it + // in vcl many times, create a size-optimized version + const Size aNeededBitmapSizePixel(nBWidth, nBHeight); - // prepare OutDev - const Point aEmptyPoint(0, 0); - const Rectangle aVisiblePixel(aEmptyPoint, mpOutputDevice->GetOutputSizePixel()); - const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled()); - mpOutputDevice->EnableMapMode(false); + if(aNeededBitmapSizePixel != aBitmapEx.GetSizePixel()) + { + aBitmapEx.Scale(aNeededBitmapSizePixel); + } - for(sal_Int32 nXPos(nBLeft); nXPos < aObjTL.X() + nOWidth; nXPos += nBWidth) - { - for(sal_Int32 nYPos(nBTop); nYPos < aObjTL.Y() + nOHeight; nYPos += nBHeight) - { - const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel); + // prepare OutDev + const Point aEmptyPoint(0, 0); + const Rectangle aVisiblePixel(aEmptyPoint, mpOutputDevice->GetOutputSizePixel()); + const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled()); + mpOutputDevice->EnableMapMode(false); - if(aOutRectPixel.IsOver(aVisiblePixel)) + for(sal_Int32 nXPos(nBLeft); nXPos < aObjTL.X() + nOWidth; nXPos += nBWidth) { - mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aBitmapEx); + for(sal_Int32 nYPos(nBTop); nYPos < aObjTL.Y() + nOHeight; nYPos += nBHeight) + { + const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel); + + if(aOutRectPixel.IsOver(aVisiblePixel)) + { + mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aBitmapEx); + } + } } + + // restore OutDev + mpOutputDevice->EnableMapMode(bWasEnabled); } } - - // restore OutDev - mpOutputDevice->EnableMapMode(bWasEnabled); } } } @@ -861,69 +849,42 @@ namespace drawinglayer return; } - switch(rMarkArrayCandidate.getStyle()) + // get data + const std::vector< basegfx::B2DPoint >& rPositions = rMarkArrayCandidate.getPositions(); + const sal_uInt32 nCount(rPositions.size()); + + if(nCount && !rMarkArrayCandidate.getMarker().IsEmpty()) { - default : - { - // not handled/unknown MarkerArrayPrimitive2D, use decomposition - process(rMarkArrayCandidate.get2DDecomposition(getViewInformation2D())); - break; - } - case primitive2d::MARKERSTYLE2D_CROSS : - case primitive2d::MARKERSTYLE2D_GLUEPOINT : + // get pixel size + const BitmapEx& rMarker(rMarkArrayCandidate.getMarker()); + const Size aBitmapSize(rMarker.GetSizePixel()); + + if(aBitmapSize.Width() && aBitmapSize.Height()) { - // directly supported markers - const std::vector< basegfx::B2DPoint >& rPositions = rMarkArrayCandidate.getPositions(); - const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(rMarkArrayCandidate.getRGBColor())); - const Color aVCLColor(aRGBColor); - const basegfx::B2DHomMatrix aTransObjectToDiscrete(mpOutputDevice->GetViewTransformation() * maCurrentTransformation); + // get discrete half size + const basegfx::B2DVector aDiscreteHalfSize( + (aBitmapSize.getWidth() - 1.0) * 0.5, + (aBitmapSize.getHeight() - 1.0) * 0.5); + const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled()); - for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); aIter++) - { - const basegfx::B2DPoint aDiscretePosition(aTransObjectToDiscrete * (*aIter)); - const Point aPos(basegfx::fround(aDiscretePosition.getX()), basegfx::fround(aDiscretePosition.getY())); + // do not forget evtl. moved origin in target device MapMode when + // switching it off; it would be missing and lead to wrong positions. + // All his could be done using logic sizes and coordinates, too, but + // we want a 1:1 bitmap rendering here, so it's more safe and faster + // to work with switching off MapMode usage completely. + const Point aOrigin(mpOutputDevice->GetMapMode().GetOrigin()); - switch(rMarkArrayCandidate.getStyle()) - { - default : - { - // this would be an error, ther cases here need to be consistent with the initially - // accepted ones - OSL_ENSURE(false, "Inconsistent RenderMarkerArrayPrimitive2D implementation (!)"); - break; - } - case primitive2d::MARKERSTYLE2D_CROSS : - { - mpOutputDevice->DrawPixel(aPos, aVCLColor); - mpOutputDevice->DrawPixel(Point(aPos.X() - 1L, aPos.Y()), aVCLColor); - mpOutputDevice->DrawPixel(Point(aPos.X() + 1L, aPos.Y()), aVCLColor); - mpOutputDevice->DrawPixel(Point(aPos.X(), aPos.Y() - 1L), aVCLColor); - mpOutputDevice->DrawPixel(Point(aPos.X(), aPos.Y() + 1L), aVCLColor); + mpOutputDevice->EnableMapMode(false); - break; - } - case primitive2d::MARKERSTYLE2D_GLUEPOINT : - { - // backpen - mpOutputDevice->SetLineColor(aVCLColor); - mpOutputDevice->DrawLine(aPos + Point(-2, -3), aPos + Point(+3, +2)); - mpOutputDevice->DrawLine(aPos + Point(-3, -2), aPos + Point(+2, +3)); - mpOutputDevice->DrawLine(aPos + Point(-3, +2), aPos + Point(+2, -3)); - mpOutputDevice->DrawLine(aPos + Point(-2, +3), aPos + Point(+3, -2)); - - // frontpen (hard coded) - const basegfx::BColor aRGBFrontColor(maBColorModifierStack.getModifiedColor(Color(COL_LIGHTBLUE).getBColor())); - mpOutputDevice->SetLineColor(Color(aRGBFrontColor)); - mpOutputDevice->DrawLine(aPos + Point(-2, -2), aPos + Point(+2, +2)); - mpOutputDevice->DrawLine(aPos + Point(-2, +2), aPos + Point(+2, -2)); - - break; - } - } + for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); aIter++) + { + const basegfx::B2DPoint aDiscreteTopLeft((maCurrentTransformation * (*aIter)) - aDiscreteHalfSize); + const Point aDiscretePoint(basegfx::fround(aDiscreteTopLeft.getX()), basegfx::fround(aDiscreteTopLeft.getY())); + mpOutputDevice->DrawBitmapEx(aDiscretePoint + aOrigin, rMarker); } - break; + mpOutputDevice->EnableMapMode(bWasEnabled); } } } @@ -952,8 +913,8 @@ namespace drawinglayer if(basegfx::fTools::more(fLineWidth, 0.0)) { - const basegfx::B2DVector aDiscreteUnit(maCurrentTransformation * basegfx::B2DVector(1.0, 1.0)); - const double fDiscreteLineWidth((fLineWidth * aDiscreteUnit.getX() + fLineWidth * aDiscreteUnit.getY()) * 0.5); + const basegfx::B2DVector aDiscreteUnit(maCurrentTransformation * basegfx::B2DVector(fLineWidth, 0.0)); + const double fDiscreteLineWidth(aDiscreteUnit.getLength()); if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 2.5)) { diff --git a/officecfg/registry/data/org/openoffice/Office/Canvas.xcu b/officecfg/registry/data/org/openoffice/Office/Canvas.xcu index 451d3de1eb5a..de3a4704fd6e 100755 --- a/officecfg/registry/data/org/openoffice/Office/Canvas.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Canvas.xcu @@ -32,6 +32,19 @@ com.sun.star.comp.rendering.Canvas.VCL </value> </prop> + <prop oor:name="AcceleratedImplementations" oor:type="oor:string-list"> + <value oor:separator=",">com.sun.star.comp.rendering.Canvas.GL, + com.sun.star.comp.rendering.Canvas.Java + </value> + </prop> + <prop oor:name="AntialiasingImplementations" oor:type="oor:string-list"> + <value oor:separator=",">com.sun.star.comp.rendering.BitmapCanvas.GDI+, + com.sun.star.comp.rendering.Canvas.GDI+, + com.sun.star.comp.rendering.Canvas.Cairo, + com.sun.star.comp.rendering.Canvas.GL, + com.sun.star.comp.rendering.Canvas.Java + </value> + </prop> </node> <node oor:name="com.sun.star.rendering.SpriteCanvas" oor:op="replace"> <prop oor:name="PreferredImplementations" oor:type="oor:string-list"> @@ -43,6 +56,22 @@ com.sun.star.comp.rendering.SpriteCanvas.VCL </value> </prop> + <prop oor:name="AcceleratedImplementations" oor:type="oor:string-list"> + <value oor:separator=",">com.sun.star.comp.rendering.SpriteCanvas.DX9, + com.sun.star.comp.rendering.SpriteCanvas.DX5, + com.sun.star.comp.rendering.SpriteCanvas.Cairo, + com.sun.star.comp.rendering.SpriteCanvas.GL, + com.sun.star.comp.rendering.SpriteCanvas.Java + </value> + </prop> + <prop oor:name="AntialiasingImplementations" oor:type="oor:string-list"> + <value oor:separator=",">com.sun.star.comp.rendering.SpriteCanvas.DX9, + com.sun.star.comp.rendering.SpriteCanvas.DX5, + com.sun.star.comp.rendering.SpriteCanvas.Cairo, + com.sun.star.comp.rendering.SpriteCanvas.GL, + com.sun.star.comp.rendering.SpriteCanvas.Java + </value> + </prop> </node> </node> </oor:component-data> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu index 6a1dbbd223f9..3acb9ea7a1cb 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu @@ -1428,7 +1428,7 @@ <node oor:name=".uno:SolidCreate" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">Create Object with Attributes</value> + <value xml:lang="en-US">Modify Object with Attributes</value> </prop> <prop oor:name="Properties" oor:type="xs:int"> <value>1</value> diff --git a/officecfg/registry/schema/org/openoffice/Office/Canvas.xcs b/officecfg/registry/schema/org/openoffice/Office/Canvas.xcs index 5198d3eedf0a..65b41bd9c9b4 100755 --- a/officecfg/registry/schema/org/openoffice/Office/Canvas.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Canvas.xcs @@ -17,6 +17,16 @@ <desc>List of implementation names.</desc> </info> </prop> + <prop oor:name="AcceleratedImplementations" oor:type="oor:string-list"> + <info> + <desc>List of implementations that are hardware-accelerated.</desc> + </info> + </prop> + <prop oor:name="AntialiasingImplementations" oor:type="oor:string-list"> + <info> + <desc>List of implementations that do anti-aliasing.</desc> + </info> + </prop> </group> </templates> <component> @@ -89,6 +99,28 @@ </info> <value>false</value> </prop> + <prop oor:name="UseAcceleratedCanvas" oor:type="xs:boolean"> + <info> + <author>THB</author> + <desc>When true, suggest canvas factory to use a + canvas service listed in the + AcceleratedImplementations lists. + </desc> + <label>Use a canvas listed among the AcceleratedImplementations</label> + </info> + <value>true</value> + </prop> + <prop oor:name="UseAntialiasingCanvas" oor:type="xs:boolean"> + <info> + <author>THB</author> + <desc>When true, suggest canvas factory to use a + canvas service listed in the + AntialiasingImplementations lists. + </desc> + <label>Use a canvas listed among the AntialiasingImplementations</label> + </info> + <value>true</value> + </prop> </component> </oor:component-schema> diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 9df8fa4945bd..25ddaf318481 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -1098,12 +1098,27 @@ Dymamic border coloring means that when the mouse is hovered over a control, and <prop oor:name="AntiAliasing" oor:type="xs:boolean"> <info> <author>AW</author> - <desc>This switch allows to switch DrawingLayer based views to be rendered using AntiAliasing or not. - Of course this takes only effect when AntiAliasing is supported for the System OOo is running on. + <desc> + This switch allows to switch DrawingLayer based views to be rendered using AntiAliasing or not. + Of course this takes only effect when AntiAliasing is supported for the System OOo is running on. </desc> <label>This switch determines if DrawingLayer based views use AntiAliasing.</label> </info> - <value>false</value> + <value>true</value> + </prop> + <prop oor:name="SolidDragCreate" oor:type="xs:boolean"> + <info> + <author>AW</author> + <desc> + This switch decides if Interactions in the DrawingLayer are visualized using Wireframe or Full-Object + previews. If false, only Wireframe will be used. If true, Full-Object preview which gives a much better + feedback about the object interaction will be used. This mode is used for modification and creation of + objects. During interaction, a geometric copy of the object(s) is shown with 50% transparence in the + foreground. That copy shows exactly what You will get when You end the interaction. + </desc> + <label>This switch determines if DrawingLayer Interactions show Wireframe or Full-Object preview.</label> + </info> + <value>true</value> </prop> <prop oor:name="Quadratic3DRenderLimit" oor:type="xs:int"> <info> diff --git a/officecfg/registry/schema/org/openoffice/Office/Draw.xcs b/officecfg/registry/schema/org/openoffice/Office/Draw.xcs index 3947ba38325f..f29972ca7fcf 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Draw.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Draw.xcs @@ -381,16 +381,16 @@ </info> <value>false</value> </prop> - <prop oor:name="CreateWithAttributes" oor:type="xs:boolean"> + <prop oor:name="ModifyWithAttributes" oor:type="xs:boolean"> <!-- OldPath: Draw/Other --> <!-- OldLocation: soffice.cfg --> <!-- UIHints: Optionbar --> <info> <author>AF</author> - <desc>Indicates whether the current attributes will be assigned to newly created objects.</desc> - <label>Create with attributes</label> + <desc>Indicates whether the object creation and modification will be visualized using the full object attribute set or wireframe.</desc> + <label>Modify with attributes</label> </info> - <value>false</value> + <value>true</value> </prop> <group oor:name="TextObject"> <info> diff --git a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs index 5e0d3750ca7e..23127636c0ee 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs @@ -418,13 +418,14 @@ </info> <value>false</value> </prop> - <prop oor:name="CreateWithAttributes" oor:type="xs:boolean"> + <prop oor:name="ModifyWithAttributes" oor:type="xs:boolean"> <!-- OldPath: Impress/Other --> <!-- OldLocation: soffice.cfg --> <!-- UIHints: Optionbar --> <info> - <desc>Indicates whether the current attributes will be assigned to newly created objects.</desc> - <label>Create with attributes</label> + <author>AF</author> + <desc>Indicates whether the object creation and modification will be visualized using the full object attribute set or wireframe.</desc> + <label>Modify with attributes</label> </info> <value>false</value> </prop> diff --git a/readlicense_oo/docs/readme/readme.xrm b/readlicense_oo/docs/readme/readme.xrm index 75a1a4e37375..3ab8636e0125 100755 --- a/readlicense_oo/docs/readme/readme.xrm +++ b/readlicense_oo/docs/readme/readme.xrm @@ -88,7 +88,7 @@ <Paragraph id="WNT2" os="WNT"><!-- WINDOWS --> <List> - <Text id="s2s3sdf2" xml:lang="en-US">Microsoft Windows 2000 (Service Pack 2 or higher), XP, or Vista</Text> + <Text id="s2s3sdf2" xml:lang="en-US">Microsoft Windows 2000 (Service Pack 4 or higher), XP, or Vista</Text> <Text id="utzu6" xml:lang="en-US">Pentium compatible PC (Pentium III or Athlon recommended)</Text> <Text id="ghuj67" xml:lang="en-US">256 MB RAM (512 MB RAM recommended)</Text> <Text id="jzjtzu6" xml:lang="en-US">370 MB available hard disk space</Text> diff --git a/svx/inc/dragmt3d.hxx b/svx/inc/dragmt3d.hxx index 54485f9e05c7..69c324ce1f62 100644 --- a/svx/inc/dragmt3d.hxx +++ b/svx/inc/dragmt3d.hxx @@ -86,21 +86,22 @@ protected: public: TYPEINFO(); - E3dDragMethod(SdrDragView &rView, + E3dDragMethod( + SdrDragView &rView, const SdrMarkList& rMark, E3dDragConstraint eConstr = E3DDRAG_CONSTR_XYZ, - BOOL bFull=FALSE); + BOOL bFull = FALSE); - virtual void TakeComment(String& rStr) const; - virtual FASTBOOL Beg(); - virtual void Mov(const Point& rPnt); - virtual void Brk(); - virtual FASTBOOL End(FASTBOOL bCopy); + virtual void TakeSdrDragComment(String& rStr) const; + virtual bool BeginSdrDrag(); + virtual void MoveSdrDrag(const Point& rPnt); + virtual void CancelSdrDrag(); + virtual bool EndSdrDrag(bool bCopy); - E3dView& Get3DView() { return (E3dView&)rView; } + E3dView& Get3DView() { return (E3dView&)getSdrDragView(); } // for migration from XOR to overlay - virtual void CreateOverlayGeometry(::sdr::overlay::OverlayManager& rOverlayManager, ::sdr::overlay::OverlayObjectList& rOverlayList); + virtual void CreateOverlayGeometry(::sdr::overlay::OverlayManager& rOverlayManager); }; @@ -116,13 +117,14 @@ class E3dDragRotate : public E3dDragMethod public: TYPEINFO(); - E3dDragRotate(SdrDragView &rView, + E3dDragRotate( + SdrDragView &rView, const SdrMarkList& rMark, E3dDragConstraint eConstr = E3DDRAG_CONSTR_XYZ, - BOOL bFull=FALSE); + BOOL bFull = FALSE); - virtual void Mov(const Point& rPnt); - virtual Pointer GetPointer() const; + virtual void MoveSdrDrag(const Point& rPnt); + virtual Pointer GetSdrDragPointer() const; }; @@ -139,14 +141,15 @@ class E3dDragMove : public E3dDragMethod public: TYPEINFO(); - E3dDragMove(SdrDragView &rView, + E3dDragMove( + SdrDragView &rView, const SdrMarkList& rMark, SdrHdlKind eDrgHdl = HDL_MOVE, E3dDragConstraint eConstr = E3DDRAG_CONSTR_XYZ, - BOOL bFull=FALSE); + BOOL bFull = FALSE); - virtual void Mov(const Point& rPnt); - virtual Pointer GetPointer() const; + virtual void MoveSdrDrag(const Point& rPnt); + virtual Pointer GetSdrDragPointer() const; }; diff --git a/svx/inc/pch/precompiled_svx.hxx b/svx/inc/pch/precompiled_svx.hxx index c9661dc4f113..580f5925d859 100644 --- a/svx/inc/pch/precompiled_svx.hxx +++ b/svx/inc/pch/precompiled_svx.hxx @@ -805,7 +805,6 @@ #include "svtools/miscopt.hxx" #include "svtools/moduleoptions.hxx" #include "svtools/numuno.hxx" -#include "svtools/options3d.hxx" #include "svtools/optionsdlg.hxx" #include "svtools/parhtml.hxx" #include "svtools/parrtf.hxx" diff --git a/svx/inc/svx/obj3d.hxx b/svx/inc/svx/obj3d.hxx index 4a21b7fad652..3c15cd6951ef 100644 --- a/svx/inc/svx/obj3d.hxx +++ b/svx/inc/svx/obj3d.hxx @@ -255,7 +255,6 @@ public : virtual basegfx::B2DPolyPolygon TakeXorPoly() const; virtual sal_uInt32 GetHdlCount() const; virtual void AddToHdlList(SdrHdlList& rHdlList) const; - virtual FASTBOOL HasSpecialDrag() const; // DoubleSided: TRUE/FALSE BOOL GetDoubleSided() const diff --git a/svx/inc/svx/sdr/contact/displayinfo.hxx b/svx/inc/svx/sdr/contact/displayinfo.hxx index c2a32897600d..13336bb3175a 100644 --- a/svx/inc/svx/sdr/contact/displayinfo.hxx +++ b/svx/inc/svx/sdr/contact/displayinfo.hxx @@ -56,10 +56,6 @@ namespace sdr class SVX_DLLPUBLIC DisplayInfo { protected: - // For being able to detect the processed page, allow setting - // it at DisplayInfo - //SdrPage* mpProcessedPage; - // The Layers which shall be processed (visible) SetOfByte maProcessLayers; @@ -101,38 +97,29 @@ namespace sdr // destructor virtual ~DisplayInfo(); - // access to ProcessedPage, write is for internal use only. - // read is used from various places eventually, to identify the - // currently painting page - //void SetProcessedPage(SdrPage* pNew); - //const SdrPage* GetProcessedPage() const; - // access to ProcessLayers void SetProcessLayers(const SetOfByte& rSet); - const SetOfByte& GetProcessLayers() const; + const SetOfByte& GetProcessLayers() const { return maProcessLayers; } // access to RedrawArea void SetRedrawArea(const Region& rRegion); - const Region& GetRedrawArea() const; + const Region& GetRedrawArea() const { return maRedrawArea; } // Access to ControlLayerProcessingActive flag void SetControlLayerProcessingActive(bool bDoPaint); - bool GetControlLayerProcessingActive() const; + bool GetControlLayerProcessingActive() const { return mbControlLayerProcessingActive; } // Access to PageProcessingActive flag void SetPageProcessingActive(bool bDoPaint); - bool GetPageProcessingActive() const; - - // Access to svtools::ColorConfig - const svtools::ColorConfig& GetColorConfig() const; + bool GetPageProcessingActive() const { return mbPageProcessingActive; } // Save the original DrawMode from outdev void ClearGhostedDrawMode(); void SetGhostedDrawMode(); - bool IsGhostedDrawModeActive() const; + bool IsGhostedDrawModeActive() const { return mbGhostedDrawModeActive; } // access to master page painting flag - bool GetSubContentActive() const; + bool GetSubContentActive() const { return mbSubContentActive; } void SetSubContentActive(bool bNew); }; } // end of namespace contact diff --git a/svx/inc/svx/sdr/contact/objectcontact.hxx b/svx/inc/svx/sdr/contact/objectcontact.hxx index 8bf05ac1a9be..448b61c486ca 100644 --- a/svx/inc/svx/sdr/contact/objectcontact.hxx +++ b/svx/inc/svx/sdr/contact/objectcontact.hxx @@ -211,6 +211,14 @@ namespace sdr // access to OutputDevice. May return 0L like the default implementations do. Needs to be overloaded as needed. virtual OutputDevice* TryToGetOutputDevice() const; + + // reset ViewPort at internal ViewInformation2D. This is needed when the OC is used + // not for ProcessDisplay() but to get a VOC associated with it. When trying to get + // a sequence of primitives from the VOC then, the last initialized ViewPort from + // the last ProcessDisplay() is used for geometric visibility testing. If this is not + // wanted (like in such cases) this method is used. It will reuse the current + // ViewInformation2D, but clear the ViewPort (no ViewPort means all is visible) + void resetViewPort(); }; } // end of namespace contact } // end of namespace sdr diff --git a/svx/inc/svx/sdr/contact/objectcontacttools.hxx b/svx/inc/svx/sdr/contact/objectcontacttools.hxx index 7f64aab2ddef..28ef32117ff3 100644 --- a/svx/inc/svx/sdr/contact/objectcontacttools.hxx +++ b/svx/inc/svx/sdr/contact/objectcontacttools.hxx @@ -54,8 +54,7 @@ namespace sdr // deletion is duty of the caller drawinglayer::processor2d::BaseProcessor2D* createBaseProcessor2DFromOutputDevice( OutputDevice& rTargetOutDev, - const drawinglayer::geometry::ViewInformation2D& rViewInformation2D, - bool bTryToTestCanvas = false); + const drawinglayer::geometry::ViewInformation2D& rViewInformation2D); } // end of namespace contact } // end of namespace sdr diff --git a/svx/inc/svx/sdr/overlay/overlaymanager.hxx b/svx/inc/svx/sdr/overlay/overlaymanager.hxx index 11362db93911..d2e4f8a8aba3 100644 --- a/svx/inc/svx/sdr/overlay/overlaymanager.hxx +++ b/svx/inc/svx/sdr/overlay/overlaymanager.hxx @@ -39,6 +39,8 @@ #include "svx/svxdllapi.h" #include <svtools/optionsdrawinglayer.hxx> #include <boost/shared_ptr.hpp> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <drawinglayer/geometry/viewinformation2d.hxx> ////////////////////////////////////////////////////////////////////////////// // predeclarations @@ -46,18 +48,13 @@ class OutputDevice; class Region; -namespace sdr -{ - namespace overlay - { - class OverlayObject; - } // end of namespace overlay -} // end of namespace sdr +namespace sdr { namespace overlay { + class OverlayObject; +}} -namespace basegfx -{ +namespace basegfx { class B2DRange; -} // end of namespace basegfx +} ////////////////////////////////////////////////////////////////////////////// @@ -69,30 +66,39 @@ namespace sdr { protected: // the OutputDevice to work on, set on construction and not to be changed - OutputDevice& rmOutputDevice; + OutputDevice& rmOutputDevice; // start, end and number of the double linked list of OverlayObjects // managed by this manager - OverlayObject* mpOverlayObjectStart; - OverlayObject* mpOverlayObjectEnd; + OverlayObject* mpOverlayObjectStart; + OverlayObject* mpOverlayObjectEnd; // MapMode for MapMode change watching - MapMode maMapMode; + MapMode maMapMode; // Stripe support. All striped OverlayObjects use these stripe // values. Changes change all those objects. - Color maStripeColorA; // defaults to Color(COL_BLACK) - Color maStripeColorB; // defaults to Color(COL_WHITE) - sal_uInt32 mnStripeLengthPixel; // defaults to 4L + Color maStripeColorA; // defaults to Color(COL_BLACK) + Color maStripeColorB; // defaults to Color(COL_WHITE) + sal_uInt32 mnStripeLengthPixel; // defaults to 4L // hold an incarnation of Drawinglayer configuration options - SvtOptionsDrawinglayer maDrawinglayerOpt; + SvtOptionsDrawinglayer maDrawinglayerOpt; + + // hold buffered the logic length of discrete vector (1.0, 0.0) and the + // view transformation belonging to it. Update happens in getDiscreteOne() + basegfx::B2DHomMatrix maViewTransformation; + double mfDiscreteOne; // internal void ImpDrawMembers(const basegfx::B2DRange& rRange, OutputDevice& rDestinationDevice) const; void ImpCheckMapModeChange() const; void ImpStripeDefinitionChanged(); + // return mfDiscreteOne to derivations, but also check for buffered local + // ViewTransformation and evtl. correct mfDiscreteOne + const double getDiscreteOne() const; + public: OverlayManager(OutputDevice& rOutputDevice); virtual ~OverlayManager(); @@ -131,6 +137,9 @@ namespace sdr sal_uInt32 getStripeLengthPixel() const { return mnStripeLengthPixel; } void setStripeLengthPixel(sal_uInt32 nNew = 5L); + // access to maDrawinglayerOpt + const SvtOptionsDrawinglayer& getDrawinglayerOpt() const { return maDrawinglayerOpt; } + /** Return a list of all OverlayObjects that currently belong to the called OverlayManager. Subsequent calls to add() or remove() will not alter the content of the returned list. diff --git a/svx/inc/svx/sdr/overlay/overlayobject.hxx b/svx/inc/svx/sdr/overlay/overlayobject.hxx index dfa3c9cd27b6..41c13db0e457 100644 --- a/svx/inc/svx/sdr/overlay/overlayobject.hxx +++ b/svx/inc/svx/sdr/overlay/overlayobject.hxx @@ -119,7 +119,6 @@ namespace sdr void ImpDrawLineStriped(OutputDevice& rOutputDevice, double x1, double y1, double x2, double y2); void ImpDrawLineStriped(OutputDevice& rOutputDevice, const basegfx::B2DPoint& rStart, const basegfx::B2DPoint& rEnd); void ImpDrawPolygonStriped(OutputDevice& rOutputDevice, const basegfx::B2DPolygon& rPolygon); - void ImpDrawStripes(OutputDevice& rOutputDevice, const basegfx::B2DPolyPolygon& rPolyPolygon); public: OverlayObject(Color aBaseColor); diff --git a/svx/inc/svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx b/svx/inc/svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx new file mode 100644 index 000000000000..1ca1a0a7d18a --- /dev/null +++ b/svx/inc/svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx @@ -0,0 +1,79 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: overlaysdrobject.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SDR_OVERLAY_OVERLAYPRIMITIVE2DSEQUENCEOBJECT_HXX +#define _SDR_OVERLAY_OVERLAYPRIMITIVE2DSEQUENCEOBJECT_HXX + +#include <svx/sdr/overlay/overlayobject.hxx> +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace sdr +{ + namespace overlay + { + class OverlayPrimitive2DSequenceObject : public OverlayObjectWithBasePosition + { + protected: + // the sequence of primitives to show + const drawinglayer::primitive2d::Primitive2DSequence maSequence; + + // Draw geometry + virtual void drawGeometry(OutputDevice& rOutputDevice); + + // Create the BaseRange. This method needs to calculate maBaseRange. + virtual void createBaseRange(OutputDevice& rOutputDevice); + + // Hittest with logical coordinates. Default tests against maBaseRange. + virtual sal_Bool isHit(const basegfx::B2DPoint& rPos, double fTol = 0.0) const; + + private: + // internal helper to create a drawinglayer::geometry::ViewInformation2D + // using a OutputDevice and local knowledge + drawinglayer::geometry::ViewInformation2D impCreateViewInformation2D(OutputDevice& rOutputDevice) const; + + public: + OverlayPrimitive2DSequenceObject(const drawinglayer::primitive2d::Primitive2DSequence& rSequence); + + virtual ~OverlayPrimitive2DSequenceObject(); + + // data read access + const drawinglayer::primitive2d::Primitive2DSequence& getSequence() const { return maSequence; } + }; + } // end of namespace overlay +} // end of namespace sdr + +////////////////////////////////////////////////////////////////////////////// + +#endif //_SDR_OVERLAY_OVERLAYPRIMITIVE2DSEQUENCEOBJECT_HXX + +// eof diff --git a/svx/inc/svx/sdr/primitive2d/sdrprimitivetools.hxx b/svx/inc/svx/sdr/primitive2d/sdrprimitivetools.hxx new file mode 100644 index 000000000000..37edea1a5878 --- /dev/null +++ b/svx/inc/svx/sdr/primitive2d/sdrprimitivetools.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: primitiveFactory2d.hxx,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_SDR_PRIMITIVE2D_PRIMITIVETOOLS_HXX +#define INCLUDED_SDR_PRIMITIVE2D_PRIMITIVETOOLS_HXX + +#include <vcl/bitmapex.hxx> + +////////////////////////////////////////////////////////////////////////////// +// predefines + +namespace basegfx { + class BColor; +} + +////////////////////////////////////////////////////////////////////////////// +// helper methods + +namespace drawinglayer +{ + namespace primitive2d + { + // create a 3x3 cross in given color as BitmapEx + BitmapEx createDefaultCross_3x3(const basegfx::BColor& rBColor); + + // create a 7x7 gluepoint symbol in given colors as BitmapEx + BitmapEx createDefaultGluepoint_7x7(const basegfx::BColor& rBColorA, const basegfx::BColor& rBColorB); + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_SDR_PRIMITIVE2D_PRIMITIVETOOLS_HXX + +// eof diff --git a/svx/inc/svx/svddrgmt.hxx b/svx/inc/svx/svddrgmt.hxx index e79f14c20662..fa4e09c9a324 100644 --- a/svx/inc/svx/svddrgmt.hxx +++ b/svx/inc/svx/svddrgmt.hxx @@ -33,6 +33,7 @@ #include <svx/svddrgv.hxx> #include "svx/svxdllapi.h" +#include <svx/sdr/contact/objectcontact.hxx> //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -51,107 +52,206 @@ class SdrDragView; class SdrDragStat; -class SVX_DLLPUBLIC SdrDragMethod { +////////////////////////////////////////////////////////////////////////////// + +class SdrDragEntry +{ +private: + // bitfield + unsigned mbAddToTransparent : 1; + protected: - SdrDragView& rView; - bool bMoveOnly; + // access for derived classes + void setAddToTransparent(bool bNew) { mbAddToTransparent = bNew; } + +public: + SdrDragEntry(); + virtual ~SdrDragEntry(); + + virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) = 0; + + // data read access + bool getAddToTransparent() const { return mbAddToTransparent; } +}; + +////////////////////////////////////////////////////////////////////////////// + +class SVX_DLLPUBLIC SdrDragEntryPolyPolygon : public SdrDragEntry +{ +private: + basegfx::B2DPolyPolygon maOriginalPolyPolygon; + +public: + SdrDragEntryPolyPolygon(const basegfx::B2DPolyPolygon& rOriginalPolyPolygon); + virtual ~SdrDragEntryPolyPolygon(); + + virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod); +}; + +////////////////////////////////////////////////////////////////////////////// + +class SdrDragEntrySdrObject : public SdrDragEntry +{ +private: + const SdrObject& maOriginal; + SdrObject* mpClone; + sdr::contact::ObjectContact& mrObjectContact; + bool mbModify; + +public: + SdrDragEntrySdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify); + virtual ~SdrDragEntrySdrObject(); + + virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod); +}; + +////////////////////////////////////////////////////////////////////////////// + +class SdrDragEntryPointGlueDrag : public SdrDragEntry +{ +private: + std::vector< basegfx::B2DPoint > maPositions; + bool mbIsPointDrag; + +public: + SdrDragEntryPointGlueDrag(const std::vector< basegfx::B2DPoint >& rPositions, bool bIsPointDrag); + virtual ~SdrDragEntryPointGlueDrag(); + + virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod); +}; + +////////////////////////////////////////////////////////////////////////////// + +class SVX_DLLPUBLIC SdrDragMethod +{ +private: + std::vector< SdrDragEntry* > maSdrDragEntries; + sdr::overlay::OverlayObjectList maOverlayObjectList; + SdrDragView& mrSdrDragView; + + // bitfield + unsigned mbMoveOnly : 1; + unsigned mbSolidDraggingActive : 1; + protected: -//#if 0 // _SOLAR__PRIVATE - void ImpTakeDescriptionStr(USHORT nStrCacheID, String& rStr, USHORT nVal=0) const; -//#endif // __PRIVATE - SdrHdl* GetDragHdl() const { return rView.pDragHdl; } - SdrHdlKind GetDragHdlKind() const { return rView.eDragHdl; } - SdrDragStat& DragStat() { return rView.aDragStat; } - const SdrDragStat& DragStat() const { return rView.aDragStat; } - Point& Ref1() const { return rView.aRef1; } - Point& Ref2() const { return rView.aRef2; } - const SdrHdlList& GetHdlList() const { return rView.aHdl; } - void AddUndo(SdrUndoAction* pUndo) { rView.AddUndo(pUndo); } - void SetDragPolys() { rView.SetDragPolys(); } - FASTBOOL IsDragLimit() { return rView.bDragLimit; } - const Rectangle& GetDragLimitRect() { return rView.aDragLimit; } - const SdrMarkList& GetMarkedObjectList() { return rView.GetMarkedObjectList(); } - Point GetSnapPos(const Point& rPt) const { return rView.GetSnapPos(rPt,rView.pMarkedPV); } - USHORT SnapPos(Point& rPt) const { return rView.SnapPos(rPt,rView.pMarkedPV); } + // access for derivated classes to maSdrDragEntries + void clearSdrDragEntries() { for(sal_uInt32 a(0); a < maSdrDragEntries.size(); a++) { delete maSdrDragEntries[a]; } maSdrDragEntries.clear(); } + void addSdrDragEntry(SdrDragEntry* pNew) { if(pNew) { maSdrDragEntries.push_back(pNew); }} + virtual void createSdrDragEntries(); + + // access for derivated classes to maOverlayObjectList + void clearOverlayObjectList() { maOverlayObjectList.clear(); } + void addToOverlayObjectList(sdr::overlay::OverlayObject& rNew) { maOverlayObjectList.append(rNew); } + basegfx::B2DRange getB2DRangeFromOverlayObjectList() const { return maOverlayObjectList.getBaseRange(); } + + // access for derivated classes to mrSdrDragView + SdrDragView& getSdrDragView() { return mrSdrDragView; } + const SdrDragView& getSdrDragView() const { return mrSdrDragView; } + + // access for derivated classes for bools + void setMoveOnly(bool bNew) { mbMoveOnly = bNew; } + void setSolidDraggingActive(bool bNew) { mbSolidDraggingActive = bNew; } + + // internal helpers for creation of standard drag entries + void createSdrDragEntries_SolidDrag(); + void createSdrDragEntries_PolygonDrag(); + void createSdrDragEntries_PointDrag(); + void createSdrDragEntries_GlueDrag(); + + // old call forwarders to the SdrDragView + void ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, String& rStr, sal_uInt16 nVal=0) const; + SdrHdl* GetDragHdl() const { return getSdrDragView().pDragHdl; } + SdrHdlKind GetDragHdlKind() const { return getSdrDragView().eDragHdl; } + SdrDragStat& DragStat() { return getSdrDragView().aDragStat; } + const SdrDragStat& DragStat() const { return getSdrDragView().aDragStat; } + Point& Ref1() const { return mrSdrDragView.aRef1; } + Point& Ref2() const { return mrSdrDragView.aRef2; } + const SdrHdlList& GetHdlList() const { return getSdrDragView().aHdl; } + void AddUndo(SdrUndoAction* pUndo) { getSdrDragView().AddUndo(pUndo); } + bool IsDragLimit() { return getSdrDragView().bDragLimit; } + const Rectangle& GetDragLimitRect() { return getSdrDragView().aDragLimit; } + const SdrMarkList& GetMarkedObjectList() { return getSdrDragView().GetMarkedObjectList(); } + Point GetSnapPos(const Point& rPt) const { return getSdrDragView().GetSnapPos(rPt,getSdrDragView().pMarkedPV); } + sal_uInt16 SnapPos(Point& rPt) const { return getSdrDragView().SnapPos(rPt,getSdrDragView().pMarkedPV); } inline const Rectangle& GetMarkedRect() const; SdrPageView* GetDragPV() const; SdrObject* GetDragObj() const; - OutputDevice* GetDragWin() const { return rView.pDragWin; } - FASTBOOL IsDraggingPoints() const { return rView.IsDraggingPoints(); } - FASTBOOL IsDraggingGluePoints() const { return rView.IsDraggingGluePoints(); } + OutputDevice* GetDragWin() const { return getSdrDragView().pDragWin; } + bool IsDraggingPoints() const { return getSdrDragView().IsDraggingPoints(); } + bool IsDraggingGluePoints() const { return getSdrDragView().IsDraggingGluePoints(); } - void CreateOverlayGeometryLines(basegfx::B2DPolyPolygon& rResult); - void CreateOverlayGeometryPoints(basegfx::B2DPolyPolygon& rResult, const Size& rLogicSize); - sal_Bool DoAddConnectorOverlays(); - void AddConnectorOverlays(basegfx::B2DPolyPolygon& rResult); - sal_Bool DoAddDragStripeOverlay(); + bool DoAddConnectorOverlays(); + drawinglayer::primitive2d::Primitive2DSequence AddConnectorOverlays(); public: TYPEINFO(); + void resetSdrDragEntries(); + basegfx::B2DRange getCurrentRange() const; + // #i58950# also moved constructor implementation to cxx SdrDragMethod(SdrDragView& rNewView); // #i58950# virtual destructor was missing virtual ~SdrDragMethod(); - virtual void Draw() const; - virtual void Show(); - virtual void Hide(); - virtual void TakeComment(String& rStr) const=0; - virtual FASTBOOL Beg()=0; - virtual void MovAllPoints(); - virtual void MovPoint(Point& rPnt); - virtual void Mov(const Point& rPnt)=0; - virtual FASTBOOL End(FASTBOOL bCopy)=0; - virtual void Brk(); - virtual Pointer GetPointer() const=0; - virtual FASTBOOL IsMoveOnly() const; // TRUE, wenn nur verschoben wird - - // for migration from XOR to overlay - virtual void CreateOverlayGeometry(::sdr::overlay::OverlayManager& rOverlayManager, ::sdr::overlay::OverlayObjectList& rOverlayList); + void Show(); + void Hide(); + virtual void TakeSdrDragComment(String& rStr) const=0; + virtual bool BeginSdrDrag()=0; + virtual void MoveSdrDrag(const Point& rPnt)=0; + virtual bool EndSdrDrag(bool bCopy)=0; + virtual void CancelSdrDrag(); + virtual Pointer GetSdrDragPointer() const=0; + + virtual void CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlayManager); + void destroyOverlayGeometry(); + + virtual basegfx::B2DHomMatrix getCurrentTransformation(); + virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget); + virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget); + + // data read access + bool getMoveOnly() const { return mbMoveOnly; } + bool getSolidDraggingActive() const { return mbSolidDraggingActive; } }; inline const Rectangle& SdrDragMethod::GetMarkedRect() const { - return rView.eDragHdl==HDL_POLY ? rView.GetMarkedPointsRect() : - rView.eDragHdl==HDL_GLUE ? rView.GetMarkedGluePointsRect() : - rView.GetMarkedObjRect(); + return getSdrDragView().eDragHdl==HDL_POLY ? getSdrDragView().GetMarkedPointsRect() : + getSdrDragView().eDragHdl==HDL_GLUE ? getSdrDragView().GetMarkedGluePointsRect() : + getSdrDragView().GetMarkedObjRect(); } -//************************************************************ +//////////////////////////////////////////////////////////////////////////////////////////////////// // SdrDragMove -//************************************************************ class SVX_DLLPUBLIC SdrDragMove : public SdrDragMethod { +private: long nBestXSnap; long nBestYSnap; - FASTBOOL bXSnapped; - FASTBOOL bYSnapped; + bool bXSnapped; + bool bYSnapped; -private: void ImpCheckSnap(const Point& rPt); public: TYPEINFO(); - SdrDragMove(SdrDragView& rNewView): SdrDragMethod(rNewView) {} - - virtual void TakeComment(String& rStr) const; - - virtual FASTBOOL Beg(); - virtual void MovAllPoints(); - virtual void MovPoint(Point& rPnt); -// virtual void MovPoint(Point& rPnt, const Point& rPvOfs); - virtual void Mov(const Point& rPnt); - virtual FASTBOOL End(FASTBOOL bCopy); - virtual FASTBOOL IsMoveOnly() const; - virtual Pointer GetPointer() const; + SdrDragMove(SdrDragView& rNewView); + + virtual void TakeSdrDragComment(String& rStr) const; + virtual bool BeginSdrDrag(); + virtual void MoveSdrDrag(const Point& rPnt); + virtual bool EndSdrDrag(bool bCopy); + virtual Pointer GetSdrDragPointer() const; + + virtual basegfx::B2DHomMatrix getCurrentTransformation(); + virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget); }; -//************************************************************ +//////////////////////////////////////////////////////////////////////////////////////////////////// // SdrDragResize -//************************************************************ class SVX_DLLPUBLIC SdrDragResize : public SdrDragMethod { @@ -161,44 +261,47 @@ protected: public: TYPEINFO(); - SdrDragResize(SdrDragView& rNewView): SdrDragMethod(rNewView), aXFact(1,1), aYFact(1,1) {} + SdrDragResize(SdrDragView& rNewView); - virtual void TakeComment(String& rStr) const; + virtual void TakeSdrDragComment(String& rStr) const; + virtual bool BeginSdrDrag(); + virtual void MoveSdrDrag(const Point& rPnt); + virtual bool EndSdrDrag(bool bCopy); + virtual Pointer GetSdrDragPointer() const; - virtual FASTBOOL Beg(); - virtual void MovPoint(Point& rPnt); - virtual void Mov(const Point& rPnt); - virtual FASTBOOL End(FASTBOOL bCopy); - virtual Pointer GetPointer() const; + virtual basegfx::B2DHomMatrix getCurrentTransformation(); + virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget); }; -//************************************************************ +//////////////////////////////////////////////////////////////////////////////////////////////////// // SdrDragObjOwn -//************************************************************ class SVX_DLLPUBLIC SdrDragObjOwn : public SdrDragMethod { -public: - TYPEINFO(); - SdrDragObjOwn(SdrDragView& rNewView): SdrDragMethod(rNewView) {} - - virtual void TakeComment(String& rStr) const; - - virtual FASTBOOL Beg(); - virtual void Mov(const Point& rPnt); - virtual FASTBOOL End(FASTBOOL bCopy); - virtual Pointer GetPointer() const; +private: + // SdrDragObjOwn always works on a clone since it has no transformation + // mechanism to modify wireframe visualisations, but uses the + // SdrObject::applySpecialDrag() method to change a clone of the + // SdrObject + SdrObject* mpClone; - // for migration from XOR to overlay - virtual void CreateOverlayGeometry(::sdr::overlay::OverlayManager& rOverlayManager, ::sdr::overlay::OverlayObjectList& rOverlayList); +protected: + virtual void createSdrDragEntries(); - //SJ: added following method, otherwise the object won't be - //able to notice that dragging has been cancelled. - virtual void Brk(); +public: + TYPEINFO(); + SdrDragObjOwn(SdrDragView& rNewView); + virtual ~SdrDragObjOwn(); + + virtual void TakeSdrDragComment(String& rStr) const; + virtual bool BeginSdrDrag(); + virtual void MoveSdrDrag(const Point& rPnt); + virtual bool EndSdrDrag(bool bCopy); + virtual Pointer GetSdrDragPointer() const; }; //////////////////////////////////////////////////////////////////////////////////////////////////// - #endif //_SVDDRGMT_HXX +// eof diff --git a/svx/inc/svx/svddrgv.hxx b/svx/inc/svx/svddrgv.hxx index 586da302beeb..3e03f437909a 100644 --- a/svx/inc/svx/svddrgv.hxx +++ b/svx/inc/svx/svddrgv.hxx @@ -63,17 +63,11 @@ class SVX_DLLPUBLIC SdrDragView: public SdrExchangeView protected: SdrHdl* pDragHdl; - SdrDragMethod* pDragBla; + SdrDragMethod* mpCurrentSdrDragMethod; SdrUndoGeoObj* pInsPointUndo; - - // for migrating stuff from XOR, use ImpSdrDragViewExtraData ATM to not need to - // compile the apps all the time - ImpSdrDragViewExtraData* mpDragViewExtraData; - Rectangle aDragLimit; XubString aInsPointUndoStr; SdrMarkList aFollowingEdges; // Wenn Knoten gedraggd werden, sollen alle Kanten als Xor folgen - SdrHdlKind eDragHdl; ULONG nDragXorPolyLimit; @@ -87,14 +81,12 @@ protected: unsigned bDragLimit : 1; // Limit auf SnapRect statt BoundRect unsigned bDragHdl : 1; // TRUE: RefPt wird verschoben unsigned bDragStripes : 1; // Persistent - //HMHunsigned bNoDragHdl : 1; // Persistent - Handles waehrend des Draggens verstecken unsigned bMirrRefDragObj : 1; // Persistent - Waehrend des Draggens der Spiegelachse die gespiegelten Objekte als Xor zeigen - unsigned bSolidDragging : 1; // Dragging und Create in Echtzeit erlaubt + unsigned mbSolidDragging : 1; // allow solid create/drag of objects unsigned bMouseHideWhileDraggingPoints : 1; unsigned bResizeAtCenter : 1; unsigned bCrookAtCenter : 1; unsigned bDragWithCopy : 1; -// unsigned bInsAfter : 1; // Parameter zum Einfuegen von Folgepunkten unsigned bInsGluePoint : 1; unsigned bInsObjPointMode : 1; unsigned bInsGluePointMode : 1; @@ -111,8 +103,6 @@ private: protected: virtual void SetMarkHandles(); - // aDragPoly0 an den PageViews setzen - void SetDragPolys(bool bReset = false); void ShowDragObj(); void HideDragObj(); sal_Bool ImpBegInsObjPoint(sal_Bool bIdxZwang, sal_uInt32 nIdx, const Point& rPnt, sal_Bool bNewObj, OutputDevice* pOut); @@ -149,10 +139,9 @@ public: void MovDragObj(const Point& rPnt); BOOL EndDragObj(BOOL bCopy=FALSE); void BrkDragObj(); - BOOL IsDragObj() const { return pDragBla!=NULL && !bInsPolyPoint && !bInsGluePoint; } + BOOL IsDragObj() const { return mpCurrentSdrDragMethod && !bInsPolyPoint && !bInsGluePoint; } SdrHdl* GetDragHdl() const { return pDragHdl; } - SdrDragMethod* GetDragMethod() const { return pDragBla; } - BOOL IsMoveOnlyDragObj(BOOL bAskRTTI=FALSE) const; + SdrDragMethod* GetDragMethod() const { return mpCurrentSdrDragMethod; } BOOL IsDraggingPoints() const { return eDragHdl==HDL_POLY; } BOOL IsDraggingGluePoints() const { return eDragHdl==HDL_GLUE; } @@ -172,7 +161,7 @@ public: void MovInsObjPoint(const Point& rPnt) { MovDragObj(rPnt); } BOOL EndInsObjPoint(SdrCreateCmd eCmd); void BrkInsObjPoint() { BrkDragObj(); } - BOOL IsInsObjPoint() const { return pDragBla!=NULL && bInsPolyPoint; } + BOOL IsInsObjPoint() const { return mpCurrentSdrDragMethod && bInsPolyPoint; } // Fuer die App zum Verwalten des Status. GetPreferedPointer() wird // spaeter vielleicht einen passenden Pointer dafuer liefern @@ -184,7 +173,7 @@ public: void MovInsGluePoint(const Point& rPnt) { MovDragObj(rPnt); } BOOL EndInsGluePoint() { return EndDragObj(); } void BrkInsGluePoint() { BrkDragObj(); } - BOOL IsInsGluePoint() const { return pDragBla!=NULL && bInsGluePoint; } + BOOL IsInsGluePoint() const { return mpCurrentSdrDragMethod && bInsGluePoint; } // Fuer die App zum Verwalten des Status. GetPreferedPointer() wird // spaeter vielleicht einen passenden Pointer dafuer liefern @@ -229,8 +218,8 @@ public: void SetDragXorPointLimit(ULONG nPntAnz) { nDragXorPointLimit=nPntAnz; } ULONG GetDragXorPointLimit() const { return nDragXorPointLimit; } - void SetSolidDragging(BOOL bOn) { bSolidDragging = bOn; } - BOOL IsSolidDragging() const { return bSolidDragging; } + void SetSolidDragging(bool bOn); + bool IsSolidDragging() const; // Dragging/Creating von Verbindern: // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/svx/inc/svx/svdedtv.hxx b/svx/inc/svx/svdedtv.hxx index 359573339d27..c56bb9d01f62 100644 --- a/svx/inc/svx/svdedtv.hxx +++ b/svx/inc/svx/svdedtv.hxx @@ -95,6 +95,8 @@ enum SdrMergeMode { class SVX_DLLPUBLIC SdrEditView: public SdrMarkView { friend class SdrPageView; + friend class SdrDragDistort; + friend class SdrDragCrook; protected: diff --git a/svx/inc/svx/svdoashp.hxx b/svx/inc/svx/svdoashp.hxx index 3662f8c67c3f..a75c064e35ad 100644 --- a/svx/inc/svx/svdoashp.hxx +++ b/svx/inc/svx/svdoashp.hxx @@ -201,18 +201,15 @@ public: virtual void NbcSetStyleSheet( SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr ); - virtual FASTBOOL HasSpecialDrag() const; - virtual FASTBOOL BegDrag( SdrDragStat& rDrag ) const; - virtual FASTBOOL EndDrag( SdrDragStat& rDrag ); + // special drag methods + virtual bool hasSpecialDrag() const; + virtual bool beginSpecialDrag(SdrDragStat& rDrag) const; + virtual bool applySpecialDrag(SdrDragStat& rDrag); virtual FASTBOOL BegCreate( SdrDragStat& rStat ); virtual FASTBOOL MovCreate(SdrDragStat& rStat); // #i37448# virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd); - virtual void BrkDrag( SdrDragStat& rDrag ) const; - virtual FASTBOOL MovDrag( SdrDragStat& rDrag ) const; - virtual basegfx::B2DPolyPolygon TakeDragPoly(const SdrDragStat& rDrag) const; - virtual FASTBOOL AdjustTextFrameWidthAndHeight(Rectangle& rR, FASTBOOL bHgt=TRUE, FASTBOOL bWdt=TRUE) const; virtual FASTBOOL NbcAdjustTextFrameWidthAndHeight(FASTBOOL bHgt=TRUE, FASTBOOL bWdt=TRUE); virtual FASTBOOL AdjustTextFrameWidthAndHeight(FASTBOOL bHgt=TRUE, FASTBOOL bWdt=TRUE); diff --git a/svx/inc/svx/svdobj.hxx b/svx/inc/svx/svdobj.hxx index 65ab5a8d4ebd..a2550c43696f 100644 --- a/svx/inc/svx/svdobj.hxx +++ b/svx/inc/svx/svdobj.hxx @@ -76,6 +76,7 @@ class SfxItemPool; class PolyPolygon; class SfxPoolItem; class SdrVirtObj; +class SdrDragView; namespace sdr { @@ -734,13 +735,21 @@ public: // FALSE kann zurueckgegeben werden, wenn das Dragging das Objekt nicht // veraendert hat, wobei dir evtl. Tatsache das die Maus nicht bewegt wurde // bereits von der View abgefangen wird. - virtual FASTBOOL HasSpecialDrag() const; - virtual FASTBOOL BegDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL MovDrag(SdrDragStat& rDrag) const; // True=Xor muss repainted werden - virtual FASTBOOL EndDrag(SdrDragStat& rDrag); - virtual void BrkDrag(SdrDragStat& rDrag) const; - virtual String GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const; - virtual basegfx::B2DPolyPolygon TakeDragPoly(const SdrDragStat& rDrag) const; + virtual bool hasSpecialDrag() const; + virtual bool beginSpecialDrag(SdrDragStat& rDrag) const; + virtual bool applySpecialDrag(SdrDragStat& rDrag); + virtual String getSpecialDragComment(const SdrDragStat& rDrag) const; + virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const; + + // FullDrag support. This is for standard interactions and for SdrObjOwn + // support. If supportsFullDrag() returns true, getFullDragClone has to + // return a cloned SdrObject (who's ownership it loses) at which modifications + // like Move(), Scale(), etc or applySpecialDrag() will be executed. That + // object will be visualized on overlay for full drag, but should not be + // part of the model, thus not changing anything since it's only a temporary + // helper object for interaction + virtual bool supportsFullDrag() const; + virtual SdrObject* getFullDragClone() const; // Jedes Objekt muss in der Lage sein sich selbst interaktiv zu erzeugen. // Beim MausDown wird zunaechst ein neues Objekt erzeugt und dann seine @@ -1089,9 +1098,9 @@ public: // Give info if object is in destruction sal_Bool IsInDestruction() const; - // #i34682# // return if fill is != XFILL_NONE - sal_Bool HasFillStyle() const; + bool HasFillStyle() const; + bool HasLineStyle() const; // on import of OLE object from MS documents the BLIP size might be retrieved, // the following methods are used to control it; diff --git a/svx/inc/svx/svdocapt.hxx b/svx/inc/svx/svdocapt.hxx index ddd90736e82b..8e7860c204ce 100644 --- a/svx/inc/svx/svdocapt.hxx +++ b/svx/inc/svx/svdocapt.hxx @@ -118,15 +118,13 @@ public: virtual sal_uInt32 GetHdlCount() const; virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const; - virtual FASTBOOL HasSpecialDrag() const; - virtual FASTBOOL BegDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL MovDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL EndDrag(SdrDragStat& rDrag); - virtual void BrkDrag(SdrDragStat& rDrag) const; - virtual String GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const; + // special drag methods + virtual bool hasSpecialDrag() const; + virtual bool beginSpecialDrag(SdrDragStat& rDrag) const; + virtual bool applySpecialDrag(SdrDragStat& rDrag); + virtual String getSpecialDragComment(const SdrDragStat& rDrag) const; - virtual basegfx::B2DPolyPolygon TakeDragPoly(const SdrDragStat& rDrag) const; virtual FASTBOOL BegCreate(SdrDragStat& rStat); virtual FASTBOOL MovCreate(SdrDragStat& rStat); virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd); diff --git a/svx/inc/svx/svdocirc.hxx b/svx/inc/svx/svdocirc.hxx index abcc0d90e425..db31996939af 100644 --- a/svx/inc/svx/svdocirc.hxx +++ b/svx/inc/svx/svdocirc.hxx @@ -77,8 +77,6 @@ protected: SdrObjKind meCircleKind; long nStartWink; long nEndWink; - Point aPnt1; - Point aPnt2; // bitfield unsigned mbPolygonIsLine : 1; @@ -128,15 +126,13 @@ public: virtual sal_uInt32 GetHdlCount() const; virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const; - virtual FASTBOOL HasSpecialDrag() const; - virtual FASTBOOL BegDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL MovDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL EndDrag(SdrDragStat& rDrag); - virtual void BrkDrag(SdrDragStat& rDrag) const; - virtual String GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const; + // special drag methods + virtual bool hasSpecialDrag() const; + virtual bool beginSpecialDrag(SdrDragStat& rDrag) const; + virtual bool applySpecialDrag(SdrDragStat& rDrag); + virtual String getSpecialDragComment(const SdrDragStat& rDrag) const; - virtual basegfx::B2DPolyPolygon TakeDragPoly(const SdrDragStat& rDrag) const; virtual FASTBOOL BegCreate(SdrDragStat& rStat); virtual FASTBOOL MovCreate(SdrDragStat& rStat); virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd); diff --git a/svx/inc/svx/svdoedge.hxx b/svx/inc/svx/svdoedge.hxx index 74de1262e44f..9d2effc87c28 100644 --- a/svx/inc/svx/svdoedge.hxx +++ b/svx/inc/svx/svdoedge.hxx @@ -264,14 +264,15 @@ public: virtual sal_uInt32 GetHdlCount() const; virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const; - virtual FASTBOOL HasSpecialDrag() const; - virtual FASTBOOL BegDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL MovDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL EndDrag(SdrDragStat& rDrag); - virtual void BrkDrag(SdrDragStat& rDrag) const; - virtual String GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const; - - virtual basegfx::B2DPolyPolygon TakeDragPoly(const SdrDragStat& rDrag) const; + // special drag methods + virtual bool hasSpecialDrag() const; + virtual bool beginSpecialDrag(SdrDragStat& rDrag) const; + virtual bool applySpecialDrag(SdrDragStat& rDrag); + virtual String getSpecialDragComment(const SdrDragStat& rDrag) const; + + // FullDrag support + virtual SdrObject* getFullDragClone() const; + virtual void NbcSetSnapRect(const Rectangle& rRect); virtual void NbcMove(const Size& aSize); virtual void NbcResize(const Point& rRefPnt, const Fraction& aXFact, const Fraction& aYFact); @@ -319,7 +320,7 @@ public: // helper method for SdrDragMethod::AddConnectorOverlays. Adds a overlay polygon for // this connector to rResult. - void ImplAddConnectorOverlay(basegfx::B2DPolyPolygon& rResult, SdrDragMethod& rDragMethod, sal_Bool bTail1, sal_Bool bTail2, sal_Bool bDetail) const; + basegfx::B2DPolygon ImplAddConnectorOverlay(SdrDragMethod& rDragMethod, bool bTail1, bool bTail2, bool bDetail) const; }; //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/svx/inc/svx/svdograf.hxx b/svx/inc/svx/svdograf.hxx index 7ac03774adb6..4d464d5c9836 100644 --- a/svx/inc/svx/svdograf.hxx +++ b/svx/inc/svx/svdograf.hxx @@ -189,7 +189,7 @@ public: virtual basegfx::B2DPolyPolygon TakeXorPoly() const; virtual void operator=(const SdrObject& rObj); - virtual FASTBOOL HasSpecialDrag() const; + virtual sal_uInt32 GetHdlCount() const; virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const; diff --git a/svx/inc/svx/svdogrp.hxx b/svx/inc/svx/svdogrp.hxx index 6787969a83b4..b6d2a4519db6 100644 --- a/svx/inc/svx/svdogrp.hxx +++ b/svx/inc/svx/svdogrp.hxx @@ -93,7 +93,9 @@ public: virtual void RecalcSnapRect(); virtual basegfx::B2DPolyPolygon TakeXorPoly() const; - virtual FASTBOOL BegDrag(SdrDragStat& rDrag) const; + // special drag methods + virtual bool beginSpecialDrag(SdrDragStat& rDrag) const; + virtual FASTBOOL BegCreate(SdrDragStat& rStat); virtual long GetRotateAngle() const; diff --git a/svx/inc/svx/svdomeas.hxx b/svx/inc/svx/svdomeas.hxx index 967bc9ec1b8a..33f72b5c3529 100644 --- a/svx/inc/svx/svdomeas.hxx +++ b/svx/inc/svx/svdomeas.hxx @@ -114,14 +114,12 @@ public: virtual basegfx::B2DPolyPolygon TakeXorPoly() const; virtual sal_uInt32 GetHdlCount() const; virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const; - virtual FASTBOOL HasSpecialDrag() const; - virtual FASTBOOL BegDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL MovDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL EndDrag(SdrDragStat& rDrag); - virtual void BrkDrag(SdrDragStat& rDrag) const; - - virtual String GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const; - virtual basegfx::B2DPolyPolygon TakeDragPoly(const SdrDragStat& rDrag) const; + + // special drag methods + virtual bool hasSpecialDrag() const; + virtual bool beginSpecialDrag(SdrDragStat& rDrag) const; + virtual bool applySpecialDrag(SdrDragStat& rDrag); + virtual String getSpecialDragComment(const SdrDragStat& rDrag) const; virtual FASTBOOL BegCreate(SdrDragStat& rStat); virtual FASTBOOL MovCreate(SdrDragStat& rStat); diff --git a/svx/inc/svx/svdoole2.hxx b/svx/inc/svx/svdoole2.hxx index 6cf41fce8ac1..87a86baeb624 100644 --- a/svx/inc/svx/svdoole2.hxx +++ b/svx/inc/svx/svdoole2.hxx @@ -140,6 +140,9 @@ public: */ void SetClosedObj( bool bIsClosed ); + // FullDrag support + virtual SdrObject* getFullDragClone() const; + virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const; virtual UINT16 GetObjIdentifier() const; virtual SdrObject* CheckHit(const Point& rPnt, USHORT nTol, const SetOfByte* pVisiLayer) const; @@ -147,7 +150,6 @@ public: virtual void TakeObjNamePlural(String& rName) const; virtual void operator=(const SdrObject& rObj); - virtual FASTBOOL HasSpecialDrag() const; virtual void NbcMove(const Size& rSize); virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); diff --git a/svx/inc/svx/svdopath.hxx b/svx/inc/svx/svdopath.hxx index 79746d6a7bbe..a43b06ffd2ab 100644 --- a/svx/inc/svx/svdopath.hxx +++ b/svx/inc/svx/svdopath.hxx @@ -113,13 +113,12 @@ public: virtual SdrHdl* GetPlusHdl(const SdrHdl& rHdl, sal_uInt32 nPlNum) const; virtual void AddToHdlList(SdrHdlList& rHdlList) const; - virtual FASTBOOL HasSpecialDrag() const; - virtual FASTBOOL BegDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL MovDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL EndDrag(SdrDragStat& rDrag); - virtual void BrkDrag(SdrDragStat& rDrag) const; - virtual String GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const; - virtual basegfx::B2DPolyPolygon TakeDragPoly(const SdrDragStat& rDrag) const; + // special drag methods + virtual bool hasSpecialDrag() const; + virtual bool beginSpecialDrag(SdrDragStat& rDrag) const; + virtual bool applySpecialDrag(SdrDragStat& rDrag); + virtual String getSpecialDragComment(const SdrDragStat& rDrag) const; + virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const; virtual FASTBOOL BegCreate(SdrDragStat& rStat); virtual FASTBOOL MovCreate(SdrDragStat& rStat); diff --git a/svx/inc/svx/svdorect.hxx b/svx/inc/svx/svdorect.hxx index afc25021b081..2f4a3a3120dc 100644 --- a/svx/inc/svx/svdorect.hxx +++ b/svx/inc/svx/svdorect.hxx @@ -116,15 +116,13 @@ public: virtual sal_uInt32 GetHdlCount() const; virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const; - virtual FASTBOOL HasSpecialDrag() const; - virtual FASTBOOL BegDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL MovDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL EndDrag(SdrDragStat& rDrag); - virtual void BrkDrag(SdrDragStat& rDrag) const; - virtual String GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const; + // special drag methods + virtual bool hasSpecialDrag() const; + virtual bool beginSpecialDrag(SdrDragStat& rDrag) const; + virtual bool applySpecialDrag(SdrDragStat& rDrag); + virtual String getSpecialDragComment(const SdrDragStat& rDrag) const; - virtual basegfx::B2DPolyPolygon TakeDragPoly(const SdrDragStat& rDrag) const; virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const; virtual Pointer GetCreatePointer() const; diff --git a/svx/inc/svx/svdotable.hxx b/svx/inc/svx/svdotable.hxx index 05f288daf1ed..04348306a7de 100644 --- a/svx/inc/svx/svdotable.hxx +++ b/svx/inc/svx/svdotable.hxx @@ -246,13 +246,12 @@ public: virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const; virtual void AddToHdlList(SdrHdlList& rHdlList) const; - virtual FASTBOOL HasSpecialDrag() const; - virtual FASTBOOL BegDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL MovDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL EndDrag(SdrDragStat& rDrag); - virtual void BrkDrag(SdrDragStat& rDrag) const; - virtual String GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const; - virtual basegfx::B2DPolyPolygon TakeDragPoly(const SdrDragStat& rDrag) const; + // special drag methods + virtual bool hasSpecialDrag() const; + virtual bool beginSpecialDrag(SdrDragStat& rDrag) const; + virtual bool applySpecialDrag(SdrDragStat& rDrag); + virtual String getSpecialDragComment(const SdrDragStat& rDrag) const; + virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const; virtual FASTBOOL BegCreate(SdrDragStat& rStat); virtual FASTBOOL MovCreate(SdrDragStat& rStat); @@ -264,16 +263,11 @@ public: virtual void NbcMove(const Size& rSiz); virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); -// virtual void NbcRotate(const Point& rRef, long nWink, double sn, double cs); -// virtual void NbcMirror(const Point& rRef1, const Point& rRef2); -// virtual void NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear); -// virtual FASTBOOL HasTextEdit() const; virtual sal_Bool BegTextEdit(SdrOutliner& rOutl); virtual void EndTextEdit(SdrOutliner& rOutl); virtual void TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const; virtual void TakeTextEditArea(const sdr::table::CellPos& rPos, Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const; -// virtual SdrObject* CheckTextEditHit(const Point& rPnt, USHORT nTol, const SetOfByte* pVisiLayer) const; virtual USHORT GetOutlinerViewAnchorMode() const; virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject); @@ -284,10 +278,6 @@ public: virtual void NbcReformatText(); virtual void ReformatText(); -// virtual FASTBOOL CalcFieldValue(const SvxFieldItem& rField, USHORT nPara, USHORT nPos, FASTBOOL bEdit, Color*& rpTxtColor, Color*& rpFldColor, String& rRet) const; - -// virtual SdrObject* DoConvertToPolyObj(BOOL bBezier) const; - void SetTextEditOutliner(SdrOutliner* pOutl) { pEdtOutl=pOutl; } virtual sal_Bool IsVerticalWriting() const; diff --git a/svx/inc/svx/svdotext.hxx b/svx/inc/svx/svdotext.hxx index 4d26873e9b51..080e20fd1a77 100644 --- a/svx/inc/svx/svdotext.hxx +++ b/svx/inc/svx/svdotext.hxx @@ -448,13 +448,11 @@ public: virtual sal_uInt32 GetHdlCount() const; virtual SdrHdl* GetHdl(sal_uInt32 nHdlNum) const; - virtual FASTBOOL HasSpecialDrag() const; - virtual FASTBOOL BegDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL MovDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL EndDrag(SdrDragStat& rDrag); - virtual void BrkDrag(SdrDragStat& rDrag) const; - virtual String GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const; - virtual basegfx::B2DPolyPolygon TakeDragPoly(const SdrDragStat& rDrag) const; + + // special drag methods + virtual bool hasSpecialDrag() const; + virtual bool applySpecialDrag(SdrDragStat& rDrag); + virtual String getSpecialDragComment(const SdrDragStat& rDrag) const; virtual FASTBOOL BegCreate(SdrDragStat& rStat); virtual FASTBOOL MovCreate(SdrDragStat& rStat); diff --git a/svx/inc/svx/svdouno.hxx b/svx/inc/svx/svdouno.hxx index b454c59207f8..d0dd60fd8c9a 100644 --- a/svx/inc/svx/svdouno.hxx +++ b/svx/inc/svx/svdouno.hxx @@ -93,11 +93,16 @@ public: virtual SdrObject* CheckHit(const Point& rPnt, USHORT nTol, const SetOfByte* pVisiLayer) const; virtual void operator = (const SdrObject& rObj); - virtual FASTBOOL HasSpecialDrag() const; - virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact); virtual void NbcSetLayer(SdrLayerID nLayer); + // SpecialDrag support + virtual bool hasSpecialDrag() const; + + // FullDrag support + virtual bool supportsFullDrag() const; + virtual SdrObject* getFullDragClone() const; + virtual void TakeObjNameSingul(XubString& rName) const; virtual void TakeObjNamePlural(XubString& rName) const; diff --git a/svx/inc/svx/svdovirt.hxx b/svx/inc/svx/svdovirt.hxx index b8282a706d81..d7010cd40b48 100644 --- a/svx/inc/svx/svdovirt.hxx +++ b/svx/inc/svx/svdovirt.hxx @@ -96,14 +96,17 @@ public: virtual sal_uInt32 GetPlusHdlCount(const SdrHdl& rHdl) const; virtual SdrHdl* GetPlusHdl(const SdrHdl& rHdl, sal_uInt32 nPlNum) const; virtual void AddToHdlList(SdrHdlList& rHdlList) const; - virtual FASTBOOL HasSpecialDrag() const; - virtual FASTBOOL BegDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL MovDrag(SdrDragStat& rDrag) const; - virtual FASTBOOL EndDrag(SdrDragStat& rDrag); - virtual void BrkDrag(SdrDragStat& rDrag) const; - - virtual String GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const; - virtual basegfx::B2DPolyPolygon TakeDragPoly(const SdrDragStat& rDrag) const; + + // special drag methods + virtual bool hasSpecialDrag() const; + virtual bool beginSpecialDrag(SdrDragStat& rDrag) const; + virtual bool applySpecialDrag(SdrDragStat& rDrag); + virtual String getSpecialDragComment(const SdrDragStat& rDrag) const; + virtual basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const; + + // FullDrag support + virtual bool supportsFullDrag() const; + virtual SdrObject* getFullDragClone() const; virtual FASTBOOL BegCreate(SdrDragStat& rStat); virtual FASTBOOL MovCreate(SdrDragStat& rStat); diff --git a/svx/inc/svx/svdpagv.hxx b/svx/inc/svx/svdpagv.hxx index 5fa95b379b3d..cf5ae7e165d0 100644 --- a/svx/inc/svx/svdpagv.hxx +++ b/svx/inc/svx/svdpagv.hxx @@ -82,8 +82,6 @@ protected: Rectangle aMarkBound; // wird Rectangle aMarkSnap; // von - basegfx::B2DPolyPolygon maDragPoly0; // SdrView - basegfx::B2DPolyPolygon maDragPoly; // sal_Bool mbHasMarked; sal_Bool mbVisible; @@ -283,11 +281,6 @@ public: // Die Namen aller z.Zt. betretenen Gruppen String GetActualPathName(sal_Unicode cSep = sal_Unicode('|')) const; - const basegfx::B2DPolyPolygon& getDragPoly0() const { return maDragPoly0; } - const basegfx::B2DPolyPolygon& getDragPoly() const { return maDragPoly; } - void setDragPoly0(const basegfx::B2DPolyPolygon& rNew) { maDragPoly0 = rNew; } - void setDragPoly(const basegfx::B2DPolyPolygon& rNew) { maDragPoly = rNew; } - // #103834# Set background color for svx at SdrPageViews void SetApplicationBackgroundColor(Color aBackgroundColor); diff --git a/svx/inc/svx/svdsnpv.hxx b/svx/inc/svx/svdsnpv.hxx index 2d625cf63e4e..bf93d6b179a3 100644 --- a/svx/inc/svx/svdsnpv.hxx +++ b/svx/inc/svx/svdsnpv.hxx @@ -145,8 +145,7 @@ public: USHORT SnapPos(Point& rPnt, const SdrPageView* pPV) const; Point GetSnapPos(const Point& rPnt, const SdrPageView* pPV) const; USHORT SnapRect(const Rectangle& rRect, const SdrPageView* pPV, long& rDX, long& rDY) const; - void CheckSnap(const Point& rPt, const SdrPageView* pPV, - long& nBestXSnap, long& nBestYSnap, BOOL& bXSnapped, BOOL& bYSnapped) const; + void CheckSnap(const Point& rPt, const SdrPageView* pPV, long& nBestXSnap, long& nBestYSnap, bool& bXSnapped, bool& bYSnapped) const; // Alle Fangeinstellungen sind Persistent. BOOL IsSnapEnabled() const { return bSnapEnab; } diff --git a/svx/inc/svx/svdxcgv.hxx b/svx/inc/svx/svdxcgv.hxx index b682a8ee1e11..ed15dfd70c77 100644 --- a/svx/inc/svx/svdxcgv.hxx +++ b/svx/inc/svx/svdxcgv.hxx @@ -114,7 +114,7 @@ public: @return a graphical representation of the given object, as it appears on screen (e.g. with rotation, if any, applied). */ - static Graphic GetObjGraphic( SdrModel* pModel, SdrObject* pObj ); + static Graphic GetObjGraphic( const SdrModel* pModel, const SdrObject* pObj ); // Bestimmung des View-Mittelpunktes, z.B. zum Pasten Point GetViewCenter(const OutputDevice* pOut=NULL) const; diff --git a/svx/source/dialog/optgdlg.cxx b/svx/source/dialog/optgdlg.cxx index 51bb349a5683..14ce656e8ade 100644 --- a/svx/source/dialog/optgdlg.cxx +++ b/svx/source/dialog/optgdlg.cxx @@ -48,7 +48,6 @@ #include <i18npool/mslangid.hxx> #include <svtools/useroptions.hxx> #include <svtools/cacheoptions.hxx> -#include <svtools/options3d.hxx> #include <svtools/fontoptions.hxx> #include <svtools/menuoptions.hxx> #include <svtools/startoptions.hxx> @@ -62,9 +61,7 @@ #include <sfx2/objsh.hxx> #include <comphelper/types.hxx> #include <svtools/ctloptions.hxx> - #include <svtools/langtab.hxx> - #include <unotools/localfilehelper.hxx> #include <unotools/configmgr.hxx> #include "cuioptgenrl.hxx" @@ -113,6 +110,7 @@ #include "optgdlg.hxx" #include "ofaitem.hxx" #include <svtools/apearcfg.hxx> +#include <svtools/optionsdrawinglayer.hxx> #define CONFIG_LANGUAGES "OfficeLanguages" @@ -661,13 +659,6 @@ void CanvasSettings::EnabledHardwareAcceleration( BOOL _bEnabled ) const } // class OfaViewTabPage -------------------------------------------------- -// ----------------------------------------------------------------------- -IMPL_LINK_INLINE_START( OfaViewTabPage, OpenGLHdl, CheckBox*, EMPTYARG ) -{ - a3DOpenGLFasterCB.Enable( a3DOpenGLCB.IsChecked() ); - return 0; -} -IMPL_LINK_INLINE_END( OfaViewTabPage, OpenGLHdl, CheckBox*, EMPTYARG ) OfaViewTabPage::OfaViewTabPage(Window* pParent, const SfxItemSet& rSet ) : @@ -691,13 +682,9 @@ OfaViewTabPage::OfaViewTabPage(Window* pParent, const SfxItemSet& rSet ) : aFontListsFL ( this, SVX_RES( FL_FONTLISTS) ), aFontShowCB ( this, SVX_RES( CB_FONT_SHOW ) ), aFontHistoryCB ( this, SVX_RES( CB_FONT_HISTORY ) ), - a3DGB ( this, SVX_RES( FL_3D ) ), - a3DOpenGLCB ( this, SVX_RES( CB_3D_OPENGL ) ), - a3DOpenGLFasterCB ( this, SVX_RES( CB_3D_OPENGL_FASTER ) ), - a3DDitheringCB ( this, SVX_RES( CB_3D_DITHERING ) ), - a3DShowFullCB ( this, SVX_RES( CB_3D_SHOWFULL ) ), aRenderingFL ( this, SVX_RES( FL_RENDERING ) ), aUseHardwareAccell ( this, SVX_RES( CB_USE_HARDACCELL ) ), + aUseAntiAliase ( this, SVX_RES( CB_USE_ANTIALIASE ) ), aMouseFL ( this, SVX_RES( FL_MOUSE ) ), aMousePosFT ( this, SVX_RES( FT_MOUSEPOS ) ), aMousePosLB ( this, SVX_RES( LB_MOUSEPOS ) ), @@ -706,17 +693,9 @@ OfaViewTabPage::OfaViewTabPage(Window* pParent, const SfxItemSet& rSet ) : nSizeLB_InitialSelection(0), nStyleLB_InitialSelection(0), pAppearanceCfg(new SvtTabAppearanceCfg), - pCanvasSettings(new CanvasSettings) + pCanvasSettings(new CanvasSettings), + mpDrawinglayerOpt(new SvtOptionsDrawinglayer) { - - a3DOpenGLCB.SetClickHdl( LINK( this, OfaViewTabPage, OpenGLHdl ) ); - - if ( !pCanvasSettings->IsHardwareAccelerationAvailable() ) - { - aRenderingFL.Hide(); - aUseHardwareAccell.Hide(); - } - #if defined( UNX ) aFontAntiAliasing.SetToggleHdl( LINK( this, OfaViewTabPage, OnAntialiasingToggled ) ); @@ -806,6 +785,7 @@ OfaViewTabPage::OfaViewTabPage(Window* pParent, const SfxItemSet& rSet ) : OfaViewTabPage::~OfaViewTabPage() { + delete mpDrawinglayerOpt; delete pCanvasSettings; delete pAppearanceCfg; } @@ -960,40 +940,34 @@ BOOL OfaViewTabPage::FillItemSet( SfxItemSet& ) bModified = TRUE; } - if ( pCanvasSettings->IsHardwareAccelerationAvailable() ) - if ( pCanvasSettings && aUseHardwareAccell.IsChecked() != aUseHardwareAccell.GetSavedValue() ) + // #i95644# if disabled, do not use value, see in ::Reset() + if(aUseHardwareAccell.IsEnabled()) + { + if(aUseHardwareAccell.IsChecked() != aUseHardwareAccell.GetSavedValue()) { - pCanvasSettings->EnabledHardwareAcceleration( aUseHardwareAccell.IsChecked() ); + pCanvasSettings->EnabledHardwareAcceleration(aUseHardwareAccell.IsChecked()); bModified = TRUE; } - - // Workingset - SvtOptions3D a3DOpt; - BOOL bTemp = a3DOpt.IsOpenGL(); - - if ( bTemp != a3DOpenGLCB.IsChecked() ) - { - a3DOpt.SetOpenGL( a3DOpenGLCB.IsChecked() ); - bModified = TRUE; } - BOOL bCheck = ( a3DOpenGLCB.IsChecked() && a3DOpenGLFasterCB.IsChecked() ); - if ( a3DOpt.IsOpenGL_Faster() != bCheck ) + // #i95644# if disabled, do not use value, see in ::Reset() + if(aUseAntiAliase.IsEnabled()) { - a3DOpt.SetOpenGL_Faster( bCheck ); - bModified = TRUE; - } + if(aUseAntiAliase.IsChecked() != mpDrawinglayerOpt->IsAntiAliasing()) + { + mpDrawinglayerOpt->SetAntiAliasing(aUseAntiAliase.IsChecked()); + bModified = TRUE; - if ( a3DOpt.IsDithering() != a3DDitheringCB.IsChecked() ) - { - a3DOpt.SetDithering( a3DDitheringCB.IsChecked() ); - bModified = TRUE; - } + // react on AA change; invalidate all windows to force + // a repaint when changing from AA to non-AA or vice-versa + Window* pAppWindow = Application::GetFirstTopLevelWindow(); - if ( a3DOpt.IsShowFull() != a3DShowFullCB.IsChecked() ) - { - a3DOpt.SetShowFull( a3DShowFullCB.IsChecked() ); - bModified = TRUE; + while(pAppWindow) + { + pAppWindow->Invalidate(); + pAppWindow = Application::GetNextTopLevelWindow(pAppWindow); + } + } } SvtAccessibilityOptions aAccessibilityOptions; @@ -1026,13 +1000,6 @@ BOOL OfaViewTabPage::FillItemSet( SfxItemSet& ) --------------------------------------------------*/ void OfaViewTabPage::Reset( const SfxItemSet& ) { - SvtOptions3D a3DOpt; - a3DOpenGLCB.Check( a3DOpt.IsOpenGL() ); - a3DOpenGLFasterCB.Check( a3DOpenGLCB.IsChecked() && a3DOpt.IsOpenGL_Faster() ); - OpenGLHdl( NULL ); - a3DDitheringCB.Check( a3DOpt.IsDithering() ); - a3DShowFullCB.Check( a3DOpt.IsShowFull() ); - SvtMiscOptions aMiscOptions; if( aMiscOptions.GetSymbolsSize() != SFX_SYMBOLS_SIZE_AUTO ) @@ -1084,10 +1051,35 @@ void OfaViewTabPage::Reset( const SfxItemSet& ) SvtMenuOptions aMenuOpt; aMenuIconsCB.Check(aMenuOpt.IsMenuIconsEnabled()); aMenuIconsCB.SaveValue(); - aFontHistoryCB.Check( aFontOpt.IsFontHistoryEnabled() ); - if ( pCanvasSettings && pCanvasSettings->IsHardwareAccelerationAvailable() ) - aUseHardwareAccell.Check( pCanvasSettings->IsHardwareAccelerationEnabled() ); + + { // #i95644# HW accel (unified to disable mechanism) + if(pCanvasSettings->IsHardwareAccelerationAvailable()) + { + aUseHardwareAccell.Check(pCanvasSettings->IsHardwareAccelerationEnabled()); + } + else + { + aUseHardwareAccell.Check(false); + aUseHardwareAccell.Disable(); + } + + aUseHardwareAccell.SaveValue(); + } + + { // #i95644# AntiAliasing + if(mpDrawinglayerOpt->IsAAPossibleOnThisSystem()) + { + aUseAntiAliase.Check(mpDrawinglayerOpt->IsAntiAliasing()); + } + else + { + aUseAntiAliase.Check(false); + aUseAntiAliase.Disable(); + } + + aUseAntiAliase.SaveValue(); + } #if defined( UNX ) aFontAntiAliasing.SaveValue(); @@ -1095,8 +1087,6 @@ void OfaViewTabPage::Reset( const SfxItemSet& ) #endif aFontShowCB.SaveValue(); aFontHistoryCB.SaveValue(); - if ( pCanvasSettings->IsHardwareAccelerationAvailable() ) - aUseHardwareAccell.SaveValue(); #if defined( UNX ) LINK( this, OfaViewTabPage, OnAntialiasingToggled ).Call( NULL ); diff --git a/svx/source/dialog/optgdlg.hrc b/svx/source/dialog/optgdlg.hrc index 658b1c9c0f7a..b2d27bf7704d 100644 --- a/svx/source/dialog/optgdlg.hrc +++ b/svx/source/dialog/optgdlg.hrc @@ -77,16 +77,13 @@ #define ROW_CB_FONT_SHOW (ROW_FL_FONTLISTS + RSC_CD_FIXEDLINE_HEIGHT + ROWSPACE) #define ROW_CB_FONT_HISTORY (ROW_CB_FONT_SHOW + RSC_CD_CHECKBOX_HEIGHT + ROWSPACE) -#define ROW_FL_3D (3) -#define ROW_CB_3D_OPENGL (ROW_FL_3D + RSC_CD_FIXEDLINE_HEIGHT + ROWSPACE) -#define ROW_CB_3D_OPENGL_FASTER (ROW_CB_3D_OPENGL + RSC_CD_CHECKBOX_HEIGHT + ROWSPACE) -#define ROW_CB_3D_DITHERING (ROW_CB_3D_OPENGL_FASTER + RSC_CD_CHECKBOX_HEIGHT + ROWSPACE) -#define ROW_CB_3D_SHOWFULL (ROW_CB_3D_DITHERING + RSC_CD_CHECKBOX_HEIGHT + ROWSPACE) - -#define ROW_FL_RENDERING (ROW_CB_3D_SHOWFULL + RSC_CD_FIXEDLINE_HEIGHT + RSC_SP_FLGR_SPACE_X) +// #i95644# start on top with rendering section +#define ROW_FL_RENDERING (3) #define ROW_CB_USE_HARDACCELL (ROW_FL_RENDERING + RSC_CD_FIXEDLINE_HEIGHT + ROWSPACE) +#define ROW_CB_USE_ANTIALIASE (ROW_CB_USE_HARDACCELL + RSC_CD_CHECKBOX_HEIGHT + ROWSPACE) -#define ROW_FL_MOUSE (ROW_FL_MENU) // the same Y position as the menu - according to the spec. +// #i95644# set Menu to follow vertically (was (ROW_FL_MENU)) previously) +#define ROW_FL_MOUSE (ROW_CB_USE_ANTIALIASE + RSC_CD_FIXEDLINE_HEIGHT + RSC_SP_FLGR_SPACE_X) #define ROW_FT_MOUSEPOS (ROW_FL_MOUSE + RSC_CD_FIXEDLINE_HEIGHT + ROWSPACE) #define ROW_LB_MOUSEPOS (ROW_FT_MOUSEPOS + RSC_CD_FIXEDTEXT_HEIGHT + ROWSPACE) #define ROW_FT_MOUSEMIDDLE (ROW_LB_MOUSEPOS + RSC_CD_DROPDOWN_HEIGHT + ROWSPACE) @@ -116,12 +113,7 @@ #define CB_PRINTDLG 45 // tabpage view ---------------------------------------------------------- - -#define FL_3D 10 -#define CB_3D_OPENGL 11 -#define CB_3D_OPENGL_FASTER 12 -#define CB_3D_DITHERING 13 -#define CB_3D_SHOWFULL 14 +// #i95644# 10 .. 14 freed, may be reused #define FL_USERINTERFACE 20 #define FT_WINDOWSIZE 21 @@ -153,6 +145,7 @@ #define FL_RENDERING 67 #define CB_USE_HARDACCELL 68 +#define CB_USE_ANTIALIASE 69 // tabpage languages ----------------------------------------------------- diff --git a/svx/source/dialog/optgdlg.hxx b/svx/source/dialog/optgdlg.hxx index c63f4841fbf1..a4ee154e0160 100644 --- a/svx/source/dialog/optgdlg.hxx +++ b/svx/source/dialog/optgdlg.hxx @@ -38,7 +38,9 @@ #include <readonlyimage.hxx> #define FOLDERWEBVIEW_DEFAULTFILE "folder.so" +// predeclarations class CanvasSettings; +class SvtOptionsDrawinglayer; // class OfaMiscTabPage -------------------------------------------------- @@ -116,14 +118,9 @@ private: CheckBox aFontShowCB; CheckBox aFontHistoryCB; - FixedLine a3DGB; - CheckBox a3DOpenGLCB; - CheckBox a3DOpenGLFasterCB; - CheckBox a3DDitheringCB; - CheckBox a3DShowFullCB; - FixedLine aRenderingFL; CheckBox aUseHardwareAccell; + CheckBox aUseAntiAliase; FixedLine aMouseFL; FixedText aMousePosFT; @@ -135,10 +132,10 @@ private: UINT16 nStyleLB_InitialSelection; BOOL bSfxSymbolsAuto; - SvtTabAppearanceCfg* pAppearanceCfg; - CanvasSettings* pCanvasSettings; + SvtTabAppearanceCfg* pAppearanceCfg; + CanvasSettings* pCanvasSettings; + SvtOptionsDrawinglayer* mpDrawinglayerOpt; - DECL_LINK( OpenGLHdl, CheckBox* ); #if defined( UNX ) DECL_LINK( OnAntialiasingToggled, void* ); #endif diff --git a/svx/source/dialog/optgdlg.src b/svx/source/dialog/optgdlg.src index bcd95963fa8d..966df6cb5320 100644 --- a/svx/source/dialog/optgdlg.src +++ b/svx/source/dialog/optgdlg.src @@ -323,37 +323,6 @@ TabPage OFA_TP_VIEW Size = MAP_APPFONT ( 118 , RSC_CD_CHECKBOX_HEIGHT ) ; Text [ en-US ] = "Show font h~istory" ; }; - FixedLine FL_3D - { - Pos = MAP_APPFONT ( 133, ROW_FL_3D ) ; - Size = MAP_APPFONT ( 121 , 8 ) ; - Text [ en-US ] = "3D view" ; - }; - CheckBox CB_3D_OPENGL - { - Pos = MAP_APPFONT ( 139, ROW_CB_3D_OPENGL ) ; - Size = MAP_APPFONT ( 120 , RSC_CD_CHECKBOX_HEIGHT ) ; - Text [ en-US ] = "Use ~OpenGL" ; - }; - CheckBox CB_3D_OPENGL_FASTER - { - Pos = MAP_APPFONT ( 148 , ROW_CB_3D_OPENGL_FASTER ) ; - Size = MAP_APPFONT ( 111 , RSC_CD_CHECKBOX_HEIGHT ) ; - Text [ en-US ] = "O~ptimized output"; - }; - CheckBox CB_3D_DITHERING - { - Pos = MAP_APPFONT ( 139 , ROW_CB_3D_DITHERING ) ; - Size = MAP_APPFONT ( 120 , RSC_CD_CHECKBOX_HEIGHT ) ; - Text [ en-US ] = "Use ~dithering" ; - }; - CheckBox CB_3D_SHOWFULL - { - Pos = MAP_APPFONT ( 139 , ROW_CB_3D_SHOWFULL ) ; - Size = MAP_APPFONT ( 120 , RSC_CD_CHECKBOX_HEIGHT ) ; - Text [ en-US ] = "Ob~ject refresh during interaction" ; - }; - FixedLine FL_RENDERING { Pos = MAP_APPFONT ( 133 , ROW_FL_RENDERING ) ; @@ -368,6 +337,13 @@ TabPage OFA_TP_VIEW Text [ en-US ] = "Use hardware acceleration" ; }; + CheckBox CB_USE_ANTIALIASE + { + Pos = MAP_APPFONT ( 139, ROW_CB_USE_ANTIALIASE ) ; + Size = MAP_APPFONT ( 118 , RSC_CD_CHECKBOX_HEIGHT ) ; + Text [ en-US ] = "Use Anti-Aliasing" ; + }; + FixedLine FL_MOUSE { Pos = MAP_APPFONT ( 133 , ROW_FL_MOUSE ) ; diff --git a/svx/source/dialog/optmemory.cxx b/svx/source/dialog/optmemory.cxx index ad8be188ffad..ac5a1809fc7b 100644 --- a/svx/source/dialog/optmemory.cxx +++ b/svx/source/dialog/optmemory.cxx @@ -50,7 +50,6 @@ #include <svtools/undoopt.hxx> #include <svtools/useroptions.hxx> #include <svtools/cacheoptions.hxx> -#include <svtools/options3d.hxx> #include <svtools/fontoptions.hxx> #include <svtools/menuoptions.hxx> #include <svtools/startoptions.hxx> diff --git a/svx/source/engine3d/dragmt3d.cxx b/svx/source/engine3d/dragmt3d.cxx index 504f4e95168f..9abf4e483649 100644 --- a/svx/source/engine3d/dragmt3d.cxx +++ b/svx/source/engine3d/dragmt3d.cxx @@ -119,7 +119,7 @@ E3dDragMethod::E3dDragMethod ( |* \************************************************************************/ -void E3dDragMethod::TakeComment(XubString& /*rStr*/) const +void E3dDragMethod::TakeSdrDragComment(XubString& /*rStr*/) const { } @@ -129,7 +129,7 @@ void E3dDragMethod::TakeComment(XubString& /*rStr*/) const |* \************************************************************************/ -FASTBOOL E3dDragMethod::Beg() +bool E3dDragMethod::BeginSdrDrag() { if(E3DDRAG_CONSTR_Z == meConstraint) { @@ -162,7 +162,7 @@ FASTBOOL E3dDragMethod::Beg() |* \************************************************************************/ -FASTBOOL E3dDragMethod::End(FASTBOOL /*bCopy*/) +bool E3dDragMethod::EndSdrDrag(bool /*bCopy*/) { const sal_uInt32 nCnt(maGrp.size()); @@ -175,7 +175,7 @@ FASTBOOL E3dDragMethod::End(FASTBOOL /*bCopy*/) // Alle Transformationen anwenden und UnDo's anlegen if(mbMovedAtAll) { - rView.BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_ROTATE)); + getSdrDragView().BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_ROTATE)); sal_uInt32 nOb(0); for(nOb=0;nOb<nCnt;nOb++) @@ -183,11 +183,11 @@ FASTBOOL E3dDragMethod::End(FASTBOOL /*bCopy*/) E3dDragMethodUnit& rCandidate = maGrp[nOb]; E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj); rCandidate.mp3DObj->SetTransform(rCandidate.maTransform); - rView.AddUndo(new E3dRotateUndoAction(rCandidate.mp3DObj->GetModel(), + getSdrDragView().AddUndo(new E3dRotateUndoAction(rCandidate.mp3DObj->GetModel(), rCandidate.mp3DObj, rCandidate.maInitTransform, rCandidate.maTransform)); } - rView.EndUndo(); + getSdrDragView().EndUndo(); } return TRUE; @@ -199,7 +199,7 @@ FASTBOOL E3dDragMethod::End(FASTBOOL /*bCopy*/) |* \************************************************************************/ -void E3dDragMethod::Brk() +void E3dDragMethod::CancelSdrDrag() { if(mbMoveFull) { @@ -211,6 +211,7 @@ void E3dDragMethod::Brk() { // Transformation restaurieren E3dDragMethodUnit& rCandidate = maGrp[nOb]; + E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj); rCandidate.mp3DObj->SetTransform(rCandidate.maInitTransform); } } @@ -224,11 +225,11 @@ void E3dDragMethod::Brk() /************************************************************************* |* -|* Gemeinsames Mov() +|* Gemeinsames MoveSdrDrag() |* \************************************************************************/ -void E3dDragMethod::Mov(const Point& /*rPnt*/) +void E3dDragMethod::MoveSdrDrag(const Point& /*rPnt*/) { mbMovedAtAll = true; } @@ -240,7 +241,7 @@ void E3dDragMethod::Mov(const Point& /*rPnt*/) \************************************************************************/ // for migration from XOR to overlay -void E3dDragMethod::CreateOverlayGeometry(::sdr::overlay::OverlayManager& rOverlayManager, ::sdr::overlay::OverlayObjectList& rOverlayList) +void E3dDragMethod::CreateOverlayGeometry(::sdr::overlay::OverlayManager& rOverlayManager) { const sal_uInt32 nCnt(maGrp.size()); basegfx::B2DPolyPolygon aResult; @@ -248,7 +249,7 @@ void E3dDragMethod::CreateOverlayGeometry(::sdr::overlay::OverlayManager& rOverl for(sal_uInt32 nOb(0); nOb < nCnt; nOb++) { E3dDragMethodUnit& rCandidate = maGrp[nOb]; - SdrPageView* pPV = rView.GetSdrPageView(); + SdrPageView* pPV = getSdrDragView().GetSdrPageView(); if(pPV && pPV->HasMarkedObjPageView()) { @@ -277,7 +278,7 @@ void E3dDragMethod::CreateOverlayGeometry(::sdr::overlay::OverlayManager& rOverl { ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aResult); rOverlayManager.add(*pNew); - rOverlayList.append(*pNew); + addToOverlayObjectList(*pNew); } } @@ -351,18 +352,18 @@ E3dDragRotate::E3dDragRotate(SdrDragView &_rView, |* \************************************************************************/ -void E3dDragRotate::Mov(const Point& rPnt) +void E3dDragRotate::MoveSdrDrag(const Point& rPnt) { // call parent - E3dDragMethod::Mov(rPnt); + E3dDragMethod::MoveSdrDrag(rPnt); if(DragStat().CheckMinMoved(rPnt)) { // Modifier holen sal_uInt16 nModifier = 0; - if(rView.ISA(E3dView)) + if(getSdrDragView().ISA(E3dView)) { - const MouseEvent& rLastMouse = ((E3dView&)rView).GetMouseEvent(); + const MouseEvent& rLastMouse = ((E3dView&)getSdrDragView()).GetMouseEvent(); nModifier = rLastMouse.GetModifier(); } @@ -392,7 +393,7 @@ void E3dDragRotate::Mov(const Point& rPnt) } long nSnap = 0; - if(!rView.IsRotateAllowed(FALSE)) + if(!getSdrDragView().IsRotateAllowed(FALSE)) nSnap = 90; if(nSnap != 0) @@ -446,6 +447,7 @@ void E3dDragRotate::Mov(const Point& rPnt) if(mbMoveFull) { + E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj); rCandidate.mp3DObj->SetTransform(rCandidate.maTransform); } else @@ -464,7 +466,7 @@ void E3dDragRotate::Mov(const Point& rPnt) |* \************************************************************************/ -Pointer E3dDragRotate::GetPointer() const +Pointer E3dDragRotate::GetSdrDragPointer() const { return Pointer(POINTER_ROTATE); } @@ -520,7 +522,7 @@ E3dDragMove::E3dDragMove(SdrDragView &_rView, } // Override wenn IsResizeAtCenter() - if(rView.IsResizeAtCenter()) + if(getSdrDragView().IsResizeAtCenter()) { meWhatDragHdl = HDL_USER; maScaleFixPos = maFullBound.Center(); @@ -533,10 +535,10 @@ E3dDragMove::E3dDragMove(SdrDragView &_rView, |* \************************************************************************/ -void E3dDragMove::Mov(const Point& rPnt) +void E3dDragMove::MoveSdrDrag(const Point& rPnt) { // call parent - E3dDragMethod::Mov(rPnt); + E3dDragMethod::MoveSdrDrag(rPnt); if(DragStat().CheckMinMoved(rPnt)) { @@ -551,9 +553,9 @@ void E3dDragMove::Mov(const Point& rPnt) // Modifier holen sal_uInt16 nModifier(0); - if(rView.ISA(E3dView)) + if(getSdrDragView().ISA(E3dView)) { - const MouseEvent& rLastMouse = ((E3dView&)rView).GetMouseEvent(); + const MouseEvent& rLastMouse = ((E3dView&)getSdrDragView()).GetMouseEvent(); nModifier = rLastMouse.GetModifier(); } @@ -610,6 +612,7 @@ void E3dDragMove::Mov(const Point& rPnt) if(mbMoveFull) { + E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj); rCandidate.mp3DObj->SetTransform(rCandidate.maTransform); } else @@ -696,7 +699,7 @@ void E3dDragMove::Mov(const Point& rPnt) } // SHIFT-key used? - if(rView.IsOrtho()) + if(getSdrDragView().IsOrtho()) { if(fabs(aScaleVec.getX()) > fabs(aScaleVec.getY())) { @@ -728,6 +731,7 @@ void E3dDragMove::Mov(const Point& rPnt) if(mbMoveFull) { + E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj); rCandidate.mp3DObj->SetTransform(rCandidate.maTransform); } else @@ -749,7 +753,7 @@ void E3dDragMove::Mov(const Point& rPnt) |* \************************************************************************/ -Pointer E3dDragMove::GetPointer() const +Pointer E3dDragMove::GetSdrDragPointer() const { return Pointer(POINTER_MOVE); } diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx index 743aa3c6aa56..23e73421192d 100644 --- a/svx/source/engine3d/obj3d.cxx +++ b/svx/source/engine3d/obj3d.cxx @@ -1126,15 +1126,6 @@ void E3dCompoundObject::AddToHdlList(SdrHdlList& rHdlList) const /************************************************************************* |* -\************************************************************************/ - -FASTBOOL E3dCompoundObject::HasSpecialDrag() const -{ - return TRUE; -} - -/************************************************************************* -|* |* Identifier zurueckgeben |* \************************************************************************/ diff --git a/svx/source/engine3d/polysc3d.cxx b/svx/source/engine3d/polysc3d.cxx index 7f2c1af02e96..9cca99b55188 100644 --- a/svx/source/engine3d/polysc3d.cxx +++ b/svx/source/engine3d/polysc3d.cxx @@ -30,7 +30,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include <svtools/options3d.hxx> #include <svx/xfillit.hxx> #include <svx/svdopath.hxx> #include <svx/svdogrp.hxx> diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx index 6d57a9f1dd7a..81e4543dbe86 100644 --- a/svx/source/engine3d/view3d.cxx +++ b/svx/source/engine3d/view3d.cxx @@ -31,9 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" - #include <vcl/wrkwin.hxx> -#include <svtools/options3d.hxx> #include <svx/svdogrp.hxx> #include <svx/svdopath.hxx> #include <tools/shl.hxx> @@ -42,12 +40,10 @@ #include <svx/svdorect.hxx> #include <svx/svdmodel.hxx> #include <svx/svdpagv.hxx> - #include <svx/svxids.hrc> #include <svx/colritem.hxx> #include <svx/xtable.hxx> #include <svx/svdview.hxx> - #include <svx/dialogs.hrc> #include <svx/dialmgr.hxx> #include "globl3d.hxx" @@ -68,13 +64,19 @@ #include <basegfx/range/b2drange.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> - #include <svx/xlnwtit.hxx> #include <svx/sdr/overlay/overlaypolypolygon.hxx> #include <svx/sdr/overlay/overlaymanager.hxx> #include <sdrpaintwindow.hxx> #include <svx/sdr/contact/viewcontactofe3dscene.hxx> #include <drawinglayer/geometry/viewinformation3d.hxx> +#include <svx/sdrpagewindow.hxx> +#include <svx/sdr/contact/displayinfo.hxx> +#include <svx/sdr/contact/objectcontact.hxx> +#include <svx/sdr/contact/viewobjectcontact.hxx> +#include <drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx> +#include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx> +#include <drawinglayer/primitive2d/transformprimitive2d.hxx> #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue() @@ -91,10 +93,15 @@ class Impl3DMirrorConstructOverlay // the view const E3dView& mrView; - // the unmirrored polygons and their count + // the object count sal_uInt32 mnCount; + + // the unmirrored polygons basegfx::B2DPolyPolygon* mpPolygons; + // the overlay geometry from selected objects + drawinglayer::primitive2d::Primitive2DSequence maFullOverlay; + public: Impl3DMirrorConstructOverlay(const E3dView& rView); ~Impl3DMirrorConstructOverlay(); @@ -103,17 +110,51 @@ public: }; Impl3DMirrorConstructOverlay::Impl3DMirrorConstructOverlay(const E3dView& rView) -: mrView(rView) +: maObjects(), + mrView(rView), + mnCount(rView.GetMarkedObjectCount()), + mpPolygons(0), + maFullOverlay() { - const SdrMarkList& rMarkList = mrView.GetMarkedObjectList(); - mnCount = rMarkList.GetMarkCount(); - mpPolygons = new basegfx::B2DPolyPolygon[mnCount]; - - for(sal_uInt32 a(0L); a < mnCount; a++) + if(mnCount) { - SdrMark *pMark = rMarkList.GetMark(a); - SdrObject *pObj = pMark->GetMarkedSdrObj(); - mpPolygons[mnCount - (a + 1L)] = pObj->TakeXorPoly(); + if(mrView.IsSolidDragging()) + { + SdrPageView* pPV = rView.GetSdrPageView(); + + if(pPV && pPV->PageWindowCount()) + { + sdr::contact::ObjectContact& rOC = pPV->GetPageWindow(0)->GetObjectContact(); + sdr::contact::DisplayInfo aDisplayInfo; + + // Do not use the last ViewPort set at the OC at the last ProcessDisplay() + rOC.resetViewPort(); + + for(sal_uInt32 a(0);a < mnCount;a++) + { + SdrObject* pObject = mrView.GetMarkedObjectByIndex(a); + + if(pObject) + { + sdr::contact::ViewContact& rVC = pObject->GetViewContact(); + sdr::contact::ViewObjectContact& rVOC = rVC.GetViewObjectContact(rOC); + + const drawinglayer::primitive2d::Primitive2DSequence aNewSequence(rVOC.getPrimitive2DSequenceHierarchy(aDisplayInfo)); + drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(maFullOverlay, aNewSequence); + } + } + } + } + else + { + mpPolygons = new basegfx::B2DPolyPolygon[mnCount]; + + for(sal_uInt32 a(0); a < mnCount; a++) + { + SdrObject* pObject = mrView.GetMarkedObjectByIndex(a); + mpPolygons[mnCount - (a + 1)] = pObject->TakeXorPoly(); + } + } } } @@ -122,7 +163,10 @@ Impl3DMirrorConstructOverlay::~Impl3DMirrorConstructOverlay() // The OverlayObjects are cleared using the destructor of OverlayObjectList. // That destructor calls clear() at the list which removes all objects from the // OverlayManager and deletes them. - delete[] mpPolygons; + if(!mrView.IsSolidDragging()) + { + delete[] mpPolygons; + } } void Impl3DMirrorConstructOverlay::SetMirrorAxis(Point aMirrorAxisA, Point aMirrorAxisB) @@ -131,33 +175,60 @@ void Impl3DMirrorConstructOverlay::SetMirrorAxis(Point aMirrorAxisA, Point aMirr maObjects.clear(); // create new ones - for(sal_uInt32 a(0L); a < mrView.PaintWindowCount(); a++) + for(sal_uInt32 a(0); a < mrView.PaintWindowCount(); a++) { SdrPaintWindow* pCandidate = mrView.GetPaintWindow(a); ::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager(); if(pTargetOverlay) { - for(sal_uInt32 b(0L); b < mnCount; b++) + // buld transfoprmation: translate and rotate so that given edge is + // on x axis, them mirror in y and translate back + const basegfx::B2DVector aEdge(aMirrorAxisB.X() - aMirrorAxisA.X(), aMirrorAxisB.Y() - aMirrorAxisA.Y()); + basegfx::B2DHomMatrix aMatrixTransform; + + aMatrixTransform.translate(-aMirrorAxisA.X(), -aMirrorAxisA.Y()); + aMatrixTransform.rotate(-atan2(aEdge.getY(), aEdge.getX())); + aMatrixTransform.scale(1.0, -1.0); + aMatrixTransform.rotate(atan2(aEdge.getY(), aEdge.getX())); + aMatrixTransform.translate(aMirrorAxisA.X(), aMirrorAxisA.Y()); + + if(mrView.IsSolidDragging()) { - basegfx::B2DPolyPolygon aPolyPolygon(mpPolygons[b]); + if(maFullOverlay.hasElements()) + { + drawinglayer::primitive2d::Primitive2DSequence aContent(maFullOverlay); - // translate and rotate polygon so that given edge is on x axis, them mirror in y and translate back - const basegfx::B2DVector aEdge(aMirrorAxisB.X() - aMirrorAxisA.X(), aMirrorAxisB.Y() - aMirrorAxisA.Y()); - basegfx::B2DHomMatrix aMatrixTransform; + if(!aMatrixTransform.isIdentity()) + { + // embed in transformation group + drawinglayer::primitive2d::Primitive2DReference aTransformPrimitive2D(new drawinglayer::primitive2d::TransformPrimitive2D(aMatrixTransform, aContent)); + aContent = drawinglayer::primitive2d::Primitive2DSequence(&aTransformPrimitive2D, 1); + } - aMatrixTransform.translate(-aMirrorAxisA.X(), -aMirrorAxisA.Y()); - aMatrixTransform.rotate(-atan2(aEdge.getY(), aEdge.getX())); - aMatrixTransform.scale(1.0, -1.0); - aMatrixTransform.rotate(atan2(aEdge.getY(), aEdge.getX())); - aMatrixTransform.translate(aMirrorAxisA.X(), aMirrorAxisA.Y()); + // if we have full overlay from selected objects, embed with 50% transparence, the + // transformation is added to the OverlayPrimitive2DSequenceObject + drawinglayer::primitive2d::Primitive2DReference aUnifiedAlphaPrimitive2D(new drawinglayer::primitive2d::UnifiedAlphaPrimitive2D(aContent, 0.5)); + aContent = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedAlphaPrimitive2D, 1); - // apply to polygon - aPolyPolygon.transform(aMatrixTransform); + sdr::overlay::OverlayPrimitive2DSequenceObject* pNew = new sdr::overlay::OverlayPrimitive2DSequenceObject(aContent); - ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aPolyPolygon); - pTargetOverlay->add(*pNew); - maObjects.append(*pNew); + pTargetOverlay->add(*pNew); + maObjects.append(*pNew); + } + } + else + { + for(sal_uInt32 b(0); b < mnCount; b++) + { + // apply to polygon + basegfx::B2DPolyPolygon aPolyPolygon(mpPolygons[b]); + aPolyPolygon.transform(aMatrixTransform); + + ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aPolyPolygon); + pTargetOverlay->add(*pNew); + maObjects.append(*pNew); + } } } } @@ -1288,8 +1359,7 @@ BOOL E3dView::BegDragObj(const Point& rPnt, OutputDevice* pOut, // die nicht erlaubten Rotationen ausmaskieren eConstraint = E3dDragConstraint(eConstraint& eDragConstraint); - pForcedMeth = new E3dDragRotate(*this, GetMarkedObjectList(), eConstraint, - SvtOptions3D().IsShowFull() ); + pForcedMeth = new E3dDragRotate(*this, GetMarkedObjectList(), eConstraint, IsSolidDragging()); } break; @@ -1297,8 +1367,7 @@ BOOL E3dView::BegDragObj(const Point& rPnt, OutputDevice* pOut, { if(!bThereAreRootScenes) { - pForcedMeth = new E3dDragMove(*this, GetMarkedObjectList(), eDragHdl, eConstraint, - SvtOptions3D().IsShowFull() ); + pForcedMeth = new E3dDragMove(*this, GetMarkedObjectList(), eDragHdl, eConstraint, IsSolidDragging()); } } break; diff --git a/svx/source/sdr/contact/displayinfo.cxx b/svx/source/sdr/contact/displayinfo.cxx index 572de245c71d..93047b0c56a4 100644 --- a/svx/source/sdr/contact/displayinfo.cxx +++ b/svx/source/sdr/contact/displayinfo.cxx @@ -47,8 +47,7 @@ namespace sdr namespace contact { DisplayInfo::DisplayInfo() - : //mpProcessedPage(0), - maProcessLayers(true), // init layer info with all bits set to draw everything on default + : maProcessLayers(true), // init layer info with all bits set to draw everything on default maRedrawArea(), mbControlLayerProcessingActive(false), mbPageProcessingActive(true), @@ -59,45 +58,20 @@ namespace sdr DisplayInfo::~DisplayInfo() { - //SetProcessedPage(0); } - // access to ProcessedPage, write for internal use only. - //void DisplayInfo::SetProcessedPage(SdrPage* pNew) - //{ - // if(pNew != mpProcessedPage) - // { - // mpProcessedPage = pNew; - // } - //} - - //const SdrPage* DisplayInfo::GetProcessedPage() const - //{ - // return mpProcessedPage; - //} - // Access to LayerInfos (which layers to proccess) void DisplayInfo::SetProcessLayers(const SetOfByte& rSet) { maProcessLayers = rSet; } - const SetOfByte& DisplayInfo::GetProcessLayers() const - { - return maProcessLayers; - } - // access to RedrawArea void DisplayInfo::SetRedrawArea(const Region& rRegion) { maRedrawArea = rRegion; } - const Region& DisplayInfo::GetRedrawArea() const - { - return maRedrawArea; - } - void DisplayInfo::SetControlLayerProcessingActive(bool bDoProcess) { if((bool)mbControlLayerProcessingActive != bDoProcess) @@ -106,11 +80,6 @@ namespace sdr } } - bool DisplayInfo::GetControlLayerProcessingActive() const - { - return mbControlLayerProcessingActive; - } - void DisplayInfo::SetPageProcessingActive(bool bDoProcess) { if((bool)mbPageProcessingActive != bDoProcess) @@ -119,11 +88,6 @@ namespace sdr } } - bool DisplayInfo::GetPageProcessingActive() const - { - return mbPageProcessingActive; - } - void DisplayInfo::ClearGhostedDrawMode() { mbGhostedDrawModeActive = false; @@ -134,16 +98,6 @@ namespace sdr mbGhostedDrawModeActive = true; } - bool DisplayInfo::IsGhostedDrawModeActive() const - { - return mbGhostedDrawModeActive; - } - - bool DisplayInfo::GetSubContentActive() const - { - return mbSubContentActive; - } - void DisplayInfo::SetSubContentActive(bool bNew) { if((bool)mbSubContentActive != bNew) @@ -151,6 +105,7 @@ namespace sdr mbSubContentActive = bNew; } } + } // end of namespace contact } // end of namespace sdr diff --git a/svx/source/sdr/contact/objectcontact.cxx b/svx/source/sdr/contact/objectcontact.cxx index ca52a2209990..9491d1f06ee4 100644 --- a/svx/source/sdr/contact/objectcontact.cxx +++ b/svx/source/sdr/contact/objectcontact.cxx @@ -291,6 +291,27 @@ namespace sdr { return 0; } + + void ObjectContact::resetViewPort() + { + const drawinglayer::geometry::ViewInformation2D& rCurrentVI2D = getViewInformation2D(); + + if(!rCurrentVI2D.getViewport().isEmpty()) + { + const basegfx::B2DRange aEmptyRange; + + drawinglayer::geometry::ViewInformation2D aNewVI2D( + rCurrentVI2D.getObjectTransformation(), + rCurrentVI2D.getViewTransformation(), + aEmptyRange, + rCurrentVI2D.getVisualizedPage(), + rCurrentVI2D.getViewTime(), + rCurrentVI2D.getExtendedInformationSequence()); + + updateViewInformation2D(aNewVI2D); + } + } + } // end of namespace contact } // end of namespace sdr diff --git a/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx b/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx index af13b7b42307..b1d748d34b34 100644 --- a/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx +++ b/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx @@ -142,7 +142,7 @@ namespace sdr if(xPrimitiveSequence.hasElements()) { drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = createBaseProcessor2DFromOutputDevice( - *pTargetDevice, getViewInformation2D(), false); + *pTargetDevice, getViewInformation2D()); if(pProcessor2D) { diff --git a/svx/source/sdr/contact/objectcontactofpageview.cxx b/svx/source/sdr/contact/objectcontactofpageview.cxx index c550593f6f75..94a5756483cd 100644 --- a/svx/source/sdr/contact/objectcontactofpageview.cxx +++ b/svx/source/sdr/contact/objectcontactofpageview.cxx @@ -250,10 +250,8 @@ namespace sdr pOutDev->SetLayoutMode(0); // reset, default is no BiDi/RTL // create renderer - static bool bTryTestCanvas(false); - drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = createBaseProcessor2DFromOutputDevice( - rTargetOutDev, getViewInformation2D(), bTryTestCanvas); + rTargetOutDev, getViewInformation2D()); if(pProcessor2D) { diff --git a/svx/source/sdr/contact/objectcontacttools.cxx b/svx/source/sdr/contact/objectcontacttools.cxx index 379d263058b3..8ed6dcaf9e27 100644 --- a/svx/source/sdr/contact/objectcontacttools.cxx +++ b/svx/source/sdr/contact/objectcontacttools.cxx @@ -55,8 +55,7 @@ namespace sdr { drawinglayer::processor2d::BaseProcessor2D* createBaseProcessor2DFromOutputDevice( OutputDevice& rTargetOutDev, - const drawinglayer::geometry::ViewInformation2D& rViewInformation2D, - bool bTryToTestCanvas) + const drawinglayer::geometry::ViewInformation2D& rViewInformation2D) { const GDIMetaFile* pMetaFile = rTargetOutDev.GetConnectMetaFile(); const bool bOutputToRecordingMetaFile(pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause()); @@ -68,7 +67,28 @@ namespace sdr } else { - if(bTryToTestCanvas) +#ifdef WIN32 + // for a first AA incarnation VCL-PixelRenderer will be okay since + // simple (and fast) GDIPlus support over VCL will be used. + // Leaving the code below as a hint for what to do when we will + // use canvas renderers in the future + + //static SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; + + //if(false && aSvtOptionsDrawinglayer.IsAntiAliasing()) + //{ + // // for WIN32 AA, create cairo canvas processor + // return new drawinglayer::processor2d::canvasProcessor2D(rViewInformation2D, rTargetOutDev); + //} + //else + //{ + // create Pixel Vcl-Processor + return new drawinglayer::processor2d::VclPixelProcessor2D(rViewInformation2D, rTargetOutDev); + //} +#else + static bool bTryTestCanvas(false); + + if(bTryTestCanvas) { // create test-cancas-Processor return new drawinglayer::processor2d::canvasProcessor2D(rViewInformation2D, rTargetOutDev); @@ -78,6 +98,7 @@ namespace sdr // create Pixel Vcl-Processor return new drawinglayer::processor2d::VclPixelProcessor2D(rViewInformation2D, rTargetOutDev); } +#endif } } } // end of namespace contact diff --git a/svx/source/sdr/contact/viewcontactofsdrobj.cxx b/svx/source/sdr/contact/viewcontactofsdrobj.cxx index 1afc0d968af7..64e7e79a4263 100644 --- a/svx/source/sdr/contact/viewcontactofsdrobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrobj.cxx @@ -44,6 +44,7 @@ #include <svx/sdr/contact/objectcontactofpageview.hxx> #include <svx/sdrpagewindow.hxx> #include <sdrpaintwindow.hxx> +#include <svx/sdr/primitive2d/sdrprimitivetools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -177,11 +178,11 @@ namespace sdr if(aGluepointVector.size()) { - const ::basegfx::BColor aBackPen(1.0, 1.0, 1.0); + const basegfx::BColor aBackPen(1.0, 1.0, 1.0); + const basegfx::BColor aRGBFrontColor(0.0, 0.0, 1.0); // COL_LIGHTBLUE const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::MarkerArrayPrimitive2D( aGluepointVector, - drawinglayer::primitive2d::MARKERSTYLE2D_GLUEPOINT, - aBackPen)); + drawinglayer::primitive2d::createDefaultGluepoint_7x7(aBackPen, aRGBFrontColor))); xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); } } diff --git a/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx b/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx index 1fff15216f81..b96e21ef8cfe 100644 --- a/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx @@ -44,6 +44,7 @@ #include <drawinglayer/primitive2d/gridprimitive2d.hxx> #include <drawinglayer/primitive2d/helplineprimitive2d.hxx> #include <basegfx/polygon/b2dpolygon.hxx> +#include <svx/sdr/primitive2d/sdrprimitivetools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -544,8 +545,9 @@ namespace sdr const sal_uInt32 nSubdivisionsY(aFine.getHeight() ? aRaw.getHeight() / aFine.getHeight() : 0L); xRetval.realloc(1); - xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::GridPrimitive2D(aGridMatrix, fWidthX, fWidthY, - 10.0, 3.0, nSubdivisionsX, nSubdivisionsY, aRGBGridColor)); + xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::GridPrimitive2D( + aGridMatrix, fWidthX, fWidthY, 10.0, 3.0, nSubdivisionsX, nSubdivisionsY, aRGBGridColor, + drawinglayer::primitive2d::createDefaultCross_3x3(aRGBGridColor))); } return xRetval; @@ -623,6 +625,7 @@ namespace sdr { const SdrHelpLine& rHelpLine = rHelpLineList[(sal_uInt16)a]; const basegfx::B2DPoint aPosition((double)rHelpLine.GetPos().X(), (double)rHelpLine.GetPos().Y()); + const double fDiscreteDashLength(4.0); switch(rHelpLine.GetKind()) { @@ -630,21 +633,21 @@ namespace sdr { xRetval[a] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::HelplinePrimitive2D( aPosition, basegfx::B2DVector(1.0, 0.0), drawinglayer::primitive2d::HELPLINESTYLE2D_POINT, - aRGBColorA, aRGBColorB, 4.0)); + aRGBColorA, aRGBColorB, fDiscreteDashLength)); break; } case SDRHELPLINE_VERTICAL : { xRetval[a] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::HelplinePrimitive2D( aPosition, basegfx::B2DVector(0.0, 1.0), drawinglayer::primitive2d::HELPLINESTYLE2D_LINE, - aRGBColorA, aRGBColorB, 4.0)); + aRGBColorA, aRGBColorB, fDiscreteDashLength)); break; } case SDRHELPLINE_HORIZONTAL : { xRetval[a] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::HelplinePrimitive2D( aPosition, basegfx::B2DVector(1.0, 0.0), drawinglayer::primitive2d::HELPLINESTYLE2D_LINE, - aRGBColorA, aRGBColorB, 4.0)); + aRGBColorA, aRGBColorB, fDiscreteDashLength)); break; } } @@ -686,12 +689,6 @@ namespace sdr && !GetObjectContact().isOutputToPrinter() && GetObjectContact().getActiveViewContact() == &GetViewContact()); - //if(!rDisplayInfo.GetSubContentActive()) - //{ - // // Make processed page accessible from SdrPageView via DisplayInfo - // rDisplayInfo.SetProcessedPage(GetViewContact().TryToGetSdrPage()); - //} - if(bDoGhostedDisplaying) { rDisplayInfo.ClearGhostedDrawMode(); @@ -719,12 +716,6 @@ namespace sdr { rDisplayInfo.SetGhostedDrawMode(); } - - //if(!rDisplayInfo.GetSubContentActive()) - //{ - // // Reset processed page at DisplayInfo and DisplayInfo at SdrPageView - // rDisplayInfo.SetProcessedPage(0); - //} } return xRetval; diff --git a/svx/source/sdr/overlay/makefile.mk b/svx/source/sdr/overlay/makefile.mk index fa12baba4c5d..1243a71e2585 100644 --- a/svx/source/sdr/overlay/makefile.mk +++ b/svx/source/sdr/overlay/makefile.mk @@ -42,22 +42,23 @@ ENABLE_EXCEPTIONS=TRUE # --- Files -------------------------------------------------------- SLOFILES=\ - $(SLO)$/overlayanimatedbitmapex.obj \ - $(SLO)$/overlaybitmap.obj \ - $(SLO)$/overlaybitmapex.obj \ - $(SLO)$/overlayline.obj \ - $(SLO)$/overlaylinestriped.obj \ - $(SLO)$/overlaymanager.obj \ - $(SLO)$/overlaymanagerbuffered.obj \ - $(SLO)$/overlayobject.obj \ - $(SLO)$/overlayobjectlist.obj \ - $(SLO)$/overlaytriangle.obj \ - $(SLO)$/overlaycrosshair.obj \ - $(SLO)$/overlayhelpline.obj \ - $(SLO)$/overlayhatchrect.obj \ - $(SLO)$/overlayrollingrectangle.obj \ - $(SLO)$/overlaypolypolygon.obj \ - $(SLO)$/overlaysdrobject.obj \ + $(SLO)$/overlayanimatedbitmapex.obj \ + $(SLO)$/overlaybitmap.obj \ + $(SLO)$/overlaybitmapex.obj \ + $(SLO)$/overlayline.obj \ + $(SLO)$/overlaylinestriped.obj \ + $(SLO)$/overlaymanager.obj \ + $(SLO)$/overlaymanagerbuffered.obj \ + $(SLO)$/overlayobject.obj \ + $(SLO)$/overlayobjectlist.obj \ + $(SLO)$/overlaytriangle.obj \ + $(SLO)$/overlaycrosshair.obj \ + $(SLO)$/overlayhelpline.obj \ + $(SLO)$/overlayhatchrect.obj \ + $(SLO)$/overlayrollingrectangle.obj \ + $(SLO)$/overlaypolypolygon.obj \ + $(SLO)$/overlaysdrobject.obj \ + $(SLO)$/overlayprimitive2dsequenceobject.obj \ $(SLO)$/overlayobjectcell.obj .INCLUDE : target.mk diff --git a/svx/source/sdr/overlay/overlaymanager.cxx b/svx/source/sdr/overlay/overlaymanager.cxx index 659e94660569..4549e98995a1 100644 --- a/svx/source/sdr/overlay/overlaymanager.cxx +++ b/svx/source/sdr/overlay/overlaymanager.cxx @@ -39,6 +39,8 @@ #include <vcl/window.hxx> #include <svx/sdr/overlay/overlayobject.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <drawinglayer/processor2d/baseprocessor2d.hxx> +#include <svx/sdr/contact/objectcontacttools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -119,6 +121,19 @@ namespace sdr } } + const double OverlayManager::getDiscreteOne() const + { + if(getOutputDevice().GetViewTransformation() != maViewTransformation) + { + OverlayManager* pThis = const_cast< OverlayManager* >(this); + pThis->maViewTransformation = getOutputDevice().GetViewTransformation(); + const basegfx::B2DVector aDiscreteInLogic(getOutputDevice().GetInverseViewTransformation() * basegfx::B2DVector(1.0, 0.0)); + pThis->mfDiscreteOne = aDiscreteInLogic.getLength(); + } + + return mfDiscreteOne; + } + OverlayManager::OverlayManager(OutputDevice& rOutputDevice) : Scheduler(), rmOutputDevice(rOutputDevice), @@ -127,7 +142,9 @@ namespace sdr maStripeColorA(Color(COL_BLACK)), maStripeColorB(Color(COL_WHITE)), mnStripeLengthPixel(5L), - maDrawinglayerOpt() + maDrawinglayerOpt(), + maViewTransformation(), + mfDiscreteOne(0.0) { } @@ -261,12 +278,12 @@ namespace sdr if(maDrawinglayerOpt.IsAntiAliasing()) { // assume AA needs one pixel more and invalidate one pixel more - const basegfx::B2DVector aDiscreteInLogic(getOutputDevice().GetViewTransformation() * basegfx::B2DVector(1.0, 1.0)); + const double fDiscreteOne(getDiscreteOne()); const Rectangle aInvalidateRectangle( - (sal_Int32)floor(rRange.getMinX() - aDiscreteInLogic.getX()), - (sal_Int32)floor(rRange.getMinY() - aDiscreteInLogic.getY()), - (sal_Int32)ceil(rRange.getMaxX() + aDiscreteInLogic.getX()), - (sal_Int32)ceil(rRange.getMaxY() + aDiscreteInLogic.getY())); + (sal_Int32)floor(rRange.getMinX() - fDiscreteOne), + (sal_Int32)floor(rRange.getMinY() - fDiscreteOne), + (sal_Int32)ceil(rRange.getMaxX() + fDiscreteOne), + (sal_Int32)ceil(rRange.getMaxY() + fDiscreteOne)); // simply invalidate ((Window&)getOutputDevice()).Invalidate(aInvalidateRectangle, INVALIDATE_NOERASE); diff --git a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx index 64275dc038b8..584faedcdda2 100644 --- a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx +++ b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx @@ -475,40 +475,43 @@ namespace sdr void OverlayManagerBuffered::invalidateRange(const basegfx::B2DRange& rRange) { - // buffered output, do not invalidate but use the timer - // to trigger a timer event for refresh - maBufferTimer.Start(); - - // add the discrete range to the remembered region - // #i75163# use double precision and floor/ceil rounding to get overlapped pixel region, even - // when the given logic region has a width/height of 0.0. This does NOT work with LogicToPixel - // since it just transforms the top left and bottom right points equally without taking - // discrete pixel coverage into account. An empty B2DRange and thus empty logic Rectangle translated - // to an also empty discrete pixel rectangle - what is wrong. - basegfx::B2DRange aDiscreteRange(rRange); - aDiscreteRange.transform(getOutputDevice().GetViewTransformation()); - - if(maDrawinglayerOpt.IsAntiAliasing()) + if(!rRange.isEmpty()) { - // assume AA needs one pixel more and invalidate one pixel more - const basegfx::B2DVector aDiscreteInLogic(getOutputDevice().GetViewTransformation() * basegfx::B2DVector(1.0, 1.0)); - const basegfx::B2IPoint aTopLeft( - (sal_Int32)floor(aDiscreteRange.getMinX() - aDiscreteInLogic.getX()), - (sal_Int32)floor(aDiscreteRange.getMinY() - aDiscreteInLogic.getY())); - const basegfx::B2IPoint aBottomRight( - (sal_Int32)ceil(aDiscreteRange.getMaxX() + aDiscreteInLogic.getX()), - (sal_Int32)ceil(aDiscreteRange.getMaxY() + aDiscreteInLogic.getY())); - - maBufferRememberedRangePixel.expand(aTopLeft); - maBufferRememberedRangePixel.expand(aBottomRight); - } - else - { - const basegfx::B2IPoint aTopLeft((sal_Int32)floor(aDiscreteRange.getMinX()), (sal_Int32)floor(aDiscreteRange.getMinY())); - const basegfx::B2IPoint aBottomRight((sal_Int32)ceil(aDiscreteRange.getMaxX()), (sal_Int32)ceil(aDiscreteRange.getMaxY())); + // buffered output, do not invalidate but use the timer + // to trigger a timer event for refresh + maBufferTimer.Start(); + + // add the discrete range to the remembered region + // #i75163# use double precision and floor/ceil rounding to get overlapped pixel region, even + // when the given logic region has a width/height of 0.0. This does NOT work with LogicToPixel + // since it just transforms the top left and bottom right points equally without taking + // discrete pixel coverage into account. An empty B2DRange and thus empty logic Rectangle translated + // to an also empty discrete pixel rectangle - what is wrong. + basegfx::B2DRange aDiscreteRange(rRange); + aDiscreteRange.transform(getOutputDevice().GetViewTransformation()); + + if(maDrawinglayerOpt.IsAntiAliasing()) + { + // assume AA needs one pixel more and invalidate one pixel more + const double fDiscreteOne(getDiscreteOne()); + const basegfx::B2IPoint aTopLeft( + (sal_Int32)floor(aDiscreteRange.getMinX() - fDiscreteOne), + (sal_Int32)floor(aDiscreteRange.getMinY() - fDiscreteOne)); + const basegfx::B2IPoint aBottomRight( + (sal_Int32)ceil(aDiscreteRange.getMaxX() + fDiscreteOne), + (sal_Int32)ceil(aDiscreteRange.getMaxY() + fDiscreteOne)); + + maBufferRememberedRangePixel.expand(aTopLeft); + maBufferRememberedRangePixel.expand(aBottomRight); + } + else + { + const basegfx::B2IPoint aTopLeft((sal_Int32)floor(aDiscreteRange.getMinX()), (sal_Int32)floor(aDiscreteRange.getMinY())); + const basegfx::B2IPoint aBottomRight((sal_Int32)ceil(aDiscreteRange.getMaxX()), (sal_Int32)ceil(aDiscreteRange.getMaxY())); - maBufferRememberedRangePixel.expand(aTopLeft); - maBufferRememberedRangePixel.expand(aBottomRight); + maBufferRememberedRangePixel.expand(aTopLeft); + maBufferRememberedRangePixel.expand(aBottomRight); + } } } diff --git a/svx/source/sdr/overlay/overlayobject.cxx b/svx/source/sdr/overlay/overlayobject.cxx index 56b2349b5023..658b6719709e 100644 --- a/svx/source/sdr/overlay/overlayobject.cxx +++ b/svx/source/sdr/overlay/overlayobject.cxx @@ -41,6 +41,9 @@ #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <svx/sdr/contact/objectcontacttools.hxx> +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#include <drawinglayer/processor2d/baseprocessor2d.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -117,51 +120,83 @@ namespace sdr { if(getOverlayManager() && rPolygon.count()) { - const sal_uInt32 nLenPixel(getOverlayManager()->getStripeLengthPixel()); - const Size aDashSizePixel(nLenPixel, nLenPixel); - const Size aDashSizeLogic(rOutputDevice.PixelToLogic(aDashSizePixel)); - const double fDashLength(aDashSizeLogic.Width()); - const double fFullDotDashLength(fDashLength + fDashLength); - - // fill DashDot vector - ::std::vector<double> aDotDashArray; - aDotDashArray.push_back(fDashLength); - aDotDashArray.push_back(fDashLength); - - // get dash polygons - basegfx::B2DPolyPolygon aStripesA; - basegfx::B2DPolyPolygon aStripesB; - basegfx::tools::applyLineDashing(rPolygon, aDotDashArray, &aStripesA, &aStripesB, fFullDotDashLength); - - // draw stripes A - if(aStripesA.count()) + if(getOverlayManager() && getOverlayManager()->getDrawinglayerOpt().IsAntiAliasing()) { - rOutputDevice.SetFillColor(); - rOutputDevice.SetLineColor(getOverlayManager()->getStripeColorA()); - ImpDrawStripes(rOutputDevice, aStripesA); + // prepare ViewInformation2D + const drawinglayer::geometry::ViewInformation2D aViewInformation2D( + basegfx::B2DHomMatrix(), + rOutputDevice.GetViewTransformation(), + basegfx::B2DRange(), + 0, + 0.0, + 0); + + // create processor + drawinglayer::processor2d::BaseProcessor2D* pProcessor = ::sdr::contact::createBaseProcessor2DFromOutputDevice( + rOutputDevice, + aViewInformation2D); + + if(pProcessor) + { + // prepare primitives + const drawinglayer::primitive2d::Primitive2DReference aPolygonMarkerPrimitive2D( + new drawinglayer::primitive2d::PolygonMarkerPrimitive2D( + rPolygon, + getOverlayManager()->getStripeColorA().getBColor(), + getOverlayManager()->getStripeColorB().getBColor(), + getOverlayManager()->getStripeLengthPixel())); + const drawinglayer::primitive2d::Primitive2DSequence aSequence(&aPolygonMarkerPrimitive2D, 1); + + pProcessor->process(aSequence); + + delete pProcessor; + } } - - // draw stripes B - if(aStripesB.count()) + else { - rOutputDevice.SetFillColor(); - rOutputDevice.SetLineColor(getOverlayManager()->getStripeColorB()); - ImpDrawStripes(rOutputDevice, aStripesB); + const sal_uInt32 nLenPixel(getOverlayManager()->getStripeLengthPixel()); + const Size aDashSizePixel(nLenPixel, nLenPixel); + const Size aDashSizeLogic(rOutputDevice.PixelToLogic(aDashSizePixel)); + const double fDashLength(aDashSizeLogic.Width()); + const double fFullDotDashLength(fDashLength + fDashLength); + + // fill DashDot vector + ::std::vector<double> aDotDashArray; + aDotDashArray.push_back(fDashLength); + aDotDashArray.push_back(fDashLength); + + // get dash polygons + basegfx::B2DPolyPolygon aStripesA; + basegfx::B2DPolyPolygon aStripesB; + basegfx::tools::applyLineDashing(rPolygon, aDotDashArray, &aStripesA, &aStripesB, fFullDotDashLength); + + // draw stripes A + if(aStripesA.count()) + { + rOutputDevice.SetFillColor(); + rOutputDevice.SetLineColor(getOverlayManager()->getStripeColorA()); + + for(sal_uInt32 a(0L); a < aStripesA.count();a ++) + { + rOutputDevice.DrawPolyLine(aStripesA.getB2DPolygon(a)); + } + } + + // draw stripes B + if(aStripesB.count()) + { + rOutputDevice.SetFillColor(); + rOutputDevice.SetLineColor(getOverlayManager()->getStripeColorB()); + + for(sal_uInt32 a(0L); a < aStripesB.count();a ++) + { + rOutputDevice.DrawPolyLine(aStripesB.getB2DPolygon(a)); + } + } } } } - void OverlayObject::ImpDrawStripes(OutputDevice& rOutputDevice, const basegfx::B2DPolyPolygon& rPolyPolygon) - { - for(sal_uInt32 a(0L); a < rPolyPolygon.count();a ++) - { - // #i82889# Do not just paint from start point to end point - // assuming that each partial Polygon contains a single line. Instead, - // paint the whole polygon - rOutputDevice.DrawPolyLine(Polygon(rPolyPolygon.getB2DPolygon(a))); - } - } - OverlayObject::OverlayObject(Color aBaseColor) : Event(0L), mpOverlayManager(0L), diff --git a/svx/source/sdr/overlay/overlayprimitive2dsequenceobject.cxx b/svx/source/sdr/overlay/overlayprimitive2dsequenceobject.cxx new file mode 100644 index 000000000000..1383a296709b --- /dev/null +++ b/svx/source/sdr/overlay/overlayprimitive2dsequenceobject.cxx @@ -0,0 +1,110 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: overlaysdrobject.cxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx> +#include <drawinglayer/geometry/viewinformation2d.hxx> +#include <drawinglayer/processor2d/vclpixelprocessor2d.hxx> +#include <svx/sdr/contact/objectcontacttools.hxx> +#include <svx/sdr/overlay/overlaymanager.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace sdr +{ + namespace overlay + { + void OverlayPrimitive2DSequenceObject::drawGeometry(OutputDevice& rOutputDevice) + { + if(getOverlayManager()) + { + // prepare ViewInformation2D + const drawinglayer::geometry::ViewInformation2D aViewInformation2D( + basegfx::B2DHomMatrix(), + rOutputDevice.GetViewTransformation(), + basegfx::B2DRange(), + 0, + 0.0, + 0); + + // create processor + drawinglayer::processor2d::BaseProcessor2D* pProcessor = ::sdr::contact::createBaseProcessor2DFromOutputDevice( + rOutputDevice, + aViewInformation2D); + + if(pProcessor) + { + pProcessor->process(getSequence()); + + delete pProcessor; + } + } + } + + void OverlayPrimitive2DSequenceObject::createBaseRange(OutputDevice& rOutputDevice) + { + const drawinglayer::geometry::ViewInformation2D aViewInformation2D( + basegfx::B2DHomMatrix(), + rOutputDevice.GetViewTransformation(), + basegfx::B2DRange(), + 0, + 0.0, + 0); + + maBaseRange = drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence( + getSequence(), aViewInformation2D); + } + + sal_Bool OverlayPrimitive2DSequenceObject::isHit(const basegfx::B2DPoint& /*rPos*/, double /*fTol*/) const + { + if(isHittable()) + { + return false; + } + + return false; + } + + OverlayPrimitive2DSequenceObject::OverlayPrimitive2DSequenceObject(const drawinglayer::primitive2d::Primitive2DSequence& rSequence) + : OverlayObjectWithBasePosition(basegfx::B2DPoint(), Color(COL_BLACK)), + maSequence(rSequence) + { + } + + OverlayPrimitive2DSequenceObject::~OverlayPrimitive2DSequenceObject() + { + } + } // end of namespace overlay +} // end of namespace sdr + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/svx/source/sdr/primitive2d/makefile.mk b/svx/source/sdr/primitive2d/makefile.mk index 93978104cf1c..e9e976d434ed 100644 --- a/svx/source/sdr/primitive2d/makefile.mk +++ b/svx/source/sdr/primitive2d/makefile.mk @@ -52,6 +52,7 @@ SLOFILES=\ $(SLO)$/sdrgrafprimitive2d.obj \ $(SLO)$/sdrole2primitive2d.obj \ $(SLO)$/sdrpathprimitive2d.obj \ + $(SLO)$/sdrprimitivetools.obj \ $(SLO)$/sdrmeasureprimitive2d.obj \ $(SLO)$/sdrconnectorprimitive2d.obj \ $(SLO)$/sdrtextprimitive2d.obj diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx index d4b41352c5dc..edc7d482641b 100644 --- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx +++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx @@ -572,7 +572,9 @@ namespace drawinglayer if(aBitmap.GetPrefMapMode() != aDestinationMapUnit) { - aBitmap.SetPrefSize(Application::GetDefaultDevice()->PixelToLogic(aBitmap.GetPrefSize(), aDestinationMapUnit)); + // #i96237# need to use LogicToLogic, source is not always pixels + aBitmap.SetPrefSize(Application::GetDefaultDevice()->LogicToLogic( + aBitmap.GetPrefSize(), aBitmap.GetPrefMapMode(), aDestinationMapUnit)); aBitmap.SetPrefMapMode(aDestinationMapUnit); } diff --git a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx new file mode 100644 index 000000000000..12d7f1e856f0 --- /dev/null +++ b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx @@ -0,0 +1,175 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: primitivefactory2d.cxx,v $ + * + * $Revision: 1.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <svx/sdr/primitive2d/sdrprimitivetools.hxx> +#include <vcl/bmpacc.hxx> +#include <osl/mutex.hxx> + +////////////////////////////////////////////////////////////////////////////// +// helper methods + +namespace drawinglayer +{ + namespace primitive2d + { + BitmapEx createDefaultCross_3x3(const basegfx::BColor& rBColor) + { + static BitmapEx aRetval; + static basegfx::BColor aColor; + ::osl::Mutex m_mutex; + + if(aRetval.IsEmpty() || rBColor != aColor) + { + // copy values + aColor = rBColor; + + // create bitmap + Bitmap aContent(Size(3, 3), 24); + Bitmap aMask(Size(3, 3), 1); + BitmapWriteAccess* pWContent = aContent.AcquireWriteAccess(); + BitmapWriteAccess* pWMask = aMask.AcquireWriteAccess(); + OSL_ENSURE(pWContent && pWMask, "No WriteAccess to bitmap (!)"); + const Color aVCLColor(aColor); + const BitmapColor aPixColor(aVCLColor); + const BitmapColor aMaskColor(0x01); + + // Y,X unusual order (!) + pWContent->SetPixel(0, 1, aPixColor); + pWContent->SetPixel(1, 0, aPixColor); + pWContent->SetPixel(1, 1, aPixColor); + pWContent->SetPixel(1, 2, aPixColor); + pWContent->SetPixel(2, 1, aPixColor); + + pWMask->SetPixel(0, 0, aMaskColor); + pWMask->SetPixel(0, 2, aMaskColor); + pWMask->SetPixel(2, 0, aMaskColor); + pWMask->SetPixel(2, 2, aMaskColor); + + aContent.ReleaseAccess(pWContent); + aMask.ReleaseAccess(pWMask); + + aRetval = BitmapEx(aContent, aMask); + } + + return aRetval; + } + + BitmapEx createDefaultGluepoint_7x7(const basegfx::BColor& rBColorA, const basegfx::BColor& rBColorB) + { + static BitmapEx aRetval; + static basegfx::BColor aColorA; + static basegfx::BColor aColorB; + ::osl::Mutex m_mutex; + + if(aRetval.IsEmpty() || rBColorA != aColorA || rBColorB != aColorB) + { + // copy values + aColorA = rBColorA; + aColorB = rBColorB; + + // create bitmap + Bitmap aContent(Size(7, 7), 24); + Bitmap aMask(Size(7, 7), 1); + BitmapWriteAccess* pWContent = aContent.AcquireWriteAccess(); + BitmapWriteAccess* pWMask = aMask.AcquireWriteAccess(); + OSL_ENSURE(pWContent && pWMask, "No WriteAccess to bitmap (!)"); + const Color aColA(aColorA); + const Color aColB(aColorB); + const BitmapColor aPixColorA(aColA); + const BitmapColor aPixColorB(aColB); + const BitmapColor aMaskColor(0x01); + + // Y,X unusual order (!) + pWContent->SetPixel(0, 1, aPixColorA); + pWContent->SetPixel(0, 5, aPixColorA); + pWContent->SetPixel(1, 0, aPixColorA); + pWContent->SetPixel(1, 2, aPixColorA); + pWContent->SetPixel(1, 4, aPixColorA); + pWContent->SetPixel(1, 6, aPixColorA); + pWContent->SetPixel(2, 1, aPixColorA); + pWContent->SetPixel(2, 3, aPixColorA); + pWContent->SetPixel(2, 5, aPixColorA); + pWContent->SetPixel(3, 2, aPixColorA); + pWContent->SetPixel(3, 4, aPixColorA); + pWContent->SetPixel(4, 1, aPixColorA); + pWContent->SetPixel(4, 3, aPixColorA); + pWContent->SetPixel(4, 5, aPixColorA); + pWContent->SetPixel(5, 0, aPixColorA); + pWContent->SetPixel(5, 2, aPixColorA); + pWContent->SetPixel(5, 4, aPixColorA); + pWContent->SetPixel(5, 6, aPixColorA); + pWContent->SetPixel(6, 1, aPixColorA); + pWContent->SetPixel(6, 5, aPixColorA); + + pWContent->SetPixel(1, 1, aPixColorB); + pWContent->SetPixel(1, 5, aPixColorB); + pWContent->SetPixel(2, 2, aPixColorB); + pWContent->SetPixel(2, 4, aPixColorB); + pWContent->SetPixel(3, 3, aPixColorB); + pWContent->SetPixel(4, 2, aPixColorB); + pWContent->SetPixel(4, 4, aPixColorB); + pWContent->SetPixel(5, 1, aPixColorB); + pWContent->SetPixel(5, 5, aPixColorB); + + pWMask->SetPixel(0, 0, aMaskColor); + pWMask->SetPixel(0, 2, aMaskColor); + pWMask->SetPixel(0, 3, aMaskColor); + pWMask->SetPixel(0, 4, aMaskColor); + pWMask->SetPixel(0, 6, aMaskColor); + pWMask->SetPixel(1, 3, aMaskColor); + pWMask->SetPixel(2, 0, aMaskColor); + pWMask->SetPixel(2, 6, aMaskColor); + pWMask->SetPixel(3, 0, aMaskColor); + pWMask->SetPixel(3, 1, aMaskColor); + pWMask->SetPixel(3, 5, aMaskColor); + pWMask->SetPixel(3, 6, aMaskColor); + pWMask->SetPixel(4, 0, aMaskColor); + pWMask->SetPixel(4, 6, aMaskColor); + pWMask->SetPixel(5, 3, aMaskColor); + pWMask->SetPixel(6, 0, aMaskColor); + pWMask->SetPixel(6, 2, aMaskColor); + pWMask->SetPixel(6, 3, aMaskColor); + pWMask->SetPixel(6, 4, aMaskColor); + pWMask->SetPixel(6, 6, aMaskColor); + + aContent.ReleaseAccess(pWContent); + aMask.ReleaseAccess(pWMask); + + aRetval = BitmapEx(aContent, aMask); + } + + return aRetval; + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/svx/source/svdraw/svddrgm1.hxx b/svx/source/svdraw/svddrgm1.hxx index 70d8fca2067c..d6c6fcb83ca2 100644 --- a/svx/source/svdraw/svddrgm1.hxx +++ b/svx/source/svdraw/svddrgm1.hxx @@ -36,127 +36,124 @@ #include <svx/svddrgv.hxx> #include <svx/svddrgmt.hxx> -//************************************************************ -// Vorausdeklarationen -//************************************************************ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// predeclarations class SdrDragView; class SdrDragStat; -//************************************************************ +//////////////////////////////////////////////////////////////////////////////////////////////////// // SdrDragMovHdl -//************************************************************ class SdrDragMovHdl : public SdrDragMethod { - FASTBOOL bMirrObjShown; +private: + bool bMirrObjShown; + +protected: + // define nothing, overload to do so + virtual void createSdrDragEntries(); public: TYPEINFO(); - SdrDragMovHdl(SdrDragView& rNewView): SdrDragMethod(rNewView), bMirrObjShown(FALSE) {} - - virtual void TakeComment(String& rStr) const; - - virtual FASTBOOL Beg(); - virtual void Mov(const Point& rPnt); - virtual FASTBOOL End(FASTBOOL bCopy); - virtual void Brk(); - virtual Pointer GetPointer() const; - virtual void Show(); - virtual void Hide(); + SdrDragMovHdl(SdrDragView& rNewView); + + virtual void TakeSdrDragComment(String& rStr) const; + virtual bool BeginSdrDrag(); + virtual void MoveSdrDrag(const Point& rPnt); + virtual bool EndSdrDrag(bool bCopy); + virtual void CancelSdrDrag(); + virtual Pointer GetSdrDragPointer() const; }; -//************************************************************ +//////////////////////////////////////////////////////////////////////////////////////////////////// // SdrDragRotate -//************************************************************ class SdrDragRotate : public SdrDragMethod { -protected: +private: double nSin; double nCos; long nWink0; long nWink; - FASTBOOL bRight; + bool bRight; public: TYPEINFO(); - SdrDragRotate(SdrDragView& rNewView): SdrDragMethod(rNewView),nSin(0.0),nCos(1.0),nWink0(0),nWink(0),bRight(FALSE) {} + SdrDragRotate(SdrDragView& rNewView); - virtual void TakeComment(String& rStr) const; + virtual void TakeSdrDragComment(String& rStr) const; + virtual bool BeginSdrDrag(); + virtual void MoveSdrDrag(const Point& rPnt); + virtual bool EndSdrDrag(bool bCopy); + virtual Pointer GetSdrDragPointer() const; - virtual FASTBOOL Beg(); - virtual void MovPoint(Point& rPnt); - virtual void Mov(const Point& rPnt); - virtual FASTBOOL End(FASTBOOL bCopy); - virtual Pointer GetPointer() const; + virtual basegfx::B2DHomMatrix getCurrentTransformation(); + virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget); }; -//************************************************************ +//////////////////////////////////////////////////////////////////////////////////////////////////// // SdrDragShear -//************************************************************ class SdrDragShear : public SdrDragMethod { +private: Fraction aFact; long nWink0; long nWink; double nTan; - FASTBOOL bVertical; // Vertikales verzerren - FASTBOOL bResize; // Shear mit Resize - FASTBOOL bUpSideDown; // Beim Shear/Slant gespiegelt - FASTBOOL bSlant; + bool bVertical; // Vertikales verzerren + bool bResize; // Shear mit Resize + bool bUpSideDown; // Beim Shear/Slant gespiegelt + bool bSlant; public: TYPEINFO(); - SdrDragShear(SdrDragView& rNewView,FASTBOOL bSlant1): SdrDragMethod(rNewView), - aFact(1,1),nWink0(0),nWink(0), - nTan(0.0), - bVertical(FALSE),bResize(FALSE),bUpSideDown(FALSE), - bSlant(bSlant1) {} - - virtual void TakeComment(String& rStr) const; - - virtual FASTBOOL Beg(); - virtual void MovPoint(Point& rPnt); - virtual void Mov(const Point& rPnt); - virtual FASTBOOL End(FASTBOOL bCopy); - virtual Pointer GetPointer() const; + SdrDragShear(SdrDragView& rNewView,bool bSlant1); + + virtual void TakeSdrDragComment(String& rStr) const; + virtual bool BeginSdrDrag(); + virtual void MoveSdrDrag(const Point& rPnt); + virtual bool EndSdrDrag(bool bCopy); + virtual Pointer GetSdrDragPointer() const; + + virtual basegfx::B2DHomMatrix getCurrentTransformation(); + virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget); }; -//************************************************************ +//////////////////////////////////////////////////////////////////////////////////////////////////// // SdrDragMirror -//************************************************************ class SdrDragMirror : public SdrDragMethod { +private: Point aDif; long nWink; bool bMirrored; bool bSide0; -private: - FASTBOOL ImpCheckSide(const Point& rPnt) const; + bool ImpCheckSide(const Point& rPnt) const; public: TYPEINFO(); - SdrDragMirror(SdrDragView& rNewView): SdrDragMethod(rNewView),nWink(0),bMirrored(FALSE),bSide0(FALSE) { } + SdrDragMirror(SdrDragView& rNewView); - virtual void TakeComment(String& rStr) const; + virtual void TakeSdrDragComment(String& rStr) const; + virtual bool BeginSdrDrag(); + virtual void MoveSdrDrag(const Point& rPnt); + virtual bool EndSdrDrag(bool bCopy); + virtual Pointer GetSdrDragPointer() const; - virtual FASTBOOL Beg(); - virtual void MovPoint(Point& rPnt); - virtual void Mov(const Point& rPnt); - virtual FASTBOOL End(FASTBOOL bCopy); - virtual Pointer GetPointer() const; + virtual basegfx::B2DHomMatrix getCurrentTransformation(); + virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget); }; -//************************************************************ +//////////////////////////////////////////////////////////////////////////////////////////////////// // SdrDragGradient -//************************************************************ class SdrDragGradient : public SdrDragMethod { +private: // Handles to work on SdrHdlGradient* pIAOHandle; @@ -165,25 +162,24 @@ class SdrDragGradient : public SdrDragMethod public: TYPEINFO(); - SdrDragGradient(SdrDragView& rNewView, BOOL bGrad = TRUE); - - BOOL IsGradient() const { return bIsGradient; } + SdrDragGradient(SdrDragView& rNewView, bool bGrad = true); - virtual void TakeComment(String& rStr) const; + bool IsGradient() const { return bIsGradient; } - virtual FASTBOOL Beg(); - virtual void Mov(const Point& rPnt); - virtual FASTBOOL End(FASTBOOL bCopy); - virtual Pointer GetPointer() const; - virtual void Brk(); + virtual void TakeSdrDragComment(String& rStr) const; + virtual bool BeginSdrDrag(); + virtual void MoveSdrDrag(const Point& rPnt); + virtual bool EndSdrDrag(bool bCopy); + virtual Pointer GetSdrDragPointer() const; + virtual void CancelSdrDrag(); }; -//************************************************************ +//////////////////////////////////////////////////////////////////////////////////////////////////// // SdrDragCrook -//************************************************************ class SdrDragCrook : public SdrDragMethod { +private: Rectangle aMarkRect; Point aMarkCenter; Point aCenter; @@ -208,54 +204,64 @@ class SdrDragCrook : public SdrDragMethod long nMarkSize; SdrCrookMode eMode; + // helpers for applyCurrentTransformationToPolyPolygon + void _MovAllPoints(basegfx::B2DPolyPolygon& rTarget); + void _MovCrookPoint(Point& rPnt, Point* pC1, Point* pC2); + +protected: + // needs to add drag geometry to the default + virtual void createSdrDragEntries(); + public: TYPEINFO(); - SdrDragCrook(SdrDragView& rNewView): SdrDragMethod(rNewView),aFact(1,1), - bContortionAllowed(FALSE),bNoContortionAllowed(FALSE),bContortion(FALSE), - bResizeAllowed(FALSE),bResize(FALSE),bRotateAllowed(FALSE),bRotate(FALSE), - bVertical(FALSE),bValid(FALSE),bLft(FALSE),bRgt(FALSE),bUpr(FALSE),bLwr(FALSE),bAtCenter(FALSE), - nWink(0),nMarkSize(0),eMode(SDRCROOK_ROTATE) {} - - virtual void TakeComment(String& rStr) const; - - virtual FASTBOOL Beg(); - virtual void MovAllPoints(); - void MovCrookPoint(Point& rPnt, Point* pC1, Point* pC2); - virtual void Mov(const Point& rPnt); - virtual FASTBOOL End(FASTBOOL bCopy); - virtual Pointer GetPointer() const; + SdrDragCrook(SdrDragView& rNewView); + + virtual void TakeSdrDragComment(String& rStr) const; + virtual bool BeginSdrDrag(); + virtual void MoveSdrDrag(const Point& rPnt); + virtual bool EndSdrDrag(bool bCopy); + virtual Pointer GetSdrDragPointer() const; + + virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget); + virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget); }; -//************************************************************ +//////////////////////////////////////////////////////////////////////////////////////////////////// // SdrDragDistort -//************************************************************ class SdrDragDistort : public SdrDragMethod { +private: Rectangle aMarkRect; XPolygon aDistortedRect; - USHORT nPolyPt; + sal_uInt16 nPolyPt; bool bContortionAllowed; bool bNoContortionAllowed; bool bContortion; + // helper for applyCurrentTransformationToPolyPolygon + void _MovAllPoints(basegfx::B2DPolyPolygon& rTarget); + +protected: + // needs to add drag geometry to the default + virtual void createSdrDragEntries(); + public: TYPEINFO(); - SdrDragDistort(SdrDragView& rNewView): SdrDragMethod(rNewView),nPolyPt(0), - bContortionAllowed(FALSE),bNoContortionAllowed(FALSE),bContortion(FALSE) {} + SdrDragDistort(SdrDragView& rNewView); - virtual void TakeComment(String& rStr) const; + virtual void TakeSdrDragComment(String& rStr) const; + virtual bool BeginSdrDrag(); + virtual void MoveSdrDrag(const Point& rPnt); + virtual bool EndSdrDrag(bool bCopy); + virtual Pointer GetSdrDragPointer() const; - virtual FASTBOOL Beg(); - virtual void MovAllPoints(); - virtual void Mov(const Point& rPnt); - virtual FASTBOOL End(FASTBOOL bCopy); - virtual Pointer GetPointer() const; + virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget); + virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget); }; -//************************************************************ +//////////////////////////////////////////////////////////////////////////////////////////////////// // SdrDragCrop -//************************************************************ class SdrDragCrop : public SdrDragResize { @@ -263,12 +269,12 @@ public: TYPEINFO(); SdrDragCrop(SdrDragView& rNewView); - virtual void TakeComment(String& rStr) const; - virtual FASTBOOL End(FASTBOOL bCopy); - virtual Pointer GetPointer() const; + virtual void TakeSdrDragComment(String& rStr) const; + virtual bool EndSdrDrag(bool bCopy); + virtual Pointer GetSdrDragPointer() const; }; //////////////////////////////////////////////////////////////////////////////////////////////////// - #endif //_SVDDRGM1_HXX +// eof diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index 817e5709ff29..20523c81b9fb 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -65,336 +65,868 @@ #include <sdrpaintwindow.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <svx/sdr/contact/viewobjectcontact.hxx> +#include <svx/sdr/contact/viewcontact.hxx> +#include <svx/sdr/contact/displayinfo.hxx> +#include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx> +#include <drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx> +#include <svx/sdr/contact/objectcontact.hxx> +#include "svditer.hxx" +#include <svx/svdopath.hxx> +#include <svx/polypolygoneditor.hxx> +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#include <drawinglayer/primitive2d/transformprimitive2d.hxx> +#include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx> +#include <svx/sdr/primitive2d/sdrattributecreator.hxx> +#include <drawinglayer/attribute/sdrattribute.hxx> +#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdovirt.hxx> +#include <svx/svdouno.hxx> +#include <svx/sdr/primitive2d/sdrprimitivetools.hxx> //////////////////////////////////////////////////////////////////////////////////////////////////// -TYPEINIT0(SdrDragMethod); +SdrDragEntry::SdrDragEntry() +: mbAddToTransparent(false) +{ +} -void SdrDragMethod::ImpTakeDescriptionStr(USHORT nStrCacheID, XubString& rStr, USHORT nVal) const +SdrDragEntry::~SdrDragEntry() { - USHORT nOpt=0; - if (IsDraggingPoints()) { - nOpt=IMPSDR_POINTSDESCRIPTION; - } else if (IsDraggingGluePoints()) { - nOpt=IMPSDR_GLUEPOINTSDESCRIPTION; - } - rView.ImpTakeDescriptionStr(nStrCacheID,rStr,nVal,nOpt); } -SdrObject* SdrDragMethod::GetDragObj() const +//////////////////////////////////////////////////////////////////////////////////////////////////// + +SdrDragEntryPolyPolygon::SdrDragEntryPolyPolygon(const basegfx::B2DPolyPolygon& rOriginalPolyPolygon) +: SdrDragEntry(), + maOriginalPolyPolygon(rOriginalPolyPolygon) { - SdrObject* pObj=NULL; - if (rView.pDragHdl!=NULL) pObj=rView.pDragHdl->GetObj(); - if (pObj==NULL) pObj=rView.pMarkedObj; - return pObj; } -SdrPageView* SdrDragMethod::GetDragPV() const +SdrDragEntryPolyPolygon::~SdrDragEntryPolyPolygon() { - SdrPageView* pPV=NULL; - if (rView.pDragHdl!=NULL) pPV=rView.pDragHdl->GetPageView(); - if (pPV==NULL) pPV=rView.pMarkedPV; - return pPV; } -// #i58950# also moved constructor implementation to cxx -SdrDragMethod::SdrDragMethod(SdrDragView& rNewView) -: rView(rNewView), - bMoveOnly(FALSE) +drawinglayer::primitive2d::Primitive2DSequence SdrDragEntryPolyPolygon::createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) { + drawinglayer::primitive2d::Primitive2DSequence aRetval; + + if(maOriginalPolyPolygon.count()) + { + basegfx::B2DPolyPolygon aCopy(maOriginalPolyPolygon); + const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; + + rDragMethod.applyCurrentTransformationToPolyPolygon(aCopy); + basegfx::BColor aColA(aSvtOptionsDrawinglayer.GetStripeColorA().getBColor()); + basegfx::BColor aColB(aSvtOptionsDrawinglayer.GetStripeColorB().getBColor()); + const double fStripeLength(aSvtOptionsDrawinglayer.GetStripeLength()); + + if(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) + { + aColA = aColB = Application::GetSettings().GetStyleSettings().GetHighlightColor().getBColor(); + aColB.invert(); + } + + drawinglayer::primitive2d::Primitive2DReference aPolyPolygonMarkerPrimitive2D( + new drawinglayer::primitive2d::PolyPolygonMarkerPrimitive2D(aCopy, aColA, aColB, fStripeLength)); + + aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aPolyPolygonMarkerPrimitive2D, 1); + } + + return aRetval; } -// #i58950# virtual destructor was missing -SdrDragMethod::~SdrDragMethod() +//////////////////////////////////////////////////////////////////////////////////////////////////// + +SdrDragEntrySdrObject::SdrDragEntrySdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify) +: SdrDragEntry(), + maOriginal(rOriginal), + mpClone(0), + mrObjectContact(rObjectContact), + mbModify(bModify) { + // add SdrObject parts to transparent overlay stuff + setAddToTransparent(true); } -void SdrDragMethod::Draw() const +SdrDragEntrySdrObject::~SdrDragEntrySdrObject() { + if(mpClone) + { + SdrObject::Free(mpClone); + } } -void SdrDragMethod::Show() +drawinglayer::primitive2d::Primitive2DSequence SdrDragEntrySdrObject::createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) { - rView.ShowDragObj(); + // for the moment, i need to re-create the clone in all cases. I need to figure + // out when clone and original have the same class, so that i can use operator= + // in those cases + + // // copy all other needed stuff + // basegfx::B2DHomMatrix aMatrix; + // basegfx::B2DPolyPolygon aPolyPolygon; + // pOleObject->TRGetBaseGeometry(aMatrix, aPolyPolygon); + // pClone->TRSetBaseGeometry(aMatrix, aPolyPolygon); + + const SdrObject* pSource = &maOriginal; + + if(mpClone) + { + SdrObject::Free(mpClone); + mpClone = 0; + } + + if(mbModify) + { + if(!mpClone) + { + mpClone = maOriginal.getFullDragClone(); + } + + // apply original transformation, implemented at the DragMethods + rDragMethod.applyCurrentTransformationToSdrObject(*mpClone); + + // choose source for geometry data + pSource = mpClone; + } + + // get VOC and Primitive2DSequence + sdr::contact::ViewContact& rVC = pSource->GetViewContact(); + sdr::contact::ViewObjectContact& rVOC = rVC.GetViewObjectContact(mrObjectContact); + sdr::contact::DisplayInfo aDisplayInfo; + + // Do not use the last ViewPort set at the OC from the last ProcessDisplay(), + // here we want the complete primitive sequence without visibility clippings + mrObjectContact.resetViewPort(); + + return rVOC.getPrimitive2DSequenceHierarchy(aDisplayInfo); } -void SdrDragMethod::Hide() +//////////////////////////////////////////////////////////////////////////////////////////////////// + +SdrDragEntryPointGlueDrag::SdrDragEntryPointGlueDrag(const std::vector< basegfx::B2DPoint >& rPositions, bool bIsPointDrag) +: maPositions(rPositions), + mbIsPointDrag(bIsPointDrag) { - rView.HideDragObj(); + // add SdrObject parts to transparent overlay stuff + setAddToTransparent(true); } -void SdrDragMethod::MovAllPoints() +SdrDragEntryPointGlueDrag::~SdrDragEntryPointGlueDrag() { - SdrPageView* pPV = rView.GetSdrPageView(); +} - if(pPV) +drawinglayer::primitive2d::Primitive2DSequence SdrDragEntryPointGlueDrag::createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) +{ + drawinglayer::primitive2d::Primitive2DSequence aRetval; + + if(maPositions.size()) { - if (pPV->HasMarkedObjPageView()) + basegfx::B2DPolygon aPolygon; + sal_uInt32 a(0); + + for(a = 0; a < maPositions.size(); a++) { - XPolyPolygon aTempPolyPoly(pPV->getDragPoly0()); - USHORT i,j; - USHORT nPolyAnz=aTempPolyPoly.Count(); - for (j=0; j<nPolyAnz; j++) { - XPolygon& aPol=aTempPolyPoly[j]; - USHORT nPtAnz=aPol.GetPointCount(); - for (i=0; i<nPtAnz; i++) { - MovPoint(aPol[i]); // ,aOfs); - } + aPolygon.append(maPositions[a]); + } + + basegfx::B2DPolyPolygon aPolyPolygon(aPolygon); + + rDragMethod.applyCurrentTransformationToPolyPolygon(aPolyPolygon); + + const basegfx::B2DPolygon aTransformed(aPolyPolygon.getB2DPolygon(0)); + std::vector< basegfx::B2DPoint > aTransformedPositions; + + aTransformedPositions.reserve(aTransformed.count()); + + for(a = 0; a < aTransformed.count(); a++) + { + aTransformedPositions.push_back(aTransformed.getB2DPoint(a)); + } + + if(mbIsPointDrag) + { + const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; + basegfx::BColor aColor(aSvtOptionsDrawinglayer.GetStripeColorA().getBColor()); + + if(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) + { + aColor = Application::GetSettings().GetStyleSettings().GetHighlightColor().getBColor(); } - pPV->setDragPoly(aTempPolyPoly.getB2DPolyPolygon()); + + drawinglayer::primitive2d::Primitive2DReference aMarkerArrayPrimitive2D( + new drawinglayer::primitive2d::MarkerArrayPrimitive2D(aTransformedPositions, + drawinglayer::primitive2d::createDefaultCross_3x3(aColor))); + + aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aMarkerArrayPrimitive2D, 1); + } + else + { + const basegfx::BColor aBackPen(1.0, 1.0, 1.0); + const basegfx::BColor aRGBFrontColor(0.0, 0.0, 1.0); // COL_LIGHTBLUE + drawinglayer::primitive2d::Primitive2DReference aMarkerArrayPrimitive2D( + new drawinglayer::primitive2d::MarkerArrayPrimitive2D(aTransformedPositions, + drawinglayer::primitive2d::createDefaultGluepoint_7x7(aBackPen, aRGBFrontColor))); + + aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aMarkerArrayPrimitive2D, 1); } } + + return aRetval; } -void SdrDragMethod::MovPoint(Point& /*rPnt*/) +//////////////////////////////////////////////////////////////////////////////////////////////////// + +TYPEINIT0(SdrDragMethod); + +void SdrDragMethod::resetSdrDragEntries() { + // clear entries; creation is on demand + clearSdrDragEntries(); } -void SdrDragMethod::Brk() +basegfx::B2DRange SdrDragMethod::getCurrentRange() const { - Hide(); + return getB2DRangeFromOverlayObjectList(); } -FASTBOOL SdrDragMethod::IsMoveOnly() const +void SdrDragMethod::createSdrDragEntries() { - return FALSE; + if(getSdrDragView().GetSdrPageView() && getSdrDragView().GetSdrPageView()->HasMarkedObjPageView()) + { + if(getSdrDragView().IsDraggingPoints()) + { + createSdrDragEntries_PointDrag(); + } + else if(getSdrDragView().IsDraggingGluePoints()) + { + createSdrDragEntries_GlueDrag(); + } + else + { + if(getSolidDraggingActive()) + { + createSdrDragEntries_SolidDrag(); + } + else + { + createSdrDragEntries_PolygonDrag(); + } + } + } } -// for migration from XOR to overlay -void SdrDragMethod::CreateOverlayGeometry(::sdr::overlay::OverlayManager& rOverlayManager, ::sdr::overlay::OverlayObjectList& rOverlayList) +void SdrDragMethod::createSdrDragEntries_SolidDrag() { - basegfx::B2DPolyPolygon aResult; + const sal_uInt32 nMarkAnz(getSdrDragView().GetMarkedObjectCount()); + SdrPageView* pPV = getSdrDragView().GetSdrPageView(); - if(IsDraggingGluePoints() || IsDraggingPoints()) + if(pPV) { - const sal_Int32 nHandleSize(IsDraggingGluePoints() ? 3L : rView.aHdl.GetHdlSize()); - const Size aLogicSize(rOverlayManager.getOutputDevice().PixelToLogic(Size(nHandleSize, nHandleSize))); + for(sal_uInt32 a(0); a < nMarkAnz; a++) + { + SdrMark* pM = getSdrDragView().GetSdrMarkByIndex(a); + + if(pM->GetPageView() == pPV) + { + const SdrObject* pObject = pM->GetMarkedSdrObj(); - CreateOverlayGeometryPoints(aResult, aLogicSize); + if(pObject) + { + if(pPV->PageWindowCount()) + { + sdr::contact::ObjectContact& rOC = pPV->GetPageWindow(0)->GetObjectContact(); + SdrObjListIter aIter(*pObject); + + while(aIter.IsMore()) + { + SdrObject* pCandidate = aIter.Next(); + + if(pCandidate) + { + const bool bSuppressFullDrag(!pCandidate->supportsFullDrag()); + bool bAddWireframe(bSuppressFullDrag); + + if(!bAddWireframe && !pCandidate->HasLineStyle()) + { + // add wireframe for objects without outline + bAddWireframe = true; + } + + if(!bSuppressFullDrag) + { + // add full obejct drag; Clone() at the object has to work + // for this + addSdrDragEntry(new SdrDragEntrySdrObject(*pCandidate, rOC, true)); + } + + 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 thext frames etc. + addSdrDragEntry(new SdrDragEntryPolyPolygon(pCandidate->TakeXorPoly())); + } + } + } + } + } + } + } } - else +} + +void SdrDragMethod::createSdrDragEntries_PolygonDrag() +{ + const sal_uInt32 nMarkAnz(getSdrDragView().GetMarkedObjectCount()); + bool bNoPolygons(getSdrDragView().IsNoDragXorPolys() || nMarkAnz > getSdrDragView().GetDragXorPolyLimit()); + basegfx::B2DPolyPolygon aResult; + sal_uInt32 nPointCount(0); + + for(sal_uInt32 a(0); !bNoPolygons && a < nMarkAnz; a++) { - CreateOverlayGeometryLines(aResult); + SdrMark* pM = getSdrDragView().GetSdrMarkByIndex(a); + + if(pM->GetPageView() == getSdrDragView().GetSdrPageView()) + { + const basegfx::B2DPolyPolygon aNewPolyPolygon(pM->GetMarkedSdrObj()->TakeXorPoly()); + + for(sal_uInt32 b(0); b < aNewPolyPolygon.count(); b++) + { + nPointCount += aNewPolyPolygon.getB2DPolygon(b).count(); + } + + if(nPointCount > getSdrDragView().GetDragXorPointLimit()) + { + bNoPolygons = true; + } + + if(!bNoPolygons) + { + aResult.append(aNewPolyPolygon); + } + } } - // replace rView.ImpDrawEdgeXor(rXOut,bFull); - if(DoAddConnectorOverlays()) + if(bNoPolygons) { - AddConnectorOverlays(aResult); + const Rectangle aR(getSdrDragView().GetSdrPageView()->MarkSnap()); + const basegfx::B2DRange aNewRectangle(aR.Left(), aR.Top(), aR.Right(), aR.Bottom()); + basegfx::B2DPolygon aNewPolygon(basegfx::tools::createPolygonFromRect(aNewRectangle)); + + aResult = basegfx::B2DPolyPolygon(basegfx::tools::expandToCurve(aNewPolygon)); } if(aResult.count()) { - ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aResult); - rOverlayManager.add(*pNew); - rOverlayList.append(*pNew); + addSdrDragEntry(new SdrDragEntryPolyPolygon(aResult)); } +} + +void SdrDragMethod::createSdrDragEntries_PointDrag() +{ + const sal_uInt32 nMarkAnz(getSdrDragView().GetMarkedObjectCount()); + std::vector< basegfx::B2DPoint > aPositions; - // test for DragStripes (help lines cross the page when dragging) - if(DoAddDragStripeOverlay()) + for(sal_uInt32 nm(0); nm < nMarkAnz; nm++) { - Rectangle aActionRectangle; - rView.TakeActionRect(aActionRectangle); + SdrMark* pM = getSdrDragView().GetSdrMarkByIndex(nm); - const basegfx::B2DPoint aTopLeft(aActionRectangle.Left(), aActionRectangle.Top()); - const basegfx::B2DPoint aBottomRight(aActionRectangle.Right(), aActionRectangle.Bottom()); - ::sdr::overlay::OverlayRollingRectangleStriped* pNew = new ::sdr::overlay::OverlayRollingRectangleStriped( - aTopLeft, aBottomRight, sal_True, sal_False); + if(pM->GetPageView() == getSdrDragView().GetSdrPageView()) + { + const SdrUShortCont* pPts = pM->GetMarkedPoints(); - rOverlayManager.add(*pNew); - rOverlayList.append(*pNew); + if(pPts && pPts->GetCount()) + { + const SdrObject* pObj = pM->GetMarkedSdrObj(); + const SdrPathObj* pPath = dynamic_cast< const SdrPathObj* >(pObj); + + if(pPath) + { + const basegfx::B2DPolyPolygon aPathXPP = pPath->GetPathPoly(); + + if(aPathXPP.count()) + { + const sal_uInt32 nPtAnz(pPts->GetCount()); + + for(sal_uInt32 nPtNum(0); nPtNum < nPtAnz; nPtNum++) + { + sal_uInt32 nPolyNum, nPointNum; + const sal_uInt16 nObjPt(pPts->GetObject(nPtNum)); + + if(sdr::PolyPolygonEditor::GetRelativePolyPoint(aPathXPP, nObjPt, nPolyNum, nPointNum)) + { + aPositions.push_back(aPathXPP.getB2DPolygon(nPolyNum).getB2DPoint(nPointNum)); + } + } + } + } + } + } + } + + if(aPositions.size()) + { + addSdrDragEntry(new SdrDragEntryPointGlueDrag(aPositions, true)); } } -sal_Bool SdrDragMethod::DoAddConnectorOverlays() +void SdrDragMethod::createSdrDragEntries_GlueDrag() { - // these conditions are translated from SdrDragView::ImpDrawEdgeXor - const SdrMarkList& rMarkedNodes = rView.GetEdgesOfMarkedNodes(); + const sal_uInt32 nMarkAnz(getSdrDragView().GetMarkedObjectCount()); + std::vector< basegfx::B2DPoint > aPositions; - if(!rMarkedNodes.GetMarkCount()) + for(sal_uInt32 nm(0); nm < nMarkAnz; nm++) { - return sal_False; - } + SdrMark* pM = getSdrDragView().GetSdrMarkByIndex(nm); - if(!rView.IsRubberEdgeDragging() && !rView.IsDetailedEdgeDragging()) - { - return sal_False; + if(pM->GetPageView() == getSdrDragView().GetSdrPageView()) + { + const SdrUShortCont* pPts = pM->GetMarkedGluePoints(); + + if(pPts && pPts->GetCount()) + { + const SdrObject* pObj = pM->GetMarkedSdrObj(); + const SdrGluePointList* pGPL = pObj->GetGluePointList(); + + if(pGPL) + { + const sal_uInt32 nPtAnz(pPts->GetCount()); + + for(sal_uInt32 nPtNum(0); nPtNum < nPtAnz; nPtNum++) + { + const sal_uInt16 nObjPt(pPts->GetObject(nPtNum)); + const sal_uInt16 nGlueNum(pGPL->FindGluePoint(nObjPt)); + + if(SDRGLUEPOINT_NOTFOUND != nGlueNum) + { + const Point aPoint((*pGPL)[nGlueNum].GetAbsolutePos(*pObj)); + aPositions.push_back(basegfx::B2DPoint(aPoint.X(), aPoint.Y())); + } + } + } + } + } } - if(rView.IsDraggingPoints() || rView.IsDraggingGluePoints()) + if(aPositions.size()) { - return sal_False; + addSdrDragEntry(new SdrDragEntryPointGlueDrag(aPositions, false)); } +} - if(!IsMoveOnly() && !( - IS_TYPE(SdrDragMove, this) || IS_TYPE(SdrDragResize, this) || - IS_TYPE(SdrDragRotate,this) || IS_TYPE(SdrDragMirror,this))) - { - return sal_False; +void SdrDragMethod::ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, XubString& rStr, sal_uInt16 nVal) const +{ + sal_uInt16 nOpt=0; + if (IsDraggingPoints()) { + nOpt=IMPSDR_POINTSDESCRIPTION; + } else if (IsDraggingGluePoints()) { + nOpt=IMPSDR_GLUEPOINTSDESCRIPTION; } + getSdrDragView().ImpTakeDescriptionStr(nStrCacheID,rStr,nVal,nOpt); +} - const sal_Bool bDetail(rView.IsDetailedEdgeDragging() && IsMoveOnly()); +SdrObject* SdrDragMethod::GetDragObj() const +{ + SdrObject* pObj=NULL; + if (getSdrDragView().pDragHdl!=NULL) pObj=getSdrDragView().pDragHdl->GetObj(); + if (pObj==NULL) pObj=getSdrDragView().pMarkedObj; + return pObj; +} - if(!bDetail && !rView.IsRubberEdgeDragging()) - { - return sal_False; - } +SdrPageView* SdrDragMethod::GetDragPV() const +{ + SdrPageView* pPV=NULL; + if (getSdrDragView().pDragHdl!=NULL) pPV=getSdrDragView().pDragHdl->GetPageView(); + if (pPV==NULL) pPV=getSdrDragView().pMarkedPV; + return pPV; +} - // one more migrated from SdrEdgeObj::NspToggleEdgeXor - if(IS_TYPE(SdrDragObjOwn, this) || IS_TYPE(SdrDragMovHdl, this)) +void SdrDragMethod::applyCurrentTransformationToSdrObject(SdrObject& rTarget) +{ + // the original applies the transformation using TRGetBaseGeometry/TRSetBaseGeometry. + // Later this should be the only needed one for linear transforms (not for SdrDragCrook and + // SdrDragDistort, those are NOT linear). Currently, this can not yet be used since the + // special handling of rotate/mirror due to the not-being-able to handle it in the old + // drawinglayer stuff. Text would currently not correctly be mirrored in the preview. + basegfx::B2DHomMatrix aObjectTransform; + basegfx::B2DPolyPolygon aObjectPolyPolygon; + bool bPolyUsed(rTarget.TRGetBaseGeometry(aObjectTransform, aObjectPolyPolygon)); + + // apply transform to object transform + aObjectTransform *= getCurrentTransformation(); + + if(bPolyUsed) { - return sal_False; + // do something special since the object size is in the polygon + // break up matrix to get the scale + basegfx::B2DTuple aScale; + basegfx::B2DTuple aTranslate; + double fRotate, fShearX; + aObjectTransform.decompose(aScale, aTranslate, fRotate, fShearX); + + // get polygon's pos and size + const basegfx::B2DRange aPolyRange(aObjectPolyPolygon.getB2DRange()); + + // get the scaling factors (do not mirror, this is in the object transformation) + const double fScaleX(fabs(aScale.getX()) / (basegfx::fTools::equalZero(aPolyRange.getWidth()) ? 1.0 : aPolyRange.getWidth())); + const double fScaleY(fabs(aScale.getY()) / (basegfx::fTools::equalZero(aPolyRange.getHeight()) ? 1.0 : aPolyRange.getHeight())); + + // prepare transform matrix for polygon + basegfx::B2DHomMatrix aPolyTransform; + + aPolyTransform.translate(-aPolyRange.getMinX(), -aPolyRange.getMinY()); + aPolyTransform.scale(fScaleX, fScaleY); + + // normally the poly should be moved back, but the translation is in the object + // transformation and thus does not need to be done + // aPolyTransform.translate(-aPolyRange.getMinX(), -aPolyRange.getMinY()); + + // transform the polygon + aObjectPolyPolygon.transform(aPolyTransform); } - return sal_True; + rTarget.TRSetBaseGeometry(getCurrentTransformation() * aObjectTransform, aObjectPolyPolygon); } -sal_Bool SdrDragMethod::DoAddDragStripeOverlay() +void SdrDragMethod::applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget) +{ + // original uses CurrentTransformation + rTarget.transform(getCurrentTransformation()); +} + +SdrDragMethod::SdrDragMethod(SdrDragView& rNewView) +: maSdrDragEntries(), + maOverlayObjectList(), + mrSdrDragView(rNewView), + mbMoveOnly(false), + mbSolidDraggingActive(getSdrDragView().IsSolidDragging()) { - if(rView.IsDragStripes()) + if(mbSolidDraggingActive && Application::GetSettings().GetStyleSettings().GetHighContrastMode()) { - return sal_True; + // fallback to wireframe when high contrast is used + mbSolidDraggingActive = false; } +} - return sal_False; +SdrDragMethod::~SdrDragMethod() +{ + clearSdrDragEntries(); } -void SdrDragMethod::AddConnectorOverlays(basegfx::B2DPolyPolygon& rResult) +void SdrDragMethod::Show() { - const sal_Bool bDetail(rView.IsDetailedEdgeDragging() && IsMoveOnly()); - const SdrMarkList& rMarkedNodes = rView.GetEdgesOfMarkedNodes(); + getSdrDragView().ShowDragObj(); +} - for(sal_uInt16 a(0); a < rMarkedNodes.GetMarkCount(); a++) +void SdrDragMethod::Hide() +{ + getSdrDragView().HideDragObj(); +} + +basegfx::B2DHomMatrix SdrDragMethod::getCurrentTransformation() +{ + return basegfx::B2DHomMatrix(); +} + +void SdrDragMethod::CancelSdrDrag() +{ + Hide(); +} + +void SdrDragMethod::CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlayManager) +{ + // create SdrDragEntries on demand + if(!maSdrDragEntries.size()) { - SdrMark* pEM = rMarkedNodes.GetMark(a); + createSdrDragEntries(); + } - if(pEM && pEM->GetMarkedSdrObj() && pEM->GetMarkedSdrObj()->ISA(SdrEdgeObj)) + // if there are entries, derive OverlayObjects fromthe entries, including + // modification from current interactive state + if(maSdrDragEntries.size()) + { + drawinglayer::primitive2d::Primitive2DSequence aResult; + drawinglayer::primitive2d::Primitive2DSequence aResultTransparent; + + for(sal_uInt32 a(0); a < maSdrDragEntries.size(); a++) { - SdrEdgeObj* pEdge = (SdrEdgeObj*)pEM->GetMarkedSdrObj(); - // SdrPageView* pEPV = pEM->GetPageView(); - pEdge->ImplAddConnectorOverlay(rResult, *this, pEM->IsCon1(), pEM->IsCon2(), bDetail); + SdrDragEntry* pCandidate = maSdrDragEntries[a]; + + if(pCandidate) + { + const drawinglayer::primitive2d::Primitive2DSequence aCandidateResult(pCandidate->createPrimitive2DSequenceInCurrentState(*this)); + + if(aCandidateResult.hasElements()) + { + if(pCandidate->getAddToTransparent()) + { + drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aResultTransparent, aCandidateResult); + } + else + { + drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aResult, aCandidateResult); + } + } + } } + + if(DoAddConnectorOverlays()) + { + const drawinglayer::primitive2d::Primitive2DSequence aConnectorOverlays(AddConnectorOverlays()); + + if(aConnectorOverlays.hasElements()) + { + // add connector overlays to transparent part + drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aResultTransparent, aConnectorOverlays); + } + } + + if(aResult.hasElements()) + { + sdr::overlay::OverlayObject* pNewOverlayObject = new sdr::overlay::OverlayPrimitive2DSequenceObject(aResult); + rOverlayManager.add(*pNewOverlayObject); + addToOverlayObjectList(*pNewOverlayObject); + } + + if(aResultTransparent.hasElements()) + { + drawinglayer::primitive2d::Primitive2DReference aUnifiedAlphaPrimitive2D(new drawinglayer::primitive2d::UnifiedAlphaPrimitive2D(aResultTransparent, 0.5)); + aResultTransparent = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedAlphaPrimitive2D, 1); + + sdr::overlay::OverlayObject* pNewOverlayObject = new sdr::overlay::OverlayPrimitive2DSequenceObject(aResultTransparent); + rOverlayManager.add(*pNewOverlayObject); + addToOverlayObjectList(*pNewOverlayObject); + } + } + + // evtl add DragStripes (help lines cross the page when dragging) + if(getSdrDragView().IsDragStripes()) + { + Rectangle aActionRectangle; + getSdrDragView().TakeActionRect(aActionRectangle); + + const basegfx::B2DPoint aTopLeft(aActionRectangle.Left(), aActionRectangle.Top()); + const basegfx::B2DPoint aBottomRight(aActionRectangle.Right(), aActionRectangle.Bottom()); + sdr::overlay::OverlayRollingRectangleStriped* pNew = new sdr::overlay::OverlayRollingRectangleStriped( + aTopLeft, aBottomRight, true, false); + + rOverlayManager.add(*pNew); + addToOverlayObjectList(*pNew); } } -void SdrDragMethod::CreateOverlayGeometryLines(basegfx::B2DPolyPolygon& rResult) +void SdrDragMethod::destroyOverlayGeometry() { - SdrPageView* pPV = rView.GetSdrPageView(); + clearOverlayObjectList(); +} - if(pPV) +bool SdrDragMethod::DoAddConnectorOverlays() +{ + // these conditions are translated from SdrDragView::ImpDrawEdgeXor + const SdrMarkList& rMarkedNodes = getSdrDragView().GetEdgesOfMarkedNodes(); + + if(!rMarkedNodes.GetMarkCount()) { - if(pPV->HasMarkedObjPageView()) - { - rResult.append(pPV->getDragPoly()); - } + return false; + } + + if(!getSdrDragView().IsRubberEdgeDragging() && !getSdrDragView().IsDetailedEdgeDragging()) + { + return false; + } + + if(getSdrDragView().IsDraggingPoints() || getSdrDragView().IsDraggingGluePoints()) + { + return false; } + + if(!getMoveOnly() && !( + IS_TYPE(SdrDragMove, this) || IS_TYPE(SdrDragResize, this) || + IS_TYPE(SdrDragRotate,this) || IS_TYPE(SdrDragMirror,this))) + { + return false; + } + + const bool bDetail(getSdrDragView().IsDetailedEdgeDragging() && getMoveOnly()); + + if(!bDetail && !getSdrDragView().IsRubberEdgeDragging()) + { + return false; + } + + // one more migrated from SdrEdgeObj::NspToggleEdgeXor + if(IS_TYPE(SdrDragObjOwn, this) || IS_TYPE(SdrDragMovHdl, this)) + { + return false; + } + + return true; } -void SdrDragMethod::CreateOverlayGeometryPoints(basegfx::B2DPolyPolygon& rResult, const Size& rLogicSize) +drawinglayer::primitive2d::Primitive2DSequence SdrDragMethod::AddConnectorOverlays() { - SdrPageView* pPV = rView.GetSdrPageView(); + drawinglayer::primitive2d::Primitive2DSequence aRetval; + const bool bDetail(getSdrDragView().IsDetailedEdgeDragging() && getMoveOnly()); + const SdrMarkList& rMarkedNodes = getSdrDragView().GetEdgesOfMarkedNodes(); - if(pPV) + for(sal_uInt16 a(0); a < rMarkedNodes.GetMarkCount(); a++) { - if(pPV->HasMarkedObjPageView()) + SdrMark* pEM = rMarkedNodes.GetMark(a); + + if(pEM && pEM->GetMarkedSdrObj()) { - const basegfx::B2DPolyPolygon& rPolyPolygon = pPV->getDragPoly(); - const sal_uInt32 nPolyAnz(rPolyPolygon.count()); + SdrEdgeObj* pEdge = dynamic_cast< SdrEdgeObj* >(pEM->GetMarkedSdrObj()); - for(sal_uInt32 nPolyNum(0L); nPolyNum < nPolyAnz; nPolyNum++) + if(pEdge) { - const basegfx::B2DPolygon aPolygon(rPolyPolygon.getB2DPolygon(nPolyNum)); - const sal_uInt32 nPtAnz(aPolygon.count()); + const basegfx::B2DPolygon aEdgePolygon(pEdge->ImplAddConnectorOverlay(*this, pEM->IsCon1(), pEM->IsCon2(), bDetail)); - for(sal_uInt32 nPtNum(0L); nPtNum < nPtAnz; nPtNum++) + if(aEdgePolygon.count()) { - const basegfx::B2DPoint aPoint(aPolygon.getB2DPoint(nPtNum)); - const double fX1(aPoint.getX() - rLogicSize.Width()); - const double fX2(aPoint.getX() + rLogicSize.Width()); - const double fY1(aPoint.getY() - rLogicSize.Height()); - const double fY2(aPoint.getY() + rLogicSize.Height()); - - if(IsDraggingGluePoints()) + // this polygon is a temporary calculated connector path, so it is not possible to fetch + // the needed primitives directly from the pEdge object which does not get changed. If full + // drag is on, use the SdrObjects ItemSet to create a adequate representation + if(getSolidDraggingActive()) { - // create small crosses - basegfx::B2DPolygon aTempPolyA, aTempPolyB; + const SfxItemSet& rItemSet = pEdge->GetMergedItemSet(); + drawinglayer::attribute::SdrLineAttribute* pLine = drawinglayer::primitive2d::createNewSdrLineAttribute(rItemSet); + drawinglayer::attribute::SdrLineStartEndAttribute* pLineStartEnd = 0; + + if(pLine && !pLine->isVisible()) + { + delete pLine; + pLine = 0; + } + + if(pLine) + { + pLineStartEnd = drawinglayer::primitive2d::createNewSdrLineStartEndAttribute(rItemSet, pLine->getWidth()); + + if(pLineStartEnd && !pLineStartEnd->isVisible()) + { + delete pLineStartEnd; + pLineStartEnd = 0; + } - aTempPolyA.append(basegfx::B2DPoint(fX1, fY1)); - aTempPolyA.append(basegfx::B2DPoint(fX2, fY2)); - rResult.append(aTempPolyA); + drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence( + aRetval, drawinglayer::primitive2d::createPolygonLinePrimitive( + aEdgePolygon, basegfx::B2DHomMatrix(), *pLine, pLineStartEnd)); - aTempPolyB.append(basegfx::B2DPoint(fX1, fY2)); - aTempPolyB.append(basegfx::B2DPoint(fX2, fY1)); - rResult.append(aTempPolyB); + if(pLineStartEnd) + { + delete pLineStartEnd; + } + + delete pLine; + } } else { - // create small boxes - basegfx::B2DPolygon aTempPoly; - - aTempPoly.append(basegfx::B2DPoint(fX1, fY1)); - aTempPoly.append(basegfx::B2DPoint(fX2, fY1)); - aTempPoly.append(basegfx::B2DPoint(fX2, fY2)); - aTempPoly.append(basegfx::B2DPoint(fX1, fY2)); - aTempPoly.setClosed(true); - rResult.append(aTempPoly); + const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; + basegfx::BColor aColA(aSvtOptionsDrawinglayer.GetStripeColorA().getBColor()); + basegfx::BColor aColB(aSvtOptionsDrawinglayer.GetStripeColorB().getBColor()); + const double fStripeLength(aSvtOptionsDrawinglayer.GetStripeLength()); + + if(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) + { + aColA = aColB = Application::GetSettings().GetStyleSettings().GetHighlightColor().getBColor(); + aColB.invert(); + } + + drawinglayer::primitive2d::Primitive2DReference aPolyPolygonMarkerPrimitive2D( + new drawinglayer::primitive2d::PolyPolygonMarkerPrimitive2D( + basegfx::B2DPolyPolygon(aEdgePolygon), aColA, aColB, fStripeLength)); + drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aPolyPolygonMarkerPrimitive2D); } } } } } + + return aRetval; } //////////////////////////////////////////////////////////////////////////////////////////////////// TYPEINIT1(SdrDragMovHdl,SdrDragMethod); -void SdrDragMovHdl::TakeComment(XubString& rStr) const +SdrDragMovHdl::SdrDragMovHdl(SdrDragView& rNewView) +: SdrDragMethod(rNewView), + bMirrObjShown(false) +{ +} + +void SdrDragMovHdl::createSdrDragEntries() +{ + // SdrDragMovHdl does not use the default drags, + // but creates nothing +} + +void SdrDragMovHdl::TakeSdrDragComment(XubString& rStr) const { rStr=ImpGetResStr(STR_DragMethMovHdl); - if (rView.IsDragWithCopy()) rStr+=ImpGetResStr(STR_EditWithCopy); + if (getSdrDragView().IsDragWithCopy()) rStr+=ImpGetResStr(STR_EditWithCopy); } -FASTBOOL SdrDragMovHdl::Beg() +bool SdrDragMovHdl::BeginSdrDrag() { DragStat().Ref1()=GetDragHdl()->GetPos(); DragStat().SetShown(!DragStat().IsShown()); SdrHdlKind eKind=GetDragHdl()->GetKind(); SdrHdl* pH1=GetHdlList().GetHdl(HDL_REF1); SdrHdl* pH2=GetHdlList().GetHdl(HDL_REF2); - if (eKind==HDL_MIRX) { - if (pH1==NULL || pH2==NULL) { - DBG_ERROR("SdrDragMovHdl::Beg(): Verschieben der Spiegelachse: Referenzhandles nicht gefunden"); - return FALSE; + + if (eKind==HDL_MIRX) + { + if (pH1==NULL || pH2==NULL) + { + DBG_ERROR("SdrDragMovHdl::BeginSdrDrag(): Verschieben der Spiegelachse: Referenzhandles nicht gefunden"); + return false; } + DragStat().SetActionRect(Rectangle(pH1->GetPos(),pH2->GetPos())); - } else { + } + else + { Point aPt(GetDragHdl()->GetPos()); DragStat().SetActionRect(Rectangle(aPt,aPt)); } - return TRUE; + + return true; } -void SdrDragMovHdl::Mov(const Point& rNoSnapPnt) +void SdrDragMovHdl::MoveSdrDrag(const Point& rNoSnapPnt) { Point aPnt(rNoSnapPnt); - if (DragStat().CheckMinMoved(rNoSnapPnt)) { - if (GetDragHdl()->GetKind()==HDL_MIRX) { + + if (DragStat().CheckMinMoved(rNoSnapPnt)) + { + if (GetDragHdl()->GetKind()==HDL_MIRX) + { SdrHdl* pH1=GetHdlList().GetHdl(HDL_REF1); SdrHdl* pH2=GetHdlList().GetHdl(HDL_REF2); - if (pH1==NULL || pH2==NULL) return; - if (!DragStat().IsNoSnap()) { + + if (pH1==NULL || pH2==NULL) + return; + + if (!DragStat().IsNoSnap()) + { long nBestXSnap=0; long nBestYSnap=0; - BOOL bXSnapped=FALSE; - BOOL bYSnapped=FALSE; + bool bXSnapped=false; + bool bYSnapped=false; Point aDif(aPnt-DragStat().GetStart()); - rView.CheckSnap(Ref1()+aDif,NULL,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped); - rView.CheckSnap(Ref2()+aDif,NULL,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped); + getSdrDragView().CheckSnap(Ref1()+aDif,NULL,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped); + getSdrDragView().CheckSnap(Ref2()+aDif,NULL,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped); aPnt.X()+=nBestXSnap; aPnt.Y()+=nBestYSnap; } - if (aPnt!=DragStat().GetNow()) { + + if (aPnt!=DragStat().GetNow()) + { Hide(); DragStat().NextMove(aPnt); Point aDif(DragStat().GetNow()-DragStat().GetStart()); @@ -402,26 +934,42 @@ void SdrDragMovHdl::Mov(const Point& rNoSnapPnt) pH2->SetPos(Ref2()+aDif); SdrHdl* pHM = GetHdlList().GetHdl(HDL_MIRX); + if(pHM) pHM->Touch(); Show(); DragStat().SetActionRect(Rectangle(pH1->GetPos(),pH2->GetPos())); } - } else { + } + else + { if (!DragStat().IsNoSnap()) SnapPos(aPnt); long nSA=0; - if (rView.IsAngleSnapEnabled()) nSA=rView.GetSnapAngle(); - if (rView.IsMirrorAllowed(TRUE,TRUE)) { // eingeschraenkt - if (!rView.IsMirrorAllowed(FALSE,FALSE)) nSA=4500; - if (!rView.IsMirrorAllowed(TRUE,FALSE)) nSA=9000; + + if (getSdrDragView().IsAngleSnapEnabled()) + nSA=getSdrDragView().GetSnapAngle(); + + if (getSdrDragView().IsMirrorAllowed(true,true)) + { // eingeschraenkt + if (!getSdrDragView().IsMirrorAllowed(false,false)) nSA=4500; + if (!getSdrDragView().IsMirrorAllowed(true,false)) nSA=9000; } - if (rView.IsOrtho() && nSA!=9000) nSA=4500; - if (nSA!=0) { // Winkelfang + + if (getSdrDragView().IsOrtho() && nSA!=9000) + nSA=4500; + + if (nSA!=0) + { // Winkelfang SdrHdlKind eRef=HDL_REF1; - if (GetDragHdl()->GetKind()==HDL_REF1) eRef=HDL_REF2; + + if (GetDragHdl()->GetKind()==HDL_REF1) + eRef=HDL_REF2; + SdrHdl* pH=GetHdlList().GetHdl(eRef); - if (pH!=NULL) { + + if (pH!=NULL) + { Point aRef(pH->GetPos()); long nWink=NormAngle360(GetAngle(aPnt-aRef)); long nNeuWink=nWink; @@ -433,21 +981,29 @@ void SdrDragMovHdl::Mov(const Point& rNoSnapPnt) double nSin=sin(a); double nCos=cos(a); RotatePoint(aPnt,aRef,nSin,nCos); + // Bei bestimmten Werten Rundungsfehler ausschliessen: - if (nSA==9000) { + if (nSA==9000) + { if (nNeuWink==0 || nNeuWink==18000) aPnt.Y()=aRef.Y(); if (nNeuWink==9000 || nNeuWink==27000) aPnt.X()=aRef.X(); } - if (nSA==4500) OrthoDistance8(aRef,aPnt,TRUE); + + if (nSA==4500) + OrthoDistance8(aRef,aPnt,true); } } - if (aPnt!=DragStat().GetNow()) { + + if (aPnt!=DragStat().GetNow()) + { Hide(); DragStat().NextMove(aPnt); GetDragHdl()->SetPos(DragStat().GetNow()); SdrHdl* pHM = GetHdlList().GetHdl(HDL_MIRX); + if(pHM) pHM->Touch(); + Show(); DragStat().SetActionRect(Rectangle(aPnt,aPnt)); } @@ -455,94 +1011,48 @@ void SdrDragMovHdl::Mov(const Point& rNoSnapPnt) } } -FASTBOOL SdrDragMovHdl::End(FASTBOOL /*bCopy*/) +bool SdrDragMovHdl::EndSdrDrag(bool /*bCopy*/) { - switch (GetDragHdl()->GetKind()) { - case HDL_REF1: Ref1()=DragStat().GetNow(); break; - case HDL_REF2: Ref2()=DragStat().GetNow(); break; - case HDL_MIRX: { + switch (GetDragHdl()->GetKind()) + { + case HDL_REF1: + Ref1()=DragStat().GetNow(); + break; + + case HDL_REF2: + Ref2()=DragStat().GetNow(); + break; + + case HDL_MIRX: Ref1()+=DragStat().GetNow()-DragStat().GetStart(); Ref2()+=DragStat().GetNow()-DragStat().GetStart(); - } break; + break; + default: break; } - return TRUE; + + return true; } -void SdrDragMovHdl::Brk() +void SdrDragMovHdl::CancelSdrDrag() { Hide(); GetDragHdl()->SetPos(DragStat().GetRef1()); SdrHdl* pHM = GetHdlList().GetHdl(HDL_MIRX); + if(pHM) pHM->Touch(); - Draw(); -} - -void SdrDragMovHdl::Show() -{ - SdrHdl* pDragHdl=GetDragHdl(); - SdrHdlKind eDragHdl=pDragHdl->GetKind(); - bool bMirX=eDragHdl==HDL_MIRX; - bool bShown=DragStat().IsShown(); - if (rView.IsSolidMarkHdl()) { - if (!bShown) { - const SdrHdlList& rHL=GetHdlList(); - SdrHdlKind eHdl1=eDragHdl; - SdrHdlKind eHdl2=eDragHdl; - if (bMirX) { eHdl1=HDL_REF1; eHdl2=HDL_REF2; } - SdrHdl* pHdl1=rHL.GetHdl(eHdl1); - SdrHdl* pHdl2=rHL.GetHdl(eHdl2); - ULONG nHdlNum1=rHL.GetHdlNum(pHdl1); - ULONG nHdlNum2=rHL.GetHdlNum(pHdl2); - if (nHdlNum1==CONTAINER_ENTRY_NOTFOUND || pHdl1==NULL) { - DBG_ERROR("SdrDragMovHdl::Show(): Handle nicht in der HandleList gefunden!"); - return; - } - if (bMirX && (nHdlNum2==CONTAINER_ENTRY_NOTFOUND || pHdl2==NULL)) { - DBG_ERROR("SdrDragMovHdl::Show(): Handle nicht in der HandleList gefunden!"); - return; - } - } - } - SdrDragMethod::Show(); } -void SdrDragMovHdl::Hide() +Pointer SdrDragMovHdl::GetSdrDragPointer() const { - SdrHdl* pDragHdl=GetDragHdl(); - SdrHdlKind eDragHdl=pDragHdl->GetKind(); - bool bMirX=eDragHdl==HDL_MIRX; - bool bShown=DragStat().IsShown(); - SdrDragMethod::Hide(); - if (rView.IsSolidMarkHdl()) { - if (bShown) { - const SdrHdlList& rHL=GetHdlList(); - SdrHdlKind eHdl1=eDragHdl; - SdrHdlKind eHdl2=eDragHdl; - if (bMirX) { eHdl1=HDL_REF1; eHdl2=HDL_REF2; } - SdrHdl* pHdl1=rHL.GetHdl(eHdl1); - SdrHdl* pHdl2=rHL.GetHdl(eHdl2); - ULONG nHdlNum1=rHL.GetHdlNum(pHdl1); - ULONG nHdlNum2=rHL.GetHdlNum(pHdl2); - if (nHdlNum1==CONTAINER_ENTRY_NOTFOUND || pHdl1==NULL) { - DBG_ERROR("SdrDragMovHdl::Hide(): Handle nicht in der HandleList gefunden!"); - return; - } - if (bMirX && (nHdlNum2==CONTAINER_ENTRY_NOTFOUND || pHdl2==NULL)) { - DBG_ERROR("SdrDragMovHdl::Hide(): Handle nicht in der HandleList gefunden!"); - return; - } - } - } -} + const SdrHdl* pHdl = GetDragHdl(); -Pointer SdrDragMovHdl::GetPointer() const -{ - const SdrHdl* pHdl=GetDragHdl(); - if (pHdl!=NULL) { + if (pHdl!=NULL) + { return pHdl->GetPointer(); } + return Pointer(POINTER_REFHAND); } @@ -550,134 +1060,276 @@ Pointer SdrDragMovHdl::GetPointer() const TYPEINIT1(SdrDragObjOwn,SdrDragMethod); -void SdrDragObjOwn::TakeComment(XubString& rStr) const +SdrDragObjOwn::SdrDragObjOwn(SdrDragView& rNewView) +: SdrDragMethod(rNewView), + mpClone(0) { - const SdrObject* pObj=GetDragObj(); - if (pObj!=NULL) { - rStr=pObj->GetDragComment(DragStat(),FALSE,FALSE); - // Kein Copy bei ObjOwn + const SdrObject* pObj = GetDragObj(); + + if(pObj) + { + // suppress full drag for some object types + setSolidDraggingActive(pObj->supportsFullDrag()); } } -FASTBOOL SdrDragObjOwn::Beg() +SdrDragObjOwn::~SdrDragObjOwn() { - SdrObject* pObj=GetDragObj(); - return pObj!=NULL ? pObj->BegDrag(DragStat()) : FALSE; + if(mpClone) + { + SdrObject::Free(mpClone); + } } -void SdrDragObjOwn::Mov(const Point& rNoSnapPnt) +void SdrDragObjOwn::createSdrDragEntries() { - Point aPnt(rNoSnapPnt); - SdrPageView* pPV=GetDragPV(); - if (pPV!=NULL) { - if (!DragStat().IsNoSnap()) SnapPos(aPnt); - //FASTBOOL bOrtho=rView.IsOrtho(); - if (rView.IsOrtho()) { - if (DragStat().IsOrtho8Possible()) OrthoDistance8(DragStat().GetStart(),aPnt,rView.IsBigOrtho()); - else if (DragStat().IsOrtho4Possible()) OrthoDistance4(DragStat().GetStart(),aPnt,rView.IsBigOrtho()); - } -// const SdrHdl* pHdl=DragStat().GetHdl(); -// if (pHdl!=NULL) { -// aPnt-=pPV->GetOffset(); -// } - SdrObject* pObj=GetDragObj(); - if (pObj!=NULL && DragStat().CheckMinMoved(/*aPnt*/rNoSnapPnt)) { - if (aPnt!=DragStat().GetNow()) { - Hide(); - DragStat().NextMove(aPnt); - pObj->MovDrag(DragStat()); - pPV->setDragPoly(pObj->TakeDragPoly(DragStat())); - Show(); + if(mpClone) + { + basegfx::B2DPolyPolygon aDragPolyPolygon; + bool bAddWireframe(true); + + if(getSolidDraggingActive()) + { + SdrPageView* pPV = getSdrDragView().GetSdrPageView(); + + if(pPV && pPV->PageWindowCount()) + { + sdr::contact::ObjectContact& rOC = pPV->GetPageWindow(0)->GetObjectContact(); + addSdrDragEntry(new SdrDragEntrySdrObject(*mpClone, rOC, false)); + + // potentially no wireframe needed, full drag works + bAddWireframe = false; + } + } + + if(!bAddWireframe) + { + // check for extra conditions for wireframe, e.g. no border at + // objects + if(!mpClone->HasLineStyle()) + { + bAddWireframe = true; + } + } + + if(bAddWireframe) + { + // use wireframe poly when full drag is off or did not work + aDragPolyPolygon = mpClone->TakeXorPoly(); + } + + // add evtl. extra DragPolyPolygon + const basegfx::B2DPolyPolygon aSpecialDragPolyPolygon(mpClone->getSpecialDragPoly(DragStat())); + + if(aSpecialDragPolyPolygon.count()) + { + aDragPolyPolygon.append(aSpecialDragPolyPolygon); + } + + if(aDragPolyPolygon.count()) + { + addSdrDragEntry(new SdrDragEntryPolyPolygon(aDragPolyPolygon)); + } + } +} + +void SdrDragObjOwn::TakeSdrDragComment(XubString& rStr) const +{ + const SdrObject* pObj = GetDragObj(); + + if(pObj) + { + rStr = pObj->getSpecialDragComment(DragStat()); + } +} + +bool SdrDragObjOwn::BeginSdrDrag() +{ + if(!mpClone) + { + const SdrObject* pObj = GetDragObj(); + + if(pObj && !pObj->IsResizeProtect()) + { + if(pObj->beginSpecialDrag(DragStat())) + { + // create nitial clone to have a start visualisation + mpClone = pObj->getFullDragClone(); + mpClone->applySpecialDrag(DragStat()); + + return true; } } } + + return false; } -FASTBOOL SdrDragObjOwn::End(FASTBOOL /*bCopy*/) +void SdrDragObjOwn::MoveSdrDrag(const Point& rNoSnapPnt) +{ + const SdrObject* pObj = GetDragObj(); + + if(pObj) + { + Point aPnt(rNoSnapPnt); + SdrPageView* pPV = GetDragPV(); + + if(pPV) + { + if(!DragStat().IsNoSnap()) + { + SnapPos(aPnt); + } + + if(getSdrDragView().IsOrtho()) + { + if (DragStat().IsOrtho8Possible()) + { + OrthoDistance8(DragStat().GetStart(),aPnt,getSdrDragView().IsBigOrtho()); + } + else if (DragStat().IsOrtho4Possible()) + { + OrthoDistance4(DragStat().GetStart(),aPnt,getSdrDragView().IsBigOrtho()); + } + } + + if(DragStat().CheckMinMoved(rNoSnapPnt)) + { + if(aPnt != DragStat().GetNow()) + { + Hide(); + DragStat().NextMove(aPnt); + + // since SdrDragObjOwn currently supports no transformation of + // existing SdrDragEntries but only their recreation, a recreation + // after every move is needed in this mode. Delete existing + // SdrDragEntries here to force their recreation in the following Show(). + clearSdrDragEntries(); + + // delete current clone (after the last reference to it is deleted above) + if(mpClone) + { + SdrObject::Free(mpClone); + mpClone = 0; + } + + // create a new clone and modify to current drag state + if(!mpClone) + { + mpClone = pObj->getFullDragClone(); + mpClone->applySpecialDrag(DragStat()); + } + + Show(); + } + } + } + } +} + +bool SdrDragObjOwn::EndSdrDrag(bool /*bCopy*/) { Hide(); - SdrUndoAction* pUndo=NULL; - SdrUndoAction* pUndo2=NULL; + SdrUndoAction* pUndo = NULL; + SdrUndoAction* pUndo2 = NULL; std::vector< SdrUndoAction* > vConnectorUndoActions; - bool bRet=FALSE; - SdrObject* pObj=GetDragObj(); - if (pObj!=NULL) + bool bRet = false; + SdrObject* pObj = GetDragObj(); + + if(pObj) { - if(!rView.IsInsObjPoint() && pObj->IsInserted() ) + if(!getSdrDragView().IsInsObjPoint() && pObj->IsInserted() ) { if (DragStat().IsEndDragChangesAttributes()) { - pUndo=rView.GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj); + pUndo=getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj); + if (DragStat().IsEndDragChangesGeoAndAttributes()) { - vConnectorUndoActions = rView.CreateConnectorUndo( *pObj ); - pUndo2 = rView.GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj); + vConnectorUndoActions = getSdrDragView().CreateConnectorUndo( *pObj ); + pUndo2 = getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj); } } else { - vConnectorUndoActions = rView.CreateConnectorUndo( *pObj ); - pUndo= rView.GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj); + vConnectorUndoActions = getSdrDragView().CreateConnectorUndo( *pObj ); + pUndo= getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj); } } if( pUndo ) - rView.BegUndo( pUndo->GetComment() ); + { + getSdrDragView().BegUndo( pUndo->GetComment() ); + } else - rView.BegUndo(); + { + getSdrDragView().BegUndo(); + } - bRet=pObj->EndDrag(DragStat()); + // evtl. use opertator= for setting changed object data (do not change selection in + // view, this will destroy the interactor). This is possible since a clone is now + // directly modified by the modifiers. Only SdrTableObj is adding own UNDOs + // in it's SdrTableObj::endSpecialDrag, so currently not possible. OTOH it uses + // a CreateUndoGeoObject() so maybe setting SetEndDragChangesAttributes is okay. I + // will test this now + Rectangle aBoundRect0; + + if(pObj->GetUserCall()) + { + aBoundRect0 = pObj->GetLastBoundRect(); + } + + bRet = pObj->applySpecialDrag(DragStat()); + + if(bRet) + { + pObj->SetChanged(); + pObj->BroadcastObjectChange(); + pObj->SendUserCall( SDRUSERCALL_RESIZE, aBoundRect0 ); + } if(bRet) { - rView.AddUndoActions( vConnectorUndoActions ); + getSdrDragView().AddUndoActions( vConnectorUndoActions ); + if ( pUndo ) - rView.AddUndo(pUndo); + { + getSdrDragView().AddUndo(pUndo); + } if ( pUndo2 ) - rView.AddUndo(pUndo2); + { + getSdrDragView().AddUndo(pUndo2); + } } else { std::vector< SdrUndoAction* >::iterator vConnectorUndoIter( vConnectorUndoActions.begin() ); + while( vConnectorUndoIter != vConnectorUndoActions.end() ) + { delete *vConnectorUndoIter++; + } + delete pUndo; delete pUndo2; } - rView.EndUndo(); + getSdrDragView().EndUndo(); } + return bRet; } -// for migration from XOR to overlay -void SdrDragObjOwn::CreateOverlayGeometry(::sdr::overlay::OverlayManager& rOverlayManager, ::sdr::overlay::OverlayObjectList& rOverlayList) +Pointer SdrDragObjOwn::GetSdrDragPointer() const { - SdrPageView* pPageView = GetDragPV(); + const SdrHdl* pHdl=GetDragHdl(); - if(pPageView) + if (pHdl) { - ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(pPageView->getDragPoly()); - rOverlayManager.add(*pNew); - rOverlayList.append(*pNew); - } -} - -void SdrDragObjOwn::Brk() -{ - SdrObject* pObj = GetDragObj(); - if ( pObj ) - pObj->BrkDrag( DragStat() ); - SdrDragMethod::Brk(); -} - -Pointer SdrDragObjOwn::GetPointer() const -{ - const SdrHdl* pHdl=GetDragHdl(); - if (pHdl!=NULL) { return pHdl->GetPointer(); } + return Pointer(POINTER_MOVE); } @@ -685,94 +1337,101 @@ Pointer SdrDragObjOwn::GetPointer() const TYPEINIT1(SdrDragMove,SdrDragMethod); -void SdrDragMove::TakeComment(XubString& rStr) const +void SdrDragMove::applyCurrentTransformationToSdrObject(SdrObject& rTarget) +{ + rTarget.Move(Size(DragStat().GetDX(), DragStat().GetDY())); +} + +SdrDragMove::SdrDragMove(SdrDragView& rNewView) +: SdrDragMethod(rNewView) +{ + setMoveOnly(true); +} + +void SdrDragMove::TakeSdrDragComment(XubString& rStr) const { XubString aStr; ImpTakeDescriptionStr(STR_DragMethMove, rStr); rStr.AppendAscii(" (x="); - rView.GetModel()->TakeMetricStr(DragStat().GetDX(), aStr); + getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDX(), aStr); rStr += aStr; rStr.AppendAscii(" y="); - rView.GetModel()->TakeMetricStr(DragStat().GetDY(), aStr); + getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDY(), aStr); rStr += aStr; rStr += sal_Unicode(')'); - if(rView.IsDragWithCopy()) + if(getSdrDragView().IsDragWithCopy()) { - if(!rView.IsInsObjPoint() && !rView.IsInsGluePoint()) + if(!getSdrDragView().IsInsObjPoint() && !getSdrDragView().IsInsGluePoint()) { rStr += ImpGetResStr(STR_EditWithCopy); } } } -FASTBOOL SdrDragMove::Beg() +bool SdrDragMove::BeginSdrDrag() { - SetDragPolys(); DragStat().SetActionRect(GetMarkedRect()); Show(); - return TRUE; + + return true; } -void SdrDragMove::MovAllPoints() +basegfx::B2DHomMatrix SdrDragMove::getCurrentTransformation() { - SdrPageView* pPV = rView.GetSdrPageView(); + basegfx::B2DHomMatrix aRetval; - if(pPV) - { - if (pPV->HasMarkedObjPageView()) - { - basegfx::B2DPolyPolygon aDragPolygon(pPV->getDragPoly0()); - basegfx::B2DHomMatrix aMatrix; + aRetval.translate(DragStat().GetDX(), DragStat().GetDY()); - aMatrix.translate(DragStat().GetDX(),DragStat().GetDY()); - aDragPolygon.transform(aMatrix); - - pPV->setDragPoly(aDragPolygon); - } - } -} - -void SdrDragMove::MovPoint(Point& rPnt) -{ - rPnt.X()+=DragStat().GetDX(); - rPnt.Y()+=DragStat().GetDY(); + return aRetval; } void SdrDragMove::ImpCheckSnap(const Point& rPt) { Point aPt(rPt); - USHORT nRet=SnapPos(aPt); + sal_uInt16 nRet=SnapPos(aPt); aPt-=rPt; - if ((nRet & SDRSNAP_XSNAPPED) !=0) { - if (bXSnapped) { - if (Abs(aPt.X())<Abs(nBestXSnap)) { + + if ((nRet & SDRSNAP_XSNAPPED) !=0) + { + if (bXSnapped) + { + if (Abs(aPt.X())<Abs(nBestXSnap)) + { nBestXSnap=aPt.X(); } - } else { + } + else + { nBestXSnap=aPt.X(); - bXSnapped=TRUE; + bXSnapped=true; } } - if ((nRet & SDRSNAP_YSNAPPED) !=0) { - if (bYSnapped) { - if (Abs(aPt.Y())<Abs(nBestYSnap)) { + + if ((nRet & SDRSNAP_YSNAPPED) !=0) + { + if (bYSnapped) + { + if (Abs(aPt.Y())<Abs(nBestYSnap)) + { nBestYSnap=aPt.Y(); } - } else { + } + else + { nBestYSnap=aPt.Y(); - bYSnapped=TRUE; + bYSnapped=true; } } } -void SdrDragMove::Mov(const Point& rNoSnapPnt_) +void SdrDragMove::MoveSdrDrag(const Point& rNoSnapPnt_) { nBestXSnap=0; nBestYSnap=0; - bXSnapped=FALSE; - bYSnapped=FALSE; + bXSnapped=false; + bYSnapped=false; Point aNoSnapPnt(rNoSnapPnt_); const Rectangle& aSR=GetMarkedRect(); long nMovedx=aNoSnapPnt.X()-DragStat().GetStart().X(); @@ -782,61 +1441,100 @@ void SdrDragMove::Mov(const Point& rNoSnapPnt_) Point aLU(aLO.X(),aRU.Y()); Point aRO(aRU.X(),aLO.Y()); ImpCheckSnap(aLO); - if (!rView.IsMoveSnapOnlyTopLeft()) { + + if (!getSdrDragView().IsMoveSnapOnlyTopLeft()) + { ImpCheckSnap(aRO); ImpCheckSnap(aLU); ImpCheckSnap(aRU); } + Point aPnt(aNoSnapPnt.X()+nBestXSnap,aNoSnapPnt.Y()+nBestYSnap); - bool bOrtho=rView.IsOrtho(); - if (bOrtho) OrthoDistance8(DragStat().GetStart(),aPnt,rView.IsBigOrtho()); - if (DragStat().CheckMinMoved(aNoSnapPnt)) { + bool bOrtho=getSdrDragView().IsOrtho(); + + if (bOrtho) + OrthoDistance8(DragStat().GetStart(),aPnt,getSdrDragView().IsBigOrtho()); + + if (DragStat().CheckMinMoved(aNoSnapPnt)) + { Point aPt1(aPnt); - Rectangle aLR(rView.GetWorkArea()); + Rectangle aLR(getSdrDragView().GetWorkArea()); bool bWorkArea=!aLR.IsEmpty(); bool bDragLimit=IsDragLimit(); - if (bDragLimit || bWorkArea) { + + if (bDragLimit || bWorkArea) + { Rectangle aSR2(GetMarkedRect()); Point aD(aPt1-DragStat().GetStart()); - if (bDragLimit) { + + if (bDragLimit) + { Rectangle aR2(GetDragLimitRect()); - if (bWorkArea) aLR.Intersection(aR2); - else aLR=aR2; + + if (bWorkArea) + aLR.Intersection(aR2); + else + aLR=aR2; } - if (aSR2.Left()>aLR.Left() || aSR2.Right()<aLR.Right()) { // ist ueberhaupt Platz zum verschieben? + + if (aSR2.Left()>aLR.Left() || aSR2.Right()<aLR.Right()) + { // ist ueberhaupt Platz zum verschieben? aSR2.Move(aD.X(),0); - if (aSR2.Left()<aLR.Left()) { + + if (aSR2.Left()<aLR.Left()) + { aPt1.X()-=aSR2.Left()-aLR.Left(); - } else if (aSR2.Right()>aLR.Right()) { + } + else if (aSR2.Right()>aLR.Right()) + { aPt1.X()-=aSR2.Right()-aLR.Right(); } - } else aPt1.X()=DragStat().GetStart().X(); // kein Platz zum verschieben - if (aSR2.Top()>aLR.Top() || aSR2.Bottom()<aLR.Bottom()) { // ist ueberhaupt Platz zum verschieben? + } + else + aPt1.X()=DragStat().GetStart().X(); // kein Platz zum verschieben + + if (aSR2.Top()>aLR.Top() || aSR2.Bottom()<aLR.Bottom()) + { // ist ueberhaupt Platz zum verschieben? aSR2.Move(0,aD.Y()); - if (aSR2.Top()<aLR.Top()) { + + if (aSR2.Top()<aLR.Top()) + { aPt1.Y()-=aSR2.Top()-aLR.Top(); - } else if (aSR2.Bottom()>aLR.Bottom()) { + } + else if (aSR2.Bottom()>aLR.Bottom()) + { aPt1.Y()-=aSR2.Bottom()-aLR.Bottom(); } - } else aPt1.Y()=DragStat().GetStart().Y(); // kein Platz zum verschieben + } + else + aPt1.Y()=DragStat().GetStart().Y(); // kein Platz zum verschieben } - if (rView.IsDraggingGluePoints()) { // Klebepunkte aufs BoundRect des Obj limitieren + + if (getSdrDragView().IsDraggingGluePoints()) + { // Klebepunkte aufs BoundRect des Obj limitieren aPt1-=DragStat().GetStart(); const SdrMarkList& rML=GetMarkedObjectList(); ULONG nMarkAnz=rML.GetMarkCount(); - for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) { + + for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) + { const SdrMark* pM=rML.GetMark(nMarkNum); const SdrUShortCont* pPts=pM->GetMarkedGluePoints(); ULONG nPtAnz=pPts==NULL ? 0 : pPts->GetCount(); - if (nPtAnz!=0) { + + if (nPtAnz!=0) + { const SdrObject* pObj=pM->GetMarkedSdrObj(); - //const SdrPageView* pPV=pM->GetPageView(); const SdrGluePointList* pGPL=pObj->GetGluePointList(); Rectangle aBound(pObj->GetCurrentBoundRect()); - for (ULONG nPtNum=0; nPtNum<nPtAnz; nPtNum++) { - USHORT nId=pPts->GetObject(nPtNum); - USHORT nGlueNum=pGPL->FindGluePoint(nId); - if (nGlueNum!=SDRGLUEPOINT_NOTFOUND) { + + for (ULONG nPtNum=0; nPtNum<nPtAnz; nPtNum++) + { + sal_uInt16 nId=pPts->GetObject(nPtNum); + sal_uInt16 nGlueNum=pGPL->FindGluePoint(nId); + + if (nGlueNum!=SDRGLUEPOINT_NOTFOUND) + { Point aPt((*pGPL)[nGlueNum].GetAbsolutePos(*pObj)); aPt+=aPt1; // soviel soll verschoben werden if (aPt.X()<aBound.Left() ) aPt1.X()-=aPt.X()-aBound.Left() ; @@ -847,13 +1545,17 @@ void SdrDragMove::Mov(const Point& rNoSnapPnt_) } } } + aPt1+=DragStat().GetStart(); } - if (bOrtho) OrthoDistance8(DragStat().GetStart(),aPt1,FALSE); - if (aPt1!=DragStat().GetNow()) { + + if (bOrtho) + OrthoDistance8(DragStat().GetStart(),aPt1,false); + + if (aPt1!=DragStat().GetNow()) + { Hide(); DragStat().NextMove(aPt1); - MovAllPoints(); Rectangle aAction(GetMarkedRect()); aAction.Move(DragStat().GetDX(),DragStat().GetDY()); DragStat().SetActionRect(aAction); @@ -862,30 +1564,37 @@ void SdrDragMove::Mov(const Point& rNoSnapPnt_) } } -FASTBOOL SdrDragMove::End(FASTBOOL bCopy) +bool SdrDragMove::EndSdrDrag(bool bCopy) { Hide(); - if (rView.IsInsObjPoint() || rView.IsInsGluePoint()) bCopy=FALSE; - if (IsDraggingPoints()) { - rView.MoveMarkedPoints(Size(DragStat().GetDX(),DragStat().GetDY()),bCopy); - } else if (IsDraggingGluePoints()) { - rView.MoveMarkedGluePoints(Size(DragStat().GetDX(),DragStat().GetDY()),bCopy); - } else { - rView.MoveMarkedObj(Size(DragStat().GetDX(),DragStat().GetDY()),bCopy); + + if (getSdrDragView().IsInsObjPoint() || getSdrDragView().IsInsGluePoint()) + bCopy=false; + + if (IsDraggingPoints()) + { + getSdrDragView().MoveMarkedPoints(Size(DragStat().GetDX(),DragStat().GetDY()),bCopy); + } + else if (IsDraggingGluePoints()) + { + getSdrDragView().MoveMarkedGluePoints(Size(DragStat().GetDX(),DragStat().GetDY()),bCopy); + } + else + { + getSdrDragView().MoveMarkedObj(Size(DragStat().GetDX(),DragStat().GetDY()),bCopy); } - return TRUE; -} -FASTBOOL SdrDragMove::IsMoveOnly() const -{ - return TRUE; + return true; } -Pointer SdrDragMove::GetPointer() const +Pointer SdrDragMove::GetSdrDragPointer() const { - if (IsDraggingPoints() || IsDraggingGluePoints()) { + if (IsDraggingPoints() || IsDraggingGluePoints()) + { return Pointer(POINTER_MOVEPOINT); - } else { + } + else + { return Pointer(POINTER_MOVE); } } @@ -894,10 +1603,17 @@ Pointer SdrDragMove::GetPointer() const TYPEINIT1(SdrDragResize,SdrDragMethod); -void SdrDragResize::TakeComment(XubString& rStr) const +SdrDragResize::SdrDragResize(SdrDragView& rNewView) +: SdrDragMethod(rNewView), + aXFact(1,1), + aYFact(1,1) +{ +} + +void SdrDragResize::TakeSdrDragComment(XubString& rStr) const { ImpTakeDescriptionStr(STR_DragMethResize, rStr); - BOOL bEqual(aXFact == aYFact); + bool bEqual(aXFact == aYFact); Fraction aFact1(1,1); Point aStart(DragStat().GetStart()); Point aRef(DragStat().GetRef1()); @@ -911,8 +1627,8 @@ void SdrDragResize::TakeComment(XubString& rStr) const if(!nYDiv) nYDiv = 1; - BOOL bX(aXFact != aFact1 && Abs(nXDiv) > 1); - BOOL bY(aYFact != aFact1 && Abs(nYDiv) > 1); + bool bX(aXFact != aFact1 && Abs(nXDiv) > 1); + bool bY(aYFact != aFact1 && Abs(nYDiv) > 1); if(bX || bY) { @@ -925,7 +1641,7 @@ void SdrDragResize::TakeComment(XubString& rStr) const if(!bEqual) rStr.AppendAscii("x="); - rView.GetModel()->TakePercentStr(aXFact, aStr); + getSdrDragView().GetModel()->TakePercentStr(aXFact, aStr); rStr += aStr; } @@ -935,167 +1651,288 @@ void SdrDragResize::TakeComment(XubString& rStr) const rStr += sal_Unicode(' '); rStr.AppendAscii("y="); - rView.GetModel()->TakePercentStr(aYFact, aStr); + getSdrDragView().GetModel()->TakePercentStr(aYFact, aStr); rStr += aStr; } rStr += sal_Unicode(')'); } - if(rView.IsDragWithCopy()) + if(getSdrDragView().IsDragWithCopy()) rStr += ImpGetResStr(STR_EditWithCopy); } -FASTBOOL SdrDragResize::Beg() +bool SdrDragResize::BeginSdrDrag() { SdrHdlKind eRefHdl=HDL_MOVE; SdrHdl* pRefHdl=NULL; - switch (GetDragHdlKind()) { + + switch (GetDragHdlKind()) + { case HDL_UPLFT: eRefHdl=HDL_LWRGT; break; - case HDL_UPPER: eRefHdl=HDL_LOWER; DragStat().SetHorFixed(TRUE); break; + case HDL_UPPER: eRefHdl=HDL_LOWER; DragStat().SetHorFixed(true); break; case HDL_UPRGT: eRefHdl=HDL_LWLFT; break; - case HDL_LEFT : eRefHdl=HDL_RIGHT; DragStat().SetVerFixed(TRUE); break; - case HDL_RIGHT: eRefHdl=HDL_LEFT ; DragStat().SetVerFixed(TRUE); break; + case HDL_LEFT : eRefHdl=HDL_RIGHT; DragStat().SetVerFixed(true); break; + case HDL_RIGHT: eRefHdl=HDL_LEFT ; DragStat().SetVerFixed(true); break; case HDL_LWLFT: eRefHdl=HDL_UPRGT; break; - case HDL_LOWER: eRefHdl=HDL_UPPER; DragStat().SetHorFixed(TRUE); break; + case HDL_LOWER: eRefHdl=HDL_UPPER; DragStat().SetHorFixed(true); break; case HDL_LWRGT: eRefHdl=HDL_UPLFT; break; default: break; } - if (eRefHdl!=HDL_MOVE) pRefHdl=GetHdlList().GetHdl(eRefHdl); - if (pRefHdl!=NULL && !rView.IsResizeAtCenter()) { + + if (eRefHdl!=HDL_MOVE) + pRefHdl=GetHdlList().GetHdl(eRefHdl); + + if (pRefHdl!=NULL && !getSdrDragView().IsResizeAtCenter()) + { DragStat().Ref1()=pRefHdl->GetPos(); - } else { + } + else + { SdrHdl* pRef1=GetHdlList().GetHdl(HDL_UPLFT); SdrHdl* pRef2=GetHdlList().GetHdl(HDL_LWRGT); - if (pRef1!=NULL && pRef2!=NULL) { + + if (pRef1!=NULL && pRef2!=NULL) + { DragStat().Ref1()=Rectangle(pRef1->GetPos(),pRef2->GetPos()).Center(); - } else { + } + else + { DragStat().Ref1()=GetMarkedRect().Center(); } } - SetDragPolys(); + Show(); - return TRUE; + + return true; } -void SdrDragResize::MovPoint(Point& rPnt) +basegfx::B2DHomMatrix SdrDragResize::getCurrentTransformation() { - Point aRef(DragStat().Ref1()); - ResizePoint(rPnt,aRef,aXFact,aYFact); + basegfx::B2DHomMatrix aRetval; + + aRetval.translate(-DragStat().Ref1().X(), -DragStat().Ref1().Y()); + aRetval.scale(aXFact, aYFact); + aRetval.translate(DragStat().Ref1().X(), DragStat().Ref1().Y()); + + return aRetval; } -void SdrDragResize::Mov(const Point& rNoSnapPnt) +void SdrDragResize::MoveSdrDrag(const Point& rNoSnapPnt) { Point aPnt(GetSnapPos(rNoSnapPnt)); Point aStart(DragStat().GetStart()); Point aRef(DragStat().GetRef1()); Fraction aMaxFact(0x7FFFFFFF,1); - Rectangle aLR(rView.GetWorkArea()); + Rectangle aLR(getSdrDragView().GetWorkArea()); bool bWorkArea=!aLR.IsEmpty(); bool bDragLimit=IsDragLimit(); - if (bDragLimit || bWorkArea) { + + if (bDragLimit || bWorkArea) + { Rectangle aSR(GetMarkedRect()); - if (bDragLimit) { + + if (bDragLimit) + { Rectangle aR2(GetDragLimitRect()); - if (bWorkArea) aLR.Intersection(aR2); - else aLR=aR2; - } - if (aPnt.X()<aLR.Left()) aPnt.X()=aLR.Left(); - else if (aPnt.X()>aLR.Right()) aPnt.X()=aLR.Right(); - if (aPnt.Y()<aLR.Top()) aPnt.Y()=aLR.Top(); - else if (aPnt.Y()>aLR.Bottom()) aPnt.Y()=aLR.Bottom(); - if (aRef.X()>aSR.Left()) { + + if (bWorkArea) + aLR.Intersection(aR2); + else + aLR=aR2; + } + + if (aPnt.X()<aLR.Left()) + aPnt.X()=aLR.Left(); + else if (aPnt.X()>aLR.Right()) + aPnt.X()=aLR.Right(); + + if (aPnt.Y()<aLR.Top()) + aPnt.Y()=aLR.Top(); + else if (aPnt.Y()>aLR.Bottom()) + aPnt.Y()=aLR.Bottom(); + + if (aRef.X()>aSR.Left()) + { Fraction aMax(aRef.X()-aLR.Left(),aRef.X()-aSR.Left()); - if (aMax<aMaxFact) aMaxFact=aMax; + + if (aMax<aMaxFact) + aMaxFact=aMax; } - if (aRef.X()<aSR.Right()) { + + if (aRef.X()<aSR.Right()) + { Fraction aMax(aLR.Right()-aRef.X(),aSR.Right()-aRef.X()); - if (aMax<aMaxFact) aMaxFact=aMax; + + if (aMax<aMaxFact) + aMaxFact=aMax; } - if (aRef.Y()>aSR.Top()) { + + if (aRef.Y()>aSR.Top()) + { Fraction aMax(aRef.Y()-aLR.Top(),aRef.Y()-aSR.Top()); - if (aMax<aMaxFact) aMaxFact=aMax; + + if (aMax<aMaxFact) + aMaxFact=aMax; } - if (aRef.Y()<aSR.Bottom()) { + + if (aRef.Y()<aSR.Bottom()) + { Fraction aMax(aLR.Bottom()-aRef.Y(),aSR.Bottom()-aRef.Y()); - if (aMax<aMaxFact) aMaxFact=aMax; + + if (aMax<aMaxFact) + aMaxFact=aMax; } } + long nXDiv=aStart.X()-aRef.X(); if (nXDiv==0) nXDiv=1; long nYDiv=aStart.Y()-aRef.Y(); if (nYDiv==0) nYDiv=1; long nXMul=aPnt.X()-aRef.X(); long nYMul=aPnt.Y()-aRef.Y(); - if (nXDiv<0) { nXDiv=-nXDiv; nXMul=-nXMul; } - if (nYDiv<0) { nYDiv=-nYDiv; nYMul=-nYMul; } + + if (nXDiv<0) + { + nXDiv=-nXDiv; + nXMul=-nXMul; + } + + if (nYDiv<0) + { + nYDiv=-nYDiv; + nYMul=-nYMul; + } + bool bXNeg=nXMul<0; if (bXNeg) nXMul=-nXMul; bool bYNeg=nYMul<0; if (bYNeg) nYMul=-nYMul; - bool bOrtho=rView.IsOrtho() || !rView.IsResizeAllowed(FALSE); - if (!DragStat().IsHorFixed() && !DragStat().IsVerFixed()) { - if (Abs(nXDiv)<=1 || Abs(nYDiv)<=1) bOrtho=FALSE; - if (bOrtho) { - if ((Fraction(nXMul,nXDiv)>Fraction(nYMul,nYDiv)) !=rView.IsBigOrtho()) { + bool bOrtho=getSdrDragView().IsOrtho() || !getSdrDragView().IsResizeAllowed(false); + + if (!DragStat().IsHorFixed() && !DragStat().IsVerFixed()) + { + if (Abs(nXDiv)<=1 || Abs(nYDiv)<=1) + bOrtho=false; + + if (bOrtho) + { + if ((Fraction(nXMul,nXDiv)>Fraction(nYMul,nYDiv)) !=getSdrDragView().IsBigOrtho()) + { nXMul=nYMul; nXDiv=nYDiv; - } else { + } + else + { nYMul=nXMul; nYDiv=nXDiv; } } - } else { - if (bOrtho) { - if (DragStat().IsHorFixed()) { bXNeg=FALSE; nXMul=nYMul; nXDiv=nYDiv; } - if (DragStat().IsVerFixed()) { bYNeg=FALSE; nYMul=nXMul; nYDiv=nXDiv; } - } else { - if (DragStat().IsHorFixed()) { bXNeg=FALSE; nXMul=1; nXDiv=1; } - if (DragStat().IsVerFixed()) { bYNeg=FALSE; nYMul=1; nYDiv=1; } + } + else + { + if (bOrtho) + { + if (DragStat().IsHorFixed()) + { + bXNeg=false; + nXMul=nYMul; + nXDiv=nYDiv; + } + + if (DragStat().IsVerFixed()) + { + bYNeg=false; + nYMul=nXMul; + nYDiv=nXDiv; + } + } + else + { + if (DragStat().IsHorFixed()) + { + bXNeg=false; + nXMul=1; + nXDiv=1; + } + + if (DragStat().IsVerFixed()) + { + bYNeg=false; + nYMul=1; + nYDiv=1; + } } } + Fraction aNeuXFact(nXMul,nXDiv); Fraction aNeuYFact(nYMul,nYDiv); - if (bOrtho) { - if (aNeuXFact>aMaxFact) { + + if (bOrtho) + { + if (aNeuXFact>aMaxFact) + { aNeuXFact=aMaxFact; aNeuYFact=aMaxFact; } - if (aNeuYFact>aMaxFact) { + + if (aNeuYFact>aMaxFact) + { aNeuXFact=aMaxFact; aNeuYFact=aMaxFact; } } - if (bXNeg) aNeuXFact=Fraction(-aNeuXFact.GetNumerator(),aNeuXFact.GetDenominator()); - if (bYNeg) aNeuYFact=Fraction(-aNeuYFact.GetNumerator(),aNeuYFact.GetDenominator()); - if (DragStat().CheckMinMoved(aPnt)) { + + if (bXNeg) + aNeuXFact=Fraction(-aNeuXFact.GetNumerator(),aNeuXFact.GetDenominator()); + + if (bYNeg) + aNeuYFact=Fraction(-aNeuYFact.GetNumerator(),aNeuYFact.GetDenominator()); + + if (DragStat().CheckMinMoved(aPnt)) + { if ((!DragStat().IsHorFixed() && aPnt.X()!=DragStat().GetNow().X()) || - (!DragStat().IsVerFixed() && aPnt.Y()!=DragStat().GetNow().Y())) { + (!DragStat().IsVerFixed() && aPnt.Y()!=DragStat().GetNow().Y())) + { Hide(); DragStat().NextMove(aPnt); aXFact=aNeuXFact; aYFact=aNeuYFact; - MovAllPoints(); Show(); } } } -FASTBOOL SdrDragResize::End(FASTBOOL bCopy) +void SdrDragResize::applyCurrentTransformationToSdrObject(SdrObject& rTarget) +{ + rTarget.Resize(DragStat().Ref1(),aXFact,aYFact); +} + +bool SdrDragResize::EndSdrDrag(bool bCopy) { Hide(); - if (IsDraggingPoints()) { - rView.ResizeMarkedPoints(DragStat().Ref1(),aXFact,aYFact,bCopy); - } else if (IsDraggingGluePoints()) { - rView.ResizeMarkedGluePoints(DragStat().Ref1(),aXFact,aYFact,bCopy); - } else { - rView.ResizeMarkedObj(DragStat().Ref1(),aXFact,aYFact,bCopy); + + if (IsDraggingPoints()) + { + getSdrDragView().ResizeMarkedPoints(DragStat().Ref1(),aXFact,aYFact,bCopy); + } + else if (IsDraggingGluePoints()) + { + getSdrDragView().ResizeMarkedGluePoints(DragStat().Ref1(),aXFact,aYFact,bCopy); } - return TRUE; + else + { + getSdrDragView().ResizeMarkedObj(DragStat().Ref1(),aXFact,aYFact,bCopy); + } + + return true; } -Pointer SdrDragResize::GetPointer() const +Pointer SdrDragResize::GetSdrDragPointer() const { const SdrHdl* pHdl=GetDragHdl(); - if (pHdl!=NULL) { + + if (pHdl!=NULL) + { return pHdl->GetPointer(); } + return Pointer(POINTER_MOVE); } @@ -1103,7 +1940,22 @@ Pointer SdrDragResize::GetPointer() const TYPEINIT1(SdrDragRotate,SdrDragMethod); -void SdrDragRotate::TakeComment(XubString& rStr) const +void SdrDragRotate::applyCurrentTransformationToSdrObject(SdrObject& rTarget) +{ + rTarget.Rotate(DragStat().GetRef1(), nWink, sin(nWink*nPi180), cos(nWink*nPi180)); +} + +SdrDragRotate::SdrDragRotate(SdrDragView& rNewView) +: SdrDragMethod(rNewView), + nSin(0.0), + nCos(1.0), + nWink0(0), + nWink(0), + bRight(false) +{ +} + +void SdrDragRotate::TakeSdrDragComment(XubString& rStr) const { ImpTakeDescriptionStr(STR_DragMethRotate, rStr); rStr.AppendAscii(" ("); @@ -1115,53 +1967,77 @@ void SdrDragRotate::TakeComment(XubString& rStr) const nTmpWink -= 36000; } - rView.GetModel()->TakeWinkStr(nTmpWink, aStr); + getSdrDragView().GetModel()->TakeWinkStr(nTmpWink, aStr); rStr += aStr; rStr += sal_Unicode(')'); - if(rView.IsDragWithCopy()) + if(getSdrDragView().IsDragWithCopy()) rStr += ImpGetResStr(STR_EditWithCopy); } -FASTBOOL SdrDragRotate::Beg() +bool SdrDragRotate::BeginSdrDrag() { SdrHdl* pH=GetHdlList().GetHdl(HDL_REF1); - if (pH!=NULL) { - SetDragPolys(); + + if (pH!=NULL) + { Show(); DragStat().Ref1()=pH->GetPos(); nWink0=GetAngle(DragStat().GetStart()-DragStat().GetRef1()); - return TRUE; - } else { - DBG_ERROR("SdrDragRotate::Beg(): Kein Referenzpunkt-Handle gefunden"); - return FALSE; + return true; + } + else + { + DBG_ERROR("SdrDragRotate::BeginSdrDrag(): Kein Referenzpunkt-Handle gefunden"); + return false; } } -void SdrDragRotate::MovPoint(Point& rPnt) +basegfx::B2DHomMatrix SdrDragRotate::getCurrentTransformation() { - RotatePoint(rPnt,DragStat().GetRef1(),nSin,nCos); + basegfx::B2DHomMatrix aRetval; + + aRetval.translate(-DragStat().GetRef1().X(), -DragStat().GetRef1().Y()); + aRetval.rotate(-atan2(nSin, nCos)); + aRetval.translate(DragStat().GetRef1().X(), DragStat().GetRef1().Y()); + + return aRetval; } -void SdrDragRotate::Mov(const Point& rPnt_) +void SdrDragRotate::MoveSdrDrag(const Point& rPnt_) { Point aPnt(rPnt_); - if (DragStat().CheckMinMoved(aPnt)) { + if (DragStat().CheckMinMoved(aPnt)) + { long nNeuWink=NormAngle360(GetAngle(aPnt-DragStat().GetRef1())-nWink0); long nSA=0; - if (rView.IsAngleSnapEnabled()) nSA=rView.GetSnapAngle(); - if (!rView.IsRotateAllowed(FALSE)) nSA=9000; - if (nSA!=0) { // Winkelfang + + if (getSdrDragView().IsAngleSnapEnabled()) + nSA=getSdrDragView().GetSnapAngle(); + + if (!getSdrDragView().IsRotateAllowed(false)) + nSA=9000; + + if (nSA!=0) + { // Winkelfang nNeuWink+=nSA/2; nNeuWink/=nSA; nNeuWink*=nSA; } + nNeuWink=NormAngle180(nNeuWink); - if (nWink!=nNeuWink) { - USHORT nSekt0=GetAngleSector(nWink); - USHORT nSekt1=GetAngleSector(nNeuWink); - if (nSekt0==0 && nSekt1==3) bRight=TRUE; - if (nSekt0==3 && nSekt1==0) bRight=FALSE; + + if (nWink!=nNeuWink) + { + sal_uInt16 nSekt0=GetAngleSector(nWink); + sal_uInt16 nSekt1=GetAngleSector(nNeuWink); + + if (nSekt0==0 && nSekt1==3) + bRight=true; + + if (nSekt0==3 && nSekt1==0) + bRight=false; + nWink=nNeuWink; double a=nWink*nPi180; double nSin1=sin(a); // schonmal berechnen, damit mgl. wenig Zeit @@ -1170,28 +2046,34 @@ void SdrDragRotate::Mov(const Point& rPnt_) nSin=nSin1; nCos=nCos1; DragStat().NextMove(aPnt); - MovAllPoints(); Show(); } } } -FASTBOOL SdrDragRotate::End(FASTBOOL bCopy) +bool SdrDragRotate::EndSdrDrag(bool bCopy) { Hide(); - if (nWink!=0) { - if (IsDraggingPoints()) { - rView.RotateMarkedPoints(DragStat().GetRef1(),nWink,bCopy); - } else if (IsDraggingGluePoints()) { - rView.RotateMarkedGluePoints(DragStat().GetRef1(),nWink,bCopy); - } else { - rView.RotateMarkedObj(DragStat().GetRef1(),nWink,bCopy); + + if (nWink!=0) + { + if (IsDraggingPoints()) + { + getSdrDragView().RotateMarkedPoints(DragStat().GetRef1(),nWink,bCopy); + } + else if (IsDraggingGluePoints()) + { + getSdrDragView().RotateMarkedGluePoints(DragStat().GetRef1(),nWink,bCopy); + } + else + { + getSdrDragView().RotateMarkedObj(DragStat().GetRef1(),nWink,bCopy); } } - return TRUE; + return true; } -Pointer SdrDragRotate::GetPointer() const +Pointer SdrDragRotate::GetSdrDragPointer() const { return Pointer(POINTER_ROTATE); } @@ -1200,7 +2082,20 @@ Pointer SdrDragRotate::GetPointer() const TYPEINIT1(SdrDragShear,SdrDragMethod); -void SdrDragShear::TakeComment(XubString& rStr) const +SdrDragShear::SdrDragShear(SdrDragView& rNewView, bool bSlant1) +: SdrDragMethod(rNewView), + aFact(1,1), + nWink0(0), + nWink(0), + nTan(0.0), + bVertical(false), + bResize(false), + bUpSideDown(false), + bSlant(bSlant1) +{ +} + +void SdrDragShear::TakeSdrDragComment(XubString& rStr) const { ImpTakeDescriptionStr(STR_DragMethShear, rStr); rStr.AppendAscii(" ("); @@ -1214,108 +2109,172 @@ void SdrDragShear::TakeComment(XubString& rStr) const XubString aStr; - rView.GetModel()->TakeWinkStr(nTmpWink, aStr); + getSdrDragView().GetModel()->TakeWinkStr(nTmpWink, aStr); rStr += aStr; rStr += sal_Unicode(')'); - if(rView.IsDragWithCopy()) + if(getSdrDragView().IsDragWithCopy()) rStr += ImpGetResStr(STR_EditWithCopy); } -FASTBOOL SdrDragShear::Beg() +bool SdrDragShear::BeginSdrDrag() { SdrHdlKind eRefHdl=HDL_MOVE; SdrHdl* pRefHdl=NULL; - switch (GetDragHdlKind()) { + + switch (GetDragHdlKind()) + { case HDL_UPPER: eRefHdl=HDL_LOWER; break; case HDL_LOWER: eRefHdl=HDL_UPPER; break; - case HDL_LEFT : eRefHdl=HDL_RIGHT; bVertical=TRUE; break; - case HDL_RIGHT: eRefHdl=HDL_LEFT ; bVertical=TRUE; break; + case HDL_LEFT : eRefHdl=HDL_RIGHT; bVertical=true; break; + case HDL_RIGHT: eRefHdl=HDL_LEFT ; bVertical=true; break; default: break; } - if (eRefHdl!=HDL_MOVE) pRefHdl=GetHdlList().GetHdl(eRefHdl); - if (pRefHdl!=NULL) { + + if (eRefHdl!=HDL_MOVE) + pRefHdl=GetHdlList().GetHdl(eRefHdl); + + if (pRefHdl!=NULL) + { DragStat().Ref1()=pRefHdl->GetPos(); nWink0=GetAngle(DragStat().GetStart()-DragStat().GetRef1()); - } else { - DBG_ERROR("SdrDragShear::Beg(): Kein Referenzpunkt-Handle fuer Shear gefunden"); - return FALSE; } - SetDragPolys(); + else + { + DBG_ERROR("SdrDragShear::BeginSdrDrag(): Kein Referenzpunkt-Handle fuer Shear gefunden"); + return false; + } + Show(); - return TRUE; + return true; } -void SdrDragShear::MovPoint(Point& rPnt) +basegfx::B2DHomMatrix SdrDragShear::getCurrentTransformation() { - Point aRef(DragStat().GetRef1()); - if (bResize) { - if (bVertical) { - ResizePoint(rPnt,aRef,aFact,Fraction(1,1)); - } else { - ResizePoint(rPnt,aRef,Fraction(1,1),aFact); + basegfx::B2DHomMatrix aRetval; + + aRetval.translate(-DragStat().GetRef1().X(), -DragStat().GetRef1().Y()); + + if (bResize) + { + if (bVertical) + { + aRetval.scale(aFact, 1.0); + aRetval.shearY(-nTan); + } + else + { + aRetval.scale(1.0, aFact); + aRetval.shearX(-nTan); } } - ShearPoint(rPnt,aRef,nTan,bVertical); + + aRetval.translate(DragStat().GetRef1().X(), DragStat().GetRef1().Y()); + + return aRetval; } -void SdrDragShear::Mov(const Point& rPnt) +void SdrDragShear::MoveSdrDrag(const Point& rPnt) { - if (DragStat().CheckMinMoved(rPnt)) { - bResize=!rView.IsOrtho(); + if (DragStat().CheckMinMoved(rPnt)) + { + bResize=!getSdrDragView().IsOrtho(); long nSA=0; - if (rView.IsAngleSnapEnabled()) nSA=rView.GetSnapAngle(); + + if (getSdrDragView().IsAngleSnapEnabled()) + nSA=getSdrDragView().GetSnapAngle(); + Point aP0(DragStat().GetStart()); Point aPnt(rPnt); Fraction aNeuFact(1,1); + // Wenn kein Winkelfang, dann ggf. Rasterfang (ausser bei Slant) - if (nSA==0 && !bSlant) aPnt=GetSnapPos(aPnt); - if (!bSlant && !bResize) { // Shear ohne Resize - if (bVertical) aPnt.X()=aP0.X(); else aPnt.Y()=aP0.Y(); + if (nSA==0 && !bSlant) + aPnt=GetSnapPos(aPnt); + + if (!bSlant && !bResize) + { // Shear ohne Resize + if (bVertical) + aPnt.X()=aP0.X(); + else + aPnt.Y()=aP0.Y(); } + Point aRef(DragStat().GetRef1()); Point aDif(aPnt-aRef); long nNeuWink=0; - if (bSlant) { + + if (bSlant) + { nNeuWink=NormAngle180(-(GetAngle(aDif)-nWink0)); - if (bVertical) nNeuWink=NormAngle180(-nNeuWink); - } else { - if (bVertical) nNeuWink=NormAngle180(GetAngle(aDif)); - else nNeuWink=NormAngle180(-(GetAngle(aDif)-9000)); - if (nNeuWink<-9000 || nNeuWink>9000) nNeuWink=NormAngle180(nNeuWink+18000); - if (bResize) { + + if (bVertical) + nNeuWink=NormAngle180(-nNeuWink); + } + else + { + if (bVertical) + nNeuWink=NormAngle180(GetAngle(aDif)); + else + nNeuWink=NormAngle180(-(GetAngle(aDif)-9000)); + + if (nNeuWink<-9000 || nNeuWink>9000) + nNeuWink=NormAngle180(nNeuWink+18000); + + if (bResize) + { Point aPt2(aPnt); - if (nSA!=0) aPt2=GetSnapPos(aPnt); // den also in jedem Falle fangen - if (bVertical) { + + if (nSA!=0) + aPt2=GetSnapPos(aPnt); // den also in jedem Falle fangen + + if (bVertical) + { aNeuFact=Fraction(aPt2.X()-aRef.X(),aP0.X()-aRef.X()); - } else { + } + else + { aNeuFact=Fraction(aPt2.Y()-aRef.Y(),aP0.Y()-aRef.Y()); } } } + bool bNeg=nNeuWink<0; - if (bNeg) nNeuWink=-nNeuWink; - if (nSA!=0) { // Winkelfang + + if (bNeg) + nNeuWink=-nNeuWink; + + if (nSA!=0) + { // Winkelfang nNeuWink+=nSA/2; nNeuWink/=nSA; nNeuWink*=nSA; } + nNeuWink=NormAngle360(nNeuWink); bUpSideDown=nNeuWink>9000 && nNeuWink<27000; - if (bSlant) { // Resize fuer Slant berechnen + + if (bSlant) + { // Resize fuer Slant berechnen // Mit Winkelfang jedoch ohne 89deg Begrenzung long nTmpWink=nNeuWink; if (bUpSideDown) nNeuWink-=18000; if (bNeg) nTmpWink=-nTmpWink; - bResize=TRUE; + bResize=true; double nCos=cos(nTmpWink*nPi180); aNeuFact=nCos; Kuerzen(aFact,10); // 3 Dezimalstellen sollten reichen } - if (nNeuWink>8900) nNeuWink=8900; - if (bNeg) nNeuWink=-nNeuWink; - if (nWink!=nNeuWink || aFact!=aNeuFact) { + + if (nNeuWink>8900) + nNeuWink=8900; + + if (bNeg) + nNeuWink=-nNeuWink; + + if (nWink!=nNeuWink || aFact!=aNeuFact) + { nWink=nNeuWink; aFact=aNeuFact; double a=nWink*nPi180; @@ -1324,72 +2283,138 @@ void SdrDragShear::Mov(const Point& rPnt) Hide(); nTan=nTan1; DragStat().NextMove(rPnt); - MovAllPoints(); Show(); } } } -FASTBOOL SdrDragShear::End(FASTBOOL bCopy) +void SdrDragShear::applyCurrentTransformationToSdrObject(SdrObject& rTarget) +{ + if (bResize) + { + if (bVertical) + { + rTarget.Resize(DragStat().GetRef1(),aFact,Fraction(1,1)); + } + else + { + rTarget.Resize(DragStat().GetRef1(),Fraction(1,1),aFact); + } + } + + if (nWink!=0) + { + rTarget.Shear(DragStat().GetRef1(),nWink,tan(nWink*nPi180),bVertical); + } +} + +bool SdrDragShear::EndSdrDrag(bool bCopy) { Hide(); - if (bResize && aFact==Fraction(1,1)) bResize=FALSE; - if (nWink!=0 || bResize) { - if (nWink!=0 && bResize) { + + if (bResize && aFact==Fraction(1,1)) + bResize=false; + + if (nWink!=0 || bResize) + { + if (nWink!=0 && bResize) + { XubString aStr; ImpTakeDescriptionStr(STR_EditShear,aStr); - if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy); - rView.BegUndo(aStr); + + if (bCopy) + aStr+=ImpGetResStr(STR_EditWithCopy); + + getSdrDragView().BegUndo(aStr); } - if (bResize) { - if (bVertical) { - rView.ResizeMarkedObj(DragStat().GetRef1(),aFact,Fraction(1,1),bCopy); - } else { - rView.ResizeMarkedObj(DragStat().GetRef1(),Fraction(1,1),aFact,bCopy); + + if (bResize) + { + if (bVertical) + { + getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),aFact,Fraction(1,1),bCopy); } - bCopy=FALSE; + else + { + getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),Fraction(1,1),aFact,bCopy); + } + + bCopy=false; } - if (nWink!=0) { - rView.ShearMarkedObj(DragStat().GetRef1(),nWink,bVertical,bCopy); + + if (nWink!=0) + { + getSdrDragView().ShearMarkedObj(DragStat().GetRef1(),nWink,bVertical,bCopy); } - if (nWink!=0 && bResize) rView.EndUndo(); - return TRUE; + + if (nWink!=0 && bResize) + getSdrDragView().EndUndo(); + + return true; } - return FALSE; + + return false; } -Pointer SdrDragShear::GetPointer() const +Pointer SdrDragShear::GetSdrDragPointer() const { - if (bVertical) return Pointer(POINTER_VSHEAR); - else return Pointer(POINTER_HSHEAR); + if (bVertical) + return Pointer(POINTER_VSHEAR); + else + return Pointer(POINTER_HSHEAR); } //////////////////////////////////////////////////////////////////////////////////////////////////// TYPEINIT1(SdrDragMirror,SdrDragMethod); -FASTBOOL SdrDragMirror::ImpCheckSide(const Point& rPnt) const +void SdrDragMirror::applyCurrentTransformationToSdrObject(SdrObject& rTarget) +{ + if(bMirrored) + { + rTarget.Mirror(DragStat().GetRef1(), DragStat().GetRef2()); + } +} + +SdrDragMirror::SdrDragMirror(SdrDragView& rNewView) +: SdrDragMethod(rNewView), + nWink(0), + bMirrored(false), + bSide0(false) +{ +} + +bool SdrDragMirror::ImpCheckSide(const Point& rPnt) const { long nWink1=GetAngle(rPnt-DragStat().GetRef1()); nWink1-=nWink; nWink1=NormAngle360(nWink1); + return nWink1<18000; } -void SdrDragMirror::TakeComment(XubString& rStr) const +void SdrDragMirror::TakeSdrDragComment(XubString& rStr) const { - if (aDif.X()==0) ImpTakeDescriptionStr(STR_DragMethMirrorHori,rStr); - else if (aDif.Y()==0) ImpTakeDescriptionStr(STR_DragMethMirrorVert,rStr); - else if (Abs(aDif.X())==Abs(aDif.Y())) ImpTakeDescriptionStr(STR_DragMethMirrorDiag,rStr); - else ImpTakeDescriptionStr(STR_DragMethMirrorFree,rStr); - if (rView.IsDragWithCopy()) rStr+=ImpGetResStr(STR_EditWithCopy); + if (aDif.X()==0) + ImpTakeDescriptionStr(STR_DragMethMirrorHori,rStr); + else if (aDif.Y()==0) + ImpTakeDescriptionStr(STR_DragMethMirrorVert,rStr); + else if (Abs(aDif.X())==Abs(aDif.Y())) + ImpTakeDescriptionStr(STR_DragMethMirrorDiag,rStr); + else + ImpTakeDescriptionStr(STR_DragMethMirrorFree,rStr); + + if (getSdrDragView().IsDragWithCopy()) + rStr+=ImpGetResStr(STR_EditWithCopy); } -FASTBOOL SdrDragMirror::Beg() +bool SdrDragMirror::BeginSdrDrag() { SdrHdl* pH1=GetHdlList().GetHdl(HDL_REF1); SdrHdl* pH2=GetHdlList().GetHdl(HDL_REF2); - if (pH1!=NULL && pH2!=NULL) { + + if (pH1!=NULL && pH2!=NULL) + { DragStat().Ref1()=pH1->GetPos(); DragStat().Ref2()=pH2->GetPos(); Ref1()=pH1->GetPos(); @@ -1398,52 +2423,74 @@ FASTBOOL SdrDragMirror::Beg() bool b90=(aDif.X()==0) || aDif.Y()==0; bool b45=b90 || (Abs(aDif.X())==Abs(aDif.Y())); nWink=NormAngle360(GetAngle(aDif)); - if (!rView.IsMirrorAllowed(FALSE,FALSE) && !b45) return FALSE; // freier Achsenwinkel nicht erlaubt - if (!rView.IsMirrorAllowed(TRUE,FALSE) && !b90) return FALSE; // 45deg auch nicht erlaubt + + if (!getSdrDragView().IsMirrorAllowed(false,false) && !b45) + return false; // freier Achsenwinkel nicht erlaubt + + if (!getSdrDragView().IsMirrorAllowed(true,false) && !b90) + return false; // 45deg auch nicht erlaubt + bSide0=ImpCheckSide(DragStat().GetStart()); - SetDragPolys(); Show(); - return TRUE; - } else { - DBG_ERROR("SdrDragMirror::Beg(): Spiegelachse nicht gefunden"); - return FALSE; + return true; + } + else + { + DBG_ERROR("SdrDragMirror::BeginSdrDrag(): Spiegelachse nicht gefunden"); + return false; } } -void SdrDragMirror::MovPoint(Point& rPnt) +basegfx::B2DHomMatrix SdrDragMirror::getCurrentTransformation() { - if (bMirrored) { - Point aRef1(DragStat().GetRef1()); - Point aRef2(DragStat().GetRef2()); - MirrorPoint(rPnt,aRef1,aRef2); + basegfx::B2DHomMatrix aRetval; + + if (bMirrored) + { + const double fDeltaX(DragStat().GetRef2().X() - DragStat().GetRef1().X()); + const double fDeltaY(DragStat().GetRef2().Y() - DragStat().GetRef1().Y()); + const double fRotation(atan2(fDeltaY, fDeltaX)); + + aRetval.translate(-DragStat().GetRef1().X(), -DragStat().GetRef1().Y()); + aRetval.rotate(-fRotation); + aRetval.scale(1.0, -1.0); + aRetval.rotate(fRotation); + aRetval.translate(DragStat().GetRef1().X(), DragStat().GetRef1().Y()); } + + return aRetval; } -void SdrDragMirror::Mov(const Point& rPnt) +void SdrDragMirror::MoveSdrDrag(const Point& rPnt) { - if (DragStat().CheckMinMoved(rPnt)) { + if (DragStat().CheckMinMoved(rPnt)) + { bool bNeuSide=ImpCheckSide(rPnt); bool bNeuMirr=bSide0!=bNeuSide; - if (bMirrored!=bNeuMirr) { + + if (bMirrored!=bNeuMirr) + { Hide(); bMirrored=bNeuMirr; DragStat().NextMove(rPnt); - MovAllPoints(); Show(); } } } -FASTBOOL SdrDragMirror::End(FASTBOOL bCopy) +bool SdrDragMirror::EndSdrDrag(bool bCopy) { Hide(); - if (bMirrored) { - rView.MirrorMarkedObj(DragStat().GetRef1(),DragStat().GetRef2(),bCopy); + + if (bMirrored) + { + getSdrDragView().MirrorMarkedObj(DragStat().GetRef1(),DragStat().GetRef2(),bCopy); } - return TRUE; + + return true; } -Pointer SdrDragMirror::GetPointer() const +Pointer SdrDragMirror::GetSdrDragPointer() const { return Pointer(POINTER_MIRROR); } @@ -1452,14 +2499,14 @@ Pointer SdrDragMirror::GetPointer() const TYPEINIT1(SdrDragGradient, SdrDragMethod); -SdrDragGradient::SdrDragGradient(SdrDragView& rNewView, BOOL bGrad) +SdrDragGradient::SdrDragGradient(SdrDragView& rNewView, bool bGrad) : SdrDragMethod(rNewView), pIAOHandle(NULL), bIsGradient(bGrad) { } -void SdrDragGradient::TakeComment(XubString& rStr) const +void SdrDragGradient::TakeSdrDragComment(XubString& rStr) const { if(IsGradient()) ImpTakeDescriptionStr(STR_DragMethGradient, rStr); @@ -1467,11 +2514,12 @@ void SdrDragGradient::TakeComment(XubString& rStr) const ImpTakeDescriptionStr(STR_DragMethTransparence, rStr); } -FASTBOOL SdrDragGradient::Beg() +bool SdrDragGradient::BeginSdrDrag() { - bool bRetval(FALSE); + bool bRetval(false); pIAOHandle = (SdrHdlGradient*)GetHdlList().GetHdl(IsGradient() ? HDL_GRAD : HDL_TRNS); + if(pIAOHandle) { // save old values @@ -1479,12 +2527,12 @@ FASTBOOL SdrDragGradient::Beg() DragStat().Ref2() = pIAOHandle->Get2ndPos(); // what was hit? - BOOL bHit(FALSE); + bool bHit(false); SdrHdlColor* pColHdl = pIAOHandle->GetColorHdl1(); // init handling flags - pIAOHandle->SetMoveSingleHandle(FALSE); - pIAOHandle->SetMoveFirstHandle(FALSE); + pIAOHandle->SetMoveSingleHandle(false); + pIAOHandle->SetMoveFirstHandle(false); // test first color handle if(pColHdl) @@ -1493,22 +2541,23 @@ FASTBOOL SdrDragGradient::Beg() if(pColHdl->getOverlayObjectList().isHit(aPosition)) { - bHit = TRUE; - pIAOHandle->SetMoveSingleHandle(TRUE); - pIAOHandle->SetMoveFirstHandle(TRUE); + bHit = true; + pIAOHandle->SetMoveSingleHandle(true); + pIAOHandle->SetMoveFirstHandle(true); } } // test second color handle pColHdl = pIAOHandle->GetColorHdl2(); + if(!bHit && pColHdl) { basegfx::B2DPoint aPosition(DragStat().GetStart().X(), DragStat().GetStart().Y()); if(pColHdl->getOverlayObjectList().isHit(aPosition)) { - bHit = TRUE; - pIAOHandle->SetMoveSingleHandle(TRUE); + bHit = true; + pIAOHandle->SetMoveSingleHandle(true); } } @@ -1519,7 +2568,7 @@ FASTBOOL SdrDragGradient::Beg() if(pIAOHandle->getOverlayObjectList().isHit(aPosition)) { - bHit = TRUE; + bHit = true; } } @@ -1528,13 +2577,13 @@ FASTBOOL SdrDragGradient::Beg() } else { - DBG_ERROR("SdrDragGradient::Beg(): IAOGradient nicht gefunden"); + DBG_ERROR("SdrDragGradient::BeginSdrDrag(): IAOGradient nicht gefunden"); } return bRetval; } -void SdrDragGradient::Mov(const Point& rPnt) +void SdrDragGradient::MoveSdrDrag(const Point& rPnt) { if(pIAOHandle && DragStat().CheckMinMoved(rPnt)) { @@ -1562,44 +2611,48 @@ void SdrDragGradient::Mov(const Point& rPnt) { pIAOHandle->SetPos(DragStat().Ref1() + aMoveDiff); pIAOHandle->Set2ndPos(DragStat().Ref2() + aMoveDiff); + if(pIAOHandle->GetColorHdl1()) pIAOHandle->GetColorHdl1()->SetPos(DragStat().Ref1() + aMoveDiff); + if(pIAOHandle->GetColorHdl2()) pIAOHandle->GetColorHdl2()->SetPos(DragStat().Ref2() + aMoveDiff); } // new state - pIAOHandle->FromIAOToItem(rView.GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(), FALSE, FALSE); + pIAOHandle->FromIAOToItem(getSdrDragView().GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(), false, false); } } -FASTBOOL SdrDragGradient::End(FASTBOOL /*bCopy*/) +bool SdrDragGradient::EndSdrDrag(bool /*bCopy*/) { // here the result is clear, do something with the values Ref1() = pIAOHandle->GetPos(); Ref2() = pIAOHandle->Get2ndPos(); // new state - pIAOHandle->FromIAOToItem(rView.GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(), TRUE, TRUE); + pIAOHandle->FromIAOToItem(getSdrDragView().GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(), true, true); - return TRUE; + return true; } -void SdrDragGradient::Brk() +void SdrDragGradient::CancelSdrDrag() { // restore old values pIAOHandle->SetPos(DragStat().Ref1()); pIAOHandle->Set2ndPos(DragStat().Ref2()); + if(pIAOHandle->GetColorHdl1()) pIAOHandle->GetColorHdl1()->SetPos(DragStat().Ref1()); + if(pIAOHandle->GetColorHdl2()) pIAOHandle->GetColorHdl2()->SetPos(DragStat().Ref2()); // new state - pIAOHandle->FromIAOToItem(rView.GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(), TRUE, FALSE); + pIAOHandle->FromIAOToItem(getSdrDragView().GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(), true, false); } -Pointer SdrDragGradient::GetPointer() const +Pointer SdrDragGradient::GetSdrDragPointer() const { return Pointer(POINTER_REFHAND); } @@ -1608,7 +2661,30 @@ Pointer SdrDragGradient::GetPointer() const TYPEINIT1(SdrDragCrook,SdrDragMethod); -void SdrDragCrook::TakeComment(XubString& rStr) const +SdrDragCrook::SdrDragCrook(SdrDragView& rNewView) +: SdrDragMethod(rNewView), + aFact(1,1), + bContortionAllowed(false), + bNoContortionAllowed(false), + bContortion(false), + bResizeAllowed(false), + bResize(false), + bRotateAllowed(false), + bRotate(false), + bVertical(false), + bValid(false), + bLft(false), + bRgt(false), + bUpr(false), + bLwr(false), + bAtCenter(false), + nWink(0), + nMarkSize(0), + eMode(SDRCROOK_ROTATE) +{ +} + +void SdrDragCrook::TakeSdrDragComment(XubString& rStr) const { ImpTakeDescriptionStr(!bContortion ? STR_DragMethCrook : STR_DragMethCrookContortion, rStr); @@ -1623,231 +2699,290 @@ void SdrDragCrook::TakeComment(XubString& rStr) const nVal *= 2; nVal = Abs(nVal); - rView.GetModel()->TakeWinkStr(nVal, aStr); + getSdrDragView().GetModel()->TakeWinkStr(nVal, aStr); rStr += aStr; rStr += sal_Unicode(')'); } - if(rView.IsDragWithCopy()) + if(getSdrDragView().IsDragWithCopy()) rStr += ImpGetResStr(STR_EditWithCopy); } -// #96920# -basegfx::B2DPolyPolygon ImplCreateDragRaster(const Rectangle& rRect, sal_uInt32 nHorDiv, sal_uInt32 nVerDiv) +// #96920# These defines parametrise the created raster +// for interactions +#define DRAG_CROOK_RASTER_MINIMUM (4) +#define DRAG_CROOK_RASTER_MAXIMUM (15) +#define DRAG_CROOK_RASTER_DISTANCE (30) + +basegfx::B2DPolyPolygon impCreateDragRaster(SdrPageView& rPageView, const Rectangle& rMarkRect) { basegfx::B2DPolyPolygon aRetval; - const double fXLen(rRect.GetWidth() / (double)nHorDiv); - const double fYLen(rRect.GetHeight() / (double)nVerDiv); - double fYPos(rRect.Top()); - sal_uInt32 a, b; - for(a = 0L; a <= nVerDiv; a++) + if(rPageView.PageWindowCount()) { - // hor lines - for(b = 0L; b < nHorDiv; b++) + OutputDevice& rOut = (rPageView.GetPageWindow(0)->GetPaintWindow().GetOutputDevice()); + Rectangle aPixelSize = rOut.LogicToPixel(rMarkRect); + sal_uInt32 nHorDiv(aPixelSize.GetWidth() / DRAG_CROOK_RASTER_DISTANCE); + sal_uInt32 nVerDiv(aPixelSize.GetHeight() / DRAG_CROOK_RASTER_DISTANCE); + + if(nHorDiv > DRAG_CROOK_RASTER_MAXIMUM) + nHorDiv = DRAG_CROOK_RASTER_MAXIMUM; + if(nHorDiv < DRAG_CROOK_RASTER_MINIMUM) + nHorDiv = DRAG_CROOK_RASTER_MINIMUM; + + if(nVerDiv > DRAG_CROOK_RASTER_MAXIMUM) + nVerDiv = DRAG_CROOK_RASTER_MAXIMUM; + if(nVerDiv < DRAG_CROOK_RASTER_MINIMUM) + nVerDiv = DRAG_CROOK_RASTER_MINIMUM; + + const double fXLen(rMarkRect.GetWidth() / (double)nHorDiv); + const double fYLen(rMarkRect.GetHeight() / (double)nVerDiv); + double fYPos(rMarkRect.Top()); + sal_uInt32 a, b; + + for(a = 0; a <= nVerDiv; a++) { - basegfx::B2DPolygon aHorLineSegment; + // hor lines + for(b = 0; b < nHorDiv; b++) + { + basegfx::B2DPolygon aHorLineSegment; + + const double fNewX(rMarkRect.Left() + (b * fXLen)); + aHorLineSegment.append(basegfx::B2DPoint(fNewX, fYPos)); + aHorLineSegment.appendBezierSegment( + basegfx::B2DPoint(fNewX + (fXLen * (1.0 / 3.0)), fYPos), + basegfx::B2DPoint(fNewX + (fXLen * (2.0 / 3.0)), fYPos), + basegfx::B2DPoint(fNewX + fXLen, fYPos)); + aRetval.append(aHorLineSegment); + } - const double fNewX(rRect.Left() + (b * fXLen)); - aHorLineSegment.append(basegfx::B2DPoint(fNewX, fYPos)); - aHorLineSegment.appendBezierSegment( - basegfx::B2DPoint(fNewX + (fXLen * (1.0 / 3.0)), fYPos), - basegfx::B2DPoint(fNewX + (fXLen * (2.0 / 3.0)), fYPos), - basegfx::B2DPoint(fNewX + fXLen, fYPos)); - aRetval.append(aHorLineSegment); + // increments + fYPos += fYLen; } - // increments - fYPos += fYLen; - } - - double fXPos(rRect.Left()); + double fXPos(rMarkRect.Left()); - for(a = 0; a <= nHorDiv; a++) - { - // ver lines - for(b = 0; b < nVerDiv; b++) + for(a = 0; a <= nHorDiv; a++) { - basegfx::B2DPolygon aVerLineSegment; + // ver lines + for(b = 0; b < nVerDiv; b++) + { + basegfx::B2DPolygon aVerLineSegment; + + const double fNewY(rMarkRect.Top() + (b * fYLen)); + aVerLineSegment.append(basegfx::B2DPoint(fXPos, fNewY)); + aVerLineSegment.appendBezierSegment( + basegfx::B2DPoint(fXPos, fNewY + (fYLen * (1.0 / 3.0))), + basegfx::B2DPoint(fXPos, fNewY + (fYLen * (2.0 / 3.0))), + basegfx::B2DPoint(fXPos, fNewY + fYLen)); + aRetval.append(aVerLineSegment); + } - const double fNewY(rRect.Top() + (b * fYLen)); - aVerLineSegment.append(basegfx::B2DPoint(fXPos, fNewY)); - aVerLineSegment.appendBezierSegment( - basegfx::B2DPoint(fXPos, fNewY + (fYLen * (1.0 / 3.0))), - basegfx::B2DPoint(fXPos, fNewY + (fYLen * (2.0 / 3.0))), - basegfx::B2DPoint(fXPos, fNewY + fYLen)); - aRetval.append(aVerLineSegment); + // increments + fXPos += fXLen; } - - // increments - fXPos += fXLen; } return aRetval; } -// #96920# These defines parametrise the created raster -// for interactions -#define DRAG_CROOK_RASTER_MINIMUM (4) -#define DRAG_CROOK_RASTER_MAXIMUM (15) -#define DRAG_CROOK_RASTER_DISTANCE (30) +void SdrDragCrook::createSdrDragEntries() +{ + // Add extended frame raster first, so it will be behind objects + if(getSdrDragView().GetSdrPageView()) + { + const basegfx::B2DPolyPolygon aDragRaster(impCreateDragRaster(*getSdrDragView().GetSdrPageView(), GetMarkedRect())); + + if(aDragRaster.count()) + { + addSdrDragEntry(new SdrDragEntryPolyPolygon(aDragRaster)); + } + } -FASTBOOL SdrDragCrook::Beg() + // call parent + SdrDragMethod::createSdrDragEntries(); +} + +bool SdrDragCrook::BeginSdrDrag() { - bContortionAllowed=rView.IsCrookAllowed(FALSE); - bNoContortionAllowed=rView.IsCrookAllowed(TRUE); - bResizeAllowed=rView.IsResizeAllowed(FALSE); - bRotateAllowed=rView.IsRotateAllowed(FALSE); - if (bContortionAllowed || bNoContortionAllowed) { + bContortionAllowed=getSdrDragView().IsCrookAllowed(false); + bNoContortionAllowed=getSdrDragView().IsCrookAllowed(true); + bResizeAllowed=getSdrDragView().IsResizeAllowed(false); + bRotateAllowed=getSdrDragView().IsRotateAllowed(false); + + if (bContortionAllowed || bNoContortionAllowed) + { bVertical=(GetDragHdlKind()==HDL_LOWER || GetDragHdlKind()==HDL_UPPER); aMarkRect=GetMarkedRect(); aMarkCenter=aMarkRect.Center(); nMarkSize=bVertical ? (aMarkRect.GetHeight()-1) : (aMarkRect.GetWidth()-1); aCenter=aMarkCenter; aStart=DragStat().GetStart(); - SetDragPolys(); - - // #96920# Add extended XOR frame raster - SdrPageView* pPV = rView.GetSdrPageView(); - - if(pPV) - { - if(pPV->PageWindowCount()) - { - OutputDevice& rOut = (pPV->GetPageWindow(0)->GetPaintWindow().GetOutputDevice()); - Rectangle aPixelSize = rOut.LogicToPixel(aMarkRect); - - sal_uInt32 nHorDiv(aPixelSize.GetWidth() / DRAG_CROOK_RASTER_DISTANCE); - sal_uInt32 nVerDiv(aPixelSize.GetHeight() / DRAG_CROOK_RASTER_DISTANCE); - - if(nHorDiv > DRAG_CROOK_RASTER_MAXIMUM) - nHorDiv = DRAG_CROOK_RASTER_MAXIMUM; - if(nHorDiv < DRAG_CROOK_RASTER_MINIMUM) - nHorDiv = DRAG_CROOK_RASTER_MINIMUM; - - if(nVerDiv > DRAG_CROOK_RASTER_MAXIMUM) - nVerDiv = DRAG_CROOK_RASTER_MAXIMUM; - if(nVerDiv < DRAG_CROOK_RASTER_MINIMUM) - nVerDiv = DRAG_CROOK_RASTER_MINIMUM; - - basegfx::B2DPolyPolygon aPolyPolygon(pPV->getDragPoly0()); - aPolyPolygon.append(ImplCreateDragRaster(aMarkRect, nHorDiv, nVerDiv)); - pPV->setDragPoly0(aPolyPolygon); - pPV->setDragPoly(pPV->getDragPoly0()); - } - } - Show(); - return TRUE; - } else { - return FALSE; + return true; + } + else + { + return false; } } -void SdrDragCrook::MovAllPoints() +void SdrDragCrook::_MovAllPoints(basegfx::B2DPolyPolygon& rTarget) { - SdrPageView* pPV = rView.GetSdrPageView(); + SdrPageView* pPV = getSdrDragView().GetSdrPageView(); if(pPV) { - XPolyPolygon aTempPolyPoly(pPV->getDragPoly0()); + XPolyPolygon aTempPolyPoly(rTarget); if (pPV->HasMarkedObjPageView()) { - USHORT nPolyAnz=aTempPolyPoly.Count(); - if (!bContortion && !rView.IsNoDragXorPolys()) { - USHORT n1st=0,nLast=0; + sal_uInt16 nPolyAnz=aTempPolyPoly.Count(); + + if (!bContortion && !getSdrDragView().IsNoDragXorPolys()) + { + sal_uInt16 n1st=0,nLast=0; Point aC(aCenter); - while (n1st<nPolyAnz) { + + while (n1st<nPolyAnz) + { nLast=n1st; while (nLast<nPolyAnz && aTempPolyPoly[nLast].GetPointCount()!=0) nLast++; Rectangle aBound(aTempPolyPoly[n1st].GetBoundRect()); - USHORT i; - for (i=n1st+1; i<nLast; i++) { + sal_uInt16 i; + + for (i=n1st+1; i<nLast; i++) + { aBound.Union(aTempPolyPoly[n1st].GetBoundRect()); } + Point aCtr0(aBound.Center()); Point aCtr1(aCtr0); - if (bResize) { + + if (bResize) + { Fraction aFact1(1,1); - if (bVertical) { + + if (bVertical) + { ResizePoint(aCtr1,aC,aFact1,aFact); - } else { + } + else + { ResizePoint(aCtr1,aC,aFact,aFact1); } } - bool bRotOk=FALSE; + + bool bRotOk=false; double nSin=0,nCos=0; - if (aRad.X()!=0 && aRad.Y()!=0) { + + if (aRad.X()!=0 && aRad.Y()!=0) + { bRotOk=bRotate; - switch (eMode) { + + switch (eMode) + { case SDRCROOK_ROTATE : CrookRotateXPoint (aCtr1,NULL,NULL,aC,aRad,nSin,nCos,bVertical); break; case SDRCROOK_SLANT : CrookSlantXPoint (aCtr1,NULL,NULL,aC,aRad,nSin,nCos,bVertical); break; case SDRCROOK_STRETCH: CrookStretchXPoint(aCtr1,NULL,NULL,aC,aRad,nSin,nCos,bVertical,aMarkRect); break; } // switch } + aCtr1-=aCtr0; - for (i=n1st; i<nLast; i++) { - if (bRotOk) { + + for (i=n1st; i<nLast; i++) + { + if (bRotOk) + { RotateXPoly(aTempPolyPoly[i],aCtr0,nSin,nCos); } + aTempPolyPoly[i].Move(aCtr1.X(),aCtr1.Y()); } + n1st=nLast+1; } - } else { - USHORT i,j; - for (j=0; j<nPolyAnz; j++) { + } + else + { + sal_uInt16 i,j; + + for (j=0; j<nPolyAnz; j++) + { XPolygon& aPol=aTempPolyPoly[j]; - USHORT nPtAnz=aPol.GetPointCount(); + sal_uInt16 nPtAnz=aPol.GetPointCount(); i=0; - while (i<nPtAnz) { + + while (i<nPtAnz) + { Point* pPnt=&aPol[i]; Point* pC1=NULL; Point* pC2=NULL; - if (i+1<nPtAnz && aPol.IsControl(i)) { // Kontrollpunkt links + + if (i+1<nPtAnz && aPol.IsControl(i)) + { // Kontrollpunkt links pC1=pPnt; i++; pPnt=&aPol[i]; } + i++; - if (i<nPtAnz && aPol.IsControl(i)) { // Kontrollpunkt rechts + + if (i<nPtAnz && aPol.IsControl(i)) + { // Kontrollpunkt rechts pC2=&aPol[i]; i++; } - MovCrookPoint(*pPnt,pC1,pC2); + + _MovCrookPoint(*pPnt,pC1,pC2); } } } } - pPV->setDragPoly(aTempPolyPoly.getB2DPolyPolygon()); + rTarget = aTempPolyPoly.getB2DPolyPolygon(); } } -void SdrDragCrook::MovCrookPoint(Point& rPnt, Point* pC1, Point* pC2) +void SdrDragCrook::_MovCrookPoint(Point& rPnt, Point* pC1, Point* pC2) { - //FASTBOOL bSlant=eMode==SDRCROOK_SLANT; - //FASTBOOL bStretch=eMode==SDRCROOK_STRETCH; bool bVert=bVertical; bool bC1=pC1!=NULL; bool bC2=pC2!=NULL; Point aC(aCenter); - if (bResize) { + + if (bResize) + { Fraction aFact1(1,1); - if (bVert) { + + if (bVert) + { ResizePoint(rPnt,aC,aFact1,aFact); - if (bC1) ResizePoint(*pC1,aC,aFact1,aFact); - if (bC2) ResizePoint(*pC2,aC,aFact1,aFact); - } else { + + if (bC1) + ResizePoint(*pC1,aC,aFact1,aFact); + + if (bC2) + ResizePoint(*pC2,aC,aFact1,aFact); + } + else + { ResizePoint(rPnt,aC,aFact,aFact1); - if (bC1) ResizePoint(*pC1,aC,aFact,aFact1); - if (bC2) ResizePoint(*pC2,aC,aFact,aFact1); + + if (bC1) + ResizePoint(*pC1,aC,aFact,aFact1); + + if (bC2) + ResizePoint(*pC2,aC,aFact,aFact1); } } - if (aRad.X()!=0 && aRad.Y()!=0) { + + if (aRad.X()!=0 && aRad.Y()!=0) + { double nSin,nCos; - switch (eMode) { + + switch (eMode) + { case SDRCROOK_ROTATE : CrookRotateXPoint (rPnt,pC1,pC2,aC,aRad,nSin,nCos,bVert); break; case SDRCROOK_SLANT : CrookSlantXPoint (rPnt,pC1,pC2,aC,aRad,nSin,nCos,bVert); break; case SDRCROOK_STRETCH: CrookStretchXPoint(rPnt,pC1,pC2,aC,aRad,nSin,nCos,bVert,aMarkRect); break; @@ -1855,77 +2990,115 @@ void SdrDragCrook::MovCrookPoint(Point& rPnt, Point* pC1, Point* pC2) } } -void SdrDragCrook::Mov(const Point& rPnt) +void SdrDragCrook::MoveSdrDrag(const Point& rPnt) { - if (DragStat().CheckMinMoved(rPnt)) { + if (DragStat().CheckMinMoved(rPnt)) + { Point aPnt(rPnt); - bool bNeuMoveOnly=rView.IsMoveOnlyDragging(); - bAtCenter=FALSE; - SdrCrookMode eNeuMode=rView.GetCrookMode(); - bool bNeuContortion=!bNeuMoveOnly && ((bContortionAllowed && !rView.IsCrookNoContortion()) || !bNoContortionAllowed); - bResize=!rView.IsOrtho() && bResizeAllowed && !bNeuMoveOnly; + bool bNeuMoveOnly=getSdrDragView().IsMoveOnlyDragging(); + bAtCenter=false; + SdrCrookMode eNeuMode=getSdrDragView().GetCrookMode(); + bool bNeuContortion=!bNeuMoveOnly && ((bContortionAllowed && !getSdrDragView().IsCrookNoContortion()) || !bNoContortionAllowed); + bResize=!getSdrDragView().IsOrtho() && bResizeAllowed && !bNeuMoveOnly; bool bNeuRotate=bRotateAllowed && !bNeuContortion && !bNeuMoveOnly && eNeuMode==SDRCROOK_ROTATE; long nSA=0; - if (nSA==0) aPnt=GetSnapPos(aPnt); + + if (nSA==0) + aPnt=GetSnapPos(aPnt); + Point aNeuCenter(aMarkCenter.X(),aStart.Y()); - if (bVertical) { aNeuCenter.X()=aStart.X(); aNeuCenter.Y()=aMarkCenter.Y(); } - if (!rView.IsCrookAtCenter()) { - switch (GetDragHdlKind()) { - case HDL_UPLFT: aNeuCenter.X()=aMarkRect.Right(); bLft=TRUE; break; - case HDL_UPPER: aNeuCenter.Y()=aMarkRect.Bottom(); bUpr=TRUE; break; - case HDL_UPRGT: aNeuCenter.X()=aMarkRect.Left(); bRgt=TRUE; break; - case HDL_LEFT : aNeuCenter.X()=aMarkRect.Right(); bLft=TRUE; break; - case HDL_RIGHT: aNeuCenter.X()=aMarkRect.Left(); bRgt=TRUE; break; - case HDL_LWLFT: aNeuCenter.X()=aMarkRect.Right(); bLft=TRUE; break; - case HDL_LOWER: aNeuCenter.Y()=aMarkRect.Top(); bLwr=TRUE; break; - case HDL_LWRGT: aNeuCenter.X()=aMarkRect.Left(); bRgt=TRUE; break; - default: bAtCenter=TRUE; - } - } else bAtCenter=TRUE; + + if (bVertical) + { + aNeuCenter.X()=aStart.X(); + aNeuCenter.Y()=aMarkCenter.Y(); + } + + if (!getSdrDragView().IsCrookAtCenter()) + { + switch (GetDragHdlKind()) + { + case HDL_UPLFT: aNeuCenter.X()=aMarkRect.Right(); bLft=true; break; + case HDL_UPPER: aNeuCenter.Y()=aMarkRect.Bottom(); bUpr=true; break; + case HDL_UPRGT: aNeuCenter.X()=aMarkRect.Left(); bRgt=true; break; + case HDL_LEFT : aNeuCenter.X()=aMarkRect.Right(); bLft=true; break; + case HDL_RIGHT: aNeuCenter.X()=aMarkRect.Left(); bRgt=true; break; + case HDL_LWLFT: aNeuCenter.X()=aMarkRect.Right(); bLft=true; break; + case HDL_LOWER: aNeuCenter.Y()=aMarkRect.Top(); bLwr=true; break; + case HDL_LWRGT: aNeuCenter.X()=aMarkRect.Left(); bRgt=true; break; + default: bAtCenter=true; + } + } + else + bAtCenter=true; + Fraction aNeuFact(1,1); long dx1=aPnt.X()-aNeuCenter.X(); long dy1=aPnt.Y()-aNeuCenter.Y(); bValid=bVertical ? dx1!=0 : dy1!=0; - if (bValid) { - if (bVertical) bValid=Abs(dx1)*100>Abs(dy1); - else bValid=Abs(dy1)*100>Abs(dx1); + + if (bValid) + { + if (bVertical) + bValid=Abs(dx1)*100>Abs(dy1); + else + bValid=Abs(dy1)*100>Abs(dx1); } + long nNeuRad=0; nWink=0; - if (bValid) { + + if (bValid) + { double a=0; // Steigung des Radius long nPntWink=0; - if (bVertical) { + + if (bVertical) + { a=((double)dy1)/((double)dx1); // Steigung des Radius nNeuRad=((long)(dy1*a)+dx1) /2; aNeuCenter.X()+=nNeuRad; nPntWink=GetAngle(aPnt-aNeuCenter); - } else { + } + else + { a=((double)dx1)/((double)dy1); // Steigung des Radius nNeuRad=((long)(dx1*a)+dy1) /2; aNeuCenter.Y()+=nNeuRad; nPntWink=GetAngle(aPnt-aNeuCenter)-9000; } - if (!bAtCenter) { - if (nNeuRad<0) { + + if (!bAtCenter) + { + if (nNeuRad<0) + { if (bRgt) nPntWink+=18000; if (bLft) nPntWink=18000-nPntWink; if (bLwr) nPntWink=-nPntWink; - } else { + } + else + { if (bRgt) nPntWink=-nPntWink; if (bUpr) nPntWink=18000-nPntWink; if (bLwr) nPntWink+=18000; } + nPntWink=NormAngle360(nPntWink); - } else { + } + else + { if (nNeuRad<0) nPntWink+=18000; if (bVertical) nPntWink=18000-nPntWink; nPntWink=NormAngle180(nPntWink); nPntWink=Abs(nPntWink); } + double nUmfang=2*Abs(nNeuRad)*nPi; - if (bResize) { - if (nSA!=0) { // Winkelfang + + if (bResize) + { + if (nSA!=0) + { // Winkelfang long nWink0=nPntWink; nPntWink+=nSA/2; nPntWink/=nSA; @@ -1934,17 +3107,30 @@ void SdrDragCrook::Mov(const Point& rPnt) a2*=BigInt(nWink); a2/=BigInt(nWink0); nNeuRad=long(a2); - if (bVertical) aNeuCenter.X()=aStart.X()+nNeuRad; - else aNeuCenter.Y()=aStart.Y()+nNeuRad; + + if (bVertical) + aNeuCenter.X()=aStart.X()+nNeuRad; + else + aNeuCenter.Y()=aStart.Y()+nNeuRad; } + long nMul=(long)(nUmfang*NormAngle360(nPntWink)/36000); - if (bAtCenter) nMul*=2; + + if (bAtCenter) + nMul*=2; + aNeuFact=Fraction(nMul,nMarkSize); nWink=nPntWink; - } else { + } + else + { nWink=(long)((nMarkSize*360/nUmfang)*100)/2; - if (nWink==0) bValid=FALSE; - if (bValid && nSA!=0) { // Winkelfang + + if (nWink==0) + bValid=false; + + if (bValid && nSA!=0) + { // Winkelfang long nWink0=nWink; nWink+=nSA/2; nWink/=nSA; @@ -1953,25 +3139,44 @@ void SdrDragCrook::Mov(const Point& rPnt) a2*=BigInt(nWink); a2/=BigInt(nWink0); nNeuRad=long(a2); - if (bVertical) aNeuCenter.X()=aStart.X()+nNeuRad; - else aNeuCenter.Y()=aStart.Y()+nNeuRad; + + if (bVertical) + aNeuCenter.X()=aStart.X()+nNeuRad; + else + aNeuCenter.Y()=aStart.Y()+nNeuRad; } } } - if (nWink==0 || nNeuRad==0) bValid=FALSE; - if (!bValid) nNeuRad=0; - if (!bValid && bResize) { + + if (nWink==0 || nNeuRad==0) + bValid=false; + + if (!bValid) + nNeuRad=0; + + if (!bValid && bResize) + { long nMul=bVertical ? dy1 : dx1; - if (bLft || bUpr) nMul=-nMul; + + if (bLft || bUpr) + nMul=-nMul; + long nDiv=nMarkSize; - if (bAtCenter) { nMul*=2; nMul=Abs(nMul); } + + if (bAtCenter) + { + nMul*=2; + nMul=Abs(nMul); + } + aNeuFact=Fraction(nMul,nDiv); } + if (aNeuCenter!=aCenter || bNeuContortion!=bContortion || aNeuFact!=aFact || - bNeuMoveOnly!=bMoveOnly || bNeuRotate!=bRotate || eNeuMode!=eMode) + bNeuMoveOnly != getMoveOnly() || bNeuRotate!=bRotate || eNeuMode!=eMode) { Hide(); - bMoveOnly=bNeuMoveOnly; + setMoveOnly(bNeuMoveOnly); bRotate=bNeuRotate; eMode=eNeuMode; bContortion=bNeuContortion; @@ -1980,57 +3185,146 @@ void SdrDragCrook::Mov(const Point& rPnt) aRad=Point(nNeuRad,nNeuRad); bResize=aFact!=Fraction(1,1) && aFact.GetDenominator()!=0 && aFact.IsValid(); DragStat().NextMove(aPnt); - MovAllPoints(); Show(); } } } -FASTBOOL SdrDragCrook::End(FASTBOOL bCopy) +void SdrDragCrook::applyCurrentTransformationToSdrObject(SdrObject& rTarget) +{ + const bool bDoResize(aFact!=Fraction(1,1)); + const bool bDoCrook(aCenter!=aMarkCenter && aRad.X()!=0 && aRad.Y()!=0); + + if (bDoCrook || bDoResize) + { + if (bDoResize) + { + Fraction aFact1(1,1); + + if (bContortion) + { + if (bVertical) + { + rTarget.Resize(aCenter,aFact1,aFact); + } + else + { + rTarget.Resize(aCenter,aFact,aFact1); + } + } + else + { + Point aCtr0(rTarget.GetSnapRect().Center()); + Point aCtr1(aCtr0); + + if (bVertical) + { + ResizePoint(aCtr1,aCenter,aFact1,aFact); + } + else + { + ResizePoint(aCtr1,aCenter,aFact,aFact1); + } + + Size aSiz(aCtr1.X()-aCtr0.X(),aCtr1.Y()-aCtr0.Y()); + + rTarget.Move(aSiz); + } + } + + if (bDoCrook) + { + const Rectangle aLocalMarkRect(getSdrDragView().GetMarkedObjRect()); + const bool bLocalRotate(!bContortion && eMode == SDRCROOK_ROTATE && getSdrDragView().IsRotateAllowed(false)); + + getSdrDragView().ImpCrookObj(&rTarget,aCenter,aRad,eMode,bVertical,!bContortion,bLocalRotate,aLocalMarkRect); + } + } +} + +void SdrDragCrook::applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget) +{ + // use helper derived from old stuff + _MovAllPoints(rTarget); +} + +bool SdrDragCrook::EndSdrDrag(bool bCopy) { Hide(); - if (bResize && aFact==Fraction(1,1)) bResize=FALSE; + + if (bResize && aFact==Fraction(1,1)) + bResize=false; + bool bDoCrook=aCenter!=aMarkCenter && aRad.X()!=0 && aRad.Y()!=0; - if (bDoCrook || bResize) { - if (bResize) { + + if (bDoCrook || bResize) + { + if (bResize) + { XubString aStr; ImpTakeDescriptionStr(!bContortion?STR_EditCrook:STR_EditCrookContortion,aStr); - if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy); - rView.BegUndo(aStr); + + if (bCopy) + aStr+=ImpGetResStr(STR_EditWithCopy); + + getSdrDragView().BegUndo(aStr); } - if (bResize) { + + if (bResize) + { Fraction aFact1(1,1); - if (bContortion) { - if (bVertical) rView.ResizeMarkedObj(aCenter,aFact1,aFact,bCopy); - else rView.ResizeMarkedObj(aCenter,aFact,aFact1,bCopy); - } else { - if (bCopy) rView.CopyMarkedObj(); - ULONG nMarkAnz=rView.GetMarkedObjectList().GetMarkCount(); - for (ULONG nm=0; nm<nMarkAnz; nm++) { - SdrMark* pM=rView.GetMarkedObjectList().GetMark(nm); + + if (bContortion) + { + if (bVertical) + getSdrDragView().ResizeMarkedObj(aCenter,aFact1,aFact,bCopy); + else + getSdrDragView().ResizeMarkedObj(aCenter,aFact,aFact1,bCopy); + } + else + { + if (bCopy) + getSdrDragView().CopyMarkedObj(); + + ULONG nMarkAnz=getSdrDragView().GetMarkedObjectList().GetMarkCount(); + + for (ULONG nm=0; nm<nMarkAnz; nm++) + { + SdrMark* pM=getSdrDragView().GetMarkedObjectList().GetMark(nm); SdrObject* pO=pM->GetMarkedSdrObj(); Point aCtr0(pO->GetSnapRect().Center()); Point aCtr1(aCtr0); - if (bVertical) ResizePoint(aCtr1,aCenter,aFact1,aFact); - else ResizePoint(aCtr1,aCenter,aFact,aFact1); + + if (bVertical) + ResizePoint(aCtr1,aCenter,aFact1,aFact); + else + ResizePoint(aCtr1,aCenter,aFact,aFact1); + Size aSiz(aCtr1.X()-aCtr0.X(),aCtr1.Y()-aCtr0.Y()); - AddUndo(rView.GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pO,aSiz)); + AddUndo(getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pO,aSiz)); pO->Move(aSiz); } } - bCopy=FALSE; + + bCopy=false; } - if (bDoCrook) { - rView.CrookMarkedObj(aCenter,aRad,eMode,bVertical,!bContortion,bCopy); - rView.SetLastCrookCenter(aCenter); + + if (bDoCrook) + { + getSdrDragView().CrookMarkedObj(aCenter,aRad,eMode,bVertical,!bContortion,bCopy); + getSdrDragView().SetLastCrookCenter(aCenter); } - if (bResize) rView.EndUndo(); - return TRUE; + + if (bResize) + getSdrDragView().EndUndo(); + + return true; } - return FALSE; + + return false; } -Pointer SdrDragCrook::GetPointer() const +Pointer SdrDragCrook::GetSdrDragPointer() const { return Pointer(POINTER_CROOK); } @@ -2039,197 +3333,225 @@ Pointer SdrDragCrook::GetPointer() const TYPEINIT1(SdrDragDistort,SdrDragMethod); -void SdrDragDistort::TakeComment(XubString& rStr) const +SdrDragDistort::SdrDragDistort(SdrDragView& rNewView) +: SdrDragMethod(rNewView), + nPolyPt(0), + bContortionAllowed(false), + bNoContortionAllowed(false), + bContortion(false) +{ +} + +void SdrDragDistort::TakeSdrDragComment(XubString& rStr) const { ImpTakeDescriptionStr(STR_DragMethDistort, rStr); XubString aStr; rStr.AppendAscii(" (x="); - rView.GetModel()->TakeMetricStr(DragStat().GetDX(), aStr); + getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDX(), aStr); rStr += aStr; rStr.AppendAscii(" y="); - rView.GetModel()->TakeMetricStr(DragStat().GetDY(), aStr); + getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDY(), aStr); rStr += aStr; rStr += sal_Unicode(')'); - if(rView.IsDragWithCopy()) + if(getSdrDragView().IsDragWithCopy()) rStr += ImpGetResStr(STR_EditWithCopy); } -FASTBOOL SdrDragDistort::Beg() +void SdrDragDistort::createSdrDragEntries() +{ + // Add extended frame raster first, so it will be behind objects + if(getSdrDragView().GetSdrPageView()) + { + const basegfx::B2DPolyPolygon aDragRaster(impCreateDragRaster(*getSdrDragView().GetSdrPageView(), GetMarkedRect())); + + if(aDragRaster.count()) + { + addSdrDragEntry(new SdrDragEntryPolyPolygon(aDragRaster)); + } + } + + // call parent + SdrDragMethod::createSdrDragEntries(); +} + +bool SdrDragDistort::BeginSdrDrag() { - bContortionAllowed=rView.IsDistortAllowed(FALSE); - bNoContortionAllowed=rView.IsDistortAllowed(TRUE); - if (bContortionAllowed || bNoContortionAllowed) { + bContortionAllowed=getSdrDragView().IsDistortAllowed(false); + bNoContortionAllowed=getSdrDragView().IsDistortAllowed(true); + + if (bContortionAllowed || bNoContortionAllowed) + { SdrHdlKind eKind=GetDragHdlKind(); nPolyPt=0xFFFF; + if (eKind==HDL_UPLFT) nPolyPt=0; if (eKind==HDL_UPRGT) nPolyPt=1; if (eKind==HDL_LWRGT) nPolyPt=2; if (eKind==HDL_LWLFT) nPolyPt=3; - if (nPolyPt>3) return FALSE; + if (nPolyPt>3) return false; + aMarkRect=GetMarkedRect(); aDistortedRect=XPolygon(aMarkRect); - SetDragPolys(); - - // #96920# Add extended XOR frame raster - SdrPageView* pPV = rView.GetSdrPageView(); - - if(pPV) - { - if(pPV->PageWindowCount()) - { - OutputDevice& rOut = (pPV->GetPageWindow(0)->GetPaintWindow().GetOutputDevice()); - Rectangle aPixelSize = rOut.LogicToPixel(aMarkRect); - - sal_uInt32 nHorDiv(aPixelSize.GetWidth() / DRAG_CROOK_RASTER_DISTANCE); - sal_uInt32 nVerDiv(aPixelSize.GetHeight() / DRAG_CROOK_RASTER_DISTANCE); - - if(nHorDiv > DRAG_CROOK_RASTER_MAXIMUM) - nHorDiv = DRAG_CROOK_RASTER_MAXIMUM; - if(nHorDiv < DRAG_CROOK_RASTER_MINIMUM) - nHorDiv = DRAG_CROOK_RASTER_MINIMUM; - - if(nVerDiv > DRAG_CROOK_RASTER_MAXIMUM) - nVerDiv = DRAG_CROOK_RASTER_MAXIMUM; - if(nVerDiv < DRAG_CROOK_RASTER_MINIMUM) - nVerDiv = DRAG_CROOK_RASTER_MINIMUM; - - basegfx::B2DPolyPolygon aPolyPolygon(pPV->getDragPoly0()); - aPolyPolygon.append(ImplCreateDragRaster(aMarkRect, nHorDiv, nVerDiv)); - pPV->setDragPoly0(aPolyPolygon); - pPV->setDragPoly(pPV->getDragPoly0()); - } - } - Show(); - return TRUE; - } else { - return FALSE; + return true; + } + else + { + return false; } } -void SdrDragDistort::MovAllPoints() +void SdrDragDistort::_MovAllPoints(basegfx::B2DPolyPolygon& rTarget) { if (bContortion) { - SdrPageView* pPV = rView.GetSdrPageView(); + SdrPageView* pPV = getSdrDragView().GetSdrPageView(); if(pPV) { if (pPV->HasMarkedObjPageView()) { - basegfx::B2DPolyPolygon aDragPolygon(pPV->getDragPoly0()); + basegfx::B2DPolyPolygon aDragPolygon(rTarget); const basegfx::B2DRange aOriginalRange(aMarkRect.Left(), aMarkRect.Top(), aMarkRect.Right(), aMarkRect.Bottom()); 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::tools::distort(aDragPolygon, aOriginalRange, aTopLeft, aTopRight, aBottomLeft, aBottomRight); - pPV->setDragPoly(aDragPolygon); + rTarget = aDragPolygon; } } } } -void SdrDragDistort::Mov(const Point& rPnt) +void SdrDragDistort::MoveSdrDrag(const Point& rPnt) { - if (DragStat().CheckMinMoved(rPnt)) { + if (DragStat().CheckMinMoved(rPnt)) + { Point aPnt(GetSnapPos(rPnt)); - if (rView.IsOrtho()) OrthoDistance8(DragStat().GetStart(),aPnt,rView.IsBigOrtho()); - bool bNeuContortion=(bContortionAllowed && !rView.IsCrookNoContortion()) || !bNoContortionAllowed; - if (bNeuContortion!=bContortion || aDistortedRect[nPolyPt]!=aPnt) { + + if (getSdrDragView().IsOrtho()) + OrthoDistance8(DragStat().GetStart(),aPnt,getSdrDragView().IsBigOrtho()); + + bool bNeuContortion=(bContortionAllowed && !getSdrDragView().IsCrookNoContortion()) || !bNoContortionAllowed; + + if (bNeuContortion!=bContortion || aDistortedRect[nPolyPt]!=aPnt) + { Hide(); aDistortedRect[nPolyPt]=aPnt; bContortion=bNeuContortion; DragStat().NextMove(aPnt); - MovAllPoints(); Show(); } } } -FASTBOOL SdrDragDistort::End(FASTBOOL bCopy) +bool SdrDragDistort::EndSdrDrag(bool bCopy) { Hide(); bool bDoDistort=DragStat().GetDX()!=0 || DragStat().GetDY()!=0; - if (bDoDistort) { - rView.DistortMarkedObj(aMarkRect,aDistortedRect,!bContortion,bCopy); - return TRUE; + + if (bDoDistort) + { + getSdrDragView().DistortMarkedObj(aMarkRect,aDistortedRect,!bContortion,bCopy); + return true; } - return FALSE; + + return false; } -Pointer SdrDragDistort::GetPointer() const +Pointer SdrDragDistort::GetSdrDragPointer() const { return Pointer(POINTER_REFHAND); } +void SdrDragDistort::applyCurrentTransformationToSdrObject(SdrObject& rTarget) +{ + const bool bDoDistort(DragStat().GetDX()!=0 || DragStat().GetDY()!=0); + + if (bDoDistort) + { + getSdrDragView().ImpDistortObj(&rTarget, aMarkRect, aDistortedRect, !bContortion); + } +} + +void SdrDragDistort::applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget) +{ + // use helper derived from old stuff + _MovAllPoints(rTarget); +} + //////////////////////////////////////////////////////////////////////////////////////////////////// TYPEINIT1(SdrDragCrop,SdrDragResize); SdrDragCrop::SdrDragCrop(SdrDragView& rNewView) -: SdrDragResize(rNewView) +: SdrDragResize(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 + setSolidDraggingActive(false); } -void SdrDragCrop::TakeComment(XubString& rStr) const +void SdrDragCrop::TakeSdrDragComment(XubString& rStr) const { ImpTakeDescriptionStr(STR_DragMethCrop, rStr); XubString aStr; rStr.AppendAscii(" (x="); - rView.GetModel()->TakeMetricStr(DragStat().GetDX(), aStr); + getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDX(), aStr); rStr += aStr; rStr.AppendAscii(" y="); - rView.GetModel()->TakeMetricStr(DragStat().GetDY(), aStr); + getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDY(), aStr); rStr += aStr; rStr += sal_Unicode(')'); - if(rView.IsDragWithCopy()) + if(getSdrDragView().IsDragWithCopy()) rStr += ImpGetResStr(STR_EditWithCopy); } -FASTBOOL SdrDragCrop::End(FASTBOOL bCopy) +bool SdrDragCrop::EndSdrDrag(bool bCopy) { Hide(); + if( DragStat().GetDX()==0 && DragStat().GetDY()==0 ) - return FALSE; + return false; + + const SdrMarkList& rMarkList = getSdrDragView().GetMarkedObjectList(); - const SdrMarkList& rMarkList = rView.GetMarkedObjectList(); if( rMarkList.GetMarkCount() != 1 ) - return FALSE; + return false; SdrGrafObj* pObj = dynamic_cast<SdrGrafObj*>( rMarkList.GetMark( 0 )->GetMarkedSdrObj() ); if( !pObj || (pObj->GetGraphicType() == GRAPHIC_NONE) || (pObj->GetGraphicType() == GRAPHIC_DEFAULT) ) - return FALSE; + return false; const GraphicObject& rGraphicObject = pObj->GetGraphicObject(); - const MapMode aMapMode100thmm(MAP_100TH_MM); - Size aGraphicSize(rGraphicObject.GetPrefSize()); if( MAP_PIXEL == rGraphicObject.GetPrefMapMode().GetMapUnit() ) aGraphicSize = Application::GetDefaultDevice()->PixelToLogic( aGraphicSize, aMapMode100thmm ); else aGraphicSize = Application::GetDefaultDevice()->LogicToLogic( aGraphicSize, rGraphicObject.GetPrefMapMode(), aMapMode100thmm); + if( aGraphicSize.nA == 0 || aGraphicSize.nB == 0 ) - return FALSE; + return false; const SdrGrafCropItem& rOldCrop = (const SdrGrafCropItem&)pObj->GetMergedItem(SDRATTR_GRAFCROP); - String aUndoStr; ImpTakeDescriptionStr(STR_DragMethCrop, aUndoStr); - rView.BegUndo( aUndoStr ); - rView.AddUndo( rView.GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) ); + getSdrDragView().BegUndo( aUndoStr ); + getSdrDragView().AddUndo( getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) ); Rectangle aOldRect( pObj->GetLogicRect() ); - rView.ResizeMarkedObj(DragStat().Ref1(),aXFact,aYFact,bCopy); + getSdrDragView().ResizeMarkedObj(DragStat().Ref1(),aXFact,aYFact,bCopy); Rectangle aNewRect( pObj->GetLogicRect() ); double fScaleX = ( aGraphicSize.Width() - rOldCrop.GetLeft() - rOldCrop.GetRight() ) / (double)aOldRect.GetWidth(); @@ -2245,18 +3567,19 @@ FASTBOOL SdrDragCrop::End(FASTBOOL bCopy) sal_Int32 nRightCrop = static_cast<sal_Int32>( rOldCrop.GetRight() - nDiffRight * fScaleX ); sal_Int32 nBottomCrop = static_cast<sal_Int32>( rOldCrop.GetBottom() - nDiffBottom * fScaleY ); - SfxItemPool& rPool = rView.GetModel()->GetItemPool(); + SfxItemPool& rPool = getSdrDragView().GetModel()->GetItemPool(); SfxItemSet aSet( rPool, SDRATTR_GRAFCROP, SDRATTR_GRAFCROP ); aSet.Put( SdrGrafCropItem( nLeftCrop, nTopCrop, nRightCrop, nBottomCrop ) ); - rView.SetAttributes( aSet, FALSE ); - rView.EndUndo(); + getSdrDragView().SetAttributes( aSet, false ); + getSdrDragView().EndUndo(); - return TRUE; + return true; } -Pointer SdrDragCrop::GetPointer() const +Pointer SdrDragCrop::GetSdrDragPointer() const { return Pointer(POINTER_CROP); } +//////////////////////////////////////////////////////////////////////////////////////////////////// // eof diff --git a/svx/source/svdraw/svddrgv.cxx b/svx/source/svdraw/svddrgv.cxx index 6cc43df61a3e..4843cdc4afc4 100644 --- a/svx/source/svdraw/svddrgv.cxx +++ b/svx/source/svdraw/svddrgv.cxx @@ -39,10 +39,10 @@ #include <svx/svdundo.hxx> #include <svx/svdocapt.hxx> #include <svx/svdpagv.hxx> -#include <svx/svdopath.hxx> // wg. Sonderbehandlung in SetDragPolys() -#include <svx/svdoedge.hxx> // wg. Sonderbehandlung in IsInsGluePossible() -#include "svdstr.hrc" // Namen aus der Resource -#include "svdglob.hxx" // StringCache +#include <svx/svdopath.hxx> +#include <svx/svdoedge.hxx> +#include "svdstr.hrc" +#include "svdglob.hxx" #include "svddrgm1.hxx" #include <svx/obj3d.hxx> #include <svx/svdoashp.hxx> @@ -50,62 +50,11 @@ #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <svx/polypolygoneditor.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> using namespace sdr; //////////////////////////////////////////////////////////////////////////////////////////////////// - -class ImpSdrDragViewExtraData -{ - // The OverlayObjects for XOR replacement - ::sdr::overlay::OverlayObjectList maObjects; - -public: - ImpSdrDragViewExtraData(); - ~ImpSdrDragViewExtraData(); - - void CreateAndShowOverlay(const SdrDragView& rView); - void HideOverlay(); -}; - -ImpSdrDragViewExtraData::ImpSdrDragViewExtraData() -{ -} - -ImpSdrDragViewExtraData::~ImpSdrDragViewExtraData() -{ - HideOverlay(); -} - -void ImpSdrDragViewExtraData::CreateAndShowOverlay(const SdrDragView& rView) -{ - // This method replaces DrawDragObj and creates the necessary overlay objects instead. - // This is only half of the migration, but necessary to get rid of the XOR painting. - - // get DragMethod. All calls to this method test pDragBla. - SdrDragMethod& rDragMethod = *rView.GetDragMethod(); - - // for each PaintWindow and each OverlayManager, create the drag geometry - for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++) - { - SdrPaintWindow* pCandidate = rView.GetPaintWindow(a); - ::sdr::overlay::OverlayManager* pOverlayManager = pCandidate->GetOverlayManager(); - - if(pOverlayManager) - { - rDragMethod.CreateOverlayGeometry(*pOverlayManager, maObjects); - } - } -} - -void ImpSdrDragViewExtraData::HideOverlay() -{ - // the clear() call at the list removes all objects from the - // OverlayManager and deletes them. - maObjects.clear(); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// // // @@@@@ @@@@@ @@@@ @@@@ @@ @@ @@ @@@@@ @@ @@ @@ -129,14 +78,11 @@ void SdrDragView::ImpClearVars() pDragHdl=NULL; bDragHdl=FALSE; bDragSpecial=FALSE; - pDragBla=NULL; + mpCurrentSdrDragMethod=NULL; bDragStripes=FALSE; - //HMHbNoDragHdl=TRUE; bMirrRefDragObj=TRUE; - bSolidDragging=FALSE; bDragWithCopy=FALSE; pInsPointUndo=NULL; -// bInsAfter=FALSE; bInsGluePoint=FALSE; bInsObjPointMode=FALSE; bInsGluePointMode=FALSE; @@ -152,6 +98,9 @@ void SdrDragView::ImpClearVars() bResizeAtCenter=FALSE; bCrookAtCenter=FALSE; bMouseHideWhileDraggingPoints=FALSE; + + // init using default + mbSolidDragging = getOptionsDrawinglayer().IsSolidDragCreate(); } void SdrDragView::ImpMakeDragAttr() @@ -160,8 +109,7 @@ void SdrDragView::ImpMakeDragAttr() } SdrDragView::SdrDragView(SdrModel* pModel1, OutputDevice* pOut) -: SdrExchangeView(pModel1,pOut), - mpDragViewExtraData(new ImpSdrDragViewExtraData()) +: SdrExchangeView(pModel1,pOut) { ImpClearVars(); ImpMakeDragAttr(); @@ -169,7 +117,6 @@ SdrDragView::SdrDragView(SdrModel* pModel1, OutputDevice* pOut) SdrDragView::~SdrDragView() { - delete mpDragViewExtraData; ImpDelDragAttr(); } @@ -179,13 +126,13 @@ void SdrDragView::ImpDelDragAttr() BOOL SdrDragView::IsAction() const { - return (pDragBla || SdrExchangeView::IsAction()); + return (mpCurrentSdrDragMethod || SdrExchangeView::IsAction()); } void SdrDragView::MovAction(const Point& rPnt) { SdrExchangeView::MovAction(rPnt); - if (pDragBla!=NULL) + if (mpCurrentSdrDragMethod) { MovDragObj(rPnt); } @@ -193,7 +140,7 @@ void SdrDragView::MovAction(const Point& rPnt) void SdrDragView::EndAction() { - if (pDragBla!=NULL) + if (mpCurrentSdrDragMethod) { EndDragObj(FALSE); } @@ -214,31 +161,20 @@ void SdrDragView::BrkAction() void SdrDragView::TakeActionRect(Rectangle& rRect) const { - if (pDragBla!=NULL) + if (mpCurrentSdrDragMethod) { rRect=aDragStat.GetActionRect(); if (rRect.IsEmpty()) { - BOOL b1st=TRUE; SdrPageView* pPV = GetSdrPageView(); - if(pPV) + if(pPV&& pPV->HasMarkedObjPageView()) { - if (pPV->HasMarkedObjPageView()) - { - const basegfx::B2DRange aBoundRange(basegfx::tools::getRange(pPV->getDragPoly())); - const Rectangle aR(basegfx::fround(aBoundRange.getMinX()), basegfx::fround(aBoundRange.getMinY()), basegfx::fround(aBoundRange.getMaxX()), basegfx::fround(aBoundRange.getMaxY())); - - if (b1st) - { - b1st=FALSE; - rRect=aR; - } - else - { - rRect.Union(aR); - } - } + // #i95646# is this used..? + const basegfx::B2DRange aBoundRange(mpCurrentSdrDragMethod->getCurrentRange()); + rRect = Rectangle( + basegfx::fround(aBoundRange.getMinX()), basegfx::fround(aBoundRange.getMinY()), + basegfx::fround(aBoundRange.getMaxX()), basegfx::fround(aBoundRange.getMaxY())); } } if (rRect.IsEmpty()) @@ -252,157 +188,6 @@ void SdrDragView::TakeActionRect(Rectangle& rRect) const } } -void SdrDragView::SetDragPolys(bool bReset) -{ - SdrPageView* pPV = GetSdrPageView(); - ULONG nMarkAnz=GetMarkedObjectCount(); - - if(bReset) - { - if(pPV) - { - pPV->setDragPoly(basegfx::B2DPolyPolygon()); - } - } - else if(IsDraggingPoints() || IsDraggingGluePoints()) - { - BOOL bGlue=IsDraggingGluePoints(); - - if(pPV) - { - pPV->setDragPoly0(basegfx::B2DPolyPolygon()); - if (pPV->HasMarkedObjPageView()) - { - for (ULONG nm=0; nm<nMarkAnz; nm++) - { - SdrMark* pM=GetSdrMarkByIndex(nm); - if (pM->GetPageView()==pPV) - { - const SdrUShortCont* pPts=bGlue ? pM->GetMarkedGluePoints() : pM->GetMarkedPoints(); - if (pPts!=NULL && pPts->GetCount()!=0) - { - const SdrObject* pObj=pM->GetMarkedSdrObj(); - const SdrPathObj* pPath=bGlue ? NULL : PTR_CAST(SdrPathObj,pObj); - const basegfx::B2DPolyPolygon aPathXPP = (pPath) ? pPath->GetPathPoly() : basegfx::B2DPolyPolygon(); - const SdrGluePointList* pGPL=bGlue ? pObj->GetGluePointList() : NULL; - const sal_uInt32 nPtAnz(pPts->GetCount()); - basegfx::B2DPolygon aPolygon; - - for(sal_uInt32 nPtNum(0L); nPtNum < nPtAnz; nPtNum++) - { - sal_uInt16 nObjPt(pPts->GetObject(nPtNum)); - - if(bGlue) - { - if(pGPL) - { - sal_uInt16 nGlueNum(pGPL->FindGluePoint(nObjPt)); - - if(SDRGLUEPOINT_NOTFOUND != nGlueNum) - { - const Point aPoint((*pGPL)[nGlueNum].GetAbsolutePos(*pObj)); - aPolygon.append(basegfx::B2DPoint(aPoint.X(), aPoint.Y())); - } - } - } - else - { - if(pPath && aPathXPP.count()) - { - sal_uInt32 nPolyNum, nPointNum; - - if(PolyPolygonEditor::GetRelativePolyPoint(aPathXPP, nObjPt, nPolyNum, nPointNum)) - { - aPolygon.append(aPathXPP.getB2DPolygon(nPolyNum).getB2DPoint(nPointNum)); - } - } - } - } - - basegfx::B2DPolyPolygon aDragPoly(pPV->getDragPoly0()); - aDragPoly.append(aPolygon); - pPV->setDragPoly0(aDragPoly); - } - } - } - } - pPV->setDragPoly(pPV->getDragPoly0()); - } - return; - } - else - { - Rectangle aRect; - XPolygon aEmptyPoly(0); // Lerres XPoly fuer Separate - ULONG nMaxObj=nDragXorPolyLimit; - ULONG nMaxPnt=nDragXorPointLimit; - BOOL bNoPoly = IsNoDragXorPolys() || GetMarkedObjectCount()>nMaxObj; - BOOL bBrk=FALSE; - ULONG nPolyCnt=0; // Max nDragXorPolyLimit Polys - ULONG nPntCnt=0; // Max 5*nDragXorPolyLimit Punkte - - if(!bNoPoly) - { - if(pPV) - { - if(pPV->HasMarkedObjPageView()) - { - pPV->setDragPoly0(basegfx::B2DPolyPolygon()); - basegfx::B2DPolyPolygon aDazuPP; - - for(ULONG nm=0; nm<nMarkAnz && !bBrk; nm++) - { - SdrMark* pM=GetSdrMarkByIndex(nm); - - if(pM->GetPageView()==pPV) - { - aDazuPP = pM->GetMarkedSdrObj()->TakeXorPoly(); - const sal_uInt32 nDazuPolyAnz(aDazuPP.count()); - nPolyCnt += nDazuPolyAnz; - - for(sal_uInt32 i(0L); i < nDazuPolyAnz; i++) - { - nPntCnt += aDazuPP.getB2DPolygon(i).count(); - } - - if(nPolyCnt > nMaxObj || nPntCnt > nMaxPnt) - { - bBrk = TRUE; - bNoPoly = TRUE; - } - - if(!bBrk) - { - basegfx::B2DPolyPolygon aPolyPoygon(pPV->getDragPoly0()); - aPolyPoygon.append(aDazuPP); - pPV->setDragPoly0(aPolyPoygon); - } - } - } - - pPV->setDragPoly(pPV->getDragPoly0()); - } - } - } - - if(bNoPoly) - { - if(pPV) - { - if (pPV->HasMarkedObjPageView()) - { - const Rectangle aR(pPV->MarkSnap()); - const basegfx::B2DRange aNewRectangle(aR.Left(), aR.Top(), aR.Right(), aR.Bottom()); - basegfx::B2DPolygon aNewPolygon(basegfx::tools::createPolygonFromRect(aNewRectangle)); - aNewPolygon = basegfx::tools::expandToCurve(aNewPolygon); - pPV->setDragPoly0(basegfx::B2DPolyPolygon(aNewPolygon)); - pPV->setDragPoly(pPV->getDragPoly0()); - } - } - } - } -} - BOOL SdrDragView::TakeDragObjAnchorPos(Point& rPos, BOOL bTR ) const { Rectangle aR; @@ -410,14 +195,14 @@ BOOL SdrDragView::TakeDragObjAnchorPos(Point& rPos, BOOL bTR ) const rPos = bTR ? aR.TopRight() : aR.TopLeft(); if (GetMarkedObjectCount()==1 && IsDragObj() && // nur bei Einzelselektion !IsDraggingPoints() && !IsDraggingGluePoints() && // nicht beim Punkteschieben - !pDragBla->ISA(SdrDragMovHdl)) // nicht beim Handlesschieben + !mpCurrentSdrDragMethod->ISA(SdrDragMovHdl)) // nicht beim Handlesschieben { SdrObject* pObj=GetMarkedObjectByIndex(0); if (pObj->ISA(SdrCaptionObj)) { Point aPt(((SdrCaptionObj*)pObj)->GetTailPos()); BOOL bTail=eDragHdl==HDL_POLY; // Schwanz wird gedraggt (nicht so ganz feine Abfrage hier) - BOOL bOwn=pDragBla->ISA(SdrDragObjOwn); // Objektspeziefisch + BOOL bOwn=mpCurrentSdrDragMethod->ISA(SdrDragObjOwn); // Objektspeziefisch if (!bTail) { // bei bTail liefert TakeActionRect schon das richtige if (bOwn) @@ -426,8 +211,10 @@ BOOL SdrDragView::TakeDragObjAnchorPos(Point& rPos, BOOL bTR ) const } else { - // hier nun dragging des gesamten Objekts (Move, Resize, ...) - pDragBla->MovPoint(aPt); // ,Point()); //GetSdrPageViewOfMarkedByIndex(0)->GetOffset()); + // drag the whole Object (Move, Resize, ...) + const basegfx::B2DPoint aTransformed(mpCurrentSdrDragMethod->getCurrentTransformation() * basegfx::B2DPoint(aPt.X(), aPt.Y())); + rPos.X() = basegfx::fround(aTransformed.getX()); + rPos.Y() = basegfx::fround(aTransformed.getY()); } } } @@ -452,7 +239,7 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl SetDragWithCopy(FALSE); //ForceEdgesOfMarkedNodes(); //TODO: aAni.Reset(); - pDragBla=NULL; + mpCurrentSdrDragMethod=NULL; bDragSpecial=FALSE; bDragLimit=FALSE; SdrDragMode eTmpMode=eDragMode; @@ -462,7 +249,7 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl bDragLimit=TakeDragLimit(eTmpMode,aDragLimit); bFramDrag=ImpIsFrameHandles(); if (!bFramDrag && - (pMarkedObj==NULL || !pMarkedObj->HasSpecialDrag()) && + (pMarkedObj==NULL || !pMarkedObj->hasSpecialDrag()) && (pHdl==NULL || pHdl->GetObj()==NULL)) { bFramDrag=TRUE; } @@ -496,7 +283,7 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl if(bDragHdl) { - pDragBla = new SdrDragMovHdl(*this); + mpCurrentSdrDragMethod = new SdrDragMovHdl(*this); } else if(!bNotDraggable) { @@ -522,7 +309,7 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl // Rotationen handelt if (!b3DObjSelected && !IsShearAllowed()) return FALSE; - pDragBla=new SdrDragShear(*this,eDragMode==SDRDRAG_ROTATE); + mpCurrentSdrDragMethod = new SdrDragShear(*this,eDragMode==SDRDRAG_ROTATE); } break; case HDL_UPLFT: case HDL_UPRGT: case HDL_LWLFT: case HDL_LWRGT: @@ -530,12 +317,12 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl if (eDragMode==SDRDRAG_SHEAR || eDragMode==SDRDRAG_DISTORT) { if (!IsDistortAllowed(TRUE) && !IsDistortAllowed(FALSE)) return FALSE; - pDragBla=new SdrDragDistort(*this); + mpCurrentSdrDragMethod = new SdrDragDistort(*this); } else { if (!IsRotateAllowed(TRUE)) return FALSE; - pDragBla=new SdrDragRotate(*this); + mpCurrentSdrDragMethod = new SdrDragRotate(*this); } } break; default: @@ -543,12 +330,12 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl if (IsMarkedHitMovesAlways() && eDragHdl==HDL_MOVE) { // HDL_MOVE ist auch wenn Obj direkt getroffen if (!IsMoveAllowed()) return FALSE; - pDragBla=new SdrDragMove(*this); + mpCurrentSdrDragMethod = new SdrDragMove(*this); } else { if (!IsRotateAllowed(TRUE)) return FALSE; - pDragBla=new SdrDragRotate(*this); + mpCurrentSdrDragMethod = new SdrDragRotate(*this); } } } @@ -558,12 +345,12 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways()) { if (!IsMoveAllowed()) return FALSE; - pDragBla=new SdrDragMove(*this); + mpCurrentSdrDragMethod = new SdrDragMove(*this); } else { if (!IsMirrorAllowed(TRUE,TRUE)) return FALSE; - pDragBla=new SdrDragMirror(*this); + mpCurrentSdrDragMethod = new SdrDragMirror(*this); } } break; @@ -573,13 +360,13 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl { if (!IsMoveAllowed()) return FALSE; - pDragBla=new SdrDragMove(*this); + mpCurrentSdrDragMethod = new SdrDragMove(*this); } else { if (!IsCrookAllowed(TRUE) && !IsCrookAllowed(FALSE)) return FALSE; - pDragBla=new SdrDragCrop(*this); + mpCurrentSdrDragMethod = new SdrDragCrop(*this); } } break; @@ -590,14 +377,14 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl { if(!IsMoveAllowed()) return FALSE; - pDragBla = new SdrDragMove(*this); + mpCurrentSdrDragMethod = new SdrDragMove(*this); } else { if(!IsTransparenceAllowed()) return FALSE; - pDragBla = new SdrDragGradient(*this, FALSE); + mpCurrentSdrDragMethod = new SdrDragGradient(*this, FALSE); } break; } @@ -607,14 +394,14 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl { if(!IsMoveAllowed()) return FALSE; - pDragBla = new SdrDragMove(*this); + mpCurrentSdrDragMethod = new SdrDragMove(*this); } else { if(!IsGradientAllowed()) return FALSE; - pDragBla = new SdrDragGradient(*this); + mpCurrentSdrDragMethod = new SdrDragGradient(*this); } break; } @@ -624,12 +411,12 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways()) { if (!IsMoveAllowed()) return FALSE; - pDragBla=new SdrDragMove(*this); + mpCurrentSdrDragMethod = new SdrDragMove(*this); } else { if (!IsCrookAllowed(TRUE) && !IsCrookAllowed(FALSE)) return FALSE; - pDragBla=new SdrDragCrook(*this); + mpCurrentSdrDragMethod = new SdrDragCrook(*this); } } break; @@ -642,7 +429,7 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl } else if(eDragHdl == HDL_GLUE) { - pDragBla = new SdrDragMove(*this); + mpCurrentSdrDragMethod = new SdrDragMove(*this); } else { @@ -650,7 +437,7 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl { if(eDragHdl == HDL_MOVE) { - pDragBla=new SdrDragMove(*this); + mpCurrentSdrDragMethod = new SdrDragMove(*this); } else { @@ -659,14 +446,14 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl return FALSE; } - pDragBla = new SdrDragResize(*this); + mpCurrentSdrDragMethod = new SdrDragResize(*this); } } else { if((eDragHdl == HDL_MOVE) && (GetMarkedObjectCount() == 1) && GetMarkedObjectByIndex(0)->ISA(SdrObjCustomShape)) { - pDragBla = new SdrDragMove( *this ); + mpCurrentSdrDragMethod = new SdrDragMove( *this ); } else if((eDragHdl == HDL_POLY) && (!IsMoveAllowed() || !IsResizeAllowed())) { @@ -676,7 +463,7 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl else { bDragSpecial = TRUE; - pDragBla = new SdrDragObjOwn(*this); + mpCurrentSdrDragMethod = new SdrDragObjOwn(*this); } } } @@ -685,33 +472,36 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl } if (pForcedMeth!=NULL) { - delete pDragBla; - pDragBla=pForcedMeth; + delete mpCurrentSdrDragMethod; + mpCurrentSdrDragMethod = pForcedMeth; } - aDragStat.SetDragMethod(pDragBla); - if (pDragBla!=NULL) + aDragStat.SetDragMethod(mpCurrentSdrDragMethod); + if (mpCurrentSdrDragMethod) { - bRet=pDragBla->Beg(); + bRet = mpCurrentSdrDragMethod->BeginSdrDrag(); if (!bRet) { - if (pHdl==NULL && IS_TYPE(SdrDragObjOwn,pDragBla)) + if (pHdl==NULL && IS_TYPE(SdrDragObjOwn,mpCurrentSdrDragMethod)) { // Aha, Obj kann nicht Move SpecialDrag, also MoveFrameDrag versuchen - delete pDragBla; - pDragBla=NULL; + delete mpCurrentSdrDragMethod; + mpCurrentSdrDragMethod = 0; bDragSpecial=FALSE; - if (!IsMoveAllowed()) return FALSE; + + if (!IsMoveAllowed()) + return FALSE; + bFramDrag=TRUE; - pDragBla=new SdrDragMove(*this); - aDragStat.SetDragMethod(pDragBla); - bRet=pDragBla->Beg(); + mpCurrentSdrDragMethod = new SdrDragMove(*this); + aDragStat.SetDragMethod(mpCurrentSdrDragMethod); + bRet = mpCurrentSdrDragMethod->BeginSdrDrag(); } } if (!bRet) { - delete pDragBla; - pDragBla=NULL; - aDragStat.SetDragMethod(pDragBla); + delete mpCurrentSdrDragMethod; + mpCurrentSdrDragMethod = 0; + aDragStat.SetDragMethod(mpCurrentSdrDragMethod); } } } @@ -721,18 +511,11 @@ BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl void SdrDragView::MovDragObj(const Point& rPnt) { - if (pDragBla!=NULL) + if (mpCurrentSdrDragMethod) { Point aPnt(rPnt); ImpLimitToWorkArea(aPnt); - pDragBla->Mov(aPnt); // this call already makes a Hide()/Show combination -//SDO if (/*HMHIsDragHdlHide() &&*/ aDragStat.IsMinMoved() && !bDragHdl /*HMH&& IsMarkHdlShown()*/) { -//SDO //HMHBOOL bLeaveRefs=IS_TYPE(SdrDragMirror,pDragBla) || IS_TYPE(SdrDragRotate,pDragBla); -//SDO BOOL bFlag=IsSolidMarkHdl() && aDragStat.IsShown(); -//SDO if (bFlag) HideDragObj(); -//SDO //HMHHideMarkHdl(bLeaveRefs); -//SDO if (bFlag) ShowDragObj(); -//SDO } + mpCurrentSdrDragMethod->MoveSdrDrag(aPnt); // this call already makes a Hide()/Show combination } } @@ -741,22 +524,29 @@ BOOL SdrDragView::EndDragObj(BOOL bCopy) bool bRet(false); // #i73341# If insert GluePoint, do not insist on last points being different - if(pDragBla && aDragStat.IsMinMoved() && (IsInsertGluePoint() || aDragStat.GetNow() != aDragStat.GetPrev())) + if(mpCurrentSdrDragMethod && aDragStat.IsMinMoved() && (IsInsertGluePoint() || aDragStat.GetNow() != aDragStat.GetPrev())) { ULONG nHdlAnzMerk=0; + if (bEliminatePolyPoints) { // IBM Special nHdlAnzMerk=GetMarkablePointCount(); } + if (IsInsertGluePoint()) { BegUndo(aInsPointUndoStr); AddUndo(pInsPointUndo); } - bRet=pDragBla->End(bCopy); - if (IsInsertGluePoint()) EndUndo(); - delete pDragBla; - pDragBla=NULL; + + bRet = mpCurrentSdrDragMethod->EndSdrDrag(bCopy); + + if (IsInsertGluePoint()) + EndUndo(); + + delete mpCurrentSdrDragMethod; + mpCurrentSdrDragMethod = 0; + if (bEliminatePolyPoints) { // IBM Special if (nHdlAnzMerk!=GetMarkablePointCount()) @@ -764,13 +554,11 @@ BOOL SdrDragView::EndDragObj(BOOL bCopy) UnmarkAllPoints(); } } + if (bInsPolyPoint) { - //HMHBOOL bVis=IsMarkHdlShown(); - //HMHif (bVis) HideMarkHdl(); SetMarkHandles(); bInsPolyPoint=FALSE; - //HMHif (bVis) ShowMarkHdl(); BegUndo(aInsPointUndoStr); AddUndo(pInsPointUndo); EndUndo(); @@ -782,18 +570,17 @@ BOOL SdrDragView::EndDragObj(BOOL bCopy) if (!bSomeObjChgdFlag) { // Aha, Obj hat nicht gebroadcastet (z.B. Writer FlyFrames) - if(/*HMHIsDragHdlHide() &&*/ !bDragHdl && !IS_TYPE(SdrDragMirror,pDragBla) && !IS_TYPE(SdrDragRotate,pDragBla)) + if(!bDragHdl) { AdjustMarkHdl(); - //HMHShowMarkHdl(); } } - SetDragPolys(true); } else { BrkDragObj(); } + bInsPolyPoint=FALSE; SetInsertGluePoint(FALSE); @@ -802,22 +589,22 @@ BOOL SdrDragView::EndDragObj(BOOL bCopy) void SdrDragView::BrkDragObj() { - if (pDragBla!=NULL) + if (mpCurrentSdrDragMethod) { - pDragBla->Brk(); - delete pDragBla; - pDragBla=NULL; + mpCurrentSdrDragMethod->CancelSdrDrag(); + + delete mpCurrentSdrDragMethod; + mpCurrentSdrDragMethod = 0; + if (bInsPolyPoint) { - //HMHBOOL bVis=IsMarkHdlShown(); - //HMHif (bVis) HideMarkHdl(); pInsPointUndo->Undo(); // Den eingefuegten Punkt wieder raus delete pInsPointUndo; pInsPointUndo=NULL; SetMarkHandles(); bInsPolyPoint=FALSE; - //HMHif (bVis) ShowMarkHdl(); } + if (IsInsertGluePoint()) { pInsPointUndo->Undo(); // Den eingefuegten Klebepunkt wieder raus @@ -825,14 +612,9 @@ void SdrDragView::BrkDragObj() pInsPointUndo=NULL; SetInsertGluePoint(FALSE); } -//HMH if (IsDragHdlHide() && !bDragHdl && -//HMH !IS_TYPE(SdrDragMirror,pDragBla) && !IS_TYPE(SdrDragRotate,pDragBla)) -//HMH { -//HMH ShowMarkHdl(); -//HMH } + eDragHdl=HDL_MOVE; pDragHdl=NULL; - SetDragPolys(true); } } @@ -864,7 +646,7 @@ sal_Bool SdrDragView::ImpBegInsObjPoint(sal_Bool bIdxZwang, sal_uInt32 nIdx, con } aInsPointUndoStr = aStr; - Point aPt(rPnt); // - pMarkedPV->GetOffset()); + Point aPt(rPnt); if(bNewObj) aPt = GetSnapPos(aPt,pMarkedPV); @@ -890,18 +672,10 @@ sal_Bool SdrDragView::ImpBegInsObjPoint(sal_Bool bIdxZwang, sal_uInt32 nIdx, con if(0xffffffff != mnInsPointNum) { - //HMHsal_Bool bVis(IsMarkHdlShown()); - - //HMHif(bVis) - //HMH HideMarkHdl(); - bInsPolyPoint = sal_True; UnmarkAllPoints(); AdjustMarkHdl(); - //HMHif(bVis) - //HMH ShowMarkHdl(); - bRet = BegDragObj(rPnt, pOut, aHdl.GetHdl(mnInsPointNum), 0); if (bRet) @@ -969,7 +743,6 @@ BOOL SdrDragView::BegInsGluePoint(const Point& rPnt) { BrkAction(); UnmarkAllGluePoints(); - //SdrMark* pM=GetSdrMarkByIndex(nMarkNum); pInsPointUndo= dynamic_cast< SdrUndoGeoObj* >( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj) ); DBG_ASSERT( pInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" ); XubString aStr(ImpGetResStr(STR_DragInsertGluePoint)); @@ -1024,32 +797,19 @@ BOOL SdrDragView::BegInsGluePoint(const Point& rPnt) return bRet; } -BOOL SdrDragView::IsMoveOnlyDragObj(BOOL bAskRTTI) const -{ - bool bRet=false; - if (pDragBla!=NULL && !IsDraggingPoints() && !IsDraggingGluePoints()) - { - if (bAskRTTI) - { - bRet=IS_TYPE(SdrDragMove,pDragBla); - } - else - { - bRet=pDragBla->IsMoveOnly(); - } - } - return bRet; -} - void SdrDragView::ShowDragObj() { - if(pDragBla && !aDragStat.IsShown()) + if(mpCurrentSdrDragMethod && !aDragStat.IsShown()) { - // for migration from XOR, replace DrawDragObj here to create - // overlay objects instead. - if(pDragBla) + for(sal_uInt32 a(0); a < PaintWindowCount(); a++) { - mpDragViewExtraData->CreateAndShowOverlay(*this); + SdrPaintWindow* pCandidate = GetPaintWindow(a); + sdr::overlay::OverlayManager* pOverlayManager = pCandidate->GetOverlayManager(); + + if(pOverlayManager) + { + mpCurrentSdrDragMethod->CreateOverlayGeometry(*pOverlayManager); + } } aDragStat.SetShown(TRUE); @@ -1058,13 +818,9 @@ void SdrDragView::ShowDragObj() void SdrDragView::HideDragObj() { - if(pDragBla && aDragStat.IsShown()) + if(mpCurrentSdrDragMethod && aDragStat.IsShown()) { - // for migration from XOR, replace DrawDragObj here to create - // overlay objects instead. - mpDragViewExtraData->HideOverlay(); - - //DrawDragObj(pOut, FALSE); + mpCurrentSdrDragMethod->destroyOverlayGeometry(); aDragStat.SetShown(FALSE); } } @@ -1075,23 +831,32 @@ void SdrDragView::SetNoDragXorPolys(BOOL bOn) { if (IsNoDragXorPolys()!=bOn) { - BOOL bDragging=pDragBla!=NULL; - BOOL bShown=bDragging && aDragStat.IsShown(); - if (bShown) HideDragObj(); - bNoDragXorPolys=bOn; - if (bDragging) + const bool bDragging(mpCurrentSdrDragMethod); + const bool bShown(bDragging && aDragStat.IsShown()); + + if(bShown) { - SetDragPolys(); - pDragBla->MovAllPoints(); // die gedraggten Polys neu berechnen + HideDragObj(); } - if (bShown) + + bNoDragXorPolys = bOn; + + if(bDragging) + { + // force recreation of drag content + mpCurrentSdrDragMethod->resetSdrDragEntries(); + } + + if(bShown) + { ShowDragObj(); + } } } void SdrDragView::SetDragStripes(BOOL bOn) { - if (pDragBla!=NULL && aDragStat.IsShown()) + if (mpCurrentSdrDragMethod && aDragStat.IsShown()) { HideDragObj(); bDragStripes=bOn; @@ -1103,22 +868,13 @@ void SdrDragView::SetDragStripes(BOOL bOn) } } -//HMHvoid SdrDragView::SetDragHdlHide(BOOL bOn) -//HMH{ -//HMH bNoDragHdl=bOn; -//HMH if (pDragBla!=NULL && !bDragHdl && !IS_TYPE(SdrDragMirror,pDragBla) && !IS_TYPE(SdrDragRotate,pDragBla)) -//HMH { -//HMH if (bOn) HideMarkHdl(); -//HMH else ShowMarkHdl(); -//HMH } -//HMH} - BOOL SdrDragView::IsOrthoDesired() const { - if (pDragBla!=NULL && (IS_TYPE(SdrDragObjOwn,pDragBla) || IS_TYPE(SdrDragResize,pDragBla))) + if(mpCurrentSdrDragMethod && (IS_TYPE(SdrDragObjOwn, mpCurrentSdrDragMethod) || IS_TYPE(SdrDragResize, mpCurrentSdrDragMethod))) { return bOrthoDesiredOnMarked; } + return FALSE; } @@ -1186,12 +942,25 @@ void SdrDragView::SetDetailedEdgeDraggingLimit(USHORT nEdgeObjAnz) void SdrDragView::SetMarkHandles() { -// DBG_ASSERT( (pDragBla == 0) && (pDragHdl == 0), "svx::SdrDragView::SetMarkHandles(), who calls me during drag operation?" ); - if( pDragHdl ) pDragHdl = 0; SdrExchangeView::SetMarkHandles(); } +void SdrDragView::SetSolidDragging(bool bOn) +{ + if((bool)mbSolidDragging != bOn) + { + mbSolidDragging = bOn; + } +} + +bool SdrDragView::IsSolidDragging() const +{ + // allow each user to disable by having a local setting, but using AND for + // checking allowance + return mbSolidDragging && getOptionsDrawinglayer().IsSolidDragCreate(); +} + // eof diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx index fb5f76d41229..6499708c6186 100644 --- a/svx/source/svdraw/svdmrkv.cxx +++ b/svx/source/svdraw/svdmrkv.cxx @@ -657,7 +657,7 @@ BOOL SdrMarkView::ImpIsFrameHandles() const for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && !bFrmHdl; nMarkNum++) { const SdrMark* pM=GetSdrMarkByIndex(nMarkNum); const SdrObject* pObj=pM->GetMarkedSdrObj(); - bFrmHdl=!pObj->HasSpecialDrag(); + bFrmHdl=!pObj->hasSpecialDrag(); } } return bFrmHdl; diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index c4327a975e25..86ce62c58fc7 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -2101,33 +2101,27 @@ SdrHdl* SdrObjCustomShape::GetHdl( sal_uInt32 nHdlNum ) const return pH; } -FASTBOOL SdrObjCustomShape::HasSpecialDrag() const -{ - return TRUE; -} +//////////////////////////////////////////////////////////////////////////////////////////////////// -struct ImpCustomShapeDragUser : public SdrDragStatUserData +bool SdrObjCustomShape::hasSpecialDrag() const { - Rectangle aR; - SdrObjCustomShape* pCustoObj; -}; + return true; +} -FASTBOOL SdrObjCustomShape::BegDrag( SdrDragStat& rDrag ) const +bool SdrObjCustomShape::beginSpecialDrag(SdrDragStat& rDrag) const { - FASTBOOL bRet = TRUE; const SdrHdl* pHdl = rDrag.GetHdl(); - if ( pHdl && ( pHdl->GetKind() == HDL_CUSTOMSHAPE1 ) ) + + if(pHdl && HDL_CUSTOMSHAPE1 == pHdl->GetKind()) { - rDrag.SetEndDragChangesAttributes( sal_True ); - rDrag.SetNoSnap( TRUE ); + rDrag.SetEndDragChangesAttributes(true); + rDrag.SetNoSnap(true); } else { - if ( bSizProt ) - return FALSE; + const SdrHdl* pHdl2 = rDrag.GetHdl(); + const SdrHdlKind eHdl((pHdl2 == NULL) ? HDL_MOVE : pHdl2->GetKind()); - const SdrHdl* pHdl2=rDrag.GetHdl(); - SdrHdlKind eHdl=pHdl2==NULL ? HDL_MOVE : pHdl2->GetKind(); switch( eHdl ) { case HDL_UPLFT : @@ -2140,31 +2134,16 @@ FASTBOOL SdrObjCustomShape::BegDrag( SdrDragStat& rDrag ) const case HDL_LWRGT : case HDL_MOVE : { - bRet = TRUE; + break; } - break; default: - bRet = FALSE; + { + return false; + } } } - if(bRet) - { - ImpCustomShapeDragUser* pUser = (ImpCustomShapeDragUser*)rDrag.GetUser(); - - if(pUser) - { - SdrObject* pObj = static_cast<SdrObject*>(pUser->pCustoObj); - SdrObject::Free(pObj); - delete pUser; - } - - pUser = new ImpCustomShapeDragUser; - pUser->aR = aRect; - pUser->pCustoObj = (SdrObjCustomShape*)Clone(); - rDrag.SetUser(pUser); - } - return bRet; + return true; } void SdrObjCustomShape::DragResizeCustomShape( const Rectangle& rNewRect, SdrObjCustomShape* pObj ) const @@ -2262,104 +2241,6 @@ void SdrObjCustomShape::DragResizeCustomShape( const Rectangle& rNewRect, SdrObj } } -/* -void SdrObjCustomShape::DragResizeCustomShape( const Rectangle& rNewRect, SdrObjCustomShape* pObj ) const -{ - Rectangle aOld( pObj->aRect ); - sal_Bool bOldMirroredX( pObj->IsMirroredX() ); - sal_Bool bOldMirroredY( pObj->IsMirroredY() ); - - Rectangle aNewRect( rNewRect ); - aNewRect.Justify(); - - std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( pObj ) ); - - if ( rNewRect.Left() > rNewRect.Right() ) - { -// pObj->SetMirroredX( bOldMirroredX == sal_False ); - Point aTop( ( pObj->aRect.Left() + pObj->aRect.Right() ) >> 1, pObj->aRect.Top() ); - Point aBottom( aTop.X(), aTop.Y() + 1000 ); - pObj->NbcMirror( aTop, aBottom ); - - } - if ( rNewRect.Top() > rNewRect.Bottom() ) - { -// pObj->SetMirroredY( bOldMirroredY == sal_False ); - Point aLeft( pObj->aRect.Left(), ( pObj->aRect.Top() + pObj->aRect.Bottom() ) >> 1 ); - Point aRight( aLeft.X() + 1000, aLeft.Y() ); - pObj->NbcMirror( aLeft, aRight ); - } - - if ( aNewRect.TopLeft()!= pObj->aRect.TopLeft() && - ( pObj->aGeo.nDrehWink || pObj->aGeo.nShearWink ) ) - { - Point aNewPos( aNewRect.TopLeft() ); - if ( pObj->aGeo.nShearWink ) ShearPoint( aNewPos, pObj->aRect.TopLeft(), pObj->aGeo.nTan ); - if ( pObj->aGeo.nDrehWink ) RotatePoint(aNewPos, pObj->aRect.TopLeft(), pObj->aGeo.nSin, pObj->aGeo.nCos ); - aNewRect.SetPos( aNewPos ); - } - if ( aNewRect != pObj->aRect ) - { - pObj->SetLogicRect( aNewRect ); - std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() ); - while ( aIter != aInteractionHandles.end() ) - { - try - { - if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED ) - aIter->xInteraction->setControllerPosition( aIter->aPosition ); - if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X ) - { - sal_Int32 nX; - if ( bOldMirroredX ) - { - nX = ( aIter->aPosition.X - aOld.Right() ); - if ( rNewRect.Left() > rNewRect.Right() ) - nX = pObj->aRect.Left() - nX; - else - nX += pObj->aRect.Right(); - } - else - { - nX = ( aIter->aPosition.X - aOld.Left() ); - if ( rNewRect.Left() > rNewRect.Right() ) - nX = pObj->aRect.Right() - nX; - else - nX += pObj->aRect.Left(); - } - aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( nX, aIter->xInteraction->getPosition().Y ) ); - } - if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y ) - { - sal_Int32 nY; - if ( bOldMirroredY ) - { - nY = ( aIter->aPosition.Y - aOld.Bottom() ); - if ( rNewRect.Top() > rNewRect.Bottom() ) - nY = pObj->aRect.Top() - nY; - else - nY += pObj->aRect.Bottom(); - } - else - { - nY = ( aIter->aPosition.Y - aOld.Top() ); - if ( rNewRect.Top() > rNewRect.Bottom() ) - nY = pObj->aRect.Bottom() - nY; - else - nY += pObj->aRect.Top(); - } - aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( aIter->xInteraction->getPosition().X, nY ) ); - } - } - catch ( const uno::RuntimeException& ) - { - } - aIter++; - } - } -} -*/ - void SdrObjCustomShape::DragMoveCustomShapeHdl( const Point aDestination, const sal_uInt16 nCustomShapeHdlNum, SdrObjCustomShape* pObj ) const { std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( pObj ) ); @@ -2402,127 +2283,47 @@ void SdrObjCustomShape::DragMoveCustomShapeHdl( const Point aDestination, const } } -FASTBOOL SdrObjCustomShape::MovDrag( SdrDragStat& rDrag ) const +bool SdrObjCustomShape::applySpecialDrag(SdrDragStat& rDrag) { - FASTBOOL bRet = TRUE; - const SdrHdl* pHdl = rDrag.GetHdl(); - SdrHdlKind eHdl = pHdl == NULL ? HDL_MOVE : pHdl->GetKind(); - ImpCustomShapeDragUser* pUser = (ImpCustomShapeDragUser*)rDrag.GetUser(); + const SdrHdlKind eHdl((pHdl == NULL) ? HDL_MOVE : pHdl->GetKind()); - if ( pUser && pUser->pCustoObj ) + switch(eHdl) { - switch( eHdl ) + case HDL_CUSTOMSHAPE1 : { - case HDL_CUSTOMSHAPE1 : - { - rDrag.SetEndDragChangesGeoAndAttributes( TRUE ); - DragMoveCustomShapeHdl( rDrag.GetNow(), (sal_uInt16)pHdl->GetPointNum(), pUser->pCustoObj ); - } + rDrag.SetEndDragChangesGeoAndAttributes(true); + DragMoveCustomShapeHdl( rDrag.GetNow(), (sal_uInt16)pHdl->GetPointNum(), this ); + SetRectsDirty(); + InvalidateRenderGeometry(); + SetChanged(); break; - - case HDL_UPLFT : - case HDL_UPPER : - case HDL_UPRGT : - case HDL_LEFT : - case HDL_RIGHT : - case HDL_LWLFT : - case HDL_LOWER : - case HDL_LWRGT : - { - SdrObject* pObj = static_cast<SdrObject*>(pUser->pCustoObj); - SdrObject::Free(pObj); - pUser->pCustoObj = (SdrObjCustomShape*)Clone(); - pUser->aR = ImpDragCalcRect( rDrag ); - DragResizeCustomShape( pUser->aR, pUser->pCustoObj ); - } - break; - - case HDL_MOVE : - { - SdrObject* pObj = static_cast<SdrObject*>(pUser->pCustoObj); - SdrObject::Free(pObj); - pUser->pCustoObj = (SdrObjCustomShape*)Clone(); - pUser->pCustoObj->Move( Size( rDrag.GetDX(), rDrag.GetDY() ) ); - } - break; - default: break; } - } - - return bRet; -} -FASTBOOL SdrObjCustomShape::EndDrag( SdrDragStat& rDrag ) -{ - FASTBOOL bRet = TRUE; - const SdrHdl* pHdl = rDrag.GetHdl(); - SdrHdlKind eHdl = pHdl == NULL ? HDL_MOVE : pHdl->GetKind(); - ImpCustomShapeDragUser* pUser = (ImpCustomShapeDragUser*)rDrag.GetUser(); - - if ( pUser && pUser->pCustoObj ) - { - switch( eHdl ) + case HDL_UPLFT : + case HDL_UPPER : + case HDL_UPRGT : + case HDL_LEFT : + case HDL_RIGHT : + case HDL_LWLFT : + case HDL_LOWER : + case HDL_LWRGT : { - case HDL_CUSTOMSHAPE1 : - { - Rectangle aBoundRect0; - if ( pUserCall ) - aBoundRect0 = GetLastBoundRect(); - // SendRepaintBroadcast(); - - DragMoveCustomShapeHdl( rDrag.GetNow(), (sal_uInt16)pHdl->GetPointNum(), this ); - - SetRectsDirty(); - InvalidateRenderGeometry(); - SetChanged(); - // SendRepaintBroadcast(); - BroadcastObjectChange(); - SendUserCall( SDRUSERCALL_RESIZE, aBoundRect0 ); - } - break; - - case HDL_UPLFT : - case HDL_UPPER : - case HDL_UPRGT : - case HDL_LEFT : - case HDL_RIGHT : - case HDL_LWLFT : - case HDL_LOWER : - case HDL_LWRGT : - { - DragResizeCustomShape( pUser->aR, this ); - } + DragResizeCustomShape(ImpDragCalcRect(rDrag), this); break; - case HDL_MOVE : - { - Move( Size( rDrag.GetDX(), rDrag.GetDY() ) ); - } + } + case HDL_MOVE : + { + Move(Size(rDrag.GetDX(), rDrag.GetDY())); break; - default: break; } - - SdrObject* pObj = static_cast<SdrObject*>(pUser->pCustoObj); - SdrObject::Free(pObj); - delete pUser; - rDrag.SetUser(NULL); + default: break; } - return bRet; + return true; } -void SdrObjCustomShape::BrkDrag( SdrDragStat& rDrag ) const -{ - ImpCustomShapeDragUser* pUser = (ImpCustomShapeDragUser*)rDrag.GetUser(); - - if(pUser) - { - SdrObject* pObj = static_cast<SdrObject*>(pUser->pCustoObj); - SdrObject::Free(pObj); - delete pUser; - rDrag.SetUser( NULL ); - } -} +//////////////////////////////////////////////////////////////////////////////////////////////////// void SdrObjCustomShape::DragCreateObject( SdrDragStat& rStat ) { @@ -2618,37 +2419,6 @@ basegfx::B2DPolyPolygon SdrObjCustomShape::TakeCreatePoly(const SdrDragStat& /*r return GetLineGeometry( this, sal_False ); } -basegfx::B2DPolyPolygon SdrObjCustomShape::TakeDragPoly(const SdrDragStat& rDrag) const -{ - const SdrHdl* pHdl = rDrag.GetHdl(); - SdrHdlKind eHdl = pHdl == NULL ? HDL_MOVE : pHdl->GetKind(); - switch( eHdl ) - { - case HDL_CUSTOMSHAPE1 : - case HDL_UPLFT : - case HDL_UPPER : - case HDL_UPRGT : - case HDL_LEFT : - case HDL_RIGHT : - case HDL_LWLFT : - case HDL_LOWER : - case HDL_LWRGT : - case HDL_MOVE : - { - ImpCustomShapeDragUser* pUser = (ImpCustomShapeDragUser*)rDrag.GetUser(); - - if(pUser && pUser->pCustoObj) - { - return GetLineGeometry(pUser->pCustoObj, sal_False); - } - } - break; - default: break; - } - - return SdrTextObj::TakeDragPoly(rDrag); -} - //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -3486,7 +3256,7 @@ void SdrObjCustomShape::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, aGeo.RecalcTan(); // force metric to pool metric - SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); + SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0); if(eMapUnit != SFX_MAPUNIT_100TH_MM) { switch(eMapUnit) @@ -3511,7 +3281,7 @@ void SdrObjCustomShape::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, } // if anchor is used, make position relative to it - if( pModel->IsWriter() ) + if( pModel && pModel->IsWriter() ) { if(GetAnchorPos().X() || GetAnchorPos().Y()) { @@ -3623,7 +3393,7 @@ sal_Bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, ba basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top()); // position maybe relative to anchorpos, convert - if( pModel->IsWriter() ) + if( pModel && pModel->IsWriter() ) { if(GetAnchorPos().X() || GetAnchorPos().Y()) { @@ -3632,7 +3402,7 @@ sal_Bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, ba } // force MapUnit to 100th mm - SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); + SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0); if(eMapUnit != SFX_MAPUNIT_100TH_MM) { switch(eMapUnit) diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index d9f7ffa0c922..475ffbb8ea98 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -1320,55 +1320,64 @@ Rectangle SdrObject::ImpDragCalcRect(const SdrDragStat& rDrag) const return aTmpRect; } -FASTBOOL SdrObject::HasSpecialDrag() const +//////////////////////////////////////////////////////////////////////////////////////////////////// + +bool SdrObject::hasSpecialDrag() const { - return FALSE; // noch nicht ganz fertig ... + return false; } -FASTBOOL SdrObject::BegDrag(SdrDragStat& rDrag) const +bool SdrObject::supportsFullDrag() const { - if (bSizProt) return FALSE; // Groesse geschuetzt - const SdrHdl* pHdl=rDrag.GetHdl(); - SdrHdlKind eHdl=pHdl==NULL ? HDL_MOVE : pHdl->GetKind(); - if (eHdl==HDL_UPLFT || eHdl==HDL_UPPER || eHdl==HDL_UPRGT || - eHdl==HDL_LEFT || eHdl==HDL_RIGHT || - eHdl==HDL_LWLFT || eHdl==HDL_LOWER || eHdl==HDL_LWRGT) return TRUE; - return FALSE; + return true; } -FASTBOOL SdrObject::MovDrag(SdrDragStat& /*rDrag*/) const +SdrObject* SdrObject::getFullDragClone() const { - return TRUE; + // default uses simple clone + return Clone(); } -FASTBOOL SdrObject::EndDrag(SdrDragStat& rDrag) +bool SdrObject::beginSpecialDrag(SdrDragStat& rDrag) const { - Rectangle aNewRect(ImpDragCalcRect(rDrag)); - if (aNewRect!=GetSnapRect()) { - SetSnapRect(aNewRect); + const SdrHdl* pHdl = rDrag.GetHdl(); + + SdrHdlKind eHdl = (pHdl == NULL) ? HDL_MOVE : pHdl->GetKind(); + + if(eHdl==HDL_UPLFT || eHdl==HDL_UPPER || eHdl==HDL_UPRGT || + eHdl==HDL_LEFT || eHdl==HDL_RIGHT || eHdl==HDL_LWLFT || + eHdl==HDL_LOWER || eHdl==HDL_LWRGT) + { + return true; } - return TRUE; + + return false; } -void SdrObject::BrkDrag(SdrDragStat& /*rDrag*/) const +bool SdrObject::applySpecialDrag(SdrDragStat& rDrag) { + Rectangle aNewRect(ImpDragCalcRect(rDrag)); + + if(aNewRect != GetSnapRect()) + { + NbcSetSnapRect(aNewRect); + } + + return true; } -XubString SdrObject::GetDragComment(const SdrDragStat& /*rDrag*/, FASTBOOL /*bDragUndoComment*/, FASTBOOL /*bCreateComment*/) const +String SdrObject::getSpecialDragComment(const SdrDragStat& /*rDrag*/) const { return String(); } -basegfx::B2DPolyPolygon SdrObject::TakeDragPoly(const SdrDragStat& rDrag) const +basegfx::B2DPolyPolygon SdrObject::getSpecialDragPoly(const SdrDragStat& /*rDrag*/) const { - basegfx::B2DPolyPolygon aRetval; - Rectangle aTmpRect(ImpDragCalcRect(rDrag)); - - aRetval.append(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(aTmpRect.Left(), aTmpRect.Top(), aTmpRect.Right(), aTmpRect.Bottom()))); - - return aRetval; + // default has nothing to add + return basegfx::B2DPolyPolygon(); } +//////////////////////////////////////////////////////////////////////////////////////////////////// // Create FASTBOOL SdrObject::BegCreate(SdrDragStat& rStat) { @@ -2913,7 +2922,7 @@ sal_Bool SdrObject::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top()); // position maybe relative to anchorpos, convert - if( pModel->IsWriter() ) + if( pModel && pModel->IsWriter() ) { if(GetAnchorPos().X() || GetAnchorPos().Y()) { @@ -2922,7 +2931,7 @@ sal_Bool SdrObject::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B } // force MapUnit to 100th mm - SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); + SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0); if(eMapUnit != SFX_MAPUNIT_100TH_MM) { switch(eMapUnit) @@ -2983,7 +2992,7 @@ void SdrObject::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const ba } // force metric to pool metric - SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); + SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0); if(eMapUnit != SFX_MAPUNIT_100TH_MM) { switch(eMapUnit) @@ -3008,7 +3017,7 @@ void SdrObject::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const ba } // if anchor is used, make position relative to it - if( pModel->IsWriter() ) + if( pModel && pModel->IsWriter() ) { if(GetAnchorPos().X() || GetAnchorPos().Y()) { @@ -3053,13 +3062,17 @@ sal_Bool SdrObject::IsInDestruction() const return sal_False; } -// #i34682# // return if fill is != XFILL_NONE -sal_Bool SdrObject::HasFillStyle() const +bool SdrObject::HasFillStyle() const { return (((const XFillStyleItem&)GetObjectItem(XATTR_FILLSTYLE)).GetValue() != XFILL_NONE); } +bool SdrObject::HasLineStyle() const +{ + return (((const XLineStyleItem&)GetObjectItem(XATTR_LINESTYLE)).GetValue() != XLINE_NONE); +} + // #i52224# // on import of OLE object from MS documents the BLIP size might be retrieved, diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx index 9ff1416dbd2f..47fc34dba5ba 100644 --- a/svx/source/svdraw/svdocapt.cxx +++ b/svx/source/svdraw/svdocapt.cxx @@ -346,154 +346,109 @@ SdrHdl* SdrCaptionObj::GetHdl(sal_uInt32 nHdlNum) const } } -FASTBOOL SdrCaptionObj::HasSpecialDrag() const +//////////////////////////////////////////////////////////////////////////////////////////////////// + +bool SdrCaptionObj::hasSpecialDrag() const { - return TRUE; + return true; } -FASTBOOL SdrCaptionObj::BegDrag(SdrDragStat& rDrag) const +bool SdrCaptionObj::beginSpecialDrag(SdrDragStat& rDrag) const { - const SdrHdl* pHdl=rDrag.GetHdl(); + const SdrHdl* pHdl = rDrag.GetHdl(); + rDrag.SetEndDragChangesAttributes(true); + rDrag.SetEndDragChangesGeoAndAttributes(true); - // #109992# - // If this is a CaptionObj, set the flags bEndDragChangesAttributes - // and bEndDragChangesGeoAndAttributes to create an undo action which - // contains geo and attr changes. Joe seems to have added this as a fix - // for a similar occurring problem. - rDrag.SetEndDragChangesAttributes(TRUE); - rDrag.SetEndDragChangesGeoAndAttributes(TRUE); + if(pHdl && 0 == pHdl->GetPolyNum()) + { + return SdrRectObj::beginSpecialDrag(rDrag); + } + else + { + rDrag.SetOrtho8Possible(true); - if (pHdl!=NULL && pHdl->GetPolyNum()==0) { - return SdrRectObj::BegDrag(rDrag); - } else { - rDrag.SetOrtho8Possible(TRUE); - if (pHdl==NULL) { - if (bMovProt) return FALSE; // Position geschuetzt - rDrag.SetNoSnap(TRUE); // Snap mache ich in diesem Fall selbst (RectSnap) + if(!pHdl) + { + if (bMovProt) + return 0; + + rDrag.SetNoSnap(true); rDrag.SetActionRect(aRect); + Point aHit(rDrag.GetStart()); - if (SdrRectObj::CheckHit(aHit,0,NULL)!=NULL) return TRUE; - else return FALSE; - } else { - return (pHdl->GetPolyNum()==1) && (pHdl->GetPointNum()==0); - } - } -} -FASTBOOL SdrCaptionObj::MovDrag(SdrDragStat& rDrag) const -{ - const SdrHdl* pHdl=rDrag.GetHdl(); - if (pHdl!=NULL && pHdl->GetPolyNum()==0) { - return SdrRectObj::MovDrag(rDrag); - } else { - SdrView* pView=rDrag.GetView(); - SdrPageView* pPV=rDrag.GetPageView(); - Rectangle aR(aRect); - aR.Move(rDrag.GetDX(),rDrag.GetDY()); - if (pView!=NULL && pPV!=NULL && pView->IsSnapEnabled()) { // RectSnap - long nDX=0,nDY=0; - pView->SnapRect(aR,pPV,nDX,nDY); - rDrag.Now().X()+=nDX; - rDrag.Now().Y()+=nDY; - aR.Move(nDX,nDY); + if(SdrRectObj::CheckHit(aHit, 0, NULL)) + return true; + } + else + { + if((1 == pHdl->GetPolyNum()) && (0 == pHdl->GetPointNum())) + return true; } - rDrag.SetActionRect(aR); - return TRUE; } + + return false; } -FASTBOOL SdrCaptionObj::EndDrag(SdrDragStat& rDrag) +bool SdrCaptionObj::applySpecialDrag(SdrDragStat& rDrag) { - Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect(); - const SdrHdl* pHdl=rDrag.GetHdl(); - if (pHdl!=NULL && pHdl->GetPolyNum()==0) { - FASTBOOL bRet=SdrRectObj::EndDrag(rDrag); - ImpRecalcTail(); + const SdrHdl* pHdl = rDrag.GetHdl(); - // Here only redraw wanted + if(pHdl && 0 == pHdl->GetPolyNum()) + { + const bool bRet(SdrRectObj::applySpecialDrag(rDrag)); + ImpRecalcTail(); ActionChanged(); - // BroadcastObjectChange(); - SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); return bRet; - } else { - // #110094#-14 SendRepaintBroadcast(); + } + else + { Point aDelt(rDrag.GetNow()-rDrag.GetStart()); - if (pHdl==NULL) { // Rect verschoben + + if(!pHdl) + { aRect.Move(aDelt.X(),aDelt.Y()); - } else { // Schwanz verschoben - aTailPoly[0]+=aDelt; } - ImpRecalcTail(); - SetChanged(); - BroadcastObjectChange(); - SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); - return TRUE; - } -} + else + { + aTailPoly[0] += aDelt; + } -void SdrCaptionObj::BrkDrag(SdrDragStat& rDrag) const -{ - const SdrHdl* pHdl=rDrag.GetHdl(); - if (pHdl!=NULL && pHdl->GetPolyNum()==0) { - SdrRectObj::BrkDrag(rDrag); - } else { - } -} + ImpRecalcTail(); + ActionChanged(); -XubString SdrCaptionObj::GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const -{ - if (bCreateComment) return String(); - const SdrHdl* pHdl=rDrag.GetHdl(); - if (pHdl!=NULL && pHdl->GetPolyNum()==0) { - return SdrRectObj::GetDragComment(rDrag,bUndoDragComment,FALSE); - } else { - XubString aStr; - if (pHdl==NULL) { - ImpTakeDescriptionStr(STR_DragCaptFram,aStr); - } else { - ImpTakeDescriptionStr(STR_DragCaptTail,aStr); - } - return aStr; + return true; } } -basegfx::B2DPolyPolygon SdrCaptionObj::TakeDragPoly(const SdrDragStat& rDrag) const +String SdrCaptionObj::getSpecialDragComment(const SdrDragStat& rDrag) const { const SdrHdl* pHdl = rDrag.GetHdl(); - const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); - const bool bRectSiz(pHdl && 0L == pHdl->GetPolyNum()); - if(bRad) + if(pHdl && 0 == pHdl->GetPolyNum()) { - return SdrRectObj::TakeDragPoly(rDrag); + return SdrRectObj::getSpecialDragComment(rDrag); } else { - XPolyPolygon aXPP; + XubString aStr; - Point aDelt(rDrag.GetNow()-rDrag.GetStart()); - Polygon aTmpPoly(aTailPoly); - Rectangle aTmpRect; - if (bRectSiz) aTmpRect=ImpDragCalcRect(rDrag); - else aTmpRect=aRect; - ImpCaptParams aPara; - ImpGetCaptParams(aPara); - if (!bRectSiz) { - if (pHdl==NULL) { // Rect verschieben - aTmpRect.Move(aDelt.X(),aDelt.Y()); - } else { // Schwanz verschieben - aTmpPoly[0]+=aDelt; - } + if(!pHdl) + { + ImpTakeDescriptionStr(STR_DragCaptFram, aStr); + } + else + { + ImpTakeDescriptionStr(STR_DragCaptTail, aStr); } - ImpCalcTail(aPara,aTmpPoly,aTmpRect); - aXPP.Insert(ImpCalcXPoly(aTmpRect,GetEckenradius())); - aXPP.Insert(XPolygon(aTmpPoly)); - return aXPP.getB2DPolyPolygon(); + return aStr; } } +//////////////////////////////////////////////////////////////////////////////////////////////////// + void SdrCaptionObj::ImpGetCaptParams(ImpCaptParams& rPara) const { const SfxItemSet& rSet = GetObjectItemSet(); diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx index d156071a858d..9c8b8bf81937 100644 --- a/svx/source/svdraw/svdocirc.cxx +++ b/svx/source/svdraw/svdocirc.cxx @@ -65,7 +65,7 @@ ////////////////////////////////////////////////////////////////////////////// -void SetWinkPnt(const Rectangle& rR, long nWink, Point& rPnt) +Point GetWinkPnt(const Rectangle& rR, long nWink) { Point aCenter(rR.Center()); long nWdt=rR.Right()-rR.Left(); @@ -73,31 +73,32 @@ void SetWinkPnt(const Rectangle& rR, long nWink, Point& rPnt) long nMaxRad=((nWdt>nHgt ? nWdt : nHgt)+1) /2; double a; a=nWink*nPi180; - rPnt=Point(Round(cos(a)*nMaxRad),-Round(sin(a)*nMaxRad)); - if (nWdt==0) rPnt.X()=0; - if (nHgt==0) rPnt.Y()=0; + Point aRetval(Round(cos(a)*nMaxRad),-Round(sin(a)*nMaxRad)); + if (nWdt==0) aRetval.X()=0; + if (nHgt==0) aRetval.Y()=0; if (nWdt!=nHgt) { if (nWdt>nHgt) { if (nWdt!=0) { // eventuelle Ueberlaeufe bei sehr grossen Objekten abfangen (Bug 23384) - if (Abs(nHgt)>32767 || Abs(rPnt.Y())>32767) { - rPnt.Y()=BigMulDiv(rPnt.Y(),nHgt,nWdt); + if (Abs(nHgt)>32767 || Abs(aRetval.Y())>32767) { + aRetval.Y()=BigMulDiv(aRetval.Y(),nHgt,nWdt); } else { - rPnt.Y()=rPnt.Y()*nHgt/nWdt; + aRetval.Y()=aRetval.Y()*nHgt/nWdt; } } } else { if (nHgt!=0) { // eventuelle Ueberlaeufe bei sehr grossen Objekten abfangen (Bug 23384) - if (Abs(nWdt)>32767 || Abs(rPnt.X())>32767) { - rPnt.X()=BigMulDiv(rPnt.X(),nWdt,nHgt); + if (Abs(nWdt)>32767 || Abs(aRetval.X())>32767) { + aRetval.X()=BigMulDiv(aRetval.X(),nWdt,nHgt); } else { - rPnt.X()=rPnt.X()*nWdt/nHgt; + aRetval.X()=aRetval.X()*nWdt/nHgt; } } } } - rPnt+=aCenter; + aRetval+=aCenter; + return aRetval; } ////////////////////////////////////////////////////////////////////////////// @@ -409,10 +410,10 @@ SdrObject* SdrCircObj::CheckHit(const Point& rPnt, USHORT nTol, const SetOfByte* if (!bRet) { Rectangle aR(aPtNoStretch.X()-nMyTol,aPtNoStretch.Y()-nMyTol, aPtNoStretch.X()+nMyTol,aPtNoStretch.Y()+nMyTol); - Point aP1(aPnt1); + Point aP1(GetWinkPnt(aRect,nStartWink)); aP1.X()-=aRect.Left()+nXRadReal; aP1.Y()-=aRect.Top()+nYRadReal; - Point aP2(aPnt2); + Point aP2(GetWinkPnt(aRect,nEndWink)); aP2.X()-=aRect.Left()+nXRadReal; aP2.Y()-=aRect.Top()+nYRadReal; if (meCircleKind==OBJ_SECT) { // Kreissektor: nur noch die beiden Strecken testen @@ -493,8 +494,6 @@ void SdrCircObj::operator=(const SdrObject& rObj) nStartWink = ((SdrCircObj&)rObj).nStartWink; nEndWink = ((SdrCircObj&)rObj).nEndWink; - aPnt1 = ((SdrCircObj&)rObj).aPnt1; - aPnt2 = ((SdrCircObj&)rObj).aPnt2; } basegfx::B2DPolyPolygon SdrCircObj::TakeXorPoly() const @@ -545,85 +544,142 @@ sal_uInt32 SdrCircObj::GetHdlCount() const SdrHdl* SdrCircObj::GetHdl(sal_uInt32 nHdlNum) const { if (meCircleKind==OBJ_CIRC) - nHdlNum += 2L; // Keine Winkelhandles fuer den Vollkreis - SdrHdl* pH=NULL; + { + nHdlNum += 2L; + } + + SdrHdl* pH = NULL; Point aPnt; - SdrHdlKind eLocalKind=HDL_MOVE; - sal_uInt32 nPNum(0L); - switch (nHdlNum) { - case 0: aPnt=aPnt1; eLocalKind=HDL_CIRC; nPNum=1L; break; // StartWink - case 1: aPnt=aPnt2; eLocalKind=HDL_CIRC; nPNum=2L; break; // EndWink - case 2: aPnt=aRect.TopLeft(); eLocalKind=HDL_UPLFT; break; // Oben links - case 3: aPnt=aRect.TopCenter(); eLocalKind=HDL_UPPER; break; // Oben - case 4: aPnt=aRect.TopRight(); eLocalKind=HDL_UPRGT; break; // Oben rechts - case 5: aPnt=aRect.LeftCenter(); eLocalKind=HDL_LEFT ; break; // Links - case 6: aPnt=aRect.RightCenter(); eLocalKind=HDL_RIGHT; break; // Rechts - case 7: aPnt=aRect.BottomLeft(); eLocalKind=HDL_LWLFT; break; // Unten links - case 8: aPnt=aRect.BottomCenter(); eLocalKind=HDL_LOWER; break; // Unten - case 9: aPnt=aRect.BottomRight(); eLocalKind=HDL_LWRGT; break; // Unten rechts + SdrHdlKind eLocalKind(HDL_MOVE); + sal_uInt32 nPNum(0); + + switch (nHdlNum) + { + case 0: + aPnt = GetWinkPnt(aRect,nStartWink); + eLocalKind = HDL_CIRC; + nPNum = 1; + break; + case 1: + aPnt = GetWinkPnt(aRect,nEndWink); + eLocalKind = HDL_CIRC; + nPNum = 2L; + break; + case 2: + aPnt = aRect.TopLeft(); + eLocalKind = HDL_UPLFT; + break; + case 3: + aPnt = aRect.TopCenter(); + eLocalKind = HDL_UPPER; + break; + case 4: + aPnt = aRect.TopRight(); + eLocalKind = HDL_UPRGT; + break; + case 5: + aPnt = aRect.LeftCenter(); + eLocalKind = HDL_LEFT; + break; + case 6: + aPnt = aRect.RightCenter(); + eLocalKind = HDL_RIGHT; + break; + case 7: + aPnt = aRect.BottomLeft(); + eLocalKind = HDL_LWLFT; + break; + case 8: + aPnt = aRect.BottomCenter(); + eLocalKind = HDL_LOWER; + break; + case 9: + aPnt = aRect.BottomRight(); + eLocalKind = HDL_LWRGT; + break; + } + + if (aGeo.nShearWink) + { + ShearPoint(aPnt,aRect.TopLeft(),aGeo.nTan); + } + + if (aGeo.nDrehWink) + { + RotatePoint(aPnt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos); } - if (aGeo.nShearWink!=0) ShearPoint(aPnt,aRect.TopLeft(),aGeo.nTan); - if (aGeo.nDrehWink!=0) RotatePoint(aPnt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos); - if (eLocalKind!=HDL_MOVE) { - pH=new SdrHdl(aPnt,eLocalKind); + + if (eLocalKind != HDL_MOVE) + { + pH = new SdrHdl(aPnt,eLocalKind); pH->SetPointNum(nPNum); pH->SetObj((SdrObject*)this); pH->SetDrehWink(aGeo.nDrehWink); } + return pH; } -FASTBOOL SdrCircObj::HasSpecialDrag() const +//////////////////////////////////////////////////////////////////////////////////////////////////// + +bool SdrCircObj::hasSpecialDrag() const { - return TRUE; + return true; } -FASTBOOL SdrCircObj::BegDrag(SdrDragStat& rDrag) const +bool SdrCircObj::beginSpecialDrag(SdrDragStat& rDrag) const { const bool bWink(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); if(bWink) { - ImpCircUser* pNewUser = new ImpCircUser; - pNewUser->nWink = 0; - rDrag.SetUser(pNewUser); - if(1 == rDrag.GetHdl()->GetPointNum() || 2 == rDrag.GetHdl()->GetPointNum()) { - rDrag.SetNoSnap(TRUE); + rDrag.SetNoSnap(true); } return true; } - else - { - return SdrTextObj::BegDrag(rDrag); - } + + return SdrTextObj::beginSpecialDrag(rDrag); } -FASTBOOL SdrCircObj::MovDrag(SdrDragStat& rDrag) const +bool SdrCircObj::applySpecialDrag(SdrDragStat& rDrag) { const bool bWink(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); if(bWink) { Point aPt(rDrag.GetNow()); - // Unrotate: - if (aGeo.nDrehWink!=0) RotatePoint(aPt,aRect.TopLeft(),-aGeo.nSin,aGeo.nCos); // -sin fuer Umkehrung - // Unshear: - if (aGeo.nShearWink!=0) ShearPoint(aPt,aRect.TopLeft(),-aGeo.nTan); // -tan fuer Umkehrung + + if (aGeo.nDrehWink!=0) + RotatePoint(aPt,aRect.TopLeft(),-aGeo.nSin,aGeo.nCos); + + if (aGeo.nShearWink!=0) + ShearPoint(aPt,aRect.TopLeft(),-aGeo.nTan); + aPt-=aRect.Center(); + long nWdt=aRect.Right()-aRect.Left(); long nHgt=aRect.Bottom()-aRect.Top(); - if (nWdt>=nHgt) { + + if(nWdt>=nHgt) + { aPt.Y()=BigMulDiv(aPt.Y(),nWdt,nHgt); - } else { + } + else + { aPt.X()=BigMulDiv(aPt.X(),nHgt,nWdt); } + long nWink=NormAngle360(GetAngle(aPt)); - if (rDrag.GetView()!=NULL && rDrag.GetView()->IsAngleSnapEnabled()) { + + if (rDrag.GetView() && rDrag.GetView()->IsAngleSnapEnabled()) + { long nSA=rDrag.GetView()->GetSnapAngle(); - if (nSA!=0) { // Winkelfang + + if (nSA!=0) + { nWink+=nSA/2; nWink/=nSA; nWink*=nSA; @@ -631,95 +687,36 @@ FASTBOOL SdrCircObj::MovDrag(SdrDragStat& rDrag) const } } - ImpCircUser* pUserData = (ImpCircUser*)rDrag.GetUser(); - - if(pUserData && pUserData->nWink != nWink) - { - pUserData->nWink = nWink; - return TRUE; - } - else - { - return FALSE; - } - } - else - { - return SdrTextObj::MovDrag(rDrag); - } -} - -FASTBOOL SdrCircObj::EndDrag(SdrDragStat& rDrag) -{ - const bool bWink(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); - - if(bWink) - { - Rectangle aBoundRect0; if(pUserCall) aBoundRect0 = GetLastBoundRect(); - ImpCircUser* pUserData = (ImpCircUser*)rDrag.GetUser(); - if(1 == rDrag.GetHdl()->GetPointNum()) { - nStartWink = pUserData->nWink; + nStartWink = nWink; } else if(2 == rDrag.GetHdl()->GetPointNum()) { - nEndWink = pUserData->nWink; + nEndWink = nWink; } SetRectsDirty(); SetXPolyDirty(); ImpSetCircInfoToAttr(); SetChanged(); - BroadcastObjectChange(); - SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); - return TRUE; + return true; } else { - return SdrTextObj::EndDrag(rDrag); + return SdrTextObj::applySpecialDrag(rDrag); } } -void SdrCircObj::BrkDrag(SdrDragStat& rDrag) const -{ - SdrTextObj::BrkDrag(rDrag); -} - -XubString SdrCircObj::GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const +String SdrCircObj::getSpecialDragComment(const SdrDragStat& rDrag) const { - if(bCreateComment) - { - XubString aStr; - ImpTakeDescriptionStr(STR_ViewCreateObj, aStr); - UINT32 nPntAnz(rDrag.GetPointAnz()); - - if(meCircleKind != OBJ_CIRC && nPntAnz > 2) - { - ImpCircUser* pU = (ImpCircUser*)rDrag.GetUser(); - INT32 nWink; - - aStr.AppendAscii(" ("); - - if(nPntAnz == 3) - nWink = pU->nStart; - else - nWink = pU->nEnd; - - aStr += GetWinkStr(nWink,FALSE); - aStr += sal_Unicode(')'); - } - return aStr; - } - const bool bWink(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); if(bWink) { XubString aStr; - ImpCircUser* pUserData = (ImpCircUser*)rDrag.GetUser(); - const sal_Int32 nWink(pUserData ? pUserData->nWink : 0L); + const sal_Int32 nWink(1 == rDrag.GetHdl()->GetPointNum() ? nStartWink : nEndWink); ImpTakeDescriptionStr(STR_DragCircAngle, aStr); aStr.AppendAscii(" ("); @@ -730,38 +727,11 @@ XubString SdrCircObj::GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDra } else { - return SdrTextObj::GetDragComment(rDrag, bUndoDragComment, FALSE); + return SdrTextObj::getSpecialDragComment(rDrag); } } -basegfx::B2DPolyPolygon SdrCircObj::TakeDragPoly(const SdrDragStat& rDrag) const -{ - const bool bWink(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); - long a(nStartWink); - long e(nEndWink); - - if(bWink) - { - ImpCircUser* pUserData = (ImpCircUser*)rDrag.GetUser(); - - if(pUserData) - { - if(1 == rDrag.GetHdl()->GetPointNum()) - { - a = pUserData->nWink; - } - else - { - e = pUserData->nWink; - } - } - } - - const Rectangle aTmpRect(bWink ? aRect : ImpDragCalcRect(rDrag)); - const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind, aTmpRect, a, e)); - - return basegfx::B2DPolyPolygon(aCircPolygon); -} +//////////////////////////////////////////////////////////////////////////////////////////////////// void ImpCircUser::SetCreateParams(SdrDragStat& rStat) { @@ -792,7 +762,7 @@ void ImpCircUser::SetCreateParams(SdrDragStat& rStat) nStart=NormAngle360(nStart); } } - SetWinkPnt(aR,nStart,aP1); + aP1 = GetWinkPnt(aR,nStart); nEnd=nStart; aP2=aP1; } else aP1=aCenter; @@ -813,7 +783,7 @@ void ImpCircUser::SetCreateParams(SdrDragStat& rStat) nEnd=NormAngle360(nEnd); } } - SetWinkPnt(aR,nEnd,aP2); + aP2 = GetWinkPnt(aR,nEnd); } else aP2=aCenter; } @@ -945,8 +915,6 @@ void SdrCircObj::NbcMove(const Size& aSiz) MoveRect(aRect,aSiz); MoveRect(aOutRect,aSiz); MoveRect(maSnapRect,aSiz); - MovePoint(aPnt1,aSiz); - MovePoint(aPnt2,aSiz); SetXPolyDirty(); SetRectsDirty(sal_True); } @@ -1107,16 +1075,16 @@ void SdrCircObj::TakeUnrotatedSnapRect(Rectangle& rRect) const { rRect=aRect; if (meCircleKind!=OBJ_CIRC) { - SetWinkPnt(rRect,nStartWink,((SdrCircObj*)(this))->aPnt1); - SetWinkPnt(rRect,nEndWink ,((SdrCircObj*)(this))->aPnt2); + const Point aPntStart(GetWinkPnt(aRect,nStartWink)); + const Point aPntEnd(GetWinkPnt(aRect,nEndWink)); long a=nStartWink; long e=nEndWink; rRect.Left ()=aRect.Right(); rRect.Right ()=aRect.Left(); rRect.Top ()=aRect.Bottom(); rRect.Bottom()=aRect.Top(); - Union(rRect,aPnt1); - Union(rRect,aPnt2); + Union(rRect,aPntStart); + Union(rRect,aPntEnd); if ((a<=18000 && e>=18000) || (a>e && (a<=18000 || e>=18000))) { Union(rRect,aRect.LeftCenter()); } @@ -1196,8 +1164,8 @@ sal_uInt32 SdrCircObj::GetSnapPointCount() const Point SdrCircObj::GetSnapPoint(sal_uInt32 i) const { switch (i) { - case 1 : return aPnt1; - case 2 : return aPnt2; + case 1 : return GetWinkPnt(aRect,nStartWink); + case 2 : return GetWinkPnt(aRect,nEndWink); default: return aRect.Center(); } } diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx index f55424c75182..4d4b9a985e15 100644 --- a/svx/source/svdraw/svdoedge.cxx +++ b/svx/source/svdraw/svdoedge.cxx @@ -57,6 +57,7 @@ #include <svx/sdr/contact/viewcontactofsdredgeobj.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -675,8 +676,6 @@ XPolygon SdrEdgeObj::ImpCalcObjToCenter(const Point& rStPt, long nEscAngle, cons FASTBOOL bObn=nEscAngle==9000; FASTBOOL bLks=nEscAngle==18000; FASTBOOL bUnt=nEscAngle==27000; - //FASTBOOL bHor=bLks || bRts; - //FASTBOOL bVer=bObn || bUnt; Point aP1(rStPt); // erstmal den Pflichtabstand if (bLks) aP1.X()=rRect.Left(); @@ -919,8 +918,6 @@ XPolygon SdrEdgeObj::ImpCalcEdgeTrack(const Point& rPt1, long nAngle1, const Rec nQ+=Abs(aXP[3].X()-aXP[2].X())+Abs(aXP[3].Y()-aXP[2].Y()); *pnQuality=nQ; } - //USHORT n1=1; - //USHORT n2=1; if (bInfo) { pInfo->nObj1Lines=2; pInfo->nObj2Lines=2; @@ -1813,163 +1810,210 @@ SdrHdl* SdrEdgeObj::GetHdl(sal_uInt32 nHdlNum) const return pHdl; } -FASTBOOL SdrEdgeObj::HasSpecialDrag() const +//////////////////////////////////////////////////////////////////////////////////////////////////// + +bool SdrEdgeObj::hasSpecialDrag() const { - return TRUE; + return true; +} + +SdrObject* SdrEdgeObj::getFullDragClone() const +{ + // use Clone operator + SdrEdgeObj* pRetval = (SdrEdgeObj*)Clone(); + + // copy connections for clone, SdrEdgeObj::operator= does not do this + pRetval->ConnectToNode(true, GetConnectedNode(true)); + pRetval->ConnectToNode(false, GetConnectedNode(false)); + + return pRetval; } -struct ImpEdgeUser : public SdrDragStatUserData -{ - XPolygon aXP; - SdrObjConnection aCon1; - SdrObjConnection aCon2; - SdrObjConnection* pDragCon; - SdrEdgeInfoRec aInfo; -}; - -FASTBOOL SdrEdgeObj::BegDrag(SdrDragStat& rDragStat) const -{ - if (rDragStat.GetHdl()==NULL) return FALSE; - rDragStat.SetEndDragChangesAttributes(TRUE); - rDragStat.SetUser(new ImpEdgeUser); - ImpEdgeUser* pEdgeUser=(ImpEdgeUser*)rDragStat.GetUser(); - pEdgeUser->aXP=(*pEdgeTrack); - pEdgeUser->aInfo=aEdgeInfo; - pEdgeUser->aCon1=aCon1; - pEdgeUser->aCon2=aCon2; - pEdgeUser->pDragCon=NULL; - if (rDragStat.GetHdl()->GetPointNum()<2) { - rDragStat.SetEndDragChangesGeoAndAttributes(TRUE); - if (rDragStat.GetHdl()->GetPointNum()==0) pEdgeUser->pDragCon=&pEdgeUser->aCon1; - if (rDragStat.GetHdl()->GetPointNum()==1) pEdgeUser->pDragCon=&pEdgeUser->aCon2; - rDragStat.SetNoSnap(TRUE); +bool SdrEdgeObj::beginSpecialDrag(SdrDragStat& rDrag) const +{ + if(!rDrag.GetHdl()) + return false; + + rDrag.SetEndDragChangesAttributes(true); + + if(rDrag.GetHdl()->GetPointNum() < 2) + { + rDrag.SetNoSnap(true); } - return TRUE; + + return true; } -FASTBOOL SdrEdgeObj::MovDrag(SdrDragStat& rDragStat) const -{ - Point aPt(rDragStat.GetNow()); - ImpEdgeUser* pEdgeUser=(ImpEdgeUser*)rDragStat.GetUser(); - const SdrHdl* pHdl=rDragStat.GetHdl(); - const ImpEdgeHdl* pEdgeHdl=(ImpEdgeHdl*)pHdl; - pEdgeUser->aXP=(*pEdgeTrack); - pEdgeUser->aInfo=aEdgeInfo; - if (pHdl->GetPointNum()<2) { - pEdgeUser->pDragCon->pObj=NULL; - if (rDragStat.GetPageView()!=NULL) { - ImpFindConnector(aPt,*rDragStat.GetPageView(),*pEdgeUser->pDragCon,this); - if (rDragStat.GetView()!=NULL) { - rDragStat.GetView()->SetConnectMarker(*pEdgeUser->pDragCon,*rDragStat.GetPageView()); +bool SdrEdgeObj::applySpecialDrag(SdrDragStat& rDragStat) +{ + SdrEdgeObj* pOriginalEdge = dynamic_cast< SdrEdgeObj* >(rDragStat.GetHdl()->GetObj()); + const bool bOriginalEdgeModified(pOriginalEdge == this); + + if(!bOriginalEdgeModified && pOriginalEdge) + { + // copy connections when clone is modified. This is needed because + // as preparation to this modification the data from the original object + // was copied to the clone using the operator=. As can be seen there, + // that operator does not copy the connections (for good reason) + ConnectToNode(true, pOriginalEdge->GetConnection(true).GetObject()); + ConnectToNode(false, pOriginalEdge->GetConnection(false).GetObject()); + } + + if(rDragStat.GetHdl()->GetPointNum() < 2) + { + // start or end point connector drag + const bool bDragA(0 == rDragStat.GetHdl()->GetPointNum()); + const Point aPointNow(rDragStat.GetNow()); + + if(rDragStat.GetPageView()) + { + SdrObjConnection* pDraggedOne(bDragA ? &aCon1 : &aCon2); + + // clear connection + DisconnectFromNode(bDragA); + + // look for new connection + ImpFindConnector(aPointNow, *rDragStat.GetPageView(), *pDraggedOne, pOriginalEdge); + + if(pDraggedOne->pObj) + { + // if found, officially connect to it; ImpFindConnector only + // sets pObj hard + SdrObject* pNewConnection = pDraggedOne->pObj; + pDraggedOne->pObj = 0; + ConnectToNode(bDragA, pNewConnection); + } + + if(rDragStat.GetView() && !bOriginalEdgeModified) + { + // show IA helper, but only do this during IA, so not when the original + // Edge gets modified in the last call + rDragStat.GetView()->SetConnectMarker(*pDraggedOne, *rDragStat.GetPageView()); } } - if (pHdl->GetPointNum()==0) pEdgeUser->aXP[0]=aPt; - else pEdgeUser->aXP[USHORT(pEdgeUser->aXP.GetPointCount()-1)]=aPt; - pEdgeUser->aInfo.aObj1Line2=Point(); - pEdgeUser->aInfo.aObj1Line3=Point(); - pEdgeUser->aInfo.aObj2Line2=Point(); - pEdgeUser->aInfo.aObj2Line3=Point(); - pEdgeUser->aInfo.aMiddleLine=Point(); - } else { // Sonst Dragging eines Linienversatzes - SdrEdgeLineCode eLineCode=pEdgeHdl->GetLineCode(); - Point aDist(rDragStat.GetNow()); aDist-=rDragStat.GetStart(); - long nDist=pEdgeHdl->IsHorzDrag() ? aDist.X() : aDist.Y(); - nDist+=pEdgeUser->aInfo.ImpGetLineVersatz(eLineCode,pEdgeUser->aXP); - pEdgeUser->aInfo.ImpSetLineVersatz(eLineCode,pEdgeUser->aXP,nDist); - } - pEdgeUser->aXP=ImpCalcEdgeTrack(pEdgeUser->aXP,pEdgeUser->aCon1,pEdgeUser->aCon2,&pEdgeUser->aInfo); - return TRUE; -} -FASTBOOL SdrEdgeObj::EndDrag(SdrDragStat& rDragStat) -{ - Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect(); - // #110094#-14 SendRepaintBroadcast(); - ImpEdgeUser* pEdgeUser=(ImpEdgeUser*)rDragStat.GetUser(); - if (rDragStat.GetHdl()->GetPointNum()<2) { - (*pEdgeTrack)=pEdgeUser->aXP; - aEdgeInfo=pEdgeUser->aInfo; - if (rDragStat.GetHdl()->GetPointNum()==0) { - ConnectToNode(TRUE,pEdgeUser->aCon1.pObj); - aCon1=pEdgeUser->aCon1; - } else { - ConnectToNode(FALSE,pEdgeUser->aCon2.pObj); - aCon2=pEdgeUser->aCon2; + if(pEdgeTrack) + { + // change pEdgeTrack to modified position + if(bDragA) + { + (*pEdgeTrack)[0] = aPointNow; + } + else + { + (*pEdgeTrack)[sal_uInt16(pEdgeTrack->GetPointCount()-1)] = aPointNow; + } } - } else { // Sonst Dragging eines Linienversatzes - (*pEdgeTrack)=pEdgeUser->aXP; - aEdgeInfo=pEdgeUser->aInfo; + + // reset edge info's offsets, this is a end point drag + aEdgeInfo.aObj1Line2 = Point(); + aEdgeInfo.aObj1Line3 = Point(); + aEdgeInfo.aObj2Line2 = Point(); + aEdgeInfo.aObj2Line3 = Point(); + aEdgeInfo.aMiddleLine = Point(); } - ImpSetEdgeInfoToAttr(); - delete (ImpEdgeUser*)rDragStat.GetUser(); - rDragStat.SetUser(NULL); - bEdgeTrackUserDefined = sal_False; - SetRectsDirty(); - SetChanged(); - BroadcastObjectChange(); - if (rDragStat.GetView()!=NULL) { - rDragStat.GetView()->HideConnectMarker(); + else + { + // control point connector drag + const ImpEdgeHdl* pEdgeHdl = (ImpEdgeHdl*)rDragStat.GetHdl(); + const SdrEdgeLineCode eLineCode = pEdgeHdl->GetLineCode(); + const Point aDist(rDragStat.GetNow() - rDragStat.GetStart()); + sal_Int32 nDist(pEdgeHdl->IsHorzDrag() ? aDist.X() : aDist.Y()); + + nDist += aEdgeInfo.ImpGetLineVersatz(eLineCode, *pEdgeTrack); + aEdgeInfo.ImpSetLineVersatz(eLineCode, *pEdgeTrack, nDist); } - SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); - return TRUE; -} -void SdrEdgeObj::BrkDrag(SdrDragStat& rDragStat) const -{ - delete (ImpEdgeUser*)rDragStat.GetUser(); - rDragStat.SetUser(NULL); - if (rDragStat.GetView()!=NULL) { + // force recalc EdgeTrack + *pEdgeTrack = ImpCalcEdgeTrack(*pEdgeTrack, aCon1, aCon2, &aEdgeInfo); + bEdgeTrackDirty=FALSE; + + // save EdgeInfos and mark object as user modified + ImpSetEdgeInfoToAttr(); + bEdgeTrackUserDefined = false; + //SetRectsDirty(); + //SetChanged(); + + if(bOriginalEdgeModified && rDragStat.GetView()) + { + // hide connect marker helper again when original gets changed. + // This happens at the end of the interaction rDragStat.GetView()->HideConnectMarker(); } + + return true; } -XubString SdrEdgeObj::GetDragComment(const SdrDragStat& /*rDragStat*/, FASTBOOL /*bUndoDragComment*/, FASTBOOL bCreateComment) const +String SdrEdgeObj::getSpecialDragComment(const SdrDragStat& /*rDrag*/) const { XubString aStr; - if (!bCreateComment) ImpTakeDescriptionStr(STR_DragEdgeTail,aStr); + ImpTakeDescriptionStr(STR_DragEdgeTail,aStr); return aStr; } -basegfx::B2DPolyPolygon SdrEdgeObj::TakeDragPoly(const SdrDragStat& rDragStat) const -{ - ImpEdgeUser* pEdgeUser=(ImpEdgeUser*)rDragStat.GetUser(); - - XPolyPolygon aXPP; - aXPP.Insert(pEdgeUser->aXP); - return aXPP.getB2DPolyPolygon(); -} +//////////////////////////////////////////////////////////////////////////////////////////////////// -void SdrEdgeObj::ImplAddConnectorOverlay(basegfx::B2DPolyPolygon& rResult, SdrDragMethod& rDragMethod, sal_Bool bTail1, sal_Bool bTail2, sal_Bool bDetail) const +basegfx::B2DPolygon SdrEdgeObj::ImplAddConnectorOverlay(SdrDragMethod& rDragMethod, bool bTail1, bool bTail2, bool bDetail) const { + basegfx::B2DPolygon aResult; + if(bDetail) { SdrObjConnection aMyCon1(aCon1); SdrObjConnection aMyCon2(aCon2); - if (bTail1) rDragMethod.MovPoint(aMyCon1.aObjOfs); - if (bTail2) rDragMethod.MovPoint(aMyCon2.aObjOfs); + + if (bTail1) + { + const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aMyCon1.aObjOfs.X(), aMyCon1.aObjOfs.Y())); + aMyCon1.aObjOfs.X() = basegfx::fround(aTemp.getX()); + aMyCon1.aObjOfs.Y() = basegfx::fround(aTemp.getY()); + } + + if (bTail2) + { + const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aMyCon2.aObjOfs.X(), aMyCon2.aObjOfs.Y())); + aMyCon2.aObjOfs.X() = basegfx::fround(aTemp.getX()); + aMyCon2.aObjOfs.Y() = basegfx::fround(aTemp.getY()); + } + SdrEdgeInfoRec aInfo(aEdgeInfo); XPolygon aXP(ImpCalcEdgeTrack(*pEdgeTrack, aMyCon1, aMyCon2, &aInfo)); if(aXP.GetPointCount()) { - rResult.append(aXP.getB2DPolygon()); + aResult = aXP.getB2DPolygon(); } } else { Point aPt1((*pEdgeTrack)[0]); Point aPt2((*pEdgeTrack)[sal_uInt16(pEdgeTrack->GetPointCount() - 1)]); - if (aCon1.pObj && (aCon1.bBestConn || aCon1.bBestVertex)) aPt1 = aCon1.pObj->GetSnapRect().Center(); - if (aCon2.pObj && (aCon2.bBestConn || aCon2.bBestVertex)) aPt2 = aCon2.pObj->GetSnapRect().Center(); - if (bTail1) rDragMethod.MovPoint(aPt1); - if (bTail2) rDragMethod.MovPoint(aPt2); - basegfx::B2DPolygon aTemporary; - aTemporary.append(basegfx::B2DPoint(aPt1.X(), aPt1.Y())); - aTemporary.append(basegfx::B2DPoint(aPt2.X(), aPt2.Y())); + if (aCon1.pObj && (aCon1.bBestConn || aCon1.bBestVertex)) + aPt1 = aCon1.pObj->GetSnapRect().Center(); + + if (aCon2.pObj && (aCon2.bBestConn || aCon2.bBestVertex)) + aPt2 = aCon2.pObj->GetSnapRect().Center(); + + if (bTail1) + { + const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aPt1.X(), aPt1.Y())); + aPt1.X() = basegfx::fround(aTemp.getX()); + aPt1.Y() = basegfx::fround(aTemp.getY()); + } - rResult.append(aTemporary); + if (bTail2) + { + const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aPt2.X(), aPt2.Y())); + aPt2.X() = basegfx::fround(aTemp.getX()); + aPt2.Y() = basegfx::fround(aTemp.getY()); + } + + aResult.append(basegfx::B2DPoint(aPt1.X(), aPt1.Y())); + aResult.append(basegfx::B2DPoint(aPt2.X(), aPt2.Y())); } + + return aResult; } FASTBOOL SdrEdgeObj::BegCreate(SdrDragStat& rDragStat) diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index fd6d76f0b94b..805577df9b72 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -717,13 +717,6 @@ basegfx::B2DPolyPolygon SdrGrafObj::TakeXorPoly() const // ----------------------------------------------------------------------------- -FASTBOOL SdrGrafObj::HasSpecialDrag() const -{ - return TRUE; -} - -// ----------------------------------------------------------------------------- - sal_uInt32 SdrGrafObj::GetHdlCount() const { return 8L; diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx index c2408bb42061..879a53851919 100644 --- a/svx/source/svdraw/svdogrp.cxx +++ b/svx/source/svdraw/svdogrp.cxx @@ -402,9 +402,9 @@ basegfx::B2DPolyPolygon SdrObjGroup::TakeXorPoly() const return aRetval; } -FASTBOOL SdrObjGroup::BegDrag(SdrDragStat& /*rDrag*/) const +bool SdrObjGroup::beginSpecialDrag(SdrDragStat& /*rDrag*/) const { - return FALSE; + return false; } diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx index a446be3d0efe..5e61a923a51e 100644 --- a/svx/source/svdraw/svdomeas.cxx +++ b/svx/source/svdraw/svdomeas.cxx @@ -860,47 +860,55 @@ SdrHdl* SdrMeasureObj::GetHdl(sal_uInt32 nHdlNum) const return pHdl; } -FASTBOOL SdrMeasureObj::HasSpecialDrag() const +//////////////////////////////////////////////////////////////////////////////////////////////////// + +bool SdrMeasureObj::hasSpecialDrag() const { - return TRUE; + return true; } -FASTBOOL SdrMeasureObj::BegDrag(SdrDragStat& rDrag) const +bool SdrMeasureObj::beginSpecialDrag(SdrDragStat& rDrag) const { - const SdrHdl* pHdl=rDrag.GetHdl(); - if (pHdl!=NULL) { - sal_uInt32 nHdlNum(pHdl->GetObjHdlNum()); - if (nHdlNum!=2L && nHdlNum!=3L) { - rDrag.SetEndDragChangesAttributes(TRUE); + const SdrHdl* pHdl = rDrag.GetHdl(); + + if(pHdl) + { + const sal_uInt32 nHdlNum(pHdl->GetObjHdlNum()); + + if(nHdlNum != 2 && nHdlNum != 3) + { + rDrag.SetEndDragChangesAttributes(true); } - ImpMeasureRec* pMR=new ImpMeasureRec; // #48544# - ImpTakeAttr(*pMR); - rDrag.SetUser(pMR); - } - return pHdl!=NULL; -} -FASTBOOL SdrMeasureObj::MovDrag(SdrDragStat& rDrag) const -{ - ImpMeasureRec* pMR=(ImpMeasureRec*)rDrag.GetUser(); - if (pMR!=NULL) { // #48544# - ImpTakeAttr(*pMR); - ImpEvalDrag(*pMR,rDrag); + return true; } - return TRUE; + + return false; } -FASTBOOL SdrMeasureObj::EndDrag(SdrDragStat& rDrag) +bool SdrMeasureObj::applySpecialDrag(SdrDragStat& rDrag) { - Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect(); - ImpMeasureRec* pMR=(ImpMeasureRec*)rDrag.GetUser(); // #48544# - ImpMeasureRec aRec0; - ImpTakeAttr(aRec0); - const SdrHdl* pHdl=rDrag.GetHdl(); - sal_uInt32 nHdlNum(pHdl->GetObjHdlNum()); - switch (nHdlNum) { - case 2: aPt1=pMR->aPt1; SetTextDirty(); break; - case 3: aPt2=pMR->aPt2; SetTextDirty(); break; + ImpMeasureRec aMeasureRec; + const SdrHdl* pHdl = rDrag.GetHdl(); + const sal_uInt32 nHdlNum(pHdl->GetObjHdlNum()); + + ImpTakeAttr(aMeasureRec); + ImpEvalDrag(aMeasureRec, rDrag); + + switch (nHdlNum) + { + case 2: + { + aPt1 = aMeasureRec.aPt1; + SetTextDirty(); + break; + } + case 3: + { + aPt2 = aMeasureRec.aPt2; + SetTextDirty(); + break; + } default: { switch(nHdlNum) @@ -908,14 +916,17 @@ FASTBOOL SdrMeasureObj::EndDrag(SdrDragStat& rDrag) case 0: case 1: { - if(pMR->nHelpline1Len!=aRec0.nHelpline1Len) + ImpMeasureRec aOrigMeasureRec; + ImpTakeAttr(aOrigMeasureRec); + + if(aMeasureRec.nHelpline1Len != aOrigMeasureRec.nHelpline1Len) { - SetObjectItem(SdrMeasureHelpline1LenItem(pMR->nHelpline1Len)); + SetObjectItem(SdrMeasureHelpline1LenItem(aMeasureRec.nHelpline1Len)); } - if(pMR->nHelpline2Len!=aRec0.nHelpline2Len) + if(aMeasureRec.nHelpline2Len != aOrigMeasureRec.nHelpline2Len) { - SetObjectItem(SdrMeasureHelpline2LenItem(pMR->nHelpline2Len)); + SetObjectItem(SdrMeasureHelpline2LenItem(aMeasureRec.nHelpline2Len)); } break; @@ -924,43 +935,30 @@ FASTBOOL SdrMeasureObj::EndDrag(SdrDragStat& rDrag) case 4: case 5: { - if (pMR->nLineDist!=aRec0.nLineDist) + ImpMeasureRec aOrigMeasureRec; + ImpTakeAttr(aOrigMeasureRec); + + if(aMeasureRec.nLineDist != aOrigMeasureRec.nLineDist) { - SetObjectItem(SdrMeasureLineDistItem(pMR->nLineDist)); + SetObjectItem(SdrMeasureLineDistItem(aMeasureRec.nLineDist)); } - if(pMR->bBelowRefEdge!=aRec0.bBelowRefEdge) + if(aMeasureRec.bBelowRefEdge != aOrigMeasureRec.bBelowRefEdge) { - SetObjectItem(SdrMeasureBelowRefEdgeItem(pMR->bBelowRefEdge)); + SetObjectItem(SdrMeasureBelowRefEdgeItem(aMeasureRec.bBelowRefEdge)); } } } } } // switch - SetRectsDirty(); - // Here is a SetCHanged() missing, object gets changed. + SetRectsDirty(); SetChanged(); - BroadcastObjectChange(); - - if (pMR!=NULL) { - delete pMR; // #48544# - rDrag.SetUser(NULL); - } - SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); - return TRUE; -} -void SdrMeasureObj::BrkDrag(SdrDragStat& rDrag) const -{ - ImpMeasureRec* pMR=(ImpMeasureRec*)rDrag.GetUser(); - if (pMR!=NULL) { - delete pMR; // #48544# - rDrag.SetUser(NULL); - } + return true; } -XubString SdrMeasureObj::GetDragComment(const SdrDragStat& /*rDrag*/, FASTBOOL /*bUndoDragComment*/, FASTBOOL /*bCreateComment*/) const +String SdrMeasureObj::getSpecialDragComment(const SdrDragStat& /*rDrag*/) const { XubString aStr; return aStr; @@ -1034,20 +1032,7 @@ void SdrMeasureObj::ImpEvalDrag(ImpMeasureRec& rRec, const SdrDragStat& rDrag) c } // switch } -basegfx::B2DPolyPolygon SdrMeasureObj::TakeDragPoly(const SdrDragStat& rDrag) const -{ - basegfx::B2DPolyPolygon aRetval; - ImpMeasureRec* pMR = (ImpMeasureRec*)rDrag.GetUser(); // #48544# - - if(pMR) - { - ImpMeasurePoly aMPol; - ImpCalcGeometrics(*pMR, aMPol); - aRetval.append(ImpCalcXPoly(aMPol)); - } - - return aRetval; -} +//////////////////////////////////////////////////////////////////////////////////////////////////// FASTBOOL SdrMeasureObj::BegCreate(SdrDragStat& rStat) { diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index 60cc420716c2..791915e1e977 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -88,6 +88,7 @@ #include "impgrf.hxx" #include <svtools/chartprettypainter.hxx> #include <svx/sdr/contact/viewcontactofsdrole2obj.hxx> +#include <svx/svdograf.hxx> using namespace ::rtl; using namespace ::com::sun::star; @@ -1466,6 +1467,29 @@ void SdrOle2Obj::SetClosedObj( bool bIsClosed ) // ----------------------------------------------------------------------------- +SdrObject* SdrOle2Obj::getFullDragClone() const +{ + // special handling for OLE. The default handling works, but is too + // slow when the whole OLE needs to be cloned. Get the Metafile and + // create a graphic object with it + Graphic* pOLEGraphic = GetGraphic(); + + if(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) + { + pOLEGraphic = getEmbeddedObjectRef().GetHCGraphic(); + } + + SdrObject* pClone = new SdrGrafObj(*pOLEGraphic, GetSnapRect()); + + // this would be the place where to copy all attributes + // when OLE will support fill and line style + // pClone->SetMergedItem(pOleObject->GetMergedItemSet()); + + return pClone; +} + +// ----------------------------------------------------------------------------- + void SdrOle2Obj::SetPersistName( const String& rPersistName ) { DBG_ASSERT( !mpImpl->aPersistName.Len(), "Persist name changed!"); @@ -1636,13 +1660,6 @@ void SdrOle2Obj::operator=(const SdrObject& rObj) // ----------------------------------------------------------------------------- -FASTBOOL SdrOle2Obj::HasSpecialDrag() const -{ - return FALSE; -} - -// ----------------------------------------------------------------------------- - void SdrOle2Obj::ImpSetVisAreaSize() { // currently there is no need to recalculate scaling for iconified objects diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index 0f8213d37e9e..c2ee3d910559 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -151,14 +151,13 @@ ImpSdrPathDragData::ImpSdrPathDragData(const SdrPathObj& rPO, const SdrHdl& rHdl const SdrMarkView& rMarkView = *rDrag.GetView(); const SdrHdlList& rHdlList = rMarkView.GetHdlList(); const sal_uInt32 nHdlCount = rHdlList.GetHdlCount(); + const SdrObject* pInteractionObject(nHdlCount && rHdlList.GetHdl(0) ? rHdlList.GetHdl(0)->GetObj() : 0); for(sal_uInt32 a(0); a < nHdlCount; a++) { SdrHdl* pTestHdl = rHdlList.GetHdl(a); - if(pTestHdl - && pTestHdl->IsSelected() - && pTestHdl->GetObj() == (SdrObject*)&rPO) + if(pTestHdl && pTestHdl->IsSelected() && pTestHdl->GetObj() == pInteractionObject) { maHandles.Insert(pTestHdl, CONTAINER_APPEND); } @@ -514,6 +513,7 @@ class ImpPathForDragAndCreate SdrPathObj& mrSdrPathObject; XPolyPolygon aPathPolygon; SdrObjKind meObjectKind; + ImpSdrPathDragData* mpSdrPathDragData; bool mbCreating; public: @@ -521,12 +521,12 @@ public: ~ImpPathForDragAndCreate(); // drag stuff - FASTBOOL BegDrag(SdrDragStat& rDrag) const; - FASTBOOL MovDrag(SdrDragStat& rDrag) const; - FASTBOOL EndDrag(SdrDragStat& rDrag); - void BrkDrag(SdrDragStat& rDrag) const; - String GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const; - basegfx::B2DPolyPolygon TakeDragPoly(const SdrDragStat& rDrag) const; + bool beginPathDrag( SdrDragStat& rDrag ) const; + bool movePathDrag( SdrDragStat& rDrag ) const; + bool endPathDrag( SdrDragStat& rDrag ); + //void cancelSpecialDrag( SdrDragStat& rDrag ) const; + String getSpecialDragComment(const SdrDragStat& rDrag) const; + basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const; // create stuff FASTBOOL BegCreate(SdrDragStat& rStat); @@ -552,15 +552,20 @@ ImpPathForDragAndCreate::ImpPathForDragAndCreate(SdrPathObj& rSdrPathObject) : mrSdrPathObject(rSdrPathObject), aPathPolygon(rSdrPathObject.GetPathPoly()), meObjectKind(mrSdrPathObject.meKind), + mpSdrPathDragData(0), mbCreating(false) { } ImpPathForDragAndCreate::~ImpPathForDragAndCreate() { + if(mpSdrPathDragData) + { + delete mpSdrPathDragData; + } } -FASTBOOL ImpPathForDragAndCreate::BegDrag(SdrDragStat& rDrag) const +bool ImpPathForDragAndCreate::beginPathDrag( SdrDragStat& rDrag ) const { const SdrHdl* pHdl=rDrag.GetHdl(); if(!pHdl) @@ -576,18 +581,14 @@ FASTBOOL ImpPathForDragAndCreate::BegDrag(SdrDragStat& rDrag) const const SdrMarkView& rMarkView = *rDrag.GetView(); const SdrHdlList& rHdlList = rMarkView.GetHdlList(); const sal_uInt32 nHdlCount = rHdlList.GetHdlCount(); + const SdrObject* pInteractionObject(nHdlCount && rHdlList.GetHdl(0) ? rHdlList.GetHdl(0)->GetObj() : 0); sal_uInt32 nSelectedPoints(0); for(sal_uInt32 a(0); a < nHdlCount; a++) { SdrHdl* pTestHdl = rHdlList.GetHdl(a); - if(pTestHdl - && pTestHdl->IsSelected() - // #i77148# OOps - comparison need to be done with the SdrObject, not with his. - // This is an error from drag isolation and a good example that direct c-casts - // are bad. - && pTestHdl->GetObj() == &mrSdrPathObject) + if(pTestHdl && pTestHdl->IsSelected() && pTestHdl->GetObj() == pInteractionObject) { nSelectedPoints++; } @@ -597,38 +598,40 @@ FASTBOOL ImpPathForDragAndCreate::BegDrag(SdrDragStat& rDrag) const bMultiPointDrag = FALSE; } - ImpSdrPathDragData* pID=new ImpSdrPathDragData(mrSdrPathObject,*pHdl,bMultiPointDrag,rDrag); - if (!pID->bValid) { + ((ImpPathForDragAndCreate*)this)->mpSdrPathDragData = new ImpSdrPathDragData(mrSdrPathObject,*pHdl,bMultiPointDrag,rDrag); + + if(!mpSdrPathDragData || !mpSdrPathDragData->bValid) + { DBG_ERROR("ImpPathForDragAndCreate::BegDrag(): ImpSdrPathDragData ist ungueltig"); - delete pID; - return FALSE; + delete mpSdrPathDragData; + ((ImpPathForDragAndCreate*)this)->mpSdrPathDragData = 0; + return false; } - rDrag.SetUser(pID); - return TRUE; + return true; } -FASTBOOL ImpPathForDragAndCreate::MovDrag(SdrDragStat& rDrag) const +bool ImpPathForDragAndCreate::movePathDrag( SdrDragStat& rDrag ) const { - ImpSdrPathDragData* pID=(ImpSdrPathDragData*)rDrag.GetUser(); - if (pID==NULL || !pID->bValid) { + if(!mpSdrPathDragData || !mpSdrPathDragData->bValid) + { DBG_ERROR("ImpPathForDragAndCreate::MovDrag(): ImpSdrPathDragData ist ungueltig"); - return FALSE; + return false; } - if(pID->IsMultiPointDrag()) + if(mpSdrPathDragData->IsMultiPointDrag()) { Point aDelta(rDrag.GetNow() - rDrag.GetStart()); if(aDelta.X() || aDelta.Y()) { - for(sal_uInt32 a(0); a < pID->maHandles.Count(); a++) + for(sal_uInt32 a(0); a < mpSdrPathDragData->maHandles.Count(); a++) { - SdrHdl* pHandle = (SdrHdl*)pID->maHandles.GetObject(a); + SdrHdl* pHandle = (SdrHdl*)mpSdrPathDragData->maHandles.GetObject(a); const sal_uInt16 nPolyIndex((sal_uInt16)pHandle->GetPolyNum()); const sal_uInt16 nPointIndex((sal_uInt16)pHandle->GetPointNum()); - const XPolygon& rOrig = pID->maOrig[nPolyIndex]; - XPolygon& rMove = pID->maMove[nPolyIndex]; + const XPolygon& rOrig = mpSdrPathDragData->maOrig[nPolyIndex]; + XPolygon& rMove = mpSdrPathDragData->maMove[nPolyIndex]; const sal_uInt16 nPointCount(rOrig.GetPointCount()); BOOL bClosed(rOrig[0] == rOrig[nPointCount-1]); @@ -664,43 +667,43 @@ FASTBOOL ImpPathForDragAndCreate::MovDrag(SdrDragStat& rDrag) const } else { - pID->ResetPoly(mrSdrPathObject); + mpSdrPathDragData->ResetPoly(mrSdrPathObject); // Div. Daten lokal Kopieren fuer weniger Code und schnelleren Zugriff - FASTBOOL bClosed =pID->bClosed ; // geschlossenes Objekt? - USHORT nPnt =pID->nPnt ; // Punktnummer innerhalb des obigen Polygons - FASTBOOL bBegPnt =pID->bBegPnt ; // Gedraggter Punkt ist der Anfangspunkt einer Polyline - FASTBOOL bEndPnt =pID->bEndPnt ; // Gedraggter Punkt ist der Endpunkt einer Polyline - USHORT nPrevPnt =pID->nPrevPnt ; // Index des vorherigen Punkts - USHORT nNextPnt =pID->nNextPnt ; // Index des naechsten Punkts - FASTBOOL bPrevIsBegPnt =pID->bPrevIsBegPnt ; // Vorheriger Punkt ist Anfangspunkt einer Polyline - FASTBOOL bNextIsEndPnt =pID->bNextIsEndPnt ; // Folgepunkt ist Endpunkt einer Polyline - USHORT nPrevPrevPnt =pID->nPrevPrevPnt ; // Index des vorvorherigen Punkts - USHORT nNextNextPnt =pID->nNextNextPnt ; // Index des uebernaechsten Punkts - FASTBOOL bControl =pID->bControl ; // Punkt ist ein Kontrollpunkt - //FASTBOOL bIsPrevControl=pID->bIsPrevControl; // Punkt ist Kontrollpunkt vor einem Stuetzpunkt - FASTBOOL bIsNextControl=pID->bIsNextControl; // Punkt ist Kontrollpunkt hinter einem Stuetzpunkt - FASTBOOL bPrevIsControl=pID->bPrevIsControl; // Falls nPnt ein StPnt: Davor ist ein Kontrollpunkt - FASTBOOL bNextIsControl=pID->bNextIsControl; // Falls nPnt ein StPnt: Dahinter ist ein Kontrollpunkt + FASTBOOL bClosed =mpSdrPathDragData->bClosed ; // geschlossenes Objekt? + USHORT nPnt =mpSdrPathDragData->nPnt ; // Punktnummer innerhalb des obigen Polygons + FASTBOOL bBegPnt =mpSdrPathDragData->bBegPnt ; // Gedraggter Punkt ist der Anfangspunkt einer Polyline + FASTBOOL bEndPnt =mpSdrPathDragData->bEndPnt ; // Gedraggter Punkt ist der Endpunkt einer Polyline + USHORT nPrevPnt =mpSdrPathDragData->nPrevPnt ; // Index des vorherigen Punkts + USHORT nNextPnt =mpSdrPathDragData->nNextPnt ; // Index des naechsten Punkts + FASTBOOL bPrevIsBegPnt =mpSdrPathDragData->bPrevIsBegPnt ; // Vorheriger Punkt ist Anfangspunkt einer Polyline + FASTBOOL bNextIsEndPnt =mpSdrPathDragData->bNextIsEndPnt ; // Folgepunkt ist Endpunkt einer Polyline + USHORT nPrevPrevPnt =mpSdrPathDragData->nPrevPrevPnt ; // Index des vorvorherigen Punkts + USHORT nNextNextPnt =mpSdrPathDragData->nNextNextPnt ; // Index des uebernaechsten Punkts + FASTBOOL bControl =mpSdrPathDragData->bControl ; // Punkt ist ein Kontrollpunkt + //FASTBOOL bIsPrevControl=mpSdrPathDragData->bIsPrevControl; // Punkt ist Kontrollpunkt vor einem Stuetzpunkt + FASTBOOL bIsNextControl=mpSdrPathDragData->bIsNextControl; // Punkt ist Kontrollpunkt hinter einem Stuetzpunkt + FASTBOOL bPrevIsControl=mpSdrPathDragData->bPrevIsControl; // Falls nPnt ein StPnt: Davor ist ein Kontrollpunkt + FASTBOOL bNextIsControl=mpSdrPathDragData->bNextIsControl; // Falls nPnt ein StPnt: Dahinter ist ein Kontrollpunkt // Ortho bei Linien/Polygonen = Winkel beibehalten if (!bControl && rDrag.GetView()!=NULL && rDrag.GetView()->IsOrtho()) { FASTBOOL bBigOrtho=rDrag.GetView()->IsBigOrtho(); Point aPos(rDrag.GetNow()); // die aktuelle Position - Point aPnt(pID->aXP[nPnt]); // der gedraggte Punkt + Point aPnt(mpSdrPathDragData->aXP[nPnt]); // der gedraggte Punkt USHORT nPnt1=0xFFFF,nPnt2=0xFFFF; // seine Nachbarpunkte Point aNeuPos1,aNeuPos2; // die neuen Alternativen fuer aPos FASTBOOL bPnt1=FALSE,bPnt2=FALSE; // die neuen Alternativen gueltig? - if (!bClosed && pID->nPntAnz>=2) { // Mind. 2 Pt bei Linien + if (!bClosed && mpSdrPathDragData->nPntAnz>=2) { // Mind. 2 Pt bei Linien if (!bBegPnt) nPnt1=nPrevPnt; if (!bEndPnt) nPnt2=nNextPnt; } - if (bClosed && pID->nPntAnz>=3) { // Mind. 3 Pt bei Polygon + if (bClosed && mpSdrPathDragData->nPntAnz>=3) { // Mind. 3 Pt bei Polygon nPnt1=nPrevPnt; nPnt2=nNextPnt; } if (nPnt1!=0xFFFF && !bPrevIsControl) { - Point aPnt1=pID->aXP[nPnt1]; + Point aPnt1=mpSdrPathDragData->aXP[nPnt1]; long ndx0=aPnt.X()-aPnt1.X(); long ndy0=aPnt.Y()-aPnt1.Y(); FASTBOOL bHLin=ndy0==0; @@ -721,7 +724,7 @@ FASTBOOL ImpPathForDragAndCreate::MovDrag(SdrDragStat& rDrag) const } } if (nPnt2!=0xFFFF && !bNextIsControl) { - Point aPnt2=pID->aXP[nPnt2]; + Point aPnt2=mpSdrPathDragData->aXP[nPnt2]; long ndx0=aPnt.X()-aPnt2.X(); long ndy0=aPnt.Y()-aPnt2.Y(); FASTBOOL bHLin=ndy0==0; @@ -761,25 +764,25 @@ FASTBOOL ImpPathForDragAndCreate::MovDrag(SdrDragStat& rDrag) const if (!bControl && rDrag.GetView()!=NULL && rDrag.GetView()->IsEliminatePolyPoints() && !bBegPnt && !bEndPnt && !bPrevIsControl && !bNextIsControl) { - Point aPt(pID->aXP[nNextPnt]); + Point aPt(mpSdrPathDragData->aXP[nNextPnt]); aPt-=rDrag.GetNow(); long nWink1=GetAngle(aPt); aPt=rDrag.GetNow(); - aPt-=pID->aXP[nPrevPnt]; + aPt-=mpSdrPathDragData->aXP[nPrevPnt]; long nWink2=GetAngle(aPt); long nDiff=nWink1-nWink2; nDiff=Abs(nDiff); - pID->bEliminate=nDiff<=rDrag.GetView()->GetEliminatePolyPointLimitAngle(); - if (pID->bEliminate) { // Position anpassen, damit Smooth an den Enden stimmt - aPt=pID->aXP[nNextPnt]; - aPt+=pID->aXP[nPrevPnt]; + mpSdrPathDragData->bEliminate=nDiff<=rDrag.GetView()->GetEliminatePolyPointLimitAngle(); + if (mpSdrPathDragData->bEliminate) { // Position anpassen, damit Smooth an den Enden stimmt + aPt=mpSdrPathDragData->aXP[nNextPnt]; + aPt+=mpSdrPathDragData->aXP[nPrevPnt]; aPt/=2; rDrag.Now()=aPt; } } // Um diese Entfernung wurde insgesamt gedraggd - Point aDiff(rDrag.GetNow()); aDiff-=pID->aXP[nPnt]; + Point aDiff(rDrag.GetNow()); aDiff-=mpSdrPathDragData->aXP[nPnt]; // Insgesamt sind 8 Faelle moeglich: // X 1. Weder rechts noch links Ctrl. @@ -794,7 +797,7 @@ FASTBOOL ImpPathForDragAndCreate::MovDrag(SdrDragStat& rDrag) const // eine evtl. Kurve am anderen Ende der Linie bewirkt, falls dort Smooth // gesetzt ist (Kontrollpunktausrichtung an Gerade). - pID->aXP[nPnt]+=aDiff; + mpSdrPathDragData->aXP[nPnt]+=aDiff; // Nun symmetrische PlusHandles etc. checken if (bControl) { // Faelle 5,6,7,8 @@ -807,44 +810,44 @@ FASTBOOL ImpPathForDragAndCreate::MovDrag(SdrDragStat& rDrag) const nSt=nNextPnt; nFix=nNextNextPnt; } - if (pID->aXP.IsSmooth(nSt)) { - pID->aXP.CalcSmoothJoin(nSt,nPnt,nFix); + if (mpSdrPathDragData->aXP.IsSmooth(nSt)) { + mpSdrPathDragData->aXP.CalcSmoothJoin(nSt,nPnt,nFix); } } if (!bControl) { // Faelle 1,2,3,4 wobei bei 1 nix passiert und bei 3+4 unten noch mehr folgt // die beiden Kontrollpunkte mit verschieben - if (bPrevIsControl) pID->aXP[nPrevPnt]+=aDiff; - if (bNextIsControl) pID->aXP[nNextPnt]+=aDiff; + if (bPrevIsControl) mpSdrPathDragData->aXP[nPrevPnt]+=aDiff; + if (bNextIsControl) mpSdrPathDragData->aXP[nNextPnt]+=aDiff; // Kontrollpunkt ggf. an Gerade ausrichten - if (pID->aXP.IsSmooth(nPnt)) { + if (mpSdrPathDragData->aXP.IsSmooth(nPnt)) { if (bPrevIsControl && !bNextIsControl && !bEndPnt) { // Fall 3 - pID->aXP.CalcSmoothJoin(nPnt,nNextPnt,nPrevPnt); + mpSdrPathDragData->aXP.CalcSmoothJoin(nPnt,nNextPnt,nPrevPnt); } if (bNextIsControl && !bPrevIsControl && !bBegPnt) { // Fall 4 - pID->aXP.CalcSmoothJoin(nPnt,nPrevPnt,nNextPnt); + mpSdrPathDragData->aXP.CalcSmoothJoin(nPnt,nPrevPnt,nNextPnt); } } // Und nun noch die anderen Enden der Strecken ueberpruefen (nPnt+-1). // Ist dort eine Kurve (IsControl(nPnt+-2)) mit SmoothJoin (nPnt+-1), // so muss der entsprechende Kontrollpunkt (nPnt+-2) angepasst werden. - if (!bBegPnt && !bPrevIsControl && !bPrevIsBegPnt && pID->aXP.IsSmooth(nPrevPnt)) { - if (pID->aXP.IsControl(nPrevPrevPnt)) { - pID->aXP.CalcSmoothJoin(nPrevPnt,nPnt,nPrevPrevPnt); + if (!bBegPnt && !bPrevIsControl && !bPrevIsBegPnt && mpSdrPathDragData->aXP.IsSmooth(nPrevPnt)) { + if (mpSdrPathDragData->aXP.IsControl(nPrevPrevPnt)) { + mpSdrPathDragData->aXP.CalcSmoothJoin(nPrevPnt,nPnt,nPrevPrevPnt); } } - if (!bEndPnt && !bNextIsControl && !bNextIsEndPnt && pID->aXP.IsSmooth(nNextPnt)) { - if (pID->aXP.IsControl(nNextNextPnt)) { - pID->aXP.CalcSmoothJoin(nNextPnt,nPnt,nNextNextPnt); + if (!bEndPnt && !bNextIsControl && !bNextIsEndPnt && mpSdrPathDragData->aXP.IsSmooth(nNextPnt)) { + if (mpSdrPathDragData->aXP.IsControl(nNextNextPnt)) { + mpSdrPathDragData->aXP.CalcSmoothJoin(nNextPnt,nPnt,nNextNextPnt); } } } } - return TRUE; + return true; } -FASTBOOL ImpPathForDragAndCreate::EndDrag(SdrDragStat& rDrag) +bool ImpPathForDragAndCreate::endPathDrag(SdrDragStat& rDrag) { Point aLinePt1; Point aLinePt2; @@ -854,34 +857,35 @@ FASTBOOL ImpPathForDragAndCreate::EndDrag(SdrDragStat& rDrag) aLinePt1=rXP[0]; aLinePt2=rXP[1]; } - ImpSdrPathDragData* pID=(ImpSdrPathDragData*)rDrag.GetUser(); - if(pID->IsMultiPointDrag()) + if(!mpSdrPathDragData || !mpSdrPathDragData->bValid) { - aPathPolygon = pID->maMove; + DBG_ERROR("ImpPathForDragAndCreate::MovDrag(): ImpSdrPathDragData ist ungueltig"); + return false; + } + + if(mpSdrPathDragData->IsMultiPointDrag()) + { + aPathPolygon = mpSdrPathDragData->maMove; } else { const SdrHdl* pHdl=rDrag.GetHdl(); - if (pID==NULL || !pID->bValid) { - DBG_ERROR("ImpPathForDragAndCreate::EndDrag(): ImpSdrPathDragData ist ungueltig"); - return FALSE; - } // Referenz auf das Polygon XPolygon& rXP=aPathPolygon[(sal_uInt16)pHdl->GetPolyNum()]; // Die 5 Punkte die sich evtl. geaendert haben - if (!pID->bPrevIsBegPnt) rXP[pID->nPrevPrevPnt0]=pID->aXP[pID->nPrevPrevPnt]; - if (!pID->bNextIsEndPnt) rXP[pID->nNextNextPnt0]=pID->aXP[pID->nNextNextPnt]; - if (!pID->bBegPnt) rXP[pID->nPrevPnt0] =pID->aXP[pID->nPrevPnt]; - if (!pID->bEndPnt) rXP[pID->nNextPnt0] =pID->aXP[pID->nNextPnt]; - rXP[pID->nPnt0] =pID->aXP[pID->nPnt]; + if (!mpSdrPathDragData->bPrevIsBegPnt) rXP[mpSdrPathDragData->nPrevPrevPnt0]=mpSdrPathDragData->aXP[mpSdrPathDragData->nPrevPrevPnt]; + if (!mpSdrPathDragData->bNextIsEndPnt) rXP[mpSdrPathDragData->nNextNextPnt0]=mpSdrPathDragData->aXP[mpSdrPathDragData->nNextNextPnt]; + if (!mpSdrPathDragData->bBegPnt) rXP[mpSdrPathDragData->nPrevPnt0] =mpSdrPathDragData->aXP[mpSdrPathDragData->nPrevPnt]; + if (!mpSdrPathDragData->bEndPnt) rXP[mpSdrPathDragData->nNextPnt0] =mpSdrPathDragData->aXP[mpSdrPathDragData->nNextPnt]; + rXP[mpSdrPathDragData->nPnt0] =mpSdrPathDragData->aXP[mpSdrPathDragData->nPnt]; // Letzter Punkt muss beim Geschlossenen immer gleich dem Ersten sein - if (pID->bClosed) rXP[rXP.GetPointCount()-1]=rXP[0]; + if (mpSdrPathDragData->bClosed) rXP[rXP.GetPointCount()-1]=rXP[0]; - if (pID->bEliminate) + if (mpSdrPathDragData->bEliminate) { basegfx::B2DPolyPolygon aTempPolyPolygon(aPathPolygon.getB2DPolyPolygon()); sal_uInt32 nPoly,nPnt; @@ -927,322 +931,280 @@ FASTBOOL ImpPathForDragAndCreate::EndDrag(SdrDragStat& rDrag) } } - delete pID; - rDrag.SetUser(NULL); + delete mpSdrPathDragData; + mpSdrPathDragData = 0; - return TRUE; + return true; } -void ImpPathForDragAndCreate::BrkDrag(SdrDragStat& rDrag) const +/*void ImpPathForDragAndCreate::cancelSpecialDrag( SdrDragStat& rDrag ) const { ImpSdrPathDragData* pID=(ImpSdrPathDragData*)rDrag.GetUser(); if (pID!=NULL) { delete pID; rDrag.SetUser(NULL); } -} +}*/ -XubString ImpPathForDragAndCreate::GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const +String ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag) const { - ImpSdrPathDragData* pID = (ImpSdrPathDragData*)rDrag.GetUser(); + ImpSdrPathDragData* pDragData = mpSdrPathDragData; - if(!pID || !pID->bValid) + if(!pDragData) + { + // getSpecialDragComment is also used from create, so fallback to GetUser() + // when mpSdrPathDragData is not set + pDragData = (ImpSdrPathDragData*)rDrag.GetUser(); + } + + if(!pDragData) + { + DBG_ERROR("ImpPathForDragAndCreate::MovDrag(): ImpSdrPathDragData ist ungueltig"); return String(); + } - // Hier auch mal pID verwenden !!! + // Hier auch mal pDragData verwenden !!! XubString aStr; - if(!bCreateComment) - { - const SdrHdl* pHdl = rDrag.GetHdl(); + const SdrHdl* pHdl = rDrag.GetHdl(); - if(bUndoDragComment || !mrSdrPathObject.GetModel() || !pHdl) + if(!mrSdrPathObject.GetModel() || !pHdl) + { + mrSdrPathObject.ImpTakeDescriptionStr(STR_DragPathObj, aStr); + } + else + { + if(!pDragData->IsMultiPointDrag() && pDragData->bEliminate) { - mrSdrPathObject.ImpTakeDescriptionStr(STR_DragPathObj, aStr); + // Punkt von ... + mrSdrPathObject.ImpTakeDescriptionStr(STR_ViewMarkedPoint, aStr); + + // %O loeschen + XubString aStr2(ImpGetResStr(STR_EditDelete)); + + // UNICODE: Punkt von ... loeschen + aStr2.SearchAndReplaceAscii("%O", aStr); + + return aStr2; } - else + + // dx=0.00 dy=0.00 // Beide Seiten Bezier + // dx=0.00 dy=0.00 l=0.00 0.00ø // Anfang oder Ende oder eine Seite Bezier bzw. Hebel + // dx=0.00 dy=0.00 l=0.00 0.00ø / l=0.00 0.00ø // Mittendrin + XubString aMetr; + Point aBeg(rDrag.GetStart()); + Point aNow(rDrag.GetNow()); + + aStr = String(); + aStr.AppendAscii("dx="); + mrSdrPathObject.GetModel()->TakeMetricStr(aNow.X() - aBeg.X(), aMetr, TRUE); + aStr += aMetr; + + aStr.AppendAscii(" dy="); + mrSdrPathObject.GetModel()->TakeMetricStr(aNow.Y() - aBeg.Y(), aMetr, TRUE); + aStr += aMetr; + + if(!pDragData->IsMultiPointDrag()) { - if(!pID->IsMultiPointDrag() && pID->bEliminate) + UINT16 nPntNum((sal_uInt16)pHdl->GetPointNum()); + const XPolygon& rXPoly = aPathPolygon[(sal_uInt16)rDrag.GetHdl()->GetPolyNum()]; + UINT16 nPntAnz((sal_uInt16)rXPoly.GetPointCount()); + BOOL bClose(IsClosed(meObjectKind)); + + if(bClose) + nPntAnz--; + + if(pHdl->IsPlusHdl()) { - // Punkt von ... - mrSdrPathObject.ImpTakeDescriptionStr(STR_ViewMarkedPoint, aStr); + // Hebel + UINT16 nRef(nPntNum); - // %O loeschen - XubString aStr2(ImpGetResStr(STR_EditDelete)); + if(rXPoly.IsControl(nPntNum + 1)) + nRef--; + else + nRef++; - // UNICODE: Punkt von ... loeschen - aStr2.SearchAndReplaceAscii("%O", aStr); + aNow -= rXPoly[nRef]; - return aStr2; - } + INT32 nLen(GetLen(aNow)); + aStr.AppendAscii(" l="); + mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, TRUE); + aStr += aMetr; - // dx=0.00 dy=0.00 // Beide Seiten Bezier - // dx=0.00 dy=0.00 l=0.00 0.00ø // Anfang oder Ende oder eine Seite Bezier bzw. Hebel - // dx=0.00 dy=0.00 l=0.00 0.00ø / l=0.00 0.00ø // Mittendrin - XubString aMetr; - Point aBeg(rDrag.GetStart()); - Point aNow(rDrag.GetNow()); + INT32 nWink(GetAngle(aNow)); + aStr += sal_Unicode(' '); + mrSdrPathObject.GetModel()->TakeWinkStr(nWink, aMetr); + aStr += aMetr; + } + else if(nPntAnz > 1) + { + UINT16 nPntMax(nPntAnz - 1); + Point aPt1,aPt2; + BOOL bIsClosed(IsClosed(meObjectKind)); + BOOL bPt1(nPntNum > 0); + BOOL bPt2(nPntNum < nPntMax); - aStr = String(); - aStr.AppendAscii("dx="); - mrSdrPathObject.GetModel()->TakeMetricStr(aNow.X() - aBeg.X(), aMetr, TRUE); - aStr += aMetr; + if(bIsClosed && nPntAnz > 2) + { + bPt1 = TRUE; + bPt2 = TRUE; + } - aStr.AppendAscii(" dy="); - mrSdrPathObject.GetModel()->TakeMetricStr(aNow.Y() - aBeg.Y(), aMetr, TRUE); - aStr += aMetr; + UINT16 nPt1,nPt2; - if(!pID->IsMultiPointDrag()) - { - UINT16 nPntNum((sal_uInt16)pHdl->GetPointNum()); - const XPolygon& rXPoly = aPathPolygon[(sal_uInt16)rDrag.GetHdl()->GetPolyNum()]; - UINT16 nPntAnz((sal_uInt16)rXPoly.GetPointCount()); - BOOL bClose(IsClosed(meObjectKind)); + if(nPntNum > 0) + nPt1 = nPntNum - 1; + else + nPt1 = nPntMax; - if(bClose) - nPntAnz--; + if(nPntNum < nPntMax) + nPt2 = nPntNum + 1; + else + nPt2 = 0; - if(pHdl->IsPlusHdl()) - { - // Hebel - UINT16 nRef(nPntNum); + if(bPt1 && rXPoly.IsControl(nPt1)) + bPt1 = FALSE; // Keine Anzeige - if(rXPoly.IsControl(nPntNum + 1)) - nRef--; - else - nRef++; + if(bPt2 && rXPoly.IsControl(nPt2)) + bPt2 = FALSE; // von Bezierdaten - aNow -= rXPoly[nRef]; + if(bPt1) + { + Point aPt(aNow); + aPt -= rXPoly[nPt1]; - INT32 nLen(GetLen(aNow)); + INT32 nLen(GetLen(aPt)); aStr.AppendAscii(" l="); mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, TRUE); aStr += aMetr; - INT32 nWink(GetAngle(aNow)); + INT32 nWink(GetAngle(aPt)); aStr += sal_Unicode(' '); mrSdrPathObject.GetModel()->TakeWinkStr(nWink, aMetr); aStr += aMetr; } - else if(nPntAnz > 1) - { - UINT16 nPntMax(nPntAnz - 1); - Point aPt1,aPt2; - BOOL bIsClosed(IsClosed(meObjectKind)); - BOOL bPt1(nPntNum > 0); - BOOL bPt2(nPntNum < nPntMax); - - if(bIsClosed && nPntAnz > 2) - { - bPt1 = TRUE; - bPt2 = TRUE; - } - - UINT16 nPt1,nPt2; - if(nPntNum > 0) - nPt1 = nPntNum - 1; - else - nPt1 = nPntMax; - - if(nPntNum < nPntMax) - nPt2 = nPntNum + 1; + if(bPt2) + { + if(bPt1) + aStr.AppendAscii(" / "); else - nPt2 = 0; - - if(bPt1 && rXPoly.IsControl(nPt1)) - bPt1 = FALSE; // Keine Anzeige + aStr.AppendAscii(" "); - if(bPt2 && rXPoly.IsControl(nPt2)) - bPt2 = FALSE; // von Bezierdaten + Point aPt(aNow); + aPt -= rXPoly[nPt2]; - if(bPt1) - { - Point aPt(aNow); - aPt -= rXPoly[nPt1]; - - INT32 nLen(GetLen(aPt)); - aStr.AppendAscii(" l="); - mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, TRUE); - aStr += aMetr; - - INT32 nWink(GetAngle(aPt)); - aStr += sal_Unicode(' '); - mrSdrPathObject.GetModel()->TakeWinkStr(nWink, aMetr); - aStr += aMetr; - } + INT32 nLen(GetLen(aPt)); + aStr.AppendAscii("l="); + mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, TRUE); + aStr += aMetr; - if(bPt2) - { - if(bPt1) - aStr.AppendAscii(" / "); - else - aStr.AppendAscii(" "); - - Point aPt(aNow); - aPt -= rXPoly[nPt2]; - - INT32 nLen(GetLen(aPt)); - aStr.AppendAscii("l="); - mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, TRUE); - aStr += aMetr; - - INT32 nWink(GetAngle(aPt)); - aStr += sal_Unicode(' '); - mrSdrPathObject.GetModel()->TakeWinkStr(nWink, aMetr); - aStr += aMetr; - } + INT32 nWink(GetAngle(aPt)); + aStr += sal_Unicode(' '); + mrSdrPathObject.GetModel()->TakeWinkStr(nWink, aMetr); + aStr += aMetr; } } } } - else if(mrSdrPathObject.GetModel() && !pID->IsMultiPointDrag()) - { - // Ansonsten CreateComment - ImpPathCreateUser* pU = (ImpPathCreateUser*)rDrag.GetUser(); - SdrObjKind eKindMerk = meObjectKind; - - // fuer Description bei Mixed das Aktuelle... - mrSdrPathObject.meKind = pU->eAktKind; - mrSdrPathObject.ImpTakeDescriptionStr(STR_ViewCreateObj, aStr); - mrSdrPathObject.meKind = eKindMerk; - - Point aPrev(rDrag.GetPrev()); - Point aNow(rDrag.GetNow()); - - if(pU->bLine) - aNow = pU->aLineEnd; - - aNow -= aPrev; - aStr.AppendAscii(" ("); - - XubString aMetr; - - if(pU->bCircle) - { - mrSdrPathObject.GetModel()->TakeWinkStr(Abs(pU->nCircRelWink), aMetr); - aStr += aMetr; - aStr.AppendAscii(" r="); - mrSdrPathObject.GetModel()->TakeMetricStr(pU->nCircRadius, aMetr, TRUE); - aStr += aMetr; - } - - aStr.AppendAscii("dx="); - mrSdrPathObject.GetModel()->TakeMetricStr(aNow.X(), aMetr, TRUE); - aStr += aMetr; - - aStr.AppendAscii(" dy="); - mrSdrPathObject.GetModel()->TakeMetricStr(aNow.Y(), aMetr, TRUE); - aStr += aMetr; - - if(!IsFreeHand(meObjectKind)) - { - INT32 nLen(GetLen(aNow)); - aStr.AppendAscii(" l="); - mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, TRUE); - aStr += aMetr; - - INT32 nWink(GetAngle(aNow)); - aStr += sal_Unicode(' '); - mrSdrPathObject.GetModel()->TakeWinkStr(nWink, aMetr); - aStr += aMetr; - } - - aStr += sal_Unicode(')'); - } return aStr; } -basegfx::B2DPolyPolygon ImpPathForDragAndCreate::TakeDragPoly(const SdrDragStat& rDrag) const +basegfx::B2DPolyPolygon ImpPathForDragAndCreate::getSpecialDragPoly(const SdrDragStat& rDrag) const { - XPolyPolygon aXPP; - ImpSdrPathDragData* pID=(ImpSdrPathDragData*)rDrag.GetUser(); + if(!mpSdrPathDragData || !mpSdrPathDragData->bValid) + { + DBG_ERROR("ImpPathForDragAndCreate::MovDrag(): ImpSdrPathDragData ist ungueltig"); + return basegfx::B2DPolyPolygon(); + } + + XPolyPolygon aRetval; - if(pID->IsMultiPointDrag()) + if(mpSdrPathDragData->IsMultiPointDrag()) { - aXPP.Insert(pID->maMove); + aRetval.Insert(mpSdrPathDragData->maMove); } else { const XPolygon& rXP=aPathPolygon[(sal_uInt16)rDrag.GetHdl()->GetPolyNum()]; - if (rXP.GetPointCount()<=2 /*|| rXPoly.GetFlags(1)==XPOLY_CONTROL && rXPoly.GetPointCount()<=4*/) { + if (rXP.GetPointCount()<=2) { //|| rXPoly.GetFlags(1)==XPOLY_CONTROL && rXPoly.GetPointCount()<=4 XPolygon aXPoly(rXP); aXPoly[(sal_uInt16)rDrag.GetHdl()->GetPointNum()]=rDrag.GetNow(); - aXPP.Insert(aXPoly); - return aXPP.getB2DPolyPolygon(); + aRetval.Insert(aXPoly); + return aRetval.getB2DPolyPolygon(); } // Div. Daten lokal Kopieren fuer weniger Code und schnelleren Zugriff - FASTBOOL bClosed =pID->bClosed ; // geschlossenes Objekt? - USHORT nPntAnz =pID->nPntAnz ; // Punktanzahl - USHORT nPnt =pID->nPnt ; // Punktnummer innerhalb des Polygons - FASTBOOL bBegPnt =pID->bBegPnt ; // Gedraggter Punkt ist der Anfangspunkt einer Polyline - FASTBOOL bEndPnt =pID->bEndPnt ; // Gedraggter Punkt ist der Endpunkt einer Polyline - USHORT nPrevPnt =pID->nPrevPnt ; // Index des vorherigen Punkts - USHORT nNextPnt =pID->nNextPnt ; // Index des naechsten Punkts - FASTBOOL bPrevIsBegPnt =pID->bPrevIsBegPnt ; // Vorheriger Punkt ist Anfangspunkt einer Polyline - FASTBOOL bNextIsEndPnt =pID->bNextIsEndPnt ; // Folgepunkt ist Endpunkt einer Polyline - USHORT nPrevPrevPnt =pID->nPrevPrevPnt ; // Index des vorvorherigen Punkts - USHORT nNextNextPnt =pID->nNextNextPnt ; // Index des uebernaechsten Punkts - FASTBOOL bControl =pID->bControl ; // Punkt ist ein Kontrollpunkt - //FASTBOOL bIsPrevControl=pID->bIsPrevControl; // Punkt ist Kontrollpunkt vor einem Stuetzpunkt - FASTBOOL bIsNextControl=pID->bIsNextControl; // Punkt ist Kontrollpunkt hinter einem Stuetzpunkt - FASTBOOL bPrevIsControl=pID->bPrevIsControl; // Falls nPnt ein StPnt: Davor ist ein Kontrollpunkt - FASTBOOL bNextIsControl=pID->bNextIsControl; // Falls nPnt ein StPnt: Dahinter ist ein Kontrollpunkt - XPolygon aXPoly(pID->aXP); + FASTBOOL bClosed =mpSdrPathDragData->bClosed ; // geschlossenes Objekt? + USHORT nPntAnz =mpSdrPathDragData->nPntAnz ; // Punktanzahl + USHORT nPnt =mpSdrPathDragData->nPnt ; // Punktnummer innerhalb des Polygons + FASTBOOL bBegPnt =mpSdrPathDragData->bBegPnt ; // Gedraggter Punkt ist der Anfangspunkt einer Polyline + FASTBOOL bEndPnt =mpSdrPathDragData->bEndPnt ; // Gedraggter Punkt ist der Endpunkt einer Polyline + USHORT nPrevPnt =mpSdrPathDragData->nPrevPnt ; // Index des vorherigen Punkts + USHORT nNextPnt =mpSdrPathDragData->nNextPnt ; // Index des naechsten Punkts + FASTBOOL bPrevIsBegPnt =mpSdrPathDragData->bPrevIsBegPnt ; // Vorheriger Punkt ist Anfangspunkt einer Polyline + FASTBOOL bNextIsEndPnt =mpSdrPathDragData->bNextIsEndPnt ; // Folgepunkt ist Endpunkt einer Polyline + USHORT nPrevPrevPnt =mpSdrPathDragData->nPrevPrevPnt ; // Index des vorvorherigen Punkts + USHORT nNextNextPnt =mpSdrPathDragData->nNextNextPnt ; // Index des uebernaechsten Punkts + FASTBOOL bControl =mpSdrPathDragData->bControl ; // Punkt ist ein Kontrollpunkt + //FASTBOOL bIsPrevControl=mpSdrPathDragData->bIsPrevControl; // Punkt ist Kontrollpunkt vor einem Stuetzpunkt + FASTBOOL bIsNextControl=mpSdrPathDragData->bIsNextControl; // Punkt ist Kontrollpunkt hinter einem Stuetzpunkt + FASTBOOL bPrevIsControl=mpSdrPathDragData->bPrevIsControl; // Falls nPnt ein StPnt: Davor ist ein Kontrollpunkt + FASTBOOL bNextIsControl=mpSdrPathDragData->bNextIsControl; // Falls nPnt ein StPnt: Dahinter ist ein Kontrollpunkt + XPolygon aXPoly(mpSdrPathDragData->aXP); XPolygon aLine1(2); XPolygon aLine2(2); XPolygon aLine3(2); XPolygon aLine4(2); if (bControl) { - aLine1[1]=pID->aXP[nPnt]; + aLine1[1]=mpSdrPathDragData->aXP[nPnt]; if (bIsNextControl) { // bin ich Kontrollpunkt hinter der Stuetzstelle? - aLine1[0]=pID->aXP[nPrevPnt]; - aLine2[0]=pID->aXP[nNextNextPnt]; - aLine2[1]=pID->aXP[nNextPnt]; - if (pID->aXP.IsSmooth(nPrevPnt) && !bPrevIsBegPnt && pID->aXP.IsControl(nPrevPrevPnt)) { - aXPoly.Insert(0,rXP[pID->nPrevPrevPnt0-1],XPOLY_CONTROL); - aXPoly.Insert(0,rXP[pID->nPrevPrevPnt0-2],XPOLY_NORMAL); + aLine1[0]=mpSdrPathDragData->aXP[nPrevPnt]; + aLine2[0]=mpSdrPathDragData->aXP[nNextNextPnt]; + aLine2[1]=mpSdrPathDragData->aXP[nNextPnt]; + if (mpSdrPathDragData->aXP.IsSmooth(nPrevPnt) && !bPrevIsBegPnt && mpSdrPathDragData->aXP.IsControl(nPrevPrevPnt)) { + aXPoly.Insert(0,rXP[mpSdrPathDragData->nPrevPrevPnt0-1],XPOLY_CONTROL); + aXPoly.Insert(0,rXP[mpSdrPathDragData->nPrevPrevPnt0-2],XPOLY_NORMAL); // Hebellienien fuer das gegenueberliegende Kurvensegment - aLine3[0]=pID->aXP[nPrevPnt]; - aLine3[1]=pID->aXP[nPrevPrevPnt]; - aLine4[0]=rXP[pID->nPrevPrevPnt0-2]; - aLine4[1]=rXP[pID->nPrevPrevPnt0-1]; + aLine3[0]=mpSdrPathDragData->aXP[nPrevPnt]; + aLine3[1]=mpSdrPathDragData->aXP[nPrevPrevPnt]; + aLine4[0]=rXP[mpSdrPathDragData->nPrevPrevPnt0-2]; + aLine4[1]=rXP[mpSdrPathDragData->nPrevPrevPnt0-1]; } else { aXPoly.Remove(0,1); } } else { // ansonsten bin ich Kontrollpunkt vor der Stuetzstelle - aLine1[0]=pID->aXP[nNextPnt]; - aLine2[0]=pID->aXP[nPrevPrevPnt]; - aLine2[1]=pID->aXP[nPrevPnt]; - if (pID->aXP.IsSmooth(nNextPnt) && !bNextIsEndPnt && pID->aXP.IsControl(nNextNextPnt)) { - aXPoly.Insert(XPOLY_APPEND,rXP[pID->nNextNextPnt0+1],XPOLY_CONTROL); - aXPoly.Insert(XPOLY_APPEND,rXP[pID->nNextNextPnt0+2],XPOLY_NORMAL); + aLine1[0]=mpSdrPathDragData->aXP[nNextPnt]; + aLine2[0]=mpSdrPathDragData->aXP[nPrevPrevPnt]; + aLine2[1]=mpSdrPathDragData->aXP[nPrevPnt]; + if (mpSdrPathDragData->aXP.IsSmooth(nNextPnt) && !bNextIsEndPnt && mpSdrPathDragData->aXP.IsControl(nNextNextPnt)) { + aXPoly.Insert(XPOLY_APPEND,rXP[mpSdrPathDragData->nNextNextPnt0+1],XPOLY_CONTROL); + aXPoly.Insert(XPOLY_APPEND,rXP[mpSdrPathDragData->nNextNextPnt0+2],XPOLY_NORMAL); // Hebellinien fuer das gegenueberliegende Kurvensegment - aLine3[0]=pID->aXP[nNextPnt]; - aLine3[1]=pID->aXP[nNextNextPnt]; - aLine4[0]=rXP[pID->nNextNextPnt0+2]; - aLine4[1]=rXP[pID->nNextNextPnt0+1]; + aLine3[0]=mpSdrPathDragData->aXP[nNextPnt]; + aLine3[1]=mpSdrPathDragData->aXP[nNextNextPnt]; + aLine4[0]=rXP[mpSdrPathDragData->nNextNextPnt0+2]; + aLine4[1]=rXP[mpSdrPathDragData->nNextNextPnt0+1]; } else { aXPoly.Remove(aXPoly.GetPointCount()-1,1); } } } else { // ansonsten kein Kontrollpunkt - if (pID->bEliminate) { + if (mpSdrPathDragData->bEliminate) { aXPoly.Remove(2,1); } - if (bPrevIsControl) aXPoly.Insert(0,rXP[pID->nPrevPrevPnt0-1],XPOLY_NORMAL); - else if (!bBegPnt && !bPrevIsBegPnt && pID->aXP.IsControl(nPrevPrevPnt)) { - aXPoly.Insert(0,rXP[pID->nPrevPrevPnt0-1],XPOLY_CONTROL); - aXPoly.Insert(0,rXP[pID->nPrevPrevPnt0-2],XPOLY_NORMAL); + if (bPrevIsControl) aXPoly.Insert(0,rXP[mpSdrPathDragData->nPrevPrevPnt0-1],XPOLY_NORMAL); + else if (!bBegPnt && !bPrevIsBegPnt && mpSdrPathDragData->aXP.IsControl(nPrevPrevPnt)) { + aXPoly.Insert(0,rXP[mpSdrPathDragData->nPrevPrevPnt0-1],XPOLY_CONTROL); + aXPoly.Insert(0,rXP[mpSdrPathDragData->nPrevPrevPnt0-2],XPOLY_NORMAL); } else { aXPoly.Remove(0,1); if (bBegPnt) aXPoly.Remove(0,1); } - if (bNextIsControl) aXPoly.Insert(XPOLY_APPEND,rXP[pID->nNextNextPnt0+1],XPOLY_NORMAL); - else if (!bEndPnt && !bNextIsEndPnt && pID->aXP.IsControl(nNextNextPnt)) { - aXPoly.Insert(XPOLY_APPEND,rXP[pID->nNextNextPnt0+1],XPOLY_CONTROL); - aXPoly.Insert(XPOLY_APPEND,rXP[pID->nNextNextPnt0+2],XPOLY_NORMAL); + if (bNextIsControl) aXPoly.Insert(XPOLY_APPEND,rXP[mpSdrPathDragData->nNextNextPnt0+1],XPOLY_NORMAL); + else if (!bEndPnt && !bNextIsEndPnt && mpSdrPathDragData->aXP.IsControl(nNextNextPnt)) { + aXPoly.Insert(XPOLY_APPEND,rXP[mpSdrPathDragData->nNextNextPnt0+1],XPOLY_CONTROL); + aXPoly.Insert(XPOLY_APPEND,rXP[mpSdrPathDragData->nNextNextPnt0+2],XPOLY_NORMAL); } else { aXPoly.Remove(aXPoly.GetPointCount()-1,1); if (bEndPnt) aXPoly.Remove(aXPoly.GetPointCount()-1,1); @@ -1256,14 +1218,14 @@ basegfx::B2DPolyPolygon ImpPathForDragAndCreate::TakeDragPoly(const SdrDragStat& } } } - aXPP.Insert(aXPoly); - if (aLine1.GetPointCount()>1) aXPP.Insert(aLine1); - if (aLine2.GetPointCount()>1) aXPP.Insert(aLine2); - if (aLine3.GetPointCount()>1) aXPP.Insert(aLine3); - if (aLine4.GetPointCount()>1) aXPP.Insert(aLine4); + aRetval.Insert(aXPoly); + if (aLine1.GetPointCount()>1) aRetval.Insert(aLine1); + if (aLine2.GetPointCount()>1) aRetval.Insert(aLine2); + if (aLine3.GetPointCount()>1) aRetval.Insert(aLine3); + if (aLine4.GetPointCount()>1) aRetval.Insert(aLine4); } - return aXPP.getB2DPolyPolygon(); + return aRetval.getB2DPolyPolygon(); } FASTBOOL ImpPathForDragAndCreate::BegCreate(SdrDragStat& rStat) @@ -2187,51 +2149,73 @@ SdrHdl* SdrPathObj::GetPlusHdl(const SdrHdl& rHdl, sal_uInt32 nPlusNum) const return pHdl; } -FASTBOOL SdrPathObj::HasSpecialDrag() const -{ - return TRUE; -} +//////////////////////////////////////////////////////////////////////////////////////////////////// -FASTBOOL SdrPathObj::BegDrag(SdrDragStat& rDrag) const +bool SdrPathObj::hasSpecialDrag() const { - impDeleteDAC(); - return impGetDAC().BegDrag(rDrag); + return true; } -FASTBOOL SdrPathObj::MovDrag(SdrDragStat& rDrag) const +bool SdrPathObj::beginSpecialDrag(SdrDragStat& rDrag) const { - return impGetDAC().MovDrag(rDrag); + ImpPathForDragAndCreate aDragAndCreate(*((SdrPathObj*)this)); + + return aDragAndCreate.beginPathDrag(rDrag); } -FASTBOOL SdrPathObj::EndDrag(SdrDragStat& rDrag) +bool SdrPathObj::applySpecialDrag(SdrDragStat& rDrag) { - FASTBOOL bRetval(impGetDAC().EndDrag(rDrag)); + ImpPathForDragAndCreate aDragAndCreate(*this); + bool bRetval(aDragAndCreate.beginPathDrag(rDrag)); - if(bRetval && mpDAC) + if(bRetval) { - SetPathPoly(mpDAC->getModifiedPolyPolygon()); - impDeleteDAC(); + bRetval = aDragAndCreate.movePathDrag(rDrag); + } + + if(bRetval) + { + bRetval = aDragAndCreate.endPathDrag(rDrag); + } + + if(bRetval) + { + NbcSetPathPoly(aDragAndCreate.getModifiedPolyPolygon()); } return bRetval; } -void SdrPathObj::BrkDrag(SdrDragStat& rDrag) const +String SdrPathObj::getSpecialDragComment(const SdrDragStat& rDrag) const { - impGetDAC().BrkDrag(rDrag); - impDeleteDAC(); -} + String aRetval; + ImpPathForDragAndCreate aDragAndCreate(*((SdrPathObj*)this)); + bool bDidWork(aDragAndCreate.beginPathDrag((SdrDragStat&)rDrag)); -XubString SdrPathObj::GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const -{ - return impGetDAC().GetDragComment(rDrag, bUndoDragComment, bCreateComment); + if(bDidWork) + { + aRetval = aDragAndCreate.getSpecialDragComment(rDrag); + } + + return aRetval; } -basegfx::B2DPolyPolygon SdrPathObj::TakeDragPoly(const SdrDragStat& rDrag) const +basegfx::B2DPolyPolygon SdrPathObj::getSpecialDragPoly(const SdrDragStat& rDrag) const { - return impGetDAC().TakeDragPoly(rDrag); + basegfx::B2DPolyPolygon aRetval; + ImpPathForDragAndCreate aDragAndCreate(*((SdrPathObj*)this)); + bool bDidWork(aDragAndCreate.beginPathDrag((SdrDragStat&)rDrag)); + + if(bDidWork) + { + aRetval = aDragAndCreate.getSpecialDragPoly(rDrag); + } + + return aRetval; } +//////////////////////////////////////////////////////////////////////////////////////////////////// + FASTBOOL SdrPathObj::BegCreate(SdrDragStat& rStat) { impDeleteDAC(); @@ -2382,7 +2366,17 @@ void SdrPathObj::NbcShear(const Point& rRefPnt, long nAngle, double fTan, FASTBO { basegfx::B2DHomMatrix aTrans; aTrans.translate(-rRefPnt.X(), -rRefPnt.Y()); - aTrans.shearX(-fTan); // Thank JOE, the angles are defined mirrored to the mathematical meanings + + if(bVShear) + { + // Thank JOE, the angles are defined mirrored to the mathematical meanings + aTrans.shearY(-fTan); + } + else + { + aTrans.shearX(-fTan); + } + aTrans.translate(rRefPnt.X(), rRefPnt.Y()); maPathPolygon.transform(aTrans); @@ -2922,7 +2916,7 @@ sal_Bool SdrPathObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx:: } // position maybe relative to anchorpos, convert - if( pModel->IsWriter() ) + if( pModel && pModel->IsWriter() ) { if(GetAnchorPos().X() || GetAnchorPos().Y()) { @@ -2931,7 +2925,7 @@ sal_Bool SdrPathObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx:: } // force MapUnit to 100th mm - SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); + SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0); if(eMapUnit != SFX_MAPUNIT_100TH_MM) { switch(eMapUnit) @@ -3021,7 +3015,7 @@ void SdrPathObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b aGeo.RecalcTan(); // force metric to pool metric - SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); + SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0); if(eMapUnit != SFX_MAPUNIT_100TH_MM) { switch(eMapUnit) @@ -3051,7 +3045,7 @@ void SdrPathObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b } } - if( pModel->IsWriter() ) + if( pModel && pModel->IsWriter() ) { // if anchor is used, make position relative to it if(GetAnchorPos().X() || GetAnchorPos().Y()) diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx index 8620110d6979..ed841692a5f8 100644 --- a/svx/source/svdraw/svdorect.cxx +++ b/svx/source/svdraw/svdorect.cxx @@ -442,71 +442,60 @@ SdrHdl* SdrRectObj::GetHdl(sal_uInt32 nHdlNum) const return pH; } -FASTBOOL SdrRectObj::HasSpecialDrag() const -{ - return TRUE; -} +//////////////////////////////////////////////////////////////////////////////////////////////////// -FASTBOOL SdrRectObj::BegDrag(SdrDragStat& rDrag) const +bool SdrRectObj::hasSpecialDrag() const { - FASTBOOL bRad=rDrag.GetHdl()!=NULL && rDrag.GetHdl()->GetKind()==HDL_CIRC; - if (bRad) { - rDrag.SetEndDragChangesAttributes(TRUE); - return TRUE; - } else { - return SdrTextObj::BegDrag(rDrag); - } + return true; } -FASTBOOL SdrRectObj::MovDrag(SdrDragStat& rDrag) const +bool SdrRectObj::beginSpecialDrag(SdrDragStat& rDrag) const { - FASTBOOL bRad=rDrag.GetHdl()!=NULL && rDrag.GetHdl()->GetKind()==HDL_CIRC; - if (bRad) { - return TRUE; - } else { - return SdrTextObj::MovDrag(rDrag); + const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); + + if(bRad) + { + rDrag.SetEndDragChangesAttributes(true); + + return true; } + + return SdrTextObj::beginSpecialDrag(rDrag); } -FASTBOOL SdrRectObj::EndDrag(SdrDragStat& rDrag) +bool SdrRectObj::applySpecialDrag(SdrDragStat& rDrag) { - FASTBOOL bRad=rDrag.GetHdl()!=NULL && rDrag.GetHdl()->GetKind()==HDL_CIRC; - if (bRad) { - Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect(); - // #110094#-14 SendRepaintBroadcast(); + const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); + + if (bRad) + { + Rectangle aBoundRect0; Point aPt(rDrag.GetNow()); - if (aGeo.nDrehWink!=0) RotatePoint(aPt,aRect.TopLeft(),-aGeo.nSin,aGeo.nCos); // -sin fuer Umkehrung - // Shear nicht noetig, da Pt auf einer Linie mit dem RefPt (LiOb Ecke des Rect) - long nRad=aPt.X()-aRect.Left(); - if (nRad<0) nRad=0; - long nAltRad=GetEckenradius(); - if (nRad!=nAltRad) NbcSetEckenradius(nRad); - SetChanged(); - SetRectsDirty(); - SetXPolyDirty(); - BroadcastObjectChange(); - SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0); - return TRUE; - } else { - return SdrTextObj::EndDrag(rDrag); - } -} -void SdrRectObj::BrkDrag(SdrDragStat& rDrag) const -{ - FASTBOOL bRad=rDrag.GetHdl()!=NULL && rDrag.GetHdl()->GetKind()==HDL_CIRC; - if (bRad) { - } else { - SdrTextObj::BrkDrag(rDrag); + if(aGeo.nDrehWink) + RotatePoint(aPt,aRect.TopLeft(),-aGeo.nSin,aGeo.nCos); + + sal_Int32 nRad(aPt.X() - aRect.Left()); + + if (nRad < 0) + nRad = 0; + + if(nRad != GetEckenradius()) + { + NbcSetEckenradius(nRad); + } + + return true; + } + else + { + return SdrTextObj::applySpecialDrag(rDrag); } } -XubString SdrRectObj::GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const +String SdrRectObj::getSpecialDragComment(const SdrDragStat& rDrag) const { - if(bCreateComment) - return String(); - - BOOL bRad(rDrag.GetHdl() && rDrag.GetHdl()->GetKind() == HDL_CIRC); + const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); if(bRad) { @@ -516,7 +505,7 @@ XubString SdrRectObj::GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDra if(aGeo.nDrehWink) RotatePoint(aPt, aRect.TopLeft(), -aGeo.nSin, aGeo.nCos); - INT32 nRad(aPt.X() - aRect.Left()); + sal_Int32 nRad(aPt.X() - aRect.Left()); if(nRad < 0) nRad = 0; @@ -532,31 +521,11 @@ XubString SdrRectObj::GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDra } else { - return SdrTextObj::GetDragComment(rDrag, bUndoDragComment, FALSE); + return SdrTextObj::getSpecialDragComment(rDrag); } } -basegfx::B2DPolyPolygon SdrRectObj::TakeDragPoly(const SdrDragStat& rDrag) const -{ - XPolyPolygon aXPP; - const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind()); - - if(bRad) - { - Point aPt(rDrag.GetNow()); - if (aGeo.nDrehWink!=0) RotatePoint(aPt,aRect.TopLeft(),-aGeo.nSin,aGeo.nCos); // -sin fuer Umkehrung - // Shear nicht noetig, da Pt auf einer Linie mit dem RefPt (LiOb Ecke des Rect) - long nRad=aPt.X()-aRect.Left(); - if (nRad<0) nRad=0; - aXPP.Insert(ImpCalcXPoly(aRect,nRad)); - } - else - { - aXPP.Insert(ImpCalcXPoly(ImpDragCalcRect(rDrag),GetEckenradius())); - } - - return aXPP.getB2DPolyPolygon(); -} +//////////////////////////////////////////////////////////////////////////////////////////////////// basegfx::B2DPolyPolygon SdrRectObj::TakeCreatePoly(const SdrDragStat& rDrag) const { diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 5ff91a10a9dd..c7b9a715c400 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -1787,7 +1787,7 @@ sal_Bool SdrTextObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx:: basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top()); // position maybe relative to anchorpos, convert - if( pModel->IsWriter() ) + if( pModel && pModel->IsWriter() ) { if(GetAnchorPos().X() || GetAnchorPos().Y()) { @@ -1796,7 +1796,7 @@ sal_Bool SdrTextObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx:: } // force MapUnit to 100th mm - SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); + SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0); if(eMapUnit != SFX_MAPUNIT_100TH_MM) { switch(eMapUnit) @@ -1877,7 +1877,7 @@ void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b aGeo.RecalcTan(); // force metric to pool metric - SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0); + SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0); if(eMapUnit != SFX_MAPUNIT_100TH_MM) { switch(eMapUnit) @@ -1902,7 +1902,7 @@ void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b } // if anchor is used, make position relative to it - if( pModel->IsWriter() ) + if( pModel && pModel->IsWriter() ) { if(GetAnchorPos().X() || GetAnchorPos().Y()) { diff --git a/svx/source/svdraw/svdotxdr.cxx b/svx/source/svdraw/svdotxdr.cxx index eee0acf3f21d..8e442f628f35 100644 --- a/svx/source/svdraw/svdotxdr.cxx +++ b/svx/source/svdraw/svdotxdr.cxx @@ -88,9 +88,11 @@ SdrHdl* SdrTextObj::GetHdl(sal_uInt32 nHdlNum) const return pH; } -FASTBOOL SdrTextObj::HasSpecialDrag() const +//////////////////////////////////////////////////////////////////////////////////////////////////// + +bool SdrTextObj::hasSpecialDrag() const { - return TRUE; + return true; } Rectangle SdrTextObj::ImpDragCalcRect(const SdrDragStat& rDrag) const @@ -167,98 +169,41 @@ Rectangle SdrTextObj::ImpDragCalcRect(const SdrDragStat& rDrag) const return aTmpRect; } -struct ImpTextDragUser : public SdrDragStatUserData -{ - Rectangle aR; -}; - -FASTBOOL SdrTextObj::BegDrag(SdrDragStat& rDrag) const -{ - if (bSizProt) return FALSE; // Groesse geschuetzt - const SdrHdl* pHdl=rDrag.GetHdl(); - SdrHdlKind eHdl=pHdl==NULL ? HDL_MOVE : pHdl->GetKind(); - if (eHdl==HDL_UPLFT || eHdl==HDL_UPPER || eHdl==HDL_UPRGT || - eHdl==HDL_LEFT || eHdl==HDL_RIGHT || - eHdl==HDL_LWLFT || eHdl==HDL_LOWER || eHdl==HDL_LWRGT) - { - ImpTextDragUser* pUser=new ImpTextDragUser; - pUser->aR=aRect; - rDrag.SetUser(pUser); - return TRUE; - } - return FALSE; -} +//////////////////////////////////////////////////////////////////////////////////////////////////// +// drag -FASTBOOL SdrTextObj::MovDrag(SdrDragStat& rDrag) const +bool SdrTextObj::applySpecialDrag(SdrDragStat& rDrag) { - FASTBOOL bRet = TRUE; - ImpTextDragUser* pUser=(ImpTextDragUser*)rDrag.GetUser(); - if ( pUser ) - { - Rectangle aOldRect(pUser->aR); - pUser->aR=ImpDragCalcRect(rDrag); - return pUser->aR != aOldRect; - } - return bRet; -} + Rectangle aNewRect(ImpDragCalcRect(rDrag)); -FASTBOOL SdrTextObj::EndDrag(SdrDragStat& rDrag) -{ - ImpTextDragUser* pUser=(ImpTextDragUser*)rDrag.GetUser(); - Rectangle aNewRect(pUser->aR); - if (aNewRect.TopLeft()!=aRect.TopLeft() && - (aGeo.nDrehWink!=0 || aGeo.nShearWink!=0)) + if(aNewRect.TopLeft() != aRect.TopLeft() && (aGeo.nDrehWink || aGeo.nShearWink)) { Point aNewPos(aNewRect.TopLeft()); - if (aGeo.nShearWink!=0) ShearPoint(aNewPos,aRect.TopLeft(),aGeo.nTan); - if (aGeo.nDrehWink!=0) RotatePoint(aNewPos,aRect.TopLeft(),aGeo.nSin,aGeo.nCos); + + if(aGeo.nShearWink) + ShearPoint(aNewPos,aRect.TopLeft(),aGeo.nTan); + + if(aGeo.nDrehWink) + RotatePoint(aNewPos,aRect.TopLeft(),aGeo.nSin,aGeo.nCos); + aNewRect.SetPos(aNewPos); } - if (aNewRect!=aRect) { - //long nHgt0=aRect.Bottom()-aRect.Top(); - //long nHgt1=aNewRect.Bottom()-aNewRect.Top(); - //long nWdt0=aRect.Right()-aRect.Left(); - //long nWdt1=aNewRect.Right()-aNewRect.Left(); - SetLogicRect(aNewRect); + + if(aNewRect != aRect) + { + NbcSetLogicRect(aNewRect); } - delete pUser; - rDrag.SetUser(NULL); - return TRUE; -} -void SdrTextObj::BrkDrag(SdrDragStat& rDrag) const -{ - delete rDrag.GetUser(); - rDrag.SetUser(NULL); + return true; } -XubString SdrTextObj::GetDragComment(const SdrDragStat& /*rDrag*/, FASTBOOL /*bUndoDragComment*/, FASTBOOL bCreateComment) const +String SdrTextObj::getSpecialDragComment(const SdrDragStat& /*rDrag*/) const { XubString aStr; - if (!bCreateComment) ImpTakeDescriptionStr(STR_DragRectResize,aStr); + ImpTakeDescriptionStr(STR_DragRectResize,aStr); return aStr; } -basegfx::B2DPolyPolygon SdrTextObj::TakeDragPoly(const SdrDragStat& rDrag) const -{ - XPolyPolygon aXPP; - Rectangle aTmpRect(ImpDragCalcRect(rDrag)); - - if(aGeo.nDrehWink || aGeo.nShearWink) - { - Polygon aPoly(aTmpRect); - if (aGeo.nShearWink!=0) ShearPoly(aPoly,aRect.TopLeft(),aGeo.nTan); - if (aGeo.nDrehWink!=0) RotatePoly(aPoly,aRect.TopLeft(),aGeo.nSin,aGeo.nCos); - aXPP.Insert(XPolygon(aPoly)); - } - else - { - aXPP.Insert(XPolygon(aTmpRect)); - } - - return aXPP.getB2DPolyPolygon(); -} - //////////////////////////////////////////////////////////////////////////////////////////////////// // Create diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx index 92077ebf85c2..cf9476ed2489 100644 --- a/svx/source/svdraw/svdouno.cxx +++ b/svx/source/svdraw/svdouno.cxx @@ -62,6 +62,7 @@ #include <svx/sdrpagewindow.hxx> #include <sdrpaintwindow.hxx> #include <tools/diagnose_ex.h> +#include <svx/svdograf.hxx> using namespace ::com::sun::star; using namespace ::sdr::contact; @@ -406,11 +407,6 @@ void SdrUnoObj::operator = (const SdrObject& rObj) m_pImpl->pEventListener->StartListening(xComp); } -FASTBOOL SdrUnoObj::HasSpecialDrag() const -{ - return FALSE; -} - void SdrUnoObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { SdrRectObj::NbcResize(rRef,xFact,yFact); @@ -433,6 +429,46 @@ void SdrUnoObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fracti } // ----------------------------------------------------------------------------- + +bool SdrUnoObj::hasSpecialDrag() const +{ + // no special drag; we have no rounding rect and + // do want frame handles + return false; +} + +bool SdrUnoObj::supportsFullDrag() const +{ + // overloaded to have the possibility to enable/disable in debug and + // to ckeck some things out. Current solution is working, so default is + // enabled + static bool bDoSupportFullDrag(true); + + return bDoSupportFullDrag; +} + +SdrObject* SdrUnoObj::getFullDragClone() const +{ + SdrObject* pRetval = 0; + static bool bHandleSpecial(false); + + if(bHandleSpecial) + { + // special handling for SdrUnoObj (FormControl). Create a SdrGrafObj + // for drag containing the graphical representation. This does not work too + // well, so the default is to simply clone + pRetval = new SdrGrafObj(SdrDragView::GetObjGraphic(GetModel(), this), GetLogicRect()); + } + else + { + // call parent (simply clone) + pRetval = SdrRectObj::getFullDragClone(); + } + + return pRetval; +} + +// ----------------------------------------------------------------------------- void SdrUnoObj::NbcSetLayer( SdrLayerID _nLayer ) { if ( GetLayer() == _nLayer ) diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx index aea0523c895b..a93905fe21ed 100644 --- a/svx/source/svdraw/svdovirt.cxx +++ b/svx/source/svdraw/svdovirt.cxx @@ -38,6 +38,8 @@ #include <svx/svdhdl.hxx> #include <svx/sdr/contact/viewcontactofvirtobj.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <svx/svdograf.hxx> +#include <svx/svddrgv.hxx> //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -299,40 +301,59 @@ void SdrVirtObj::AddToHdlList(SdrHdlList& rHdlList) const } } -FASTBOOL SdrVirtObj::HasSpecialDrag() const +//////////////////////////////////////////////////////////////////////////////////////////////////// + +bool SdrVirtObj::hasSpecialDrag() const { - return rRefObj.HasSpecialDrag(); + return rRefObj.hasSpecialDrag(); } -FASTBOOL SdrVirtObj::BegDrag(SdrDragStat& rDrag) const +bool SdrVirtObj::supportsFullDrag() const { - return rRefObj.BegDrag(rDrag); + return false; } -FASTBOOL SdrVirtObj::MovDrag(SdrDragStat& rDrag) const +SdrObject* SdrVirtObj::getFullDragClone() const { - return rRefObj.MovDrag(rDrag); + static bool bSpecialHandling(false); + SdrObject* pRetval = 0; + + if(bSpecialHandling) + { + // special handling for VirtObj. Do not create another + // reference to rRefObj, this would allow to change that + // one on drag. Instead, create a SdrGrafObj for drag containing + // the graphical representation + pRetval = new SdrGrafObj(SdrDragView::GetObjGraphic(GetModel(), this), GetLogicRect()); + } + else + { + SdrObject& rReferencedObject = ((SdrVirtObj*)this)->ReferencedObj(); + pRetval = new SdrGrafObj(SdrDragView::GetObjGraphic(GetModel(), &rReferencedObject), GetLogicRect()); + } + + return pRetval; } -FASTBOOL SdrVirtObj::EndDrag(SdrDragStat& rDrag) +bool SdrVirtObj::beginSpecialDrag(SdrDragStat& rDrag) const { - return rRefObj.EndDrag(rDrag); + return rRefObj.beginSpecialDrag(rDrag); } -void SdrVirtObj::BrkDrag(SdrDragStat& rDrag) const +bool SdrVirtObj::applySpecialDrag(SdrDragStat& rDrag) { - rRefObj.BrkDrag(rDrag); + return rRefObj.applySpecialDrag(rDrag); } -basegfx::B2DPolyPolygon SdrVirtObj::TakeDragPoly(const SdrDragStat& rDrag) const +basegfx::B2DPolyPolygon SdrVirtObj::getSpecialDragPoly(const SdrDragStat& rDrag) const { - return rRefObj.TakeDragPoly(rDrag); + return rRefObj.getSpecialDragPoly(rDrag); // Offset handlen !!!!!! fehlt noch !!!!!!! } -XubString SdrVirtObj::GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const +String SdrVirtObj::getSpecialDragComment(const SdrDragStat& rDrag) const { - return rRefObj.GetDragComment(rDrag,bUndoDragComment,bCreateComment); + return rRefObj.getSpecialDragComment(rDrag); } //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/svx/source/svdraw/svdsnpv.cxx b/svx/source/svdraw/svdsnpv.cxx index 3d35db9d29ab..be0e871d61bf 100644 --- a/svx/source/svdraw/svdsnpv.cxx +++ b/svx/source/svdraw/svdsnpv.cxx @@ -461,9 +461,7 @@ USHORT SdrSnapView::SnapPos(Point& rPnt, const SdrPageView* pPV) const return bRet; } -void SdrSnapView::CheckSnap(const Point& rPt, const SdrPageView* pPV, - long& nBestXSnap, long& nBestYSnap, - BOOL& bXSnapped, BOOL& bYSnapped) const +void SdrSnapView::CheckSnap(const Point& rPt, const SdrPageView* pPV, long& nBestXSnap, long& nBestYSnap, bool& bXSnapped, bool& bYSnapped) const { Point aPt(rPt); USHORT nRet=SnapPos(aPt,pPV); @@ -494,8 +492,8 @@ USHORT SdrSnapView::SnapRect(const Rectangle& rRect, const SdrPageView* pPV, lon { long nBestXSnap=0; long nBestYSnap=0; - BOOL bXSnapped=FALSE; - BOOL bYSnapped=FALSE; + bool bXSnapped=FALSE; + bool bYSnapped=FALSE; CheckSnap(rRect.TopLeft() ,pPV,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped); if (!bMoveSnapOnlyTopLeft) { CheckSnap(rRect.TopRight() ,pPV,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped); diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx index 465b5be209c3..84ddc594f97e 100644 --- a/svx/source/svdraw/svdview.cxx +++ b/svx/source/svdraw/svdview.cxx @@ -981,14 +981,14 @@ Pointer SdrView::GetPreferedPointer(const Point& rMousePos, const OutputDevice* { return pAktCreate->GetCreatePointer(); } - if (pDragBla!=NULL) + if (mpCurrentSdrDragMethod) { if ((IsDraggingPoints() || IsDraggingGluePoints()) && IsMouseHideWhileDraggingPoints()) return Pointer(POINTER_NULL); - OSL_TRACE("SdrView::GetPreferedPointer(%lx) %lx\n", this, pDragBla); + OSL_TRACE("SdrView::GetPreferedPointer(%lx) %lx\n", this, mpCurrentSdrDragMethod); - return pDragBla->GetPointer(); + return mpCurrentSdrDragMethod->GetSdrDragPointer(); } if (IsMarkObj() || IsMarkPoints() || IsMarkGluePoints() || IsEncirclement() || IsSetPageOrg()) return Pointer(POINTER_ARROW); if (IsDragHelpLine()) return GetDraggedHelpLinePointer(); @@ -1207,7 +1207,7 @@ XubString SdrView::GetStatusText() if (pAktCreate!=NULL) { - aStr=pAktCreate->GetDragComment(aDragStat,FALSE,TRUE); + aStr=pAktCreate->getSpecialDragComment(aDragStat); if(!aStr.Len()) { @@ -1215,7 +1215,7 @@ XubString SdrView::GetStatusText() aStr = ImpGetResStr(STR_ViewCreateObj); } } - else if (pDragBla!=NULL) + else if (mpCurrentSdrDragMethod) { if (bInsPolyPoint || IsInsertGluePoint()) { @@ -1225,8 +1225,8 @@ XubString SdrView::GetStatusText() { if (aDragStat.IsMinMoved()) { - OSL_TRACE("SdrView::GetStatusText(%lx) %lx\n", this, pDragBla); - pDragBla->TakeComment(aStr); + OSL_TRACE("SdrView::GetStatusText(%lx) %lx\n", this, mpCurrentSdrDragMethod); + mpCurrentSdrDragMethod->TakeSdrDragComment(aStr); } } } diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx index 207faa7d78ea..58ef0c2e9743 100644 --- a/svx/source/svdraw/svdxcgv.cxx +++ b/svx/source/svdraw/svdxcgv.cxx @@ -628,25 +628,27 @@ Graphic SdrExchangeView::GetAllMarkedGraphic() const // ----------------------------------------------------------------------------- -Graphic SdrExchangeView::GetObjGraphic( SdrModel* pModel, SdrObject* pObj ) +Graphic SdrExchangeView::GetObjGraphic( const SdrModel* pModel, const SdrObject* pObj ) { Graphic aRet; if( pModel && pObj ) { // try to get a graphic from the object first - if( pObj->ISA( SdrGrafObj ) ) + const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj); + const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pObj); + + if(pSdrGrafObj) { // #110981# Make behaviour coherent with metafile // recording below (which of course also takes // view-transformed objects) - aRet = static_cast< SdrGrafObj* >( pObj )->GetTransformedGraphic(); + aRet = pSdrGrafObj->GetTransformedGraphic(); } - else if( pObj->ISA( SdrOle2Obj ) ) + else if(pSdrOle2Obj) { - SdrOle2Obj* pOLEObj = static_cast< SdrOle2Obj* >( pObj ); - if ( pOLEObj->GetGraphic() ) - aRet = *pOLEObj->GetGraphic(); + if ( pSdrOle2Obj->GetGraphic() ) + aRet = *pSdrOle2Obj->GetGraphic(); } // if graphic could not be retrieved => go the hard way and create a MetaFile @@ -770,7 +772,7 @@ SdrModel* SdrExchangeView::GetMarkedObjModel() const { // convert SdrPageObj's to a graphic representation, because // virtual connection to referenced page gets lost in new model - pNeuObj = new SdrGrafObj( GetObjGraphic( pMod, const_cast< SdrObject* >( pObj ) ), pObj->GetLogicRect() ); + pNeuObj = new SdrGrafObj( GetObjGraphic( pMod, pObj ), pObj->GetLogicRect() ); pNeuObj->SetPage( pNeuPag ); pNeuObj->SetModel( pNeuMod ); } diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index dabbe9f9a741..b47f91d13b23 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -2476,126 +2476,58 @@ SdrHdl* SdrTableObj::GetHdl(sal_uInt32 nHdlNum) const return pRetval; } -// -------------------------------------------------------------------- +//////////////////////////////////////////////////////////////////////////////////////////////////// // Draging -// -------------------------------------------------------------------- - -FASTBOOL SdrTableObj::HasSpecialDrag() const -{ - return TRUE; -} - -// -------------------------------------------------------------------- -struct ImpSdrTableObjDragUser : public SdrDragStatUserData +bool SdrTableObj::hasSpecialDrag() const { - Rectangle maRectangle; -}; - -// -------------------------------------------------------------------- - -FASTBOOL SdrTableObj::BegDrag(SdrDragStat& rDrag) const -{ - FASTBOOL bRet = TRUE; - - const SdrHdl* pHdl = rDrag.GetHdl(); - SdrHdlKind eHdl = pHdl == NULL ? HDL_MOVE : pHdl->GetKind(); - switch( eHdl ) - { - case HDL_UPLFT: - case HDL_UPPER: - case HDL_UPRGT: - case HDL_LEFT: - case HDL_RIGHT: - case HDL_LWLFT: - case HDL_LOWER: - case HDL_LWRGT: - case HDL_MOVE: - break; - - case HDL_USER: - rDrag.SetEndDragChangesAttributes( sal_False ); - rDrag.SetNoSnap( TRUE ); - break; - - default: - bRet = FALSE; - } - - if( bRet ) - { - ImpSdrTableObjDragUser* pUser = static_cast<ImpSdrTableObjDragUser*>(rDrag.GetUser()); - - if(!pUser) - pUser = new ImpSdrTableObjDragUser; - - pUser->maRectangle = aRect; - rDrag.SetUser(pUser); - } - - return bRet; + return true; } -// -------------------------------------------------------------------- - -FASTBOOL SdrTableObj::MovDrag(SdrDragStat& rDrag) const +bool SdrTableObj::beginSpecialDrag(SdrDragStat& rDrag) const { - FASTBOOL bRet = TRUE; - const SdrHdl* pHdl = rDrag.GetHdl(); - SdrHdlKind eHdl = pHdl == NULL ? HDL_MOVE : pHdl->GetKind(); - ImpSdrTableObjDragUser* pUser = static_cast<ImpSdrTableObjDragUser*>(rDrag.GetUser()); + const SdrHdlKind eHdl((pHdl == NULL) ? HDL_MOVE : pHdl->GetKind()); - if( pUser ) switch( eHdl ) - { - case HDL_UPLFT: - case HDL_UPPER: - case HDL_UPRGT: - case HDL_LEFT: - case HDL_RIGHT: - case HDL_LWLFT: - case HDL_LOWER: - case HDL_LWRGT: - { - pUser->maRectangle = ImpDragCalcRect( rDrag ); - break; - } - case HDL_MOVE: + switch( eHdl ) { - pUser->maRectangle = aRect; - pUser->maRectangle.Move( rDrag.GetDX(), rDrag.GetDY() ); - break; - } + case HDL_UPLFT: + case HDL_UPPER: + case HDL_UPRGT: + case HDL_LEFT: + case HDL_RIGHT: + case HDL_LWLFT: + case HDL_LOWER: + case HDL_LWRGT: + case HDL_MOVE: + { + break; + } - case HDL_USER: - { - rDrag.SetEndDragChangesAttributes( sal_False ); - rDrag.SetNoSnap( TRUE ); - break; - } + case HDL_USER: + { + rDrag.SetEndDragChangesAttributes(false); + rDrag.SetNoSnap(true); + break; + } - default: - bRet = FALSE; + default: + { + return false; + } } - return bRet; + return true; } -// -------------------------------------------------------------------- - -FASTBOOL SdrTableObj::EndDrag(SdrDragStat& rDrag) +bool SdrTableObj::applySpecialDrag(SdrDragStat& rDrag) { - FASTBOOL bRet = TRUE; - + bool bRet(true); const SdrHdl* pHdl = rDrag.GetHdl(); - SdrHdlKind eHdl = pHdl == NULL ? HDL_MOVE : pHdl->GetKind(); - ImpSdrTableObjDragUser* pUser = static_cast<ImpSdrTableObjDragUser*>(rDrag.GetUser()); + const SdrHdlKind eHdl((pHdl == NULL) ? HDL_MOVE : pHdl->GetKind()); - if( pUser ) + switch( eHdl ) { - - switch( eHdl ) - { case HDL_UPLFT: case HDL_UPPER: case HDL_UPRGT: @@ -2604,21 +2536,35 @@ FASTBOOL SdrTableObj::EndDrag(SdrDragStat& rDrag) case HDL_LWLFT: case HDL_LOWER: case HDL_LWRGT: - if(pUser->maRectangle != aRect) - SetLogicRect(pUser->maRectangle); + { + const Rectangle aNewRectangle(ImpDragCalcRect(rDrag)); + + if(aNewRectangle != aRect) + { + NbcSetLogicRect(aNewRectangle); + } + break; + } case HDL_MOVE: - Move( Size( rDrag.GetDX(), rDrag.GetDY() ) ); + { + NbcMove( Size( rDrag.GetDX(), rDrag.GetDY() ) ); break; + } case HDL_USER: { + rDrag.SetEndDragChangesAttributes(false); + rDrag.SetNoSnap(true); const TableEdgeHdl* pEdgeHdl = dynamic_cast< const TableEdgeHdl* >( pHdl ); + if( pEdgeHdl ) { if( GetModel() && IsInserted() ) - GetModel()->AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*this) ); + { + rDrag.SetEndDragChangesAttributes(true); + } mpImpl->DragEdge( pEdgeHdl->IsHorizontalEdge(), pEdgeHdl->GetPointNum(), pEdgeHdl->GetValidDragOffset( rDrag ) ); } @@ -2626,77 +2572,38 @@ FASTBOOL SdrTableObj::EndDrag(SdrDragStat& rDrag) } default: - bRet = FALSE; + { + bRet = false; } - - rDrag.SetUser(NULL); - delete pUser; } return bRet; } -// -------------------------------------------------------------------- - -void SdrTableObj::BrkDrag(SdrDragStat& rDrag ) const +String SdrTableObj::getSpecialDragComment(const SdrDragStat& rDrag) const { - ImpSdrTableObjDragUser* pUser = static_cast<ImpSdrTableObjDragUser*>(rDrag.GetUser()); - if( pUser ) - { - delete pUser; - rDrag.SetUser(NULL); - } + return SdrTextObj::getSpecialDragComment( rDrag ); } -// -------------------------------------------------------------------- - -XubString SdrTableObj::GetDragComment(const SdrDragStat& rDrag, FASTBOOL bUndoDragComment, FASTBOOL bCreateComment) const +basegfx::B2DPolyPolygon SdrTableObj::getSpecialDragPoly(const SdrDragStat& rDrag) const { - return SdrTextObj::GetDragComment( rDrag, bUndoDragComment, bCreateComment ); -} - -// -------------------------------------------------------------------- - -basegfx::B2DPolyPolygon SdrTableObj::TakeDragPoly(const SdrDragStat& rDrag) const -{ - basegfx::B2DPolyPolygon aRetVal; - + basegfx::B2DPolyPolygon aRetval; const SdrHdl* pHdl = rDrag.GetHdl(); - SdrHdlKind eHdl = pHdl == NULL ? HDL_MOVE : pHdl->GetKind(); - ImpSdrTableObjDragUser* pUser = static_cast<ImpSdrTableObjDragUser*>(rDrag.GetUser()); - if( pUser ) switch( eHdl ) + if(HDL_USER == pHdl->GetKind()) { - case HDL_UPLFT: - case HDL_UPPER: - case HDL_UPRGT: - case HDL_LEFT: - case HDL_RIGHT: - case HDL_LWLFT: - case HDL_LOWER: - case HDL_LWRGT: - case HDL_MOVE: - { - aRetVal.append( - basegfx::tools::createPolygonFromRect( - vcl::unotools::b2DRectangleFromRectangle( pUser->maRectangle ) ) ); - break; - } + const TableEdgeHdl* pEdgeHdl = dynamic_cast< const TableEdgeHdl* >( pHdl ); - case HDL_USER : + if( pEdgeHdl ) { - const TableEdgeHdl* pEdgeHdl = dynamic_cast< const TableEdgeHdl* >( pHdl ); - if( pEdgeHdl ) - aRetVal = pEdgeHdl->TakeDragPoly( &rDrag ); - break; + aRetval = pEdgeHdl->getSpecialDragPoly( rDrag ); } - - default: break; } - return aRetVal; + + return aRetval; } -// -------------------------------------------------------------------- +//////////////////////////////////////////////////////////////////////////////////////////////////// // Create // -------------------------------------------------------------------- diff --git a/svx/source/table/tablehandles.cxx b/svx/source/table/tablehandles.cxx index 883e9cb29e0c..6b88e1d9a0ac 100644 --- a/svx/source/table/tablehandles.cxx +++ b/svx/source/table/tablehandles.cxx @@ -132,9 +132,9 @@ sal_Int32 TableEdgeHdl::GetValidDragOffset( const SdrDragStat& rDrag ) const return std::min( std::max( static_cast<sal_Int32>(mbHorizontal ? rDrag.GetDY() : rDrag.GetDX()), mnMin ), mnMax ); } -basegfx::B2DPolyPolygon TableEdgeHdl::TakeDragPoly( const SdrDragStat* pDrag /*= 0*/ ) const +basegfx::B2DPolyPolygon TableEdgeHdl::getSpecialDragPoly(const SdrDragStat& rDrag) const { - return GetPolyPolygon(false, pDrag); + return GetPolyPolygon(false, &rDrag); } bool TableEdgeHdl::IsHdlHit(const Point& rPnt) const diff --git a/svx/source/table/tablehandles.hxx b/svx/source/table/tablehandles.hxx index d546bee4971f..a6831f72bc88 100644 --- a/svx/source/table/tablehandles.hxx +++ b/svx/source/table/tablehandles.hxx @@ -67,7 +67,7 @@ public: bool IsHorizontalEdge() const { return mbHorizontal; } - basegfx::B2DPolyPolygon TakeDragPoly( const SdrDragStat* pDrag = 0 ) const; + basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const; basegfx::B2DPolyPolygon GetPolyPolygon( bool bOnlyVisible, const SdrDragStat* pDrag = 0 ) const; protected: diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx index a28d2291363b..988cf1a5dc23 100644 --- a/svx/source/table/tablemodel.cxx +++ b/svx/source/table/tablemodel.cxx @@ -941,7 +941,7 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount ) } if( pModel && mpTableObj->IsInserted() ) - { + { pModel->BegUndo( ImpGetResStr(STR_TABLE_INSROW) ); pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); TableModelRef xThis( this ); |