Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <osl/mutex.hxx>
21 : #include <com/sun/star/accessibility/AccessibleRole.hpp>
22 : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
23 : #include <unotools/accessiblestatesethelper.hxx>
24 : #include <comphelper/servicehelper.hxx>
25 : #include <vcl/svapp.hxx>
26 : #include <ftnfrm.hxx>
27 : #include <fmtftn.hxx>
28 : #include <txtftn.hxx>
29 : #include <viewsh.hxx>
30 : #include <accmap.hxx>
31 : #include "accfootnote.hxx"
32 : #include "access.hrc"
33 :
34 : using namespace ::com::sun::star;
35 : using namespace ::com::sun::star::uno;
36 : using namespace ::com::sun::star::lang;
37 : using namespace ::com::sun::star::accessibility;
38 : using ::rtl::OUString;
39 :
40 : const sal_Char sServiceNameFootnote[] = "com.sun.star.text.AccessibleFootnoteView";
41 : const sal_Char sServiceNameEndnote[] = "com.sun.star.text.AccessibleEndnoteView";
42 : const sal_Char sImplementationNameFootnote[] = "com.sun.star.comp.Writer.SwAccessibleFootnoteView";
43 : const sal_Char sImplementationNameEndnote[] = "com.sun.star.comp.Writer.SwAccessibleEndnoteView";
44 :
45 0 : SwAccessibleFootnote::SwAccessibleFootnote(
46 : SwAccessibleMap* pInitMap,
47 : sal_Bool bIsEndnote,
48 : sal_Int32 nFootEndNote,
49 : const SwFtnFrm *pFtnFrm ) :
50 : SwAccessibleContext( pInitMap,
51 : bIsEndnote ? AccessibleRole::END_NOTE : AccessibleRole::FOOTNOTE,
52 0 : pFtnFrm )
53 : {
54 0 : SolarMutexGuard aGuard;
55 :
56 : sal_uInt16 nResId = bIsEndnote ? STR_ACCESS_ENDNOTE_NAME
57 0 : : STR_ACCESS_FOOTNOTE_NAME;
58 0 : OUString sArg( OUString::valueOf( nFootEndNote ) );
59 0 : SetName( GetResource( nResId, &sArg ) );
60 0 : }
61 :
62 0 : SwAccessibleFootnote::~SwAccessibleFootnote()
63 : {
64 0 : }
65 :
66 0 : OUString SAL_CALL SwAccessibleFootnote::getAccessibleDescription (void)
67 : throw (uno::RuntimeException)
68 : {
69 0 : SolarMutexGuard aGuard;
70 :
71 0 : CHECK_FOR_DEFUNC( XAccessibleContext )
72 :
73 0 : sal_uInt16 nResId = AccessibleRole::END_NOTE == GetRole()
74 : ? STR_ACCESS_ENDNOTE_DESC
75 0 : : STR_ACCESS_FOOTNOTE_DESC ;
76 :
77 0 : OUString sArg;
78 : const SwTxtFtn *pTxtFtn =
79 0 : static_cast< const SwFtnFrm *>( GetFrm() )->GetAttr();
80 0 : if( pTxtFtn )
81 : {
82 0 : const SwDoc *pDoc = GetMap()->GetShell()->GetDoc();
83 0 : sArg = pTxtFtn->GetFtn().GetViewNumStr( *pDoc );
84 : }
85 :
86 0 : return GetResource( nResId, &sArg );
87 : }
88 :
89 0 : OUString SAL_CALL SwAccessibleFootnote::getImplementationName()
90 : throw( RuntimeException )
91 : {
92 0 : if( AccessibleRole::END_NOTE == GetRole() )
93 0 : return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationNameEndnote));
94 : else
95 0 : return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationNameFootnote));
96 : }
97 :
98 0 : sal_Bool SAL_CALL SwAccessibleFootnote::supportsService(
99 : const ::rtl::OUString& sTestServiceName)
100 : throw (uno::RuntimeException)
101 : {
102 0 : if( sTestServiceName.equalsAsciiL( sAccessibleServiceName,
103 0 : sizeof(sAccessibleServiceName)-1 ) )
104 0 : return sal_True;
105 0 : else if( AccessibleRole::END_NOTE == GetRole() )
106 0 : return sTestServiceName.equalsAsciiL( sServiceNameEndnote, sizeof(sServiceNameEndnote)-1 );
107 : else
108 0 : return sTestServiceName.equalsAsciiL( sServiceNameFootnote, sizeof(sServiceNameFootnote)-1 );
109 :
110 : }
111 :
112 0 : Sequence< OUString > SAL_CALL SwAccessibleFootnote::getSupportedServiceNames()
113 : throw( uno::RuntimeException )
114 : {
115 0 : Sequence< OUString > aRet(2);
116 0 : OUString* pArray = aRet.getArray();
117 0 : if( AccessibleRole::END_NOTE == GetRole() )
118 0 : pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceNameEndnote) );
119 : else
120 0 : pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceNameFootnote) );
121 0 : pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) );
122 0 : return aRet;
123 : }
124 :
125 : namespace
126 : {
127 : class theSwAccessibleFootnoteImplementationId : public rtl::Static< UnoTunnelIdInit, theSwAccessibleFootnoteImplementationId > {};
128 : }
129 :
130 0 : Sequence< sal_Int8 > SAL_CALL SwAccessibleFootnote::getImplementationId()
131 : throw(RuntimeException)
132 : {
133 0 : return theSwAccessibleFootnoteImplementationId::get().getSeq();
134 : }
135 :
136 0 : sal_Bool SwAccessibleFootnote::IsEndnote( const SwFtnFrm *pFtnFrm )
137 : {
138 0 : const SwTxtFtn *pTxtFtn = pFtnFrm ->GetAttr();
139 0 : return pTxtFtn && pTxtFtn->GetFtn().IsEndNote() ;
140 : }
141 :
142 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|