1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2008 by Sun Microsystems, Inc.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
30 #include <com/sun/star/uno/Any.hxx>
31 #include <com/sun/star/uno/Reference.hxx>
32 #include <comphelper/accessiblekeybindinghelper.hxx>
34 #include "AccessibleHyperlink.hxx"
35 #include "editeng/unoedprx.hxx"
36 #include <editeng/flditem.hxx>
37 #include <vcl/keycodes.hxx>
39 using namespace ::com::sun::star
;
42 //------------------------------------------------------------------------
44 // AccessibleHyperlink implementation
46 //------------------------------------------------------------------------
48 namespace accessibility
51 AccessibleHyperlink::AccessibleHyperlink( SvxAccessibleTextAdapter
& r
, SvxFieldItem
* p
, sal_uInt16 nP
, sal_uInt16 nR
, sal_Int32 nStt
, sal_Int32 nEnd
, const ::rtl::OUString
& rD
)
62 AccessibleHyperlink::~AccessibleHyperlink()
68 sal_Int32 SAL_CALL
AccessibleHyperlink::getAccessibleActionCount() throw (uno::RuntimeException
)
70 return isValid() ? 1 : 0;
73 sal_Bool SAL_CALL
AccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
75 sal_Bool bRet
= sal_False
;
76 if ( isValid() && ( nIndex
== 0 ) )
78 rTA
.FieldClicked( *pFld
, nPara
, nRealIdx
);
84 ::rtl::OUString SAL_CALL
AccessibleHyperlink::getAccessibleActionDescription( sal_Int32 nIndex
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
86 ::rtl::OUString aDesc
;
88 if ( isValid() && ( nIndex
== 0 ) )
94 uno::Reference
< ::com::sun::star::accessibility::XAccessibleKeyBinding
> SAL_CALL
AccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
96 uno::Reference
< ::com::sun::star::accessibility::XAccessibleKeyBinding
> xKeyBinding
;
98 if( isValid() && ( nIndex
== 0 ) )
100 ::comphelper::OAccessibleKeyBindingHelper
* pKeyBindingHelper
= new ::comphelper::OAccessibleKeyBindingHelper();
101 xKeyBinding
= pKeyBindingHelper
;
103 awt::KeyStroke aKeyStroke
;
104 aKeyStroke
.Modifiers
= 0;
105 aKeyStroke
.KeyCode
= KEY_RETURN
;
106 aKeyStroke
.KeyChar
= 0;
107 aKeyStroke
.KeyFunc
= 0;
108 pKeyBindingHelper
->AddKeyBinding( aKeyStroke
);
114 // XAccessibleHyperlink
115 uno::Any SAL_CALL
AccessibleHyperlink::getAccessibleActionAnchor( sal_Int32
/*nIndex*/ ) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
120 uno::Any SAL_CALL
AccessibleHyperlink::getAccessibleActionObject( sal_Int32
/*nIndex*/ ) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
125 sal_Int32 SAL_CALL
AccessibleHyperlink::getStartIndex() throw (uno::RuntimeException
)
130 sal_Int32 SAL_CALL
AccessibleHyperlink::getEndIndex() throw (uno::RuntimeException
)
135 sal_Bool SAL_CALL
AccessibleHyperlink::isValid( ) throw (uno::RuntimeException
)
137 return rTA
.IsValid();
140 } // end of namespace accessibility
142 //------------------------------------------------------------------------
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */