xref: /AOO41X/main/svx/source/svdraw/svdhdl.cxx (revision b5697104d707bccaa4bcd2a9a325df3bef60684f)
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
10cdf0e10cSrcweir  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
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 
662376739dSArmin Le Grand #include <basegfx/polygon/b2dpolygontools.hxx>
672376739dSArmin Le Grand #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
682376739dSArmin Le Grand #include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx>
692376739dSArmin Le Grand #include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
702376739dSArmin Le Grand #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
712376739dSArmin Le Grand #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
728185c382SArmin Le Grand #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
732376739dSArmin Le Grand 
74cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
75cdf0e10cSrcweir // #i15222#
76ef96bc24Smseidel // Due to the resource problems in Win95/98 with bitmap resources I
77ef96bc24Smseidel // will change this handle bitmap providing class. Old version was splitting
78cdf0e10cSrcweir // and preparing all small handle bitmaps in device bitmap format, now this will
79ef96bc24Smseidel // be done on the fly. Thus, there is only the one big bitmap remembered. With
80ef96bc24Smseidel // three source bitmaps, this will be 3 system bitmap resources instead of hundreds.
81cdf0e10cSrcweir // The price for that needs to be evaluated. Maybe we will need another change here
82cdf0e10cSrcweir // if this is too expensive.
83cdf0e10cSrcweir class SdrHdlBitmapSet
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 	// the bitmap holding all infos
86cdf0e10cSrcweir 	BitmapEx					maMarkersBitmap;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	// the cropped Bitmaps for reusage
89cdf0e10cSrcweir 	::std::vector< BitmapEx >	maRealMarkers;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 	// elpers
92cdf0e10cSrcweir 	BitmapEx& impGetOrCreateTargetBitmap(sal_uInt16 nIndex, const Rectangle& rRectangle);
93cdf0e10cSrcweir 
94cdf0e10cSrcweir public:
95cdf0e10cSrcweir 	SdrHdlBitmapSet(sal_uInt16 nResId);
96cdf0e10cSrcweir 	~SdrHdlBitmapSet();
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	const BitmapEx& GetBitmapEx(BitmapMarkerKind eKindOfMarker, sal_uInt16 nInd=0);
99cdf0e10cSrcweir };
100cdf0e10cSrcweir 
101cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
102cdf0e10cSrcweir #define KIND_COUNT			(14)
103cdf0e10cSrcweir #define INDEX_COUNT			(6)
104777ec61eSmseidel #define INDIVIDUAL_COUNT	(6)
105cdf0e10cSrcweir 
SdrHdlBitmapSet(sal_uInt16 nResId)106cdf0e10cSrcweir SdrHdlBitmapSet::SdrHdlBitmapSet(sal_uInt16 nResId)
107ef96bc24Smseidel :	maMarkersBitmap(ResId(nResId, *ImpGetResMgr())), // just use resource with alpha channel
1082a90d9eaSmseidel 	// 14 kinds (BitmapMarkerKind) use index [0..5], 6 extra
109cdf0e10cSrcweir 	maRealMarkers((KIND_COUNT * INDEX_COUNT) + INDIVIDUAL_COUNT)
110cdf0e10cSrcweir {
111cdf0e10cSrcweir }
112cdf0e10cSrcweir 
~SdrHdlBitmapSet()113cdf0e10cSrcweir SdrHdlBitmapSet::~SdrHdlBitmapSet()
114cdf0e10cSrcweir {
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
impGetOrCreateTargetBitmap(sal_uInt16 nIndex,const Rectangle & rRectangle)117cdf0e10cSrcweir BitmapEx& SdrHdlBitmapSet::impGetOrCreateTargetBitmap(sal_uInt16 nIndex, const Rectangle& rRectangle)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir 	BitmapEx& rTargetBitmap = maRealMarkers[nIndex];
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	if(rTargetBitmap.IsEmpty())
122cdf0e10cSrcweir 	{
123cdf0e10cSrcweir 		rTargetBitmap = maMarkersBitmap;
124cdf0e10cSrcweir 		rTargetBitmap.Crop(rRectangle);
125cdf0e10cSrcweir 	}
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	return rTargetBitmap;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
130ef96bc24Smseidel // change getting of bitmap to use the big resource bitmap
GetBitmapEx(BitmapMarkerKind eKindOfMarker,sal_uInt16 nInd)131cdf0e10cSrcweir const BitmapEx& SdrHdlBitmapSet::GetBitmapEx(BitmapMarkerKind eKindOfMarker, sal_uInt16 nInd)
132cdf0e10cSrcweir {
133cdf0e10cSrcweir 	// fill in size and source position in maMarkersBitmap
134cdf0e10cSrcweir 	const sal_uInt16 nYPos(nInd * 11);
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	switch(eKindOfMarker)
137cdf0e10cSrcweir 	{
138cdf0e10cSrcweir 		default:
139cdf0e10cSrcweir 		{
140cdf0e10cSrcweir 			DBG_ERROR( "unknown kind of marker" );
141cdf0e10cSrcweir 			// no break here, return Rect_7x7 as default
142cdf0e10cSrcweir 		}
143cdf0e10cSrcweir 		case Rect_7x7:
144cdf0e10cSrcweir 		{
145cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((0 * INDEX_COUNT) + nInd, Rectangle(Point(0, nYPos), Size(7, 7)));
146cdf0e10cSrcweir 		}
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 		case Rect_9x9:
149cdf0e10cSrcweir 		{
150cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((1 * INDEX_COUNT) + nInd, Rectangle(Point(7, nYPos), Size(9, 9)));
151cdf0e10cSrcweir 		}
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 		case Rect_11x11:
154cdf0e10cSrcweir 		{
155cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((2 * INDEX_COUNT) + nInd, Rectangle(Point(16, nYPos), Size(11, 11)));
156cdf0e10cSrcweir 		}
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 		case Rect_13x13:
159cdf0e10cSrcweir 		{
160cdf0e10cSrcweir 			const sal_uInt16 nIndex((3 * INDEX_COUNT) + nInd);
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 			switch(nInd)
163cdf0e10cSrcweir 			{
164cdf0e10cSrcweir 				case 0:
165cdf0e10cSrcweir 				{
166cdf0e10cSrcweir 					return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(72, 66), Size(13, 13)));
167cdf0e10cSrcweir 				}
168cdf0e10cSrcweir 				case 1:
169cdf0e10cSrcweir 				{
170cdf0e10cSrcweir 					return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(85, 66), Size(13, 13)));
171cdf0e10cSrcweir 				}
172cdf0e10cSrcweir 				case 2:
173cdf0e10cSrcweir 				{
1744772d9afSArmin Le Grand 					return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(72, 79), Size(13, 13)));
175cdf0e10cSrcweir 				}
176cdf0e10cSrcweir 				case 3:
177cdf0e10cSrcweir 				{
1784772d9afSArmin Le Grand 					return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(85, 79), Size(13, 13)));
179cdf0e10cSrcweir 				}
180cdf0e10cSrcweir 				case 4:
181cdf0e10cSrcweir 				{
1824772d9afSArmin Le Grand 					return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(98, 79), Size(13, 13)));
183cdf0e10cSrcweir 				}
184cdf0e10cSrcweir 				default: // case 5:
185cdf0e10cSrcweir 				{
186cdf0e10cSrcweir 					return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(98, 66), Size(13, 13)));
187cdf0e10cSrcweir 				}
188cdf0e10cSrcweir 			}
189cdf0e10cSrcweir 		}
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 		case Circ_7x7:
1924772d9afSArmin Le Grand 		case Customshape_7x7:
193cdf0e10cSrcweir 		{
194cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((4 * INDEX_COUNT) + nInd, Rectangle(Point(27, nYPos), Size(7, 7)));
195cdf0e10cSrcweir 		}
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 		case Circ_9x9:
1984772d9afSArmin Le Grand 		case Customshape_9x9:
199cdf0e10cSrcweir 		{
200cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((5 * INDEX_COUNT) + nInd, Rectangle(Point(34, nYPos), Size(9, 9)));
201cdf0e10cSrcweir 		}
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 		case Circ_11x11:
2044772d9afSArmin Le Grand 		case Customshape_11x11:
205cdf0e10cSrcweir 		{
206cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((6 * INDEX_COUNT) + nInd, Rectangle(Point(43, nYPos), Size(11, 11)));
207cdf0e10cSrcweir 		}
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 		case Elli_7x9:
210cdf0e10cSrcweir 		{
211cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((7 * INDEX_COUNT) + nInd, Rectangle(Point(54, nYPos), Size(7, 9)));
212cdf0e10cSrcweir 		}
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 		case Elli_9x11:
215cdf0e10cSrcweir 		{
216cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((8 * INDEX_COUNT) + nInd, Rectangle(Point(61, nYPos), Size(9, 11)));
217cdf0e10cSrcweir 		}
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 		case Elli_9x7:
220cdf0e10cSrcweir 		{
221cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((9 * INDEX_COUNT) + nInd, Rectangle(Point(70, nYPos), Size(9, 7)));
222cdf0e10cSrcweir 		}
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 		case Elli_11x9:
225cdf0e10cSrcweir 		{
226cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((10 * INDEX_COUNT) + nInd, Rectangle(Point(79, nYPos), Size(11, 9)));
227cdf0e10cSrcweir 		}
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 		case RectPlus_7x7:
230cdf0e10cSrcweir 		{
231cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((11 * INDEX_COUNT) + nInd, Rectangle(Point(90, nYPos), Size(7, 7)));
232cdf0e10cSrcweir 		}
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 		case RectPlus_9x9:
235cdf0e10cSrcweir 		{
236cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((12 * INDEX_COUNT) + nInd, Rectangle(Point(97, nYPos), Size(9, 9)));
237cdf0e10cSrcweir 		}
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 		case RectPlus_11x11:
240cdf0e10cSrcweir 		{
241cdf0e10cSrcweir 			return impGetOrCreateTargetBitmap((13 * INDEX_COUNT) + nInd, Rectangle(Point(106, nYPos), Size(11, 11)));
242cdf0e10cSrcweir 		}
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 		case Crosshair:
245cdf0e10cSrcweir 		{
2462a90d9eaSmseidel 			return impGetOrCreateTargetBitmap((KIND_COUNT * INDEX_COUNT) + 0, Rectangle(Point(0, 66), Size(13, 13)));
2472a90d9eaSmseidel 		}
2482a90d9eaSmseidel 
2492a90d9eaSmseidel 		case Crosshair_Unselected:
2502a90d9eaSmseidel 		{
2512a90d9eaSmseidel 			return impGetOrCreateTargetBitmap((KIND_COUNT * INDEX_COUNT) + 1, Rectangle(Point(0, 79), Size(13, 13)));
252cdf0e10cSrcweir 		}
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 		case Glue:
255cdf0e10cSrcweir 		{
256*b5697104Smseidel 			return impGetOrCreateTargetBitmap((KIND_COUNT * INDEX_COUNT) + 2, Rectangle(Point(13, 70), Size(11, 11)));
2572a90d9eaSmseidel 		}
2582a90d9eaSmseidel 
2592a90d9eaSmseidel 		case Glue_Unselected:
2602a90d9eaSmseidel 		{
261*b5697104Smseidel 			return impGetOrCreateTargetBitmap((KIND_COUNT * INDEX_COUNT) + 3, Rectangle(Point(13, 81), Size(11, 11)));
262cdf0e10cSrcweir 		}
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 		case Anchor: // #101688# AnchorTR for SW
265cdf0e10cSrcweir 		case AnchorTR:
266cdf0e10cSrcweir 		{
2672a90d9eaSmseidel 			return impGetOrCreateTargetBitmap((KIND_COUNT * INDEX_COUNT) + 4, Rectangle(Point(24, 68), Size(24, 24)));
268cdf0e10cSrcweir 		}
269cdf0e10cSrcweir 
270ef96bc24Smseidel 		// #98388# add AnchorPressed to be able to animate anchor control
271cdf0e10cSrcweir 		case AnchorPressed:
272cdf0e10cSrcweir 		case AnchorPressedTR:
273cdf0e10cSrcweir 		{
2742a90d9eaSmseidel 			return impGetOrCreateTargetBitmap((KIND_COUNT * INDEX_COUNT) + 5, Rectangle(Point(48, 68), Size(24, 24)));
275cdf0e10cSrcweir 		}
276cdf0e10cSrcweir 	}
277cdf0e10cSrcweir 
278ef96bc24Smseidel 	// cannot happen since all paths return something; return Rect_7x7 as default (see switch)
279cdf0e10cSrcweir 	return maRealMarkers[0];
280cdf0e10cSrcweir }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
283cdf0e10cSrcweir 
getSimpleSet()284cdf0e10cSrcweir SdrHdlBitmapSet& getSimpleSet()
285cdf0e10cSrcweir {
286cdf0e10cSrcweir 	static vcl::DeleteOnDeinit< SdrHdlBitmapSet > aSimpleSet(new SdrHdlBitmapSet(SIP_SA_MARKERS));
287cdf0e10cSrcweir 	return *aSimpleSet.get();
288cdf0e10cSrcweir }
289cdf0e10cSrcweir 
getModernSet()290cdf0e10cSrcweir SdrHdlBitmapSet& getModernSet()
291cdf0e10cSrcweir {
292cdf0e10cSrcweir 	static vcl::DeleteOnDeinit< SdrHdlBitmapSet > aModernSet(new SdrHdlBitmapSet(SIP_SA_FINE_MARKERS));
293cdf0e10cSrcweir 	return *aModernSet.get();
294cdf0e10cSrcweir }
295cdf0e10cSrcweir 
getHighContrastSet()296cdf0e10cSrcweir SdrHdlBitmapSet& getHighContrastSet()
297cdf0e10cSrcweir {
298cdf0e10cSrcweir 	static vcl::DeleteOnDeinit< SdrHdlBitmapSet > aHighContrastSet(new SdrHdlBitmapSet(SIP_SA_ACCESSIBILITY_MARKERS));
299cdf0e10cSrcweir 	return *aHighContrastSet.get();
300cdf0e10cSrcweir }
301cdf0e10cSrcweir 
302cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
303cdf0e10cSrcweir 
SdrHdl()304cdf0e10cSrcweir SdrHdl::SdrHdl():
305cdf0e10cSrcweir 	pObj(NULL),
306cdf0e10cSrcweir 	pPV(NULL),
307cdf0e10cSrcweir 	pHdlList(NULL),
308cdf0e10cSrcweir 	eKind(HDL_MOVE),
309cdf0e10cSrcweir 	nDrehWink(0),
310cdf0e10cSrcweir 	nObjHdlNum(0),
311cdf0e10cSrcweir 	nPolyNum(0),
312cdf0e10cSrcweir 	nPPntNum(0),
313cdf0e10cSrcweir 	nSourceHdlNum(0),
314cdf0e10cSrcweir 	bSelect(sal_False),
315cdf0e10cSrcweir 	b1PixMore(sal_False),
316cdf0e10cSrcweir 	bPlusHdl(sal_False),
317cdf0e10cSrcweir 	mbMoveOutside(false),
318cdf0e10cSrcweir 	mbMouseOver(false)
319cdf0e10cSrcweir {
320cdf0e10cSrcweir }
321cdf0e10cSrcweir 
SdrHdl(const Point & rPnt,SdrHdlKind eNewKind)322cdf0e10cSrcweir SdrHdl::SdrHdl(const Point& rPnt, SdrHdlKind eNewKind):
323cdf0e10cSrcweir 	pObj(NULL),
324cdf0e10cSrcweir 	pPV(NULL),
325cdf0e10cSrcweir 	pHdlList(NULL),
326cdf0e10cSrcweir 	aPos(rPnt),
327cdf0e10cSrcweir 	eKind(eNewKind),
328cdf0e10cSrcweir 	nDrehWink(0),
329cdf0e10cSrcweir 	nObjHdlNum(0),
330cdf0e10cSrcweir 	nPolyNum(0),
331cdf0e10cSrcweir 	nPPntNum(0),
332cdf0e10cSrcweir 	nSourceHdlNum(0),
333cdf0e10cSrcweir 	bSelect(sal_False),
334cdf0e10cSrcweir 	b1PixMore(sal_False),
335cdf0e10cSrcweir 	bPlusHdl(sal_False),
336cdf0e10cSrcweir 	mbMoveOutside(false),
337cdf0e10cSrcweir 	mbMouseOver(false)
338cdf0e10cSrcweir {
339cdf0e10cSrcweir }
340cdf0e10cSrcweir 
~SdrHdl()341cdf0e10cSrcweir SdrHdl::~SdrHdl()
342cdf0e10cSrcweir {
343cdf0e10cSrcweir 	GetRidOfIAObject();
344cdf0e10cSrcweir }
345cdf0e10cSrcweir 
Set1PixMore(sal_Bool bJa)346cdf0e10cSrcweir void SdrHdl::Set1PixMore(sal_Bool bJa)
347cdf0e10cSrcweir {
348cdf0e10cSrcweir 	if(b1PixMore != bJa)
349cdf0e10cSrcweir 	{
350cdf0e10cSrcweir 		b1PixMore = bJa;
351cdf0e10cSrcweir 
352cdf0e10cSrcweir 		// create new display
353cdf0e10cSrcweir 		Touch();
354cdf0e10cSrcweir 	}
355cdf0e10cSrcweir }
356cdf0e10cSrcweir 
SetMoveOutside(bool bMoveOutside)357cdf0e10cSrcweir void SdrHdl::SetMoveOutside( bool bMoveOutside )
358cdf0e10cSrcweir {
359cdf0e10cSrcweir 	if(mbMoveOutside != bMoveOutside)
360cdf0e10cSrcweir 	{
361cdf0e10cSrcweir 		mbMoveOutside = bMoveOutside;
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 		// create new display
364cdf0e10cSrcweir 		Touch();
365cdf0e10cSrcweir 	}
366cdf0e10cSrcweir }
367cdf0e10cSrcweir 
SetDrehWink(long n)368cdf0e10cSrcweir void SdrHdl::SetDrehWink(long n)
369cdf0e10cSrcweir {
370cdf0e10cSrcweir 	if(nDrehWink != n)
371cdf0e10cSrcweir 	{
372cdf0e10cSrcweir 		nDrehWink = n;
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 		// create new display
375cdf0e10cSrcweir 		Touch();
376cdf0e10cSrcweir 	}
377cdf0e10cSrcweir }
378cdf0e10cSrcweir 
SetPos(const Point & rPnt)379cdf0e10cSrcweir void SdrHdl::SetPos(const Point& rPnt)
380cdf0e10cSrcweir {
381cdf0e10cSrcweir 	if(aPos != rPnt)
382cdf0e10cSrcweir 	{
383cdf0e10cSrcweir 		// remember new position
384cdf0e10cSrcweir 		aPos = rPnt;
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 		// create new display
387cdf0e10cSrcweir 		Touch();
388cdf0e10cSrcweir 	}
389cdf0e10cSrcweir }
390cdf0e10cSrcweir 
SetSelected(sal_Bool bJa)391cdf0e10cSrcweir void SdrHdl::SetSelected(sal_Bool bJa)
392cdf0e10cSrcweir {
393cdf0e10cSrcweir 	if(bSelect != bJa)
394cdf0e10cSrcweir 	{
395cdf0e10cSrcweir 		// remember new value
396cdf0e10cSrcweir 		bSelect = bJa;
397cdf0e10cSrcweir 
398cdf0e10cSrcweir 		// create new display
399cdf0e10cSrcweir 		Touch();
400cdf0e10cSrcweir 	}
401cdf0e10cSrcweir }
402cdf0e10cSrcweir 
SetHdlList(SdrHdlList * pList)403cdf0e10cSrcweir void SdrHdl::SetHdlList(SdrHdlList* pList)
404cdf0e10cSrcweir {
405cdf0e10cSrcweir 	if(pHdlList != pList)
406cdf0e10cSrcweir 	{
407ef96bc24Smseidel 		// remember list
408cdf0e10cSrcweir 		pHdlList = pList;
409cdf0e10cSrcweir 
410ef96bc24Smseidel 		// now it's possible to create graphic representation
411cdf0e10cSrcweir 		Touch();
412cdf0e10cSrcweir 	}
413cdf0e10cSrcweir }
414cdf0e10cSrcweir 
SetObj(SdrObject * pNewObj)415cdf0e10cSrcweir void SdrHdl::SetObj(SdrObject* pNewObj)
416cdf0e10cSrcweir {
417cdf0e10cSrcweir 	if(pObj != pNewObj)
418cdf0e10cSrcweir 	{
419cdf0e10cSrcweir 		// remember new object
420cdf0e10cSrcweir 		pObj = pNewObj;
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 		// graphic representation may have changed
423cdf0e10cSrcweir 		Touch();
424cdf0e10cSrcweir 	}
425cdf0e10cSrcweir }
426cdf0e10cSrcweir 
Touch()427cdf0e10cSrcweir void SdrHdl::Touch()
428cdf0e10cSrcweir {
429cdf0e10cSrcweir 	// force update of graphic representation
430cdf0e10cSrcweir 	CreateB2dIAObject();
431cdf0e10cSrcweir }
432cdf0e10cSrcweir 
GetRidOfIAObject()433cdf0e10cSrcweir void SdrHdl::GetRidOfIAObject()
434cdf0e10cSrcweir {
435cdf0e10cSrcweir 	//OLMaIAOGroup.Delete();
436cdf0e10cSrcweir 
437cdf0e10cSrcweir 	// OVERLAYMANAGER
438cdf0e10cSrcweir 	maOverlayGroup.clear();
439cdf0e10cSrcweir }
440cdf0e10cSrcweir 
CreateB2dIAObject()441cdf0e10cSrcweir void SdrHdl::CreateB2dIAObject()
442cdf0e10cSrcweir {
443cdf0e10cSrcweir 	// first throw away old one
444cdf0e10cSrcweir 	GetRidOfIAObject();
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 	if(pHdlList && pHdlList->GetView() && !pHdlList->GetView()->areMarkHandlesHidden())
447cdf0e10cSrcweir 	{
448cdf0e10cSrcweir 		BitmapColorIndex eColIndex = LightGreen;
449cdf0e10cSrcweir 		BitmapMarkerKind eKindOfMarker = Rect_7x7;
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 		sal_Bool bRot = pHdlList->IsRotateShear();
452cdf0e10cSrcweir 		if(pObj)
453cdf0e10cSrcweir 			eColIndex = (bSelect) ? Cyan : LightCyan;
454cdf0e10cSrcweir 		if(bRot)
455cdf0e10cSrcweir 		{
456ef96bc24Smseidel 			// Rotation handles in red
457cdf0e10cSrcweir 			if(pObj && bSelect)
458cdf0e10cSrcweir 				eColIndex = Red;
459cdf0e10cSrcweir 			else
460cdf0e10cSrcweir 				eColIndex = LightRed;
461cdf0e10cSrcweir 		}
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 		switch(eKind)
464cdf0e10cSrcweir 		{
465cdf0e10cSrcweir 			case HDL_MOVE:
466cdf0e10cSrcweir 			{
467cdf0e10cSrcweir 				eKindOfMarker = (b1PixMore) ? Rect_9x9 : Rect_7x7;
468cdf0e10cSrcweir 				break;
469cdf0e10cSrcweir 			}
470cdf0e10cSrcweir 			case HDL_UPLFT:
471cdf0e10cSrcweir 			case HDL_UPRGT:
472cdf0e10cSrcweir 			case HDL_LWLFT:
473cdf0e10cSrcweir 			case HDL_LWRGT:
474cdf0e10cSrcweir 			{
475ef96bc24Smseidel 				// Corner handles
476cdf0e10cSrcweir 				if(bRot)
477cdf0e10cSrcweir 				{
478cdf0e10cSrcweir 					eKindOfMarker = Circ_7x7;
479cdf0e10cSrcweir 				}
480cdf0e10cSrcweir 				else
481cdf0e10cSrcweir 				{
482cdf0e10cSrcweir 					eKindOfMarker = Rect_7x7;
483cdf0e10cSrcweir 				}
484cdf0e10cSrcweir 				break;
485cdf0e10cSrcweir 			}
486cdf0e10cSrcweir 			case HDL_UPPER:
487cdf0e10cSrcweir 			case HDL_LOWER:
488cdf0e10cSrcweir 			{
489cdf0e10cSrcweir 				// Upper/Lower handles
490cdf0e10cSrcweir 				if(bRot)
491cdf0e10cSrcweir 				{
492cdf0e10cSrcweir 					eKindOfMarker = Elli_9x7;
493cdf0e10cSrcweir 				}
494cdf0e10cSrcweir 				else
495cdf0e10cSrcweir 				{
496cdf0e10cSrcweir 					eKindOfMarker = Rect_7x7;
497cdf0e10cSrcweir 				}
498cdf0e10cSrcweir 				break;
499cdf0e10cSrcweir 			}
500cdf0e10cSrcweir 			case HDL_LEFT:
501cdf0e10cSrcweir 			case HDL_RIGHT:
502cdf0e10cSrcweir 			{
503cdf0e10cSrcweir 				// Left/Right handles
504cdf0e10cSrcweir 				if(bRot)
505cdf0e10cSrcweir 				{
506cdf0e10cSrcweir 					eKindOfMarker = Elli_7x9;
507cdf0e10cSrcweir 				}
508cdf0e10cSrcweir 				else
509cdf0e10cSrcweir 				{
510cdf0e10cSrcweir 					eKindOfMarker = Rect_7x7;
511cdf0e10cSrcweir 				}
512cdf0e10cSrcweir 				break;
513cdf0e10cSrcweir 			}
514cdf0e10cSrcweir 			case HDL_POLY:
515cdf0e10cSrcweir 			{
516cdf0e10cSrcweir 				if(bRot)
517cdf0e10cSrcweir 				{
518cdf0e10cSrcweir 					eKindOfMarker = (b1PixMore) ? Circ_9x9 : Circ_7x7;
519cdf0e10cSrcweir 				}
520cdf0e10cSrcweir 				else
521cdf0e10cSrcweir 				{
522cdf0e10cSrcweir 					eKindOfMarker = (b1PixMore) ? Rect_9x9 : Rect_7x7;
523cdf0e10cSrcweir 				}
524cdf0e10cSrcweir 				break;
525cdf0e10cSrcweir 			}
526cdf0e10cSrcweir 			case HDL_BWGT: // weight at poly
527cdf0e10cSrcweir 			{
528cdf0e10cSrcweir 				eKindOfMarker = Circ_7x7;
529cdf0e10cSrcweir 				break;
530cdf0e10cSrcweir 			}
531cdf0e10cSrcweir 			case HDL_CIRC:
532cdf0e10cSrcweir 			{
533cdf0e10cSrcweir 				eKindOfMarker = Rect_11x11;
534cdf0e10cSrcweir 				break;
535cdf0e10cSrcweir 			}
536cdf0e10cSrcweir 			case HDL_REF1:
537cdf0e10cSrcweir 			case HDL_REF2:
538cdf0e10cSrcweir 			{
539cdf0e10cSrcweir 				eKindOfMarker = Crosshair;
540cdf0e10cSrcweir 				break;
541cdf0e10cSrcweir 			}
5422a90d9eaSmseidel 			{
5432a90d9eaSmseidel 				eKindOfMarker = Crosshair_Unselected;
5442a90d9eaSmseidel 				break;
5452a90d9eaSmseidel 			}
546cdf0e10cSrcweir 			case HDL_GLUE:
547cdf0e10cSrcweir 			{
548cdf0e10cSrcweir 				eKindOfMarker = Glue;
549cdf0e10cSrcweir 				break;
550cdf0e10cSrcweir 			}
5512a90d9eaSmseidel 			case HDL_GLUE_UNSEL:
5522a90d9eaSmseidel 			{
5532a90d9eaSmseidel 				eKindOfMarker = Glue_Unselected;
5542a90d9eaSmseidel 				break;
5552a90d9eaSmseidel 			}
556cdf0e10cSrcweir 			case HDL_ANCHOR:
557cdf0e10cSrcweir 			{
558cdf0e10cSrcweir 				eKindOfMarker = Anchor;
559cdf0e10cSrcweir 				break;
560cdf0e10cSrcweir 			}
561cdf0e10cSrcweir 			case HDL_USER:
562cdf0e10cSrcweir 			{
563cdf0e10cSrcweir 				break;
564cdf0e10cSrcweir 			}
565cdf0e10cSrcweir 			// #101688# top right anchor for SW
566cdf0e10cSrcweir 			case HDL_ANCHOR_TR:
567cdf0e10cSrcweir 			{
568cdf0e10cSrcweir 				eKindOfMarker = AnchorTR;
569cdf0e10cSrcweir 				break;
570cdf0e10cSrcweir 			}
571cdf0e10cSrcweir 
572cdf0e10cSrcweir 			// for SJ and the CustomShapeHandles:
573cdf0e10cSrcweir 			case HDL_CUSTOMSHAPE1:
574cdf0e10cSrcweir 			{
5755f27b83cSArmin Le Grand 				eKindOfMarker = (b1PixMore) ? Customshape_9x9 : Customshape_7x7;
576cdf0e10cSrcweir 				eColIndex = Yellow;
577cdf0e10cSrcweir 				break;
578cdf0e10cSrcweir 			}
579cdf0e10cSrcweir 			default:
580cdf0e10cSrcweir 				break;
581cdf0e10cSrcweir 		}
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
584cdf0e10cSrcweir 		SdrPageView* pPageView = pView->GetSdrPageView();
585cdf0e10cSrcweir 
586cdf0e10cSrcweir 		if(pPageView)
587cdf0e10cSrcweir 		{
588cdf0e10cSrcweir 			for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
589cdf0e10cSrcweir 			{
590cdf0e10cSrcweir 				// const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
591cdf0e10cSrcweir 				const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 				if(rPageWindow.GetPaintWindow().OutputToWindow())
594cdf0e10cSrcweir 				{
595cdf0e10cSrcweir 					Point aMoveOutsideOffset(0, 0);
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 					// add offset if necessary
598cdf0e10cSrcweir 					if(pHdlList->IsMoveOutside() || mbMoveOutside)
599cdf0e10cSrcweir 					{
600cdf0e10cSrcweir 						OutputDevice& rOutDev = rPageWindow.GetPaintWindow().GetOutputDevice();
601cdf0e10cSrcweir 						Size aOffset = rOutDev.PixelToLogic(Size(4, 4));
602cdf0e10cSrcweir 
603cdf0e10cSrcweir 						if(eKind == HDL_UPLFT || eKind == HDL_UPPER || eKind == HDL_UPRGT)
604cdf0e10cSrcweir 							aMoveOutsideOffset.Y() -= aOffset.Width();
605cdf0e10cSrcweir 						if(eKind == HDL_LWLFT || eKind == HDL_LOWER || eKind == HDL_LWRGT)
606cdf0e10cSrcweir 							aMoveOutsideOffset.Y() += aOffset.Height();
607cdf0e10cSrcweir 						if(eKind == HDL_UPLFT || eKind == HDL_LEFT  || eKind == HDL_LWLFT)
608cdf0e10cSrcweir 							aMoveOutsideOffset.X() -= aOffset.Width();
609cdf0e10cSrcweir 						if(eKind == HDL_UPRGT || eKind == HDL_RIGHT || eKind == HDL_LWRGT)
610cdf0e10cSrcweir 							aMoveOutsideOffset.X() += aOffset.Height();
611cdf0e10cSrcweir 					}
612cdf0e10cSrcweir 
613cdf0e10cSrcweir 					if(rPageWindow.GetOverlayManager())
614cdf0e10cSrcweir 					{
615cdf0e10cSrcweir 						basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
616cdf0e10cSrcweir 						::sdr::overlay::OverlayObject* pNewOverlayObject = CreateOverlayObject(
617cdf0e10cSrcweir 							aPosition,
618cdf0e10cSrcweir 							eColIndex,
619cdf0e10cSrcweir 							eKindOfMarker,
620cdf0e10cSrcweir 							aMoveOutsideOffset);
621cdf0e10cSrcweir 
622cdf0e10cSrcweir 						// OVERLAYMANAGER
623cdf0e10cSrcweir 						if(pNewOverlayObject)
624cdf0e10cSrcweir 						{
625cdf0e10cSrcweir 							rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
626cdf0e10cSrcweir 							maOverlayGroup.append(*pNewOverlayObject);
627cdf0e10cSrcweir 						}
628cdf0e10cSrcweir 					}
629cdf0e10cSrcweir 				}
630cdf0e10cSrcweir 			}
631cdf0e10cSrcweir 		}
632cdf0e10cSrcweir 	}
633cdf0e10cSrcweir }
634cdf0e10cSrcweir 
GetNextBigger(BitmapMarkerKind eKnd) const635cdf0e10cSrcweir BitmapMarkerKind SdrHdl::GetNextBigger(BitmapMarkerKind eKnd) const
636cdf0e10cSrcweir {
637cdf0e10cSrcweir 	BitmapMarkerKind eRetval(eKnd);
638cdf0e10cSrcweir 
639cdf0e10cSrcweir 	switch(eKnd)
640cdf0e10cSrcweir 	{
641cdf0e10cSrcweir 		case Rect_7x7:			eRetval = Rect_9x9;			break;
642cdf0e10cSrcweir 		case Rect_9x9:			eRetval = Rect_11x11;		break;
643cdf0e10cSrcweir 		case Rect_11x11:		eRetval = Rect_13x13;		break;
644cdf0e10cSrcweir 		//case Rect_13x13:		eRetval = ;	break;
645cdf0e10cSrcweir 
646cdf0e10cSrcweir 		case Circ_7x7:			eRetval = Circ_9x9;			break;
647cdf0e10cSrcweir 		case Circ_9x9:			eRetval = Circ_11x11;		break;
648cdf0e10cSrcweir 		//case Circ_11x11:		eRetval = ;	break;
649cdf0e10cSrcweir 
6504772d9afSArmin Le Grand 		case Customshape_7x7:		eRetval = Customshape_9x9;		break;
6514772d9afSArmin Le Grand 		case Customshape_9x9:		eRetval = Customshape_11x11;	break;
6524772d9afSArmin Le Grand 		//case Customshape_11x11:	eRetval = ;	break;
6534772d9afSArmin Le Grand 
654cdf0e10cSrcweir 		case Elli_7x9:			eRetval = Elli_9x11;		break;
655cdf0e10cSrcweir 		//case Elli_9x11:			eRetval = ;	break;
656cdf0e10cSrcweir 
657cdf0e10cSrcweir 		case Elli_9x7:			eRetval = Elli_11x9;		break;
658cdf0e10cSrcweir 		//case Elli_11x9:			eRetval = ;	break;
659cdf0e10cSrcweir 
660cdf0e10cSrcweir 		case RectPlus_7x7:		eRetval = RectPlus_9x9;		break;
661cdf0e10cSrcweir 		case RectPlus_9x9:		eRetval = RectPlus_11x11;	break;
662cdf0e10cSrcweir 		//case RectPlus_11x11:	eRetval = ;	break;
663cdf0e10cSrcweir 
664cdf0e10cSrcweir 		//case Crosshair:			eRetval = ;	break;
665cdf0e10cSrcweir 		//case Glue:				eRetval = ;	break;
666cdf0e10cSrcweir 
667ef96bc24Smseidel 		// #98388# let anchor blink with its pressed state
668cdf0e10cSrcweir 		case Anchor:			eRetval = AnchorPressed;	break;
669cdf0e10cSrcweir 
670cdf0e10cSrcweir 		// #101688# same for AnchorTR
671cdf0e10cSrcweir 		case AnchorTR:			eRetval = AnchorPressedTR;	break;
672cdf0e10cSrcweir 		default:
673cdf0e10cSrcweir 			break;
674cdf0e10cSrcweir 	}
675cdf0e10cSrcweir 
676cdf0e10cSrcweir 	return eRetval;
677cdf0e10cSrcweir }
678cdf0e10cSrcweir 
679cdf0e10cSrcweir // #101928#
ImpGetBitmapEx(BitmapMarkerKind eKindOfMarker,sal_uInt16 nInd,sal_Bool bFine,sal_Bool bIsHighContrast)680cdf0e10cSrcweir BitmapEx SdrHdl::ImpGetBitmapEx(BitmapMarkerKind eKindOfMarker, sal_uInt16 nInd, sal_Bool bFine, sal_Bool bIsHighContrast)
681cdf0e10cSrcweir {
682cdf0e10cSrcweir 	if(bIsHighContrast)
683cdf0e10cSrcweir 	{
684cdf0e10cSrcweir 		return getHighContrastSet().GetBitmapEx(eKindOfMarker, nInd);
685cdf0e10cSrcweir 	}
686cdf0e10cSrcweir 	else
687cdf0e10cSrcweir 	{
688cdf0e10cSrcweir 		if(bFine)
689cdf0e10cSrcweir 		{
690cdf0e10cSrcweir 			return getModernSet().GetBitmapEx(eKindOfMarker, nInd);
691cdf0e10cSrcweir 		}
692cdf0e10cSrcweir 		else
693cdf0e10cSrcweir 		{
694cdf0e10cSrcweir 			return getSimpleSet().GetBitmapEx(eKindOfMarker, nInd);
695cdf0e10cSrcweir 		}
696cdf0e10cSrcweir 	}
697cdf0e10cSrcweir }
698cdf0e10cSrcweir 
CreateOverlayObject(const basegfx::B2DPoint & rPos,BitmapColorIndex eColIndex,BitmapMarkerKind eKindOfMarker,Point aMoveOutsideOffset)699cdf0e10cSrcweir ::sdr::overlay::OverlayObject* SdrHdl::CreateOverlayObject(
700cdf0e10cSrcweir 	const basegfx::B2DPoint& rPos,
701cdf0e10cSrcweir 	BitmapColorIndex eColIndex, BitmapMarkerKind eKindOfMarker, Point aMoveOutsideOffset)
702cdf0e10cSrcweir {
703cdf0e10cSrcweir 	::sdr::overlay::OverlayObject* pRetval = 0L;
704cdf0e10cSrcweir 	sal_Bool bIsFineHdl(pHdlList->IsFineHdl());
705cdf0e10cSrcweir 	const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
706cdf0e10cSrcweir 	sal_Bool bIsHighContrast(rStyleSettings.GetHighContrastMode());
707cdf0e10cSrcweir 
708cdf0e10cSrcweir 	// support bigger sizes
709cdf0e10cSrcweir 	sal_Bool bForceBiggerSize(sal_False);
710cdf0e10cSrcweir 
711cdf0e10cSrcweir 	if(pHdlList->GetHdlSize() > 3)
712cdf0e10cSrcweir 	{
7134772d9afSArmin Le Grand 		switch(eKindOfMarker)
7144772d9afSArmin Le Grand 		{
7154772d9afSArmin Le Grand 			case Anchor:
7164772d9afSArmin Le Grand 			case AnchorPressed:
7174772d9afSArmin Le Grand 			case AnchorTR:
7184772d9afSArmin Le Grand 			case AnchorPressedTR:
7194772d9afSArmin Le Grand 			{
7204772d9afSArmin Le Grand 				// #121463# For anchor, do not simply make bigger because of HdlSize,
7214772d9afSArmin Le Grand 				// do it dependent of IsSelected() which Writer can set in drag mode
7224772d9afSArmin Le Grand 				if(IsSelected())
7234772d9afSArmin Le Grand 				{
724cdf0e10cSrcweir 					bForceBiggerSize = sal_True;
725cdf0e10cSrcweir 				}
7264772d9afSArmin Le Grand 				break;
7274772d9afSArmin Le Grand 			}
7284772d9afSArmin Le Grand 			default:
7294772d9afSArmin Le Grand 			{
7304772d9afSArmin Le Grand 				bForceBiggerSize = sal_True;
7314772d9afSArmin Le Grand 				break;
7324772d9afSArmin Le Grand 			}
7334772d9afSArmin Le Grand 		}
7344772d9afSArmin Le Grand 	}
735cdf0e10cSrcweir 
736cdf0e10cSrcweir 	// #101928# ...for high contrast, too.
737cdf0e10cSrcweir 	if(!bForceBiggerSize && bIsHighContrast)
738cdf0e10cSrcweir 	{
739cdf0e10cSrcweir 		// #107925#
740cdf0e10cSrcweir 		// ...but not for anchors, else they will not blink when activated
741cdf0e10cSrcweir 		if(Anchor != eKindOfMarker && AnchorTR != eKindOfMarker)
742cdf0e10cSrcweir 		{
743cdf0e10cSrcweir 			bForceBiggerSize = sal_True;
744cdf0e10cSrcweir 		}
745cdf0e10cSrcweir 	}
746cdf0e10cSrcweir 
747cdf0e10cSrcweir 	if(bForceBiggerSize)
748cdf0e10cSrcweir 	{
749cdf0e10cSrcweir 		eKindOfMarker = GetNextBigger(eKindOfMarker);
750cdf0e10cSrcweir 	}
751cdf0e10cSrcweir 
752cdf0e10cSrcweir 	// #97016# II This handle has the focus, visualize it
753cdf0e10cSrcweir 	if(IsFocusHdl() && pHdlList && pHdlList->GetFocusHdl() == this)
754cdf0e10cSrcweir 	{
755cdf0e10cSrcweir 		// create animated handle
756cdf0e10cSrcweir 		BitmapMarkerKind eNextBigger = GetNextBigger(eKindOfMarker);
757cdf0e10cSrcweir 
758cdf0e10cSrcweir 		if(eNextBigger == eKindOfMarker)
759cdf0e10cSrcweir 		{
760cdf0e10cSrcweir 			// this may happen for the not supported getting-bigger types.
761cdf0e10cSrcweir 			// Choose an alternative here
762cdf0e10cSrcweir 			switch(eKindOfMarker)
763cdf0e10cSrcweir 			{
764cdf0e10cSrcweir 				case Rect_13x13:		eNextBigger = Rect_11x11;	break;
765cdf0e10cSrcweir 				case Circ_11x11:		eNextBigger = Elli_11x9;	break;
766cdf0e10cSrcweir 				case Elli_9x11:			eNextBigger = Elli_11x9;	break;
767cdf0e10cSrcweir 				case Elli_11x9:			eNextBigger = Elli_9x11;	break;
768cdf0e10cSrcweir 				case RectPlus_11x11:	eNextBigger = Rect_13x13;	break;
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 				case Crosshair:
7712a90d9eaSmseidel 					eNextBigger = Crosshair_Unselected;
772cdf0e10cSrcweir 					break;
773cdf0e10cSrcweir 
774cdf0e10cSrcweir 				case Glue:
7752a90d9eaSmseidel 					eNextBigger = Glue_Unselected;
776cdf0e10cSrcweir 					break;
777cdf0e10cSrcweir 				default:
778cdf0e10cSrcweir 					break;
779cdf0e10cSrcweir 			}
780cdf0e10cSrcweir 		}
781cdf0e10cSrcweir 
782cdf0e10cSrcweir 		// create animated hdl
783cdf0e10cSrcweir 		// #101928# use ImpGetBitmapEx(...) now
784cdf0e10cSrcweir 		BitmapEx aBmpEx1 = ImpGetBitmapEx(eKindOfMarker, (sal_uInt16)eColIndex, bIsFineHdl, bIsHighContrast);
785cdf0e10cSrcweir 		BitmapEx aBmpEx2 = ImpGetBitmapEx(eNextBigger, (sal_uInt16)eColIndex, bIsFineHdl, bIsHighContrast);
786cdf0e10cSrcweir 
787cdf0e10cSrcweir 		// #i53216# Use system cursor blink time. Use the unsigned value.
788cdf0e10cSrcweir 		const sal_uInt32 nBlinkTime((sal_uInt32)Application::GetSettings().GetStyleSettings().GetCursorBlinkTime());
789cdf0e10cSrcweir 
790cdf0e10cSrcweir 		if(eKindOfMarker == Anchor || eKindOfMarker == AnchorPressed)
791cdf0e10cSrcweir 		{
792cdf0e10cSrcweir 			// #98388# when anchor is used take upper left as reference point inside the handle
793cdf0e10cSrcweir 			pRetval = new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos, aBmpEx1, aBmpEx2, nBlinkTime);
794cdf0e10cSrcweir 		}
795cdf0e10cSrcweir 		else if(eKindOfMarker == AnchorTR || eKindOfMarker == AnchorPressedTR)
796cdf0e10cSrcweir 		{
797cdf0e10cSrcweir 			// #101688# AnchorTR for SW, take top right as (0,0)
798cdf0e10cSrcweir 			pRetval = new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos, aBmpEx1, aBmpEx2, nBlinkTime,
799cdf0e10cSrcweir 				(sal_uInt16)(aBmpEx1.GetSizePixel().Width() - 1), 0,
800cdf0e10cSrcweir 				(sal_uInt16)(aBmpEx2.GetSizePixel().Width() - 1), 0);
801cdf0e10cSrcweir 		}
802cdf0e10cSrcweir 		else
803cdf0e10cSrcweir 		{
804cdf0e10cSrcweir 			// create centered handle as default
805cdf0e10cSrcweir 			pRetval = new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos, aBmpEx1, aBmpEx2, nBlinkTime,
806cdf0e10cSrcweir 				(sal_uInt16)(aBmpEx1.GetSizePixel().Width() - 1) >> 1,
807cdf0e10cSrcweir 				(sal_uInt16)(aBmpEx1.GetSizePixel().Height() - 1) >> 1,
808cdf0e10cSrcweir 				(sal_uInt16)(aBmpEx2.GetSizePixel().Width() - 1) >> 1,
809cdf0e10cSrcweir 				(sal_uInt16)(aBmpEx2.GetSizePixel().Height() - 1) >> 1);
810cdf0e10cSrcweir 		}
811cdf0e10cSrcweir 	}
812cdf0e10cSrcweir 	else
813cdf0e10cSrcweir 	{
814cdf0e10cSrcweir 		// create normal handle
815cdf0e10cSrcweir 		// #101928# use ImpGetBitmapEx(...) now
816cdf0e10cSrcweir 		BitmapEx aBmpEx = ImpGetBitmapEx(eKindOfMarker, (sal_uInt16)eColIndex, bIsFineHdl, bIsHighContrast);
817cdf0e10cSrcweir 
818cdf0e10cSrcweir 		if(eKindOfMarker == Anchor || eKindOfMarker == AnchorPressed)
819cdf0e10cSrcweir 		{
820cdf0e10cSrcweir 			// #98388# upper left as reference point inside the handle for AnchorPressed, too
821cdf0e10cSrcweir 			pRetval = new ::sdr::overlay::OverlayBitmapEx(rPos, aBmpEx);
822cdf0e10cSrcweir 		}
823cdf0e10cSrcweir 		else if(eKindOfMarker == AnchorTR || eKindOfMarker == AnchorPressedTR)
824cdf0e10cSrcweir 		{
825cdf0e10cSrcweir 			// #101688# AnchorTR for SW, take top right as (0,0)
826cdf0e10cSrcweir 			pRetval = new ::sdr::overlay::OverlayBitmapEx(rPos, aBmpEx,
827cdf0e10cSrcweir 				(sal_uInt16)(aBmpEx.GetSizePixel().Width() - 1), 0);
828cdf0e10cSrcweir 		}
829cdf0e10cSrcweir 		else
830cdf0e10cSrcweir 		{
831cdf0e10cSrcweir 			sal_uInt16 nCenX((sal_uInt16)(aBmpEx.GetSizePixel().Width() - 1L) >> 1);
832cdf0e10cSrcweir 			sal_uInt16 nCenY((sal_uInt16)(aBmpEx.GetSizePixel().Height() - 1L) >> 1);
833cdf0e10cSrcweir 
834cdf0e10cSrcweir 			if(aMoveOutsideOffset.X() > 0)
835cdf0e10cSrcweir 			{
836cdf0e10cSrcweir 				nCenX = 0;
837cdf0e10cSrcweir 			}
838cdf0e10cSrcweir 			else if(aMoveOutsideOffset.X() < 0)
839cdf0e10cSrcweir 			{
840cdf0e10cSrcweir 				nCenX = (sal_uInt16)(aBmpEx.GetSizePixel().Width() - 1);
841cdf0e10cSrcweir 			}
842cdf0e10cSrcweir 
843cdf0e10cSrcweir 			if(aMoveOutsideOffset.Y() > 0)
844cdf0e10cSrcweir 			{
845cdf0e10cSrcweir 				nCenY = 0;
846cdf0e10cSrcweir 			}
847cdf0e10cSrcweir 			else if(aMoveOutsideOffset.Y() < 0)
848cdf0e10cSrcweir 			{
849cdf0e10cSrcweir 				nCenY = (sal_uInt16)(aBmpEx.GetSizePixel().Height() - 1);
850cdf0e10cSrcweir 			}
851cdf0e10cSrcweir 
852cdf0e10cSrcweir 			// create centered handle as default
853cdf0e10cSrcweir 			pRetval = new ::sdr::overlay::OverlayBitmapEx(rPos, aBmpEx, nCenX, nCenY);
854cdf0e10cSrcweir 		}
855cdf0e10cSrcweir 	}
856cdf0e10cSrcweir 
857cdf0e10cSrcweir 	return pRetval;
858cdf0e10cSrcweir }
859cdf0e10cSrcweir 
IsHdlHit(const Point & rPnt) const860cdf0e10cSrcweir bool SdrHdl::IsHdlHit(const Point& rPnt) const
861cdf0e10cSrcweir {
862cdf0e10cSrcweir 	// OVERLAYMANAGER
863cdf0e10cSrcweir 	basegfx::B2DPoint aPosition(rPnt.X(), rPnt.Y());
864cdf0e10cSrcweir 	return maOverlayGroup.isHitLogic(aPosition);
865cdf0e10cSrcweir }
866cdf0e10cSrcweir 
GetPointer() const867cdf0e10cSrcweir Pointer SdrHdl::GetPointer() const
868cdf0e10cSrcweir {
869cdf0e10cSrcweir 	PointerStyle ePtr=POINTER_MOVE;
870cdf0e10cSrcweir 	const sal_Bool bSize=eKind>=HDL_UPLFT && eKind<=HDL_LWRGT;
871cdf0e10cSrcweir 	const sal_Bool bRot=pHdlList!=NULL && pHdlList->IsRotateShear();
872cdf0e10cSrcweir 	const sal_Bool bDis=pHdlList!=NULL && pHdlList->IsDistortShear();
873cdf0e10cSrcweir 	if (bSize && pHdlList!=NULL && (bRot || bDis)) {
874cdf0e10cSrcweir 		switch (eKind) {
875cdf0e10cSrcweir 			case HDL_UPLFT: case HDL_UPRGT:
876cdf0e10cSrcweir 			case HDL_LWLFT: case HDL_LWRGT: ePtr=bRot ? POINTER_ROTATE : POINTER_REFHAND; break;
877cdf0e10cSrcweir 			case HDL_LEFT : case HDL_RIGHT: ePtr=POINTER_VSHEAR; break;
878cdf0e10cSrcweir 			case HDL_UPPER: case HDL_LOWER: ePtr=POINTER_HSHEAR; break;
879cdf0e10cSrcweir 			default:
880cdf0e10cSrcweir 				break;
881cdf0e10cSrcweir 		}
882cdf0e10cSrcweir 	} else {
883cdf0e10cSrcweir 		// Fuer Resize von gedrehten Rechtecken die Mauszeiger etwas mitdrehen
884cdf0e10cSrcweir 		if (bSize && nDrehWink!=0) {
885cdf0e10cSrcweir 			long nHdlWink=0;
886cdf0e10cSrcweir 			switch (eKind) {
887cdf0e10cSrcweir 				case HDL_LWRGT: nHdlWink=31500;	break;
888cdf0e10cSrcweir 				case HDL_LOWER: nHdlWink=27000;	break;
889cdf0e10cSrcweir 				case HDL_LWLFT: nHdlWink=22500;	break;
890cdf0e10cSrcweir 				case HDL_LEFT : nHdlWink=18000;	break;
891cdf0e10cSrcweir 				case HDL_UPLFT: nHdlWink=13500;	break;
892cdf0e10cSrcweir 				case HDL_UPPER: nHdlWink=9000;	break;
893cdf0e10cSrcweir 				case HDL_UPRGT: nHdlWink=4500;	break;
894cdf0e10cSrcweir 				case HDL_RIGHT: nHdlWink=0;		break;
895cdf0e10cSrcweir 				default:
896cdf0e10cSrcweir 					break;
897cdf0e10cSrcweir 			}
898cdf0e10cSrcweir 			nHdlWink+=nDrehWink+2249; // und etwas drauf (zum runden)
899cdf0e10cSrcweir 			while (nHdlWink<0) nHdlWink+=36000;
900cdf0e10cSrcweir 			while (nHdlWink>=36000) nHdlWink-=36000;
901cdf0e10cSrcweir 			nHdlWink/=4500;
902cdf0e10cSrcweir 			switch ((sal_uInt8)nHdlWink) {
903cdf0e10cSrcweir 				case 0: ePtr=POINTER_ESIZE;		break;
904cdf0e10cSrcweir 				case 1: ePtr=POINTER_NESIZE;	break;
905cdf0e10cSrcweir 				case 2: ePtr=POINTER_NSIZE;		break;
906cdf0e10cSrcweir 				case 3: ePtr=POINTER_NWSIZE;	break;
907cdf0e10cSrcweir 				case 4: ePtr=POINTER_WSIZE;		break;
908cdf0e10cSrcweir 				case 5: ePtr=POINTER_SWSIZE;	break;
909cdf0e10cSrcweir 				case 6: ePtr=POINTER_SSIZE;		break;
910cdf0e10cSrcweir 				case 7: ePtr=POINTER_SESIZE;	break;
911cdf0e10cSrcweir 			} // switch
912cdf0e10cSrcweir 		} else {
913cdf0e10cSrcweir 			switch (eKind) {
914cdf0e10cSrcweir 				case HDL_UPLFT: ePtr=POINTER_NWSIZE;	break;
915cdf0e10cSrcweir 				case HDL_UPPER: ePtr=POINTER_NSIZE;		break;
916cdf0e10cSrcweir 				case HDL_UPRGT: ePtr=POINTER_NESIZE;	break;
917cdf0e10cSrcweir 				case HDL_LEFT : ePtr=POINTER_WSIZE;		break;
918cdf0e10cSrcweir 				case HDL_RIGHT: ePtr=POINTER_ESIZE;		break;
919cdf0e10cSrcweir 				case HDL_LWLFT: ePtr=POINTER_SWSIZE;	break;
920cdf0e10cSrcweir 				case HDL_LOWER: ePtr=POINTER_SSIZE;		break;
921cdf0e10cSrcweir 				case HDL_LWRGT: ePtr=POINTER_SESIZE;	break;
922cdf0e10cSrcweir 				case HDL_POLY : ePtr=POINTER_MOVEPOINT;	break;
923cdf0e10cSrcweir 				case HDL_CIRC : ePtr=POINTER_HAND;		break;
924cdf0e10cSrcweir 				case HDL_REF1 : ePtr=POINTER_REFHAND;	break;
925cdf0e10cSrcweir 				case HDL_REF2 : ePtr=POINTER_REFHAND;	break;
926cdf0e10cSrcweir 				case HDL_BWGT : ePtr=POINTER_MOVEBEZIERWEIGHT;	break;
927cdf0e10cSrcweir 				case HDL_GLUE : ePtr=POINTER_MOVEPOINT;	break;
9282a90d9eaSmseidel 				case HDL_GLUE_UNSEL : ePtr=POINTER_MOVEPOINT;	break;
929cdf0e10cSrcweir 				case HDL_CUSTOMSHAPE1 : ePtr=POINTER_HAND;	break;
930cdf0e10cSrcweir 				default:
931cdf0e10cSrcweir 					break;
932cdf0e10cSrcweir 			}
933cdf0e10cSrcweir 		}
934cdf0e10cSrcweir 	}
935cdf0e10cSrcweir 	return Pointer(ePtr);
936cdf0e10cSrcweir }
937cdf0e10cSrcweir 
938cdf0e10cSrcweir // #97016# II
IsFocusHdl() const939cdf0e10cSrcweir sal_Bool SdrHdl::IsFocusHdl() const
940cdf0e10cSrcweir {
941cdf0e10cSrcweir 	switch(eKind)
942cdf0e10cSrcweir 	{
943ef96bc24Smseidel 		case HDL_UPLFT:		// top left
944ef96bc24Smseidel 		case HDL_UPPER:		// top
945ef96bc24Smseidel 		case HDL_UPRGT:		// top right
946ef96bc24Smseidel 		case HDL_LEFT:		// left
947ef96bc24Smseidel 		case HDL_RIGHT:		// right
948ef96bc24Smseidel 		case HDL_LWLFT:		// bottom left
949ef96bc24Smseidel 		case HDL_LOWER:		// bottom
950ef96bc24Smseidel 		case HDL_LWRGT:		// bottom right
951cdf0e10cSrcweir 		{
9522a90d9eaSmseidel 			// if it's an activated TextEdit, it's moved to extended points
953cdf0e10cSrcweir 			if(pHdlList && pHdlList->IsMoveOutside())
954cdf0e10cSrcweir 				return sal_False;
955cdf0e10cSrcweir 			else
956cdf0e10cSrcweir 				return sal_True;
957cdf0e10cSrcweir 		}
958cdf0e10cSrcweir 
959cdf0e10cSrcweir 		case HDL_MOVE:		// Handle zum Verschieben des Objekts
960cdf0e10cSrcweir 		case HDL_POLY:		// Punktselektion an Polygon oder Bezierkurve
961cdf0e10cSrcweir 		case HDL_BWGT:		// Gewicht an einer Bezierkurve
962cdf0e10cSrcweir 		case HDL_CIRC:		// Winkel an Kreissegmenten, Eckenradius am Rect
963cdf0e10cSrcweir 		case HDL_REF1:		// Referenzpunkt 1, z.B. Rotationsmitte
964cdf0e10cSrcweir 		case HDL_REF2:		// Referenzpunkt 2, z.B. Endpunkt der Spiegelachse
965cdf0e10cSrcweir 		//case HDL_MIRX:		// Die Spiegelachse selbst
9662a90d9eaSmseidel 		case HDL_GLUE:		// glue point
9672a90d9eaSmseidel 		case HDL_GLUE_UNSEL: // glue point unselected
968cdf0e10cSrcweir 
969cdf0e10cSrcweir 		// #98388# do NOT activate here, let SW implement their own SdrHdl and
970cdf0e10cSrcweir 		// overload IsFocusHdl() there to make the anchor accessible
971cdf0e10cSrcweir 		//case HDL_ANCHOR:		// anchor symbol (SD, SW)
972cdf0e10cSrcweir 		// #101688# same for AnchorTR
973cdf0e10cSrcweir 		//case HDL_ANCHOR_TR:	// anchor symbol (SD, SW)
974cdf0e10cSrcweir 
975ef96bc24Smseidel 		//case HDL_TRNS:		// interactive transparency
976cdf0e10cSrcweir 		//case HDL_GRAD:		// interactive gradient
977cdf0e10cSrcweir 		//case HDL_COLR:		// interactive color
978cdf0e10cSrcweir 
979cdf0e10cSrcweir 		// for SJ and the CustomShapeHandles:
980cdf0e10cSrcweir 		case HDL_CUSTOMSHAPE1:
981cdf0e10cSrcweir 
982cdf0e10cSrcweir 		case HDL_USER:
983cdf0e10cSrcweir 		{
984cdf0e10cSrcweir 			return sal_True;
985cdf0e10cSrcweir 		}
986cdf0e10cSrcweir 
987cdf0e10cSrcweir 		default:
988cdf0e10cSrcweir 		{
989cdf0e10cSrcweir 			return sal_False;
990cdf0e10cSrcweir 		}
991cdf0e10cSrcweir 	}
992cdf0e10cSrcweir }
993cdf0e10cSrcweir 
onMouseEnter(const MouseEvent &)994cdf0e10cSrcweir void SdrHdl::onMouseEnter(const MouseEvent& /*rMEvt*/)
995cdf0e10cSrcweir {
996cdf0e10cSrcweir }
997cdf0e10cSrcweir 
onMouseLeave()998cdf0e10cSrcweir void SdrHdl::onMouseLeave()
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir }
1001cdf0e10cSrcweir 
isMouseOver() const1002cdf0e10cSrcweir bool SdrHdl::isMouseOver() const
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir 	return mbMouseOver;
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1008cdf0e10cSrcweir // class SdrHdlColor
1009cdf0e10cSrcweir 
SdrHdlColor(const Point & rRef,Color aCol,const Size & rSize,sal_Bool bLum)1010cdf0e10cSrcweir SdrHdlColor::SdrHdlColor(const Point& rRef, Color aCol, const Size& rSize, sal_Bool bLum)
1011cdf0e10cSrcweir :	SdrHdl(rRef, HDL_COLR),
1012cdf0e10cSrcweir 	aMarkerSize(rSize),
1013cdf0e10cSrcweir 	bUseLuminance(bLum)
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir 	if(IsUseLuminance())
1016cdf0e10cSrcweir 		aCol = GetLuminance(aCol);
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir 	// remember color
1019cdf0e10cSrcweir 	aMarkerColor = aCol;
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir 
~SdrHdlColor()1022cdf0e10cSrcweir SdrHdlColor::~SdrHdlColor()
1023cdf0e10cSrcweir {
1024cdf0e10cSrcweir }
1025cdf0e10cSrcweir 
CreateB2dIAObject()1026cdf0e10cSrcweir void SdrHdlColor::CreateB2dIAObject()
1027cdf0e10cSrcweir {
1028cdf0e10cSrcweir 	// first throw away old one
1029cdf0e10cSrcweir 	GetRidOfIAObject();
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir 	if(pHdlList)
1032cdf0e10cSrcweir 	{
1033cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir 		if(pView && !pView->areMarkHandlesHidden())
1036cdf0e10cSrcweir 		{
1037cdf0e10cSrcweir 			SdrPageView* pPageView = pView->GetSdrPageView();
1038cdf0e10cSrcweir 
1039cdf0e10cSrcweir 			if(pPageView)
1040cdf0e10cSrcweir 			{
1041cdf0e10cSrcweir 				for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1042cdf0e10cSrcweir 				{
1043cdf0e10cSrcweir 					// const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
1044cdf0e10cSrcweir 					const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1045cdf0e10cSrcweir 
1046cdf0e10cSrcweir 					if(rPageWindow.GetPaintWindow().OutputToWindow())
1047cdf0e10cSrcweir 					{
1048cdf0e10cSrcweir 						if(rPageWindow.GetOverlayManager())
1049cdf0e10cSrcweir 						{
1050cdf0e10cSrcweir 							Bitmap aBmpCol(CreateColorDropper(aMarkerColor));
1051cdf0e10cSrcweir 							basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
1052cdf0e10cSrcweir 							::sdr::overlay::OverlayObject* pNewOverlayObject = new
1053cdf0e10cSrcweir 								::sdr::overlay::OverlayBitmapEx(
1054cdf0e10cSrcweir 									aPosition,
1055cdf0e10cSrcweir 									BitmapEx(aBmpCol),
1056cdf0e10cSrcweir 									(sal_uInt16)(aBmpCol.GetSizePixel().Width() - 1) >> 1,
1057cdf0e10cSrcweir 									(sal_uInt16)(aBmpCol.GetSizePixel().Height() - 1) >> 1
1058cdf0e10cSrcweir 								);
1059cdf0e10cSrcweir 							DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir 							// OVERLAYMANAGER
1062cdf0e10cSrcweir 							if(pNewOverlayObject)
1063cdf0e10cSrcweir 							{
1064cdf0e10cSrcweir 								rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1065cdf0e10cSrcweir 								maOverlayGroup.append(*pNewOverlayObject);
1066cdf0e10cSrcweir 							}
1067cdf0e10cSrcweir 						}
1068cdf0e10cSrcweir 					}
1069cdf0e10cSrcweir 				}
1070cdf0e10cSrcweir 			}
1071cdf0e10cSrcweir 		}
1072cdf0e10cSrcweir 	}
1073cdf0e10cSrcweir }
1074cdf0e10cSrcweir 
CreateColorDropper(Color aCol)1075cdf0e10cSrcweir Bitmap SdrHdlColor::CreateColorDropper(Color aCol)
1076cdf0e10cSrcweir {
1077cdf0e10cSrcweir 	// get the Bitmap
1078cdf0e10cSrcweir 	Bitmap aRetval(aMarkerSize, 24);
1079cdf0e10cSrcweir 	aRetval.Erase(aCol);
1080cdf0e10cSrcweir 
1081cdf0e10cSrcweir 	// get write access
1082cdf0e10cSrcweir 	BitmapWriteAccess* pWrite = aRetval.AcquireWriteAccess();
1083cdf0e10cSrcweir 	DBG_ASSERT(pWrite, "Got NO write access to a new Bitmap !!!");
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir 	if(pWrite)
1086cdf0e10cSrcweir 	{
1087cdf0e10cSrcweir 		// draw outer border
1088cdf0e10cSrcweir 		sal_Int32 nWidth = aMarkerSize.Width();
1089cdf0e10cSrcweir 		sal_Int32 nHeight = aMarkerSize.Height();
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir 		pWrite->SetLineColor(Color(COL_LIGHTGRAY));
1092cdf0e10cSrcweir 		pWrite->DrawLine(Point(0, 0), Point(0, nHeight - 1));
1093cdf0e10cSrcweir 		pWrite->DrawLine(Point(1, 0), Point(nWidth - 1, 0));
1094cdf0e10cSrcweir 		pWrite->SetLineColor(Color(COL_GRAY));
1095cdf0e10cSrcweir 		pWrite->DrawLine(Point(1, nHeight - 1), Point(nWidth - 1, nHeight - 1));
1096cdf0e10cSrcweir 		pWrite->DrawLine(Point(nWidth - 1, 1), Point(nWidth - 1, nHeight - 2));
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir 		// draw lighter UpperLeft
1099cdf0e10cSrcweir 		const Color aLightColor(
1100cdf0e10cSrcweir 			(sal_uInt8)(::std::min((sal_Int16)((sal_Int16)aCol.GetRed() + (sal_Int16)0x0040), (sal_Int16)0x00ff)),
1101cdf0e10cSrcweir 			(sal_uInt8)(::std::min((sal_Int16)((sal_Int16)aCol.GetGreen() + (sal_Int16)0x0040), (sal_Int16)0x00ff)),
1102cdf0e10cSrcweir 			(sal_uInt8)(::std::min((sal_Int16)((sal_Int16)aCol.GetBlue() + (sal_Int16)0x0040), (sal_Int16)0x00ff)));
1103cdf0e10cSrcweir 		pWrite->SetLineColor(aLightColor);
1104cdf0e10cSrcweir 		pWrite->DrawLine(Point(1, 1), Point(1, nHeight - 2));
1105cdf0e10cSrcweir 		pWrite->DrawLine(Point(2, 1), Point(nWidth - 2, 1));
1106cdf0e10cSrcweir 
1107cdf0e10cSrcweir 		// draw darker LowerRight
1108cdf0e10cSrcweir 		const Color aDarkColor(
1109cdf0e10cSrcweir 			(sal_uInt8)(::std::max((sal_Int16)((sal_Int16)aCol.GetRed() - (sal_Int16)0x0040), (sal_Int16)0x0000)),
1110cdf0e10cSrcweir 			(sal_uInt8)(::std::max((sal_Int16)((sal_Int16)aCol.GetGreen() - (sal_Int16)0x0040), (sal_Int16)0x0000)),
1111cdf0e10cSrcweir 			(sal_uInt8)(::std::max((sal_Int16)((sal_Int16)aCol.GetBlue() - (sal_Int16)0x0040), (sal_Int16)0x0000)));
1112cdf0e10cSrcweir 		pWrite->SetLineColor(aDarkColor);
1113cdf0e10cSrcweir 		pWrite->DrawLine(Point(2, nHeight - 2), Point(nWidth - 2, nHeight - 2));
1114cdf0e10cSrcweir 		pWrite->DrawLine(Point(nWidth - 2, 2), Point(nWidth - 2, nHeight - 3));
1115cdf0e10cSrcweir 
1116cdf0e10cSrcweir 		// get rid of write access
1117cdf0e10cSrcweir 		delete pWrite;
1118cdf0e10cSrcweir 	}
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir 	return aRetval;
1121cdf0e10cSrcweir }
1122cdf0e10cSrcweir 
GetLuminance(const Color & rCol)1123cdf0e10cSrcweir Color SdrHdlColor::GetLuminance(const Color& rCol)
1124cdf0e10cSrcweir {
1125cdf0e10cSrcweir 	sal_uInt8 aLum = rCol.GetLuminance();
1126cdf0e10cSrcweir 	Color aRetval(aLum, aLum, aLum);
1127cdf0e10cSrcweir 	return aRetval;
1128cdf0e10cSrcweir }
1129cdf0e10cSrcweir 
CallColorChangeLink()1130cdf0e10cSrcweir void SdrHdlColor::CallColorChangeLink()
1131cdf0e10cSrcweir {
1132cdf0e10cSrcweir 	aColorChangeHdl.Call(this);
1133cdf0e10cSrcweir }
1134cdf0e10cSrcweir 
SetColor(Color aNew,sal_Bool bCallLink)1135cdf0e10cSrcweir void SdrHdlColor::SetColor(Color aNew, sal_Bool bCallLink)
1136cdf0e10cSrcweir {
1137cdf0e10cSrcweir 	if(IsUseLuminance())
1138cdf0e10cSrcweir 		aNew = GetLuminance(aNew);
1139cdf0e10cSrcweir 
1140cdf0e10cSrcweir 	if(aMarkerColor != aNew)
1141cdf0e10cSrcweir 	{
1142cdf0e10cSrcweir 		// remember new color
1143cdf0e10cSrcweir 		aMarkerColor = aNew;
1144cdf0e10cSrcweir 
1145cdf0e10cSrcweir 		// create new display
1146cdf0e10cSrcweir 		Touch();
1147cdf0e10cSrcweir 
1148cdf0e10cSrcweir 		// tell about change
1149cdf0e10cSrcweir 		if(bCallLink)
1150cdf0e10cSrcweir 			CallColorChangeLink();
1151cdf0e10cSrcweir 	}
1152cdf0e10cSrcweir }
1153cdf0e10cSrcweir 
SetSize(const Size & rNew)1154cdf0e10cSrcweir void SdrHdlColor::SetSize(const Size& rNew)
1155cdf0e10cSrcweir {
1156cdf0e10cSrcweir 	if(rNew != aMarkerSize)
1157cdf0e10cSrcweir 	{
1158cdf0e10cSrcweir 		// remember new size
1159cdf0e10cSrcweir 		aMarkerSize = rNew;
1160cdf0e10cSrcweir 
1161cdf0e10cSrcweir 		// create new display
1162cdf0e10cSrcweir 		Touch();
1163cdf0e10cSrcweir 	}
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir 
1166cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1167cdf0e10cSrcweir // class SdrHdlGradient
1168cdf0e10cSrcweir 
SdrHdlGradient(const Point & rRef1,const Point & rRef2,sal_Bool bGrad)1169cdf0e10cSrcweir SdrHdlGradient::SdrHdlGradient(const Point& rRef1, const Point& rRef2, sal_Bool bGrad)
1170cdf0e10cSrcweir :	SdrHdl(rRef1, bGrad ? HDL_GRAD : HDL_TRNS),
1171cdf0e10cSrcweir 	pColHdl1(NULL),
1172cdf0e10cSrcweir 	pColHdl2(NULL),
1173cdf0e10cSrcweir 	a2ndPos(rRef2),
1174cdf0e10cSrcweir 	bGradient(bGrad)
1175cdf0e10cSrcweir {
1176cdf0e10cSrcweir }
1177cdf0e10cSrcweir 
~SdrHdlGradient()1178cdf0e10cSrcweir SdrHdlGradient::~SdrHdlGradient()
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir }
1181cdf0e10cSrcweir 
Set2ndPos(const Point & rPnt)1182cdf0e10cSrcweir void SdrHdlGradient::Set2ndPos(const Point& rPnt)
1183cdf0e10cSrcweir {
1184cdf0e10cSrcweir 	if(a2ndPos != rPnt)
1185cdf0e10cSrcweir 	{
1186cdf0e10cSrcweir 		// remember new position
1187cdf0e10cSrcweir 		a2ndPos = rPnt;
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir 		// create new display
1190cdf0e10cSrcweir 		Touch();
1191cdf0e10cSrcweir 	}
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir 
CreateB2dIAObject()1194cdf0e10cSrcweir void SdrHdlGradient::CreateB2dIAObject()
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir 	// first throw away old one
1197cdf0e10cSrcweir 	GetRidOfIAObject();
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir 	if(pHdlList)
1200cdf0e10cSrcweir 	{
1201cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir 		if(pView && !pView->areMarkHandlesHidden())
1204cdf0e10cSrcweir 		{
1205cdf0e10cSrcweir 			SdrPageView* pPageView = pView->GetSdrPageView();
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir 			if(pPageView)
1208cdf0e10cSrcweir 			{
1209cdf0e10cSrcweir 				for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1210cdf0e10cSrcweir 				{
1211cdf0e10cSrcweir 					const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir 					if(rPageWindow.GetPaintWindow().OutputToWindow())
1214cdf0e10cSrcweir 					{
1215cdf0e10cSrcweir 						if(rPageWindow.GetOverlayManager())
1216cdf0e10cSrcweir 						{
1217cdf0e10cSrcweir 							// striped line in between
1218cdf0e10cSrcweir 							basegfx::B2DVector aVec(a2ndPos.X() - aPos.X(), a2ndPos.Y() - aPos.Y());
1219cdf0e10cSrcweir 							double fVecLen = aVec.getLength();
1220cdf0e10cSrcweir 							double fLongPercentArrow = (1.0 - 0.05) * fVecLen;
1221cdf0e10cSrcweir 							double fHalfArrowWidth = (0.05 * 0.5) * fVecLen;
1222cdf0e10cSrcweir 							aVec.normalize();
1223cdf0e10cSrcweir 							basegfx::B2DVector aPerpend(-aVec.getY(), aVec.getX());
1224cdf0e10cSrcweir 							sal_Int32 nMidX = (sal_Int32)(aPos.X() + aVec.getX() * fLongPercentArrow);
1225cdf0e10cSrcweir 							sal_Int32 nMidY = (sal_Int32)(aPos.Y() + aVec.getY() * fLongPercentArrow);
1226cdf0e10cSrcweir 							Point aMidPoint(nMidX, nMidY);
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir 							basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
1229cdf0e10cSrcweir 							basegfx::B2DPoint aMidPos(aMidPoint.X(), aMidPoint.Y());
1230cdf0e10cSrcweir 
1231cdf0e10cSrcweir 							::sdr::overlay::OverlayObject* pNewOverlayObject = new
1232cdf0e10cSrcweir 								::sdr::overlay::OverlayLineStriped(
1233cdf0e10cSrcweir 									aPosition, aMidPos
1234cdf0e10cSrcweir 								);
1235cdf0e10cSrcweir 							DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir 							pNewOverlayObject->setBaseColor(IsGradient() ? Color(COL_BLACK) : Color(COL_BLUE));
1238cdf0e10cSrcweir 							rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1239cdf0e10cSrcweir 							maOverlayGroup.append(*pNewOverlayObject);
1240cdf0e10cSrcweir 
1241cdf0e10cSrcweir 							// arrowhead
1242cdf0e10cSrcweir 							Point aLeft(aMidPoint.X() + (sal_Int32)(aPerpend.getX() * fHalfArrowWidth),
1243cdf0e10cSrcweir 										aMidPoint.Y() + (sal_Int32)(aPerpend.getY() * fHalfArrowWidth));
1244cdf0e10cSrcweir 							Point aRight(aMidPoint.X() - (sal_Int32)(aPerpend.getX() * fHalfArrowWidth),
1245cdf0e10cSrcweir 										aMidPoint.Y() - (sal_Int32)(aPerpend.getY() * fHalfArrowWidth));
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir 							basegfx::B2DPoint aPositionLeft(aLeft.X(), aLeft.Y());
1248cdf0e10cSrcweir 							basegfx::B2DPoint aPositionRight(aRight.X(), aRight.Y());
1249cdf0e10cSrcweir 							basegfx::B2DPoint aPosition2(a2ndPos.X(), a2ndPos.Y());
1250cdf0e10cSrcweir 
1251cdf0e10cSrcweir 							pNewOverlayObject = new
1252cdf0e10cSrcweir 								::sdr::overlay::OverlayTriangle(
1253cdf0e10cSrcweir 									aPositionLeft,
1254cdf0e10cSrcweir 									aPosition2,
1255cdf0e10cSrcweir 									aPositionRight,
1256cdf0e10cSrcweir 									IsGradient() ? Color(COL_BLACK) : Color(COL_BLUE)
1257cdf0e10cSrcweir 								);
1258cdf0e10cSrcweir 							DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
1259cdf0e10cSrcweir 
1260cdf0e10cSrcweir 							rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1261cdf0e10cSrcweir 							maOverlayGroup.append(*pNewOverlayObject);
1262cdf0e10cSrcweir 						}
1263cdf0e10cSrcweir 					}
1264cdf0e10cSrcweir 				}
1265cdf0e10cSrcweir 			}
1266cdf0e10cSrcweir 		}
1267cdf0e10cSrcweir 	}
1268cdf0e10cSrcweir }
1269cdf0e10cSrcweir 
1270cdf0e10cSrcweir IMPL_LINK(SdrHdlGradient, ColorChangeHdl, SdrHdl*, /*pHdl*/)
1271cdf0e10cSrcweir {
1272cdf0e10cSrcweir 	if(GetObj())
1273cdf0e10cSrcweir 		FromIAOToItem(GetObj(), sal_True, sal_True);
1274cdf0e10cSrcweir 	return 0;
1275cdf0e10cSrcweir }
1276cdf0e10cSrcweir 
FromIAOToItem(SdrObject * _pObj,sal_Bool bSetItemOnObject,sal_Bool bUndo)1277cdf0e10cSrcweir void SdrHdlGradient::FromIAOToItem(SdrObject* _pObj, sal_Bool bSetItemOnObject, sal_Bool bUndo)
1278cdf0e10cSrcweir {
1279cdf0e10cSrcweir 	// from IAO positions and colors to gradient
1280cdf0e10cSrcweir 	const SfxItemSet& rSet = _pObj->GetMergedItemSet();
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir 	GradTransformer aGradTransformer;
1283cdf0e10cSrcweir 	GradTransGradient aOldGradTransGradient;
1284cdf0e10cSrcweir 	GradTransGradient aGradTransGradient;
1285cdf0e10cSrcweir 	GradTransVector aGradTransVector;
1286cdf0e10cSrcweir 
1287cdf0e10cSrcweir 	String aString;
1288cdf0e10cSrcweir 
1289cdf0e10cSrcweir 	aGradTransVector.maPositionA = basegfx::B2DPoint(GetPos().X(), GetPos().Y());
1290cdf0e10cSrcweir 	aGradTransVector.maPositionB = basegfx::B2DPoint(Get2ndPos().X(), Get2ndPos().Y());
1291cdf0e10cSrcweir 	if(pColHdl1)
1292cdf0e10cSrcweir 		aGradTransVector.aCol1 = pColHdl1->GetColor();
1293cdf0e10cSrcweir 	if(pColHdl2)
1294cdf0e10cSrcweir 		aGradTransVector.aCol2 = pColHdl2->GetColor();
1295cdf0e10cSrcweir 
1296cdf0e10cSrcweir 	if(IsGradient())
1297cdf0e10cSrcweir 		aOldGradTransGradient.aGradient = ((XFillGradientItem&)rSet.Get(XATTR_FILLGRADIENT)).GetGradientValue();
1298cdf0e10cSrcweir 	else
1299cdf0e10cSrcweir 		aOldGradTransGradient.aGradient = ((XFillFloatTransparenceItem&)rSet.Get(XATTR_FILLFLOATTRANSPARENCE)).GetGradientValue();
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir 	// transform vector data to gradient
1302cdf0e10cSrcweir 	aGradTransformer.VecToGrad(aGradTransVector, aGradTransGradient, aOldGradTransGradient, _pObj, bMoveSingleHandle, bMoveFirstHandle);
1303cdf0e10cSrcweir 
1304cdf0e10cSrcweir 	if(bSetItemOnObject)
1305cdf0e10cSrcweir 	{
1306cdf0e10cSrcweir 		SdrModel* pModel = _pObj->GetModel();
1307cdf0e10cSrcweir 		SfxItemSet aNewSet(pModel->GetItemPool());
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir 		if(IsGradient())
1310cdf0e10cSrcweir 		{
1311cdf0e10cSrcweir 			aString = String();
1312cdf0e10cSrcweir 			XFillGradientItem aNewGradItem(aString, aGradTransGradient.aGradient);
1313cdf0e10cSrcweir 			aNewSet.Put(aNewGradItem);
1314cdf0e10cSrcweir 		}
1315cdf0e10cSrcweir 		else
1316cdf0e10cSrcweir 		{
1317cdf0e10cSrcweir 			aString = String();
1318cdf0e10cSrcweir 			XFillFloatTransparenceItem aNewTransItem(aString, aGradTransGradient.aGradient);
1319cdf0e10cSrcweir 			aNewSet.Put(aNewTransItem);
1320cdf0e10cSrcweir 		}
1321cdf0e10cSrcweir 
1322cdf0e10cSrcweir 		if(bUndo && pModel->IsUndoEnabled())
1323cdf0e10cSrcweir 		{
1324cdf0e10cSrcweir 			pModel->BegUndo(SVX_RESSTR(IsGradient() ? SIP_XA_FILLGRADIENT : SIP_XA_FILLTRANSPARENCE));
1325cdf0e10cSrcweir 			pModel->AddUndo(pModel->GetSdrUndoFactory().CreateUndoAttrObject(*_pObj));
1326cdf0e10cSrcweir 			pModel->EndUndo();
1327cdf0e10cSrcweir 		}
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir 		pObj->SetMergedItemSetAndBroadcast(aNewSet);
1330cdf0e10cSrcweir 	}
1331cdf0e10cSrcweir 
1332cdf0e10cSrcweir 	// back transformation, set values on pIAOHandle
1333cdf0e10cSrcweir 	aGradTransformer.GradToVec(aGradTransGradient, aGradTransVector, _pObj);
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir 	SetPos(Point(FRound(aGradTransVector.maPositionA.getX()), FRound(aGradTransVector.maPositionA.getY())));
1336cdf0e10cSrcweir 	Set2ndPos(Point(FRound(aGradTransVector.maPositionB.getX()), FRound(aGradTransVector.maPositionB.getY())));
1337cdf0e10cSrcweir 	if(pColHdl1)
1338cdf0e10cSrcweir 	{
1339cdf0e10cSrcweir 		pColHdl1->SetPos(Point(FRound(aGradTransVector.maPositionA.getX()), FRound(aGradTransVector.maPositionA.getY())));
1340cdf0e10cSrcweir 		pColHdl1->SetColor(aGradTransVector.aCol1);
1341cdf0e10cSrcweir 	}
1342cdf0e10cSrcweir 	if(pColHdl2)
1343cdf0e10cSrcweir 	{
1344cdf0e10cSrcweir 		pColHdl2->SetPos(Point(FRound(aGradTransVector.maPositionB.getX()), FRound(aGradTransVector.maPositionB.getY())));
1345cdf0e10cSrcweir 		pColHdl2->SetColor(aGradTransVector.aCol2);
1346cdf0e10cSrcweir 	}
1347cdf0e10cSrcweir }
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1350cdf0e10cSrcweir 
~SdrHdlLine()1351cdf0e10cSrcweir SdrHdlLine::~SdrHdlLine() {}
1352cdf0e10cSrcweir 
CreateB2dIAObject()1353cdf0e10cSrcweir void SdrHdlLine::CreateB2dIAObject()
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir 	// first throw away old one
1356cdf0e10cSrcweir 	GetRidOfIAObject();
1357cdf0e10cSrcweir 
1358cdf0e10cSrcweir 	if(pHdlList)
1359cdf0e10cSrcweir 	{
1360cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
1361cdf0e10cSrcweir 
1362cdf0e10cSrcweir 		if(pView && !pView->areMarkHandlesHidden() && pHdl1 && pHdl2)
1363cdf0e10cSrcweir 		{
1364cdf0e10cSrcweir 			SdrPageView* pPageView = pView->GetSdrPageView();
1365cdf0e10cSrcweir 
1366cdf0e10cSrcweir 			if(pPageView)
1367cdf0e10cSrcweir 			{
1368cdf0e10cSrcweir 				for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1369cdf0e10cSrcweir 				{
1370cdf0e10cSrcweir 					const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1371cdf0e10cSrcweir 
1372cdf0e10cSrcweir 					if(rPageWindow.GetPaintWindow().OutputToWindow())
1373cdf0e10cSrcweir 					{
1374cdf0e10cSrcweir 						if(rPageWindow.GetOverlayManager())
1375cdf0e10cSrcweir 						{
1376cdf0e10cSrcweir 							basegfx::B2DPoint aPosition1(pHdl1->GetPos().X(), pHdl1->GetPos().Y());
1377cdf0e10cSrcweir 							basegfx::B2DPoint aPosition2(pHdl2->GetPos().X(), pHdl2->GetPos().Y());
1378cdf0e10cSrcweir 
1379cdf0e10cSrcweir 							::sdr::overlay::OverlayObject* pNewOverlayObject = new
1380cdf0e10cSrcweir 								::sdr::overlay::OverlayLineStriped(
1381cdf0e10cSrcweir 									aPosition1,
1382cdf0e10cSrcweir 									aPosition2
1383cdf0e10cSrcweir 								);
1384cdf0e10cSrcweir 							DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
1385cdf0e10cSrcweir 
1386cdf0e10cSrcweir 							// OVERLAYMANAGER
1387cdf0e10cSrcweir 							if(pNewOverlayObject)
1388cdf0e10cSrcweir 							{
1389cdf0e10cSrcweir 								// color(?)
1390cdf0e10cSrcweir 								pNewOverlayObject->setBaseColor(Color(COL_LIGHTRED));
1391cdf0e10cSrcweir 
1392cdf0e10cSrcweir 								rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1393cdf0e10cSrcweir 								maOverlayGroup.append(*pNewOverlayObject);
1394cdf0e10cSrcweir 							}
1395cdf0e10cSrcweir 						}
1396cdf0e10cSrcweir 					}
1397cdf0e10cSrcweir 				}
1398cdf0e10cSrcweir 			}
1399cdf0e10cSrcweir 		}
1400cdf0e10cSrcweir 	}
1401cdf0e10cSrcweir }
1402cdf0e10cSrcweir 
GetPointer() const1403cdf0e10cSrcweir Pointer SdrHdlLine::GetPointer() const
1404cdf0e10cSrcweir {
1405cdf0e10cSrcweir 	return Pointer(POINTER_REFHAND);
1406cdf0e10cSrcweir }
1407cdf0e10cSrcweir 
1408cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1409cdf0e10cSrcweir 
~SdrHdlBezWgt()1410cdf0e10cSrcweir SdrHdlBezWgt::~SdrHdlBezWgt() {}
1411cdf0e10cSrcweir 
CreateB2dIAObject()1412cdf0e10cSrcweir void SdrHdlBezWgt::CreateB2dIAObject()
1413cdf0e10cSrcweir {
1414cdf0e10cSrcweir 	// call parent
1415cdf0e10cSrcweir 	SdrHdl::CreateB2dIAObject();
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir 	// create lines
1418cdf0e10cSrcweir 	if(pHdlList)
1419cdf0e10cSrcweir 	{
1420cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
1421cdf0e10cSrcweir 
1422cdf0e10cSrcweir 		if(pView && !pView->areMarkHandlesHidden())
1423cdf0e10cSrcweir 		{
1424cdf0e10cSrcweir 			SdrPageView* pPageView = pView->GetSdrPageView();
1425cdf0e10cSrcweir 
1426cdf0e10cSrcweir 			if(pPageView)
1427cdf0e10cSrcweir 			{
1428cdf0e10cSrcweir 				for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1429cdf0e10cSrcweir 				{
1430cdf0e10cSrcweir 					const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1431cdf0e10cSrcweir 
1432cdf0e10cSrcweir 					if(rPageWindow.GetPaintWindow().OutputToWindow())
1433cdf0e10cSrcweir 					{
1434cdf0e10cSrcweir 						if(rPageWindow.GetOverlayManager())
1435cdf0e10cSrcweir 						{
1436cdf0e10cSrcweir 							basegfx::B2DPoint aPosition1(pHdl1->GetPos().X(), pHdl1->GetPos().Y());
1437cdf0e10cSrcweir 							basegfx::B2DPoint aPosition2(aPos.X(), aPos.Y());
1438cdf0e10cSrcweir 
1439cdf0e10cSrcweir 							if(!aPosition1.equal(aPosition2))
1440cdf0e10cSrcweir 							{
1441cdf0e10cSrcweir 								::sdr::overlay::OverlayObject* pNewOverlayObject = new
1442cdf0e10cSrcweir 									::sdr::overlay::OverlayLineStriped(
1443cdf0e10cSrcweir 										aPosition1,
1444cdf0e10cSrcweir 										aPosition2
1445cdf0e10cSrcweir 									);
1446cdf0e10cSrcweir 								DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
1447cdf0e10cSrcweir 
1448cdf0e10cSrcweir 								// OVERLAYMANAGER
1449cdf0e10cSrcweir 								if(pNewOverlayObject)
1450cdf0e10cSrcweir 								{
1451cdf0e10cSrcweir 									// line part is not hittable
1452cdf0e10cSrcweir 									pNewOverlayObject->setHittable(sal_False);
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir 									// color(?)
1455cdf0e10cSrcweir 									pNewOverlayObject->setBaseColor(Color(COL_LIGHTBLUE));
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir 									rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1458cdf0e10cSrcweir 									maOverlayGroup.append(*pNewOverlayObject);
1459cdf0e10cSrcweir 								}
1460cdf0e10cSrcweir 							}
1461cdf0e10cSrcweir 						}
1462cdf0e10cSrcweir 					}
1463cdf0e10cSrcweir 				}
1464cdf0e10cSrcweir 			}
1465cdf0e10cSrcweir 		}
1466cdf0e10cSrcweir 	}
1467cdf0e10cSrcweir }
1468cdf0e10cSrcweir 
1469cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1470cdf0e10cSrcweir 
E3dVolumeMarker(const basegfx::B2DPolyPolygon & rWireframePoly)1471cdf0e10cSrcweir E3dVolumeMarker::E3dVolumeMarker(const basegfx::B2DPolyPolygon& rWireframePoly)
1472cdf0e10cSrcweir {
1473cdf0e10cSrcweir 	aWireframePoly = rWireframePoly;
1474cdf0e10cSrcweir }
1475cdf0e10cSrcweir 
CreateB2dIAObject()1476cdf0e10cSrcweir void E3dVolumeMarker::CreateB2dIAObject()
1477cdf0e10cSrcweir {
1478cdf0e10cSrcweir 	// create lines
1479cdf0e10cSrcweir 	if(pHdlList)
1480cdf0e10cSrcweir 	{
1481cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir 		if(pView && !pView->areMarkHandlesHidden())
1484cdf0e10cSrcweir 		{
1485cdf0e10cSrcweir 			SdrPageView* pPageView = pView->GetSdrPageView();
1486cdf0e10cSrcweir 
1487cdf0e10cSrcweir 			if(pPageView)
1488cdf0e10cSrcweir 			{
1489cdf0e10cSrcweir 				for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1490cdf0e10cSrcweir 				{
1491cdf0e10cSrcweir 					const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir 					if(rPageWindow.GetPaintWindow().OutputToWindow())
1494cdf0e10cSrcweir 					{
1495cdf0e10cSrcweir 						if(rPageWindow.GetOverlayManager() && aWireframePoly.count())
1496cdf0e10cSrcweir 							{
1497cdf0e10cSrcweir 								::sdr::overlay::OverlayObject* pNewOverlayObject = new
14981cd65da9SArmin Le Grand 								::sdr::overlay::OverlayPolyPolygonStripedAndFilled(
14991cd65da9SArmin Le Grand 									aWireframePoly);
1500cdf0e10cSrcweir 								DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
1501cdf0e10cSrcweir 
1502cdf0e10cSrcweir 								// OVERLAYMANAGER
1503cdf0e10cSrcweir 								if(pNewOverlayObject)
1504cdf0e10cSrcweir 								{
1505cdf0e10cSrcweir 									pNewOverlayObject->setBaseColor(Color(COL_BLACK));
1506cdf0e10cSrcweir 
1507cdf0e10cSrcweir 									rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1508cdf0e10cSrcweir 									maOverlayGroup.append(*pNewOverlayObject);
1509cdf0e10cSrcweir 								}
1510cdf0e10cSrcweir 							}
1511cdf0e10cSrcweir 						}
1512cdf0e10cSrcweir 					}
1513cdf0e10cSrcweir 				}
1514cdf0e10cSrcweir 			}
1515cdf0e10cSrcweir 		}
1516cdf0e10cSrcweir 	}
1517cdf0e10cSrcweir 
1518cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1519cdf0e10cSrcweir 
~ImpEdgeHdl()1520cdf0e10cSrcweir ImpEdgeHdl::~ImpEdgeHdl()
1521cdf0e10cSrcweir {
1522cdf0e10cSrcweir }
1523cdf0e10cSrcweir 
CreateB2dIAObject()1524cdf0e10cSrcweir void ImpEdgeHdl::CreateB2dIAObject()
1525cdf0e10cSrcweir {
1526cdf0e10cSrcweir 	if(nObjHdlNum <= 1 && pObj)
1527cdf0e10cSrcweir 	{
1528cdf0e10cSrcweir 		// first throw away old one
1529cdf0e10cSrcweir 		GetRidOfIAObject();
1530cdf0e10cSrcweir 
1531cdf0e10cSrcweir 		BitmapColorIndex eColIndex = LightCyan;
1532cdf0e10cSrcweir 		BitmapMarkerKind eKindOfMarker = Rect_7x7;
1533cdf0e10cSrcweir 
1534cdf0e10cSrcweir 		if(pHdlList)
1535cdf0e10cSrcweir 		{
1536cdf0e10cSrcweir 			SdrMarkView* pView = pHdlList->GetView();
1537cdf0e10cSrcweir 
1538cdf0e10cSrcweir 			if(pView && !pView->areMarkHandlesHidden())
1539cdf0e10cSrcweir 			{
1540cdf0e10cSrcweir 				const SdrEdgeObj* pEdge = (SdrEdgeObj*)pObj;
1541cdf0e10cSrcweir 
1542cdf0e10cSrcweir 				if(pEdge->GetConnectedNode(nObjHdlNum == 0) != NULL)
1543cdf0e10cSrcweir 					eColIndex = LightRed;
1544cdf0e10cSrcweir 
1545cdf0e10cSrcweir 				if(nPPntNum < 2)
1546cdf0e10cSrcweir 				{
1547cdf0e10cSrcweir 					// Handle with plus sign inside
1548cdf0e10cSrcweir 					eKindOfMarker = Circ_7x7;
1549cdf0e10cSrcweir 				}
1550cdf0e10cSrcweir 
1551cdf0e10cSrcweir 				SdrPageView* pPageView = pView->GetSdrPageView();
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir 				if(pPageView)
1554cdf0e10cSrcweir 				{
1555cdf0e10cSrcweir 					for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++)
1556cdf0e10cSrcweir 					{
1557cdf0e10cSrcweir 						const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1558cdf0e10cSrcweir 
1559cdf0e10cSrcweir 						if(rPageWindow.GetPaintWindow().OutputToWindow())
1560cdf0e10cSrcweir 						{
1561cdf0e10cSrcweir 							if(rPageWindow.GetOverlayManager())
1562cdf0e10cSrcweir 							{
1563cdf0e10cSrcweir 								basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
1564cdf0e10cSrcweir 
1565cdf0e10cSrcweir 								::sdr::overlay::OverlayObject* pNewOverlayObject = CreateOverlayObject(
1566cdf0e10cSrcweir 									aPosition,
1567cdf0e10cSrcweir 									eColIndex,
1568cdf0e10cSrcweir 									eKindOfMarker);
1569cdf0e10cSrcweir 
1570cdf0e10cSrcweir 								// OVERLAYMANAGER
1571cdf0e10cSrcweir 								if(pNewOverlayObject)
1572cdf0e10cSrcweir 								{
1573cdf0e10cSrcweir 									rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1574cdf0e10cSrcweir 									maOverlayGroup.append(*pNewOverlayObject);
1575cdf0e10cSrcweir 								}
1576cdf0e10cSrcweir 							}
1577cdf0e10cSrcweir 						}
1578cdf0e10cSrcweir 					}
1579cdf0e10cSrcweir 				}
1580cdf0e10cSrcweir 			}
1581cdf0e10cSrcweir 		}
1582cdf0e10cSrcweir 	}
1583cdf0e10cSrcweir 	else
1584cdf0e10cSrcweir 	{
1585cdf0e10cSrcweir 		// call parent
1586cdf0e10cSrcweir 		SdrHdl::CreateB2dIAObject();
1587cdf0e10cSrcweir 	}
1588cdf0e10cSrcweir }
1589cdf0e10cSrcweir 
SetLineCode(SdrEdgeLineCode eCode)1590cdf0e10cSrcweir void ImpEdgeHdl::SetLineCode(SdrEdgeLineCode eCode)
1591cdf0e10cSrcweir {
1592cdf0e10cSrcweir 	if(eLineCode != eCode)
1593cdf0e10cSrcweir 	{
1594cdf0e10cSrcweir 		// remember new value
1595cdf0e10cSrcweir 		eLineCode = eCode;
1596cdf0e10cSrcweir 
1597cdf0e10cSrcweir 		// create new display
1598cdf0e10cSrcweir 		Touch();
1599cdf0e10cSrcweir 	}
1600cdf0e10cSrcweir }
1601cdf0e10cSrcweir 
GetPointer() const1602cdf0e10cSrcweir Pointer ImpEdgeHdl::GetPointer() const
1603cdf0e10cSrcweir {
1604cdf0e10cSrcweir 	SdrEdgeObj* pEdge=PTR_CAST(SdrEdgeObj,pObj);
1605cdf0e10cSrcweir 	if (pEdge==NULL)
1606cdf0e10cSrcweir 		return SdrHdl::GetPointer();
1607cdf0e10cSrcweir 	if (nObjHdlNum<=1)
1608cdf0e10cSrcweir 		return Pointer(POINTER_MOVEPOINT); //Pointer(POINTER_DRAW_CONNECT);
1609cdf0e10cSrcweir 	if (IsHorzDrag())
1610cdf0e10cSrcweir 		return Pointer(POINTER_ESIZE);
1611cdf0e10cSrcweir 	else
1612cdf0e10cSrcweir 		return Pointer(POINTER_SSIZE);
1613cdf0e10cSrcweir }
1614cdf0e10cSrcweir 
IsHorzDrag() const1615cdf0e10cSrcweir sal_Bool ImpEdgeHdl::IsHorzDrag() const
1616cdf0e10cSrcweir {
1617cdf0e10cSrcweir 	SdrEdgeObj* pEdge=PTR_CAST(SdrEdgeObj,pObj);
1618cdf0e10cSrcweir 	if (pEdge==NULL)
1619cdf0e10cSrcweir 		return sal_False;
1620cdf0e10cSrcweir 	if (nObjHdlNum<=1)
1621cdf0e10cSrcweir 		return sal_False;
1622cdf0e10cSrcweir 
1623cdf0e10cSrcweir 	SdrEdgeKind eEdgeKind = ((SdrEdgeKindItem&)(pEdge->GetObjectItem(SDRATTR_EDGEKIND))).GetValue();
1624cdf0e10cSrcweir 
1625cdf0e10cSrcweir 	const SdrEdgeInfoRec& rInfo=pEdge->aEdgeInfo;
1626cdf0e10cSrcweir 	if (eEdgeKind==SDREDGE_ORTHOLINES || eEdgeKind==SDREDGE_BEZIER)
1627cdf0e10cSrcweir 	{
1628cdf0e10cSrcweir 		return !rInfo.ImpIsHorzLine(eLineCode,*pEdge->pEdgeTrack);
1629cdf0e10cSrcweir 	}
1630cdf0e10cSrcweir 	else if (eEdgeKind==SDREDGE_THREELINES)
1631cdf0e10cSrcweir 	{
1632cdf0e10cSrcweir 		long nWink=nObjHdlNum==2 ? rInfo.nAngle1 : rInfo.nAngle2;
1633cdf0e10cSrcweir 		if (nWink==0 || nWink==18000)
1634cdf0e10cSrcweir 			return sal_True;
1635cdf0e10cSrcweir 		else
1636cdf0e10cSrcweir 			return sal_False;
1637cdf0e10cSrcweir 	}
1638cdf0e10cSrcweir 	return sal_False;
1639cdf0e10cSrcweir }
1640cdf0e10cSrcweir 
1641cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1642cdf0e10cSrcweir 
~ImpMeasureHdl()1643cdf0e10cSrcweir ImpMeasureHdl::~ImpMeasureHdl()
1644cdf0e10cSrcweir {
1645cdf0e10cSrcweir }
1646cdf0e10cSrcweir 
CreateB2dIAObject()1647cdf0e10cSrcweir void ImpMeasureHdl::CreateB2dIAObject()
1648cdf0e10cSrcweir {
1649cdf0e10cSrcweir 	// first throw away old one
1650cdf0e10cSrcweir 	GetRidOfIAObject();
1651cdf0e10cSrcweir 
1652cdf0e10cSrcweir 	if(pHdlList)
1653cdf0e10cSrcweir 	{
1654cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
1655cdf0e10cSrcweir 
1656cdf0e10cSrcweir 		if(pView && !pView->areMarkHandlesHidden())
1657cdf0e10cSrcweir 		{
1658cdf0e10cSrcweir 			BitmapColorIndex eColIndex = LightCyan;
1659cdf0e10cSrcweir 			BitmapMarkerKind eKindOfMarker = Rect_9x9;
1660cdf0e10cSrcweir 
1661cdf0e10cSrcweir 			if(nObjHdlNum > 1)
1662cdf0e10cSrcweir 			{
1663cdf0e10cSrcweir 				eKindOfMarker = Rect_7x7;
1664cdf0e10cSrcweir 			}
1665cdf0e10cSrcweir 
1666cdf0e10cSrcweir 			if(bSelect)
1667cdf0e10cSrcweir 			{
1668cdf0e10cSrcweir 				eColIndex = Cyan;
1669cdf0e10cSrcweir 			}
1670cdf0e10cSrcweir 
1671cdf0e10cSrcweir 			SdrPageView* pPageView = pView->GetSdrPageView();
1672cdf0e10cSrcweir 
1673cdf0e10cSrcweir 			if(pPageView)
1674cdf0e10cSrcweir 			{
1675cdf0e10cSrcweir 				for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1676cdf0e10cSrcweir 				{
1677cdf0e10cSrcweir 					const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1678cdf0e10cSrcweir 
1679cdf0e10cSrcweir 					if(rPageWindow.GetPaintWindow().OutputToWindow())
1680cdf0e10cSrcweir 					{
1681cdf0e10cSrcweir 						if(rPageWindow.GetOverlayManager())
1682cdf0e10cSrcweir 						{
1683cdf0e10cSrcweir 							basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
1684cdf0e10cSrcweir 
1685cdf0e10cSrcweir 							::sdr::overlay::OverlayObject* pNewOverlayObject = CreateOverlayObject(
1686cdf0e10cSrcweir 								aPosition,
1687cdf0e10cSrcweir 								eColIndex,
1688cdf0e10cSrcweir 								eKindOfMarker);
1689cdf0e10cSrcweir 
1690cdf0e10cSrcweir 							// OVERLAYMANAGER
1691cdf0e10cSrcweir 							if(pNewOverlayObject)
1692cdf0e10cSrcweir 							{
1693cdf0e10cSrcweir 								rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1694cdf0e10cSrcweir 								maOverlayGroup.append(*pNewOverlayObject);
1695cdf0e10cSrcweir 							}
1696cdf0e10cSrcweir 						}
1697cdf0e10cSrcweir 					}
1698cdf0e10cSrcweir 				}
1699cdf0e10cSrcweir 			}
1700cdf0e10cSrcweir 		}
1701cdf0e10cSrcweir 	}
1702cdf0e10cSrcweir }
1703cdf0e10cSrcweir 
GetPointer() const1704cdf0e10cSrcweir Pointer ImpMeasureHdl::GetPointer() const
1705cdf0e10cSrcweir {
1706cdf0e10cSrcweir 	switch (nObjHdlNum)
1707cdf0e10cSrcweir 	{
1708cdf0e10cSrcweir 		case 0: case 1: return Pointer(POINTER_HAND);
1709cdf0e10cSrcweir 		case 2: case 3: return Pointer(POINTER_MOVEPOINT);
1710ef96bc24Smseidel 		case 4: case 5: return SdrHdl::GetPointer(); // will be rotated accordingly
1711cdf0e10cSrcweir 	} // switch
1712cdf0e10cSrcweir 	return Pointer(POINTER_NOTALLOWED);
1713cdf0e10cSrcweir }
1714cdf0e10cSrcweir 
1715cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1716cdf0e10cSrcweir 
ImpTextframeHdl(const Rectangle & rRect)1717cdf0e10cSrcweir ImpTextframeHdl::ImpTextframeHdl(const Rectangle& rRect) :
1718cdf0e10cSrcweir 	SdrHdl(rRect.TopLeft(),HDL_MOVE),
1719cdf0e10cSrcweir 	maRect(rRect)
1720cdf0e10cSrcweir {
1721cdf0e10cSrcweir }
1722cdf0e10cSrcweir 
CreateB2dIAObject()1723cdf0e10cSrcweir void ImpTextframeHdl::CreateB2dIAObject()
1724cdf0e10cSrcweir {
1725cdf0e10cSrcweir 	// first throw away old one
1726cdf0e10cSrcweir 	GetRidOfIAObject();
1727cdf0e10cSrcweir 
1728cdf0e10cSrcweir 	if(pHdlList)
1729cdf0e10cSrcweir 	{
1730cdf0e10cSrcweir 		SdrMarkView* pView = pHdlList->GetView();
1731cdf0e10cSrcweir 
1732cdf0e10cSrcweir 		if(pView && !pView->areMarkHandlesHidden())
1733cdf0e10cSrcweir 		{
1734cdf0e10cSrcweir 			SdrPageView* pPageView = pView->GetSdrPageView();
1735cdf0e10cSrcweir 
1736cdf0e10cSrcweir 			if(pPageView)
1737cdf0e10cSrcweir 			{
1738cdf0e10cSrcweir 				for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
1739cdf0e10cSrcweir 				{
1740cdf0e10cSrcweir 					const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
1741cdf0e10cSrcweir 
1742cdf0e10cSrcweir 					if(rPageWindow.GetPaintWindow().OutputToWindow())
1743cdf0e10cSrcweir 					{
1744cdf0e10cSrcweir 						if(rPageWindow.GetOverlayManager())
1745cdf0e10cSrcweir 						{
1746cdf0e10cSrcweir 							const basegfx::B2DPoint aTopLeft(maRect.Left(), maRect.Top());
1747cdf0e10cSrcweir 							const basegfx::B2DPoint aBottomRight(maRect.Right(), maRect.Bottom());
17481cd65da9SArmin Le Grand 							const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
17491cd65da9SArmin Le Grand 							const Color aHilightColor(aSvtOptionsDrawinglayer.getHilightColor());
17501cd65da9SArmin Le Grand 							const double fTransparence(aSvtOptionsDrawinglayer.GetTransparentSelectionPercent() * 0.01);
1751cdf0e10cSrcweir 
17521cd65da9SArmin Le Grand 							::sdr::overlay::OverlayRectangle* pNewOverlayObject = new ::sdr::overlay::OverlayRectangle(
1753cdf0e10cSrcweir 								aTopLeft,
1754cdf0e10cSrcweir 								aBottomRight,
17551cd65da9SArmin Le Grand 								aHilightColor,
17561cd65da9SArmin Le Grand 								fTransparence,
1757cdf0e10cSrcweir 								3.0,
1758cdf0e10cSrcweir 								3.0,
17591cd65da9SArmin Le Grand 								nDrehWink * -F_PI18000,
17601cd65da9SArmin Le Grand 								500,
17611cd65da9SArmin Le Grand 								true); // allow animation; the Handle is not shown at text edit time
17621cd65da9SArmin Le Grand 
1763cdf0e10cSrcweir 							pNewOverlayObject->setHittable(false);
1764cdf0e10cSrcweir 
1765cdf0e10cSrcweir 							// OVERLAYMANAGER
1766cdf0e10cSrcweir 							if(pNewOverlayObject)
1767cdf0e10cSrcweir 							{
1768cdf0e10cSrcweir 								rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
1769cdf0e10cSrcweir 								maOverlayGroup.append(*pNewOverlayObject);
1770cdf0e10cSrcweir 							}
1771cdf0e10cSrcweir 						}
1772cdf0e10cSrcweir 					}
1773cdf0e10cSrcweir 				}
1774cdf0e10cSrcweir 			}
1775cdf0e10cSrcweir 		}
1776cdf0e10cSrcweir 	}
1777cdf0e10cSrcweir }
1778cdf0e10cSrcweir 
1779cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1780cdf0e10cSrcweir 
1781cdf0e10cSrcweir class ImpSdrHdlListSorter: public ContainerSorter {
1782cdf0e10cSrcweir public:
ImpSdrHdlListSorter(Container & rNewCont)1783cdf0e10cSrcweir 	ImpSdrHdlListSorter(Container& rNewCont): ContainerSorter(rNewCont) {}
1784cdf0e10cSrcweir 	virtual int Compare(const void* pElem1, const void* pElem2) const;
1785cdf0e10cSrcweir };
1786cdf0e10cSrcweir 
Compare(const void * pElem1,const void * pElem2) const1787cdf0e10cSrcweir int ImpSdrHdlListSorter::Compare(const void* pElem1, const void* pElem2) const
1788cdf0e10cSrcweir {
1789cdf0e10cSrcweir 	SdrHdlKind eKind1=((SdrHdl*)pElem1)->GetKind();
1790cdf0e10cSrcweir 	SdrHdlKind eKind2=((SdrHdl*)pElem2)->GetKind();
1791cdf0e10cSrcweir 	// Level 1: Erst normale Handles, dann Glue, dann User, dann Plushandles, dann Retpunkt-Handles
1792cdf0e10cSrcweir 	unsigned n1=1;
1793cdf0e10cSrcweir 	unsigned n2=1;
1794cdf0e10cSrcweir 	if (eKind1!=eKind2)
1795cdf0e10cSrcweir 	{
1796cdf0e10cSrcweir 		if (eKind1==HDL_REF1 || eKind1==HDL_REF2 || eKind1==HDL_MIRX) n1=5;
17972a90d9eaSmseidel 		else if (eKind1==HDL_GLUE || eKind1==HDL_GLUE_UNSEL) n1=2;
1798cdf0e10cSrcweir 		else if (eKind1==HDL_USER) n1=3;
1799cdf0e10cSrcweir 		else if (eKind1==HDL_SMARTTAG) n1=0;
1800cdf0e10cSrcweir 		if (eKind2==HDL_REF1 || eKind2==HDL_REF2 || eKind2==HDL_MIRX) n2=5;
18012a90d9eaSmseidel 		else if (eKind2==HDL_GLUE || eKind1==HDL_GLUE_UNSEL) n2=2;
1802cdf0e10cSrcweir 		else if (eKind2==HDL_USER) n2=3;
1803cdf0e10cSrcweir 		else if (eKind2==HDL_SMARTTAG) n2=0;
1804cdf0e10cSrcweir 	}
1805cdf0e10cSrcweir 	if (((SdrHdl*)pElem1)->IsPlusHdl()) n1=4;
1806cdf0e10cSrcweir 	if (((SdrHdl*)pElem2)->IsPlusHdl()) n2=4;
1807cdf0e10cSrcweir 	if (n1==n2)
1808cdf0e10cSrcweir 	{
1809cdf0e10cSrcweir 		// Level 2: PageView (Pointer)
1810cdf0e10cSrcweir 		SdrPageView* pPV1=((SdrHdl*)pElem1)->GetPageView();
1811cdf0e10cSrcweir 		SdrPageView* pPV2=((SdrHdl*)pElem2)->GetPageView();
1812cdf0e10cSrcweir 		if (pPV1==pPV2)
1813cdf0e10cSrcweir 		{
1814cdf0e10cSrcweir 			// Level 3: Position (x+y)
1815cdf0e10cSrcweir 			SdrObject* pObj1=((SdrHdl*)pElem1)->GetObj();
1816cdf0e10cSrcweir 			SdrObject* pObj2=((SdrHdl*)pElem2)->GetObj();
1817cdf0e10cSrcweir 			if (pObj1==pObj2)
1818cdf0e10cSrcweir 			{
1819cdf0e10cSrcweir 				sal_uInt32 nNum1=((SdrHdl*)pElem1)->GetObjHdlNum();
1820cdf0e10cSrcweir 				sal_uInt32 nNum2=((SdrHdl*)pElem2)->GetObjHdlNum();
1821cdf0e10cSrcweir 				if (nNum1==nNum2)
1822cdf0e10cSrcweir 				{ // #48763#
1823cdf0e10cSrcweir 					if (eKind1==eKind2)
1824cdf0e10cSrcweir 						return (long)pElem1<(long)pElem2 ? -1 : 1; // Notloesung, um immer die gleiche Sortierung zu haben
1825cdf0e10cSrcweir 					return (sal_uInt16)eKind1<(sal_uInt16)eKind2 ? -1 : 1;
1826cdf0e10cSrcweir 				}
1827cdf0e10cSrcweir 				else
1828cdf0e10cSrcweir 					return nNum1<nNum2 ? -1 : 1;
1829cdf0e10cSrcweir 			}
1830cdf0e10cSrcweir 			else
1831cdf0e10cSrcweir 			{
1832cdf0e10cSrcweir 				return (long)pObj1<(long)pObj2 ? -1 : 1;
1833cdf0e10cSrcweir 			}
1834cdf0e10cSrcweir 		}
1835cdf0e10cSrcweir 		else
1836cdf0e10cSrcweir 		{
1837cdf0e10cSrcweir 			return (long)pPV1<(long)pPV2 ? -1 : 1;
1838cdf0e10cSrcweir 		}
1839cdf0e10cSrcweir 	}
1840cdf0e10cSrcweir 	else
1841cdf0e10cSrcweir 	{
1842cdf0e10cSrcweir 		return n1<n2 ? -1 : 1;
1843cdf0e10cSrcweir 	}
1844cdf0e10cSrcweir }
1845cdf0e10cSrcweir 
GetView() const1846cdf0e10cSrcweir SdrMarkView* SdrHdlList::GetView() const
1847cdf0e10cSrcweir {
1848cdf0e10cSrcweir 	return pView;
1849cdf0e10cSrcweir }
1850cdf0e10cSrcweir 
1851cdf0e10cSrcweir // #105678# Help struct for re-sorting handles
1852cdf0e10cSrcweir struct ImplHdlAndIndex
1853cdf0e10cSrcweir {
1854cdf0e10cSrcweir 	SdrHdl*						mpHdl;
1855cdf0e10cSrcweir 	sal_uInt32					mnIndex;
1856cdf0e10cSrcweir };
1857cdf0e10cSrcweir 
1858cdf0e10cSrcweir // #105678# Help method for sorting handles taking care of OrdNums, keeping order in
1859cdf0e10cSrcweir // single objects and re-sorting polygon handles intuitively
ImplSortHdlFunc(const void * pVoid1,const void * pVoid2)1860cdf0e10cSrcweir extern "C" int __LOADONCALLAPI ImplSortHdlFunc( const void* pVoid1, const void* pVoid2 )
1861cdf0e10cSrcweir {
1862cdf0e10cSrcweir 	const ImplHdlAndIndex* p1 = (ImplHdlAndIndex*)pVoid1;
1863cdf0e10cSrcweir 	const ImplHdlAndIndex* p2 = (ImplHdlAndIndex*)pVoid2;
1864cdf0e10cSrcweir 
1865cdf0e10cSrcweir 	if(p1->mpHdl->GetObj() == p2->mpHdl->GetObj())
1866cdf0e10cSrcweir 	{
1867cdf0e10cSrcweir 		if(p1->mpHdl->GetObj() && p1->mpHdl->GetObj()->ISA(SdrPathObj))
1868cdf0e10cSrcweir 		{
1869cdf0e10cSrcweir 			// same object and a path object
1870cdf0e10cSrcweir 			if((p1->mpHdl->GetKind() == HDL_POLY || p1->mpHdl->GetKind() == HDL_BWGT)
1871cdf0e10cSrcweir 				&& (p2->mpHdl->GetKind() == HDL_POLY || p2->mpHdl->GetKind() == HDL_BWGT))
1872cdf0e10cSrcweir 			{
1873cdf0e10cSrcweir 				// both handles are point or control handles
1874cdf0e10cSrcweir 				if(p1->mpHdl->GetPolyNum() == p2->mpHdl->GetPolyNum())
1875cdf0e10cSrcweir 				{
1876cdf0e10cSrcweir 					if(p1->mpHdl->GetPointNum() < p2->mpHdl->GetPointNum())
1877cdf0e10cSrcweir 					{
1878cdf0e10cSrcweir 						return -1;
1879cdf0e10cSrcweir 					}
1880cdf0e10cSrcweir 					else
1881cdf0e10cSrcweir 					{
1882cdf0e10cSrcweir 						return 1;
1883cdf0e10cSrcweir 					}
1884cdf0e10cSrcweir 				}
1885cdf0e10cSrcweir 				else if(p1->mpHdl->GetPolyNum() < p2->mpHdl->GetPolyNum())
1886cdf0e10cSrcweir 				{
1887cdf0e10cSrcweir 					return -1;
1888cdf0e10cSrcweir 				}
1889cdf0e10cSrcweir 				else
1890cdf0e10cSrcweir 				{
1891cdf0e10cSrcweir 					return 1;
1892cdf0e10cSrcweir 				}
1893cdf0e10cSrcweir 			}
1894cdf0e10cSrcweir 		}
1895cdf0e10cSrcweir 	}
1896cdf0e10cSrcweir 	else
1897cdf0e10cSrcweir 	{
1898cdf0e10cSrcweir 		if(!p1->mpHdl->GetObj())
1899cdf0e10cSrcweir 		{
1900cdf0e10cSrcweir 			return -1;
1901cdf0e10cSrcweir 		}
1902cdf0e10cSrcweir 		else if(!p2->mpHdl->GetObj())
1903cdf0e10cSrcweir 		{
1904cdf0e10cSrcweir 			return 1;
1905cdf0e10cSrcweir 		}
1906cdf0e10cSrcweir 		else
1907cdf0e10cSrcweir 		{
1908cdf0e10cSrcweir 			// different objects, use OrdNum for sort
1909cdf0e10cSrcweir 			const sal_uInt32 nOrdNum1 = p1->mpHdl->GetObj()->GetOrdNum();
1910cdf0e10cSrcweir 			const sal_uInt32 nOrdNum2 = p2->mpHdl->GetObj()->GetOrdNum();
1911cdf0e10cSrcweir 
1912cdf0e10cSrcweir 			if(nOrdNum1 < nOrdNum2)
1913cdf0e10cSrcweir 			{
1914cdf0e10cSrcweir 				return -1;
1915cdf0e10cSrcweir 			}
1916cdf0e10cSrcweir 			else
1917cdf0e10cSrcweir 			{
1918cdf0e10cSrcweir 				return 1;
1919cdf0e10cSrcweir 			}
1920cdf0e10cSrcweir 		}
1921cdf0e10cSrcweir 	}
1922cdf0e10cSrcweir 
1923cdf0e10cSrcweir 	// fallback to indices
1924cdf0e10cSrcweir 	if(p1->mnIndex < p2->mnIndex)
1925cdf0e10cSrcweir 	{
1926cdf0e10cSrcweir 		return -1;
1927cdf0e10cSrcweir 	}
1928cdf0e10cSrcweir 	else
1929cdf0e10cSrcweir 	{
1930cdf0e10cSrcweir 		return 1;
1931cdf0e10cSrcweir 	}
1932cdf0e10cSrcweir }
1933cdf0e10cSrcweir 
1934cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
1935cdf0e10cSrcweir // #97016# II
1936cdf0e10cSrcweir 
TravelFocusHdl(sal_Bool bForward)1937cdf0e10cSrcweir void SdrHdlList::TravelFocusHdl(sal_Bool bForward)
1938cdf0e10cSrcweir {
1939cdf0e10cSrcweir 	// security correction
1940cdf0e10cSrcweir 	if(mnFocusIndex != CONTAINER_ENTRY_NOTFOUND && mnFocusIndex >= GetHdlCount())
1941cdf0e10cSrcweir 		mnFocusIndex = CONTAINER_ENTRY_NOTFOUND;
1942cdf0e10cSrcweir 
1943cdf0e10cSrcweir 	if(aList.Count())
1944cdf0e10cSrcweir 	{
1945cdf0e10cSrcweir 		// take care of old handle
1946cdf0e10cSrcweir 		const sal_uIntPtr nOldHdlNum(mnFocusIndex);
1947cdf0e10cSrcweir 		SdrHdl* pOld = GetHdl(nOldHdlNum);
1948cdf0e10cSrcweir 		//SDOsal_Bool bRefresh(sal_False);
1949cdf0e10cSrcweir 
1950cdf0e10cSrcweir 		if(pOld)
1951cdf0e10cSrcweir 		{
1952cdf0e10cSrcweir 			// switch off old handle
1953cdf0e10cSrcweir 			mnFocusIndex = CONTAINER_ENTRY_NOTFOUND;
1954cdf0e10cSrcweir 			pOld->Touch();
1955cdf0e10cSrcweir 			//SDObRefresh = sal_True;
1956cdf0e10cSrcweir 		}
1957cdf0e10cSrcweir 
1958cdf0e10cSrcweir 		// #105678# Alloc pointer array for sorted handle list
1959cdf0e10cSrcweir 		ImplHdlAndIndex* pHdlAndIndex = new ImplHdlAndIndex[aList.Count()];
1960cdf0e10cSrcweir 
1961cdf0e10cSrcweir 		// #105678# build sorted handle list
1962cdf0e10cSrcweir 		sal_uInt32 a;
1963cdf0e10cSrcweir 		for( a = 0; a < aList.Count(); a++)
1964cdf0e10cSrcweir 		{
1965cdf0e10cSrcweir 			pHdlAndIndex[a].mpHdl = (SdrHdl*)aList.GetObject(a);
1966cdf0e10cSrcweir 			pHdlAndIndex[a].mnIndex = a;
1967cdf0e10cSrcweir 		}
1968cdf0e10cSrcweir 
1969cdf0e10cSrcweir 		// #105678# qsort all entries
1970cdf0e10cSrcweir 		qsort(pHdlAndIndex, aList.Count(), sizeof(ImplHdlAndIndex), ImplSortHdlFunc);
1971cdf0e10cSrcweir 
1972cdf0e10cSrcweir 		// #105678# look for old num in sorted array
1973cdf0e10cSrcweir 		sal_uIntPtr nOldHdl(nOldHdlNum);
1974cdf0e10cSrcweir 
1975cdf0e10cSrcweir 		if(nOldHdlNum != CONTAINER_ENTRY_NOTFOUND)
1976cdf0e10cSrcweir 		{
1977cdf0e10cSrcweir 			for(a = 0; a < aList.Count(); a++)
1978cdf0e10cSrcweir 			{
1979cdf0e10cSrcweir 				if(pHdlAndIndex[a].mpHdl == pOld)
1980cdf0e10cSrcweir 				{
1981cdf0e10cSrcweir 					nOldHdl = a;
1982cdf0e10cSrcweir 					break;
1983cdf0e10cSrcweir 				}
1984cdf0e10cSrcweir 			}
1985cdf0e10cSrcweir 		}
1986cdf0e10cSrcweir 
1987cdf0e10cSrcweir 		// #105678# build new HdlNum
1988cdf0e10cSrcweir 		sal_uIntPtr nNewHdl(nOldHdl);
1989cdf0e10cSrcweir 
1990cdf0e10cSrcweir 		// #105678# do the focus travel
1991cdf0e10cSrcweir 		if(bForward)
1992cdf0e10cSrcweir 		{
1993cdf0e10cSrcweir 			if(nOldHdl != CONTAINER_ENTRY_NOTFOUND)
1994cdf0e10cSrcweir 			{
1995cdf0e10cSrcweir 				if(nOldHdl == aList.Count() - 1)
1996cdf0e10cSrcweir 				{
1997cdf0e10cSrcweir 					// end forward run
1998cdf0e10cSrcweir 					nNewHdl = CONTAINER_ENTRY_NOTFOUND;
1999cdf0e10cSrcweir 				}
2000cdf0e10cSrcweir 				else
2001cdf0e10cSrcweir 				{
2002cdf0e10cSrcweir 					// simply the next handle
2003cdf0e10cSrcweir 					nNewHdl++;
2004cdf0e10cSrcweir 				}
2005cdf0e10cSrcweir 			}
2006cdf0e10cSrcweir 			else
2007cdf0e10cSrcweir 			{
2008cdf0e10cSrcweir 				// start forward run at first entry
2009cdf0e10cSrcweir 				nNewHdl = 0;
2010cdf0e10cSrcweir 			}
2011cdf0e10cSrcweir 		}
2012cdf0e10cSrcweir 		else
2013cdf0e10cSrcweir 		{
2014cdf0e10cSrcweir 			if(nOldHdl == CONTAINER_ENTRY_NOTFOUND)
2015cdf0e10cSrcweir 			{
2016cdf0e10cSrcweir 				// start backward run at last entry
2017cdf0e10cSrcweir 				nNewHdl = aList.Count() - 1;
2018cdf0e10cSrcweir 
2019cdf0e10cSrcweir 			}
2020cdf0e10cSrcweir 			else
2021cdf0e10cSrcweir 			{
2022cdf0e10cSrcweir 				if(nOldHdl == 0)
2023cdf0e10cSrcweir 				{
2024cdf0e10cSrcweir 					// end backward run
2025cdf0e10cSrcweir 					nNewHdl = CONTAINER_ENTRY_NOTFOUND;
2026cdf0e10cSrcweir 				}
2027cdf0e10cSrcweir 				else
2028cdf0e10cSrcweir 				{
2029cdf0e10cSrcweir 					// simply the previous handle
2030cdf0e10cSrcweir 					nNewHdl--;
2031cdf0e10cSrcweir 				}
2032cdf0e10cSrcweir 			}
2033cdf0e10cSrcweir 		}
2034cdf0e10cSrcweir 
2035cdf0e10cSrcweir 		// #105678# build new HdlNum
2036cdf0e10cSrcweir 		sal_uInt32 nNewHdlNum(nNewHdl);
2037cdf0e10cSrcweir 
2038cdf0e10cSrcweir 		// look for old num in sorted array
2039cdf0e10cSrcweir 		if(nNewHdl != CONTAINER_ENTRY_NOTFOUND)
2040cdf0e10cSrcweir 		{
2041cdf0e10cSrcweir 			SdrHdl* pNew = pHdlAndIndex[nNewHdl].mpHdl;
2042cdf0e10cSrcweir 
2043cdf0e10cSrcweir 			for(a = 0; a < aList.Count(); a++)
2044cdf0e10cSrcweir 			{
2045cdf0e10cSrcweir 				if((SdrHdl*)aList.GetObject(a) == pNew)
2046cdf0e10cSrcweir 				{
2047cdf0e10cSrcweir 					nNewHdlNum = a;
2048cdf0e10cSrcweir 					break;
2049cdf0e10cSrcweir 				}
2050cdf0e10cSrcweir 			}
2051cdf0e10cSrcweir 		}
2052cdf0e10cSrcweir 
2053cdf0e10cSrcweir 		// take care of next handle
2054cdf0e10cSrcweir 		if(nOldHdlNum != nNewHdlNum)
2055cdf0e10cSrcweir 		{
2056cdf0e10cSrcweir 			mnFocusIndex = nNewHdlNum;
2057cdf0e10cSrcweir 			SdrHdl* pNew = GetHdl(mnFocusIndex);
2058cdf0e10cSrcweir 
2059cdf0e10cSrcweir 			if(pNew)
2060cdf0e10cSrcweir 			{
2061cdf0e10cSrcweir 				pNew->Touch();
2062cdf0e10cSrcweir 				//SDObRefresh = sal_True;
2063cdf0e10cSrcweir 			}
2064cdf0e10cSrcweir 		}
2065cdf0e10cSrcweir 
2066cdf0e10cSrcweir 		// #105678# free mem again
2067cdf0e10cSrcweir 		delete [] pHdlAndIndex;
2068cdf0e10cSrcweir 	}
2069cdf0e10cSrcweir }
2070cdf0e10cSrcweir 
GetFocusHdl() const2071cdf0e10cSrcweir SdrHdl* SdrHdlList::GetFocusHdl() const
2072cdf0e10cSrcweir {
2073cdf0e10cSrcweir 	if(mnFocusIndex != CONTAINER_ENTRY_NOTFOUND && mnFocusIndex < GetHdlCount())
2074cdf0e10cSrcweir 		return GetHdl(mnFocusIndex);
2075cdf0e10cSrcweir 	else
2076cdf0e10cSrcweir 		return 0L;
2077cdf0e10cSrcweir }
2078cdf0e10cSrcweir 
SetFocusHdl(SdrHdl * pNew)2079cdf0e10cSrcweir void SdrHdlList::SetFocusHdl(SdrHdl* pNew)
2080cdf0e10cSrcweir {
2081cdf0e10cSrcweir 	if(pNew)
2082cdf0e10cSrcweir 	{
2083cdf0e10cSrcweir 		SdrHdl* pActual = GetFocusHdl();
2084cdf0e10cSrcweir 
2085cdf0e10cSrcweir 		if(!pActual || pActual != pNew)
2086cdf0e10cSrcweir 		{
2087cdf0e10cSrcweir 			sal_uIntPtr nNewHdlNum = GetHdlNum(pNew);
2088cdf0e10cSrcweir 
2089cdf0e10cSrcweir 			if(nNewHdlNum != CONTAINER_ENTRY_NOTFOUND)
2090cdf0e10cSrcweir 			{
2091cdf0e10cSrcweir 				//SDOsal_Bool bRefresh(sal_False);
2092cdf0e10cSrcweir 				mnFocusIndex = nNewHdlNum;
2093cdf0e10cSrcweir 
2094cdf0e10cSrcweir 				if(pActual)
2095cdf0e10cSrcweir 				{
2096cdf0e10cSrcweir 					pActual->Touch();
2097cdf0e10cSrcweir 					//SDObRefresh = sal_True;
2098cdf0e10cSrcweir 				}
2099cdf0e10cSrcweir 
2100cdf0e10cSrcweir 				if(pNew)
2101cdf0e10cSrcweir 				{
2102cdf0e10cSrcweir 					pNew->Touch();
2103cdf0e10cSrcweir 					//SDObRefresh = sal_True;
2104cdf0e10cSrcweir 				}
2105cdf0e10cSrcweir 
2106cdf0e10cSrcweir 				//OLMif(bRefresh)
2107cdf0e10cSrcweir 				//OLM{
2108cdf0e10cSrcweir 				//OLM	if(pView)
2109cdf0e10cSrcweir 				//OLM		pView->RefreshAllIAOManagers();
2110cdf0e10cSrcweir 				//OLM}
2111cdf0e10cSrcweir 			}
2112cdf0e10cSrcweir 		}
2113cdf0e10cSrcweir 	}
2114cdf0e10cSrcweir }
2115cdf0e10cSrcweir 
ResetFocusHdl()2116cdf0e10cSrcweir void SdrHdlList::ResetFocusHdl()
2117cdf0e10cSrcweir {
2118cdf0e10cSrcweir 	SdrHdl* pHdl = GetFocusHdl();
2119cdf0e10cSrcweir 
2120cdf0e10cSrcweir 	mnFocusIndex = CONTAINER_ENTRY_NOTFOUND;
2121cdf0e10cSrcweir 
2122cdf0e10cSrcweir 	if(pHdl)
2123cdf0e10cSrcweir 	{
2124cdf0e10cSrcweir 		pHdl->Touch();
2125cdf0e10cSrcweir 	}
2126cdf0e10cSrcweir }
2127cdf0e10cSrcweir 
2128cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
2129cdf0e10cSrcweir 
SdrHdlList(SdrMarkView * pV)2130cdf0e10cSrcweir SdrHdlList::SdrHdlList(SdrMarkView* pV)
2131cdf0e10cSrcweir :	mnFocusIndex(CONTAINER_ENTRY_NOTFOUND),
2132cdf0e10cSrcweir 	pView(pV),
2133cdf0e10cSrcweir 	aList(1024,32,32)
2134cdf0e10cSrcweir {
2135cdf0e10cSrcweir 	nHdlSize = 3;
2136cdf0e10cSrcweir 	bRotateShear = sal_False;
2137cdf0e10cSrcweir 	bMoveOutside = sal_False;
2138cdf0e10cSrcweir 	bDistortShear = sal_False;
21394772d9afSArmin Le Grand 	bFineHandles = sal_True; // new default: Handles are fine handles
2140cdf0e10cSrcweir }
2141cdf0e10cSrcweir 
~SdrHdlList()2142cdf0e10cSrcweir SdrHdlList::~SdrHdlList()
2143cdf0e10cSrcweir {
2144cdf0e10cSrcweir 	Clear();
2145cdf0e10cSrcweir }
2146cdf0e10cSrcweir 
SetHdlSize(sal_uInt16 nSiz)2147cdf0e10cSrcweir void SdrHdlList::SetHdlSize(sal_uInt16 nSiz)
2148cdf0e10cSrcweir {
2149cdf0e10cSrcweir 	if(nHdlSize != nSiz)
2150cdf0e10cSrcweir 	{
2151cdf0e10cSrcweir 		// remember new value
2152cdf0e10cSrcweir 		nHdlSize = nSiz;
2153cdf0e10cSrcweir 
2154cdf0e10cSrcweir 		// propagate change to IAOs
2155cdf0e10cSrcweir 		for(sal_uInt32 i=0; i<GetHdlCount(); i++)
2156cdf0e10cSrcweir 		{
2157cdf0e10cSrcweir 			SdrHdl* pHdl = GetHdl(i);
2158cdf0e10cSrcweir 			pHdl->Touch();
2159cdf0e10cSrcweir 		}
2160cdf0e10cSrcweir 	}
2161cdf0e10cSrcweir }
2162cdf0e10cSrcweir 
SetMoveOutside(sal_Bool bOn)2163cdf0e10cSrcweir void SdrHdlList::SetMoveOutside(sal_Bool bOn)
2164cdf0e10cSrcweir {
2165cdf0e10cSrcweir 	if(bMoveOutside != bOn)
2166cdf0e10cSrcweir 	{
2167cdf0e10cSrcweir 		// remember new value
2168cdf0e10cSrcweir 		bMoveOutside = bOn;
2169cdf0e10cSrcweir 
2170cdf0e10cSrcweir 		// propagate change to IAOs
2171cdf0e10cSrcweir 		for(sal_uInt32 i=0; i<GetHdlCount(); i++)
2172cdf0e10cSrcweir 		{
2173cdf0e10cSrcweir 			SdrHdl* pHdl = GetHdl(i);
2174cdf0e10cSrcweir 			pHdl->Touch();
2175cdf0e10cSrcweir 		}
2176cdf0e10cSrcweir 	}
2177cdf0e10cSrcweir }
2178cdf0e10cSrcweir 
SetRotateShear(sal_Bool bOn)2179cdf0e10cSrcweir void SdrHdlList::SetRotateShear(sal_Bool bOn)
2180cdf0e10cSrcweir {
2181cdf0e10cSrcweir 	bRotateShear = bOn;
2182cdf0e10cSrcweir }
2183cdf0e10cSrcweir 
SetDistortShear(sal_Bool bOn)2184cdf0e10cSrcweir void SdrHdlList::SetDistortShear(sal_Bool bOn)
2185cdf0e10cSrcweir {
2186cdf0e10cSrcweir 	bDistortShear = bOn;
2187cdf0e10cSrcweir }
2188cdf0e10cSrcweir 
SetFineHdl(sal_Bool bOn)2189cdf0e10cSrcweir void SdrHdlList::SetFineHdl(sal_Bool bOn)
2190cdf0e10cSrcweir {
2191cdf0e10cSrcweir 	if(bFineHandles != bOn)
2192cdf0e10cSrcweir 	{
2193cdf0e10cSrcweir 		// remember new state
2194cdf0e10cSrcweir 		bFineHandles = bOn;
2195cdf0e10cSrcweir 
2196cdf0e10cSrcweir 		// propagate change to IAOs
2197cdf0e10cSrcweir 		for(sal_uInt32 i=0; i<GetHdlCount(); i++)
2198cdf0e10cSrcweir 		{
2199cdf0e10cSrcweir 			SdrHdl* pHdl = GetHdl(i);
2200cdf0e10cSrcweir 			pHdl->Touch();
2201cdf0e10cSrcweir 		}
2202cdf0e10cSrcweir 	}
2203cdf0e10cSrcweir }
2204cdf0e10cSrcweir 
RemoveHdl(sal_uIntPtr nNum)2205cdf0e10cSrcweir SdrHdl* SdrHdlList::RemoveHdl(sal_uIntPtr nNum)
2206cdf0e10cSrcweir {
2207cdf0e10cSrcweir 	SdrHdl* pRetval = (SdrHdl*)aList.Remove(nNum);
2208cdf0e10cSrcweir 
2209cdf0e10cSrcweir 	return pRetval;
2210cdf0e10cSrcweir }
2211cdf0e10cSrcweir 
Clear()2212cdf0e10cSrcweir void SdrHdlList::Clear()
2213cdf0e10cSrcweir {
2214cdf0e10cSrcweir 	for (sal_uIntPtr i=0; i<GetHdlCount(); i++)
2215cdf0e10cSrcweir 	{
2216cdf0e10cSrcweir 		SdrHdl* pHdl=GetHdl(i);
2217cdf0e10cSrcweir 		delete pHdl;
2218cdf0e10cSrcweir 	}
2219cdf0e10cSrcweir 	aList.Clear();
2220cdf0e10cSrcweir 
2221cdf0e10cSrcweir 	bRotateShear=sal_False;
2222cdf0e10cSrcweir 	bDistortShear=sal_False;
2223cdf0e10cSrcweir }
2224cdf0e10cSrcweir 
Sort()2225cdf0e10cSrcweir void SdrHdlList::Sort()
2226cdf0e10cSrcweir {
2227cdf0e10cSrcweir 	// #97016# II: remember current focused handle
2228cdf0e10cSrcweir 	SdrHdl* pPrev = GetFocusHdl();
2229cdf0e10cSrcweir 
2230cdf0e10cSrcweir 	ImpSdrHdlListSorter aSort(aList);
2231cdf0e10cSrcweir 	aSort.DoSort();
2232cdf0e10cSrcweir 
2233cdf0e10cSrcweir 	// #97016# II: get now and compare
2234cdf0e10cSrcweir 	SdrHdl* pNow = GetFocusHdl();
2235cdf0e10cSrcweir 
2236cdf0e10cSrcweir 	if(pPrev != pNow)
2237cdf0e10cSrcweir 	{
2238cdf0e10cSrcweir 		//SDOsal_Bool bRefresh(sal_False);
2239cdf0e10cSrcweir 
2240cdf0e10cSrcweir 		if(pPrev)
2241cdf0e10cSrcweir 		{
2242cdf0e10cSrcweir 			pPrev->Touch();
2243cdf0e10cSrcweir 			//SDObRefresh = sal_True;
2244cdf0e10cSrcweir 		}
2245cdf0e10cSrcweir 
2246cdf0e10cSrcweir 		if(pNow)
2247cdf0e10cSrcweir 		{
2248cdf0e10cSrcweir 			pNow->Touch();
2249cdf0e10cSrcweir 			//SDObRefresh = sal_True;
2250cdf0e10cSrcweir 		}
2251cdf0e10cSrcweir 	}
2252cdf0e10cSrcweir }
2253cdf0e10cSrcweir 
GetHdlNum(const SdrHdl * pHdl) const2254cdf0e10cSrcweir sal_uIntPtr SdrHdlList::GetHdlNum(const SdrHdl* pHdl) const
2255cdf0e10cSrcweir {
2256cdf0e10cSrcweir 	if (pHdl==NULL)
2257cdf0e10cSrcweir 		return CONTAINER_ENTRY_NOTFOUND;
2258cdf0e10cSrcweir 	sal_uIntPtr nPos=aList.GetPos(pHdl);
2259cdf0e10cSrcweir 	return nPos;
2260cdf0e10cSrcweir }
2261cdf0e10cSrcweir 
AddHdl(SdrHdl * pHdl,sal_Bool bAtBegin)2262cdf0e10cSrcweir void SdrHdlList::AddHdl(SdrHdl* pHdl, sal_Bool bAtBegin)
2263cdf0e10cSrcweir {
2264cdf0e10cSrcweir 	if (pHdl!=NULL)
2265cdf0e10cSrcweir 	{
2266cdf0e10cSrcweir 		if (bAtBegin)
2267cdf0e10cSrcweir 		{
2268cdf0e10cSrcweir 			aList.Insert(pHdl,sal_uIntPtr(0));
2269cdf0e10cSrcweir 		}
2270cdf0e10cSrcweir 		else
2271cdf0e10cSrcweir 		{
2272cdf0e10cSrcweir 			aList.Insert(pHdl,CONTAINER_APPEND);
2273cdf0e10cSrcweir 		}
2274cdf0e10cSrcweir 		pHdl->SetHdlList(this);
2275cdf0e10cSrcweir 	}
2276cdf0e10cSrcweir }
2277cdf0e10cSrcweir 
IsHdlListHit(const Point & rPnt,sal_Bool bBack,sal_Bool bNext,SdrHdl * pHdl0) const2278cdf0e10cSrcweir SdrHdl* SdrHdlList::IsHdlListHit(const Point& rPnt, sal_Bool bBack, sal_Bool bNext, SdrHdl* pHdl0) const
2279cdf0e10cSrcweir {
2280cdf0e10cSrcweir 	SdrHdl* pRet=NULL;
2281cdf0e10cSrcweir 	sal_uIntPtr nAnz=GetHdlCount();
2282cdf0e10cSrcweir 	sal_uIntPtr nNum=bBack ? 0 : nAnz;
2283cdf0e10cSrcweir 	while ((bBack ? nNum<nAnz : nNum>0) && pRet==NULL)
2284cdf0e10cSrcweir 	{
2285cdf0e10cSrcweir 		if (!bBack)
2286cdf0e10cSrcweir 			nNum--;
2287cdf0e10cSrcweir 		SdrHdl* pHdl=GetHdl(nNum);
2288cdf0e10cSrcweir 		if (bNext)
2289cdf0e10cSrcweir 		{
2290cdf0e10cSrcweir 			if (pHdl==pHdl0)
2291cdf0e10cSrcweir 				bNext=sal_False;
2292cdf0e10cSrcweir 		}
2293cdf0e10cSrcweir 		else
2294cdf0e10cSrcweir 		{
2295cdf0e10cSrcweir 			if (pHdl->IsHdlHit(rPnt))
2296cdf0e10cSrcweir 				pRet=pHdl;
2297cdf0e10cSrcweir 		}
2298cdf0e10cSrcweir 		if (bBack)
2299cdf0e10cSrcweir 			nNum++;
2300cdf0e10cSrcweir 	}
2301cdf0e10cSrcweir 	return pRet;
2302cdf0e10cSrcweir }
2303cdf0e10cSrcweir 
GetHdl(SdrHdlKind eKind1) const2304cdf0e10cSrcweir SdrHdl* SdrHdlList::GetHdl(SdrHdlKind eKind1) const
2305cdf0e10cSrcweir {
2306cdf0e10cSrcweir 	SdrHdl* pRet=NULL;
2307cdf0e10cSrcweir 	for (sal_uIntPtr i=0; i<GetHdlCount() && pRet==NULL; i++)
2308cdf0e10cSrcweir 	{
2309cdf0e10cSrcweir 		SdrHdl* pHdl=GetHdl(i);
2310cdf0e10cSrcweir 		if (pHdl->GetKind()==eKind1)
2311cdf0e10cSrcweir 			pRet=pHdl;
2312cdf0e10cSrcweir 	}
2313cdf0e10cSrcweir 	return pRet;
2314cdf0e10cSrcweir }
2315cdf0e10cSrcweir 
2316cdf0e10cSrcweir // --------------------------------------------------------------------
2317cdf0e10cSrcweir // SdrCropHdl
2318cdf0e10cSrcweir // --------------------------------------------------------------------
2319cdf0e10cSrcweir 
SdrCropHdl(const Point & rPnt,SdrHdlKind eNewKind,double fShearX,double fRotation)2320414a0e15SArmin Le Grand SdrCropHdl::SdrCropHdl(
2321414a0e15SArmin Le Grand 	const Point& rPnt,
2322414a0e15SArmin Le Grand 	SdrHdlKind eNewKind,
2323414a0e15SArmin Le Grand 	double fShearX,
2324414a0e15SArmin Le Grand 	double fRotation)
2325414a0e15SArmin Le Grand :	SdrHdl(rPnt, eNewKind),
2326414a0e15SArmin Le Grand 	mfShearX(fShearX),
2327414a0e15SArmin Le Grand 	mfRotation(fRotation)
2328cdf0e10cSrcweir {
2329cdf0e10cSrcweir }
2330cdf0e10cSrcweir 
2331cdf0e10cSrcweir // --------------------------------------------------------------------
2332cdf0e10cSrcweir 
GetHandlesBitmap(bool bIsFineHdl,bool bIsHighContrast)2333cdf0e10cSrcweir BitmapEx SdrCropHdl::GetHandlesBitmap( bool bIsFineHdl, bool bIsHighContrast )
2334cdf0e10cSrcweir {
2335cdf0e10cSrcweir 	if( bIsHighContrast )
2336cdf0e10cSrcweir 	{
2337cdf0e10cSrcweir 		static BitmapEx* pHighContrastBitmap = 0;
2338cdf0e10cSrcweir 		if( pHighContrastBitmap == 0 )
2339cdf0e10cSrcweir 			pHighContrastBitmap = new BitmapEx(ResId(SIP_SA_ACCESSIBILITY_CROP_MARKERS, *ImpGetResMgr()));
2340cdf0e10cSrcweir 		return *pHighContrastBitmap;
2341cdf0e10cSrcweir 	}
2342cdf0e10cSrcweir 	else if( bIsFineHdl )
2343cdf0e10cSrcweir 	{
2344cdf0e10cSrcweir 		static BitmapEx* pModernBitmap = 0;
2345cdf0e10cSrcweir 		if( pModernBitmap == 0 )
2346cdf0e10cSrcweir 			pModernBitmap = new BitmapEx(ResId(SIP_SA_CROP_FINE_MARKERS, *ImpGetResMgr()));
2347cdf0e10cSrcweir 		return *pModernBitmap;
2348cdf0e10cSrcweir 	}
2349cdf0e10cSrcweir 	else
2350cdf0e10cSrcweir 	{
2351cdf0e10cSrcweir 		static BitmapEx* pSimpleBitmap = 0;
2352cdf0e10cSrcweir 		if( pSimpleBitmap == 0 )
2353cdf0e10cSrcweir 			pSimpleBitmap = new BitmapEx(ResId(SIP_SA_CROP_MARKERS, *ImpGetResMgr()));
2354cdf0e10cSrcweir 		return *pSimpleBitmap;
2355cdf0e10cSrcweir 	}
2356cdf0e10cSrcweir }
2357cdf0e10cSrcweir 
2358cdf0e10cSrcweir // --------------------------------------------------------------------
2359cdf0e10cSrcweir 
GetBitmapForHandle(const BitmapEx & rBitmap,int nSize)2360cdf0e10cSrcweir BitmapEx SdrCropHdl::GetBitmapForHandle( const BitmapEx& rBitmap, int nSize )
2361cdf0e10cSrcweir {
2362cdf0e10cSrcweir 	int nPixelSize = 0, nX = 0, nY = 0, nOffset = 0;
2363cdf0e10cSrcweir 
2364cdf0e10cSrcweir 	if( nSize <= 3 )
2365cdf0e10cSrcweir 	{
2366cdf0e10cSrcweir 		nPixelSize = 13;
2367cdf0e10cSrcweir 		nOffset = 0;
2368cdf0e10cSrcweir 	}
2369cdf0e10cSrcweir 	else if( nSize <=4 )
2370cdf0e10cSrcweir 	{
2371cdf0e10cSrcweir 		nPixelSize = 17;
23728b6ef4e4Smseidel 		nOffset = 39;
2373cdf0e10cSrcweir 	}
2374cdf0e10cSrcweir 	else
2375cdf0e10cSrcweir 	{
2376cdf0e10cSrcweir 		nPixelSize = 21;
23778b6ef4e4Smseidel 		nOffset = 90;
2378cdf0e10cSrcweir 	}
2379cdf0e10cSrcweir 
2380cdf0e10cSrcweir 	switch( eKind )
2381cdf0e10cSrcweir 	{
2382cdf0e10cSrcweir 		case HDL_UPLFT: nX = 0; nY = 0; break;
2383cdf0e10cSrcweir 		case HDL_UPPER: nX = 1; nY = 0; break;
2384cdf0e10cSrcweir 		case HDL_UPRGT: nX = 2; nY = 0; break;
2385cdf0e10cSrcweir 		case HDL_LEFT:  nX = 0; nY = 1; break;
2386cdf0e10cSrcweir 		case HDL_RIGHT: nX = 2; nY = 1; break;
2387cdf0e10cSrcweir 		case HDL_LWLFT: nX = 0; nY = 2; break;
2388cdf0e10cSrcweir 		case HDL_LOWER: nX = 1; nY = 2; break;
2389cdf0e10cSrcweir 		case HDL_LWRGT: nX = 2; nY = 2; break;
2390cdf0e10cSrcweir 		default: break;
2391cdf0e10cSrcweir 	}
2392cdf0e10cSrcweir 
23938b6ef4e4Smseidel 	Rectangle aSourceRect( Point( nX * (nPixelSize) + nOffset, nY * (nPixelSize)), Size(nPixelSize, nPixelSize) );
2394cdf0e10cSrcweir 
2395cdf0e10cSrcweir 	BitmapEx aRetval(rBitmap);
2396cdf0e10cSrcweir 	aRetval.Crop(aSourceRect);
2397cdf0e10cSrcweir 	return aRetval;
2398cdf0e10cSrcweir }
2399cdf0e10cSrcweir 
2400cdf0e10cSrcweir // --------------------------------------------------------------------
2401cdf0e10cSrcweir 
CreateB2dIAObject()2402cdf0e10cSrcweir void SdrCropHdl::CreateB2dIAObject()
2403cdf0e10cSrcweir {
2404cdf0e10cSrcweir 	// first throw away old one
2405cdf0e10cSrcweir 	GetRidOfIAObject();
2406cdf0e10cSrcweir 
2407cdf0e10cSrcweir 	SdrMarkView* pView = pHdlList ? pHdlList->GetView() : 0;
2408cdf0e10cSrcweir 	SdrPageView* pPageView = pView ? pView->GetSdrPageView() : 0;
2409cdf0e10cSrcweir 
2410cdf0e10cSrcweir 	if( pPageView && !pView->areMarkHandlesHidden() )
2411cdf0e10cSrcweir 	{
2412cdf0e10cSrcweir 		sal_Bool bIsFineHdl(pHdlList->IsFineHdl());
2413cdf0e10cSrcweir 		const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
2414cdf0e10cSrcweir 		sal_Bool bIsHighContrast(rStyleSettings.GetHighContrastMode());
2415cdf0e10cSrcweir 		int nHdlSize = pHdlList->GetHdlSize();
2416cdf0e10cSrcweir 		if( bIsHighContrast )
2417cdf0e10cSrcweir 			nHdlSize = 4;
2418cdf0e10cSrcweir 
2419cdf0e10cSrcweir 		const BitmapEx aHandlesBitmap( GetHandlesBitmap( bIsFineHdl, bIsHighContrast ) );
2420cdf0e10cSrcweir 		BitmapEx aBmpEx1( GetBitmapForHandle( aHandlesBitmap, nHdlSize ) );
2421cdf0e10cSrcweir 
2422cdf0e10cSrcweir 		for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
2423cdf0e10cSrcweir 		{
2424cdf0e10cSrcweir 			// const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
2425cdf0e10cSrcweir 			const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
2426cdf0e10cSrcweir 
2427cdf0e10cSrcweir 			if(rPageWindow.GetPaintWindow().OutputToWindow())
2428cdf0e10cSrcweir 			{
2429cdf0e10cSrcweir 				if(rPageWindow.GetOverlayManager())
2430cdf0e10cSrcweir 				{
2431cdf0e10cSrcweir 					basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
2432cdf0e10cSrcweir 
2433cdf0e10cSrcweir 					::sdr::overlay::OverlayObject* pOverlayObject = 0L;
2434cdf0e10cSrcweir 
2435cdf0e10cSrcweir 					// animate focused handles
2436cdf0e10cSrcweir 					if(IsFocusHdl() && (pHdlList->GetFocusHdl() == this))
2437cdf0e10cSrcweir 					{
2438cdf0e10cSrcweir 						if( nHdlSize >= 2 )
2439cdf0e10cSrcweir 							nHdlSize = 1;
2440cdf0e10cSrcweir 
2441cdf0e10cSrcweir 						BitmapEx aBmpEx2( GetBitmapForHandle( aHandlesBitmap, nHdlSize + 1 ) );
2442cdf0e10cSrcweir 
2443cdf0e10cSrcweir 						const sal_uInt32 nBlinkTime = sal::static_int_cast<sal_uInt32>(rStyleSettings.GetCursorBlinkTime());
2444cdf0e10cSrcweir 
2445414a0e15SArmin Le Grand 						pOverlayObject = new ::sdr::overlay::OverlayAnimatedBitmapEx(
2446414a0e15SArmin Le Grand 							aPosition,
2447414a0e15SArmin Le Grand 							aBmpEx1,
2448414a0e15SArmin Le Grand 							aBmpEx2,
2449414a0e15SArmin Le Grand 							nBlinkTime,
2450cdf0e10cSrcweir 							(sal_uInt16)(aBmpEx1.GetSizePixel().Width() - 1) >> 1,
2451cdf0e10cSrcweir 							(sal_uInt16)(aBmpEx1.GetSizePixel().Height() - 1) >> 1,
2452cdf0e10cSrcweir 							(sal_uInt16)(aBmpEx2.GetSizePixel().Width() - 1) >> 1,
2453414a0e15SArmin Le Grand 							(sal_uInt16)(aBmpEx2.GetSizePixel().Height() - 1) >> 1,
2454414a0e15SArmin Le Grand 							mfShearX,
2455414a0e15SArmin Le Grand 							mfRotation);
2456cdf0e10cSrcweir 					}
2457cdf0e10cSrcweir 					else
2458cdf0e10cSrcweir 					{
2459cdf0e10cSrcweir 						// create centered handle as default
2460414a0e15SArmin Le Grand 						pOverlayObject = new ::sdr::overlay::OverlayBitmapEx(
2461414a0e15SArmin Le Grand 							aPosition,
2462414a0e15SArmin Le Grand 							aBmpEx1,
2463cdf0e10cSrcweir 							(sal_uInt16)(aBmpEx1.GetSizePixel().Width() - 1) >> 1,
2464414a0e15SArmin Le Grand 							(sal_uInt16)(aBmpEx1.GetSizePixel().Height() - 1) >> 1,
2465414a0e15SArmin Le Grand 							0.0,
2466414a0e15SArmin Le Grand 							mfShearX,
2467414a0e15SArmin Le Grand 							mfRotation);
2468cdf0e10cSrcweir 					}
2469cdf0e10cSrcweir 
2470cdf0e10cSrcweir 					// OVERLAYMANAGER
2471cdf0e10cSrcweir 					if(pOverlayObject)
2472cdf0e10cSrcweir 					{
2473cdf0e10cSrcweir 						rPageWindow.GetOverlayManager()->add(*pOverlayObject);
2474cdf0e10cSrcweir 						maOverlayGroup.append(*pOverlayObject);
2475cdf0e10cSrcweir 					}
2476cdf0e10cSrcweir 				}
2477cdf0e10cSrcweir 			}
2478cdf0e10cSrcweir 		}
2479cdf0e10cSrcweir 	}
2480cdf0e10cSrcweir }
2481cdf0e10cSrcweir 
24822376739dSArmin Le Grand ////////////////////////////////////////////////////////////////////////////////////////////////////
2483414a0e15SArmin Le Grand // with the correction of crop handling I could get rid of the extra mirroring flag, adapted stuff
2484414a0e15SArmin Le Grand // accordingly
24852376739dSArmin Le Grand 
SdrCropViewHdl(const basegfx::B2DHomMatrix & rObjectTransform,const Graphic & rGraphic,double fCropLeft,double fCropTop,double fCropRight,double fCropBottom)24862376739dSArmin Le Grand SdrCropViewHdl::SdrCropViewHdl(
24872376739dSArmin Le Grand 	const basegfx::B2DHomMatrix& rObjectTransform,
24882376739dSArmin Le Grand 	const Graphic& rGraphic,
24892376739dSArmin Le Grand 	double fCropLeft,
24902376739dSArmin Le Grand 	double fCropTop,
24912376739dSArmin Le Grand 	double fCropRight,
2492414a0e15SArmin Le Grand 	double fCropBottom)
24932376739dSArmin Le Grand :	SdrHdl(Point(), HDL_USER),
24942376739dSArmin Le Grand 	maObjectTransform(rObjectTransform),
24952376739dSArmin Le Grand 	maGraphic(rGraphic),
24962376739dSArmin Le Grand 	mfCropLeft(fCropLeft),
24972376739dSArmin Le Grand 	mfCropTop(fCropTop),
24982376739dSArmin Le Grand 	mfCropRight(fCropRight),
2499414a0e15SArmin Le Grand 	mfCropBottom(fCropBottom)
25002376739dSArmin Le Grand {
25012376739dSArmin Le Grand }
25022376739dSArmin Le Grand 
CreateB2dIAObject()25032376739dSArmin Le Grand void SdrCropViewHdl::CreateB2dIAObject()
25042376739dSArmin Le Grand {
25052376739dSArmin Le Grand 	GetRidOfIAObject();
25062376739dSArmin Le Grand 	SdrMarkView* pView = pHdlList ? pHdlList->GetView() : 0;
25072376739dSArmin Le Grand 	SdrPageView* pPageView = pView ? pView->GetSdrPageView() : 0;
25082376739dSArmin Le Grand 
25092376739dSArmin Le Grand 	if(pPageView && pView->areMarkHandlesHidden())
25102376739dSArmin Le Grand 	{
25112376739dSArmin Le Grand 		return;
25122376739dSArmin Le Grand 	}
25132376739dSArmin Le Grand 
25142376739dSArmin Le Grand 	// decompose to have current translate and scale
25152376739dSArmin Le Grand 	basegfx::B2DVector aScale, aTranslate;
25162376739dSArmin Le Grand 	double fRotate, fShearX;
25172376739dSArmin Le Grand 
25182376739dSArmin Le Grand 	maObjectTransform.decompose(aScale, aTranslate, fRotate, fShearX);
25192376739dSArmin Le Grand 
25202376739dSArmin Le Grand 	if(aScale.equalZero())
25212376739dSArmin Le Grand 	{
25222376739dSArmin Le Grand 		return;
25232376739dSArmin Le Grand 	}
25242376739dSArmin Le Grand 
25252376739dSArmin Le Grand 	// detect 180 degree rotation, this is the same as mirrored in X and Y,
25262376739dSArmin Le Grand 	// thus change to mirroring. Prefer mirroring here. Use the equal call
25272376739dSArmin Le Grand 	// with getSmallValue here, the original which uses rtl::math::approxEqual
25282376739dSArmin Le Grand 	// is too correct here. Maybe this changes with enhanced precision in aw080
25292376739dSArmin Le Grand 	// to the better so that this can be reduced to the more precise call again
25302376739dSArmin Le Grand 	if(basegfx::fTools::equal(fabs(fRotate), F_PI, 0.000000001))
25312376739dSArmin Le Grand 	{
25322376739dSArmin Le Grand 		aScale.setX(aScale.getX() * -1.0);
25332376739dSArmin Le Grand 		aScale.setY(aScale.getY() * -1.0);
25342376739dSArmin Le Grand 		fRotate = 0.0;
25352376739dSArmin Le Grand 	}
25362376739dSArmin Le Grand 
25372376739dSArmin Le Grand 	// remember mirroring, reset at Scale and adapt crop values for usage;
25382376739dSArmin Le Grand 	// mirroring can stay in the object transformation, so do not have to
25392376739dSArmin Le Grand 	// cope with it here (except later for the CroppedImage transformation,
25402376739dSArmin Le Grand 	// see below)
25412376739dSArmin Le Grand 	const bool bMirroredX(aScale.getX() < 0.0);
25422376739dSArmin Le Grand 	const bool bMirroredY(aScale.getY() < 0.0);
25432376739dSArmin Le Grand 	double fCropLeft(mfCropLeft);
25442376739dSArmin Le Grand 	double fCropTop(mfCropTop);
25452376739dSArmin Le Grand 	double fCropRight(mfCropRight);
25462376739dSArmin Le Grand 	double fCropBottom(mfCropBottom);
25472376739dSArmin Le Grand 
25482376739dSArmin Le Grand 	if(bMirroredX)
25492376739dSArmin Le Grand 	{
25502376739dSArmin Le Grand 		aScale.setX(-aScale.getX());
25512376739dSArmin Le Grand 	}
25522376739dSArmin Le Grand 
25532376739dSArmin Le Grand 	if(bMirroredY)
25542376739dSArmin Le Grand 	{
25552376739dSArmin Le Grand 		aScale.setY(-aScale.getY());
25562376739dSArmin Le Grand 	}
25572376739dSArmin Le Grand 
25582376739dSArmin Le Grand 	// create target translate and scale
25592376739dSArmin Le Grand 	const basegfx::B2DVector aTargetScale(
25602376739dSArmin Le Grand 		aScale.getX() + fCropRight + fCropLeft,
25612376739dSArmin Le Grand 		aScale.getY() + fCropBottom + fCropTop);
25622376739dSArmin Le Grand 	const basegfx::B2DVector aTargetTranslate(
25632376739dSArmin Le Grand 		aTranslate.getX() - fCropLeft,
25642376739dSArmin Le Grand 		aTranslate.getY() - fCropTop);
25652376739dSArmin Le Grand 
25662376739dSArmin Le Grand 	// create ranges to make comparisons
25672376739dSArmin Le Grand 	const basegfx::B2DRange aCurrentForCompare(
25682376739dSArmin Le Grand 		aTranslate.getX(), aTranslate.getY(),
25692376739dSArmin Le Grand 		aTranslate.getX() + aScale.getX(), aTranslate.getY() + aScale.getY());
25702376739dSArmin Le Grand 	basegfx::B2DRange aCropped(
25712376739dSArmin Le Grand 		aTargetTranslate.getX(), aTargetTranslate.getY(),
25722376739dSArmin Le Grand 		aTargetTranslate.getX() + aTargetScale.getX(), aTargetTranslate.getY() + aTargetScale.getY());
25732376739dSArmin Le Grand 
25742376739dSArmin Le Grand 	if(aCropped.isEmpty())
25752376739dSArmin Le Grand 	{
25762376739dSArmin Le Grand 		// nothing to return since cropped content is completely empty
25772376739dSArmin Le Grand 		return;
25782376739dSArmin Le Grand 	}
25792376739dSArmin Le Grand 
25802376739dSArmin Le Grand 	if(aCurrentForCompare.equal(aCropped))
25812376739dSArmin Le Grand 	{
25822376739dSArmin Le Grand 		// no crop at all
25832376739dSArmin Le Grand 		return;
25842376739dSArmin Le Grand 	}
25852376739dSArmin Le Grand 
25862376739dSArmin Le Grand 	// back-transform to have values in unit coordinates
25872376739dSArmin Le Grand 	basegfx::B2DHomMatrix aBackToUnit;
25882376739dSArmin Le Grand 	aBackToUnit.translate(-aTranslate.getX(), -aTranslate.getY());
25892376739dSArmin Le Grand 	aBackToUnit.scale(
25902376739dSArmin Le Grand 		basegfx::fTools::equalZero(aScale.getX()) ? 1.0 : 1.0 / aScale.getX(),
25912376739dSArmin Le Grand 		basegfx::fTools::equalZero(aScale.getY()) ? 1.0 : 1.0 / aScale.getY());
25922376739dSArmin Le Grand 
25932376739dSArmin Le Grand 	// transform cropped back to unit coordinates
25942376739dSArmin Le Grand 	aCropped.transform(aBackToUnit);
25952376739dSArmin Le Grand 
25962376739dSArmin Le Grand 	// prepare crop PolyPolygon
25978185c382SArmin Le Grand 	basegfx::B2DPolygon aGraphicOutlinePolygon(
25982376739dSArmin Le Grand 		basegfx::tools::createPolygonFromRect(
25992376739dSArmin Le Grand 			aCropped));
26008185c382SArmin Le Grand 	basegfx::B2DPolyPolygon aCropPolyPolygon(aGraphicOutlinePolygon);
26012376739dSArmin Le Grand 
26022376739dSArmin Le Grand 	// current range is unit range
26032376739dSArmin Le Grand 	basegfx::B2DRange aOverlap(0.0, 0.0, 1.0, 1.0);
26042376739dSArmin Le Grand 
26052376739dSArmin Le Grand 	aOverlap.intersect(aCropped);
26062376739dSArmin Le Grand 
26072376739dSArmin Le Grand 	if(!aOverlap.isEmpty())
26082376739dSArmin Le Grand 	{
26092376739dSArmin Le Grand 		aCropPolyPolygon.append(
26102376739dSArmin Le Grand 			basegfx::tools::createPolygonFromRect(
26112376739dSArmin Le Grand 				aOverlap));
26122376739dSArmin Le Grand 	}
26132376739dSArmin Le Grand 
26142376739dSArmin Le Grand 	// transform to object coordinates to prepare for clip
26152376739dSArmin Le Grand 	aCropPolyPolygon.transform(maObjectTransform);
26168185c382SArmin Le Grand 	aGraphicOutlinePolygon.transform(maObjectTransform);
26172376739dSArmin Le Grand 
26182376739dSArmin Le Grand 	// create cropped transformation
26192376739dSArmin Le Grand 	basegfx::B2DHomMatrix aCroppedTransform;
2620414a0e15SArmin Le Grand 	const bool bCombinedMirrorX(bMirroredX);
26212376739dSArmin Le Grand 
26222376739dSArmin Le Grand 	aCroppedTransform.scale(
2623414a0e15SArmin Le Grand 		aCropped.getWidth(),
2624414a0e15SArmin Le Grand 		aCropped.getHeight());
26252376739dSArmin Le Grand 	aCroppedTransform.translate(
2626414a0e15SArmin Le Grand 		aCropped.getMinX(),
2627414a0e15SArmin Le Grand 		aCropped.getMinY());
26282376739dSArmin Le Grand 	aCroppedTransform = maObjectTransform * aCroppedTransform;
26292376739dSArmin Le Grand 
2630ef96bc24Smseidel 	// prepare graphic primitive (transformed)
26312376739dSArmin Le Grand 	const drawinglayer::primitive2d::Primitive2DReference aGraphic(
26322376739dSArmin Le Grand 		new drawinglayer::primitive2d::GraphicPrimitive2D(
26332376739dSArmin Le Grand 			aCroppedTransform,
26342376739dSArmin Le Grand 			maGraphic));
26352376739dSArmin Le Grand 
26368185c382SArmin Le Grand 	// prepare outline polygon for whole graphic
26378185c382SArmin Le Grand 	const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
26388185c382SArmin Le Grand 	const basegfx::BColor aHilightColor(aSvtOptionsDrawinglayer.getHilightColor().getBColor());
26398185c382SArmin Le Grand 	const drawinglayer::primitive2d::Primitive2DReference aGraphicOutline(
26408185c382SArmin Le Grand 		new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
26418185c382SArmin Le Grand 		aGraphicOutlinePolygon,
26428185c382SArmin Le Grand 		aHilightColor));
26438185c382SArmin Le Grand 
26448185c382SArmin Le Grand 	// combine these
26458185c382SArmin Le Grand 	drawinglayer::primitive2d::Primitive2DSequence aCombination(2);
26468185c382SArmin Le Grand 	aCombination[0] = aGraphic;
26478185c382SArmin Le Grand 	aCombination[1] = aGraphicOutline;
26488185c382SArmin Le Grand 
26492376739dSArmin Le Grand 	// embed to MaskPrimitive2D
26502376739dSArmin Le Grand 	const drawinglayer::primitive2d::Primitive2DReference aMaskedGraphic(
26512376739dSArmin Le Grand 		new drawinglayer::primitive2d::MaskPrimitive2D(
26522376739dSArmin Le Grand 			aCropPolyPolygon,
26538185c382SArmin Le Grand 			aCombination));
26542376739dSArmin Le Grand 
26552376739dSArmin Le Grand 	// embed to UnifiedTransparencePrimitive2D
26562376739dSArmin Le Grand 	const drawinglayer::primitive2d::Primitive2DReference aTransparenceMaskedGraphic(
26572376739dSArmin Le Grand 		new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
26582376739dSArmin Le Grand 			drawinglayer::primitive2d::Primitive2DSequence(&aMaskedGraphic, 1),
26592376739dSArmin Le Grand 			0.8));
26602376739dSArmin Le Grand 
26612376739dSArmin Le Grand 	const drawinglayer::primitive2d::Primitive2DSequence aSequence(&aTransparenceMaskedGraphic, 1);
26622376739dSArmin Le Grand 
26632376739dSArmin Le Grand 	for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
26642376739dSArmin Le Grand 	{
26652376739dSArmin Le Grand 		// const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
26662376739dSArmin Le Grand 		const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
26672376739dSArmin Le Grand 
26682376739dSArmin Le Grand 		if(rPageWindow.GetPaintWindow().OutputToWindow())
26692376739dSArmin Le Grand 		{
26702376739dSArmin Le Grand 			if(rPageWindow.GetOverlayManager())
26712376739dSArmin Le Grand 			{
26722376739dSArmin Le Grand 				::sdr::overlay::OverlayObject* pNew = new sdr::overlay::OverlayPrimitive2DSequenceObject(aSequence);
26732376739dSArmin Le Grand 				DBG_ASSERT(pNew, "Got NO new IAO!");
26742376739dSArmin Le Grand 
26752376739dSArmin Le Grand 				if(pNew)
26762376739dSArmin Le Grand 				{
26772376739dSArmin Le Grand 					// only informative object, no hit
26782376739dSArmin Le Grand 					pNew->setHittable(false);
26792376739dSArmin Le Grand 
26802376739dSArmin Le Grand 					rPageWindow.GetOverlayManager()->add(*pNew);
26812376739dSArmin Le Grand 					maOverlayGroup.append(*pNew);
26822376739dSArmin Le Grand 				}
26832376739dSArmin Le Grand 			}
26842376739dSArmin Le Grand 		}
26852376739dSArmin Le Grand 	}
26862376739dSArmin Le Grand }
26872376739dSArmin Le Grand 
26882376739dSArmin Le Grand ////////////////////////////////////////////////////////////////////////////////////////////////////
26892376739dSArmin Le Grand // eof
2690