2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2009-10-31 00:36:06 +01:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2009-10-31 00:36:06 +01:00
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* This file is part of OpenOffice.org.
|
|
|
|
*
|
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include <linkdlg.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include "helpid.hrc"
|
|
|
|
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#include <svtools/svmedit.hxx>
|
|
|
|
#include <svtools/filedlg.hxx>
|
|
|
|
#include <vcl/dialog.hxx>
|
|
|
|
#include <vcl/button.hxx>
|
|
|
|
#include <vcl/fixed.hxx>
|
|
|
|
#include <vcl/group.hxx>
|
|
|
|
#include <vcl/lstbox.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#include <vcl/timer.hxx>
|
|
|
|
#include <svtools/svtabbx.hxx>
|
|
|
|
|
|
|
|
#include <svuidlg.hrc>
|
|
|
|
#include <sfx2/linkmgr.hxx>
|
|
|
|
#include <sfx2/linksrc.hxx>
|
|
|
|
#include <svtools/soerr.hxx>
|
|
|
|
#include <sfx2/lnkbase.hxx>
|
|
|
|
#include <sfx2/objsh.hxx>
|
|
|
|
|
2009-11-02 20:49:14 +01:00
|
|
|
#include <dialmgr.hxx>
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
#define FILEOBJECT ( OBJECT_CLIENT_FILE & ~OBJECT_CLIENT_SO )
|
|
|
|
|
|
|
|
using namespace sfx2;
|
|
|
|
|
2012-08-06 11:59:47 +02:00
|
|
|
class SvBaseLinkMemberList : private std::vector<SvBaseLink*> {
|
|
|
|
public:
|
|
|
|
~SvBaseLinkMemberList()
|
|
|
|
{
|
|
|
|
for( const_iterator it = begin(); it != end(); ++it )
|
|
|
|
{
|
|
|
|
SvBaseLink* p = *it;
|
|
|
|
if( p )
|
|
|
|
p->ReleaseReference();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
using std::vector<SvBaseLink*>::size;
|
|
|
|
using std::vector<SvBaseLink*>::operator[];
|
|
|
|
|
|
|
|
void push_back(SvBaseLink* p) { std::vector<SvBaseLink*>::push_back(p); p->AddRef(); }
|
|
|
|
};
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2012-04-15 17:50:21 +02:00
|
|
|
// attention, this array is indexed directly (0, 1, ...) in the code
|
2009-10-31 00:36:06 +01:00
|
|
|
static long nTabs[] =
|
|
|
|
{ 4, // Number of Tabs
|
|
|
|
0, 77, 144, 209
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-14 12:41:27 +01:00
|
|
|
SvBaseLinksDlg::SvBaseLinksDlg( Window * pParent, LinkManager* pMgr, sal_Bool bHtml )
|
2009-11-02 20:49:14 +01:00
|
|
|
: ModalDialog( pParent, CUI_RES( MD_UPDATE_BASELINKS ) ),
|
|
|
|
aFtFiles( this, CUI_RES( FT_FILES ) ),
|
|
|
|
aFtLinks( this, CUI_RES( FT_LINKS ) ),
|
|
|
|
aFtType( this, CUI_RES( FT_TYPE ) ),
|
|
|
|
aFtStatus( this, CUI_RES( FT_STATUS ) ),
|
2011-01-20 12:21:31 +01:00
|
|
|
aTbLinks( this, CUI_RES(TB_LINKS ) ),
|
2009-11-02 20:49:14 +01:00
|
|
|
aFtFiles2( this, CUI_RES( FT_FILES2 ) ),
|
2011-01-20 12:21:31 +01:00
|
|
|
aFtFullFileName( this, CUI_RES( FT_FULL_FILE_NAME ) ),
|
2009-11-02 20:49:14 +01:00
|
|
|
aFtSource2( this, CUI_RES( FT_SOURCE2 ) ),
|
2011-01-20 12:21:31 +01:00
|
|
|
aFtFullSourceName( this, CUI_RES( FT_FULL_SOURCE_NAME ) ),
|
2009-11-02 20:49:14 +01:00
|
|
|
aFtType2( this, CUI_RES( FT_TYPE2 ) ),
|
2011-01-20 12:21:31 +01:00
|
|
|
aFtFullTypeName( this, CUI_RES( FT_FULL_TYPE_NAME ) ),
|
2009-11-02 20:49:14 +01:00
|
|
|
aFtUpdate( this, CUI_RES( FT_UPDATE ) ),
|
|
|
|
aRbAutomatic( this, CUI_RES( RB_AUTOMATIC ) ),
|
|
|
|
aRbManual( this, CUI_RES( RB_MANUAL ) ),
|
2011-01-20 12:21:31 +01:00
|
|
|
aCancelButton1( this, CUI_RES( 1 ) ),
|
|
|
|
aHelpButton1( this, CUI_RES( 1 ) ),
|
|
|
|
aPbUpdateNow( this, CUI_RES( PB_UPDATE_NOW ) ),
|
|
|
|
aPbOpenSource( this, CUI_RES( PB_OPEN_SOURCE ) ),
|
|
|
|
aPbChangeSource( this, CUI_RES( PB_CHANGE_SOURCE ) ),
|
|
|
|
aPbBreakLink( this, CUI_RES( PB_BREAK_LINK ) ),
|
2009-11-02 20:49:14 +01:00
|
|
|
aStrAutolink( CUI_RES( STR_AUTOLINK ) ),
|
|
|
|
aStrManuallink( CUI_RES( STR_MANUALLINK ) ),
|
|
|
|
aStrBrokenlink( CUI_RES( STR_BROKENLINK ) ),
|
|
|
|
aStrGraphiclink( CUI_RES( STR_GRAPHICLINK ) ),
|
|
|
|
aStrButtonclose( CUI_RES( STR_BUTTONCLOSE ) ),
|
|
|
|
aStrCloselinkmsg( CUI_RES( STR_CLOSELINKMSG ) ),
|
|
|
|
aStrCloselinkmsgMulti( CUI_RES( STR_CLOSELINKMSG_MULTI ) ),
|
|
|
|
aStrWaitinglink( CUI_RES( STR_WAITINGLINK ) ),
|
2009-10-31 00:36:06 +01:00
|
|
|
pLinkMgr( NULL ),
|
2011-01-20 12:21:31 +01:00
|
|
|
bHtmlMode(bHtml)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
aTbLinks.SetHelpId(HID_LINKDLG_TABLB);
|
|
|
|
aTbLinks.SetSelectionMode( MULTIPLE_SELECTION );
|
|
|
|
aTbLinks.SetTabs( &nTabs[0], MAP_APPFONT );
|
2012-04-15 17:50:21 +02:00
|
|
|
aTbLinks.Resize(); // OS: hack for correct selection
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2012-04-15 17:50:21 +02:00
|
|
|
// UpdateTimer for DDE-/Grf-links, which are waited for
|
2009-10-31 00:36:06 +01:00
|
|
|
aUpdateTimer.SetTimeoutHdl( LINK( this, SvBaseLinksDlg, UpdateWaitingHdl ) );
|
|
|
|
aUpdateTimer.SetTimeout( 1000 );
|
2012-06-27 13:27:03 +02:00
|
|
|
|
2011-01-20 12:21:31 +01:00
|
|
|
// Set the ZOrder, and accessible name to the dialog's title
|
|
|
|
aTbLinks.SetZOrder(0, WINDOW_ZORDER_FIRST);
|
|
|
|
aTbLinks.SetAccessibleName(this->GetText());
|
|
|
|
aTbLinks.SetAccessibleRelationLabeledBy(&aFtFiles);
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
OpenSource().Hide();
|
|
|
|
|
|
|
|
Links().SetSelectHdl( LINK( this, SvBaseLinksDlg, LinksSelectHdl ) );
|
|
|
|
Links().SetDoubleClickHdl( LINK( this, SvBaseLinksDlg, LinksDoubleClickHdl ) );
|
|
|
|
Automatic().SetClickHdl( LINK( this, SvBaseLinksDlg, AutomaticClickHdl ) );
|
|
|
|
Manual().SetClickHdl( LINK( this, SvBaseLinksDlg, ManualClickHdl ) );
|
|
|
|
UpdateNow().SetClickHdl( LINK( this, SvBaseLinksDlg, UpdateNowClickHdl ) );
|
|
|
|
ChangeSource().SetClickHdl( LINK( this, SvBaseLinksDlg, ChangeSourceClickHdl ) );
|
|
|
|
if(!bHtmlMode)
|
|
|
|
BreakLink().SetClickHdl( LINK( this, SvBaseLinksDlg, BreakLinkClickHdl ) );
|
|
|
|
else
|
|
|
|
BreakLink().Hide();
|
|
|
|
|
|
|
|
SetManager( pMgr );
|
|
|
|
}
|
|
|
|
|
|
|
|
SvBaseLinksDlg::~SvBaseLinksDlg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|* SvBaseLinksDlg::Handler()
|
|
|
|
*************************************************************************/
|
|
|
|
IMPL_LINK( SvBaseLinksDlg, LinksSelectHdl, SvTabListBox *, pSvTabListBox )
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nSelectionCount = pSvTabListBox ?
|
|
|
|
(sal_uInt16)pSvTabListBox->GetSelectionCount() : 0;
|
2009-10-31 00:36:06 +01:00
|
|
|
if(nSelectionCount > 1)
|
|
|
|
{
|
2012-04-15 17:50:21 +02:00
|
|
|
// possibly deselect old entries in case of multi-selection
|
2009-10-31 00:36:06 +01:00
|
|
|
SvLBoxEntry* pEntry = 0;
|
|
|
|
SvBaseLink* pLink = 0;
|
|
|
|
pEntry = pSvTabListBox->GetHdlEntry();
|
|
|
|
pLink = (SvBaseLink*)pEntry->GetUserData();
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nObjectType = pLink->GetObjType();
|
2009-10-31 00:36:06 +01:00
|
|
|
if((OBJECT_CLIENT_FILE & nObjectType) != OBJECT_CLIENT_FILE)
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
pSvTabListBox->SelectAll(sal_False);
|
2009-10-31 00:36:06 +01:00
|
|
|
pSvTabListBox->Select(pEntry);
|
|
|
|
nSelectionCount = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
for( sal_uInt16 i = 0; i < nSelectionCount; i++)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
pEntry = i == 0 ? pSvTabListBox->FirstSelected() :
|
|
|
|
pSvTabListBox->NextSelected(pEntry);
|
|
|
|
DBG_ASSERT(pEntry, "Wo ist der Entry?");
|
|
|
|
pLink = (SvBaseLink*)pEntry->GetUserData();
|
|
|
|
DBG_ASSERT(pLink, "Wo ist der Link?");
|
|
|
|
if( (OBJECT_CLIENT_FILE & pLink->GetObjType()) != OBJECT_CLIENT_FILE )
|
2011-01-14 12:41:27 +01:00
|
|
|
pSvTabListBox->Select( pEntry, sal_False );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateNow().Enable();
|
|
|
|
|
|
|
|
Automatic().Disable();
|
|
|
|
Manual().Check();
|
|
|
|
Manual().Disable();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nPos;
|
2009-10-31 00:36:06 +01:00
|
|
|
SvBaseLink* pLink = GetSelEntry( &nPos );
|
|
|
|
if( !pLink )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
UpdateNow().Enable();
|
|
|
|
|
|
|
|
String sType, sLink;
|
|
|
|
String *pLinkNm = &sLink, *pFilter = 0;
|
|
|
|
|
|
|
|
if( FILEOBJECT & pLink->GetObjType() )
|
|
|
|
{
|
|
|
|
Automatic().Disable();
|
|
|
|
Manual().Check();
|
|
|
|
Manual().Disable();
|
|
|
|
if( OBJECT_CLIENT_GRF == pLink->GetObjType() )
|
|
|
|
pLinkNm = 0, pFilter = &sLink;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Automatic().Enable();
|
|
|
|
Manual().Enable();
|
|
|
|
|
|
|
|
if( LINKUPDATE_ALWAYS == pLink->GetUpdateMode() )
|
|
|
|
Automatic().Check();
|
|
|
|
else
|
|
|
|
Manual().Check();
|
|
|
|
}
|
|
|
|
|
|
|
|
String aFileName;
|
|
|
|
pLinkMgr->GetDisplayNames( pLink, &sType, &aFileName, pLinkNm, pFilter );
|
2009-12-10 18:00:39 +01:00
|
|
|
aFileName = INetURLObject::decode(aFileName, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS);
|
2009-10-31 00:36:06 +01:00
|
|
|
FileName().SetText( aFileName );
|
|
|
|
SourceName().SetText( sLink );
|
|
|
|
TypeName().SetText( sType );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK_INLINE_START( SvBaseLinksDlg, LinksDoubleClickHdl, SvTabListBox *, pSvTabListBox )
|
|
|
|
{
|
|
|
|
(void)pSvTabListBox;
|
|
|
|
|
|
|
|
ChangeSourceClickHdl( 0 );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
IMPL_LINK_INLINE_END( SvBaseLinksDlg, LinksDoubleClickHdl, SvTabListBox *, pSvTabListBox )
|
|
|
|
|
|
|
|
IMPL_LINK_INLINE_START( SvBaseLinksDlg, AutomaticClickHdl, RadioButton *, pRadioButton )
|
|
|
|
{
|
|
|
|
(void)pRadioButton;
|
|
|
|
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nPos;
|
2009-10-31 00:36:06 +01:00
|
|
|
SvBaseLink* pLink = GetSelEntry( &nPos );
|
|
|
|
if( pLink && !( FILEOBJECT & pLink->GetObjType() ) &&
|
|
|
|
LINKUPDATE_ALWAYS != pLink->GetUpdateMode() )
|
|
|
|
SetType( *pLink, nPos, LINKUPDATE_ALWAYS );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
IMPL_LINK_INLINE_END( SvBaseLinksDlg, AutomaticClickHdl, RadioButton *, pRadioButton )
|
|
|
|
|
|
|
|
IMPL_LINK_INLINE_START( SvBaseLinksDlg, ManualClickHdl, RadioButton *, pRadioButton )
|
|
|
|
{
|
|
|
|
(void)pRadioButton;
|
|
|
|
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nPos;
|
2009-10-31 00:36:06 +01:00
|
|
|
SvBaseLink* pLink = GetSelEntry( &nPos );
|
|
|
|
if( pLink && !( FILEOBJECT & pLink->GetObjType() ) &&
|
|
|
|
LINKUPDATE_ONCALL != pLink->GetUpdateMode())
|
|
|
|
SetType( *pLink, nPos, LINKUPDATE_ONCALL );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
IMPL_LINK_INLINE_END( SvBaseLinksDlg, ManualClickHdl, RadioButton *, pRadioButton )
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(SvBaseLinksDlg, UpdateNowClickHdl)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
SvTabListBox& rListBox = Links();
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nSelCnt = (sal_uInt16)rListBox.GetSelectionCount();
|
2009-10-31 00:36:06 +01:00
|
|
|
if( 255 < nSelCnt )
|
|
|
|
nSelCnt = 255;
|
|
|
|
|
|
|
|
std::vector< SvBaseLink* > aLnkArr;
|
2011-01-14 12:41:27 +01:00
|
|
|
std::vector< sal_uInt16 > aPosArr;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
SvLBoxEntry* pE = rListBox.FirstSelected();
|
|
|
|
while( pE )
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nFndPos = (sal_uInt16)rListBox.GetModel()->GetAbsPos( pE );
|
2009-10-31 00:36:06 +01:00
|
|
|
if( LISTBOX_ENTRY_NOTFOUND != nFndPos )
|
|
|
|
{
|
|
|
|
aLnkArr.push_back( static_cast< SvBaseLink* >( pE->GetUserData() ) );
|
|
|
|
aPosArr.push_back( nFndPos );
|
|
|
|
}
|
|
|
|
pE = rListBox.NextSelected( pE );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !aLnkArr.empty() )
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
for( sal_uInt16 n = 0; n < aLnkArr.size(); ++n )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
SvBaseLinkRef xLink = aLnkArr[ n ];
|
|
|
|
|
2012-04-15 17:50:21 +02:00
|
|
|
// first look for the entry in the array
|
2012-06-12 15:41:27 +02:00
|
|
|
for( sal_uInt16 i = 0; i < pLinkMgr->GetLinks().size(); ++i )
|
2009-10-31 00:36:06 +01:00
|
|
|
if( &xLink == *pLinkMgr->GetLinks()[ i ] )
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
xLink->SetUseCache( sal_False );
|
2009-10-31 00:36:06 +01:00
|
|
|
SetType( *xLink, aPosArr[ n ], xLink->GetUpdateMode() );
|
2011-01-14 12:41:27 +01:00
|
|
|
xLink->SetUseCache( sal_True );
|
2009-10-31 00:36:06 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-15 17:50:21 +02:00
|
|
|
// if somebody is of the opinion to swap his links (SD)
|
2010-01-13 22:25:07 +01:00
|
|
|
LinkManager* pNewMgr = pLinkMgr;
|
2009-10-31 00:36:06 +01:00
|
|
|
pLinkMgr = 0;
|
|
|
|
SetManager( pNewMgr );
|
|
|
|
|
|
|
|
|
|
|
|
if( 0 == (pE = rListBox.GetEntry( aPosArr[ 0 ] )) ||
|
|
|
|
pE->GetUserData() != aLnkArr[ 0 ] )
|
|
|
|
{
|
2012-04-15 17:50:21 +02:00
|
|
|
// search the link
|
2009-10-31 00:36:06 +01:00
|
|
|
pE = rListBox.First();
|
|
|
|
while( pE )
|
|
|
|
{
|
|
|
|
if( pE->GetUserData() == aLnkArr[ 0 ] )
|
|
|
|
break;
|
|
|
|
pE = rListBox.Next( pE );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !pE )
|
|
|
|
pE = rListBox.FirstSelected();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pE )
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pSelEntry = rListBox.FirstSelected();
|
|
|
|
if( pE != pSelEntry )
|
2011-01-14 12:41:27 +01:00
|
|
|
rListBox.Select( pSelEntry, sal_False );
|
2009-10-31 00:36:06 +01:00
|
|
|
rListBox.Select( pE );
|
|
|
|
rListBox.MakeVisible( pE );
|
|
|
|
}
|
2010-10-05 15:39:06 -04:00
|
|
|
|
|
|
|
pNewMgr->CloseCachedComps();
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( SvBaseLinksDlg, ChangeSourceClickHdl, PushButton *, pPushButton )
|
|
|
|
{
|
|
|
|
(void)pPushButton;
|
|
|
|
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nSelectionCount = (sal_uInt16)Links().GetSelectionCount();
|
2009-10-31 00:36:06 +01:00
|
|
|
if(nSelectionCount > 1)
|
|
|
|
{
|
|
|
|
PathDialog aPathDlg( this );
|
|
|
|
String sType, sFile, sLinkName;
|
|
|
|
String sFilter;
|
|
|
|
SvLBoxEntry* pEntry = Links().FirstSelected();
|
|
|
|
SvBaseLink* pLink = (SvBaseLink*)pEntry->GetUserData();
|
|
|
|
pLinkMgr->GetDisplayNames( pLink, &sType, &sFile, 0, 0 );
|
|
|
|
INetURLObject aUrl(sFile);
|
|
|
|
if(aUrl.GetProtocol() == INET_PROT_FILE)
|
|
|
|
{
|
|
|
|
rtl::OUString sOldPath(aUrl.PathToFileName());
|
|
|
|
sal_Int32 nLen = aUrl.GetName().getLength();
|
|
|
|
sOldPath = sOldPath.copy(0, sOldPath.getLength() - nLen);
|
|
|
|
aPathDlg.SetPath(sOldPath);
|
|
|
|
}
|
|
|
|
if(aPathDlg.Execute() == RET_OK)
|
|
|
|
{
|
|
|
|
String aPath = aPathDlg.GetPath();
|
|
|
|
|
2011-01-14 12:41:27 +01:00
|
|
|
for( sal_uInt16 i = 0; i < nSelectionCount; i++)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
pEntry = i==0 ?
|
|
|
|
Links().FirstSelected() :
|
|
|
|
Links().NextSelected( pEntry );
|
|
|
|
DBG_ASSERT(pEntry,"Wo ist der Entry");
|
|
|
|
pLink = (SvBaseLink*)pEntry->GetUserData();
|
|
|
|
DBG_ASSERT(pLink,"Wo ist der Link");
|
|
|
|
pLinkMgr->GetDisplayNames( pLink, &sType, &sFile, &sLinkName, &sFilter );
|
|
|
|
INetURLObject aUrl_(sFile);
|
|
|
|
INetURLObject aUrl2(aPath, INET_PROT_FILE);
|
|
|
|
aUrl2.insertName( aUrl_.getName() );
|
|
|
|
String sNewLinkName;
|
|
|
|
MakeLnkName( sNewLinkName, 0 ,
|
|
|
|
aUrl2.GetMainURL(INetURLObject::DECODE_TO_IURI), sLinkName, &sFilter);
|
|
|
|
pLink->SetLinkSourceName( sNewLinkName );
|
|
|
|
pLink->Update();
|
|
|
|
}
|
|
|
|
if( pLinkMgr->GetPersist() )
|
|
|
|
pLinkMgr->GetPersist()->SetModified();
|
2010-01-13 22:25:07 +01:00
|
|
|
LinkManager* pNewMgr = pLinkMgr;
|
2009-10-31 00:36:06 +01:00
|
|
|
pLinkMgr = 0;
|
|
|
|
SetManager( pNewMgr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nPos;
|
2009-10-31 00:36:06 +01:00
|
|
|
SvBaseLink* pLink = GetSelEntry( &nPos );
|
|
|
|
if ( pLink && (pLink->GetLinkSourceName().Len() != 0) )
|
|
|
|
pLink->Edit( this, LINK( this, SvBaseLinksDlg, EndEditHdl ) );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( SvBaseLinksDlg, BreakLinkClickHdl, PushButton *, pPushButton )
|
|
|
|
{
|
|
|
|
(void)pPushButton;
|
|
|
|
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_Bool bModified = sal_False;
|
2009-10-31 00:36:06 +01:00
|
|
|
if(Links().GetSelectionCount() <= 1)
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nPos;
|
2009-10-31 00:36:06 +01:00
|
|
|
SvBaseLinkRef xLink = GetSelEntry( &nPos );
|
|
|
|
if( !xLink.Is() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
QueryBox aBox( this, WB_YES_NO | WB_DEF_YES, Closelinkmsg() );
|
|
|
|
|
|
|
|
if( RET_YES == aBox.Execute() )
|
|
|
|
{
|
|
|
|
Links().GetModel()->Remove( Links().GetEntry( nPos ) );
|
|
|
|
|
2012-04-15 17:50:21 +02:00
|
|
|
// close object, if it's still existing
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_Bool bNewLnkMgr = OBJECT_CLIENT_FILE == xLink->GetObjType();
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2012-04-15 17:50:21 +02:00
|
|
|
// tell the link that it will be resolved!
|
2009-10-31 00:36:06 +01:00
|
|
|
xLink->Closed();
|
|
|
|
|
2012-04-15 17:50:21 +02:00
|
|
|
// if somebody has forgotten to deregister himself
|
2009-10-31 00:36:06 +01:00
|
|
|
if( xLink.Is() )
|
|
|
|
pLinkMgr->Remove( &xLink );
|
|
|
|
|
|
|
|
if( bNewLnkMgr )
|
|
|
|
{
|
2010-01-13 22:25:07 +01:00
|
|
|
LinkManager* pNewMgr = pLinkMgr;
|
2009-10-31 00:36:06 +01:00
|
|
|
pLinkMgr = 0;
|
|
|
|
SetManager( pNewMgr );
|
|
|
|
|
|
|
|
SvLBoxEntry* pEntry = Links().GetEntry( nPos ? --nPos : 0 );
|
|
|
|
if( pEntry )
|
|
|
|
Links().SetCurEntry( pEntry );
|
|
|
|
}
|
2011-01-14 12:41:27 +01:00
|
|
|
bModified = sal_True;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QueryBox aBox( this, WB_YES_NO | WB_DEF_YES, CloselinkmsgMulti() );
|
|
|
|
|
|
|
|
if( RET_YES == aBox.Execute() )
|
|
|
|
{
|
|
|
|
|
|
|
|
SvBaseLinkMemberList aLinkList;
|
|
|
|
SvLBoxEntry* pEntry = Links().FirstSelected();
|
|
|
|
while ( pEntry )
|
|
|
|
{
|
|
|
|
void * pUD = pEntry->GetUserData();
|
|
|
|
if( pUD )
|
2012-08-06 11:59:47 +02:00
|
|
|
aLinkList.push_back( (SvBaseLink*)pUD );
|
2009-10-31 00:36:06 +01:00
|
|
|
pEntry = Links().NextSelected(pEntry);
|
|
|
|
}
|
|
|
|
Links().RemoveSelection();
|
2012-08-06 11:59:47 +02:00
|
|
|
for( sal_uLong i = 0; i < aLinkList.size(); i++ )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2012-08-06 11:59:47 +02:00
|
|
|
SvBaseLinkRef xLink = aLinkList[i];
|
2012-04-15 17:50:21 +02:00
|
|
|
// tell the link that it will be resolved!
|
2009-10-31 00:36:06 +01:00
|
|
|
xLink->Closed();
|
|
|
|
|
2012-04-15 17:50:21 +02:00
|
|
|
// if somebody has forgotten to deregister himself
|
2009-10-31 00:36:06 +01:00
|
|
|
pLinkMgr->Remove( &xLink );
|
2011-01-14 12:41:27 +01:00
|
|
|
bModified = sal_True;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2012-04-15 17:50:21 +02:00
|
|
|
// then remove all selected entries
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(bModified)
|
|
|
|
{
|
|
|
|
if( !Links().GetEntryCount() )
|
|
|
|
{
|
|
|
|
Automatic().Disable();
|
|
|
|
Manual().Disable();
|
|
|
|
UpdateNow().Disable();
|
|
|
|
ChangeSource().Disable();
|
|
|
|
BreakLink().Disable();
|
|
|
|
|
|
|
|
String aEmpty;
|
|
|
|
SourceName().SetText( aEmpty );
|
|
|
|
TypeName().SetText( aEmpty );
|
|
|
|
}
|
|
|
|
if( pLinkMgr->GetPersist() )
|
|
|
|
pLinkMgr->GetPersist()->SetModified();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( SvBaseLinksDlg, UpdateWaitingHdl, Timer*, pTimer )
|
|
|
|
{
|
|
|
|
(void)pTimer;
|
|
|
|
|
2011-01-14 12:41:27 +01:00
|
|
|
Links().SetUpdateMode(sal_False);
|
|
|
|
for( sal_uLong nPos = Links().GetEntryCount(); nPos; )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
SvLBoxEntry* pBox = Links().GetEntry( --nPos );
|
|
|
|
SvBaseLinkRef xLink( (SvBaseLink*)pBox->GetUserData() );
|
|
|
|
if( xLink.Is() )
|
|
|
|
{
|
|
|
|
String sCur( ImplGetStateStr( *xLink ) ),
|
|
|
|
sOld( Links().GetEntryText( pBox, 3 ) );
|
|
|
|
if( sCur != sOld )
|
|
|
|
Links().SetEntryText( sCur, pBox, 3 );
|
|
|
|
}
|
|
|
|
}
|
2011-01-14 12:41:27 +01:00
|
|
|
Links().SetUpdateMode(sal_True);
|
2009-10-31 00:36:06 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( SvBaseLinksDlg, EndEditHdl, sfx2::SvBaseLink*, _pLink )
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nPos;
|
2009-12-10 18:00:39 +01:00
|
|
|
GetSelEntry( &nPos );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2009-12-10 18:00:39 +01:00
|
|
|
if( _pLink && _pLink->WasLastEditOK() )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2012-04-15 17:50:21 +02:00
|
|
|
// StarImpress/Draw swap the LinkObjects themselves!
|
|
|
|
// So search for the link in the manager; if it does not exist
|
|
|
|
// anymore, fill the list completely new. Otherwise only the
|
|
|
|
// edited link needs to be refreshed.
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_Bool bLinkFnd = sal_False;
|
2012-06-12 15:41:27 +02:00
|
|
|
for( sal_uInt16 n = pLinkMgr->GetLinks().size(); n; )
|
2009-10-31 00:36:06 +01:00
|
|
|
if( _pLink == &(*pLinkMgr->GetLinks()[ --n ]) )
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
bLinkFnd = sal_True;
|
2009-10-31 00:36:06 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bLinkFnd )
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
Links().SetUpdateMode(sal_False);
|
2009-10-31 00:36:06 +01:00
|
|
|
Links().GetModel()->Remove( Links().GetEntry( nPos ) );
|
|
|
|
SvLBoxEntry* pToUnselect = Links().FirstSelected();
|
|
|
|
InsertEntry( *_pLink, nPos, sal_True );
|
|
|
|
if(pToUnselect)
|
2011-01-14 12:41:27 +01:00
|
|
|
Links().Select(pToUnselect, sal_False);
|
|
|
|
Links().SetUpdateMode(sal_True);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-01-13 22:25:07 +01:00
|
|
|
LinkManager* pNewMgr = pLinkMgr;
|
2009-10-31 00:36:06 +01:00
|
|
|
pLinkMgr = 0;
|
|
|
|
SetManager( pNewMgr );
|
|
|
|
}
|
|
|
|
if( pLinkMgr->GetPersist() )
|
|
|
|
pLinkMgr->GetPersist()->SetModified();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
String SvBaseLinksDlg::ImplGetStateStr( const SvBaseLink& rLnk )
|
|
|
|
{
|
|
|
|
String sRet;
|
|
|
|
if( !rLnk.GetObj() )
|
|
|
|
sRet = Brokenlink();
|
|
|
|
else if( rLnk.GetObj()->IsPending() )
|
|
|
|
{
|
|
|
|
sRet = Waitinglink();
|
|
|
|
StartUpdateTimer();
|
|
|
|
}
|
|
|
|
else if( LINKUPDATE_ALWAYS == rLnk.GetUpdateMode() )
|
|
|
|
sRet = Autolink();
|
|
|
|
else
|
|
|
|
sRet = Manuallink();
|
|
|
|
|
|
|
|
return sRet;
|
|
|
|
}
|
|
|
|
|
2010-01-13 22:25:07 +01:00
|
|
|
void SvBaseLinksDlg::SetManager( LinkManager* pNewMgr )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
if( pLinkMgr == pNewMgr )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( pNewMgr )
|
2012-04-15 17:50:21 +02:00
|
|
|
// update has to be stopped before clear
|
2011-01-14 12:41:27 +01:00
|
|
|
Links().SetUpdateMode( sal_False );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
Links().Clear();
|
|
|
|
pLinkMgr = pNewMgr;
|
|
|
|
|
|
|
|
if( pLinkMgr )
|
|
|
|
{
|
|
|
|
SvBaseLinks& rLnks = (SvBaseLinks&)pLinkMgr->GetLinks();
|
2012-06-12 15:41:27 +02:00
|
|
|
for( sal_uInt16 n = 0; n < rLnks.size(); ++n )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
SvBaseLinkRef* pLinkRef = rLnks[ n ];
|
|
|
|
if( !pLinkRef->Is() )
|
|
|
|
{
|
2012-06-12 15:41:27 +02:00
|
|
|
rLnks.erase( rLnks.begin() + n );
|
2009-10-31 00:36:06 +01:00
|
|
|
--n;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if( (*pLinkRef)->IsVisible() )
|
|
|
|
InsertEntry( **pLinkRef );
|
|
|
|
}
|
|
|
|
|
2012-06-12 15:41:27 +02:00
|
|
|
if( !rLnks.empty() )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
SvLBoxEntry* pEntry = Links().GetEntry( 0 );
|
|
|
|
Links().SetCurEntry( pEntry );
|
|
|
|
Links().Select( pEntry );
|
|
|
|
LinksSelectHdl( 0 );
|
|
|
|
}
|
2011-01-14 12:41:27 +01:00
|
|
|
Links().SetUpdateMode( sal_True );
|
2009-10-31 00:36:06 +01:00
|
|
|
Links().Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-14 12:41:27 +01:00
|
|
|
void SvBaseLinksDlg::InsertEntry( const SvBaseLink& rLink, sal_uInt16 nPos, sal_Bool bSelect )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
String aEntry, sFileNm, sLinkNm, sTypeNm, sFilter;
|
|
|
|
|
|
|
|
pLinkMgr->GetDisplayNames( (SvBaseLink*)&rLink, &sTypeNm, &sFileNm, &sLinkNm, &sFilter );
|
|
|
|
|
2012-04-15 17:50:21 +02:00
|
|
|
// GetTab(0) gives the position of the bitmap which is automatically inserted by the TabListBox.
|
|
|
|
// So the first text column's width is Tab(2)-Tab(1).
|
2009-10-31 00:36:06 +01:00
|
|
|
long nWidthPixel = Links().GetLogicTab( 2 ) - Links().GetLogicTab( 1 );
|
|
|
|
nWidthPixel -= SV_TAB_BORDER;
|
|
|
|
XubString aTxt = Links().GetEllipsisString( sFileNm, nWidthPixel, TEXT_DRAW_PATHELLIPSIS );
|
|
|
|
INetURLObject aPath( sFileNm, INET_PROT_FILE );
|
|
|
|
String aFileName = aPath.getName();
|
2009-12-10 18:00:39 +01:00
|
|
|
aFileName = INetURLObject::decode(aFileName, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS);
|
|
|
|
|
2009-10-31 00:36:06 +01:00
|
|
|
if( aFileName.Len() > aTxt.Len() )
|
|
|
|
aTxt = aFileName;
|
|
|
|
else if( aTxt.Search( aFileName, aTxt.Len() - aFileName.Len() ) == STRING_NOTFOUND )
|
|
|
|
// filename not in string
|
|
|
|
aTxt = aFileName;
|
|
|
|
|
|
|
|
aEntry = aTxt;
|
|
|
|
aEntry += '\t';
|
|
|
|
if( OBJECT_CLIENT_GRF == rLink.GetObjType() )
|
|
|
|
aEntry += sFilter;
|
|
|
|
else
|
|
|
|
aEntry += sLinkNm;
|
|
|
|
aEntry += '\t';
|
|
|
|
aEntry += sTypeNm;
|
|
|
|
aEntry += '\t';
|
|
|
|
aEntry += ImplGetStateStr( rLink );
|
|
|
|
|
|
|
|
SvLBoxEntry * pE = Links().InsertEntryToColumn( aEntry, nPos );
|
|
|
|
pE->SetUserData( (void*)&rLink );
|
|
|
|
if(bSelect)
|
|
|
|
Links().Select(pE);
|
|
|
|
}
|
|
|
|
|
2011-01-14 12:41:27 +01:00
|
|
|
SvBaseLink* SvBaseLinksDlg::GetSelEntry( sal_uInt16* pPos )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
SvLBoxEntry* pE = Links().FirstSelected();
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nPos;
|
2009-10-31 00:36:06 +01:00
|
|
|
if( pE && LISTBOX_ENTRY_NOTFOUND !=
|
2011-01-14 12:41:27 +01:00
|
|
|
( nPos = (sal_uInt16)Links().GetModel()->GetAbsPos( pE ) ) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" );
|
|
|
|
|
|
|
|
if( pPos )
|
|
|
|
*pPos = nPos;
|
|
|
|
return (SvBaseLink*)pE->GetUserData();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvBaseLinksDlg::SetType( SvBaseLink& rLink,
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nSelPos,
|
|
|
|
sal_uInt16 nType )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
rLink.SetUpdateMode( nType );
|
|
|
|
rLink.Update();
|
|
|
|
SvLBoxEntry* pBox = Links().GetEntry( nSelPos );
|
|
|
|
Links().SetEntryText( ImplGetStateStr( rLink ), pBox, 3 );
|
|
|
|
if( pLinkMgr->GetPersist() )
|
|
|
|
pLinkMgr->GetPersist()->SetModified();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SvBaseLinksDlg::SetActLink( SvBaseLink * pLink )
|
|
|
|
{
|
|
|
|
if( pLinkMgr )
|
|
|
|
{
|
|
|
|
const SvBaseLinks& rLnks = pLinkMgr->GetLinks();
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uInt16 nSelect = 0;
|
2012-06-12 15:41:27 +02:00
|
|
|
for( sal_uInt16 n = 0; n < rLnks.size(); ++n )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
SvBaseLinkRef* pLinkRef = rLnks[ n ];
|
|
|
|
// #109573# only visible links have been inserted into the TreeListBox,
|
|
|
|
// invisible ones have to be skipped here
|
|
|
|
if( (*pLinkRef)->IsVisible() )
|
|
|
|
{
|
|
|
|
if( pLink == *pLinkRef )
|
|
|
|
{
|
|
|
|
Links().Select( Links().GetEntry( nSelect ) );
|
|
|
|
LinksSelectHdl( 0 );
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
nSelect++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|