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>
24 #include <AccessibleTextHelper.hxx>
25 #include <DrawViewWrapper.hxx>
27 #include <vcl/svapp.hxx>
29 #include <svx/AccessibleTextHelper.hxx>
30 #include <svx/unoshtxt.hxx>
31 #include <toolkit/helper/vclunohelper.hxx>
32 #include <vcl/window.hxx>
34 #include <com/sun/star/awt/XWindow.hpp>
35 #include <com/sun/star/accessibility/AccessibleRole.hpp>
36 #include <osl/diagnose.h>
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 m_pDrawViewWrapper( pDrawViewWrapper
)
52 AccessibleTextHelper::~AccessibleTextHelper()
56 void AccessibleTextHelper::initialize( const OUString
& aCID
,
57 const Reference
< XAccessible
>& xEventSource
,
58 const Reference
< awt::XWindow
>& xWindow
)
60 OSL_ENSURE( !aCID
.isEmpty(), "Empty CID" );
61 OSL_ENSURE( xEventSource
.is(), "Empty Event Source" );
62 OSL_ENSURE( xWindow
.is(), "Empty Window" );
63 if( !xEventSource
.is() || aCID
.isEmpty() )
66 SolarMutexGuard aSolarGuard
;
68 m_pTextHelper
.reset();
70 VclPtr
<vcl::Window
> pWindow( VCLUnoHelper::GetWindow( xWindow
));
73 SdrView
* pView
= m_pDrawViewWrapper
;
76 SdrObject
* pTextObj
= m_pDrawViewWrapper
->getNamedSdrObject( aCID
);
79 m_pTextHelper
.reset( new ::accessibility::AccessibleTextHelper(std::make_unique
<SvxTextEditSource
>(*pTextObj
, nullptr, *pView
, *pWindow
->GetOutDev())) );
80 m_pTextHelper
->SetEventSource( xEventSource
);
85 OSL_ENSURE( m_pTextHelper
, "Couldn't create text helper" );
88 // ____ XAccessibleContext ____
89 sal_Int64 SAL_CALL
AccessibleTextHelper::getAccessibleChildCount()
93 SolarMutexGuard aSolarGuard
;
94 return m_pTextHelper
->GetChildCount();
99 Reference
< XAccessible
> SAL_CALL
AccessibleTextHelper::getAccessibleChild( sal_Int64 i
)
103 SolarMutexGuard aSolarGuard
;
104 return m_pTextHelper
->GetChild( i
);
106 return Reference
< XAccessible
>();
109 Reference
< XAccessible
> SAL_CALL
AccessibleTextHelper::getAccessibleParent()
111 OSL_FAIL( "Not implemented in this helper" );
112 return Reference
< XAccessible
>();
115 sal_Int64 SAL_CALL
AccessibleTextHelper::getAccessibleIndexInParent()
117 OSL_FAIL( "Not implemented in this helper" );
121 ::sal_Int16 SAL_CALL
AccessibleTextHelper::getAccessibleRole()
123 OSL_FAIL( "Not implemented in this helper" );
124 return AccessibleRole::UNKNOWN
;
127 OUString SAL_CALL
AccessibleTextHelper::getAccessibleDescription()
129 OSL_FAIL( "Not implemented in this helper" );
133 OUString SAL_CALL
AccessibleTextHelper::getAccessibleName()
135 OSL_FAIL( "Not implemented in this helper" );
139 Reference
< XAccessibleRelationSet
> SAL_CALL
AccessibleTextHelper::getAccessibleRelationSet()
141 OSL_FAIL( "Not implemented in this helper" );
142 return Reference
< XAccessibleRelationSet
>();
145 sal_Int64 SAL_CALL
AccessibleTextHelper::getAccessibleStateSet()
147 OSL_FAIL( "Not implemented in this helper" );
151 lang::Locale SAL_CALL
AccessibleTextHelper::getLocale()
153 OSL_FAIL( "Not implemented in this helper" );
154 return lang::Locale();
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */