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>
23 #include <vcl/svapp.hxx>
24 #include <hffrm.hxx>
25 #include "accheaderfooter.hxx"
26 #include <strings.hrc>
27 
28 using namespace ::com::sun::star;
29 using namespace ::com::sun::star::lang;
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::accessibility;
32 
33 const sal_Char sImplementationNameHeader[] = "com.sun.star.comp.Writer.SwAccessibleHeaderView";
34 const sal_Char sImplementationNameFooter[] = "com.sun.star.comp.Writer.SwAccessibleFooterView";
35 
37  std::shared_ptr<SwAccessibleMap> const& pInitMap,
38  const SwHeaderFrame* pHdFrame ) :
39  SwAccessibleContext( pInitMap, AccessibleRole::HEADER, pHdFrame )
40 {
41  OUString sArg( OUString::number( pHdFrame->GetPhyPageNum() ) );
42  SetName( GetResource( STR_ACCESS_HEADER_NAME, &sArg ) );
43 }
44 
46  std::shared_ptr<SwAccessibleMap> const& pInitMap,
47  const SwFooterFrame* pFtFrame ) :
48  SwAccessibleContext( pInitMap, AccessibleRole::FOOTER, pFtFrame )
49 {
50  OUString sArg( OUString::number( pFtFrame->GetPhyPageNum() ) );
51  SetName( GetResource( STR_ACCESS_FOOTER_NAME, &sArg ) );
52 }
53 
55 {
56 }
57 
59 {
60  SolarMutexGuard aGuard;
61 
63 
64  const char* pResId = AccessibleRole::HEADER == GetRole()
65  ? STR_ACCESS_HEADER_DESC
66  : STR_ACCESS_FOOTER_DESC ;
67 
68  OUString sArg( GetFormattedPageNumber() );
69 
70  return GetResource(pResId, &sArg);
71 }
72 
74 {
75  if( AccessibleRole::HEADER == GetRole() )
77  else
79 }
80 
81 sal_Bool SAL_CALL SwAccessibleHeaderFooter::supportsService(const OUString& sTestServiceName)
82 {
83  return cppu::supportsService(this, sTestServiceName);
84 }
85 
87 {
88  return { (AccessibleRole::HEADER == GetRole())?OUString("com.sun.star.text.AccessibleHeaderView"):OUString("com.sun.star.text.AccessibleFooterView"),
90 }
91 
93 {
94  return css::uno::Sequence<sal_Int8>();
95 }
96 
98 {
99  Reference< XAccessible > xParent = getAccessibleParent();
100  if (xParent.is())
101  {
102  Reference< XAccessibleComponent > xAccContext (xParent,UNO_QUERY);
103  if(xAccContext.is())
104  {
105  return xAccContext->getBackground();
106  }
107  }
109 }
110 
111 /* 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:644
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:965
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1689
OUString GetFormattedPageNumber() const
Definition: accframe.cxx:433
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.