Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "AccessibleTextHelper.hxx"
21 : #include "DrawViewWrapper.hxx"
22 :
23 : #include <vcl/svapp.hxx>
24 : #include <osl/mutex.hxx>
25 :
26 : #include <svx/AccessibleTextHelper.hxx>
27 : #include <svx/unoshtxt.hxx>
28 : #include <toolkit/helper/vclunohelper.hxx>
29 : #include <vcl/window.hxx>
30 :
31 : #include <com/sun/star/accessibility/AccessibleRole.hpp>
32 :
33 : using namespace ::com::sun::star;
34 : using namespace ::com::sun::star::accessibility;
35 :
36 : using ::com::sun::star::uno::Reference;
37 : using ::com::sun::star::uno::Sequence;
38 :
39 : namespace chart
40 : {
41 :
42 0 : AccessibleTextHelper::AccessibleTextHelper(
43 : DrawViewWrapper * pDrawViewWrapper ) :
44 : impl::AccessibleTextHelper_Base( m_aMutex ),
45 : m_pTextHelper( 0 ),
46 0 : m_pDrawViewWrapper( pDrawViewWrapper )
47 0 : {}
48 :
49 0 : AccessibleTextHelper::~AccessibleTextHelper()
50 : {
51 0 : if( m_pTextHelper )
52 0 : delete m_pTextHelper;
53 0 : }
54 :
55 : // ____ XInitialization ____
56 0 : void SAL_CALL AccessibleTextHelper::initialize( const Sequence< uno::Any >& aArguments )
57 : throw (uno::Exception,
58 : uno::RuntimeException, std::exception)
59 : {
60 0 : OUString aCID;
61 0 : Reference< XAccessible > xEventSource;
62 0 : Reference< awt::XWindow > xWindow;
63 :
64 0 : if( aArguments.getLength() >= 3 )
65 : {
66 0 : aArguments[0] >>= aCID;
67 0 : aArguments[1] >>= xEventSource;
68 0 : aArguments[2] >>= xWindow;
69 : }
70 : OSL_ENSURE( !aCID.isEmpty(), "Empty CID" );
71 : OSL_ENSURE( xEventSource.is(), "Empty Event Source" );
72 : OSL_ENSURE( xWindow.is(), "Empty Window" );
73 0 : if( !xEventSource.is() || aCID.isEmpty() )
74 0 : return;
75 :
76 0 : SolarMutexGuard aSolarGuard;
77 :
78 0 : if( m_pTextHelper )
79 0 : delete m_pTextHelper;
80 :
81 0 : Window* pWindow( VCLUnoHelper::GetWindow( xWindow ));
82 0 : if( pWindow )
83 : {
84 0 : SdrView * pView = m_pDrawViewWrapper;
85 0 : if( pView )
86 : {
87 0 : SdrObject * pTextObj = m_pDrawViewWrapper->getNamedSdrObject( aCID );
88 0 : if( pTextObj )
89 : {
90 0 : SvxEditSource * pEditSource = new SvxTextEditSource( *pTextObj, 0, *pView, *pWindow );
91 : m_pTextHelper = new ::accessibility::AccessibleTextHelper(
92 0 : ::std::auto_ptr< SvxEditSource >( pEditSource ));
93 0 : if( m_pTextHelper )
94 0 : m_pTextHelper->SetEventSource( xEventSource );
95 : }
96 : }
97 : }
98 :
99 0 : OSL_ENSURE( m_pTextHelper, "Couldn't create text helper" );
100 : }
101 :
102 : // ____ XAccessibleContext ____
103 0 : ::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleChildCount()
104 : throw (uno::RuntimeException, std::exception)
105 : {
106 0 : if( m_pTextHelper )
107 : {
108 0 : SolarMutexGuard aSolarGuard;
109 0 : return m_pTextHelper->GetChildCount();
110 : }
111 0 : return 0;
112 : }
113 :
114 0 : Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleChild( ::sal_Int32 i )
115 : throw (lang::IndexOutOfBoundsException,
116 : uno::RuntimeException, std::exception)
117 : {
118 0 : if( m_pTextHelper )
119 : {
120 0 : SolarMutexGuard aSolarGuard;
121 0 : return m_pTextHelper->GetChild( i );
122 : }
123 0 : return Reference< XAccessible >();
124 : }
125 :
126 0 : Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleParent()
127 : throw (uno::RuntimeException, std::exception)
128 : {
129 : OSL_FAIL( "Not implemented in this helper" );
130 0 : return Reference< XAccessible >();
131 : }
132 :
133 0 : ::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleIndexInParent()
134 : throw (uno::RuntimeException, std::exception)
135 : {
136 : OSL_FAIL( "Not implemented in this helper" );
137 0 : return -1;
138 : }
139 :
140 0 : ::sal_Int16 SAL_CALL AccessibleTextHelper::getAccessibleRole()
141 : throw (uno::RuntimeException, std::exception)
142 : {
143 : OSL_FAIL( "Not implemented in this helper" );
144 0 : return AccessibleRole::UNKNOWN;
145 : }
146 :
147 0 : OUString SAL_CALL AccessibleTextHelper::getAccessibleDescription()
148 : throw (uno::RuntimeException, std::exception)
149 : {
150 : OSL_FAIL( "Not implemented in this helper" );
151 0 : return OUString();
152 : }
153 :
154 0 : OUString SAL_CALL AccessibleTextHelper::getAccessibleName()
155 : throw (uno::RuntimeException, std::exception)
156 : {
157 : OSL_FAIL( "Not implemented in this helper" );
158 0 : return OUString();
159 : }
160 :
161 0 : Reference< XAccessibleRelationSet > SAL_CALL AccessibleTextHelper::getAccessibleRelationSet()
162 : throw (uno::RuntimeException, std::exception)
163 : {
164 : OSL_FAIL( "Not implemented in this helper" );
165 0 : return Reference< XAccessibleRelationSet >();
166 : }
167 :
168 0 : Reference< XAccessibleStateSet > SAL_CALL AccessibleTextHelper::getAccessibleStateSet()
169 : throw (uno::RuntimeException, std::exception)
170 : {
171 : OSL_FAIL( "Not implemented in this helper" );
172 0 : return Reference< XAccessibleStateSet >();
173 : }
174 :
175 0 : lang::Locale SAL_CALL AccessibleTextHelper::getLocale()
176 : throw (IllegalAccessibleComponentStateException,
177 : uno::RuntimeException, std::exception)
178 : {
179 : OSL_FAIL( "Not implemented in this helper" );
180 0 : return lang::Locale();
181 : }
182 :
183 : } // namespace chart
184 :
185 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|