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 1 : SwAccessibleFootnote::SwAccessibleFootnote(
46 : SwAccessibleMap* pInitMap,
47 : bool bIsEndnote,
48 : const SwFootnoteFrm *pFootnoteFrm ) :
49 : SwAccessibleContext( pInitMap,
50 : bIsEndnote ? AccessibleRole::END_NOTE : AccessibleRole::FOOTNOTE,
51 1 : pFootnoteFrm )
52 : {
53 1 : SolarMutexGuard aGuard;
54 :
55 : sal_uInt16 nResId = bIsEndnote ? STR_ACCESS_ENDNOTE_NAME
56 1 : : STR_ACCESS_FOOTNOTE_NAME;
57 :
58 2 : OUString sArg;
59 : const SwTextFootnote *pTextFootnote =
60 1 : static_cast< const SwFootnoteFrm *>( GetFrm() )->GetAttr();
61 1 : if( pTextFootnote )
62 : {
63 1 : const SwDoc *pDoc = GetShell()->GetDoc();
64 1 : sArg = pTextFootnote->GetFootnote().GetViewNumStr( *pDoc );
65 : }
66 :
67 2 : SetName( GetResource( nResId, &sArg ) );
68 1 : }
69 :
70 2 : SwAccessibleFootnote::~SwAccessibleFootnote()
71 : {
72 2 : }
73 :
74 7 : OUString SAL_CALL SwAccessibleFootnote::getAccessibleDescription()
75 : throw (uno::RuntimeException, std::exception)
76 : {
77 7 : SolarMutexGuard aGuard;
78 :
79 7 : CHECK_FOR_DEFUNC( XAccessibleContext )
80 :
81 7 : sal_uInt16 nResId = AccessibleRole::END_NOTE == GetRole()
82 : ? STR_ACCESS_ENDNOTE_DESC
83 7 : : STR_ACCESS_FOOTNOTE_DESC ;
84 :
85 14 : OUString sArg;
86 : const SwTextFootnote *pTextFootnote =
87 7 : static_cast< const SwFootnoteFrm *>( GetFrm() )->GetAttr();
88 7 : if( pTextFootnote )
89 : {
90 7 : const SwDoc *pDoc = GetMap()->GetShell()->GetDoc();
91 7 : sArg = pTextFootnote->GetFootnote().GetViewNumStr( *pDoc );
92 : }
93 :
94 14 : return GetResource( nResId, &sArg );
95 : }
96 :
97 1 : OUString SAL_CALL SwAccessibleFootnote::getImplementationName()
98 : throw( RuntimeException, std::exception )
99 : {
100 1 : if( AccessibleRole::END_NOTE == GetRole() )
101 1 : 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] = sServiceNameEndnote;
119 : else
120 0 : pArray[0] = sServiceNameFootnote;
121 0 : pArray[1] = 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 1 : bool SwAccessibleFootnote::IsEndnote( const SwFootnoteFrm *pFootnoteFrm )
132 : {
133 1 : const SwTextFootnote *pTextFootnote = pFootnoteFrm ->GetAttr();
134 1 : return pTextFootnote && pTextFootnote->GetFootnote().IsEndNote() ;
135 177 : }
136 :
137 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|