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