1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: accheaderfooter.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <vos/mutex.hxx>
36 #include <com/sun/star/accessibility/AccessibleRole.hpp>
37 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
38 #include <unotools/accessiblestatesethelper.hxx>
40 #include <vcl/svapp.hxx>
42 #include "accheaderfooter.hxx"
47 using namespace ::com::sun::star
;
48 using namespace ::com::sun::star::lang
;
49 using namespace ::com::sun::star::uno
;
50 using namespace ::com::sun::star::accessibility
;
51 using ::rtl::OUString
;
53 const sal_Char sServiceNameHeader
[] = "com.sun.star.text.AccessibleHeaderView";
54 const sal_Char sServiceNameFooter
[] = "com.sun.star.text.AccessibleFooterView";
55 const sal_Char sImplementationNameHeader
[] = "com.sun.star.comp.Writer.SwAccessibleHeaderView";
56 const sal_Char sImplementationNameFooter
[] = "com.sun.star.comp.Writer.SwAccessibleFooterView";
58 SwAccessibleHeaderFooter::SwAccessibleHeaderFooter(
59 SwAccessibleMap
* pInitMap
,
60 const SwHeaderFrm
* pHdFrm
) :
61 SwAccessibleContext( pInitMap
, AccessibleRole::HEADER
, pHdFrm
)
63 vos::OGuard
aGuard(Application::GetSolarMutex());
65 OUString
sArg( OUString::valueOf( (sal_Int32
)pHdFrm
->GetPhyPageNum() ) );
66 SetName( GetResource( STR_ACCESS_HEADER_NAME
, &sArg
) );
69 SwAccessibleHeaderFooter::SwAccessibleHeaderFooter(
70 SwAccessibleMap
* pInitMap
,
71 const SwFooterFrm
* pFtFrm
) :
72 SwAccessibleContext( pInitMap
, AccessibleRole::FOOTER
, pFtFrm
)
74 vos::OGuard
aGuard(Application::GetSolarMutex());
76 OUString
sArg( OUString::valueOf( (sal_Int32
)pFtFrm
->GetPhyPageNum() ) );
77 SetName( GetResource( STR_ACCESS_FOOTER_NAME
, &sArg
) );
80 SwAccessibleHeaderFooter::~SwAccessibleHeaderFooter()
84 OUString SAL_CALL
SwAccessibleHeaderFooter::getAccessibleDescription (void)
85 throw (uno::RuntimeException
)
87 vos::OGuard
aGuard(Application::GetSolarMutex());
89 CHECK_FOR_DEFUNC( XAccessibleContext
)
91 sal_uInt16 nResId
= AccessibleRole::HEADER
== GetRole()
92 ? STR_ACCESS_HEADER_DESC
93 : STR_ACCESS_FOOTER_DESC
;
95 OUString
sArg( GetFormattedPageNumber() );
97 return GetResource( nResId
, &sArg
);
100 OUString SAL_CALL
SwAccessibleHeaderFooter::getImplementationName()
101 throw( RuntimeException
)
103 if( AccessibleRole::HEADER
== GetRole() )
104 return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationNameHeader
));
106 return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationNameFooter
));
109 sal_Bool SAL_CALL
SwAccessibleHeaderFooter::supportsService(
110 const ::rtl::OUString
& sTestServiceName
)
111 throw (uno::RuntimeException
)
113 if( sTestServiceName
.equalsAsciiL( sAccessibleServiceName
,
114 sizeof(sAccessibleServiceName
)-1 ) )
116 else if( AccessibleRole::HEADER
== GetRole() )
117 return sTestServiceName
.equalsAsciiL( sServiceNameHeader
, sizeof(sServiceNameHeader
)-1 );
119 return sTestServiceName
.equalsAsciiL( sServiceNameFooter
, sizeof(sServiceNameFooter
)-1 );
123 Sequence
< OUString
> SAL_CALL
SwAccessibleHeaderFooter::getSupportedServiceNames()
124 throw( uno::RuntimeException
)
126 Sequence
< OUString
> aRet(2);
127 OUString
* pArray
= aRet
.getArray();
128 if( AccessibleRole::HEADER
== GetRole() )
129 pArray
[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceNameHeader
) );
131 pArray
[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceNameFooter
) );
132 pArray
[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName
) );
136 Sequence
< sal_Int8
> SAL_CALL
SwAccessibleHeaderFooter::getImplementationId()
137 throw(RuntimeException
)
139 vos::OGuard
aGuard(Application::GetSolarMutex());
140 static Sequence
< sal_Int8
> aId( 16 );
141 static sal_Bool bInit
= sal_False
;
144 rtl_createUuid( (sal_uInt8
*)(aId
.getArray() ), 0, sal_True
);