1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file
5f6e50924SAndrew Rist * distributed with this work for additional information
6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at
10f6e50924SAndrew Rist *
11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist *
13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist * software distributed under the License is distributed on an
15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the
17f6e50924SAndrew Rist * specific language governing permissions and limitations
18f6e50924SAndrew Rist * under the License.
19f6e50924SAndrew Rist *
20f6e50924SAndrew Rist *************************************************************/
21f6e50924SAndrew Rist
22f6e50924SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #define _SDR_NOITEMS
28cdf0e10cSrcweir #define _SDR_NOTOUCH
29cdf0e10cSrcweir #define _SDR_NOTRANSFORM
30cdf0e10cSrcweir #define _SDR_NOOBJECTS
31cdf0e10cSrcweir #define _SDR_NOVIEWMARKER
32cdf0e10cSrcweir #define _SDR_NODRAGMETHODS
33cdf0e10cSrcweir #define _SDR_NOUNDO
34cdf0e10cSrcweir #define _SDR_NOXOUTDEV
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include <stdlib.h>
37cdf0e10cSrcweir #include <tools/shl.hxx>
38cdf0e10cSrcweir #ifndef _EINF_HXX
39cdf0e10cSrcweir #include <tools/errinf.hxx>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #include <tools/urlobj.hxx>
42cdf0e10cSrcweir #ifndef _UNOTOOLS_UCBSTREAMHELPER_HXX
43cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir #include <vcl/msgbox.hxx>
46cdf0e10cSrcweir #include <vcl/group.hxx>
47cdf0e10cSrcweir #include <vcl/lstbox.hxx>
48cdf0e10cSrcweir #include <svl/eitem.hxx>
49cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
50cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
51cdf0e10cSrcweir #include <sfx2/module.hxx>
52cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx>
53cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
54cdf0e10cSrcweir #include <svl/urihelper.hxx>
55cdf0e10cSrcweir #include <svtools/miscopt.hxx>
56cdf0e10cSrcweir #include <svtools/ehdl.hxx>
57cdf0e10cSrcweir #include <svtools/sfxecode.hxx>
58cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
59cdf0e10cSrcweir #include <sfx2/objsh.hxx>
60cdf0e10cSrcweir #include <sfx2/docfile.hxx>
61cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
62cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
63cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
64cdf0e10cSrcweir #endif
65cdf0e10cSrcweir
66cdf0e10cSrcweir #define _IMAPDLG_PRIVATE
67cdf0e10cSrcweir #include "svx/imapdlg.hxx"
68cdf0e10cSrcweir
69cdf0e10cSrcweir #include <svx/dialmgr.hxx>
70cdf0e10cSrcweir #include <svx/dialogs.hrc>
71cdf0e10cSrcweir #include <svx/svxids.hrc>
72cdf0e10cSrcweir #include "imapdlg.hrc"
73cdf0e10cSrcweir #include "imapwnd.hxx"
74cdf0e10cSrcweir #include "imapimp.hxx"
75cdf0e10cSrcweir #include "svx/dlgutil.hxx"
76cdf0e10cSrcweir #include <svx/svdtrans.hxx>
77cdf0e10cSrcweir #include <svx/svdopath.hxx>
78cdf0e10cSrcweir #include <vcl/svapp.hxx>
79cdf0e10cSrcweir
80cdf0e10cSrcweir #define SELF_TARGET "_self"
81*b2797c1aSMatthias Seidel #define IMAP_ALL_FILTER "*"
82cdf0e10cSrcweir #define IMAP_CERN_FILTER "MAP - CERN"
83cdf0e10cSrcweir #define IMAP_NCSA_FILTER "MAP - NCSA"
84cdf0e10cSrcweir #define IMAP_BINARY_FILTER "SIP - StarView ImageMap"
85cdf0e10cSrcweir #define IMAP_ALL_TYPE "*.*"
86cdf0e10cSrcweir #define IMAP_BINARY_TYPE "*.sip"
87cdf0e10cSrcweir #define IMAP_CERN_TYPE "*.map"
88cdf0e10cSrcweir #define IMAP_NCSA_TYPE "*.map"
89cdf0e10cSrcweir #define IMAP_BINARY_EXT "sip"
90cdf0e10cSrcweir #define IMAP_CERN_EXT "map"
91cdf0e10cSrcweir #define IMAP_NCSA_EXT "map"
92cdf0e10cSrcweir
93cdf0e10cSrcweir /******************************************************************************/
94cdf0e10cSrcweir
95cdf0e10cSrcweir SFX_IMPL_MODELESSDIALOG( SvxIMapDlgChildWindow, SID_IMAP );
96cdf0e10cSrcweir
97cdf0e10cSrcweir /******************************************************************************/
98cdf0e10cSrcweir
GetUnitString(long nVal_100,FieldUnit eFieldUnit,sal_Unicode cSep)99cdf0e10cSrcweir inline String GetUnitString( long nVal_100, FieldUnit eFieldUnit, sal_Unicode cSep )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir String aVal = UniString::CreateFromInt64( MetricField::ConvertValue( nVal_100, 2, MAP_100TH_MM, eFieldUnit ) );
102cdf0e10cSrcweir
103cdf0e10cSrcweir while( aVal.Len() < 3 )
104cdf0e10cSrcweir aVal.Insert( sal_Unicode('0'), 0 );
105cdf0e10cSrcweir
106cdf0e10cSrcweir aVal.Insert( cSep, aVal.Len() - 2 );
107cdf0e10cSrcweir aVal += sal_Unicode(' ');
108cdf0e10cSrcweir aVal += SdrFormatter::GetUnitStr( eFieldUnit );
109cdf0e10cSrcweir
110cdf0e10cSrcweir return aVal;
111cdf0e10cSrcweir }
112cdf0e10cSrcweir
113cdf0e10cSrcweir /*************************************************************************
114cdf0e10cSrcweir |*
115cdf0e10cSrcweir |* ControllerItem
116cdf0e10cSrcweir |*
117cdf0e10cSrcweir \************************************************************************/
118cdf0e10cSrcweir
SvxIMapDlgItem(sal_uInt16 _nId,SvxIMapDlg & rIMapDlg,SfxBindings & rBindings)119cdf0e10cSrcweir SvxIMapDlgItem::SvxIMapDlgItem( sal_uInt16 _nId, SvxIMapDlg& rIMapDlg, SfxBindings& rBindings ) :
120cdf0e10cSrcweir SfxControllerItem ( _nId, rBindings ),
121cdf0e10cSrcweir rIMap ( rIMapDlg )
122cdf0e10cSrcweir {
123cdf0e10cSrcweir }
124cdf0e10cSrcweir
125cdf0e10cSrcweir /*************************************************************************
126cdf0e10cSrcweir |*
127cdf0e10cSrcweir |* StateChanged-Methode
128cdf0e10cSrcweir |*
129cdf0e10cSrcweir \************************************************************************/
130cdf0e10cSrcweir
StateChanged(sal_uInt16 nSID,SfxItemState,const SfxPoolItem * pItem)131cdf0e10cSrcweir void SvxIMapDlgItem::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/,
132cdf0e10cSrcweir const SfxPoolItem* pItem )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir if ( ( nSID == SID_IMAP_EXEC ) && pItem )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir const SfxBoolItem* pStateItem = PTR_CAST( SfxBoolItem, pItem );
137cdf0e10cSrcweir
138cdf0e10cSrcweir DBG_ASSERT( pStateItem || pItem == 0, "SfxBoolItem erwartet");
139cdf0e10cSrcweir
140cdf0e10cSrcweir // Float ggf. disablen
141cdf0e10cSrcweir rIMap.SetExecState( !pStateItem->GetValue() );
142cdf0e10cSrcweir }
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir /*************************************************************************
146cdf0e10cSrcweir |*
147cdf0e10cSrcweir |*
148cdf0e10cSrcweir |*
149cdf0e10cSrcweir \************************************************************************/
150cdf0e10cSrcweir
SvxIMapDlgChildWindow(Window * _pParent,sal_uInt16 nId,SfxBindings * pBindings,SfxChildWinInfo * pInfo)151cdf0e10cSrcweir SvxIMapDlgChildWindow::SvxIMapDlgChildWindow( Window* _pParent, sal_uInt16 nId,
152cdf0e10cSrcweir SfxBindings* pBindings,
153cdf0e10cSrcweir SfxChildWinInfo* pInfo ) :
154cdf0e10cSrcweir SfxChildWindow( _pParent, nId )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir pWindow = new SvxIMapDlg( pBindings, this, _pParent, SVX_RES( RID_SVXDLG_IMAP ) );
157cdf0e10cSrcweir SvxIMapDlg* pDlg = (SvxIMapDlg*) pWindow;
158cdf0e10cSrcweir
159cdf0e10cSrcweir if ( pInfo->nFlags & SFX_CHILDWIN_ZOOMIN )
160cdf0e10cSrcweir pDlg->RollUp();
161cdf0e10cSrcweir
162cdf0e10cSrcweir eChildAlignment = SFX_ALIGN_NOALIGNMENT;
163cdf0e10cSrcweir
164cdf0e10cSrcweir pDlg->Initialize( pInfo );
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
167cdf0e10cSrcweir
168cdf0e10cSrcweir /*************************************************************************
169cdf0e10cSrcweir |*
170cdf0e10cSrcweir |*
171cdf0e10cSrcweir |*
172cdf0e10cSrcweir \************************************************************************/
173cdf0e10cSrcweir
UpdateIMapDlg(const Graphic & rGraphic,const ImageMap * pImageMap,const TargetList * pTargetList,void * pEditingObj)174cdf0e10cSrcweir void SvxIMapDlgChildWindow::UpdateIMapDlg( const Graphic& rGraphic, const ImageMap* pImageMap,
175cdf0e10cSrcweir const TargetList* pTargetList, void* pEditingObj )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir if ( SfxViewFrame::Current() &&
178cdf0e10cSrcweir SfxViewFrame::Current()->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
179cdf0e10cSrcweir SVXIMAPDLG()->Update( rGraphic, pImageMap, pTargetList, pEditingObj );
180cdf0e10cSrcweir }
181cdf0e10cSrcweir
182cdf0e10cSrcweir
183cdf0e10cSrcweir /*************************************************************************
184cdf0e10cSrcweir |*
185cdf0e10cSrcweir |*
186cdf0e10cSrcweir |*
187cdf0e10cSrcweir \************************************************************************/
188cdf0e10cSrcweir
SvxIMapDlg(SfxBindings * _pBindings,SfxChildWindow * pCW,Window * _pParent,const ResId & rResId)189cdf0e10cSrcweir SvxIMapDlg::SvxIMapDlg( SfxBindings *_pBindings, SfxChildWindow *pCW,
190cdf0e10cSrcweir Window* _pParent, const ResId& rResId ) :
191cdf0e10cSrcweir SfxModelessDialog ( _pBindings, pCW, _pParent, rResId ),
192cdf0e10cSrcweir
193cdf0e10cSrcweir aTbxIMapDlg1 ( this, SVX_RES( TBX_IMAPDLG1 ) ),
194cdf0e10cSrcweir aFtURL ( this, SVX_RES( FT_URL ) ),
195cdf0e10cSrcweir maURLBox ( this, SVX_RES( CBB_URL ) ),
196cdf0e10cSrcweir aFtText ( this, SVX_RES( FT_TEXT ) ),
197cdf0e10cSrcweir aEdtText ( this, SVX_RES( EDT_TEXT ) ),
198cdf0e10cSrcweir maFtTarget ( this, SVX_RES( RID_SVXCTL_FT_TARGET ) ),
199cdf0e10cSrcweir maCbbTarget ( this, SVX_RES( RID_SVXCTL_CBB_TARGET ) ),
200cdf0e10cSrcweir aStbStatus ( this, WB_BORDER | WB_3DLOOK | WB_LEFT ),
201cdf0e10cSrcweir maImageList ( SVX_RES( IL_IMAPDLG ) ),
202cdf0e10cSrcweir maImageListH ( SVX_RES( ILH_IMAPDLG ) ),
203cdf0e10cSrcweir pCheckObj ( NULL ),
204cdf0e10cSrcweir aIMapItem ( SID_IMAP_EXEC, *this, *_pBindings )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir pIMapWnd = new IMapWindow( this, SVX_RES( RID_SVXCTL_IMAP ), _pBindings->GetActiveFrame() );
207cdf0e10cSrcweir
208cdf0e10cSrcweir ApplyImageList();
209cdf0e10cSrcweir
210cdf0e10cSrcweir FreeResource();
211cdf0e10cSrcweir
212cdf0e10cSrcweir pOwnData = new IMapOwnData( this );
213cdf0e10cSrcweir
214cdf0e10cSrcweir pIMapWnd->SetInfoLink( LINK( this, SvxIMapDlg, InfoHdl ) );
215cdf0e10cSrcweir pIMapWnd->SetMousePosLink( LINK( this, SvxIMapDlg, MousePosHdl ) );
216cdf0e10cSrcweir pIMapWnd->SetGraphSizeLink( LINK( this, SvxIMapDlg, GraphSizeHdl ) );
217cdf0e10cSrcweir pIMapWnd->SetUpdateLink( LINK( this, SvxIMapDlg, StateHdl ) );
218cdf0e10cSrcweir
219cdf0e10cSrcweir maURLBox.SetModifyHdl( LINK( this, SvxIMapDlg, URLModifyHdl ) );
220cdf0e10cSrcweir maURLBox.SetSelectHdl( LINK( this, SvxIMapDlg, URLModifyHdl ) );
221cdf0e10cSrcweir maURLBox.SetLoseFocusHdl( LINK( this, SvxIMapDlg, URLLoseFocusHdl ) );
222cdf0e10cSrcweir aEdtText.SetModifyHdl( LINK( this, SvxIMapDlg, URLModifyHdl ) );
223cdf0e10cSrcweir maCbbTarget.SetLoseFocusHdl( LINK( this, SvxIMapDlg, URLLoseFocusHdl ) );
224cdf0e10cSrcweir
225cdf0e10cSrcweir SvtMiscOptions aMiscOptions;
226cdf0e10cSrcweir aMiscOptions.AddListenerLink( LINK( this, SvxIMapDlg, MiscHdl ) );
227cdf0e10cSrcweir
228cdf0e10cSrcweir aTbxIMapDlg1.SetOutStyle( aMiscOptions.GetToolboxStyle() );
229cdf0e10cSrcweir aTbxIMapDlg1.SetSizePixel( aTbxIMapDlg1.CalcWindowSizePixel() );
230cdf0e10cSrcweir aTbxIMapDlg1.SetSelectHdl( LINK( this, SvxIMapDlg, TbxClickHdl ) );
231cdf0e10cSrcweir aTbxIMapDlg1.CheckItem( TBI_SELECT, sal_True );
232cdf0e10cSrcweir TbxClickHdl( &aTbxIMapDlg1 );
233cdf0e10cSrcweir
234cdf0e10cSrcweir SetMinOutputSizePixel( aLastSize = GetOutputSizePixel() );
235cdf0e10cSrcweir
236cdf0e10cSrcweir aStbStatus.InsertItem( 1, 130, SIB_LEFT | SIB_IN | SIB_AUTOSIZE );
237cdf0e10cSrcweir aStbStatus.InsertItem( 2, 10 + GetTextWidth( DEFINE_CONST_UNICODE( " 9999,99 cm / 9999,99 cm ") ), SIB_CENTER | SIB_IN );
238cdf0e10cSrcweir aStbStatus.InsertItem( 3, 10 + GetTextWidth( DEFINE_CONST_UNICODE( " 9999,99 cm x 9999,99 cm ") ), SIB_CENTER | SIB_IN );
239cdf0e10cSrcweir
240cdf0e10cSrcweir aFtURL.Disable();
241cdf0e10cSrcweir maURLBox.Disable();
242cdf0e10cSrcweir aFtText.Disable();
243cdf0e10cSrcweir aEdtText.Disable();
244cdf0e10cSrcweir maFtTarget.Disable();
245cdf0e10cSrcweir maCbbTarget.Disable();
246cdf0e10cSrcweir pOwnData->bExecState = sal_False;
247cdf0e10cSrcweir
248cdf0e10cSrcweir Resize();
249cdf0e10cSrcweir
250cdf0e10cSrcweir pOwnData->aTimer.SetTimeout( 100 );
251cdf0e10cSrcweir pOwnData->aTimer.SetTimeoutHdl( LINK( this, SvxIMapDlg, UpdateHdl ) );
252cdf0e10cSrcweir
253cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_ACTIVE, sal_False );
254cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_MACRO, sal_False );
255cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_PROPERTY, sal_False );
256cdf0e10cSrcweir }
257cdf0e10cSrcweir
258cdf0e10cSrcweir
259cdf0e10cSrcweir /*************************************************************************
260cdf0e10cSrcweir |*
261cdf0e10cSrcweir |* Dtor
262cdf0e10cSrcweir |*
263cdf0e10cSrcweir \************************************************************************/
264cdf0e10cSrcweir
~SvxIMapDlg()265cdf0e10cSrcweir SvxIMapDlg::~SvxIMapDlg()
266cdf0e10cSrcweir {
267cdf0e10cSrcweir // URL-Liste loeschen
268cdf0e10cSrcweir delete pIMapWnd;
269cdf0e10cSrcweir delete pOwnData;
270cdf0e10cSrcweir }
271cdf0e10cSrcweir
272cdf0e10cSrcweir
273cdf0e10cSrcweir /*************************************************************************
274cdf0e10cSrcweir |*
275cdf0e10cSrcweir |* Resize-Methode
276cdf0e10cSrcweir |*
277cdf0e10cSrcweir \************************************************************************/
278cdf0e10cSrcweir
Resize()279cdf0e10cSrcweir void SvxIMapDlg::Resize()
280cdf0e10cSrcweir {
281cdf0e10cSrcweir SfxModelessDialog::Resize();
282cdf0e10cSrcweir
283cdf0e10cSrcweir Size aMinSize( GetMinOutputSizePixel() );
284cdf0e10cSrcweir Size aNewSize( GetOutputSizePixel() );
285cdf0e10cSrcweir
286cdf0e10cSrcweir if ( aNewSize.Height() >= aMinSize.Height() )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir Size _aSize( aStbStatus.GetSizePixel() );
289cdf0e10cSrcweir Point aPoint( 0, aNewSize.Height() - _aSize.Height() );
290cdf0e10cSrcweir
291cdf0e10cSrcweir // StatusBar positionieren
292cdf0e10cSrcweir aStbStatus.SetPosSizePixel( aPoint, Size( aNewSize.Width(), _aSize.Height() ) );
293cdf0e10cSrcweir aStbStatus.Show();
294cdf0e10cSrcweir
295cdf0e10cSrcweir // EditWindow positionieren
296cdf0e10cSrcweir _aSize.Width() = aNewSize.Width() - 18;
297cdf0e10cSrcweir _aSize.Height() = aPoint.Y() - pIMapWnd->GetPosPixel().Y() - 6;
298cdf0e10cSrcweir pIMapWnd->SetSizePixel( _aSize );
299cdf0e10cSrcweir
300cdf0e10cSrcweir aLastSize = aNewSize;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir }
303cdf0e10cSrcweir
304cdf0e10cSrcweir
305cdf0e10cSrcweir /*************************************************************************
306cdf0e10cSrcweir |*
307cdf0e10cSrcweir |* Close-Methode
308cdf0e10cSrcweir |*
309cdf0e10cSrcweir \************************************************************************/
310cdf0e10cSrcweir
Close()311cdf0e10cSrcweir sal_Bool SvxIMapDlg::Close()
312cdf0e10cSrcweir {
313cdf0e10cSrcweir sal_Bool bRet = sal_True;
314cdf0e10cSrcweir
315cdf0e10cSrcweir if ( aTbxIMapDlg1.IsItemEnabled( TBI_APPLY ) )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir QueryBox aQBox( this, WB_YES_NO_CANCEL | WB_DEF_YES,
318cdf0e10cSrcweir String( SVX_RES( STR_IMAPDLG_MODIFY ) ) );
319cdf0e10cSrcweir const long nRet = aQBox.Execute();
320cdf0e10cSrcweir
321cdf0e10cSrcweir if( nRet == RET_YES )
322cdf0e10cSrcweir {
323cdf0e10cSrcweir SfxBoolItem aBoolItem( SID_IMAP_EXEC, sal_True );
324cdf0e10cSrcweir GetBindings().GetDispatcher()->Execute(
325cdf0e10cSrcweir SID_IMAP_EXEC, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aBoolItem, 0L );
326cdf0e10cSrcweir }
327cdf0e10cSrcweir else if( nRet == RET_CANCEL )
328cdf0e10cSrcweir bRet = sal_False;
329cdf0e10cSrcweir }
330cdf0e10cSrcweir else if( pIMapWnd->IsChanged() )
331cdf0e10cSrcweir {
332cdf0e10cSrcweir QueryBox aQBox( this, WB_YES_NO_CANCEL | WB_DEF_YES,
333cdf0e10cSrcweir String( SVX_RES( STR_IMAPDLG_SAVE ) ) );
334cdf0e10cSrcweir const long nRet = aQBox.Execute();
335cdf0e10cSrcweir
336cdf0e10cSrcweir if( nRet == RET_YES )
337cdf0e10cSrcweir bRet = DoSave();
338cdf0e10cSrcweir else if( nRet == RET_CANCEL )
339cdf0e10cSrcweir bRet = sal_False;
340cdf0e10cSrcweir }
341cdf0e10cSrcweir
342cdf0e10cSrcweir return( bRet ? SfxModelessDialog::Close() : sal_False );
343cdf0e10cSrcweir }
344cdf0e10cSrcweir
345cdf0e10cSrcweir
346cdf0e10cSrcweir /*************************************************************************
347cdf0e10cSrcweir |*
348cdf0e10cSrcweir |* Enabled oder disabled alle Controls
349cdf0e10cSrcweir |*
350cdf0e10cSrcweir \************************************************************************/
351cdf0e10cSrcweir
SetExecState(sal_Bool bEnable)352cdf0e10cSrcweir void SvxIMapDlg::SetExecState( sal_Bool bEnable )
353cdf0e10cSrcweir {
354cdf0e10cSrcweir pOwnData->bExecState = bEnable;
355cdf0e10cSrcweir }
356cdf0e10cSrcweir
357cdf0e10cSrcweir
358cdf0e10cSrcweir /*************************************************************************
359cdf0e10cSrcweir |*
360cdf0e10cSrcweir |*
361cdf0e10cSrcweir |*
362cdf0e10cSrcweir \************************************************************************/
363cdf0e10cSrcweir
SetGraphic(const Graphic & rGraphic)364cdf0e10cSrcweir void SvxIMapDlg::SetGraphic( const Graphic& rGraphic )
365cdf0e10cSrcweir {
366cdf0e10cSrcweir pIMapWnd->SetGraphic( rGraphic );
367cdf0e10cSrcweir }
368cdf0e10cSrcweir
369cdf0e10cSrcweir
370cdf0e10cSrcweir /*************************************************************************
371cdf0e10cSrcweir |*
372cdf0e10cSrcweir |*
373cdf0e10cSrcweir |*
374cdf0e10cSrcweir \************************************************************************/
375cdf0e10cSrcweir
SetImageMap(const ImageMap & rImageMap)376cdf0e10cSrcweir void SvxIMapDlg::SetImageMap( const ImageMap& rImageMap )
377cdf0e10cSrcweir {
378cdf0e10cSrcweir pIMapWnd->SetImageMap( rImageMap );
379cdf0e10cSrcweir }
380cdf0e10cSrcweir
381cdf0e10cSrcweir
382cdf0e10cSrcweir /*************************************************************************
383cdf0e10cSrcweir |*
384cdf0e10cSrcweir |*
385cdf0e10cSrcweir |*
386cdf0e10cSrcweir \************************************************************************/
387cdf0e10cSrcweir
GetImageMap() const388cdf0e10cSrcweir const ImageMap& SvxIMapDlg::GetImageMap() const
389cdf0e10cSrcweir {
390cdf0e10cSrcweir return pIMapWnd->GetImageMap();
391cdf0e10cSrcweir }
392cdf0e10cSrcweir
393cdf0e10cSrcweir
394cdf0e10cSrcweir /*************************************************************************
395cdf0e10cSrcweir |*
396cdf0e10cSrcweir |*
397cdf0e10cSrcweir |*
398cdf0e10cSrcweir \************************************************************************/
399cdf0e10cSrcweir
SetTargetList(const TargetList & rTargetList)400cdf0e10cSrcweir void SvxIMapDlg::SetTargetList( const TargetList& rTargetList )
401cdf0e10cSrcweir {
402cdf0e10cSrcweir TargetList aNewList( rTargetList );
403cdf0e10cSrcweir
404cdf0e10cSrcweir pIMapWnd->SetTargetList( aNewList );
405cdf0e10cSrcweir
406cdf0e10cSrcweir maCbbTarget.Clear();
407cdf0e10cSrcweir
408cdf0e10cSrcweir for( String* pStr = aNewList.First(); pStr; pStr = aNewList.Next() )
409cdf0e10cSrcweir maCbbTarget.InsertEntry( *pStr );
410cdf0e10cSrcweir }
411cdf0e10cSrcweir
412cdf0e10cSrcweir
413cdf0e10cSrcweir /*************************************************************************
414cdf0e10cSrcweir |*
415cdf0e10cSrcweir |*
416cdf0e10cSrcweir |*
417cdf0e10cSrcweir \************************************************************************/
418cdf0e10cSrcweir
GetTargetList() const419cdf0e10cSrcweir const TargetList& SvxIMapDlg::GetTargetList() const
420cdf0e10cSrcweir {
421cdf0e10cSrcweir return pIMapWnd->GetTargetList();
422cdf0e10cSrcweir }
423cdf0e10cSrcweir
424cdf0e10cSrcweir
425cdf0e10cSrcweir /*************************************************************************
426cdf0e10cSrcweir |*
427cdf0e10cSrcweir |*
428cdf0e10cSrcweir |*
429cdf0e10cSrcweir \************************************************************************/
430cdf0e10cSrcweir
Update(const Graphic & rGraphic,const ImageMap * pImageMap,const TargetList * pTargetList,void * pEditingObj)431cdf0e10cSrcweir void SvxIMapDlg::Update( const Graphic& rGraphic, const ImageMap* pImageMap,
432cdf0e10cSrcweir const TargetList* pTargetList, void* pEditingObj )
433cdf0e10cSrcweir {
434cdf0e10cSrcweir pOwnData->aUpdateGraphic = rGraphic;
435cdf0e10cSrcweir
436cdf0e10cSrcweir if ( pImageMap )
437cdf0e10cSrcweir pOwnData->aUpdateImageMap = *pImageMap;
438cdf0e10cSrcweir else
439cdf0e10cSrcweir pOwnData->aUpdateImageMap.ClearImageMap();
440cdf0e10cSrcweir
441cdf0e10cSrcweir pOwnData->pUpdateEditingObject = pEditingObj;
442cdf0e10cSrcweir
443cdf0e10cSrcweir // UpdateTargetList loeschen, da diese Methode
444cdf0e10cSrcweir // vor dem Zuschlagen des Update-Timers noch
445cdf0e10cSrcweir // mehrmals gerufen werden kann( #46540 )
446cdf0e10cSrcweir for( String* pStr = pOwnData->aUpdateTargetList.First(); pStr; pStr = pOwnData->aUpdateTargetList.Next() )
447cdf0e10cSrcweir delete pStr;
448cdf0e10cSrcweir pOwnData->aUpdateTargetList.Clear();
449cdf0e10cSrcweir
450cdf0e10cSrcweir // TargetListe muss kopiert werden, da sie im
451cdf0e10cSrcweir // Besitz des Aufrufers ist und von ihm nach diesem
452cdf0e10cSrcweir // Aufruf sofort geloescht werden kann;
453cdf0e10cSrcweir // die kopierte Liste wird im Handler wieder geloescht
454cdf0e10cSrcweir if( pTargetList )
455cdf0e10cSrcweir {
456cdf0e10cSrcweir TargetList aTargetList( *pTargetList );
457cdf0e10cSrcweir
458cdf0e10cSrcweir for( String* pStr = aTargetList.First(); pStr; pStr = aTargetList.Next() )
459cdf0e10cSrcweir pOwnData->aUpdateTargetList.Insert( new String( *pStr ) );
460cdf0e10cSrcweir }
461cdf0e10cSrcweir
462cdf0e10cSrcweir pOwnData->aTimer.Start();
463cdf0e10cSrcweir }
464cdf0e10cSrcweir
465cdf0e10cSrcweir
KeyInput(const KeyEvent & rKEvt)466cdf0e10cSrcweir void SvxIMapDlg::KeyInput( const KeyEvent& rKEvt )
467cdf0e10cSrcweir {
468cdf0e10cSrcweir SfxModelessDialog::KeyInput( rKEvt );
469cdf0e10cSrcweir }
470cdf0e10cSrcweir
471cdf0e10cSrcweir /*************************************************************************
472cdf0e10cSrcweir |*
473cdf0e10cSrcweir |* Click-Hdl fuer ToolBox
474cdf0e10cSrcweir |*
475cdf0e10cSrcweir \************************************************************************/
476cdf0e10cSrcweir
IMPL_LINK(SvxIMapDlg,TbxClickHdl,ToolBox *,pTbx)477cdf0e10cSrcweir IMPL_LINK( SvxIMapDlg, TbxClickHdl, ToolBox*, pTbx )
478cdf0e10cSrcweir {
479cdf0e10cSrcweir sal_uInt16 nNewItemId = pTbx->GetCurItemId();
480cdf0e10cSrcweir
481cdf0e10cSrcweir switch( pTbx->GetCurItemId() )
482cdf0e10cSrcweir {
483cdf0e10cSrcweir case( TBI_APPLY ):
484cdf0e10cSrcweir {
485cdf0e10cSrcweir URLLoseFocusHdl( NULL );
486cdf0e10cSrcweir SfxBoolItem aBoolItem( SID_IMAP_EXEC, sal_True );
487cdf0e10cSrcweir GetBindings().GetDispatcher()->Execute(
488cdf0e10cSrcweir SID_IMAP_EXEC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aBoolItem, 0L );
489cdf0e10cSrcweir }
490cdf0e10cSrcweir break;
491cdf0e10cSrcweir
492cdf0e10cSrcweir case( TBI_OPEN ):
493cdf0e10cSrcweir DoOpen();
494cdf0e10cSrcweir break;
495cdf0e10cSrcweir
496cdf0e10cSrcweir case( TBI_SAVEAS ):
497cdf0e10cSrcweir DoSave();
498cdf0e10cSrcweir break;
499cdf0e10cSrcweir
500cdf0e10cSrcweir case( TBI_SELECT ):
501cdf0e10cSrcweir {
502cdf0e10cSrcweir pTbx->CheckItem( nNewItemId, sal_True );
503cdf0e10cSrcweir pIMapWnd->SetEditMode( sal_True );
504cdf0e10cSrcweir if( pTbx->IsKeyEvent() )
505cdf0e10cSrcweir {
506cdf0e10cSrcweir if((pTbx->GetKeyModifier() & KEY_MOD1) != 0)
507cdf0e10cSrcweir pIMapWnd->SelectFirstObject();
508cdf0e10cSrcweir else
509cdf0e10cSrcweir pIMapWnd->GrabFocus();
510cdf0e10cSrcweir }
511cdf0e10cSrcweir }
512cdf0e10cSrcweir break;
513cdf0e10cSrcweir
514cdf0e10cSrcweir case( TBI_RECT ):
515cdf0e10cSrcweir {
516cdf0e10cSrcweir pTbx->CheckItem( nNewItemId, sal_True );
517cdf0e10cSrcweir pIMapWnd->SetObjKind( OBJ_RECT );
518cdf0e10cSrcweir if( pTbx->IsKeyEvent() && ((pTbx->GetKeyModifier() & KEY_MOD1) != 0) )
519cdf0e10cSrcweir {
520cdf0e10cSrcweir pIMapWnd->CreateDefaultObject();
521cdf0e10cSrcweir pIMapWnd->GrabFocus();
522cdf0e10cSrcweir }
523cdf0e10cSrcweir }
524cdf0e10cSrcweir break;
525cdf0e10cSrcweir
526cdf0e10cSrcweir case( TBI_CIRCLE ):
527cdf0e10cSrcweir {
528cdf0e10cSrcweir pTbx->CheckItem( nNewItemId, sal_True );
529cdf0e10cSrcweir pIMapWnd->SetObjKind( OBJ_CIRC );
530cdf0e10cSrcweir if( pTbx->IsKeyEvent() && ((pTbx->GetKeyModifier() & KEY_MOD1) != 0) )
531cdf0e10cSrcweir {
532cdf0e10cSrcweir pIMapWnd->CreateDefaultObject();
533cdf0e10cSrcweir pIMapWnd->GrabFocus();
534cdf0e10cSrcweir }
535cdf0e10cSrcweir }
536cdf0e10cSrcweir break;
537cdf0e10cSrcweir
538cdf0e10cSrcweir case( TBI_POLY ):
539cdf0e10cSrcweir {
540cdf0e10cSrcweir pTbx->CheckItem( nNewItemId, sal_True );
541cdf0e10cSrcweir pIMapWnd->SetObjKind( OBJ_POLY );
542cdf0e10cSrcweir if( pTbx->IsKeyEvent() && ((pTbx->GetKeyModifier() & KEY_MOD1) != 0) )
543cdf0e10cSrcweir {
544cdf0e10cSrcweir pIMapWnd->CreateDefaultObject();
545cdf0e10cSrcweir pIMapWnd->GrabFocus();
546cdf0e10cSrcweir }
547cdf0e10cSrcweir }
548cdf0e10cSrcweir break;
549cdf0e10cSrcweir
550cdf0e10cSrcweir case( TBI_FREEPOLY ):
551cdf0e10cSrcweir {
552cdf0e10cSrcweir pTbx->CheckItem( nNewItemId, sal_True );
553cdf0e10cSrcweir pIMapWnd->SetObjKind( OBJ_FREEFILL );
554cdf0e10cSrcweir if( pTbx->IsKeyEvent() && ((pTbx->GetKeyModifier() & KEY_MOD1) != 0) )
555cdf0e10cSrcweir {
556cdf0e10cSrcweir pIMapWnd->CreateDefaultObject();
557cdf0e10cSrcweir pIMapWnd->GrabFocus();
558cdf0e10cSrcweir }
559cdf0e10cSrcweir }
560cdf0e10cSrcweir break;
561cdf0e10cSrcweir
562cdf0e10cSrcweir case( TBI_ACTIVE ):
563cdf0e10cSrcweir {
564cdf0e10cSrcweir URLLoseFocusHdl( NULL );
565cdf0e10cSrcweir sal_Bool bNewState = !pTbx->IsItemChecked( TBI_ACTIVE );
566cdf0e10cSrcweir pTbx->CheckItem( TBI_ACTIVE, bNewState );
567cdf0e10cSrcweir pIMapWnd->SetCurrentObjState( !bNewState );
568cdf0e10cSrcweir }
569cdf0e10cSrcweir break;
570cdf0e10cSrcweir
571cdf0e10cSrcweir case( TBI_MACRO ):
572cdf0e10cSrcweir pIMapWnd->DoMacroAssign();
573cdf0e10cSrcweir break;
574cdf0e10cSrcweir
575cdf0e10cSrcweir case( TBI_PROPERTY ):
576cdf0e10cSrcweir pIMapWnd->DoPropertyDialog();
577cdf0e10cSrcweir break;
578cdf0e10cSrcweir
579cdf0e10cSrcweir case( TBI_POLYEDIT ):
580cdf0e10cSrcweir pIMapWnd->SetPolyEditMode( pTbx->IsItemChecked( TBI_POLYEDIT ) ? SID_BEZIER_MOVE : 0 );
581cdf0e10cSrcweir if( pTbx->IsKeyEvent() && pTbx->IsItemChecked( TBI_POLYEDIT ) )
582cdf0e10cSrcweir pIMapWnd->StartPolyEdit();
583cdf0e10cSrcweir break;
584cdf0e10cSrcweir
585cdf0e10cSrcweir case( TBI_POLYMOVE ):
586cdf0e10cSrcweir pIMapWnd->SetPolyEditMode( SID_BEZIER_MOVE );
587cdf0e10cSrcweir break;
588cdf0e10cSrcweir
589cdf0e10cSrcweir case( TBI_POLYINSERT ):
590cdf0e10cSrcweir pIMapWnd->SetPolyEditMode( SID_BEZIER_INSERT );
591cdf0e10cSrcweir break;
592cdf0e10cSrcweir
593cdf0e10cSrcweir case( TBI_POLYDELETE ):
594cdf0e10cSrcweir pIMapWnd->GetSdrView()->DeleteMarkedPoints();
595cdf0e10cSrcweir break;
596cdf0e10cSrcweir
597cdf0e10cSrcweir case( TBI_UNDO ):
598cdf0e10cSrcweir {
599cdf0e10cSrcweir URLLoseFocusHdl( NULL );
600cdf0e10cSrcweir pIMapWnd->GetSdrModel()->Undo();
601cdf0e10cSrcweir }
602cdf0e10cSrcweir break;
603cdf0e10cSrcweir
604cdf0e10cSrcweir case( TBI_REDO ):
605cdf0e10cSrcweir {
606cdf0e10cSrcweir URLLoseFocusHdl( NULL );
607cdf0e10cSrcweir pIMapWnd->GetSdrModel()->Redo();
608cdf0e10cSrcweir }
609cdf0e10cSrcweir break;
610cdf0e10cSrcweir
611cdf0e10cSrcweir default:
612cdf0e10cSrcweir break;
613cdf0e10cSrcweir }
614cdf0e10cSrcweir
615cdf0e10cSrcweir return 0;
616cdf0e10cSrcweir }
617cdf0e10cSrcweir
618cdf0e10cSrcweir
619cdf0e10cSrcweir /*************************************************************************
620cdf0e10cSrcweir |*
621cdf0e10cSrcweir |*
622cdf0e10cSrcweir |*
623cdf0e10cSrcweir \************************************************************************/
624cdf0e10cSrcweir
DoOpen()625cdf0e10cSrcweir void SvxIMapDlg::DoOpen()
626cdf0e10cSrcweir {
627cdf0e10cSrcweir ::sfx2::FileDialogHelper aDlg(
628cdf0e10cSrcweir com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
629cdf0e10cSrcweir
630cdf0e10cSrcweir ImageMap aLoadIMap;
631cdf0e10cSrcweir const String aFilter( DEFINE_CONST_UNICODE( IMAP_ALL_FILTER ) );
632cdf0e10cSrcweir
633cdf0e10cSrcweir aDlg.AddFilter( aFilter, DEFINE_CONST_UNICODE( IMAP_ALL_TYPE ) );
634cdf0e10cSrcweir aDlg.AddFilter( DEFINE_CONST_UNICODE( IMAP_CERN_FILTER ), DEFINE_CONST_UNICODE( IMAP_CERN_TYPE ) );
635cdf0e10cSrcweir aDlg.AddFilter( DEFINE_CONST_UNICODE( IMAP_NCSA_FILTER ), DEFINE_CONST_UNICODE( IMAP_NCSA_TYPE ) );
636cdf0e10cSrcweir aDlg.AddFilter( DEFINE_CONST_UNICODE( IMAP_BINARY_FILTER ), DEFINE_CONST_UNICODE( IMAP_BINARY_TYPE ) );
637cdf0e10cSrcweir
638cdf0e10cSrcweir aDlg.SetCurrentFilter( aFilter );
639cdf0e10cSrcweir aDlg.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
640cdf0e10cSrcweir
641cdf0e10cSrcweir if( aDlg.Execute() == ERRCODE_NONE )
642cdf0e10cSrcweir {
643cdf0e10cSrcweir INetURLObject aURL( aDlg.GetPath() );
644cdf0e10cSrcweir DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
645cdf0e10cSrcweir SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
646cdf0e10cSrcweir
647cdf0e10cSrcweir if( pIStm )
648cdf0e10cSrcweir {
649cdf0e10cSrcweir aLoadIMap.Read( *pIStm, IMAP_FORMAT_DETECT, String() );
650cdf0e10cSrcweir
651cdf0e10cSrcweir if( pIStm->GetError() )
652cdf0e10cSrcweir {
653cdf0e10cSrcweir SfxErrorContext eEC(ERRCODE_SFX_GENERAL,this);
654cdf0e10cSrcweir ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
655cdf0e10cSrcweir }
656cdf0e10cSrcweir else
657cdf0e10cSrcweir pIMapWnd->SetImageMap( aLoadIMap );
658cdf0e10cSrcweir
659cdf0e10cSrcweir delete pIStm;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir
662cdf0e10cSrcweir pIMapWnd->Invalidate();
663cdf0e10cSrcweir }
664cdf0e10cSrcweir }
665cdf0e10cSrcweir
666cdf0e10cSrcweir
667cdf0e10cSrcweir /*************************************************************************
668cdf0e10cSrcweir |*
669cdf0e10cSrcweir |*
670cdf0e10cSrcweir |*
671cdf0e10cSrcweir \************************************************************************/
672cdf0e10cSrcweir
DoSave()673cdf0e10cSrcweir sal_Bool SvxIMapDlg::DoSave()
674cdf0e10cSrcweir {
675cdf0e10cSrcweir ::sfx2::FileDialogHelper aDlg(
676cdf0e10cSrcweir com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
677cdf0e10cSrcweir
678cdf0e10cSrcweir const String aBinFilter( DEFINE_CONST_UNICODE( IMAP_BINARY_FILTER ) );
679cdf0e10cSrcweir const String aCERNFilter( DEFINE_CONST_UNICODE( IMAP_CERN_FILTER ) );
680cdf0e10cSrcweir const String aNCSAFilter( DEFINE_CONST_UNICODE( IMAP_NCSA_FILTER ) );
681cdf0e10cSrcweir SdrModel* pModel = pIMapWnd->GetSdrModel();
682cdf0e10cSrcweir const sal_Bool bChanged = pModel->IsChanged();
683cdf0e10cSrcweir sal_Bool bRet = false;
684cdf0e10cSrcweir
685cdf0e10cSrcweir aDlg.AddFilter( aCERNFilter, DEFINE_CONST_UNICODE( IMAP_CERN_TYPE ) );
686cdf0e10cSrcweir aDlg.AddFilter( aNCSAFilter, DEFINE_CONST_UNICODE( IMAP_NCSA_TYPE ) );
687cdf0e10cSrcweir aDlg.AddFilter( aBinFilter, DEFINE_CONST_UNICODE( IMAP_BINARY_TYPE ) );
688cdf0e10cSrcweir
689cdf0e10cSrcweir aDlg.SetCurrentFilter( aCERNFilter );
690cdf0e10cSrcweir aDlg.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
691cdf0e10cSrcweir
692cdf0e10cSrcweir if( aDlg.Execute() == ERRCODE_NONE )
693cdf0e10cSrcweir {
694cdf0e10cSrcweir const String aFilter( aDlg.GetCurrentFilter() );
695cdf0e10cSrcweir String aExt;
696cdf0e10cSrcweir sal_uIntPtr nFormat;
697cdf0e10cSrcweir
698cdf0e10cSrcweir if ( aFilter == aBinFilter )
699cdf0e10cSrcweir {
700cdf0e10cSrcweir nFormat = IMAP_FORMAT_BIN;
701cdf0e10cSrcweir aExt = DEFINE_CONST_UNICODE( IMAP_BINARY_EXT );
702cdf0e10cSrcweir }
703cdf0e10cSrcweir else if ( aFilter == aCERNFilter )
704cdf0e10cSrcweir {
705cdf0e10cSrcweir nFormat = IMAP_FORMAT_CERN;
706cdf0e10cSrcweir aExt = DEFINE_CONST_UNICODE( IMAP_CERN_EXT );
707cdf0e10cSrcweir }
708cdf0e10cSrcweir else if ( aFilter == aNCSAFilter )
709cdf0e10cSrcweir {
710cdf0e10cSrcweir nFormat = IMAP_FORMAT_NCSA;
711cdf0e10cSrcweir aExt = DEFINE_CONST_UNICODE( IMAP_NCSA_EXT );
712cdf0e10cSrcweir }
713cdf0e10cSrcweir else
714cdf0e10cSrcweir {
715cdf0e10cSrcweir return sal_False;
716cdf0e10cSrcweir }
717cdf0e10cSrcweir
718cdf0e10cSrcweir INetURLObject aURL( aDlg.GetPath() );
719cdf0e10cSrcweir
720cdf0e10cSrcweir if( aURL.GetProtocol() == INET_PROT_NOT_VALID )
721cdf0e10cSrcweir {
722cdf0e10cSrcweir DBG_ERROR( "invalid URL" );
723cdf0e10cSrcweir }
724cdf0e10cSrcweir else
725cdf0e10cSrcweir {
726cdf0e10cSrcweir if( !aURL.getExtension().getLength() )
727cdf0e10cSrcweir aURL.setExtension( aExt );
728cdf0e10cSrcweir
729cdf0e10cSrcweir SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_TRUNC );
730cdf0e10cSrcweir if( pOStm )
731cdf0e10cSrcweir {
732cdf0e10cSrcweir pIMapWnd->GetImageMap().Write( *pOStm, nFormat, String() );
733cdf0e10cSrcweir
734cdf0e10cSrcweir if( pOStm->GetError() )
735cdf0e10cSrcweir ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
736cdf0e10cSrcweir
737cdf0e10cSrcweir delete pOStm;
738cdf0e10cSrcweir pModel->SetChanged( bChanged );
739cdf0e10cSrcweir bRet = sal_True;
740cdf0e10cSrcweir }
741cdf0e10cSrcweir }
742cdf0e10cSrcweir }
743cdf0e10cSrcweir
744cdf0e10cSrcweir return bRet;
745cdf0e10cSrcweir }
746cdf0e10cSrcweir
747cdf0e10cSrcweir
748cdf0e10cSrcweir /*************************************************************************
749cdf0e10cSrcweir |*
750cdf0e10cSrcweir |*
751cdf0e10cSrcweir |*
752cdf0e10cSrcweir \************************************************************************/
753cdf0e10cSrcweir
IMPL_LINK(SvxIMapDlg,InfoHdl,IMapWindow *,pWnd)754cdf0e10cSrcweir IMPL_LINK( SvxIMapDlg, InfoHdl, IMapWindow*, pWnd )
755cdf0e10cSrcweir {
756cdf0e10cSrcweir String aStr;
757cdf0e10cSrcweir const NotifyInfo& rInfo = pWnd->GetInfo();
758cdf0e10cSrcweir
759cdf0e10cSrcweir if ( rInfo.bNewObj )
760cdf0e10cSrcweir {
761cdf0e10cSrcweir if( rInfo.aMarkURL.Len() && ( maURLBox.GetEntryPos( rInfo.aMarkURL ) == LISTBOX_ENTRY_NOTFOUND ) )
762cdf0e10cSrcweir maURLBox.InsertEntry( rInfo.aMarkURL );
763cdf0e10cSrcweir
764cdf0e10cSrcweir maURLBox.SetText( rInfo.aMarkURL );
765cdf0e10cSrcweir aEdtText.SetText( rInfo.aMarkAltText );
766cdf0e10cSrcweir
767cdf0e10cSrcweir if ( !rInfo.aMarkTarget.Len() )
768cdf0e10cSrcweir maCbbTarget.SetText( DEFINE_CONST_UNICODE( SELF_TARGET ) );
769cdf0e10cSrcweir else
770cdf0e10cSrcweir maCbbTarget.SetText( rInfo.aMarkTarget );
771cdf0e10cSrcweir }
772cdf0e10cSrcweir
773cdf0e10cSrcweir if ( !rInfo.bOneMarked )
774cdf0e10cSrcweir {
775cdf0e10cSrcweir aTbxIMapDlg1.CheckItem( TBI_ACTIVE, sal_False );
776cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_ACTIVE, sal_False );
777cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_MACRO, sal_False );
778cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_PROPERTY, sal_False );
779cdf0e10cSrcweir aStbStatus.SetItemText( 1, aStr );
780cdf0e10cSrcweir
781cdf0e10cSrcweir aFtURL.Disable();
782cdf0e10cSrcweir maURLBox.Disable();
783cdf0e10cSrcweir aFtText.Disable();
784cdf0e10cSrcweir aEdtText.Disable();
785cdf0e10cSrcweir maFtTarget.Disable();
786cdf0e10cSrcweir maCbbTarget.Disable();
787cdf0e10cSrcweir
788cdf0e10cSrcweir maURLBox.SetText( String() );
789cdf0e10cSrcweir aEdtText.SetText( String() );
790cdf0e10cSrcweir }
791cdf0e10cSrcweir else
792cdf0e10cSrcweir {
793cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_ACTIVE, sal_True );
794cdf0e10cSrcweir aTbxIMapDlg1.CheckItem( TBI_ACTIVE, !rInfo.bActivated );
795cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_MACRO, sal_True );
796cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_PROPERTY, sal_True );
797cdf0e10cSrcweir
798cdf0e10cSrcweir aFtURL.Enable();
799cdf0e10cSrcweir maURLBox.Enable();
800cdf0e10cSrcweir aFtText.Enable();
801cdf0e10cSrcweir aEdtText.Enable();
802cdf0e10cSrcweir maFtTarget.Enable();
803cdf0e10cSrcweir maCbbTarget.Enable();
804cdf0e10cSrcweir
805cdf0e10cSrcweir aStbStatus.SetItemText( 1, rInfo.aMarkURL );
806cdf0e10cSrcweir
807cdf0e10cSrcweir if ( maURLBox.GetText() != rInfo.aMarkURL )
808cdf0e10cSrcweir maURLBox.SetText( rInfo.aMarkURL );
809cdf0e10cSrcweir
810cdf0e10cSrcweir if ( aEdtText.GetText() != rInfo.aMarkAltText )
811cdf0e10cSrcweir aEdtText.SetText( rInfo.aMarkAltText );
812cdf0e10cSrcweir
813cdf0e10cSrcweir if ( !rInfo.aMarkTarget.Len() )
814cdf0e10cSrcweir maCbbTarget.SetText( DEFINE_CONST_UNICODE( SELF_TARGET ) );
815cdf0e10cSrcweir else
816cdf0e10cSrcweir maCbbTarget.SetText( rInfo.aMarkTarget );
817cdf0e10cSrcweir }
818cdf0e10cSrcweir
819cdf0e10cSrcweir return 0;
820cdf0e10cSrcweir }
821cdf0e10cSrcweir
822cdf0e10cSrcweir /*************************************************************************
823cdf0e10cSrcweir |*
824cdf0e10cSrcweir |*
825cdf0e10cSrcweir |*
826cdf0e10cSrcweir \************************************************************************/
827cdf0e10cSrcweir
IMPL_LINK(SvxIMapDlg,MousePosHdl,IMapWindow *,pWnd)828cdf0e10cSrcweir IMPL_LINK( SvxIMapDlg, MousePosHdl, IMapWindow*, pWnd )
829cdf0e10cSrcweir {
830cdf0e10cSrcweir String aStr;
831cdf0e10cSrcweir const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
832cdf0e10cSrcweir const Point& rMousePos = pWnd->GetMousePos();
833cdf0e10cSrcweir LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
834cdf0e10cSrcweir const sal_Unicode cSep = aLocaleWrapper.getNumDecimalSep().GetChar(0);
835cdf0e10cSrcweir
836cdf0e10cSrcweir aStr.Assign( GetUnitString( rMousePos.X(), eFieldUnit, cSep ) );
837cdf0e10cSrcweir aStr.Append( DEFINE_CONST_UNICODE( " / " ) );
838cdf0e10cSrcweir aStr.Append( GetUnitString( rMousePos.Y(), eFieldUnit, cSep ) );
839cdf0e10cSrcweir
840cdf0e10cSrcweir aStbStatus.SetItemText( 2, aStr );
841cdf0e10cSrcweir
842cdf0e10cSrcweir return 0L;
843cdf0e10cSrcweir }
844cdf0e10cSrcweir
845cdf0e10cSrcweir /*************************************************************************
846cdf0e10cSrcweir |*
847cdf0e10cSrcweir |*
848cdf0e10cSrcweir |*
849cdf0e10cSrcweir \************************************************************************/
850cdf0e10cSrcweir
IMPL_LINK(SvxIMapDlg,GraphSizeHdl,IMapWindow *,pWnd)851cdf0e10cSrcweir IMPL_LINK( SvxIMapDlg, GraphSizeHdl, IMapWindow*, pWnd )
852cdf0e10cSrcweir {
853cdf0e10cSrcweir String aStr;
854cdf0e10cSrcweir const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
855cdf0e10cSrcweir const Size& rSize = pWnd->GetGraphicSize();
856cdf0e10cSrcweir LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
857cdf0e10cSrcweir const sal_Unicode cSep = aLocaleWrapper.getNumDecimalSep().GetChar(0);
858cdf0e10cSrcweir
859cdf0e10cSrcweir aStr.Assign( GetUnitString( rSize.Width(), eFieldUnit, cSep ) );
860cdf0e10cSrcweir aStr.Append( DEFINE_CONST_UNICODE( " x " ) );
861cdf0e10cSrcweir aStr.Append( GetUnitString( rSize.Height(), eFieldUnit, cSep ) );
862cdf0e10cSrcweir
863cdf0e10cSrcweir aStbStatus.SetItemText( 3, aStr );
864cdf0e10cSrcweir
865cdf0e10cSrcweir return 0L;
866cdf0e10cSrcweir }
867cdf0e10cSrcweir
868cdf0e10cSrcweir /*************************************************************************
869cdf0e10cSrcweir |*
870cdf0e10cSrcweir |*
871cdf0e10cSrcweir |*
872cdf0e10cSrcweir \************************************************************************/
873cdf0e10cSrcweir
IMPL_LINK(SvxIMapDlg,URLModifyHdl,void *,EMPTYARG)874cdf0e10cSrcweir IMPL_LINK( SvxIMapDlg, URLModifyHdl, void*, EMPTYARG )
875cdf0e10cSrcweir {
876cdf0e10cSrcweir NotifyInfo aNewInfo;
877cdf0e10cSrcweir
878cdf0e10cSrcweir aNewInfo.aMarkURL = maURLBox.GetText();
879cdf0e10cSrcweir aNewInfo.aMarkAltText = aEdtText.GetText();
880cdf0e10cSrcweir aNewInfo.aMarkTarget = maCbbTarget.GetText();
881cdf0e10cSrcweir
882cdf0e10cSrcweir pIMapWnd->ReplaceActualIMapInfo( aNewInfo );
883cdf0e10cSrcweir
884cdf0e10cSrcweir return 0;
885cdf0e10cSrcweir }
886cdf0e10cSrcweir
887cdf0e10cSrcweir
888cdf0e10cSrcweir /*************************************************************************
889cdf0e10cSrcweir |*
890cdf0e10cSrcweir |*
891cdf0e10cSrcweir |*
892cdf0e10cSrcweir \************************************************************************/
893cdf0e10cSrcweir
IMPL_LINK(SvxIMapDlg,URLLoseFocusHdl,void *,EMPTYARG)894cdf0e10cSrcweir IMPL_LINK( SvxIMapDlg, URLLoseFocusHdl, void*, EMPTYARG )
895cdf0e10cSrcweir {
896cdf0e10cSrcweir NotifyInfo aNewInfo;
897cdf0e10cSrcweir const String aURLText( maURLBox.GetText() );
898cdf0e10cSrcweir const String aTargetText( maCbbTarget.GetText() );
899cdf0e10cSrcweir
900cdf0e10cSrcweir if ( aURLText.Len() )
901cdf0e10cSrcweir {
902cdf0e10cSrcweir String aBase = GetBindings().GetDispatcher()->GetFrame()->GetObjectShell()->GetMedium()->GetBaseURL();
903cdf0e10cSrcweir aNewInfo.aMarkURL = ::URIHelper::SmartRel2Abs( INetURLObject(aBase), aURLText, URIHelper::GetMaybeFileHdl(), true, false,
904cdf0e10cSrcweir INetURLObject::WAS_ENCODED,
905cdf0e10cSrcweir INetURLObject::DECODE_UNAMBIGUOUS );
906cdf0e10cSrcweir }
907cdf0e10cSrcweir else
908cdf0e10cSrcweir aNewInfo.aMarkURL = aURLText;
909cdf0e10cSrcweir
910cdf0e10cSrcweir aNewInfo.aMarkAltText = aEdtText.GetText();
911cdf0e10cSrcweir
912cdf0e10cSrcweir if ( !aTargetText.Len() )
913cdf0e10cSrcweir aNewInfo.aMarkTarget = DEFINE_CONST_UNICODE( SELF_TARGET );
914cdf0e10cSrcweir else
915cdf0e10cSrcweir aNewInfo.aMarkTarget = aTargetText;
916cdf0e10cSrcweir
917cdf0e10cSrcweir pIMapWnd->ReplaceActualIMapInfo( aNewInfo );
918cdf0e10cSrcweir
919cdf0e10cSrcweir return 0;
920cdf0e10cSrcweir }
921cdf0e10cSrcweir
922cdf0e10cSrcweir
923cdf0e10cSrcweir /*************************************************************************
924cdf0e10cSrcweir |*
925cdf0e10cSrcweir |*
926cdf0e10cSrcweir |*
927cdf0e10cSrcweir \************************************************************************/
928cdf0e10cSrcweir
IMPL_LINK(SvxIMapDlg,UpdateHdl,Timer *,EMPTYARG)929cdf0e10cSrcweir IMPL_LINK( SvxIMapDlg, UpdateHdl, Timer*, EMPTYARG )
930cdf0e10cSrcweir {
931cdf0e10cSrcweir pOwnData->aTimer.Stop();
932cdf0e10cSrcweir
933cdf0e10cSrcweir if ( pOwnData->pUpdateEditingObject != pCheckObj )
934cdf0e10cSrcweir {
935cdf0e10cSrcweir if ( pIMapWnd->IsChanged() &&
936cdf0e10cSrcweir ( QueryBox( this, WB_YES_NO | WB_DEF_YES,
937cdf0e10cSrcweir String( SVX_RES( STR_IMAPDLG_SAVE ) ) ).Execute() == RET_YES ) )
938cdf0e10cSrcweir {
939cdf0e10cSrcweir DoSave();
940cdf0e10cSrcweir }
941cdf0e10cSrcweir
942cdf0e10cSrcweir SetGraphic( pOwnData->aUpdateGraphic );
943cdf0e10cSrcweir SetImageMap( pOwnData->aUpdateImageMap );
944cdf0e10cSrcweir SetTargetList( pOwnData->aUpdateTargetList );
945cdf0e10cSrcweir SetEditingObject( pOwnData->pUpdateEditingObject );
946cdf0e10cSrcweir
947cdf0e10cSrcweir // Nach Wechsel => default Selektion
948cdf0e10cSrcweir aTbxIMapDlg1.CheckItem( TBI_SELECT, sal_True );
949cdf0e10cSrcweir pIMapWnd->SetEditMode( sal_True );
950cdf0e10cSrcweir }
951cdf0e10cSrcweir
952cdf0e10cSrcweir // die in der Update-Methode kopierte Liste wieder loeschen
953cdf0e10cSrcweir for( String* pStr = pOwnData->aUpdateTargetList.First(); pStr; pStr = pOwnData->aUpdateTargetList.Next() )
954cdf0e10cSrcweir delete pStr;
955cdf0e10cSrcweir
956cdf0e10cSrcweir pOwnData->aUpdateTargetList.Clear();
957cdf0e10cSrcweir
958cdf0e10cSrcweir GetBindings().Invalidate( SID_IMAP_EXEC );
959cdf0e10cSrcweir
960cdf0e10cSrcweir return 0L;
961cdf0e10cSrcweir }
962cdf0e10cSrcweir
963cdf0e10cSrcweir
964cdf0e10cSrcweir /*************************************************************************
965cdf0e10cSrcweir |*
966cdf0e10cSrcweir |*
967cdf0e10cSrcweir |*
968cdf0e10cSrcweir \************************************************************************/
969cdf0e10cSrcweir
IMPL_LINK(SvxIMapDlg,StateHdl,IMapWindow *,pWnd)970cdf0e10cSrcweir IMPL_LINK( SvxIMapDlg, StateHdl, IMapWindow*, pWnd )
971cdf0e10cSrcweir {
972cdf0e10cSrcweir const SdrObject* pObj = pWnd->GetSelectedSdrObject();
973cdf0e10cSrcweir const SdrModel* pModel = pWnd->GetSdrModel();
974cdf0e10cSrcweir const SdrView* pView = pWnd->GetSdrView();
975cdf0e10cSrcweir const sal_Bool bPolyEdit = ( pObj != NULL ) && pObj->ISA( SdrPathObj );
976cdf0e10cSrcweir const sal_Bool bDrawEnabled = !( bPolyEdit && aTbxIMapDlg1.IsItemChecked( TBI_POLYEDIT ) );
977cdf0e10cSrcweir
978cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_APPLY, pOwnData->bExecState && pWnd->IsChanged() );
979cdf0e10cSrcweir
980cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_SELECT, bDrawEnabled );
981cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_RECT, bDrawEnabled );
982cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_CIRCLE, bDrawEnabled );
983cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_POLY, bDrawEnabled );
984cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_FREEPOLY, bDrawEnabled );
985cdf0e10cSrcweir
986cdf0e10cSrcweir // BezierEditor-Stati
987cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_POLYEDIT, bPolyEdit );
988cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_POLYMOVE, !bDrawEnabled );
989cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_POLYINSERT, !bDrawEnabled );
990cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_POLYDELETE, !bDrawEnabled && pView->IsDeleteMarkedPointsPossible() );
991cdf0e10cSrcweir
992cdf0e10cSrcweir // Undo/Redo
993cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_UNDO, pModel->GetUndoActionCount() > 0 );
994cdf0e10cSrcweir aTbxIMapDlg1.EnableItem( TBI_REDO, pModel->GetRedoActionCount() > 0 );
995cdf0e10cSrcweir
996cdf0e10cSrcweir if ( bPolyEdit )
997cdf0e10cSrcweir {
998cdf0e10cSrcweir sal_uInt16 nId = 0;
999cdf0e10cSrcweir
1000cdf0e10cSrcweir switch( pWnd->GetPolyEditMode() )
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir case( SID_BEZIER_MOVE ): nId = TBI_POLYMOVE; break;
1003cdf0e10cSrcweir case( SID_BEZIER_INSERT ): nId = TBI_POLYINSERT; break;
1004cdf0e10cSrcweir
1005cdf0e10cSrcweir default:
1006cdf0e10cSrcweir break;
1007cdf0e10cSrcweir }
1008cdf0e10cSrcweir
1009cdf0e10cSrcweir aTbxIMapDlg1.CheckItem( nId, sal_True );
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir else
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir aTbxIMapDlg1.CheckItem( TBI_POLYEDIT, sal_False );
1014cdf0e10cSrcweir aTbxIMapDlg1.CheckItem( TBI_POLYMOVE, sal_True );
1015cdf0e10cSrcweir aTbxIMapDlg1.CheckItem( TBI_POLYINSERT, sal_False );
1016cdf0e10cSrcweir pWnd->SetPolyEditMode( 0 );
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir
1019cdf0e10cSrcweir return 0L;
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir /*************************************************************************
1023cdf0e10cSrcweir |*
1024cdf0e10cSrcweir |*
1025cdf0e10cSrcweir |*
1026cdf0e10cSrcweir \************************************************************************/
1027cdf0e10cSrcweir
IMPL_LINK(SvxIMapDlg,MiscHdl,void *,EMPTYARG)1028cdf0e10cSrcweir IMPL_LINK( SvxIMapDlg, MiscHdl, void*, EMPTYARG )
1029cdf0e10cSrcweir {
1030cdf0e10cSrcweir SvtMiscOptions aMiscOptions;
1031cdf0e10cSrcweir aTbxIMapDlg1.SetOutStyle( aMiscOptions.GetToolboxStyle() );
1032cdf0e10cSrcweir
1033cdf0e10cSrcweir return 0L;
1034cdf0e10cSrcweir }
1035cdf0e10cSrcweir
ApplyImageList()1036cdf0e10cSrcweir void SvxIMapDlg::ApplyImageList()
1037cdf0e10cSrcweir {
1038cdf0e10cSrcweir bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
1039cdf0e10cSrcweir
1040cdf0e10cSrcweir ImageList& rImgLst = bHighContrast ? maImageListH : maImageList;
1041cdf0e10cSrcweir
1042cdf0e10cSrcweir aTbxIMapDlg1.SetImageList( rImgLst );
1043cdf0e10cSrcweir }
1044cdf0e10cSrcweir
DataChanged(const DataChangedEvent & rDCEvt)1045cdf0e10cSrcweir void SvxIMapDlg::DataChanged( const DataChangedEvent& rDCEvt )
1046cdf0e10cSrcweir {
1047cdf0e10cSrcweir SfxModelessDialog::DataChanged( rDCEvt );
1048cdf0e10cSrcweir
1049cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1050cdf0e10cSrcweir ApplyImageList();
1051cdf0e10cSrcweir }
1052