Line data Source code
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 <osl/mutex.hxx>
21 : #include <com/sun/star/accessibility/AccessibleRole.hpp>
22 : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
23 : #include <unotools/accessiblestatesethelper.hxx>
24 : #include <comphelper/servicehelper.hxx>
25 : #include <cppuhelper/supportsservice.hxx>
26 : #include <vcl/svapp.hxx>
27 : #include <hffrm.hxx>
28 : #include "accheaderfooter.hxx"
29 : #include "access.hrc"
30 :
31 : using namespace ::com::sun::star;
32 : using namespace ::com::sun::star::lang;
33 : using namespace ::com::sun::star::uno;
34 : using namespace ::com::sun::star::accessibility;
35 :
36 : const sal_Char sImplementationNameHeader[] = "com.sun.star.comp.Writer.SwAccessibleHeaderView";
37 : const sal_Char sImplementationNameFooter[] = "com.sun.star.comp.Writer.SwAccessibleFooterView";
38 :
39 0 : SwAccessibleHeaderFooter::SwAccessibleHeaderFooter(
40 : SwAccessibleMap* pInitMap,
41 : const SwHeaderFrm* pHdFrm ) :
42 0 : SwAccessibleContext( pInitMap, AccessibleRole::HEADER, pHdFrm )
43 : {
44 0 : SolarMutexGuard aGuard;
45 :
46 0 : OUString sArg( OUString::number( pHdFrm->GetPhyPageNum() ) );
47 0 : SetName( GetResource( STR_ACCESS_HEADER_NAME, &sArg ) );
48 0 : }
49 :
50 0 : SwAccessibleHeaderFooter::SwAccessibleHeaderFooter(
51 : SwAccessibleMap* pInitMap,
52 : const SwFooterFrm* pFtFrm ) :
53 0 : SwAccessibleContext( pInitMap, AccessibleRole::FOOTER, pFtFrm )
54 : {
55 0 : SolarMutexGuard aGuard;
56 :
57 0 : OUString sArg( OUString::number( pFtFrm->GetPhyPageNum() ) );
58 0 : SetName( GetResource( STR_ACCESS_FOOTER_NAME, &sArg ) );
59 0 : }
60 :
61 0 : SwAccessibleHeaderFooter::~SwAccessibleHeaderFooter()
62 : {
63 0 : }
64 :
65 0 : OUString SAL_CALL SwAccessibleHeaderFooter::getAccessibleDescription (void)
66 : throw (uno::RuntimeException, std::exception)
67 : {
68 0 : SolarMutexGuard aGuard;
69 :
70 0 : CHECK_FOR_DEFUNC( XAccessibleContext )
71 :
72 0 : sal_uInt16 nResId = AccessibleRole::HEADER == GetRole()
73 : ? STR_ACCESS_HEADER_DESC
74 0 : : STR_ACCESS_FOOTER_DESC ;
75 :
76 0 : OUString sArg( GetFormattedPageNumber() );
77 :
78 0 : return GetResource( nResId, &sArg );
79 : }
80 :
81 0 : OUString SAL_CALL SwAccessibleHeaderFooter::getImplementationName()
82 : throw( RuntimeException, std::exception )
83 : {
84 0 : if( AccessibleRole::HEADER == GetRole() )
85 0 : return OUString(sImplementationNameHeader);
86 : else
87 0 : return OUString(sImplementationNameFooter);
88 : }
89 :
90 0 : sal_Bool SAL_CALL SwAccessibleHeaderFooter::supportsService(const OUString& sTestServiceName)
91 : throw (uno::RuntimeException, std::exception)
92 : {
93 0 : return cppu::supportsService(this, sTestServiceName);
94 : }
95 :
96 0 : Sequence< OUString > SAL_CALL SwAccessibleHeaderFooter::getSupportedServiceNames()
97 : throw( uno::RuntimeException, std::exception )
98 : {
99 0 : Sequence< OUString > aRet(2);
100 0 : OUString* pArray = aRet.getArray();
101 0 : if( AccessibleRole::HEADER == GetRole() )
102 0 : pArray[0] = "com.sun.star.text.AccessibleHeaderView";
103 : else
104 0 : pArray[0] = "com.sun.star.text.AccessibleFooterView";
105 0 : pArray[1] = OUString( sAccessibleServiceName );
106 0 : return aRet;
107 : }
108 :
109 0 : Sequence< sal_Int8 > SAL_CALL SwAccessibleHeaderFooter::getImplementationId()
110 : throw(RuntimeException, std::exception)
111 : {
112 0 : return css::uno::Sequence<sal_Int8>();
113 : }
114 :
115 0 : sal_Int32 SAL_CALL SwAccessibleHeaderFooter::getBackground()
116 : throw (::com::sun::star::uno::RuntimeException, std::exception)
117 : {
118 0 : Reference< XAccessible > xParent = getAccessibleParent();
119 0 : if (xParent.is())
120 : {
121 0 : Reference< XAccessibleComponent > xAccContext (xParent,UNO_QUERY);
122 0 : if(xAccContext.is())
123 : {
124 0 : return xAccContext->getBackground();
125 0 : }
126 : }
127 0 : return SwAccessibleContext::getBackground();
128 : }
129 :
130 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|