1  /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 
32 #include <vcl/svapp.hxx>
33 #include <com/sun/star/accessibility/AccessibleRole.hpp>
34 #include <com/sun/star/uno/RuntimeException.hpp>
35 #include <rtl/uuid.h>
36 #include <flyfrm.hxx>
37 #include "accembedded.hxx"
38 
39 using namespace ::com::sun::star;
40 using namespace ::com::sun::star::lang;
41 using namespace ::com::sun::star::accessibility;
42 using ::rtl::OUString;
43 
44 const sal_Char sServiceName[] = "com.sun.star.text.AccessibleTextEmbeddedObject";
45 const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessibleEmbeddedObject";
46 
47 SwAccessibleEmbeddedObject::SwAccessibleEmbeddedObject(
48         SwAccessibleMap* pInitMap,
49         const SwFlyFrm* pFlyFrm  ) :
50     SwAccessibleNoTextFrame( pInitMap, AccessibleRole::EMBEDDED_OBJECT, pFlyFrm )
51 {
52 }
53 
54 SwAccessibleEmbeddedObject::~SwAccessibleEmbeddedObject()
55 {
56 }
57 
58 OUString SAL_CALL SwAccessibleEmbeddedObject::getImplementationName()
59         throw( uno::RuntimeException )
60 {
61 	return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationName));
62 }
63 
64 sal_Bool SAL_CALL SwAccessibleEmbeddedObject::supportsService(
65 		const ::rtl::OUString& sTestServiceName)
66     throw (uno::RuntimeException)
67 {
68 	return sTestServiceName.equalsAsciiL( sServiceName,
69 										  sizeof(sServiceName)-1 ) ||
70 		   sTestServiceName.equalsAsciiL( sAccessibleServiceName,
71 				   						  sizeof(sAccessibleServiceName)-1 );
72 }
73 
74 uno::Sequence< OUString > SAL_CALL SwAccessibleEmbeddedObject::getSupportedServiceNames()
75         throw( uno::RuntimeException )
76 {
77     uno::Sequence< OUString > aRet(2);
78 	OUString* pArray = aRet.getArray();
79 	pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceName) );
80 	pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) );
81 	return aRet;
82 }
83 
84 
85 uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleEmbeddedObject::getImplementationId()
86         throw(uno::RuntimeException)
87 {
88     vos::OGuard aGuard(Application::GetSolarMutex());
89     static uno::Sequence< sal_Int8 > aId( 16 );
90     static sal_Bool bInit = sal_False;
91     if(!bInit)
92     {
93         rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
94         bInit = sal_True;
95     }
96     return aId;
97 }
98