Line data Source code
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 _IMAPWND_HXX
20 : #define _IMAPWND_HXX
21 :
22 : #include <vcl/dialog.hxx>
23 : #include <vcl/fixed.hxx>
24 : #include <vcl/button.hxx>
25 : #include <vcl/menu.hxx>
26 : #include <svl/itempool.hxx>
27 : #include <svtools/imapobj.hxx>
28 : #include <svtools/transfer.hxx>
29 : #include <svtools/imap.hxx>
30 : #include <sfx2/frame.hxx>
31 : #include <svx/graphctl.hxx>
32 :
33 : #include <com/sun/star/frame/XFrame.hpp>
34 :
35 0 : struct NotifyInfo
36 : {
37 : String aMarkURL;
38 : String aMarkAltText;
39 : String aMarkTarget;
40 : sal_Bool bNewObj;
41 : sal_Bool bOneMarked;
42 : sal_Bool bActivated;
43 : };
44 :
45 :
46 : struct NotifyPosSize
47 : {
48 : Size aPictureSize;
49 : Point aMousePos;
50 : sal_Bool bPictureSize;
51 : sal_Bool bMousePos;
52 : };
53 :
54 : #define SVD_IMAP_USERDATA 0x0001
55 :
56 : const sal_uInt32 IMapInventor = sal_uInt32('I') * 0x00000001+
57 : sal_uInt32('M') * 0x00000100+
58 : sal_uInt32('A') * 0x00010000+
59 : sal_uInt32('P') * 0x01000000;
60 :
61 :
62 : typedef boost::shared_ptr< IMapObject > IMapObjectPtr;
63 :
64 : class IMapUserData : public SdrObjUserData
65 : {
66 : // #i98386# use boost::shared_ptr here due to cloning possibilities
67 : IMapObjectPtr mpObj;
68 :
69 : public:
70 :
71 : IMapUserData() :
72 : SdrObjUserData ( IMapInventor, SVD_IMAP_USERDATA, 0 ),
73 : mpObj ( ) {}
74 :
75 0 : IMapUserData( const IMapObjectPtr& rIMapObj ) :
76 : SdrObjUserData ( IMapInventor, SVD_IMAP_USERDATA, 0 ),
77 0 : mpObj ( rIMapObj ) {}
78 :
79 0 : IMapUserData( const IMapUserData& rIMapUserData ) :
80 : SdrObjUserData ( IMapInventor, SVD_IMAP_USERDATA, 0 ),
81 0 : mpObj ( rIMapUserData.mpObj ) {}
82 :
83 0 : ~IMapUserData() { }
84 :
85 0 : virtual SdrObjUserData* Clone( SdrObject * ) const { return new IMapUserData( *this ); }
86 :
87 : void SetObject( const IMapObjectPtr& rIMapObj ) { mpObj = rIMapObj; }
88 0 : const IMapObjectPtr GetObject() const { return mpObj; }
89 0 : void ReplaceObject( const IMapObjectPtr& pNewIMapObject ) { mpObj = pNewIMapObject; }
90 : };
91 :
92 : class IMapWindow : public GraphCtrl, public DropTargetHelper
93 : {
94 : NotifyInfo aInfo;
95 : ImageMap aIMap;
96 : TargetList aTargetList;
97 : Link aInfoLink;
98 : SfxItemPool* pIMapPool;
99 : SfxItemInfo* pItemInfo;
100 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
101 : mxDocumentFrame;
102 :
103 : DECL_LINK( MenuSelectHdl, Menu* );
104 : DECL_LINK( MouseTimerHdl, Timer* );
105 :
106 : protected:
107 :
108 : // GraphCtrl
109 : virtual void MouseButtonUp(const MouseEvent& rMEvt);
110 : virtual void Command(const CommandEvent& rCEvt);
111 : virtual void RequestHelp( const HelpEvent& rHEvt );
112 : virtual void SdrObjCreated( const SdrObject& rObj );
113 : virtual void SdrObjChanged( const SdrObject& rObj );
114 : virtual void MarkListHasChanged();
115 : virtual void InitSdrModel();
116 :
117 : // DropTargetHelper
118 : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
119 : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
120 :
121 : void CreateImageMap();
122 : void ReplaceImageMap( const ImageMap& rNewImageMap, sal_Bool bScaleToGraphic );
123 :
124 : void ClearTargetList();
125 :
126 : SdrObject* CreateObj( const IMapObject* pIMapObj );
127 : IMapObject* GetIMapObj( const SdrObject* pSdrObj ) const;
128 : SdrObject* GetHitSdrObj( const Point& rPosPixel ) const;
129 :
130 : void UpdateInfo( sal_Bool bNewObj );
131 :
132 : public:
133 :
134 : IMapWindow( Window* pParent, const ResId& rResId, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxDocumentFrame );
135 : ~IMapWindow();
136 :
137 : sal_Bool ReplaceActualIMapInfo( const NotifyInfo& rNewInfo );
138 :
139 : void SetImageMap( const ImageMap& rImageMap );
140 : const ImageMap& GetImageMap();
141 :
142 : void SetCurrentObjState( sal_Bool bActive );
143 : void DoMacroAssign();
144 : void DoPropertyDialog();
145 :
146 0 : void SetInfoLink( const Link& rLink ) { aInfoLink = rLink; }
147 : const Link& GetInfoLink() const { return aInfoLink; }
148 :
149 : void SetTargetList( TargetList& rTargetList );
150 : const TargetList& GetTargetList() const { return aTargetList; }
151 :
152 0 : const NotifyInfo& GetInfo() const { return aInfo; }
153 :
154 : void CreateDefaultObject();
155 : void SelectFirstObject();
156 : void StartPolyEdit();
157 :
158 : virtual void KeyInput( const KeyEvent& rKEvt );
159 : };
160 :
161 :
162 : #endif
163 :
164 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|