2003-06-12 07:06:58 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 01:51:13 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-06-12 07:06:58 +00:00
|
|
|
*
|
2005-09-09 01:51:13 +00:00
|
|
|
* $RCSfile: acchyperlink.cxx,v $
|
2003-06-12 07:06:58 +00:00
|
|
|
*
|
2007-06-05 16:26:47 +00:00
|
|
|
* $Revision: 1.6 $
|
2003-06-12 07:06:58 +00:00
|
|
|
*
|
2007-06-05 16:26:47 +00:00
|
|
|
* last change: $Author: ihi $ $Date: 2007-06-05 17:26:47 $
|
2003-06-12 07:06:58 +00:00
|
|
|
*
|
2005-09-09 01:51:13 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2003-06-12 07:06:58 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 01:51:13 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2003-06-12 07:06:58 +00:00
|
|
|
*
|
2005-09-09 01:51:13 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2003-06-12 07:06:58 +00:00
|
|
|
*
|
2005-09-09 01:51:13 +00:00
|
|
|
* This library 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 for more details.
|
2003-06-12 07:06:58 +00:00
|
|
|
*
|
2005-09-09 01:51:13 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2003-06-12 07:06:58 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 19:36:44 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sw.hxx"
|
|
|
|
|
2003-06-12 07:06:58 +00:00
|
|
|
#ifndef COMPHELPER_ACCESSIBLE_KEYBINDING_HELPER_HXX
|
|
|
|
#include <comphelper/accessiblekeybindinghelper.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SWURL_HXX //autogen
|
|
|
|
#include <swurl.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _VOS_MUTEX_HXX_ //autogen
|
|
|
|
#include <vos/mutex.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_SVAPP_HXX //autogen
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _NDTXT_HXX
|
|
|
|
#include <ndtxt.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _TXTINET_HXX
|
|
|
|
#include <txtinet.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _ACCPARA_HXX
|
|
|
|
#include <accpara.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _ACCHYPERLINK_HXX
|
|
|
|
#include <acchyperlink.hxx>
|
|
|
|
#endif
|
|
|
|
|
2007-06-05 16:26:47 +00:00
|
|
|
using namespace ::com::sun::star;
|
2003-06-12 07:06:58 +00:00
|
|
|
using namespace ::com::sun::star::accessibility;
|
|
|
|
using namespace ::rtl;
|
|
|
|
|
|
|
|
SwAccessibleHyperlink::SwAccessibleHyperlink( sal_uInt16 nHPos,
|
2004-06-16 08:30:02 +00:00
|
|
|
SwAccessibleParagraph *p, sal_Int32 nStt, sal_Int32 nEnd ) :
|
2003-06-12 07:06:58 +00:00
|
|
|
nHintPos( nHPos ),
|
2004-06-16 08:30:02 +00:00
|
|
|
xPara( p ),
|
2003-06-12 07:06:58 +00:00
|
|
|
nStartIdx( nStt ),
|
|
|
|
nEndIdx( nEnd )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const SwTxtAttr *SwAccessibleHyperlink::GetTxtAttr() const
|
|
|
|
{
|
|
|
|
const SwTxtAttr *pTxtAttr = 0;
|
|
|
|
if( xPara.isValid() && xPara->GetMap() )
|
|
|
|
{
|
|
|
|
const SwTxtNode *pTxtNd = xPara->GetTxtNode();
|
|
|
|
const SwpHints *pHints = pTxtNd->GetpSwpHints();
|
|
|
|
if( pHints && nHintPos < pHints->Count() )
|
|
|
|
{
|
|
|
|
const SwTxtAttr *pHt = (*pHints)[nHintPos];
|
|
|
|
if( RES_TXTATR_INETFMT == pHt->Which() )
|
|
|
|
pTxtAttr = pHt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pTxtAttr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// XAccessibleAction
|
|
|
|
sal_Int32 SAL_CALL SwAccessibleHyperlink::getAccessibleActionCount()
|
2007-06-05 16:26:47 +00:00
|
|
|
throw (uno::RuntimeException)
|
2003-06-12 07:06:58 +00:00
|
|
|
{
|
|
|
|
return isValid() ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL SwAccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex )
|
2007-06-05 16:26:47 +00:00
|
|
|
throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
|
2003-06-12 07:06:58 +00:00
|
|
|
{
|
|
|
|
vos::OGuard aGuard(Application::GetSolarMutex());
|
|
|
|
|
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
|
|
|
|
const SwTxtAttr *pTxtAttr = GetTxtAttr();
|
|
|
|
if( pTxtAttr && 0 == nIndex )
|
|
|
|
{
|
|
|
|
const SwFmtINetFmt& rINetFmt = pTxtAttr->GetINetFmt();
|
|
|
|
if( rINetFmt.GetValue().Len() )
|
|
|
|
{
|
|
|
|
ViewShell *pVSh = xPara->GetShell();
|
|
|
|
if( pVSh )
|
|
|
|
{
|
|
|
|
LoadURL( rINetFmt.GetValue(), pVSh, URLLOAD_NOFILTER,
|
|
|
|
&rINetFmt.GetTargetFrame() );
|
|
|
|
ASSERT( pTxtAttr == rINetFmt.GetTxtINetFmt(),
|
|
|
|
"lost my txt attr" );
|
|
|
|
const SwTxtINetFmt* pTxtAttr2 = rINetFmt.GetTxtINetFmt();
|
|
|
|
if( pTxtAttr2 )
|
|
|
|
{
|
|
|
|
const_cast< SwTxtINetFmt* >( pTxtAttr2 )->SetVisited( sal_True );
|
|
|
|
const_cast< SwTxtINetFmt* >( pTxtAttr2 )->SetValidVis( sal_True );
|
|
|
|
}
|
|
|
|
bRet = sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
OUString SAL_CALL SwAccessibleHyperlink::getAccessibleActionDescription(
|
|
|
|
sal_Int32 nIndex )
|
2007-06-05 16:26:47 +00:00
|
|
|
throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
|
2003-06-12 07:06:58 +00:00
|
|
|
{
|
|
|
|
OUString sDesc;
|
|
|
|
|
|
|
|
const SwTxtAttr *pTxtAttr = GetTxtAttr();
|
|
|
|
if( pTxtAttr && 0 == nIndex )
|
|
|
|
{
|
|
|
|
const SwFmtINetFmt& rINetFmt = pTxtAttr->GetINetFmt();
|
|
|
|
sDesc = OUString( rINetFmt.GetValue() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return sDesc;
|
|
|
|
}
|
|
|
|
|
2007-06-05 16:26:47 +00:00
|
|
|
uno::Reference< XAccessibleKeyBinding > SAL_CALL
|
2003-06-12 07:06:58 +00:00
|
|
|
SwAccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex )
|
2007-06-05 16:26:47 +00:00
|
|
|
throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
|
2003-06-12 07:06:58 +00:00
|
|
|
{
|
2007-06-05 16:26:47 +00:00
|
|
|
uno::Reference< XAccessibleKeyBinding > xKeyBinding;
|
2003-06-12 07:06:58 +00:00
|
|
|
|
|
|
|
if( isValid() && 0==nIndex )
|
|
|
|
{
|
|
|
|
::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper =
|
|
|
|
new ::comphelper::OAccessibleKeyBindingHelper();
|
|
|
|
xKeyBinding = pKeyBindingHelper;
|
|
|
|
|
|
|
|
::com::sun::star::awt::KeyStroke aKeyStroke;
|
|
|
|
aKeyStroke.Modifiers = 0;
|
|
|
|
aKeyStroke.KeyCode = KEY_RETURN;
|
|
|
|
aKeyStroke.KeyChar = 0;
|
|
|
|
aKeyStroke.KeyFunc = 0;
|
|
|
|
pKeyBindingHelper->AddKeyBinding( aKeyStroke );
|
|
|
|
}
|
|
|
|
|
|
|
|
return xKeyBinding;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XAccessibleHyperlink
|
2007-06-05 16:26:47 +00:00
|
|
|
uno::Any SAL_CALL SwAccessibleHyperlink::getAccessibleActionAnchor(
|
2003-06-12 07:06:58 +00:00
|
|
|
sal_Int32 nIndex )
|
2007-06-05 16:26:47 +00:00
|
|
|
throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
|
2003-06-12 07:06:58 +00:00
|
|
|
{
|
2007-06-05 16:26:47 +00:00
|
|
|
return uno::Any();
|
2003-06-12 07:06:58 +00:00
|
|
|
}
|
|
|
|
|
2007-06-05 16:26:47 +00:00
|
|
|
uno::Any SAL_CALL SwAccessibleHyperlink::getAccessibleActionObject(
|
2003-06-12 07:06:58 +00:00
|
|
|
sal_Int32 nIndex )
|
2007-06-05 16:26:47 +00:00
|
|
|
throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
|
2003-06-12 07:06:58 +00:00
|
|
|
{
|
2007-06-05 16:26:47 +00:00
|
|
|
return uno::Any();
|
2003-06-12 07:06:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 SAL_CALL SwAccessibleHyperlink::getStartIndex()
|
2007-06-05 16:26:47 +00:00
|
|
|
throw (uno::RuntimeException)
|
2003-06-12 07:06:58 +00:00
|
|
|
{
|
|
|
|
return nStartIdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 SAL_CALL SwAccessibleHyperlink::getEndIndex()
|
2007-06-05 16:26:47 +00:00
|
|
|
throw (uno::RuntimeException)
|
2003-06-12 07:06:58 +00:00
|
|
|
{
|
|
|
|
return nEndIdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL SwAccessibleHyperlink::isValid( )
|
2007-06-05 16:26:47 +00:00
|
|
|
throw (uno::RuntimeException)
|
2003-06-12 07:06:58 +00:00
|
|
|
{
|
|
|
|
vos::OGuard aGuard(Application::GetSolarMutex());
|
|
|
|
return xPara.isValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwAccessibleHyperlink::Invalidate()
|
|
|
|
{
|
|
|
|
vos::OGuard aGuard(Application::GetSolarMutex());
|
|
|
|
xPara = 0;
|
|
|
|
}
|
|
|
|
|