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