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>
21 #include <cppuhelper/supportsservice.hxx>
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 constexpr OUStringLiteral sImplementationNameHeader
33 = u"com.sun.star.comp.Writer.SwAccessibleHeaderView";
34 constexpr OUStringLiteral sImplementationNameFooter
35 = u"com.sun.star.comp.Writer.SwAccessibleFooterView";
36
SwAccessibleHeaderFooter(std::shared_ptr<SwAccessibleMap> const & pInitMap,const SwHeaderFrame * pHdFrame)37 SwAccessibleHeaderFooter::SwAccessibleHeaderFooter(
38 std::shared_ptr<SwAccessibleMap> const& pInitMap,
39 const SwHeaderFrame* pHdFrame ) :
40 SwAccessibleContext( pInitMap, AccessibleRole::HEADER, pHdFrame )
41 {
42 OUString sArg( OUString::number( pHdFrame->GetPhyPageNum() ) );
43 SetName( GetResource( STR_ACCESS_HEADER_NAME, &sArg ) );
44 }
45
SwAccessibleHeaderFooter(std::shared_ptr<SwAccessibleMap> const & pInitMap,const SwFooterFrame * pFtFrame)46 SwAccessibleHeaderFooter::SwAccessibleHeaderFooter(
47 std::shared_ptr<SwAccessibleMap> const& pInitMap,
48 const SwFooterFrame* pFtFrame ) :
49 SwAccessibleContext( pInitMap, AccessibleRole::FOOTER, pFtFrame )
50 {
51 OUString sArg( OUString::number( pFtFrame->GetPhyPageNum() ) );
52 SetName( GetResource( STR_ACCESS_FOOTER_NAME, &sArg ) );
53 }
54
~SwAccessibleHeaderFooter()55 SwAccessibleHeaderFooter::~SwAccessibleHeaderFooter()
56 {
57 }
58
getAccessibleDescription()59 OUString SAL_CALL SwAccessibleHeaderFooter::getAccessibleDescription()
60 {
61 SolarMutexGuard aGuard;
62
63 ThrowIfDisposed();
64
65 const char* pResId = AccessibleRole::HEADER == GetRole()
66 ? STR_ACCESS_HEADER_DESC
67 : STR_ACCESS_FOOTER_DESC ;
68
69 OUString sArg( GetFormattedPageNumber() );
70
71 return GetResource(pResId, &sArg);
72 }
73
getImplementationName()74 OUString SAL_CALL SwAccessibleHeaderFooter::getImplementationName()
75 {
76 if( AccessibleRole::HEADER == GetRole() )
77 return sImplementationNameHeader;
78 else
79 return sImplementationNameFooter;
80 }
81
supportsService(const OUString & sTestServiceName)82 sal_Bool SAL_CALL SwAccessibleHeaderFooter::supportsService(const OUString& sTestServiceName)
83 {
84 return cppu::supportsService(this, sTestServiceName);
85 }
86
getSupportedServiceNames()87 Sequence< OUString > SAL_CALL SwAccessibleHeaderFooter::getSupportedServiceNames()
88 {
89 return { (AccessibleRole::HEADER == GetRole())?OUString("com.sun.star.text.AccessibleHeaderView"):OUString("com.sun.star.text.AccessibleFooterView"),
90 sAccessibleServiceName };
91 }
92
getImplementationId()93 Sequence< sal_Int8 > SAL_CALL SwAccessibleHeaderFooter::getImplementationId()
94 {
95 return css::uno::Sequence<sal_Int8>();
96 }
97
getBackground()98 sal_Int32 SAL_CALL SwAccessibleHeaderFooter::getBackground()
99 {
100 Reference< XAccessible > xParent = getAccessibleParent();
101 if (xParent.is())
102 {
103 Reference< XAccessibleComponent > xAccContext (xParent,UNO_QUERY);
104 if(xAccContext.is())
105 {
106 return xAccContext->getBackground();
107 }
108 }
109 return SwAccessibleContext::getBackground();
110 }
111
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
113