1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/accessibility/AccessibleRole.hpp>
21 #include <cppuhelper/supportsservice.hxx>
22 #include <vcl/svapp.hxx>
28 #include "accfootnote.hxx"
29 #include <strings.hrc>
31 using namespace ::com::sun::star
;
32 using namespace ::com::sun::star::uno
;
33 using namespace ::com::sun::star::lang
;
34 using namespace ::com::sun::star::accessibility
;
36 constexpr OUStringLiteral sImplementationNameFootnote
37 = u
"com.sun.star.comp.Writer.SwAccessibleFootnoteView";
38 constexpr OUStringLiteral sImplementationNameEndnote
39 = u
"com.sun.star.comp.Writer.SwAccessibleEndnoteView";
41 SwAccessibleFootnote::SwAccessibleFootnote(
42 std::shared_ptr
<SwAccessibleMap
> const& pInitMap
,
44 const SwFootnoteFrame
*pFootnoteFrame
) :
45 SwAccessibleContext( pInitMap
,
46 bIsEndnote
? AccessibleRole::END_NOTE
: AccessibleRole::FOOTNOTE
,
49 TranslateId pResId
= bIsEndnote
? STR_ACCESS_ENDNOTE_NAME
50 : STR_ACCESS_FOOTNOTE_NAME
;
53 const SwTextFootnote
*pTextFootnote
=
54 static_cast< const SwFootnoteFrame
*>( GetFrame() )->GetAttr();
57 const SwDoc
*pDoc
= GetShell()->GetDoc();
58 sArg
= pTextFootnote
->GetFootnote().GetViewNumStr(*pDoc
, pFootnoteFrame
->getRootFrame());
61 SetName(GetResource(pResId
, &sArg
));
64 SwAccessibleFootnote::~SwAccessibleFootnote()
68 OUString SAL_CALL
SwAccessibleFootnote::getAccessibleDescription()
70 SolarMutexGuard aGuard
;
74 TranslateId pResId
= AccessibleRole::END_NOTE
== GetRole()
75 ? STR_ACCESS_ENDNOTE_DESC
76 : STR_ACCESS_FOOTNOTE_DESC
;
79 const SwTextFootnote
*pTextFootnote
=
80 static_cast< const SwFootnoteFrame
*>( GetFrame() )->GetAttr();
83 const SwDoc
*pDoc
= GetMap()->GetShell()->GetDoc();
84 sArg
= pTextFootnote
->GetFootnote().GetViewNumStr(*pDoc
, GetFrame()->getRootFrame());
87 return GetResource(pResId
, &sArg
);
90 OUString SAL_CALL
SwAccessibleFootnote::getImplementationName()
92 if( AccessibleRole::END_NOTE
== GetRole() )
93 return sImplementationNameEndnote
;
95 return sImplementationNameFootnote
;
98 sal_Bool SAL_CALL
SwAccessibleFootnote::supportsService(const OUString
& sTestServiceName
)
100 return cppu::supportsService(this, sTestServiceName
);
103 Sequence
< OUString
> SAL_CALL
SwAccessibleFootnote::getSupportedServiceNames()
105 return { (AccessibleRole::END_NOTE
== GetRole())?OUString("com.sun.star.text.AccessibleEndnoteView"):OUString("com.sun.star.text.AccessibleFootnoteView"),
106 sAccessibleServiceName
};
109 Sequence
< sal_Int8
> SAL_CALL
SwAccessibleFootnote::getImplementationId()
111 return css::uno::Sequence
<sal_Int8
>();
114 bool SwAccessibleFootnote::IsEndnote( const SwFootnoteFrame
*pFootnoteFrame
)
116 const SwTextFootnote
*pTextFootnote
= pFootnoteFrame
->GetAttr();
117 return pTextFootnote
&& pTextFootnote
->GetFootnote().IsEndNote() ;
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */