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 const sal_Char sImplementationNameFootnote[] = "com.sun.star.comp.Writer.SwAccessibleFootnoteView";
37 const sal_Char sImplementationNameEndnote[] = "com.sun.star.comp.Writer.SwAccessibleEndnoteView";
38 
40  std::shared_ptr<SwAccessibleMap> const& pInitMap,
41  bool bIsEndnote,
42  const SwFootnoteFrame *pFootnoteFrame ) :
43  SwAccessibleContext( pInitMap,
44  bIsEndnote ? AccessibleRole::END_NOTE : AccessibleRole::FOOTNOTE,
45  pFootnoteFrame )
46 {
47  const char* pResId = bIsEndnote ? STR_ACCESS_ENDNOTE_NAME
48  : STR_ACCESS_FOOTNOTE_NAME;
49 
50  OUString sArg;
51  const SwTextFootnote *pTextFootnote =
52  static_cast< const SwFootnoteFrame *>( GetFrame() )->GetAttr();
53  if( pTextFootnote )
54  {
55  const SwDoc *pDoc = GetShell()->GetDoc();
56  sArg = pTextFootnote->GetFootnote().GetViewNumStr(*pDoc, pFootnoteFrame->getRootFrame());
57  }
58 
59  SetName(GetResource(pResId, &sArg));
60 }
61 
63 {
64 }
65 
67 {
68  SolarMutexGuard aGuard;
69 
71 
72  const char* pResId = AccessibleRole::END_NOTE == GetRole()
73  ? STR_ACCESS_ENDNOTE_DESC
74  : STR_ACCESS_FOOTNOTE_DESC ;
75 
76  OUString sArg;
77  const SwTextFootnote *pTextFootnote =
78  static_cast< const SwFootnoteFrame *>( GetFrame() )->GetAttr();
79  if( pTextFootnote )
80  {
81  const SwDoc *pDoc = GetMap()->GetShell()->GetDoc();
82  sArg = pTextFootnote->GetFootnote().GetViewNumStr(*pDoc, GetFrame()->getRootFrame());
83  }
84 
85  return GetResource(pResId, &sArg);
86 }
87 
89 {
90  if( AccessibleRole::END_NOTE == GetRole() )
92  else
94 }
95 
96 sal_Bool SAL_CALL SwAccessibleFootnote::supportsService(const OUString& sTestServiceName)
97 {
98  return cppu::supportsService(this, sTestServiceName);
99 }
100 
102 {
103  return { (AccessibleRole::END_NOTE == GetRole())?OUString("com.sun.star.text.AccessibleEndnoteView"):OUString("com.sun.star.text.AccessibleFootnoteView"),
105 }
106 
108 {
109  return css::uno::Sequence<sal_Int8>();
110 }
111 
113 {
114  const SwTextFootnote *pTextFootnote = pFootnoteFrame ->GetAttr();
115  return pTextFootnote && pTextFootnote->GetFootnote().IsEndNote() ;
116 }
117 
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int16 GetRole() const
Definition: acccontext.hxx:100
static OUString GetResource(const char *pResId, const OUString *pArg1=nullptr, const OUString *pArg2=nullptr)
const sal_Char sAccessibleServiceName[]
Definition: acccontext.hxx:43
static bool IsEndnote(const SwFootnoteFrame *pFrame)
Definition: doc.hxx:185
SwViewShell * GetShell()
convenience method to get the SwViewShell through accessibility map
Definition: acccontext.hxx:116
bool IsEndNote() const
Definition: fmtftn.hxx:74
OUString GetViewNumStr(const SwDoc &rDoc, SwRootFrame const *pLayout, bool bInclStrings=false) const
Returns string to be displayed of footnote / endnote.
Definition: atrftn.cxx:213
virtual ~SwAccessibleFootnote() override
Definition: accfootnote.cxx:62
SwViewShell * GetShell() const
Definition: accmap.hxx:169
const SwFrame * GetFrame() const
Definition: accframe.hxx:103
char sal_Char
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: accfootnote.cxx:88
virtual OUString SAL_CALL getAccessibleDescription() override
Return this object's description.
Definition: accfootnote.cxx:66
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Returns a list of all supported services.
unsigned char sal_Bool
const sal_Char sImplementationNameEndnote[]
Definition: accfootnote.cxx:37
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:200
const sal_Char sImplementationNameFootnote[]
Definition: accfootnote.cxx:36
const SwTextFootnote * GetAttr() const
Definition: ftnfrm.hxx:107
SwAccessibleFootnote(std::shared_ptr< SwAccessibleMap > const &pInitMap, bool bIsEndnote, const SwFootnoteFrame *pFootnoteFrame)
Definition: accfootnote.cxx:39
SwAccessibleMap * GetMap()
Definition: acccontext.hxx:112
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
void SetName(const OUString &rName)
Definition: acccontext.hxx:99
SwRootFrame * getRootFrame()
Definition: frame.hxx:657
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
Definition: accfootnote.cxx:96