1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/urlobj.hxx>
21 #include <vcl/msgbox.hxx>
22 #include <vcl/help.hxx>
23 #include <sfx2/sfxsids.hrc> // SID_ATTR_MACROITEM
24 #include <svtools/imaprect.hxx>
25 #include <svtools/imapcirc.hxx>
26 #include <svtools/imappoly.hxx>
27 #include <svl/urlbmk.hxx>
29 #include <svx/xoutbmp.hxx>
30 #include <svx/dialmgr.hxx>
31 #include <svx/dialogs.hrc>
32 #include <svx/svxids.hrc>
33 #include <imapdlg.hrc>
34 #include <imapwnd.hxx>
35 #include <svx/svdpage.hxx>
36 #include <svx/svdorect.hxx>
37 #include <svx/svdocirc.hxx>
38 #include <svx/svdopath.hxx>
39 #include <svx/xfltrit.hxx>
40 #include <svx/svdpagv.hxx>
41 #include <svl/urihelper.hxx>
42 #include <svx/xfillit.hxx>
43 #include <svx/xlineit.hxx>
44 #include <sfx2/evntconf.hxx>
46 #include <sot/formats.hxx>
48 #include <svx/svxdlg.hxx>
49 #include <basegfx/point/b2dpoint.hxx>
50 #include <basegfx/polygon/b2dpolygon.hxx>
52 using ::com::sun::star::frame::XFrame
;
53 using ::com::sun::star::uno::Reference
;
55 #define TRANSCOL Color( COL_WHITE )
57 IMapWindow::IMapWindow( Window
* pParent
, const ResId
& rResId
, const Reference
< XFrame
>& rxDocumentFrame
) :
58 GraphCtrl( pParent
, rResId
),
59 DropTargetHelper( this ),
60 mxDocumentFrame( rxDocumentFrame
)
62 SetWinStyle( WB_SDRMODE
);
64 pItemInfo
= new SfxItemInfo
[ 1 ];
65 memset( pItemInfo
, 0, sizeof( SfxItemInfo
) );
66 pIMapPool
= new SfxItemPool( OUString("IMapItemPool"),
67 SID_ATTR_MACROITEM
, SID_ATTR_MACROITEM
, pItemInfo
);
68 pIMapPool
->FreezeIdRanges();
71 IMapWindow::~IMapWindow()
74 for ( size_t i
= 0, n
= aTargetList
.size(); i
< n
; ++i
)
75 delete aTargetList
[ i
];
77 SfxItemPool::Free(pIMapPool
);
81 void IMapWindow::SetImageMap( const ImageMap
& rImageMap
)
83 ReplaceImageMap( rImageMap
, sal_False
);
86 void IMapWindow::ReplaceImageMap( const ImageMap
& rImageMap
, sal_Bool
/*bScaleToGraphic*/ )
94 pPage
= GetSdrModel()->GetPage(0L);
99 // clear all draw objects
105 // #i63762# reset selection at view
106 GetSdrView()->UnmarkAllObj();
109 // create new drawing objects
110 const sal_uInt16
nCount(rImageMap
.GetIMapObjectCount());
112 for ( sal_uInt16
i(nCount
); i
> 0; i
-- )
114 SdrObject
* pNewObj
= CreateObj( rImageMap
.GetIMapObject( i
- 1 ) );
118 pPage
->InsertObject( pNewObj
);
123 sal_Bool
IMapWindow::ReplaceActualIMapInfo( const NotifyInfo
& rNewInfo
)
125 const SdrObject
* pSdrObj
= GetSelectedSdrObject();
126 IMapObject
* pIMapObj
;
127 sal_Bool bRet
= sal_False
;
129 if ( pSdrObj
&& ( ( pIMapObj
= GetIMapObj( pSdrObj
) ) != NULL
) )
131 pIMapObj
->SetURL( rNewInfo
.aMarkURL
);
132 pIMapObj
->SetAltText( rNewInfo
.aMarkAltText
);
133 pIMapObj
->SetTarget( rNewInfo
.aMarkTarget
);
134 pModel
->SetChanged( sal_True
);
135 UpdateInfo( sal_False
);
143 const ImageMap
& IMapWindow::GetImageMap()
145 if ( pModel
->IsChanged() )
147 SdrPage
* pPage
= (SdrPage
*) pModel
->GetPage( 0 );
151 const long nCount
= pPage
->GetObjCount();
153 aIMap
.ClearImageMap();
155 for ( long i
= nCount
- 1; i
> -1; i
-- )
156 aIMap
.InsertIMapObject( *( ( (IMapUserData
*) pPage
->GetObj( i
)->GetUserData( 0 ) )->GetObject() ) );
159 pModel
->SetChanged( sal_False
);
165 void IMapWindow::SetTargetList( TargetList
& rTargetList
)
168 for( size_t i
= 0, n
= aTargetList
.size(); i
< n
; ++i
)
169 delete aTargetList
[ i
];
172 // Fill with the provided list
173 for( size_t i
= 0, n
= rTargetList
.size(); i
< n
; ++i
)
174 aTargetList
.push_back( new String( *rTargetList
[ i
] ) );
176 pModel
->SetChanged( sal_False
);
179 SdrObject
* IMapWindow::CreateObj( const IMapObject
* pIMapObj
)
182 Rectangle
aClipRect( aPoint
, GetGraphicSize() );
183 SdrObject
* pSdrObj
= NULL
;
184 IMapObjectPtr pCloneIMapObj
;
186 switch( pIMapObj
->GetType() )
188 case( IMAP_OBJ_RECTANGLE
):
190 IMapRectangleObject
* pIMapRectObj
= (IMapRectangleObject
*) pIMapObj
;
191 Rectangle
aDrawRect( pIMapRectObj
->GetRectangle( sal_False
) );
193 // clipped on CanvasPane
194 aDrawRect
.Intersection( aClipRect
);
196 pSdrObj
= (SdrObject
*) new SdrRectObj( aDrawRect
);
197 pCloneIMapObj
.reset((IMapObject
*) new IMapRectangleObject( *pIMapRectObj
));
201 case( IMAP_OBJ_CIRCLE
):
203 IMapCircleObject
* pIMapCircleObj
= (IMapCircleObject
*) pIMapObj
;
204 const Point
aCenter( pIMapCircleObj
->GetCenter( sal_False
) );
205 const long nRadius
= pIMapCircleObj
->GetRadius( sal_False
);
206 const Point
aOffset( nRadius
, nRadius
);
207 Rectangle
aCircle( aCenter
- aOffset
, aCenter
+ aOffset
);
209 // limited to CanvasPane
210 aCircle
.Intersection( aClipRect
);
212 pSdrObj
= (SdrObject
*) new SdrCircObj( OBJ_CIRC
, aCircle
, 0, 36000 );
213 pCloneIMapObj
.reset((IMapObject
*) new IMapCircleObject( *pIMapCircleObj
));
217 case( IMAP_OBJ_POLYGON
):
219 IMapPolygonObject
* pIMapPolyObj
= (IMapPolygonObject
*) pIMapObj
;
221 // If it actually is an ellipse, then another ellipse is created again
222 if ( pIMapPolyObj
->HasExtraEllipse() )
224 Rectangle
aDrawRect( pIMapPolyObj
->GetExtraEllipse() );
226 // clipped on CanvasPane
227 aDrawRect
.Intersection( aClipRect
);
229 pSdrObj
= (SdrObject
*) new SdrCircObj( OBJ_CIRC
, aDrawRect
, 0, 36000 );
233 const Polygon
& rPoly
= pIMapPolyObj
->GetPolygon( sal_False
);
234 Polygon
aDrawPoly( rPoly
);
236 // clipped on CanvasPane
237 aDrawPoly
.Clip( aClipRect
);
239 basegfx::B2DPolygon aPolygon
;
240 aPolygon
.append(aDrawPoly
.getB2DPolygon());
241 pSdrObj
= (SdrObject
*)new SdrPathObj(OBJ_POLY
, basegfx::B2DPolyPolygon(aPolygon
));
244 pCloneIMapObj
.reset((IMapObject
*) new IMapPolygonObject( *pIMapPolyObj
));
254 SfxItemSet
aSet( pModel
->GetItemPool() );
256 aSet
.Put( XFillStyleItem( XFILL_SOLID
) );
257 aSet
.Put( XFillColorItem( String(), TRANSCOL
) );
259 if ( !pIMapObj
->IsActive() )
261 aSet
.Put( XFillTransparenceItem( 100 ) );
262 aSet
.Put( XLineColorItem( String(), Color( COL_RED
) ) );
266 aSet
.Put( XFillTransparenceItem( 50 ) );
267 aSet
.Put( XLineColorItem( String(), Color( COL_BLACK
) ) );
270 pSdrObj
->SetMergedItemSetAndBroadcast(aSet
);
272 pSdrObj
->AppendUserData( new IMapUserData( pCloneIMapObj
) );
273 pSdrObj
->SetUserCall( GetSdrUserCall() );
279 void IMapWindow::InitSdrModel()
281 GraphCtrl::InitSdrModel();
283 SfxItemSet
aSet( pModel
->GetItemPool() );
285 aSet
.Put( XFillColorItem( String(), TRANSCOL
) );
286 aSet
.Put( XFillTransparenceItem( 50 ) );
287 pView
->SetAttributes( aSet
);
288 pView
->SetFrameDragSingles( sal_True
);
291 void IMapWindow::SdrObjCreated( const SdrObject
& rObj
)
293 switch( rObj
.GetObjIdentifier() )
297 SdrRectObj
* pRectObj
= (SdrRectObj
*) &rObj
;
298 IMapRectangleObject
* pObj
= new IMapRectangleObject( pRectObj
->GetLogicRect(),
299 String(), String(), String(), String(), String(), sal_True
, sal_False
);
301 pRectObj
->AppendUserData( new IMapUserData( IMapObjectPtr(pObj
) ) );
307 SdrCircObj
* pCircObj
= (SdrCircObj
*) &rObj
;
308 SdrPathObj
* pPathObj
= (SdrPathObj
*) pCircObj
->ConvertToPolyObj( sal_False
, sal_False
);
309 Polygon
aPoly(pPathObj
->GetPathPoly().getB2DPolygon(0L));
312 IMapPolygonObject
* pObj
= new IMapPolygonObject( Polygon(aPoly
), String(), String(), String(), String(), String(), sal_True
, sal_False
);
313 pObj
->SetExtraEllipse( aPoly
.GetBoundRect() );
314 pCircObj
->AppendUserData( new IMapUserData( IMapObjectPtr(pObj
) ) );
319 case( OBJ_FREEFILL
):
320 case( OBJ_PATHPOLY
):
321 case( OBJ_PATHFILL
):
323 SdrPathObj
* pPathObj
= (SdrPathObj
*) &rObj
;
324 const basegfx::B2DPolyPolygon
& rXPolyPoly
= pPathObj
->GetPathPoly();
326 if ( rXPolyPoly
.count() )
328 Polygon
aPoly(rXPolyPoly
.getB2DPolygon(0L));
329 IMapPolygonObject
* pObj
= new IMapPolygonObject( aPoly
, String(), String(), String(), String(), String(), sal_True
, sal_False
);
330 pPathObj
->AppendUserData( new IMapUserData( IMapObjectPtr(pObj
) ) );
340 void IMapWindow::SdrObjChanged( const SdrObject
& rObj
)
342 IMapUserData
* pUserData
= (IMapUserData
*) rObj
.GetUserData( 0 );
350 IMapObjectPtr pIMapObj
= pUserData
->GetObject();
351 sal_Bool bActive
= sal_True
;
353 if ( pIMapObj
.get() )
355 aURL
= pIMapObj
->GetURL();
356 aAltText
= pIMapObj
->GetAltText();
357 aDesc
= pIMapObj
->GetDesc();
358 aTarget
= pIMapObj
->GetTarget();
359 bActive
= pIMapObj
->IsActive();
362 switch( rObj
.GetObjIdentifier() )
366 pUserData
->ReplaceObject( IMapObjectPtr(new IMapRectangleObject( ( (const SdrRectObj
&) rObj
).GetLogicRect(),
367 aURL
, aAltText
, aDesc
, aTarget
, String(), bActive
, sal_False
) ) );
373 const SdrCircObj
& rCircObj
= (const SdrCircObj
&) rObj
;
374 SdrPathObj
* pPathObj
= (SdrPathObj
*) rCircObj
.ConvertToPolyObj( sal_False
, sal_False
);
375 Polygon
aPoly(pPathObj
->GetPathPoly().getB2DPolygon(0L));
377 IMapPolygonObject
* pObj
= new IMapPolygonObject( aPoly
, aURL
, aAltText
, aDesc
, aTarget
, String(), bActive
, sal_False
);
378 pObj
->SetExtraEllipse( aPoly
.GetBoundRect() );
380 // was only created by us temporarily
382 pUserData
->ReplaceObject( IMapObjectPtr(pObj
) );
387 case( OBJ_FREEFILL
):
388 case( OBJ_PATHPOLY
):
389 case( OBJ_PATHFILL
):
391 const SdrPathObj
& rPathObj
= (const SdrPathObj
&) rObj
;
392 const basegfx::B2DPolyPolygon
& rXPolyPoly
= rPathObj
.GetPathPoly();
394 if ( rXPolyPoly
.count() )
396 Polygon
aPoly(rPathObj
.GetPathPoly().getB2DPolygon(0L));
397 IMapPolygonObject
* pObj
= new IMapPolygonObject( aPoly
, aURL
, aAltText
, aDesc
, aTarget
, String(), bActive
, sal_False
);
398 pUserData
->ReplaceObject( IMapObjectPtr(pObj
) );
409 void IMapWindow::MouseButtonUp(const MouseEvent
& rMEvt
)
411 GraphCtrl::MouseButtonUp( rMEvt
);
412 UpdateInfo( sal_True
);
415 void IMapWindow::MarkListHasChanged()
417 GraphCtrl::MarkListHasChanged();
418 UpdateInfo( sal_False
);
421 SdrObject
* IMapWindow::GetHitSdrObj( const Point
& rPosPixel
) const
423 SdrObject
* pObj
= NULL
;
424 Point aPt
= PixelToLogic( rPosPixel
);
426 if ( Rectangle( Point(), GetGraphicSize() ).IsInside( aPt
) )
428 SdrPage
* pPage
= (SdrPage
*) pModel
->GetPage( 0 );
431 if ( pPage
&& ( ( nCount
= pPage
->GetObjCount() ) > 0 ) )
433 for ( long i
= nCount
- 1; i
>= 0; i
-- )
435 SdrObject
* pTestObj
= pPage
->GetObj( i
);
436 IMapObject
* pIMapObj
= GetIMapObj( pTestObj
);
438 if ( pIMapObj
&& pIMapObj
->IsHit( aPt
) )
450 IMapObject
* IMapWindow::GetIMapObj( const SdrObject
* pSdrObj
) const
452 IMapObject
* pIMapObj
= NULL
;
456 IMapUserData
* pUserData
= (IMapUserData
*) pSdrObj
->GetUserData( 0 );
459 pIMapObj
= pUserData
->GetObject().get();
465 void IMapWindow::Command(const CommandEvent
& rCEvt
)
469 if ( rCEvt
.GetCommand() == COMMAND_CONTEXTMENU
)
471 PopupMenu
aMenu( SVX_RES( RID_SVXMN_IMAP
) );
472 const SdrMarkList
& rMarkList
= pView
->GetMarkedObjectList();
473 sal_uIntPtr nMarked
= rMarkList
.GetMarkCount();
475 aMenu
.EnableItem( MN_URL
, sal_False
);
476 aMenu
.EnableItem( MN_ACTIVATE
, sal_False
);
477 aMenu
.EnableItem( MN_MACRO
, sal_False
);
478 aMenu
.EnableItem( MN_MARK_ALL
, pModel
->GetPage( 0 )->GetObjCount() != pView
->GetMarkedObjectCount() );
482 aMenu
.EnableItem( MN_POSITION
, sal_False
);
483 aMenu
.EnableItem( MN_FRAME_TO_TOP
, sal_False
);
484 aMenu
.EnableItem( MN_MOREFRONT
, sal_False
);
485 aMenu
.EnableItem( MN_MOREBACK
, sal_False
);
486 aMenu
.EnableItem( MN_FRAME_TO_BOTTOM
, sal_False
);
487 aMenu
.EnableItem( MN_DELETE1
, sal_False
);
493 SdrObject
* pSdrObj
= GetSelectedSdrObject();
495 aMenu
.EnableItem( MN_URL
, sal_True
);
496 aMenu
.EnableItem( MN_ACTIVATE
, sal_True
);
497 aMenu
.EnableItem( MN_MACRO
, sal_True
);
498 aMenu
.CheckItem( MN_ACTIVATE
, GetIMapObj( pSdrObj
)->IsActive() );
501 aMenu
.EnableItem( MN_POSITION
, sal_True
);
502 aMenu
.EnableItem( MN_FRAME_TO_TOP
, sal_True
);
503 aMenu
.EnableItem( MN_MOREFRONT
, sal_True
);
504 aMenu
.EnableItem( MN_MOREBACK
, sal_True
);
505 aMenu
.EnableItem( MN_FRAME_TO_BOTTOM
, sal_True
);
506 aMenu
.EnableItem( MN_DELETE1
, sal_True
);
509 aMenu
.SetSelectHdl( LINK( this, IMapWindow
, MenuSelectHdl
) );
510 aMenu
.Execute( this, rCEvt
.GetMousePosPixel() );
513 Window::Command(rCEvt
);
516 sal_Int8
IMapWindow::AcceptDrop( const AcceptDropEvent
& rEvt
)
518 return( ( GetHitSdrObj( rEvt
.maPosPixel
) != NULL
) ? rEvt
.mnAction
: DND_ACTION_NONE
);
521 sal_Int8
IMapWindow::ExecuteDrop( const ExecuteDropEvent
& rEvt
)
523 sal_Int8 nRet
= DND_ACTION_NONE
;
525 if( IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
) )
527 const String aString
;
528 INetBookmark
aBookMark( aString
, aString
);
529 SdrObject
* pSdrObj
= GetHitSdrObj( rEvt
.maPosPixel
);
531 if( pSdrObj
&& TransferableDataHelper( rEvt
.maDropEvent
.Transferable
).GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
, aBookMark
) )
533 IMapObject
* pIMapObj
= GetIMapObj( pSdrObj
);
535 pIMapObj
->SetURL( aBookMark
.GetURL() );
536 pIMapObj
->SetAltText( aBookMark
.GetDescription() );
537 pModel
->SetChanged( sal_True
);
539 pView
->MarkObj( pSdrObj
, pView
->GetSdrPageView() );
540 UpdateInfo( sal_True
);
541 nRet
= rEvt
.mnAction
;
548 void IMapWindow::RequestHelp( const HelpEvent
& rHEvt
)
550 Point aPos
= PixelToLogic( ScreenToOutputPixel( rHEvt
.GetMousePosPixel() ) );
552 if ( Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled() )
554 SdrObject
* pSdrObj
= NULL
;
555 SdrPageView
* pPageView
= NULL
;
556 if ( pView
->PickObj( aPos
, pView
->getHitTolLog(), pSdrObj
, pPageView
) )
558 const IMapObject
* pIMapObj
= GetIMapObj( pSdrObj
);
561 if ( pIMapObj
&& ( aStr
= pIMapObj
->GetURL() ).Len() )
563 Rectangle
aLogicPix( LogicToPixel( Rectangle( Point(), GetGraphicSize() ) ) );
564 Rectangle
aScreenRect( OutputToScreenPixel( aLogicPix
.TopLeft() ),
565 OutputToScreenPixel( aLogicPix
.BottomRight() ) );
567 if ( Help::IsBalloonHelpEnabled() )
568 Help::ShowBalloon( this, rHEvt
.GetMousePosPixel(), aScreenRect
, aStr
);
569 else if ( Help::IsQuickHelpEnabled() )
570 Help::ShowQuickHelp( this, aScreenRect
, aStr
);
574 Window::RequestHelp( rHEvt
);
578 void IMapWindow::SetCurrentObjState( sal_Bool bActive
)
580 SdrObject
* pObj
= GetSelectedSdrObject();
584 SfxItemSet
aSet( pModel
->GetItemPool() );
586 GetIMapObj( pObj
)->SetActive( bActive
);
588 aSet
.Put( XFillColorItem( String(), TRANSCOL
) );
592 aSet
.Put( XFillTransparenceItem( 100 ) );
593 aSet
.Put( XLineColorItem( String(), Color( COL_RED
) ) );
597 aSet
.Put( XFillTransparenceItem( 50 ) );
598 aSet
.Put( XLineColorItem( String(), Color( COL_BLACK
) ) );
601 pView
->SetAttributes( aSet
, sal_False
);
605 void IMapWindow::UpdateInfo( sal_Bool bNewObj
)
607 if ( aInfoLink
.IsSet() )
609 const SdrObject
* pSdrObj
= GetSelectedSdrObject();
610 const IMapObject
* pIMapObj
= pSdrObj
? GetIMapObj( pSdrObj
) : NULL
;
612 aInfo
.bNewObj
= bNewObj
;
616 aInfo
.bOneMarked
= sal_True
;
617 aInfo
.aMarkURL
= pIMapObj
->GetURL();
618 aInfo
.aMarkAltText
= pIMapObj
->GetAltText();
619 aInfo
.aMarkTarget
= pIMapObj
->GetTarget();
620 aInfo
.bActivated
= pIMapObj
->IsActive();
621 aInfoLink
.Call( this );
625 aInfo
.aMarkURL
= aInfo
.aMarkAltText
= aInfo
.aMarkTarget
= String();
626 aInfo
.bOneMarked
= sal_False
;
627 aInfo
.bActivated
= sal_False
;
630 aInfoLink
.Call( this );
634 void IMapWindow::DoMacroAssign()
636 SdrObject
* pSdrObj
= GetSelectedSdrObject();
640 SfxItemSet
aSet( *pIMapPool
, SID_ATTR_MACROITEM
, SID_ATTR_MACROITEM
, SID_EVENTCONFIG
, SID_EVENTCONFIG
, 0 );
642 SfxEventNamesItem
aNamesItem(SID_EVENTCONFIG
);
643 aNamesItem
.AddEvent( OUString("MouseOver"), String(), SFX_EVENT_MOUSEOVER_OBJECT
);
644 aNamesItem
.AddEvent( OUString("MouseOut"), String(), SFX_EVENT_MOUSEOUT_OBJECT
);
645 aSet
.Put( aNamesItem
);
647 SvxMacroItem
aMacroItem(SID_ATTR_MACROITEM
);
648 IMapObject
* pIMapObj
= GetIMapObj( pSdrObj
);
649 aMacroItem
.SetMacroTable( pIMapObj
->GetMacroTable() );
650 aSet
.Put( aMacroItem
, SID_ATTR_MACROITEM
);
652 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
653 SfxAbstractDialog
* pMacroDlg
= pFact
->CreateSfxDialog( this, aSet
, mxDocumentFrame
, SID_EVENTCONFIG
);
655 if ( pMacroDlg
&& pMacroDlg
->Execute() == RET_OK
)
657 const SfxItemSet
* pOutSet
= pMacroDlg
->GetOutputItemSet();
658 pIMapObj
->SetMacroTable( ((const SvxMacroItem
& )pOutSet
->Get( SID_ATTR_MACROITEM
)).GetMacroTable() );
659 pModel
->SetChanged( sal_True
);
660 UpdateInfo( sal_False
);
667 void IMapWindow::DoPropertyDialog()
669 SdrObject
* pSdrObj
= GetSelectedSdrObject();
673 IMapObject
* pIMapObj
= GetIMapObj( pSdrObj
);
674 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
677 AbstractURLDlg
* aDlg
= pFact
->CreateURLDialog( this, pIMapObj
->GetURL(), pIMapObj
->GetAltText(), pIMapObj
->GetDesc(),
678 pIMapObj
->GetTarget(), pIMapObj
->GetName(), aTargetList
);
679 DBG_ASSERT(aDlg
, "Dialogdiet fail!");
680 if ( aDlg
->Execute() == RET_OK
)
682 const String
aURLText( aDlg
->GetURL() );
684 if ( aURLText
.Len() )
686 INetURLObject
aObj( aURLText
, INET_PROT_FILE
);
687 DBG_ASSERT( aObj
.GetProtocol() != INET_PROT_NOT_VALID
, "Invalid URL" );
688 pIMapObj
->SetURL( aObj
.GetMainURL( INetURLObject::NO_DECODE
) );
691 pIMapObj
->SetURL( aURLText
);
693 pIMapObj
->SetAltText( aDlg
->GetAltText() );
694 pIMapObj
->SetDesc( aDlg
->GetDesc() );
695 pIMapObj
->SetTarget( aDlg
->GetTarget() );
696 pIMapObj
->SetName( aDlg
->GetName() );
697 pModel
->SetChanged( sal_True
);
698 UpdateInfo( sal_True
);
705 IMPL_LINK( IMapWindow
, MenuSelectHdl
, Menu
*, pMenu
)
709 sal_uInt16 nId
= pMenu
->GetCurItemId();
723 const sal_Bool bNewState
= !pMenu
->IsItemChecked( MN_ACTIVATE
);
725 pMenu
->CheckItem( MN_ACTIVATE
, bNewState
);
726 SetCurrentObjState( bNewState
);
727 UpdateInfo( sal_False
);
730 case( MN_FRAME_TO_TOP
):
731 pView
->PutMarkedToTop();
734 case( MN_MOREFRONT
):
735 pView
->MovMarkedToTop();
739 pView
->MovMarkedToBtm();
742 case( MN_FRAME_TO_BOTTOM
):
743 pView
->PutMarkedToBtm();
751 pView
->DeleteMarked();
761 void IMapWindow::CreateDefaultObject()
763 SdrPageView
* pPageView
= pView
->GetSdrPageView();
767 // calc position and size
768 Point
aPagePos(0, 0); // = pPageView->GetOffset();
769 Size aPageSize
= pPageView
->GetPage()->GetSize();
770 sal_uInt32 nDefaultObjectSizeWidth
= aPageSize
.Width() / 4;
771 sal_uInt32 nDefaultObjectSizeHeight
= aPageSize
.Height() / 4;
772 aPagePos
.X() += (aPageSize
.Width() / 2) - (nDefaultObjectSizeWidth
/ 2);
773 aPagePos
.Y() += (aPageSize
.Height() / 2) - (nDefaultObjectSizeHeight
/ 2);
774 Rectangle
aNewObjectRectangle(aPagePos
, Size(nDefaultObjectSizeWidth
, nDefaultObjectSizeHeight
));
776 SdrObject
* pObj
= SdrObjFactory::MakeNewObject( pView
->GetCurrentObjInventor(), pView
->GetCurrentObjIdentifier(), 0L, pModel
);
777 pObj
->SetLogicRect(aNewObjectRectangle
);
779 switch( pObj
->GetObjIdentifier() )
784 basegfx::B2DPolygon aInnerPoly
;
785 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.BottomLeft().X(), aNewObjectRectangle
.BottomLeft().Y()));
786 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.TopLeft().X(), aNewObjectRectangle
.TopLeft().Y()));
787 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.TopCenter().X(), aNewObjectRectangle
.TopCenter().Y()));
788 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.Center().X(), aNewObjectRectangle
.Center().Y()));
789 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.RightCenter().X(), aNewObjectRectangle
.RightCenter().Y()));
790 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.BottomRight().X(), aNewObjectRectangle
.BottomRight().Y()));
791 aInnerPoly
.setClosed(true);
792 ((SdrPathObj
*)pObj
)->SetPathPoly(basegfx::B2DPolyPolygon(aInnerPoly
));
798 sal_Int32
nWdt(aNewObjectRectangle
.GetWidth() / 2);
799 sal_Int32
nHgt(aNewObjectRectangle
.GetHeight() / 2);
800 basegfx::B2DPolygon
aInnerPoly(XPolygon(aNewObjectRectangle
.Center(), nWdt
, nHgt
).getB2DPolygon());
801 ((SdrPathObj
*)pObj
)->SetPathPoly(basegfx::B2DPolyPolygon(aInnerPoly
));
807 pView
->InsertObjectAtView(pObj
, *pPageView
);
808 SdrObjCreated( *pObj
);
809 SetCurrentObjState( true );
810 pView
->MarkObj( pObj
, pPageView
);
814 void IMapWindow::KeyInput( const KeyEvent
& rKEvt
)
816 GraphCtrl::KeyInput( rKEvt
);
819 void IMapWindow::SelectFirstObject()
821 SdrPage
* pPage
= (SdrPage
*) pModel
->GetPage( 0 );
822 if( pPage
->GetObjCount() != 0 )
825 pView
->UnmarkAllObj();
826 pView
->MarkNextObj(sal_True
);
830 void IMapWindow::StartPolyEdit()
834 if( !pView
->AreObjectsMarked() )
835 pView
->MarkNextObj(sal_True
);
837 const SdrHdlList
& rHdlList
= pView
->GetHdlList();
838 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
842 ((SdrHdlList
&)rHdlList
).TravelFocusHdl(true);
846 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */