Update ooo320-m1
[ooovba.git] / chart2 / source / controller / accessibility / AccessibleTextHelper.cxx
blob7242f3e5d4077627cfa0f4ac33bef631e3e0fe04
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleTextHelper.cxx,v $
10 * $Revision: 1.4 $
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_chart2.hxx"
34 #include "AccessibleTextHelper.hxx"
35 #include "DrawViewWrapper.hxx"
37 #include <vcl/svapp.hxx>
38 #include <vos/mutex.hxx>
40 #include <svx/AccessibleTextHelper.hxx>
41 #include <svx/unoshtxt.hxx>
42 #include <toolkit/helper/vclunohelper.hxx>
43 #include <vcl/window.hxx>
45 #include <com/sun/star/accessibility/AccessibleRole.hpp>
47 using namespace ::com::sun::star;
48 using namespace ::com::sun::star::accessibility;
50 using ::com::sun::star::uno::Reference;
51 using ::com::sun::star::uno::Sequence;
52 using ::rtl::OUString;
54 namespace chart
57 AccessibleTextHelper::AccessibleTextHelper(
58 DrawViewWrapper * pDrawViewWrapper ) :
59 impl::AccessibleTextHelper_Base( m_aMutex ),
60 m_pTextHelper( 0 ),
61 m_pDrawViewWrapper( pDrawViewWrapper )
64 AccessibleTextHelper::~AccessibleTextHelper()
66 if( m_pTextHelper )
67 delete m_pTextHelper;
70 // ____ XInitialization ____
71 void SAL_CALL AccessibleTextHelper::initialize( const Sequence< uno::Any >& aArguments )
72 throw (uno::Exception,
73 uno::RuntimeException)
75 OUString aCID;
76 Reference< XAccessible > xEventSource;
77 Reference< awt::XWindow > xWindow;
79 if( aArguments.getLength() >= 3 )
81 aArguments[0] >>= aCID;
82 aArguments[1] >>= xEventSource;
83 aArguments[2] >>= xWindow;
85 OSL_ENSURE( aCID.getLength() > 0, "Empty CID" );
86 OSL_ENSURE( xEventSource.is(), "Empty Event Source" );
87 OSL_ENSURE( xWindow.is(), "Empty Window" );
88 if( !xEventSource.is() || aCID.getLength() == 0 )
89 return;
91 // /-- solar
92 ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
94 if( m_pTextHelper )
95 delete m_pTextHelper;
97 Window* pWindow( VCLUnoHelper::GetWindow( xWindow ));
98 if( pWindow )
100 SdrView * pView = m_pDrawViewWrapper;
101 if( pView )
103 SdrObject * pTextObj = m_pDrawViewWrapper->getNamedSdrObject( aCID );
104 if( pTextObj )
106 SvxEditSource * pEditSource = new SvxTextEditSource( *pTextObj, 0, *pView, *pWindow );
107 m_pTextHelper = new ::accessibility::AccessibleTextHelper(
108 ::std::auto_ptr< SvxEditSource >( pEditSource ));
109 if( m_pTextHelper )
110 m_pTextHelper->SetEventSource( xEventSource );
115 OSL_ENSURE( m_pTextHelper, "Couldn't create text helper" );
116 // \-- solar
119 // ____ XAccessibleContext ____
120 ::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleChildCount()
121 throw (uno::RuntimeException)
123 if( m_pTextHelper )
125 // /-- solar
126 ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
127 return m_pTextHelper->GetChildCount();
128 // \-- solar
130 return 0;
133 Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleChild( ::sal_Int32 i )
134 throw (lang::IndexOutOfBoundsException,
135 uno::RuntimeException)
137 if( m_pTextHelper )
139 // /-- solar
140 ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
141 return m_pTextHelper->GetChild( i );
142 // \-- solar
144 return Reference< XAccessible >();
147 Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleParent()
148 throw (uno::RuntimeException)
150 OSL_ENSURE( false, "Not implemented in this helper" );
151 return Reference< XAccessible >();
154 ::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleIndexInParent()
155 throw (uno::RuntimeException)
157 OSL_ENSURE( false, "Not implemented in this helper" );
158 return -1;
161 ::sal_Int16 SAL_CALL AccessibleTextHelper::getAccessibleRole()
162 throw (uno::RuntimeException)
164 OSL_ENSURE( false, "Not implemented in this helper" );
165 return AccessibleRole::UNKNOWN;
168 OUString SAL_CALL AccessibleTextHelper::getAccessibleDescription()
169 throw (uno::RuntimeException)
171 OSL_ENSURE( false, "Not implemented in this helper" );
172 return OUString();
175 OUString SAL_CALL AccessibleTextHelper::getAccessibleName()
176 throw (uno::RuntimeException)
178 OSL_ENSURE( false, "Not implemented in this helper" );
179 return OUString();
182 Reference< XAccessibleRelationSet > SAL_CALL AccessibleTextHelper::getAccessibleRelationSet()
183 throw (uno::RuntimeException)
185 OSL_ENSURE( false, "Not implemented in this helper" );
186 return Reference< XAccessibleRelationSet >();
189 Reference< XAccessibleStateSet > SAL_CALL AccessibleTextHelper::getAccessibleStateSet()
190 throw (uno::RuntimeException)
192 OSL_ENSURE( false, "Not implemented in this helper" );
193 return Reference< XAccessibleStateSet >();
196 lang::Locale SAL_CALL AccessibleTextHelper::getLocale()
197 throw (IllegalAccessibleComponentStateException,
198 uno::RuntimeException)
200 OSL_ENSURE( false, "Not implemented in this helper" );
201 return lang::Locale();
206 } // namespace chart