LibreOffice Module sw (master) 1
accfootnote.cxx
Go to the documentation of this file.
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 <com/sun/star/accessibility/AccessibleRole.hpp>
22#include <vcl/svapp.hxx>
23#include <ftnfrm.hxx>
24#include <fmtftn.hxx>
25#include <txtftn.hxx>
26#include <viewsh.hxx>
27#include <accmap.hxx>
28#include "accfootnote.hxx"
29#include <strings.hrc>
30
31using namespace ::com::sun::star;
32using namespace ::com::sun::star::uno;
33using namespace ::com::sun::star::lang;
34using namespace ::com::sun::star::accessibility;
35
36constexpr OUStringLiteral sImplementationNameFootnote
37 = u"com.sun.star.comp.Writer.SwAccessibleFootnoteView";
38constexpr OUStringLiteral sImplementationNameEndnote
39 = u"com.sun.star.comp.Writer.SwAccessibleEndnoteView";
40
42 std::shared_ptr<SwAccessibleMap> const& pInitMap,
43 bool bIsEndnote,
44 const SwFootnoteFrame *pFootnoteFrame ) :
45 SwAccessibleContext( pInitMap,
46 bIsEndnote ? AccessibleRole::END_NOTE : AccessibleRole::FOOTNOTE,
47 pFootnoteFrame )
48{
49 TranslateId pResId = bIsEndnote ? STR_ACCESS_ENDNOTE_NAME
50 : STR_ACCESS_FOOTNOTE_NAME;
51
52 OUString sArg;
53 const SwTextFootnote *pTextFootnote =
54 static_cast< const SwFootnoteFrame *>( GetFrame() )->GetAttr();
55 if( pTextFootnote )
56 {
57 const SwDoc *pDoc = GetShell()->GetDoc();
58 sArg = pTextFootnote->GetFootnote().GetViewNumStr(*pDoc, pFootnoteFrame->getRootFrame());
59 }
60
61 SetName(GetResource(pResId, &sArg));
62}
63
65{
66}
67
69{
70 SolarMutexGuard aGuard;
71
73
74 TranslateId pResId = AccessibleRole::END_NOTE == GetRole()
75 ? STR_ACCESS_ENDNOTE_DESC
76 : STR_ACCESS_FOOTNOTE_DESC ;
77
78 OUString sArg;
79 const SwTextFootnote *pTextFootnote =
80 static_cast< const SwFootnoteFrame *>( GetFrame() )->GetAttr();
81 if( pTextFootnote )
82 {
83 const SwDoc *pDoc = GetMap()->GetShell()->GetDoc();
84 sArg = pTextFootnote->GetFootnote().GetViewNumStr(*pDoc, GetFrame()->getRootFrame());
85 }
86
87 return GetResource(pResId, &sArg);
88}
89
91{
92 if( AccessibleRole::END_NOTE == GetRole() )
94 else
96}
97
98sal_Bool SAL_CALL SwAccessibleFootnote::supportsService(const OUString& sTestServiceName)
99{
100 return cppu::supportsService(this, sTestServiceName);
101}
102
104{
105 return { (AccessibleRole::END_NOTE == GetRole())?OUString("com.sun.star.text.AccessibleEndnoteView"):OUString("com.sun.star.text.AccessibleFootnoteView"),
107}
108
109Sequence< sal_Int8 > SAL_CALL SwAccessibleFootnote::getImplementationId()
110{
111 return css::uno::Sequence<sal_Int8>();
112}
113
115{
116 const SwTextFootnote *pTextFootnote = pFootnoteFrame ->GetAttr();
117 return pTextFootnote && pTextFootnote->GetFootnote().IsEndNote() ;
118}
119
120/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OUStringLiteral sAccessibleServiceName
Definition: acccontext.hxx:42
constexpr OUStringLiteral sImplementationNameEndnote
Definition: accfootnote.cxx:39
constexpr OUStringLiteral sImplementationNameFootnote
Definition: accfootnote.cxx:37
void SetName(const OUString &rName)
Definition: acccontext.hxx:99
sal_Int16 GetRole() const
Definition: acccontext.hxx:100
SwAccessibleMap * GetMap()
Definition: acccontext.hxx:112
static OUString GetResource(TranslateId pResId, const OUString *pArg1=nullptr, const OUString *pArg2=nullptr)
SwViewShell * GetShell()
convenience method to get the SwViewShell through accessibility map
Definition: acccontext.hxx:116
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
Definition: accfootnote.cxx:98
virtual OUString SAL_CALL getAccessibleDescription() override
Return this object's description.
Definition: accfootnote.cxx:68
static bool IsEndnote(const SwFootnoteFrame *pFrame)
virtual ~SwAccessibleFootnote() override
Definition: accfootnote.cxx:64
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: accfootnote.cxx:90
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
SwAccessibleFootnote(std::shared_ptr< SwAccessibleMap > const &pInitMap, bool bIsEndnote, const SwFootnoteFrame *pFootnoteFrame)
Definition: accfootnote.cxx:41
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Returns a list of all supported services.
const SwFrame * GetFrame() const
Definition: accframe.hxx:102
SwViewShell * GetShell() const
Definition: accmap.hxx:173
Definition: doc.hxx:197
Represents one footnote or endnote in the layout.
Definition: ftnfrm.hxx:84
const SwTextFootnote * GetAttr() const
Definition: ftnfrm.hxx:126
OUString GetViewNumStr(const SwDoc &rDoc, SwRootFrame const *pLayout, bool bInclStrings=false) const
Returns string to be displayed of footnote / endnote.
Definition: atrftn.cxx:218
bool IsEndNote() const
Definition: fmtftn.hxx:75
SwRootFrame * getRootFrame()
Definition: frame.hxx:685
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:208
SwTextAttr subclass for footnotes and endnotes.
Definition: txtftn.hxx:34
SwDoc * GetDoc() const
Definition: viewsh.hxx:308
float u
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
FOOTNOTE
unsigned char sal_Bool