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 <osl/mutex.hxx>
30 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
31 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
32 : : #include <unotools/accessiblestatesethelper.hxx>
33 : : #include <comphelper/servicehelper.hxx>
34 : : #include <vcl/svapp.hxx>
35 : : #include <ftnfrm.hxx>
36 : : #include <fmtftn.hxx>
37 : : #include <txtftn.hxx>
38 : : #include <viewsh.hxx>
39 : : #include <accmap.hxx>
40 : : #include "accfootnote.hxx"
41 : : #include "access.hrc"
42 : :
43 : : using namespace ::com::sun::star;
44 : : using namespace ::com::sun::star::uno;
45 : : using namespace ::com::sun::star::lang;
46 : : using namespace ::com::sun::star::accessibility;
47 : : using ::rtl::OUString;
48 : :
49 : : const sal_Char sServiceNameFootnote[] = "com.sun.star.text.AccessibleFootnoteView";
50 : : const sal_Char sServiceNameEndnote[] = "com.sun.star.text.AccessibleEndnoteView";
51 : : const sal_Char sImplementationNameFootnote[] = "com.sun.star.comp.Writer.SwAccessibleFootnoteView";
52 : : const sal_Char sImplementationNameEndnote[] = "com.sun.star.comp.Writer.SwAccessibleEndnoteView";
53 : :
54 : 2 : SwAccessibleFootnote::SwAccessibleFootnote(
55 : : SwAccessibleMap* pInitMap,
56 : : sal_Bool bIsEndnote,
57 : : sal_Int32 nFootEndNote,
58 : : const SwFtnFrm *pFtnFrm ) :
59 : : SwAccessibleContext( pInitMap,
60 : : bIsEndnote ? AccessibleRole::END_NOTE : AccessibleRole::FOOTNOTE,
61 [ + - ]: 2 : pFtnFrm )
62 : : {
63 [ + - ]: 2 : SolarMutexGuard aGuard;
64 : :
65 : : sal_uInt16 nResId = bIsEndnote ? STR_ACCESS_ENDNOTE_NAME
66 [ + - ]: 2 : : STR_ACCESS_FOOTNOTE_NAME;
67 : 2 : OUString sArg( OUString::valueOf( nFootEndNote ) );
68 [ + - ][ + - ]: 2 : SetName( GetResource( nResId, &sArg ) );
69 : 2 : }
70 : :
71 : 2 : SwAccessibleFootnote::~SwAccessibleFootnote()
72 : : {
73 [ - + ]: 4 : }
74 : :
75 : 14 : OUString SAL_CALL SwAccessibleFootnote::getAccessibleDescription (void)
76 : : throw (uno::RuntimeException)
77 : : {
78 [ + - ]: 14 : SolarMutexGuard aGuard;
79 : :
80 [ + - ][ - + ]: 14 : CHECK_FOR_DEFUNC( XAccessibleContext )
[ - + ][ # # ]
[ # # ][ # # ]
[ # # ]
81 : :
82 : 14 : sal_uInt16 nResId = AccessibleRole::END_NOTE == GetRole()
83 : : ? STR_ACCESS_ENDNOTE_DESC
84 [ + - ]: 14 : : STR_ACCESS_FOOTNOTE_DESC ;
85 : :
86 : 14 : OUString sArg;
87 : : const SwTxtFtn *pTxtFtn =
88 : 14 : static_cast< const SwFtnFrm *>( GetFrm() )->GetAttr();
89 [ + - ]: 14 : if( pTxtFtn )
90 : : {
91 : 14 : const SwDoc *pDoc = GetMap()->GetShell()->GetDoc();
92 [ + - ][ + - ]: 14 : sArg = pTxtFtn->GetFtn().GetViewNumStr( *pDoc );
[ + - ]
93 : : }
94 : :
95 [ + - ][ + - ]: 14 : return GetResource( nResId, &sArg );
96 : : }
97 : :
98 : 2 : OUString SAL_CALL SwAccessibleFootnote::getImplementationName()
99 : : throw( RuntimeException )
100 : : {
101 [ + - ]: 2 : if( AccessibleRole::END_NOTE == GetRole() )
102 : 2 : return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationNameEndnote));
103 : : else
104 : 2 : return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationNameFootnote));
105 : : }
106 : :
107 : 0 : sal_Bool SAL_CALL SwAccessibleFootnote::supportsService(
108 : : const ::rtl::OUString& sTestServiceName)
109 : : throw (uno::RuntimeException)
110 : : {
111 [ # # ]: 0 : if( sTestServiceName.equalsAsciiL( sAccessibleServiceName,
112 : 0 : sizeof(sAccessibleServiceName)-1 ) )
113 : 0 : return sal_True;
114 [ # # ]: 0 : else if( AccessibleRole::END_NOTE == GetRole() )
115 : 0 : return sTestServiceName.equalsAsciiL( sServiceNameEndnote, sizeof(sServiceNameEndnote)-1 );
116 : : else
117 : 0 : return sTestServiceName.equalsAsciiL( sServiceNameFootnote, sizeof(sServiceNameFootnote)-1 );
118 : :
119 : : }
120 : :
121 : 0 : Sequence< OUString > SAL_CALL SwAccessibleFootnote::getSupportedServiceNames()
122 : : throw( uno::RuntimeException )
123 : : {
124 : 0 : Sequence< OUString > aRet(2);
125 [ # # ]: 0 : OUString* pArray = aRet.getArray();
126 [ # # ]: 0 : if( AccessibleRole::END_NOTE == GetRole() )
127 [ # # ]: 0 : pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceNameEndnote) );
128 : : else
129 [ # # ]: 0 : pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceNameFootnote) );
130 [ # # ]: 0 : pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) );
131 : 0 : return aRet;
132 : : }
133 : :
134 : : namespace
135 : : {
136 : : class theSwAccessibleFootnoteImplementationId : public rtl::Static< UnoTunnelIdInit, theSwAccessibleFootnoteImplementationId > {};
137 : : }
138 : :
139 : 0 : Sequence< sal_Int8 > SAL_CALL SwAccessibleFootnote::getImplementationId()
140 : : throw(RuntimeException)
141 : : {
142 : 0 : return theSwAccessibleFootnoteImplementationId::get().getSeq();
143 : : }
144 : :
145 : 2 : sal_Bool SwAccessibleFootnote::IsEndnote( const SwFtnFrm *pFtnFrm )
146 : : {
147 : 2 : const SwTxtFtn *pTxtFtn = pFtnFrm ->GetAttr();
148 [ + - ][ + - ]: 2 : return pTxtFtn && pTxtFtn->GetFtn().IsEndNote() ;
149 : : }
150 : :
151 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|