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 <cppuhelper/supportsservice.hxx>
26 : #include <vcl/svapp.hxx>
27 : #include <ftnfrm.hxx>
28 : #include <fmtftn.hxx>
29 : #include <txtftn.hxx>
30 : #include <viewsh.hxx>
31 : #include <accmap.hxx>
32 : #include "accfootnote.hxx"
33 : #include "access.hrc"
34 :
35 : using namespace ::com::sun::star;
36 : using namespace ::com::sun::star::uno;
37 : using namespace ::com::sun::star::lang;
38 : using namespace ::com::sun::star::accessibility;
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 2 : SwAccessibleFootnote::SwAccessibleFootnote(
46 : SwAccessibleMap* pInitMap,
47 : bool bIsEndnote,
48 : const SwFtnFrm *pFtnFrm ) :
49 : SwAccessibleContext( pInitMap,
50 : bIsEndnote ? AccessibleRole::END_NOTE : AccessibleRole::FOOTNOTE,
51 2 : pFtnFrm )
52 : {
53 2 : SolarMutexGuard aGuard;
54 :
55 : sal_uInt16 nResId = bIsEndnote ? STR_ACCESS_ENDNOTE_NAME
56 2 : : STR_ACCESS_FOOTNOTE_NAME;
57 :
58 4 : OUString sArg;
59 : const SwTxtFtn *pTxtFtn =
60 2 : static_cast< const SwFtnFrm *>( GetFrm() )->GetAttr();
61 2 : if( pTxtFtn )
62 : {
63 2 : const SwDoc *pDoc = GetShell()->GetDoc();
64 2 : sArg = pTxtFtn->GetFtn().GetViewNumStr( *pDoc );
65 : }
66 :
67 4 : SetName( GetResource( nResId, &sArg ) );
68 2 : }
69 :
70 4 : SwAccessibleFootnote::~SwAccessibleFootnote()
71 : {
72 4 : }
73 :
74 14 : OUString SAL_CALL SwAccessibleFootnote::getAccessibleDescription (void)
75 : throw (uno::RuntimeException, std::exception)
76 : {
77 14 : SolarMutexGuard aGuard;
78 :
79 14 : CHECK_FOR_DEFUNC( XAccessibleContext )
80 :
81 14 : sal_uInt16 nResId = AccessibleRole::END_NOTE == GetRole()
82 : ? STR_ACCESS_ENDNOTE_DESC
83 14 : : STR_ACCESS_FOOTNOTE_DESC ;
84 :
85 28 : OUString sArg;
86 : const SwTxtFtn *pTxtFtn =
87 14 : static_cast< const SwFtnFrm *>( GetFrm() )->GetAttr();
88 14 : if( pTxtFtn )
89 : {
90 14 : const SwDoc *pDoc = GetMap()->GetShell()->GetDoc();
91 14 : sArg = pTxtFtn->GetFtn().GetViewNumStr( *pDoc );
92 : }
93 :
94 28 : return GetResource( nResId, &sArg );
95 : }
96 :
97 2 : OUString SAL_CALL SwAccessibleFootnote::getImplementationName()
98 : throw( RuntimeException, std::exception )
99 : {
100 2 : if( AccessibleRole::END_NOTE == GetRole() )
101 2 : return OUString(sImplementationNameEndnote);
102 : else
103 0 : return OUString(sImplementationNameFootnote);
104 : }
105 :
106 0 : sal_Bool SAL_CALL SwAccessibleFootnote::supportsService(const OUString& sTestServiceName)
107 : throw (uno::RuntimeException, std::exception)
108 : {
109 0 : return cppu::supportsService(this, sTestServiceName);
110 : }
111 :
112 0 : Sequence< OUString > SAL_CALL SwAccessibleFootnote::getSupportedServiceNames()
113 : throw( uno::RuntimeException, std::exception )
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( sServiceNameEndnote );
119 : else
120 0 : pArray[0] = OUString( sServiceNameFootnote );
121 0 : pArray[1] = OUString( sAccessibleServiceName );
122 0 : return aRet;
123 : }
124 :
125 0 : Sequence< sal_Int8 > SAL_CALL SwAccessibleFootnote::getImplementationId()
126 : throw(RuntimeException, std::exception)
127 : {
128 0 : return css::uno::Sequence<sal_Int8>();
129 : }
130 :
131 2 : bool SwAccessibleFootnote::IsEndnote( const SwFtnFrm *pFtnFrm )
132 : {
133 2 : const SwTxtFtn *pTxtFtn = pFtnFrm ->GetAttr();
134 2 : return pTxtFtn && pTxtFtn->GetFtn().IsEndNote() ;
135 270 : }
136 :
137 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|