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>
23 #include <vcl/svapp.hxx>
24 #include <ftnfrm.hxx>
25 #include <fmtftn.hxx>
26 #include <txtftn.hxx>
27 #include <viewsh.hxx>
28 #include <accmap.hxx>
29 #include "accfootnote.hxx"
30 #include <strings.hrc>
31 
32 using namespace ::com::sun::star;
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::lang;
35 using namespace ::com::sun::star::accessibility;
36 
37 const sal_Char sImplementationNameFootnote[] = "com.sun.star.comp.Writer.SwAccessibleFootnoteView";
38 const sal_Char sImplementationNameEndnote[] = "com.sun.star.comp.Writer.SwAccessibleEndnoteView";
39 
41  std::shared_ptr<SwAccessibleMap> const& pInitMap,
42  bool bIsEndnote,
43  const SwFootnoteFrame *pFootnoteFrame ) :
44  SwAccessibleContext( pInitMap,
45  bIsEndnote ? AccessibleRole::END_NOTE : AccessibleRole::FOOTNOTE,
46  pFootnoteFrame )
47 {
48  const char* pResId = bIsEndnote ? STR_ACCESS_ENDNOTE_NAME
49  : STR_ACCESS_FOOTNOTE_NAME;
50 
51  OUString sArg;
52  const SwTextFootnote *pTextFootnote =
53  static_cast< const SwFootnoteFrame *>( GetFrame() )->GetAttr();
54  if( pTextFootnote )
55  {
56  const SwDoc *pDoc = GetShell()->GetDoc();
57  sArg = pTextFootnote->GetFootnote().GetViewNumStr(*pDoc, pFootnoteFrame->getRootFrame());
58  }
59 
60  SetName(GetResource(pResId, &sArg));
61 }
62 
64 {
65 }
66 
68 {
69  SolarMutexGuard aGuard;
70 
72 
73  const char* pResId = AccessibleRole::END_NOTE == GetRole()
74  ? STR_ACCESS_ENDNOTE_DESC
75  : STR_ACCESS_FOOTNOTE_DESC ;
76 
77  OUString sArg;
78  const SwTextFootnote *pTextFootnote =
79  static_cast< const SwFootnoteFrame *>( GetFrame() )->GetAttr();
80  if( pTextFootnote )
81  {
82  const SwDoc *pDoc = GetMap()->GetShell()->GetDoc();
83  sArg = pTextFootnote->GetFootnote().GetViewNumStr(*pDoc, GetFrame()->getRootFrame());
84  }
85 
86  return GetResource(pResId, &sArg);
87 }
88 
90 {
91  if( AccessibleRole::END_NOTE == GetRole() )
92  return OUString(sImplementationNameEndnote);
93  else
94  return OUString(sImplementationNameFootnote);
95 }
96 
97 sal_Bool SAL_CALL SwAccessibleFootnote::supportsService(const OUString& sTestServiceName)
98 {
99  return cppu::supportsService(this, sTestServiceName);
100 }
101 
103 {
104  Sequence< OUString > aRet(2);
105  OUString* pArray = aRet.getArray();
106  if( AccessibleRole::END_NOTE == GetRole() )
107  pArray[0] = "com.sun.star.text.AccessibleEndnoteView";
108  else
109  pArray[0] = "com.sun.star.text.AccessibleFootnoteView";
110  pArray[1] = sAccessibleServiceName;
111  return aRet;
112 }
113 
115 {
116  return css::uno::Sequence<sal_Int8>();
117 }
118 
120 {
121  const SwTextFootnote *pTextFootnote = pFootnoteFrame ->GetAttr();
122  return pTextFootnote && pTextFootnote->GetFootnote().IsEndNote() ;
123 }
124 
125 /* 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:73
OUString GetViewNumStr(const SwDoc &rDoc, SwRootFrame const *pLayout, bool bInclStrings=false) const
Returns string to be displayed of footnote / endnote.
Definition: atrftn.cxx:210
virtual ~SwAccessibleFootnote() override
Definition: accfootnote.cxx:63
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:89
virtual OUString SAL_CALL getAccessibleDescription() override
Return this object's description.
Definition: accfootnote.cxx:67
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:38
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:200
const sal_Char sImplementationNameFootnote[]
Definition: accfootnote.cxx:37
const SwTextFootnote * GetAttr() const
Definition: ftnfrm.hxx:107
SwAccessibleFootnote(std::shared_ptr< SwAccessibleMap > const &pInitMap, bool bIsEndnote, const SwFootnoteFrame *pFootnoteFrame)
Definition: accfootnote.cxx:40
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:97