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