1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
32 #include <svx/svdhdl.hxx>
33 #include <svx/svdpagv.hxx>
34 #include <svx/svdetc.hxx>
35 #include <svx/svdmrkv.hxx>
36 #include <vcl/window.hxx>
38 #include <vcl/virdev.hxx>
39 #include <tools/poly.hxx>
40 #include <vcl/bmpacc.hxx>
42 #include <svx/sxekitm.hxx>
43 #include "svx/svdstr.hrc"
44 #include "svx/svdglob.hxx"
46 #include <svx/svdmodel.hxx>
47 #include "gradtrns.hxx"
48 #include <svx/xflgrit.hxx>
49 #include <svx/svdundo.hxx>
50 #include <svx/dialmgr.hxx>
51 #include <svx/xflftrit.hxx>
54 #include <svx/svdopath.hxx>
55 #include <basegfx/vector/b2dvector.hxx>
56 #include <basegfx/polygon/b2dpolygon.hxx>
57 #include <svx/sdr/overlay/overlaymanager.hxx>
58 #include <svx/sdr/overlay/overlayanimatedbitmapex.hxx>
59 #include <svx/sdr/overlay/overlaybitmapex.hxx>
60 #include <svx/sdr/overlay/overlayline.hxx>
61 #include <svx/sdr/overlay/overlaytriangle.hxx>
62 #include <svx/sdr/overlay/overlayhatchrect.hxx>
63 #include <svx/sdrpagewindow.hxx>
64 #include <svx/sdrpaintwindow.hxx>
65 #include <vcl/svapp.hxx>
66 #include <svx/sdr/overlay/overlaypolypolygon.hxx>
67 #include <vcl/lazydelete.hxx>
69 ////////////////////////////////////////////////////////////////////////////////////////////////////
71 // Due to the resource problems in Win95/98 with bitmap resources I
72 // will change this handle bitmap providing class. Old version was splitting
73 // and preparing all small handle bitmaps in device bitmap format, now this will
74 // be done on the fly. Thus, there is only one big bitmap in memory. With
75 // three source bitmaps, this will be 3 system bitmap resources instead of hundreds.
76 // The price for that needs to be evaluated. Maybe we will need another change here
77 // if this is too expensive.
80 // the bitmap holding all information
81 BitmapEx maMarkersBitmap
;
83 // the cropped Bitmaps for reusage
84 ::std::vector
< BitmapEx
> maRealMarkers
;
87 BitmapEx
& impGetOrCreateTargetBitmap(sal_uInt16 nIndex
, const Rectangle
& rRectangle
);
90 SdrHdlBitmapSet(sal_uInt16 nResId
);
93 const BitmapEx
& GetBitmapEx(BitmapMarkerKind eKindOfMarker
, sal_uInt16 nInd
=0);
96 ////////////////////////////////////////////////////////////////////////////////////////////////////
97 #define KIND_COUNT (14)
98 #define INDEX_COUNT (6)
99 #define INDIVIDUAL_COUNT (4)
101 SdrHdlBitmapSet::SdrHdlBitmapSet(sal_uInt16 nResId
)
102 : maMarkersBitmap(ResId(nResId
, *ImpGetResMgr())),
103 // 14 kinds (BitmapMarkerKind) use index [0..5], 4 extra
104 maRealMarkers((KIND_COUNT
* INDEX_COUNT
) + INDIVIDUAL_COUNT
)
108 SdrHdlBitmapSet::~SdrHdlBitmapSet()
112 BitmapEx
& SdrHdlBitmapSet::impGetOrCreateTargetBitmap(sal_uInt16 nIndex
, const Rectangle
& rRectangle
)
114 BitmapEx
& rTargetBitmap
= maRealMarkers
[nIndex
];
116 if(rTargetBitmap
.IsEmpty())
118 rTargetBitmap
= maMarkersBitmap
;
119 rTargetBitmap
.Crop(rRectangle
);
122 return rTargetBitmap
;
125 // change getting of bitmap to use the big resource bitmap
126 const BitmapEx
& SdrHdlBitmapSet::GetBitmapEx(BitmapMarkerKind eKindOfMarker
, sal_uInt16 nInd
)
128 // fill in size and source position in maMarkersBitmap
129 const sal_uInt16
nYPos(nInd
* 11);
131 switch(eKindOfMarker
)
135 OSL_FAIL( "Unknown kind of marker." );
136 // no break here, return Rect_9x9 as default
140 return impGetOrCreateTargetBitmap((1 * INDEX_COUNT
) + nInd
, Rectangle(Point(7, nYPos
), Size(9, 9)));
145 return impGetOrCreateTargetBitmap((0 * INDEX_COUNT
) + nInd
, Rectangle(Point(0, nYPos
), Size(7, 7)));
150 return impGetOrCreateTargetBitmap((2 * INDEX_COUNT
) + nInd
, Rectangle(Point(16, nYPos
), Size(11, 11)));
155 const sal_uInt16
nIndex((3 * INDEX_COUNT
) + nInd
);
161 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(72, 66), Size(13, 13)));
165 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(85, 66), Size(13, 13)));
169 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(72, 79), Size(13, 13)));
173 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(85, 79), Size(13, 13)));
177 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(98, 79), Size(13, 13)));
181 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(98, 66), Size(13, 13)));
188 return impGetOrCreateTargetBitmap((4 * INDEX_COUNT
) + nInd
, Rectangle(Point(27, nYPos
), Size(7, 7)));
194 return impGetOrCreateTargetBitmap((5 * INDEX_COUNT
) + nInd
, Rectangle(Point(34, nYPos
), Size(9, 9)));
199 return impGetOrCreateTargetBitmap((6 * INDEX_COUNT
) + nInd
, Rectangle(Point(43, nYPos
), Size(11, 11)));
204 return impGetOrCreateTargetBitmap((7 * INDEX_COUNT
) + nInd
, Rectangle(Point(54, nYPos
), Size(7, 9)));
209 return impGetOrCreateTargetBitmap((8 * INDEX_COUNT
) + nInd
, Rectangle(Point(61, nYPos
), Size(9, 11)));
214 return impGetOrCreateTargetBitmap((9 * INDEX_COUNT
) + nInd
, Rectangle(Point(70, nYPos
), Size(9, 7)));
219 return impGetOrCreateTargetBitmap((10 * INDEX_COUNT
) + nInd
, Rectangle(Point(79, nYPos
), Size(11, 9)));
224 return impGetOrCreateTargetBitmap((11 * INDEX_COUNT
) + nInd
, Rectangle(Point(90, nYPos
), Size(7, 7)));
229 return impGetOrCreateTargetBitmap((12 * INDEX_COUNT
) + nInd
, Rectangle(Point(97, nYPos
), Size(9, 9)));
234 return impGetOrCreateTargetBitmap((13 * INDEX_COUNT
) + nInd
, Rectangle(Point(106, nYPos
), Size(11, 11)));
239 return impGetOrCreateTargetBitmap((KIND_COUNT
* INDEX_COUNT
) + 0, Rectangle(Point(0, 68), Size(15, 15)));
244 return impGetOrCreateTargetBitmap((KIND_COUNT
* INDEX_COUNT
) + 1, Rectangle(Point(15, 76), Size(9, 9)));
247 case Glue_Deselected
:
249 return impGetOrCreateTargetBitmap((KIND_COUNT
* INDEX_COUNT
) + 1, Rectangle(Point(15, 67), Size(9, 9)));
252 case Anchor
: // AnchorTR for SW
255 return impGetOrCreateTargetBitmap((KIND_COUNT
* INDEX_COUNT
) + 2, Rectangle(Point(24, 67), Size(24, 24)));
258 // add AnchorPressed to be able to animate anchor control
260 case AnchorPressedTR
:
262 return impGetOrCreateTargetBitmap((KIND_COUNT
* INDEX_COUNT
) + 3, Rectangle(Point(48, 67), Size(24, 24)));
267 ////////////////////////////////////////////////////////////////////////////////////////////////////
280 b1PixMore(sal_False
),
282 mbMoveOutside(false),
287 SdrHdl::SdrHdl(const Point
& rPnt
, SdrHdlKind eNewKind
):
299 b1PixMore(sal_False
),
301 mbMoveOutside(false),
311 void SdrHdl::Set1PixMore(sal_Bool bJa
)
317 // create new display
322 void SdrHdl::SetMoveOutside( bool bMoveOutside
)
324 if(mbMoveOutside
!= bMoveOutside
)
326 mbMoveOutside
= bMoveOutside
;
328 // create new display
333 void SdrHdl::SetDrehWink(long n
)
339 // create new display
344 void SdrHdl::SetPos(const Point
& rPnt
)
348 // remember new position
351 // create new display
356 void SdrHdl::SetSelected(sal_Bool bJa
)
360 // remember new value
363 // create new display
368 void SdrHdl::SetHdlList(SdrHdlList
* pList
)
370 if(pHdlList
!= pList
)
375 // now its possible to create graphic representation
380 void SdrHdl::SetObj(SdrObject
* pNewObj
)
384 // remember new object
387 // graphic representation may have changed
394 // force update of graphic representation
398 void SdrHdl::GetRidOfIAObject()
402 maOverlayGroup
.clear();
405 void SdrHdl::CreateB2dIAObject()
407 // first throw away old one
410 if(pHdlList
&& pHdlList
->GetView() && !pHdlList
->GetView()->areMarkHandlesHidden())
412 BitmapColorIndex eColIndex
= LightGreen
;
413 BitmapMarkerKind eKindOfMarker
= Rect_7x7
;
415 sal_Bool bRot
= pHdlList
->IsRotateShear();
417 eColIndex
= (bSelect
) ? Cyan
: LightCyan
;
420 // red rotation handles
424 eColIndex
= LightRed
;
431 eKindOfMarker
= (b1PixMore
) ? Rect_9x9
: Rect_7x7
;
442 eKindOfMarker
= Circ_7x7
;
446 eKindOfMarker
= Rect_7x7
;
453 // Upper/Lower handles
456 eKindOfMarker
= Elli_9x7
;
460 eKindOfMarker
= Rect_7x7
;
467 // Left/Right handles
470 eKindOfMarker
= Elli_7x9
;
474 eKindOfMarker
= Rect_7x7
;
482 eKindOfMarker
= (b1PixMore
) ? Circ_9x9
: Circ_7x7
;
486 eKindOfMarker
= (b1PixMore
) ? Rect_9x9
: Rect_7x7
;
490 case HDL_BWGT
: // weight at poly
492 eKindOfMarker
= Circ_7x7
;
497 eKindOfMarker
= Rect_11x11
;
503 eKindOfMarker
= Crosshair
;
508 eKindOfMarker
= Glue
;
511 case HDL_GLUE_DESELECTED
:
513 eKindOfMarker
= Glue_Deselected
;
518 eKindOfMarker
= Anchor
;
525 // top right anchor for SW
528 eKindOfMarker
= AnchorTR
;
532 // for SJ and the CustomShapeHandles:
533 case HDL_CUSTOMSHAPE1
:
535 eKindOfMarker
= Customshape1
;
543 SdrMarkView
* pView
= pHdlList
->GetView();
544 SdrPageView
* pPageView
= pView
->GetSdrPageView();
548 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
550 // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
551 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
553 if(rPageWindow
.GetPaintWindow().OutputToWindow())
555 Point
aMoveOutsideOffset(0, 0);
557 // add offset if necessary
558 if(pHdlList
->IsMoveOutside() || mbMoveOutside
)
560 OutputDevice
& rOutDev
= rPageWindow
.GetPaintWindow().GetOutputDevice();
561 Size aOffset
= rOutDev
.PixelToLogic(Size(4, 4));
563 if(eKind
== HDL_UPLFT
|| eKind
== HDL_UPPER
|| eKind
== HDL_UPRGT
)
564 aMoveOutsideOffset
.Y() -= aOffset
.Width();
565 if(eKind
== HDL_LWLFT
|| eKind
== HDL_LOWER
|| eKind
== HDL_LWRGT
)
566 aMoveOutsideOffset
.Y() += aOffset
.Height();
567 if(eKind
== HDL_UPLFT
|| eKind
== HDL_LEFT
|| eKind
== HDL_LWLFT
)
568 aMoveOutsideOffset
.X() -= aOffset
.Width();
569 if(eKind
== HDL_UPRGT
|| eKind
== HDL_RIGHT
|| eKind
== HDL_LWRGT
)
570 aMoveOutsideOffset
.X() += aOffset
.Height();
573 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
576 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
577 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= CreateOverlayObject(
584 if(pNewOverlayObject
)
586 xManager
->add(*pNewOverlayObject
);
587 maOverlayGroup
.append(*pNewOverlayObject
);
596 BitmapMarkerKind
SdrHdl::GetNextBigger(BitmapMarkerKind eKnd
) const
598 BitmapMarkerKind
eRetval(eKnd
);
602 case Rect_7x7
: eRetval
= Rect_9x9
; break;
603 case Rect_9x9
: eRetval
= Rect_11x11
; break;
604 case Rect_11x11
: eRetval
= Rect_13x13
; break;
606 case Circ_7x7
: eRetval
= Circ_9x9
; break;
607 case Circ_9x9
: eRetval
= Circ_11x11
; break;
609 case Elli_7x9
: eRetval
= Elli_9x11
; break;
611 case Elli_9x7
: eRetval
= Elli_11x9
; break;
613 case RectPlus_7x7
: eRetval
= RectPlus_9x9
; break;
614 case RectPlus_9x9
: eRetval
= RectPlus_11x11
; break;
616 // let anchor blink with its pressed state
617 case Anchor
: eRetval
= AnchorPressed
; break;
620 case AnchorTR
: eRetval
= AnchorPressedTR
; break;
628 BitmapEx
SdrHdl::ImpGetBitmapEx( BitmapMarkerKind eKindOfMarker
, sal_uInt16 nInd
)
630 static vcl::DeleteOnDeinit
< SdrHdlBitmapSet
> aModernSet(new SdrHdlBitmapSet(SIP_SA_MARKERS
));
631 return aModernSet
.get()->GetBitmapEx(eKindOfMarker
, nInd
);
634 ::sdr::overlay::OverlayObject
* SdrHdl::CreateOverlayObject(
635 const basegfx::B2DPoint
& rPos
,
636 BitmapColorIndex eColIndex
, BitmapMarkerKind eKindOfMarker
, Point aMoveOutsideOffset
)
638 ::sdr::overlay::OverlayObject
* pRetval
= 0L;
640 // support bigger sizes
641 sal_Bool
bForceBiggerSize(sal_False
);
643 if(pHdlList
->GetHdlSize() > 3)
645 bForceBiggerSize
= sal_True
;
650 eKindOfMarker
= GetNextBigger(eKindOfMarker
);
653 // This handle has the focus, visualize it
654 if(IsFocusHdl() && pHdlList
&& pHdlList
->GetFocusHdl() == this)
656 // create animated handle
657 BitmapMarkerKind eNextBigger
= GetNextBigger(eKindOfMarker
);
659 if(eNextBigger
== eKindOfMarker
)
661 // this may happen for the not supported getting-bigger types.
662 // Choose an alternative here
663 switch(eKindOfMarker
)
665 case Rect_13x13
: eNextBigger
= Rect_11x11
; break;
666 case Circ_11x11
: eNextBigger
= Elli_11x9
; break;
667 case Elli_9x11
: eNextBigger
= Elli_11x9
; break;
668 case Elli_11x9
: eNextBigger
= Elli_9x11
; break;
669 case RectPlus_11x11
: eNextBigger
= Rect_13x13
; break;
676 eNextBigger
= Crosshair
;
678 case Glue_Deselected
:
686 // create animated handle
687 BitmapEx aBmpEx1
= ImpGetBitmapEx( eKindOfMarker
, (sal_uInt16
)eColIndex
);
688 BitmapEx aBmpEx2
= ImpGetBitmapEx( eNextBigger
, (sal_uInt16
)eColIndex
);
690 // #i53216# Use system cursor blink time. Use the unsigned value.
691 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
692 const sal_uInt32
nBlinkTime((sal_uInt32
)rStyleSettings
.GetCursorBlinkTime());
694 if(eKindOfMarker
== Anchor
|| eKindOfMarker
== AnchorPressed
)
696 // when anchor is used take upper left as reference point inside the handle
697 pRetval
= new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos
, aBmpEx1
, aBmpEx2
, nBlinkTime
);
699 else if(eKindOfMarker
== AnchorTR
|| eKindOfMarker
== AnchorPressedTR
)
701 // AnchorTR for SW, take top right as (0,0)
702 pRetval
= new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos
, aBmpEx1
, aBmpEx2
, nBlinkTime
,
703 (sal_uInt16
)(aBmpEx1
.GetSizePixel().Width() - 1), 0,
704 (sal_uInt16
)(aBmpEx2
.GetSizePixel().Width() - 1), 0);
708 // create centered handle as default
709 pRetval
= new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos
, aBmpEx1
, aBmpEx2
, nBlinkTime
,
710 (sal_uInt16
)(aBmpEx1
.GetSizePixel().Width() - 1) >> 1,
711 (sal_uInt16
)(aBmpEx1
.GetSizePixel().Height() - 1) >> 1,
712 (sal_uInt16
)(aBmpEx2
.GetSizePixel().Width() - 1) >> 1,
713 (sal_uInt16
)(aBmpEx2
.GetSizePixel().Height() - 1) >> 1);
718 // create normal handle: use ImpGetBitmapEx(...) now
719 BitmapEx aBmpEx
= ImpGetBitmapEx(eKindOfMarker
, (sal_uInt16
)eColIndex
);
721 if(eKindOfMarker
== Anchor
|| eKindOfMarker
== AnchorPressed
)
723 // upper left as reference point inside the handle for AnchorPressed, too
724 pRetval
= new ::sdr::overlay::OverlayBitmapEx(rPos
, aBmpEx
);
726 else if(eKindOfMarker
== AnchorTR
|| eKindOfMarker
== AnchorPressedTR
)
728 // AnchorTR for SW, take top right as (0,0)
729 pRetval
= new ::sdr::overlay::OverlayBitmapEx(rPos
, aBmpEx
,
730 (sal_uInt16
)(aBmpEx
.GetSizePixel().Width() - 1), 0);
734 sal_uInt16
nCenX((sal_uInt16
)(aBmpEx
.GetSizePixel().Width() - 1L) >> 1);
735 sal_uInt16
nCenY((sal_uInt16
)(aBmpEx
.GetSizePixel().Height() - 1L) >> 1);
737 if(aMoveOutsideOffset
.X() > 0)
741 else if(aMoveOutsideOffset
.X() < 0)
743 nCenX
= (sal_uInt16
)(aBmpEx
.GetSizePixel().Width() - 1);
746 if(aMoveOutsideOffset
.Y() > 0)
750 else if(aMoveOutsideOffset
.Y() < 0)
752 nCenY
= (sal_uInt16
)(aBmpEx
.GetSizePixel().Height() - 1);
755 // create centered handle as default
756 pRetval
= new ::sdr::overlay::OverlayBitmapEx(rPos
, aBmpEx
, nCenX
, nCenY
);
763 bool SdrHdl::IsHdlHit(const Point
& rPnt
) const
766 basegfx::B2DPoint
aPosition(rPnt
.X(), rPnt
.Y());
767 return maOverlayGroup
.isHitLogic(aPosition
);
770 Pointer
SdrHdl::GetPointer() const
772 PointerStyle ePtr
=POINTER_MOVE
;
773 const sal_Bool bSize
=eKind
>=HDL_UPLFT
&& eKind
<=HDL_LWRGT
;
774 const sal_Bool bRot
=pHdlList
!=NULL
&& pHdlList
->IsRotateShear();
775 const sal_Bool bDis
=pHdlList
!=NULL
&& pHdlList
->IsDistortShear();
776 if (bSize
&& pHdlList
!=NULL
&& (bRot
|| bDis
)) {
778 case HDL_UPLFT
: case HDL_UPRGT
:
779 case HDL_LWLFT
: case HDL_LWRGT
: ePtr
=bRot
? POINTER_ROTATE
: POINTER_REFHAND
; break;
780 case HDL_LEFT
: case HDL_RIGHT
: ePtr
=POINTER_VSHEAR
; break;
781 case HDL_UPPER
: case HDL_LOWER
: ePtr
=POINTER_HSHEAR
; break;
786 // When resizing rotated rectangles, rotate the mouse cursor slightly, too
787 if (bSize
&& nDrehWink
!=0) {
790 case HDL_LWRGT
: nHdlWink
=31500; break;
791 case HDL_LOWER
: nHdlWink
=27000; break;
792 case HDL_LWLFT
: nHdlWink
=22500; break;
793 case HDL_LEFT
: nHdlWink
=18000; break;
794 case HDL_UPLFT
: nHdlWink
=13500; break;
795 case HDL_UPPER
: nHdlWink
=9000; break;
796 case HDL_UPRGT
: nHdlWink
=4500; break;
797 case HDL_RIGHT
: nHdlWink
=0; break;
801 nHdlWink
+=nDrehWink
+2249; // a little bit more (for rounding)
802 while (nHdlWink
<0) nHdlWink
+=36000;
803 while (nHdlWink
>=36000) nHdlWink
-=36000;
805 switch ((sal_uInt8
)nHdlWink
) {
806 case 0: ePtr
=POINTER_ESIZE
; break;
807 case 1: ePtr
=POINTER_NESIZE
; break;
808 case 2: ePtr
=POINTER_NSIZE
; break;
809 case 3: ePtr
=POINTER_NWSIZE
; break;
810 case 4: ePtr
=POINTER_WSIZE
; break;
811 case 5: ePtr
=POINTER_SWSIZE
; break;
812 case 6: ePtr
=POINTER_SSIZE
; break;
813 case 7: ePtr
=POINTER_SESIZE
; break;
817 case HDL_UPLFT
: ePtr
=POINTER_NWSIZE
; break;
818 case HDL_UPPER
: ePtr
=POINTER_NSIZE
; break;
819 case HDL_UPRGT
: ePtr
=POINTER_NESIZE
; break;
820 case HDL_LEFT
: ePtr
=POINTER_WSIZE
; break;
821 case HDL_RIGHT
: ePtr
=POINTER_ESIZE
; break;
822 case HDL_LWLFT
: ePtr
=POINTER_SWSIZE
; break;
823 case HDL_LOWER
: ePtr
=POINTER_SSIZE
; break;
824 case HDL_LWRGT
: ePtr
=POINTER_SESIZE
; break;
825 case HDL_POLY
: ePtr
=POINTER_MOVEPOINT
; break;
826 case HDL_CIRC
: ePtr
=POINTER_HAND
; break;
827 case HDL_REF1
: ePtr
=POINTER_REFHAND
; break;
828 case HDL_REF2
: ePtr
=POINTER_REFHAND
; break;
829 case HDL_BWGT
: ePtr
=POINTER_MOVEBEZIERWEIGHT
; break;
830 case HDL_GLUE
: ePtr
=POINTER_MOVEPOINT
; break;
831 case HDL_GLUE_DESELECTED
: ePtr
=POINTER_MOVEPOINT
; break;
832 case HDL_CUSTOMSHAPE1
: ePtr
=POINTER_HAND
; break;
838 return Pointer(ePtr
);
841 sal_Bool
SdrHdl::IsFocusHdl() const
854 // if it's an activated TextEdit, it's moved to extended points
855 if(pHdlList
&& pHdlList
->IsMoveOutside())
861 case HDL_MOVE
: // handle to move object
862 case HDL_POLY
: // selected point of polygon or curve
863 case HDL_BWGT
: // weight at a curve
864 case HDL_CIRC
: // angle of circle segments, corner radius of rectangles
865 case HDL_REF1
: // reference point 1, e. g. center of rotation
866 case HDL_REF2
: // reference point 2, e. g. endpoint of reflection axis
867 case HDL_GLUE
: // glue point
868 case HDL_GLUE_DESELECTED
: // deselected glue point, used to be a little blue cross
870 // for SJ and the CustomShapeHandles:
871 case HDL_CUSTOMSHAPE1
:
885 void SdrHdl::onMouseEnter(const MouseEvent
& /*rMEvt*/)
889 void SdrHdl::onMouseLeave()
893 ////////////////////////////////////////////////////////////////////////////////////////////////////
896 SdrHdlColor::SdrHdlColor(const Point
& rRef
, Color aCol
, const Size
& rSize
, sal_Bool bLum
)
897 : SdrHdl(rRef
, HDL_COLR
),
902 aCol
= GetLuminance(aCol
);
908 SdrHdlColor::~SdrHdlColor()
912 void SdrHdlColor::CreateB2dIAObject()
914 // first throw away old one
919 SdrMarkView
* pView
= pHdlList
->GetView();
921 if(pView
&& !pView
->areMarkHandlesHidden())
923 SdrPageView
* pPageView
= pView
->GetSdrPageView();
927 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
929 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
931 if(rPageWindow
.GetPaintWindow().OutputToWindow())
933 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
936 Bitmap
aBmpCol(CreateColorDropper(aMarkerColor
));
937 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
938 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
939 ::sdr::overlay::OverlayBitmapEx(
942 (sal_uInt16
)(aBmpCol
.GetSizePixel().Width() - 1) >> 1,
943 (sal_uInt16
)(aBmpCol
.GetSizePixel().Height() - 1) >> 1
945 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
948 if(pNewOverlayObject
)
950 xManager
->add(*pNewOverlayObject
);
951 maOverlayGroup
.append(*pNewOverlayObject
);
961 Bitmap
SdrHdlColor::CreateColorDropper(Color aCol
)
964 Bitmap
aRetval(aMarkerSize
, 24);
968 BitmapWriteAccess
* pWrite
= aRetval
.AcquireWriteAccess();
969 DBG_ASSERT(pWrite
, "Got NO write access to a new Bitmap!");
974 sal_Int32 nWidth
= aMarkerSize
.Width();
975 sal_Int32 nHeight
= aMarkerSize
.Height();
977 pWrite
->SetLineColor(Color(COL_LIGHTGRAY
));
978 pWrite
->DrawLine(Point(0, 0), Point(0, nHeight
- 1));
979 pWrite
->DrawLine(Point(1, 0), Point(nWidth
- 1, 0));
980 pWrite
->SetLineColor(Color(COL_GRAY
));
981 pWrite
->DrawLine(Point(1, nHeight
- 1), Point(nWidth
- 1, nHeight
- 1));
982 pWrite
->DrawLine(Point(nWidth
- 1, 1), Point(nWidth
- 1, nHeight
- 2));
984 // draw lighter UpperLeft
985 const Color
aLightColor(
986 (sal_uInt8
)(::std::min((sal_Int16
)((sal_Int16
)aCol
.GetRed() + (sal_Int16
)0x0040), (sal_Int16
)0x00ff)),
987 (sal_uInt8
)(::std::min((sal_Int16
)((sal_Int16
)aCol
.GetGreen() + (sal_Int16
)0x0040), (sal_Int16
)0x00ff)),
988 (sal_uInt8
)(::std::min((sal_Int16
)((sal_Int16
)aCol
.GetBlue() + (sal_Int16
)0x0040), (sal_Int16
)0x00ff)));
989 pWrite
->SetLineColor(aLightColor
);
990 pWrite
->DrawLine(Point(1, 1), Point(1, nHeight
- 2));
991 pWrite
->DrawLine(Point(2, 1), Point(nWidth
- 2, 1));
993 // draw darker LowerRight
994 const Color
aDarkColor(
995 (sal_uInt8
)(::std::max((sal_Int16
)((sal_Int16
)aCol
.GetRed() - (sal_Int16
)0x0040), (sal_Int16
)0x0000)),
996 (sal_uInt8
)(::std::max((sal_Int16
)((sal_Int16
)aCol
.GetGreen() - (sal_Int16
)0x0040), (sal_Int16
)0x0000)),
997 (sal_uInt8
)(::std::max((sal_Int16
)((sal_Int16
)aCol
.GetBlue() - (sal_Int16
)0x0040), (sal_Int16
)0x0000)));
998 pWrite
->SetLineColor(aDarkColor
);
999 pWrite
->DrawLine(Point(2, nHeight
- 2), Point(nWidth
- 2, nHeight
- 2));
1000 pWrite
->DrawLine(Point(nWidth
- 2, 2), Point(nWidth
- 2, nHeight
- 3));
1002 // get rid of write access
1009 Color
SdrHdlColor::GetLuminance(const Color
& rCol
)
1011 sal_uInt8 aLum
= rCol
.GetLuminance();
1012 Color
aRetval(aLum
, aLum
, aLum
);
1016 void SdrHdlColor::CallColorChangeLink()
1018 aColorChangeHdl
.Call(this);
1021 void SdrHdlColor::SetColor(Color aNew
, sal_Bool bCallLink
)
1023 if(IsUseLuminance())
1024 aNew
= GetLuminance(aNew
);
1026 if(aMarkerColor
!= aNew
)
1028 // remember new color
1029 aMarkerColor
= aNew
;
1031 // create new display
1034 // tell about change
1036 CallColorChangeLink();
1040 void SdrHdlColor::SetSize(const Size
& rNew
)
1042 if(rNew
!= aMarkerSize
)
1044 // remember new size
1047 // create new display
1052 ////////////////////////////////////////////////////////////////////////////////////////////////////
1053 // class SdrHdlGradient
1055 SdrHdlGradient::SdrHdlGradient(const Point
& rRef1
, const Point
& rRef2
, sal_Bool bGrad
)
1056 : SdrHdl(rRef1
, bGrad
? HDL_GRAD
: HDL_TRNS
),
1064 SdrHdlGradient::~SdrHdlGradient()
1068 void SdrHdlGradient::Set2ndPos(const Point
& rPnt
)
1072 // remember new position
1075 // create new display
1080 void SdrHdlGradient::CreateB2dIAObject()
1082 // first throw away old one
1087 SdrMarkView
* pView
= pHdlList
->GetView();
1089 if(pView
&& !pView
->areMarkHandlesHidden())
1091 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1095 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1097 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1099 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1101 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1104 // striped line in between
1105 basegfx::B2DVector
aVec(a2ndPos
.X() - aPos
.X(), a2ndPos
.Y() - aPos
.Y());
1106 double fVecLen
= aVec
.getLength();
1107 double fLongPercentArrow
= (1.0 - 0.05) * fVecLen
;
1108 double fHalfArrowWidth
= (0.05 * 0.5) * fVecLen
;
1110 basegfx::B2DVector
aPerpend(-aVec
.getY(), aVec
.getX());
1111 sal_Int32 nMidX
= (sal_Int32
)(aPos
.X() + aVec
.getX() * fLongPercentArrow
);
1112 sal_Int32 nMidY
= (sal_Int32
)(aPos
.Y() + aVec
.getY() * fLongPercentArrow
);
1113 Point
aMidPoint(nMidX
, nMidY
);
1115 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
1116 basegfx::B2DPoint
aMidPos(aMidPoint
.X(), aMidPoint
.Y());
1118 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
1119 ::sdr::overlay::OverlayLineStriped(
1122 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1124 pNewOverlayObject
->setBaseColor(IsGradient() ? Color(COL_BLACK
) : Color(COL_BLUE
));
1125 xManager
->add(*pNewOverlayObject
);
1126 maOverlayGroup
.append(*pNewOverlayObject
);
1129 Point
aLeft(aMidPoint
.X() + (sal_Int32
)(aPerpend
.getX() * fHalfArrowWidth
),
1130 aMidPoint
.Y() + (sal_Int32
)(aPerpend
.getY() * fHalfArrowWidth
));
1131 Point
aRight(aMidPoint
.X() - (sal_Int32
)(aPerpend
.getX() * fHalfArrowWidth
),
1132 aMidPoint
.Y() - (sal_Int32
)(aPerpend
.getY() * fHalfArrowWidth
));
1134 basegfx::B2DPoint
aPositionLeft(aLeft
.X(), aLeft
.Y());
1135 basegfx::B2DPoint
aPositionRight(aRight
.X(), aRight
.Y());
1136 basegfx::B2DPoint
aPosition2(a2ndPos
.X(), a2ndPos
.Y());
1138 pNewOverlayObject
= new
1139 ::sdr::overlay::OverlayTriangle(
1143 IsGradient() ? Color(COL_BLACK
) : Color(COL_BLUE
)
1145 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1147 xManager
->add(*pNewOverlayObject
);
1148 maOverlayGroup
.append(*pNewOverlayObject
);
1157 IMPL_LINK(SdrHdlGradient
, ColorChangeHdl
, SdrHdl
*, /*pHdl*/)
1160 FromIAOToItem(GetObj(), sal_True
, sal_True
);
1164 void SdrHdlGradient::FromIAOToItem(SdrObject
* _pObj
, sal_Bool bSetItemOnObject
, sal_Bool bUndo
)
1166 // from IAO positions and colors to gradient
1167 const SfxItemSet
& rSet
= _pObj
->GetMergedItemSet();
1169 GradTransformer aGradTransformer
;
1170 GradTransGradient aOldGradTransGradient
;
1171 GradTransGradient aGradTransGradient
;
1172 GradTransVector aGradTransVector
;
1176 aGradTransVector
.maPositionA
= basegfx::B2DPoint(GetPos().X(), GetPos().Y());
1177 aGradTransVector
.maPositionB
= basegfx::B2DPoint(Get2ndPos().X(), Get2ndPos().Y());
1179 aGradTransVector
.aCol1
= pColHdl1
->GetColor();
1181 aGradTransVector
.aCol2
= pColHdl2
->GetColor();
1184 aOldGradTransGradient
.aGradient
= ((XFillGradientItem
&)rSet
.Get(XATTR_FILLGRADIENT
)).GetGradientValue();
1186 aOldGradTransGradient
.aGradient
= ((XFillFloatTransparenceItem
&)rSet
.Get(XATTR_FILLFLOATTRANSPARENCE
)).GetGradientValue();
1188 // transform vector data to gradient
1189 aGradTransformer
.VecToGrad(aGradTransVector
, aGradTransGradient
, aOldGradTransGradient
, _pObj
, bMoveSingleHandle
, bMoveFirstHandle
);
1191 if(bSetItemOnObject
)
1193 SdrModel
* pModel
= _pObj
->GetModel();
1194 SfxItemSet
aNewSet(pModel
->GetItemPool());
1199 XFillGradientItem
aNewGradItem(aString
, aGradTransGradient
.aGradient
);
1200 aNewSet
.Put(aNewGradItem
);
1205 XFillFloatTransparenceItem
aNewTransItem(aString
, aGradTransGradient
.aGradient
);
1206 aNewSet
.Put(aNewTransItem
);
1209 if(bUndo
&& pModel
->IsUndoEnabled())
1211 pModel
->BegUndo(SVX_RESSTR(IsGradient() ? SIP_XA_FILLGRADIENT
: SIP_XA_FILLTRANSPARENCE
));
1212 pModel
->AddUndo(pModel
->GetSdrUndoFactory().CreateUndoAttrObject(*_pObj
));
1216 pObj
->SetMergedItemSetAndBroadcast(aNewSet
);
1219 // back transformation, set values on pIAOHandle
1220 aGradTransformer
.GradToVec(aGradTransGradient
, aGradTransVector
, _pObj
);
1222 SetPos(Point(FRound(aGradTransVector
.maPositionA
.getX()), FRound(aGradTransVector
.maPositionA
.getY())));
1223 Set2ndPos(Point(FRound(aGradTransVector
.maPositionB
.getX()), FRound(aGradTransVector
.maPositionB
.getY())));
1226 pColHdl1
->SetPos(Point(FRound(aGradTransVector
.maPositionA
.getX()), FRound(aGradTransVector
.maPositionA
.getY())));
1227 pColHdl1
->SetColor(aGradTransVector
.aCol1
);
1231 pColHdl2
->SetPos(Point(FRound(aGradTransVector
.maPositionB
.getX()), FRound(aGradTransVector
.maPositionB
.getY())));
1232 pColHdl2
->SetColor(aGradTransVector
.aCol2
);
1236 ////////////////////////////////////////////////////////////////////////////////////////////////////
1238 SdrHdlLine::~SdrHdlLine() {}
1240 void SdrHdlLine::CreateB2dIAObject()
1242 // first throw away old one
1247 SdrMarkView
* pView
= pHdlList
->GetView();
1249 if(pView
&& !pView
->areMarkHandlesHidden() && pHdl1
&& pHdl2
)
1251 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1255 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1257 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1259 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1261 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1264 basegfx::B2DPoint
aPosition1(pHdl1
->GetPos().X(), pHdl1
->GetPos().Y());
1265 basegfx::B2DPoint
aPosition2(pHdl2
->GetPos().X(), pHdl2
->GetPos().Y());
1267 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
1268 ::sdr::overlay::OverlayLineStriped(
1272 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1275 if(pNewOverlayObject
)
1278 pNewOverlayObject
->setBaseColor(Color(COL_LIGHTRED
));
1280 xManager
->add(*pNewOverlayObject
);
1281 maOverlayGroup
.append(*pNewOverlayObject
);
1291 Pointer
SdrHdlLine::GetPointer() const
1293 return Pointer(POINTER_REFHAND
);
1296 ////////////////////////////////////////////////////////////////////////////////////////////////////
1298 SdrHdlBezWgt::~SdrHdlBezWgt() {}
1300 void SdrHdlBezWgt::CreateB2dIAObject()
1303 SdrHdl::CreateB2dIAObject();
1308 SdrMarkView
* pView
= pHdlList
->GetView();
1310 if(pView
&& !pView
->areMarkHandlesHidden())
1312 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1316 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1318 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1320 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1322 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1325 basegfx::B2DPoint
aPosition1(pHdl1
->GetPos().X(), pHdl1
->GetPos().Y());
1326 basegfx::B2DPoint
aPosition2(aPos
.X(), aPos
.Y());
1328 if(!aPosition1
.equal(aPosition2
))
1330 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
1331 ::sdr::overlay::OverlayLineStriped(
1335 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1338 if(pNewOverlayObject
)
1340 // line part is not hittable
1341 pNewOverlayObject
->setHittable(sal_False
);
1344 pNewOverlayObject
->setBaseColor(Color(COL_LIGHTBLUE
));
1346 xManager
->add(*pNewOverlayObject
);
1347 maOverlayGroup
.append(*pNewOverlayObject
);
1358 ////////////////////////////////////////////////////////////////////////////////////////////////////
1360 E3dVolumeMarker::E3dVolumeMarker(const basegfx::B2DPolyPolygon
& rWireframePoly
)
1362 aWireframePoly
= rWireframePoly
;
1365 void E3dVolumeMarker::CreateB2dIAObject()
1370 SdrMarkView
* pView
= pHdlList
->GetView();
1372 if(pView
&& !pView
->areMarkHandlesHidden())
1374 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1378 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1380 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1382 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1384 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1385 if (xManager
.is() && aWireframePoly
.count())
1387 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
1388 ::sdr::overlay::OverlayPolyPolygonStriped(aWireframePoly
);
1389 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1392 if(pNewOverlayObject
)
1394 pNewOverlayObject
->setBaseColor(Color(COL_BLACK
));
1396 xManager
->add(*pNewOverlayObject
);
1397 maOverlayGroup
.append(*pNewOverlayObject
);
1407 ////////////////////////////////////////////////////////////////////////////////////////////////////
1409 ImpEdgeHdl::~ImpEdgeHdl()
1413 void ImpEdgeHdl::CreateB2dIAObject()
1415 if(nObjHdlNum
<= 1 && pObj
)
1417 // first throw away old one
1420 BitmapColorIndex eColIndex
= LightCyan
;
1421 BitmapMarkerKind eKindOfMarker
= Rect_7x7
;
1425 SdrMarkView
* pView
= pHdlList
->GetView();
1427 if(pView
&& !pView
->areMarkHandlesHidden())
1429 const SdrEdgeObj
* pEdge
= (SdrEdgeObj
*)pObj
;
1431 if(pEdge
->GetConnectedNode(nObjHdlNum
== 0) != NULL
)
1432 eColIndex
= LightRed
;
1436 // Handle with plus sign inside
1437 eKindOfMarker
= Circ_7x7
;
1440 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1444 for(sal_uInt32
b(0); b
< pPageView
->PageWindowCount(); b
++)
1446 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1448 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1450 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1453 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
1455 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= CreateOverlayObject(
1461 if(pNewOverlayObject
)
1463 xManager
->add(*pNewOverlayObject
);
1464 maOverlayGroup
.append(*pNewOverlayObject
);
1476 SdrHdl::CreateB2dIAObject();
1480 void ImpEdgeHdl::SetLineCode(SdrEdgeLineCode eCode
)
1482 if(eLineCode
!= eCode
)
1484 // remember new value
1487 // create new display
1492 Pointer
ImpEdgeHdl::GetPointer() const
1494 SdrEdgeObj
* pEdge
=PTR_CAST(SdrEdgeObj
,pObj
);
1496 return SdrHdl::GetPointer();
1498 return Pointer(POINTER_MOVEPOINT
);
1500 return Pointer(POINTER_ESIZE
);
1502 return Pointer(POINTER_SSIZE
);
1505 sal_Bool
ImpEdgeHdl::IsHorzDrag() const
1507 SdrEdgeObj
* pEdge
=PTR_CAST(SdrEdgeObj
,pObj
);
1513 SdrEdgeKind eEdgeKind
= ((SdrEdgeKindItem
&)(pEdge
->GetObjectItem(SDRATTR_EDGEKIND
))).GetValue();
1515 const SdrEdgeInfoRec
& rInfo
=pEdge
->aEdgeInfo
;
1516 if (eEdgeKind
==SDREDGE_ORTHOLINES
|| eEdgeKind
==SDREDGE_BEZIER
)
1518 return !rInfo
.ImpIsHorzLine(eLineCode
,*pEdge
->pEdgeTrack
);
1520 else if (eEdgeKind
==SDREDGE_THREELINES
)
1522 long nWink
=nObjHdlNum
==2 ? rInfo
.nAngle1
: rInfo
.nAngle2
;
1523 if (nWink
==0 || nWink
==18000)
1531 ////////////////////////////////////////////////////////////////////////////////////////////////////
1533 ImpMeasureHdl::~ImpMeasureHdl()
1537 void ImpMeasureHdl::CreateB2dIAObject()
1539 // first throw away old one
1544 SdrMarkView
* pView
= pHdlList
->GetView();
1546 if(pView
&& !pView
->areMarkHandlesHidden())
1548 BitmapColorIndex eColIndex
= LightCyan
;
1549 BitmapMarkerKind eKindOfMarker
= Rect_9x9
;
1553 eKindOfMarker
= Rect_7x7
;
1561 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1565 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1567 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1569 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1571 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1574 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
1576 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= CreateOverlayObject(
1582 if(pNewOverlayObject
)
1584 xManager
->add(*pNewOverlayObject
);
1585 maOverlayGroup
.append(*pNewOverlayObject
);
1595 Pointer
ImpMeasureHdl::GetPointer() const
1599 case 0: case 1: return Pointer(POINTER_HAND
);
1600 case 2: case 3: return Pointer(POINTER_MOVEPOINT
);
1601 case 4: case 5: return SdrHdl::GetPointer(); // will then be rotated appropriately
1603 return Pointer(POINTER_NOTALLOWED
);
1606 ////////////////////////////////////////////////////////////////////////////////////////////////////
1608 ImpTextframeHdl::ImpTextframeHdl(const Rectangle
& rRect
) :
1609 SdrHdl(rRect
.TopLeft(),HDL_MOVE
),
1614 void ImpTextframeHdl::CreateB2dIAObject()
1616 // first throw away old one
1621 SdrMarkView
* pView
= pHdlList
->GetView();
1623 if(pView
&& !pView
->areMarkHandlesHidden())
1625 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1629 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1631 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1633 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1635 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1638 const basegfx::B2DPoint
aTopLeft(maRect
.Left(), maRect
.Top());
1639 const basegfx::B2DPoint
aBottomRight(maRect
.Right(), maRect
.Bottom());
1640 const svtools::ColorConfig aColorConfig
;
1641 const Color
aHatchCol( aColorConfig
.GetColorValue( svtools::FONTCOLOR
).nColor
);
1643 ::sdr::overlay::OverlayHatchRect
* pNewOverlayObject
= new ::sdr::overlay::OverlayHatchRect(
1650 nDrehWink
* -F_PI18000
);
1651 pNewOverlayObject
->setHittable(false);
1654 if(pNewOverlayObject
)
1656 xManager
->add(*pNewOverlayObject
);
1657 maOverlayGroup
.append(*pNewOverlayObject
);
1667 ////////////////////////////////////////////////////////////////////////////////////////////////////
1669 class ImpSdrHdlListSorter
: public ContainerSorter
{
1671 ImpSdrHdlListSorter(Container
& rNewCont
): ContainerSorter(rNewCont
) {}
1672 virtual ~ImpSdrHdlListSorter() {}
1673 virtual int Compare(const void* pElem1
, const void* pElem2
) const;
1676 int ImpSdrHdlListSorter::Compare(const void* pElem1
, const void* pElem2
) const
1678 SdrHdlKind eKind1
=((SdrHdl
*)pElem1
)->GetKind();
1679 SdrHdlKind eKind2
=((SdrHdl
*)pElem2
)->GetKind();
1680 // Level 1: first normal handles, then Glue, then User, then Plus handles, then reference point handles
1685 if (eKind1
==HDL_REF1
|| eKind1
==HDL_REF2
|| eKind1
==HDL_MIRX
) n1
=5;
1686 else if (eKind1
==HDL_GLUE
|| eKind1
==HDL_GLUE_DESELECTED
) n1
=2;
1687 else if (eKind1
==HDL_USER
) n1
=3;
1688 else if (eKind1
==HDL_SMARTTAG
) n1
=0;
1689 if (eKind2
==HDL_REF1
|| eKind2
==HDL_REF2
|| eKind2
==HDL_MIRX
) n2
=5;
1690 else if (eKind2
==HDL_GLUE
|| eKind2
==HDL_GLUE_DESELECTED
) n2
=2;
1691 else if (eKind2
==HDL_USER
) n2
=3;
1692 else if (eKind2
==HDL_SMARTTAG
) n2
=0;
1694 if (((SdrHdl
*)pElem1
)->IsPlusHdl()) n1
=4;
1695 if (((SdrHdl
*)pElem2
)->IsPlusHdl()) n2
=4;
1698 // Level 2: PageView (Pointer)
1699 SdrPageView
* pPV1
=((SdrHdl
*)pElem1
)->GetPageView();
1700 SdrPageView
* pPV2
=((SdrHdl
*)pElem2
)->GetPageView();
1703 // Level 3: Position (x+y)
1704 SdrObject
* pObj1
=((SdrHdl
*)pElem1
)->GetObj();
1705 SdrObject
* pObj2
=((SdrHdl
*)pElem2
)->GetObj();
1708 sal_uInt32 nNum1
=((SdrHdl
*)pElem1
)->GetObjHdlNum();
1709 sal_uInt32 nNum2
=((SdrHdl
*)pElem2
)->GetObjHdlNum();
1713 return (long)pElem1
<(long)pElem2
? -1 : 1; // Hack, to always get to the same sorting
1714 return (sal_uInt16
)eKind1
<(sal_uInt16
)eKind2
? -1 : 1;
1717 return nNum1
<nNum2
? -1 : 1;
1721 return (long)pObj1
<(long)pObj2
? -1 : 1;
1726 return (long)pPV1
<(long)pPV2
? -1 : 1;
1731 return n1
<n2
? -1 : 1;
1735 SdrMarkView
* SdrHdlList::GetView() const
1740 // Helper struct for re-sorting handles
1741 struct ImplHdlAndIndex
1747 // Helper method for sorting handles taking care of OrdNums, keeping order in
1748 // single objects and re-sorting polygon handles intuitively
1749 extern "C" int __LOADONCALLAPI
ImplSortHdlFunc( const void* pVoid1
, const void* pVoid2
)
1751 const ImplHdlAndIndex
* p1
= (ImplHdlAndIndex
*)pVoid1
;
1752 const ImplHdlAndIndex
* p2
= (ImplHdlAndIndex
*)pVoid2
;
1754 if(p1
->mpHdl
->GetObj() == p2
->mpHdl
->GetObj())
1756 if(p1
->mpHdl
->GetObj() && p1
->mpHdl
->GetObj()->ISA(SdrPathObj
))
1758 // same object and a path object
1759 if((p1
->mpHdl
->GetKind() == HDL_POLY
|| p1
->mpHdl
->GetKind() == HDL_BWGT
)
1760 && (p2
->mpHdl
->GetKind() == HDL_POLY
|| p2
->mpHdl
->GetKind() == HDL_BWGT
))
1762 // both handles are point or control handles
1763 if(p1
->mpHdl
->GetPolyNum() == p2
->mpHdl
->GetPolyNum())
1765 if(p1
->mpHdl
->GetPointNum() < p2
->mpHdl
->GetPointNum())
1774 else if(p1
->mpHdl
->GetPolyNum() < p2
->mpHdl
->GetPolyNum())
1787 if(!p1
->mpHdl
->GetObj())
1791 else if(!p2
->mpHdl
->GetObj())
1797 // different objects, use OrdNum for sort
1798 const sal_uInt32 nOrdNum1
= p1
->mpHdl
->GetObj()->GetOrdNum();
1799 const sal_uInt32 nOrdNum2
= p2
->mpHdl
->GetObj()->GetOrdNum();
1801 if(nOrdNum1
< nOrdNum2
)
1812 // fallback to indices
1813 if(p1
->mnIndex
< p2
->mnIndex
)
1823 ////////////////////////////////////////////////////////////////////////////////////////////////////
1825 void SdrHdlList::TravelFocusHdl(sal_Bool bForward
)
1827 // security correction
1828 if(mnFocusIndex
!= CONTAINER_ENTRY_NOTFOUND
&& mnFocusIndex
>= GetHdlCount())
1829 mnFocusIndex
= CONTAINER_ENTRY_NOTFOUND
;
1833 // take care of old handle
1834 const sal_uIntPtr
nOldHdlNum(mnFocusIndex
);
1835 SdrHdl
* pOld
= GetHdl(nOldHdlNum
);
1839 // switch off old handle
1840 mnFocusIndex
= CONTAINER_ENTRY_NOTFOUND
;
1844 // allocate pointer array for sorted handle list
1845 ImplHdlAndIndex
* pHdlAndIndex
= new ImplHdlAndIndex
[aList
.Count()];
1847 // build sorted handle list
1849 for( a
= 0; a
< aList
.Count(); a
++)
1851 pHdlAndIndex
[a
].mpHdl
= (SdrHdl
*)aList
.GetObject(a
);
1852 pHdlAndIndex
[a
].mnIndex
= a
;
1855 qsort(pHdlAndIndex
, aList
.Count(), sizeof(ImplHdlAndIndex
), ImplSortHdlFunc
);
1857 // look for old num in sorted array
1858 sal_uIntPtr
nOldHdl(nOldHdlNum
);
1860 if(nOldHdlNum
!= CONTAINER_ENTRY_NOTFOUND
)
1862 for(a
= 0; a
< aList
.Count(); a
++)
1864 if(pHdlAndIndex
[a
].mpHdl
== pOld
)
1873 sal_uIntPtr
nNewHdl(nOldHdl
);
1875 // do the focus travel
1878 if(nOldHdl
!= CONTAINER_ENTRY_NOTFOUND
)
1880 if(nOldHdl
== aList
.Count() - 1)
1883 nNewHdl
= CONTAINER_ENTRY_NOTFOUND
;
1887 // simply the next handle
1893 // start forward run at first entry
1899 if(nOldHdl
== CONTAINER_ENTRY_NOTFOUND
)
1901 // start backward run at last entry
1902 nNewHdl
= aList
.Count() - 1;
1910 nNewHdl
= CONTAINER_ENTRY_NOTFOUND
;
1914 // simply the previous handle
1921 sal_uInt32
nNewHdlNum(nNewHdl
);
1923 // look for old num in sorted array
1924 if(nNewHdl
!= CONTAINER_ENTRY_NOTFOUND
)
1926 SdrHdl
* pNew
= pHdlAndIndex
[nNewHdl
].mpHdl
;
1928 for(a
= 0; a
< aList
.Count(); a
++)
1930 if((SdrHdl
*)aList
.GetObject(a
) == pNew
)
1938 // take care of next handle
1939 if(nOldHdlNum
!= nNewHdlNum
)
1941 mnFocusIndex
= nNewHdlNum
;
1942 SdrHdl
* pNew
= GetHdl(mnFocusIndex
);
1950 // free memory again
1951 delete [] pHdlAndIndex
;
1955 SdrHdl
* SdrHdlList::GetFocusHdl() const
1957 if(mnFocusIndex
!= CONTAINER_ENTRY_NOTFOUND
&& mnFocusIndex
< GetHdlCount())
1958 return GetHdl(mnFocusIndex
);
1963 void SdrHdlList::SetFocusHdl(SdrHdl
* pNew
)
1967 SdrHdl
* pActual
= GetFocusHdl();
1969 if(!pActual
|| pActual
!= pNew
)
1971 sal_uIntPtr nNewHdlNum
= GetHdlNum(pNew
);
1973 if(nNewHdlNum
!= CONTAINER_ENTRY_NOTFOUND
)
1975 mnFocusIndex
= nNewHdlNum
;
1992 void SdrHdlList::ResetFocusHdl()
1994 SdrHdl
* pHdl
= GetFocusHdl();
1996 mnFocusIndex
= CONTAINER_ENTRY_NOTFOUND
;
2004 ////////////////////////////////////////////////////////////////////////////////////////////////////
2006 SdrHdlList::SdrHdlList(SdrMarkView
* pV
)
2007 : mnFocusIndex(CONTAINER_ENTRY_NOTFOUND
),
2012 bRotateShear
= sal_False
;
2013 bMoveOutside
= sal_False
;
2014 bDistortShear
= sal_False
;
2017 SdrHdlList::~SdrHdlList()
2022 void SdrHdlList::SetHdlSize(sal_uInt16 nSiz
)
2024 if(nHdlSize
!= nSiz
)
2026 // remember new value
2029 // propagate change to IAOs
2030 for(sal_uInt32 i
=0; i
<GetHdlCount(); i
++)
2032 SdrHdl
* pHdl
= GetHdl(i
);
2038 void SdrHdlList::SetMoveOutside(sal_Bool bOn
)
2040 if(bMoveOutside
!= bOn
)
2042 // remember new value
2045 // propagate change to IAOs
2046 for(sal_uInt32 i
=0; i
<GetHdlCount(); i
++)
2048 SdrHdl
* pHdl
= GetHdl(i
);
2054 void SdrHdlList::SetRotateShear(sal_Bool bOn
)
2059 void SdrHdlList::SetDistortShear(sal_Bool bOn
)
2061 bDistortShear
= bOn
;
2064 SdrHdl
* SdrHdlList::RemoveHdl(sal_uIntPtr nNum
)
2066 SdrHdl
* pRetval
= (SdrHdl
*)aList
.Remove(nNum
);
2071 void SdrHdlList::RemoveAllByKind(SdrHdlKind eKind
)
2073 SdrHdl
* p
= static_cast<SdrHdl
*>(aList
.Last());
2076 if (p
->GetKind() == eKind
)
2078 // If removing an item doesn't invalidate the current position,
2079 // then perhaps it's safe to keep calling Prev here. But then I'm
2080 // too lazy to find out & this Container needs to be replaced by
2081 // STL anyways... :-P
2084 p
= static_cast<SdrHdl
*>(aList
.Last()); // start from the back again.
2087 p
= static_cast<SdrHdl
*>(aList
.Prev());
2091 void SdrHdlList::Clear()
2093 for (sal_uIntPtr i
=0; i
<GetHdlCount(); i
++)
2095 SdrHdl
* pHdl
=GetHdl(i
);
2100 bRotateShear
=sal_False
;
2101 bDistortShear
=sal_False
;
2104 void SdrHdlList::Sort()
2106 // remember currently focused handle
2107 SdrHdl
* pPrev
= GetFocusHdl();
2109 ImpSdrHdlListSorter
aSort(aList
);
2112 // get now and compare
2113 SdrHdl
* pNow
= GetFocusHdl();
2130 sal_uIntPtr
SdrHdlList::GetHdlNum(const SdrHdl
* pHdl
) const
2133 return CONTAINER_ENTRY_NOTFOUND
;
2134 sal_uIntPtr nPos
=aList
.GetPos(pHdl
);
2138 void SdrHdlList::AddHdl(SdrHdl
* pHdl
, sal_Bool bAtBegin
)
2144 aList
.Insert(pHdl
,sal_uIntPtr(0));
2148 aList
.Insert(pHdl
,CONTAINER_APPEND
);
2150 pHdl
->SetHdlList(this);
2154 SdrHdl
* SdrHdlList::IsHdlListHit(const Point
& rPnt
, sal_Bool bBack
, sal_Bool bNext
, SdrHdl
* pHdl0
) const
2157 sal_uIntPtr nAnz
=GetHdlCount();
2158 sal_uIntPtr nNum
=bBack
? 0 : nAnz
;
2159 while ((bBack
? nNum
<nAnz
: nNum
>0) && pRet
==NULL
)
2163 SdrHdl
* pHdl
=GetHdl(nNum
);
2171 if (pHdl
->IsHdlHit(rPnt
))
2180 SdrHdl
* SdrHdlList::GetHdl(SdrHdlKind eKind1
) const
2183 for (sal_uIntPtr i
=0; i
<GetHdlCount() && pRet
==NULL
; i
++)
2185 SdrHdl
* pHdl
=GetHdl(i
);
2186 if (pHdl
->GetKind()==eKind1
)
2192 // --------------------------------------------------------------------
2194 // --------------------------------------------------------------------
2196 SdrCropHdl::SdrCropHdl(const Point
& rPnt
, SdrHdlKind eNewKind
)
2197 : SdrHdl( rPnt
, eNewKind
)
2201 // --------------------------------------------------------------------
2203 BitmapEx
SdrCropHdl::GetHandlesBitmap()
2205 static BitmapEx
* pModernBitmap
= 0;
2206 if( pModernBitmap
== 0 )
2207 pModernBitmap
= new BitmapEx(ResId(SIP_SA_CROP_MARKERS
, *ImpGetResMgr()));
2208 return *pModernBitmap
;
2211 // --------------------------------------------------------------------
2213 BitmapEx
SdrCropHdl::GetBitmapForHandle( const BitmapEx
& rBitmap
, int nSize
)
2215 int nPixelSize
= 0, nX
= 0, nY
= 0, nOffset
= 0;
2222 else if( nSize
<=4 )
2235 case HDL_UPLFT
: nX
= 0; nY
= 0; break;
2236 case HDL_UPPER
: nX
= 1; nY
= 0; break;
2237 case HDL_UPRGT
: nX
= 2; nY
= 0; break;
2238 case HDL_LEFT
: nX
= 0; nY
= 1; break;
2239 case HDL_RIGHT
: nX
= 2; nY
= 1; break;
2240 case HDL_LWLFT
: nX
= 0; nY
= 2; break;
2241 case HDL_LOWER
: nX
= 1; nY
= 2; break;
2242 case HDL_LWRGT
: nX
= 2; nY
= 2; break;
2246 Rectangle
aSourceRect( Point( nX
* (nPixelSize
) + nOffset
, nY
* (nPixelSize
)), Size(nPixelSize
, nPixelSize
) );
2248 BitmapEx
aRetval(rBitmap
);
2249 aRetval
.Crop(aSourceRect
);
2253 // --------------------------------------------------------------------
2255 void SdrCropHdl::CreateB2dIAObject()
2257 // first throw away old one
2260 SdrMarkView
* pView
= pHdlList
? pHdlList
->GetView() : 0;
2261 SdrPageView
* pPageView
= pView
? pView
->GetSdrPageView() : 0;
2263 if( pPageView
&& !pView
->areMarkHandlesHidden() )
2265 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
2266 int nHdlSize
= pHdlList
->GetHdlSize();
2268 const BitmapEx
aHandlesBitmap( GetHandlesBitmap() );
2269 BitmapEx
aBmpEx1( GetBitmapForHandle( aHandlesBitmap
, nHdlSize
) );
2271 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
2273 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
2275 if(rPageWindow
.GetPaintWindow().OutputToWindow())
2277 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
2280 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
2282 ::sdr::overlay::OverlayObject
* pOverlayObject
= 0L;
2284 // animate focused handles
2285 if(IsFocusHdl() && (pHdlList
->GetFocusHdl() == this))
2290 BitmapEx
aBmpEx2( GetBitmapForHandle( aHandlesBitmap
, nHdlSize
+ 1 ) );
2292 const sal_uInt32 nBlinkTime
= sal::static_int_cast
<sal_uInt32
>(rStyleSettings
.GetCursorBlinkTime());
2294 pOverlayObject
= new ::sdr::overlay::OverlayAnimatedBitmapEx(aPosition
, aBmpEx1
, aBmpEx2
, nBlinkTime
,
2295 (sal_uInt16
)(aBmpEx1
.GetSizePixel().Width() - 1) >> 1,
2296 (sal_uInt16
)(aBmpEx1
.GetSizePixel().Height() - 1) >> 1,
2297 (sal_uInt16
)(aBmpEx2
.GetSizePixel().Width() - 1) >> 1,
2298 (sal_uInt16
)(aBmpEx2
.GetSizePixel().Height() - 1) >> 1);
2302 // create centered handle as default
2303 pOverlayObject
= new ::sdr::overlay::OverlayBitmapEx(aPosition
, aBmpEx1
,
2304 (sal_uInt16
)(aBmpEx1
.GetSizePixel().Width() - 1) >> 1,
2305 (sal_uInt16
)(aBmpEx1
.GetSizePixel().Height() - 1) >> 1);
2311 xManager
->add(*pOverlayObject
);
2312 maOverlayGroup
.append(*pOverlayObject
);
2320 // --------------------------------------------------------------------
2322 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */