1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_editeng.hxx" 30 31 //------------------------------------------------------------------------ 32 // 33 // Global header 34 // 35 //------------------------------------------------------------------------ 36 #include <vos/mutex.hxx> 37 #include <com/sun/star/uno/Any.hxx> 38 #include <com/sun/star/uno/Reference.hxx> 39 #include <cppuhelper/weakref.hxx> 40 #include <com/sun/star/lang/XComponent.hpp> 41 #include <cppuhelper/typeprovider.hxx> 42 43 44 //------------------------------------------------------------------------ 45 // 46 // Project-local header 47 // 48 //------------------------------------------------------------------------ 49 50 #include <editeng/unopracc.hxx> 51 #include <editeng/unoedsrc.hxx> 52 53 using namespace ::com::sun::star; 54 55 //------------------------------------------------------------------------ 56 // 57 // SvxAccessibleTextPropertySet implementation 58 // 59 //------------------------------------------------------------------------ 60 61 SvxAccessibleTextPropertySet::SvxAccessibleTextPropertySet( const SvxEditSource* pEditSrc, const SvxItemPropertySet* pPropSet ) 62 : SvxUnoTextRangeBase( pEditSrc, pPropSet ) 63 { 64 } 65 66 SvxAccessibleTextPropertySet::~SvxAccessibleTextPropertySet() throw() 67 { 68 } 69 70 uno::Reference< text::XText > SAL_CALL SvxAccessibleTextPropertySet::getText() throw (uno::RuntimeException) 71 { 72 // TODO (empty?) 73 return uno::Reference< text::XText > (); 74 } 75 76 uno::Any SAL_CALL SvxAccessibleTextPropertySet::queryAggregation( const uno::Type & ) throw(uno::RuntimeException) 77 { 78 // TODO (empty?) 79 return uno::Any(); 80 } 81 82 uno::Any SAL_CALL SvxAccessibleTextPropertySet::queryInterface( const uno::Type & rType ) 83 throw(uno::RuntimeException) 84 { 85 return OWeakObject::queryInterface(rType); 86 } 87 88 void SAL_CALL SvxAccessibleTextPropertySet::acquire() 89 throw() 90 { 91 OWeakObject::acquire(); 92 } 93 94 void SAL_CALL SvxAccessibleTextPropertySet::release() 95 throw() 96 { 97 OWeakObject::release(); 98 } 99 100 // XTypeProvider 101 uno::Sequence< uno::Type > SAL_CALL SvxAccessibleTextPropertySet::getTypes() throw ( uno::RuntimeException ) 102 { 103 static ::cppu::OTypeCollection* pTypeCollection = NULL ; 104 105 // double-checked locking pattern. 106 if ( pTypeCollection == NULL ) 107 { 108 osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 109 110 // Control these pointer again ... it can be, that another instance will be faster then these! 111 if ( pTypeCollection == NULL ) 112 { 113 // Create a static typecollection ... 114 static ::cppu::OTypeCollection aTypeCollection( 115 ::getCppuType( static_cast< const uno::Reference< beans::XPropertySet >* > (0) ), 116 ::getCppuType( static_cast< const uno::Reference< beans::XMultiPropertySet >* > (0) ), 117 ::getCppuType( static_cast< const uno::Reference< beans::XPropertyState >* > (0) ), 118 ::getCppuType( static_cast< const uno::Reference< lang::XServiceInfo >* > (0) ), 119 ::getCppuType( static_cast< const uno::Reference< lang::XTypeProvider >* > (0) ) ); 120 121 // ... and set his address to static pointer! 122 pTypeCollection = &aTypeCollection ; 123 } 124 } 125 126 return pTypeCollection->getTypes() ; 127 } 128 129 uno::Sequence< sal_Int8 > SAL_CALL SvxAccessibleTextPropertySet::getImplementationId() 130 throw (uno::RuntimeException) 131 { 132 static uno::Sequence< sal_Int8 > aId; 133 if( aId.getLength() == 0 ) 134 { 135 aId.realloc( 16 ); 136 rtl_createUuid( reinterpret_cast< sal_uInt8* > (aId.getArray()), 0, sal_True ); 137 } 138 return aId; 139 } 140 141 // XServiceInfo 142 ::rtl::OUString SAL_CALL SAL_CALL SvxAccessibleTextPropertySet::getImplementationName (void) throw (uno::RuntimeException) 143 { 144 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("SvxAccessibleTextPropertySet")); 145 } 146 147 sal_Bool SAL_CALL SvxAccessibleTextPropertySet::supportsService (const ::rtl::OUString& sServiceName) throw (uno::RuntimeException) 148 { 149 // Iterate over all supported service names and return true if on of them 150 // matches the given name. 151 uno::Sequence< ::rtl::OUString> aSupportedServices ( 152 getSupportedServiceNames ()); 153 for (int i=0; i<aSupportedServices.getLength(); i++) 154 if (sServiceName == aSupportedServices[i]) 155 return sal_True; 156 return sal_False; 157 } 158 159 uno::Sequence< ::rtl::OUString> SAL_CALL SvxAccessibleTextPropertySet::getSupportedServiceNames (void) throw (uno::RuntimeException) 160 { 161 // TODO 162 return SvxUnoTextRangeBase::getSupportedServiceNames(); 163 } 164 165 // XServiceName 166 ::rtl::OUString SAL_CALL SvxAccessibleTextPropertySet::getServiceName() throw (uno::RuntimeException) 167 { 168 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.beans.PropertyValue")); 169 } 170 171 172