Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <osl/mutex.hxx>
30 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
31 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
32 : : #include <unotools/accessiblestatesethelper.hxx>
33 : : #include <comphelper/servicehelper.hxx>
34 : : #include <vcl/svapp.hxx>
35 : : #include <hffrm.hxx>
36 : : #include "accheaderfooter.hxx"
37 : : #include "access.hrc"
38 : :
39 : : using namespace ::com::sun::star;
40 : : using namespace ::com::sun::star::lang;
41 : : using namespace ::com::sun::star::uno;
42 : : using namespace ::com::sun::star::accessibility;
43 : : using ::rtl::OUString;
44 : :
45 : : const sal_Char sServiceNameHeader[] = "com.sun.star.text.AccessibleHeaderView";
46 : : const sal_Char sServiceNameFooter[] = "com.sun.star.text.AccessibleFooterView";
47 : : const sal_Char sImplementationNameHeader[] = "com.sun.star.comp.Writer.SwAccessibleHeaderView";
48 : : const sal_Char sImplementationNameFooter[] = "com.sun.star.comp.Writer.SwAccessibleFooterView";
49 : :
50 : 0 : SwAccessibleHeaderFooter::SwAccessibleHeaderFooter(
51 : : SwAccessibleMap* pInitMap,
52 : : const SwHeaderFrm* pHdFrm ) :
53 : 0 : SwAccessibleContext( pInitMap, AccessibleRole::HEADER, pHdFrm )
54 : : {
55 [ # # ]: 0 : SolarMutexGuard aGuard;
56 : :
57 [ # # ]: 0 : OUString sArg( OUString::valueOf( (sal_Int32)pHdFrm->GetPhyPageNum() ) );
58 [ # # ][ # # ]: 0 : SetName( GetResource( STR_ACCESS_HEADER_NAME, &sArg ) );
59 : 0 : }
60 : :
61 : 0 : SwAccessibleHeaderFooter::SwAccessibleHeaderFooter(
62 : : SwAccessibleMap* pInitMap,
63 : : const SwFooterFrm* pFtFrm ) :
64 : 0 : SwAccessibleContext( pInitMap, AccessibleRole::FOOTER, pFtFrm )
65 : : {
66 [ # # ]: 0 : SolarMutexGuard aGuard;
67 : :
68 [ # # ]: 0 : OUString sArg( OUString::valueOf( (sal_Int32)pFtFrm->GetPhyPageNum() ) );
69 [ # # ][ # # ]: 0 : SetName( GetResource( STR_ACCESS_FOOTER_NAME, &sArg ) );
70 : 0 : }
71 : :
72 : 0 : SwAccessibleHeaderFooter::~SwAccessibleHeaderFooter()
73 : : {
74 [ # # ]: 0 : }
75 : :
76 : 0 : OUString SAL_CALL SwAccessibleHeaderFooter::getAccessibleDescription (void)
77 : : throw (uno::RuntimeException)
78 : : {
79 [ # # ]: 0 : SolarMutexGuard aGuard;
80 : :
81 [ # # ][ # # ]: 0 : CHECK_FOR_DEFUNC( XAccessibleContext )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
82 : :
83 : 0 : sal_uInt16 nResId = AccessibleRole::HEADER == GetRole()
84 : : ? STR_ACCESS_HEADER_DESC
85 [ # # ]: 0 : : STR_ACCESS_FOOTER_DESC ;
86 : :
87 [ # # ][ # # ]: 0 : OUString sArg( GetFormattedPageNumber() );
[ # # ]
88 : :
89 [ # # ][ # # ]: 0 : return GetResource( nResId, &sArg );
90 : : }
91 : :
92 : 0 : OUString SAL_CALL SwAccessibleHeaderFooter::getImplementationName()
93 : : throw( RuntimeException )
94 : : {
95 [ # # ]: 0 : if( AccessibleRole::HEADER == GetRole() )
96 : 0 : return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationNameHeader));
97 : : else
98 : 0 : return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationNameFooter));
99 : : }
100 : :
101 : 0 : sal_Bool SAL_CALL SwAccessibleHeaderFooter::supportsService(
102 : : const ::rtl::OUString& sTestServiceName)
103 : : throw (uno::RuntimeException)
104 : : {
105 [ # # ]: 0 : if( sTestServiceName.equalsAsciiL( sAccessibleServiceName,
106 : 0 : sizeof(sAccessibleServiceName)-1 ) )
107 : 0 : return sal_True;
108 [ # # ]: 0 : else if( AccessibleRole::HEADER == GetRole() )
109 : 0 : return sTestServiceName.equalsAsciiL( sServiceNameHeader, sizeof(sServiceNameHeader)-1 );
110 : : else
111 : 0 : return sTestServiceName.equalsAsciiL( sServiceNameFooter, sizeof(sServiceNameFooter)-1 );
112 : :
113 : : }
114 : :
115 : 0 : Sequence< OUString > SAL_CALL SwAccessibleHeaderFooter::getSupportedServiceNames()
116 : : throw( uno::RuntimeException )
117 : : {
118 : 0 : Sequence< OUString > aRet(2);
119 [ # # ]: 0 : OUString* pArray = aRet.getArray();
120 [ # # ]: 0 : if( AccessibleRole::HEADER == GetRole() )
121 [ # # ]: 0 : pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceNameHeader) );
122 : : else
123 [ # # ]: 0 : pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceNameFooter) );
124 [ # # ]: 0 : pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) );
125 : 0 : return aRet;
126 : : }
127 : :
128 : : namespace
129 : : {
130 : : class theSwAccessibleHeaderFooterImplementationId : public rtl::Static< UnoTunnelIdInit, theSwAccessibleHeaderFooterImplementationId > {};
131 : : }
132 : :
133 : 0 : Sequence< sal_Int8 > SAL_CALL SwAccessibleHeaderFooter::getImplementationId()
134 : : throw(RuntimeException)
135 : : {
136 : 0 : return theSwAccessibleHeaderFooterImplementationId::get().getSeq();
137 : : }
138 : :
139 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|