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