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>
30 #include <svx/AccessibleTextHelper.hxx>
31 #include <svx/unoshtxt.hxx>
32 #include <toolkit/helper/vclunohelper.hxx>
33 #include <vcl/window.hxx>
35 #include <com/sun/star/accessibility/AccessibleRole.hpp>
36 #include <o3tl/make_unique.hxx>
37 using namespace ::com::sun::star
;
38 using namespace ::com::sun::star::accessibility
;
40 using ::com::sun::star::uno::Reference
;
41 using ::com::sun::star::uno::Sequence
;
46 AccessibleTextHelper::AccessibleTextHelper(
47 DrawViewWrapper
* pDrawViewWrapper
) :
48 impl::AccessibleTextHelper_Base( m_aMutex
),
49 m_pTextHelper( nullptr ),
50 m_pDrawViewWrapper( pDrawViewWrapper
)
53 AccessibleTextHelper::~AccessibleTextHelper()
57 // ____ XInitialization ____
58 void SAL_CALL
AccessibleTextHelper::initialize( const Sequence
< uno::Any
>& aArguments
)
61 Reference
< XAccessible
> xEventSource
;
62 Reference
< awt::XWindow
> xWindow
;
64 if( aArguments
.getLength() >= 3 )
66 aArguments
[0] >>= aCID
;
67 aArguments
[1] >>= xEventSource
;
68 aArguments
[2] >>= xWindow
;
70 OSL_ENSURE( !aCID
.isEmpty(), "Empty CID" );
71 OSL_ENSURE( xEventSource
.is(), "Empty Event Source" );
72 OSL_ENSURE( xWindow
.is(), "Empty Window" );
73 if( !xEventSource
.is() || aCID
.isEmpty() )
76 SolarMutexGuard aSolarGuard
;
78 m_pTextHelper
.reset();
80 VclPtr
<vcl::Window
> pWindow( VCLUnoHelper::GetWindow( xWindow
));
83 SdrView
* pView
= m_pDrawViewWrapper
;
86 SdrObject
* pTextObj
= m_pDrawViewWrapper
->getNamedSdrObject( aCID
);
89 m_pTextHelper
.reset( new ::accessibility::AccessibleTextHelper(o3tl::make_unique
<SvxTextEditSource
>(*pTextObj
, nullptr, *pView
, *pWindow
)) );
90 m_pTextHelper
->SetEventSource( xEventSource
);
95 OSL_ENSURE( m_pTextHelper
, "Couldn't create text helper" );
98 // ____ XAccessibleContext ____
99 ::sal_Int32 SAL_CALL
AccessibleTextHelper::getAccessibleChildCount()
103 SolarMutexGuard aSolarGuard
;
104 return m_pTextHelper
->GetChildCount();
109 Reference
< XAccessible
> SAL_CALL
AccessibleTextHelper::getAccessibleChild( ::sal_Int32 i
)
113 SolarMutexGuard aSolarGuard
;
114 return m_pTextHelper
->GetChild( i
);
116 return Reference
< XAccessible
>();
119 Reference
< XAccessible
> SAL_CALL
AccessibleTextHelper::getAccessibleParent()
121 OSL_FAIL( "Not implemented in this helper" );
122 return Reference
< XAccessible
>();
125 ::sal_Int32 SAL_CALL
AccessibleTextHelper::getAccessibleIndexInParent()
127 OSL_FAIL( "Not implemented in this helper" );
131 ::sal_Int16 SAL_CALL
AccessibleTextHelper::getAccessibleRole()
133 OSL_FAIL( "Not implemented in this helper" );
134 return AccessibleRole::UNKNOWN
;
137 OUString SAL_CALL
AccessibleTextHelper::getAccessibleDescription()
139 OSL_FAIL( "Not implemented in this helper" );
143 OUString SAL_CALL
AccessibleTextHelper::getAccessibleName()
145 OSL_FAIL( "Not implemented in this helper" );
149 Reference
< XAccessibleRelationSet
> SAL_CALL
AccessibleTextHelper::getAccessibleRelationSet()
151 OSL_FAIL( "Not implemented in this helper" );
152 return Reference
< XAccessibleRelationSet
>();
155 Reference
< XAccessibleStateSet
> SAL_CALL
AccessibleTextHelper::getAccessibleStateSet()
157 OSL_FAIL( "Not implemented in this helper" );
158 return Reference
< XAccessibleStateSet
>();
161 lang::Locale SAL_CALL
AccessibleTextHelper::getLocale()
163 OSL_FAIL( "Not implemented in this helper" );
164 return lang::Locale();
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */