1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdhdl.cxx,v $
10 * $Revision: 1.34.18.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
36 #include <svx/svdhdl.hxx>
37 #include <svx/svdpagv.hxx>
38 #include <svx/svdetc.hxx>
39 #include <svx/svdmrkv.hxx>
40 #include <vcl/window.hxx>
42 #include <vcl/virdev.hxx>
43 #include <tools/poly.hxx>
44 #include <vcl/bmpacc.hxx>
46 #include <svx/sxekitm.hxx>
48 #include "svdglob.hxx"
50 #include <svx/svdmodel.hxx>
51 #include "gradtrns.hxx"
52 #include <svx/xflgrit.hxx>
53 #include <svx/svdundo.hxx>
54 #include <svx/dialmgr.hxx>
55 #include <svx/xflftrit.hxx>
58 #include <svx/svdopath.hxx>
59 #include <basegfx/vector/b2dvector.hxx>
60 #include <basegfx/polygon/b2dpolygon.hxx>
61 #include <svx/sdr/overlay/overlaymanager.hxx>
62 #include <svx/sdr/overlay/overlayanimatedbitmapex.hxx>
63 #include <svx/sdr/overlay/overlaybitmapex.hxx>
64 #include <svx/sdr/overlay/overlayline.hxx>
65 #include <svx/sdr/overlay/overlaytriangle.hxx>
66 #include <svx/sdr/overlay/overlayhatchrect.hxx>
67 #include <svx/sdrpagewindow.hxx>
68 #include <sdrpaintwindow.hxx>
69 #include <vcl/svapp.hxx>
70 #include <svx/sdr/overlay/overlaypolypolygon.hxx>
71 #include <vcl/lazydelete.hxx>
73 ////////////////////////////////////////////////////////////////////////////////////////////////////
75 // Due to the ressource problems in Win95/98 with bitmap ressources i
76 // will change this handle bitmap provinging class. Old version was splitting
77 // and preparing all small handle bitmaps in device bitmap format, now this will
78 // be done on the fly. Thus, tehre is only the one big bitmap remembered. With
79 // three source bitmaps, this will be 3 system bitmap ressources instead of hundreds.
80 // The price for that needs to be evaluated. Maybe we will need another change here
81 // if this is too expensive.
84 // the bitmap holding all infos
85 BitmapEx maMarkersBitmap
;
87 // the cropped Bitmaps for reusage
88 ::std::vector
< BitmapEx
> maRealMarkers
;
91 BitmapEx
& impGetOrCreateTargetBitmap(sal_uInt16 nIndex
, const Rectangle
& rRectangle
);
94 SdrHdlBitmapSet(UINT16 nResId
);
97 const BitmapEx
& GetBitmapEx(BitmapMarkerKind eKindOfMarker
, UINT16 nInd
=0);
100 ////////////////////////////////////////////////////////////////////////////////////////////////////
101 #define KIND_COUNT (14)
102 #define INDEX_COUNT (6)
103 #define INDIVIDUAL_COUNT (4)
105 SdrHdlBitmapSet::SdrHdlBitmapSet(UINT16 nResId
)
107 // 14 kinds (BitmapMarkerKind) use index [0..5], 4 extra
108 maRealMarkers((KIND_COUNT
* INDEX_COUNT
) + INDIVIDUAL_COUNT
)
110 // #101928# change color used for transparent parts to 0x00ff00ff (ImageList standard)
111 const Color
aColTransparent(0x00ff00ff);
112 const Bitmap
aBitmap(ResId(nResId
, *ImpGetResMgr()));
113 const Bitmap
aMask(aBitmap
.CreateMask(aColTransparent
));
115 // create a real BitmapEx with an AlphaMask
116 maMarkersBitmap
= BitmapEx(aBitmap
, aMask
);
117 // maMarkersBitmap = BitmapEx(aBitmap, aColTransparent);
120 SdrHdlBitmapSet::~SdrHdlBitmapSet()
124 BitmapEx
& SdrHdlBitmapSet::impGetOrCreateTargetBitmap(sal_uInt16 nIndex
, const Rectangle
& rRectangle
)
126 BitmapEx
& rTargetBitmap
= maRealMarkers
[nIndex
];
128 if(rTargetBitmap
.IsEmpty())
130 rTargetBitmap
= maMarkersBitmap
;
131 rTargetBitmap
.Crop(rRectangle
);
134 return rTargetBitmap
;
137 // change getting of bitmap to use the big ressource bitmap
138 const BitmapEx
& SdrHdlBitmapSet::GetBitmapEx(BitmapMarkerKind eKindOfMarker
, UINT16 nInd
)
140 // fill in size and source position in maMarkersBitmap
141 const sal_uInt16
nYPos(nInd
* 11);
143 switch(eKindOfMarker
)
147 DBG_ERROR( "unknown kind of marker" );
148 // no break here, return Rect_7x7 as default
152 return impGetOrCreateTargetBitmap((0 * INDEX_COUNT
) + nInd
, Rectangle(Point(0, nYPos
), Size(7, 7)));
157 return impGetOrCreateTargetBitmap((1 * INDEX_COUNT
) + nInd
, Rectangle(Point(7, nYPos
), Size(9, 9)));
162 return impGetOrCreateTargetBitmap((2 * INDEX_COUNT
) + nInd
, Rectangle(Point(16, nYPos
), Size(11, 11)));
167 const sal_uInt16
nIndex((3 * INDEX_COUNT
) + nInd
);
173 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(72, 66), Size(13, 13)));
177 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(85, 66), Size(13, 13)));
181 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(72, 78), Size(13, 13)));
185 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(85, 78), Size(13, 13)));
189 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(98, 78), Size(13, 13)));
193 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(98, 66), Size(13, 13)));
200 return impGetOrCreateTargetBitmap((4 * INDEX_COUNT
) + nInd
, Rectangle(Point(27, nYPos
), Size(7, 7)));
206 return impGetOrCreateTargetBitmap((5 * INDEX_COUNT
) + nInd
, Rectangle(Point(34, nYPos
), Size(9, 9)));
211 return impGetOrCreateTargetBitmap((6 * INDEX_COUNT
) + nInd
, Rectangle(Point(43, nYPos
), Size(11, 11)));
216 return impGetOrCreateTargetBitmap((7 * INDEX_COUNT
) + nInd
, Rectangle(Point(54, nYPos
), Size(7, 9)));
221 return impGetOrCreateTargetBitmap((8 * INDEX_COUNT
) + nInd
, Rectangle(Point(61, nYPos
), Size(9, 11)));
226 return impGetOrCreateTargetBitmap((9 * INDEX_COUNT
) + nInd
, Rectangle(Point(70, nYPos
), Size(9, 7)));
231 return impGetOrCreateTargetBitmap((10 * INDEX_COUNT
) + nInd
, Rectangle(Point(79, nYPos
), Size(11, 9)));
236 return impGetOrCreateTargetBitmap((11 * INDEX_COUNT
) + nInd
, Rectangle(Point(90, nYPos
), Size(7, 7)));
241 return impGetOrCreateTargetBitmap((12 * INDEX_COUNT
) + nInd
, Rectangle(Point(97, nYPos
), Size(9, 9)));
246 return impGetOrCreateTargetBitmap((13 * INDEX_COUNT
) + nInd
, Rectangle(Point(106, nYPos
), Size(11, 11)));
251 return impGetOrCreateTargetBitmap((KIND_COUNT
* INDEX_COUNT
) + 0, Rectangle(Point(0, 68), Size(15, 15)));
256 return impGetOrCreateTargetBitmap((KIND_COUNT
* INDEX_COUNT
) + 1, Rectangle(Point(15, 74), Size(9, 9)));
259 case Anchor
: // #101688# AnchorTR for SW
262 return impGetOrCreateTargetBitmap((KIND_COUNT
* INDEX_COUNT
) + 2, Rectangle(Point(24, 68), Size(24, 23)));
265 // #98388# add AnchorPressed to be able to aninate anchor control
267 case AnchorPressedTR
:
269 return impGetOrCreateTargetBitmap((KIND_COUNT
* INDEX_COUNT
) + 3, Rectangle(Point(48, 68), Size(24, 23)));
273 // cannot happen since all pathes return something; return Rect_7x7 as default (see switch)
274 return maRealMarkers
[0];
277 ////////////////////////////////////////////////////////////////////////////////////////////////////
279 SdrHdlBitmapSet
& getSimpleSet()
281 static vcl::DeleteOnDeinit
< SdrHdlBitmapSet
> aSimpleSet(new SdrHdlBitmapSet(SIP_SA_MARKERS
));
282 return *aSimpleSet
.get();
285 SdrHdlBitmapSet
& getModernSet()
287 static vcl::DeleteOnDeinit
< SdrHdlBitmapSet
> aModernSet(new SdrHdlBitmapSet(SIP_SA_MARKERS
));
288 return *aModernSet
.get();
291 SdrHdlBitmapSet
& getHighContrastSet()
293 static vcl::DeleteOnDeinit
< SdrHdlBitmapSet
> aHighContrastSet(new SdrHdlBitmapSet(SIP_SA_MARKERS
));
294 return *aHighContrastSet
.get();
297 ////////////////////////////////////////////////////////////////////////////////////////////////////
316 SdrHdl::SdrHdl(const Point
& rPnt
, SdrHdlKind eNewKind
):
339 void SdrHdl::Set1PixMore(BOOL bJa
)
345 // create new display
350 void SdrHdl::SetMoveOutside( bool bMoveOutside
)
352 if(mbMoveOutside
!= bMoveOutside
)
354 mbMoveOutside
= bMoveOutside
;
356 // create new display
361 void SdrHdl::SetDrehWink(long n
)
367 // create new display
372 void SdrHdl::SetPos(const Point
& rPnt
)
376 // remember new position
379 // create new display
384 void SdrHdl::SetSelected(BOOL bJa
)
388 // remember new value
391 // create new display
396 void SdrHdl::SetHdlList(SdrHdlList
* pList
)
398 if(pHdlList
!= pList
)
403 // now its possible to create graphic representation
408 void SdrHdl::SetObj(SdrObject
* pNewObj
)
412 // remember new object
415 // graphic representation may have changed
422 // force update of graphic representation
426 void SdrHdl::GetRidOfIAObject()
428 //OLMaIAOGroup.Delete();
431 maOverlayGroup
.clear();
434 void SdrHdl::CreateB2dIAObject()
436 // first throw away old one
439 if(pHdlList
&& pHdlList
->GetView() && !pHdlList
->GetView()->areMarkHandlesHidden())
441 BitmapColorIndex eColIndex
= LightGreen
;
442 BitmapMarkerKind eKindOfMarker
= Rect_7x7
;
444 BOOL bRot
= pHdlList
->IsRotateShear();
446 eColIndex
= (bSelect
) ? Cyan
: LightCyan
;
449 // Drehhandles in Rot
453 eColIndex
= LightRed
;
460 eKindOfMarker
= (b1PixMore
) ? Rect_9x9
: Rect_7x7
;
471 eKindOfMarker
= Circ_7x7
;
475 eKindOfMarker
= Rect_7x7
;
482 // Upper/Lower handles
485 eKindOfMarker
= Elli_9x7
;
489 eKindOfMarker
= Rect_7x7
;
496 // Left/Right handles
499 eKindOfMarker
= Elli_7x9
;
503 eKindOfMarker
= Rect_7x7
;
511 eKindOfMarker
= (b1PixMore
) ? Circ_9x9
: Circ_7x7
;
515 eKindOfMarker
= (b1PixMore
) ? Rect_9x9
: Rect_7x7
;
519 case HDL_BWGT
: // weight at poly
521 eKindOfMarker
= Circ_7x7
;
526 eKindOfMarker
= Rect_11x11
;
532 eKindOfMarker
= Crosshair
;
537 eKindOfMarker
= Glue
;
542 eKindOfMarker
= Anchor
;
549 // #101688# top right anchor for SW
552 eKindOfMarker
= AnchorTR
;
556 // for SJ and the CustomShapeHandles:
557 case HDL_CUSTOMSHAPE1
:
559 eKindOfMarker
= Customshape1
;
567 SdrMarkView
* pView
= pHdlList
->GetView();
568 SdrPageView
* pPageView
= pView
->GetSdrPageView();
572 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
574 // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
575 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
577 if(rPageWindow
.GetPaintWindow().OutputToWindow())
579 Point
aMoveOutsideOffset(0, 0);
581 // add offset if necessary
582 if(pHdlList
->IsMoveOutside() || mbMoveOutside
)
584 OutputDevice
& rOutDev
= rPageWindow
.GetPaintWindow().GetOutputDevice();
585 Size aOffset
= rOutDev
.PixelToLogic(Size(4, 4));
587 if(eKind
== HDL_UPLFT
|| eKind
== HDL_UPPER
|| eKind
== HDL_UPRGT
)
588 aMoveOutsideOffset
.Y() -= aOffset
.Width();
589 if(eKind
== HDL_LWLFT
|| eKind
== HDL_LOWER
|| eKind
== HDL_LWRGT
)
590 aMoveOutsideOffset
.Y() += aOffset
.Height();
591 if(eKind
== HDL_UPLFT
|| eKind
== HDL_LEFT
|| eKind
== HDL_LWLFT
)
592 aMoveOutsideOffset
.X() -= aOffset
.Width();
593 if(eKind
== HDL_UPRGT
|| eKind
== HDL_RIGHT
|| eKind
== HDL_LWRGT
)
594 aMoveOutsideOffset
.X() += aOffset
.Height();
597 if(rPageWindow
.GetOverlayManager())
599 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
600 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= CreateOverlayObject(
607 if(pNewOverlayObject
)
609 rPageWindow
.GetOverlayManager()->add(*pNewOverlayObject
);
610 maOverlayGroup
.append(*pNewOverlayObject
);
619 BitmapMarkerKind
SdrHdl::GetNextBigger(BitmapMarkerKind eKnd
) const
621 BitmapMarkerKind
eRetval(eKnd
);
625 case Rect_7x7
: eRetval
= Rect_9x9
; break;
626 case Rect_9x9
: eRetval
= Rect_11x11
; break;
627 case Rect_11x11
: eRetval
= Rect_13x13
; break;
628 //case Rect_13x13: eRetval = ; break;
630 case Circ_7x7
: eRetval
= Circ_9x9
; break;
631 case Circ_9x9
: eRetval
= Circ_11x11
; break;
632 //case Circ_11x11: eRetval = ; break;
634 case Elli_7x9
: eRetval
= Elli_9x11
; break;
635 //case Elli_9x11: eRetval = ; break;
637 case Elli_9x7
: eRetval
= Elli_11x9
; break;
638 //case Elli_11x9: eRetval = ; break;
640 case RectPlus_7x7
: eRetval
= RectPlus_9x9
; break;
641 case RectPlus_9x9
: eRetval
= RectPlus_11x11
; break;
642 //case RectPlus_11x11: eRetval = ; break;
644 //case Crosshair: eRetval = ; break;
645 //case Glue: eRetval = ; break;
647 // #98388# let anchor blink with it's pressed state
648 case Anchor
: eRetval
= AnchorPressed
; break;
650 // #101688# same for AnchorTR
651 case AnchorTR
: eRetval
= AnchorPressedTR
; break;
660 BitmapEx
SdrHdl::ImpGetBitmapEx(BitmapMarkerKind eKindOfMarker
, sal_uInt16 nInd
, sal_Bool bFine
, sal_Bool bIsHighContrast
)
664 return getHighContrastSet().GetBitmapEx(eKindOfMarker
, nInd
);
670 return getModernSet().GetBitmapEx(eKindOfMarker
, nInd
);
674 return getSimpleSet().GetBitmapEx(eKindOfMarker
, nInd
);
679 ::sdr::overlay::OverlayObject
* SdrHdl::CreateOverlayObject(
680 const basegfx::B2DPoint
& rPos
,
681 BitmapColorIndex eColIndex
, BitmapMarkerKind eKindOfMarker
, Point aMoveOutsideOffset
)
683 ::sdr::overlay::OverlayObject
* pRetval
= 0L;
684 sal_Bool
bIsFineHdl(pHdlList
->IsFineHdl());
685 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
686 sal_Bool
bIsHighContrast(rStyleSettings
.GetHighContrastMode());
688 // support bigger sizes
689 sal_Bool
bForceBiggerSize(sal_False
);
691 if(pHdlList
->GetHdlSize() > 3)
693 bForceBiggerSize
= sal_True
;
696 // #101928# ...for high contrast, too.
697 if(!bForceBiggerSize
&& bIsHighContrast
)
700 // ...but not for anchors, else they will not blink when activated
701 if(Anchor
!= eKindOfMarker
&& AnchorTR
!= eKindOfMarker
)
703 bForceBiggerSize
= sal_True
;
709 eKindOfMarker
= GetNextBigger(eKindOfMarker
);
712 // #97016# II This handle has the focus, visualize it
713 if(IsFocusHdl() && pHdlList
&& pHdlList
->GetFocusHdl() == this)
715 // create animated handle
716 BitmapMarkerKind eNextBigger
= GetNextBigger(eKindOfMarker
);
718 if(eNextBigger
== eKindOfMarker
)
720 // this may happen for the not supported getting-bigger types.
721 // Choose an alternative here
722 switch(eKindOfMarker
)
724 case Rect_13x13
: eNextBigger
= Rect_11x11
; break;
725 case Circ_11x11
: eNextBigger
= Elli_11x9
; break;
726 case Elli_9x11
: eNextBigger
= Elli_11x9
; break;
727 case Elli_11x9
: eNextBigger
= Elli_9x11
; break;
728 case RectPlus_11x11
: eNextBigger
= Rect_13x13
; break;
735 eNextBigger
= Crosshair
;
742 // create animated hdl
743 // #101928# use ImpGetBitmapEx(...) now
744 BitmapEx aBmpEx1
= ImpGetBitmapEx(eKindOfMarker
, (sal_uInt16
)eColIndex
, bIsFineHdl
, bIsHighContrast
);
745 BitmapEx aBmpEx2
= ImpGetBitmapEx(eNextBigger
, (sal_uInt16
)eColIndex
, bIsFineHdl
, bIsHighContrast
);
747 // #i53216# Use system cursor blink time. Use the unsigned value.
748 const sal_uInt32
nBlinkTime((sal_uInt32
)Application::GetSettings().GetStyleSettings().GetCursorBlinkTime());
750 if(eKindOfMarker
== Anchor
|| eKindOfMarker
== AnchorPressed
)
752 // #98388# when anchor is used take upper left as reference point inside the handle
753 pRetval
= new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos
, aBmpEx1
, aBmpEx2
, nBlinkTime
);
755 else if(eKindOfMarker
== AnchorTR
|| eKindOfMarker
== AnchorPressedTR
)
757 // #101688# AnchorTR for SW, take top right as (0,0)
758 pRetval
= new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos
, aBmpEx1
, aBmpEx2
, nBlinkTime
,
759 (UINT16
)(aBmpEx1
.GetSizePixel().Width() - 1), 0,
760 (UINT16
)(aBmpEx2
.GetSizePixel().Width() - 1), 0);
764 // create centered handle as default
765 pRetval
= new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos
, aBmpEx1
, aBmpEx2
, nBlinkTime
,
766 (UINT16
)(aBmpEx1
.GetSizePixel().Width() - 1) >> 1,
767 (UINT16
)(aBmpEx1
.GetSizePixel().Height() - 1) >> 1,
768 (UINT16
)(aBmpEx2
.GetSizePixel().Width() - 1) >> 1,
769 (UINT16
)(aBmpEx2
.GetSizePixel().Height() - 1) >> 1);
774 // create normal handle
775 // #101928# use ImpGetBitmapEx(...) now
776 BitmapEx aBmpEx
= ImpGetBitmapEx(eKindOfMarker
, (sal_uInt16
)eColIndex
, bIsFineHdl
, bIsHighContrast
);
778 if(eKindOfMarker
== Anchor
|| eKindOfMarker
== AnchorPressed
)
780 // #98388# upper left as reference point inside the handle for AnchorPressed, too
781 pRetval
= new ::sdr::overlay::OverlayBitmapEx(rPos
, aBmpEx
);
783 else if(eKindOfMarker
== AnchorTR
|| eKindOfMarker
== AnchorPressedTR
)
785 // #101688# AnchorTR for SW, take top right as (0,0)
786 pRetval
= new ::sdr::overlay::OverlayBitmapEx(rPos
, aBmpEx
,
787 (UINT16
)(aBmpEx
.GetSizePixel().Width() - 1), 0);
791 sal_uInt16
nCenX((sal_uInt16
)(aBmpEx
.GetSizePixel().Width() - 1L) >> 1);
792 sal_uInt16
nCenY((sal_uInt16
)(aBmpEx
.GetSizePixel().Height() - 1L) >> 1);
794 if(aMoveOutsideOffset
.X() > 0)
798 else if(aMoveOutsideOffset
.X() < 0)
800 nCenX
= (sal_uInt16
)(aBmpEx
.GetSizePixel().Width() - 1);
803 if(aMoveOutsideOffset
.Y() > 0)
807 else if(aMoveOutsideOffset
.Y() < 0)
809 nCenY
= (sal_uInt16
)(aBmpEx
.GetSizePixel().Height() - 1);
812 // create centered handle as default
813 pRetval
= new ::sdr::overlay::OverlayBitmapEx(rPos
, aBmpEx
, nCenX
, nCenY
);
820 bool SdrHdl::IsHdlHit(const Point
& rPnt
) const
823 basegfx::B2DPoint
aPosition(rPnt
.X(), rPnt
.Y());
824 return maOverlayGroup
.isHitLogic(aPosition
);
827 Pointer
SdrHdl::GetPointer() const
829 PointerStyle ePtr
=POINTER_MOVE
;
830 const BOOL bSize
=eKind
>=HDL_UPLFT
&& eKind
<=HDL_LWRGT
;
831 const BOOL bRot
=pHdlList
!=NULL
&& pHdlList
->IsRotateShear();
832 const BOOL bDis
=pHdlList
!=NULL
&& pHdlList
->IsDistortShear();
833 if (bSize
&& pHdlList
!=NULL
&& (bRot
|| bDis
)) {
835 case HDL_UPLFT
: case HDL_UPRGT
:
836 case HDL_LWLFT
: case HDL_LWRGT
: ePtr
=bRot
? POINTER_ROTATE
: POINTER_REFHAND
; break;
837 case HDL_LEFT
: case HDL_RIGHT
: ePtr
=POINTER_VSHEAR
; break;
838 case HDL_UPPER
: case HDL_LOWER
: ePtr
=POINTER_HSHEAR
; break;
843 // Fuer Resize von gedrehten Rechtecken die Mauszeiger etwas mitdrehen
844 if (bSize
&& nDrehWink
!=0) {
847 case HDL_LWRGT
: nHdlWink
=31500; break;
848 case HDL_LOWER
: nHdlWink
=27000; break;
849 case HDL_LWLFT
: nHdlWink
=22500; break;
850 case HDL_LEFT
: nHdlWink
=18000; break;
851 case HDL_UPLFT
: nHdlWink
=13500; break;
852 case HDL_UPPER
: nHdlWink
=9000; break;
853 case HDL_UPRGT
: nHdlWink
=4500; break;
854 case HDL_RIGHT
: nHdlWink
=0; break;
858 nHdlWink
+=nDrehWink
+2249; // und etwas drauf (zum runden)
859 while (nHdlWink
<0) nHdlWink
+=36000;
860 while (nHdlWink
>=36000) nHdlWink
-=36000;
862 switch ((BYTE
)nHdlWink
) {
863 case 0: ePtr
=POINTER_ESIZE
; break;
864 case 1: ePtr
=POINTER_NESIZE
; break;
865 case 2: ePtr
=POINTER_NSIZE
; break;
866 case 3: ePtr
=POINTER_NWSIZE
; break;
867 case 4: ePtr
=POINTER_WSIZE
; break;
868 case 5: ePtr
=POINTER_SWSIZE
; break;
869 case 6: ePtr
=POINTER_SSIZE
; break;
870 case 7: ePtr
=POINTER_SESIZE
; break;
874 case HDL_UPLFT
: ePtr
=POINTER_NWSIZE
; break;
875 case HDL_UPPER
: ePtr
=POINTER_NSIZE
; break;
876 case HDL_UPRGT
: ePtr
=POINTER_NESIZE
; break;
877 case HDL_LEFT
: ePtr
=POINTER_WSIZE
; break;
878 case HDL_RIGHT
: ePtr
=POINTER_ESIZE
; break;
879 case HDL_LWLFT
: ePtr
=POINTER_SWSIZE
; break;
880 case HDL_LOWER
: ePtr
=POINTER_SSIZE
; break;
881 case HDL_LWRGT
: ePtr
=POINTER_SESIZE
; break;
882 case HDL_POLY
: ePtr
=POINTER_MOVEPOINT
; break;
883 case HDL_CIRC
: ePtr
=POINTER_HAND
; break;
884 case HDL_REF1
: ePtr
=POINTER_REFHAND
; break;
885 case HDL_REF2
: ePtr
=POINTER_REFHAND
; break;
886 case HDL_BWGT
: ePtr
=POINTER_MOVEBEZIERWEIGHT
; break;
887 case HDL_GLUE
: ePtr
=POINTER_MOVEPOINT
; break;
888 case HDL_CUSTOMSHAPE1
: ePtr
=POINTER_HAND
; break;
894 return Pointer(ePtr
);
898 BOOL
SdrHdl::IsFocusHdl() const
902 case HDL_UPLFT
: // Oben links
903 case HDL_UPPER
: // Oben
904 case HDL_UPRGT
: // Oben rechts
905 case HDL_LEFT
: // Links
906 case HDL_RIGHT
: // Rechts
907 case HDL_LWLFT
: // Unten links
908 case HDL_LOWER
: // Unten
909 case HDL_LWRGT
: // Unten rechts
911 // if it's a activated TextEdit, it's moved to extended points
912 if(pHdlList
&& pHdlList
->IsMoveOutside())
918 case HDL_MOVE
: // Handle zum Verschieben des Objekts
919 case HDL_POLY
: // Punktselektion an Polygon oder Bezierkurve
920 case HDL_BWGT
: // Gewicht an einer Bezierkurve
921 case HDL_CIRC
: // Winkel an Kreissegmenten, Eckenradius am Rect
922 case HDL_REF1
: // Referenzpunkt 1, z.B. Rotationsmitte
923 case HDL_REF2
: // Referenzpunkt 2, z.B. Endpunkt der Spiegelachse
924 //case HDL_MIRX: // Die Spiegelachse selbst
925 case HDL_GLUE
: // GluePoint
927 // #98388# do NOT activate here, let SW implement their own SdrHdl and
928 // overload IsFocusHdl() there to make the anchor accessible
929 //case HDL_ANCHOR: // anchor symbol (SD, SW)
930 // #101688# same for AnchorTR
931 //case HDL_ANCHOR_TR: // anchor symbol (SD, SW)
933 //case HDL_TRNS: // interactive transparence
934 //case HDL_GRAD: // interactive gradient
935 //case HDL_COLR: // interactive color
937 // for SJ and the CustomShapeHandles:
938 case HDL_CUSTOMSHAPE1
:
952 ////////////////////////////////////////////////////////////////////////////////////////////////////
955 SdrHdlColor::SdrHdlColor(const Point
& rRef
, Color aCol
, const Size
& rSize
, BOOL bLum
)
956 : SdrHdl(rRef
, HDL_COLR
),
961 aCol
= GetLuminance(aCol
);
967 SdrHdlColor::~SdrHdlColor()
971 void SdrHdlColor::CreateB2dIAObject()
973 // first throw away old one
978 SdrMarkView
* pView
= pHdlList
->GetView();
980 if(pView
&& !pView
->areMarkHandlesHidden())
982 SdrPageView
* pPageView
= pView
->GetSdrPageView();
986 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
988 // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
989 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
991 if(rPageWindow
.GetPaintWindow().OutputToWindow())
993 if(rPageWindow
.GetOverlayManager())
995 Bitmap
aBmpCol(CreateColorDropper(aMarkerColor
));
996 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
997 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
998 ::sdr::overlay::OverlayBitmapEx(
1001 (UINT16
)(aBmpCol
.GetSizePixel().Width() - 1) >> 1,
1002 (UINT16
)(aBmpCol
.GetSizePixel().Height() - 1) >> 1
1004 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1007 if(pNewOverlayObject
)
1009 rPageWindow
.GetOverlayManager()->add(*pNewOverlayObject
);
1010 maOverlayGroup
.append(*pNewOverlayObject
);
1020 Bitmap
SdrHdlColor::CreateColorDropper(Color aCol
)
1023 Bitmap
aRetval(aMarkerSize
, 24);
1024 aRetval
.Erase(aCol
);
1027 BitmapWriteAccess
* pWrite
= aRetval
.AcquireWriteAccess();
1028 DBG_ASSERT(pWrite
, "Got NO write access to a new Bitmap !!!");
1032 // draw outer border
1033 INT32 nWidth
= aMarkerSize
.Width();
1034 INT32 nHeight
= aMarkerSize
.Height();
1036 pWrite
->SetLineColor(Color(COL_LIGHTGRAY
));
1037 pWrite
->DrawLine(Point(0, 0), Point(0, nHeight
- 1));
1038 pWrite
->DrawLine(Point(1, 0), Point(nWidth
- 1, 0));
1039 pWrite
->SetLineColor(Color(COL_GRAY
));
1040 pWrite
->DrawLine(Point(1, nHeight
- 1), Point(nWidth
- 1, nHeight
- 1));
1041 pWrite
->DrawLine(Point(nWidth
- 1, 1), Point(nWidth
- 1, nHeight
- 2));
1043 // draw lighter UpperLeft
1044 const Color
aLightColor(
1045 (sal_uInt8
)(::std::min((sal_Int16
)((sal_Int16
)aCol
.GetRed() + (sal_Int16
)0x0040), (sal_Int16
)0x00ff)),
1046 (sal_uInt8
)(::std::min((sal_Int16
)((sal_Int16
)aCol
.GetGreen() + (sal_Int16
)0x0040), (sal_Int16
)0x00ff)),
1047 (sal_uInt8
)(::std::min((sal_Int16
)((sal_Int16
)aCol
.GetBlue() + (sal_Int16
)0x0040), (sal_Int16
)0x00ff)));
1048 pWrite
->SetLineColor(aLightColor
);
1049 pWrite
->DrawLine(Point(1, 1), Point(1, nHeight
- 2));
1050 pWrite
->DrawLine(Point(2, 1), Point(nWidth
- 2, 1));
1052 // draw darker LowerRight
1053 const Color
aDarkColor(
1054 (sal_uInt8
)(::std::max((sal_Int16
)((sal_Int16
)aCol
.GetRed() - (sal_Int16
)0x0040), (sal_Int16
)0x0000)),
1055 (sal_uInt8
)(::std::max((sal_Int16
)((sal_Int16
)aCol
.GetGreen() - (sal_Int16
)0x0040), (sal_Int16
)0x0000)),
1056 (sal_uInt8
)(::std::max((sal_Int16
)((sal_Int16
)aCol
.GetBlue() - (sal_Int16
)0x0040), (sal_Int16
)0x0000)));
1057 pWrite
->SetLineColor(aDarkColor
);
1058 pWrite
->DrawLine(Point(2, nHeight
- 2), Point(nWidth
- 2, nHeight
- 2));
1059 pWrite
->DrawLine(Point(nWidth
- 2, 2), Point(nWidth
- 2, nHeight
- 3));
1061 // get rid of write access
1068 Color
SdrHdlColor::GetLuminance(const Color
& rCol
)
1070 UINT8 aLum
= rCol
.GetLuminance();
1071 Color
aRetval(aLum
, aLum
, aLum
);
1075 void SdrHdlColor::CallColorChangeLink()
1077 aColorChangeHdl
.Call(this);
1080 void SdrHdlColor::SetColor(Color aNew
, BOOL bCallLink
)
1082 if(IsUseLuminance())
1083 aNew
= GetLuminance(aNew
);
1085 if(aMarkerColor
!= aNew
)
1087 // remember new color
1088 aMarkerColor
= aNew
;
1090 // create new display
1093 // tell about change
1095 CallColorChangeLink();
1099 void SdrHdlColor::SetSize(const Size
& rNew
)
1101 if(rNew
!= aMarkerSize
)
1103 // remember new size
1106 // create new display
1111 ////////////////////////////////////////////////////////////////////////////////////////////////////
1112 // class SdrHdlGradient
1114 SdrHdlGradient::SdrHdlGradient(const Point
& rRef1
, const Point
& rRef2
, BOOL bGrad
)
1115 : SdrHdl(rRef1
, bGrad
? HDL_GRAD
: HDL_TRNS
),
1123 SdrHdlGradient::~SdrHdlGradient()
1127 void SdrHdlGradient::Set2ndPos(const Point
& rPnt
)
1131 // remember new position
1134 // create new display
1139 void SdrHdlGradient::CreateB2dIAObject()
1141 // first throw away old one
1146 SdrMarkView
* pView
= pHdlList
->GetView();
1148 if(pView
&& !pView
->areMarkHandlesHidden())
1150 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1154 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1156 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1158 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1160 if(rPageWindow
.GetOverlayManager())
1162 // striped line in between
1163 basegfx::B2DVector
aVec(a2ndPos
.X() - aPos
.X(), a2ndPos
.Y() - aPos
.Y());
1164 double fVecLen
= aVec
.getLength();
1165 double fLongPercentArrow
= (1.0 - 0.05) * fVecLen
;
1166 double fHalfArrowWidth
= (0.05 * 0.5) * fVecLen
;
1168 basegfx::B2DVector
aPerpend(-aVec
.getY(), aVec
.getX());
1169 INT32 nMidX
= (INT32
)(aPos
.X() + aVec
.getX() * fLongPercentArrow
);
1170 INT32 nMidY
= (INT32
)(aPos
.Y() + aVec
.getY() * fLongPercentArrow
);
1171 Point
aMidPoint(nMidX
, nMidY
);
1173 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
1174 basegfx::B2DPoint
aMidPos(aMidPoint
.X(), aMidPoint
.Y());
1176 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
1177 ::sdr::overlay::OverlayLineStriped(
1180 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1182 pNewOverlayObject
->setBaseColor(IsGradient() ? Color(COL_BLACK
) : Color(COL_BLUE
));
1183 rPageWindow
.GetOverlayManager()->add(*pNewOverlayObject
);
1184 maOverlayGroup
.append(*pNewOverlayObject
);
1187 Point
aLeft(aMidPoint
.X() + (INT32
)(aPerpend
.getX() * fHalfArrowWidth
),
1188 aMidPoint
.Y() + (INT32
)(aPerpend
.getY() * fHalfArrowWidth
));
1189 Point
aRight(aMidPoint
.X() - (INT32
)(aPerpend
.getX() * fHalfArrowWidth
),
1190 aMidPoint
.Y() - (INT32
)(aPerpend
.getY() * fHalfArrowWidth
));
1192 basegfx::B2DPoint
aPositionLeft(aLeft
.X(), aLeft
.Y());
1193 basegfx::B2DPoint
aPositionRight(aRight
.X(), aRight
.Y());
1194 basegfx::B2DPoint
aPosition2(a2ndPos
.X(), a2ndPos
.Y());
1196 pNewOverlayObject
= new
1197 ::sdr::overlay::OverlayTriangle(
1201 IsGradient() ? Color(COL_BLACK
) : Color(COL_BLUE
)
1203 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1205 rPageWindow
.GetOverlayManager()->add(*pNewOverlayObject
);
1206 maOverlayGroup
.append(*pNewOverlayObject
);
1215 IMPL_LINK(SdrHdlGradient
, ColorChangeHdl
, SdrHdl
*, /*pHdl*/)
1218 FromIAOToItem(GetObj(), TRUE
, TRUE
);
1222 void SdrHdlGradient::FromIAOToItem(SdrObject
* _pObj
, BOOL bSetItemOnObject
, BOOL bUndo
)
1224 // from IAO positions and colors to gradient
1225 const SfxItemSet
& rSet
= _pObj
->GetMergedItemSet();
1227 GradTransformer aGradTransformer
;
1228 GradTransGradient aOldGradTransGradient
;
1229 GradTransGradient aGradTransGradient
;
1230 GradTransVector aGradTransVector
;
1234 aGradTransVector
.maPositionA
= basegfx::B2DPoint(GetPos().X(), GetPos().Y());
1235 aGradTransVector
.maPositionB
= basegfx::B2DPoint(Get2ndPos().X(), Get2ndPos().Y());
1237 aGradTransVector
.aCol1
= pColHdl1
->GetColor();
1239 aGradTransVector
.aCol2
= pColHdl2
->GetColor();
1242 aOldGradTransGradient
.aGradient
= ((XFillGradientItem
&)rSet
.Get(XATTR_FILLGRADIENT
)).GetGradientValue();
1244 aOldGradTransGradient
.aGradient
= ((XFillFloatTransparenceItem
&)rSet
.Get(XATTR_FILLFLOATTRANSPARENCE
)).GetGradientValue();
1246 // transform vector data to gradient
1247 aGradTransformer
.VecToGrad(aGradTransVector
, aGradTransGradient
, aOldGradTransGradient
, _pObj
, bMoveSingleHandle
, bMoveFirstHandle
);
1249 if(bSetItemOnObject
)
1251 SdrModel
* pModel
= _pObj
->GetModel();
1252 SfxItemSet
aNewSet(pModel
->GetItemPool());
1257 XFillGradientItem
aNewGradItem(aString
, aGradTransGradient
.aGradient
);
1258 aNewSet
.Put(aNewGradItem
);
1263 XFillFloatTransparenceItem
aNewTransItem(aString
, aGradTransGradient
.aGradient
);
1264 aNewSet
.Put(aNewTransItem
);
1267 if(bUndo
&& pModel
->IsUndoEnabled())
1269 pModel
->BegUndo(SVX_RESSTR(IsGradient() ? SIP_XA_FILLGRADIENT
: SIP_XA_FILLTRANSPARENCE
));
1270 pModel
->AddUndo(pModel
->GetSdrUndoFactory().CreateUndoAttrObject(*_pObj
));
1274 pObj
->SetMergedItemSetAndBroadcast(aNewSet
);
1277 // back transformation, set values on pIAOHandle
1278 aGradTransformer
.GradToVec(aGradTransGradient
, aGradTransVector
, _pObj
);
1280 SetPos(Point(FRound(aGradTransVector
.maPositionA
.getX()), FRound(aGradTransVector
.maPositionA
.getY())));
1281 Set2ndPos(Point(FRound(aGradTransVector
.maPositionB
.getX()), FRound(aGradTransVector
.maPositionB
.getY())));
1284 pColHdl1
->SetPos(Point(FRound(aGradTransVector
.maPositionA
.getX()), FRound(aGradTransVector
.maPositionA
.getY())));
1285 pColHdl1
->SetColor(aGradTransVector
.aCol1
);
1289 pColHdl2
->SetPos(Point(FRound(aGradTransVector
.maPositionB
.getX()), FRound(aGradTransVector
.maPositionB
.getY())));
1290 pColHdl2
->SetColor(aGradTransVector
.aCol2
);
1294 ////////////////////////////////////////////////////////////////////////////////////////////////////
1296 SdrHdlLine::~SdrHdlLine() {}
1298 void SdrHdlLine::CreateB2dIAObject()
1300 // first throw away old one
1305 SdrMarkView
* pView
= pHdlList
->GetView();
1307 if(pView
&& !pView
->areMarkHandlesHidden() && pHdl1
&& pHdl2
)
1309 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1313 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1315 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1317 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1319 if(rPageWindow
.GetOverlayManager())
1321 basegfx::B2DPoint
aPosition1(pHdl1
->GetPos().X(), pHdl1
->GetPos().Y());
1322 basegfx::B2DPoint
aPosition2(pHdl2
->GetPos().X(), pHdl2
->GetPos().Y());
1324 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
1325 ::sdr::overlay::OverlayLineStriped(
1329 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1332 if(pNewOverlayObject
)
1335 pNewOverlayObject
->setBaseColor(Color(COL_LIGHTRED
));
1337 rPageWindow
.GetOverlayManager()->add(*pNewOverlayObject
);
1338 maOverlayGroup
.append(*pNewOverlayObject
);
1348 Pointer
SdrHdlLine::GetPointer() const
1350 return Pointer(POINTER_REFHAND
);
1353 ////////////////////////////////////////////////////////////////////////////////////////////////////
1355 SdrHdlBezWgt::~SdrHdlBezWgt() {}
1357 void SdrHdlBezWgt::CreateB2dIAObject()
1360 SdrHdl::CreateB2dIAObject();
1365 SdrMarkView
* pView
= pHdlList
->GetView();
1367 if(pView
&& !pView
->areMarkHandlesHidden())
1369 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1373 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1375 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1377 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1379 if(rPageWindow
.GetOverlayManager())
1381 basegfx::B2DPoint
aPosition1(pHdl1
->GetPos().X(), pHdl1
->GetPos().Y());
1382 basegfx::B2DPoint
aPosition2(aPos
.X(), aPos
.Y());
1384 if(!aPosition1
.equal(aPosition2
))
1386 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
1387 ::sdr::overlay::OverlayLineStriped(
1391 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1394 if(pNewOverlayObject
)
1396 // line part is not hittable
1397 pNewOverlayObject
->setHittable(sal_False
);
1400 pNewOverlayObject
->setBaseColor(Color(COL_LIGHTBLUE
));
1402 rPageWindow
.GetOverlayManager()->add(*pNewOverlayObject
);
1403 maOverlayGroup
.append(*pNewOverlayObject
);
1414 ////////////////////////////////////////////////////////////////////////////////////////////////////
1416 E3dVolumeMarker::E3dVolumeMarker(const basegfx::B2DPolyPolygon
& rWireframePoly
)
1418 aWireframePoly
= rWireframePoly
;
1421 void E3dVolumeMarker::CreateB2dIAObject()
1426 SdrMarkView
* pView
= pHdlList
->GetView();
1428 if(pView
&& !pView
->areMarkHandlesHidden())
1430 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1434 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1436 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1438 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1440 if(rPageWindow
.GetOverlayManager() && aWireframePoly
.count())
1442 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
1443 ::sdr::overlay::OverlayPolyPolygonStriped(aWireframePoly
);
1444 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1447 if(pNewOverlayObject
)
1449 pNewOverlayObject
->setBaseColor(Color(COL_BLACK
));
1451 rPageWindow
.GetOverlayManager()->add(*pNewOverlayObject
);
1452 maOverlayGroup
.append(*pNewOverlayObject
);
1462 ////////////////////////////////////////////////////////////////////////////////////////////////////
1464 ImpEdgeHdl::~ImpEdgeHdl()
1468 void ImpEdgeHdl::CreateB2dIAObject()
1470 if(nObjHdlNum
<= 1 && pObj
)
1472 // first throw away old one
1475 BitmapColorIndex eColIndex
= LightCyan
;
1476 BitmapMarkerKind eKindOfMarker
= Rect_7x7
;
1480 SdrMarkView
* pView
= pHdlList
->GetView();
1482 if(pView
&& !pView
->areMarkHandlesHidden())
1484 const SdrEdgeObj
* pEdge
= (SdrEdgeObj
*)pObj
;
1486 if(pEdge
->GetConnectedNode(nObjHdlNum
== 0) != NULL
)
1487 eColIndex
= LightRed
;
1491 // Handle with plus sign inside
1492 eKindOfMarker
= Circ_7x7
;
1495 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1499 for(sal_uInt32
b(0); b
< pPageView
->PageWindowCount(); b
++)
1501 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1503 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1505 if(rPageWindow
.GetOverlayManager())
1507 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
1509 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= CreateOverlayObject(
1515 if(pNewOverlayObject
)
1517 rPageWindow
.GetOverlayManager()->add(*pNewOverlayObject
);
1518 maOverlayGroup
.append(*pNewOverlayObject
);
1530 SdrHdl::CreateB2dIAObject();
1534 void ImpEdgeHdl::SetLineCode(SdrEdgeLineCode eCode
)
1536 if(eLineCode
!= eCode
)
1538 // remember new value
1541 // create new display
1546 Pointer
ImpEdgeHdl::GetPointer() const
1548 SdrEdgeObj
* pEdge
=PTR_CAST(SdrEdgeObj
,pObj
);
1550 return SdrHdl::GetPointer();
1552 return Pointer(POINTER_MOVEPOINT
); //Pointer(POINTER_DRAW_CONNECT);
1554 return Pointer(POINTER_ESIZE
);
1556 return Pointer(POINTER_SSIZE
);
1559 BOOL
ImpEdgeHdl::IsHorzDrag() const
1561 SdrEdgeObj
* pEdge
=PTR_CAST(SdrEdgeObj
,pObj
);
1567 SdrEdgeKind eEdgeKind
= ((SdrEdgeKindItem
&)(pEdge
->GetObjectItem(SDRATTR_EDGEKIND
))).GetValue();
1569 const SdrEdgeInfoRec
& rInfo
=pEdge
->aEdgeInfo
;
1570 if (eEdgeKind
==SDREDGE_ORTHOLINES
|| eEdgeKind
==SDREDGE_BEZIER
)
1572 return !rInfo
.ImpIsHorzLine(eLineCode
,*pEdge
->pEdgeTrack
);
1574 else if (eEdgeKind
==SDREDGE_THREELINES
)
1576 long nWink
=nObjHdlNum
==2 ? rInfo
.nAngle1
: rInfo
.nAngle2
;
1577 if (nWink
==0 || nWink
==18000)
1585 ////////////////////////////////////////////////////////////////////////////////////////////////////
1587 ImpMeasureHdl::~ImpMeasureHdl()
1591 void ImpMeasureHdl::CreateB2dIAObject()
1593 // first throw away old one
1598 SdrMarkView
* pView
= pHdlList
->GetView();
1600 if(pView
&& !pView
->areMarkHandlesHidden())
1602 BitmapColorIndex eColIndex
= LightCyan
;
1603 BitmapMarkerKind eKindOfMarker
= Rect_9x9
;
1607 eKindOfMarker
= Rect_7x7
;
1615 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1619 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1621 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1623 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1625 if(rPageWindow
.GetOverlayManager())
1627 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
1629 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= CreateOverlayObject(
1635 if(pNewOverlayObject
)
1637 rPageWindow
.GetOverlayManager()->add(*pNewOverlayObject
);
1638 maOverlayGroup
.append(*pNewOverlayObject
);
1648 Pointer
ImpMeasureHdl::GetPointer() const
1652 case 0: case 1: return Pointer(POINTER_HAND
);
1653 case 2: case 3: return Pointer(POINTER_MOVEPOINT
);
1654 case 4: case 5: return SdrHdl::GetPointer(); // wird dann entsprechend gedreht
1656 return Pointer(POINTER_NOTALLOWED
);
1659 ////////////////////////////////////////////////////////////////////////////////////////////////////
1661 ImpTextframeHdl::ImpTextframeHdl(const Rectangle
& rRect
) :
1662 SdrHdl(rRect
.TopLeft(),HDL_MOVE
),
1667 void ImpTextframeHdl::CreateB2dIAObject()
1669 // first throw away old one
1674 SdrMarkView
* pView
= pHdlList
->GetView();
1676 if(pView
&& !pView
->areMarkHandlesHidden())
1678 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1682 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1684 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1686 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1688 if(rPageWindow
.GetOverlayManager())
1690 const basegfx::B2DPoint
aTopLeft(maRect
.Left(), maRect
.Top());
1691 const basegfx::B2DPoint
aBottomRight(maRect
.Right(), maRect
.Bottom());
1692 const svtools::ColorConfig aColorConfig
;
1693 const Color
aHatchCol( aColorConfig
.GetColorValue( svtools::FONTCOLOR
).nColor
);
1695 ::sdr::overlay::OverlayHatchRect
* pNewOverlayObject
= new ::sdr::overlay::OverlayHatchRect(
1702 nDrehWink
* -F_PI18000
);
1703 pNewOverlayObject
->setHittable(false);
1706 if(pNewOverlayObject
)
1708 rPageWindow
.GetOverlayManager()->add(*pNewOverlayObject
);
1709 maOverlayGroup
.append(*pNewOverlayObject
);
1719 ////////////////////////////////////////////////////////////////////////////////////////////////////
1721 class ImpSdrHdlListSorter
: public ContainerSorter
{
1723 ImpSdrHdlListSorter(Container
& rNewCont
): ContainerSorter(rNewCont
) {}
1724 virtual int Compare(const void* pElem1
, const void* pElem2
) const;
1727 int ImpSdrHdlListSorter::Compare(const void* pElem1
, const void* pElem2
) const
1729 SdrHdlKind eKind1
=((SdrHdl
*)pElem1
)->GetKind();
1730 SdrHdlKind eKind2
=((SdrHdl
*)pElem2
)->GetKind();
1731 // Level 1: Erst normale Handles, dann Glue, dann User, dann Plushandles, dann Retpunkt-Handles
1736 if (eKind1
==HDL_REF1
|| eKind1
==HDL_REF2
|| eKind1
==HDL_MIRX
) n1
=5;
1737 else if (eKind1
==HDL_GLUE
) n1
=2;
1738 else if (eKind1
==HDL_USER
) n1
=3;
1739 else if (eKind1
==HDL_SMARTTAG
) n1
=0;
1740 if (eKind2
==HDL_REF1
|| eKind2
==HDL_REF2
|| eKind2
==HDL_MIRX
) n2
=5;
1741 else if (eKind2
==HDL_GLUE
) n2
=2;
1742 else if (eKind2
==HDL_USER
) n2
=3;
1743 else if (eKind2
==HDL_SMARTTAG
) n2
=0;
1745 if (((SdrHdl
*)pElem1
)->IsPlusHdl()) n1
=4;
1746 if (((SdrHdl
*)pElem2
)->IsPlusHdl()) n2
=4;
1749 // Level 2: PageView (Pointer)
1750 SdrPageView
* pPV1
=((SdrHdl
*)pElem1
)->GetPageView();
1751 SdrPageView
* pPV2
=((SdrHdl
*)pElem2
)->GetPageView();
1754 // Level 3: Position (x+y)
1755 SdrObject
* pObj1
=((SdrHdl
*)pElem1
)->GetObj();
1756 SdrObject
* pObj2
=((SdrHdl
*)pElem2
)->GetObj();
1759 sal_uInt32 nNum1
=((SdrHdl
*)pElem1
)->GetObjHdlNum();
1760 sal_uInt32 nNum2
=((SdrHdl
*)pElem2
)->GetObjHdlNum();
1764 return (long)pElem1
<(long)pElem2
? -1 : 1; // Notloesung, um immer die gleiche Sortierung zu haben
1765 return (USHORT
)eKind1
<(USHORT
)eKind2
? -1 : 1;
1768 return nNum1
<nNum2
? -1 : 1;
1772 return (long)pObj1
<(long)pObj2
? -1 : 1;
1777 return (long)pPV1
<(long)pPV2
? -1 : 1;
1782 return n1
<n2
? -1 : 1;
1786 SdrMarkView
* SdrHdlList::GetView() const
1791 // #105678# Help struct for re-sorting handles
1792 struct ImplHdlAndIndex
1798 // #105678# Help method for sorting handles taking care of OrdNums, keeping order in
1799 // single objects and re-sorting polygon handles intuitively
1800 extern "C" int __LOADONCALLAPI
ImplSortHdlFunc( const void* pVoid1
, const void* pVoid2
)
1802 const ImplHdlAndIndex
* p1
= (ImplHdlAndIndex
*)pVoid1
;
1803 const ImplHdlAndIndex
* p2
= (ImplHdlAndIndex
*)pVoid2
;
1805 if(p1
->mpHdl
->GetObj() == p2
->mpHdl
->GetObj())
1807 if(p1
->mpHdl
->GetObj() && p1
->mpHdl
->GetObj()->ISA(SdrPathObj
))
1809 // same object and a path object
1810 if((p1
->mpHdl
->GetKind() == HDL_POLY
|| p1
->mpHdl
->GetKind() == HDL_BWGT
)
1811 && (p2
->mpHdl
->GetKind() == HDL_POLY
|| p2
->mpHdl
->GetKind() == HDL_BWGT
))
1813 // both handles are point or control handles
1814 if(p1
->mpHdl
->GetPolyNum() == p2
->mpHdl
->GetPolyNum())
1816 if(p1
->mpHdl
->GetPointNum() < p2
->mpHdl
->GetPointNum())
1825 else if(p1
->mpHdl
->GetPolyNum() < p2
->mpHdl
->GetPolyNum())
1838 if(!p1
->mpHdl
->GetObj())
1842 else if(!p2
->mpHdl
->GetObj())
1848 // different objects, use OrdNum for sort
1849 const sal_uInt32 nOrdNum1
= p1
->mpHdl
->GetObj()->GetOrdNum();
1850 const sal_uInt32 nOrdNum2
= p2
->mpHdl
->GetObj()->GetOrdNum();
1852 if(nOrdNum1
< nOrdNum2
)
1863 // fallback to indices
1864 if(p1
->mnIndex
< p2
->mnIndex
)
1874 ////////////////////////////////////////////////////////////////////////////////////////////////////
1877 void SdrHdlList::TravelFocusHdl(sal_Bool bForward
)
1879 // security correction
1880 if(mnFocusIndex
!= CONTAINER_ENTRY_NOTFOUND
&& mnFocusIndex
>= GetHdlCount())
1881 mnFocusIndex
= CONTAINER_ENTRY_NOTFOUND
;
1885 // take care of old handle
1886 const ULONG
nOldHdlNum(mnFocusIndex
);
1887 SdrHdl
* pOld
= GetHdl(nOldHdlNum
);
1888 //SDOsal_Bool bRefresh(sal_False);
1892 // switch off old handle
1893 mnFocusIndex
= CONTAINER_ENTRY_NOTFOUND
;
1895 //SDObRefresh = sal_True;
1898 // #105678# Alloc pointer array for sorted handle list
1899 ImplHdlAndIndex
* pHdlAndIndex
= new ImplHdlAndIndex
[aList
.Count()];
1901 // #105678# build sorted handle list
1903 for( a
= 0; a
< aList
.Count(); a
++)
1905 pHdlAndIndex
[a
].mpHdl
= (SdrHdl
*)aList
.GetObject(a
);
1906 pHdlAndIndex
[a
].mnIndex
= a
;
1909 // #105678# qsort all entries
1910 qsort(pHdlAndIndex
, aList
.Count(), sizeof(ImplHdlAndIndex
), ImplSortHdlFunc
);
1912 // #105678# look for old num in sorted array
1913 ULONG
nOldHdl(nOldHdlNum
);
1915 if(nOldHdlNum
!= CONTAINER_ENTRY_NOTFOUND
)
1917 for(a
= 0; a
< aList
.Count(); a
++)
1919 if(pHdlAndIndex
[a
].mpHdl
== pOld
)
1927 // #105678# build new HdlNum
1928 ULONG
nNewHdl(nOldHdl
);
1930 // #105678# do the focus travel
1933 if(nOldHdl
!= CONTAINER_ENTRY_NOTFOUND
)
1935 if(nOldHdl
== aList
.Count() - 1)
1938 nNewHdl
= CONTAINER_ENTRY_NOTFOUND
;
1942 // simply the next handle
1948 // start forward run at first entry
1954 if(nOldHdl
== CONTAINER_ENTRY_NOTFOUND
)
1956 // start backward run at last entry
1957 nNewHdl
= aList
.Count() - 1;
1965 nNewHdl
= CONTAINER_ENTRY_NOTFOUND
;
1969 // simply the previous handle
1975 // #105678# build new HdlNum
1976 sal_uInt32
nNewHdlNum(nNewHdl
);
1978 // look for old num in sorted array
1979 if(nNewHdl
!= CONTAINER_ENTRY_NOTFOUND
)
1981 SdrHdl
* pNew
= pHdlAndIndex
[nNewHdl
].mpHdl
;
1983 for(a
= 0; a
< aList
.Count(); a
++)
1985 if((SdrHdl
*)aList
.GetObject(a
) == pNew
)
1993 // take care of next handle
1994 if(nOldHdlNum
!= nNewHdlNum
)
1996 mnFocusIndex
= nNewHdlNum
;
1997 SdrHdl
* pNew
= GetHdl(mnFocusIndex
);
2002 //SDObRefresh = sal_True;
2006 // #105678# free mem again
2007 delete pHdlAndIndex
;
2011 SdrHdl
* SdrHdlList::GetFocusHdl() const
2013 if(mnFocusIndex
!= CONTAINER_ENTRY_NOTFOUND
&& mnFocusIndex
< GetHdlCount())
2014 return GetHdl(mnFocusIndex
);
2019 void SdrHdlList::SetFocusHdl(SdrHdl
* pNew
)
2023 SdrHdl
* pActual
= GetFocusHdl();
2025 if(!pActual
|| pActual
!= pNew
)
2027 ULONG nNewHdlNum
= GetHdlNum(pNew
);
2029 if(nNewHdlNum
!= CONTAINER_ENTRY_NOTFOUND
)
2031 //SDOsal_Bool bRefresh(sal_False);
2032 mnFocusIndex
= nNewHdlNum
;
2037 //SDObRefresh = sal_True;
2043 //SDObRefresh = sal_True;
2049 //OLM pView->RefreshAllIAOManagers();
2056 void SdrHdlList::ResetFocusHdl()
2058 SdrHdl
* pHdl
= GetFocusHdl();
2060 mnFocusIndex
= CONTAINER_ENTRY_NOTFOUND
;
2068 ////////////////////////////////////////////////////////////////////////////////////////////////////
2070 SdrHdlList::SdrHdlList(SdrMarkView
* pV
)
2071 : mnFocusIndex(CONTAINER_ENTRY_NOTFOUND
),
2076 bRotateShear
= FALSE
;
2077 bMoveOutside
= FALSE
;
2078 bDistortShear
= FALSE
;
2079 bFineHandles
= FALSE
;
2082 SdrHdlList::~SdrHdlList()
2087 void SdrHdlList::SetHdlSize(USHORT nSiz
)
2089 if(nHdlSize
!= nSiz
)
2091 // remember new value
2094 // propagate change to IAOs
2095 for(UINT32 i
=0; i
<GetHdlCount(); i
++)
2097 SdrHdl
* pHdl
= GetHdl(i
);
2103 void SdrHdlList::SetMoveOutside(BOOL bOn
)
2105 if(bMoveOutside
!= bOn
)
2107 // remember new value
2110 // propagate change to IAOs
2111 for(UINT32 i
=0; i
<GetHdlCount(); i
++)
2113 SdrHdl
* pHdl
= GetHdl(i
);
2119 void SdrHdlList::SetRotateShear(BOOL bOn
)
2124 void SdrHdlList::SetDistortShear(BOOL bOn
)
2126 bDistortShear
= bOn
;
2129 void SdrHdlList::SetFineHdl(BOOL bOn
)
2131 if(bFineHandles
!= bOn
)
2133 // remember new state
2136 // propagate change to IAOs
2137 for(UINT32 i
=0; i
<GetHdlCount(); i
++)
2139 SdrHdl
* pHdl
= GetHdl(i
);
2145 SdrHdl
* SdrHdlList::RemoveHdl(ULONG nNum
)
2147 SdrHdl
* pRetval
= (SdrHdl
*)aList
.Remove(nNum
);
2152 void SdrHdlList::Clear()
2154 for (ULONG i
=0; i
<GetHdlCount(); i
++)
2156 SdrHdl
* pHdl
=GetHdl(i
);
2162 bDistortShear
=FALSE
;
2165 void SdrHdlList::Sort()
2167 // #97016# II: remember current focused handle
2168 SdrHdl
* pPrev
= GetFocusHdl();
2170 ImpSdrHdlListSorter
aSort(aList
);
2173 // #97016# II: get now and compare
2174 SdrHdl
* pNow
= GetFocusHdl();
2178 //SDOsal_Bool bRefresh(sal_False);
2183 //SDObRefresh = sal_True;
2189 //SDObRefresh = sal_True;
2194 ULONG
SdrHdlList::GetHdlNum(const SdrHdl
* pHdl
) const
2197 return CONTAINER_ENTRY_NOTFOUND
;
2198 ULONG nPos
=aList
.GetPos(pHdl
);
2202 void SdrHdlList::AddHdl(SdrHdl
* pHdl
, BOOL bAtBegin
)
2208 aList
.Insert(pHdl
,ULONG(0));
2212 aList
.Insert(pHdl
,CONTAINER_APPEND
);
2214 pHdl
->SetHdlList(this);
2218 SdrHdl
* SdrHdlList::IsHdlListHit(const Point
& rPnt
, BOOL bBack
, BOOL bNext
, SdrHdl
* pHdl0
) const
2221 ULONG nAnz
=GetHdlCount();
2222 ULONG nNum
=bBack
? 0 : nAnz
;
2223 while ((bBack
? nNum
<nAnz
: nNum
>0) && pRet
==NULL
)
2227 SdrHdl
* pHdl
=GetHdl(nNum
);
2235 if (pHdl
->IsHdlHit(rPnt
))
2244 SdrHdl
* SdrHdlList::GetHdl(SdrHdlKind eKind1
) const
2247 for (ULONG i
=0; i
<GetHdlCount() && pRet
==NULL
; i
++)
2249 SdrHdl
* pHdl
=GetHdl(i
);
2250 if (pHdl
->GetKind()==eKind1
)
2256 // --------------------------------------------------------------------
2258 // --------------------------------------------------------------------
2260 SdrCropHdl::SdrCropHdl(const Point
& rPnt
, SdrHdlKind eNewKind
)
2261 : SdrHdl( rPnt
, eNewKind
)
2265 // --------------------------------------------------------------------
2267 BitmapEx
SdrCropHdl::GetHandlesBitmap( bool bIsFineHdl
, bool bIsHighContrast
)
2269 if( bIsHighContrast
)
2271 static BitmapEx
* pHighContrastBitmap
= 0;
2272 if( pHighContrastBitmap
== 0 )
2273 pHighContrastBitmap
= new BitmapEx(ResId(SIP_SA_ACCESSIBILITY_CROP_MARKERS
, *ImpGetResMgr()));
2274 return *pHighContrastBitmap
;
2276 else if( bIsFineHdl
)
2278 static BitmapEx
* pModernBitmap
= 0;
2279 if( pModernBitmap
== 0 )
2280 pModernBitmap
= new BitmapEx(ResId(SIP_SA_CROP_FINE_MARKERS
, *ImpGetResMgr()));
2281 return *pModernBitmap
;
2285 static BitmapEx
* pSimpleBitmap
= 0;
2286 if( pSimpleBitmap
== 0 )
2287 pSimpleBitmap
= new BitmapEx(ResId(SIP_SA_CROP_MARKERS
, *ImpGetResMgr()));
2288 return *pSimpleBitmap
;
2292 // --------------------------------------------------------------------
2294 BitmapEx
SdrCropHdl::GetBitmapForHandle( const BitmapEx
& rBitmap
, int nSize
)
2296 int nPixelSize
= 0, nX
= 0, nY
= 0, nOffset
= 0;
2303 else if( nSize
<=4 )
2316 case HDL_UPLFT
: nX
= 0; nY
= 0; break;
2317 case HDL_UPPER
: nX
= 1; nY
= 0; break;
2318 case HDL_UPRGT
: nX
= 2; nY
= 0; break;
2319 case HDL_LEFT
: nX
= 0; nY
= 1; break;
2320 case HDL_RIGHT
: nX
= 2; nY
= 1; break;
2321 case HDL_LWLFT
: nX
= 0; nY
= 2; break;
2322 case HDL_LOWER
: nX
= 1; nY
= 2; break;
2323 case HDL_LWRGT
: nX
= 2; nY
= 2; break;
2327 Rectangle
aSourceRect( Point( nX
* (nPixelSize
-1) + nOffset
, nY
* (nPixelSize
-1)), Size(nPixelSize
, nPixelSize
) );
2329 BitmapEx
aRetval(rBitmap
);
2330 aRetval
.Crop(aSourceRect
);
2334 // --------------------------------------------------------------------
2336 void SdrCropHdl::CreateB2dIAObject()
2338 // first throw away old one
2341 SdrMarkView
* pView
= pHdlList
? pHdlList
->GetView() : 0;
2342 SdrPageView
* pPageView
= pView
? pView
->GetSdrPageView() : 0;
2344 if( pPageView
&& !pView
->areMarkHandlesHidden() )
2346 sal_Bool
bIsFineHdl(pHdlList
->IsFineHdl());
2347 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
2348 sal_Bool
bIsHighContrast(rStyleSettings
.GetHighContrastMode());
2349 int nHdlSize
= pHdlList
->GetHdlSize();
2350 if( bIsHighContrast
)
2353 const BitmapEx
aHandlesBitmap( GetHandlesBitmap( bIsFineHdl
, bIsHighContrast
) );
2354 BitmapEx
aBmpEx1( GetBitmapForHandle( aHandlesBitmap
, nHdlSize
) );
2356 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
2358 // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
2359 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
2361 if(rPageWindow
.GetPaintWindow().OutputToWindow())
2363 if(rPageWindow
.GetOverlayManager())
2365 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
2367 ::sdr::overlay::OverlayObject
* pOverlayObject
= 0L;
2369 // animate focused handles
2370 if(IsFocusHdl() && (pHdlList
->GetFocusHdl() == this))
2375 BitmapEx
aBmpEx2( GetBitmapForHandle( aHandlesBitmap
, nHdlSize
+ 1 ) );
2377 const sal_uInt32 nBlinkTime
= sal::static_int_cast
<sal_uInt32
>(rStyleSettings
.GetCursorBlinkTime());
2379 pOverlayObject
= new ::sdr::overlay::OverlayAnimatedBitmapEx(aPosition
, aBmpEx1
, aBmpEx2
, nBlinkTime
,
2380 (UINT16
)(aBmpEx1
.GetSizePixel().Width() - 1) >> 1,
2381 (UINT16
)(aBmpEx1
.GetSizePixel().Height() - 1) >> 1,
2382 (UINT16
)(aBmpEx2
.GetSizePixel().Width() - 1) >> 1,
2383 (UINT16
)(aBmpEx2
.GetSizePixel().Height() - 1) >> 1);
2387 // create centered handle as default
2388 pOverlayObject
= new ::sdr::overlay::OverlayBitmapEx(aPosition
, aBmpEx1
,
2389 (UINT16
)(aBmpEx1
.GetSizePixel().Width() - 1) >> 1,
2390 (UINT16
)(aBmpEx1
.GetSizePixel().Height() - 1) >> 1);
2396 rPageWindow
.GetOverlayManager()->add(*pOverlayObject
);
2397 maOverlayGroup
.append(*pOverlayObject
);
2405 // --------------------------------------------------------------------