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 <sal/config.h>
21 :
22 : #include <memory>
23 : #include <utility>
24 :
25 : #include "AccessibleTextHelper.hxx"
26 : #include "DrawViewWrapper.hxx"
27 :
28 : #include <vcl/svapp.hxx>
29 : #include <osl/mutex.hxx>
30 :
31 : #include <svx/AccessibleTextHelper.hxx>
32 : #include <svx/unoshtxt.hxx>
33 : #include <toolkit/helper/vclunohelper.hxx>
34 : #include <vcl/window.hxx>
35 :
36 : #include <com/sun/star/accessibility/AccessibleRole.hpp>
37 :
38 : using namespace ::com::sun::star;
39 : using namespace ::com::sun::star::accessibility;
40 :
41 : using ::com::sun::star::uno::Reference;
42 : using ::com::sun::star::uno::Sequence;
43 :
44 : namespace chart
45 : {
46 :
47 0 : AccessibleTextHelper::AccessibleTextHelper(
48 : DrawViewWrapper * pDrawViewWrapper ) :
49 : impl::AccessibleTextHelper_Base( m_aMutex ),
50 : m_pTextHelper( 0 ),
51 0 : m_pDrawViewWrapper( pDrawViewWrapper )
52 0 : {}
53 :
54 0 : AccessibleTextHelper::~AccessibleTextHelper()
55 : {
56 0 : if( m_pTextHelper )
57 0 : delete m_pTextHelper;
58 0 : }
59 :
60 : // ____ XInitialization ____
61 0 : void SAL_CALL AccessibleTextHelper::initialize( const Sequence< uno::Any >& aArguments )
62 : throw (uno::Exception,
63 : uno::RuntimeException, std::exception)
64 : {
65 0 : OUString aCID;
66 0 : Reference< XAccessible > xEventSource;
67 0 : Reference< awt::XWindow > xWindow;
68 :
69 0 : if( aArguments.getLength() >= 3 )
70 : {
71 0 : aArguments[0] >>= aCID;
72 0 : aArguments[1] >>= xEventSource;
73 0 : aArguments[2] >>= xWindow;
74 : }
75 : OSL_ENSURE( !aCID.isEmpty(), "Empty CID" );
76 : OSL_ENSURE( xEventSource.is(), "Empty Event Source" );
77 : OSL_ENSURE( xWindow.is(), "Empty Window" );
78 0 : if( !xEventSource.is() || aCID.isEmpty() )
79 0 : return;
80 :
81 0 : SolarMutexGuard aSolarGuard;
82 :
83 0 : if( m_pTextHelper )
84 0 : delete m_pTextHelper;
85 :
86 0 : vcl::Window* pWindow( VCLUnoHelper::GetWindow( xWindow ));
87 0 : if( pWindow )
88 : {
89 0 : SdrView * pView = m_pDrawViewWrapper;
90 0 : if( pView )
91 : {
92 0 : SdrObject * pTextObj = m_pDrawViewWrapper->getNamedSdrObject( aCID );
93 0 : if( pTextObj )
94 : {
95 0 : std::unique_ptr<SvxEditSource> pEditSource(new SvxTextEditSource( *pTextObj, 0, *pView, *pWindow ));
96 : m_pTextHelper = new ::accessibility::AccessibleTextHelper(
97 0 : std::move(pEditSource));
98 0 : if( m_pTextHelper )
99 0 : m_pTextHelper->SetEventSource( xEventSource );
100 : }
101 : }
102 : }
103 :
104 0 : OSL_ENSURE( m_pTextHelper, "Couldn't create text helper" );
105 : }
106 :
107 : // ____ XAccessibleContext ____
108 0 : ::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleChildCount()
109 : throw (uno::RuntimeException, std::exception)
110 : {
111 0 : if( m_pTextHelper )
112 : {
113 0 : SolarMutexGuard aSolarGuard;
114 0 : return m_pTextHelper->GetChildCount();
115 : }
116 0 : return 0;
117 : }
118 :
119 0 : Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleChild( ::sal_Int32 i )
120 : throw (lang::IndexOutOfBoundsException,
121 : uno::RuntimeException, std::exception)
122 : {
123 0 : if( m_pTextHelper )
124 : {
125 0 : SolarMutexGuard aSolarGuard;
126 0 : return m_pTextHelper->GetChild( i );
127 : }
128 0 : return Reference< XAccessible >();
129 : }
130 :
131 0 : Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleParent()
132 : throw (uno::RuntimeException, std::exception)
133 : {
134 : OSL_FAIL( "Not implemented in this helper" );
135 0 : return Reference< XAccessible >();
136 : }
137 :
138 0 : ::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleIndexInParent()
139 : throw (uno::RuntimeException, std::exception)
140 : {
141 : OSL_FAIL( "Not implemented in this helper" );
142 0 : return -1;
143 : }
144 :
145 0 : ::sal_Int16 SAL_CALL AccessibleTextHelper::getAccessibleRole()
146 : throw (uno::RuntimeException, std::exception)
147 : {
148 : OSL_FAIL( "Not implemented in this helper" );
149 0 : return AccessibleRole::UNKNOWN;
150 : }
151 :
152 0 : OUString SAL_CALL AccessibleTextHelper::getAccessibleDescription()
153 : throw (uno::RuntimeException, std::exception)
154 : {
155 : OSL_FAIL( "Not implemented in this helper" );
156 0 : return OUString();
157 : }
158 :
159 0 : OUString SAL_CALL AccessibleTextHelper::getAccessibleName()
160 : throw (uno::RuntimeException, std::exception)
161 : {
162 : OSL_FAIL( "Not implemented in this helper" );
163 0 : return OUString();
164 : }
165 :
166 0 : Reference< XAccessibleRelationSet > SAL_CALL AccessibleTextHelper::getAccessibleRelationSet()
167 : throw (uno::RuntimeException, std::exception)
168 : {
169 : OSL_FAIL( "Not implemented in this helper" );
170 0 : return Reference< XAccessibleRelationSet >();
171 : }
172 :
173 0 : Reference< XAccessibleStateSet > SAL_CALL AccessibleTextHelper::getAccessibleStateSet()
174 : throw (uno::RuntimeException, std::exception)
175 : {
176 : OSL_FAIL( "Not implemented in this helper" );
177 0 : return Reference< XAccessibleStateSet >();
178 : }
179 :
180 0 : lang::Locale SAL_CALL AccessibleTextHelper::getLocale()
181 : throw (IllegalAccessibleComponentStateException,
182 : uno::RuntimeException, std::exception)
183 : {
184 : OSL_FAIL( "Not implemented in this helper" );
185 0 : return lang::Locale();
186 : }
187 :
188 102 : } // namespace chart
189 :
190 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|