1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: imapwnd.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <tools/urlobj.hxx>
34 #include <vcl/msgbox.hxx>
35 #include <vcl/help.hxx>
36 #include <sfx2/sfxsids.hrc> // SID_ATTR_MACROITEM
38 #include <svtools/imaprect.hxx>
39 #include <svtools/imapcirc.hxx>
40 #include <svtools/imappoly.hxx>
41 #include <svtools/urlbmk.hxx>
43 #include <xoutbmp.hxx>
44 #include <svx/dialmgr.hxx>
45 #include <svx/dialogs.hrc>
46 #include <svx/svxids.hrc>
47 #include <imapdlg.hrc>
48 #include <imapwnd.hxx>
49 #include <svx/svdpage.hxx>
50 #include <svx/svdorect.hxx>
51 #include <svx/svdocirc.hxx>
52 #include <svx/svdopath.hxx>
53 #include <svx/xfltrit.hxx>
54 #include <svx/svdpagv.hxx>
55 #include <svtools/urihelper.hxx>
56 #include <svx/xfillit.hxx>
57 #include <svx/xlineit.hxx>
58 #include <sfx2/evntconf.hxx>
60 #include <sot/formats.hxx>
62 #include <svx/svxdlg.hxx>
63 #include <svx/dialogs.hrc>
64 #include <basegfx/point/b2dpoint.hxx>
65 #include <basegfx/polygon/b2dpolygon.hxx>
67 using ::com::sun::star::frame::XFrame
;
68 using ::com::sun::star::uno::Reference
;
70 #define TRANSCOL Color( COL_WHITE )
72 /*************************************************************************
76 \************************************************************************/
78 IMapWindow::IMapWindow( Window
* pParent
, const ResId
& rResId
, const Reference
< XFrame
>& rxDocumentFrame
) :
79 GraphCtrl( pParent
, rResId
),
80 DropTargetHelper( this ),
81 mxDocumentFrame( rxDocumentFrame
)
83 SetWinStyle( WB_SDRMODE
);
85 pItemInfo
= new SfxItemInfo
[ 1 ];
86 memset( pItemInfo
, 0, sizeof( SfxItemInfo
) );
87 pIMapPool
= new SfxItemPool( String::CreateFromAscii( "IMapItemPool" ),
88 SID_ATTR_MACROITEM
, SID_ATTR_MACROITEM
, pItemInfo
);
89 pIMapPool
->FreezeIdRanges();
92 /*************************************************************************
96 \************************************************************************/
98 IMapWindow::~IMapWindow()
101 for( String
* pStr
= aTargetList
.First(); pStr
; pStr
= aTargetList
.Next() )
104 SfxItemPool::Free(pIMapPool
);
108 /*************************************************************************
112 \************************************************************************/
114 void IMapWindow::SetImageMap( const ImageMap
& rImageMap
)
116 ReplaceImageMap( rImageMap
, FALSE
);
119 /*************************************************************************
123 \************************************************************************/
125 void IMapWindow::ReplaceImageMap( const ImageMap
& rImageMap
, BOOL
/*bScaleToGraphic*/ )
132 // try to access page
133 pPage
= GetSdrModel()->GetPage(0L);
138 // clear all draw objects
144 // #i63762# reset selection at view
145 GetSdrView()->UnmarkAllObj();
148 // create new drawing objects
149 const USHORT
nCount(rImageMap
.GetIMapObjectCount());
151 for ( USHORT
i(nCount
); i
> 0; i
-- )
153 SdrObject
* pNewObj
= CreateObj( rImageMap
.GetIMapObject( i
- 1 ) );
157 pPage
->InsertObject( pNewObj
);
162 /*************************************************************************
166 \************************************************************************/
168 BOOL
IMapWindow::ReplaceActualIMapInfo( const NotifyInfo
& rNewInfo
)
170 const SdrObject
* pSdrObj
= GetSelectedSdrObject();
171 IMapObject
* pIMapObj
;
174 if ( pSdrObj
&& ( ( pIMapObj
= GetIMapObj( pSdrObj
) ) != NULL
) )
176 pIMapObj
->SetURL( rNewInfo
.aMarkURL
);
177 pIMapObj
->SetAltText( rNewInfo
.aMarkAltText
);
178 pIMapObj
->SetTarget( rNewInfo
.aMarkTarget
);
179 pModel
->SetChanged( sal_True
);
188 /*************************************************************************
192 \************************************************************************/
194 const ImageMap
& IMapWindow::GetImageMap()
196 if ( pModel
->IsChanged() )
198 SdrPage
* pPage
= (SdrPage
*) pModel
->GetPage( 0 );
202 const long nCount
= pPage
->GetObjCount();
204 aIMap
.ClearImageMap();
206 for ( long i
= nCount
- 1; i
> -1; i
-- )
207 aIMap
.InsertIMapObject( *( ( (IMapUserData
*) pPage
->GetObj( i
)->GetUserData( 0 ) )->GetObject() ) );
210 pModel
->SetChanged( sal_False
);
216 /*************************************************************************
220 \************************************************************************/
222 void IMapWindow::SetTargetList( TargetList
& rTargetList
)
226 // alte Liste loeschen
227 for( pStr
= aTargetList
.First(); pStr
; pStr
= aTargetList
.Next() )
232 // mit uebergebener Liste fuellen
233 for( pStr
= rTargetList
.First(); pStr
; pStr
= rTargetList
.Next() )
234 aTargetList
.Insert( new String( *pStr
) );
236 pModel
->SetChanged( sal_False
);
239 /*************************************************************************
243 \************************************************************************/
245 SdrObject
* IMapWindow::CreateObj( const IMapObject
* pIMapObj
)
248 Rectangle
aClipRect( aPoint
, GetGraphicSize() );
249 SdrObject
* pSdrObj
= NULL
;
250 IMapObjectPtr pCloneIMapObj
;
252 switch( pIMapObj
->GetType() )
254 case( IMAP_OBJ_RECTANGLE
):
256 IMapRectangleObject
* pIMapRectObj
= (IMapRectangleObject
*) pIMapObj
;
257 Rectangle
aDrawRect( pIMapRectObj
->GetRectangle( FALSE
) );
259 // auf Zeichenflaeche clippen
260 aDrawRect
.Intersection( aClipRect
);
262 pSdrObj
= (SdrObject
*) new SdrRectObj( aDrawRect
);
263 pCloneIMapObj
.reset((IMapObject
*) new IMapRectangleObject( *pIMapRectObj
));
267 case( IMAP_OBJ_CIRCLE
):
269 IMapCircleObject
* pIMapCircleObj
= (IMapCircleObject
*) pIMapObj
;
270 const Point
aCenter( pIMapCircleObj
->GetCenter( FALSE
) );
271 const long nRadius
= pIMapCircleObj
->GetRadius( FALSE
);
272 const Point
aOffset( nRadius
, nRadius
);
273 Rectangle
aCircle( aCenter
- aOffset
, aCenter
+ aOffset
);
275 // auf Zeichenflaeche begrenzen
276 aCircle
.Intersection( aClipRect
);
278 pSdrObj
= (SdrObject
*) new SdrCircObj( OBJ_CIRC
, aCircle
, 0, 36000 );
279 pCloneIMapObj
.reset((IMapObject
*) new IMapCircleObject( *pIMapCircleObj
));
283 case( IMAP_OBJ_POLYGON
):
285 IMapPolygonObject
* pIMapPolyObj
= (IMapPolygonObject
*) pIMapObj
;
287 // Falls wir eigentlich eine Ellipse sind,
288 // erzeugen wir auch wieder eine Ellipse
289 if ( pIMapPolyObj
->HasExtraEllipse() )
291 Rectangle
aDrawRect( pIMapPolyObj
->GetExtraEllipse() );
293 // auf Zeichenflaeche clippen
294 aDrawRect
.Intersection( aClipRect
);
296 pSdrObj
= (SdrObject
*) new SdrCircObj( OBJ_CIRC
, aDrawRect
, 0, 36000 );
300 const Polygon
& rPoly
= pIMapPolyObj
->GetPolygon( FALSE
);
301 Polygon
aDrawPoly( rPoly
);
303 // auf Zeichenflaeche clippen
304 aDrawPoly
.Clip( aClipRect
);
306 basegfx::B2DPolygon aPolygon
;
307 aPolygon
.append(aDrawPoly
.getB2DPolygon());
308 pSdrObj
= (SdrObject
*)new SdrPathObj(OBJ_POLY
, basegfx::B2DPolyPolygon(aPolygon
));
311 pCloneIMapObj
.reset((IMapObject
*) new IMapPolygonObject( *pIMapPolyObj
));
321 SfxItemSet
aSet( pModel
->GetItemPool() );
323 aSet
.Put( XFillStyleItem( XFILL_SOLID
) );
324 aSet
.Put( XFillColorItem( String(), TRANSCOL
) );
326 if ( !pIMapObj
->IsActive() )
328 aSet
.Put( XFillTransparenceItem( 100 ) );
329 aSet
.Put( XLineColorItem( String(), Color( COL_RED
) ) );
333 aSet
.Put( XFillTransparenceItem( 50 ) );
334 aSet
.Put( XLineColorItem( String(), Color( COL_BLACK
) ) );
337 //pSdrObj->SetItemSetAndBroadcast(aSet);
338 pSdrObj
->SetMergedItemSetAndBroadcast(aSet
);
340 pSdrObj
->InsertUserData( new IMapUserData( pCloneIMapObj
) );
341 pSdrObj
->SetUserCall( GetSdrUserCall() );
347 /*************************************************************************
351 \************************************************************************/
353 void IMapWindow::InitSdrModel()
355 GraphCtrl::InitSdrModel();
357 SfxItemSet
aSet( pModel
->GetItemPool() );
359 aSet
.Put( XFillColorItem( String(), TRANSCOL
) );
360 aSet
.Put( XFillTransparenceItem( 50 ) );
361 pView
->SetAttributes( aSet
);
362 pView
->SetFrameDragSingles( TRUE
);
365 /*************************************************************************
369 \************************************************************************/
371 void IMapWindow::SdrObjCreated( const SdrObject
& rObj
)
373 switch( rObj
.GetObjIdentifier() )
377 SdrRectObj
* pRectObj
= (SdrRectObj
*) &rObj
;
378 IMapRectangleObject
* pObj
= new IMapRectangleObject( pRectObj
->GetLogicRect(),
379 String(), String(), String(), String(), String(), TRUE
, FALSE
);
381 pRectObj
->InsertUserData( new IMapUserData( IMapObjectPtr(pObj
) ) );
387 SdrCircObj
* pCircObj
= (SdrCircObj
*) &rObj
;
388 SdrPathObj
* pPathObj
= (SdrPathObj
*) pCircObj
->ConvertToPolyObj( FALSE
, FALSE
);
389 Polygon
aPoly(pPathObj
->GetPathPoly().getB2DPolygon(0L));
392 IMapPolygonObject
* pObj
= new IMapPolygonObject( Polygon(aPoly
), String(), String(), String(), String(), String(), TRUE
, FALSE
);
393 pObj
->SetExtraEllipse( aPoly
.GetBoundRect() );
394 pCircObj
->InsertUserData( new IMapUserData( IMapObjectPtr(pObj
) ) );
399 case( OBJ_FREEFILL
):
400 case( OBJ_PATHPOLY
):
401 case( OBJ_PATHFILL
):
403 SdrPathObj
* pPathObj
= (SdrPathObj
*) &rObj
;
404 const basegfx::B2DPolyPolygon
& rXPolyPoly
= pPathObj
->GetPathPoly();
406 if ( rXPolyPoly
.count() )
408 Polygon
aPoly(rXPolyPoly
.getB2DPolygon(0L));
409 IMapPolygonObject
* pObj
= new IMapPolygonObject( aPoly
, String(), String(), String(), String(), String(), TRUE
, FALSE
);
410 pPathObj
->InsertUserData( new IMapUserData( IMapObjectPtr(pObj
) ) );
420 /*************************************************************************
424 \************************************************************************/
426 void IMapWindow::SdrObjChanged( const SdrObject
& rObj
)
428 IMapUserData
* pUserData
= (IMapUserData
*) rObj
.GetUserData( 0 );
436 IMapObjectPtr pIMapObj
= pUserData
->GetObject();
439 if ( pIMapObj
.get() )
441 aURL
= pIMapObj
->GetURL();
442 aAltText
= pIMapObj
->GetAltText();
443 aDesc
= pIMapObj
->GetDesc();
444 aTarget
= pIMapObj
->GetTarget();
445 bActive
= pIMapObj
->IsActive();
448 switch( rObj
.GetObjIdentifier() )
452 pUserData
->ReplaceObject( IMapObjectPtr(new IMapRectangleObject( ( (const SdrRectObj
&) rObj
).GetLogicRect(),
453 aURL
, aAltText
, aDesc
, aTarget
, String(), bActive
, FALSE
) ) );
459 const SdrCircObj
& rCircObj
= (const SdrCircObj
&) rObj
;
460 SdrPathObj
* pPathObj
= (SdrPathObj
*) rCircObj
.ConvertToPolyObj( FALSE
, FALSE
);
461 Polygon
aPoly(pPathObj
->GetPathPoly().getB2DPolygon(0L));
463 IMapPolygonObject
* pObj
= new IMapPolygonObject( aPoly
, aURL
, aAltText
, aDesc
, aTarget
, String(), bActive
, FALSE
);
464 pObj
->SetExtraEllipse( aPoly
.GetBoundRect() );
466 // wurde von uns nur temporaer angelegt
468 pUserData
->ReplaceObject( IMapObjectPtr(pObj
) );
473 case( OBJ_FREEFILL
):
474 case( OBJ_PATHPOLY
):
475 case( OBJ_PATHFILL
):
477 const SdrPathObj
& rPathObj
= (const SdrPathObj
&) rObj
;
478 const basegfx::B2DPolyPolygon
& rXPolyPoly
= rPathObj
.GetPathPoly();
480 if ( rXPolyPoly
.count() )
482 Polygon
aPoly(rPathObj
.GetPathPoly().getB2DPolygon(0L));
483 IMapPolygonObject
* pObj
= new IMapPolygonObject( aPoly
, aURL
, aAltText
, aDesc
, aTarget
, String(), bActive
, FALSE
);
484 pUserData
->ReplaceObject( IMapObjectPtr(pObj
) );
495 /*************************************************************************
499 \************************************************************************/
501 void IMapWindow::MouseButtonUp(const MouseEvent
& rMEvt
)
503 GraphCtrl::MouseButtonUp( rMEvt
);
507 /*************************************************************************
511 \************************************************************************/
513 void IMapWindow::MarkListHasChanged()
515 GraphCtrl::MarkListHasChanged();
519 /*************************************************************************
523 \************************************************************************/
525 SdrObject
* IMapWindow::GetHitSdrObj( const Point
& rPosPixel
) const
527 SdrObject
* pObj
= NULL
;
528 Point aPt
= PixelToLogic( rPosPixel
);
530 if ( Rectangle( Point(), GetGraphicSize() ).IsInside( aPt
) )
532 SdrPage
* pPage
= (SdrPage
*) pModel
->GetPage( 0 );
535 if ( pPage
&& ( ( nCount
= pPage
->GetObjCount() ) > 0 ) )
537 for ( long i
= nCount
- 1; i
>= 0; i
-- )
539 SdrObject
* pTestObj
= pPage
->GetObj( i
);
540 IMapObject
* pIMapObj
= GetIMapObj( pTestObj
);
542 if ( pIMapObj
&& pIMapObj
->IsHit( aPt
) )
554 /*************************************************************************
558 \************************************************************************/
560 IMapObject
* IMapWindow::GetIMapObj( const SdrObject
* pSdrObj
) const
562 IMapObject
* pIMapObj
= NULL
;
566 IMapUserData
* pUserData
= (IMapUserData
*) pSdrObj
->GetUserData( 0 );
569 pIMapObj
= pUserData
->GetObject().get();
575 /*************************************************************************
579 \************************************************************************/
581 SdrObject
* IMapWindow::GetSdrObj( const IMapObject
* pIMapObj
) const
583 SdrObject
* pSdrObj
= NULL
;
584 SdrPage
* pPage
= (SdrPage
*) pModel
->GetPage( 0 );
587 if ( pPage
&& ( ( nCount
= pPage
->GetObjCount() ) > 0 ) )
589 for ( ULONG i
= 0; i
< nCount
; i
++ )
591 SdrObject
* pTestObj
= pPage
->GetObj( i
);
593 if ( pIMapObj
== GetIMapObj( pTestObj
) )
604 /*************************************************************************
608 \************************************************************************/
610 void IMapWindow::Command(const CommandEvent
& rCEvt
)
614 if ( rCEvt
.GetCommand() == COMMAND_CONTEXTMENU
)
616 PopupMenu
aMenu( SVX_RES( RID_SVXMN_IMAP
) );
617 const SdrMarkList
& rMarkList
= pView
->GetMarkedObjectList();
618 ULONG nMarked
= rMarkList
.GetMarkCount();
620 aMenu
.EnableItem( MN_URL
, FALSE
);
621 aMenu
.EnableItem( MN_ACTIVATE
, FALSE
);
622 aMenu
.EnableItem( MN_MACRO
, FALSE
);
623 aMenu
.EnableItem( MN_MARK_ALL
, pModel
->GetPage( 0 )->GetObjCount() != pView
->GetMarkedObjectCount() );
627 aMenu
.EnableItem( MN_POSITION
, FALSE
);
628 aMenu
.EnableItem( MN_FRAME_TO_TOP
, FALSE
);
629 aMenu
.EnableItem( MN_MOREFRONT
, FALSE
);
630 aMenu
.EnableItem( MN_MOREBACK
, FALSE
);
631 aMenu
.EnableItem( MN_FRAME_TO_BOTTOM
, FALSE
);
632 aMenu
.EnableItem( MN_DELETE1
, FALSE
);
638 SdrObject
* pSdrObj
= GetSelectedSdrObject();
640 aMenu
.EnableItem( MN_URL
, TRUE
);
641 aMenu
.EnableItem( MN_ACTIVATE
, TRUE
);
642 aMenu
.EnableItem( MN_MACRO
, TRUE
);
643 aMenu
.CheckItem( MN_ACTIVATE
, GetIMapObj( pSdrObj
)->IsActive() );
646 aMenu
.EnableItem( MN_POSITION
, TRUE
);
647 aMenu
.EnableItem( MN_FRAME_TO_TOP
, TRUE
);
648 aMenu
.EnableItem( MN_MOREFRONT
, TRUE
);
649 aMenu
.EnableItem( MN_MOREBACK
, TRUE
);
650 aMenu
.EnableItem( MN_FRAME_TO_BOTTOM
, TRUE
);
651 aMenu
.EnableItem( MN_DELETE1
, TRUE
);
654 aMenu
.SetSelectHdl( LINK( this, IMapWindow
, MenuSelectHdl
) );
655 aMenu
.Execute( this, rCEvt
.GetMousePosPixel() );
658 Window::Command(rCEvt
);
661 /*************************************************************************
665 \************************************************************************/
667 sal_Int8
IMapWindow::AcceptDrop( const AcceptDropEvent
& rEvt
)
669 return( ( GetHitSdrObj( rEvt
.maPosPixel
) != NULL
) ? rEvt
.mnAction
: DND_ACTION_NONE
);
672 /*************************************************************************
676 \************************************************************************/
678 sal_Int8
IMapWindow::ExecuteDrop( const ExecuteDropEvent
& rEvt
)
680 sal_Int8 nRet
= DND_ACTION_NONE
;
682 if( IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
) )
684 const String aString
;
685 INetBookmark
aBookMark( aString
, aString
);
686 SdrObject
* pSdrObj
= GetHitSdrObj( rEvt
.maPosPixel
);
688 if( pSdrObj
&& TransferableDataHelper( rEvt
.maDropEvent
.Transferable
).GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
, aBookMark
) )
690 IMapObject
* pIMapObj
= GetIMapObj( pSdrObj
);
692 pIMapObj
->SetURL( aBookMark
.GetURL() );
693 pIMapObj
->SetAltText( aBookMark
.GetDescription() );
694 pModel
->SetChanged( sal_True
);
696 pView
->MarkObj( pSdrObj
, pView
->GetSdrPageView() );
698 nRet
= rEvt
.mnAction
;
705 /*************************************************************************
709 \************************************************************************/
711 void IMapWindow::RequestHelp( const HelpEvent
& rHEvt
)
713 SdrObject
* pSdrObj
= NULL
;
714 SdrPageView
* pPageView
= NULL
;
715 Point aPos
= PixelToLogic( ScreenToOutputPixel( rHEvt
.GetMousePosPixel() ) );
717 if ( Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled() )
719 if ( pView
->PickObj( aPos
, pView
->getHitTolLog(), pSdrObj
, pPageView
) )
721 const IMapObject
* pIMapObj
= GetIMapObj( pSdrObj
);
724 if ( pIMapObj
&& ( aStr
= pIMapObj
->GetURL() ).Len() )
726 String
aDescr( pIMapObj
->GetAltText() );
727 Rectangle
aLogicPix( LogicToPixel( Rectangle( Point(), GetGraphicSize() ) ) );
728 Rectangle
aScreenRect( OutputToScreenPixel( aLogicPix
.TopLeft() ),
729 OutputToScreenPixel( aLogicPix
.BottomRight() ) );
731 if ( Help::IsBalloonHelpEnabled() )
732 Help::ShowBalloon( this, rHEvt
.GetMousePosPixel(), aScreenRect
, aStr
);
733 else if ( Help::IsQuickHelpEnabled() )
734 Help::ShowQuickHelp( this, aScreenRect
, aStr
);
738 Window::RequestHelp( rHEvt
);
742 /*************************************************************************
746 \************************************************************************/
748 void IMapWindow::SetCurrentObjState( BOOL bActive
)
750 SdrObject
* pObj
= GetSelectedSdrObject();
754 SfxItemSet
aSet( pModel
->GetItemPool() );
756 GetIMapObj( pObj
)->SetActive( bActive
);
758 aSet
.Put( XFillColorItem( String(), TRANSCOL
) );
762 aSet
.Put( XFillTransparenceItem( 100 ) );
763 aSet
.Put( XLineColorItem( String(), Color( COL_RED
) ) );
767 aSet
.Put( XFillTransparenceItem( 50 ) );
768 aSet
.Put( XLineColorItem( String(), Color( COL_BLACK
) ) );
771 pView
->SetAttributes( aSet
, FALSE
);
775 /*************************************************************************
779 \************************************************************************/
781 void IMapWindow::UpdateInfo( BOOL bNewObj
)
783 if ( aInfoLink
.IsSet() )
785 const SdrObject
* pSdrObj
= GetSelectedSdrObject();
786 const IMapObject
* pIMapObj
= pSdrObj
? GetIMapObj( pSdrObj
) : NULL
;
788 aInfo
.bNewObj
= bNewObj
;
792 aInfo
.bOneMarked
= TRUE
;
793 aInfo
.aMarkURL
= pIMapObj
->GetURL();
794 aInfo
.aMarkAltText
= pIMapObj
->GetAltText();
795 aInfo
.aMarkTarget
= pIMapObj
->GetTarget();
796 aInfo
.bActivated
= pIMapObj
->IsActive();
797 aInfoLink
.Call( this );
801 aInfo
.aMarkURL
= aInfo
.aMarkAltText
= aInfo
.aMarkTarget
= String();
802 aInfo
.bOneMarked
= FALSE
;
803 aInfo
.bActivated
= FALSE
;
806 aInfoLink
.Call( this );
810 /*************************************************************************
814 \************************************************************************/
816 void IMapWindow::DoMacroAssign()
818 SdrObject
* pSdrObj
= GetSelectedSdrObject();
822 SfxItemSet
aSet( *pIMapPool
, SID_ATTR_MACROITEM
, SID_ATTR_MACROITEM
, SID_EVENTCONFIG
, SID_EVENTCONFIG
);
824 SfxEventNamesItem
aNamesItem(SID_EVENTCONFIG
);
825 aNamesItem
.AddEvent( String::CreateFromAscii( "MouseOver" ), String(), SFX_EVENT_MOUSEOVER_OBJECT
);
826 aNamesItem
.AddEvent( String::CreateFromAscii( "MouseOut" ), String(), SFX_EVENT_MOUSEOUT_OBJECT
);
828 SvxMacroItem
aMacroItem(SID_ATTR_MACROITEM
);
829 IMapObject
* pIMapObj
= GetIMapObj( pSdrObj
);
830 aMacroItem
.SetMacroTable( pIMapObj
->GetMacroTable() );
831 aSet
.Put( aMacroItem
, SID_ATTR_MACROITEM
);
833 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
834 SfxAbstractDialog
* pMacroDlg
= pFact
->CreateSfxDialog( this, aSet
, mxDocumentFrame
, SID_EVENTCONFIG
);
836 if ( pMacroDlg
&& pMacroDlg
->Execute() == RET_OK
)
838 const SfxItemSet
* pOutSet
= pMacroDlg
->GetOutputItemSet();
839 pIMapObj
->SetMacroTable( ((const SvxMacroItem
& )pOutSet
->Get( SID_ATTR_MACROITEM
)).GetMacroTable() );
840 pModel
->SetChanged( sal_True
);
848 /*************************************************************************
852 \************************************************************************/
854 void IMapWindow::DoPropertyDialog()
856 SdrObject
* pSdrObj
= GetSelectedSdrObject();
860 IMapObject
* pIMapObj
= GetIMapObj( pSdrObj
);
861 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
864 AbstractURLDlg
* aDlg
= pFact
->CreateURLDialog( this, pIMapObj
->GetURL(), pIMapObj
->GetAltText(), pIMapObj
->GetDesc(),
865 pIMapObj
->GetTarget(), pIMapObj
->GetName(), aTargetList
);
866 DBG_ASSERT(aDlg
, "Dialogdiet fail!");
867 if ( aDlg
->Execute() == RET_OK
)
869 const String
aURLText( aDlg
->GetURL() );
871 if ( aURLText
.Len() )
873 INetURLObject
aObj( aURLText
, INET_PROT_FILE
);
874 DBG_ASSERT( aObj
.GetProtocol() != INET_PROT_NOT_VALID
, "Invalid URL" );
875 pIMapObj
->SetURL( aObj
.GetMainURL( INetURLObject::NO_DECODE
) );
878 pIMapObj
->SetURL( aURLText
);
880 pIMapObj
->SetAltText( aDlg
->GetAltText() );
881 pIMapObj
->SetDesc( aDlg
->GetDesc() );
882 pIMapObj
->SetTarget( aDlg
->GetTarget() );
883 pIMapObj
->SetName( aDlg
->GetName() );
884 pModel
->SetChanged( sal_True
);
887 delete aDlg
; //add by CHINA001
892 /*************************************************************************
896 \************************************************************************/
898 IMPL_LINK( IMapWindow
, MenuSelectHdl
, Menu
*, pMenu
)
902 USHORT nId
= pMenu
->GetCurItemId();
916 const BOOL bNewState
= !pMenu
->IsItemChecked( MN_ACTIVATE
);
918 pMenu
->CheckItem( MN_ACTIVATE
, bNewState
);
919 SetCurrentObjState( bNewState
);
923 case( MN_FRAME_TO_TOP
):
924 pView
->PutMarkedToTop();
927 case( MN_MOREFRONT
):
928 pView
->MovMarkedToTop();
932 pView
->MovMarkedToBtm();
935 case( MN_FRAME_TO_BOTTOM
):
936 pView
->PutMarkedToBtm();
944 pView
->DeleteMarked();
954 void IMapWindow::CreateDefaultObject()
956 SdrPageView
* pPageView
= pView
->GetSdrPageView();
960 // calc position and size
961 Point
aPagePos(0, 0); // = pPageView->GetOffset();
962 Size aPageSize
= pPageView
->GetPage()->GetSize();
963 sal_uInt32 nDefaultObjectSizeWidth
= aPageSize
.Width() / 4;
964 sal_uInt32 nDefaultObjectSizeHeight
= aPageSize
.Height() / 4;
965 aPagePos
.X() += (aPageSize
.Width() / 2) - (nDefaultObjectSizeWidth
/ 2);
966 aPagePos
.Y() += (aPageSize
.Height() / 2) - (nDefaultObjectSizeHeight
/ 2);
967 Rectangle
aNewObjectRectangle(aPagePos
, Size(nDefaultObjectSizeWidth
, nDefaultObjectSizeHeight
));
969 SdrObject
* pObj
= SdrObjFactory::MakeNewObject( pView
->GetCurrentObjInventor(), pView
->GetCurrentObjIdentifier(), 0L, pModel
);
970 pObj
->SetLogicRect(aNewObjectRectangle
);
972 switch( pObj
->GetObjIdentifier() )
977 basegfx::B2DPolygon aInnerPoly
;
978 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.BottomLeft().X(), aNewObjectRectangle
.BottomLeft().Y()));
979 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.TopLeft().X(), aNewObjectRectangle
.TopLeft().Y()));
980 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.TopCenter().X(), aNewObjectRectangle
.TopCenter().Y()));
981 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.Center().X(), aNewObjectRectangle
.Center().Y()));
982 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.RightCenter().X(), aNewObjectRectangle
.RightCenter().Y()));
983 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.BottomRight().X(), aNewObjectRectangle
.BottomRight().Y()));
984 aInnerPoly
.setClosed(true);
985 ((SdrPathObj
*)pObj
)->SetPathPoly(basegfx::B2DPolyPolygon(aInnerPoly
));
991 sal_Int32
nWdt(aNewObjectRectangle
.GetWidth() / 2);
992 sal_Int32
nHgt(aNewObjectRectangle
.GetHeight() / 2);
993 basegfx::B2DPolygon
aInnerPoly(XPolygon(aNewObjectRectangle
.Center(), nWdt
, nHgt
).getB2DPolygon());
994 ((SdrPathObj
*)pObj
)->SetPathPoly(basegfx::B2DPolyPolygon(aInnerPoly
));
1000 pView
->InsertObjectAtView(pObj
, *pPageView
);
1001 SdrObjCreated( *pObj
);
1002 SetCurrentObjState( true );
1003 pView
->MarkObj( pObj
, pPageView
);
1007 void IMapWindow::KeyInput( const KeyEvent
& rKEvt
)
1009 KeyCode aCode
= rKEvt
.GetKeyCode();
1012 switch(aCode.GetCode())
1016 if ( pView->IsAction() )
1021 else if ( pView->AreObjectsMarked() )
1023 const SdrHdlList& rHdlList = pView->GetHdlList();
1024 SdrHdl* pHdl = rHdlList.GetFocusHdl();
1028 ((SdrHdlList&)rHdlList).ResetFocusHdl();
1032 pView->UnmarkAllObj();
1033 ((Dialog*)GetParent())->GrabFocusToFirstControl();
1043 GraphCtrl::KeyInput( rKEvt
);
1046 void IMapWindow::SelectFirstObject()
1048 SdrPage
* pPage
= (SdrPage
*) pModel
->GetPage( 0 );
1049 if( pPage
->GetObjCount() != 0 )
1052 pView
->UnmarkAllObj();
1053 pView
->MarkNextObj(TRUE
);
1057 void IMapWindow::StartPolyEdit()
1061 if( !pView
->AreObjectsMarked() )
1062 pView
->MarkNextObj(TRUE
);
1064 const SdrHdlList
& rHdlList
= pView
->GetHdlList();
1065 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
1069 ((SdrHdlList
&)rHdlList
).TravelFocusHdl(true);