ScriptForge - Methods about data arrays
[LibreOffice.git] / svx / source / dialog / imapwnd.cxx
blob66a367f0d8bc7ce161bf5b6394e075a7afed3fb2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/commandevent.hxx>
22 #include <vcl/imaprect.hxx>
23 #include <vcl/imapcirc.hxx>
24 #include <vcl/imappoly.hxx>
25 #include <vcl/svapp.hxx>
26 #include <svl/urlbmk.hxx>
28 #include <svx/svxids.hrc>
29 #include "imapwnd.hxx"
30 #include <svx/svdpage.hxx>
31 #include <svx/svdorect.hxx>
32 #include <svx/svdocirc.hxx>
33 #include <svx/svdopath.hxx>
34 #include <svx/xfltrit.hxx>
35 #include <svx/svdpagv.hxx>
36 #include <svx/xfillit0.hxx>
37 #include <svx/xflclit.hxx>
38 #include <svx/xlnclit.hxx>
40 #include <sfx2/evntconf.hxx>
42 #include <sot/formats.hxx>
44 #include <svx/svxdlg.hxx>
45 #include <basegfx/polygon/b2dpolygon.hxx>
46 #include <memory>
48 using namespace com::sun::star;
49 using ::com::sun::star::frame::XFrame;
50 using ::com::sun::star::uno::Reference;
52 #define TRANSCOL COL_WHITE
54 static ItemInfoPackage& getItemInfoPackageIMapWindow()
56 class ItemInfoPackageIMapWindow : public ItemInfoPackage
58 typedef std::array<ItemInfoStatic, 1> ItemInfoArrayIMapWindow;
59 ItemInfoArrayIMapWindow maItemInfos {{
60 // m_nWhich, m_pItem, m_nSlotID, m_nItemInfoFlags
61 { SID_ATTR_MACROITEM, new SvxMacroItem(SID_ATTR_MACROITEM), 0, SFX_ITEMINFOFLAG_NONE }
62 }};
64 virtual const ItemInfoStatic& getItemInfoStatic(size_t nIndex) const override { return maItemInfos[nIndex]; }
66 public:
67 virtual size_t size() const override { return maItemInfos.size(); }
68 virtual const ItemInfo& getItemInfo(size_t nIndex, SfxItemPool& /*rPool*/) override { return maItemInfos[nIndex]; }
71 static std::unique_ptr<ItemInfoPackageIMapWindow> g_aItemInfoPackageIMapWindow;
72 if (!g_aItemInfoPackageIMapWindow)
73 g_aItemInfoPackageIMapWindow.reset(new ItemInfoPackageIMapWindow);
74 return *g_aItemInfoPackageIMapWindow;
77 IMapWindow::IMapWindow(const Reference< XFrame >& rxDocumentFrame, weld::Dialog* pDialog)
78 : GraphCtrl(pDialog)
79 , mxDocumentFrame(rxDocumentFrame)
81 pIMapPool = new SfxItemPool(u"IMapItemPool"_ustr);
82 pIMapPool->registerItemInfoPackage(getItemInfoPackageIMapWindow());
85 IMapWindow::~IMapWindow()
89 void IMapWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea)
91 Size aSize(pDrawingArea->get_ref_device().LogicToPixel(Size(270, 170), MapMode(MapUnit::MapAppFont)));
92 pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
93 SetOutputSizePixel(aSize);
94 weld::CustomWidgetController::SetDrawingArea(pDrawingArea);
96 SetSdrMode(true);
98 mxDropTargetHelper.reset(new IMapDropTargetHelper(*this));
101 void IMapWindow::SetImageMap( const ImageMap& rImageMap )
103 ReplaceImageMap( rImageMap );
106 void IMapWindow::ReplaceImageMap( const ImageMap& rImageMap )
108 SdrPage* pPage = nullptr;
109 aIMap = rImageMap;
111 if(GetSdrModel())
113 // try to access page
114 pPage = GetSdrModel()->GetPage(0);
117 if(pPage)
119 // clear SdrObjects with broadcasting
120 pPage->ClearSdrObjList();
123 if(GetSdrView())
125 // #i63762# reset selection at view
126 GetSdrView()->UnmarkAllObj();
129 // create new drawing objects
130 const sal_uInt16 nCount(rImageMap.GetIMapObjectCount());
132 for ( sal_uInt16 i(nCount); i > 0; i-- )
134 rtl::Reference<SdrObject> pNewObj = CreateObj( rImageMap.GetIMapObject( i - 1 ) );
136 if (pNewObj && pPage)
138 pPage->InsertObject( pNewObj.get() );
143 void IMapWindow::ReplaceActualIMapInfo( const NotifyInfo& rNewInfo )
145 const SdrObject* pSdrObj = GetSelectedSdrObject();
147 if ( pSdrObj )
149 IMapObject* pIMapObj = GetIMapObj( pSdrObj );
150 if (pIMapObj)
152 pIMapObj->SetURL( rNewInfo.aMarkURL );
153 pIMapObj->SetAltText( rNewInfo.aMarkAltText );
154 pIMapObj->SetTarget( rNewInfo.aMarkTarget );
155 pModel->SetChanged();
156 UpdateInfo( false );
161 const ImageMap& IMapWindow::GetImageMap()
163 if ( pModel->IsChanged() )
165 SdrPage* pPage = pModel->GetPage( 0 );
167 if ( pPage )
169 const size_t nCount = pPage->GetObjCount();
171 aIMap.ClearImageMap();
173 for ( size_t i = nCount; i; )
175 --i;
176 aIMap.InsertIMapObject( *( static_cast<IMapUserData*>( pPage->GetObj( i )->GetUserData( 0 ) )->GetObject() ) );
180 pModel->SetChanged( false );
183 return aIMap;
186 void IMapWindow::SetTargetList( const TargetList& rTargetList )
188 // Delete old List
189 // Fill with the provided list
190 aTargetList = rTargetList;
192 pModel->SetChanged( false );
195 rtl::Reference<SdrObject> IMapWindow::CreateObj( const IMapObject* pIMapObj )
197 tools::Rectangle aClipRect( Point(), GetGraphicSize() );
198 rtl::Reference<SdrObject> pSdrObj;
199 IMapObjectPtr pCloneIMapObj;
201 switch( pIMapObj->GetType() )
203 case IMapObjectType::Rectangle:
205 const IMapRectangleObject* pIMapRectObj = static_cast<const IMapRectangleObject*>(pIMapObj);
206 tools::Rectangle aDrawRect( pIMapRectObj->GetRectangle( false ) );
208 // clipped on CanvasPane
209 aDrawRect.Intersection( aClipRect );
211 pSdrObj = new SdrRectObj(*pModel, aDrawRect);
212 pCloneIMapObj.reset(static_cast<IMapObject*>(new IMapRectangleObject( *pIMapRectObj )));
214 break;
216 case IMapObjectType::Circle:
218 const IMapCircleObject* pIMapCircleObj = static_cast<const IMapCircleObject*>(pIMapObj);
219 const Point aCenter( pIMapCircleObj->GetCenter( false ) );
220 const tools::Long nRadius = pIMapCircleObj->GetRadius( false );
221 const Point aOffset( nRadius, nRadius );
222 tools::Rectangle aCircle( aCenter - aOffset, aCenter + aOffset );
224 // limited to CanvasPane
225 aCircle.Intersection( aClipRect );
227 pSdrObj = new SdrCircObj(
228 *pModel,
229 SdrCircKind::Full,
230 aCircle,
231 0_deg100,
232 36000_deg100);
233 pCloneIMapObj.reset(static_cast<IMapObject*>(new IMapCircleObject( *pIMapCircleObj )));
235 break;
237 case IMapObjectType::Polygon:
239 const IMapPolygonObject* pIMapPolyObj = static_cast<const IMapPolygonObject*>(pIMapObj);
241 // If it actually is an ellipse, then another ellipse is created again
242 if ( pIMapPolyObj->HasExtraEllipse() )
244 tools::Rectangle aDrawRect( pIMapPolyObj->GetExtraEllipse() );
246 // clipped on CanvasPane
247 aDrawRect.Intersection( aClipRect );
249 pSdrObj = new SdrCircObj(
250 *pModel,
251 SdrCircKind::Full,
252 aDrawRect,
253 0_deg100,
254 36000_deg100);
256 else
258 const tools::Polygon aPoly = pIMapPolyObj->GetPolygon( false );
259 tools::Polygon aDrawPoly( aPoly );
261 // clipped on CanvasPane
262 aDrawPoly.Clip( aClipRect );
264 basegfx::B2DPolygon aPolygon;
265 aPolygon.append(aDrawPoly.getB2DPolygon());
266 pSdrObj = new SdrPathObj(
267 *pModel,
268 SdrObjKind::Polygon,
269 basegfx::B2DPolyPolygon(aPolygon));
272 pCloneIMapObj.reset(static_cast<IMapObject*>(new IMapPolygonObject( *pIMapPolyObj )));
274 break;
276 default:
277 break;
280 if ( pSdrObj )
282 SfxItemSet aSet( pModel->GetItemPool() );
284 aSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) );
285 aSet.Put( XFillColorItem( u""_ustr, TRANSCOL ) );
287 if ( !pIMapObj->IsActive() )
289 aSet.Put( XFillTransparenceItem( 100 ) );
290 aSet.Put( XLineColorItem( u""_ustr, COL_RED ) );
292 else
294 aSet.Put( XFillTransparenceItem( 50 ) );
295 aSet.Put( XLineColorItem( u""_ustr, COL_BLACK ) );
298 pSdrObj->SetMergedItemSetAndBroadcast(aSet);
300 pSdrObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new IMapUserData( std::move(pCloneIMapObj) )) );
301 pSdrObj->SetUserCall( GetSdrUserCall() );
304 return pSdrObj;
307 void IMapWindow::InitSdrModel()
309 GraphCtrl::InitSdrModel();
311 SfxItemSet aSet( pModel->GetItemPool() );
313 aSet.Put( XFillColorItem( u""_ustr, TRANSCOL ) );
314 aSet.Put( XFillTransparenceItem( 50 ) );
315 pView->SetAttributes( aSet );
316 pView->SetFrameDragSingles();
319 void IMapWindow::SdrObjCreated( const SdrObject& rObj )
321 switch( rObj.GetObjIdentifier() )
323 case SdrObjKind::Rectangle:
325 SdrRectObj* pRectObj = const_cast<SdrRectObj*>(static_cast<const SdrRectObj*>(&rObj));
326 auto pObj = std::make_shared<IMapRectangleObject>( pRectObj->GetLogicRect(), "", "", "", "", "", true, false );
328 pRectObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new IMapUserData( pObj )) );
330 break;
332 case SdrObjKind::CircleOrEllipse:
334 SdrCircObj* pCircObj = const_cast<SdrCircObj*>( static_cast<const SdrCircObj*>(&rObj) );
335 rtl::Reference<SdrPathObj> pPathObj = static_cast<SdrPathObj*>( pCircObj->ConvertToPolyObj( false, false ).get() );
336 tools::Polygon aPoly(pPathObj->GetPathPoly().getB2DPolygon(0));
338 pPathObj.clear();
340 auto pObj = std::make_shared<IMapPolygonObject>( aPoly, "", "", "", "", "", true, false );
341 pObj->SetExtraEllipse( aPoly.GetBoundRect() );
342 pCircObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new IMapUserData( pObj )) );
344 break;
346 case SdrObjKind::Polygon:
347 case SdrObjKind::FreehandFill:
348 case SdrObjKind::PathPoly:
349 case SdrObjKind::PathFill:
351 SdrPathObj* pPathObj = const_cast<SdrPathObj*>( static_cast<const SdrPathObj*>(&rObj) );
352 const basegfx::B2DPolyPolygon& rXPolyPoly = pPathObj->GetPathPoly();
354 if ( rXPolyPoly.count() )
356 tools::Polygon aPoly(rXPolyPoly.getB2DPolygon(0));
357 auto pObj = std::make_shared<IMapPolygonObject>( aPoly, "", "", "", "", "", true, false );
358 pPathObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new IMapUserData( pObj )) );
361 break;
363 default:
364 break;
368 void IMapWindow::SdrObjChanged( const SdrObject& rObj )
370 IMapUserData* pUserData = static_cast<IMapUserData*>( rObj.GetUserData( 0 ) );
372 if ( !pUserData )
373 return;
375 OUString aURL;
376 OUString aAltText;
377 OUString aDesc;
378 OUString aTarget;
379 IMapObjectPtr pIMapObj = pUserData->GetObject();
380 bool bActive = true;
382 if ( pIMapObj )
384 aURL = pIMapObj->GetURL();
385 aAltText = pIMapObj->GetAltText();
386 aDesc = pIMapObj->GetDesc();
387 aTarget = pIMapObj->GetTarget();
388 bActive = pIMapObj->IsActive();
391 switch( rObj.GetObjIdentifier() )
393 case SdrObjKind::Rectangle:
395 pUserData->ReplaceObject( std::make_shared<IMapRectangleObject>( static_cast<const SdrRectObj&>(rObj).GetLogicRect(),
396 aURL, aAltText, aDesc, aTarget, "", bActive, false ) );
398 break;
400 case SdrObjKind::CircleOrEllipse:
402 const SdrCircObj& rCircObj = static_cast<const SdrCircObj&>(rObj);
403 rtl::Reference<SdrPathObj> pPathObj = static_cast<SdrPathObj*>( rCircObj.ConvertToPolyObj( false, false ).get() );
404 tools::Polygon aPoly(pPathObj->GetPathPoly().getB2DPolygon(0));
406 auto pObj = std::make_shared<IMapPolygonObject>( aPoly, aURL, aAltText, aDesc, aTarget, "", bActive, false );
407 pObj->SetExtraEllipse( aPoly.GetBoundRect() );
409 pPathObj.clear();
411 pUserData->ReplaceObject( pObj );
413 break;
415 case SdrObjKind::Polygon:
416 case SdrObjKind::FreehandFill:
417 case SdrObjKind::PathPoly:
418 case SdrObjKind::PathFill:
420 const SdrPathObj& rPathObj = static_cast<const SdrPathObj&>(rObj);
421 const basegfx::B2DPolyPolygon& rXPolyPoly = rPathObj.GetPathPoly();
423 if ( rXPolyPoly.count() )
425 tools::Polygon aPoly(rPathObj.GetPathPoly().getB2DPolygon(0));
426 auto pObj = std::make_shared<IMapPolygonObject>( aPoly, aURL, aAltText, aDesc, aTarget, "", bActive, false );
427 pUserData->ReplaceObject( pObj );
430 break;
432 default:
433 break;
437 bool IMapWindow::MouseButtonUp(const MouseEvent& rMEvt)
439 bool bRet = GraphCtrl::MouseButtonUp( rMEvt );
440 UpdateInfo( true );
441 return bRet;
444 void IMapWindow::MarkListHasChanged()
446 GraphCtrl::MarkListHasChanged();
447 UpdateInfo( false );
450 SdrObject* IMapWindow::GetHitSdrObj( const Point& rPosPixel ) const
452 OutputDevice& rDevice = GetDrawingArea()->get_ref_device();
454 SdrObject* pObj = nullptr;
455 Point aPt = rDevice.PixelToLogic( rPosPixel );
457 if ( tools::Rectangle( Point(), GetGraphicSize() ).Contains( aPt ) )
459 SdrPage* pPage = pModel->GetPage( 0 );
460 if ( pPage )
462 for ( size_t i = pPage->GetObjCount(); i > 0; )
464 --i;
465 SdrObject* pTestObj = pPage->GetObj( i );
466 IMapObject* pIMapObj = GetIMapObj( pTestObj );
468 if ( pIMapObj && pIMapObj->IsHit( aPt ) )
470 pObj = pTestObj;
471 break;
477 return pObj;
480 IMapObject* IMapWindow::GetIMapObj( const SdrObject* pSdrObj )
482 IMapObject* pIMapObj = nullptr;
484 if ( pSdrObj )
486 IMapUserData* pUserData = static_cast<IMapUserData*>( pSdrObj->GetUserData( 0 ) );
488 if ( pUserData )
489 pIMapObj = pUserData->GetObject().get();
492 return pIMapObj;
495 bool IMapWindow::Command(const CommandEvent& rCEvt)
497 if ( rCEvt.GetCommand() == CommandEventId::ContextMenu )
499 std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetDrawingArea(), u"svx/ui/imapmenu.ui"_ustr));
500 mxPopupMenu = xBuilder->weld_menu(u"menu"_ustr);
501 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
502 const size_t nMarked = rMarkList.GetMarkCount();
504 mxPopupMenu->set_sensitive(u"url"_ustr, false);
505 mxPopupMenu->set_sensitive(u"active"_ustr, false);
506 mxPopupMenu->set_sensitive(u"macro"_ustr, false);
507 mxPopupMenu->set_sensitive(u"selectall"_ustr, pModel->GetPage(0)->GetObjCount() != rMarkList.GetMarkCount());
509 if ( !nMarked )
511 mxPopupMenu->set_sensitive(u"arrange"_ustr, false);
512 mxPopupMenu->set_sensitive(u"delete"_ustr, false);
514 else
516 if ( nMarked == 1 )
518 SdrObject* pSdrObj = GetSelectedSdrObject();
520 mxPopupMenu->set_sensitive(u"url"_ustr, true);
521 mxPopupMenu->set_sensitive(u"active"_ustr, true);
522 mxPopupMenu->set_sensitive(u"macro"_ustr, true);
523 mxPopupMenu->set_active(u"active"_ustr, GetIMapObj(pSdrObj)->IsActive());
526 mxPopupMenu->set_sensitive(u"arrange"_ustr, true);
527 mxPopupMenu->set_sensitive(u"delete"_ustr, true);
530 MenuSelectHdl(mxPopupMenu->popup_at_rect(GetDrawingArea(), tools::Rectangle(rCEvt.GetMousePosPixel(), Size(1,1))));
532 mxPopupMenu.reset();
534 return true;
536 return CustomWidgetController::Command(rCEvt);
539 IMapDropTargetHelper::IMapDropTargetHelper(IMapWindow& rImapWindow)
540 : DropTargetHelper(rImapWindow.GetDrawingArea()->get_drop_target())
541 , m_rImapWindow(rImapWindow)
545 sal_Int8 IMapDropTargetHelper::AcceptDrop( const AcceptDropEvent& rEvt )
547 return m_rImapWindow.AcceptDrop(rEvt);
550 sal_Int8 IMapDropTargetHelper::ExecuteDrop( const ExecuteDropEvent& rEvt )
552 return m_rImapWindow.ExecuteDrop(rEvt);
555 sal_Int8 IMapWindow::AcceptDrop( const AcceptDropEvent& rEvt )
557 return( ( GetHitSdrObj( rEvt.maPosPixel ) != nullptr ) ? rEvt.mnAction : DND_ACTION_NONE );
560 sal_Int8 IMapWindow::ExecuteDrop( const ExecuteDropEvent& rEvt )
562 sal_Int8 nRet = DND_ACTION_NONE;
564 if (mxDropTargetHelper->IsDropFormatSupported(SotClipboardFormatId::NETSCAPE_BOOKMARK))
566 INetBookmark aBookMark( u""_ustr, u""_ustr );
567 SdrObject* pSdrObj = GetHitSdrObj( rEvt.maPosPixel );
569 if( pSdrObj && TransferableDataHelper( rEvt.maDropEvent.Transferable ).GetINetBookmark( SotClipboardFormatId::NETSCAPE_BOOKMARK, aBookMark ) )
571 IMapObject* pIMapObj = GetIMapObj( pSdrObj );
573 pIMapObj->SetURL( aBookMark.GetURL() );
574 pIMapObj->SetAltText( aBookMark.GetDescription() );
575 pModel->SetChanged();
576 pView->UnmarkAll();
577 pView->MarkObj( pSdrObj, pView->GetSdrPageView() );
578 UpdateInfo( true );
579 nRet = rEvt.mnAction;
583 return nRet;
586 OUString IMapWindow::RequestHelp(tools::Rectangle& rHelpArea)
588 OutputDevice& rDevice = GetDrawingArea()->get_ref_device();
590 Point aPos = rDevice.PixelToLogic(rHelpArea.TopLeft());
592 SdrPageView* pPageView = nullptr;
593 SdrObject* pSdrObj = pView->PickObj(aPos, pView->getHitTolLog(), pPageView);
594 if (pSdrObj)
596 const IMapObject* pIMapObj = GetIMapObj( pSdrObj );
597 if ( pIMapObj )
599 OUString aStr = pIMapObj->GetURL();
600 if ( !aStr.isEmpty() )
602 rHelpArea = rDevice.LogicToPixel(tools::Rectangle( Point(), GetGraphicSize()));
603 return aStr;
608 return OUString();
611 void IMapWindow::SetCurrentObjState( bool bActive )
613 SdrObject* pObj = GetSelectedSdrObject();
615 if ( !pObj )
616 return;
618 SfxItemSet aSet( pModel->GetItemPool() );
620 GetIMapObj( pObj )->SetActive( bActive );
622 aSet.Put( XFillColorItem( u""_ustr, TRANSCOL ) );
624 if ( !bActive )
626 aSet.Put( XFillTransparenceItem( 100 ) );
627 aSet.Put( XLineColorItem( u""_ustr, COL_RED ) );
629 else
631 aSet.Put( XFillTransparenceItem( 50 ) );
632 aSet.Put( XLineColorItem( u""_ustr, COL_BLACK ) );
635 pView->SetAttributes( aSet );
638 void IMapWindow::UpdateInfo( bool bNewObj )
640 if ( !aInfoLink.IsSet() )
641 return;
643 const SdrObject* pSdrObj = GetSelectedSdrObject();
644 const IMapObject* pIMapObj = pSdrObj ? GetIMapObj( pSdrObj ) : nullptr;
646 aInfo.bNewObj = bNewObj;
648 if ( pIMapObj )
650 aInfo.bOneMarked = true;
651 aInfo.aMarkURL = pIMapObj->GetURL();
652 aInfo.aMarkAltText = pIMapObj->GetAltText();
653 aInfo.aMarkTarget = pIMapObj->GetTarget();
654 aInfo.bActivated = pIMapObj->IsActive();
655 aInfoLink.Call( *this );
657 else
659 aInfo.aMarkURL.clear();
660 aInfo.aMarkAltText.clear();
661 aInfo.aMarkTarget.clear();
662 aInfo.bOneMarked = false;
663 aInfo.bActivated = false;
666 aInfoLink.Call( *this );
669 void IMapWindow::DoMacroAssign()
671 SdrObject* pSdrObj = GetSelectedSdrObject();
673 if ( !pSdrObj )
674 return;
676 auto xSet = std::make_unique<SfxItemSetFixed<SID_ATTR_MACROITEM, SID_ATTR_MACROITEM, SID_EVENTCONFIG, SID_EVENTCONFIG>>
677 (*pIMapPool);
679 SfxEventNamesItem aNamesItem(SID_EVENTCONFIG);
680 aNamesItem.AddEvent( u"MouseOver"_ustr, u""_ustr, SvMacroItemId::OnMouseOver );
681 aNamesItem.AddEvent( u"MouseOut"_ustr, u""_ustr, SvMacroItemId::OnMouseOut );
682 xSet->Put( aNamesItem );
684 SvxMacroItem aMacroItem(SID_ATTR_MACROITEM);
685 IMapObject* pIMapObj = GetIMapObj( pSdrObj );
686 aMacroItem.SetMacroTable( pIMapObj->GetMacroTable() );
687 xSet->Put( aMacroItem );
689 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
690 VclPtr<SfxAbstractDialog> pMacroDlg(pFact->CreateEventConfigDialog(GetDrawingArea(), std::move(xSet), mxDocumentFrame));
692 pMacroDlg->StartExecuteAsync(
693 [this, pMacroDlg, pIMapObj] (sal_Int32 nResult)->void
695 if (nResult == RET_OK)
697 const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet();
698 pIMapObj->SetMacroTable( pOutSet->Get( SID_ATTR_MACROITEM ).GetMacroTable() );
699 pModel->SetChanged();
700 UpdateInfo( false );
702 pMacroDlg->disposeOnce();
707 void IMapWindow::DoPropertyDialog()
709 SdrObject* pSdrObj = GetSelectedSdrObject();
711 if ( !pSdrObj )
712 return;
714 IMapObject* pIMapObj = GetIMapObj( pSdrObj );
715 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
716 ScopedVclPtr<AbstractURLDlg> aDlg(pFact->CreateURLDialog(GetDrawingArea(), pIMapObj->GetURL(), pIMapObj->GetAltText(), pIMapObj->GetDesc(),
717 pIMapObj->GetTarget(), pIMapObj->GetName(), aTargetList));
718 if ( aDlg->Execute() != RET_OK )
719 return;
721 const OUString aURLText( aDlg->GetURL() );
723 if ( !aURLText.isEmpty() )
725 INetURLObject aObj( aURLText, INetProtocol::File );
726 DBG_ASSERT( aObj.GetProtocol() != INetProtocol::NotValid, "Invalid URL" );
727 pIMapObj->SetURL( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
729 else
730 pIMapObj->SetURL( aURLText );
732 pIMapObj->SetAltText( aDlg->GetAltText() );
733 pIMapObj->SetDesc( aDlg->GetDesc() );
734 pIMapObj->SetTarget( aDlg->GetTarget() );
735 pIMapObj->SetName( aDlg->GetName() );
736 pModel->SetChanged();
737 UpdateInfo( true );
740 void IMapWindow::MenuSelectHdl(const OUString& rId)
742 if (rId == "url")
743 DoPropertyDialog();
744 else if (rId == "macro")
745 DoMacroAssign();
746 else if (rId == "active")
748 const bool bNewState = !mxPopupMenu->get_active(rId);
749 SetCurrentObjState(bNewState);
750 UpdateInfo( false );
752 else if (rId == "front")
753 pView->PutMarkedToTop();
754 else if (rId == "forward")
755 pView->MovMarkedToTop();
756 else if (rId == "backward")
757 pView->MovMarkedToBtm();
758 else if (rId == "back")
759 pView->PutMarkedToBtm();
760 else if (rId == "selectall")
761 pView->MarkAll();
762 else if (rId == "delete")
763 pView->DeleteMarked();
766 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */