xref: /aoo41x/main/svx/source/svdraw/svdhdl.cxx (revision 2376739d)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f6e50924SAndrew Rist  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19f6e50924SAndrew Rist  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <algorithm>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <svx/svdhdl.hxx>
30cdf0e10cSrcweir #include <svx/svdpagv.hxx>
31cdf0e10cSrcweir #include <svx/svdetc.hxx>
32cdf0e10cSrcweir #include <svx/svdmrkv.hxx>
33cdf0e10cSrcweir #include <vcl/window.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <vcl/virdev.hxx>
36cdf0e10cSrcweir #include <tools/poly.hxx>
37cdf0e10cSrcweir #include <vcl/bmpacc.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <svx/sxekitm.hxx>
40cdf0e10cSrcweir #include "svx/svdstr.hrc"
41cdf0e10cSrcweir #include "svx/svdglob.hxx"
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <svx/svdmodel.hxx>
44cdf0e10cSrcweir #include "gradtrns.hxx"
45cdf0e10cSrcweir #include <svx/xflgrit.hxx>
46cdf0e10cSrcweir #include <svx/svdundo.hxx>
47cdf0e10cSrcweir #include <svx/dialmgr.hxx>
48cdf0e10cSrcweir #include <svx/xflftrit.hxx>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir // #105678#
51cdf0e10cSrcweir #include <svx/svdopath.hxx>
52cdf0e10cSrcweir #include <basegfx/vector/b2dvector.hxx>
53cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
54cdf0e10cSrcweir #include <svx/sdr/overlay/overlaymanager.hxx>
55cdf0e10cSrcweir #include <svx/sdr/overlay/overlayanimatedbitmapex.hxx>
56cdf0e10cSrcweir #include <svx/sdr/overlay/overlaybitmapex.hxx>
57cdf0e10cSrcweir #include <svx/sdr/overlay/overlayline.hxx>
58cdf0e10cSrcweir #include <svx/sdr/overlay/overlaytriangle.hxx>
591cd65da9SArmin Le Grand #include <svx/sdr/overlay/overlayrectangle.hxx>
60cdf0e10cSrcweir #include <svx/sdrpagewindow.hxx>
61cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx>
62cdf0e10cSrcweir #include <vcl/svapp.hxx>
63cdf0e10cSrcweir #include <svx/sdr/overlay/overlaypolypolygon.hxx>
64cdf0e10cSrcweir #include <vcl/lazydelete.hxx>
65cdf0e10cSrcweir 
66*2376739dSArmin Le Grand #include <basegfx/polygon/b2dpolygontools.hxx>
67*2376739dSArmin Le Grand #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
68*2376739dSArmin Le Grand #include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx>
69*2376739dSArmin Le Grand #include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
70*2376739dSArmin Le Grand #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
71*2376739dSArmin Le Grand #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
72*2376739dSArmin Le Grand 
73cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
74cdf0e10cSrcweir // #i15222#
75cdf0e10cSrcweir // Due to the ressource problems in Win95/98 with bitmap ressources i
76cdf0e10cSrcweir // will change this handle bitmap provinging class. Old version was splitting
77cdf0e10cSrcweir // and preparing all small handle bitmaps in device bitmap format, now this will
78cdf0e10cSrcweir // be done on the fly. Thus, tehre is only the one big bitmap remembered. With
79cdf0e10cSrcweir // three source bitmaps, this will be 3 system bitmap ressources instead of hundreds.
80cdf0e10cSrcweir // The price for that needs to be evaluated. Maybe we will need another change here
81cdf0e10cSrcweir // if this is too expensive.
82cdf0e10cSrcweir class SdrHdlBitmapSet
83cdf0e10cSrcweir {
84cdf0e10cSrcweir 	// the bitmap holding all infos
85cdf0e10cSrcweir 	BitmapEx				    maMarkersBitmap;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     // the cropped Bitmaps for reusage
88cdf0e10cSrcweir     ::std::vector< BitmapEx >   maRealMarkers;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     // elpers
91cdf0e10cSrcweir     BitmapEx& impGetOrCreateTargetBitmap(sal_uInt16 nIndex, const Rectangle& rRectangle);
92cdf0e10cSrcweir 
93cdf0e10cSrcweir public:
94cdf0e10cSrcweir 	SdrHdlBitmapSet(sal_uInt16 nResId);
95cdf0e10cSrcweir 	~SdrHdlBitmapSet();
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	const BitmapEx& GetBitmapEx(BitmapMarkerKind eKindOfMarker, sal_uInt16 nInd=0);
98cdf0e10cSrcweir };
99cdf0e10cSrcweir 
100cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
101cdf0e10cSrcweir #define KIND_COUNT          (14)
102cdf0e10cSrcweir #define INDEX_COUNT         (6)
103cdf0e10cSrcweir #define INDIVIDUAL_COUNT    (4)
104cdf0e10cSrcweir 
105cdf0e10cSrcweir SdrHdlBitmapSet::SdrHdlBitmapSet(sal_uInt16 nResId)
1064772d9afSArmin Le Grand :   maMarkersBitmap(ResId(nResId, *ImpGetResMgr())), // just use ressource with alpha channel
107cdf0e10cSrcweir     // 14 kinds (BitmapMarkerKind) use index [0..5], 4 extra
108cdf0e10cSrcweir     maRealMarkers((KIND_COUNT * INDEX_COUNT) + INDIVIDUAL_COUNT)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir SdrHdlBitmapSet::~SdrHdlBitmapSet()
113cdf0e10cSrcweir {
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir BitmapEx& SdrHdlBitmapSet::impGetOrCreateTargetBitmap(sal_uInt16 nIndex, const Rectangle& rRectangle)
117cdf0e10cSrcweir {
118cdf0e10cSrcweir     BitmapEx& rTargetBitmap = maRealMarkers[nIndex];
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     if(rTargetBitmap.IsEmpty())
121cdf0e10cSrcweir     {
122cdf0e10cSrcweir         rTargetBitmap = maMarkersBitmap;
123cdf0e10cSrcweir         rTargetBitmap.Crop(rRectangle);
124cdf0e10cSrcweir     }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     return rTargetBitmap;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir // change getting of bitmap to use the big ressource bitmap
130cdf0e10cSrcweir const BitmapEx& SdrHdlBitmapSet::GetBitmapEx(BitmapMarkerKind eKindOfMarker, sal_uInt16 nInd)
131cdf0e10cSrcweir {
132cdf0e10cSrcweir 	// fill in size and source position in maMarkersBitmap
133cdf0e10cSrcweir 	const sal_uInt16 nYPos(nInd * 11);
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	switch(eKindOfMarker)
136cdf0e10cSrcweir 	{
137cdf0e10cSrcweir 		default:
138cdf0e10cSrcweir 		{
139cdf0e10cSrcweir 			DBG_ERROR( "unknown kind of marker" );
140cdf0e10cSrcweir 			// no break here, return Rect_7x7 as default
141cdf0e10cSrcweir 		}
142cdf0e10cSrcweir 		case Rect_7x7:
143cdf0e10cSrcweir 		{
144cdf0e10cSrcweir             return impGetOrCreateTargetBitmap((0 * INDEX_COUNT) + nInd, Rectangle(Point(0, nYPos), Size(7, 7)));
145cdf0e10cSrcweir 		}
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 		case Rect_9x9:
148cdf0e10cSrcweir 		{
149cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((1 * INDEX_COUNT) + nInd, Rectangle(Point(7, nYPos), Size(9, 9)));
150cdf0e10cSrcweir 		}
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 		case Rect_11x11:
153cdf0e10cSrcweir 		{
154cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((2 * INDEX_COUNT) + nInd, Rectangle(Point(16, nYPos), Size(11, 11)));
155cdf0e10cSrcweir 		}
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		case Rect_13x13:
158cdf0e10cSrcweir 		{
159cdf0e10cSrcweir             const sal_uInt16 nIndex((3 * INDEX_COUNT) + nInd);
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 			switch(nInd)
162cdf0e10cSrcweir 			{
163cdf0e10cSrcweir     			case 0:
164cdf0e10cSrcweir                 {
165cdf0e10cSrcweir                     return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(72, 66), Size(13, 13)));
166cdf0e10cSrcweir                 }
167cdf0e10cSrcweir 	    		case 1:
168cdf0e10cSrcweir                 {
169cdf0e10cSrcweir                     return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(85, 66), Size(13, 13)));
170cdf0e10cSrcweir                 }
171cdf0e10cSrcweir 		    	case 2:
172cdf0e10cSrcweir                 {
1734772d9afSArmin Le Grand                     return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(72, 79), Size(13, 13)));
174cdf0e10cSrcweir                 }
175cdf0e10cSrcweir 			    case 3:
176cdf0e10cSrcweir                 {
1774772d9afSArmin Le Grand                     return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(85, 79), Size(13, 13)));
178cdf0e10cSrcweir                 }
179cdf0e10cSrcweir     			case 4:
180cdf0e10cSrcweir                 {
1814772d9afSArmin Le Grand                     return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(98, 79), Size(13, 13)));
182cdf0e10cSrcweir                 }
183cdf0e10cSrcweir                 default: // case 5:
184cdf0e10cSrcweir                 {
185cdf0e10cSrcweir                     return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(98, 66), Size(13, 13)));
186cdf0e10cSrcweir                 }
187cdf0e10cSrcweir 			}
188cdf0e10cSrcweir 		}
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 		case Circ_7x7:
1914772d9afSArmin Le Grand 		case Customshape_7x7:
192cdf0e10cSrcweir 		{
193cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((4 * INDEX_COUNT) + nInd, Rectangle(Point(27, nYPos), Size(7, 7)));
194cdf0e10cSrcweir 		}
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 		case Circ_9x9:
1974772d9afSArmin Le Grand 		case Customshape_9x9:
198cdf0e10cSrcweir 		{
199cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((5 * INDEX_COUNT) + nInd, Rectangle(Point(34, nYPos), Size(9, 9)));
200cdf0e10cSrcweir 		}
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 		case Circ_11x11:
2034772d9afSArmin Le Grand 		case Customshape_11x11:
204cdf0e10cSrcweir 		{
205cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((6 * INDEX_COUNT) + nInd, Rectangle(Point(43, nYPos), Size(11, 11)));
206cdf0e10cSrcweir 		}
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 		case Elli_7x9:
209cdf0e10cSrcweir 		{
210cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((7 * INDEX_COUNT) + nInd, Rectangle(Point(54, nYPos), Size(7, 9)));
211cdf0e10cSrcweir 		}
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 		case Elli_9x11:
214cdf0e10cSrcweir 		{
215cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((8 * INDEX_COUNT) + nInd, Rectangle(Point(61, nYPos), Size(9, 11)));
216cdf0e10cSrcweir 		}
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 		case Elli_9x7:
219cdf0e10cSrcweir 		{
220cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((9 * INDEX_COUNT) + nInd, Rectangle(Point(70, nYPos), Size(9, 7)));
221cdf0e10cSrcweir 		}
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 		case Elli_11x9:
224cdf0e10cSrcweir 		{
225cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((10 * INDEX_COUNT) + nInd, Rectangle(Point(79, nYPos), Size(11, 9)));
226cdf0e10cSrcweir 		}
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 		case RectPlus_7x7:
229cdf0e10cSrcweir 		{
230cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((11 * INDEX_COUNT) + nInd, Rectangle(Point(90, nYPos), Size(7, 7)));
231cdf0e10cSrcweir 		}
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 		case RectPlus_9x9:
234cdf0e10cSrcweir 		{
235cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((12 * INDEX_COUNT) + nInd, Rectangle(Point(97, nYPos), Size(9, 9)));
236cdf0e10cSrcweir 		}
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 		case RectPlus_11x11:
239cdf0e10cSrcweir 		{
240cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((13 * INDEX_COUNT) + nInd, Rectangle(Point(106, nYPos), Size(11, 11)));
241cdf0e10cSrcweir 		}
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 		case Crosshair:
244cdf0e10cSrcweir 		{
245cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((KIND_COUNT * INDEX_COUNT) + 0, Rectangle(Point(0, 68), Size(15, 15)));
246cdf0e10cSrcweir 		}
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 		case Glue:
249cdf0e10cSrcweir 		{
250cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((KIND_COUNT * INDEX_COUNT) + 1, Rectangle(Point(15, 74), Size(9, 9)));
251cdf0e10cSrcweir 		}
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 		case Anchor: // #101688# AnchorTR for SW
254cdf0e10cSrcweir 		case AnchorTR:
255cdf0e10cSrcweir 		{
2564772d9afSArmin Le Grand 			return impGetOrCreateTargetBitmap((KIND_COUNT * INDEX_COUNT) + 2, Rectangle(Point(24, 68), Size(24, 24)));
257cdf0e10cSrcweir 		}
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 		// #98388# add AnchorPressed to be able to aninate anchor control
260cdf0e10cSrcweir 		case AnchorPressed:
261cdf0e10cSrcweir 		case AnchorPressedTR:
262cdf0e10cSrcweir 		{
2634772d9afSArmin Le Grand 			return impGetOrCreateTargetBitmap((KIND_COUNT * INDEX_COUNT) + 3, Rectangle(Point(48, 68), Size(24, 24)));
264cdf0e10cSrcweir 		}
265cdf0e10cSrcweir 	}
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 	// cannot happen since all pathes return something; return Rect_7x7 as default (see switch)
268cdf0e10cSrcweir     return maRealMarkers[0];
269cdf0e10cSrcweir }
270cdf0e10cSrcweir 
271cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
272cdf0e10cSrcweir 
273cdf0e10cSrcweir SdrHdlBitmapSet& getSimpleSet()
274cdf0e10cSrcweir {
275cdf0e10cSrcweir     static vcl::DeleteOnDeinit< SdrHdlBitmapSet > aSimpleSet(new SdrHdlBitmapSet(SIP_SA_MARKERS));
276cdf0e10cSrcweir     return *aSimpleSet.get();
277cdf0e10cSrcweir }
278cdf0e10cSrcweir 
279cdf0e10cSrcweir SdrHdlBitmapSet& getModernSet()
280cdf0e10cSrcweir {
281cdf0e10cSrcweir     static vcl::DeleteOnDeinit< SdrHdlBitmapSet > aModernSet(new SdrHdlBitmapSet(SIP_SA_FINE_MARKERS));
282cdf0e10cSrcweir     return *aModernSet.get();
283cdf0e10cSrcweir }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir SdrHdlBitmapSet& getHighContrastSet()
286cdf0e10cSrcweir {
287cdf0e10cSrcweir     static vcl::DeleteOnDeinit< SdrHdlBitmapSet > aHighContrastSet(new SdrHdlBitmapSet(SIP_SA_ACCESSIBILITY_MARKERS));
288cdf0e10cSrcweir     return *aHighContrastSet.get();
289cdf0e10cSrcweir }
290cdf0e10cSrcweir 
291cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
292cdf0e10cSrcweir 
293cdf0e10cSrcweir SdrHdl::SdrHdl():
294cdf0e10cSrcweir     pObj(NULL),
295cdf0e10cSrcweir     pPV(NULL),
296cdf0e10cSrcweir     pHdlList(NULL),
297cdf0e10cSrcweir     eKind(HDL_MOVE),
298cdf0e10cSrcweir     nDrehWink(0),
299cdf0e10cSrcweir     nObjHdlNum(0),
300cdf0e10cSrcweir     nPolyNum(0),
301cdf0e10cSrcweir     nPPntNum(0),
302cdf0e10cSrcweir     nSourceHdlNum(0),
303cdf0e10cSrcweir     bSelect(sal_False),
304cdf0e10cSrcweir     b1PixMore(sal_False),
305cdf0e10cSrcweir     bPlusHdl(sal_False),
306cdf0e10cSrcweir 	mbMoveOutside(false),
307cdf0e10cSrcweir 	mbMouseOver(false)
308cdf0e10cSrcweir {
309cdf0e10cSrcweir }
310cdf0e10cSrcweir 
311cdf0e10cSrcweir SdrHdl::SdrHdl(const Point& rPnt, SdrHdlKind eNewKind):
312cdf0e10cSrcweir     pObj(NULL),
313cdf0e10cSrcweir     pPV(NULL),
314cdf0e10cSrcweir     pHdlList(NULL),
315cdf0e10cSrcweir     aPos(rPnt),
316cdf0e10cSrcweir     eKind(eNewKind),
317cdf0e10cSrcweir     nDrehWink(0),
318cdf0e10cSrcweir     nObjHdlNum(0),
319cdf0e10cSrcweir     nPolyNum(0),
320cdf0e10cSrcweir     nPPntNum(0),
321cdf0e10cSrcweir     nSourceHdlNum(0),
322cdf0e10cSrcweir     bSelect(sal_False),
323cdf0e10cSrcweir     b1PixMore(sal_False),
324cdf0e10cSrcweir     bPlusHdl(sal_False),
325cdf0e10cSrcweir 	mbMoveOutside(false),
326cdf0e10cSrcweir 	mbMouseOver(false)
327cdf0e10cSrcweir {
328cdf0e10cSrcweir }
329cdf0e10cSrcweir 
330cdf0e10cSrcweir SdrHdl::~SdrHdl()
331cdf0e10cSrcweir {
332cdf0e10cSrcweir 	GetRidOfIAObject();
333cdf0e10cSrcweir }
334cdf0e10cSrcweir 
335cdf0e10cSrcweir void SdrHdl::Set1PixMore(sal_Bool bJa)
336cdf0e10cSrcweir {
337cdf0e10cSrcweir 	if(b1PixMore != bJa)
338cdf0e10cSrcweir 	{
339cdf0e10cSrcweir 		b1PixMore = bJa;
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 		// create new display
342cdf0e10cSrcweir 		Touch();
343cdf0e10cSrcweir 	}
344cdf0e10cSrcweir }
345cdf0e10cSrcweir 
346cdf0e10cSrcweir void SdrHdl::SetMoveOutside( bool bMoveOutside )
347cdf0e10cSrcweir {
348cdf0e10cSrcweir 	if(mbMoveOutside != bMoveOutside)
349cdf0e10cSrcweir 	{
350cdf0e10cSrcweir 		mbMoveOutside = bMoveOutside;
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 		// create new display
353cdf0e10cSrcweir 		Touch();
354cdf0e10cSrcweir 	}
355cdf0e10cSrcweir }
356cdf0e10cSrcweir 
357cdf0e10cSrcweir void SdrHdl::SetDrehWink(long n)
358cdf0e10cSrcweir {
359cdf0e10cSrcweir 	if(nDrehWink != n)
360cdf0e10cSrcweir 	{
361cdf0e10cSrcweir 		nDrehWink = n;
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 		// create new display
364cdf0e10cSrcweir 		Touch();
365cdf0e10cSrcweir 	}
366cdf0e10cSrcweir }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir void SdrHdl::SetPos(const Point& rPnt)
369cdf0e10cSrcweir {
370cdf0e10cSrcweir 	if(aPos != rPnt)
371cdf0e10cSrcweir 	{
372cdf0e10cSrcweir 		// remember new position
373cdf0e10cSrcweir 		aPos = rPnt;
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 		// create new display
376cdf0e10cSrcweir 		Touch();
377cdf0e10cSrcweir 	}
378cdf0e10cSrcweir }
379cdf0e10cSrcweir 
380cdf0e10cSrcweir void SdrHdl::SetSelected(sal_Bool bJa)
381cdf0e10cSrcweir {
382cdf0e10cSrcweir 	if(bSelect != bJa)
383cdf0e10cSrcweir 	{
384cdf0e10cSrcweir 		// remember new value
385cdf0e10cSrcweir 		bSelect = bJa;
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 		// create new display
388cdf0e10cSrcweir 		Touch();
389cdf0e10cSrcweir 	}
390cdf0e10cSrcweir }
391cdf0e10cSrcweir 
392cdf0e10cSrcweir void SdrHdl::SetHdlList(SdrHdlList* pList)
393cdf0e10cSrcweir {
394cdf0e10cSrcweir 	if(pHdlList != pList)
395cdf0e10cSrcweir 	{
396cdf0e10cSrcweir 		// rememver list
397cdf0e10cSrcweir 		pHdlList = pList;
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 		// now its possible to create graphic representation
400cdf0e10cSrcweir 		Touch();
401cdf0e10cSrcweir 	}
402cdf0e10cSrcweir }
403cdf0e10cSrcweir 
404cdf0e10cSrcweir void SdrHdl::SetObj(SdrObject* pNewObj)
405cdf0e10cSrcweir {
406cdf0e10cSrcweir 	if(pObj != pNewObj)
407cdf0e10cSrcweir 	{
408cdf0e10cSrcweir 		// remember new object
409cdf0e10cSrcweir 		pObj = pNewObj;
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 		// graphic representation may have changed
412cdf0e10cSrcweir 		Touch();
413cdf0e10cSrcweir 	}
414cdf0e10cSrcweir }
415cdf0e10cSrcweir 
416cdf0e10cSrcweir void SdrHdl::Touch()
417cdf0e10cSrcweir {
418cdf0e10cSrcweir 	// force update of graphic representation
419cdf0e10cSrcweir 	CreateB2dIAObject();
420cdf0e10cSrcweir }
421cdf0e10cSrcweir 
422cdf0e10cSrcweir void SdrHdl::GetRidOfIAObject()
423cdf0e10cSrcweir {
424cdf0e10cSrcweir 	//OLMaIAOGroup.Delete();
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 	// OVERLAYMANAGER
427cdf0e10cSrcweir 	maOverlayGroup.clear();
428cdf0e10cSrcweir }
429cdf0e10cSrcweir 
430cdf0e10cSrcweir void SdrHdl::CreateB2dIAObject()
431cdf0e10cSrcweir {
432cdf0e10cSrcweir 	// first throw away old one
433cdf0e10cSrcweir 	GetRidOfIAObject();
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 	if(pHdlList && pHdlList->GetView() && !pHdlList->GetView()->areMarkHandlesHidden())
436cdf0e10cSrcweir 	{
437cdf0e10cSrcweir 		BitmapColorIndex eColIndex = LightGreen;
438cdf0e10cSrcweir 		BitmapMarkerKind eKindOfMarker = Rect_7x7;
439cdf0e10cSrcweir 
440cdf0e10cSrcweir         sal_Bool bRot = pHdlList->IsRotateShear();
441cdf0e10cSrcweir         if(pObj)
442cdf0e10cSrcweir             eColIndex = (bSelect) ? Cyan : LightCyan;
443cdf0e10cSrcweir         if(bRot)
444cdf0e10cSrcweir 		{
445cdf0e10cSrcweir 			// Drehhandles in Rot
446cdf0e10cSrcweir             if(pObj && bSelect)
447cdf0e10cSrcweir 				eColIndex = Red;
448cdf0e10cSrcweir 			else
449cdf0e10cSrcweir 	            eColIndex = LightRed;
450cdf0e10cSrcweir         }
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 		switch(eKind)
453cdf0e10cSrcweir 		{
454cdf0e10cSrcweir 			case HDL_MOVE:
455cdf0e10cSrcweir 			{
456cdf0e10cSrcweir 				eKindOfMarker = (b1PixMore) ? Rect_9x9 : Rect_7x7;
457cdf0e10cSrcweir 				break;
458cdf0e10cSrcweir 			}
459cdf0e10cSrcweir 			case HDL_UPLFT:
460cdf0e10cSrcweir 			case HDL_UPRGT:
461cdf0e10cSrcweir 			case HDL_LWLFT:
462cdf0e10cSrcweir 			case HDL_LWRGT:
463cdf0e10cSrcweir 			{
464cdf0e10cSrcweir 				// corner handles
465cdf0e10cSrcweir 				if(bRot)
466cdf0e10cSrcweir 				{
467cdf0e10cSrcweir 					eKindOfMarker = Circ_7x7;
468cdf0e10cSrcweir 				}
469cdf0e10cSrcweir 				else
470cdf0e10cSrcweir 				{
471cdf0e10cSrcweir 					eKindOfMarker = Rect_7x7;
472cdf0e10cSrcweir 				}
473cdf0e10cSrcweir 				break;
474cdf0e10cSrcweir 			}
475cdf0e10cSrcweir 			case HDL_UPPER:
476cdf0e10cSrcweir 			case HDL_LOWER:
477cdf0e10cSrcweir 			{
478cdf0e10cSrcweir 				// Upper/Lower handles
479cdf0e10cSrcweir 				if(bRot)
480cdf0e10cSrcweir 				{
481cdf0e10cSrcweir 					eKindOfMarker = Elli_9x7;
482cdf0e10cSrcweir 				}
483cdf0e10cSrcweir 				else
484cdf0e10cSrcweir 				{
485cdf0e10cSrcweir 					eKindOfMarker = Rect_7x7;
486cdf0e10cSrcweir 				}
487cdf0e10cSrcweir 				break;
488cdf0e10cSrcweir 			}
489cdf0e10cSrcweir 			case HDL_LEFT:
490cdf0e10cSrcweir 			case HDL_RIGHT:
491cdf0e10cSrcweir 			{
492cdf0e10cSrcweir 				// Left/Right handles
493cdf0e10cSrcweir 				if(bRot)
494cdf0e10cSrcweir 				{
495cdf0e10cSrcweir 					eKindOfMarker = Elli_7x9;
496cdf0e10cSrcweir 				}
497cdf0e10cSrcweir 				else
498cdf0e10cSrcweir 				{
499cdf0e10cSrcweir 					eKindOfMarker = Rect_7x7;
500cdf0e10cSrcweir 				}
501cdf0e10cSrcweir 				break;
502cdf0e10cSrcweir 			}
503cdf0e10cSrcweir 			case HDL_POLY:
504cdf0e10cSrcweir 			{
505cdf0e10cSrcweir 				if(bRot)
506cdf0e10cSrcweir 				{
507cdf0e10cSrcweir 					eKindOfMarker = (b1PixMore) ? Circ_9x9 : Circ_7x7;
508cdf0e10cSrcweir 				}
509cdf0e10cSrcweir 				else
510cdf0e10cSrcweir 				{
511cdf0e10cSrcweir 					eKindOfMarker = (b1PixMore) ? Rect_9x9 : Rect_7x7;
512cdf0e10cSrcweir 				}
513cdf0e10cSrcweir 				break;
514cdf0e10cSrcweir 			}
515cdf0e10cSrcweir 			case HDL_BWGT: // weight at poly
516cdf0e10cSrcweir 			{
517cdf0e10cSrcweir 				eKindOfMarker = Circ_7x7;
518cdf0e10cSrcweir 				break;
519cdf0e10cSrcweir 			}
520cdf0e10cSrcweir 			case HDL_CIRC:
521cdf0e10cSrcweir 			{
522cdf0e10cSrcweir 				eKindOfMarker = Rect_11x11;
523cdf0e10cSrcweir 				break;
524cdf0e10cSrcweir 			}
525cdf0e10cSrcweir 			case HDL_REF1:
526cdf0e10cSrcweir 			case HDL_REF2:
527cdf0e10cSrcweir 			{
528cdf0e10cSrcweir 				eKindOfMarker = Crosshair;
529cdf0e10cSrcweir 				break;
530cdf0e10cSrcweir 			}
531cdf0e10cSrcweir 			case HDL_GLUE:
532cdf0e10cSrcweir 			{
533cdf0e10cSrcweir 				eKindOfMarker = Glue;
534cdf0e10cSrcweir 				break;
535cdf0e10cSrcweir 			}
536cdf0e10cSrcweir 			case HDL_ANCHOR:
537cdf0e10cSrcweir 			{
538cdf0e10cSrcweir 				eKindOfMarker = Anchor;
539cdf0e10cSrcweir 				break;
540cdf0e10cSrcweir 			}
541cdf0e10cSrcweir 			case HDL_USER:
542cdf0e10cSrcweir 			{
543cdf0e10cSrcweir 				break;
544cdf0e10cSrcweir 			}
545cdf0e10cSrcweir 			// #101688# top right anchor for SW
546cdf0e10cSrcweir 			case HDL_ANCHOR_TR:
547cdf0e10cSrcweir 			{
548cdf0e10cSrcweir 				eKindOfMarker = AnchorTR;
549cdf0e10cSrcweir 				break;
550cdf0e10cSrcweir 			}
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 			// for SJ and the CustomShapeHandles:
553cdf0e10cSrcweir 			case HDL_CUSTOMSHAPE1:
554cdf0e10cSrcweir 			{
5555f27b83cSArmin Le Grand 				eKindOfMarker = (b1PixMore) ? Customshape_9x9 : Customshape_7x7;
556cdf0e10cSrcweir 				eColIndex = Yellow;
557cdf0e10cSrcweir 				break;
558cdf0e10cSrcweir 			}
559cdf0e10cSrcweir             default:
560cdf0e10cSrcweir                 break;
561cdf0e10cSrcweir 		}
562cdf0e10cSrcweir 
563cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
564cdf0e10cSrcweir 		SdrPageView* pPageView = pView->GetSdrPageView();
565cdf0e10cSrcweir 
566cdf0e10cSrcweir 		if(pPageView)
567cdf0e10cSrcweir 		{
568cdf0e10cSrcweir 			for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
569cdf0e10cSrcweir 			{
570cdf0e10cSrcweir 				// const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
571cdf0e10cSrcweir 				const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 				if(rPageWindow.GetPaintWindow().OutputToWindow())
574cdf0e10cSrcweir 				{
575cdf0e10cSrcweir 					Point aMoveOutsideOffset(0, 0);
576cdf0e10cSrcweir 
577cdf0e10cSrcweir 					// add offset if necessary
578cdf0e10cSrcweir 					if(pHdlList->IsMoveOutside() || mbMoveOutside)
579cdf0e10cSrcweir 					{
580cdf0e10cSrcweir 						OutputDevice& rOutDev = rPageWindow.GetPaintWindow().GetOutputDevice();
581cdf0e10cSrcweir 						Size aOffset = rOutDev.PixelToLogic(Size(4, 4));
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 						if(eKind == HDL_UPLFT || eKind == HDL_UPPER || eKind == HDL_UPRGT)
584cdf0e10cSrcweir 							aMoveOutsideOffset.Y() -= aOffset.Width();
585cdf0e10cSrcweir 						if(eKind == HDL_LWLFT || eKind == HDL_LOWER || eKind == HDL_LWRGT)
586cdf0e10cSrcweir 							aMoveOutsideOffset.Y() += aOffset.Height();
587cdf0e10cSrcweir 						if(eKind == HDL_UPLFT || eKind == HDL_LEFT  || eKind == HDL_LWLFT)
588cdf0e10cSrcweir 							aMoveOutsideOffset.X() -= aOffset.Width();
589cdf0e10cSrcweir 						if(eKind == HDL_UPRGT || eKind == HDL_RIGHT || eKind == HDL_LWRGT)
590cdf0e10cSrcweir 							aMoveOutsideOffset.X() += aOffset.Height();
591cdf0e10cSrcweir 					}
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 					if(rPageWindow.GetOverlayManager())
594cdf0e10cSrcweir 					{
595cdf0e10cSrcweir 						basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
596cdf0e10cSrcweir 						::sdr::overlay::OverlayObject* pNewOverlayObject = CreateOverlayObject(
597cdf0e10cSrcweir 							aPosition,
598cdf0e10cSrcweir 							eColIndex,
599cdf0e10cSrcweir 							eKindOfMarker,
600cdf0e10cSrcweir 							aMoveOutsideOffset);
601cdf0e10cSrcweir 
602cdf0e10cSrcweir 						// OVERLAYMANAGER
603cdf0e10cSrcweir 						if(pNewOverlayObject)
604cdf0e10cSrcweir 						{
605cdf0e10cSrcweir 							rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
606cdf0e10cSrcweir 							maOverlayGroup.append(*pNewOverlayObject);
607cdf0e10cSrcweir 						}
608cdf0e10cSrcweir 					}
609cdf0e10cSrcweir 				}
610cdf0e10cSrcweir 			}
611cdf0e10cSrcweir 		}
612cdf0e10cSrcweir 	}
613cdf0e10cSrcweir }
614cdf0e10cSrcweir 
615cdf0e10cSrcweir BitmapMarkerKind SdrHdl::GetNextBigger(BitmapMarkerKind eKnd) const
616cdf0e10cSrcweir {
617cdf0e10cSrcweir 	BitmapMarkerKind eRetval(eKnd);
618cdf0e10cSrcweir 
619cdf0e10cSrcweir 	switch(eKnd)
620cdf0e10cSrcweir 	{
621cdf0e10cSrcweir 		case Rect_7x7:			eRetval = Rect_9x9;			break;
622cdf0e10cSrcweir 		case Rect_9x9:			eRetval = Rect_11x11;		break;
623cdf0e10cSrcweir 		case Rect_11x11:		eRetval = Rect_13x13;		break;
624cdf0e10cSrcweir 		//case Rect_13x13:		eRetval = ;	break;
625cdf0e10cSrcweir 
626cdf0e10cSrcweir 		case Circ_7x7:			eRetval = Circ_9x9;			break;
627cdf0e10cSrcweir 		case Circ_9x9:			eRetval = Circ_11x11;		break;
628cdf0e10cSrcweir 		//case Circ_11x11:		eRetval = ;	break;
629cdf0e10cSrcweir 
6304772d9afSArmin Le Grand 		case Customshape_7x7:		eRetval = Customshape_9x9;	    break;
6314772d9afSArmin Le Grand 		case Customshape_9x9:		eRetval = Customshape_11x11;    break;
6324772d9afSArmin Le Grand 		//case Customshape_11x11:	eRetval = ;	break;
6334772d9afSArmin Le Grand 
634cdf0e10cSrcweir 		case Elli_7x9:			eRetval = Elli_9x11;		break;
635cdf0e10cSrcweir 		//case Elli_9x11:			eRetval = ;	break;
636cdf0e10cSrcweir 
637cdf0e10cSrcweir 		case Elli_9x7:			eRetval = Elli_11x9;		break;
638cdf0e10cSrcweir 		//case Elli_11x9:			eRetval = ;	break;
639cdf0e10cSrcweir 
640cdf0e10cSrcweir 		case RectPlus_7x7:		eRetval = RectPlus_9x9;		break;
641cdf0e10cSrcweir 		case RectPlus_9x9:		eRetval = RectPlus_11x11;	break;
642cdf0e10cSrcweir 		//case RectPlus_11x11:	eRetval = ;	break;
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 		//case Crosshair:			eRetval = ;	break;
645cdf0e10cSrcweir 		//case Glue:				eRetval = ;	break;
646cdf0e10cSrcweir 
647cdf0e10cSrcweir 		// #98388# let anchor blink with it's pressed state
648cdf0e10cSrcweir 		case Anchor:			eRetval = AnchorPressed;	break;
649cdf0e10cSrcweir 
650cdf0e10cSrcweir 		// #101688# same for AnchorTR
651cdf0e10cSrcweir 		case AnchorTR:			eRetval = AnchorPressedTR;	break;
652cdf0e10cSrcweir         default:
653cdf0e10cSrcweir             break;
654cdf0e10cSrcweir 	}
655cdf0e10cSrcweir 
656cdf0e10cSrcweir 	return eRetval;
657cdf0e10cSrcweir }
658cdf0e10cSrcweir 
659cdf0e10cSrcweir // #101928#
660cdf0e10cSrcweir BitmapEx SdrHdl::ImpGetBitmapEx(BitmapMarkerKind eKindOfMarker, sal_uInt16 nInd, sal_Bool bFine, sal_Bool bIsHighContrast)
661cdf0e10cSrcweir {
662cdf0e10cSrcweir 	if(bIsHighContrast)
663cdf0e10cSrcweir 	{
664cdf0e10cSrcweir 		return getHighContrastSet().GetBitmapEx(eKindOfMarker, nInd);
665cdf0e10cSrcweir 	}
666cdf0e10cSrcweir 	else
667cdf0e10cSrcweir 	{
668cdf0e10cSrcweir 		if(bFine)
669cdf0e10cSrcweir 		{
670cdf0e10cSrcweir 			return getModernSet().GetBitmapEx(eKindOfMarker, nInd);
671cdf0e10cSrcweir 		}
672cdf0e10cSrcweir 		else
673cdf0e10cSrcweir 		{
674cdf0e10cSrcweir 			return getSimpleSet().GetBitmapEx(eKindOfMarker, nInd);
675cdf0e10cSrcweir 		}
676cdf0e10cSrcweir 	}
677cdf0e10cSrcweir }
678cdf0e10cSrcweir 
679cdf0e10cSrcweir ::sdr::overlay::OverlayObject* SdrHdl::CreateOverlayObject(
680cdf0e10cSrcweir 	const basegfx::B2DPoint& rPos,
681cdf0e10cSrcweir 	BitmapColorIndex eColIndex, BitmapMarkerKind eKindOfMarker, Point aMoveOutsideOffset)
682cdf0e10cSrcweir {
683cdf0e10cSrcweir 	::sdr::overlay::OverlayObject* pRetval = 0L;
684cdf0e10cSrcweir 	sal_Bool bIsFineHdl(pHdlList->IsFineHdl());
685cdf0e10cSrcweir 	const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
686cdf0e10cSrcweir 	sal_Bool bIsHighContrast(rStyleSettings.GetHighContrastMode());
687cdf0e10cSrcweir 
688cdf0e10cSrcweir 	// support bigger sizes
689cdf0e10cSrcweir 	sal_Bool bForceBiggerSize(sal_False);
690cdf0e10cSrcweir 
691cdf0e10cSrcweir 	if(pHdlList->GetHdlSize() > 3)
692cdf0e10cSrcweir 	{
6934772d9afSArmin Le Grand         switch(eKindOfMarker)
6944772d9afSArmin Le Grand         {
6954772d9afSArmin Le Grand             case Anchor:
6964772d9afSArmin Le Grand             case AnchorPressed:
6974772d9afSArmin Le Grand             case AnchorTR:
6984772d9afSArmin Le Grand             case AnchorPressedTR:
6994772d9afSArmin Le Grand             {
7004772d9afSArmin Le Grand                 // #121463# For anchor, do not simply make bigger because of HdlSize,
7014772d9afSArmin Le Grand                 // do it dependent of IsSelected() which Writer can set in drag mode
7024772d9afSArmin Le Grand                 if(IsSelected())
7034772d9afSArmin Le Grand                 {
7044772d9afSArmin Le Grand                     bForceBiggerSize = sal_True;
7054772d9afSArmin Le Grand                 }
7064772d9afSArmin Le Grand                 break;
7074772d9afSArmin Le Grand             }
7084772d9afSArmin Le Grand             default:
7094772d9afSArmin Le Grand             {
7104772d9afSArmin Le Grand                 bForceBiggerSize = sal_True;
7114772d9afSArmin Le Grand                 break;
7124772d9afSArmin Le Grand             }
7134772d9afSArmin Le Grand         }
714cdf0e10cSrcweir 	}
715cdf0e10cSrcweir 
716cdf0e10cSrcweir 	// #101928# ...for high contrast, too.
717cdf0e10cSrcweir 	if(!bForceBiggerSize && bIsHighContrast)
718cdf0e10cSrcweir 	{
719cdf0e10cSrcweir 		// #107925#
720cdf0e10cSrcweir 		// ...but not for anchors, else they will not blink when activated
721cdf0e10cSrcweir 		if(Anchor != eKindOfMarker && AnchorTR != eKindOfMarker)
722cdf0e10cSrcweir 		{
723cdf0e10cSrcweir 			bForceBiggerSize = sal_True;
724cdf0e10cSrcweir 		}
725cdf0e10cSrcweir 	}
726cdf0e10cSrcweir 
727cdf0e10cSrcweir 	if(bForceBiggerSize)
728cdf0e10cSrcweir 	{
729cdf0e10cSrcweir 		eKindOfMarker = GetNextBigger(eKindOfMarker);
730cdf0e10cSrcweir 	}
731cdf0e10cSrcweir 
732cdf0e10cSrcweir 	// #97016# II This handle has the focus, visualize it
733cdf0e10cSrcweir 	if(IsFocusHdl() && pHdlList && pHdlList->GetFocusHdl() == this)
734cdf0e10cSrcweir 	{
735cdf0e10cSrcweir 		// create animated handle
736cdf0e10cSrcweir 		BitmapMarkerKind eNextBigger = GetNextBigger(eKindOfMarker);
737cdf0e10cSrcweir 
738cdf0e10cSrcweir 		if(eNextBigger == eKindOfMarker)
739cdf0e10cSrcweir 		{
740cdf0e10cSrcweir 			// this may happen for the not supported getting-bigger types.
741cdf0e10cSrcweir 			// Choose an alternative here
742cdf0e10cSrcweir 			switch(eKindOfMarker)
743cdf0e10cSrcweir 			{
744cdf0e10cSrcweir 				case Rect_13x13:		eNextBigger = Rect_11x11;	break;
745cdf0e10cSrcweir 				case Circ_11x11:		eNextBigger = Elli_11x9;	break;
746cdf0e10cSrcweir 				case Elli_9x11:			eNextBigger = Elli_11x9;	break;
747cdf0e10cSrcweir 				case Elli_11x9:			eNextBigger = Elli_9x11;	break;
748cdf0e10cSrcweir 				case RectPlus_11x11:	eNextBigger = Rect_13x13;	break;
749cdf0e10cSrcweir 
750cdf0e10cSrcweir 				case Crosshair:
751cdf0e10cSrcweir 					eNextBigger = Glue;
752cdf0e10cSrcweir 					break;
753cdf0e10cSrcweir 
754cdf0e10cSrcweir 				case Glue:
755cdf0e10cSrcweir 					eNextBigger = Crosshair;
756cdf0e10cSrcweir 					break;
757cdf0e10cSrcweir                 default:
758cdf0e10cSrcweir                     break;
759cdf0e10cSrcweir 			}
760cdf0e10cSrcweir 		}
761cdf0e10cSrcweir 
762cdf0e10cSrcweir 		// create animated hdl
763cdf0e10cSrcweir 		// #101928# use ImpGetBitmapEx(...) now
764cdf0e10cSrcweir 		BitmapEx aBmpEx1 = ImpGetBitmapEx(eKindOfMarker, (sal_uInt16)eColIndex, bIsFineHdl, bIsHighContrast);
765cdf0e10cSrcweir 		BitmapEx aBmpEx2 = ImpGetBitmapEx(eNextBigger, (sal_uInt16)eColIndex, bIsFineHdl, bIsHighContrast);
766cdf0e10cSrcweir 
767cdf0e10cSrcweir 		// #i53216# Use system cursor blink time. Use the unsigned value.
768cdf0e10cSrcweir 		const sal_uInt32 nBlinkTime((sal_uInt32)Application::GetSettings().GetStyleSettings().GetCursorBlinkTime());
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 		if(eKindOfMarker == Anchor || eKindOfMarker == AnchorPressed)
771cdf0e10cSrcweir 		{
772cdf0e10cSrcweir 			// #98388# when anchor is used take upper left as reference point inside the handle
773cdf0e10cSrcweir 			pRetval = new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos, aBmpEx1, aBmpEx2, nBlinkTime);
774cdf0e10cSrcweir 		}
775cdf0e10cSrcweir 		else if(eKindOfMarker == AnchorTR || eKindOfMarker == AnchorPressedTR)
776cdf0e10cSrcweir 		{
777cdf0e10cSrcweir 			// #101688# AnchorTR for SW, take top right as (0,0)
778cdf0e10cSrcweir 			pRetval = new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos, aBmpEx1, aBmpEx2, nBlinkTime,
779cdf0e10cSrcweir 				(sal_uInt16)(aBmpEx1.GetSizePixel().Width() - 1), 0,
780cdf0e10cSrcweir 				(sal_uInt16)(aBmpEx2.GetSizePixel().Width() - 1), 0);
781cdf0e10cSrcweir 		}
782cdf0e10cSrcweir 		else
783cdf0e10cSrcweir 		{
784cdf0e10cSrcweir 			// create centered handle as default
785cdf0e10cSrcweir 			pRetval = new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos, aBmpEx1, aBmpEx2, nBlinkTime,
786cdf0e10cSrcweir 				(sal_uInt16)(aBmpEx1.GetSizePixel().Width() - 1) >> 1,
787cdf0e10cSrcweir 				(sal_uInt16)(aBmpEx1.GetSizePixel().Height() - 1) >> 1,
788cdf0e10cSrcweir 				(sal_uInt16)(aBmpEx2.GetSizePixel().Width() - 1) >> 1,
789cdf0e10cSrcweir 				(sal_uInt16)(aBmpEx2.GetSizePixel().Height() - 1) >> 1);
790cdf0e10cSrcweir 		}
791cdf0e10cSrcweir 	}
792cdf0e10cSrcweir 	else
793cdf0e10cSrcweir 	{
794cdf0e10cSrcweir 		// create normal handle
795cdf0e10cSrcweir 		// #101928# use ImpGetBitmapEx(...) now
796cdf0e10cSrcweir 		BitmapEx aBmpEx = ImpGetBitmapEx(eKindOfMarker, (sal_uInt16)eColIndex, bIsFineHdl, bIsHighContrast);
797cdf0e10cSrcweir 
798cdf0e10cSrcweir 		if(eKindOfMarker == Anchor || eKindOfMarker == AnchorPressed)
799cdf0e10cSrcweir 		{
800cdf0e10cSrcweir 			// #98388# upper left as reference point inside the handle for AnchorPressed, too
801cdf0e10cSrcweir 			pRetval = new ::sdr::overlay::OverlayBitmapEx(rPos, aBmpEx);
802cdf0e10cSrcweir 		}
803cdf0e10cSrcweir 		else if(eKindOfMarker == AnchorTR || eKindOfMarker == AnchorPressedTR)
804cdf0e10cSrcweir 		{
805cdf0e10cSrcweir 			// #101688# AnchorTR for SW, take top right as (0,0)
806cdf0e10cSrcweir 			pRetval = new ::sdr::overlay::OverlayBitmapEx(rPos, aBmpEx,
807cdf0e10cSrcweir 				(sal_uInt16)(aBmpEx.GetSizePixel().Width() - 1), 0);
808cdf0e10cSrcweir 		}
809cdf0e10cSrcweir 		else
810cdf0e10cSrcweir 		{
811cdf0e10cSrcweir 			sal_uInt16 nCenX((sal_uInt16)(aBmpEx.GetSizePixel().Width() - 1L) >> 1);
812cdf0e10cSrcweir 			sal_uInt16 nCenY((sal_uInt16)(aBmpEx.GetSizePixel().Height() - 1L) >> 1);
813cdf0e10cSrcweir 
814cdf0e10cSrcweir 			if(aMoveOutsideOffset.X() > 0)
815cdf0e10cSrcweir 			{
816cdf0e10cSrcweir 				nCenX = 0;
817cdf0e10cSrcweir 			}
818cdf0e10cSrcweir 			else if(aMoveOutsideOffset.X() < 0)
819cdf0e10cSrcweir 			{
820cdf0e10cSrcweir 				nCenX = (sal_uInt16)(aBmpEx.GetSizePixel().Width() - 1);
821cdf0e10cSrcweir 			}
822cdf0e10cSrcweir 
823cdf0e10cSrcweir 			if(aMoveOutsideOffset.Y() > 0)
824cdf0e10cSrcweir 			{
825cdf0e10cSrcweir 				nCenY = 0;
826cdf0e10cSrcweir 			}
827cdf0e10cSrcweir 			else if(aMoveOutsideOffset.Y() < 0)
828cdf0e10cSrcweir 			{
829cdf0e10cSrcweir 				nCenY = (sal_uInt16)(aBmpEx.GetSizePixel().Height() - 1);
830cdf0e10cSrcweir 			}
831cdf0e10cSrcweir 
832cdf0e10cSrcweir 			// create centered handle as default
833cdf0e10cSrcweir 			pRetval = new ::sdr::overlay::OverlayBitmapEx(rPos, aBmpEx, nCenX, nCenY);
834cdf0e10cSrcweir 		}
835cdf0e10cSrcweir 	}
836cdf0e10cSrcweir 
837cdf0e10cSrcweir 	return pRetval;
838cdf0e10cSrcweir }
839cdf0e10cSrcweir 
840cdf0e10cSrcweir bool SdrHdl::IsHdlHit(const Point& rPnt) const
841cdf0e10cSrcweir {
842cdf0e10cSrcweir 	// OVERLAYMANAGER
843cdf0e10cSrcweir 	basegfx::B2DPoint aPosition(rPnt.X(), rPnt.Y());
844cdf0e10cSrcweir 	return maOverlayGroup.isHitLogic(aPosition);
845cdf0e10cSrcweir }
846cdf0e10cSrcweir 
847cdf0e10cSrcweir Pointer SdrHdl::GetPointer() const
848cdf0e10cSrcweir {
849cdf0e10cSrcweir     PointerStyle ePtr=POINTER_MOVE;
850cdf0e10cSrcweir     const sal_Bool bSize=eKind>=HDL_UPLFT && eKind<=HDL_LWRGT;
851cdf0e10cSrcweir     const sal_Bool bRot=pHdlList!=NULL && pHdlList->IsRotateShear();
852cdf0e10cSrcweir     const sal_Bool bDis=pHdlList!=NULL && pHdlList->IsDistortShear();
853cdf0e10cSrcweir     if (bSize && pHdlList!=NULL && (bRot || bDis)) {
854cdf0e10cSrcweir         switch (eKind) {
855cdf0e10cSrcweir             case HDL_UPLFT: case HDL_UPRGT:
856cdf0e10cSrcweir             case HDL_LWLFT: case HDL_LWRGT: ePtr=bRot ? POINTER_ROTATE : POINTER_REFHAND; break;
857cdf0e10cSrcweir             case HDL_LEFT : case HDL_RIGHT: ePtr=POINTER_VSHEAR; break;
858cdf0e10cSrcweir             case HDL_UPPER: case HDL_LOWER: ePtr=POINTER_HSHEAR; break;
859cdf0e10cSrcweir             default:
860cdf0e10cSrcweir                 break;
861cdf0e10cSrcweir         }
862cdf0e10cSrcweir     } else {
863cdf0e10cSrcweir         // Fuer Resize von gedrehten Rechtecken die Mauszeiger etwas mitdrehen
864cdf0e10cSrcweir         if (bSize && nDrehWink!=0) {
865cdf0e10cSrcweir             long nHdlWink=0;
866cdf0e10cSrcweir             switch (eKind) {
867cdf0e10cSrcweir                 case HDL_LWRGT: nHdlWink=31500; break;
868cdf0e10cSrcweir                 case HDL_LOWER: nHdlWink=27000; break;
869cdf0e10cSrcweir                 case HDL_LWLFT: nHdlWink=22500; break;
870cdf0e10cSrcweir                 case HDL_LEFT : nHdlWink=18000; break;
871cdf0e10cSrcweir                 case HDL_UPLFT: nHdlWink=13500; break;
872cdf0e10cSrcweir                 case HDL_UPPER: nHdlWink=9000;  break;
873cdf0e10cSrcweir                 case HDL_UPRGT: nHdlWink=4500;  break;
874cdf0e10cSrcweir                 case HDL_RIGHT: nHdlWink=0;     break;
875cdf0e10cSrcweir                 default:
876cdf0e10cSrcweir                     break;
877cdf0e10cSrcweir             }
878cdf0e10cSrcweir             nHdlWink+=nDrehWink+2249; // und etwas drauf (zum runden)
879cdf0e10cSrcweir             while (nHdlWink<0) nHdlWink+=36000;
880cdf0e10cSrcweir             while (nHdlWink>=36000) nHdlWink-=36000;
881cdf0e10cSrcweir             nHdlWink/=4500;
882cdf0e10cSrcweir             switch ((sal_uInt8)nHdlWink) {
883cdf0e10cSrcweir                 case 0: ePtr=POINTER_ESIZE;  break;
884cdf0e10cSrcweir                 case 1: ePtr=POINTER_NESIZE; break;
885cdf0e10cSrcweir                 case 2: ePtr=POINTER_NSIZE;  break;
886cdf0e10cSrcweir                 case 3: ePtr=POINTER_NWSIZE; break;
887cdf0e10cSrcweir                 case 4: ePtr=POINTER_WSIZE;  break;
888cdf0e10cSrcweir                 case 5: ePtr=POINTER_SWSIZE; break;
889cdf0e10cSrcweir                 case 6: ePtr=POINTER_SSIZE;  break;
890cdf0e10cSrcweir                 case 7: ePtr=POINTER_SESIZE; break;
891cdf0e10cSrcweir             } // switch
892cdf0e10cSrcweir         } else {
893cdf0e10cSrcweir             switch (eKind) {
894cdf0e10cSrcweir                 case HDL_UPLFT: ePtr=POINTER_NWSIZE;  break;
895cdf0e10cSrcweir                 case HDL_UPPER: ePtr=POINTER_NSIZE;     break;
896cdf0e10cSrcweir                 case HDL_UPRGT: ePtr=POINTER_NESIZE;  break;
897cdf0e10cSrcweir                 case HDL_LEFT : ePtr=POINTER_WSIZE;     break;
898cdf0e10cSrcweir                 case HDL_RIGHT: ePtr=POINTER_ESIZE;     break;
899cdf0e10cSrcweir                 case HDL_LWLFT: ePtr=POINTER_SWSIZE;  break;
900cdf0e10cSrcweir                 case HDL_LOWER: ePtr=POINTER_SSIZE;     break;
901cdf0e10cSrcweir                 case HDL_LWRGT: ePtr=POINTER_SESIZE;  break;
902cdf0e10cSrcweir                 case HDL_POLY : ePtr=POINTER_MOVEPOINT; break;
903cdf0e10cSrcweir                 case HDL_CIRC : ePtr=POINTER_HAND;      break;
904cdf0e10cSrcweir                 case HDL_REF1 : ePtr=POINTER_REFHAND;   break;
905cdf0e10cSrcweir                 case HDL_REF2 : ePtr=POINTER_REFHAND;   break;
906cdf0e10cSrcweir                 case HDL_BWGT : ePtr=POINTER_MOVEBEZIERWEIGHT; break;
907cdf0e10cSrcweir                 case HDL_GLUE : ePtr=POINTER_MOVEPOINT; break;
908cdf0e10cSrcweir 				case HDL_CUSTOMSHAPE1 : ePtr=POINTER_HAND; break;
909cdf0e10cSrcweir                 default:
910cdf0e10cSrcweir                     break;
911cdf0e10cSrcweir             }
912cdf0e10cSrcweir         }
913cdf0e10cSrcweir     }
914cdf0e10cSrcweir     return Pointer(ePtr);
915cdf0e10cSrcweir }
916cdf0e10cSrcweir 
917cdf0e10cSrcweir // #97016# II
918cdf0e10cSrcweir sal_Bool SdrHdl::IsFocusHdl() const
919cdf0e10cSrcweir {
920cdf0e10cSrcweir 	switch(eKind)
921cdf0e10cSrcweir 	{
922cdf0e10cSrcweir 		case HDL_UPLFT:		// Oben links
923cdf0e10cSrcweir 		case HDL_UPPER:		// Oben
924cdf0e10cSrcweir 		case HDL_UPRGT:		// Oben rechts
925cdf0e10cSrcweir 		case HDL_LEFT:		// Links
926cdf0e10cSrcweir 		case HDL_RIGHT:		// Rechts
927cdf0e10cSrcweir 		case HDL_LWLFT:		// Unten links
928cdf0e10cSrcweir 		case HDL_LOWER:		// Unten
929cdf0e10cSrcweir 		case HDL_LWRGT:		// Unten rechts
930cdf0e10cSrcweir 		{
931cdf0e10cSrcweir 			// if it's a activated TextEdit, it's moved to extended points
932cdf0e10cSrcweir 			if(pHdlList && pHdlList->IsMoveOutside())
933cdf0e10cSrcweir 				return sal_False;
934cdf0e10cSrcweir 			else
935cdf0e10cSrcweir 				return sal_True;
936cdf0e10cSrcweir 		}
937cdf0e10cSrcweir 
938cdf0e10cSrcweir 		case HDL_MOVE:		// Handle zum Verschieben des Objekts
939cdf0e10cSrcweir 		case HDL_POLY:		// Punktselektion an Polygon oder Bezierkurve
940cdf0e10cSrcweir 		case HDL_BWGT:		// Gewicht an einer Bezierkurve
941cdf0e10cSrcweir 		case HDL_CIRC:		// Winkel an Kreissegmenten, Eckenradius am Rect
942cdf0e10cSrcweir 		case HDL_REF1:		// Referenzpunkt 1, z.B. Rotationsmitte
943cdf0e10cSrcweir 		case HDL_REF2:		// Referenzpunkt 2, z.B. Endpunkt der Spiegelachse
944cdf0e10cSrcweir 		//case HDL_MIRX:		// Die Spiegelachse selbst
945cdf0e10cSrcweir 		case HDL_GLUE:		// GluePoint
946cdf0e10cSrcweir 
947cdf0e10cSrcweir 		// #98388# do NOT activate here, let SW implement their own SdrHdl and
948cdf0e10cSrcweir 		// overload IsFocusHdl() there to make the anchor accessible
949cdf0e10cSrcweir 		//case HDL_ANCHOR:		// anchor symbol (SD, SW)
950cdf0e10cSrcweir 		// #101688# same for AnchorTR
951cdf0e10cSrcweir 		//case HDL_ANCHOR_TR:	// anchor symbol (SD, SW)
952cdf0e10cSrcweir 
953cdf0e10cSrcweir 		//case HDL_TRNS:		// interactive transparence
954cdf0e10cSrcweir 		//case HDL_GRAD:		// interactive gradient
955cdf0e10cSrcweir 		//case HDL_COLR:		// interactive color
956cdf0e10cSrcweir 
957cdf0e10cSrcweir 		// for SJ and the CustomShapeHandles:
958cdf0e10cSrcweir 		case HDL_CUSTOMSHAPE1:
959cdf0e10cSrcweir 
960cdf0e10cSrcweir 		case HDL_USER:
961cdf0e10cSrcweir 		{
962cdf0e10cSrcweir 			return sal_True;
963cdf0e10cSrcweir 		}
964cdf0e10cSrcweir 
965cdf0e10cSrcweir 		default:
966cdf0e10cSrcweir 		{
967cdf0e10cSrcweir 			return sal_False;
968cdf0e10cSrcweir 		}
969cdf0e10cSrcweir 	}
970cdf0e10cSrcweir }
971cdf0e10cSrcweir 
972cdf0e10cSrcweir void SdrHdl::onMouseEnter(const MouseEvent& /*rMEvt*/)
973cdf0e10cSrcweir {
974cdf0e10cSrcweir }
975cdf0e10cSrcweir 
976cdf0e10cSrcweir void SdrHdl::onMouseLeave()
977cdf0e10cSrcweir {
978cdf0e10cSrcweir }
979cdf0e10cSrcweir 
980cdf0e10cSrcweir bool SdrHdl::isMouseOver() const
981cdf0e10cSrcweir {
982cdf0e10cSrcweir 	return mbMouseOver;
983cdf0e10cSrcweir }
984cdf0e10cSrcweir 
985cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
986cdf0e10cSrcweir // class SdrHdlColor
987cdf0e10cSrcweir 
988cdf0e10cSrcweir SdrHdlColor::SdrHdlColor(const Point& rRef, Color aCol, const Size& rSize, sal_Bool bLum)
989cdf0e10cSrcweir :	SdrHdl(rRef, HDL_COLR),
990cdf0e10cSrcweir 	aMarkerSize(rSize),
991cdf0e10cSrcweir 	bUseLuminance(bLum)
992cdf0e10cSrcweir {
993cdf0e10cSrcweir 	if(IsUseLuminance())
994cdf0e10cSrcweir 		aCol = GetLuminance(aCol);
995cdf0e10cSrcweir 
996cdf0e10cSrcweir 	// remember color
997cdf0e10cSrcweir 	aMarkerColor = aCol;
998cdf0e10cSrcweir }
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir SdrHdlColor::~SdrHdlColor()
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir }
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir void SdrHdlColor::CreateB2dIAObject()
1005cdf0e10cSrcweir {
1006cdf0e10cSrcweir 	// first throw away old one
1007cdf0e10cSrcweir 	GetRidOfIAObject();
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir 	if(pHdlList)
1010cdf0e10cSrcweir 	{
1011cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir 		if(pView && !pView->areMarkHandlesHidden())
1014cdf0e10cSrcweir 		{
1015cdf0e10cSrcweir 			SdrPageView* pPageView = pView->GetSdrPageView();
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir 			if(pPageView)
1018cdf0e10cSrcweir 			{
1019cdf0e10cSrcweir 				for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1020cdf0e10cSrcweir 				{
1021cdf0e10cSrcweir 					// const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
1022cdf0e10cSrcweir 					const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir 					if(rPageWindow.GetPaintWindow().OutputToWindow())
1025cdf0e10cSrcweir 					{
1026cdf0e10cSrcweir 						if(rPageWindow.GetOverlayManager())
1027cdf0e10cSrcweir 						{
1028cdf0e10cSrcweir 							Bitmap aBmpCol(CreateColorDropper(aMarkerColor));
1029cdf0e10cSrcweir 							basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
1030cdf0e10cSrcweir 							::sdr::overlay::OverlayObject* pNewOverlayObject = new
1031cdf0e10cSrcweir 								::sdr::overlay::OverlayBitmapEx(
1032cdf0e10cSrcweir 									aPosition,
1033cdf0e10cSrcweir                                     BitmapEx(aBmpCol),
1034cdf0e10cSrcweir 									(sal_uInt16)(aBmpCol.GetSizePixel().Width() - 1) >> 1,
1035cdf0e10cSrcweir 									(sal_uInt16)(aBmpCol.GetSizePixel().Height() - 1) >> 1
1036cdf0e10cSrcweir 								);
1037cdf0e10cSrcweir 							DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
1038cdf0e10cSrcweir 
1039cdf0e10cSrcweir 							// OVERLAYMANAGER
1040cdf0e10cSrcweir 							if(pNewOverlayObject)
1041cdf0e10cSrcweir 							{
1042cdf0e10cSrcweir 								rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1043cdf0e10cSrcweir 								maOverlayGroup.append(*pNewOverlayObject);
1044cdf0e10cSrcweir 							}
1045cdf0e10cSrcweir 						}
1046cdf0e10cSrcweir 					}
1047cdf0e10cSrcweir 				}
1048cdf0e10cSrcweir 			}
1049cdf0e10cSrcweir 		}
1050cdf0e10cSrcweir 	}
1051cdf0e10cSrcweir }
1052cdf0e10cSrcweir 
1053cdf0e10cSrcweir Bitmap SdrHdlColor::CreateColorDropper(Color aCol)
1054cdf0e10cSrcweir {
1055cdf0e10cSrcweir 	// get the Bitmap
1056cdf0e10cSrcweir 	Bitmap aRetval(aMarkerSize, 24);
1057cdf0e10cSrcweir 	aRetval.Erase(aCol);
1058cdf0e10cSrcweir 
1059cdf0e10cSrcweir 	// get write access
1060cdf0e10cSrcweir 	BitmapWriteAccess* pWrite = aRetval.AcquireWriteAccess();
1061cdf0e10cSrcweir 	DBG_ASSERT(pWrite, "Got NO write access to a new Bitmap !!!");
1062cdf0e10cSrcweir 
1063cdf0e10cSrcweir 	if(pWrite)
1064cdf0e10cSrcweir 	{
1065cdf0e10cSrcweir 		// draw outer border
1066cdf0e10cSrcweir 		sal_Int32 nWidth = aMarkerSize.Width();
1067cdf0e10cSrcweir 		sal_Int32 nHeight = aMarkerSize.Height();
1068cdf0e10cSrcweir 
1069cdf0e10cSrcweir 		pWrite->SetLineColor(Color(COL_LIGHTGRAY));
1070cdf0e10cSrcweir 		pWrite->DrawLine(Point(0, 0), Point(0, nHeight - 1));
1071cdf0e10cSrcweir 		pWrite->DrawLine(Point(1, 0), Point(nWidth - 1, 0));
1072cdf0e10cSrcweir 		pWrite->SetLineColor(Color(COL_GRAY));
1073cdf0e10cSrcweir 		pWrite->DrawLine(Point(1, nHeight - 1), Point(nWidth - 1, nHeight - 1));
1074cdf0e10cSrcweir 		pWrite->DrawLine(Point(nWidth - 1, 1), Point(nWidth - 1, nHeight - 2));
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir 		// draw lighter UpperLeft
1077cdf0e10cSrcweir         const Color aLightColor(
1078cdf0e10cSrcweir             (sal_uInt8)(::std::min((sal_Int16)((sal_Int16)aCol.GetRed() + (sal_Int16)0x0040), (sal_Int16)0x00ff)),
1079cdf0e10cSrcweir             (sal_uInt8)(::std::min((sal_Int16)((sal_Int16)aCol.GetGreen() + (sal_Int16)0x0040), (sal_Int16)0x00ff)),
1080cdf0e10cSrcweir             (sal_uInt8)(::std::min((sal_Int16)((sal_Int16)aCol.GetBlue() + (sal_Int16)0x0040), (sal_Int16)0x00ff)));
1081cdf0e10cSrcweir 		pWrite->SetLineColor(aLightColor);
1082cdf0e10cSrcweir 		pWrite->DrawLine(Point(1, 1), Point(1, nHeight - 2));
1083cdf0e10cSrcweir 		pWrite->DrawLine(Point(2, 1), Point(nWidth - 2, 1));
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir 		// draw darker LowerRight
1086cdf0e10cSrcweir         const Color aDarkColor(
1087cdf0e10cSrcweir             (sal_uInt8)(::std::max((sal_Int16)((sal_Int16)aCol.GetRed() - (sal_Int16)0x0040), (sal_Int16)0x0000)),
1088cdf0e10cSrcweir             (sal_uInt8)(::std::max((sal_Int16)((sal_Int16)aCol.GetGreen() - (sal_Int16)0x0040), (sal_Int16)0x0000)),
1089cdf0e10cSrcweir             (sal_uInt8)(::std::max((sal_Int16)((sal_Int16)aCol.GetBlue() - (sal_Int16)0x0040), (sal_Int16)0x0000)));
1090cdf0e10cSrcweir 		pWrite->SetLineColor(aDarkColor);
1091cdf0e10cSrcweir 		pWrite->DrawLine(Point(2, nHeight - 2), Point(nWidth - 2, nHeight - 2));
1092cdf0e10cSrcweir 		pWrite->DrawLine(Point(nWidth - 2, 2), Point(nWidth - 2, nHeight - 3));
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir 		// get rid of write access
1095cdf0e10cSrcweir 		delete pWrite;
1096cdf0e10cSrcweir 	}
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir 	return aRetval;
1099cdf0e10cSrcweir }
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir Color SdrHdlColor::GetLuminance(const Color& rCol)
1102cdf0e10cSrcweir {
1103cdf0e10cSrcweir 	sal_uInt8 aLum = rCol.GetLuminance();
1104cdf0e10cSrcweir 	Color aRetval(aLum, aLum, aLum);
1105cdf0e10cSrcweir 	return aRetval;
1106cdf0e10cSrcweir }
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir void SdrHdlColor::CallColorChangeLink()
1109cdf0e10cSrcweir {
1110cdf0e10cSrcweir 	aColorChangeHdl.Call(this);
1111cdf0e10cSrcweir }
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir void SdrHdlColor::SetColor(Color aNew, sal_Bool bCallLink)
1114cdf0e10cSrcweir {
1115cdf0e10cSrcweir 	if(IsUseLuminance())
1116cdf0e10cSrcweir 		aNew = GetLuminance(aNew);
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir 	if(aMarkerColor != aNew)
1119cdf0e10cSrcweir 	{
1120cdf0e10cSrcweir 		// remember new color
1121cdf0e10cSrcweir 		aMarkerColor = aNew;
1122cdf0e10cSrcweir 
1123cdf0e10cSrcweir 		// create new display
1124cdf0e10cSrcweir 		Touch();
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir 		// tell about change
1127cdf0e10cSrcweir 		if(bCallLink)
1128cdf0e10cSrcweir 			CallColorChangeLink();
1129cdf0e10cSrcweir 	}
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir 
1132cdf0e10cSrcweir void SdrHdlColor::SetSize(const Size& rNew)
1133cdf0e10cSrcweir {
1134cdf0e10cSrcweir 	if(rNew != aMarkerSize)
1135cdf0e10cSrcweir 	{
1136cdf0e10cSrcweir 		// remember new size
1137cdf0e10cSrcweir 		aMarkerSize = rNew;
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir 		// create new display
1140cdf0e10cSrcweir 		Touch();
1141cdf0e10cSrcweir 	}
1142cdf0e10cSrcweir }
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1145cdf0e10cSrcweir // class SdrHdlGradient
1146cdf0e10cSrcweir 
1147cdf0e10cSrcweir SdrHdlGradient::SdrHdlGradient(const Point& rRef1, const Point& rRef2, sal_Bool bGrad)
1148cdf0e10cSrcweir :	SdrHdl(rRef1, bGrad ? HDL_GRAD : HDL_TRNS),
1149cdf0e10cSrcweir 	pColHdl1(NULL),
1150cdf0e10cSrcweir 	pColHdl2(NULL),
1151cdf0e10cSrcweir     a2ndPos(rRef2),
1152cdf0e10cSrcweir     bGradient(bGrad)
1153cdf0e10cSrcweir {
1154cdf0e10cSrcweir }
1155cdf0e10cSrcweir 
1156cdf0e10cSrcweir SdrHdlGradient::~SdrHdlGradient()
1157cdf0e10cSrcweir {
1158cdf0e10cSrcweir }
1159cdf0e10cSrcweir 
1160cdf0e10cSrcweir void SdrHdlGradient::Set2ndPos(const Point& rPnt)
1161cdf0e10cSrcweir {
1162cdf0e10cSrcweir 	if(a2ndPos != rPnt)
1163cdf0e10cSrcweir 	{
1164cdf0e10cSrcweir 		// remember new position
1165cdf0e10cSrcweir 		a2ndPos = rPnt;
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir 		// create new display
1168cdf0e10cSrcweir 		Touch();
1169cdf0e10cSrcweir 	}
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir 
1172cdf0e10cSrcweir void SdrHdlGradient::CreateB2dIAObject()
1173cdf0e10cSrcweir {
1174cdf0e10cSrcweir 	// first throw away old one
1175cdf0e10cSrcweir 	GetRidOfIAObject();
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir 	if(pHdlList)
1178cdf0e10cSrcweir 	{
1179cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir 		if(pView && !pView->areMarkHandlesHidden())
1182cdf0e10cSrcweir 		{
1183cdf0e10cSrcweir 			SdrPageView* pPageView = pView->GetSdrPageView();
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir 			if(pPageView)
1186cdf0e10cSrcweir 			{
1187cdf0e10cSrcweir 				for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1188cdf0e10cSrcweir 				{
1189cdf0e10cSrcweir 					const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1190cdf0e10cSrcweir 
1191cdf0e10cSrcweir 					if(rPageWindow.GetPaintWindow().OutputToWindow())
1192cdf0e10cSrcweir 					{
1193cdf0e10cSrcweir 						if(rPageWindow.GetOverlayManager())
1194cdf0e10cSrcweir 						{
1195cdf0e10cSrcweir 							// striped line in between
1196cdf0e10cSrcweir 							basegfx::B2DVector aVec(a2ndPos.X() - aPos.X(), a2ndPos.Y() - aPos.Y());
1197cdf0e10cSrcweir 							double fVecLen = aVec.getLength();
1198cdf0e10cSrcweir 							double fLongPercentArrow = (1.0 - 0.05) * fVecLen;
1199cdf0e10cSrcweir 							double fHalfArrowWidth = (0.05 * 0.5) * fVecLen;
1200cdf0e10cSrcweir 							aVec.normalize();
1201cdf0e10cSrcweir 							basegfx::B2DVector aPerpend(-aVec.getY(), aVec.getX());
1202cdf0e10cSrcweir 							sal_Int32 nMidX = (sal_Int32)(aPos.X() + aVec.getX() * fLongPercentArrow);
1203cdf0e10cSrcweir 							sal_Int32 nMidY = (sal_Int32)(aPos.Y() + aVec.getY() * fLongPercentArrow);
1204cdf0e10cSrcweir 							Point aMidPoint(nMidX, nMidY);
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir 							basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
1207cdf0e10cSrcweir 							basegfx::B2DPoint aMidPos(aMidPoint.X(), aMidPoint.Y());
1208cdf0e10cSrcweir 
1209cdf0e10cSrcweir 							::sdr::overlay::OverlayObject* pNewOverlayObject = new
1210cdf0e10cSrcweir 								::sdr::overlay::OverlayLineStriped(
1211cdf0e10cSrcweir 									aPosition, aMidPos
1212cdf0e10cSrcweir 								);
1213cdf0e10cSrcweir 							DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir 							pNewOverlayObject->setBaseColor(IsGradient() ? Color(COL_BLACK) : Color(COL_BLUE));
1216cdf0e10cSrcweir 							rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1217cdf0e10cSrcweir 							maOverlayGroup.append(*pNewOverlayObject);
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir 							// arrowhead
1220cdf0e10cSrcweir 							Point aLeft(aMidPoint.X() + (sal_Int32)(aPerpend.getX() * fHalfArrowWidth),
1221cdf0e10cSrcweir 										aMidPoint.Y() + (sal_Int32)(aPerpend.getY() * fHalfArrowWidth));
1222cdf0e10cSrcweir 							Point aRight(aMidPoint.X() - (sal_Int32)(aPerpend.getX() * fHalfArrowWidth),
1223cdf0e10cSrcweir 										aMidPoint.Y() - (sal_Int32)(aPerpend.getY() * fHalfArrowWidth));
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir 							basegfx::B2DPoint aPositionLeft(aLeft.X(), aLeft.Y());
1226cdf0e10cSrcweir 							basegfx::B2DPoint aPositionRight(aRight.X(), aRight.Y());
1227cdf0e10cSrcweir 							basegfx::B2DPoint aPosition2(a2ndPos.X(), a2ndPos.Y());
1228cdf0e10cSrcweir 
1229cdf0e10cSrcweir 							pNewOverlayObject = new
1230cdf0e10cSrcweir 								::sdr::overlay::OverlayTriangle(
1231cdf0e10cSrcweir 									aPositionLeft,
1232cdf0e10cSrcweir                                     aPosition2,
1233cdf0e10cSrcweir                                     aPositionRight,
1234cdf0e10cSrcweir                                     IsGradient() ? Color(COL_BLACK) : Color(COL_BLUE)
1235cdf0e10cSrcweir 								);
1236cdf0e10cSrcweir 							DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir 							rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1239cdf0e10cSrcweir 							maOverlayGroup.append(*pNewOverlayObject);
1240cdf0e10cSrcweir 						}
1241cdf0e10cSrcweir 					}
1242cdf0e10cSrcweir 				}
1243cdf0e10cSrcweir 			}
1244cdf0e10cSrcweir 		}
1245cdf0e10cSrcweir 	}
1246cdf0e10cSrcweir }
1247cdf0e10cSrcweir 
1248cdf0e10cSrcweir IMPL_LINK(SdrHdlGradient, ColorChangeHdl, SdrHdl*, /*pHdl*/)
1249cdf0e10cSrcweir {
1250cdf0e10cSrcweir 	if(GetObj())
1251cdf0e10cSrcweir 		FromIAOToItem(GetObj(), sal_True, sal_True);
1252cdf0e10cSrcweir 	return 0;
1253cdf0e10cSrcweir }
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir void SdrHdlGradient::FromIAOToItem(SdrObject* _pObj, sal_Bool bSetItemOnObject, sal_Bool bUndo)
1256cdf0e10cSrcweir {
1257cdf0e10cSrcweir 	// from IAO positions and colors to gradient
1258cdf0e10cSrcweir     const SfxItemSet& rSet = _pObj->GetMergedItemSet();
1259cdf0e10cSrcweir 
1260cdf0e10cSrcweir 	GradTransformer aGradTransformer;
1261cdf0e10cSrcweir 	GradTransGradient aOldGradTransGradient;
1262cdf0e10cSrcweir 	GradTransGradient aGradTransGradient;
1263cdf0e10cSrcweir 	GradTransVector aGradTransVector;
1264cdf0e10cSrcweir 
1265cdf0e10cSrcweir 	String aString;
1266cdf0e10cSrcweir 
1267cdf0e10cSrcweir 	aGradTransVector.maPositionA = basegfx::B2DPoint(GetPos().X(), GetPos().Y());
1268cdf0e10cSrcweir 	aGradTransVector.maPositionB = basegfx::B2DPoint(Get2ndPos().X(), Get2ndPos().Y());
1269cdf0e10cSrcweir 	if(pColHdl1)
1270cdf0e10cSrcweir 		aGradTransVector.aCol1 = pColHdl1->GetColor();
1271cdf0e10cSrcweir 	if(pColHdl2)
1272cdf0e10cSrcweir 		aGradTransVector.aCol2 = pColHdl2->GetColor();
1273cdf0e10cSrcweir 
1274cdf0e10cSrcweir 	if(IsGradient())
1275cdf0e10cSrcweir 		aOldGradTransGradient.aGradient = ((XFillGradientItem&)rSet.Get(XATTR_FILLGRADIENT)).GetGradientValue();
1276cdf0e10cSrcweir 	else
1277cdf0e10cSrcweir 		aOldGradTransGradient.aGradient = ((XFillFloatTransparenceItem&)rSet.Get(XATTR_FILLFLOATTRANSPARENCE)).GetGradientValue();
1278cdf0e10cSrcweir 
1279cdf0e10cSrcweir 	// transform vector data to gradient
1280cdf0e10cSrcweir     aGradTransformer.VecToGrad(aGradTransVector, aGradTransGradient, aOldGradTransGradient, _pObj, bMoveSingleHandle, bMoveFirstHandle);
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir 	if(bSetItemOnObject)
1283cdf0e10cSrcweir 	{
1284cdf0e10cSrcweir         SdrModel* pModel = _pObj->GetModel();
1285cdf0e10cSrcweir 		SfxItemSet aNewSet(pModel->GetItemPool());
1286cdf0e10cSrcweir 
1287cdf0e10cSrcweir 		if(IsGradient())
1288cdf0e10cSrcweir 		{
1289cdf0e10cSrcweir 			aString = String();
1290cdf0e10cSrcweir 			XFillGradientItem aNewGradItem(aString, aGradTransGradient.aGradient);
1291cdf0e10cSrcweir 			aNewSet.Put(aNewGradItem);
1292cdf0e10cSrcweir 		}
1293cdf0e10cSrcweir 		else
1294cdf0e10cSrcweir 		{
1295cdf0e10cSrcweir 			aString = String();
1296cdf0e10cSrcweir 			XFillFloatTransparenceItem aNewTransItem(aString, aGradTransGradient.aGradient);
1297cdf0e10cSrcweir 			aNewSet.Put(aNewTransItem);
1298cdf0e10cSrcweir 		}
1299cdf0e10cSrcweir 
1300cdf0e10cSrcweir 		if(bUndo && pModel->IsUndoEnabled())
1301cdf0e10cSrcweir 		{
1302cdf0e10cSrcweir 			pModel->BegUndo(SVX_RESSTR(IsGradient() ? SIP_XA_FILLGRADIENT : SIP_XA_FILLTRANSPARENCE));
1303cdf0e10cSrcweir 			pModel->AddUndo(pModel->GetSdrUndoFactory().CreateUndoAttrObject(*_pObj));
1304cdf0e10cSrcweir 			pModel->EndUndo();
1305cdf0e10cSrcweir 		}
1306cdf0e10cSrcweir 
1307cdf0e10cSrcweir 		pObj->SetMergedItemSetAndBroadcast(aNewSet);
1308cdf0e10cSrcweir 	}
1309cdf0e10cSrcweir 
1310cdf0e10cSrcweir 	// back transformation, set values on pIAOHandle
1311cdf0e10cSrcweir     aGradTransformer.GradToVec(aGradTransGradient, aGradTransVector, _pObj);
1312cdf0e10cSrcweir 
1313cdf0e10cSrcweir 	SetPos(Point(FRound(aGradTransVector.maPositionA.getX()), FRound(aGradTransVector.maPositionA.getY())));
1314cdf0e10cSrcweir 	Set2ndPos(Point(FRound(aGradTransVector.maPositionB.getX()), FRound(aGradTransVector.maPositionB.getY())));
1315cdf0e10cSrcweir 	if(pColHdl1)
1316cdf0e10cSrcweir 	{
1317cdf0e10cSrcweir 		pColHdl1->SetPos(Point(FRound(aGradTransVector.maPositionA.getX()), FRound(aGradTransVector.maPositionA.getY())));
1318cdf0e10cSrcweir 		pColHdl1->SetColor(aGradTransVector.aCol1);
1319cdf0e10cSrcweir 	}
1320cdf0e10cSrcweir 	if(pColHdl2)
1321cdf0e10cSrcweir 	{
1322cdf0e10cSrcweir 		pColHdl2->SetPos(Point(FRound(aGradTransVector.maPositionB.getX()), FRound(aGradTransVector.maPositionB.getY())));
1323cdf0e10cSrcweir 		pColHdl2->SetColor(aGradTransVector.aCol2);
1324cdf0e10cSrcweir 	}
1325cdf0e10cSrcweir }
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir SdrHdlLine::~SdrHdlLine() {}
1330cdf0e10cSrcweir 
1331cdf0e10cSrcweir void SdrHdlLine::CreateB2dIAObject()
1332cdf0e10cSrcweir {
1333cdf0e10cSrcweir 	// first throw away old one
1334cdf0e10cSrcweir 	GetRidOfIAObject();
1335cdf0e10cSrcweir 
1336cdf0e10cSrcweir 	if(pHdlList)
1337cdf0e10cSrcweir 	{
1338cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
1339cdf0e10cSrcweir 
1340cdf0e10cSrcweir 		if(pView && !pView->areMarkHandlesHidden() && pHdl1 && pHdl2)
1341cdf0e10cSrcweir 		{
1342cdf0e10cSrcweir 			SdrPageView* pPageView = pView->GetSdrPageView();
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir 			if(pPageView)
1345cdf0e10cSrcweir 			{
1346cdf0e10cSrcweir 				for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1347cdf0e10cSrcweir 				{
1348cdf0e10cSrcweir 					const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1349cdf0e10cSrcweir 
1350cdf0e10cSrcweir 					if(rPageWindow.GetPaintWindow().OutputToWindow())
1351cdf0e10cSrcweir 					{
1352cdf0e10cSrcweir 						if(rPageWindow.GetOverlayManager())
1353cdf0e10cSrcweir 						{
1354cdf0e10cSrcweir 							basegfx::B2DPoint aPosition1(pHdl1->GetPos().X(), pHdl1->GetPos().Y());
1355cdf0e10cSrcweir 							basegfx::B2DPoint aPosition2(pHdl2->GetPos().X(), pHdl2->GetPos().Y());
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir 							::sdr::overlay::OverlayObject* pNewOverlayObject = new
1358cdf0e10cSrcweir 								::sdr::overlay::OverlayLineStriped(
1359cdf0e10cSrcweir 									aPosition1,
1360cdf0e10cSrcweir 									aPosition2
1361cdf0e10cSrcweir 								);
1362cdf0e10cSrcweir 							DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
1363cdf0e10cSrcweir 
1364cdf0e10cSrcweir 							// OVERLAYMANAGER
1365cdf0e10cSrcweir 							if(pNewOverlayObject)
1366cdf0e10cSrcweir 							{
1367cdf0e10cSrcweir 								// color(?)
1368cdf0e10cSrcweir 								pNewOverlayObject->setBaseColor(Color(COL_LIGHTRED));
1369cdf0e10cSrcweir 
1370cdf0e10cSrcweir 								rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1371cdf0e10cSrcweir 								maOverlayGroup.append(*pNewOverlayObject);
1372cdf0e10cSrcweir 							}
1373cdf0e10cSrcweir 						}
1374cdf0e10cSrcweir 					}
1375cdf0e10cSrcweir 				}
1376cdf0e10cSrcweir 			}
1377cdf0e10cSrcweir 		}
1378cdf0e10cSrcweir 	}
1379cdf0e10cSrcweir }
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir Pointer SdrHdlLine::GetPointer() const
1382cdf0e10cSrcweir {
1383cdf0e10cSrcweir     return Pointer(POINTER_REFHAND);
1384cdf0e10cSrcweir }
1385cdf0e10cSrcweir 
1386cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1387cdf0e10cSrcweir 
1388cdf0e10cSrcweir SdrHdlBezWgt::~SdrHdlBezWgt() {}
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir void SdrHdlBezWgt::CreateB2dIAObject()
1391cdf0e10cSrcweir {
1392cdf0e10cSrcweir 	// call parent
1393cdf0e10cSrcweir 	SdrHdl::CreateB2dIAObject();
1394cdf0e10cSrcweir 
1395cdf0e10cSrcweir 	// create lines
1396cdf0e10cSrcweir 	if(pHdlList)
1397cdf0e10cSrcweir 	{
1398cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
1399cdf0e10cSrcweir 
1400cdf0e10cSrcweir 		if(pView && !pView->areMarkHandlesHidden())
1401cdf0e10cSrcweir 		{
1402cdf0e10cSrcweir 			SdrPageView* pPageView = pView->GetSdrPageView();
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir 			if(pPageView)
1405cdf0e10cSrcweir 			{
1406cdf0e10cSrcweir 				for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1407cdf0e10cSrcweir 				{
1408cdf0e10cSrcweir 					const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir 					if(rPageWindow.GetPaintWindow().OutputToWindow())
1411cdf0e10cSrcweir 					{
1412cdf0e10cSrcweir 						if(rPageWindow.GetOverlayManager())
1413cdf0e10cSrcweir 						{
1414cdf0e10cSrcweir 							basegfx::B2DPoint aPosition1(pHdl1->GetPos().X(), pHdl1->GetPos().Y());
1415cdf0e10cSrcweir 							basegfx::B2DPoint aPosition2(aPos.X(), aPos.Y());
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir 							if(!aPosition1.equal(aPosition2))
1418cdf0e10cSrcweir 							{
1419cdf0e10cSrcweir 								::sdr::overlay::OverlayObject* pNewOverlayObject = new
1420cdf0e10cSrcweir 									::sdr::overlay::OverlayLineStriped(
1421cdf0e10cSrcweir 										aPosition1,
1422cdf0e10cSrcweir 										aPosition2
1423cdf0e10cSrcweir 									);
1424cdf0e10cSrcweir 								DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
1425cdf0e10cSrcweir 
1426cdf0e10cSrcweir 								// OVERLAYMANAGER
1427cdf0e10cSrcweir 								if(pNewOverlayObject)
1428cdf0e10cSrcweir 								{
1429cdf0e10cSrcweir 									// line part is not hittable
1430cdf0e10cSrcweir 									pNewOverlayObject->setHittable(sal_False);
1431cdf0e10cSrcweir 
1432cdf0e10cSrcweir 									// color(?)
1433cdf0e10cSrcweir 									pNewOverlayObject->setBaseColor(Color(COL_LIGHTBLUE));
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir 									rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1436cdf0e10cSrcweir 									maOverlayGroup.append(*pNewOverlayObject);
1437cdf0e10cSrcweir 								}
1438cdf0e10cSrcweir 							}
1439cdf0e10cSrcweir 						}
1440cdf0e10cSrcweir 					}
1441cdf0e10cSrcweir 				}
1442cdf0e10cSrcweir 			}
1443cdf0e10cSrcweir 		}
1444cdf0e10cSrcweir 	}
1445cdf0e10cSrcweir }
1446cdf0e10cSrcweir 
1447cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1448cdf0e10cSrcweir 
1449cdf0e10cSrcweir E3dVolumeMarker::E3dVolumeMarker(const basegfx::B2DPolyPolygon& rWireframePoly)
1450cdf0e10cSrcweir {
1451cdf0e10cSrcweir 	aWireframePoly = rWireframePoly;
1452cdf0e10cSrcweir }
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir void E3dVolumeMarker::CreateB2dIAObject()
1455cdf0e10cSrcweir {
1456cdf0e10cSrcweir 	// create lines
1457cdf0e10cSrcweir 	if(pHdlList)
1458cdf0e10cSrcweir 	{
1459cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
1460cdf0e10cSrcweir 
1461cdf0e10cSrcweir 		if(pView && !pView->areMarkHandlesHidden())
1462cdf0e10cSrcweir 		{
1463cdf0e10cSrcweir 			SdrPageView* pPageView = pView->GetSdrPageView();
1464cdf0e10cSrcweir 
1465cdf0e10cSrcweir 			if(pPageView)
1466cdf0e10cSrcweir 			{
1467cdf0e10cSrcweir 				for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1468cdf0e10cSrcweir 				{
1469cdf0e10cSrcweir 					const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1470cdf0e10cSrcweir 
1471cdf0e10cSrcweir 					if(rPageWindow.GetPaintWindow().OutputToWindow())
1472cdf0e10cSrcweir 					{
1473cdf0e10cSrcweir 						if(rPageWindow.GetOverlayManager() && aWireframePoly.count())
1474cdf0e10cSrcweir 							{
1475cdf0e10cSrcweir 								::sdr::overlay::OverlayObject* pNewOverlayObject = new
14761cd65da9SArmin Le Grand 								::sdr::overlay::OverlayPolyPolygonStripedAndFilled(
14771cd65da9SArmin Le Grand                                     aWireframePoly);
1478cdf0e10cSrcweir 								DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
1479cdf0e10cSrcweir 
1480cdf0e10cSrcweir 								// OVERLAYMANAGER
1481cdf0e10cSrcweir 								if(pNewOverlayObject)
1482cdf0e10cSrcweir 								{
1483cdf0e10cSrcweir 									pNewOverlayObject->setBaseColor(Color(COL_BLACK));
1484cdf0e10cSrcweir 
1485cdf0e10cSrcweir 									rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1486cdf0e10cSrcweir 									maOverlayGroup.append(*pNewOverlayObject);
1487cdf0e10cSrcweir 								}
1488cdf0e10cSrcweir 							}
1489cdf0e10cSrcweir 						}
1490cdf0e10cSrcweir 					}
1491cdf0e10cSrcweir 				}
1492cdf0e10cSrcweir 			}
1493cdf0e10cSrcweir 		}
1494cdf0e10cSrcweir 	}
1495cdf0e10cSrcweir 
1496cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1497cdf0e10cSrcweir 
1498cdf0e10cSrcweir ImpEdgeHdl::~ImpEdgeHdl()
1499cdf0e10cSrcweir {
1500cdf0e10cSrcweir }
1501cdf0e10cSrcweir 
1502cdf0e10cSrcweir void ImpEdgeHdl::CreateB2dIAObject()
1503cdf0e10cSrcweir {
1504cdf0e10cSrcweir 	if(nObjHdlNum <= 1 && pObj)
1505cdf0e10cSrcweir 	{
1506cdf0e10cSrcweir 		// first throw away old one
1507cdf0e10cSrcweir 		GetRidOfIAObject();
1508cdf0e10cSrcweir 
1509cdf0e10cSrcweir 		BitmapColorIndex eColIndex = LightCyan;
1510cdf0e10cSrcweir 		BitmapMarkerKind eKindOfMarker = Rect_7x7;
1511cdf0e10cSrcweir 
1512cdf0e10cSrcweir 		if(pHdlList)
1513cdf0e10cSrcweir 		{
1514cdf0e10cSrcweir 			SdrMarkView* pView = pHdlList->GetView();
1515cdf0e10cSrcweir 
1516cdf0e10cSrcweir 			if(pView && !pView->areMarkHandlesHidden())
1517cdf0e10cSrcweir 			{
1518cdf0e10cSrcweir 				const SdrEdgeObj* pEdge = (SdrEdgeObj*)pObj;
1519cdf0e10cSrcweir 
1520cdf0e10cSrcweir 				if(pEdge->GetConnectedNode(nObjHdlNum == 0) != NULL)
1521cdf0e10cSrcweir 					eColIndex = LightRed;
1522cdf0e10cSrcweir 
1523cdf0e10cSrcweir 				if(nPPntNum < 2)
1524cdf0e10cSrcweir 				{
1525cdf0e10cSrcweir 					// Handle with plus sign inside
1526cdf0e10cSrcweir 					eKindOfMarker = Circ_7x7;
1527cdf0e10cSrcweir 				}
1528cdf0e10cSrcweir 
1529cdf0e10cSrcweir 				SdrPageView* pPageView = pView->GetSdrPageView();
1530cdf0e10cSrcweir 
1531cdf0e10cSrcweir 				if(pPageView)
1532cdf0e10cSrcweir 				{
1533cdf0e10cSrcweir 					for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++)
1534cdf0e10cSrcweir 					{
1535cdf0e10cSrcweir 						const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1536cdf0e10cSrcweir 
1537cdf0e10cSrcweir 						if(rPageWindow.GetPaintWindow().OutputToWindow())
1538cdf0e10cSrcweir 						{
1539cdf0e10cSrcweir 							if(rPageWindow.GetOverlayManager())
1540cdf0e10cSrcweir 							{
1541cdf0e10cSrcweir 								basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
1542cdf0e10cSrcweir 
1543cdf0e10cSrcweir 								::sdr::overlay::OverlayObject* pNewOverlayObject = CreateOverlayObject(
1544cdf0e10cSrcweir 									aPosition,
1545cdf0e10cSrcweir 									eColIndex,
1546cdf0e10cSrcweir 									eKindOfMarker);
1547cdf0e10cSrcweir 
1548cdf0e10cSrcweir 								// OVERLAYMANAGER
1549cdf0e10cSrcweir 								if(pNewOverlayObject)
1550cdf0e10cSrcweir 								{
1551cdf0e10cSrcweir 									rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1552cdf0e10cSrcweir 									maOverlayGroup.append(*pNewOverlayObject);
1553cdf0e10cSrcweir 								}
1554cdf0e10cSrcweir 							}
1555cdf0e10cSrcweir 						}
1556cdf0e10cSrcweir 					}
1557cdf0e10cSrcweir 				}
1558cdf0e10cSrcweir 			}
1559cdf0e10cSrcweir 		}
1560cdf0e10cSrcweir 	}
1561cdf0e10cSrcweir 	else
1562cdf0e10cSrcweir 	{
1563cdf0e10cSrcweir 		// call parent
1564cdf0e10cSrcweir 		SdrHdl::CreateB2dIAObject();
1565cdf0e10cSrcweir 	}
1566cdf0e10cSrcweir }
1567cdf0e10cSrcweir 
1568cdf0e10cSrcweir void ImpEdgeHdl::SetLineCode(SdrEdgeLineCode eCode)
1569cdf0e10cSrcweir {
1570cdf0e10cSrcweir 	if(eLineCode != eCode)
1571cdf0e10cSrcweir 	{
1572cdf0e10cSrcweir 		// remember new value
1573cdf0e10cSrcweir 		eLineCode = eCode;
1574cdf0e10cSrcweir 
1575cdf0e10cSrcweir 		// create new display
1576cdf0e10cSrcweir 		Touch();
1577cdf0e10cSrcweir 	}
1578cdf0e10cSrcweir }
1579cdf0e10cSrcweir 
1580cdf0e10cSrcweir Pointer ImpEdgeHdl::GetPointer() const
1581cdf0e10cSrcweir {
1582cdf0e10cSrcweir     SdrEdgeObj* pEdge=PTR_CAST(SdrEdgeObj,pObj);
1583cdf0e10cSrcweir     if (pEdge==NULL)
1584cdf0e10cSrcweir 		return SdrHdl::GetPointer();
1585cdf0e10cSrcweir     if (nObjHdlNum<=1)
1586cdf0e10cSrcweir 		return Pointer(POINTER_MOVEPOINT); //Pointer(POINTER_DRAW_CONNECT);
1587cdf0e10cSrcweir     if (IsHorzDrag())
1588cdf0e10cSrcweir 		return Pointer(POINTER_ESIZE);
1589cdf0e10cSrcweir     else
1590cdf0e10cSrcweir 		return Pointer(POINTER_SSIZE);
1591cdf0e10cSrcweir }
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir sal_Bool ImpEdgeHdl::IsHorzDrag() const
1594cdf0e10cSrcweir {
1595cdf0e10cSrcweir     SdrEdgeObj* pEdge=PTR_CAST(SdrEdgeObj,pObj);
1596cdf0e10cSrcweir     if (pEdge==NULL)
1597cdf0e10cSrcweir 		return sal_False;
1598cdf0e10cSrcweir     if (nObjHdlNum<=1)
1599cdf0e10cSrcweir 		return sal_False;
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir 	SdrEdgeKind eEdgeKind = ((SdrEdgeKindItem&)(pEdge->GetObjectItem(SDRATTR_EDGEKIND))).GetValue();
1602cdf0e10cSrcweir 
1603cdf0e10cSrcweir 	const SdrEdgeInfoRec& rInfo=pEdge->aEdgeInfo;
1604cdf0e10cSrcweir     if (eEdgeKind==SDREDGE_ORTHOLINES || eEdgeKind==SDREDGE_BEZIER)
1605cdf0e10cSrcweir 	{
1606cdf0e10cSrcweir         return !rInfo.ImpIsHorzLine(eLineCode,*pEdge->pEdgeTrack);
1607cdf0e10cSrcweir     }
1608cdf0e10cSrcweir 	else if (eEdgeKind==SDREDGE_THREELINES)
1609cdf0e10cSrcweir 	{
1610cdf0e10cSrcweir         long nWink=nObjHdlNum==2 ? rInfo.nAngle1 : rInfo.nAngle2;
1611cdf0e10cSrcweir         if (nWink==0 || nWink==18000)
1612cdf0e10cSrcweir 			return sal_True;
1613cdf0e10cSrcweir         else
1614cdf0e10cSrcweir 			return sal_False;
1615cdf0e10cSrcweir     }
1616cdf0e10cSrcweir     return sal_False;
1617cdf0e10cSrcweir }
1618cdf0e10cSrcweir 
1619cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1620cdf0e10cSrcweir 
1621cdf0e10cSrcweir ImpMeasureHdl::~ImpMeasureHdl()
1622cdf0e10cSrcweir {
1623cdf0e10cSrcweir }
1624cdf0e10cSrcweir 
1625cdf0e10cSrcweir void ImpMeasureHdl::CreateB2dIAObject()
1626cdf0e10cSrcweir {
1627cdf0e10cSrcweir 	// first throw away old one
1628cdf0e10cSrcweir 	GetRidOfIAObject();
1629cdf0e10cSrcweir 
1630cdf0e10cSrcweir 	if(pHdlList)
1631cdf0e10cSrcweir 	{
1632cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
1633cdf0e10cSrcweir 
1634cdf0e10cSrcweir 		if(pView && !pView->areMarkHandlesHidden())
1635cdf0e10cSrcweir 		{
1636cdf0e10cSrcweir 			BitmapColorIndex eColIndex = LightCyan;
1637cdf0e10cSrcweir 			BitmapMarkerKind eKindOfMarker = Rect_9x9;
1638cdf0e10cSrcweir 
1639cdf0e10cSrcweir 			if(nObjHdlNum > 1)
1640cdf0e10cSrcweir 			{
1641cdf0e10cSrcweir 				eKindOfMarker = Rect_7x7;
1642cdf0e10cSrcweir 			}
1643cdf0e10cSrcweir 
1644cdf0e10cSrcweir 			if(bSelect)
1645cdf0e10cSrcweir 			{
1646cdf0e10cSrcweir 				eColIndex = Cyan;
1647cdf0e10cSrcweir 			}
1648cdf0e10cSrcweir 
1649cdf0e10cSrcweir 			SdrPageView* pPageView = pView->GetSdrPageView();
1650cdf0e10cSrcweir 
1651cdf0e10cSrcweir 			if(pPageView)
1652cdf0e10cSrcweir 			{
1653cdf0e10cSrcweir 				for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1654cdf0e10cSrcweir 				{
1655cdf0e10cSrcweir 					const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1656cdf0e10cSrcweir 
1657cdf0e10cSrcweir 					if(rPageWindow.GetPaintWindow().OutputToWindow())
1658cdf0e10cSrcweir 					{
1659cdf0e10cSrcweir 						if(rPageWindow.GetOverlayManager())
1660cdf0e10cSrcweir 						{
1661cdf0e10cSrcweir 							basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
1662cdf0e10cSrcweir 
1663cdf0e10cSrcweir 							::sdr::overlay::OverlayObject* pNewOverlayObject = CreateOverlayObject(
1664cdf0e10cSrcweir 								aPosition,
1665cdf0e10cSrcweir 								eColIndex,
1666cdf0e10cSrcweir 								eKindOfMarker);
1667cdf0e10cSrcweir 
1668cdf0e10cSrcweir 							// OVERLAYMANAGER
1669cdf0e10cSrcweir 							if(pNewOverlayObject)
1670cdf0e10cSrcweir 							{
1671cdf0e10cSrcweir 								rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1672cdf0e10cSrcweir 								maOverlayGroup.append(*pNewOverlayObject);
1673cdf0e10cSrcweir 							}
1674cdf0e10cSrcweir 						}
1675cdf0e10cSrcweir 					}
1676cdf0e10cSrcweir 				}
1677cdf0e10cSrcweir 			}
1678cdf0e10cSrcweir 		}
1679cdf0e10cSrcweir 	}
1680cdf0e10cSrcweir }
1681cdf0e10cSrcweir 
1682cdf0e10cSrcweir Pointer ImpMeasureHdl::GetPointer() const
1683cdf0e10cSrcweir {
1684cdf0e10cSrcweir     switch (nObjHdlNum)
1685cdf0e10cSrcweir 	{
1686cdf0e10cSrcweir         case 0: case 1: return Pointer(POINTER_HAND);
1687cdf0e10cSrcweir         case 2: case 3: return Pointer(POINTER_MOVEPOINT);
1688cdf0e10cSrcweir         case 4: case 5: return SdrHdl::GetPointer(); // wird dann entsprechend gedreht
1689cdf0e10cSrcweir     } // switch
1690cdf0e10cSrcweir     return Pointer(POINTER_NOTALLOWED);
1691cdf0e10cSrcweir }
1692cdf0e10cSrcweir 
1693cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1694cdf0e10cSrcweir 
1695cdf0e10cSrcweir ImpTextframeHdl::ImpTextframeHdl(const Rectangle& rRect) :
1696cdf0e10cSrcweir     SdrHdl(rRect.TopLeft(),HDL_MOVE),
1697cdf0e10cSrcweir     maRect(rRect)
1698cdf0e10cSrcweir {
1699cdf0e10cSrcweir }
1700cdf0e10cSrcweir 
1701cdf0e10cSrcweir void ImpTextframeHdl::CreateB2dIAObject()
1702cdf0e10cSrcweir {
1703cdf0e10cSrcweir 	// first throw away old one
1704cdf0e10cSrcweir 	GetRidOfIAObject();
1705cdf0e10cSrcweir 
1706cdf0e10cSrcweir 	if(pHdlList)
1707cdf0e10cSrcweir 	{
1708cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
1709cdf0e10cSrcweir 
1710cdf0e10cSrcweir 		if(pView && !pView->areMarkHandlesHidden())
1711cdf0e10cSrcweir 		{
1712cdf0e10cSrcweir 			SdrPageView* pPageView = pView->GetSdrPageView();
1713cdf0e10cSrcweir 
1714cdf0e10cSrcweir 			if(pPageView)
1715cdf0e10cSrcweir 			{
1716cdf0e10cSrcweir 				for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1717cdf0e10cSrcweir 				{
1718cdf0e10cSrcweir 					const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1719cdf0e10cSrcweir 
1720cdf0e10cSrcweir 					if(rPageWindow.GetPaintWindow().OutputToWindow())
1721cdf0e10cSrcweir 					{
1722cdf0e10cSrcweir 						if(rPageWindow.GetOverlayManager())
1723cdf0e10cSrcweir 						{
1724cdf0e10cSrcweir                             const basegfx::B2DPoint aTopLeft(maRect.Left(), maRect.Top());
1725cdf0e10cSrcweir                             const basegfx::B2DPoint aBottomRight(maRect.Right(), maRect.Bottom());
17261cd65da9SArmin Le Grand                             const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
17271cd65da9SArmin Le Grand                             const Color aHilightColor(aSvtOptionsDrawinglayer.getHilightColor());
17281cd65da9SArmin Le Grand                             const double fTransparence(aSvtOptionsDrawinglayer.GetTransparentSelectionPercent() * 0.01);
1729cdf0e10cSrcweir 
17301cd65da9SArmin Le Grand                             ::sdr::overlay::OverlayRectangle* pNewOverlayObject = new ::sdr::overlay::OverlayRectangle(
1731cdf0e10cSrcweir                                 aTopLeft,
1732cdf0e10cSrcweir                                 aBottomRight,
17331cd65da9SArmin Le Grand                                 aHilightColor,
17341cd65da9SArmin Le Grand                                 fTransparence,
1735cdf0e10cSrcweir                                 3.0,
1736cdf0e10cSrcweir                                 3.0,
17371cd65da9SArmin Le Grand                                 nDrehWink * -F_PI18000,
17381cd65da9SArmin Le Grand                                 500,
17391cd65da9SArmin Le Grand                                 true); // allow animation; the Handle is not shown at text edit time
17401cd65da9SArmin Le Grand 
1741cdf0e10cSrcweir                             pNewOverlayObject->setHittable(false);
1742cdf0e10cSrcweir 
1743cdf0e10cSrcweir                             // OVERLAYMANAGER
1744cdf0e10cSrcweir                             if(pNewOverlayObject)
1745cdf0e10cSrcweir                             {
1746cdf0e10cSrcweir                                 rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1747cdf0e10cSrcweir                                 maOverlayGroup.append(*pNewOverlayObject);
1748cdf0e10cSrcweir                             }
1749cdf0e10cSrcweir                         }
1750cdf0e10cSrcweir                     }
1751cdf0e10cSrcweir                 }
1752cdf0e10cSrcweir             }
1753cdf0e10cSrcweir 		}
1754cdf0e10cSrcweir 	}
1755cdf0e10cSrcweir }
1756cdf0e10cSrcweir 
1757cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1758cdf0e10cSrcweir 
1759cdf0e10cSrcweir class ImpSdrHdlListSorter: public ContainerSorter {
1760cdf0e10cSrcweir public:
1761cdf0e10cSrcweir     ImpSdrHdlListSorter(Container& rNewCont): ContainerSorter(rNewCont) {}
1762cdf0e10cSrcweir     virtual int Compare(const void* pElem1, const void* pElem2) const;
1763cdf0e10cSrcweir };
1764cdf0e10cSrcweir 
1765cdf0e10cSrcweir int ImpSdrHdlListSorter::Compare(const void* pElem1, const void* pElem2) const
1766cdf0e10cSrcweir {
1767cdf0e10cSrcweir     SdrHdlKind eKind1=((SdrHdl*)pElem1)->GetKind();
1768cdf0e10cSrcweir     SdrHdlKind eKind2=((SdrHdl*)pElem2)->GetKind();
1769cdf0e10cSrcweir     // Level 1: Erst normale Handles, dann Glue, dann User, dann Plushandles, dann Retpunkt-Handles
1770cdf0e10cSrcweir     unsigned n1=1;
1771cdf0e10cSrcweir     unsigned n2=1;
1772cdf0e10cSrcweir     if (eKind1!=eKind2)
1773cdf0e10cSrcweir 	{
1774cdf0e10cSrcweir         if (eKind1==HDL_REF1 || eKind1==HDL_REF2 || eKind1==HDL_MIRX) n1=5;
1775cdf0e10cSrcweir         else if (eKind1==HDL_GLUE) n1=2;
1776cdf0e10cSrcweir         else if (eKind1==HDL_USER) n1=3;
1777cdf0e10cSrcweir 		else if (eKind1==HDL_SMARTTAG) n1=0;
1778cdf0e10cSrcweir         if (eKind2==HDL_REF1 || eKind2==HDL_REF2 || eKind2==HDL_MIRX) n2=5;
1779cdf0e10cSrcweir         else if (eKind2==HDL_GLUE) n2=2;
1780cdf0e10cSrcweir         else if (eKind2==HDL_USER) n2=3;
1781cdf0e10cSrcweir 		else if (eKind2==HDL_SMARTTAG) n2=0;
1782cdf0e10cSrcweir     }
1783cdf0e10cSrcweir     if (((SdrHdl*)pElem1)->IsPlusHdl()) n1=4;
1784cdf0e10cSrcweir     if (((SdrHdl*)pElem2)->IsPlusHdl()) n2=4;
1785cdf0e10cSrcweir     if (n1==n2)
1786cdf0e10cSrcweir 	{
1787cdf0e10cSrcweir         // Level 2: PageView (Pointer)
1788cdf0e10cSrcweir         SdrPageView* pPV1=((SdrHdl*)pElem1)->GetPageView();
1789cdf0e10cSrcweir         SdrPageView* pPV2=((SdrHdl*)pElem2)->GetPageView();
1790cdf0e10cSrcweir         if (pPV1==pPV2)
1791cdf0e10cSrcweir 		{
1792cdf0e10cSrcweir             // Level 3: Position (x+y)
1793cdf0e10cSrcweir             SdrObject* pObj1=((SdrHdl*)pElem1)->GetObj();
1794cdf0e10cSrcweir             SdrObject* pObj2=((SdrHdl*)pElem2)->GetObj();
1795cdf0e10cSrcweir             if (pObj1==pObj2)
1796cdf0e10cSrcweir 			{
1797cdf0e10cSrcweir                 sal_uInt32 nNum1=((SdrHdl*)pElem1)->GetObjHdlNum();
1798cdf0e10cSrcweir                 sal_uInt32 nNum2=((SdrHdl*)pElem2)->GetObjHdlNum();
1799cdf0e10cSrcweir                 if (nNum1==nNum2)
1800cdf0e10cSrcweir 				{ // #48763#
1801cdf0e10cSrcweir                     if (eKind1==eKind2)
1802cdf0e10cSrcweir                         return (long)pElem1<(long)pElem2 ? -1 : 1; // Notloesung, um immer die gleiche Sortierung zu haben
1803cdf0e10cSrcweir                     return (sal_uInt16)eKind1<(sal_uInt16)eKind2 ? -1 : 1;
1804cdf0e10cSrcweir                 }
1805cdf0e10cSrcweir 				else
1806cdf0e10cSrcweir 					return nNum1<nNum2 ? -1 : 1;
1807cdf0e10cSrcweir             }
1808cdf0e10cSrcweir 			else
1809cdf0e10cSrcweir 			{
1810cdf0e10cSrcweir                 return (long)pObj1<(long)pObj2 ? -1 : 1;
1811cdf0e10cSrcweir             }
1812cdf0e10cSrcweir         }
1813cdf0e10cSrcweir 		else
1814cdf0e10cSrcweir 		{
1815cdf0e10cSrcweir             return (long)pPV1<(long)pPV2 ? -1 : 1;
1816cdf0e10cSrcweir         }
1817cdf0e10cSrcweir     }
1818cdf0e10cSrcweir 	else
1819cdf0e10cSrcweir 	{
1820cdf0e10cSrcweir         return n1<n2 ? -1 : 1;
1821cdf0e10cSrcweir     }
1822cdf0e10cSrcweir }
1823cdf0e10cSrcweir 
1824cdf0e10cSrcweir SdrMarkView* SdrHdlList::GetView() const
1825cdf0e10cSrcweir {
1826cdf0e10cSrcweir 	return pView;
1827cdf0e10cSrcweir }
1828cdf0e10cSrcweir 
1829cdf0e10cSrcweir // #105678# Help struct for re-sorting handles
1830cdf0e10cSrcweir struct ImplHdlAndIndex
1831cdf0e10cSrcweir {
1832cdf0e10cSrcweir 	SdrHdl*						mpHdl;
1833cdf0e10cSrcweir 	sal_uInt32					mnIndex;
1834cdf0e10cSrcweir };
1835cdf0e10cSrcweir 
1836cdf0e10cSrcweir // #105678# Help method for sorting handles taking care of OrdNums, keeping order in
1837cdf0e10cSrcweir // single objects and re-sorting polygon handles intuitively
1838cdf0e10cSrcweir extern "C" int __LOADONCALLAPI ImplSortHdlFunc( const void* pVoid1, const void* pVoid2 )
1839cdf0e10cSrcweir {
1840cdf0e10cSrcweir 	const ImplHdlAndIndex* p1 = (ImplHdlAndIndex*)pVoid1;
1841cdf0e10cSrcweir 	const ImplHdlAndIndex* p2 = (ImplHdlAndIndex*)pVoid2;
1842cdf0e10cSrcweir 
1843cdf0e10cSrcweir 	if(p1->mpHdl->GetObj() == p2->mpHdl->GetObj())
1844cdf0e10cSrcweir 	{
1845cdf0e10cSrcweir 		if(p1->mpHdl->GetObj() && p1->mpHdl->GetObj()->ISA(SdrPathObj))
1846cdf0e10cSrcweir 		{
1847cdf0e10cSrcweir 			// same object and a path object
1848cdf0e10cSrcweir 			if((p1->mpHdl->GetKind() == HDL_POLY || p1->mpHdl->GetKind() == HDL_BWGT)
1849cdf0e10cSrcweir 				&& (p2->mpHdl->GetKind() == HDL_POLY || p2->mpHdl->GetKind() == HDL_BWGT))
1850cdf0e10cSrcweir 			{
1851cdf0e10cSrcweir 				// both handles are point or control handles
1852cdf0e10cSrcweir 				if(p1->mpHdl->GetPolyNum() == p2->mpHdl->GetPolyNum())
1853cdf0e10cSrcweir 				{
1854cdf0e10cSrcweir 					if(p1->mpHdl->GetPointNum() < p2->mpHdl->GetPointNum())
1855cdf0e10cSrcweir 					{
1856cdf0e10cSrcweir 						return -1;
1857cdf0e10cSrcweir 					}
1858cdf0e10cSrcweir 					else
1859cdf0e10cSrcweir 					{
1860cdf0e10cSrcweir 						return 1;
1861cdf0e10cSrcweir 					}
1862cdf0e10cSrcweir 				}
1863cdf0e10cSrcweir 				else if(p1->mpHdl->GetPolyNum() < p2->mpHdl->GetPolyNum())
1864cdf0e10cSrcweir 				{
1865cdf0e10cSrcweir 					return -1;
1866cdf0e10cSrcweir 				}
1867cdf0e10cSrcweir 				else
1868cdf0e10cSrcweir 				{
1869cdf0e10cSrcweir 					return 1;
1870cdf0e10cSrcweir 				}
1871cdf0e10cSrcweir 			}
1872cdf0e10cSrcweir 		}
1873cdf0e10cSrcweir 	}
1874cdf0e10cSrcweir 	else
1875cdf0e10cSrcweir 	{
1876cdf0e10cSrcweir 		if(!p1->mpHdl->GetObj())
1877cdf0e10cSrcweir 		{
1878cdf0e10cSrcweir 			return -1;
1879cdf0e10cSrcweir 		}
1880cdf0e10cSrcweir 		else if(!p2->mpHdl->GetObj())
1881cdf0e10cSrcweir 		{
1882cdf0e10cSrcweir 			return 1;
1883cdf0e10cSrcweir 		}
1884cdf0e10cSrcweir 		else
1885cdf0e10cSrcweir 		{
1886cdf0e10cSrcweir 			// different objects, use OrdNum for sort
1887cdf0e10cSrcweir 			const sal_uInt32 nOrdNum1 = p1->mpHdl->GetObj()->GetOrdNum();
1888cdf0e10cSrcweir 			const sal_uInt32 nOrdNum2 = p2->mpHdl->GetObj()->GetOrdNum();
1889cdf0e10cSrcweir 
1890cdf0e10cSrcweir 			if(nOrdNum1 < nOrdNum2)
1891cdf0e10cSrcweir 			{
1892cdf0e10cSrcweir 				return -1;
1893cdf0e10cSrcweir 			}
1894cdf0e10cSrcweir 			else
1895cdf0e10cSrcweir 			{
1896cdf0e10cSrcweir 				return 1;
1897cdf0e10cSrcweir 			}
1898cdf0e10cSrcweir 		}
1899cdf0e10cSrcweir 	}
1900cdf0e10cSrcweir 
1901cdf0e10cSrcweir 	// fallback to indices
1902cdf0e10cSrcweir 	if(p1->mnIndex < p2->mnIndex)
1903cdf0e10cSrcweir 	{
1904cdf0e10cSrcweir 		return -1;
1905cdf0e10cSrcweir 	}
1906cdf0e10cSrcweir 	else
1907cdf0e10cSrcweir 	{
1908cdf0e10cSrcweir 		return 1;
1909cdf0e10cSrcweir 	}
1910cdf0e10cSrcweir }
1911cdf0e10cSrcweir 
1912cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1913cdf0e10cSrcweir // #97016# II
1914cdf0e10cSrcweir 
1915cdf0e10cSrcweir void SdrHdlList::TravelFocusHdl(sal_Bool bForward)
1916cdf0e10cSrcweir {
1917cdf0e10cSrcweir 	// security correction
1918cdf0e10cSrcweir 	if(mnFocusIndex != CONTAINER_ENTRY_NOTFOUND && mnFocusIndex >= GetHdlCount())
1919cdf0e10cSrcweir 		mnFocusIndex = CONTAINER_ENTRY_NOTFOUND;
1920cdf0e10cSrcweir 
1921cdf0e10cSrcweir 	if(aList.Count())
1922cdf0e10cSrcweir 	{
1923cdf0e10cSrcweir 		// take care of old handle
1924cdf0e10cSrcweir 		const sal_uIntPtr nOldHdlNum(mnFocusIndex);
1925cdf0e10cSrcweir 		SdrHdl* pOld = GetHdl(nOldHdlNum);
1926cdf0e10cSrcweir 		//SDOsal_Bool bRefresh(sal_False);
1927cdf0e10cSrcweir 
1928cdf0e10cSrcweir 		if(pOld)
1929cdf0e10cSrcweir 		{
1930cdf0e10cSrcweir 			// switch off old handle
1931cdf0e10cSrcweir 			mnFocusIndex = CONTAINER_ENTRY_NOTFOUND;
1932cdf0e10cSrcweir 			pOld->Touch();
1933cdf0e10cSrcweir 			//SDObRefresh = sal_True;
1934cdf0e10cSrcweir 		}
1935cdf0e10cSrcweir 
1936cdf0e10cSrcweir 		// #105678# Alloc pointer array for sorted handle list
1937cdf0e10cSrcweir 		ImplHdlAndIndex* pHdlAndIndex = new ImplHdlAndIndex[aList.Count()];
1938cdf0e10cSrcweir 
1939cdf0e10cSrcweir 		// #105678# build sorted handle list
1940cdf0e10cSrcweir 		sal_uInt32 a;
1941cdf0e10cSrcweir 		for( a = 0; a < aList.Count(); a++)
1942cdf0e10cSrcweir 		{
1943cdf0e10cSrcweir 			pHdlAndIndex[a].mpHdl = (SdrHdl*)aList.GetObject(a);
1944cdf0e10cSrcweir 			pHdlAndIndex[a].mnIndex = a;
1945cdf0e10cSrcweir 		}
1946cdf0e10cSrcweir 
1947cdf0e10cSrcweir 		// #105678# qsort all entries
1948cdf0e10cSrcweir 		qsort(pHdlAndIndex, aList.Count(), sizeof(ImplHdlAndIndex), ImplSortHdlFunc);
1949cdf0e10cSrcweir 
1950cdf0e10cSrcweir 		// #105678# look for old num in sorted array
1951cdf0e10cSrcweir 		sal_uIntPtr nOldHdl(nOldHdlNum);
1952cdf0e10cSrcweir 
1953cdf0e10cSrcweir 		if(nOldHdlNum != CONTAINER_ENTRY_NOTFOUND)
1954cdf0e10cSrcweir 		{
1955cdf0e10cSrcweir 			for(a = 0; a < aList.Count(); a++)
1956cdf0e10cSrcweir 			{
1957cdf0e10cSrcweir 				if(pHdlAndIndex[a].mpHdl == pOld)
1958cdf0e10cSrcweir 				{
1959cdf0e10cSrcweir 					nOldHdl = a;
1960cdf0e10cSrcweir 					break;
1961cdf0e10cSrcweir 				}
1962cdf0e10cSrcweir 			}
1963cdf0e10cSrcweir 		}
1964cdf0e10cSrcweir 
1965cdf0e10cSrcweir 		// #105678# build new HdlNum
1966cdf0e10cSrcweir 		sal_uIntPtr nNewHdl(nOldHdl);
1967cdf0e10cSrcweir 
1968cdf0e10cSrcweir 		// #105678# do the focus travel
1969cdf0e10cSrcweir 		if(bForward)
1970cdf0e10cSrcweir 		{
1971cdf0e10cSrcweir 			if(nOldHdl != CONTAINER_ENTRY_NOTFOUND)
1972cdf0e10cSrcweir 			{
1973cdf0e10cSrcweir 				if(nOldHdl == aList.Count() - 1)
1974cdf0e10cSrcweir 				{
1975cdf0e10cSrcweir 					// end forward run
1976cdf0e10cSrcweir 					nNewHdl = CONTAINER_ENTRY_NOTFOUND;
1977cdf0e10cSrcweir 				}
1978cdf0e10cSrcweir 				else
1979cdf0e10cSrcweir 				{
1980cdf0e10cSrcweir 					// simply the next handle
1981cdf0e10cSrcweir 					nNewHdl++;
1982cdf0e10cSrcweir 				}
1983cdf0e10cSrcweir 			}
1984cdf0e10cSrcweir 			else
1985cdf0e10cSrcweir 			{
1986cdf0e10cSrcweir 				// start forward run at first entry
1987cdf0e10cSrcweir 				nNewHdl = 0;
1988cdf0e10cSrcweir 			}
1989cdf0e10cSrcweir 		}
1990cdf0e10cSrcweir 		else
1991cdf0e10cSrcweir 		{
1992cdf0e10cSrcweir 			if(nOldHdl == CONTAINER_ENTRY_NOTFOUND)
1993cdf0e10cSrcweir 			{
1994cdf0e10cSrcweir 				// start backward run at last entry
1995cdf0e10cSrcweir 				nNewHdl = aList.Count() - 1;
1996cdf0e10cSrcweir 
1997cdf0e10cSrcweir 			}
1998cdf0e10cSrcweir 			else
1999cdf0e10cSrcweir 			{
2000cdf0e10cSrcweir 				if(nOldHdl == 0)
2001cdf0e10cSrcweir 				{
2002cdf0e10cSrcweir 					// end backward run
2003cdf0e10cSrcweir 					nNewHdl = CONTAINER_ENTRY_NOTFOUND;
2004cdf0e10cSrcweir 				}
2005cdf0e10cSrcweir 				else
2006cdf0e10cSrcweir 				{
2007cdf0e10cSrcweir 					// simply the previous handle
2008cdf0e10cSrcweir 					nNewHdl--;
2009cdf0e10cSrcweir 				}
2010cdf0e10cSrcweir 			}
2011cdf0e10cSrcweir 		}
2012cdf0e10cSrcweir 
2013cdf0e10cSrcweir 		// #105678# build new HdlNum
2014cdf0e10cSrcweir 		sal_uInt32 nNewHdlNum(nNewHdl);
2015cdf0e10cSrcweir 
2016cdf0e10cSrcweir 		// look for old num in sorted array
2017cdf0e10cSrcweir 		if(nNewHdl != CONTAINER_ENTRY_NOTFOUND)
2018cdf0e10cSrcweir 		{
2019cdf0e10cSrcweir 			SdrHdl* pNew = pHdlAndIndex[nNewHdl].mpHdl;
2020cdf0e10cSrcweir 
2021cdf0e10cSrcweir 			for(a = 0; a < aList.Count(); a++)
2022cdf0e10cSrcweir 			{
2023cdf0e10cSrcweir 				if((SdrHdl*)aList.GetObject(a) == pNew)
2024cdf0e10cSrcweir 				{
2025cdf0e10cSrcweir 					nNewHdlNum = a;
2026cdf0e10cSrcweir 					break;
2027cdf0e10cSrcweir 				}
2028cdf0e10cSrcweir 			}
2029cdf0e10cSrcweir 		}
2030cdf0e10cSrcweir 
2031cdf0e10cSrcweir 		// take care of next handle
2032cdf0e10cSrcweir 		if(nOldHdlNum != nNewHdlNum)
2033cdf0e10cSrcweir 		{
2034cdf0e10cSrcweir 			mnFocusIndex = nNewHdlNum;
2035cdf0e10cSrcweir 			SdrHdl* pNew = GetHdl(mnFocusIndex);
2036cdf0e10cSrcweir 
2037cdf0e10cSrcweir 			if(pNew)
2038cdf0e10cSrcweir 			{
2039cdf0e10cSrcweir 				pNew->Touch();
2040cdf0e10cSrcweir 				//SDObRefresh = sal_True;
2041cdf0e10cSrcweir 			}
2042cdf0e10cSrcweir 		}
2043cdf0e10cSrcweir 
2044cdf0e10cSrcweir 		// #105678# free mem again
2045cdf0e10cSrcweir 		delete [] pHdlAndIndex;
2046cdf0e10cSrcweir 	}
2047cdf0e10cSrcweir }
2048cdf0e10cSrcweir 
2049cdf0e10cSrcweir SdrHdl* SdrHdlList::GetFocusHdl() const
2050cdf0e10cSrcweir {
2051cdf0e10cSrcweir 	if(mnFocusIndex != CONTAINER_ENTRY_NOTFOUND && mnFocusIndex < GetHdlCount())
2052cdf0e10cSrcweir 		return GetHdl(mnFocusIndex);
2053cdf0e10cSrcweir 	else
2054cdf0e10cSrcweir 		return 0L;
2055cdf0e10cSrcweir }
2056cdf0e10cSrcweir 
2057cdf0e10cSrcweir void SdrHdlList::SetFocusHdl(SdrHdl* pNew)
2058cdf0e10cSrcweir {
2059cdf0e10cSrcweir 	if(pNew)
2060cdf0e10cSrcweir 	{
2061cdf0e10cSrcweir 		SdrHdl* pActual = GetFocusHdl();
2062cdf0e10cSrcweir 
2063cdf0e10cSrcweir 		if(!pActual || pActual != pNew)
2064cdf0e10cSrcweir 		{
2065cdf0e10cSrcweir 			sal_uIntPtr nNewHdlNum = GetHdlNum(pNew);
2066cdf0e10cSrcweir 
2067cdf0e10cSrcweir 			if(nNewHdlNum != CONTAINER_ENTRY_NOTFOUND)
2068cdf0e10cSrcweir 			{
2069cdf0e10cSrcweir 				//SDOsal_Bool bRefresh(sal_False);
2070cdf0e10cSrcweir 				mnFocusIndex = nNewHdlNum;
2071cdf0e10cSrcweir 
2072cdf0e10cSrcweir 				if(pActual)
2073cdf0e10cSrcweir 				{
2074cdf0e10cSrcweir 					pActual->Touch();
2075cdf0e10cSrcweir 					//SDObRefresh = sal_True;
2076cdf0e10cSrcweir 				}
2077cdf0e10cSrcweir 
2078cdf0e10cSrcweir 				if(pNew)
2079cdf0e10cSrcweir 				{
2080cdf0e10cSrcweir 					pNew->Touch();
2081cdf0e10cSrcweir 					//SDObRefresh = sal_True;
2082cdf0e10cSrcweir 				}
2083cdf0e10cSrcweir 
2084cdf0e10cSrcweir 				//OLMif(bRefresh)
2085cdf0e10cSrcweir 				//OLM{
2086cdf0e10cSrcweir 				//OLM	if(pView)
2087cdf0e10cSrcweir 				//OLM		pView->RefreshAllIAOManagers();
2088cdf0e10cSrcweir 				//OLM}
2089cdf0e10cSrcweir 			}
2090cdf0e10cSrcweir 		}
2091cdf0e10cSrcweir 	}
2092cdf0e10cSrcweir }
2093cdf0e10cSrcweir 
2094cdf0e10cSrcweir void SdrHdlList::ResetFocusHdl()
2095cdf0e10cSrcweir {
2096cdf0e10cSrcweir 	SdrHdl* pHdl = GetFocusHdl();
2097cdf0e10cSrcweir 
2098cdf0e10cSrcweir 	mnFocusIndex = CONTAINER_ENTRY_NOTFOUND;
2099cdf0e10cSrcweir 
2100cdf0e10cSrcweir 	if(pHdl)
2101cdf0e10cSrcweir 	{
2102cdf0e10cSrcweir 		pHdl->Touch();
2103cdf0e10cSrcweir 	}
2104cdf0e10cSrcweir }
2105cdf0e10cSrcweir 
2106cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2107cdf0e10cSrcweir 
2108cdf0e10cSrcweir SdrHdlList::SdrHdlList(SdrMarkView* pV)
2109cdf0e10cSrcweir :	mnFocusIndex(CONTAINER_ENTRY_NOTFOUND),
2110cdf0e10cSrcweir 	pView(pV),
2111cdf0e10cSrcweir 	aList(1024,32,32)
2112cdf0e10cSrcweir {
2113cdf0e10cSrcweir 	nHdlSize = 3;
2114cdf0e10cSrcweir 	bRotateShear = sal_False;
2115cdf0e10cSrcweir 	bMoveOutside = sal_False;
2116cdf0e10cSrcweir 	bDistortShear = sal_False;
21174772d9afSArmin Le Grand 	bFineHandles = sal_True;    // new default: Handles are fine handles
2118cdf0e10cSrcweir }
2119cdf0e10cSrcweir 
2120cdf0e10cSrcweir SdrHdlList::~SdrHdlList()
2121cdf0e10cSrcweir {
2122cdf0e10cSrcweir 	Clear();
2123cdf0e10cSrcweir }
2124cdf0e10cSrcweir 
2125cdf0e10cSrcweir void SdrHdlList::SetHdlSize(sal_uInt16 nSiz)
2126cdf0e10cSrcweir {
2127cdf0e10cSrcweir 	if(nHdlSize != nSiz)
2128cdf0e10cSrcweir 	{
2129cdf0e10cSrcweir 		// remember new value
2130cdf0e10cSrcweir 		nHdlSize = nSiz;
2131cdf0e10cSrcweir 
2132cdf0e10cSrcweir 		// propagate change to IAOs
2133cdf0e10cSrcweir 		for(sal_uInt32 i=0; i<GetHdlCount(); i++)
2134cdf0e10cSrcweir 		{
2135cdf0e10cSrcweir 			SdrHdl* pHdl = GetHdl(i);
2136cdf0e10cSrcweir 			pHdl->Touch();
2137cdf0e10cSrcweir 		}
2138cdf0e10cSrcweir 	}
2139cdf0e10cSrcweir }
2140cdf0e10cSrcweir 
2141cdf0e10cSrcweir void SdrHdlList::SetMoveOutside(sal_Bool bOn)
2142cdf0e10cSrcweir {
2143cdf0e10cSrcweir 	if(bMoveOutside != bOn)
2144cdf0e10cSrcweir 	{
2145cdf0e10cSrcweir 		// remember new value
2146cdf0e10cSrcweir 		bMoveOutside = bOn;
2147cdf0e10cSrcweir 
2148cdf0e10cSrcweir 		// propagate change to IAOs
2149cdf0e10cSrcweir 		for(sal_uInt32 i=0; i<GetHdlCount(); i++)
2150cdf0e10cSrcweir 		{
2151cdf0e10cSrcweir 			SdrHdl* pHdl = GetHdl(i);
2152cdf0e10cSrcweir 			pHdl->Touch();
2153cdf0e10cSrcweir 		}
2154cdf0e10cSrcweir 	}
2155cdf0e10cSrcweir }
2156cdf0e10cSrcweir 
2157cdf0e10cSrcweir void SdrHdlList::SetRotateShear(sal_Bool bOn)
2158cdf0e10cSrcweir {
2159cdf0e10cSrcweir 	bRotateShear = bOn;
2160cdf0e10cSrcweir }
2161cdf0e10cSrcweir 
2162cdf0e10cSrcweir void SdrHdlList::SetDistortShear(sal_Bool bOn)
2163cdf0e10cSrcweir {
2164cdf0e10cSrcweir 	bDistortShear = bOn;
2165cdf0e10cSrcweir }
2166cdf0e10cSrcweir 
2167cdf0e10cSrcweir void SdrHdlList::SetFineHdl(sal_Bool bOn)
2168cdf0e10cSrcweir {
2169cdf0e10cSrcweir 	if(bFineHandles != bOn)
2170cdf0e10cSrcweir 	{
2171cdf0e10cSrcweir 		// remember new state
2172cdf0e10cSrcweir 		bFineHandles = bOn;
2173cdf0e10cSrcweir 
2174cdf0e10cSrcweir 		// propagate change to IAOs
2175cdf0e10cSrcweir 		for(sal_uInt32 i=0; i<GetHdlCount(); i++)
2176cdf0e10cSrcweir 		{
2177cdf0e10cSrcweir 			SdrHdl* pHdl = GetHdl(i);
2178cdf0e10cSrcweir 			pHdl->Touch();
2179cdf0e10cSrcweir 		}
2180cdf0e10cSrcweir 	}
2181cdf0e10cSrcweir }
2182cdf0e10cSrcweir 
2183cdf0e10cSrcweir SdrHdl* SdrHdlList::RemoveHdl(sal_uIntPtr nNum)
2184cdf0e10cSrcweir {
2185cdf0e10cSrcweir 	SdrHdl* pRetval = (SdrHdl*)aList.Remove(nNum);
2186cdf0e10cSrcweir 
2187cdf0e10cSrcweir 	return pRetval;
2188cdf0e10cSrcweir }
2189cdf0e10cSrcweir 
2190cdf0e10cSrcweir void SdrHdlList::Clear()
2191cdf0e10cSrcweir {
2192cdf0e10cSrcweir 	for (sal_uIntPtr i=0; i<GetHdlCount(); i++)
2193cdf0e10cSrcweir 	{
2194cdf0e10cSrcweir 		SdrHdl* pHdl=GetHdl(i);
2195cdf0e10cSrcweir 		delete pHdl;
2196cdf0e10cSrcweir 	}
2197cdf0e10cSrcweir 	aList.Clear();
2198cdf0e10cSrcweir 
2199cdf0e10cSrcweir 	bRotateShear=sal_False;
2200cdf0e10cSrcweir 	bDistortShear=sal_False;
2201cdf0e10cSrcweir }
2202cdf0e10cSrcweir 
2203cdf0e10cSrcweir void SdrHdlList::Sort()
2204cdf0e10cSrcweir {
2205cdf0e10cSrcweir 	// #97016# II: remember current focused handle
2206cdf0e10cSrcweir 	SdrHdl* pPrev = GetFocusHdl();
2207cdf0e10cSrcweir 
2208cdf0e10cSrcweir     ImpSdrHdlListSorter aSort(aList);
2209cdf0e10cSrcweir     aSort.DoSort();
2210cdf0e10cSrcweir 
2211cdf0e10cSrcweir 	// #97016# II: get now and compare
2212cdf0e10cSrcweir 	SdrHdl* pNow = GetFocusHdl();
2213cdf0e10cSrcweir 
2214cdf0e10cSrcweir 	if(pPrev != pNow)
2215cdf0e10cSrcweir 	{
2216cdf0e10cSrcweir 		//SDOsal_Bool bRefresh(sal_False);
2217cdf0e10cSrcweir 
2218cdf0e10cSrcweir 		if(pPrev)
2219cdf0e10cSrcweir 		{
2220cdf0e10cSrcweir 			pPrev->Touch();
2221cdf0e10cSrcweir 			//SDObRefresh = sal_True;
2222cdf0e10cSrcweir 		}
2223cdf0e10cSrcweir 
2224cdf0e10cSrcweir 		if(pNow)
2225cdf0e10cSrcweir 		{
2226cdf0e10cSrcweir 			pNow->Touch();
2227cdf0e10cSrcweir 			//SDObRefresh = sal_True;
2228cdf0e10cSrcweir 		}
2229cdf0e10cSrcweir 	}
2230cdf0e10cSrcweir }
2231cdf0e10cSrcweir 
2232cdf0e10cSrcweir sal_uIntPtr SdrHdlList::GetHdlNum(const SdrHdl* pHdl) const
2233cdf0e10cSrcweir {
2234cdf0e10cSrcweir     if (pHdl==NULL)
2235cdf0e10cSrcweir 		return CONTAINER_ENTRY_NOTFOUND;
2236cdf0e10cSrcweir     sal_uIntPtr nPos=aList.GetPos(pHdl);
2237cdf0e10cSrcweir     return nPos;
2238cdf0e10cSrcweir }
2239cdf0e10cSrcweir 
2240cdf0e10cSrcweir void SdrHdlList::AddHdl(SdrHdl* pHdl, sal_Bool bAtBegin)
2241cdf0e10cSrcweir {
2242cdf0e10cSrcweir     if (pHdl!=NULL)
2243cdf0e10cSrcweir 	{
2244cdf0e10cSrcweir         if (bAtBegin)
2245cdf0e10cSrcweir 		{
2246cdf0e10cSrcweir             aList.Insert(pHdl,sal_uIntPtr(0));
2247cdf0e10cSrcweir         }
2248cdf0e10cSrcweir 		else
2249cdf0e10cSrcweir 		{
2250cdf0e10cSrcweir             aList.Insert(pHdl,CONTAINER_APPEND);
2251cdf0e10cSrcweir         }
2252cdf0e10cSrcweir         pHdl->SetHdlList(this);
2253cdf0e10cSrcweir     }
2254cdf0e10cSrcweir }
2255cdf0e10cSrcweir 
2256cdf0e10cSrcweir SdrHdl* SdrHdlList::IsHdlListHit(const Point& rPnt, sal_Bool bBack, sal_Bool bNext, SdrHdl* pHdl0) const
2257cdf0e10cSrcweir {
2258cdf0e10cSrcweir    SdrHdl* pRet=NULL;
2259cdf0e10cSrcweir    sal_uIntPtr nAnz=GetHdlCount();
2260cdf0e10cSrcweir    sal_uIntPtr nNum=bBack ? 0 : nAnz;
2261cdf0e10cSrcweir    while ((bBack ? nNum<nAnz : nNum>0) && pRet==NULL)
2262cdf0e10cSrcweir    {
2263cdf0e10cSrcweir        if (!bBack)
2264cdf0e10cSrcweir 		   nNum--;
2265cdf0e10cSrcweir        SdrHdl* pHdl=GetHdl(nNum);
2266cdf0e10cSrcweir        if (bNext)
2267cdf0e10cSrcweir 	   {
2268cdf0e10cSrcweir            if (pHdl==pHdl0)
2269cdf0e10cSrcweir 			   bNext=sal_False;
2270cdf0e10cSrcweir        }
2271cdf0e10cSrcweir 	   else
2272cdf0e10cSrcweir 	   {
2273cdf0e10cSrcweir            if (pHdl->IsHdlHit(rPnt))
2274cdf0e10cSrcweir 			   pRet=pHdl;
2275cdf0e10cSrcweir        }
2276cdf0e10cSrcweir        if (bBack)
2277cdf0e10cSrcweir 		   nNum++;
2278cdf0e10cSrcweir    }
2279cdf0e10cSrcweir    return pRet;
2280cdf0e10cSrcweir }
2281cdf0e10cSrcweir 
2282cdf0e10cSrcweir SdrHdl* SdrHdlList::GetHdl(SdrHdlKind eKind1) const
2283cdf0e10cSrcweir {
2284cdf0e10cSrcweir    SdrHdl* pRet=NULL;
2285cdf0e10cSrcweir    for (sal_uIntPtr i=0; i<GetHdlCount() && pRet==NULL; i++)
2286cdf0e10cSrcweir    {
2287cdf0e10cSrcweir        SdrHdl* pHdl=GetHdl(i);
2288cdf0e10cSrcweir        if (pHdl->GetKind()==eKind1)
2289cdf0e10cSrcweir 		   pRet=pHdl;
2290cdf0e10cSrcweir    }
2291cdf0e10cSrcweir    return pRet;
2292cdf0e10cSrcweir }
2293cdf0e10cSrcweir 
2294cdf0e10cSrcweir // --------------------------------------------------------------------
2295cdf0e10cSrcweir // SdrCropHdl
2296cdf0e10cSrcweir // --------------------------------------------------------------------
2297cdf0e10cSrcweir 
2298cdf0e10cSrcweir SdrCropHdl::SdrCropHdl(const Point& rPnt, SdrHdlKind eNewKind)
2299cdf0e10cSrcweir : SdrHdl( rPnt, eNewKind )
2300cdf0e10cSrcweir {
2301cdf0e10cSrcweir }
2302cdf0e10cSrcweir 
2303cdf0e10cSrcweir // --------------------------------------------------------------------
2304cdf0e10cSrcweir 
2305cdf0e10cSrcweir BitmapEx SdrCropHdl::GetHandlesBitmap( bool bIsFineHdl, bool bIsHighContrast )
2306cdf0e10cSrcweir {
2307cdf0e10cSrcweir 	if( bIsHighContrast )
2308cdf0e10cSrcweir 	{
2309cdf0e10cSrcweir 		static BitmapEx* pHighContrastBitmap = 0;
2310cdf0e10cSrcweir 		if( pHighContrastBitmap == 0 )
2311cdf0e10cSrcweir 			pHighContrastBitmap = new BitmapEx(ResId(SIP_SA_ACCESSIBILITY_CROP_MARKERS, *ImpGetResMgr()));
2312cdf0e10cSrcweir 		return *pHighContrastBitmap;
2313cdf0e10cSrcweir 	}
2314cdf0e10cSrcweir 	else if( bIsFineHdl )
2315cdf0e10cSrcweir 	{
2316cdf0e10cSrcweir 		static BitmapEx* pModernBitmap = 0;
2317cdf0e10cSrcweir 		if( pModernBitmap == 0 )
2318cdf0e10cSrcweir 			pModernBitmap = new BitmapEx(ResId(SIP_SA_CROP_FINE_MARKERS, *ImpGetResMgr()));
2319cdf0e10cSrcweir 		return *pModernBitmap;
2320cdf0e10cSrcweir 	}
2321cdf0e10cSrcweir 	else
2322cdf0e10cSrcweir 	{
2323cdf0e10cSrcweir 		static BitmapEx* pSimpleBitmap = 0;
2324cdf0e10cSrcweir 		if( pSimpleBitmap == 0 )
2325cdf0e10cSrcweir 			pSimpleBitmap = new BitmapEx(ResId(SIP_SA_CROP_MARKERS, *ImpGetResMgr()));
2326cdf0e10cSrcweir 		return *pSimpleBitmap;
2327cdf0e10cSrcweir 	}
2328cdf0e10cSrcweir }
2329cdf0e10cSrcweir 
2330cdf0e10cSrcweir // --------------------------------------------------------------------
2331cdf0e10cSrcweir 
2332cdf0e10cSrcweir BitmapEx SdrCropHdl::GetBitmapForHandle( const BitmapEx& rBitmap, int nSize )
2333cdf0e10cSrcweir {
2334cdf0e10cSrcweir 	int nPixelSize = 0, nX = 0, nY = 0, nOffset = 0;
2335cdf0e10cSrcweir 
2336cdf0e10cSrcweir 	if( nSize <= 3 )
2337cdf0e10cSrcweir 	{
2338cdf0e10cSrcweir 		nPixelSize = 13;
2339cdf0e10cSrcweir 		nOffset = 0;
2340cdf0e10cSrcweir 	}
2341cdf0e10cSrcweir 	else if( nSize <=4 )
2342cdf0e10cSrcweir 	{
2343cdf0e10cSrcweir 		nPixelSize = 17;
2344cdf0e10cSrcweir 		nOffset = 36;
2345cdf0e10cSrcweir 	}
2346cdf0e10cSrcweir 	else
2347cdf0e10cSrcweir 	{
2348cdf0e10cSrcweir 		nPixelSize = 21;
2349cdf0e10cSrcweir 		nOffset = 84;
2350cdf0e10cSrcweir 	}
2351cdf0e10cSrcweir 
2352cdf0e10cSrcweir 	switch( eKind )
2353cdf0e10cSrcweir 	{
2354cdf0e10cSrcweir 		case HDL_UPLFT: nX = 0; nY = 0; break;
2355cdf0e10cSrcweir 		case HDL_UPPER: nX = 1; nY = 0; break;
2356cdf0e10cSrcweir 		case HDL_UPRGT: nX = 2; nY = 0; break;
2357cdf0e10cSrcweir 		case HDL_LEFT:  nX = 0; nY = 1; break;
2358cdf0e10cSrcweir 		case HDL_RIGHT: nX = 2; nY = 1; break;
2359cdf0e10cSrcweir 		case HDL_LWLFT: nX = 0; nY = 2; break;
2360cdf0e10cSrcweir 		case HDL_LOWER: nX = 1; nY = 2; break;
2361cdf0e10cSrcweir 		case HDL_LWRGT: nX = 2; nY = 2; break;
2362cdf0e10cSrcweir 		default: break;
2363cdf0e10cSrcweir 	}
2364cdf0e10cSrcweir 
2365cdf0e10cSrcweir 	Rectangle aSourceRect( Point( nX * (nPixelSize-1) + nOffset,  nY * (nPixelSize-1)), Size(nPixelSize, nPixelSize) );
2366cdf0e10cSrcweir 
2367cdf0e10cSrcweir 	BitmapEx aRetval(rBitmap);
2368cdf0e10cSrcweir 	aRetval.Crop(aSourceRect);
2369cdf0e10cSrcweir 	return aRetval;
2370cdf0e10cSrcweir }
2371cdf0e10cSrcweir 
2372cdf0e10cSrcweir // --------------------------------------------------------------------
2373cdf0e10cSrcweir 
2374cdf0e10cSrcweir void SdrCropHdl::CreateB2dIAObject()
2375cdf0e10cSrcweir {
2376cdf0e10cSrcweir 	// first throw away old one
2377cdf0e10cSrcweir 	GetRidOfIAObject();
2378cdf0e10cSrcweir 
2379cdf0e10cSrcweir 	SdrMarkView* pView = pHdlList ? pHdlList->GetView() : 0;
2380cdf0e10cSrcweir 	SdrPageView* pPageView = pView ? pView->GetSdrPageView() : 0;
2381cdf0e10cSrcweir 
2382cdf0e10cSrcweir 	if( pPageView && !pView->areMarkHandlesHidden() )
2383cdf0e10cSrcweir 	{
2384cdf0e10cSrcweir 		sal_Bool bIsFineHdl(pHdlList->IsFineHdl());
2385cdf0e10cSrcweir 		const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
2386cdf0e10cSrcweir 		sal_Bool bIsHighContrast(rStyleSettings.GetHighContrastMode());
2387cdf0e10cSrcweir 		int nHdlSize = pHdlList->GetHdlSize();
2388cdf0e10cSrcweir 		if( bIsHighContrast )
2389cdf0e10cSrcweir 			nHdlSize = 4;
2390cdf0e10cSrcweir 
2391cdf0e10cSrcweir 		const BitmapEx aHandlesBitmap( GetHandlesBitmap( bIsFineHdl, bIsHighContrast ) );
2392cdf0e10cSrcweir 		BitmapEx aBmpEx1( GetBitmapForHandle( aHandlesBitmap, nHdlSize ) );
2393cdf0e10cSrcweir 
2394cdf0e10cSrcweir 		for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
2395cdf0e10cSrcweir 		{
2396cdf0e10cSrcweir 			// const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
2397cdf0e10cSrcweir 			const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
2398cdf0e10cSrcweir 
2399cdf0e10cSrcweir 			if(rPageWindow.GetPaintWindow().OutputToWindow())
2400cdf0e10cSrcweir 			{
2401cdf0e10cSrcweir 				if(rPageWindow.GetOverlayManager())
2402cdf0e10cSrcweir 				{
2403cdf0e10cSrcweir 					basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
2404cdf0e10cSrcweir 
2405cdf0e10cSrcweir 					::sdr::overlay::OverlayObject* pOverlayObject = 0L;
2406cdf0e10cSrcweir 
2407cdf0e10cSrcweir 					// animate focused handles
2408cdf0e10cSrcweir 					if(IsFocusHdl() && (pHdlList->GetFocusHdl() == this))
2409cdf0e10cSrcweir 					{
2410cdf0e10cSrcweir 						if( nHdlSize >= 2 )
2411cdf0e10cSrcweir 							nHdlSize = 1;
2412cdf0e10cSrcweir 
2413cdf0e10cSrcweir 						BitmapEx aBmpEx2( GetBitmapForHandle( aHandlesBitmap, nHdlSize + 1 ) );
2414cdf0e10cSrcweir 
2415cdf0e10cSrcweir 						const sal_uInt32 nBlinkTime = sal::static_int_cast<sal_uInt32>(rStyleSettings.GetCursorBlinkTime());
2416cdf0e10cSrcweir 
2417cdf0e10cSrcweir 						pOverlayObject = new ::sdr::overlay::OverlayAnimatedBitmapEx(aPosition, aBmpEx1, aBmpEx2, nBlinkTime,
2418cdf0e10cSrcweir 							(sal_uInt16)(aBmpEx1.GetSizePixel().Width() - 1) >> 1,
2419cdf0e10cSrcweir 							(sal_uInt16)(aBmpEx1.GetSizePixel().Height() - 1) >> 1,
2420cdf0e10cSrcweir 							(sal_uInt16)(aBmpEx2.GetSizePixel().Width() - 1) >> 1,
2421cdf0e10cSrcweir 							(sal_uInt16)(aBmpEx2.GetSizePixel().Height() - 1) >> 1);
2422cdf0e10cSrcweir 					}
2423cdf0e10cSrcweir 					else
2424cdf0e10cSrcweir 					{
2425cdf0e10cSrcweir 						// create centered handle as default
2426cdf0e10cSrcweir 						pOverlayObject = new ::sdr::overlay::OverlayBitmapEx(aPosition, aBmpEx1,
2427cdf0e10cSrcweir 							(sal_uInt16)(aBmpEx1.GetSizePixel().Width() - 1) >> 1,
2428cdf0e10cSrcweir 							(sal_uInt16)(aBmpEx1.GetSizePixel().Height() - 1) >> 1);
2429cdf0e10cSrcweir 					}
2430cdf0e10cSrcweir 
2431cdf0e10cSrcweir 					// OVERLAYMANAGER
2432cdf0e10cSrcweir 					if(pOverlayObject)
2433cdf0e10cSrcweir 					{
2434cdf0e10cSrcweir 						rPageWindow.GetOverlayManager()->add(*pOverlayObject);
2435cdf0e10cSrcweir 						maOverlayGroup.append(*pOverlayObject);
2436cdf0e10cSrcweir 					}
2437cdf0e10cSrcweir 				}
2438cdf0e10cSrcweir 			}
2439cdf0e10cSrcweir 		}
2440cdf0e10cSrcweir 	}
2441cdf0e10cSrcweir }
2442cdf0e10cSrcweir 
2443*2376739dSArmin Le Grand ////////////////////////////////////////////////////////////////////////////////////////////////////
2444*2376739dSArmin Le Grand 
2445*2376739dSArmin Le Grand SdrCropViewHdl::SdrCropViewHdl(
2446*2376739dSArmin Le Grand     const basegfx::B2DHomMatrix& rObjectTransform,
2447*2376739dSArmin Le Grand     const Graphic& rGraphic,
2448*2376739dSArmin Le Grand     double fCropLeft,
2449*2376739dSArmin Le Grand     double fCropTop,
2450*2376739dSArmin Le Grand     double fCropRight,
2451*2376739dSArmin Le Grand     double fCropBottom,
2452*2376739dSArmin Le Grand     bool bExtraMirrorXFromGraphic)
2453*2376739dSArmin Le Grand :   SdrHdl(Point(), HDL_USER),
2454*2376739dSArmin Le Grand     maObjectTransform(rObjectTransform),
2455*2376739dSArmin Le Grand     maGraphic(rGraphic),
2456*2376739dSArmin Le Grand     mfCropLeft(fCropLeft),
2457*2376739dSArmin Le Grand     mfCropTop(fCropTop),
2458*2376739dSArmin Le Grand     mfCropRight(fCropRight),
2459*2376739dSArmin Le Grand     mfCropBottom(fCropBottom),
2460*2376739dSArmin Le Grand     mbExtraMirrorXFromGraphic(bExtraMirrorXFromGraphic)
2461*2376739dSArmin Le Grand {
2462*2376739dSArmin Le Grand }
2463*2376739dSArmin Le Grand 
2464*2376739dSArmin Le Grand void SdrCropViewHdl::CreateB2dIAObject()
2465*2376739dSArmin Le Grand {
2466*2376739dSArmin Le Grand     GetRidOfIAObject();
2467*2376739dSArmin Le Grand     SdrMarkView* pView = pHdlList ? pHdlList->GetView() : 0;
2468*2376739dSArmin Le Grand     SdrPageView* pPageView = pView ? pView->GetSdrPageView() : 0;
2469*2376739dSArmin Le Grand 
2470*2376739dSArmin Le Grand     if(pPageView && pView->areMarkHandlesHidden())
2471*2376739dSArmin Le Grand     {
2472*2376739dSArmin Le Grand         return;
2473*2376739dSArmin Le Grand     }
2474*2376739dSArmin Le Grand 
2475*2376739dSArmin Le Grand     // decompose to have current translate and scale
2476*2376739dSArmin Le Grand     basegfx::B2DVector aScale, aTranslate;
2477*2376739dSArmin Le Grand     double fRotate, fShearX;
2478*2376739dSArmin Le Grand 
2479*2376739dSArmin Le Grand     maObjectTransform.decompose(aScale, aTranslate, fRotate, fShearX);
2480*2376739dSArmin Le Grand 
2481*2376739dSArmin Le Grand     if(aScale.equalZero())
2482*2376739dSArmin Le Grand     {
2483*2376739dSArmin Le Grand         return;
2484*2376739dSArmin Le Grand     }
2485*2376739dSArmin Le Grand 
2486*2376739dSArmin Le Grand     // detect 180 degree rotation, this is the same as mirrored in X and Y,
2487*2376739dSArmin Le Grand     // thus change to mirroring. Prefer mirroring here. Use the equal call
2488*2376739dSArmin Le Grand     // with getSmallValue here, the original which uses rtl::math::approxEqual
2489*2376739dSArmin Le Grand     // is too correct here. Maybe this changes with enhanced precision in aw080
2490*2376739dSArmin Le Grand     // to the better so that this can be reduced to the more precise call again
2491*2376739dSArmin Le Grand     if(basegfx::fTools::equal(fabs(fRotate), F_PI, 0.000000001))
2492*2376739dSArmin Le Grand     {
2493*2376739dSArmin Le Grand         aScale.setX(aScale.getX() * -1.0);
2494*2376739dSArmin Le Grand         aScale.setY(aScale.getY() * -1.0);
2495*2376739dSArmin Le Grand         fRotate = 0.0;
2496*2376739dSArmin Le Grand     }
2497*2376739dSArmin Le Grand 
2498*2376739dSArmin Le Grand     // remember mirroring, reset at Scale and adapt crop values for usage;
2499*2376739dSArmin Le Grand     // mirroring can stay in the object transformation, so do not have to
2500*2376739dSArmin Le Grand     // cope with it here (except later for the CroppedImage transformation,
2501*2376739dSArmin Le Grand     // see below)
2502*2376739dSArmin Le Grand     const bool bMirroredX(aScale.getX() < 0.0);
2503*2376739dSArmin Le Grand     const bool bMirroredY(aScale.getY() < 0.0);
2504*2376739dSArmin Le Grand     double fCropLeft(mfCropLeft);
2505*2376739dSArmin Le Grand     double fCropTop(mfCropTop);
2506*2376739dSArmin Le Grand     double fCropRight(mfCropRight);
2507*2376739dSArmin Le Grand     double fCropBottom(mfCropBottom);
2508*2376739dSArmin Le Grand 
2509*2376739dSArmin Le Grand     if(bMirroredX)
2510*2376739dSArmin Le Grand     {
2511*2376739dSArmin Le Grand         aScale.setX(-aScale.getX());
2512*2376739dSArmin Le Grand         fCropLeft = mfCropRight;
2513*2376739dSArmin Le Grand         fCropRight = mfCropLeft;
2514*2376739dSArmin Le Grand     }
2515*2376739dSArmin Le Grand 
2516*2376739dSArmin Le Grand     if(bMirroredY)
2517*2376739dSArmin Le Grand     {
2518*2376739dSArmin Le Grand         aScale.setY(-aScale.getY());
2519*2376739dSArmin Le Grand         fCropTop = mfCropBottom;
2520*2376739dSArmin Le Grand         fCropBottom = mfCropTop;
2521*2376739dSArmin Le Grand     }
2522*2376739dSArmin Le Grand 
2523*2376739dSArmin Le Grand     // create target translate and scale
2524*2376739dSArmin Le Grand     const basegfx::B2DVector aTargetScale(
2525*2376739dSArmin Le Grand         aScale.getX() + fCropRight + fCropLeft,
2526*2376739dSArmin Le Grand         aScale.getY() + fCropBottom + fCropTop);
2527*2376739dSArmin Le Grand     const basegfx::B2DVector aTargetTranslate(
2528*2376739dSArmin Le Grand         aTranslate.getX() - fCropLeft,
2529*2376739dSArmin Le Grand         aTranslate.getY() - fCropTop);
2530*2376739dSArmin Le Grand 
2531*2376739dSArmin Le Grand     // create ranges to make comparisons
2532*2376739dSArmin Le Grand     const basegfx::B2DRange aCurrentForCompare(
2533*2376739dSArmin Le Grand         aTranslate.getX(), aTranslate.getY(),
2534*2376739dSArmin Le Grand         aTranslate.getX() + aScale.getX(), aTranslate.getY() + aScale.getY());
2535*2376739dSArmin Le Grand     basegfx::B2DRange aCropped(
2536*2376739dSArmin Le Grand         aTargetTranslate.getX(), aTargetTranslate.getY(),
2537*2376739dSArmin Le Grand         aTargetTranslate.getX() + aTargetScale.getX(), aTargetTranslate.getY() + aTargetScale.getY());
2538*2376739dSArmin Le Grand 
2539*2376739dSArmin Le Grand     if(aCropped.isEmpty())
2540*2376739dSArmin Le Grand     {
2541*2376739dSArmin Le Grand         // nothing to return since cropped content is completely empty
2542*2376739dSArmin Le Grand         return;
2543*2376739dSArmin Le Grand     }
2544*2376739dSArmin Le Grand 
2545*2376739dSArmin Le Grand     if(aCurrentForCompare.equal(aCropped))
2546*2376739dSArmin Le Grand     {
2547*2376739dSArmin Le Grand         // no crop at all
2548*2376739dSArmin Le Grand         return;
2549*2376739dSArmin Le Grand     }
2550*2376739dSArmin Le Grand 
2551*2376739dSArmin Le Grand     // back-transform to have values in unit coordinates
2552*2376739dSArmin Le Grand     basegfx::B2DHomMatrix aBackToUnit;
2553*2376739dSArmin Le Grand     aBackToUnit.translate(-aTranslate.getX(), -aTranslate.getY());
2554*2376739dSArmin Le Grand     aBackToUnit.scale(
2555*2376739dSArmin Le Grand         basegfx::fTools::equalZero(aScale.getX()) ? 1.0 : 1.0 / aScale.getX(),
2556*2376739dSArmin Le Grand         basegfx::fTools::equalZero(aScale.getY()) ? 1.0 : 1.0 / aScale.getY());
2557*2376739dSArmin Le Grand 
2558*2376739dSArmin Le Grand     // transform cropped back to unit coordinates
2559*2376739dSArmin Le Grand     aCropped.transform(aBackToUnit);
2560*2376739dSArmin Le Grand 
2561*2376739dSArmin Le Grand     // prepare crop PolyPolygon
2562*2376739dSArmin Le Grand     basegfx::B2DPolyPolygon aCropPolyPolygon(
2563*2376739dSArmin Le Grand         basegfx::tools::createPolygonFromRect(
2564*2376739dSArmin Le Grand             aCropped));
2565*2376739dSArmin Le Grand 
2566*2376739dSArmin Le Grand     // current range is unit range
2567*2376739dSArmin Le Grand     basegfx::B2DRange aOverlap(0.0, 0.0, 1.0, 1.0);
2568*2376739dSArmin Le Grand 
2569*2376739dSArmin Le Grand     aOverlap.intersect(aCropped);
2570*2376739dSArmin Le Grand 
2571*2376739dSArmin Le Grand     if(!aOverlap.isEmpty())
2572*2376739dSArmin Le Grand     {
2573*2376739dSArmin Le Grand         aCropPolyPolygon.append(
2574*2376739dSArmin Le Grand             basegfx::tools::createPolygonFromRect(
2575*2376739dSArmin Le Grand                 aOverlap));
2576*2376739dSArmin Le Grand     }
2577*2376739dSArmin Le Grand 
2578*2376739dSArmin Le Grand     // transform to object coordinates to prepare for clip
2579*2376739dSArmin Le Grand     aCropPolyPolygon.transform(maObjectTransform);
2580*2376739dSArmin Le Grand 
2581*2376739dSArmin Le Grand     // create cropped transformation
2582*2376739dSArmin Le Grand     basegfx::B2DHomMatrix aCroppedTransform;
2583*2376739dSArmin Le Grand     const bool bCombinedMirrorX(mbExtraMirrorXFromGraphic || bMirroredX);
2584*2376739dSArmin Le Grand 
2585*2376739dSArmin Le Grand     aCroppedTransform.scale(
2586*2376739dSArmin Le Grand         bCombinedMirrorX ? -aCropped.getWidth() : aCropped.getWidth(),
2587*2376739dSArmin Le Grand         bMirroredY ? -aCropped.getHeight() : aCropped.getHeight());
2588*2376739dSArmin Le Grand     aCroppedTransform.translate(
2589*2376739dSArmin Le Grand         bCombinedMirrorX ? aCropped.getMaxX() : aCropped.getMinX(),
2590*2376739dSArmin Le Grand         bMirroredY ? aCropped.getMaxY() : aCropped.getMinY());
2591*2376739dSArmin Le Grand     aCroppedTransform = maObjectTransform * aCroppedTransform;
2592*2376739dSArmin Le Grand 
2593*2376739dSArmin Le Grand     // prepare graphic primitive (tranformed)
2594*2376739dSArmin Le Grand     const drawinglayer::primitive2d::Primitive2DReference aGraphic(
2595*2376739dSArmin Le Grand         new drawinglayer::primitive2d::GraphicPrimitive2D(
2596*2376739dSArmin Le Grand             aCroppedTransform,
2597*2376739dSArmin Le Grand             maGraphic));
2598*2376739dSArmin Le Grand 
2599*2376739dSArmin Le Grand     // embed to MaskPrimitive2D
2600*2376739dSArmin Le Grand     const drawinglayer::primitive2d::Primitive2DReference aMaskedGraphic(
2601*2376739dSArmin Le Grand         new drawinglayer::primitive2d::MaskPrimitive2D(
2602*2376739dSArmin Le Grand             aCropPolyPolygon,
2603*2376739dSArmin Le Grand             drawinglayer::primitive2d::Primitive2DSequence(&aGraphic, 1)));
2604*2376739dSArmin Le Grand 
2605*2376739dSArmin Le Grand     // embed to UnifiedTransparencePrimitive2D
2606*2376739dSArmin Le Grand     const drawinglayer::primitive2d::Primitive2DReference aTransparenceMaskedGraphic(
2607*2376739dSArmin Le Grand         new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
2608*2376739dSArmin Le Grand             drawinglayer::primitive2d::Primitive2DSequence(&aMaskedGraphic, 1),
2609*2376739dSArmin Le Grand             0.8));
2610*2376739dSArmin Le Grand 
2611*2376739dSArmin Le Grand     const drawinglayer::primitive2d::Primitive2DSequence aSequence(&aTransparenceMaskedGraphic, 1);
2612*2376739dSArmin Le Grand 
2613*2376739dSArmin Le Grand     for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
2614*2376739dSArmin Le Grand     {
2615*2376739dSArmin Le Grand         // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
2616*2376739dSArmin Le Grand         const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
2617*2376739dSArmin Le Grand 
2618*2376739dSArmin Le Grand         if(rPageWindow.GetPaintWindow().OutputToWindow())
2619*2376739dSArmin Le Grand         {
2620*2376739dSArmin Le Grand             if(rPageWindow.GetOverlayManager())
2621*2376739dSArmin Le Grand             {
2622*2376739dSArmin Le Grand                 ::sdr::overlay::OverlayObject* pNew = new sdr::overlay::OverlayPrimitive2DSequenceObject(aSequence);
2623*2376739dSArmin Le Grand                 DBG_ASSERT(pNew, "Got NO new IAO!");
2624*2376739dSArmin Le Grand 
2625*2376739dSArmin Le Grand                 if(pNew)
2626*2376739dSArmin Le Grand                 {
2627*2376739dSArmin Le Grand                     // only informative object, no hit
2628*2376739dSArmin Le Grand                     pNew->setHittable(false);
2629*2376739dSArmin Le Grand 
2630*2376739dSArmin Le Grand                     rPageWindow.GetOverlayManager()->add(*pNew);
2631*2376739dSArmin Le Grand                     maOverlayGroup.append(*pNew);
2632*2376739dSArmin Le Grand                 }
2633*2376739dSArmin Le Grand             }
2634*2376739dSArmin Le Grand         }
2635*2376739dSArmin Le Grand     }
2636*2376739dSArmin Le Grand }
2637*2376739dSArmin Le Grand 
2638*2376739dSArmin Le Grand ////////////////////////////////////////////////////////////////////////////////////////////////////
2639*2376739dSArmin Le Grand // eof
2640