Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / chart2 / source / controller / accessibility / AccessibleTextHelper.cxx
blob598466ae70a47f91f526d3d43b8b2e0047e232a0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
22 #include <memory>
23 #include <utility>
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;
43 namespace chart
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 )
60 OUString aCID;
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() )
74 return;
76 SolarMutexGuard aSolarGuard;
78 m_pTextHelper.reset();
80 VclPtr<vcl::Window> pWindow( VCLUnoHelper::GetWindow( xWindow ));
81 if( pWindow )
83 SdrView * pView = m_pDrawViewWrapper;
84 if( pView )
86 SdrObject * pTextObj = m_pDrawViewWrapper->getNamedSdrObject( aCID );
87 if( pTextObj )
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()
101 if( m_pTextHelper )
103 SolarMutexGuard aSolarGuard;
104 return m_pTextHelper->GetChildCount();
106 return 0;
109 Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleChild( ::sal_Int32 i )
111 if( m_pTextHelper )
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" );
128 return -1;
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" );
140 return OUString();
143 OUString SAL_CALL AccessibleTextHelper::getAccessibleName()
145 OSL_FAIL( "Not implemented in this helper" );
146 return OUString();
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();
167 } // namespace chart
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */