1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unopracc.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 //------------------------------------------------------------------------
38 //------------------------------------------------------------------------
39 #include <vos/mutex.hxx>
40 #include <com/sun/star/uno/Any.hxx>
41 #include <com/sun/star/uno/Reference.hxx>
42 #include <cppuhelper/weakref.hxx>
43 #include <com/sun/star/lang/XComponent.hpp>
44 #include <cppuhelper/typeprovider.hxx>
47 //------------------------------------------------------------------------
49 // Project-local header
51 //------------------------------------------------------------------------
53 #ifndef _SVX_UNOPRACC_HXX_
54 #include "unopracc.hxx"
56 #include <svx/unoedsrc.hxx>
58 using namespace ::com::sun::star
;
60 //------------------------------------------------------------------------
62 // SvxAccessibleTextPropertySet implementation
64 //------------------------------------------------------------------------
66 SvxAccessibleTextPropertySet::SvxAccessibleTextPropertySet( const SvxEditSource
* pEditSrc
, const SvxItemPropertySet
* pPropSet
)
67 : SvxUnoTextRangeBase( pEditSrc
, pPropSet
)
71 SvxAccessibleTextPropertySet::~SvxAccessibleTextPropertySet() throw()
75 uno::Reference
< text::XText
> SAL_CALL
SvxAccessibleTextPropertySet::getText() throw (uno::RuntimeException
)
78 return uno::Reference
< text::XText
> ();
81 uno::Any SAL_CALL
SvxAccessibleTextPropertySet::queryAggregation( const uno::Type
& ) throw(uno::RuntimeException
)
87 uno::Any SAL_CALL
SvxAccessibleTextPropertySet::queryInterface( const uno::Type
& rType
)
88 throw(uno::RuntimeException
)
90 return OWeakObject::queryInterface(rType
);
93 void SAL_CALL
SvxAccessibleTextPropertySet::acquire()
96 OWeakObject::acquire();
99 void SAL_CALL
SvxAccessibleTextPropertySet::release()
102 OWeakObject::release();
106 uno::Sequence
< uno::Type
> SAL_CALL
SvxAccessibleTextPropertySet::getTypes() throw ( uno::RuntimeException
)
108 static ::cppu::OTypeCollection
* pTypeCollection
= NULL
;
110 // double-checked locking pattern.
111 if ( pTypeCollection
== NULL
)
113 osl::MutexGuard
aGuard( osl::Mutex::getGlobalMutex() ) ;
115 // Control these pointer again ... it can be, that another instance will be faster then these!
116 if ( pTypeCollection
== NULL
)
118 // Create a static typecollection ...
119 static ::cppu::OTypeCollection
aTypeCollection(
120 ::getCppuType( static_cast< const uno::Reference
< beans::XPropertySet
>* > (0) ),
121 ::getCppuType( static_cast< const uno::Reference
< beans::XMultiPropertySet
>* > (0) ),
122 ::getCppuType( static_cast< const uno::Reference
< beans::XPropertyState
>* > (0) ),
123 ::getCppuType( static_cast< const uno::Reference
< lang::XServiceInfo
>* > (0) ),
124 ::getCppuType( static_cast< const uno::Reference
< lang::XTypeProvider
>* > (0) ) );
126 // ... and set his address to static pointer!
127 pTypeCollection
= &aTypeCollection
;
131 return pTypeCollection
->getTypes() ;
134 uno::Sequence
< sal_Int8
> SAL_CALL
SvxAccessibleTextPropertySet::getImplementationId()
135 throw (uno::RuntimeException
)
137 static uno::Sequence
< sal_Int8
> aId
;
138 if( aId
.getLength() == 0 )
141 rtl_createUuid( reinterpret_cast< sal_uInt8
* > (aId
.getArray()), 0, sal_True
);
147 ::rtl::OUString SAL_CALL SAL_CALL
SvxAccessibleTextPropertySet::getImplementationName (void) throw (uno::RuntimeException
)
149 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("SvxAccessibleTextPropertySet"));
152 sal_Bool SAL_CALL
SvxAccessibleTextPropertySet::supportsService (const ::rtl::OUString
& sServiceName
) throw (uno::RuntimeException
)
154 // Iterate over all supported service names and return true if on of them
155 // matches the given name.
156 uno::Sequence
< ::rtl::OUString
> aSupportedServices (
157 getSupportedServiceNames ());
158 for (int i
=0; i
<aSupportedServices
.getLength(); i
++)
159 if (sServiceName
== aSupportedServices
[i
])
164 uno::Sequence
< ::rtl::OUString
> SAL_CALL
SvxAccessibleTextPropertySet::getSupportedServiceNames (void) throw (uno::RuntimeException
)
167 return SvxUnoTextRangeBase::getSupportedServiceNames();
171 ::rtl::OUString SAL_CALL
SvxAccessibleTextPropertySet::getServiceName() throw (uno::RuntimeException
)
173 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.beans.PropertyValue"));