1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <tools/shl.hxx>
22 #include <tools/errinf.hxx>
23 #include <tools/urlobj.hxx>
24 #include <unotools/ucbstreamhelper.hxx>
25 #include <vcl/msgbox.hxx>
26 #include <vcl/group.hxx>
27 #include <vcl/lstbox.hxx>
28 #include <svl/eitem.hxx>
29 #include <unotools/pathoptions.hxx>
30 #include <sfx2/dispatch.hxx>
31 #include <sfx2/module.hxx>
32 #include <sfx2/filedlghelper.hxx>
33 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
34 #include <svl/urihelper.hxx>
35 #include <svtools/miscopt.hxx>
36 #include <svtools/ehdl.hxx>
37 #include <svtools/sfxecode.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include <sfx2/objsh.hxx>
40 #include <sfx2/docfile.hxx>
41 #include <unotools/localedatawrapper.hxx>
42 #include <comphelper/processfactory.hxx>
44 #define _IMAPDLG_PRIVATE
45 #include "svx/imapdlg.hxx"
47 #include <svx/dialmgr.hxx>
48 #include <svx/dialogs.hrc>
49 #include <svx/svxids.hrc>
50 #include "imapdlg.hrc"
51 #include "imapwnd.hxx"
52 #include "imapimp.hxx"
53 #include "svx/dlgutil.hxx"
54 #include <svx/svdtrans.hxx>
55 #include <svx/svdopath.hxx>
56 #include <vcl/svapp.hxx>
57 #include "dlgunit.hxx"
59 #define SELF_TARGET "_self"
60 #define IMAP_ALL_FILTER OUString("<Alle>")
61 #define IMAP_CERN_FILTER OUString("MAP - CERN")
62 #define IMAP_NCSA_FILTER OUString("MAP - NCSA")
63 #define IMAP_BINARY_FILTER OUString("SIP - StarView ImageMap")
64 #define IMAP_ALL_TYPE OUString("*.*")
65 #define IMAP_BINARY_TYPE OUString("*.sip")
66 #define IMAP_CERN_TYPE OUString("*.map")
67 #define IMAP_NCSA_TYPE OUString("*.map")
68 #define IMAP_BINARY_EXT OUString("sip")
69 #define IMAP_CERN_EXT OUString("map")
70 #define IMAP_NCSA_EXT OUString("map")
72 /******************************************************************************/
74 SFX_IMPL_MODELESSDIALOG_WITHID( SvxIMapDlgChildWindow
, SID_IMAP
);
78 SvxIMapDlgItem::SvxIMapDlgItem( sal_uInt16 _nId
, SvxIMapDlg
& rIMapDlg
, SfxBindings
& rBindings
) :
79 SfxControllerItem ( _nId
, rBindings
),
84 void SvxIMapDlgItem::StateChanged( sal_uInt16 nSID
, SfxItemState
/*eState*/,
85 const SfxPoolItem
* pItem
)
87 if ( ( nSID
== SID_IMAP_EXEC
) && pItem
)
89 const SfxBoolItem
* pStateItem
= PTR_CAST( SfxBoolItem
, pItem
);
91 DBG_ASSERT( pStateItem
|| pItem
== 0, "SfxBoolItem expected");
93 // Disable Float if possible
94 rIMap
.SetExecState( !pStateItem
->GetValue() );
98 SvxIMapDlgChildWindow::SvxIMapDlgChildWindow( Window
* _pParent
, sal_uInt16 nId
,
99 SfxBindings
* pBindings
,
100 SfxChildWinInfo
* pInfo
) :
101 SfxChildWindow( _pParent
, nId
)
103 pWindow
= new SvxIMapDlg( pBindings
, this, _pParent
, SVX_RES( RID_SVXDLG_IMAP
) );
104 SvxIMapDlg
* pDlg
= (SvxIMapDlg
*) pWindow
;
106 if ( pInfo
->nFlags
& SFX_CHILDWIN_ZOOMIN
)
109 eChildAlignment
= SFX_ALIGN_NOALIGNMENT
;
111 pDlg
->Initialize( pInfo
);
114 void SvxIMapDlgChildWindow::UpdateIMapDlg( const Graphic
& rGraphic
, const ImageMap
* pImageMap
,
115 const TargetList
* pTargetList
, void* pEditingObj
)
117 if ( SfxViewFrame::Current() &&
118 SfxViewFrame::Current()->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
119 SVXIMAPDLG()->Update( rGraphic
, pImageMap
, pTargetList
, pEditingObj
);
122 SvxIMapDlg::SvxIMapDlg( SfxBindings
*_pBindings
, SfxChildWindow
*pCW
,
123 Window
* _pParent
, const ResId
& rResId
) :
124 SfxModelessDialog ( _pBindings
, pCW
, _pParent
, rResId
),
126 aTbxIMapDlg1 ( this, SVX_RES( TBX_IMAPDLG1
) ),
127 aFtURL ( this, SVX_RES( FT_URL
) ),
128 maURLBox ( this, SVX_RES( CBB_URL
) ),
129 aFtText ( this, SVX_RES( FT_TEXT
) ),
130 aEdtText ( this, SVX_RES( EDT_TEXT
) ),
131 maFtTarget ( this, SVX_RES( RID_SVXCTL_FT_TARGET
) ),
132 maCbbTarget ( this, SVX_RES( RID_SVXCTL_CBB_TARGET
) ),
133 aStbStatus ( this, WB_BORDER
| WB_3DLOOK
| WB_LEFT
),
134 maImageList ( SVX_RES( IL_IMAPDLG
) ),
136 aIMapItem ( SID_IMAP_EXEC
, *this, *_pBindings
)
138 pIMapWnd
= new IMapWindow( this, SVX_RES( RID_SVXCTL_IMAP
), _pBindings
->GetActiveFrame() );
144 pOwnData
= new IMapOwnData
;
146 pIMapWnd
->SetInfoLink( LINK( this, SvxIMapDlg
, InfoHdl
) );
147 pIMapWnd
->SetMousePosLink( LINK( this, SvxIMapDlg
, MousePosHdl
) );
148 pIMapWnd
->SetGraphSizeLink( LINK( this, SvxIMapDlg
, GraphSizeHdl
) );
149 pIMapWnd
->SetUpdateLink( LINK( this, SvxIMapDlg
, StateHdl
) );
151 maURLBox
.SetModifyHdl( LINK( this, SvxIMapDlg
, URLModifyHdl
) );
152 maURLBox
.SetSelectHdl( LINK( this, SvxIMapDlg
, URLModifyHdl
) );
153 maURLBox
.SetLoseFocusHdl( LINK( this, SvxIMapDlg
, URLLoseFocusHdl
) );
154 aEdtText
.SetModifyHdl( LINK( this, SvxIMapDlg
, URLModifyHdl
) );
155 maCbbTarget
.SetLoseFocusHdl( LINK( this, SvxIMapDlg
, URLLoseFocusHdl
) );
157 SvtMiscOptions aMiscOptions
;
158 aMiscOptions
.AddListenerLink( LINK( this, SvxIMapDlg
, MiscHdl
) );
160 aTbxIMapDlg1
.SetOutStyle( aMiscOptions
.GetToolboxStyle() );
161 aTbxIMapDlg1
.SetSizePixel( aTbxIMapDlg1
.CalcWindowSizePixel() );
162 aTbxIMapDlg1
.SetSelectHdl( LINK( this, SvxIMapDlg
, TbxClickHdl
) );
163 aTbxIMapDlg1
.CheckItem( TBI_SELECT
, sal_True
);
164 TbxClickHdl( &aTbxIMapDlg1
);
166 SetMinOutputSizePixel( aLastSize
= GetOutputSizePixel() );
168 aStbStatus
.InsertItem( 1, 130, SIB_LEFT
| SIB_IN
| SIB_AUTOSIZE
);
169 aStbStatus
.InsertItem( 2, 10 + GetTextWidth( OUString(" 9999,99 cm / 9999,99 cm ") ), SIB_CENTER
| SIB_IN
);
170 aStbStatus
.InsertItem( 3, 10 + GetTextWidth( OUString(" 9999,99 cm x 9999,99 cm ") ), SIB_CENTER
| SIB_IN
);
176 maFtTarget
.Disable();
177 maCbbTarget
.Disable();
178 pOwnData
->bExecState
= sal_False
;
182 pOwnData
->aTimer
.SetTimeout( 100 );
183 pOwnData
->aTimer
.SetTimeoutHdl( LINK( this, SvxIMapDlg
, UpdateHdl
) );
185 aTbxIMapDlg1
.EnableItem( TBI_ACTIVE
, sal_False
);
186 aTbxIMapDlg1
.EnableItem( TBI_MACRO
, sal_False
);
187 aTbxIMapDlg1
.EnableItem( TBI_PROPERTY
, sal_False
);
190 SvxIMapDlg::~SvxIMapDlg()
197 void SvxIMapDlg::Resize()
199 SfxModelessDialog::Resize();
201 Size
aMinSize( GetMinOutputSizePixel() );
202 Size
aNewSize( GetOutputSizePixel() );
204 if ( aNewSize
.Height() >= aMinSize
.Height() )
206 Size
_aSize( aStbStatus
.GetSizePixel() );
207 Point
aPoint( 0, aNewSize
.Height() - _aSize
.Height() );
209 // Position the StatusBar
210 aStbStatus
.SetPosSizePixel( aPoint
, Size( aNewSize
.Width(), _aSize
.Height() ) );
213 // Position the EditWindow
214 _aSize
.Width() = aNewSize
.Width() - 18;
215 _aSize
.Height() = aPoint
.Y() - pIMapWnd
->GetPosPixel().Y() - 6;
216 pIMapWnd
->SetSizePixel( _aSize
);
218 aLastSize
= aNewSize
;
222 sal_Bool
SvxIMapDlg::Close()
224 sal_Bool bRet
= sal_True
;
226 if ( aTbxIMapDlg1
.IsItemEnabled( TBI_APPLY
) )
228 QueryBox
aQBox( this, WB_YES_NO_CANCEL
| WB_DEF_YES
,
229 String( SVX_RES( STR_IMAPDLG_MODIFY
) ) );
230 const long nRet
= aQBox
.Execute();
232 if( nRet
== RET_YES
)
234 SfxBoolItem
aBoolItem( SID_IMAP_EXEC
, sal_True
);
235 GetBindings().GetDispatcher()->Execute(
236 SID_IMAP_EXEC
, SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
, &aBoolItem
, 0L );
238 else if( nRet
== RET_CANCEL
)
241 else if( pIMapWnd
->IsChanged() )
243 QueryBox
aQBox( this, WB_YES_NO_CANCEL
| WB_DEF_YES
,
244 String( SVX_RES( STR_IMAPDLG_SAVE
) ) );
245 const long nRet
= aQBox
.Execute();
247 if( nRet
== RET_YES
)
249 else if( nRet
== RET_CANCEL
)
253 return( bRet
? SfxModelessDialog::Close() : sal_False
);
256 // Enabled or disable all Controls
258 void SvxIMapDlg::SetExecState( sal_Bool bEnable
)
260 pOwnData
->bExecState
= bEnable
;
263 void SvxIMapDlg::SetGraphic( const Graphic
& rGraphic
)
265 pIMapWnd
->SetGraphic( rGraphic
);
268 void SvxIMapDlg::SetImageMap( const ImageMap
& rImageMap
)
270 pIMapWnd
->SetImageMap( rImageMap
);
273 const ImageMap
& SvxIMapDlg::GetImageMap() const
275 return pIMapWnd
->GetImageMap();
278 void SvxIMapDlg::SetTargetList( const TargetList
& rTargetList
)
280 TargetList
aNewList( rTargetList
);
282 pIMapWnd
->SetTargetList( aNewList
);
286 for ( size_t i
= 0, n
= aNewList
.size(); i
< n
; ++i
)
287 maCbbTarget
.InsertEntry( *aNewList
[ i
] );
290 void SvxIMapDlg::Update( const Graphic
& rGraphic
, const ImageMap
* pImageMap
,
291 const TargetList
* pTargetList
, void* pEditingObj
)
293 pOwnData
->aUpdateGraphic
= rGraphic
;
296 pOwnData
->aUpdateImageMap
= *pImageMap
;
298 pOwnData
->aUpdateImageMap
.ClearImageMap();
300 pOwnData
->pUpdateEditingObject
= pEditingObj
;
302 // Delete UpdateTargetList, because this method can still be called several
303 // times before the update timer is turned on
304 for ( size_t i
= 0, n
= pOwnData
->aUpdateTargetList
.size(); i
< n
; ++i
)
305 delete pOwnData
->aUpdateTargetList
[ i
];
306 pOwnData
->aUpdateTargetList
.clear();
308 // TargetList must be copied, since it is owned by the caller and can be
309 // deleted immediately after this call the copied list will be deleted
310 // again in the handler
313 TargetList
aTargetList( *pTargetList
);
315 for ( size_t i
= 0, n
= aTargetList
.size(); i
< n
; ++i
)
316 pOwnData
->aUpdateTargetList
.push_back( new String( *aTargetList
[ i
] ) );
319 pOwnData
->aTimer
.Start();
323 void SvxIMapDlg::KeyInput( const KeyEvent
& rKEvt
)
325 SfxModelessDialog::KeyInput( rKEvt
);
328 // Click-handler for ToolBox
330 IMPL_LINK( SvxIMapDlg
, TbxClickHdl
, ToolBox
*, pTbx
)
332 sal_uInt16 nNewItemId
= pTbx
->GetCurItemId();
334 switch( pTbx
->GetCurItemId() )
338 URLLoseFocusHdl( NULL
);
339 SfxBoolItem
aBoolItem( SID_IMAP_EXEC
, sal_True
);
340 GetBindings().GetDispatcher()->Execute(
341 SID_IMAP_EXEC
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
, &aBoolItem
, 0L );
355 pTbx
->CheckItem( nNewItemId
, sal_True
);
356 pIMapWnd
->SetEditMode( sal_True
);
357 if( pTbx
->IsKeyEvent() )
359 if((pTbx
->GetKeyModifier() & KEY_MOD1
) != 0)
360 pIMapWnd
->SelectFirstObject();
362 pIMapWnd
->GrabFocus();
369 pTbx
->CheckItem( nNewItemId
, sal_True
);
370 pIMapWnd
->SetObjKind( OBJ_RECT
);
371 if( pTbx
->IsKeyEvent() && ((pTbx
->GetKeyModifier() & KEY_MOD1
) != 0) )
373 pIMapWnd
->CreateDefaultObject();
374 pIMapWnd
->GrabFocus();
381 pTbx
->CheckItem( nNewItemId
, sal_True
);
382 pIMapWnd
->SetObjKind( OBJ_CIRC
);
383 if( pTbx
->IsKeyEvent() && ((pTbx
->GetKeyModifier() & KEY_MOD1
) != 0) )
385 pIMapWnd
->CreateDefaultObject();
386 pIMapWnd
->GrabFocus();
393 pTbx
->CheckItem( nNewItemId
, sal_True
);
394 pIMapWnd
->SetObjKind( OBJ_POLY
);
395 if( pTbx
->IsKeyEvent() && ((pTbx
->GetKeyModifier() & KEY_MOD1
) != 0) )
397 pIMapWnd
->CreateDefaultObject();
398 pIMapWnd
->GrabFocus();
403 case( TBI_FREEPOLY
):
405 pTbx
->CheckItem( nNewItemId
, sal_True
);
406 pIMapWnd
->SetObjKind( OBJ_FREEFILL
);
407 if( pTbx
->IsKeyEvent() && ((pTbx
->GetKeyModifier() & KEY_MOD1
) != 0) )
409 pIMapWnd
->CreateDefaultObject();
410 pIMapWnd
->GrabFocus();
417 URLLoseFocusHdl( NULL
);
418 bool bNewState
= !pTbx
->IsItemChecked( TBI_ACTIVE
);
419 pTbx
->CheckItem( TBI_ACTIVE
, bNewState
);
420 pIMapWnd
->SetCurrentObjState( !bNewState
);
425 pIMapWnd
->DoMacroAssign();
428 case( TBI_PROPERTY
):
429 pIMapWnd
->DoPropertyDialog();
432 case( TBI_POLYEDIT
):
433 pIMapWnd
->SetPolyEditMode( pTbx
->IsItemChecked( TBI_POLYEDIT
) ? SID_BEZIER_MOVE
: 0 );
434 if( pTbx
->IsKeyEvent() && pTbx
->IsItemChecked( TBI_POLYEDIT
) )
435 pIMapWnd
->StartPolyEdit();
438 case( TBI_POLYMOVE
):
439 pIMapWnd
->SetPolyEditMode( SID_BEZIER_MOVE
);
442 case( TBI_POLYINSERT
):
443 pIMapWnd
->SetPolyEditMode( SID_BEZIER_INSERT
);
446 case( TBI_POLYDELETE
):
447 pIMapWnd
->GetSdrView()->DeleteMarkedPoints();
452 URLLoseFocusHdl( NULL
);
453 pIMapWnd
->GetSdrModel()->Undo();
459 URLLoseFocusHdl( NULL
);
460 pIMapWnd
->GetSdrModel()->Redo();
471 void SvxIMapDlg::DoOpen()
473 ::sfx2::FileDialogHelper
aDlg(
474 com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
, 0 );
477 const String
aFilter( IMAP_ALL_FILTER
);
479 aDlg
.AddFilter( aFilter
, IMAP_ALL_TYPE
);
480 aDlg
.AddFilter( IMAP_CERN_FILTER
, IMAP_CERN_TYPE
);
481 aDlg
.AddFilter( IMAP_NCSA_FILTER
, IMAP_NCSA_TYPE
);
482 aDlg
.AddFilter( IMAP_BINARY_FILTER
, IMAP_BINARY_TYPE
);
484 aDlg
.SetCurrentFilter( aFilter
);
485 aDlg
.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
487 if( aDlg
.Execute() == ERRCODE_NONE
)
489 INetURLObject
aURL( aDlg
.GetPath() );
490 DBG_ASSERT( aURL
.GetProtocol() != INET_PROT_NOT_VALID
, "invalid URL" );
491 SvStream
* pIStm
= ::utl::UcbStreamHelper::CreateStream( aURL
.GetMainURL( INetURLObject::NO_DECODE
), STREAM_READ
);
495 aLoadIMap
.Read( *pIStm
, IMAP_FORMAT_DETECT
, String() );
497 if( pIStm
->GetError() )
499 SfxErrorContext
eEC(ERRCODE_SFX_GENERAL
,this);
500 ErrorHandler::HandleError( ERRCODE_IO_GENERAL
);
503 pIMapWnd
->SetImageMap( aLoadIMap
);
508 pIMapWnd
->Invalidate();
512 sal_Bool
SvxIMapDlg::DoSave()
514 ::sfx2::FileDialogHelper
aDlg(
515 com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE
, 0 );
517 const String
aBinFilter( IMAP_BINARY_FILTER
);
518 const String
aCERNFilter( IMAP_CERN_FILTER
);
519 const String
aNCSAFilter( IMAP_NCSA_FILTER
);
520 SdrModel
* pModel
= pIMapWnd
->GetSdrModel();
521 const sal_Bool bChanged
= pModel
->IsChanged();
522 sal_Bool bRet
= false;
524 aDlg
.AddFilter( aCERNFilter
, IMAP_CERN_TYPE
);
525 aDlg
.AddFilter( aNCSAFilter
, IMAP_NCSA_TYPE
);
526 aDlg
.AddFilter( aBinFilter
, IMAP_BINARY_TYPE
);
528 aDlg
.SetCurrentFilter( aCERNFilter
);
529 aDlg
.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
531 if( aDlg
.Execute() == ERRCODE_NONE
)
533 const String
aFilter( aDlg
.GetCurrentFilter() );
537 if ( aFilter
== aBinFilter
)
539 nFormat
= IMAP_FORMAT_BIN
;
540 aExt
= IMAP_BINARY_EXT
;
542 else if ( aFilter
== aCERNFilter
)
544 nFormat
= IMAP_FORMAT_CERN
;
545 aExt
= IMAP_CERN_EXT
;
547 else if ( aFilter
== aNCSAFilter
)
549 nFormat
= IMAP_FORMAT_NCSA
;
550 aExt
= IMAP_NCSA_EXT
;
557 INetURLObject
aURL( aDlg
.GetPath() );
559 if( aURL
.GetProtocol() == INET_PROT_NOT_VALID
)
561 OSL_FAIL( "invalid URL" );
565 if( aURL
.getExtension().isEmpty() )
566 aURL
.setExtension( aExt
);
568 SvStream
* pOStm
= ::utl::UcbStreamHelper::CreateStream( aURL
.GetMainURL( INetURLObject::NO_DECODE
), STREAM_WRITE
| STREAM_TRUNC
);
571 pIMapWnd
->GetImageMap().Write( *pOStm
, nFormat
, String() );
573 if( pOStm
->GetError() )
574 ErrorHandler::HandleError( ERRCODE_IO_GENERAL
);
577 pModel
->SetChanged( bChanged
);
586 IMPL_LINK( SvxIMapDlg
, InfoHdl
, IMapWindow
*, pWnd
)
589 const NotifyInfo
& rInfo
= pWnd
->GetInfo();
593 if( rInfo
.aMarkURL
.Len() && ( maURLBox
.GetEntryPos( rInfo
.aMarkURL
) == LISTBOX_ENTRY_NOTFOUND
) )
594 maURLBox
.InsertEntry( rInfo
.aMarkURL
);
596 maURLBox
.SetText( rInfo
.aMarkURL
);
597 aEdtText
.SetText( rInfo
.aMarkAltText
);
599 if ( !rInfo
.aMarkTarget
.Len() )
600 maCbbTarget
.SetText( SELF_TARGET
);
602 maCbbTarget
.SetText( rInfo
.aMarkTarget
);
605 if ( !rInfo
.bOneMarked
)
607 aTbxIMapDlg1
.CheckItem( TBI_ACTIVE
, sal_False
);
608 aTbxIMapDlg1
.EnableItem( TBI_ACTIVE
, sal_False
);
609 aTbxIMapDlg1
.EnableItem( TBI_MACRO
, sal_False
);
610 aTbxIMapDlg1
.EnableItem( TBI_PROPERTY
, sal_False
);
611 aStbStatus
.SetItemText( 1, aStr
);
617 maFtTarget
.Disable();
618 maCbbTarget
.Disable();
620 maURLBox
.SetText( String() );
621 aEdtText
.SetText( String() );
625 aTbxIMapDlg1
.EnableItem( TBI_ACTIVE
, sal_True
);
626 aTbxIMapDlg1
.CheckItem( TBI_ACTIVE
, !rInfo
.bActivated
);
627 aTbxIMapDlg1
.EnableItem( TBI_MACRO
, sal_True
);
628 aTbxIMapDlg1
.EnableItem( TBI_PROPERTY
, sal_True
);
635 maCbbTarget
.Enable();
637 aStbStatus
.SetItemText( 1, rInfo
.aMarkURL
);
639 if ( maURLBox
.GetText() != OUString(rInfo
.aMarkURL
) )
640 maURLBox
.SetText( rInfo
.aMarkURL
);
642 if ( aEdtText
.GetText() != OUString(rInfo
.aMarkAltText
) )
643 aEdtText
.SetText( rInfo
.aMarkAltText
);
645 if ( !rInfo
.aMarkTarget
.Len() )
646 maCbbTarget
.SetText( SELF_TARGET
);
648 maCbbTarget
.SetText( rInfo
.aMarkTarget
);
654 IMPL_LINK( SvxIMapDlg
, MousePosHdl
, IMapWindow
*, pWnd
)
656 const FieldUnit eFieldUnit
= GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
657 const Point
& rMousePos
= pWnd
->GetMousePos();
658 const LocaleDataWrapper
& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
659 const sal_Unicode cSep
= rLocaleWrapper
.getNumDecimalSep()[0];
661 OUString aStr
= GetUnitString( rMousePos
.X(), eFieldUnit
, cSep
) +
662 " / " + GetUnitString( rMousePos
.Y(), eFieldUnit
, cSep
);
664 aStbStatus
.SetItemText( 2, aStr
);
669 IMPL_LINK( SvxIMapDlg
, GraphSizeHdl
, IMapWindow
*, pWnd
)
671 const FieldUnit eFieldUnit
= GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
672 const Size
& rSize
= pWnd
->GetGraphicSize();
673 const LocaleDataWrapper
& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
674 const sal_Unicode cSep
= rLocaleWrapper
.getNumDecimalSep()[0];
676 OUString aStr
= GetUnitString( rSize
.Width(), eFieldUnit
, cSep
) +
677 " x " + GetUnitString( rSize
.Height(), eFieldUnit
, cSep
);
679 aStbStatus
.SetItemText( 3, aStr
);
684 IMPL_LINK_NOARG(SvxIMapDlg
, URLModifyHdl
)
688 aNewInfo
.aMarkURL
= maURLBox
.GetText();
689 aNewInfo
.aMarkAltText
= aEdtText
.GetText();
690 aNewInfo
.aMarkTarget
= maCbbTarget
.GetText();
692 pIMapWnd
->ReplaceActualIMapInfo( aNewInfo
);
697 IMPL_LINK_NOARG(SvxIMapDlg
, URLLoseFocusHdl
)
700 const String
aURLText( maURLBox
.GetText() );
701 const String
aTargetText( maCbbTarget
.GetText() );
703 if ( aURLText
.Len() )
705 String aBase
= GetBindings().GetDispatcher()->GetFrame()->GetObjectShell()->GetMedium()->GetBaseURL();
706 aNewInfo
.aMarkURL
= ::URIHelper::SmartRel2Abs( INetURLObject(aBase
), aURLText
, URIHelper::GetMaybeFileHdl(), true, false,
707 INetURLObject::WAS_ENCODED
,
708 INetURLObject::DECODE_UNAMBIGUOUS
);
711 aNewInfo
.aMarkURL
= aURLText
;
713 aNewInfo
.aMarkAltText
= aEdtText
.GetText();
715 if ( !aTargetText
.Len() )
716 aNewInfo
.aMarkTarget
= SELF_TARGET
;
718 aNewInfo
.aMarkTarget
= aTargetText
;
720 pIMapWnd
->ReplaceActualIMapInfo( aNewInfo
);
725 IMPL_LINK_NOARG(SvxIMapDlg
, UpdateHdl
)
727 pOwnData
->aTimer
.Stop();
729 if ( pOwnData
->pUpdateEditingObject
!= pCheckObj
)
731 if ( pIMapWnd
->IsChanged() &&
732 ( QueryBox( this, WB_YES_NO
| WB_DEF_YES
,
733 String( SVX_RES( STR_IMAPDLG_SAVE
) ) ).Execute() == RET_YES
) )
738 SetGraphic( pOwnData
->aUpdateGraphic
);
739 SetImageMap( pOwnData
->aUpdateImageMap
);
740 SetTargetList( pOwnData
->aUpdateTargetList
);
741 SetEditingObject( pOwnData
->pUpdateEditingObject
);
743 // After changes => default selection
744 aTbxIMapDlg1
.CheckItem( TBI_SELECT
, sal_True
);
745 pIMapWnd
->SetEditMode( sal_True
);
748 // Delete the copied list again in the Update method
749 for ( size_t i
= 0, n
= pOwnData
->aUpdateTargetList
.size(); i
< n
; ++i
)
750 delete pOwnData
->aUpdateTargetList
[ i
];
751 pOwnData
->aUpdateTargetList
.clear();
753 GetBindings().Invalidate( SID_IMAP_EXEC
);
758 IMPL_LINK( SvxIMapDlg
, StateHdl
, IMapWindow
*, pWnd
)
760 const SdrObject
* pObj
= pWnd
->GetSelectedSdrObject();
761 const SdrModel
* pModel
= pWnd
->GetSdrModel();
762 const SdrView
* pView
= pWnd
->GetSdrView();
763 const sal_Bool bPolyEdit
= ( pObj
!= NULL
) && pObj
->ISA( SdrPathObj
);
764 const sal_Bool bDrawEnabled
= !( bPolyEdit
&& aTbxIMapDlg1
.IsItemChecked( TBI_POLYEDIT
) );
766 aTbxIMapDlg1
.EnableItem( TBI_APPLY
, pOwnData
->bExecState
&& pWnd
->IsChanged() );
768 aTbxIMapDlg1
.EnableItem( TBI_SELECT
, bDrawEnabled
);
769 aTbxIMapDlg1
.EnableItem( TBI_RECT
, bDrawEnabled
);
770 aTbxIMapDlg1
.EnableItem( TBI_CIRCLE
, bDrawEnabled
);
771 aTbxIMapDlg1
.EnableItem( TBI_POLY
, bDrawEnabled
);
772 aTbxIMapDlg1
.EnableItem( TBI_FREEPOLY
, bDrawEnabled
);
774 // BezierEditor-Stati
775 aTbxIMapDlg1
.EnableItem( TBI_POLYEDIT
, bPolyEdit
);
776 aTbxIMapDlg1
.EnableItem( TBI_POLYMOVE
, !bDrawEnabled
);
777 aTbxIMapDlg1
.EnableItem( TBI_POLYINSERT
, !bDrawEnabled
);
778 aTbxIMapDlg1
.EnableItem( TBI_POLYDELETE
, !bDrawEnabled
&& pView
->IsDeleteMarkedPointsPossible() );
781 aTbxIMapDlg1
.EnableItem( TBI_UNDO
, pModel
->HasUndoActions() );
782 aTbxIMapDlg1
.EnableItem( TBI_REDO
, pModel
->HasRedoActions() );
788 switch( pWnd
->GetPolyEditMode() )
790 case( SID_BEZIER_MOVE
): nId
= TBI_POLYMOVE
; break;
791 case( SID_BEZIER_INSERT
): nId
= TBI_POLYINSERT
; break;
797 aTbxIMapDlg1
.CheckItem( nId
, sal_True
);
801 aTbxIMapDlg1
.CheckItem( TBI_POLYEDIT
, sal_False
);
802 aTbxIMapDlg1
.CheckItem( TBI_POLYMOVE
, sal_True
);
803 aTbxIMapDlg1
.CheckItem( TBI_POLYINSERT
, sal_False
);
804 pWnd
->SetPolyEditMode( 0 );
810 IMPL_LINK_NOARG(SvxIMapDlg
, MiscHdl
)
812 SvtMiscOptions aMiscOptions
;
813 aTbxIMapDlg1
.SetOutStyle( aMiscOptions
.GetToolboxStyle() );
818 void SvxIMapDlg::ApplyImageList()
820 ImageList
& rImgLst
= maImageList
;
822 aTbxIMapDlg1
.SetImageList( rImgLst
);
825 void SvxIMapDlg::DataChanged( const DataChangedEvent
& rDCEvt
)
827 SfxModelessDialog::DataChanged( rDCEvt
);
829 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
833 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */