1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <vcl/svapp.hxx>
29 #include <com/sun/star/accessibility/AccessibleRole.hpp>
30 #include <com/sun/star/uno/RuntimeException.hpp>
31 #include <rtl/uuid.h>
32 #include <flyfrm.hxx>
33 #include "accembedded.hxx"
34 
35 using namespace ::com::sun::star;
36 using namespace ::com::sun::star::lang;
37 using namespace ::com::sun::star::accessibility;
38 using ::rtl::OUString;
39 
40 const sal_Char sServiceName[] = "com.sun.star.text.AccessibleTextEmbeddedObject";
41 const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessibleEmbeddedObject";
42 
43 SwAccessibleEmbeddedObject::SwAccessibleEmbeddedObject(
44         SwAccessibleMap* pInitMap,
45         const SwFlyFrm* pFlyFrm  ) :
46     SwAccessibleNoTextFrame( pInitMap, AccessibleRole::EMBEDDED_OBJECT, pFlyFrm )
47 {
48 }
49 
50 SwAccessibleEmbeddedObject::~SwAccessibleEmbeddedObject()
51 {
52 }
53 
54 OUString SAL_CALL SwAccessibleEmbeddedObject::getImplementationName()
55         throw( uno::RuntimeException )
56 {
57 	return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationName));
58 }
59 
60 sal_Bool SAL_CALL SwAccessibleEmbeddedObject::supportsService(
61 		const ::rtl::OUString& sTestServiceName)
62     throw (uno::RuntimeException)
63 {
64 	return sTestServiceName.equalsAsciiL( sServiceName,
65 										  sizeof(sServiceName)-1 ) ||
66 		   sTestServiceName.equalsAsciiL( sAccessibleServiceName,
67 				   						  sizeof(sAccessibleServiceName)-1 );
68 }
69 
70 uno::Sequence< OUString > SAL_CALL SwAccessibleEmbeddedObject::getSupportedServiceNames()
71         throw( uno::RuntimeException )
72 {
73     uno::Sequence< OUString > aRet(2);
74 	OUString* pArray = aRet.getArray();
75 	pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceName) );
76 	pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) );
77 	return aRet;
78 }
79 
80 
81 uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleEmbeddedObject::getImplementationId()
82         throw(uno::RuntimeException)
83 {
84     vos::OGuard aGuard(Application::GetSolarMutex());
85     static uno::Sequence< sal_Int8 > aId( 16 );
86     static sal_Bool bInit = sal_False;
87     if(!bInit)
88     {
89         rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
90         bInit = sal_True;
91     }
92     return aId;
93 }
94