1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include <svx/svdhdl.hxx>
24 #include <svx/svdpagv.hxx>
25 #include <svx/svdetc.hxx>
26 #include <svx/svdmrkv.hxx>
27 #include <vcl/window.hxx>
29 #include <vcl/virdev.hxx>
30 #include <tools/poly.hxx>
31 #include <vcl/bmpacc.hxx>
33 #include <svx/sxekitm.hxx>
34 #include "svx/svdstr.hrc"
35 #include "svx/svdglob.hxx"
37 #include <svx/svdmodel.hxx>
38 #include "gradtrns.hxx"
39 #include <svx/xflgrit.hxx>
40 #include <svx/svdundo.hxx>
41 #include <svx/dialmgr.hxx>
42 #include <svx/xflftrit.hxx>
45 #include <svx/svdopath.hxx>
46 #include <basegfx/vector/b2dvector.hxx>
47 #include <basegfx/polygon/b2dpolygon.hxx>
48 #include <svx/sdr/overlay/overlaymanager.hxx>
49 #include <svx/sdr/overlay/overlayanimatedbitmapex.hxx>
50 #include <svx/sdr/overlay/overlaybitmapex.hxx>
51 #include <svx/sdr/overlay/overlayline.hxx>
52 #include <svx/sdr/overlay/overlaytriangle.hxx>
53 #include <svx/sdr/overlay/overlayhatchrect.hxx>
54 #include <svx/sdrpagewindow.hxx>
55 #include <svx/sdrpaintwindow.hxx>
56 #include <vcl/svapp.hxx>
57 #include <svx/sdr/overlay/overlaypolypolygon.hxx>
58 #include <vcl/lazydelete.hxx>
60 ////////////////////////////////////////////////////////////////////////////////////////////////////
62 // Due to the resource problems in Win95/98 with bitmap resources I
63 // will change this handle bitmap providing class. Old version was splitting
64 // and preparing all small handle bitmaps in device bitmap format, now this will
65 // be done on the fly. Thus, there is only one big bitmap in memory. With
66 // three source bitmaps, this will be 3 system bitmap resources instead of hundreds.
67 // The price for that needs to be evaluated. Maybe we will need another change here
68 // if this is too expensive.
71 // the bitmap holding all information
72 BitmapEx maMarkersBitmap
;
74 // the cropped Bitmaps for reusage
75 ::std::vector
< BitmapEx
> maRealMarkers
;
78 BitmapEx
& impGetOrCreateTargetBitmap(sal_uInt16 nIndex
, const Rectangle
& rRectangle
);
81 SdrHdlBitmapSet(sal_uInt16 nResId
);
84 const BitmapEx
& GetBitmapEx(BitmapMarkerKind eKindOfMarker
, sal_uInt16 nInd
=0);
87 ////////////////////////////////////////////////////////////////////////////////////////////////////
88 #define KIND_COUNT (14)
89 #define INDEX_COUNT (6)
90 #define INDIVIDUAL_COUNT (5)
92 SdrHdlBitmapSet::SdrHdlBitmapSet(sal_uInt16 nResId
)
93 : maMarkersBitmap(ResId(nResId
, *ImpGetResMgr())),
94 // 15 kinds (BitmapMarkerKind) use index [0..5] + 5 extra
95 maRealMarkers((KIND_COUNT
* INDEX_COUNT
) + INDIVIDUAL_COUNT
)
99 SdrHdlBitmapSet::~SdrHdlBitmapSet()
103 BitmapEx
& SdrHdlBitmapSet::impGetOrCreateTargetBitmap(sal_uInt16 nIndex
, const Rectangle
& rRectangle
)
105 BitmapEx
& rTargetBitmap
= maRealMarkers
[nIndex
];
107 if(rTargetBitmap
.IsEmpty())
109 rTargetBitmap
= maMarkersBitmap
;
110 rTargetBitmap
.Crop(rRectangle
);
113 return rTargetBitmap
;
116 // change getting of bitmap to use the big resource bitmap
117 const BitmapEx
& SdrHdlBitmapSet::GetBitmapEx(BitmapMarkerKind eKindOfMarker
, sal_uInt16 nInd
)
119 // fill in size and source position in maMarkersBitmap
120 const sal_uInt16
nYPos(nInd
* 11);
122 switch(eKindOfMarker
)
126 OSL_FAIL( "Unknown kind of marker." );
127 // no break here, return Rect_9x9 as default
131 return impGetOrCreateTargetBitmap((1 * INDEX_COUNT
) + nInd
, Rectangle(Point(7, nYPos
), Size(9, 9)));
136 return impGetOrCreateTargetBitmap((0 * INDEX_COUNT
) + nInd
, Rectangle(Point(0, nYPos
), Size(7, 7)));
141 return impGetOrCreateTargetBitmap((2 * INDEX_COUNT
) + nInd
, Rectangle(Point(16, nYPos
), Size(11, 11)));
146 const sal_uInt16
nIndex((3 * INDEX_COUNT
) + nInd
);
152 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(72, 66), Size(13, 13)));
156 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(85, 66), Size(13, 13)));
160 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(72, 79), Size(13, 13)));
164 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(85, 79), Size(13, 13)));
168 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(98, 79), Size(13, 13)));
172 return impGetOrCreateTargetBitmap(nIndex
, Rectangle(Point(98, 66), Size(13, 13)));
179 return impGetOrCreateTargetBitmap((4 * INDEX_COUNT
) + nInd
, Rectangle(Point(27, nYPos
), Size(7, 7)));
185 return impGetOrCreateTargetBitmap((5 * INDEX_COUNT
) + nInd
, Rectangle(Point(34, nYPos
), Size(9, 9)));
190 return impGetOrCreateTargetBitmap((6 * INDEX_COUNT
) + nInd
, Rectangle(Point(43, nYPos
), Size(11, 11)));
195 return impGetOrCreateTargetBitmap((7 * INDEX_COUNT
) + nInd
, Rectangle(Point(54, nYPos
), Size(7, 9)));
200 return impGetOrCreateTargetBitmap((8 * INDEX_COUNT
) + nInd
, Rectangle(Point(61, nYPos
), Size(9, 11)));
205 return impGetOrCreateTargetBitmap((9 * INDEX_COUNT
) + nInd
, Rectangle(Point(70, nYPos
), Size(9, 7)));
210 return impGetOrCreateTargetBitmap((10 * INDEX_COUNT
) + nInd
, Rectangle(Point(79, nYPos
), Size(11, 9)));
215 return impGetOrCreateTargetBitmap((11 * INDEX_COUNT
) + nInd
, Rectangle(Point(90, nYPos
), Size(7, 7)));
220 return impGetOrCreateTargetBitmap((12 * INDEX_COUNT
) + nInd
, Rectangle(Point(97, nYPos
), Size(9, 9)));
225 return impGetOrCreateTargetBitmap((13 * INDEX_COUNT
) + nInd
, Rectangle(Point(106, nYPos
), Size(11, 11)));
230 return impGetOrCreateTargetBitmap((KIND_COUNT
* INDEX_COUNT
) + 0, Rectangle(Point(0, 68), Size(15, 15)));
235 return impGetOrCreateTargetBitmap((KIND_COUNT
* INDEX_COUNT
) + 1, Rectangle(Point(15, 76), Size(9, 9)));
238 case Glue_Deselected
:
240 return impGetOrCreateTargetBitmap((KIND_COUNT
* INDEX_COUNT
) + 2, Rectangle(Point(15, 67), Size(9, 9)));
243 case Anchor
: // AnchorTR for SW
246 return impGetOrCreateTargetBitmap((KIND_COUNT
* INDEX_COUNT
) + 3, Rectangle(Point(24, 67), Size(24, 24)));
249 // add AnchorPressed to be able to animate anchor control
251 case AnchorPressedTR
:
253 return impGetOrCreateTargetBitmap((KIND_COUNT
* INDEX_COUNT
) + 4, Rectangle(Point(48, 67), Size(24, 24)));
258 ////////////////////////////////////////////////////////////////////////////////////////////////////
271 b1PixMore(sal_False
),
273 mbMoveOutside(false),
278 SdrHdl::SdrHdl(const Point
& rPnt
, SdrHdlKind eNewKind
):
290 b1PixMore(sal_False
),
292 mbMoveOutside(false),
302 void SdrHdl::Set1PixMore(sal_Bool bJa
)
308 // create new display
313 void SdrHdl::SetMoveOutside( bool bMoveOutside
)
315 if(mbMoveOutside
!= bMoveOutside
)
317 mbMoveOutside
= bMoveOutside
;
319 // create new display
324 void SdrHdl::SetDrehWink(long n
)
330 // create new display
335 void SdrHdl::SetPos(const Point
& rPnt
)
339 // remember new position
342 // create new display
347 void SdrHdl::SetSelected(sal_Bool bJa
)
351 // remember new value
354 // create new display
359 void SdrHdl::SetHdlList(SdrHdlList
* pList
)
361 if(pHdlList
!= pList
)
366 // now its possible to create graphic representation
371 void SdrHdl::SetObj(SdrObject
* pNewObj
)
375 // remember new object
378 // graphic representation may have changed
385 // force update of graphic representation
389 void SdrHdl::GetRidOfIAObject()
393 maOverlayGroup
.clear();
396 void SdrHdl::CreateB2dIAObject()
398 // first throw away old one
401 if(pHdlList
&& pHdlList
->GetView() && !pHdlList
->GetView()->areMarkHandlesHidden())
403 BitmapColorIndex eColIndex
= LightGreen
;
404 BitmapMarkerKind eKindOfMarker
= Rect_7x7
;
406 sal_Bool bRot
= pHdlList
->IsRotateShear();
408 eColIndex
= (bSelect
) ? Cyan
: LightCyan
;
411 // red rotation handles
415 eColIndex
= LightRed
;
422 eKindOfMarker
= (b1PixMore
) ? Rect_9x9
: Rect_7x7
;
433 eKindOfMarker
= Circ_7x7
;
437 eKindOfMarker
= Rect_7x7
;
444 // Upper/Lower handles
447 eKindOfMarker
= Elli_9x7
;
451 eKindOfMarker
= Rect_7x7
;
458 // Left/Right handles
461 eKindOfMarker
= Elli_7x9
;
465 eKindOfMarker
= Rect_7x7
;
473 eKindOfMarker
= (b1PixMore
) ? Circ_9x9
: Circ_7x7
;
477 eKindOfMarker
= (b1PixMore
) ? Rect_9x9
: Rect_7x7
;
481 case HDL_BWGT
: // weight at poly
483 eKindOfMarker
= Circ_7x7
;
488 eKindOfMarker
= Rect_11x11
;
494 eKindOfMarker
= Crosshair
;
499 eKindOfMarker
= Glue
;
502 case HDL_GLUE_DESELECTED
:
504 eKindOfMarker
= Glue_Deselected
;
509 eKindOfMarker
= Anchor
;
516 // top right anchor for SW
519 eKindOfMarker
= AnchorTR
;
523 // for SJ and the CustomShapeHandles:
524 case HDL_CUSTOMSHAPE1
:
526 eKindOfMarker
= Customshape1
;
534 SdrMarkView
* pView
= pHdlList
->GetView();
535 SdrPageView
* pPageView
= pView
->GetSdrPageView();
539 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
541 // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
542 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
544 if(rPageWindow
.GetPaintWindow().OutputToWindow())
546 Point
aMoveOutsideOffset(0, 0);
548 // add offset if necessary
549 if(pHdlList
->IsMoveOutside() || mbMoveOutside
)
551 OutputDevice
& rOutDev
= rPageWindow
.GetPaintWindow().GetOutputDevice();
552 Size aOffset
= rOutDev
.PixelToLogic(Size(4, 4));
554 if(eKind
== HDL_UPLFT
|| eKind
== HDL_UPPER
|| eKind
== HDL_UPRGT
)
555 aMoveOutsideOffset
.Y() -= aOffset
.Width();
556 if(eKind
== HDL_LWLFT
|| eKind
== HDL_LOWER
|| eKind
== HDL_LWRGT
)
557 aMoveOutsideOffset
.Y() += aOffset
.Height();
558 if(eKind
== HDL_UPLFT
|| eKind
== HDL_LEFT
|| eKind
== HDL_LWLFT
)
559 aMoveOutsideOffset
.X() -= aOffset
.Width();
560 if(eKind
== HDL_UPRGT
|| eKind
== HDL_RIGHT
|| eKind
== HDL_LWRGT
)
561 aMoveOutsideOffset
.X() += aOffset
.Height();
564 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
567 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
568 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= CreateOverlayObject(
575 if(pNewOverlayObject
)
577 xManager
->add(*pNewOverlayObject
);
578 maOverlayGroup
.append(*pNewOverlayObject
);
587 BitmapMarkerKind
SdrHdl::GetNextBigger(BitmapMarkerKind eKnd
) const
589 BitmapMarkerKind
eRetval(eKnd
);
593 case Rect_7x7
: eRetval
= Rect_9x9
; break;
594 case Rect_9x9
: eRetval
= Rect_11x11
; break;
595 case Rect_11x11
: eRetval
= Rect_13x13
; break;
597 case Circ_7x7
: eRetval
= Circ_9x9
; break;
598 case Circ_9x9
: eRetval
= Circ_11x11
; break;
600 case Elli_7x9
: eRetval
= Elli_9x11
; break;
602 case Elli_9x7
: eRetval
= Elli_11x9
; break;
604 case RectPlus_7x7
: eRetval
= RectPlus_9x9
; break;
605 case RectPlus_9x9
: eRetval
= RectPlus_11x11
; break;
607 // let anchor blink with its pressed state
608 case Anchor
: eRetval
= AnchorPressed
; break;
611 case AnchorTR
: eRetval
= AnchorPressedTR
; break;
619 BitmapEx
SdrHdl::ImpGetBitmapEx( BitmapMarkerKind eKindOfMarker
, sal_uInt16 nInd
)
621 static vcl::DeleteOnDeinit
< SdrHdlBitmapSet
> aModernSet(new SdrHdlBitmapSet(SIP_SA_MARKERS
));
622 return aModernSet
.get()->GetBitmapEx(eKindOfMarker
, nInd
);
625 ::sdr::overlay::OverlayObject
* SdrHdl::CreateOverlayObject(
626 const basegfx::B2DPoint
& rPos
,
627 BitmapColorIndex eColIndex
, BitmapMarkerKind eKindOfMarker
, Point aMoveOutsideOffset
)
629 ::sdr::overlay::OverlayObject
* pRetval
= 0L;
631 // support bigger sizes
632 bool bForceBiggerSize(false);
634 if(pHdlList
->GetHdlSize() > 3)
636 bForceBiggerSize
= true;
641 eKindOfMarker
= GetNextBigger(eKindOfMarker
);
644 // This handle has the focus, visualize it
645 if(IsFocusHdl() && pHdlList
&& pHdlList
->GetFocusHdl() == this)
647 // create animated handle
648 BitmapMarkerKind eNextBigger
= GetNextBigger(eKindOfMarker
);
650 if(eNextBigger
== eKindOfMarker
)
652 // this may happen for the not supported getting-bigger types.
653 // Choose an alternative here
654 switch(eKindOfMarker
)
656 case Rect_13x13
: eNextBigger
= Rect_11x11
; break;
657 case Circ_11x11
: eNextBigger
= Elli_11x9
; break;
658 case Elli_9x11
: eNextBigger
= Elli_11x9
; break;
659 case Elli_11x9
: eNextBigger
= Elli_9x11
; break;
660 case RectPlus_11x11
: eNextBigger
= Rect_13x13
; break;
667 eNextBigger
= Crosshair
;
669 case Glue_Deselected
:
677 // create animated handle
678 BitmapEx aBmpEx1
= ImpGetBitmapEx( eKindOfMarker
, (sal_uInt16
)eColIndex
);
679 BitmapEx aBmpEx2
= ImpGetBitmapEx( eNextBigger
, (sal_uInt16
)eColIndex
);
681 // #i53216# Use system cursor blink time. Use the unsigned value.
682 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
683 const sal_uInt32
nBlinkTime((sal_uInt32
)rStyleSettings
.GetCursorBlinkTime());
685 if(eKindOfMarker
== Anchor
|| eKindOfMarker
== AnchorPressed
)
687 // when anchor is used take upper left as reference point inside the handle
688 pRetval
= new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos
, aBmpEx1
, aBmpEx2
, nBlinkTime
);
690 else if(eKindOfMarker
== AnchorTR
|| eKindOfMarker
== AnchorPressedTR
)
692 // AnchorTR for SW, take top right as (0,0)
693 pRetval
= new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos
, aBmpEx1
, aBmpEx2
, nBlinkTime
,
694 (sal_uInt16
)(aBmpEx1
.GetSizePixel().Width() - 1), 0,
695 (sal_uInt16
)(aBmpEx2
.GetSizePixel().Width() - 1), 0);
699 // create centered handle as default
700 pRetval
= new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos
, aBmpEx1
, aBmpEx2
, nBlinkTime
,
701 (sal_uInt16
)(aBmpEx1
.GetSizePixel().Width() - 1) >> 1,
702 (sal_uInt16
)(aBmpEx1
.GetSizePixel().Height() - 1) >> 1,
703 (sal_uInt16
)(aBmpEx2
.GetSizePixel().Width() - 1) >> 1,
704 (sal_uInt16
)(aBmpEx2
.GetSizePixel().Height() - 1) >> 1);
709 // create normal handle: use ImpGetBitmapEx(...) now
710 BitmapEx aBmpEx
= ImpGetBitmapEx(eKindOfMarker
, (sal_uInt16
)eColIndex
);
712 if(eKindOfMarker
== Anchor
|| eKindOfMarker
== AnchorPressed
)
714 // upper left as reference point inside the handle for AnchorPressed, too
715 pRetval
= new ::sdr::overlay::OverlayBitmapEx(rPos
, aBmpEx
);
717 else if(eKindOfMarker
== AnchorTR
|| eKindOfMarker
== AnchorPressedTR
)
719 // AnchorTR for SW, take top right as (0,0)
720 pRetval
= new ::sdr::overlay::OverlayBitmapEx(rPos
, aBmpEx
,
721 (sal_uInt16
)(aBmpEx
.GetSizePixel().Width() - 1), 0);
725 sal_uInt16
nCenX((sal_uInt16
)(aBmpEx
.GetSizePixel().Width() - 1L) >> 1);
726 sal_uInt16
nCenY((sal_uInt16
)(aBmpEx
.GetSizePixel().Height() - 1L) >> 1);
728 if(aMoveOutsideOffset
.X() > 0)
732 else if(aMoveOutsideOffset
.X() < 0)
734 nCenX
= (sal_uInt16
)(aBmpEx
.GetSizePixel().Width() - 1);
737 if(aMoveOutsideOffset
.Y() > 0)
741 else if(aMoveOutsideOffset
.Y() < 0)
743 nCenY
= (sal_uInt16
)(aBmpEx
.GetSizePixel().Height() - 1);
746 // create centered handle as default
747 pRetval
= new ::sdr::overlay::OverlayBitmapEx(rPos
, aBmpEx
, nCenX
, nCenY
);
754 bool SdrHdl::IsHdlHit(const Point
& rPnt
) const
757 basegfx::B2DPoint
aPosition(rPnt
.X(), rPnt
.Y());
758 return maOverlayGroup
.isHitLogic(aPosition
);
761 Pointer
SdrHdl::GetPointer() const
763 PointerStyle ePtr
=POINTER_MOVE
;
764 const bool bSize
=eKind
>=HDL_UPLFT
&& eKind
<=HDL_LWRGT
;
765 const bool bRot
=pHdlList
!=NULL
&& pHdlList
->IsRotateShear();
766 const bool bDis
=pHdlList
!=NULL
&& pHdlList
->IsDistortShear();
767 if (bSize
&& pHdlList
!=NULL
&& (bRot
|| bDis
)) {
769 case HDL_UPLFT
: case HDL_UPRGT
:
770 case HDL_LWLFT
: case HDL_LWRGT
: ePtr
=bRot
? POINTER_ROTATE
: POINTER_REFHAND
; break;
771 case HDL_LEFT
: case HDL_RIGHT
: ePtr
=POINTER_VSHEAR
; break;
772 case HDL_UPPER
: case HDL_LOWER
: ePtr
=POINTER_HSHEAR
; break;
777 // When resizing rotated rectangles, rotate the mouse cursor slightly, too
778 if (bSize
&& nDrehWink
!=0) {
781 case HDL_LWRGT
: nHdlWink
=31500; break;
782 case HDL_LOWER
: nHdlWink
=27000; break;
783 case HDL_LWLFT
: nHdlWink
=22500; break;
784 case HDL_LEFT
: nHdlWink
=18000; break;
785 case HDL_UPLFT
: nHdlWink
=13500; break;
786 case HDL_UPPER
: nHdlWink
=9000; break;
787 case HDL_UPRGT
: nHdlWink
=4500; break;
788 case HDL_RIGHT
: nHdlWink
=0; break;
792 nHdlWink
+=nDrehWink
+2249; // a little bit more (for rounding)
793 while (nHdlWink
<0) nHdlWink
+=36000;
794 while (nHdlWink
>=36000) nHdlWink
-=36000;
796 switch ((sal_uInt8
)nHdlWink
) {
797 case 0: ePtr
=POINTER_ESIZE
; break;
798 case 1: ePtr
=POINTER_NESIZE
; break;
799 case 2: ePtr
=POINTER_NSIZE
; break;
800 case 3: ePtr
=POINTER_NWSIZE
; break;
801 case 4: ePtr
=POINTER_WSIZE
; break;
802 case 5: ePtr
=POINTER_SWSIZE
; break;
803 case 6: ePtr
=POINTER_SSIZE
; break;
804 case 7: ePtr
=POINTER_SESIZE
; break;
808 case HDL_UPLFT
: ePtr
=POINTER_NWSIZE
; break;
809 case HDL_UPPER
: ePtr
=POINTER_NSIZE
; break;
810 case HDL_UPRGT
: ePtr
=POINTER_NESIZE
; break;
811 case HDL_LEFT
: ePtr
=POINTER_WSIZE
; break;
812 case HDL_RIGHT
: ePtr
=POINTER_ESIZE
; break;
813 case HDL_LWLFT
: ePtr
=POINTER_SWSIZE
; break;
814 case HDL_LOWER
: ePtr
=POINTER_SSIZE
; break;
815 case HDL_LWRGT
: ePtr
=POINTER_SESIZE
; break;
816 case HDL_POLY
: ePtr
=POINTER_MOVEPOINT
; break;
817 case HDL_CIRC
: ePtr
=POINTER_HAND
; break;
818 case HDL_REF1
: ePtr
=POINTER_REFHAND
; break;
819 case HDL_REF2
: ePtr
=POINTER_REFHAND
; break;
820 case HDL_BWGT
: ePtr
=POINTER_MOVEBEZIERWEIGHT
; break;
821 case HDL_GLUE
: ePtr
=POINTER_MOVEPOINT
; break;
822 case HDL_GLUE_DESELECTED
: ePtr
=POINTER_MOVEPOINT
; break;
823 case HDL_CUSTOMSHAPE1
: ePtr
=POINTER_HAND
; break;
829 return Pointer(ePtr
);
832 sal_Bool
SdrHdl::IsFocusHdl() const
845 // if it's an activated TextEdit, it's moved to extended points
846 if(pHdlList
&& pHdlList
->IsMoveOutside())
852 case HDL_MOVE
: // handle to move object
853 case HDL_POLY
: // selected point of polygon or curve
854 case HDL_BWGT
: // weight at a curve
855 case HDL_CIRC
: // angle of circle segments, corner radius of rectangles
856 case HDL_REF1
: // reference point 1, e. g. center of rotation
857 case HDL_REF2
: // reference point 2, e. g. endpoint of reflection axis
858 case HDL_GLUE
: // glue point
859 case HDL_GLUE_DESELECTED
: // deselected glue point, used to be a little blue cross
861 // for SJ and the CustomShapeHandles:
862 case HDL_CUSTOMSHAPE1
:
876 void SdrHdl::onMouseEnter(const MouseEvent
& /*rMEvt*/)
880 void SdrHdl::onMouseLeave()
884 ////////////////////////////////////////////////////////////////////////////////////////////////////
887 SdrHdlColor::SdrHdlColor(const Point
& rRef
, Color aCol
, const Size
& rSize
, sal_Bool bLum
)
888 : SdrHdl(rRef
, HDL_COLR
),
893 aCol
= GetLuminance(aCol
);
899 SdrHdlColor::~SdrHdlColor()
903 void SdrHdlColor::CreateB2dIAObject()
905 // first throw away old one
910 SdrMarkView
* pView
= pHdlList
->GetView();
912 if(pView
&& !pView
->areMarkHandlesHidden())
914 SdrPageView
* pPageView
= pView
->GetSdrPageView();
918 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
920 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
922 if(rPageWindow
.GetPaintWindow().OutputToWindow())
924 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
927 Bitmap
aBmpCol(CreateColorDropper(aMarkerColor
));
928 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
929 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
930 ::sdr::overlay::OverlayBitmapEx(
933 (sal_uInt16
)(aBmpCol
.GetSizePixel().Width() - 1) >> 1,
934 (sal_uInt16
)(aBmpCol
.GetSizePixel().Height() - 1) >> 1
936 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
939 if(pNewOverlayObject
)
941 xManager
->add(*pNewOverlayObject
);
942 maOverlayGroup
.append(*pNewOverlayObject
);
952 Bitmap
SdrHdlColor::CreateColorDropper(Color aCol
)
955 Bitmap
aRetval(aMarkerSize
, 24);
959 BitmapWriteAccess
* pWrite
= aRetval
.AcquireWriteAccess();
960 DBG_ASSERT(pWrite
, "Got NO write access to a new Bitmap!");
965 sal_Int32 nWidth
= aMarkerSize
.Width();
966 sal_Int32 nHeight
= aMarkerSize
.Height();
968 pWrite
->SetLineColor(Color(COL_LIGHTGRAY
));
969 pWrite
->DrawLine(Point(0, 0), Point(0, nHeight
- 1));
970 pWrite
->DrawLine(Point(1, 0), Point(nWidth
- 1, 0));
971 pWrite
->SetLineColor(Color(COL_GRAY
));
972 pWrite
->DrawLine(Point(1, nHeight
- 1), Point(nWidth
- 1, nHeight
- 1));
973 pWrite
->DrawLine(Point(nWidth
- 1, 1), Point(nWidth
- 1, nHeight
- 2));
975 // draw lighter UpperLeft
976 const Color
aLightColor(
977 (sal_uInt8
)(::std::min((sal_Int16
)((sal_Int16
)aCol
.GetRed() + (sal_Int16
)0x0040), (sal_Int16
)0x00ff)),
978 (sal_uInt8
)(::std::min((sal_Int16
)((sal_Int16
)aCol
.GetGreen() + (sal_Int16
)0x0040), (sal_Int16
)0x00ff)),
979 (sal_uInt8
)(::std::min((sal_Int16
)((sal_Int16
)aCol
.GetBlue() + (sal_Int16
)0x0040), (sal_Int16
)0x00ff)));
980 pWrite
->SetLineColor(aLightColor
);
981 pWrite
->DrawLine(Point(1, 1), Point(1, nHeight
- 2));
982 pWrite
->DrawLine(Point(2, 1), Point(nWidth
- 2, 1));
984 // draw darker LowerRight
985 const Color
aDarkColor(
986 (sal_uInt8
)(::std::max((sal_Int16
)((sal_Int16
)aCol
.GetRed() - (sal_Int16
)0x0040), (sal_Int16
)0x0000)),
987 (sal_uInt8
)(::std::max((sal_Int16
)((sal_Int16
)aCol
.GetGreen() - (sal_Int16
)0x0040), (sal_Int16
)0x0000)),
988 (sal_uInt8
)(::std::max((sal_Int16
)((sal_Int16
)aCol
.GetBlue() - (sal_Int16
)0x0040), (sal_Int16
)0x0000)));
989 pWrite
->SetLineColor(aDarkColor
);
990 pWrite
->DrawLine(Point(2, nHeight
- 2), Point(nWidth
- 2, nHeight
- 2));
991 pWrite
->DrawLine(Point(nWidth
- 2, 2), Point(nWidth
- 2, nHeight
- 3));
993 // get rid of write access
1000 Color
SdrHdlColor::GetLuminance(const Color
& rCol
)
1002 sal_uInt8 aLum
= rCol
.GetLuminance();
1003 Color
aRetval(aLum
, aLum
, aLum
);
1007 void SdrHdlColor::CallColorChangeLink()
1009 aColorChangeHdl
.Call(this);
1012 void SdrHdlColor::SetColor(Color aNew
, sal_Bool bCallLink
)
1014 if(IsUseLuminance())
1015 aNew
= GetLuminance(aNew
);
1017 if(aMarkerColor
!= aNew
)
1019 // remember new color
1020 aMarkerColor
= aNew
;
1022 // create new display
1025 // tell about change
1027 CallColorChangeLink();
1031 void SdrHdlColor::SetSize(const Size
& rNew
)
1033 if(rNew
!= aMarkerSize
)
1035 // remember new size
1038 // create new display
1043 ////////////////////////////////////////////////////////////////////////////////////////////////////
1044 // class SdrHdlGradient
1046 SdrHdlGradient::SdrHdlGradient(const Point
& rRef1
, const Point
& rRef2
, sal_Bool bGrad
)
1047 : SdrHdl(rRef1
, bGrad
? HDL_GRAD
: HDL_TRNS
),
1055 SdrHdlGradient::~SdrHdlGradient()
1059 void SdrHdlGradient::Set2ndPos(const Point
& rPnt
)
1063 // remember new position
1066 // create new display
1071 void SdrHdlGradient::CreateB2dIAObject()
1073 // first throw away old one
1078 SdrMarkView
* pView
= pHdlList
->GetView();
1080 if(pView
&& !pView
->areMarkHandlesHidden())
1082 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1086 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1088 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1090 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1092 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1095 // striped line in between
1096 basegfx::B2DVector
aVec(a2ndPos
.X() - aPos
.X(), a2ndPos
.Y() - aPos
.Y());
1097 double fVecLen
= aVec
.getLength();
1098 double fLongPercentArrow
= (1.0 - 0.05) * fVecLen
;
1099 double fHalfArrowWidth
= (0.05 * 0.5) * fVecLen
;
1101 basegfx::B2DVector
aPerpend(-aVec
.getY(), aVec
.getX());
1102 sal_Int32 nMidX
= (sal_Int32
)(aPos
.X() + aVec
.getX() * fLongPercentArrow
);
1103 sal_Int32 nMidY
= (sal_Int32
)(aPos
.Y() + aVec
.getY() * fLongPercentArrow
);
1104 Point
aMidPoint(nMidX
, nMidY
);
1106 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
1107 basegfx::B2DPoint
aMidPos(aMidPoint
.X(), aMidPoint
.Y());
1109 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
1110 ::sdr::overlay::OverlayLineStriped(
1113 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1115 pNewOverlayObject
->setBaseColor(IsGradient() ? Color(COL_BLACK
) : Color(COL_BLUE
));
1116 xManager
->add(*pNewOverlayObject
);
1117 maOverlayGroup
.append(*pNewOverlayObject
);
1120 Point
aLeft(aMidPoint
.X() + (sal_Int32
)(aPerpend
.getX() * fHalfArrowWidth
),
1121 aMidPoint
.Y() + (sal_Int32
)(aPerpend
.getY() * fHalfArrowWidth
));
1122 Point
aRight(aMidPoint
.X() - (sal_Int32
)(aPerpend
.getX() * fHalfArrowWidth
),
1123 aMidPoint
.Y() - (sal_Int32
)(aPerpend
.getY() * fHalfArrowWidth
));
1125 basegfx::B2DPoint
aPositionLeft(aLeft
.X(), aLeft
.Y());
1126 basegfx::B2DPoint
aPositionRight(aRight
.X(), aRight
.Y());
1127 basegfx::B2DPoint
aPosition2(a2ndPos
.X(), a2ndPos
.Y());
1129 pNewOverlayObject
= new
1130 ::sdr::overlay::OverlayTriangle(
1134 IsGradient() ? Color(COL_BLACK
) : Color(COL_BLUE
)
1136 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1138 xManager
->add(*pNewOverlayObject
);
1139 maOverlayGroup
.append(*pNewOverlayObject
);
1148 IMPL_LINK(SdrHdlGradient
, ColorChangeHdl
, SdrHdl
*, /*pHdl*/)
1151 FromIAOToItem(GetObj(), sal_True
, sal_True
);
1155 void SdrHdlGradient::FromIAOToItem(SdrObject
* _pObj
, sal_Bool bSetItemOnObject
, sal_Bool bUndo
)
1157 // from IAO positions and colors to gradient
1158 const SfxItemSet
& rSet
= _pObj
->GetMergedItemSet();
1160 GradTransformer aGradTransformer
;
1161 GradTransGradient aOldGradTransGradient
;
1162 GradTransGradient aGradTransGradient
;
1163 GradTransVector aGradTransVector
;
1167 aGradTransVector
.maPositionA
= basegfx::B2DPoint(GetPos().X(), GetPos().Y());
1168 aGradTransVector
.maPositionB
= basegfx::B2DPoint(Get2ndPos().X(), Get2ndPos().Y());
1170 aGradTransVector
.aCol1
= pColHdl1
->GetColor();
1172 aGradTransVector
.aCol2
= pColHdl2
->GetColor();
1175 aOldGradTransGradient
.aGradient
= ((XFillGradientItem
&)rSet
.Get(XATTR_FILLGRADIENT
)).GetGradientValue();
1177 aOldGradTransGradient
.aGradient
= ((XFillFloatTransparenceItem
&)rSet
.Get(XATTR_FILLFLOATTRANSPARENCE
)).GetGradientValue();
1179 // transform vector data to gradient
1180 aGradTransformer
.VecToGrad(aGradTransVector
, aGradTransGradient
, aOldGradTransGradient
, _pObj
, bMoveSingleHandle
, bMoveFirstHandle
);
1182 if(bSetItemOnObject
)
1184 SdrModel
* pModel
= _pObj
->GetModel();
1185 SfxItemSet
aNewSet(pModel
->GetItemPool());
1190 XFillGradientItem
aNewGradItem(aString
, aGradTransGradient
.aGradient
);
1191 aNewSet
.Put(aNewGradItem
);
1196 XFillFloatTransparenceItem
aNewTransItem(aString
, aGradTransGradient
.aGradient
);
1197 aNewSet
.Put(aNewTransItem
);
1200 if(bUndo
&& pModel
->IsUndoEnabled())
1202 pModel
->BegUndo(SVX_RESSTR(IsGradient() ? SIP_XA_FILLGRADIENT
: SIP_XA_FILLTRANSPARENCE
));
1203 pModel
->AddUndo(pModel
->GetSdrUndoFactory().CreateUndoAttrObject(*_pObj
));
1207 pObj
->SetMergedItemSetAndBroadcast(aNewSet
);
1210 // back transformation, set values on pIAOHandle
1211 aGradTransformer
.GradToVec(aGradTransGradient
, aGradTransVector
, _pObj
);
1213 SetPos(Point(FRound(aGradTransVector
.maPositionA
.getX()), FRound(aGradTransVector
.maPositionA
.getY())));
1214 Set2ndPos(Point(FRound(aGradTransVector
.maPositionB
.getX()), FRound(aGradTransVector
.maPositionB
.getY())));
1217 pColHdl1
->SetPos(Point(FRound(aGradTransVector
.maPositionA
.getX()), FRound(aGradTransVector
.maPositionA
.getY())));
1218 pColHdl1
->SetColor(aGradTransVector
.aCol1
);
1222 pColHdl2
->SetPos(Point(FRound(aGradTransVector
.maPositionB
.getX()), FRound(aGradTransVector
.maPositionB
.getY())));
1223 pColHdl2
->SetColor(aGradTransVector
.aCol2
);
1227 ////////////////////////////////////////////////////////////////////////////////////////////////////
1229 SdrHdlLine::~SdrHdlLine() {}
1231 void SdrHdlLine::CreateB2dIAObject()
1233 // first throw away old one
1238 SdrMarkView
* pView
= pHdlList
->GetView();
1240 if(pView
&& !pView
->areMarkHandlesHidden() && pHdl1
&& pHdl2
)
1242 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1246 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1248 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1250 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1252 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1255 basegfx::B2DPoint
aPosition1(pHdl1
->GetPos().X(), pHdl1
->GetPos().Y());
1256 basegfx::B2DPoint
aPosition2(pHdl2
->GetPos().X(), pHdl2
->GetPos().Y());
1258 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
1259 ::sdr::overlay::OverlayLineStriped(
1263 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1266 if(pNewOverlayObject
)
1269 pNewOverlayObject
->setBaseColor(Color(COL_LIGHTRED
));
1271 xManager
->add(*pNewOverlayObject
);
1272 maOverlayGroup
.append(*pNewOverlayObject
);
1282 Pointer
SdrHdlLine::GetPointer() const
1284 return Pointer(POINTER_REFHAND
);
1287 ////////////////////////////////////////////////////////////////////////////////////////////////////
1289 SdrHdlBezWgt::~SdrHdlBezWgt() {}
1291 void SdrHdlBezWgt::CreateB2dIAObject()
1294 SdrHdl::CreateB2dIAObject();
1299 SdrMarkView
* pView
= pHdlList
->GetView();
1301 if(pView
&& !pView
->areMarkHandlesHidden())
1303 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1307 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1309 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1311 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1313 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1316 basegfx::B2DPoint
aPosition1(pHdl1
->GetPos().X(), pHdl1
->GetPos().Y());
1317 basegfx::B2DPoint
aPosition2(aPos
.X(), aPos
.Y());
1319 if(!aPosition1
.equal(aPosition2
))
1321 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
1322 ::sdr::overlay::OverlayLineStriped(
1326 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1329 if(pNewOverlayObject
)
1331 // line part is not hittable
1332 pNewOverlayObject
->setHittable(sal_False
);
1335 pNewOverlayObject
->setBaseColor(Color(COL_LIGHTBLUE
));
1337 xManager
->add(*pNewOverlayObject
);
1338 maOverlayGroup
.append(*pNewOverlayObject
);
1349 ////////////////////////////////////////////////////////////////////////////////////////////////////
1351 E3dVolumeMarker::E3dVolumeMarker(const basegfx::B2DPolyPolygon
& rWireframePoly
)
1353 aWireframePoly
= rWireframePoly
;
1356 void E3dVolumeMarker::CreateB2dIAObject()
1361 SdrMarkView
* pView
= pHdlList
->GetView();
1363 if(pView
&& !pView
->areMarkHandlesHidden())
1365 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1369 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1371 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1373 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1375 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1376 if (xManager
.is() && aWireframePoly
.count())
1378 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= new
1379 ::sdr::overlay::OverlayPolyPolygonStriped(aWireframePoly
);
1380 DBG_ASSERT(pNewOverlayObject
, "Got NO new IAO!");
1383 if(pNewOverlayObject
)
1385 pNewOverlayObject
->setBaseColor(Color(COL_BLACK
));
1387 xManager
->add(*pNewOverlayObject
);
1388 maOverlayGroup
.append(*pNewOverlayObject
);
1398 ////////////////////////////////////////////////////////////////////////////////////////////////////
1400 ImpEdgeHdl::~ImpEdgeHdl()
1404 void ImpEdgeHdl::CreateB2dIAObject()
1406 if(nObjHdlNum
<= 1 && pObj
)
1408 // first throw away old one
1411 BitmapColorIndex eColIndex
= LightCyan
;
1412 BitmapMarkerKind eKindOfMarker
= Rect_7x7
;
1416 SdrMarkView
* pView
= pHdlList
->GetView();
1418 if(pView
&& !pView
->areMarkHandlesHidden())
1420 const SdrEdgeObj
* pEdge
= (SdrEdgeObj
*)pObj
;
1422 if(pEdge
->GetConnectedNode(nObjHdlNum
== 0) != NULL
)
1423 eColIndex
= LightRed
;
1427 // Handle with plus sign inside
1428 eKindOfMarker
= Circ_7x7
;
1431 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1435 for(sal_uInt32
b(0); b
< pPageView
->PageWindowCount(); b
++)
1437 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1439 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1441 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1444 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
1446 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= CreateOverlayObject(
1452 if(pNewOverlayObject
)
1454 xManager
->add(*pNewOverlayObject
);
1455 maOverlayGroup
.append(*pNewOverlayObject
);
1467 SdrHdl::CreateB2dIAObject();
1471 void ImpEdgeHdl::SetLineCode(SdrEdgeLineCode eCode
)
1473 if(eLineCode
!= eCode
)
1475 // remember new value
1478 // create new display
1483 Pointer
ImpEdgeHdl::GetPointer() const
1485 SdrEdgeObj
* pEdge
=PTR_CAST(SdrEdgeObj
,pObj
);
1487 return SdrHdl::GetPointer();
1489 return Pointer(POINTER_MOVEPOINT
);
1491 return Pointer(POINTER_ESIZE
);
1493 return Pointer(POINTER_SSIZE
);
1496 sal_Bool
ImpEdgeHdl::IsHorzDrag() const
1498 SdrEdgeObj
* pEdge
=PTR_CAST(SdrEdgeObj
,pObj
);
1504 SdrEdgeKind eEdgeKind
= ((SdrEdgeKindItem
&)(pEdge
->GetObjectItem(SDRATTR_EDGEKIND
))).GetValue();
1506 const SdrEdgeInfoRec
& rInfo
=pEdge
->aEdgeInfo
;
1507 if (eEdgeKind
==SDREDGE_ORTHOLINES
|| eEdgeKind
==SDREDGE_BEZIER
)
1509 return !rInfo
.ImpIsHorzLine(eLineCode
,*pEdge
->pEdgeTrack
);
1511 else if (eEdgeKind
==SDREDGE_THREELINES
)
1513 long nWink
=nObjHdlNum
==2 ? rInfo
.nAngle1
: rInfo
.nAngle2
;
1514 if (nWink
==0 || nWink
==18000)
1522 ////////////////////////////////////////////////////////////////////////////////////////////////////
1524 ImpMeasureHdl::~ImpMeasureHdl()
1528 void ImpMeasureHdl::CreateB2dIAObject()
1530 // first throw away old one
1535 SdrMarkView
* pView
= pHdlList
->GetView();
1537 if(pView
&& !pView
->areMarkHandlesHidden())
1539 BitmapColorIndex eColIndex
= LightCyan
;
1540 BitmapMarkerKind eKindOfMarker
= Rect_9x9
;
1544 eKindOfMarker
= Rect_7x7
;
1552 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1556 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1558 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1560 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1562 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1565 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
1567 ::sdr::overlay::OverlayObject
* pNewOverlayObject
= CreateOverlayObject(
1573 if(pNewOverlayObject
)
1575 xManager
->add(*pNewOverlayObject
);
1576 maOverlayGroup
.append(*pNewOverlayObject
);
1586 Pointer
ImpMeasureHdl::GetPointer() const
1590 case 0: case 1: return Pointer(POINTER_HAND
);
1591 case 2: case 3: return Pointer(POINTER_MOVEPOINT
);
1592 case 4: case 5: return SdrHdl::GetPointer(); // will then be rotated appropriately
1594 return Pointer(POINTER_NOTALLOWED
);
1597 ////////////////////////////////////////////////////////////////////////////////////////////////////
1599 ImpTextframeHdl::ImpTextframeHdl(const Rectangle
& rRect
) :
1600 SdrHdl(rRect
.TopLeft(),HDL_MOVE
),
1605 void ImpTextframeHdl::CreateB2dIAObject()
1607 // first throw away old one
1612 SdrMarkView
* pView
= pHdlList
->GetView();
1614 if(pView
&& !pView
->areMarkHandlesHidden())
1616 SdrPageView
* pPageView
= pView
->GetSdrPageView();
1620 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
1622 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
1624 if(rPageWindow
.GetPaintWindow().OutputToWindow())
1626 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
1629 const basegfx::B2DPoint
aTopLeft(maRect
.Left(), maRect
.Top());
1630 const basegfx::B2DPoint
aBottomRight(maRect
.Right(), maRect
.Bottom());
1631 const svtools::ColorConfig aColorConfig
;
1632 const Color
aHatchCol( aColorConfig
.GetColorValue( svtools::FONTCOLOR
).nColor
);
1634 ::sdr::overlay::OverlayHatchRect
* pNewOverlayObject
= new ::sdr::overlay::OverlayHatchRect(
1641 nDrehWink
* -F_PI18000
);
1642 pNewOverlayObject
->setHittable(false);
1645 if(pNewOverlayObject
)
1647 xManager
->add(*pNewOverlayObject
);
1648 maOverlayGroup
.append(*pNewOverlayObject
);
1658 ////////////////////////////////////////////////////////////////////////////////////////////////////
1660 static bool ImpSdrHdlListSorter(SdrHdl
* const& lhs
, SdrHdl
* const& rhs
)
1662 SdrHdlKind eKind1
=lhs
->GetKind();
1663 SdrHdlKind eKind2
=rhs
->GetKind();
1664 // Level 1: first normal handles, then Glue, then User, then Plus handles, then reference point handles
1669 if (eKind1
==HDL_REF1
|| eKind1
==HDL_REF2
|| eKind1
==HDL_MIRX
) n1
=5;
1670 else if (eKind1
==HDL_GLUE
|| eKind1
==HDL_GLUE_DESELECTED
) n1
=2;
1671 else if (eKind1
==HDL_USER
) n1
=3;
1672 else if (eKind1
==HDL_SMARTTAG
) n1
=0;
1673 if (eKind2
==HDL_REF1
|| eKind2
==HDL_REF2
|| eKind2
==HDL_MIRX
) n2
=5;
1674 else if (eKind2
==HDL_GLUE
|| eKind2
==HDL_GLUE_DESELECTED
) n2
=2;
1675 else if (eKind2
==HDL_USER
) n2
=3;
1676 else if (eKind2
==HDL_SMARTTAG
) n2
=0;
1678 if (lhs
->IsPlusHdl()) n1
=4;
1679 if (rhs
->IsPlusHdl()) n2
=4;
1682 // Level 2: PageView (Pointer)
1683 SdrPageView
* pPV1
=lhs
->GetPageView();
1684 SdrPageView
* pPV2
=rhs
->GetPageView();
1687 // Level 3: Position (x+y)
1688 SdrObject
* pObj1
=lhs
->GetObj();
1689 SdrObject
* pObj2
=rhs
->GetObj();
1692 sal_uInt32 nNum1
=lhs
->GetObjHdlNum();
1693 sal_uInt32 nNum2
=rhs
->GetObjHdlNum();
1697 return (long)lhs
<(long)rhs
; // Hack, to always get to the same sorting
1698 return (sal_uInt16
)eKind1
<(sal_uInt16
)eKind2
;
1705 return (long)pObj1
<(long)pObj2
;
1710 return (long)pPV1
<(long)pPV2
;
1719 SdrMarkView
* SdrHdlList::GetView() const
1724 // Helper struct for re-sorting handles
1725 struct ImplHdlAndIndex
1731 // Helper method for sorting handles taking care of OrdNums, keeping order in
1732 // single objects and re-sorting polygon handles intuitively
1733 extern "C" int SAL_CALL
ImplSortHdlFunc( const void* pVoid1
, const void* pVoid2
)
1735 const ImplHdlAndIndex
* p1
= (ImplHdlAndIndex
*)pVoid1
;
1736 const ImplHdlAndIndex
* p2
= (ImplHdlAndIndex
*)pVoid2
;
1738 if(p1
->mpHdl
->GetObj() == p2
->mpHdl
->GetObj())
1740 if(p1
->mpHdl
->GetObj() && p1
->mpHdl
->GetObj()->ISA(SdrPathObj
))
1742 // same object and a path object
1743 if((p1
->mpHdl
->GetKind() == HDL_POLY
|| p1
->mpHdl
->GetKind() == HDL_BWGT
)
1744 && (p2
->mpHdl
->GetKind() == HDL_POLY
|| p2
->mpHdl
->GetKind() == HDL_BWGT
))
1746 // both handles are point or control handles
1747 if(p1
->mpHdl
->GetPolyNum() == p2
->mpHdl
->GetPolyNum())
1749 if(p1
->mpHdl
->GetPointNum() < p2
->mpHdl
->GetPointNum())
1758 else if(p1
->mpHdl
->GetPolyNum() < p2
->mpHdl
->GetPolyNum())
1771 if(!p1
->mpHdl
->GetObj())
1775 else if(!p2
->mpHdl
->GetObj())
1781 // different objects, use OrdNum for sort
1782 const sal_uInt32 nOrdNum1
= p1
->mpHdl
->GetObj()->GetOrdNum();
1783 const sal_uInt32 nOrdNum2
= p2
->mpHdl
->GetObj()->GetOrdNum();
1785 if(nOrdNum1
< nOrdNum2
)
1796 // fallback to indices
1797 if(p1
->mnIndex
< p2
->mnIndex
)
1807 ////////////////////////////////////////////////////////////////////////////////////////////////////
1809 void SdrHdlList::TravelFocusHdl(sal_Bool bForward
)
1811 // security correction
1812 if(mnFocusIndex
!= CONTAINER_ENTRY_NOTFOUND
&& mnFocusIndex
>= GetHdlCount())
1813 mnFocusIndex
= CONTAINER_ENTRY_NOTFOUND
;
1817 // take care of old handle
1818 const sal_uIntPtr
nOldHdlNum(mnFocusIndex
);
1819 SdrHdl
* pOld
= GetHdl(nOldHdlNum
);
1823 // switch off old handle
1824 mnFocusIndex
= CONTAINER_ENTRY_NOTFOUND
;
1828 // allocate pointer array for sorted handle list
1829 ImplHdlAndIndex
* pHdlAndIndex
= new ImplHdlAndIndex
[aList
.size()];
1831 // build sorted handle list
1833 for( a
= 0; a
< aList
.size(); a
++)
1835 pHdlAndIndex
[a
].mpHdl
= aList
[a
];
1836 pHdlAndIndex
[a
].mnIndex
= a
;
1839 qsort(pHdlAndIndex
, aList
.size(), sizeof(ImplHdlAndIndex
), ImplSortHdlFunc
);
1841 // look for old num in sorted array
1842 sal_uIntPtr
nOldHdl(nOldHdlNum
);
1844 if(nOldHdlNum
!= CONTAINER_ENTRY_NOTFOUND
)
1846 for(a
= 0; a
< aList
.size(); a
++)
1848 if(pHdlAndIndex
[a
].mpHdl
== pOld
)
1857 sal_uIntPtr
nNewHdl(nOldHdl
);
1859 // do the focus travel
1862 if(nOldHdl
!= CONTAINER_ENTRY_NOTFOUND
)
1864 if(nOldHdl
== aList
.size() - 1)
1867 nNewHdl
= CONTAINER_ENTRY_NOTFOUND
;
1871 // simply the next handle
1877 // start forward run at first entry
1883 if(nOldHdl
== CONTAINER_ENTRY_NOTFOUND
)
1885 // start backward run at last entry
1886 nNewHdl
= aList
.size() - 1;
1894 nNewHdl
= CONTAINER_ENTRY_NOTFOUND
;
1898 // simply the previous handle
1905 sal_uIntPtr
nNewHdlNum(nNewHdl
);
1907 // look for old num in sorted array
1908 if(nNewHdl
!= CONTAINER_ENTRY_NOTFOUND
)
1910 SdrHdl
* pNew
= pHdlAndIndex
[nNewHdl
].mpHdl
;
1912 for(a
= 0; a
< aList
.size(); a
++)
1914 if(aList
[a
] == pNew
)
1922 // take care of next handle
1923 if(nOldHdlNum
!= nNewHdlNum
)
1925 mnFocusIndex
= nNewHdlNum
;
1926 SdrHdl
* pNew
= GetHdl(mnFocusIndex
);
1934 // free memory again
1935 delete [] pHdlAndIndex
;
1939 SdrHdl
* SdrHdlList::GetFocusHdl() const
1941 if(mnFocusIndex
!= CONTAINER_ENTRY_NOTFOUND
&& mnFocusIndex
< GetHdlCount())
1942 return GetHdl(mnFocusIndex
);
1947 void SdrHdlList::SetFocusHdl(SdrHdl
* pNew
)
1951 SdrHdl
* pActual
= GetFocusHdl();
1953 if(!pActual
|| pActual
!= pNew
)
1955 sal_uIntPtr nNewHdlNum
= GetHdlNum(pNew
);
1957 if(nNewHdlNum
!= CONTAINER_ENTRY_NOTFOUND
)
1959 mnFocusIndex
= nNewHdlNum
;
1976 void SdrHdlList::ResetFocusHdl()
1978 SdrHdl
* pHdl
= GetFocusHdl();
1980 mnFocusIndex
= CONTAINER_ENTRY_NOTFOUND
;
1988 ////////////////////////////////////////////////////////////////////////////////////////////////////
1990 SdrHdlList::SdrHdlList(SdrMarkView
* pV
)
1991 : mnFocusIndex(CONTAINER_ENTRY_NOTFOUND
),
1996 bRotateShear
= sal_False
;
1997 bMoveOutside
= sal_False
;
1998 bDistortShear
= sal_False
;
2001 SdrHdlList::~SdrHdlList()
2006 void SdrHdlList::SetHdlSize(sal_uInt16 nSiz
)
2008 if(nHdlSize
!= nSiz
)
2010 // remember new value
2013 // propagate change to IAOs
2014 for(sal_uIntPtr i
=0; i
<GetHdlCount(); i
++)
2016 SdrHdl
* pHdl
= GetHdl(i
);
2022 void SdrHdlList::SetMoveOutside(sal_Bool bOn
)
2024 if(bMoveOutside
!= bOn
)
2026 // remember new value
2029 // propagate change to IAOs
2030 for(sal_uIntPtr i
=0; i
<GetHdlCount(); i
++)
2032 SdrHdl
* pHdl
= GetHdl(i
);
2038 void SdrHdlList::SetRotateShear(sal_Bool bOn
)
2043 void SdrHdlList::SetDistortShear(sal_Bool bOn
)
2045 bDistortShear
= bOn
;
2048 SdrHdl
* SdrHdlList::RemoveHdl(sal_uIntPtr nNum
)
2050 SdrHdl
* pRetval
= aList
[nNum
];
2051 aList
.erase(aList
.begin() + nNum
);
2056 void SdrHdlList::RemoveAllByKind(SdrHdlKind eKind
)
2058 for(std::deque
<SdrHdl
*>::iterator it
= aList
.begin(); it
!= aList
.end(); )
2061 if (p
->GetKind() == eKind
)
2063 it
= aList
.erase( it
);
2071 void SdrHdlList::Clear()
2073 for (sal_uIntPtr i
=0; i
<GetHdlCount(); i
++)
2075 SdrHdl
* pHdl
=GetHdl(i
);
2080 bRotateShear
=sal_False
;
2081 bDistortShear
=sal_False
;
2084 void SdrHdlList::Sort()
2086 // remember currently focused handle
2087 SdrHdl
* pPrev
= GetFocusHdl();
2089 std::sort( aList
.begin(), aList
.end(), ImpSdrHdlListSorter
);
2091 // get now and compare
2092 SdrHdl
* pNow
= GetFocusHdl();
2109 sal_uIntPtr
SdrHdlList::GetHdlNum(const SdrHdl
* pHdl
) const
2112 return CONTAINER_ENTRY_NOTFOUND
;
2113 std::deque
<SdrHdl
*>::const_iterator it
= std::find( aList
.begin(), aList
.end(), pHdl
);
2114 if( it
== aList
.end() )
2115 return CONTAINER_ENTRY_NOTFOUND
;
2116 return it
- aList
.begin();
2119 void SdrHdlList::AddHdl(SdrHdl
* pHdl
, sal_Bool bAtBegin
)
2125 aList
.push_front(pHdl
);
2129 aList
.push_back(pHdl
);
2131 pHdl
->SetHdlList(this);
2135 SdrHdl
* SdrHdlList::IsHdlListHit(const Point
& rPnt
, sal_Bool bBack
, sal_Bool bNext
, SdrHdl
* pHdl0
) const
2138 sal_uIntPtr nAnz
=GetHdlCount();
2139 sal_uIntPtr nNum
=bBack
? 0 : nAnz
;
2140 while ((bBack
? nNum
<nAnz
: nNum
>0) && pRet
==NULL
)
2144 SdrHdl
* pHdl
=GetHdl(nNum
);
2152 if (pHdl
->IsHdlHit(rPnt
))
2161 SdrHdl
* SdrHdlList::GetHdl(SdrHdlKind eKind1
) const
2164 for (sal_uIntPtr i
=0; i
<GetHdlCount() && pRet
==NULL
; i
++)
2166 SdrHdl
* pHdl
=GetHdl(i
);
2167 if (pHdl
->GetKind()==eKind1
)
2173 // --------------------------------------------------------------------
2175 // --------------------------------------------------------------------
2177 SdrCropHdl::SdrCropHdl(const Point
& rPnt
, SdrHdlKind eNewKind
)
2178 : SdrHdl( rPnt
, eNewKind
)
2182 // --------------------------------------------------------------------
2184 BitmapEx
SdrCropHdl::GetHandlesBitmap()
2186 static BitmapEx
* pModernBitmap
= 0;
2187 if( pModernBitmap
== 0 )
2188 pModernBitmap
= new BitmapEx(ResId(SIP_SA_CROP_MARKERS
, *ImpGetResMgr()));
2189 return *pModernBitmap
;
2192 // --------------------------------------------------------------------
2194 BitmapEx
SdrCropHdl::GetBitmapForHandle( const BitmapEx
& rBitmap
, int nSize
)
2196 int nPixelSize
= 0, nX
= 0, nY
= 0, nOffset
= 0;
2203 else if( nSize
<=4 )
2216 case HDL_UPLFT
: nX
= 0; nY
= 0; break;
2217 case HDL_UPPER
: nX
= 1; nY
= 0; break;
2218 case HDL_UPRGT
: nX
= 2; nY
= 0; break;
2219 case HDL_LEFT
: nX
= 0; nY
= 1; break;
2220 case HDL_RIGHT
: nX
= 2; nY
= 1; break;
2221 case HDL_LWLFT
: nX
= 0; nY
= 2; break;
2222 case HDL_LOWER
: nX
= 1; nY
= 2; break;
2223 case HDL_LWRGT
: nX
= 2; nY
= 2; break;
2227 Rectangle
aSourceRect( Point( nX
* (nPixelSize
) + nOffset
, nY
* (nPixelSize
)), Size(nPixelSize
, nPixelSize
) );
2229 BitmapEx
aRetval(rBitmap
);
2230 aRetval
.Crop(aSourceRect
);
2234 // --------------------------------------------------------------------
2236 void SdrCropHdl::CreateB2dIAObject()
2238 // first throw away old one
2241 SdrMarkView
* pView
= pHdlList
? pHdlList
->GetView() : 0;
2242 SdrPageView
* pPageView
= pView
? pView
->GetSdrPageView() : 0;
2244 if( pPageView
&& !pView
->areMarkHandlesHidden() )
2246 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
2247 int nHdlSize
= pHdlList
->GetHdlSize();
2249 const BitmapEx
aHandlesBitmap( GetHandlesBitmap() );
2250 BitmapEx
aBmpEx1( GetBitmapForHandle( aHandlesBitmap
, nHdlSize
) );
2252 for(sal_uInt32
b(0L); b
< pPageView
->PageWindowCount(); b
++)
2254 const SdrPageWindow
& rPageWindow
= *pPageView
->GetPageWindow(b
);
2256 if(rPageWindow
.GetPaintWindow().OutputToWindow())
2258 rtl::Reference
< ::sdr::overlay::OverlayManager
> xManager
= rPageWindow
.GetOverlayManager();
2261 basegfx::B2DPoint
aPosition(aPos
.X(), aPos
.Y());
2263 ::sdr::overlay::OverlayObject
* pOverlayObject
= 0L;
2265 // animate focused handles
2266 if(IsFocusHdl() && (pHdlList
->GetFocusHdl() == this))
2271 BitmapEx
aBmpEx2( GetBitmapForHandle( aHandlesBitmap
, nHdlSize
+ 1 ) );
2273 const sal_uInt32 nBlinkTime
= sal::static_int_cast
<sal_uInt32
>(rStyleSettings
.GetCursorBlinkTime());
2275 pOverlayObject
= new ::sdr::overlay::OverlayAnimatedBitmapEx(aPosition
, aBmpEx1
, aBmpEx2
, nBlinkTime
,
2276 (sal_uInt16
)(aBmpEx1
.GetSizePixel().Width() - 1) >> 1,
2277 (sal_uInt16
)(aBmpEx1
.GetSizePixel().Height() - 1) >> 1,
2278 (sal_uInt16
)(aBmpEx2
.GetSizePixel().Width() - 1) >> 1,
2279 (sal_uInt16
)(aBmpEx2
.GetSizePixel().Height() - 1) >> 1);
2283 // create centered handle as default
2284 pOverlayObject
= new ::sdr::overlay::OverlayBitmapEx(aPosition
, aBmpEx1
,
2285 (sal_uInt16
)(aBmpEx1
.GetSizePixel().Width() - 1) >> 1,
2286 (sal_uInt16
)(aBmpEx1
.GetSizePixel().Height() - 1) >> 1);
2292 xManager
->add(*pOverlayObject
);
2293 maOverlayGroup
.append(*pOverlayObject
);
2301 // --------------------------------------------------------------------
2303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */