LCOV - code coverage report
Current view: top level - svx/source/dialog - imapdlg.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 2 417 0.5 %
Date: 2014-04-11 Functions: 4 44 9.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <stdlib.h>
      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>
      43             : #include <vcl/layout.hxx>
      44             : #include <svx/imapdlg.hxx>
      45             : #include <svx/dialmgr.hxx>
      46             : #include <svx/dialogs.hrc>
      47             : #include <svx/svxids.hrc>
      48             : #include "imapdlg.hrc"
      49             : #include "imapwnd.hxx"
      50             : #include "imapimp.hxx"
      51             : #include "svx/dlgutil.hxx"
      52             : #include <svx/svdtrans.hxx>
      53             : #include <svx/svdopath.hxx>
      54             : #include <vcl/svapp.hxx>
      55             : #include <vcl/settings.hxx>
      56             : #include "dlgunit.hxx"
      57             : 
      58             : #define SELF_TARGET         "_self"
      59             : #define IMAP_ALL_FILTER     OUString("<Alle>")
      60             : #define IMAP_CERN_FILTER    OUString("MAP - CERN")
      61             : #define IMAP_NCSA_FILTER    OUString("MAP - NCSA")
      62             : #define IMAP_BINARY_FILTER  OUString("SIP - StarView ImageMap")
      63             : #define IMAP_ALL_TYPE       OUString("*.*")
      64             : #define IMAP_BINARY_TYPE    OUString("*.sip")
      65             : #define IMAP_CERN_TYPE      OUString("*.map")
      66             : #define IMAP_NCSA_TYPE      OUString("*.map")
      67             : #define IMAP_BINARY_EXT     OUString("sip")
      68             : #define IMAP_CERN_EXT       OUString("map")
      69             : #define IMAP_NCSA_EXT       OUString("map")
      70             : 
      71             : /******************************************************************************/
      72             : 
      73         278 : SFX_IMPL_MODELESSDIALOG_WITHID( SvxIMapDlgChildWindow, SID_IMAP );
      74             : 
      75             : // ControllerItem
      76             : 
      77           0 : SvxIMapDlgItem::SvxIMapDlgItem( sal_uInt16 _nId, SvxIMapDlg& rIMapDlg, SfxBindings& rBindings ) :
      78             :             SfxControllerItem   ( _nId, rBindings ),
      79           0 :             rIMap               ( rIMapDlg )
      80             : {
      81           0 : }
      82             : 
      83           0 : void SvxIMapDlgItem::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/,
      84             :                                    const SfxPoolItem* pItem )
      85             : {
      86           0 :     if ( ( nSID == SID_IMAP_EXEC ) && pItem )
      87             :     {
      88           0 :         const SfxBoolItem* pStateItem = PTR_CAST( SfxBoolItem, pItem );
      89             : 
      90             :         DBG_ASSERT( pStateItem || pItem == 0, "SfxBoolItem expected");
      91             : 
      92             :         // Disable Float if possible
      93           0 :         rIMap.SetExecState( !pStateItem->GetValue() );
      94             :     }
      95           0 : }
      96             : 
      97           0 : SvxIMapDlgChildWindow::SvxIMapDlgChildWindow( Window* _pParent, sal_uInt16 nId,
      98             :                                               SfxBindings* pBindings,
      99             :                                               SfxChildWinInfo* pInfo ) :
     100           0 :             SfxChildWindow( _pParent, nId )
     101             : {
     102           0 :     pWindow = new SvxIMapDlg( pBindings, this, _pParent, SVX_RES( RID_SVXDLG_IMAP ) );
     103           0 :     SvxIMapDlg* pDlg = (SvxIMapDlg*) pWindow;
     104             : 
     105           0 :     if ( pInfo->nFlags & SFX_CHILDWIN_ZOOMIN )
     106           0 :         pDlg->RollUp();
     107             : 
     108           0 :     eChildAlignment = SFX_ALIGN_NOALIGNMENT;
     109             : 
     110           0 :     pDlg->Initialize( pInfo );
     111           0 : }
     112             : 
     113           0 : void SvxIMapDlgChildWindow::UpdateIMapDlg( const Graphic& rGraphic, const ImageMap* pImageMap,
     114             :                                            const TargetList* pTargetList, void* pEditingObj )
     115             : {
     116           0 :     if ( SfxViewFrame::Current() &&
     117           0 :          SfxViewFrame::Current()->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
     118           0 :         SVXIMAPDLG()->UpdateLink( rGraphic, pImageMap, pTargetList, pEditingObj );
     119           0 : }
     120             : 
     121           0 : SvxIMapDlg::SvxIMapDlg( SfxBindings *_pBindings, SfxChildWindow *pCW,
     122             :                         Window* _pParent, const ResId& rResId ) :
     123             :         SfxModelessDialog   ( _pBindings, pCW, _pParent, rResId ),
     124             : 
     125           0 :         aTbxIMapDlg1        ( this, SVX_RES( TBX_IMAPDLG1 ) ),
     126           0 :         aFtURL              ( this, SVX_RES( FT_URL ) ),
     127           0 :         maURLBox            ( this, SVX_RES( CBB_URL ) ),
     128           0 :         aFtText             ( this, SVX_RES( FT_TEXT ) ),
     129           0 :         aEdtText            ( this, SVX_RES( EDT_TEXT ) ),
     130           0 :         maFtTarget          ( this, SVX_RES( RID_SVXCTL_FT_TARGET ) ),
     131           0 :         maCbbTarget         ( this, SVX_RES( RID_SVXCTL_CBB_TARGET ) ),
     132             :         aStbStatus          ( this, WB_BORDER | WB_3DLOOK | WB_LEFT ),
     133           0 :         maImageList         ( SVX_RES( IL_IMAPDLG ) ),
     134             :         pCheckObj           ( NULL ),
     135           0 :         aIMapItem           ( SID_IMAP_EXEC, *this, *_pBindings )
     136             : {
     137           0 :     pIMapWnd = new IMapWindow( this, SVX_RES( RID_SVXCTL_IMAP ), _pBindings->GetActiveFrame() );
     138             : 
     139           0 :     ApplyImageList();
     140             : 
     141           0 :     FreeResource();
     142             : 
     143           0 :     pOwnData = new IMapOwnData;
     144             : 
     145           0 :     pIMapWnd->SetInfoLink( LINK( this, SvxIMapDlg, InfoHdl ) );
     146           0 :     pIMapWnd->SetMousePosLink( LINK( this, SvxIMapDlg, MousePosHdl ) );
     147           0 :     pIMapWnd->SetGraphSizeLink( LINK( this, SvxIMapDlg, GraphSizeHdl ) );
     148           0 :     pIMapWnd->SetUpdateLink( LINK( this, SvxIMapDlg, StateHdl ) );
     149             : 
     150           0 :     maURLBox.SetModifyHdl( LINK( this, SvxIMapDlg, URLModifyHdl ) );
     151           0 :     maURLBox.SetSelectHdl( LINK( this, SvxIMapDlg, URLModifyHdl ) );
     152           0 :     maURLBox.SetLoseFocusHdl( LINK( this, SvxIMapDlg, URLLoseFocusHdl ) );
     153           0 :     aEdtText.SetModifyHdl( LINK( this, SvxIMapDlg, URLModifyHdl ) );
     154           0 :     maCbbTarget.SetLoseFocusHdl( LINK( this, SvxIMapDlg, URLLoseFocusHdl ) );
     155             : 
     156           0 :        SvtMiscOptions aMiscOptions;
     157           0 :     aMiscOptions.AddListenerLink( LINK( this, SvxIMapDlg, MiscHdl ) );
     158             : 
     159           0 :     aTbxIMapDlg1.SetOutStyle( aMiscOptions.GetToolboxStyle() );
     160           0 :     aTbxIMapDlg1.SetSizePixel( aTbxIMapDlg1.CalcWindowSizePixel() );
     161           0 :     aTbxIMapDlg1.SetSelectHdl( LINK( this, SvxIMapDlg, TbxClickHdl ) );
     162           0 :     aTbxIMapDlg1.CheckItem( TBI_SELECT, true );
     163           0 :     TbxClickHdl( &aTbxIMapDlg1 );
     164             : 
     165           0 :     SetMinOutputSizePixel( aLastSize = GetOutputSizePixel() );
     166             : 
     167           0 :     aStbStatus.InsertItem( 1, 130, SIB_LEFT | SIB_IN | SIB_AUTOSIZE );
     168           0 :     aStbStatus.InsertItem( 2, 10 + GetTextWidth( OUString(" 9999,99 cm / 9999,99 cm ") ), SIB_CENTER | SIB_IN );
     169           0 :     aStbStatus.InsertItem( 3, 10 + GetTextWidth( OUString(" 9999,99 cm x 9999,99 cm ") ), SIB_CENTER | SIB_IN );
     170             : 
     171           0 :     aFtURL.Disable();
     172           0 :     maURLBox.Disable();
     173           0 :     aFtText.Disable();
     174           0 :     aEdtText.Disable();
     175           0 :     maFtTarget.Disable();
     176           0 :     maCbbTarget.Disable();
     177           0 :     pOwnData->bExecState = sal_False;
     178             : 
     179           0 :     Resize();
     180             : 
     181           0 :     pOwnData->aTimer.SetTimeout( 100 );
     182           0 :     pOwnData->aTimer.SetTimeoutHdl( LINK( this, SvxIMapDlg, UpdateHdl ) );
     183             : 
     184           0 :     aTbxIMapDlg1.EnableItem( TBI_ACTIVE, false );
     185           0 :     aTbxIMapDlg1.EnableItem( TBI_MACRO, false );
     186           0 :     aTbxIMapDlg1.EnableItem( TBI_PROPERTY, false );
     187           0 : }
     188             : 
     189           0 : SvxIMapDlg::~SvxIMapDlg()
     190             : {
     191             :     // Delete URL-List
     192           0 :     delete pIMapWnd;
     193           0 :     delete pOwnData;
     194           0 : }
     195             : 
     196           0 : void SvxIMapDlg::Resize()
     197             : {
     198           0 :     SfxModelessDialog::Resize();
     199             : 
     200           0 :     Size aMinSize( GetMinOutputSizePixel() );
     201           0 :     Size aNewSize( GetOutputSizePixel() );
     202             : 
     203           0 :     if ( aNewSize.Height() >= aMinSize.Height() )
     204             :     {
     205           0 :         Size    _aSize( aStbStatus.GetSizePixel() );
     206           0 :         Point   aPoint( 0, aNewSize.Height() - _aSize.Height() );
     207             : 
     208             :         // Position the StatusBar
     209           0 :         aStbStatus.SetPosSizePixel( aPoint, Size( aNewSize.Width(), _aSize.Height() ) );
     210           0 :         aStbStatus.Show();
     211             : 
     212             :         // Position the EditWindow
     213           0 :         _aSize.Width() = aNewSize.Width() - 18;
     214           0 :         _aSize.Height() = aPoint.Y() - pIMapWnd->GetPosPixel().Y() - 6;
     215           0 :         pIMapWnd->SetSizePixel( _aSize );
     216             : 
     217           0 :         aLastSize = aNewSize;
     218             :     }
     219           0 : }
     220             : 
     221           0 : bool SvxIMapDlg::Close()
     222             : {
     223           0 :     sal_Bool bRet = sal_True;
     224             : 
     225           0 :     if ( aTbxIMapDlg1.IsItemEnabled( TBI_APPLY ) )
     226             :     {
     227           0 :         MessageDialog aQBox( this,"QueryModifyImageMapChangesDialog","svx/ui/querymodifyimagemapchangesdialog.ui");
     228           0 :         const long  nRet = aQBox.Execute();
     229             : 
     230           0 :         if( nRet == RET_YES )
     231             :         {
     232           0 :             SfxBoolItem aBoolItem( SID_IMAP_EXEC, true );
     233           0 :             GetBindings().GetDispatcher()->Execute(
     234           0 :                 SID_IMAP_EXEC, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aBoolItem, 0L );
     235             :         }
     236           0 :         else if( nRet == RET_CANCEL )
     237           0 :             bRet = sal_False;
     238             :     }
     239           0 :     else if( pIMapWnd->IsChanged() )
     240             :     {
     241           0 :         MessageDialog aQBox( this,"QuerySaveImageMapChangesDialog","svx/ui/querysaveimagemapchangesdialog.ui");
     242           0 :         const long  nRet = aQBox.Execute();
     243             : 
     244           0 :         if( nRet == RET_YES )
     245           0 :             bRet = DoSave();
     246           0 :         else if( nRet == RET_CANCEL )
     247           0 :             bRet = sal_False;
     248             :     }
     249             : 
     250           0 :     return( bRet ? SfxModelessDialog::Close() : sal_False );
     251             : }
     252             : 
     253             : // Enabled or disable all Controls
     254             : 
     255           0 : void SvxIMapDlg::SetExecState( bool bEnable )
     256             : {
     257           0 :     pOwnData->bExecState = bEnable;
     258           0 : }
     259             : 
     260           0 : void SvxIMapDlg::SetGraphic( const Graphic& rGraphic )
     261             : {
     262           0 :     pIMapWnd->SetGraphic( rGraphic );
     263           0 : }
     264             : 
     265           0 : void SvxIMapDlg::SetImageMap( const ImageMap& rImageMap )
     266             : {
     267           0 :     pIMapWnd->SetImageMap( rImageMap );
     268           0 : }
     269             : 
     270           0 : const ImageMap& SvxIMapDlg::GetImageMap() const
     271             : {
     272           0 :     return pIMapWnd->GetImageMap();
     273             : }
     274             : 
     275           0 : void SvxIMapDlg::SetTargetList( const TargetList& rTargetList )
     276             : {
     277           0 :     TargetList  aNewList( rTargetList );
     278             : 
     279           0 :     pIMapWnd->SetTargetList( aNewList );
     280             : 
     281           0 :     maCbbTarget.Clear();
     282             : 
     283           0 :     for ( size_t i = 0, n = aNewList.size(); i < n; ++i )
     284           0 :         maCbbTarget.InsertEntry( aNewList[ i ] );
     285           0 : }
     286             : 
     287           0 : void SvxIMapDlg::UpdateLink( const Graphic& rGraphic, const ImageMap* pImageMap,
     288             :                          const TargetList* pTargetList, void* pEditingObj )
     289             : {
     290           0 :     pOwnData->aUpdateGraphic = rGraphic;
     291             : 
     292           0 :     if ( pImageMap )
     293           0 :         pOwnData->aUpdateImageMap = *pImageMap;
     294             :     else
     295           0 :         pOwnData->aUpdateImageMap.ClearImageMap();
     296             : 
     297           0 :     pOwnData->pUpdateEditingObject = pEditingObj;
     298             : 
     299             :     // Delete UpdateTargetList, because this method can still be called several
     300             :     // times before the update timer is turned on
     301           0 :     pOwnData->aUpdateTargetList.clear();
     302             : 
     303             :     // TargetList must be copied, since it is owned by the caller and can be
     304             :     // deleted immediately after this call the copied list will be deleted
     305             :     // again in the handler
     306           0 :     if( pTargetList )
     307             :     {
     308           0 :         TargetList aTargetList( *pTargetList );
     309             : 
     310           0 :         for ( size_t i = 0, n = aTargetList.size(); i < n; ++i )
     311           0 :             pOwnData->aUpdateTargetList.push_back( aTargetList[ i ] );
     312             :     }
     313             : 
     314           0 :     pOwnData->aTimer.Start();
     315           0 : }
     316             : 
     317             : 
     318           0 : void SvxIMapDlg::KeyInput( const KeyEvent& rKEvt )
     319             : {
     320           0 :         SfxModelessDialog::KeyInput( rKEvt );
     321           0 : }
     322             : 
     323             : // Click-handler for ToolBox
     324             : 
     325           0 : IMPL_LINK( SvxIMapDlg, TbxClickHdl, ToolBox*, pTbx )
     326             : {
     327           0 :     sal_uInt16 nNewItemId = pTbx->GetCurItemId();
     328             : 
     329           0 :     switch( pTbx->GetCurItemId() )
     330             :     {
     331             :         case( TBI_APPLY ):
     332             :         {
     333           0 :             URLLoseFocusHdl( NULL );
     334           0 :             SfxBoolItem aBoolItem( SID_IMAP_EXEC, true );
     335           0 :             GetBindings().GetDispatcher()->Execute(
     336           0 :                 SID_IMAP_EXEC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aBoolItem, 0L );
     337             :         }
     338           0 :         break;
     339             : 
     340             :         case( TBI_OPEN ):
     341           0 :             DoOpen();
     342           0 :         break;
     343             : 
     344             :         case( TBI_SAVEAS ):
     345           0 :             DoSave();
     346           0 :         break;
     347             : 
     348             :         case( TBI_SELECT ):
     349             :         {
     350           0 :             pTbx->CheckItem( nNewItemId, true );
     351           0 :             pIMapWnd->SetEditMode( true );
     352           0 :             if( pTbx->IsKeyEvent() )
     353             :             {
     354           0 :                 if((pTbx->GetKeyModifier() & KEY_MOD1) != 0)
     355           0 :                     pIMapWnd->SelectFirstObject();
     356             :                 else
     357           0 :                     pIMapWnd->GrabFocus();
     358             :             }
     359             :         }
     360           0 :         break;
     361             : 
     362             :         case( TBI_RECT ):
     363             :         {
     364           0 :             pTbx->CheckItem( nNewItemId, true );
     365           0 :             pIMapWnd->SetObjKind( OBJ_RECT );
     366           0 :             if( pTbx->IsKeyEvent() && ((pTbx->GetKeyModifier() & KEY_MOD1) != 0) )
     367             :             {
     368           0 :                 pIMapWnd->CreateDefaultObject();
     369           0 :                 pIMapWnd->GrabFocus();
     370             :             }
     371             :         }
     372           0 :         break;
     373             : 
     374             :         case( TBI_CIRCLE ):
     375             :         {
     376           0 :             pTbx->CheckItem( nNewItemId, true );
     377           0 :             pIMapWnd->SetObjKind( OBJ_CIRC );
     378           0 :             if( pTbx->IsKeyEvent() && ((pTbx->GetKeyModifier() & KEY_MOD1) != 0) )
     379             :             {
     380           0 :                 pIMapWnd->CreateDefaultObject();
     381           0 :                 pIMapWnd->GrabFocus();
     382             :             }
     383             :         }
     384           0 :         break;
     385             : 
     386             :         case( TBI_POLY ):
     387             :         {
     388           0 :             pTbx->CheckItem( nNewItemId, true );
     389           0 :             pIMapWnd->SetObjKind( OBJ_POLY );
     390           0 :             if( pTbx->IsKeyEvent() && ((pTbx->GetKeyModifier() & KEY_MOD1) != 0) )
     391             :             {
     392           0 :                 pIMapWnd->CreateDefaultObject();
     393           0 :                 pIMapWnd->GrabFocus();
     394             :             }
     395             :         }
     396           0 :         break;
     397             : 
     398             :         case( TBI_FREEPOLY ):
     399             :         {
     400           0 :             pTbx->CheckItem( nNewItemId, true );
     401           0 :             pIMapWnd->SetObjKind( OBJ_FREEFILL );
     402           0 :             if( pTbx->IsKeyEvent() && ((pTbx->GetKeyModifier() & KEY_MOD1) != 0) )
     403             :             {
     404           0 :                 pIMapWnd->CreateDefaultObject();
     405           0 :                 pIMapWnd->GrabFocus();
     406             :             }
     407             :         }
     408           0 :         break;
     409             : 
     410             :         case( TBI_ACTIVE ):
     411             :         {
     412           0 :             URLLoseFocusHdl( NULL );
     413           0 :             bool bNewState = !pTbx->IsItemChecked( TBI_ACTIVE );
     414           0 :             pTbx->CheckItem( TBI_ACTIVE, bNewState );
     415           0 :             pIMapWnd->SetCurrentObjState( !bNewState );
     416             :         }
     417           0 :         break;
     418             : 
     419             :         case( TBI_MACRO ):
     420           0 :             pIMapWnd->DoMacroAssign();
     421           0 :         break;
     422             : 
     423             :         case( TBI_PROPERTY ):
     424           0 :             pIMapWnd->DoPropertyDialog();
     425           0 :         break;
     426             : 
     427             :         case( TBI_POLYEDIT ):
     428           0 :             pIMapWnd->SetPolyEditMode( pTbx->IsItemChecked( TBI_POLYEDIT ) ? SID_BEZIER_MOVE : 0 );
     429           0 :             if( pTbx->IsKeyEvent() && pTbx->IsItemChecked( TBI_POLYEDIT ) )
     430           0 :                 pIMapWnd->StartPolyEdit();
     431           0 :         break;
     432             : 
     433             :         case( TBI_POLYMOVE ):
     434           0 :             pIMapWnd->SetPolyEditMode( SID_BEZIER_MOVE );
     435           0 :         break;
     436             : 
     437             :         case( TBI_POLYINSERT ):
     438           0 :             pIMapWnd->SetPolyEditMode( SID_BEZIER_INSERT );
     439           0 :         break;
     440             : 
     441             :         case( TBI_POLYDELETE ):
     442           0 :             pIMapWnd->GetSdrView()->DeleteMarkedPoints();
     443           0 :         break;
     444             : 
     445             :         case( TBI_UNDO ):
     446             :         {
     447           0 :             URLLoseFocusHdl( NULL );
     448           0 :             pIMapWnd->GetSdrModel()->Undo();
     449             :         }
     450           0 :         break;
     451             : 
     452             :         case( TBI_REDO ):
     453             :         {
     454           0 :             URLLoseFocusHdl( NULL );
     455           0 :             pIMapWnd->GetSdrModel()->Redo();
     456             :         }
     457           0 :         break;
     458             : 
     459             :         default:
     460           0 :         break;
     461             :     }
     462             : 
     463           0 :     return 0;
     464             : }
     465             : 
     466           0 : void SvxIMapDlg::DoOpen()
     467             : {
     468             :     ::sfx2::FileDialogHelper aDlg(
     469           0 :         com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
     470             : 
     471           0 :     ImageMap        aLoadIMap;
     472           0 :     const OUString  aFilter( IMAP_ALL_FILTER );
     473             : 
     474           0 :     aDlg.AddFilter( aFilter, IMAP_ALL_TYPE );
     475           0 :     aDlg.AddFilter( IMAP_CERN_FILTER, IMAP_CERN_TYPE );
     476           0 :     aDlg.AddFilter( IMAP_NCSA_FILTER, IMAP_NCSA_TYPE );
     477           0 :     aDlg.AddFilter( IMAP_BINARY_FILTER, IMAP_BINARY_TYPE );
     478             : 
     479           0 :     aDlg.SetCurrentFilter( aFilter );
     480           0 :     aDlg.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
     481             : 
     482           0 :     if( aDlg.Execute() == ERRCODE_NONE )
     483             :     {
     484           0 :         INetURLObject aURL( aDlg.GetPath() );
     485             :         DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
     486           0 :         SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
     487             : 
     488           0 :         if( pIStm )
     489             :         {
     490           0 :             aLoadIMap.Read( *pIStm, IMAP_FORMAT_DETECT, "" );
     491             : 
     492           0 :             if( pIStm->GetError() )
     493             :             {
     494           0 :                 SfxErrorContext eEC(ERRCODE_SFX_GENERAL,this);
     495           0 :                 ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
     496             :             }
     497             :             else
     498           0 :                 pIMapWnd->SetImageMap( aLoadIMap );
     499             : 
     500           0 :             delete pIStm;
     501             :         }
     502             : 
     503           0 :         pIMapWnd->Invalidate();
     504           0 :     }
     505           0 : }
     506             : 
     507           0 : bool SvxIMapDlg::DoSave()
     508             : {
     509             :     ::sfx2::FileDialogHelper aDlg(
     510           0 :         com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
     511             : 
     512           0 :     const OUString    aBinFilter( IMAP_BINARY_FILTER );
     513           0 :     const OUString    aCERNFilter( IMAP_CERN_FILTER );
     514           0 :     const OUString    aNCSAFilter( IMAP_NCSA_FILTER );
     515           0 :     SdrModel*       pModel = pIMapWnd->GetSdrModel();
     516           0 :     const sal_Bool bChanged = pModel->IsChanged();
     517           0 :     bool            bRet = false;
     518             : 
     519           0 :     aDlg.AddFilter( aCERNFilter, IMAP_CERN_TYPE );
     520           0 :     aDlg.AddFilter( aNCSAFilter, IMAP_NCSA_TYPE );
     521           0 :     aDlg.AddFilter( aBinFilter, IMAP_BINARY_TYPE );
     522             : 
     523           0 :     aDlg.SetCurrentFilter( aCERNFilter );
     524           0 :     aDlg.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
     525             : 
     526           0 :     if( aDlg.Execute() == ERRCODE_NONE )
     527             :     {
     528           0 :         const OUString    aFilter( aDlg.GetCurrentFilter() );
     529           0 :         OUString          aExt;
     530             :         sal_uIntPtr       nFormat;
     531             : 
     532           0 :         if ( aFilter == aBinFilter )
     533             :         {
     534           0 :             nFormat = IMAP_FORMAT_BIN;
     535           0 :             aExt = IMAP_BINARY_EXT;
     536             :         }
     537           0 :         else if ( aFilter == aCERNFilter )
     538             :         {
     539           0 :             nFormat = IMAP_FORMAT_CERN;
     540           0 :             aExt = IMAP_CERN_EXT;
     541             :         }
     542           0 :         else if ( aFilter == aNCSAFilter )
     543             :         {
     544           0 :             nFormat = IMAP_FORMAT_NCSA;
     545           0 :             aExt = IMAP_NCSA_EXT;
     546             :         }
     547             :         else
     548             :         {
     549           0 :             return false;
     550             :         }
     551             : 
     552           0 :         INetURLObject aURL( aDlg.GetPath() );
     553             : 
     554           0 :         if( aURL.GetProtocol() == INET_PROT_NOT_VALID )
     555             :         {
     556             :             OSL_FAIL( "invalid URL" );
     557             :         }
     558             :         else
     559             :         {
     560           0 :             if( aURL.getExtension().isEmpty() )
     561           0 :                 aURL.setExtension( aExt );
     562             : 
     563           0 :             SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_TRUNC );
     564           0 :             if( pOStm )
     565             :             {
     566           0 :                 pIMapWnd->GetImageMap().Write( *pOStm, nFormat, "" );
     567             : 
     568           0 :                 if( pOStm->GetError() )
     569           0 :                     ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
     570             : 
     571           0 :                 delete pOStm;
     572           0 :                 pModel->SetChanged( bChanged );
     573           0 :                 bRet = true;
     574             :             }
     575           0 :         }
     576             :     }
     577             : 
     578           0 :     return bRet;
     579             : }
     580             : 
     581           0 : IMPL_LINK( SvxIMapDlg, InfoHdl, IMapWindow*, pWnd )
     582             : {
     583           0 :     OUString            aStr;
     584           0 :     const NotifyInfo&   rInfo = pWnd->GetInfo();
     585             : 
     586           0 :     if ( rInfo.bNewObj )
     587             :     {
     588           0 :         if( !rInfo.aMarkURL.isEmpty() && ( maURLBox.GetEntryPos( rInfo.aMarkURL ) == LISTBOX_ENTRY_NOTFOUND ) )
     589           0 :             maURLBox.InsertEntry( rInfo.aMarkURL );
     590             : 
     591           0 :         maURLBox.SetText( rInfo.aMarkURL );
     592           0 :         aEdtText.SetText( rInfo.aMarkAltText );
     593             : 
     594           0 :         if ( rInfo.aMarkTarget.isEmpty() )
     595           0 :             maCbbTarget.SetText( SELF_TARGET );
     596             :         else
     597           0 :             maCbbTarget.SetText( rInfo.aMarkTarget );
     598             :     }
     599             : 
     600           0 :     if ( !rInfo.bOneMarked )
     601             :     {
     602           0 :         aTbxIMapDlg1.CheckItem( TBI_ACTIVE, false );
     603           0 :         aTbxIMapDlg1.EnableItem( TBI_ACTIVE, false );
     604           0 :         aTbxIMapDlg1.EnableItem( TBI_MACRO, false );
     605           0 :         aTbxIMapDlg1.EnableItem( TBI_PROPERTY, false );
     606           0 :         aStbStatus.SetItemText( 1, aStr );
     607             : 
     608           0 :         aFtURL.Disable();
     609           0 :         maURLBox.Disable();
     610           0 :         aFtText.Disable();
     611           0 :         aEdtText.Disable();
     612           0 :         maFtTarget.Disable();
     613           0 :         maCbbTarget.Disable();
     614             : 
     615           0 :         maURLBox.SetText( "" );
     616           0 :         aEdtText.SetText( "" );
     617             :     }
     618             :     else
     619             :     {
     620           0 :         aTbxIMapDlg1.EnableItem( TBI_ACTIVE, true );
     621           0 :         aTbxIMapDlg1.CheckItem( TBI_ACTIVE, !rInfo.bActivated );
     622           0 :         aTbxIMapDlg1.EnableItem( TBI_MACRO, true );
     623           0 :         aTbxIMapDlg1.EnableItem( TBI_PROPERTY, true );
     624             : 
     625           0 :         aFtURL.Enable();
     626           0 :         maURLBox.Enable();
     627           0 :         aFtText.Enable();
     628           0 :         aEdtText.Enable();
     629           0 :         maFtTarget.Enable();
     630           0 :         maCbbTarget.Enable();
     631             : 
     632           0 :         aStbStatus.SetItemText( 1, rInfo.aMarkURL );
     633             : 
     634           0 :         if ( maURLBox.GetText() != OUString(rInfo.aMarkURL) )
     635           0 :             maURLBox.SetText( rInfo.aMarkURL );
     636             : 
     637           0 :         if ( aEdtText.GetText() != OUString(rInfo.aMarkAltText) )
     638           0 :             aEdtText.SetText( rInfo.aMarkAltText );
     639             : 
     640           0 :         if ( rInfo.aMarkTarget.isEmpty() )
     641           0 :             maCbbTarget.SetText( SELF_TARGET );
     642             :         else
     643           0 :             maCbbTarget.SetText(  rInfo.aMarkTarget );
     644             :     }
     645             : 
     646           0 :     return 0;
     647             : }
     648             : 
     649           0 : IMPL_LINK( SvxIMapDlg, MousePosHdl, IMapWindow*, pWnd )
     650             : {
     651           0 :     const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
     652           0 :     const Point& rMousePos = pWnd->GetMousePos();
     653           0 :     const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
     654           0 :     const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0];
     655             : 
     656           0 :     OUString aStr = GetUnitString( rMousePos.X(), eFieldUnit, cSep ) +
     657           0 :                     " / " + GetUnitString( rMousePos.Y(), eFieldUnit, cSep );
     658             : 
     659           0 :     aStbStatus.SetItemText( 2, aStr );
     660             : 
     661           0 :     return 0L;
     662             : }
     663             : 
     664           0 : IMPL_LINK( SvxIMapDlg, GraphSizeHdl, IMapWindow*, pWnd )
     665             : {
     666           0 :     const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
     667           0 :     const Size& rSize = pWnd->GetGraphicSize();
     668           0 :     const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
     669           0 :     const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0];
     670             : 
     671           0 :     OUString aStr = GetUnitString( rSize.Width(), eFieldUnit, cSep ) +
     672           0 :                     " x " + GetUnitString( rSize.Height(), eFieldUnit, cSep );
     673             : 
     674           0 :     aStbStatus.SetItemText( 3, aStr );
     675             : 
     676           0 :     return 0L;
     677             : }
     678             : 
     679           0 : IMPL_LINK_NOARG(SvxIMapDlg, URLModifyHdl)
     680             : {
     681           0 :     NotifyInfo  aNewInfo;
     682             : 
     683           0 :     aNewInfo.aMarkURL = maURLBox.GetText();
     684           0 :     aNewInfo.aMarkAltText = aEdtText.GetText();
     685           0 :     aNewInfo.aMarkTarget = maCbbTarget.GetText();
     686             : 
     687           0 :     pIMapWnd->ReplaceActualIMapInfo( aNewInfo );
     688             : 
     689           0 :     return 0;
     690             : }
     691             : 
     692           0 : IMPL_LINK_NOARG(SvxIMapDlg, URLLoseFocusHdl)
     693             : {
     694           0 :     NotifyInfo        aNewInfo;
     695           0 :     const OUString    aURLText( maURLBox.GetText() );
     696           0 :     const OUString    aTargetText( maCbbTarget.GetText() );
     697             : 
     698           0 :     if ( !aURLText.isEmpty() )
     699             :     {
     700           0 :         OUString aBase = GetBindings().GetDispatcher()->GetFrame()->GetObjectShell()->GetMedium()->GetBaseURL();
     701           0 :         aNewInfo.aMarkURL = ::URIHelper::SmartRel2Abs( INetURLObject(aBase), aURLText, URIHelper::GetMaybeFileHdl(), true, false,
     702             :                                                         INetURLObject::WAS_ENCODED,
     703           0 :                                                         INetURLObject::DECODE_UNAMBIGUOUS );
     704             :     }
     705             :     else
     706           0 :         aNewInfo.aMarkURL = aURLText;
     707             : 
     708           0 :     aNewInfo.aMarkAltText = aEdtText.GetText();
     709             : 
     710           0 :     if ( aTargetText.isEmpty() )
     711           0 :         aNewInfo.aMarkTarget = SELF_TARGET;
     712             :     else
     713           0 :         aNewInfo.aMarkTarget = aTargetText;
     714             : 
     715           0 :     pIMapWnd->ReplaceActualIMapInfo( aNewInfo );
     716             : 
     717           0 :     return 0;
     718             : }
     719             : 
     720           0 : IMPL_LINK_NOARG(SvxIMapDlg, UpdateHdl)
     721             : {
     722           0 :     pOwnData->aTimer.Stop();
     723             : 
     724           0 :     if ( pOwnData->pUpdateEditingObject != pCheckObj )
     725             :     {
     726           0 :         if ( pIMapWnd->IsChanged() &&
     727             :              ( MessageDialog( this,"QuerySaveImageMapChangesDialog",
     728           0 :              "svx/ui/querysaveimagemapchangesdialog.ui" ).Execute() == RET_YES ) )
     729             :         {
     730           0 :             DoSave();
     731             :         }
     732             : 
     733           0 :         SetGraphic( pOwnData->aUpdateGraphic );
     734           0 :         SetImageMap( pOwnData->aUpdateImageMap );
     735           0 :         SetTargetList( pOwnData->aUpdateTargetList );
     736           0 :         SetEditingObject( pOwnData->pUpdateEditingObject );
     737             : 
     738             :         // After changes => default selection
     739           0 :         aTbxIMapDlg1.CheckItem( TBI_SELECT, true );
     740           0 :         pIMapWnd->SetEditMode( true );
     741             :     }
     742             : 
     743             :     // Delete the copied list again in the Update method
     744           0 :     pOwnData->aUpdateTargetList.clear();
     745             : 
     746           0 :     GetBindings().Invalidate( SID_IMAP_EXEC );
     747             : 
     748           0 :     return 0L;
     749             : }
     750             : 
     751           0 : IMPL_LINK( SvxIMapDlg, StateHdl, IMapWindow*, pWnd )
     752             : {
     753           0 :     const SdrObject*    pObj = pWnd->GetSelectedSdrObject();
     754           0 :     const SdrModel*     pModel = pWnd->GetSdrModel();
     755           0 :     const SdrView*      pView = pWnd->GetSdrView();
     756           0 :     const sal_Bool          bPolyEdit = ( pObj != NULL ) && pObj->ISA( SdrPathObj );
     757           0 :     const sal_Bool          bDrawEnabled = !( bPolyEdit && aTbxIMapDlg1.IsItemChecked( TBI_POLYEDIT ) );
     758             : 
     759           0 :     aTbxIMapDlg1.EnableItem( TBI_APPLY, pOwnData->bExecState && pWnd->IsChanged() );
     760             : 
     761           0 :     aTbxIMapDlg1.EnableItem( TBI_SELECT, bDrawEnabled );
     762           0 :     aTbxIMapDlg1.EnableItem( TBI_RECT, bDrawEnabled );
     763           0 :     aTbxIMapDlg1.EnableItem( TBI_CIRCLE, bDrawEnabled );
     764           0 :     aTbxIMapDlg1.EnableItem( TBI_POLY, bDrawEnabled );
     765           0 :     aTbxIMapDlg1.EnableItem( TBI_FREEPOLY, bDrawEnabled );
     766             : 
     767             :     // BezierEditor State
     768           0 :     aTbxIMapDlg1.EnableItem( TBI_POLYEDIT, bPolyEdit );
     769           0 :     aTbxIMapDlg1.EnableItem( TBI_POLYMOVE, !bDrawEnabled );
     770           0 :     aTbxIMapDlg1.EnableItem( TBI_POLYINSERT, !bDrawEnabled );
     771           0 :     aTbxIMapDlg1.EnableItem( TBI_POLYDELETE, !bDrawEnabled && pView->IsDeleteMarkedPointsPossible() );
     772             : 
     773             :     // Undo/Redo
     774           0 :     aTbxIMapDlg1.EnableItem( TBI_UNDO, pModel->HasUndoActions() );
     775           0 :     aTbxIMapDlg1.EnableItem( TBI_REDO, pModel->HasRedoActions() );
     776             : 
     777           0 :     if ( bPolyEdit )
     778             :     {
     779           0 :         sal_uInt16 nId = 0;
     780             : 
     781           0 :         switch( pWnd->GetPolyEditMode() )
     782             :         {
     783           0 :             case( SID_BEZIER_MOVE ): nId = TBI_POLYMOVE; break;
     784           0 :             case( SID_BEZIER_INSERT ): nId = TBI_POLYINSERT; break;
     785             : 
     786             :             default:
     787           0 :             break;
     788             :         }
     789             : 
     790           0 :         aTbxIMapDlg1.CheckItem( nId, true );
     791             :     }
     792             :     else
     793             :     {
     794           0 :         aTbxIMapDlg1.CheckItem( TBI_POLYEDIT, false );
     795           0 :         aTbxIMapDlg1.CheckItem( TBI_POLYMOVE, true );
     796           0 :         aTbxIMapDlg1.CheckItem( TBI_POLYINSERT, false );
     797           0 :         pWnd->SetPolyEditMode( 0 );
     798             :     }
     799             : 
     800           0 :     return 0L;
     801             : }
     802             : 
     803           0 : IMPL_LINK_NOARG(SvxIMapDlg, MiscHdl)
     804             : {
     805           0 :        SvtMiscOptions aMiscOptions;
     806           0 :     aTbxIMapDlg1.SetOutStyle( aMiscOptions.GetToolboxStyle() );
     807             : 
     808           0 :     return 0L;
     809             : }
     810             : 
     811           0 : void SvxIMapDlg::ApplyImageList()
     812             : {
     813           0 :     ImageList& rImgLst = maImageList;
     814             : 
     815           0 :     aTbxIMapDlg1.SetImageList( rImgLst );
     816           0 : }
     817             : 
     818           0 : void SvxIMapDlg::DataChanged( const DataChangedEvent& rDCEvt )
     819             : {
     820           0 :     SfxModelessDialog::DataChanged( rDCEvt );
     821             : 
     822           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     823           0 :             ApplyImageList();
     824         255 : }
     825             : 
     826             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10