1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
25 #include "AccessibleTextHelper.hxx"
26 #include "DrawViewWrapper.hxx"
28 #include <vcl/svapp.hxx>
29 #include <osl/mutex.hxx>
31 #include <svx/AccessibleTextHelper.hxx>
32 #include <svx/unoshtxt.hxx>
33 #include <toolkit/helper/vclunohelper.hxx>
34 #include <vcl/window.hxx>
36 #include <com/sun/star/accessibility/AccessibleRole.hpp>
38 using namespace ::com::sun::star
;
39 using namespace ::com::sun::star::accessibility
;
41 using ::com::sun::star::uno::Reference
;
42 using ::com::sun::star::uno::Sequence
;
47 AccessibleTextHelper::AccessibleTextHelper(
48 DrawViewWrapper
* pDrawViewWrapper
) :
49 impl::AccessibleTextHelper_Base( m_aMutex
),
51 m_pDrawViewWrapper( pDrawViewWrapper
)
54 AccessibleTextHelper::~AccessibleTextHelper()
60 // ____ XInitialization ____
61 void SAL_CALL
AccessibleTextHelper::initialize( const Sequence
< uno::Any
>& aArguments
)
62 throw (uno::Exception
,
63 uno::RuntimeException
, std::exception
)
66 Reference
< XAccessible
> xEventSource
;
67 Reference
< awt::XWindow
> xWindow
;
69 if( aArguments
.getLength() >= 3 )
71 aArguments
[0] >>= aCID
;
72 aArguments
[1] >>= xEventSource
;
73 aArguments
[2] >>= xWindow
;
75 OSL_ENSURE( !aCID
.isEmpty(), "Empty CID" );
76 OSL_ENSURE( xEventSource
.is(), "Empty Event Source" );
77 OSL_ENSURE( xWindow
.is(), "Empty Window" );
78 if( !xEventSource
.is() || aCID
.isEmpty() )
81 SolarMutexGuard aSolarGuard
;
85 vcl::Window
* pWindow( VCLUnoHelper::GetWindow( xWindow
));
88 SdrView
* pView
= m_pDrawViewWrapper
;
91 SdrObject
* pTextObj
= m_pDrawViewWrapper
->getNamedSdrObject( aCID
);
94 std::unique_ptr
<SvxEditSource
> pEditSource(new SvxTextEditSource( *pTextObj
, 0, *pView
, *pWindow
));
95 m_pTextHelper
= new ::accessibility::AccessibleTextHelper(std::move(pEditSource
));
96 m_pTextHelper
->SetEventSource( xEventSource
);
101 OSL_ENSURE( m_pTextHelper
, "Couldn't create text helper" );
104 // ____ XAccessibleContext ____
105 ::sal_Int32 SAL_CALL
AccessibleTextHelper::getAccessibleChildCount()
106 throw (uno::RuntimeException
, std::exception
)
110 SolarMutexGuard aSolarGuard
;
111 return m_pTextHelper
->GetChildCount();
116 Reference
< XAccessible
> SAL_CALL
AccessibleTextHelper::getAccessibleChild( ::sal_Int32 i
)
117 throw (lang::IndexOutOfBoundsException
,
118 uno::RuntimeException
, std::exception
)
122 SolarMutexGuard aSolarGuard
;
123 return m_pTextHelper
->GetChild( i
);
125 return Reference
< XAccessible
>();
128 Reference
< XAccessible
> SAL_CALL
AccessibleTextHelper::getAccessibleParent()
129 throw (uno::RuntimeException
, std::exception
)
131 OSL_FAIL( "Not implemented in this helper" );
132 return Reference
< XAccessible
>();
135 ::sal_Int32 SAL_CALL
AccessibleTextHelper::getAccessibleIndexInParent()
136 throw (uno::RuntimeException
, std::exception
)
138 OSL_FAIL( "Not implemented in this helper" );
142 ::sal_Int16 SAL_CALL
AccessibleTextHelper::getAccessibleRole()
143 throw (uno::RuntimeException
, std::exception
)
145 OSL_FAIL( "Not implemented in this helper" );
146 return AccessibleRole::UNKNOWN
;
149 OUString SAL_CALL
AccessibleTextHelper::getAccessibleDescription()
150 throw (uno::RuntimeException
, std::exception
)
152 OSL_FAIL( "Not implemented in this helper" );
156 OUString SAL_CALL
AccessibleTextHelper::getAccessibleName()
157 throw (uno::RuntimeException
, std::exception
)
159 OSL_FAIL( "Not implemented in this helper" );
163 Reference
< XAccessibleRelationSet
> SAL_CALL
AccessibleTextHelper::getAccessibleRelationSet()
164 throw (uno::RuntimeException
, std::exception
)
166 OSL_FAIL( "Not implemented in this helper" );
167 return Reference
< XAccessibleRelationSet
>();
170 Reference
< XAccessibleStateSet
> SAL_CALL
AccessibleTextHelper::getAccessibleStateSet()
171 throw (uno::RuntimeException
, std::exception
)
173 OSL_FAIL( "Not implemented in this helper" );
174 return Reference
< XAccessibleStateSet
>();
177 lang::Locale SAL_CALL
AccessibleTextHelper::getLocale()
178 throw (IllegalAccessibleComponentStateException
,
179 uno::RuntimeException
, std::exception
)
181 OSL_FAIL( "Not implemented in this helper" );
182 return lang::Locale();
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */