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_chart2.hxx" 30 31 #include "AccessibleTextHelper.hxx" 32 #include "DrawViewWrapper.hxx" 33 34 #include <vcl/svapp.hxx> 35 #include <vos/mutex.hxx> 36 37 #include <svx/AccessibleTextHelper.hxx> 38 #include <svx/unoshtxt.hxx> 39 #include <toolkit/helper/vclunohelper.hxx> 40 #include <vcl/window.hxx> 41 42 #include <com/sun/star/accessibility/AccessibleRole.hpp> 43 44 using namespace ::com::sun::star; 45 using namespace ::com::sun::star::accessibility; 46 47 using ::com::sun::star::uno::Reference; 48 using ::com::sun::star::uno::Sequence; 49 using ::rtl::OUString; 50 51 namespace chart 52 { 53 54 AccessibleTextHelper::AccessibleTextHelper( 55 DrawViewWrapper * pDrawViewWrapper ) : 56 impl::AccessibleTextHelper_Base( m_aMutex ), 57 m_pTextHelper( 0 ), 58 m_pDrawViewWrapper( pDrawViewWrapper ) 59 {} 60 61 AccessibleTextHelper::~AccessibleTextHelper() 62 { 63 if( m_pTextHelper ) 64 delete m_pTextHelper; 65 } 66 67 // ____ XInitialization ____ 68 void SAL_CALL AccessibleTextHelper::initialize( const Sequence< uno::Any >& aArguments ) 69 throw (uno::Exception, 70 uno::RuntimeException) 71 { 72 OUString aCID; 73 Reference< XAccessible > xEventSource; 74 Reference< awt::XWindow > xWindow; 75 76 if( aArguments.getLength() >= 3 ) 77 { 78 aArguments[0] >>= aCID; 79 aArguments[1] >>= xEventSource; 80 aArguments[2] >>= xWindow; 81 } 82 OSL_ENSURE( aCID.getLength() > 0, "Empty CID" ); 83 OSL_ENSURE( xEventSource.is(), "Empty Event Source" ); 84 OSL_ENSURE( xWindow.is(), "Empty Window" ); 85 if( !xEventSource.is() || aCID.getLength() == 0 ) 86 return; 87 88 // /-- solar 89 ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 90 91 if( m_pTextHelper ) 92 delete m_pTextHelper; 93 94 Window* pWindow( VCLUnoHelper::GetWindow( xWindow )); 95 if( pWindow ) 96 { 97 SdrView * pView = m_pDrawViewWrapper; 98 if( pView ) 99 { 100 SdrObject * pTextObj = m_pDrawViewWrapper->getNamedSdrObject( aCID ); 101 if( pTextObj ) 102 { 103 SvxEditSource * pEditSource = new SvxTextEditSource( *pTextObj, 0, *pView, *pWindow ); 104 m_pTextHelper = new ::accessibility::AccessibleTextHelper( 105 ::std::auto_ptr< SvxEditSource >( pEditSource )); 106 if( m_pTextHelper ) 107 m_pTextHelper->SetEventSource( xEventSource ); 108 } 109 } 110 } 111 112 OSL_ENSURE( m_pTextHelper, "Couldn't create text helper" ); 113 // \-- solar 114 } 115 116 // ____ XAccessibleContext ____ 117 ::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleChildCount() 118 throw (uno::RuntimeException) 119 { 120 if( m_pTextHelper ) 121 { 122 // /-- solar 123 ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 124 return m_pTextHelper->GetChildCount(); 125 // \-- solar 126 } 127 return 0; 128 } 129 130 Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleChild( ::sal_Int32 i ) 131 throw (lang::IndexOutOfBoundsException, 132 uno::RuntimeException) 133 { 134 if( m_pTextHelper ) 135 { 136 // /-- solar 137 ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 138 return m_pTextHelper->GetChild( i ); 139 // \-- solar 140 } 141 return Reference< XAccessible >(); 142 } 143 144 Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleParent() 145 throw (uno::RuntimeException) 146 { 147 OSL_ENSURE( false, "Not implemented in this helper" ); 148 return Reference< XAccessible >(); 149 } 150 151 ::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleIndexInParent() 152 throw (uno::RuntimeException) 153 { 154 OSL_ENSURE( false, "Not implemented in this helper" ); 155 return -1; 156 } 157 158 ::sal_Int16 SAL_CALL AccessibleTextHelper::getAccessibleRole() 159 throw (uno::RuntimeException) 160 { 161 OSL_ENSURE( false, "Not implemented in this helper" ); 162 return AccessibleRole::UNKNOWN; 163 } 164 165 OUString SAL_CALL AccessibleTextHelper::getAccessibleDescription() 166 throw (uno::RuntimeException) 167 { 168 OSL_ENSURE( false, "Not implemented in this helper" ); 169 return OUString(); 170 } 171 172 OUString SAL_CALL AccessibleTextHelper::getAccessibleName() 173 throw (uno::RuntimeException) 174 { 175 OSL_ENSURE( false, "Not implemented in this helper" ); 176 return OUString(); 177 } 178 179 Reference< XAccessibleRelationSet > SAL_CALL AccessibleTextHelper::getAccessibleRelationSet() 180 throw (uno::RuntimeException) 181 { 182 OSL_ENSURE( false, "Not implemented in this helper" ); 183 return Reference< XAccessibleRelationSet >(); 184 } 185 186 Reference< XAccessibleStateSet > SAL_CALL AccessibleTextHelper::getAccessibleStateSet() 187 throw (uno::RuntimeException) 188 { 189 OSL_ENSURE( false, "Not implemented in this helper" ); 190 return Reference< XAccessibleStateSet >(); 191 } 192 193 lang::Locale SAL_CALL AccessibleTextHelper::getLocale() 194 throw (IllegalAccessibleComponentStateException, 195 uno::RuntimeException) 196 { 197 OSL_ENSURE( false, "Not implemented in this helper" ); 198 return lang::Locale(); 199 } 200 201 202 203 } // namespace chart 204