Update ooo320-m1
[ooovba.git] / sw / source / core / access / accfootnote.cxx
blobf3d9ca1db2b4debe1de3913feeb650e6887fb9fd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: accfootnote.cxx,v $
10 * $Revision: 1.16 $
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>
39 #include <rtl/uuid.h>
40 #include <vcl/svapp.hxx>
41 #include <ftnfrm.hxx>
42 #include <fmtftn.hxx>
43 #include <txtftn.hxx>
44 #include <viewsh.hxx>
45 #include <accmap.hxx>
46 #include "accfootnote.hxx"
47 #ifndef _ACCESS_HRC
48 #include "access.hrc"
49 #endif
51 using namespace ::com::sun::star;
52 using namespace ::com::sun::star::uno;
53 using namespace ::com::sun::star::lang;
54 using namespace ::com::sun::star::accessibility;
55 using ::rtl::OUString;
57 const sal_Char sServiceNameFootnote[] = "com.sun.star.text.AccessibleFootnoteView";
58 const sal_Char sServiceNameEndnote[] = "com.sun.star.text.AccessibleEndnoteView";
59 const sal_Char sImplementationNameFootnote[] = "com.sun.star.comp.Writer.SwAccessibleFootnoteView";
60 const sal_Char sImplementationNameEndnote[] = "com.sun.star.comp.Writer.SwAccessibleEndnoteView";
62 SwAccessibleFootnote::SwAccessibleFootnote(
63 SwAccessibleMap* pInitMap,
64 sal_Bool bIsEndnote,
65 sal_Int32 nFootEndNote,
66 const SwFtnFrm *pFtnFrm ) :
67 SwAccessibleContext( pInitMap,
68 bIsEndnote ? AccessibleRole::END_NOTE : AccessibleRole::FOOTNOTE,
69 pFtnFrm )
71 vos::OGuard aGuard(Application::GetSolarMutex());
73 sal_uInt16 nResId = bIsEndnote ? STR_ACCESS_ENDNOTE_NAME
74 : STR_ACCESS_FOOTNOTE_NAME;
75 OUString sArg( OUString::valueOf( nFootEndNote ) );
76 SetName( GetResource( nResId, &sArg ) );
79 SwAccessibleFootnote::~SwAccessibleFootnote()
83 OUString SAL_CALL SwAccessibleFootnote::getAccessibleDescription (void)
84 throw (uno::RuntimeException)
86 vos::OGuard aGuard(Application::GetSolarMutex());
88 CHECK_FOR_DEFUNC( XAccessibleContext )
90 sal_uInt16 nResId = AccessibleRole::END_NOTE == GetRole()
91 ? STR_ACCESS_ENDNOTE_DESC
92 : STR_ACCESS_FOOTNOTE_DESC ;
94 OUString sArg;
95 const SwTxtFtn *pTxtFtn =
96 static_cast< const SwFtnFrm *>( GetFrm() )->GetAttr();
97 if( pTxtFtn )
99 const SwDoc *pDoc = GetMap()->GetShell()->GetDoc();
100 sArg = pTxtFtn->GetFtn().GetViewNumStr( *pDoc );
103 return GetResource( nResId, &sArg );
106 OUString SAL_CALL SwAccessibleFootnote::getImplementationName()
107 throw( RuntimeException )
109 if( AccessibleRole::END_NOTE == GetRole() )
110 return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationNameEndnote));
111 else
112 return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationNameFootnote));
115 sal_Bool SAL_CALL SwAccessibleFootnote::supportsService(
116 const ::rtl::OUString& sTestServiceName)
117 throw (uno::RuntimeException)
119 if( sTestServiceName.equalsAsciiL( sAccessibleServiceName,
120 sizeof(sAccessibleServiceName)-1 ) )
121 return sal_True;
122 else if( AccessibleRole::END_NOTE == GetRole() )
123 return sTestServiceName.equalsAsciiL( sServiceNameEndnote, sizeof(sServiceNameEndnote)-1 );
124 else
125 return sTestServiceName.equalsAsciiL( sServiceNameFootnote, sizeof(sServiceNameFootnote)-1 );
129 Sequence< OUString > SAL_CALL SwAccessibleFootnote::getSupportedServiceNames()
130 throw( uno::RuntimeException )
132 Sequence< OUString > aRet(2);
133 OUString* pArray = aRet.getArray();
134 if( AccessibleRole::END_NOTE == GetRole() )
135 pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceNameEndnote) );
136 else
137 pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceNameFootnote) );
138 pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) );
139 return aRet;
142 Sequence< sal_Int8 > SAL_CALL SwAccessibleFootnote::getImplementationId()
143 throw(RuntimeException)
145 vos::OGuard aGuard(Application::GetSolarMutex());
146 static Sequence< sal_Int8 > aId( 16 );
147 static sal_Bool bInit = sal_False;
148 if(!bInit)
150 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
151 bInit = sal_True;
153 return aId;
156 sal_Bool SwAccessibleFootnote::IsEndnote( const SwFtnFrm *pFtnFrm )
158 const SwTxtFtn *pTxtFtn = pFtnFrm ->GetAttr();
159 return pTxtFtn && pTxtFtn->GetFtn().IsEndNote() ;