xref: /aoo41x/main/svx/source/dialog/imapwnd.hxx (revision 3334a7e6)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _IMAPWND_HXX
24 #define _IMAPWND_HXX
25 
26 #include <vcl/dialog.hxx>
27 #include <vcl/fixed.hxx>
28 #include <vcl/button.hxx>
29 #include <vcl/menu.hxx>
30 #include <svl/itempool.hxx>
31 #include <svtools/imapobj.hxx>
32 #include <svtools/transfer.hxx>
33 #include <svtools/imap.hxx>
34 #include <sfx2/frame.hxx>
35 #include <svx/graphctl.hxx>
36 
37 #include <com/sun/star/frame/XFrame.hpp>
38 
39 /*************************************************************************
40 |*
41 |*
42 |*
43 \************************************************************************/
44 
45 struct NotifyInfo
46 {
47 	String	aMarkURL;
48 	String  aMarkAltText;
49 	String	aMarkTarget;
50 	sal_Bool	bNewObj;
51 	sal_Bool	bOneMarked;
52 	sal_Bool	bActivated;
53 };
54 
55 
56 struct NotifyPosSize
57 {
58 	Size	aPictureSize;
59 	Point	aMousePos;
60 	sal_Bool	bPictureSize;
61 	sal_Bool	bMousePos;
62 };
63 
64 
65 /*************************************************************************
66 |*
67 |*
68 |*
69 \************************************************************************/
70 
71 #define SVD_IMAP_USERDATA	0x0001
72 
73 const sal_uInt32 IMapInventor = sal_uInt32('I') * 0x00000001+
74 							sal_uInt32('M') * 0x00000100+
75 							sal_uInt32('A') * 0x00010000+
76 							sal_uInt32('P') * 0x01000000;
77 
78 
79 typedef boost::shared_ptr< IMapObject > IMapObjectPtr;
80 
81 class IMapUserData : public SdrObjUserData
82 {
83 	// #i98386# use boost::shared_ptr here due to cloning possibilities
84 	IMapObjectPtr			mpObj;
85 
86 public:
87 
IMapUserData()88 							IMapUserData() :
89 								SdrObjUserData	( IMapInventor, SVD_IMAP_USERDATA, 0 ),
90 								mpObj			( ) {}
91 
IMapUserData(const IMapObjectPtr & rIMapObj)92 							IMapUserData( const IMapObjectPtr& rIMapObj ) :
93 								SdrObjUserData	( IMapInventor, SVD_IMAP_USERDATA, 0 ),
94 								mpObj			( rIMapObj ) {}
95 
IMapUserData(const IMapUserData & rIMapUserData)96 							IMapUserData( const IMapUserData& rIMapUserData ) :
97 								SdrObjUserData	( IMapInventor, SVD_IMAP_USERDATA, 0 ),
98 								mpObj			( rIMapUserData.mpObj ) {}
99 
~IMapUserData()100 							~IMapUserData() { }
101 
Clone(SdrObject *) const102     virtual SdrObjUserData* Clone( SdrObject * ) const { return new IMapUserData( *this ); }
103 
SetObject(const IMapObjectPtr & rIMapObj)104 	void					SetObject( const IMapObjectPtr& rIMapObj ) { mpObj = rIMapObj; }
GetObject() const105 	const IMapObjectPtr		GetObject() const { return mpObj; }
ReplaceObject(const IMapObjectPtr & pNewIMapObject)106 	void					ReplaceObject( const IMapObjectPtr& pNewIMapObject ) { mpObj = pNewIMapObject; }
107 };
108 
109 
110 /*************************************************************************
111 |*
112 |*
113 |*
114 \************************************************************************/
115 /* move to cui //CHINA001
116 class URLDlg : public ModalDialog
117 {
118     FixedLine           aFlURL;
119 	FixedText			aFtURL1;
120 	Edit				aEdtURL;
121 	FixedText			aFtURLDescription;
122 	Edit				aEdtURLDescription;
123 	FixedText			aFtTarget;
124 	ComboBox			aCbbTargets;
125 	FixedText			aFtName;
126 	Edit				aEdtName;
127 	OKButton			aBtnOk;
128 	CancelButton		aBtnCancel;
129 
130 public:
131 
132 						URLDlg( Window* pWindow,
133 								const String& rURL, const String& rDescription,
134 								const String& rTarget, const String& rName,
135 								TargetList& rTargetList );
136 
137 	String				GetURL() const { return aEdtURL.GetText(); }
138 	String				GetDescription() const { return aEdtURLDescription.GetText(); }
139 	String				GetTarget() const { return aCbbTargets.GetText(); }
140 	String				GetName() const { return aEdtName.GetText(); }
141 };
142 */
143 
144 /*************************************************************************
145 |*
146 |*
147 |*
148 \************************************************************************/
149 
150 class IMapWindow : public GraphCtrl, public DropTargetHelper
151 {
152 	NotifyInfo			aInfo;
153 	ImageMap			aIMap;
154 	TargetList			aTargetList;
155 	Link				aInfoLink;
156 	SfxItemPool*		pIMapPool;
157 	SfxItemInfo*		pItemInfo;
158     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
159                         mxDocumentFrame;
160 
161 						DECL_LINK( MenuSelectHdl, Menu* );
162 						DECL_LINK( MouseTimerHdl, Timer* );
163 
164 protected:
165 
166 	// GraphCtrl
167 	virtual void		MouseButtonUp(const MouseEvent& rMEvt);
168 	virtual void		Command(const CommandEvent& rCEvt);
169 	virtual void		RequestHelp( const HelpEvent& rHEvt );
170 	virtual void		SdrObjCreated( const SdrObject& rObj );
171 	virtual void		SdrObjChanged( const SdrObject& rObj );
172 	virtual void		MarkListHasChanged();
173 	virtual	void		InitSdrModel();
174 
175 	// DropTargetHelper
176 	virtual sal_Int8	AcceptDrop( const AcceptDropEvent& rEvt );
177 	virtual sal_Int8	ExecuteDrop( const ExecuteDropEvent& rEvt );
178 
179 	void				CreateImageMap();
180 	void				ReplaceImageMap( const ImageMap& rNewImageMap, sal_Bool bScaleToGraphic );
181 
182 	void				ClearTargetList();
183 
184 	SdrObject*			CreateObj( const IMapObject* pIMapObj );
185 	IMapObject*			GetIMapObj( const SdrObject* pSdrObj ) const;
186 	SdrObject*			GetSdrObj( const IMapObject* pIMapObj ) const;
187 	SdrObject*			GetHitSdrObj( const Point& rPosPixel ) const;
188 
189 	void				UpdateInfo( sal_Bool bNewObj );
190 
191 public:
192 
193 						IMapWindow( Window* pParent, const ResId& rResId, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxDocumentFrame );
194 						~IMapWindow();
195 
196 	sal_Bool				ReplaceActualIMapInfo( const NotifyInfo& rNewInfo );
197 
198 	void				SetImageMap( const ImageMap& rImageMap );
199 	const ImageMap&		GetImageMap();
200 
201 	void				SetCurrentObjState( sal_Bool bActive );
202 	void				DoMacroAssign();
203 	void				DoPropertyDialog();
204 
SetInfoLink(const Link & rLink)205 	void				SetInfoLink( const Link& rLink ) { aInfoLink = rLink; }
GetInfoLink() const206 	const Link&			GetInfoLink() const { return aInfoLink; }
207 
208 	void				SetTargetList( TargetList& rTargetList );
GetTargetList() const209 	const TargetList&	GetTargetList() const { return aTargetList; }
210 
GetInfo() const211 	const NotifyInfo&	GetInfo() const { return aInfo; }
212 
213 	void				CreateDefaultObject();
214 	void				SelectFirstObject();
215 	void				StartPolyEdit();
216 
217 	virtual void		KeyInput( const KeyEvent& rKEvt );
218 };
219 
220 
221 #endif
222 
223