1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <vos/mutex.hxx>
29cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
30cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
31cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
32cdf0e10cSrcweir #include <rtl/uuid.h>
33cdf0e10cSrcweir #include <vcl/svapp.hxx>
34cdf0e10cSrcweir #include <ftnfrm.hxx>
35cdf0e10cSrcweir #include <fmtftn.hxx>
36cdf0e10cSrcweir #include <txtftn.hxx>
37cdf0e10cSrcweir #include <viewsh.hxx>
38cdf0e10cSrcweir #include <accmap.hxx>
39cdf0e10cSrcweir #include "accfootnote.hxx"
40cdf0e10cSrcweir #ifndef _ACCESS_HRC
41cdf0e10cSrcweir #include "access.hrc"
42cdf0e10cSrcweir #endif
43cdf0e10cSrcweir 
44cdf0e10cSrcweir using namespace ::com::sun::star;
45cdf0e10cSrcweir using namespace ::com::sun::star::uno;
46cdf0e10cSrcweir using namespace ::com::sun::star::lang;
47cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
48cdf0e10cSrcweir using ::rtl::OUString;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir const sal_Char sServiceNameFootnote[] = "com.sun.star.text.AccessibleFootnoteView";
51cdf0e10cSrcweir const sal_Char sServiceNameEndnote[] = "com.sun.star.text.AccessibleEndnoteView";
52cdf0e10cSrcweir const sal_Char sImplementationNameFootnote[] = "com.sun.star.comp.Writer.SwAccessibleFootnoteView";
53cdf0e10cSrcweir const sal_Char sImplementationNameEndnote[] = "com.sun.star.comp.Writer.SwAccessibleEndnoteView";
54cdf0e10cSrcweir 
SwAccessibleFootnote(SwAccessibleMap * pInitMap,sal_Bool bIsEndnote,const SwFtnFrm * pFtnFrm)55cdf0e10cSrcweir SwAccessibleFootnote::SwAccessibleFootnote(
56cdf0e10cSrcweir         SwAccessibleMap* pInitMap,
57cdf0e10cSrcweir 		sal_Bool bIsEndnote,
58cdf0e10cSrcweir 		const SwFtnFrm *pFtnFrm	) :
59cdf0e10cSrcweir     SwAccessibleContext( pInitMap,
60cdf0e10cSrcweir 		bIsEndnote ? AccessibleRole::END_NOTE : AccessibleRole::FOOTNOTE,
61cdf0e10cSrcweir 		pFtnFrm )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	sal_uInt16 nResId = bIsEndnote ? STR_ACCESS_ENDNOTE_NAME
66cdf0e10cSrcweir 								   : STR_ACCESS_FOOTNOTE_NAME;
67*ca62e2c2SSteve Yin 	//OUString sArg( OUString::valueOf( nFootEndNote ) );
68*ca62e2c2SSteve Yin 	//old codes end
69*ca62e2c2SSteve Yin 	OUString sArg;
70*ca62e2c2SSteve Yin 	const SwTxtFtn *pTxtFtn =
71*ca62e2c2SSteve Yin 		static_cast< const SwFtnFrm *>( GetFrm() )->GetAttr();
72*ca62e2c2SSteve Yin 	if( pTxtFtn )
73*ca62e2c2SSteve Yin 	{
74*ca62e2c2SSteve Yin 		const SwDoc *pDoc = GetShell()->GetDoc();
75*ca62e2c2SSteve Yin 		sArg = pTxtFtn->GetFtn().GetViewNumStr( *pDoc );
76*ca62e2c2SSteve Yin 	}
77*ca62e2c2SSteve Yin 
78cdf0e10cSrcweir 	SetName( GetResource( nResId, &sArg ) );
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
~SwAccessibleFootnote()81cdf0e10cSrcweir SwAccessibleFootnote::~SwAccessibleFootnote()
82cdf0e10cSrcweir {
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
getAccessibleDescription(void)85cdf0e10cSrcweir OUString SAL_CALL SwAccessibleFootnote::getAccessibleDescription (void)
86cdf0e10cSrcweir         throw (uno::RuntimeException)
87cdf0e10cSrcweir {
88cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleContext )
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	sal_uInt16 nResId = AccessibleRole::END_NOTE == GetRole()
93cdf0e10cSrcweir 		? STR_ACCESS_ENDNOTE_DESC
94cdf0e10cSrcweir 		: STR_ACCESS_FOOTNOTE_DESC ;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	OUString sArg;
97cdf0e10cSrcweir 	const SwTxtFtn *pTxtFtn =
98cdf0e10cSrcweir 		static_cast< const SwFtnFrm *>( GetFrm() )->GetAttr();
99cdf0e10cSrcweir 	if( pTxtFtn )
100cdf0e10cSrcweir 	{
101cdf0e10cSrcweir 		const SwDoc *pDoc = GetMap()->GetShell()->GetDoc();
102cdf0e10cSrcweir 		sArg = pTxtFtn->GetFtn().GetViewNumStr( *pDoc );
103cdf0e10cSrcweir 	}
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	return GetResource( nResId, &sArg );
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
getImplementationName()108cdf0e10cSrcweir OUString SAL_CALL SwAccessibleFootnote::getImplementationName()
109cdf0e10cSrcweir         throw( RuntimeException )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir 	if( AccessibleRole::END_NOTE == GetRole() )
112cdf0e10cSrcweir 		return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationNameEndnote));
113cdf0e10cSrcweir 	else
114cdf0e10cSrcweir 		return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationNameFootnote));
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
supportsService(const::rtl::OUString & sTestServiceName)117cdf0e10cSrcweir sal_Bool SAL_CALL SwAccessibleFootnote::supportsService(
118cdf0e10cSrcweir 		const ::rtl::OUString& sTestServiceName)
119cdf0e10cSrcweir     throw (uno::RuntimeException)
120cdf0e10cSrcweir {
121cdf0e10cSrcweir 	if( sTestServiceName.equalsAsciiL( sAccessibleServiceName,
122cdf0e10cSrcweir 									   sizeof(sAccessibleServiceName)-1 ) )
123cdf0e10cSrcweir 		return sal_True;
124cdf0e10cSrcweir 	else if( AccessibleRole::END_NOTE == GetRole() )
125cdf0e10cSrcweir 		return sTestServiceName.equalsAsciiL( sServiceNameEndnote, sizeof(sServiceNameEndnote)-1 );
126cdf0e10cSrcweir 	else
127cdf0e10cSrcweir 		return sTestServiceName.equalsAsciiL( sServiceNameFootnote, sizeof(sServiceNameFootnote)-1 );
128cdf0e10cSrcweir 
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
getSupportedServiceNames()131cdf0e10cSrcweir Sequence< OUString > SAL_CALL SwAccessibleFootnote::getSupportedServiceNames()
132cdf0e10cSrcweir         throw( uno::RuntimeException )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir 	Sequence< OUString > aRet(2);
135cdf0e10cSrcweir 	OUString* pArray = aRet.getArray();
136cdf0e10cSrcweir 	if( AccessibleRole::END_NOTE == GetRole() )
137cdf0e10cSrcweir 		pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceNameEndnote) );
138cdf0e10cSrcweir 	else
139cdf0e10cSrcweir 		pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceNameFootnote) );
140cdf0e10cSrcweir 	pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) );
141cdf0e10cSrcweir 	return aRet;
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
getImplementationId()144cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL SwAccessibleFootnote::getImplementationId()
145cdf0e10cSrcweir 		throw(RuntimeException)
146cdf0e10cSrcweir {
147cdf0e10cSrcweir     vos::OGuard aGuard(Application::GetSolarMutex());
148cdf0e10cSrcweir     static Sequence< sal_Int8 > aId( 16 );
149cdf0e10cSrcweir     static sal_Bool bInit = sal_False;
150cdf0e10cSrcweir     if(!bInit)
151cdf0e10cSrcweir     {
152cdf0e10cSrcweir         rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
153cdf0e10cSrcweir         bInit = sal_True;
154cdf0e10cSrcweir     }
155cdf0e10cSrcweir     return aId;
156cdf0e10cSrcweir }
157cdf0e10cSrcweir 
IsEndnote(const SwFtnFrm * pFtnFrm)158cdf0e10cSrcweir sal_Bool SwAccessibleFootnote::IsEndnote( const SwFtnFrm *pFtnFrm )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir 	const SwTxtFtn *pTxtFtn = pFtnFrm ->GetAttr();
161cdf0e10cSrcweir 	return pTxtFtn && pTxtFtn->GetFtn().IsEndNote() ;
162cdf0e10cSrcweir }
163