xref: /trunk/main/sw/source/core/access/accembedded.cxx (revision 4d7c9de0)
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 #include "cntfrm.hxx"
35 #include "ndole.hxx"
36 #include <doc.hxx>
37 #include <docsh.hxx>
38 #include <../../ui/inc/wrtsh.hxx>
39 #include <../../ui/inc/view.hxx>
40 
41 using namespace ::com::sun::star;
42 using namespace ::com::sun::star::lang;
43 using namespace ::com::sun::star::accessibility;
44 using ::rtl::OUString;
45 
46 const sal_Char sServiceName[] = "com.sun.star.text.AccessibleTextEmbeddedObject";
47 const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessibleEmbeddedObject";
48 
SwAccessibleEmbeddedObject(SwAccessibleMap * pInitMap,const SwFlyFrm * pFlyFrm)49 SwAccessibleEmbeddedObject::SwAccessibleEmbeddedObject(
50         SwAccessibleMap* pInitMap,
51         const SwFlyFrm* pFlyFrm  ) :
52     SwAccessibleNoTextFrame( pInitMap, AccessibleRole::EMBEDDED_OBJECT, pFlyFrm )
53 {
54 }
55 
~SwAccessibleEmbeddedObject()56 SwAccessibleEmbeddedObject::~SwAccessibleEmbeddedObject()
57 {
58 }
59 
60 //=====  XInterface  ==========================================================
61 com::sun::star::uno::Any SAL_CALL
queryInterface(const com::sun::star::uno::Type & rType)62     SwAccessibleEmbeddedObject::queryInterface (const com::sun::star::uno::Type & rType)
63     throw (::com::sun::star::uno::RuntimeException)
64 {
65     ::com::sun::star::uno::Any aReturn = SwAccessibleNoTextFrame::queryInterface (rType);
66     if ( ! aReturn.hasValue())
67         aReturn = ::cppu::queryInterface (rType,
68 	     static_cast< ::com::sun::star::accessibility::XAccessibleExtendedAttributes* >(this) );
69     return aReturn;
70 }
71 
72 void SAL_CALL
acquire(void)73     SwAccessibleEmbeddedObject::acquire (void)
74     throw ()
75 {
76     SwAccessibleNoTextFrame::acquire ();
77 }
78 
79 void SAL_CALL
release(void)80     SwAccessibleEmbeddedObject::release (void)
81     throw ()
82 {
83     SwAccessibleNoTextFrame::release ();
84 }
85 
getImplementationName()86 OUString SAL_CALL SwAccessibleEmbeddedObject::getImplementationName()
87         throw( uno::RuntimeException )
88 {
89 	return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationName));
90 }
91 
supportsService(const::rtl::OUString & sTestServiceName)92 sal_Bool SAL_CALL SwAccessibleEmbeddedObject::supportsService(
93 		const ::rtl::OUString& sTestServiceName)
94     throw (uno::RuntimeException)
95 {
96 	return sTestServiceName.equalsAsciiL( sServiceName,
97 										  sizeof(sServiceName)-1 ) ||
98 		   sTestServiceName.equalsAsciiL( sAccessibleServiceName,
99 				   						  sizeof(sAccessibleServiceName)-1 );
100 }
101 
getSupportedServiceNames()102 uno::Sequence< OUString > SAL_CALL SwAccessibleEmbeddedObject::getSupportedServiceNames()
103         throw( uno::RuntimeException )
104 {
105     uno::Sequence< OUString > aRet(2);
106 	OUString* pArray = aRet.getArray();
107 	pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceName) );
108 	pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) );
109 	return aRet;
110 }
111 
112 
getImplementationId()113 uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleEmbeddedObject::getImplementationId()
114         throw(uno::RuntimeException)
115 {
116     vos::OGuard aGuard(Application::GetSolarMutex());
117     static uno::Sequence< sal_Int8 > aId( 16 );
118     static sal_Bool bInit = sal_False;
119     if(!bInit)
120     {
121         rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
122         bInit = sal_True;
123     }
124     return aId;
125 }
126 //=====  XAccessibleExtendedAttributes  ========================================================
getExtendedAttributes()127 ::com::sun::star::uno::Any SAL_CALL SwAccessibleEmbeddedObject::getExtendedAttributes()
128 		throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
129 {
130 	::com::sun::star::uno::Any strRet;
131 	::rtl::OUString style;
132 	SwFlyFrm* pFFrm = getFlyFrm();
133 
134 	if( pFFrm )
135 	{
136 		style = ::rtl::OUString::createFromAscii("style:");
137 		SwCntntFrm* pCFrm;
138 		pCFrm = pFFrm->ContainsCntnt();
139 		if( pCFrm )
140 		{
141 			SwCntntNode* pCNode = pCFrm->GetNode();
142 			if( pCNode )
143 			{
144 				style += ((SwOLENode*)pCNode)->GetOLEObj().GetStyleString();
145 			}
146 		}
147 		style += ::rtl::OUString::createFromAscii(";");
148 	}
149 	strRet <<= style;
150 	return strRet;
151 }
152