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