xref: /trunk/main/svx/source/dialog/imapwnd.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _IMAPWND_HXX
28*cdf0e10cSrcweir #define _IMAPWND_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <vcl/dialog.hxx>
31*cdf0e10cSrcweir #include <vcl/fixed.hxx>
32*cdf0e10cSrcweir #include <vcl/button.hxx>
33*cdf0e10cSrcweir #include <vcl/menu.hxx>
34*cdf0e10cSrcweir #include <svl/itempool.hxx>
35*cdf0e10cSrcweir #include <svtools/imapobj.hxx>
36*cdf0e10cSrcweir #include <svtools/transfer.hxx>
37*cdf0e10cSrcweir #include <svtools/imap.hxx>
38*cdf0e10cSrcweir #include <sfx2/frame.hxx>
39*cdf0e10cSrcweir #include <svx/graphctl.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir /*************************************************************************
44*cdf0e10cSrcweir |*
45*cdf0e10cSrcweir |*
46*cdf0e10cSrcweir |*
47*cdf0e10cSrcweir \************************************************************************/
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir struct NotifyInfo
50*cdf0e10cSrcweir {
51*cdf0e10cSrcweir     String  aMarkURL;
52*cdf0e10cSrcweir     String  aMarkAltText;
53*cdf0e10cSrcweir     String  aMarkTarget;
54*cdf0e10cSrcweir     sal_Bool    bNewObj;
55*cdf0e10cSrcweir     sal_Bool    bOneMarked;
56*cdf0e10cSrcweir     sal_Bool    bActivated;
57*cdf0e10cSrcweir };
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir struct NotifyPosSize
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir     Size    aPictureSize;
63*cdf0e10cSrcweir     Point   aMousePos;
64*cdf0e10cSrcweir     sal_Bool    bPictureSize;
65*cdf0e10cSrcweir     sal_Bool    bMousePos;
66*cdf0e10cSrcweir };
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir /*************************************************************************
70*cdf0e10cSrcweir |*
71*cdf0e10cSrcweir |*
72*cdf0e10cSrcweir |*
73*cdf0e10cSrcweir \************************************************************************/
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir #define SVD_IMAP_USERDATA   0x0001
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir const sal_uInt32 IMapInventor = sal_uInt32('I') * 0x00000001+
78*cdf0e10cSrcweir                             sal_uInt32('M') * 0x00000100+
79*cdf0e10cSrcweir                             sal_uInt32('A') * 0x00010000+
80*cdf0e10cSrcweir                             sal_uInt32('P') * 0x01000000;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir typedef boost::shared_ptr< IMapObject > IMapObjectPtr;
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir class IMapUserData : public SdrObjUserData
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir     // #i98386# use boost::shared_ptr here due to cloning possibilities
88*cdf0e10cSrcweir     IMapObjectPtr           mpObj;
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir public:
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir                             IMapUserData() :
93*cdf0e10cSrcweir                                 SdrObjUserData  ( IMapInventor, SVD_IMAP_USERDATA, 0 ),
94*cdf0e10cSrcweir                                 mpObj           ( ) {}
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir                             IMapUserData( const IMapObjectPtr& rIMapObj ) :
97*cdf0e10cSrcweir                                 SdrObjUserData  ( IMapInventor, SVD_IMAP_USERDATA, 0 ),
98*cdf0e10cSrcweir                                 mpObj           ( rIMapObj ) {}
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir                             IMapUserData( const IMapUserData& rIMapUserData ) :
101*cdf0e10cSrcweir                                 SdrObjUserData  ( IMapInventor, SVD_IMAP_USERDATA, 0 ),
102*cdf0e10cSrcweir                                 mpObj           ( rIMapUserData.mpObj ) {}
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir                             ~IMapUserData() { }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     virtual SdrObjUserData* Clone( SdrObject * ) const { return new IMapUserData( *this ); }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir     void                    SetObject( const IMapObjectPtr& rIMapObj ) { mpObj = rIMapObj; }
109*cdf0e10cSrcweir     const IMapObjectPtr     GetObject() const { return mpObj; }
110*cdf0e10cSrcweir     void                    ReplaceObject( const IMapObjectPtr& pNewIMapObject ) { mpObj = pNewIMapObject; }
111*cdf0e10cSrcweir };
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir /*************************************************************************
115*cdf0e10cSrcweir |*
116*cdf0e10cSrcweir |*
117*cdf0e10cSrcweir |*
118*cdf0e10cSrcweir \************************************************************************/
119*cdf0e10cSrcweir /* move to cui //CHINA001
120*cdf0e10cSrcweir class URLDlg : public ModalDialog
121*cdf0e10cSrcweir {
122*cdf0e10cSrcweir     FixedLine           aFlURL;
123*cdf0e10cSrcweir     FixedText           aFtURL1;
124*cdf0e10cSrcweir     Edit                aEdtURL;
125*cdf0e10cSrcweir     FixedText           aFtURLDescription;
126*cdf0e10cSrcweir     Edit                aEdtURLDescription;
127*cdf0e10cSrcweir     FixedText           aFtTarget;
128*cdf0e10cSrcweir     ComboBox            aCbbTargets;
129*cdf0e10cSrcweir     FixedText           aFtName;
130*cdf0e10cSrcweir     Edit                aEdtName;
131*cdf0e10cSrcweir     OKButton            aBtnOk;
132*cdf0e10cSrcweir     CancelButton        aBtnCancel;
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir public:
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir                         URLDlg( Window* pWindow,
137*cdf0e10cSrcweir                                 const String& rURL, const String& rDescription,
138*cdf0e10cSrcweir                                 const String& rTarget, const String& rName,
139*cdf0e10cSrcweir                                 TargetList& rTargetList );
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     String              GetURL() const { return aEdtURL.GetText(); }
142*cdf0e10cSrcweir     String              GetDescription() const { return aEdtURLDescription.GetText(); }
143*cdf0e10cSrcweir     String              GetTarget() const { return aCbbTargets.GetText(); }
144*cdf0e10cSrcweir     String              GetName() const { return aEdtName.GetText(); }
145*cdf0e10cSrcweir };
146*cdf0e10cSrcweir */
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir /*************************************************************************
149*cdf0e10cSrcweir |*
150*cdf0e10cSrcweir |*
151*cdf0e10cSrcweir |*
152*cdf0e10cSrcweir \************************************************************************/
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir class IMapWindow : public GraphCtrl, public DropTargetHelper
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir     NotifyInfo          aInfo;
157*cdf0e10cSrcweir     ImageMap            aIMap;
158*cdf0e10cSrcweir     TargetList          aTargetList;
159*cdf0e10cSrcweir     Link                aInfoLink;
160*cdf0e10cSrcweir     SfxItemPool*        pIMapPool;
161*cdf0e10cSrcweir     SfxItemInfo*        pItemInfo;
162*cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
163*cdf0e10cSrcweir                         mxDocumentFrame;
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir                         DECL_LINK( MenuSelectHdl, Menu* );
166*cdf0e10cSrcweir                         DECL_LINK( MouseTimerHdl, Timer* );
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir protected:
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     // GraphCtrl
171*cdf0e10cSrcweir     virtual void        MouseButtonUp(const MouseEvent& rMEvt);
172*cdf0e10cSrcweir     virtual void        Command(const CommandEvent& rCEvt);
173*cdf0e10cSrcweir     virtual void        RequestHelp( const HelpEvent& rHEvt );
174*cdf0e10cSrcweir     virtual void        SdrObjCreated( const SdrObject& rObj );
175*cdf0e10cSrcweir     virtual void        SdrObjChanged( const SdrObject& rObj );
176*cdf0e10cSrcweir     virtual void        MarkListHasChanged();
177*cdf0e10cSrcweir     virtual void        InitSdrModel();
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir     // DropTargetHelper
180*cdf0e10cSrcweir     virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt );
181*cdf0e10cSrcweir     virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt );
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     void                CreateImageMap();
184*cdf0e10cSrcweir     void                ReplaceImageMap( const ImageMap& rNewImageMap, sal_Bool bScaleToGraphic );
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     void                ClearTargetList();
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     SdrObject*          CreateObj( const IMapObject* pIMapObj );
189*cdf0e10cSrcweir     IMapObject*         GetIMapObj( const SdrObject* pSdrObj ) const;
190*cdf0e10cSrcweir     SdrObject*          GetSdrObj( const IMapObject* pIMapObj ) const;
191*cdf0e10cSrcweir     SdrObject*          GetHitSdrObj( const Point& rPosPixel ) const;
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir     void                UpdateInfo( sal_Bool bNewObj );
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir public:
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir                         IMapWindow( Window* pParent, const ResId& rResId, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxDocumentFrame );
198*cdf0e10cSrcweir                         ~IMapWindow();
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     sal_Bool                ReplaceActualIMapInfo( const NotifyInfo& rNewInfo );
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir     void                SetImageMap( const ImageMap& rImageMap );
203*cdf0e10cSrcweir     const ImageMap&     GetImageMap();
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir     void                SetCurrentObjState( sal_Bool bActive );
206*cdf0e10cSrcweir     void                DoMacroAssign();
207*cdf0e10cSrcweir     void                DoPropertyDialog();
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir     void                SetInfoLink( const Link& rLink ) { aInfoLink = rLink; }
210*cdf0e10cSrcweir     const Link&         GetInfoLink() const { return aInfoLink; }
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir     void                SetTargetList( TargetList& rTargetList );
213*cdf0e10cSrcweir     const TargetList&   GetTargetList() const { return aTargetList; }
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir     const NotifyInfo&   GetInfo() const { return aInfo; }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir     void                CreateDefaultObject();
218*cdf0e10cSrcweir     void                SelectFirstObject();
219*cdf0e10cSrcweir     void                StartPolyEdit();
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir     virtual void        KeyInput( const KeyEvent& rKEvt );
222*cdf0e10cSrcweir };
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir #endif
226*cdf0e10cSrcweir 
227