1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/accessibility/AccessibleRole.hpp>
21 #include <cppuhelper/supportsservice.hxx>
22 #include <vcl/svapp.hxx>
24 #include "accheaderfooter.hxx"
25 #include <strings.hrc>
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
;
32 constexpr OUStringLiteral sImplementationNameHeader
33 = u
"com.sun.star.comp.Writer.SwAccessibleHeaderView";
34 constexpr OUStringLiteral sImplementationNameFooter
35 = u
"com.sun.star.comp.Writer.SwAccessibleFooterView";
37 SwAccessibleHeaderFooter::SwAccessibleHeaderFooter(
38 std::shared_ptr
<SwAccessibleMap
> const& pInitMap
,
39 const SwHeaderFrame
* pHdFrame
) :
40 SwAccessibleContext( pInitMap
, AccessibleRole::HEADER
, pHdFrame
)
42 OUString
sArg( OUString::number( pHdFrame
->GetPhyPageNum() ) );
43 SetName( GetResource( STR_ACCESS_HEADER_NAME
, &sArg
) );
46 SwAccessibleHeaderFooter::SwAccessibleHeaderFooter(
47 std::shared_ptr
<SwAccessibleMap
> const& pInitMap
,
48 const SwFooterFrame
* pFtFrame
) :
49 SwAccessibleContext( pInitMap
, AccessibleRole::FOOTER
, pFtFrame
)
51 OUString
sArg( OUString::number( pFtFrame
->GetPhyPageNum() ) );
52 SetName( GetResource( STR_ACCESS_FOOTER_NAME
, &sArg
) );
55 SwAccessibleHeaderFooter::~SwAccessibleHeaderFooter()
59 OUString SAL_CALL
SwAccessibleHeaderFooter::getAccessibleDescription()
61 SolarMutexGuard aGuard
;
65 TranslateId pResId
= AccessibleRole::HEADER
== GetRole()
66 ? STR_ACCESS_HEADER_DESC
67 : STR_ACCESS_FOOTER_DESC
;
69 OUString
sArg( GetFormattedPageNumber() );
71 return GetResource(pResId
, &sArg
);
74 OUString SAL_CALL
SwAccessibleHeaderFooter::getImplementationName()
76 if( AccessibleRole::HEADER
== GetRole() )
77 return sImplementationNameHeader
;
79 return sImplementationNameFooter
;
82 sal_Bool SAL_CALL
SwAccessibleHeaderFooter::supportsService(const OUString
& sTestServiceName
)
84 return cppu::supportsService(this, sTestServiceName
);
87 Sequence
< OUString
> SAL_CALL
SwAccessibleHeaderFooter::getSupportedServiceNames()
89 return { (AccessibleRole::HEADER
== GetRole())?OUString("com.sun.star.text.AccessibleHeaderView"):OUString("com.sun.star.text.AccessibleFooterView"),
90 sAccessibleServiceName
};
93 Sequence
< sal_Int8
> SAL_CALL
SwAccessibleHeaderFooter::getImplementationId()
95 return css::uno::Sequence
<sal_Int8
>();
98 sal_Int32 SAL_CALL
SwAccessibleHeaderFooter::getBackground()
100 Reference
< XAccessible
> xParent
= getAccessibleParent();
103 Reference
< XAccessibleComponent
> xAccContext (xParent
,UNO_QUERY
);
106 return xAccContext
->getBackground();
109 return SwAccessibleContext::getBackground();
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */