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_editeng.hxx"
26
27 //------------------------------------------------------------------------
28 //
29 // Global header
30 //
31 //------------------------------------------------------------------------
32 #include <vos/mutex.hxx>
33 #include <com/sun/star/uno/Any.hxx>
34 #include <com/sun/star/uno/Reference.hxx>
35 #include <cppuhelper/weakref.hxx>
36 #include <com/sun/star/lang/XComponent.hpp>
37 #include <cppuhelper/typeprovider.hxx>
38
39
40 //------------------------------------------------------------------------
41 //
42 // Project-local header
43 //
44 //------------------------------------------------------------------------
45
46 #include <editeng/unopracc.hxx>
47 #include <editeng/unoedsrc.hxx>
48
49 using namespace ::com::sun::star;
50
51 //------------------------------------------------------------------------
52 //
53 // SvxAccessibleTextPropertySet implementation
54 //
55 //------------------------------------------------------------------------
56
SvxAccessibleTextPropertySet(const SvxEditSource * pEditSrc,const SvxItemPropertySet * pPropSet)57 SvxAccessibleTextPropertySet::SvxAccessibleTextPropertySet( const SvxEditSource* pEditSrc, const SvxItemPropertySet* pPropSet )
58 : SvxUnoTextRangeBase( pEditSrc, pPropSet )
59 {
60 }
61
~SvxAccessibleTextPropertySet()62 SvxAccessibleTextPropertySet::~SvxAccessibleTextPropertySet() throw()
63 {
64 }
65
getText()66 uno::Reference< text::XText > SAL_CALL SvxAccessibleTextPropertySet::getText() throw (uno::RuntimeException)
67 {
68 // TODO (empty?)
69 return uno::Reference< text::XText > ();
70 }
71
queryAggregation(const uno::Type &)72 uno::Any SAL_CALL SvxAccessibleTextPropertySet::queryAggregation( const uno::Type & ) throw(uno::RuntimeException)
73 {
74 // TODO (empty?)
75 return uno::Any();
76 }
77
queryInterface(const uno::Type & rType)78 uno::Any SAL_CALL SvxAccessibleTextPropertySet::queryInterface( const uno::Type & rType )
79 throw(uno::RuntimeException)
80 {
81 return OWeakObject::queryInterface(rType);
82 }
83
acquire()84 void SAL_CALL SvxAccessibleTextPropertySet::acquire()
85 throw()
86 {
87 OWeakObject::acquire();
88 }
89
release()90 void SAL_CALL SvxAccessibleTextPropertySet::release()
91 throw()
92 {
93 OWeakObject::release();
94 }
95
96 // XTypeProvider
getTypes()97 uno::Sequence< uno::Type > SAL_CALL SvxAccessibleTextPropertySet::getTypes() throw ( uno::RuntimeException )
98 {
99 static ::cppu::OTypeCollection* pTypeCollection = NULL ;
100
101 // double-checked locking pattern.
102 if ( pTypeCollection == NULL )
103 {
104 osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
105
106 // Control these pointer again ... it can be, that another instance will be faster then these!
107 if ( pTypeCollection == NULL )
108 {
109 // Create a static typecollection ...
110 static ::cppu::OTypeCollection aTypeCollection(
111 ::getCppuType( static_cast< const uno::Reference< beans::XPropertySet >* > (0) ),
112 ::getCppuType( static_cast< const uno::Reference< beans::XMultiPropertySet >* > (0) ),
113 ::getCppuType( static_cast< const uno::Reference< beans::XPropertyState >* > (0) ),
114 ::getCppuType( static_cast< const uno::Reference< lang::XServiceInfo >* > (0) ),
115 ::getCppuType( static_cast< const uno::Reference< lang::XTypeProvider >* > (0) ) );
116
117 // ... and set his address to static pointer!
118 pTypeCollection = &aTypeCollection ;
119 }
120 }
121
122 return pTypeCollection->getTypes() ;
123 }
124
getImplementationId()125 uno::Sequence< sal_Int8 > SAL_CALL SvxAccessibleTextPropertySet::getImplementationId()
126 throw (uno::RuntimeException)
127 {
128 static uno::Sequence< sal_Int8 > aId;
129 if( aId.getLength() == 0 )
130 {
131 aId.realloc( 16 );
132 rtl_createUuid( reinterpret_cast< sal_uInt8* > (aId.getArray()), 0, sal_True );
133 }
134 return aId;
135 }
136
137 // XServiceInfo
getImplementationName(void)138 ::rtl::OUString SAL_CALL SAL_CALL SvxAccessibleTextPropertySet::getImplementationName (void) throw (uno::RuntimeException)
139 {
140 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("SvxAccessibleTextPropertySet"));
141 }
142
supportsService(const::rtl::OUString & sServiceName)143 sal_Bool SAL_CALL SvxAccessibleTextPropertySet::supportsService (const ::rtl::OUString& sServiceName) throw (uno::RuntimeException)
144 {
145 // Iterate over all supported service names and return true if on of them
146 // matches the given name.
147 uno::Sequence< ::rtl::OUString> aSupportedServices (
148 getSupportedServiceNames ());
149 for (int i=0; i<aSupportedServices.getLength(); i++)
150 if (sServiceName == aSupportedServices[i])
151 return sal_True;
152 return sal_False;
153 }
154
getSupportedServiceNames(void)155 uno::Sequence< ::rtl::OUString> SAL_CALL SvxAccessibleTextPropertySet::getSupportedServiceNames (void) throw (uno::RuntimeException)
156 {
157 // TODO
158 return SvxUnoTextRangeBase::getSupportedServiceNames();
159 }
160
161 // XServiceName
getServiceName()162 ::rtl::OUString SAL_CALL SvxAccessibleTextPropertySet::getServiceName() throw (uno::RuntimeException)
163 {
164 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.beans.PropertyValue"));
165 }
166
167
168