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 
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;
35 
36 constexpr OUStringLiteral sImplementationNameFootnote
37  = u"com.sun.star.comp.Writer.SwAccessibleFootnoteView";
38 constexpr 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 
98 sal_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 
109 Sequence< 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: */
sal_Int16 GetRole() const
Definition: acccontext.hxx:103
static bool IsEndnote(const SwFootnoteFrame *pFrame)
Definition: doc.hxx:188
SwViewShell * GetShell()
convenience method to get the SwViewShell through accessibility map
Definition: acccontext.hxx:119
bool IsEndNote() const
Definition: fmtftn.hxx:71
OUString GetViewNumStr(const SwDoc &rDoc, SwRootFrame const *pLayout, bool bInclStrings=false) const
Returns string to be displayed of footnote / endnote.
Definition: atrftn.cxx:217
virtual ~SwAccessibleFootnote() override
Definition: accfootnote.cxx:64
SwViewShell * GetShell() const
Definition: accmap.hxx:169
const SwFrame * GetFrame() const
Definition: accframe.hxx:103
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr OUStringLiteral sAccessibleServiceName
Definition: acccontext.hxx:45
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
FOOTNOTE
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: accfootnote.cxx:90
virtual OUString SAL_CALL getAccessibleDescription() override
Return this object's description.
Definition: accfootnote.cxx:68
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Returns a list of all supported services.
static OUString GetResource(TranslateId pResId, const OUString *pArg1=nullptr, const OUString *pArg2=nullptr)
constexpr OUStringLiteral sImplementationNameEndnote
Definition: accfootnote.cxx:39
float u
unsigned char sal_Bool
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:204
constexpr OUStringLiteral sImplementationNameFootnote
Definition: accfootnote.cxx:37
const SwTextFootnote * GetAttr() const
Definition: ftnfrm.hxx:122
SwAccessibleFootnote(std::shared_ptr< SwAccessibleMap > const &pInitMap, bool bIsEndnote, const SwFootnoteFrame *pFootnoteFrame)
Definition: accfootnote.cxx:41
SwAccessibleMap * GetMap()
Definition: acccontext.hxx:115
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
void SetName(const OUString &rName)
Definition: acccontext.hxx:102
SwRootFrame * getRootFrame()
Definition: frame.hxx:680
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
Definition: accfootnote.cxx:98