1cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3cde9e8dcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4cde9e8dcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5cde9e8dcSAndrew Rist  * distributed with this work for additional information
6cde9e8dcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7cde9e8dcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8cde9e8dcSAndrew Rist  * "License"); you may not use this file except in compliance
9cde9e8dcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cde9e8dcSAndrew Rist  *
11cde9e8dcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cde9e8dcSAndrew Rist  *
13cde9e8dcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14cde9e8dcSAndrew Rist  * software distributed under the License is distributed on an
15cde9e8dcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16cde9e8dcSAndrew Rist  * KIND, either express or implied.  See the License for the
17cde9e8dcSAndrew Rist  * specific language governing permissions and limitations
18cde9e8dcSAndrew Rist  * under the License.
19cde9e8dcSAndrew Rist  *
20cde9e8dcSAndrew Rist  *************************************************************/
21cde9e8dcSAndrew Rist 
22cde9e8dcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "AccessibleTextHelper.hxx"
28cdf0e10cSrcweir #include "DrawViewWrapper.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <vcl/svapp.hxx>
31cdf0e10cSrcweir #include <vos/mutex.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <svx/AccessibleTextHelper.hxx>
34cdf0e10cSrcweir #include <svx/unoshtxt.hxx>
35cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
36cdf0e10cSrcweir #include <vcl/window.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir using namespace ::com::sun::star;
41cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
44cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
45cdf0e10cSrcweir using ::rtl::OUString;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir namespace chart
48cdf0e10cSrcweir {
49cdf0e10cSrcweir 
AccessibleTextHelper(DrawViewWrapper * pDrawViewWrapper)50cdf0e10cSrcweir AccessibleTextHelper::AccessibleTextHelper(
51cdf0e10cSrcweir     DrawViewWrapper * pDrawViewWrapper ) :
52cdf0e10cSrcweir         impl::AccessibleTextHelper_Base( m_aMutex ),
53cdf0e10cSrcweir         m_pTextHelper( 0 ),
54cdf0e10cSrcweir         m_pDrawViewWrapper( pDrawViewWrapper )
55cdf0e10cSrcweir {}
56cdf0e10cSrcweir 
~AccessibleTextHelper()57cdf0e10cSrcweir AccessibleTextHelper::~AccessibleTextHelper()
58cdf0e10cSrcweir {
59cdf0e10cSrcweir     if( m_pTextHelper )
60cdf0e10cSrcweir         delete m_pTextHelper;
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir // ____ XInitialization ____
initialize(const Sequence<uno::Any> & aArguments)64cdf0e10cSrcweir void SAL_CALL AccessibleTextHelper::initialize( const Sequence< uno::Any >& aArguments )
65cdf0e10cSrcweir     throw (uno::Exception,
66cdf0e10cSrcweir            uno::RuntimeException)
67cdf0e10cSrcweir {
68cdf0e10cSrcweir     OUString aCID;
69cdf0e10cSrcweir     Reference< XAccessible > xEventSource;
70cdf0e10cSrcweir     Reference< awt::XWindow > xWindow;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     if( aArguments.getLength() >= 3 )
73cdf0e10cSrcweir     {
74cdf0e10cSrcweir         aArguments[0] >>= aCID;
75cdf0e10cSrcweir         aArguments[1] >>= xEventSource;
76cdf0e10cSrcweir         aArguments[2] >>= xWindow;
77cdf0e10cSrcweir     }
78*9ec58d04SHerbert Dürr     OSL_ENSURE( !aCID.isEmpty(), "Empty CID" );
79cdf0e10cSrcweir     OSL_ENSURE( xEventSource.is(), "Empty Event Source" );
80cdf0e10cSrcweir     OSL_ENSURE( xWindow.is(), "Empty Window" );
81*9ec58d04SHerbert Dürr     if( !xEventSource.is() || aCID.isEmpty() )
82cdf0e10cSrcweir         return;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     // /-- solar
85cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     if( m_pTextHelper )
88cdf0e10cSrcweir         delete m_pTextHelper;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     Window* pWindow( VCLUnoHelper::GetWindow( xWindow ));
91cdf0e10cSrcweir     if( pWindow )
92cdf0e10cSrcweir     {
93cdf0e10cSrcweir         SdrView * pView = m_pDrawViewWrapper;
94cdf0e10cSrcweir         if( pView )
95cdf0e10cSrcweir         {
96cdf0e10cSrcweir             SdrObject * pTextObj = m_pDrawViewWrapper->getNamedSdrObject( aCID );
97cdf0e10cSrcweir             if( pTextObj )
98cdf0e10cSrcweir             {
99cdf0e10cSrcweir                 SvxEditSource * pEditSource = new SvxTextEditSource( *pTextObj, 0, *pView, *pWindow );
100cdf0e10cSrcweir                 m_pTextHelper = new ::accessibility::AccessibleTextHelper(
101cdf0e10cSrcweir                     ::std::auto_ptr< SvxEditSource >( pEditSource ));
102cdf0e10cSrcweir                 if( m_pTextHelper )
103cdf0e10cSrcweir                     m_pTextHelper->SetEventSource( xEventSource );
104cdf0e10cSrcweir             }
105cdf0e10cSrcweir         }
106cdf0e10cSrcweir     }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     OSL_ENSURE( m_pTextHelper, "Couldn't create text helper" );
109cdf0e10cSrcweir     // \-- solar
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir // ____ XAccessibleContext ____
getAccessibleChildCount()113cdf0e10cSrcweir ::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleChildCount()
114cdf0e10cSrcweir     throw (uno::RuntimeException)
115cdf0e10cSrcweir {
116cdf0e10cSrcweir     if( m_pTextHelper )
117cdf0e10cSrcweir     {
118cdf0e10cSrcweir         // /-- solar
119cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
120cdf0e10cSrcweir         return m_pTextHelper->GetChildCount();
121cdf0e10cSrcweir         // \-- solar
122cdf0e10cSrcweir     }
123cdf0e10cSrcweir     return 0;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
getAccessibleChild(::sal_Int32 i)126cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleChild( ::sal_Int32 i )
127cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException,
128cdf0e10cSrcweir            uno::RuntimeException)
129cdf0e10cSrcweir {
130cdf0e10cSrcweir     if( m_pTextHelper )
131cdf0e10cSrcweir     {
132cdf0e10cSrcweir         // /-- solar
133cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
134cdf0e10cSrcweir         return m_pTextHelper->GetChild( i );
135cdf0e10cSrcweir         // \-- solar
136cdf0e10cSrcweir     }
137cdf0e10cSrcweir     return Reference< XAccessible >();
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
getAccessibleParent()140cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleParent()
141cdf0e10cSrcweir     throw (uno::RuntimeException)
142cdf0e10cSrcweir {
143cdf0e10cSrcweir     OSL_ENSURE( false, "Not implemented in this helper" );
144cdf0e10cSrcweir     return Reference< XAccessible >();
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
getAccessibleIndexInParent()147cdf0e10cSrcweir ::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleIndexInParent()
148cdf0e10cSrcweir     throw (uno::RuntimeException)
149cdf0e10cSrcweir {
150cdf0e10cSrcweir     OSL_ENSURE( false, "Not implemented in this helper" );
151cdf0e10cSrcweir     return -1;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
getAccessibleRole()154cdf0e10cSrcweir ::sal_Int16 SAL_CALL AccessibleTextHelper::getAccessibleRole()
155cdf0e10cSrcweir     throw (uno::RuntimeException)
156cdf0e10cSrcweir {
157cdf0e10cSrcweir     OSL_ENSURE( false, "Not implemented in this helper" );
158cdf0e10cSrcweir     return AccessibleRole::UNKNOWN;
159cdf0e10cSrcweir }
160cdf0e10cSrcweir 
getAccessibleDescription()161cdf0e10cSrcweir OUString SAL_CALL AccessibleTextHelper::getAccessibleDescription()
162cdf0e10cSrcweir     throw (uno::RuntimeException)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir     OSL_ENSURE( false, "Not implemented in this helper" );
165cdf0e10cSrcweir     return OUString();
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
getAccessibleName()168cdf0e10cSrcweir OUString SAL_CALL AccessibleTextHelper::getAccessibleName()
169cdf0e10cSrcweir     throw (uno::RuntimeException)
170cdf0e10cSrcweir {
171cdf0e10cSrcweir     OSL_ENSURE( false, "Not implemented in this helper" );
172cdf0e10cSrcweir     return OUString();
173cdf0e10cSrcweir }
174cdf0e10cSrcweir 
getAccessibleRelationSet()175cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL AccessibleTextHelper::getAccessibleRelationSet()
176cdf0e10cSrcweir     throw (uno::RuntimeException)
177cdf0e10cSrcweir {
178cdf0e10cSrcweir     OSL_ENSURE( false, "Not implemented in this helper" );
179cdf0e10cSrcweir     return Reference< XAccessibleRelationSet >();
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
getAccessibleStateSet()182cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL AccessibleTextHelper::getAccessibleStateSet()
183cdf0e10cSrcweir     throw (uno::RuntimeException)
184cdf0e10cSrcweir {
185cdf0e10cSrcweir     OSL_ENSURE( false, "Not implemented in this helper" );
186cdf0e10cSrcweir     return Reference< XAccessibleStateSet >();
187cdf0e10cSrcweir }
188cdf0e10cSrcweir 
getLocale()189cdf0e10cSrcweir lang::Locale SAL_CALL AccessibleTextHelper::getLocale()
190cdf0e10cSrcweir     throw (IllegalAccessibleComponentStateException,
191cdf0e10cSrcweir            uno::RuntimeException)
192cdf0e10cSrcweir {
193cdf0e10cSrcweir     OSL_ENSURE( false, "Not implemented in this helper" );
194cdf0e10cSrcweir     return lang::Locale();
195cdf0e10cSrcweir }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 
199cdf0e10cSrcweir } //  namespace chart
200