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_chartcontroller.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 {
66 OUString aCID;
67 Reference< XAccessible > xEventSource;
68 Reference< awt::XWindow > xWindow;
69
70 if( aArguments.getLength() >= 3 )
71 {
72 aArguments[0] >>= aCID;
73 aArguments[1] >>= xEventSource;
74 aArguments[2] >>= xWindow;
75 }
76 OSL_ENSURE( !aCID.isEmpty(), "Empty CID" );
77 OSL_ENSURE( xEventSource.is(), "Empty Event Source" );
78 OSL_ENSURE( xWindow.is(), "Empty Window" );
79 if( !xEventSource.is() || aCID.isEmpty() )
80 return;
81
82 // /-- solar
83 ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
84
85 if( m_pTextHelper )
86 delete m_pTextHelper;
87
88 Window* pWindow( VCLUnoHelper::GetWindow( xWindow ));
89 if( pWindow )
90 {
91 SdrView * pView = m_pDrawViewWrapper;
92 if( pView )
93 {
94 SdrObject * pTextObj = m_pDrawViewWrapper->getNamedSdrObject( aCID );
95 if( pTextObj )
96 {
97 SvxEditSource * pEditSource = new SvxTextEditSource( *pTextObj, 0, *pView, *pWindow );
98 m_pTextHelper = new ::accessibility::AccessibleTextHelper(
99 ::std::auto_ptr< SvxEditSource >( pEditSource ));
100 if( m_pTextHelper )
101 m_pTextHelper->SetEventSource( xEventSource );
102 }
103 }
104 }
105
106 OSL_ENSURE( m_pTextHelper, "Couldn't create text helper" );
107 // \-- solar
108 }
109
110 // ____ XAccessibleContext ____
getAccessibleChildCount()111 ::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleChildCount()
112 {
113 if( m_pTextHelper )
114 {
115 // /-- solar
116 ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
117 return m_pTextHelper->GetChildCount();
118 // \-- solar
119 }
120 return 0;
121 }
122
getAccessibleChild(::sal_Int32 i)123 Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleChild( ::sal_Int32 i )
124 {
125 if( m_pTextHelper )
126 {
127 // /-- solar
128 ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
129 return m_pTextHelper->GetChild( i );
130 // \-- solar
131 }
132 return Reference< XAccessible >();
133 }
134
getAccessibleParent()135 Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleParent()
136 {
137 OSL_ENSURE( false, "Not implemented in this helper" );
138 return Reference< XAccessible >();
139 }
140
getAccessibleIndexInParent()141 ::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleIndexInParent()
142 {
143 OSL_ENSURE( false, "Not implemented in this helper" );
144 return -1;
145 }
146
getAccessibleRole()147 ::sal_Int16 SAL_CALL AccessibleTextHelper::getAccessibleRole()
148 {
149 OSL_ENSURE( false, "Not implemented in this helper" );
150 return AccessibleRole::UNKNOWN;
151 }
152
getAccessibleDescription()153 OUString SAL_CALL AccessibleTextHelper::getAccessibleDescription()
154 {
155 OSL_ENSURE( false, "Not implemented in this helper" );
156 return OUString();
157 }
158
getAccessibleName()159 OUString SAL_CALL AccessibleTextHelper::getAccessibleName()
160 {
161 OSL_ENSURE( false, "Not implemented in this helper" );
162 return OUString();
163 }
164
getAccessibleRelationSet()165 Reference< XAccessibleRelationSet > SAL_CALL AccessibleTextHelper::getAccessibleRelationSet()
166 {
167 OSL_ENSURE( false, "Not implemented in this helper" );
168 return Reference< XAccessibleRelationSet >();
169 }
170
getAccessibleStateSet()171 Reference< XAccessibleStateSet > SAL_CALL AccessibleTextHelper::getAccessibleStateSet()
172 {
173 OSL_ENSURE( false, "Not implemented in this helper" );
174 return Reference< XAccessibleStateSet >();
175 }
176
getLocale()177 lang::Locale SAL_CALL AccessibleTextHelper::getLocale()
178 {
179 OSL_ENSURE( false, "Not implemented in this helper" );
180 return lang::Locale();
181 }
182
183
184
185 } // namespace chart
186