LCOV - code coverage report
Current view: top level - cui/source/dialogs - linkdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 389 0.0 %
Date: 2012-08-25 Functions: 0 30 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 828 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <linkdlg.hxx>
      30                 :            : #include <vcl/svapp.hxx>
      31                 :            : #include "helpid.hrc"
      32                 :            : 
      33                 :            : #include <tools/urlobj.hxx>
      34                 :            : #include <svtools/svmedit.hxx>
      35                 :            : #include <svtools/filedlg.hxx>
      36                 :            : #include <vcl/dialog.hxx>
      37                 :            : #include <vcl/button.hxx>
      38                 :            : #include <vcl/fixed.hxx>
      39                 :            : #include <vcl/group.hxx>
      40                 :            : #include <vcl/lstbox.hxx>
      41                 :            : #include <vcl/msgbox.hxx>
      42                 :            : #include <vcl/timer.hxx>
      43                 :            : #include <svtools/svtabbx.hxx>
      44                 :            : 
      45                 :            : #include <svuidlg.hrc>
      46                 :            : #include <sfx2/linkmgr.hxx>
      47                 :            : #include <sfx2/linksrc.hxx>
      48                 :            : #include <svtools/soerr.hxx>
      49                 :            : #include <sfx2/lnkbase.hxx>
      50                 :            : #include <sfx2/objsh.hxx>
      51                 :            : 
      52                 :            : #include <dialmgr.hxx>
      53                 :            : 
      54                 :            : 
      55                 :            : #define FILEOBJECT ( OBJECT_CLIENT_FILE & ~OBJECT_CLIENT_SO )
      56                 :            : 
      57                 :            : using namespace sfx2;
      58                 :            : 
      59                 :          0 : class SvBaseLinkMemberList : private std::vector<SvBaseLink*> {
      60                 :            : public:
      61                 :          0 :     ~SvBaseLinkMemberList()
      62                 :          0 :     {
      63 [ #  # ][ #  # ]:          0 :         for( const_iterator it = begin(); it != end(); ++it )
         [ #  # ][ #  # ]
      64                 :            :         {
      65         [ #  # ]:          0 :             SvBaseLink* p = *it;
      66         [ #  # ]:          0 :             if( p )
      67         [ #  # ]:          0 :                 p->ReleaseReference();
      68                 :            :         }
      69                 :          0 :     }
      70                 :            : 
      71                 :            :     using std::vector<SvBaseLink*>::size;
      72                 :            :     using std::vector<SvBaseLink*>::operator[];
      73                 :            : 
      74                 :          0 :     void push_back(SvBaseLink* p) { std::vector<SvBaseLink*>::push_back(p); p->AddRef(); }
      75                 :            : };
      76                 :            : 
      77                 :            : // attention, this array is indexed directly (0, 1, ...) in the code
      78                 :            : static long nTabs[] =
      79                 :            :     {   4, // Number of Tabs
      80                 :            :         0, 77, 144, 209
      81                 :            :     };
      82                 :            : 
      83                 :            : 
      84                 :          0 : SvBaseLinksDlg::SvBaseLinksDlg( Window * pParent, LinkManager* pMgr, sal_Bool bHtml )
      85                 :          0 :     : ModalDialog( pParent, CUI_RES( MD_UPDATE_BASELINKS ) ),
      86         [ #  # ]:          0 :     aFtFiles( this, CUI_RES( FT_FILES ) ),
      87         [ #  # ]:          0 :     aFtLinks( this, CUI_RES( FT_LINKS ) ),
      88         [ #  # ]:          0 :     aFtType( this, CUI_RES( FT_TYPE ) ),
      89         [ #  # ]:          0 :     aFtStatus( this, CUI_RES( FT_STATUS ) ),
      90         [ #  # ]:          0 :     aTbLinks( this, CUI_RES(TB_LINKS ) ),
      91         [ #  # ]:          0 :     aFtFiles2( this, CUI_RES( FT_FILES2 ) ),
      92         [ #  # ]:          0 :     aFtFullFileName( this, CUI_RES( FT_FULL_FILE_NAME ) ),
      93         [ #  # ]:          0 :     aFtSource2( this, CUI_RES( FT_SOURCE2 ) ),
      94         [ #  # ]:          0 :     aFtFullSourceName( this, CUI_RES( FT_FULL_SOURCE_NAME ) ),
      95         [ #  # ]:          0 :     aFtType2( this, CUI_RES( FT_TYPE2 ) ),
      96         [ #  # ]:          0 :     aFtFullTypeName( this, CUI_RES( FT_FULL_TYPE_NAME ) ),
      97         [ #  # ]:          0 :     aFtUpdate( this, CUI_RES( FT_UPDATE ) ),
      98         [ #  # ]:          0 :     aRbAutomatic( this, CUI_RES( RB_AUTOMATIC ) ),
      99         [ #  # ]:          0 :     aRbManual( this, CUI_RES( RB_MANUAL ) ),
     100         [ #  # ]:          0 :     aCancelButton1( this, CUI_RES( 1 ) ),
     101         [ #  # ]:          0 :     aHelpButton1( this, CUI_RES( 1 ) ),
     102         [ #  # ]:          0 :     aPbUpdateNow( this, CUI_RES( PB_UPDATE_NOW ) ),
     103         [ #  # ]:          0 :     aPbOpenSource( this, CUI_RES( PB_OPEN_SOURCE ) ),
     104         [ #  # ]:          0 :     aPbChangeSource( this, CUI_RES( PB_CHANGE_SOURCE ) ),
     105         [ #  # ]:          0 :     aPbBreakLink( this, CUI_RES( PB_BREAK_LINK ) ),
     106         [ #  # ]:          0 :     aStrAutolink( CUI_RES( STR_AUTOLINK ) ),
     107         [ #  # ]:          0 :     aStrManuallink( CUI_RES( STR_MANUALLINK ) ),
     108         [ #  # ]:          0 :     aStrBrokenlink( CUI_RES( STR_BROKENLINK ) ),
     109         [ #  # ]:          0 :     aStrGraphiclink( CUI_RES( STR_GRAPHICLINK ) ),
     110         [ #  # ]:          0 :     aStrButtonclose( CUI_RES( STR_BUTTONCLOSE ) ),
     111         [ #  # ]:          0 :     aStrCloselinkmsg( CUI_RES( STR_CLOSELINKMSG ) ),
     112         [ #  # ]:          0 :     aStrCloselinkmsgMulti( CUI_RES( STR_CLOSELINKMSG_MULTI ) ),
     113         [ #  # ]:          0 :     aStrWaitinglink( CUI_RES( STR_WAITINGLINK ) ),
     114                 :            :     pLinkMgr( NULL ),
     115 [ #  # ][ #  # ]:          0 :     bHtmlMode(bHtml)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     116                 :            : {
     117         [ #  # ]:          0 :     FreeResource();
     118                 :            : 
     119         [ #  # ]:          0 :     aTbLinks.SetHelpId(HID_LINKDLG_TABLB);
     120         [ #  # ]:          0 :     aTbLinks.SetSelectionMode( MULTIPLE_SELECTION );
     121         [ #  # ]:          0 :     aTbLinks.SetTabs( &nTabs[0], MAP_APPFONT );
     122         [ #  # ]:          0 :     aTbLinks.Resize();  // OS: hack for correct selection
     123                 :            : 
     124                 :            :     // UpdateTimer for DDE-/Grf-links, which are waited for
     125         [ #  # ]:          0 :     aUpdateTimer.SetTimeoutHdl( LINK( this, SvBaseLinksDlg, UpdateWaitingHdl ) );
     126         [ #  # ]:          0 :     aUpdateTimer.SetTimeout( 1000 );
     127                 :            : 
     128                 :            :     // Set the ZOrder, and accessible name to the dialog's title
     129         [ #  # ]:          0 :     aTbLinks.SetZOrder(0, WINDOW_ZORDER_FIRST);
     130 [ #  # ][ #  # ]:          0 :     aTbLinks.SetAccessibleName(this->GetText());
                 [ #  # ]
     131         [ #  # ]:          0 :     aTbLinks.SetAccessibleRelationLabeledBy(&aFtFiles);
     132                 :            : 
     133         [ #  # ]:          0 :     OpenSource().Hide();
     134                 :            : 
     135         [ #  # ]:          0 :     Links().SetSelectHdl( LINK( this, SvBaseLinksDlg, LinksSelectHdl ) );
     136         [ #  # ]:          0 :     Links().SetDoubleClickHdl( LINK( this, SvBaseLinksDlg, LinksDoubleClickHdl ) );
     137         [ #  # ]:          0 :     Automatic().SetClickHdl( LINK( this, SvBaseLinksDlg, AutomaticClickHdl ) );
     138         [ #  # ]:          0 :     Manual().SetClickHdl( LINK( this, SvBaseLinksDlg, ManualClickHdl ) );
     139         [ #  # ]:          0 :     UpdateNow().SetClickHdl( LINK( this, SvBaseLinksDlg, UpdateNowClickHdl ) );
     140         [ #  # ]:          0 :     ChangeSource().SetClickHdl( LINK( this, SvBaseLinksDlg, ChangeSourceClickHdl ) );
     141         [ #  # ]:          0 :     if(!bHtmlMode)
     142         [ #  # ]:          0 :         BreakLink().SetClickHdl( LINK( this, SvBaseLinksDlg, BreakLinkClickHdl ) );
     143                 :            :     else
     144         [ #  # ]:          0 :         BreakLink().Hide();
     145                 :            : 
     146         [ #  # ]:          0 :     SetManager( pMgr );
     147                 :          0 : }
     148                 :            : 
     149 [ #  # ][ #  # ]:          0 : SvBaseLinksDlg::~SvBaseLinksDlg()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     150                 :            : {
     151         [ #  # ]:          0 : }
     152                 :            : 
     153                 :            : /*************************************************************************
     154                 :            : |*    SvBaseLinksDlg::Handler()
     155                 :            : *************************************************************************/
     156                 :          0 : IMPL_LINK( SvBaseLinksDlg, LinksSelectHdl, SvTabListBox *, pSvTabListBox )
     157                 :            : {
     158                 :            :     sal_uInt16 nSelectionCount = pSvTabListBox ?
     159         [ #  # ]:          0 :         (sal_uInt16)pSvTabListBox->GetSelectionCount() : 0;
     160         [ #  # ]:          0 :     if(nSelectionCount > 1)
     161                 :            :     {
     162                 :            :         // possibly deselect old entries in case of multi-selection
     163                 :          0 :         SvLBoxEntry* pEntry = 0;
     164                 :          0 :         SvBaseLink* pLink = 0;
     165                 :          0 :         pEntry = pSvTabListBox->GetHdlEntry();
     166                 :          0 :         pLink = (SvBaseLink*)pEntry->GetUserData();
     167                 :          0 :         sal_uInt16 nObjectType = pLink->GetObjType();
     168         [ #  # ]:          0 :         if((OBJECT_CLIENT_FILE & nObjectType) != OBJECT_CLIENT_FILE)
     169                 :            :         {
     170                 :          0 :             pSvTabListBox->SelectAll(sal_False);
     171                 :          0 :             pSvTabListBox->Select(pEntry);
     172                 :          0 :             nSelectionCount = 1;
     173                 :            :         }
     174                 :            :         else
     175                 :            :         {
     176         [ #  # ]:          0 :             for( sal_uInt16 i = 0; i < nSelectionCount; i++)
     177                 :            :             {
     178                 :          0 :                 pEntry = i == 0 ? pSvTabListBox->FirstSelected() :
     179         [ #  # ]:          0 :                                     pSvTabListBox->NextSelected(pEntry);
     180                 :            :                 DBG_ASSERT(pEntry, "Wo ist der Entry?");
     181                 :          0 :                 pLink = (SvBaseLink*)pEntry->GetUserData();
     182                 :            :                 DBG_ASSERT(pLink, "Wo ist der Link?");
     183         [ #  # ]:          0 :                 if( (OBJECT_CLIENT_FILE & pLink->GetObjType()) != OBJECT_CLIENT_FILE )
     184                 :          0 :                     pSvTabListBox->Select( pEntry, sal_False );
     185                 :            : 
     186                 :            :             }
     187                 :            :         }
     188                 :            : 
     189                 :          0 :         UpdateNow().Enable();
     190                 :            : 
     191                 :          0 :         Automatic().Disable();
     192                 :          0 :         Manual().Check();
     193                 :          0 :         Manual().Disable();
     194                 :            :     }
     195                 :            :     else
     196                 :            :     {
     197                 :            :         sal_uInt16 nPos;
     198         [ #  # ]:          0 :         SvBaseLink* pLink = GetSelEntry( &nPos );
     199         [ #  # ]:          0 :         if( !pLink )
     200                 :          0 :             return 0;
     201                 :            : 
     202         [ #  # ]:          0 :         UpdateNow().Enable();
     203                 :            : 
     204 [ #  # ][ #  # ]:          0 :         String sType, sLink;
     205                 :          0 :         String *pLinkNm = &sLink, *pFilter = 0;
     206                 :            : 
     207         [ #  # ]:          0 :         if( FILEOBJECT & pLink->GetObjType() )
     208                 :            :         {
     209         [ #  # ]:          0 :             Automatic().Disable();
     210         [ #  # ]:          0 :             Manual().Check();
     211         [ #  # ]:          0 :             Manual().Disable();
     212         [ #  # ]:          0 :             if( OBJECT_CLIENT_GRF == pLink->GetObjType() )
     213                 :          0 :                 pLinkNm = 0, pFilter = &sLink;
     214                 :            :         }
     215                 :            :         else
     216                 :            :         {
     217         [ #  # ]:          0 :             Automatic().Enable();
     218         [ #  # ]:          0 :             Manual().Enable();
     219                 :            : 
     220 [ #  # ][ #  # ]:          0 :             if( LINKUPDATE_ALWAYS == pLink->GetUpdateMode() )
     221         [ #  # ]:          0 :                 Automatic().Check();
     222                 :            :             else
     223         [ #  # ]:          0 :                 Manual().Check();
     224                 :            :         }
     225                 :            : 
     226         [ #  # ]:          0 :         String aFileName;
     227         [ #  # ]:          0 :         pLinkMgr->GetDisplayNames( pLink, &sType, &aFileName, pLinkNm, pFilter );
     228 [ #  # ][ #  # ]:          0 :         aFileName = INetURLObject::decode(aFileName, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS);
                 [ #  # ]
     229         [ #  # ]:          0 :         FileName().SetText( aFileName );
     230         [ #  # ]:          0 :         SourceName().SetText( sLink );
     231 [ #  # ][ #  # ]:          0 :         TypeName().SetText( sType );
         [ #  # ][ #  # ]
     232                 :            :     }
     233                 :          0 :     return 0;
     234                 :            : }
     235                 :            : 
     236                 :          0 : IMPL_LINK_INLINE_START( SvBaseLinksDlg, LinksDoubleClickHdl, SvTabListBox *, pSvTabListBox )
     237                 :            : {
     238                 :            :     (void)pSvTabListBox;
     239                 :            : 
     240                 :          0 :     ChangeSourceClickHdl( 0 );
     241                 :          0 :     return 0;
     242                 :            : }
     243                 :          0 : IMPL_LINK_INLINE_END( SvBaseLinksDlg, LinksDoubleClickHdl, SvTabListBox *, pSvTabListBox )
     244                 :            : 
     245                 :          0 : IMPL_LINK_INLINE_START( SvBaseLinksDlg, AutomaticClickHdl, RadioButton *, pRadioButton )
     246                 :            : {
     247                 :            :     (void)pRadioButton;
     248                 :            : 
     249                 :            :     sal_uInt16 nPos;
     250         [ #  # ]:          0 :     SvBaseLink* pLink = GetSelEntry( &nPos );
     251 [ #  # ][ #  # ]:          0 :     if( pLink && !( FILEOBJECT & pLink->GetObjType() ) &&
         [ #  # ][ #  # ]
     252         [ #  # ]:          0 :         LINKUPDATE_ALWAYS != pLink->GetUpdateMode() )
     253         [ #  # ]:          0 :         SetType( *pLink, nPos, LINKUPDATE_ALWAYS );
     254                 :          0 :     return 0;
     255                 :            : }
     256                 :          0 : IMPL_LINK_INLINE_END( SvBaseLinksDlg, AutomaticClickHdl, RadioButton *, pRadioButton )
     257                 :            : 
     258                 :          0 : IMPL_LINK_INLINE_START( SvBaseLinksDlg, ManualClickHdl, RadioButton *, pRadioButton )
     259                 :            : {
     260                 :            :     (void)pRadioButton;
     261                 :            : 
     262                 :            :     sal_uInt16 nPos;
     263         [ #  # ]:          0 :     SvBaseLink* pLink = GetSelEntry( &nPos );
     264 [ #  # ][ #  # ]:          0 :     if( pLink && !( FILEOBJECT & pLink->GetObjType() ) &&
         [ #  # ][ #  # ]
     265         [ #  # ]:          0 :         LINKUPDATE_ONCALL != pLink->GetUpdateMode())
     266         [ #  # ]:          0 :         SetType( *pLink, nPos, LINKUPDATE_ONCALL );
     267                 :          0 :     return 0;
     268                 :            : }
     269                 :          0 : IMPL_LINK_INLINE_END( SvBaseLinksDlg, ManualClickHdl, RadioButton *, pRadioButton )
     270                 :            : 
     271                 :          0 : IMPL_LINK_NOARG(SvBaseLinksDlg, UpdateNowClickHdl)
     272                 :            : {
     273                 :          0 :     SvTabListBox& rListBox = Links();
     274                 :          0 :     sal_uInt16 nSelCnt = (sal_uInt16)rListBox.GetSelectionCount();
     275         [ #  # ]:          0 :     if( 255 < nSelCnt )
     276                 :          0 :         nSelCnt = 255;
     277                 :            : 
     278         [ #  # ]:          0 :     std::vector< SvBaseLink* > aLnkArr;
     279         [ #  # ]:          0 :     std::vector< sal_uInt16 > aPosArr;
     280                 :            : 
     281         [ #  # ]:          0 :     SvLBoxEntry* pE = rListBox.FirstSelected();
     282         [ #  # ]:          0 :     while( pE )
     283                 :            :     {
     284         [ #  # ]:          0 :         sal_uInt16 nFndPos = (sal_uInt16)rListBox.GetModel()->GetAbsPos( pE );
     285         [ #  # ]:          0 :         if( LISTBOX_ENTRY_NOTFOUND != nFndPos )
     286                 :            :         {
     287         [ #  # ]:          0 :             aLnkArr.push_back( static_cast< SvBaseLink* >( pE->GetUserData() ) );
     288         [ #  # ]:          0 :             aPosArr.push_back( nFndPos );
     289                 :            :         }
     290         [ #  # ]:          0 :         pE = rListBox.NextSelected( pE );
     291                 :            :     }
     292                 :            : 
     293         [ #  # ]:          0 :     if( !aLnkArr.empty() )
     294                 :            :     {
     295         [ #  # ]:          0 :         for( sal_uInt16 n = 0; n < aLnkArr.size(); ++n )
     296                 :            :         {
     297         [ #  # ]:          0 :             SvBaseLinkRef xLink = aLnkArr[ n ];
     298                 :            : 
     299                 :            :             // first look for the entry in the array
     300         [ #  # ]:          0 :             for( sal_uInt16 i = 0; i < pLinkMgr->GetLinks().size(); ++i )
     301         [ #  # ]:          0 :                 if( &xLink == *pLinkMgr->GetLinks()[ i ] )
     302                 :            :                 {
     303                 :          0 :                     xLink->SetUseCache( sal_False );
     304 [ #  # ][ #  # ]:          0 :                     SetType( *xLink, aPosArr[ n ], xLink->GetUpdateMode() );
                 [ #  # ]
     305                 :          0 :                     xLink->SetUseCache( sal_True );
     306                 :          0 :                     break;
     307                 :            :                 }
     308         [ #  # ]:          0 :         }
     309                 :            : 
     310                 :            :         // if somebody is of the opinion to swap his links (SD)
     311                 :          0 :         LinkManager* pNewMgr = pLinkMgr;
     312                 :          0 :         pLinkMgr = 0;
     313         [ #  # ]:          0 :         SetManager( pNewMgr );
     314                 :            : 
     315                 :            : 
     316 [ #  # ][ #  # ]:          0 :         if( 0 == (pE = rListBox.GetEntry( aPosArr[ 0 ] )) ||
         [ #  # ][ #  # ]
                 [ #  # ]
     317         [ #  # ]:          0 :             pE->GetUserData() != aLnkArr[ 0 ] )
     318                 :            :         {
     319                 :            :             // search the link
     320         [ #  # ]:          0 :             pE = rListBox.First();
     321         [ #  # ]:          0 :             while( pE )
     322                 :            :             {
     323 [ #  # ][ #  # ]:          0 :                 if( pE->GetUserData() == aLnkArr[ 0 ] )
     324                 :          0 :                     break;
     325         [ #  # ]:          0 :                 pE = rListBox.Next( pE );
     326                 :            :             }
     327                 :            : 
     328         [ #  # ]:          0 :             if( !pE )
     329         [ #  # ]:          0 :                 pE = rListBox.FirstSelected();
     330                 :            :         }
     331                 :            : 
     332         [ #  # ]:          0 :         if( pE )
     333                 :            :         {
     334         [ #  # ]:          0 :             SvLBoxEntry* pSelEntry = rListBox.FirstSelected();
     335         [ #  # ]:          0 :             if( pE != pSelEntry )
     336         [ #  # ]:          0 :                 rListBox.Select( pSelEntry, sal_False );
     337         [ #  # ]:          0 :             rListBox.Select( pE );
     338         [ #  # ]:          0 :             rListBox.MakeVisible( pE );
     339                 :            :         }
     340                 :            : 
     341         [ #  # ]:          0 :         pNewMgr->CloseCachedComps();
     342                 :            :     }
     343                 :          0 :     return 0;
     344                 :            : }
     345                 :            : 
     346                 :          0 : IMPL_LINK( SvBaseLinksDlg, ChangeSourceClickHdl, PushButton *, pPushButton )
     347                 :            : {
     348                 :            :     (void)pPushButton;
     349                 :            : 
     350                 :          0 :     sal_uInt16 nSelectionCount = (sal_uInt16)Links().GetSelectionCount();
     351         [ #  # ]:          0 :     if(nSelectionCount > 1)
     352                 :            :     {
     353         [ #  # ]:          0 :         PathDialog aPathDlg( this );
     354 [ #  # ][ #  # ]:          0 :         String sType, sFile, sLinkName;
                 [ #  # ]
     355         [ #  # ]:          0 :         String  sFilter;
     356         [ #  # ]:          0 :         SvLBoxEntry* pEntry = Links().FirstSelected();
     357                 :          0 :         SvBaseLink* pLink = (SvBaseLink*)pEntry->GetUserData();
     358         [ #  # ]:          0 :         pLinkMgr->GetDisplayNames( pLink, &sType, &sFile, 0, 0 );
     359 [ #  # ][ #  # ]:          0 :         INetURLObject aUrl(sFile);
     360         [ #  # ]:          0 :         if(aUrl.GetProtocol() == INET_PROT_FILE)
     361                 :            :         {
     362         [ #  # ]:          0 :             rtl::OUString sOldPath(aUrl.PathToFileName());
     363         [ #  # ]:          0 :             sal_Int32 nLen = aUrl.GetName().getLength();
     364                 :          0 :             sOldPath = sOldPath.copy(0, sOldPath.getLength() - nLen);
     365         [ #  # ]:          0 :             aPathDlg.SetPath(sOldPath);
     366                 :            :         }
     367 [ #  # ][ #  # ]:          0 :         if(aPathDlg.Execute() == RET_OK)
     368                 :            :         {
     369 [ #  # ][ #  # ]:          0 :             String aPath = aPathDlg.GetPath();
     370                 :            : 
     371         [ #  # ]:          0 :             for( sal_uInt16 i = 0; i < nSelectionCount; i++)
     372                 :            :             {
     373                 :            :                 pEntry = i==0 ?
     374                 :          0 :                         Links().FirstSelected() :
     375   [ #  #  #  # ]:          0 :                             Links().NextSelected( pEntry );
                 [ #  # ]
     376                 :            :                 DBG_ASSERT(pEntry,"Wo ist der Entry");
     377                 :          0 :                 pLink = (SvBaseLink*)pEntry->GetUserData();
     378                 :            :                 DBG_ASSERT(pLink,"Wo ist der Link");
     379         [ #  # ]:          0 :                 pLinkMgr->GetDisplayNames( pLink, &sType, &sFile, &sLinkName, &sFilter );
     380 [ #  # ][ #  # ]:          0 :                 INetURLObject aUrl_(sFile);
     381 [ #  # ][ #  # ]:          0 :                 INetURLObject aUrl2(aPath, INET_PROT_FILE);
     382 [ #  # ][ #  # ]:          0 :                 aUrl2.insertName( aUrl_.getName() );
     383         [ #  # ]:          0 :                 String sNewLinkName;
     384                 :            :                 MakeLnkName( sNewLinkName, 0 ,
     385 [ #  # ][ #  # ]:          0 :                         aUrl2.GetMainURL(INetURLObject::DECODE_TO_IURI), sLinkName, &sFilter);
         [ #  # ][ #  # ]
     386         [ #  # ]:          0 :                 pLink->SetLinkSourceName( sNewLinkName );
     387         [ #  # ]:          0 :                 pLink->Update();
     388 [ #  # ][ #  # ]:          0 :             }
                 [ #  # ]
     389         [ #  # ]:          0 :             if( pLinkMgr->GetPersist() )
     390         [ #  # ]:          0 :                 pLinkMgr->GetPersist()->SetModified();
     391                 :          0 :             LinkManager* pNewMgr = pLinkMgr;
     392                 :          0 :             pLinkMgr = 0;
     393 [ #  # ][ #  # ]:          0 :             SetManager( pNewMgr );
     394 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     395                 :            :     }
     396                 :            :     else
     397                 :            :     {
     398                 :            :         sal_uInt16 nPos;
     399         [ #  # ]:          0 :         SvBaseLink* pLink = GetSelEntry( &nPos );
     400 [ #  # ][ #  # ]:          0 :         if ( pLink && (pLink->GetLinkSourceName().Len() != 0) )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     401 [ #  # ][ #  # ]:          0 :             pLink->Edit( this, LINK( this, SvBaseLinksDlg, EndEditHdl ) );
     402                 :            :     }
     403                 :          0 :     return 0;
     404                 :            : }
     405                 :            : 
     406                 :          0 : IMPL_LINK( SvBaseLinksDlg, BreakLinkClickHdl, PushButton *, pPushButton )
     407                 :            : {
     408                 :            :     (void)pPushButton;
     409                 :            : 
     410                 :          0 :     sal_Bool bModified = sal_False;
     411         [ #  # ]:          0 :     if(Links().GetSelectionCount() <= 1)
     412                 :            :     {
     413                 :            :         sal_uInt16 nPos;
     414         [ #  # ]:          0 :         SvBaseLinkRef xLink = GetSelEntry( &nPos );
     415         [ #  # ]:          0 :         if( !xLink.Is() )
     416                 :          0 :             return 0;
     417                 :            : 
     418         [ #  # ]:          0 :         QueryBox aBox( this, WB_YES_NO | WB_DEF_YES, Closelinkmsg() );
     419                 :            : 
     420 [ #  # ][ #  # ]:          0 :         if( RET_YES == aBox.Execute() )
     421                 :            :         {
     422 [ #  # ][ #  # ]:          0 :             Links().GetModel()->Remove( Links().GetEntry( nPos ) );
     423                 :            : 
     424                 :            :             // close object, if it's still existing
     425                 :          0 :             sal_Bool bNewLnkMgr = OBJECT_CLIENT_FILE == xLink->GetObjType();
     426                 :            : 
     427                 :            :             // tell the link that it will be resolved!
     428         [ #  # ]:          0 :             xLink->Closed();
     429                 :            : 
     430                 :            :             // if somebody has forgotten to deregister himself
     431         [ #  # ]:          0 :             if( xLink.Is() )
     432         [ #  # ]:          0 :                 pLinkMgr->Remove( &xLink );
     433                 :            : 
     434         [ #  # ]:          0 :             if( bNewLnkMgr )
     435                 :            :             {
     436                 :          0 :                 LinkManager* pNewMgr = pLinkMgr;
     437                 :          0 :                 pLinkMgr = 0;
     438         [ #  # ]:          0 :                 SetManager( pNewMgr );
     439                 :            : 
     440 [ #  # ][ #  # ]:          0 :                 SvLBoxEntry* pEntry = Links().GetEntry( nPos ? --nPos : 0 );
     441         [ #  # ]:          0 :                 if( pEntry )
     442         [ #  # ]:          0 :                     Links().SetCurEntry( pEntry );
     443                 :            :             }
     444                 :          0 :             bModified = sal_True;
     445 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     446                 :            :     }
     447                 :            :     else
     448                 :            :     {
     449         [ #  # ]:          0 :         QueryBox aBox( this, WB_YES_NO | WB_DEF_YES, CloselinkmsgMulti() );
     450                 :            : 
     451 [ #  # ][ #  # ]:          0 :         if( RET_YES == aBox.Execute() )
     452                 :            :         {
     453                 :            : 
     454         [ #  # ]:          0 :             SvBaseLinkMemberList aLinkList;
     455         [ #  # ]:          0 :             SvLBoxEntry* pEntry = Links().FirstSelected();
     456         [ #  # ]:          0 :             while ( pEntry )
     457                 :            :             {
     458                 :          0 :                 void * pUD = pEntry->GetUserData();
     459         [ #  # ]:          0 :                 if( pUD )
     460         [ #  # ]:          0 :                     aLinkList.push_back( (SvBaseLink*)pUD );
     461         [ #  # ]:          0 :                 pEntry = Links().NextSelected(pEntry);
     462                 :            :             }
     463         [ #  # ]:          0 :             Links().RemoveSelection();
     464         [ #  # ]:          0 :             for( sal_uLong i = 0; i < aLinkList.size(); i++ )
     465                 :            :             {
     466         [ #  # ]:          0 :                 SvBaseLinkRef xLink = aLinkList[i];
     467                 :            :                 // tell the link that it will be resolved!
     468         [ #  # ]:          0 :                 xLink->Closed();
     469                 :            : 
     470                 :            :                 // if somebody has forgotten to deregister himself
     471         [ #  # ]:          0 :                 pLinkMgr->Remove( &xLink );
     472                 :          0 :                 bModified = sal_True;
     473 [ #  # ][ #  # ]:          0 :             }
     474                 :            :             // then remove all selected entries
     475         [ #  # ]:          0 :         }
     476                 :            :     }
     477         [ #  # ]:          0 :     if(bModified)
     478                 :            :     {
     479         [ #  # ]:          0 :         if( !Links().GetEntryCount() )
     480                 :            :         {
     481         [ #  # ]:          0 :             Automatic().Disable();
     482         [ #  # ]:          0 :             Manual().Disable();
     483         [ #  # ]:          0 :             UpdateNow().Disable();
     484         [ #  # ]:          0 :             ChangeSource().Disable();
     485         [ #  # ]:          0 :             BreakLink().Disable();
     486                 :            : 
     487         [ #  # ]:          0 :             String aEmpty;
     488         [ #  # ]:          0 :             SourceName().SetText( aEmpty );
     489 [ #  # ][ #  # ]:          0 :             TypeName().SetText( aEmpty );
     490                 :            :         }
     491         [ #  # ]:          0 :         if( pLinkMgr->GetPersist() )
     492                 :          0 :             pLinkMgr->GetPersist()->SetModified();
     493                 :            :     }
     494                 :          0 :     return 0;
     495                 :            : }
     496                 :            : 
     497                 :          0 : IMPL_LINK( SvBaseLinksDlg, UpdateWaitingHdl, Timer*, pTimer )
     498                 :            : {
     499                 :            :     (void)pTimer;
     500                 :            : 
     501                 :          0 :     Links().SetUpdateMode(sal_False);
     502         [ #  # ]:          0 :     for( sal_uLong nPos = Links().GetEntryCount(); nPos; )
     503                 :            :     {
     504         [ #  # ]:          0 :         SvLBoxEntry* pBox = Links().GetEntry( --nPos );
     505                 :          0 :         SvBaseLinkRef xLink( (SvBaseLink*)pBox->GetUserData() );
     506         [ #  # ]:          0 :         if( xLink.Is() )
     507                 :            :         {
     508         [ #  # ]:          0 :             String sCur( ImplGetStateStr( *xLink ) ),
     509         [ #  # ]:          0 :                     sOld( Links().GetEntryText( pBox, 3 ) );
     510 [ #  # ][ #  # ]:          0 :             if( sCur != sOld )
     511 [ #  # ][ #  # ]:          0 :                 Links().SetEntryText( sCur, pBox, 3 );
                 [ #  # ]
     512                 :            :         }
     513         [ #  # ]:          0 :     }
     514                 :          0 :     Links().SetUpdateMode(sal_True);
     515                 :          0 :     return 0;
     516                 :            : }
     517                 :            : 
     518                 :          0 : IMPL_LINK( SvBaseLinksDlg, EndEditHdl, sfx2::SvBaseLink*, _pLink )
     519                 :            : {
     520                 :            :     sal_uInt16 nPos;
     521         [ #  # ]:          0 :     GetSelEntry( &nPos );
     522                 :            : 
     523 [ #  # ][ #  # ]:          0 :     if( _pLink && _pLink->WasLastEditOK() )
                 [ #  # ]
     524                 :            :     {
     525                 :            :         // StarImpress/Draw swap the LinkObjects themselves!
     526                 :            :         // So search for the link in the manager; if it does not exist
     527                 :            :         // anymore, fill the list completely new. Otherwise only the
     528                 :            :         // edited link needs to be refreshed.
     529                 :          0 :         sal_Bool bLinkFnd = sal_False;
     530         [ #  # ]:          0 :         for( sal_uInt16 n = pLinkMgr->GetLinks().size(); n;  )
     531         [ #  # ]:          0 :             if( _pLink == &(*pLinkMgr->GetLinks()[ --n ]) )
     532                 :            :             {
     533                 :          0 :                 bLinkFnd = sal_True;
     534                 :          0 :                 break;
     535                 :            :             }
     536                 :            : 
     537         [ #  # ]:          0 :         if( bLinkFnd )
     538                 :            :         {
     539         [ #  # ]:          0 :             Links().SetUpdateMode(sal_False);
     540 [ #  # ][ #  # ]:          0 :             Links().GetModel()->Remove( Links().GetEntry( nPos ) );
     541         [ #  # ]:          0 :             SvLBoxEntry* pToUnselect = Links().FirstSelected();
     542         [ #  # ]:          0 :             InsertEntry( *_pLink, nPos, sal_True );
     543         [ #  # ]:          0 :             if(pToUnselect)
     544         [ #  # ]:          0 :                 Links().Select(pToUnselect, sal_False);
     545         [ #  # ]:          0 :             Links().SetUpdateMode(sal_True);
     546                 :            :         }
     547                 :            :         else
     548                 :            :         {
     549                 :          0 :             LinkManager* pNewMgr = pLinkMgr;
     550                 :          0 :             pLinkMgr = 0;
     551         [ #  # ]:          0 :             SetManager( pNewMgr );
     552                 :            :         }
     553         [ #  # ]:          0 :         if( pLinkMgr->GetPersist() )
     554         [ #  # ]:          0 :             pLinkMgr->GetPersist()->SetModified();
     555                 :            :     }
     556                 :          0 :     return 0;
     557                 :            : }
     558                 :            : 
     559                 :          0 : String SvBaseLinksDlg::ImplGetStateStr( const SvBaseLink& rLnk )
     560                 :            : {
     561                 :          0 :     String sRet;
     562         [ #  # ]:          0 :     if( !rLnk.GetObj() )
     563         [ #  # ]:          0 :         sRet = Brokenlink();
     564 [ #  # ][ #  # ]:          0 :     else if( rLnk.GetObj()->IsPending() )
     565                 :            :     {
     566         [ #  # ]:          0 :         sRet = Waitinglink();
     567         [ #  # ]:          0 :         StartUpdateTimer();
     568                 :            :     }
     569 [ #  # ][ #  # ]:          0 :     else if( LINKUPDATE_ALWAYS == rLnk.GetUpdateMode() )
     570         [ #  # ]:          0 :         sRet = Autolink();
     571                 :            :     else
     572         [ #  # ]:          0 :         sRet = Manuallink();
     573                 :            : 
     574                 :          0 :     return sRet;
     575                 :            : }
     576                 :            : 
     577                 :          0 : void SvBaseLinksDlg::SetManager( LinkManager* pNewMgr )
     578                 :            : {
     579         [ #  # ]:          0 :     if( pLinkMgr == pNewMgr )
     580                 :          0 :         return;
     581                 :            : 
     582         [ #  # ]:          0 :     if( pNewMgr )
     583                 :            :         // update has to be stopped before clear
     584                 :          0 :         Links().SetUpdateMode( sal_False );
     585                 :            : 
     586                 :          0 :     Links().Clear();
     587                 :          0 :     pLinkMgr = pNewMgr;
     588                 :            : 
     589         [ #  # ]:          0 :     if( pLinkMgr )
     590                 :            :     {
     591                 :          0 :         SvBaseLinks& rLnks = (SvBaseLinks&)pLinkMgr->GetLinks();
     592         [ #  # ]:          0 :         for( sal_uInt16 n = 0; n < rLnks.size(); ++n )
     593                 :            :         {
     594                 :          0 :             SvBaseLinkRef* pLinkRef = rLnks[ n ];
     595         [ #  # ]:          0 :             if( !pLinkRef->Is() )
     596                 :            :             {
     597 [ #  # ][ #  # ]:          0 :                 rLnks.erase( rLnks.begin() + n );
     598                 :          0 :                 --n;
     599                 :          0 :                 continue;
     600                 :            :             }
     601         [ #  # ]:          0 :             if( (*pLinkRef)->IsVisible() )
     602                 :          0 :                 InsertEntry( **pLinkRef );
     603                 :            :         }
     604                 :            : 
     605         [ #  # ]:          0 :         if( !rLnks.empty() )
     606                 :            :         {
     607                 :          0 :             SvLBoxEntry* pEntry = Links().GetEntry( 0 );
     608                 :          0 :             Links().SetCurEntry( pEntry );
     609                 :          0 :             Links().Select( pEntry );
     610                 :          0 :             LinksSelectHdl( 0 );
     611                 :            :         }
     612                 :          0 :         Links().SetUpdateMode( sal_True );
     613                 :          0 :         Links().Invalidate();
     614                 :            :     }
     615                 :            : }
     616                 :            : 
     617                 :            : 
     618                 :          0 : void SvBaseLinksDlg::InsertEntry( const SvBaseLink& rLink, sal_uInt16 nPos, sal_Bool bSelect )
     619                 :            : {
     620 [ #  # ][ #  # ]:          0 :     String aEntry, sFileNm, sLinkNm, sTypeNm, sFilter;
         [ #  # ][ #  # ]
                 [ #  # ]
     621                 :            : 
     622         [ #  # ]:          0 :     pLinkMgr->GetDisplayNames( (SvBaseLink*)&rLink, &sTypeNm, &sFileNm, &sLinkNm, &sFilter );
     623                 :            : 
     624                 :            :     // GetTab(0) gives the position of the bitmap which is automatically inserted by the TabListBox.
     625                 :            :     // So the first text column's width is Tab(2)-Tab(1).
     626 [ #  # ][ #  # ]:          0 :     long nWidthPixel = Links().GetLogicTab( 2 ) - Links().GetLogicTab( 1 );
     627                 :          0 :     nWidthPixel -= SV_TAB_BORDER;
     628         [ #  # ]:          0 :     XubString aTxt = Links().GetEllipsisString( sFileNm, nWidthPixel, TEXT_DRAW_PATHELLIPSIS );
     629 [ #  # ][ #  # ]:          0 :     INetURLObject aPath( sFileNm, INET_PROT_FILE );
     630 [ #  # ][ #  # ]:          0 :     String aFileName = aPath.getName();
     631 [ #  # ][ #  # ]:          0 :     aFileName = INetURLObject::decode(aFileName, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS);
                 [ #  # ]
     632                 :            : 
     633         [ #  # ]:          0 :     if( aFileName.Len() > aTxt.Len() )
     634         [ #  # ]:          0 :         aTxt = aFileName;
     635 [ #  # ][ #  # ]:          0 :     else if( aTxt.Search( aFileName, aTxt.Len() - aFileName.Len() ) == STRING_NOTFOUND )
     636                 :            :         // filename not in string
     637         [ #  # ]:          0 :         aTxt = aFileName;
     638                 :            : 
     639         [ #  # ]:          0 :     aEntry = aTxt;
     640         [ #  # ]:          0 :     aEntry += '\t';
     641         [ #  # ]:          0 :     if( OBJECT_CLIENT_GRF == rLink.GetObjType() )
     642         [ #  # ]:          0 :         aEntry += sFilter;
     643                 :            :     else
     644         [ #  # ]:          0 :         aEntry += sLinkNm;
     645         [ #  # ]:          0 :     aEntry += '\t';
     646         [ #  # ]:          0 :     aEntry += sTypeNm;
     647         [ #  # ]:          0 :     aEntry += '\t';
     648 [ #  # ][ #  # ]:          0 :     aEntry += ImplGetStateStr( rLink );
                 [ #  # ]
     649                 :            : 
     650         [ #  # ]:          0 :     SvLBoxEntry * pE = Links().InsertEntryToColumn( aEntry, nPos );
     651                 :          0 :     pE->SetUserData( (void*)&rLink );
     652         [ #  # ]:          0 :     if(bSelect)
     653 [ #  # ][ #  # ]:          0 :         Links().Select(pE);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     654                 :          0 : }
     655                 :            : 
     656                 :          0 : SvBaseLink* SvBaseLinksDlg::GetSelEntry( sal_uInt16* pPos )
     657                 :            : {
     658                 :          0 :     SvLBoxEntry* pE = Links().FirstSelected();
     659                 :            :     sal_uInt16 nPos;
     660         [ #  # ]:          0 :     if( pE && LISTBOX_ENTRY_NOTFOUND !=
           [ #  #  #  # ]
     661                 :          0 :         ( nPos = (sal_uInt16)Links().GetModel()->GetAbsPos( pE ) ) )
     662                 :            :     {
     663                 :            :         DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" );
     664                 :            : 
     665         [ #  # ]:          0 :         if( pPos )
     666                 :          0 :             *pPos = nPos;
     667                 :          0 :         return (SvBaseLink*)pE->GetUserData();
     668                 :            :     }
     669                 :          0 :     return 0;
     670                 :            : }
     671                 :            : 
     672                 :          0 : void SvBaseLinksDlg::SetType( SvBaseLink& rLink,
     673                 :            :                                     sal_uInt16 nSelPos,
     674                 :            :                                     sal_uInt16 nType )
     675                 :            : {
     676                 :          0 :     rLink.SetUpdateMode( nType );
     677                 :          0 :     rLink.Update();
     678                 :          0 :     SvLBoxEntry* pBox = Links().GetEntry( nSelPos );
     679         [ #  # ]:          0 :     Links().SetEntryText( ImplGetStateStr( rLink ), pBox, 3 );
     680         [ #  # ]:          0 :     if( pLinkMgr->GetPersist() )
     681                 :          0 :         pLinkMgr->GetPersist()->SetModified();
     682                 :          0 : }
     683                 :            : 
     684                 :          0 : void SvBaseLinksDlg::SetActLink( SvBaseLink * pLink )
     685                 :            : {
     686         [ #  # ]:          0 :     if( pLinkMgr )
     687                 :            :     {
     688                 :          0 :         const SvBaseLinks& rLnks = pLinkMgr->GetLinks();
     689                 :          0 :         sal_uInt16 nSelect = 0;
     690         [ #  # ]:          0 :         for( sal_uInt16 n = 0; n < rLnks.size(); ++n )
     691                 :            :         {
     692                 :          0 :             SvBaseLinkRef* pLinkRef = rLnks[ n ];
     693                 :            :             // #109573# only visible links have been inserted into the TreeListBox,
     694                 :            :             // invisible ones have to be skipped here
     695         [ #  # ]:          0 :             if( (*pLinkRef)->IsVisible() )
     696                 :            :             {
     697         [ #  # ]:          0 :                 if( pLink == *pLinkRef )
     698                 :            :                 {
     699                 :          0 :                     Links().Select( Links().GetEntry( nSelect ) );
     700                 :          0 :                     LinksSelectHdl( 0 );
     701                 :          0 :                     return ;
     702                 :            :                 }
     703                 :          0 :                 nSelect++;
     704                 :            :             }
     705                 :            :         }
     706                 :            :     }
     707                 :            : }
     708                 :            : 
     709                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10