xref: /aoo42x/main/svx/source/dialog/imapwnd.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svx.hxx"
30*cdf0e10cSrcweir #include <tools/urlobj.hxx>
31*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
32*cdf0e10cSrcweir #include <vcl/help.hxx>
33*cdf0e10cSrcweir #include <sfx2/sfxsids.hrc>		// SID_ATTR_MACROITEM
34*cdf0e10cSrcweir #define _ANIMATION
35*cdf0e10cSrcweir #include <svtools/imaprect.hxx>
36*cdf0e10cSrcweir #include <svtools/imapcirc.hxx>
37*cdf0e10cSrcweir #include <svtools/imappoly.hxx>
38*cdf0e10cSrcweir #include <svl/urlbmk.hxx>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include <svx/xoutbmp.hxx>
41*cdf0e10cSrcweir #include <svx/dialmgr.hxx>
42*cdf0e10cSrcweir #include <svx/dialogs.hrc>
43*cdf0e10cSrcweir #include <svx/svxids.hrc>
44*cdf0e10cSrcweir #include <imapdlg.hrc>
45*cdf0e10cSrcweir #include <imapwnd.hxx>
46*cdf0e10cSrcweir #include <svx/svdpage.hxx>
47*cdf0e10cSrcweir #include <svx/svdorect.hxx>
48*cdf0e10cSrcweir #include <svx/svdocirc.hxx>
49*cdf0e10cSrcweir #include <svx/svdopath.hxx>
50*cdf0e10cSrcweir #include <svx/xfltrit.hxx>
51*cdf0e10cSrcweir #include <svx/svdpagv.hxx>
52*cdf0e10cSrcweir #include <svl/urihelper.hxx>
53*cdf0e10cSrcweir #include <svx/xfillit.hxx>
54*cdf0e10cSrcweir #include <svx/xlineit.hxx>
55*cdf0e10cSrcweir #include <sfx2/evntconf.hxx>
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir #include <sot/formats.hxx>
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir #include <svx/svxdlg.hxx>
60*cdf0e10cSrcweir #include <svx/dialogs.hrc>
61*cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx>
62*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir using ::com::sun::star::frame::XFrame;
65*cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir #define TRANSCOL Color( COL_WHITE )
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir /*************************************************************************
70*cdf0e10cSrcweir |*
71*cdf0e10cSrcweir |*
72*cdf0e10cSrcweir |*
73*cdf0e10cSrcweir \************************************************************************/
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir IMapWindow::IMapWindow( Window* pParent, const ResId& rResId, const Reference< XFrame >& rxDocumentFrame ) :
76*cdf0e10cSrcweir 			GraphCtrl( pParent, rResId ),
77*cdf0e10cSrcweir 			DropTargetHelper( this ),
78*cdf0e10cSrcweir             mxDocumentFrame( rxDocumentFrame )
79*cdf0e10cSrcweir {
80*cdf0e10cSrcweir 	SetWinStyle( WB_SDRMODE );
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 	pItemInfo = new SfxItemInfo[ 1 ];
83*cdf0e10cSrcweir 	memset( pItemInfo, 0, sizeof( SfxItemInfo ) );
84*cdf0e10cSrcweir 	pIMapPool = new SfxItemPool( String::CreateFromAscii( "IMapItemPool" ),
85*cdf0e10cSrcweir 								 SID_ATTR_MACROITEM, SID_ATTR_MACROITEM, pItemInfo );
86*cdf0e10cSrcweir 	pIMapPool->FreezeIdRanges();
87*cdf0e10cSrcweir }
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir /*************************************************************************
90*cdf0e10cSrcweir |*
91*cdf0e10cSrcweir |*
92*cdf0e10cSrcweir |*
93*cdf0e10cSrcweir \************************************************************************/
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir IMapWindow::~IMapWindow()
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir 	// Liste loeschen
98*cdf0e10cSrcweir 	for( String* pStr = aTargetList.First(); pStr; pStr = aTargetList.Next() )
99*cdf0e10cSrcweir 		delete pStr;
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     SfxItemPool::Free(pIMapPool);
102*cdf0e10cSrcweir 	delete[] pItemInfo;
103*cdf0e10cSrcweir }
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir /*************************************************************************
106*cdf0e10cSrcweir |*
107*cdf0e10cSrcweir |*
108*cdf0e10cSrcweir |*
109*cdf0e10cSrcweir \************************************************************************/
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir void IMapWindow::SetImageMap( const ImageMap& rImageMap )
112*cdf0e10cSrcweir {
113*cdf0e10cSrcweir 	ReplaceImageMap( rImageMap, sal_False );
114*cdf0e10cSrcweir }
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir /*************************************************************************
117*cdf0e10cSrcweir |*
118*cdf0e10cSrcweir |*
119*cdf0e10cSrcweir |*
120*cdf0e10cSrcweir \************************************************************************/
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir void IMapWindow::ReplaceImageMap( const ImageMap& rImageMap, sal_Bool /*bScaleToGraphic*/ )
123*cdf0e10cSrcweir {
124*cdf0e10cSrcweir 	SdrPage* pPage = 0;
125*cdf0e10cSrcweir 	aIMap = rImageMap;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 	if(GetSdrModel())
128*cdf0e10cSrcweir 	{
129*cdf0e10cSrcweir 		// try to access page
130*cdf0e10cSrcweir 		pPage = GetSdrModel()->GetPage(0L);
131*cdf0e10cSrcweir 	}
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 	if(pPage)
134*cdf0e10cSrcweir 	{
135*cdf0e10cSrcweir 		// clear all draw objects
136*cdf0e10cSrcweir 		pPage->Clear();
137*cdf0e10cSrcweir 	}
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 	if(GetSdrView())
140*cdf0e10cSrcweir 	{
141*cdf0e10cSrcweir 		// #i63762# reset selection at view
142*cdf0e10cSrcweir 		GetSdrView()->UnmarkAllObj();
143*cdf0e10cSrcweir 	}
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir 	// create new drawing objects
146*cdf0e10cSrcweir 	const sal_uInt16 nCount(rImageMap.GetIMapObjectCount());
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 	for ( sal_uInt16 i(nCount); i > 0; i-- )
149*cdf0e10cSrcweir 	{
150*cdf0e10cSrcweir 		SdrObject* pNewObj = CreateObj( rImageMap.GetIMapObject( i - 1 ) );
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 		if ( pNewObj )
153*cdf0e10cSrcweir 		{
154*cdf0e10cSrcweir 			pPage->InsertObject( pNewObj );
155*cdf0e10cSrcweir 		}
156*cdf0e10cSrcweir 	}
157*cdf0e10cSrcweir }
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir /*************************************************************************
160*cdf0e10cSrcweir |*
161*cdf0e10cSrcweir |*
162*cdf0e10cSrcweir |*
163*cdf0e10cSrcweir \************************************************************************/
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir sal_Bool IMapWindow::ReplaceActualIMapInfo( const NotifyInfo& rNewInfo )
166*cdf0e10cSrcweir {
167*cdf0e10cSrcweir 	const SdrObject*	pSdrObj = GetSelectedSdrObject();
168*cdf0e10cSrcweir 	IMapObject*			pIMapObj;
169*cdf0e10cSrcweir 	sal_Bool				bRet = sal_False;
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 	if ( pSdrObj && ( ( pIMapObj = GetIMapObj( pSdrObj ) ) != NULL ) )
172*cdf0e10cSrcweir 	{
173*cdf0e10cSrcweir 		pIMapObj->SetURL( rNewInfo.aMarkURL );
174*cdf0e10cSrcweir 		pIMapObj->SetAltText( rNewInfo.aMarkAltText );
175*cdf0e10cSrcweir 		pIMapObj->SetTarget( rNewInfo.aMarkTarget );
176*cdf0e10cSrcweir 		pModel->SetChanged( sal_True );
177*cdf0e10cSrcweir 		UpdateInfo( sal_False );
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 		bRet = sal_True;
180*cdf0e10cSrcweir 	}
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 	return bRet;
183*cdf0e10cSrcweir }
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir /*************************************************************************
186*cdf0e10cSrcweir |*
187*cdf0e10cSrcweir |*
188*cdf0e10cSrcweir |*
189*cdf0e10cSrcweir \************************************************************************/
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir const ImageMap& IMapWindow::GetImageMap()
192*cdf0e10cSrcweir {
193*cdf0e10cSrcweir 	if ( pModel->IsChanged() )
194*cdf0e10cSrcweir 	{
195*cdf0e10cSrcweir 		SdrPage* pPage = (SdrPage*) pModel->GetPage( 0 );
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 		if ( pPage )
198*cdf0e10cSrcweir 		{
199*cdf0e10cSrcweir 			const long nCount = pPage->GetObjCount();
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 			aIMap.ClearImageMap();
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 			for ( long i = nCount - 1; i > -1; i-- )
204*cdf0e10cSrcweir 				aIMap.InsertIMapObject( *( ( (IMapUserData*) pPage->GetObj( i )->GetUserData( 0 ) )->GetObject() ) );
205*cdf0e10cSrcweir 		}
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 		pModel->SetChanged( sal_False );
208*cdf0e10cSrcweir 	}
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir 	return aIMap;
211*cdf0e10cSrcweir }
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir /*************************************************************************
214*cdf0e10cSrcweir |*
215*cdf0e10cSrcweir |*
216*cdf0e10cSrcweir |*
217*cdf0e10cSrcweir \************************************************************************/
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir void IMapWindow::SetTargetList( TargetList& rTargetList )
220*cdf0e10cSrcweir {
221*cdf0e10cSrcweir 	String* pStr;
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 	// alte Liste loeschen
224*cdf0e10cSrcweir 	for( pStr = aTargetList.First(); pStr; pStr = aTargetList.Next() )
225*cdf0e10cSrcweir 		delete pStr;
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 	aTargetList.Clear();
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir 	// mit uebergebener Liste fuellen
230*cdf0e10cSrcweir 	for( pStr = rTargetList.First(); pStr; pStr = rTargetList.Next() )
231*cdf0e10cSrcweir 		aTargetList.Insert( new String( *pStr ) );
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 	pModel->SetChanged( sal_False );
234*cdf0e10cSrcweir }
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir /*************************************************************************
237*cdf0e10cSrcweir |*
238*cdf0e10cSrcweir |*
239*cdf0e10cSrcweir |*
240*cdf0e10cSrcweir \************************************************************************/
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir SdrObject* IMapWindow::CreateObj( const IMapObject* pIMapObj )
243*cdf0e10cSrcweir {
244*cdf0e10cSrcweir 	Point 		aPoint;
245*cdf0e10cSrcweir 	Rectangle 	aClipRect( aPoint, GetGraphicSize() );
246*cdf0e10cSrcweir 	SdrObject*	pSdrObj = NULL;
247*cdf0e10cSrcweir 	IMapObjectPtr pCloneIMapObj;
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 	switch( pIMapObj->GetType() )
250*cdf0e10cSrcweir 	{
251*cdf0e10cSrcweir 		case( IMAP_OBJ_RECTANGLE ):
252*cdf0e10cSrcweir 		{
253*cdf0e10cSrcweir 			IMapRectangleObject*	pIMapRectObj = (IMapRectangleObject*) pIMapObj;
254*cdf0e10cSrcweir 			Rectangle				aDrawRect( pIMapRectObj->GetRectangle( sal_False ) );
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 			// auf Zeichenflaeche clippen
257*cdf0e10cSrcweir 			aDrawRect.Intersection( aClipRect );
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 			pSdrObj = (SdrObject*) new SdrRectObj( aDrawRect );
260*cdf0e10cSrcweir 			pCloneIMapObj.reset((IMapObject*) new IMapRectangleObject( *pIMapRectObj ));
261*cdf0e10cSrcweir 		}
262*cdf0e10cSrcweir 		break;
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir 		case( IMAP_OBJ_CIRCLE ):
265*cdf0e10cSrcweir 		{
266*cdf0e10cSrcweir 			IMapCircleObject*	pIMapCircleObj = (IMapCircleObject*) pIMapObj;
267*cdf0e10cSrcweir 			const Point			aCenter( pIMapCircleObj->GetCenter( sal_False ) );
268*cdf0e10cSrcweir 			const long			nRadius = pIMapCircleObj->GetRadius( sal_False );
269*cdf0e10cSrcweir 			const Point			aOffset( nRadius, nRadius );
270*cdf0e10cSrcweir 			Rectangle			aCircle( aCenter - aOffset, aCenter + aOffset );
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir 			// auf Zeichenflaeche begrenzen
273*cdf0e10cSrcweir 			aCircle.Intersection( aClipRect );
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir 			pSdrObj = (SdrObject*) new SdrCircObj( OBJ_CIRC, aCircle, 0, 36000 );
276*cdf0e10cSrcweir 			pCloneIMapObj.reset((IMapObject*) new IMapCircleObject( *pIMapCircleObj ));
277*cdf0e10cSrcweir 		}
278*cdf0e10cSrcweir 		break;
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir 		case( IMAP_OBJ_POLYGON ):
281*cdf0e10cSrcweir 		{
282*cdf0e10cSrcweir 			IMapPolygonObject*	pIMapPolyObj = (IMapPolygonObject*) pIMapObj;
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir 			// Falls wir eigentlich eine Ellipse sind,
285*cdf0e10cSrcweir 			// erzeugen wir auch wieder eine Ellipse
286*cdf0e10cSrcweir 			if ( pIMapPolyObj->HasExtraEllipse() )
287*cdf0e10cSrcweir 			{
288*cdf0e10cSrcweir 				Rectangle aDrawRect( pIMapPolyObj->GetExtraEllipse() );
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir 				// auf Zeichenflaeche clippen
291*cdf0e10cSrcweir 				aDrawRect.Intersection( aClipRect );
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir 				pSdrObj = (SdrObject*) new SdrCircObj( OBJ_CIRC, aDrawRect, 0, 36000 );
294*cdf0e10cSrcweir 			}
295*cdf0e10cSrcweir 			else
296*cdf0e10cSrcweir 			{
297*cdf0e10cSrcweir 				const Polygon& 	rPoly = pIMapPolyObj->GetPolygon( sal_False );
298*cdf0e10cSrcweir                 Polygon         aDrawPoly( rPoly );
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir 				// auf Zeichenflaeche clippen
301*cdf0e10cSrcweir 				aDrawPoly.Clip( aClipRect );
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir 				basegfx::B2DPolygon aPolygon;
304*cdf0e10cSrcweir 				aPolygon.append(aDrawPoly.getB2DPolygon());
305*cdf0e10cSrcweir 				pSdrObj = (SdrObject*)new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aPolygon));
306*cdf0e10cSrcweir 			}
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir 			pCloneIMapObj.reset((IMapObject*) new IMapPolygonObject( *pIMapPolyObj ));
309*cdf0e10cSrcweir 		}
310*cdf0e10cSrcweir 		break;
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir 		default:
313*cdf0e10cSrcweir 		break;
314*cdf0e10cSrcweir 	}
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 	if ( pSdrObj )
317*cdf0e10cSrcweir 	{
318*cdf0e10cSrcweir 		SfxItemSet aSet( pModel->GetItemPool() );
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 		aSet.Put( XFillStyleItem( XFILL_SOLID ) );
321*cdf0e10cSrcweir 		aSet.Put( XFillColorItem( String(), TRANSCOL ) );
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 		if ( !pIMapObj->IsActive() )
324*cdf0e10cSrcweir 		{
325*cdf0e10cSrcweir 			aSet.Put( XFillTransparenceItem( 100 ) );
326*cdf0e10cSrcweir 			aSet.Put( XLineColorItem( String(), Color( COL_RED ) ) );
327*cdf0e10cSrcweir 		}
328*cdf0e10cSrcweir 		else
329*cdf0e10cSrcweir 		{
330*cdf0e10cSrcweir 			aSet.Put( XFillTransparenceItem( 50 ) );
331*cdf0e10cSrcweir 			aSet.Put( XLineColorItem( String(), Color( COL_BLACK ) ) );
332*cdf0e10cSrcweir 		}
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir 		//pSdrObj->SetItemSetAndBroadcast(aSet);
335*cdf0e10cSrcweir 		pSdrObj->SetMergedItemSetAndBroadcast(aSet);
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 		pSdrObj->InsertUserData( new IMapUserData( pCloneIMapObj ) );
338*cdf0e10cSrcweir 		pSdrObj->SetUserCall( GetSdrUserCall() );
339*cdf0e10cSrcweir 	}
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir 	return pSdrObj;
342*cdf0e10cSrcweir }
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir /*************************************************************************
345*cdf0e10cSrcweir |*
346*cdf0e10cSrcweir |*
347*cdf0e10cSrcweir |*
348*cdf0e10cSrcweir \************************************************************************/
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir void IMapWindow::InitSdrModel()
351*cdf0e10cSrcweir {
352*cdf0e10cSrcweir 	GraphCtrl::InitSdrModel();
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir 	SfxItemSet aSet( pModel->GetItemPool() );
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir 	aSet.Put( XFillColorItem( String(), TRANSCOL ) );
357*cdf0e10cSrcweir 	aSet.Put( XFillTransparenceItem( 50 ) );
358*cdf0e10cSrcweir 	pView->SetAttributes( aSet );
359*cdf0e10cSrcweir 	pView->SetFrameDragSingles( sal_True );
360*cdf0e10cSrcweir }
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir /*************************************************************************
363*cdf0e10cSrcweir |*
364*cdf0e10cSrcweir |*
365*cdf0e10cSrcweir |*
366*cdf0e10cSrcweir \************************************************************************/
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir void IMapWindow::SdrObjCreated( const SdrObject& rObj )
369*cdf0e10cSrcweir {
370*cdf0e10cSrcweir 	switch( rObj.GetObjIdentifier() )
371*cdf0e10cSrcweir 	{
372*cdf0e10cSrcweir 		case( OBJ_RECT ):
373*cdf0e10cSrcweir 		{
374*cdf0e10cSrcweir 			SdrRectObj*			 pRectObj = (SdrRectObj*) &rObj;
375*cdf0e10cSrcweir 			IMapRectangleObject* pObj = new IMapRectangleObject( pRectObj->GetLogicRect(),
376*cdf0e10cSrcweir 				String(), String(), String(), String(), String(), sal_True, sal_False );
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir 			pRectObj->InsertUserData( new IMapUserData( IMapObjectPtr(pObj) ) );
379*cdf0e10cSrcweir 		}
380*cdf0e10cSrcweir 		break;
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 		case( OBJ_CIRC ):
383*cdf0e10cSrcweir 		{
384*cdf0e10cSrcweir 			SdrCircObj* pCircObj = (SdrCircObj*) &rObj;
385*cdf0e10cSrcweir 			SdrPathObj* pPathObj = (SdrPathObj*) pCircObj->ConvertToPolyObj( sal_False, sal_False );
386*cdf0e10cSrcweir 			Polygon aPoly(pPathObj->GetPathPoly().getB2DPolygon(0L));
387*cdf0e10cSrcweir 			delete pPathObj;
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir 			IMapPolygonObject* pObj = new IMapPolygonObject( Polygon(aPoly), String(), String(), String(), String(), String(),  sal_True, sal_False );
390*cdf0e10cSrcweir 			pObj->SetExtraEllipse( aPoly.GetBoundRect() );
391*cdf0e10cSrcweir 			pCircObj->InsertUserData( new IMapUserData( IMapObjectPtr(pObj) ) );
392*cdf0e10cSrcweir 		}
393*cdf0e10cSrcweir 		break;
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir 		case( OBJ_POLY ):
396*cdf0e10cSrcweir 		case( OBJ_FREEFILL ):
397*cdf0e10cSrcweir 		case( OBJ_PATHPOLY ):
398*cdf0e10cSrcweir 		case( OBJ_PATHFILL ):
399*cdf0e10cSrcweir 		{
400*cdf0e10cSrcweir 			SdrPathObj* pPathObj = (SdrPathObj*) &rObj;
401*cdf0e10cSrcweir 			const basegfx::B2DPolyPolygon& rXPolyPoly = pPathObj->GetPathPoly();
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir 			if ( rXPolyPoly.count() )
404*cdf0e10cSrcweir 			{
405*cdf0e10cSrcweir 				Polygon aPoly(rXPolyPoly.getB2DPolygon(0L));
406*cdf0e10cSrcweir 				IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, String(), String(), String(), String(), String(),  sal_True, sal_False );
407*cdf0e10cSrcweir 				pPathObj->InsertUserData( new IMapUserData( IMapObjectPtr(pObj) ) );
408*cdf0e10cSrcweir 			}
409*cdf0e10cSrcweir 		}
410*cdf0e10cSrcweir 		break;
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir 		default:
413*cdf0e10cSrcweir 		break;
414*cdf0e10cSrcweir 	}
415*cdf0e10cSrcweir }
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir /*************************************************************************
418*cdf0e10cSrcweir |*
419*cdf0e10cSrcweir |*
420*cdf0e10cSrcweir |*
421*cdf0e10cSrcweir \************************************************************************/
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir void IMapWindow::SdrObjChanged( const SdrObject& rObj )
424*cdf0e10cSrcweir {
425*cdf0e10cSrcweir 	IMapUserData* pUserData = (IMapUserData*) rObj.GetUserData( 0 );
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir 	if ( pUserData )
428*cdf0e10cSrcweir 	{
429*cdf0e10cSrcweir 		String			aURL;
430*cdf0e10cSrcweir 		String			aAltText;
431*cdf0e10cSrcweir 		String			aDesc;
432*cdf0e10cSrcweir 		String			aTarget;
433*cdf0e10cSrcweir 		IMapObjectPtr	pIMapObj = pUserData->GetObject();
434*cdf0e10cSrcweir 		sal_Bool			bActive = sal_True;
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir 		if ( pIMapObj.get() )
437*cdf0e10cSrcweir 		{
438*cdf0e10cSrcweir 			aURL = pIMapObj->GetURL();
439*cdf0e10cSrcweir 			aAltText = pIMapObj->GetAltText();
440*cdf0e10cSrcweir 			aDesc = pIMapObj->GetDesc();
441*cdf0e10cSrcweir 			aTarget = pIMapObj->GetTarget();
442*cdf0e10cSrcweir 			bActive = pIMapObj->IsActive();
443*cdf0e10cSrcweir 		}
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir 		switch( rObj.GetObjIdentifier() )
446*cdf0e10cSrcweir 		{
447*cdf0e10cSrcweir 			case( OBJ_RECT ):
448*cdf0e10cSrcweir 			{
449*cdf0e10cSrcweir 				pUserData->ReplaceObject( IMapObjectPtr(new IMapRectangleObject( ( (const SdrRectObj&) rObj ).GetLogicRect(),
450*cdf0e10cSrcweir 						  aURL, aAltText, aDesc, aTarget, String(), bActive, sal_False ) ) );
451*cdf0e10cSrcweir 			}
452*cdf0e10cSrcweir 			break;
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir 			case( OBJ_CIRC ):
455*cdf0e10cSrcweir 			{
456*cdf0e10cSrcweir 				const SdrCircObj& rCircObj = (const SdrCircObj&) rObj;
457*cdf0e10cSrcweir 				SdrPathObj* pPathObj = (SdrPathObj*) rCircObj.ConvertToPolyObj( sal_False, sal_False );
458*cdf0e10cSrcweir 				Polygon aPoly(pPathObj->GetPathPoly().getB2DPolygon(0L));
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir 				IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, aURL, aAltText, aDesc, aTarget, String(), bActive, sal_False );
461*cdf0e10cSrcweir 				pObj->SetExtraEllipse( aPoly.GetBoundRect() );
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir 				// wurde von uns nur temporaer angelegt
464*cdf0e10cSrcweir 				delete pPathObj;
465*cdf0e10cSrcweir 				pUserData->ReplaceObject( IMapObjectPtr(pObj) );
466*cdf0e10cSrcweir 			}
467*cdf0e10cSrcweir 			break;
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir 			case( OBJ_POLY ):
470*cdf0e10cSrcweir 			case( OBJ_FREEFILL ):
471*cdf0e10cSrcweir 			case( OBJ_PATHPOLY ):
472*cdf0e10cSrcweir 			case( OBJ_PATHFILL ):
473*cdf0e10cSrcweir 			{
474*cdf0e10cSrcweir 				const SdrPathObj& rPathObj = (const SdrPathObj&) rObj;
475*cdf0e10cSrcweir 				const basegfx::B2DPolyPolygon& rXPolyPoly = rPathObj.GetPathPoly();
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir 				if ( rXPolyPoly.count() )
478*cdf0e10cSrcweir 				{
479*cdf0e10cSrcweir 					Polygon aPoly(rPathObj.GetPathPoly().getB2DPolygon(0L));
480*cdf0e10cSrcweir 					IMapPolygonObject*	pObj = new IMapPolygonObject( aPoly, aURL, aAltText, aDesc, aTarget, String(), bActive, sal_False );
481*cdf0e10cSrcweir 					pUserData->ReplaceObject( IMapObjectPtr(pObj) );
482*cdf0e10cSrcweir 				}
483*cdf0e10cSrcweir 			}
484*cdf0e10cSrcweir 			break;
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir 			default:
487*cdf0e10cSrcweir 			break;
488*cdf0e10cSrcweir 		}
489*cdf0e10cSrcweir 	}
490*cdf0e10cSrcweir }
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir /*************************************************************************
493*cdf0e10cSrcweir |*
494*cdf0e10cSrcweir |*
495*cdf0e10cSrcweir |*
496*cdf0e10cSrcweir \************************************************************************/
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir void IMapWindow::MouseButtonUp(const MouseEvent& rMEvt)
499*cdf0e10cSrcweir {
500*cdf0e10cSrcweir 	GraphCtrl::MouseButtonUp( rMEvt );
501*cdf0e10cSrcweir 	UpdateInfo( sal_True );
502*cdf0e10cSrcweir }
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir /*************************************************************************
505*cdf0e10cSrcweir |*
506*cdf0e10cSrcweir |*
507*cdf0e10cSrcweir |*
508*cdf0e10cSrcweir \************************************************************************/
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir void IMapWindow::MarkListHasChanged()
511*cdf0e10cSrcweir {
512*cdf0e10cSrcweir 	GraphCtrl::MarkListHasChanged();
513*cdf0e10cSrcweir 	UpdateInfo( sal_False );
514*cdf0e10cSrcweir }
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir /*************************************************************************
517*cdf0e10cSrcweir |*
518*cdf0e10cSrcweir |*
519*cdf0e10cSrcweir |*
520*cdf0e10cSrcweir \************************************************************************/
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir SdrObject* IMapWindow::GetHitSdrObj( const Point& rPosPixel ) const
523*cdf0e10cSrcweir {
524*cdf0e10cSrcweir 	SdrObject*	pObj = NULL;
525*cdf0e10cSrcweir 	Point		aPt = PixelToLogic( rPosPixel );
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir 	if ( Rectangle( Point(), GetGraphicSize() ).IsInside( aPt ) )
528*cdf0e10cSrcweir 	{
529*cdf0e10cSrcweir 		SdrPage* pPage = (SdrPage*) pModel->GetPage( 0 );
530*cdf0e10cSrcweir 		sal_uIntPtr	 nCount;
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir 		if ( pPage && ( ( nCount = pPage->GetObjCount() ) > 0 ) )
533*cdf0e10cSrcweir 		{
534*cdf0e10cSrcweir 			for ( long i = nCount - 1; i >= 0; i-- )
535*cdf0e10cSrcweir 			{
536*cdf0e10cSrcweir 				SdrObject*	pTestObj = pPage->GetObj( i );
537*cdf0e10cSrcweir 				IMapObject*	pIMapObj = GetIMapObj( pTestObj );
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir 				if ( pIMapObj && pIMapObj->IsHit( aPt ) )
540*cdf0e10cSrcweir 				{
541*cdf0e10cSrcweir 					pObj = pTestObj;
542*cdf0e10cSrcweir 					break;
543*cdf0e10cSrcweir 				}
544*cdf0e10cSrcweir 			}
545*cdf0e10cSrcweir 		}
546*cdf0e10cSrcweir 	}
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir 	return pObj;
549*cdf0e10cSrcweir }
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir /*************************************************************************
552*cdf0e10cSrcweir |*
553*cdf0e10cSrcweir |*
554*cdf0e10cSrcweir |*
555*cdf0e10cSrcweir \************************************************************************/
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir IMapObject* IMapWindow::GetIMapObj( const SdrObject* pSdrObj ) const
558*cdf0e10cSrcweir {
559*cdf0e10cSrcweir 	IMapObject*	pIMapObj = NULL;
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir 	if ( pSdrObj )
562*cdf0e10cSrcweir 	{
563*cdf0e10cSrcweir 		IMapUserData* pUserData = (IMapUserData*) pSdrObj->GetUserData( 0 );
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir 		if ( pUserData )
566*cdf0e10cSrcweir 			pIMapObj = pUserData->GetObject().get();
567*cdf0e10cSrcweir 	}
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir 	return pIMapObj;
570*cdf0e10cSrcweir }
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir /*************************************************************************
573*cdf0e10cSrcweir |*
574*cdf0e10cSrcweir |*
575*cdf0e10cSrcweir |*
576*cdf0e10cSrcweir \************************************************************************/
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir SdrObject* IMapWindow::GetSdrObj( const IMapObject* pIMapObj ) const
579*cdf0e10cSrcweir {
580*cdf0e10cSrcweir 	SdrObject*	pSdrObj = NULL;
581*cdf0e10cSrcweir 	SdrPage*	pPage = (SdrPage*) pModel->GetPage( 0 );
582*cdf0e10cSrcweir 	sal_uIntPtr		nCount;
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir 	if ( pPage && ( ( nCount = pPage->GetObjCount() ) > 0 ) )
585*cdf0e10cSrcweir 	{
586*cdf0e10cSrcweir 		for ( sal_uIntPtr i = 0; i < nCount; i++ )
587*cdf0e10cSrcweir 		{
588*cdf0e10cSrcweir 			SdrObject* pTestObj = pPage->GetObj( i );
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir 			if ( pIMapObj == GetIMapObj( pTestObj ) )
591*cdf0e10cSrcweir 			{
592*cdf0e10cSrcweir 				pSdrObj = pTestObj;
593*cdf0e10cSrcweir 				break;
594*cdf0e10cSrcweir 			}
595*cdf0e10cSrcweir 		}
596*cdf0e10cSrcweir 	}
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir 	return pSdrObj;
599*cdf0e10cSrcweir }
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir /*************************************************************************
602*cdf0e10cSrcweir |*
603*cdf0e10cSrcweir |*
604*cdf0e10cSrcweir |*
605*cdf0e10cSrcweir \************************************************************************/
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir void IMapWindow::Command(const CommandEvent& rCEvt)
608*cdf0e10cSrcweir {
609*cdf0e10cSrcweir 	Region  aRegion;
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir 	if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
612*cdf0e10cSrcweir 	{
613*cdf0e10cSrcweir 		PopupMenu			aMenu( SVX_RES( RID_SVXMN_IMAP ) );
614*cdf0e10cSrcweir 		const SdrMarkList&	rMarkList = pView->GetMarkedObjectList();
615*cdf0e10cSrcweir 		sal_uIntPtr				nMarked = rMarkList.GetMarkCount();
616*cdf0e10cSrcweir 
617*cdf0e10cSrcweir 		aMenu.EnableItem( MN_URL, sal_False );
618*cdf0e10cSrcweir 		aMenu.EnableItem( MN_ACTIVATE, sal_False );
619*cdf0e10cSrcweir 		aMenu.EnableItem( MN_MACRO, sal_False );
620*cdf0e10cSrcweir 		aMenu.EnableItem( MN_MARK_ALL, pModel->GetPage( 0 )->GetObjCount() != pView->GetMarkedObjectCount() );
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir 		if ( !nMarked )
623*cdf0e10cSrcweir 		{
624*cdf0e10cSrcweir 			aMenu.EnableItem( MN_POSITION, sal_False );
625*cdf0e10cSrcweir 			aMenu.EnableItem( MN_FRAME_TO_TOP, sal_False );
626*cdf0e10cSrcweir 			aMenu.EnableItem( MN_MOREFRONT, sal_False );
627*cdf0e10cSrcweir 			aMenu.EnableItem( MN_MOREBACK, sal_False );
628*cdf0e10cSrcweir 			aMenu.EnableItem( MN_FRAME_TO_BOTTOM, sal_False );
629*cdf0e10cSrcweir             aMenu.EnableItem( MN_DELETE1, sal_False );
630*cdf0e10cSrcweir 		}
631*cdf0e10cSrcweir 		else
632*cdf0e10cSrcweir 		{
633*cdf0e10cSrcweir 			if ( nMarked == 1 )
634*cdf0e10cSrcweir 			{
635*cdf0e10cSrcweir 				SdrObject*	pSdrObj = GetSelectedSdrObject();
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir 				aMenu.EnableItem( MN_URL, sal_True );
638*cdf0e10cSrcweir 				aMenu.EnableItem( MN_ACTIVATE, sal_True );
639*cdf0e10cSrcweir 				aMenu.EnableItem( MN_MACRO, sal_True );
640*cdf0e10cSrcweir 				aMenu.CheckItem( MN_ACTIVATE, GetIMapObj( pSdrObj )->IsActive() );
641*cdf0e10cSrcweir 			}
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir 			aMenu.EnableItem( MN_POSITION, sal_True );
644*cdf0e10cSrcweir 			aMenu.EnableItem( MN_FRAME_TO_TOP, sal_True );
645*cdf0e10cSrcweir 			aMenu.EnableItem( MN_MOREFRONT, sal_True );
646*cdf0e10cSrcweir 			aMenu.EnableItem( MN_MOREBACK, sal_True );
647*cdf0e10cSrcweir 			aMenu.EnableItem( MN_FRAME_TO_BOTTOM, sal_True );
648*cdf0e10cSrcweir             aMenu.EnableItem( MN_DELETE1, sal_True );
649*cdf0e10cSrcweir 		}
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir 		aMenu.SetSelectHdl( LINK( this, IMapWindow, MenuSelectHdl ) );
652*cdf0e10cSrcweir 		aMenu.Execute( this, rCEvt.GetMousePosPixel() );
653*cdf0e10cSrcweir 	}
654*cdf0e10cSrcweir 	else
655*cdf0e10cSrcweir 		Window::Command(rCEvt);
656*cdf0e10cSrcweir }
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir /*************************************************************************
659*cdf0e10cSrcweir |*
660*cdf0e10cSrcweir |*
661*cdf0e10cSrcweir |*
662*cdf0e10cSrcweir \************************************************************************/
663*cdf0e10cSrcweir 
664*cdf0e10cSrcweir sal_Int8 IMapWindow::AcceptDrop( const AcceptDropEvent& rEvt )
665*cdf0e10cSrcweir {
666*cdf0e10cSrcweir 	return( ( GetHitSdrObj( rEvt.maPosPixel ) != NULL ) ? rEvt.mnAction : DND_ACTION_NONE );
667*cdf0e10cSrcweir }
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir /*************************************************************************
670*cdf0e10cSrcweir |*
671*cdf0e10cSrcweir |*
672*cdf0e10cSrcweir |*
673*cdf0e10cSrcweir \************************************************************************/
674*cdf0e10cSrcweir 
675*cdf0e10cSrcweir sal_Int8 IMapWindow::ExecuteDrop( const ExecuteDropEvent& rEvt )
676*cdf0e10cSrcweir {
677*cdf0e10cSrcweir 	sal_Int8 nRet = DND_ACTION_NONE;
678*cdf0e10cSrcweir 
679*cdf0e10cSrcweir 	if( IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) )
680*cdf0e10cSrcweir 	{
681*cdf0e10cSrcweir 		const String	aString;
682*cdf0e10cSrcweir 		INetBookmark	aBookMark( aString, aString );
683*cdf0e10cSrcweir 		SdrObject*		pSdrObj = GetHitSdrObj( rEvt.maPosPixel );
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir 		if( pSdrObj && TransferableDataHelper( rEvt.maDropEvent.Transferable ).GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aBookMark ) )
686*cdf0e10cSrcweir 		{
687*cdf0e10cSrcweir 			IMapObject* pIMapObj = GetIMapObj( pSdrObj );
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir 			pIMapObj->SetURL( aBookMark.GetURL() );
690*cdf0e10cSrcweir 			pIMapObj->SetAltText( aBookMark.GetDescription() );
691*cdf0e10cSrcweir 			pModel->SetChanged( sal_True );
692*cdf0e10cSrcweir 			pView->UnmarkAll();
693*cdf0e10cSrcweir 			pView->MarkObj( pSdrObj, pView->GetSdrPageView() );
694*cdf0e10cSrcweir 			UpdateInfo( sal_True );
695*cdf0e10cSrcweir 			nRet =  rEvt.mnAction;
696*cdf0e10cSrcweir 		}
697*cdf0e10cSrcweir 	}
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir 	return nRet;
700*cdf0e10cSrcweir }
701*cdf0e10cSrcweir 
702*cdf0e10cSrcweir /*************************************************************************
703*cdf0e10cSrcweir |*
704*cdf0e10cSrcweir |*
705*cdf0e10cSrcweir |*
706*cdf0e10cSrcweir \************************************************************************/
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir void IMapWindow::RequestHelp( const HelpEvent& rHEvt )
709*cdf0e10cSrcweir {
710*cdf0e10cSrcweir 	SdrObject*			pSdrObj = NULL;
711*cdf0e10cSrcweir 	SdrPageView*		pPageView = NULL;
712*cdf0e10cSrcweir 	Point				aPos = PixelToLogic( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
713*cdf0e10cSrcweir 
714*cdf0e10cSrcweir 	if ( Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled() )
715*cdf0e10cSrcweir 	{
716*cdf0e10cSrcweir 		if ( pView->PickObj( aPos, pView->getHitTolLog(), pSdrObj, pPageView ) )
717*cdf0e10cSrcweir 		{
718*cdf0e10cSrcweir 			const IMapObject*	pIMapObj = GetIMapObj( pSdrObj );
719*cdf0e10cSrcweir 			String				aStr;
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir 			if ( pIMapObj && ( aStr = pIMapObj->GetURL() ).Len() )
722*cdf0e10cSrcweir 			{
723*cdf0e10cSrcweir 				String		aDescr( pIMapObj->GetAltText() );
724*cdf0e10cSrcweir 				Rectangle	aLogicPix( LogicToPixel( Rectangle( Point(), GetGraphicSize() ) ) );
725*cdf0e10cSrcweir 				Rectangle	aScreenRect( OutputToScreenPixel( aLogicPix.TopLeft() ),
726*cdf0e10cSrcweir 										 OutputToScreenPixel( aLogicPix.BottomRight() ) );
727*cdf0e10cSrcweir 
728*cdf0e10cSrcweir 				if ( Help::IsBalloonHelpEnabled() )
729*cdf0e10cSrcweir 					Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), aScreenRect, aStr );
730*cdf0e10cSrcweir 				else if ( Help::IsQuickHelpEnabled() )
731*cdf0e10cSrcweir 					Help::ShowQuickHelp( this, aScreenRect, aStr );
732*cdf0e10cSrcweir 			}
733*cdf0e10cSrcweir 		}
734*cdf0e10cSrcweir 		else
735*cdf0e10cSrcweir 			Window::RequestHelp( rHEvt );
736*cdf0e10cSrcweir 	}
737*cdf0e10cSrcweir }
738*cdf0e10cSrcweir 
739*cdf0e10cSrcweir /*************************************************************************
740*cdf0e10cSrcweir |*
741*cdf0e10cSrcweir |*
742*cdf0e10cSrcweir |*
743*cdf0e10cSrcweir \************************************************************************/
744*cdf0e10cSrcweir 
745*cdf0e10cSrcweir void IMapWindow::SetCurrentObjState( sal_Bool bActive )
746*cdf0e10cSrcweir {
747*cdf0e10cSrcweir 	SdrObject* pObj = GetSelectedSdrObject();
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir 	if ( pObj )
750*cdf0e10cSrcweir 	{
751*cdf0e10cSrcweir 		SfxItemSet aSet( pModel->GetItemPool() );
752*cdf0e10cSrcweir 
753*cdf0e10cSrcweir 		GetIMapObj( pObj )->SetActive( bActive );
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir 		aSet.Put( XFillColorItem( String(), TRANSCOL ) );
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir 		if ( !bActive )
758*cdf0e10cSrcweir 		{
759*cdf0e10cSrcweir 			aSet.Put( XFillTransparenceItem( 100 ) );
760*cdf0e10cSrcweir 			aSet.Put( XLineColorItem( String(), Color( COL_RED ) ) );
761*cdf0e10cSrcweir 		}
762*cdf0e10cSrcweir 		else
763*cdf0e10cSrcweir 		{
764*cdf0e10cSrcweir 			aSet.Put( XFillTransparenceItem( 50 ) );
765*cdf0e10cSrcweir 			aSet.Put( XLineColorItem( String(), Color( COL_BLACK ) ) );
766*cdf0e10cSrcweir 		}
767*cdf0e10cSrcweir 
768*cdf0e10cSrcweir 		pView->SetAttributes( aSet, sal_False );
769*cdf0e10cSrcweir 	}
770*cdf0e10cSrcweir }
771*cdf0e10cSrcweir 
772*cdf0e10cSrcweir /*************************************************************************
773*cdf0e10cSrcweir |*
774*cdf0e10cSrcweir |*
775*cdf0e10cSrcweir |*
776*cdf0e10cSrcweir \************************************************************************/
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir void IMapWindow::UpdateInfo( sal_Bool bNewObj )
779*cdf0e10cSrcweir {
780*cdf0e10cSrcweir 	if ( aInfoLink.IsSet() )
781*cdf0e10cSrcweir 	{
782*cdf0e10cSrcweir 		const SdrObject*	pSdrObj = GetSelectedSdrObject();
783*cdf0e10cSrcweir 		const IMapObject*	pIMapObj = pSdrObj ? GetIMapObj( pSdrObj ) : NULL;
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir 		aInfo.bNewObj = bNewObj;
786*cdf0e10cSrcweir 
787*cdf0e10cSrcweir 		if ( pIMapObj )
788*cdf0e10cSrcweir 		{
789*cdf0e10cSrcweir 			aInfo.bOneMarked = sal_True;
790*cdf0e10cSrcweir 			aInfo.aMarkURL = pIMapObj->GetURL();
791*cdf0e10cSrcweir 			aInfo.aMarkAltText = pIMapObj->GetAltText();
792*cdf0e10cSrcweir 			aInfo.aMarkTarget = pIMapObj->GetTarget();
793*cdf0e10cSrcweir 			aInfo.bActivated = pIMapObj->IsActive();
794*cdf0e10cSrcweir 			aInfoLink.Call( this );
795*cdf0e10cSrcweir 		}
796*cdf0e10cSrcweir 		else
797*cdf0e10cSrcweir 		{
798*cdf0e10cSrcweir 			aInfo.aMarkURL = aInfo.aMarkAltText = aInfo.aMarkTarget = String();
799*cdf0e10cSrcweir 			aInfo.bOneMarked = sal_False;
800*cdf0e10cSrcweir 			aInfo.bActivated = sal_False;
801*cdf0e10cSrcweir 		}
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir 		aInfoLink.Call( this );
804*cdf0e10cSrcweir 	}
805*cdf0e10cSrcweir }
806*cdf0e10cSrcweir 
807*cdf0e10cSrcweir /*************************************************************************
808*cdf0e10cSrcweir |*
809*cdf0e10cSrcweir |*
810*cdf0e10cSrcweir |*
811*cdf0e10cSrcweir \************************************************************************/
812*cdf0e10cSrcweir 
813*cdf0e10cSrcweir void IMapWindow::DoMacroAssign()
814*cdf0e10cSrcweir {
815*cdf0e10cSrcweir 	SdrObject*	pSdrObj = GetSelectedSdrObject();
816*cdf0e10cSrcweir 
817*cdf0e10cSrcweir 	if ( pSdrObj )
818*cdf0e10cSrcweir 	{
819*cdf0e10cSrcweir 		SfxItemSet		aSet( *pIMapPool, SID_ATTR_MACROITEM, SID_ATTR_MACROITEM, SID_EVENTCONFIG, SID_EVENTCONFIG, 0 );
820*cdf0e10cSrcweir 
821*cdf0e10cSrcweir 		SfxEventNamesItem aNamesItem(SID_EVENTCONFIG);
822*cdf0e10cSrcweir 		aNamesItem.AddEvent( String::CreateFromAscii( "MouseOver" ), String(), SFX_EVENT_MOUSEOVER_OBJECT );
823*cdf0e10cSrcweir 		aNamesItem.AddEvent( String::CreateFromAscii( "MouseOut" ), String(), SFX_EVENT_MOUSEOUT_OBJECT );
824*cdf0e10cSrcweir 		aSet.Put( aNamesItem );
825*cdf0e10cSrcweir 
826*cdf0e10cSrcweir         SvxMacroItem    aMacroItem(SID_ATTR_MACROITEM);
827*cdf0e10cSrcweir 		IMapObject*		pIMapObj = GetIMapObj( pSdrObj );
828*cdf0e10cSrcweir 		aMacroItem.SetMacroTable( pIMapObj->GetMacroTable() );
829*cdf0e10cSrcweir 		aSet.Put( aMacroItem, SID_ATTR_MACROITEM );
830*cdf0e10cSrcweir 
831*cdf0e10cSrcweir 		SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
832*cdf0e10cSrcweir 		SfxAbstractDialog* pMacroDlg = pFact->CreateSfxDialog( this, aSet, mxDocumentFrame, SID_EVENTCONFIG );
833*cdf0e10cSrcweir 
834*cdf0e10cSrcweir 		if ( pMacroDlg && pMacroDlg->Execute() == RET_OK )
835*cdf0e10cSrcweir 		{
836*cdf0e10cSrcweir 			const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet();
837*cdf0e10cSrcweir 			pIMapObj->SetMacroTable( ((const SvxMacroItem& )pOutSet->Get( SID_ATTR_MACROITEM )).GetMacroTable() );
838*cdf0e10cSrcweir     		pModel->SetChanged( sal_True );
839*cdf0e10cSrcweir 	        UpdateInfo( sal_False );
840*cdf0e10cSrcweir 		}
841*cdf0e10cSrcweir 
842*cdf0e10cSrcweir 		delete pMacroDlg;
843*cdf0e10cSrcweir 	}
844*cdf0e10cSrcweir }
845*cdf0e10cSrcweir 
846*cdf0e10cSrcweir /*************************************************************************
847*cdf0e10cSrcweir |*
848*cdf0e10cSrcweir |*
849*cdf0e10cSrcweir |*
850*cdf0e10cSrcweir \************************************************************************/
851*cdf0e10cSrcweir 
852*cdf0e10cSrcweir void IMapWindow::DoPropertyDialog()
853*cdf0e10cSrcweir {
854*cdf0e10cSrcweir 	SdrObject*	pSdrObj = GetSelectedSdrObject();
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir 	if ( pSdrObj )
857*cdf0e10cSrcweir 	{
858*cdf0e10cSrcweir 		IMapObject* pIMapObj = GetIMapObj( pSdrObj );
859*cdf0e10cSrcweir 		SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
860*cdf0e10cSrcweir 		if(pFact)
861*cdf0e10cSrcweir 		{
862*cdf0e10cSrcweir 			AbstractURLDlg* aDlg = pFact->CreateURLDialog( this, pIMapObj->GetURL(), pIMapObj->GetAltText(), pIMapObj->GetDesc(),
863*cdf0e10cSrcweir 											pIMapObj->GetTarget(), pIMapObj->GetName(), aTargetList );
864*cdf0e10cSrcweir 			DBG_ASSERT(aDlg, "Dialogdiet fail!");
865*cdf0e10cSrcweir 			if ( aDlg->Execute() == RET_OK )
866*cdf0e10cSrcweir 			{
867*cdf0e10cSrcweir 				const String aURLText( aDlg->GetURL() );
868*cdf0e10cSrcweir 
869*cdf0e10cSrcweir 				if ( aURLText.Len() )
870*cdf0e10cSrcweir 				{
871*cdf0e10cSrcweir                     INetURLObject aObj( aURLText, INET_PROT_FILE );
872*cdf0e10cSrcweir                     DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL" );
873*cdf0e10cSrcweir                     pIMapObj->SetURL( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
874*cdf0e10cSrcweir 				}
875*cdf0e10cSrcweir 				else
876*cdf0e10cSrcweir 					pIMapObj->SetURL( aURLText );
877*cdf0e10cSrcweir 
878*cdf0e10cSrcweir 				pIMapObj->SetAltText( aDlg->GetAltText() );
879*cdf0e10cSrcweir 				pIMapObj->SetDesc( aDlg->GetDesc() );
880*cdf0e10cSrcweir 				pIMapObj->SetTarget( aDlg->GetTarget() );
881*cdf0e10cSrcweir 				pIMapObj->SetName( aDlg->GetName() );
882*cdf0e10cSrcweir 				pModel->SetChanged( sal_True );
883*cdf0e10cSrcweir 				UpdateInfo( sal_True );
884*cdf0e10cSrcweir 			}
885*cdf0e10cSrcweir 			delete aDlg; //add by CHINA001
886*cdf0e10cSrcweir 		}
887*cdf0e10cSrcweir 	}
888*cdf0e10cSrcweir }
889*cdf0e10cSrcweir 
890*cdf0e10cSrcweir /*************************************************************************
891*cdf0e10cSrcweir |*
892*cdf0e10cSrcweir |*
893*cdf0e10cSrcweir |*
894*cdf0e10cSrcweir \************************************************************************/
895*cdf0e10cSrcweir 
896*cdf0e10cSrcweir IMPL_LINK( IMapWindow, MenuSelectHdl, Menu*, pMenu )
897*cdf0e10cSrcweir {
898*cdf0e10cSrcweir 	if (pMenu)
899*cdf0e10cSrcweir 	{
900*cdf0e10cSrcweir 		sal_uInt16  nId = pMenu->GetCurItemId();
901*cdf0e10cSrcweir 
902*cdf0e10cSrcweir 		switch(nId)
903*cdf0e10cSrcweir 		{
904*cdf0e10cSrcweir 			case( MN_URL ):
905*cdf0e10cSrcweir 				DoPropertyDialog();
906*cdf0e10cSrcweir 			break;
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir 			case( MN_MACRO ):
909*cdf0e10cSrcweir 				DoMacroAssign();
910*cdf0e10cSrcweir 			break;
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir 			case( MN_ACTIVATE ):
913*cdf0e10cSrcweir 			{
914*cdf0e10cSrcweir 				const sal_Bool bNewState = !pMenu->IsItemChecked( MN_ACTIVATE );
915*cdf0e10cSrcweir 
916*cdf0e10cSrcweir 				pMenu->CheckItem( MN_ACTIVATE, bNewState );
917*cdf0e10cSrcweir 				SetCurrentObjState( bNewState );
918*cdf0e10cSrcweir 				UpdateInfo( sal_False );
919*cdf0e10cSrcweir 			}
920*cdf0e10cSrcweir 
921*cdf0e10cSrcweir 			case( MN_FRAME_TO_TOP ):
922*cdf0e10cSrcweir 				pView->PutMarkedToTop();
923*cdf0e10cSrcweir 			break;
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir 			case( MN_MOREFRONT ):
926*cdf0e10cSrcweir 				pView->MovMarkedToTop();
927*cdf0e10cSrcweir 			break;
928*cdf0e10cSrcweir 
929*cdf0e10cSrcweir 			case( MN_MOREBACK ):
930*cdf0e10cSrcweir 				pView->MovMarkedToBtm();
931*cdf0e10cSrcweir 			break;
932*cdf0e10cSrcweir 
933*cdf0e10cSrcweir 			case( MN_FRAME_TO_BOTTOM ):
934*cdf0e10cSrcweir 				pView->PutMarkedToBtm();
935*cdf0e10cSrcweir 			break;
936*cdf0e10cSrcweir 
937*cdf0e10cSrcweir 			case( MN_MARK_ALL ):
938*cdf0e10cSrcweir 				pView->MarkAll();
939*cdf0e10cSrcweir 			break;
940*cdf0e10cSrcweir 
941*cdf0e10cSrcweir             case( MN_DELETE1 ):
942*cdf0e10cSrcweir 				pView->DeleteMarked();
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir 			default :
945*cdf0e10cSrcweir 			break;
946*cdf0e10cSrcweir 		}
947*cdf0e10cSrcweir 	}
948*cdf0e10cSrcweir 
949*cdf0e10cSrcweir 	return 0;
950*cdf0e10cSrcweir }
951*cdf0e10cSrcweir 
952*cdf0e10cSrcweir void IMapWindow::CreateDefaultObject()
953*cdf0e10cSrcweir {
954*cdf0e10cSrcweir 	SdrPageView* pPageView = pView->GetSdrPageView();
955*cdf0e10cSrcweir 
956*cdf0e10cSrcweir 	if(pPageView)
957*cdf0e10cSrcweir 	{
958*cdf0e10cSrcweir 		// calc position and size
959*cdf0e10cSrcweir 		Point aPagePos(0, 0); // = pPageView->GetOffset();
960*cdf0e10cSrcweir 		Size aPageSize = pPageView->GetPage()->GetSize();
961*cdf0e10cSrcweir 		sal_uInt32 nDefaultObjectSizeWidth = aPageSize.Width() / 4;
962*cdf0e10cSrcweir 		sal_uInt32 nDefaultObjectSizeHeight = aPageSize.Height() / 4;
963*cdf0e10cSrcweir 		aPagePos.X() += (aPageSize.Width() / 2) - (nDefaultObjectSizeWidth / 2);
964*cdf0e10cSrcweir 		aPagePos.Y() += (aPageSize.Height() / 2) - (nDefaultObjectSizeHeight / 2);
965*cdf0e10cSrcweir 		Rectangle aNewObjectRectangle(aPagePos, Size(nDefaultObjectSizeWidth, nDefaultObjectSizeHeight));
966*cdf0e10cSrcweir 
967*cdf0e10cSrcweir 		SdrObject* pObj = SdrObjFactory::MakeNewObject(	pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(), 0L, pModel);
968*cdf0e10cSrcweir 		pObj->SetLogicRect(aNewObjectRectangle);
969*cdf0e10cSrcweir 
970*cdf0e10cSrcweir 		switch( pObj->GetObjIdentifier() )
971*cdf0e10cSrcweir 		{
972*cdf0e10cSrcweir 		case OBJ_POLY:
973*cdf0e10cSrcweir 		case OBJ_PATHPOLY:
974*cdf0e10cSrcweir 			{
975*cdf0e10cSrcweir 				basegfx::B2DPolygon aInnerPoly;
976*cdf0e10cSrcweir 				aInnerPoly.append(basegfx::B2DPoint(aNewObjectRectangle.BottomLeft().X(), aNewObjectRectangle.BottomLeft().Y()));
977*cdf0e10cSrcweir 				aInnerPoly.append(basegfx::B2DPoint(aNewObjectRectangle.TopLeft().X(), aNewObjectRectangle.TopLeft().Y()));
978*cdf0e10cSrcweir 				aInnerPoly.append(basegfx::B2DPoint(aNewObjectRectangle.TopCenter().X(), aNewObjectRectangle.TopCenter().Y()));
979*cdf0e10cSrcweir 				aInnerPoly.append(basegfx::B2DPoint(aNewObjectRectangle.Center().X(), aNewObjectRectangle.Center().Y()));
980*cdf0e10cSrcweir 				aInnerPoly.append(basegfx::B2DPoint(aNewObjectRectangle.RightCenter().X(), aNewObjectRectangle.RightCenter().Y()));
981*cdf0e10cSrcweir 				aInnerPoly.append(basegfx::B2DPoint(aNewObjectRectangle.BottomRight().X(), aNewObjectRectangle.BottomRight().Y()));
982*cdf0e10cSrcweir 				aInnerPoly.setClosed(true);
983*cdf0e10cSrcweir 				((SdrPathObj*)pObj)->SetPathPoly(basegfx::B2DPolyPolygon(aInnerPoly));
984*cdf0e10cSrcweir 				break;
985*cdf0e10cSrcweir 			}
986*cdf0e10cSrcweir 		case OBJ_FREEFILL:
987*cdf0e10cSrcweir 		case OBJ_PATHFILL:
988*cdf0e10cSrcweir 			{
989*cdf0e10cSrcweir 				sal_Int32 nWdt(aNewObjectRectangle.GetWidth() / 2);
990*cdf0e10cSrcweir 				sal_Int32 nHgt(aNewObjectRectangle.GetHeight() / 2);
991*cdf0e10cSrcweir 				basegfx::B2DPolygon aInnerPoly(XPolygon(aNewObjectRectangle.Center(), nWdt, nHgt).getB2DPolygon());
992*cdf0e10cSrcweir 				((SdrPathObj*)pObj)->SetPathPoly(basegfx::B2DPolyPolygon(aInnerPoly));
993*cdf0e10cSrcweir 				break;
994*cdf0e10cSrcweir 			}
995*cdf0e10cSrcweir 
996*cdf0e10cSrcweir 		}
997*cdf0e10cSrcweir 
998*cdf0e10cSrcweir 		pView->InsertObjectAtView(pObj, *pPageView);
999*cdf0e10cSrcweir 		SdrObjCreated( *pObj );
1000*cdf0e10cSrcweir 		SetCurrentObjState( true );
1001*cdf0e10cSrcweir 		pView->MarkObj( pObj, pPageView );
1002*cdf0e10cSrcweir 	}
1003*cdf0e10cSrcweir }
1004*cdf0e10cSrcweir 
1005*cdf0e10cSrcweir void IMapWindow::KeyInput( const KeyEvent& rKEvt )
1006*cdf0e10cSrcweir {
1007*cdf0e10cSrcweir 	KeyCode aCode = rKEvt.GetKeyCode();
1008*cdf0e10cSrcweir 
1009*cdf0e10cSrcweir /*
1010*cdf0e10cSrcweir 	switch(aCode.GetCode())
1011*cdf0e10cSrcweir 	{
1012*cdf0e10cSrcweir 		case KEY_ESCAPE:
1013*cdf0e10cSrcweir 		{
1014*cdf0e10cSrcweir 			if ( pView->IsAction() )
1015*cdf0e10cSrcweir 			{
1016*cdf0e10cSrcweir 				pView->BrkAction();
1017*cdf0e10cSrcweir 				return;
1018*cdf0e10cSrcweir 			}
1019*cdf0e10cSrcweir 			else if ( pView->AreObjectsMarked() )
1020*cdf0e10cSrcweir 			{
1021*cdf0e10cSrcweir 				const SdrHdlList& rHdlList = pView->GetHdlList();
1022*cdf0e10cSrcweir 				SdrHdl* pHdl = rHdlList.GetFocusHdl();
1023*cdf0e10cSrcweir 
1024*cdf0e10cSrcweir 				if(pHdl)
1025*cdf0e10cSrcweir 				{
1026*cdf0e10cSrcweir 					((SdrHdlList&)rHdlList).ResetFocusHdl();
1027*cdf0e10cSrcweir 				}
1028*cdf0e10cSrcweir 				else
1029*cdf0e10cSrcweir 				{
1030*cdf0e10cSrcweir 					pView->UnmarkAllObj();
1031*cdf0e10cSrcweir 					((Dialog*)GetParent())->GrabFocusToFirstControl();
1032*cdf0e10cSrcweir 				}
1033*cdf0e10cSrcweir 
1034*cdf0e10cSrcweir 				return;
1035*cdf0e10cSrcweir 			}
1036*cdf0e10cSrcweir 		}
1037*cdf0e10cSrcweir 		break;
1038*cdf0e10cSrcweir 
1039*cdf0e10cSrcweir 	}
1040*cdf0e10cSrcweir */
1041*cdf0e10cSrcweir 	GraphCtrl::KeyInput( rKEvt );
1042*cdf0e10cSrcweir }
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir void IMapWindow::SelectFirstObject()
1045*cdf0e10cSrcweir {
1046*cdf0e10cSrcweir 	SdrPage*	pPage = (SdrPage*) pModel->GetPage( 0 );
1047*cdf0e10cSrcweir 	if( pPage->GetObjCount() != 0 )
1048*cdf0e10cSrcweir 	{
1049*cdf0e10cSrcweir 		GrabFocus();
1050*cdf0e10cSrcweir 		pView->UnmarkAllObj();
1051*cdf0e10cSrcweir 		pView->MarkNextObj(sal_True);
1052*cdf0e10cSrcweir 	}
1053*cdf0e10cSrcweir }
1054*cdf0e10cSrcweir 
1055*cdf0e10cSrcweir void IMapWindow::StartPolyEdit()
1056*cdf0e10cSrcweir {
1057*cdf0e10cSrcweir 	GrabFocus();
1058*cdf0e10cSrcweir 
1059*cdf0e10cSrcweir 	if( !pView->AreObjectsMarked() )
1060*cdf0e10cSrcweir 		pView->MarkNextObj(sal_True);
1061*cdf0e10cSrcweir 
1062*cdf0e10cSrcweir 	const SdrHdlList& rHdlList = pView->GetHdlList();
1063*cdf0e10cSrcweir 	SdrHdl* pHdl = rHdlList.GetFocusHdl();
1064*cdf0e10cSrcweir 
1065*cdf0e10cSrcweir 	if(!pHdl)
1066*cdf0e10cSrcweir 	{
1067*cdf0e10cSrcweir 		((SdrHdlList&)rHdlList).TravelFocusHdl(true);
1068*cdf0e10cSrcweir 	}
1069*cdf0e10cSrcweir }
1070