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>
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()
73 SfxItemPool::Free(pIMapPool
);
77 void IMapWindow::SetImageMap( const ImageMap
& rImageMap
)
79 ReplaceImageMap( rImageMap
, false );
82 void IMapWindow::ReplaceImageMap( const ImageMap
& rImageMap
, bool /*bScaleToGraphic*/ )
90 pPage
= GetSdrModel()->GetPage(0L);
95 // clear all draw objects
101 // #i63762# reset selection at view
102 GetSdrView()->UnmarkAllObj();
105 // create new drawing objects
106 const sal_uInt16
nCount(rImageMap
.GetIMapObjectCount());
108 for ( sal_uInt16
i(nCount
); i
> 0; i
-- )
110 SdrObject
* pNewObj
= CreateObj( rImageMap
.GetIMapObject( i
- 1 ) );
112 if (pNewObj
&& pPage
)
114 pPage
->InsertObject( pNewObj
);
119 bool IMapWindow::ReplaceActualIMapInfo( const NotifyInfo
& rNewInfo
)
121 const SdrObject
* pSdrObj
= GetSelectedSdrObject();
122 IMapObject
* pIMapObj
;
125 if ( pSdrObj
&& ( ( pIMapObj
= GetIMapObj( pSdrObj
) ) != NULL
) )
127 pIMapObj
->SetURL( rNewInfo
.aMarkURL
);
128 pIMapObj
->SetAltText( rNewInfo
.aMarkAltText
);
129 pIMapObj
->SetTarget( rNewInfo
.aMarkTarget
);
130 pModel
->SetChanged( true );
139 const ImageMap
& IMapWindow::GetImageMap()
141 if ( pModel
->IsChanged() )
143 SdrPage
* pPage
= (SdrPage
*) pModel
->GetPage( 0 );
147 const long nCount
= pPage
->GetObjCount();
149 aIMap
.ClearImageMap();
151 for ( long i
= nCount
- 1; i
> -1; i
-- )
152 aIMap
.InsertIMapObject( *( ( (IMapUserData
*) pPage
->GetObj( i
)->GetUserData( 0 ) )->GetObject() ) );
155 pModel
->SetChanged( false );
161 void IMapWindow::SetTargetList( TargetList
& rTargetList
)
166 // Fill with the provided list
167 for( size_t i
= 0, n
= rTargetList
.size(); i
< n
; ++i
)
168 aTargetList
.push_back( rTargetList
[ i
] );
170 pModel
->SetChanged( false );
173 SdrObject
* IMapWindow::CreateObj( const IMapObject
* pIMapObj
)
176 Rectangle
aClipRect( aPoint
, GetGraphicSize() );
177 SdrObject
* pSdrObj
= NULL
;
178 IMapObjectPtr pCloneIMapObj
;
180 switch( pIMapObj
->GetType() )
182 case( IMAP_OBJ_RECTANGLE
):
184 IMapRectangleObject
* pIMapRectObj
= (IMapRectangleObject
*) pIMapObj
;
185 Rectangle
aDrawRect( pIMapRectObj
->GetRectangle( false ) );
187 // clipped on CanvasPane
188 aDrawRect
.Intersection( aClipRect
);
190 pSdrObj
= (SdrObject
*) new SdrRectObj( aDrawRect
);
191 pCloneIMapObj
.reset((IMapObject
*) new IMapRectangleObject( *pIMapRectObj
));
195 case( IMAP_OBJ_CIRCLE
):
197 IMapCircleObject
* pIMapCircleObj
= (IMapCircleObject
*) pIMapObj
;
198 const Point
aCenter( pIMapCircleObj
->GetCenter( false ) );
199 const long nRadius
= pIMapCircleObj
->GetRadius( false );
200 const Point
aOffset( nRadius
, nRadius
);
201 Rectangle
aCircle( aCenter
- aOffset
, aCenter
+ aOffset
);
203 // limited to CanvasPane
204 aCircle
.Intersection( aClipRect
);
206 pSdrObj
= (SdrObject
*) new SdrCircObj( OBJ_CIRC
, aCircle
, 0, 36000 );
207 pCloneIMapObj
.reset((IMapObject
*) new IMapCircleObject( *pIMapCircleObj
));
211 case( IMAP_OBJ_POLYGON
):
213 IMapPolygonObject
* pIMapPolyObj
= (IMapPolygonObject
*) pIMapObj
;
215 // If it actually is an ellipse, then another ellipse is created again
216 if ( pIMapPolyObj
->HasExtraEllipse() )
218 Rectangle
aDrawRect( pIMapPolyObj
->GetExtraEllipse() );
220 // clipped on CanvasPane
221 aDrawRect
.Intersection( aClipRect
);
223 pSdrObj
= (SdrObject
*) new SdrCircObj( OBJ_CIRC
, aDrawRect
, 0, 36000 );
227 const Polygon
& rPoly
= pIMapPolyObj
->GetPolygon( false );
228 Polygon
aDrawPoly( rPoly
);
230 // clipped on CanvasPane
231 aDrawPoly
.Clip( aClipRect
);
233 basegfx::B2DPolygon aPolygon
;
234 aPolygon
.append(aDrawPoly
.getB2DPolygon());
235 pSdrObj
= (SdrObject
*)new SdrPathObj(OBJ_POLY
, basegfx::B2DPolyPolygon(aPolygon
));
238 pCloneIMapObj
.reset((IMapObject
*) new IMapPolygonObject( *pIMapPolyObj
));
248 SfxItemSet
aSet( pModel
->GetItemPool() );
250 aSet
.Put( XFillStyleItem( XFILL_SOLID
) );
251 aSet
.Put( XFillColorItem( "", TRANSCOL
) );
253 if ( !pIMapObj
->IsActive() )
255 aSet
.Put( XFillTransparenceItem( 100 ) );
256 aSet
.Put( XLineColorItem( "", Color( COL_RED
) ) );
260 aSet
.Put( XFillTransparenceItem( 50 ) );
261 aSet
.Put( XLineColorItem( "", Color( COL_BLACK
) ) );
264 pSdrObj
->SetMergedItemSetAndBroadcast(aSet
);
266 pSdrObj
->AppendUserData( new IMapUserData( pCloneIMapObj
) );
267 pSdrObj
->SetUserCall( GetSdrUserCall() );
273 void IMapWindow::InitSdrModel()
275 GraphCtrl::InitSdrModel();
277 SfxItemSet
aSet( pModel
->GetItemPool() );
279 aSet
.Put( XFillColorItem( "", TRANSCOL
) );
280 aSet
.Put( XFillTransparenceItem( 50 ) );
281 pView
->SetAttributes( aSet
);
282 pView
->SetFrameDragSingles( true );
285 void IMapWindow::SdrObjCreated( const SdrObject
& rObj
)
287 switch( rObj
.GetObjIdentifier() )
291 SdrRectObj
* pRectObj
= (SdrRectObj
*) &rObj
;
292 IMapRectangleObject
* pObj
= new IMapRectangleObject( pRectObj
->GetLogicRect(), "", "", "", "", "", true, false );
294 pRectObj
->AppendUserData( new IMapUserData( IMapObjectPtr(pObj
) ) );
300 SdrCircObj
* pCircObj
= (SdrCircObj
*) &rObj
;
301 SdrPathObj
* pPathObj
= (SdrPathObj
*) pCircObj
->ConvertToPolyObj( false, false );
302 Polygon
aPoly(pPathObj
->GetPathPoly().getB2DPolygon(0L));
305 IMapPolygonObject
* pObj
= new IMapPolygonObject( Polygon(aPoly
), "", "", "", "", "", true, false );
306 pObj
->SetExtraEllipse( aPoly
.GetBoundRect() );
307 pCircObj
->AppendUserData( new IMapUserData( IMapObjectPtr(pObj
) ) );
312 case( OBJ_FREEFILL
):
313 case( OBJ_PATHPOLY
):
314 case( OBJ_PATHFILL
):
316 SdrPathObj
* pPathObj
= (SdrPathObj
*) &rObj
;
317 const basegfx::B2DPolyPolygon
& rXPolyPoly
= pPathObj
->GetPathPoly();
319 if ( rXPolyPoly
.count() )
321 Polygon
aPoly(rXPolyPoly
.getB2DPolygon(0L));
322 IMapPolygonObject
* pObj
= new IMapPolygonObject( aPoly
, "", "", "", "", "", true, false );
323 pPathObj
->AppendUserData( new IMapUserData( IMapObjectPtr(pObj
) ) );
333 void IMapWindow::SdrObjChanged( const SdrObject
& rObj
)
335 IMapUserData
* pUserData
= (IMapUserData
*) rObj
.GetUserData( 0 );
343 IMapObjectPtr pIMapObj
= pUserData
->GetObject();
346 if ( pIMapObj
.get() )
348 aURL
= pIMapObj
->GetURL();
349 aAltText
= pIMapObj
->GetAltText();
350 aDesc
= pIMapObj
->GetDesc();
351 aTarget
= pIMapObj
->GetTarget();
352 bActive
= pIMapObj
->IsActive();
355 switch( rObj
.GetObjIdentifier() )
359 pUserData
->ReplaceObject( IMapObjectPtr(new IMapRectangleObject( ( (const SdrRectObj
&) rObj
).GetLogicRect(),
360 aURL
, aAltText
, aDesc
, aTarget
, "", bActive
, false ) ) );
366 const SdrCircObj
& rCircObj
= (const SdrCircObj
&) rObj
;
367 SdrPathObj
* pPathObj
= (SdrPathObj
*) rCircObj
.ConvertToPolyObj( false, false );
368 Polygon
aPoly(pPathObj
->GetPathPoly().getB2DPolygon(0L));
370 IMapPolygonObject
* pObj
= new IMapPolygonObject( aPoly
, aURL
, aAltText
, aDesc
, aTarget
, "", bActive
, false );
371 pObj
->SetExtraEllipse( aPoly
.GetBoundRect() );
373 // was only created by us temporarily
375 pUserData
->ReplaceObject( IMapObjectPtr(pObj
) );
380 case( OBJ_FREEFILL
):
381 case( OBJ_PATHPOLY
):
382 case( OBJ_PATHFILL
):
384 const SdrPathObj
& rPathObj
= (const SdrPathObj
&) rObj
;
385 const basegfx::B2DPolyPolygon
& rXPolyPoly
= rPathObj
.GetPathPoly();
387 if ( rXPolyPoly
.count() )
389 Polygon
aPoly(rPathObj
.GetPathPoly().getB2DPolygon(0L));
390 IMapPolygonObject
* pObj
= new IMapPolygonObject( aPoly
, aURL
, aAltText
, aDesc
, aTarget
, "", bActive
, false );
391 pUserData
->ReplaceObject( IMapObjectPtr(pObj
) );
402 void IMapWindow::MouseButtonUp(const MouseEvent
& rMEvt
)
404 GraphCtrl::MouseButtonUp( rMEvt
);
408 void IMapWindow::MarkListHasChanged()
410 GraphCtrl::MarkListHasChanged();
414 SdrObject
* IMapWindow::GetHitSdrObj( const Point
& rPosPixel
) const
416 SdrObject
* pObj
= NULL
;
417 Point aPt
= PixelToLogic( rPosPixel
);
419 if ( Rectangle( Point(), GetGraphicSize() ).IsInside( aPt
) )
421 SdrPage
* pPage
= (SdrPage
*) pModel
->GetPage( 0 );
424 if ( pPage
&& ( ( nCount
= pPage
->GetObjCount() ) > 0 ) )
426 for ( long i
= nCount
- 1; i
>= 0; i
-- )
428 SdrObject
* pTestObj
= pPage
->GetObj( i
);
429 IMapObject
* pIMapObj
= GetIMapObj( pTestObj
);
431 if ( pIMapObj
&& pIMapObj
->IsHit( aPt
) )
443 IMapObject
* IMapWindow::GetIMapObj( const SdrObject
* pSdrObj
) const
445 IMapObject
* pIMapObj
= NULL
;
449 IMapUserData
* pUserData
= (IMapUserData
*) pSdrObj
->GetUserData( 0 );
452 pIMapObj
= pUserData
->GetObject().get();
458 void IMapWindow::Command(const CommandEvent
& rCEvt
)
462 if ( rCEvt
.GetCommand() == COMMAND_CONTEXTMENU
)
464 PopupMenu
aMenu( SVX_RES( RID_SVXMN_IMAP
) );
465 const SdrMarkList
& rMarkList
= pView
->GetMarkedObjectList();
466 sal_uIntPtr nMarked
= rMarkList
.GetMarkCount();
468 aMenu
.EnableItem( MN_URL
, false );
469 aMenu
.EnableItem( MN_ACTIVATE
, false );
470 aMenu
.EnableItem( MN_MACRO
, false );
471 aMenu
.EnableItem( MN_MARK_ALL
, pModel
->GetPage( 0 )->GetObjCount() != pView
->GetMarkedObjectCount() );
475 aMenu
.EnableItem( MN_POSITION
, false );
476 aMenu
.EnableItem( MN_FRAME_TO_TOP
, false );
477 aMenu
.EnableItem( MN_MOREFRONT
, false );
478 aMenu
.EnableItem( MN_MOREBACK
, false );
479 aMenu
.EnableItem( MN_FRAME_TO_BOTTOM
, false );
480 aMenu
.EnableItem( MN_DELETE1
, false );
486 SdrObject
* pSdrObj
= GetSelectedSdrObject();
488 aMenu
.EnableItem( MN_URL
, true );
489 aMenu
.EnableItem( MN_ACTIVATE
, true );
490 aMenu
.EnableItem( MN_MACRO
, true );
491 aMenu
.CheckItem( MN_ACTIVATE
, GetIMapObj( pSdrObj
)->IsActive() );
494 aMenu
.EnableItem( MN_POSITION
, true );
495 aMenu
.EnableItem( MN_FRAME_TO_TOP
, true );
496 aMenu
.EnableItem( MN_MOREFRONT
, true );
497 aMenu
.EnableItem( MN_MOREBACK
, true );
498 aMenu
.EnableItem( MN_FRAME_TO_BOTTOM
, true );
499 aMenu
.EnableItem( MN_DELETE1
, true );
502 aMenu
.SetSelectHdl( LINK( this, IMapWindow
, MenuSelectHdl
) );
503 aMenu
.Execute( this, rCEvt
.GetMousePosPixel() );
506 Window::Command(rCEvt
);
509 sal_Int8
IMapWindow::AcceptDrop( const AcceptDropEvent
& rEvt
)
511 return( ( GetHitSdrObj( rEvt
.maPosPixel
) != NULL
) ? rEvt
.mnAction
: DND_ACTION_NONE
);
514 sal_Int8
IMapWindow::ExecuteDrop( const ExecuteDropEvent
& rEvt
)
516 sal_Int8 nRet
= DND_ACTION_NONE
;
518 if( IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
) )
520 const OUString aString
;
521 INetBookmark
aBookMark( aString
, aString
);
522 SdrObject
* pSdrObj
= GetHitSdrObj( rEvt
.maPosPixel
);
524 if( pSdrObj
&& TransferableDataHelper( rEvt
.maDropEvent
.Transferable
).GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK
, aBookMark
) )
526 IMapObject
* pIMapObj
= GetIMapObj( pSdrObj
);
528 pIMapObj
->SetURL( aBookMark
.GetURL() );
529 pIMapObj
->SetAltText( aBookMark
.GetDescription() );
530 pModel
->SetChanged( true );
532 pView
->MarkObj( pSdrObj
, pView
->GetSdrPageView() );
534 nRet
= rEvt
.mnAction
;
541 void IMapWindow::RequestHelp( const HelpEvent
& rHEvt
)
543 Point aPos
= PixelToLogic( ScreenToOutputPixel( rHEvt
.GetMousePosPixel() ) );
545 if ( Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled() )
547 SdrObject
* pSdrObj
= NULL
;
548 SdrPageView
* pPageView
= NULL
;
549 if ( pView
->PickObj( aPos
, pView
->getHitTolLog(), pSdrObj
, pPageView
) )
551 const IMapObject
* pIMapObj
= GetIMapObj( pSdrObj
);
554 if ( pIMapObj
&& !( aStr
= pIMapObj
->GetURL() ).isEmpty() )
556 Rectangle
aLogicPix( LogicToPixel( Rectangle( Point(), GetGraphicSize() ) ) );
557 Rectangle
aScreenRect( OutputToScreenPixel( aLogicPix
.TopLeft() ),
558 OutputToScreenPixel( aLogicPix
.BottomRight() ) );
560 if ( Help::IsBalloonHelpEnabled() )
561 Help::ShowBalloon( this, rHEvt
.GetMousePosPixel(), aScreenRect
, aStr
);
562 else if ( Help::IsQuickHelpEnabled() )
563 Help::ShowQuickHelp( this, aScreenRect
, aStr
);
567 Window::RequestHelp( rHEvt
);
571 void IMapWindow::SetCurrentObjState( bool bActive
)
573 SdrObject
* pObj
= GetSelectedSdrObject();
577 SfxItemSet
aSet( pModel
->GetItemPool() );
579 GetIMapObj( pObj
)->SetActive( bActive
);
581 aSet
.Put( XFillColorItem( "", TRANSCOL
) );
585 aSet
.Put( XFillTransparenceItem( 100 ) );
586 aSet
.Put( XLineColorItem( "", Color( COL_RED
) ) );
590 aSet
.Put( XFillTransparenceItem( 50 ) );
591 aSet
.Put( XLineColorItem( "", Color( COL_BLACK
) ) );
594 pView
->SetAttributes( aSet
, false );
598 void IMapWindow::UpdateInfo( bool bNewObj
)
600 if ( aInfoLink
.IsSet() )
602 const SdrObject
* pSdrObj
= GetSelectedSdrObject();
603 const IMapObject
* pIMapObj
= pSdrObj
? GetIMapObj( pSdrObj
) : NULL
;
605 aInfo
.bNewObj
= bNewObj
;
609 aInfo
.bOneMarked
= true;
610 aInfo
.aMarkURL
= pIMapObj
->GetURL();
611 aInfo
.aMarkAltText
= pIMapObj
->GetAltText();
612 aInfo
.aMarkTarget
= pIMapObj
->GetTarget();
613 aInfo
.bActivated
= pIMapObj
->IsActive();
614 aInfoLink
.Call( this );
618 aInfo
.aMarkURL
= aInfo
.aMarkAltText
= aInfo
.aMarkTarget
= "";
619 aInfo
.bOneMarked
= false;
620 aInfo
.bActivated
= false;
623 aInfoLink
.Call( this );
627 void IMapWindow::DoMacroAssign()
629 SdrObject
* pSdrObj
= GetSelectedSdrObject();
633 SfxItemSet
aSet( *pIMapPool
, SID_ATTR_MACROITEM
, SID_ATTR_MACROITEM
, SID_EVENTCONFIG
, SID_EVENTCONFIG
, 0 );
635 SfxEventNamesItem
aNamesItem(SID_EVENTCONFIG
);
636 aNamesItem
.AddEvent( "MouseOver", "", SFX_EVENT_MOUSEOVER_OBJECT
);
637 aNamesItem
.AddEvent( "MouseOut", "", SFX_EVENT_MOUSEOUT_OBJECT
);
638 aSet
.Put( aNamesItem
);
640 SvxMacroItem
aMacroItem(SID_ATTR_MACROITEM
);
641 IMapObject
* pIMapObj
= GetIMapObj( pSdrObj
);
642 aMacroItem
.SetMacroTable( pIMapObj
->GetMacroTable() );
643 aSet
.Put( aMacroItem
, SID_ATTR_MACROITEM
);
645 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
646 SfxAbstractDialog
* pMacroDlg
= pFact
->CreateSfxDialog( this, aSet
, mxDocumentFrame
, SID_EVENTCONFIG
);
648 if ( pMacroDlg
&& pMacroDlg
->Execute() == RET_OK
)
650 const SfxItemSet
* pOutSet
= pMacroDlg
->GetOutputItemSet();
651 pIMapObj
->SetMacroTable( ((const SvxMacroItem
& )pOutSet
->Get( SID_ATTR_MACROITEM
)).GetMacroTable() );
652 pModel
->SetChanged( true );
660 void IMapWindow::DoPropertyDialog()
662 SdrObject
* pSdrObj
= GetSelectedSdrObject();
666 IMapObject
* pIMapObj
= GetIMapObj( pSdrObj
);
667 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
670 AbstractURLDlg
* aDlg
= pFact
->CreateURLDialog( this, pIMapObj
->GetURL(), pIMapObj
->GetAltText(), pIMapObj
->GetDesc(),
671 pIMapObj
->GetTarget(), pIMapObj
->GetName(), aTargetList
);
672 DBG_ASSERT(aDlg
, "Dialogdiet fail!");
673 if ( aDlg
->Execute() == RET_OK
)
675 const OUString
aURLText( aDlg
->GetURL() );
677 if ( !aURLText
.isEmpty() )
679 INetURLObject
aObj( aURLText
, INET_PROT_FILE
);
680 DBG_ASSERT( aObj
.GetProtocol() != INET_PROT_NOT_VALID
, "Invalid URL" );
681 pIMapObj
->SetURL( aObj
.GetMainURL( INetURLObject::NO_DECODE
) );
684 pIMapObj
->SetURL( aURLText
);
686 pIMapObj
->SetAltText( aDlg
->GetAltText() );
687 pIMapObj
->SetDesc( aDlg
->GetDesc() );
688 pIMapObj
->SetTarget( aDlg
->GetTarget() );
689 pIMapObj
->SetName( aDlg
->GetName() );
690 pModel
->SetChanged( true );
698 IMPL_LINK( IMapWindow
, MenuSelectHdl
, Menu
*, pMenu
)
702 sal_uInt16 nId
= pMenu
->GetCurItemId();
716 const bool bNewState
= !pMenu
->IsItemChecked( MN_ACTIVATE
);
718 pMenu
->CheckItem( MN_ACTIVATE
, bNewState
);
719 SetCurrentObjState( bNewState
);
723 case( MN_FRAME_TO_TOP
):
724 pView
->PutMarkedToTop();
727 case( MN_MOREFRONT
):
728 pView
->MovMarkedToTop();
732 pView
->MovMarkedToBtm();
735 case( MN_FRAME_TO_BOTTOM
):
736 pView
->PutMarkedToBtm();
744 pView
->DeleteMarked();
754 void IMapWindow::CreateDefaultObject()
756 SdrPageView
* pPageView
= pView
->GetSdrPageView();
760 // calc position and size
761 Point
aPagePos(0, 0); // = pPageView->GetOffset();
762 Size aPageSize
= pPageView
->GetPage()->GetSize();
763 sal_uInt32 nDefaultObjectSizeWidth
= aPageSize
.Width() / 4;
764 sal_uInt32 nDefaultObjectSizeHeight
= aPageSize
.Height() / 4;
765 aPagePos
.X() += (aPageSize
.Width() / 2) - (nDefaultObjectSizeWidth
/ 2);
766 aPagePos
.Y() += (aPageSize
.Height() / 2) - (nDefaultObjectSizeHeight
/ 2);
767 Rectangle
aNewObjectRectangle(aPagePos
, Size(nDefaultObjectSizeWidth
, nDefaultObjectSizeHeight
));
769 SdrObject
* pObj
= SdrObjFactory::MakeNewObject( pView
->GetCurrentObjInventor(), pView
->GetCurrentObjIdentifier(), 0L, pModel
);
770 pObj
->SetLogicRect(aNewObjectRectangle
);
772 switch( pObj
->GetObjIdentifier() )
777 basegfx::B2DPolygon aInnerPoly
;
778 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.BottomLeft().X(), aNewObjectRectangle
.BottomLeft().Y()));
779 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.TopLeft().X(), aNewObjectRectangle
.TopLeft().Y()));
780 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.TopCenter().X(), aNewObjectRectangle
.TopCenter().Y()));
781 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.Center().X(), aNewObjectRectangle
.Center().Y()));
782 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.RightCenter().X(), aNewObjectRectangle
.RightCenter().Y()));
783 aInnerPoly
.append(basegfx::B2DPoint(aNewObjectRectangle
.BottomRight().X(), aNewObjectRectangle
.BottomRight().Y()));
784 aInnerPoly
.setClosed(true);
785 ((SdrPathObj
*)pObj
)->SetPathPoly(basegfx::B2DPolyPolygon(aInnerPoly
));
791 sal_Int32
nWdt(aNewObjectRectangle
.GetWidth() / 2);
792 sal_Int32
nHgt(aNewObjectRectangle
.GetHeight() / 2);
793 basegfx::B2DPolygon
aInnerPoly(XPolygon(aNewObjectRectangle
.Center(), nWdt
, nHgt
).getB2DPolygon());
794 ((SdrPathObj
*)pObj
)->SetPathPoly(basegfx::B2DPolyPolygon(aInnerPoly
));
800 pView
->InsertObjectAtView(pObj
, *pPageView
);
801 SdrObjCreated( *pObj
);
802 SetCurrentObjState( true );
803 pView
->MarkObj( pObj
, pPageView
);
807 void IMapWindow::KeyInput( const KeyEvent
& rKEvt
)
809 GraphCtrl::KeyInput( rKEvt
);
812 void IMapWindow::SelectFirstObject()
814 SdrPage
* pPage
= (SdrPage
*) pModel
->GetPage( 0 );
815 if( pPage
->GetObjCount() != 0 )
818 pView
->UnmarkAllObj();
819 pView
->MarkNextObj(true);
823 void IMapWindow::StartPolyEdit()
827 if( !pView
->AreObjectsMarked() )
828 pView
->MarkNextObj(true);
830 const SdrHdlList
& rHdlList
= pView
->GetHdlList();
831 SdrHdl
* pHdl
= rHdlList
.GetFocusHdl();
835 ((SdrHdlList
&)rHdlList
).TravelFocusHdl(true);
839 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */