LibreOffice Module sw (master)  1
accheaderfooter.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 <hffrm.hxx>
24 #include "accheaderfooter.hxx"
25 #include <strings.hrc>
26 
27 using namespace ::com::sun::star;
28 using namespace ::com::sun::star::lang;
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::accessibility;
31 
32 const sal_Char sImplementationNameHeader[] = "com.sun.star.comp.Writer.SwAccessibleHeaderView";
33 const sal_Char sImplementationNameFooter[] = "com.sun.star.comp.Writer.SwAccessibleFooterView";
34 
36  std::shared_ptr<SwAccessibleMap> const& pInitMap,
37  const SwHeaderFrame* pHdFrame ) :
38  SwAccessibleContext( pInitMap, AccessibleRole::HEADER, pHdFrame )
39 {
40  OUString sArg( OUString::number( pHdFrame->GetPhyPageNum() ) );
41  SetName( GetResource( STR_ACCESS_HEADER_NAME, &sArg ) );
42 }
43 
45  std::shared_ptr<SwAccessibleMap> const& pInitMap,
46  const SwFooterFrame* pFtFrame ) :
47  SwAccessibleContext( pInitMap, AccessibleRole::FOOTER, pFtFrame )
48 {
49  OUString sArg( OUString::number( pFtFrame->GetPhyPageNum() ) );
50  SetName( GetResource( STR_ACCESS_FOOTER_NAME, &sArg ) );
51 }
52 
54 {
55 }
56 
58 {
59  SolarMutexGuard aGuard;
60 
62 
63  const char* pResId = AccessibleRole::HEADER == GetRole()
64  ? STR_ACCESS_HEADER_DESC
65  : STR_ACCESS_FOOTER_DESC ;
66 
67  OUString sArg( GetFormattedPageNumber() );
68 
69  return GetResource(pResId, &sArg);
70 }
71 
73 {
74  if( AccessibleRole::HEADER == GetRole() )
76  else
78 }
79 
80 sal_Bool SAL_CALL SwAccessibleHeaderFooter::supportsService(const OUString& sTestServiceName)
81 {
82  return cppu::supportsService(this, sTestServiceName);
83 }
84 
86 {
87  return { (AccessibleRole::HEADER == GetRole())?OUString("com.sun.star.text.AccessibleHeaderView"):OUString("com.sun.star.text.AccessibleFooterView"),
89 }
90 
92 {
93  return css::uno::Sequence<sal_Int8>();
94 }
95 
97 {
98  Reference< XAccessible > xParent = getAccessibleParent();
99  if (xParent.is())
100  {
101  Reference< XAccessibleComponent > xAccContext (xParent,UNO_QUERY);
102  if(xAccContext.is())
103  {
104  return xAccContext->getBackground();
105  }
106  }
108 }
109 
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int16 GetRole() const
Definition: acccontext.hxx:100
const sal_Char sImplementationNameHeader[]
sal_Int32 SAL_CALL getBackground() override
static OUString GetResource(const char *pResId, const OUString *pArg1=nullptr, const OUString *pArg2=nullptr)
Header in the document layout, inside a page.
Definition: hffrm.hxx:43
const sal_Char sAccessibleServiceName[]
Definition: acccontext.hxx:43
char sal_Char
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual OUString SAL_CALL getAccessibleDescription() override
Return this object's description.
virtual ~SwAccessibleHeaderFooter() override
unsigned char sal_Bool
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
Definition: acccontext.cxx:641
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Returns a list of all supported services.
virtual sal_Int32 SAL_CALL getBackground() override
Definition: acccontext.cxx:962
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1689
OUString GetFormattedPageNumber() const
Definition: accframe.cxx:427
const sal_Char sImplementationNameFooter[]
SwAccessibleHeaderFooter(std::shared_ptr< SwAccessibleMap > const &pInitMap, const SwHeaderFrame *pHdFrame)
Footer in the document layout, inside a page.
Definition: hffrm.hxx:50
void SetName(const OUString &rName)
Definition: acccontext.hxx:99
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.