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

Generated by: LCOV version 1.10