1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 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/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 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 . 18 */ 19 #ifndef INCLUDED_SVX_SOURCE_DIALOG_IMAPWND_HXX 20 #define INCLUDED_SVX_SOURCE_DIALOG_IMAPWND_HXX 21 22 #include <vcl/imapobj.hxx> 23 #include <vcl/transfer.hxx> 24 #include <vcl/imap.hxx> 25 #include <sfx2/frame.hxx> 26 #include <svx/graphctl.hxx> 27 #include <svl/itempool.hxx> 28 29 #include <com/sun/star/frame/XFrame.hpp> 30 31 struct NotifyInfo 32 { 33 OUString aMarkURL; 34 OUString aMarkAltText; 35 OUString aMarkTarget; 36 bool bNewObj; 37 bool bOneMarked; 38 bool bActivated; 39 }; 40 41 42 #define SVD_IMAP_USERDATA 0x0001 43 44 typedef std::shared_ptr< IMapObject > IMapObjectPtr; 45 46 class IMapUserData : public SdrObjUserData 47 { 48 // #i98386# use std::shared_ptr here due to cloning possibilities 49 IMapObjectPtr mpObj; 50 51 public: 52 IMapUserData(const IMapObjectPtr & rIMapObj)53 explicit IMapUserData( const IMapObjectPtr& rIMapObj ) : 54 SdrObjUserData ( SdrInventor::IMap, SVD_IMAP_USERDATA ), 55 mpObj ( rIMapObj ) {} 56 IMapUserData(const IMapUserData & rIMapUserData)57 IMapUserData( const IMapUserData& rIMapUserData ) : 58 SdrObjUserData ( SdrInventor::IMap, SVD_IMAP_USERDATA ), 59 mpObj ( rIMapUserData.mpObj ) {} 60 Clone(SdrObject *) const61 virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject * ) const override { return std::unique_ptr<SdrObjUserData>(new IMapUserData( *this )); } 62 GetObject() const63 const IMapObjectPtr& GetObject() const { return mpObj; } ReplaceObject(const IMapObjectPtr & pNewIMapObject)64 void ReplaceObject( const IMapObjectPtr& pNewIMapObject ) { mpObj = pNewIMapObject; } 65 }; 66 67 class IMapWindow; 68 69 class IMapDropTargetHelper final : public DropTargetHelper 70 { 71 IMapWindow& m_rImapWindow; 72 public: 73 IMapDropTargetHelper(IMapWindow& rImapWindow); 74 75 // DropTargetHelper 76 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; 77 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; 78 }; 79 80 class IMapWindow final : public GraphCtrl 81 { 82 NotifyInfo aInfo; 83 ImageMap aIMap; 84 TargetList aTargetList; 85 Link<IMapWindow&,void> aInfoLink; 86 SfxItemPool* pIMapPool; 87 SfxItemInfo maItemInfos[1] = {}; 88 css::uno::Reference< css::frame::XFrame > 89 mxDocumentFrame; 90 std::unique_ptr<IMapDropTargetHelper> mxDropTargetHelper; 91 std::unique_ptr<weld::Menu> mxPopupMenu; 92 93 void MenuSelectHdl(const OString& rId); 94 95 // GraphCtrl 96 virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; 97 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; 98 virtual bool Command(const CommandEvent& rCEvt) override; 99 virtual OUString RequestHelp(tools::Rectangle& rHelpArea) override; 100 virtual void SdrObjCreated( const SdrObject& rObj ) override; 101 virtual void SdrObjChanged( const SdrObject& rObj ) override; 102 virtual void MarkListHasChanged() override; 103 virtual void InitSdrModel() override; 104 105 void ReplaceImageMap( const ImageMap& rNewImageMap ); 106 107 SdrObject* CreateObj( const IMapObject* pIMapObj ); 108 static IMapObject* GetIMapObj( const SdrObject* pSdrObj ); 109 SdrObject* GetHitSdrObj( const Point& rPosPixel ) const; 110 111 void UpdateInfo( bool bNewObj ); 112 113 public: 114 115 IMapWindow(const css::uno::Reference< css::frame::XFrame >& rxDocumentFrame, 116 weld::Dialog* pDialog); 117 virtual ~IMapWindow() override; 118 119 sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); 120 sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); 121 122 void ReplaceActualIMapInfo( const NotifyInfo& rNewInfo ); 123 124 void SetImageMap( const ImageMap& rImageMap ); 125 const ImageMap& GetImageMap(); 126 127 void SetCurrentObjState( bool bActive ); 128 void DoMacroAssign(); 129 void DoPropertyDialog(); 130 SetInfoLink(const Link<IMapWindow &,void> & rLink)131 void SetInfoLink( const Link<IMapWindow&,void>& rLink ) { aInfoLink = rLink; } 132 133 void SetTargetList( TargetList& rTargetList ); 134 GetInfo() const135 const NotifyInfo& GetInfo() const { return aInfo; } 136 }; 137 138 139 #endif 140 141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 142