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()
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 & )
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 {
80 return OWeakObject::queryInterface(rType);
81 }
82
acquire()83 void SAL_CALL SvxAccessibleTextPropertySet::acquire()
84 throw()
85 {
86 OWeakObject::acquire();
87 }
88
release()89 void SAL_CALL SvxAccessibleTextPropertySet::release()
90 throw()
91 {
92 OWeakObject::release();
93 }
94
95 // XTypeProvider
getTypes()96 uno::Sequence< uno::Type > SAL_CALL SvxAccessibleTextPropertySet::getTypes()
97 {
98 static ::cppu::OTypeCollection* pTypeCollection = NULL ;
99
100 // double-checked locking pattern.
101 if ( pTypeCollection == NULL )
102 {
103 osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
104
105 // Control these pointer again ... it can be, that another instance will be faster then these!
106 if ( pTypeCollection == NULL )
107 {
108 // Create a static typecollection ...
109 static ::cppu::OTypeCollection aTypeCollection(
110 ::getCppuType( static_cast< const uno::Reference< beans::XPropertySet >* > (0) ),
111 ::getCppuType( static_cast< const uno::Reference< beans::XMultiPropertySet >* > (0) ),
112 ::getCppuType( static_cast< const uno::Reference< beans::XPropertyState >* > (0) ),
113 ::getCppuType( static_cast< const uno::Reference< lang::XServiceInfo >* > (0) ),
114 ::getCppuType( static_cast< const uno::Reference< lang::XTypeProvider >* > (0) ) );
115
116 // ... and set his address to static pointer!
117 pTypeCollection = &aTypeCollection ;
118 }
119 }
120
121 return pTypeCollection->getTypes() ;
122 }
123
getImplementationId()124 uno::Sequence< sal_Int8 > SAL_CALL SvxAccessibleTextPropertySet::getImplementationId()
125 {
126 static uno::Sequence< sal_Int8 > aId;
127 if( aId.getLength() == 0 )
128 {
129 aId.realloc( 16 );
130 rtl_createUuid( reinterpret_cast< sal_uInt8* > (aId.getArray()), 0, sal_True );
131 }
132 return aId;
133 }
134
135 // XServiceInfo
getImplementationName(void)136 ::rtl::OUString SAL_CALL SAL_CALL SvxAccessibleTextPropertySet::getImplementationName (void)
137 {
138 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("SvxAccessibleTextPropertySet"));
139 }
140
supportsService(const::rtl::OUString & sServiceName)141 sal_Bool SAL_CALL SvxAccessibleTextPropertySet::supportsService (const ::rtl::OUString& sServiceName)
142 {
143 // Iterate over all supported service names and return true if on of them
144 // matches the given name.
145 uno::Sequence< ::rtl::OUString> aSupportedServices (
146 getSupportedServiceNames ());
147 for (int i=0; i<aSupportedServices.getLength(); i++)
148 if (sServiceName == aSupportedServices[i])
149 return sal_True;
150 return sal_False;
151 }
152
getSupportedServiceNames(void)153 uno::Sequence< ::rtl::OUString> SAL_CALL SvxAccessibleTextPropertySet::getSupportedServiceNames (void)
154 {
155 // TODO
156 return SvxUnoTextRangeBase::getSupportedServiceNames();
157 }
158
159 // XServiceName
getServiceName()160 ::rtl::OUString SAL_CALL SvxAccessibleTextPropertySet::getServiceName()
161 {
162 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.beans.PropertyValue"));
163 }
164