LibreOffice Module chart2 (master) 1
AccessibleChartElement.cxx
Go to the documentation of this file.
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
22#include <ChartModel.hxx>
23#include <ObjectIdentifier.hxx>
25#include <servicenames.hxx>
26
27#include <com/sun/star/awt/XDevice.hpp>
28#include <com/sun/star/chart2/XTitle.hpp>
29#include <com/sun/star/beans/XMultiPropertySet.hpp>
30#include <com/sun/star/accessibility/AccessibleStateType.hpp>
31#include <com/sun/star/lang/XInitialization.hpp>
32#include <com/sun/star/lang/XMultiServiceFactory.hpp>
33#include <com/sun/star/view/XSelectionSupplier.hpp>
34
36
37using namespace ::com::sun::star;
38using namespace ::com::sun::star::accessibility;
39
40using ::com::sun::star::uno::UNO_QUERY;
41using ::com::sun::star::uno::Reference;
42using ::com::sun::star::uno::Sequence;
43
44namespace chart
45{
46
48 const AccessibleElementInfo & rAccInfo,
49 bool bMayHaveChildren ) :
50 impl::AccessibleChartElement_Base( rAccInfo, bMayHaveChildren, false/*bAlwaysTransparent*/ ),
51 m_bHasText( false )
52{
53 AddState( AccessibleStateType::TRANSIENT );
54}
55
57{
58 OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) );
59}
60
61// ________ protected ________
62
64{
65 bool bResult = false;
68 GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument ),
69 uno::UNO_QUERY );
70 m_bHasText = xTitle.is();
71
72 if( m_bHasText )
73 {
75 bResult = true;
76 }
77 else
79
80 return bResult;
81}
82
84{
85 if( ! m_xTextHelper.is())
86 {
87 // get hard reference
88 Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier );
89 // get factory from selection supplier (controller)
90 Reference< lang::XMultiServiceFactory > xFact( xSelSupp, uno::UNO_QUERY );
91 if( xFact.is())
92 {
93 m_xTextHelper.set(
94 xFact->createInstance( CHART_ACCESSIBLE_TEXT_SERVICE_NAME ), uno::UNO_QUERY );
95 }
96 }
97
98 if( !m_xTextHelper.is())
99 return;
100
101 try
102 {
103 Reference< lang::XInitialization > xInit( m_xTextHelper, uno::UNO_QUERY_THROW );
104 Sequence< uno::Any > aArgs{ uno::Any(GetInfo().m_aOID.getObjectCID()),
107 xInit->initialize( aArgs );
108 }
109 catch( const uno::Exception & )
110 {
111 DBG_UNHANDLED_EXCEPTION("chart2");
112 }
113}
114
115// Interfaces
116
117// ________ AccessibleBase::XAccessibleContext ________
119{
121
122 if( m_bHasText )
123 xResult.set( m_xTextHelper->getAccessibleChild( i ));
124 else
126
127 return xResult;
128}
129
131{
132 if( m_bHasText )
133 {
134 if( m_xTextHelper.is())
135 return m_xTextHelper->getAccessibleChildCount();
136 return 0;
137 }
138
140}
141
142// ________ XServiceInfo ________
144{
145 return "AccessibleChartElement";
146}
147
148// ________ AccessibleChartElement::XAccessibleContext (override) ________
150{
152 GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument );
153}
154
155// ________ AccessibleChartElement::XAccessibleContext (override) ________
157{
158 return getToolTipText();
159}
160
161// ________ AccessibleChartElement::XAccessibleExtendedComponent ________
163{
164 CheckDisposeState();
165
167 Reference< awt::XDevice > xDevice( Reference< awt::XWindow >( GetInfo().m_xWindow ), uno::UNO_QUERY );
168
169 if( xDevice.is())
170 {
173 GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument ), uno::UNO_QUERY );
174 awt::FontDescriptor aDescr(
176 xFont = xDevice->getFont( aDescr );
177 }
178
179 return xFont;
180}
181
183{
184 return OUString();
185}
186
188{
189 CheckDisposeState();
190
192 GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument );
193}
194
195// ________ XAccessibleComponent ________
196sal_Bool SAL_CALL AccessibleChartElement::containsPoint( const awt::Point& aPoint )
197{
198 return AccessibleBase::containsPoint( aPoint );
199}
200
202{
204}
205
206awt::Rectangle SAL_CALL AccessibleChartElement::getBounds()
207{
209}
210
212{
214}
215
217{
219}
220
222{
224}
225
227{
229}
230
232{
234}
235
237{
239}
240
241} // namespace chart
242
243/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< css::accessibility::XAccessible > ImplGetAccessibleChildById(sal_Int64 i) const
Is called from getAccessibleChild().
virtual sal_Int64 ImplGetAccessibleChildCount() const
Is called from getAccessibleChildCount().
virtual sal_Int32 SAL_CALL getBackground() override
virtual css::awt::Rectangle SAL_CALL getBounds() override
virtual css::awt::Size SAL_CALL getSize() override
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
virtual css::awt::Point SAL_CALL getLocation() override
virtual void SAL_CALL grabFocus() override
virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point &aPoint) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
virtual sal_Int32 SAL_CALL getForeground() override
virtual bool ImplUpdateChildren()
Is called by UpdateChildren.
virtual sal_Int32 SAL_CALL getForeground() override
virtual sal_Int32 SAL_CALL getBackground() override
virtual css::awt::Rectangle SAL_CALL getBounds() override
virtual css::uno::Reference< css::awt::XFont > SAL_CALL getFont() override
virtual sal_Int64 ImplGetAccessibleChildCount() const override
virtual css::awt::Point SAL_CALL getLocation() override
virtual OUString SAL_CALL getAccessibleDescription() override
virtual OUString SAL_CALL getImplementationName() override
AccessibleChartElement(const AccessibleElementInfo &rAccInfo, bool bMayHaveChildren)
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
virtual OUString SAL_CALL getTitledBorderText() override
virtual void SAL_CALL grabFocus() override
virtual OUString SAL_CALL getAccessibleName() override
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
css::uno::Reference< css::accessibility::XAccessibleContext > m_xTextHelper
virtual css::awt::Size SAL_CALL getSize() override
virtual OUString SAL_CALL getToolTipText() override
virtual sal_Bool SAL_CALL containsPoint(const css::awt::Point &aPoint) override
virtual bool ImplUpdateChildren() override
virtual css::uno::Reference< css::accessibility::XAccessible > ImplGetAccessibleChildById(sal_Int64 i) const override
static css::uno::Reference< css::beans::XPropertySet > getObjectPropertySet(std::u16string_view rObjectCID, const rtl::Reference< ::chart::ChartModel > &xChartDocument)
static OUString getHelpText(std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel > &xChartModel, bool bVerbose=false)
Provides help texts for the various chart elements.
static OUString getNameForCID(std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel > &xChartDocument)
#define DBG_UNHANDLED_EXCEPTION(...)
OOO_DLLPUBLIC_CHARTTOOLS css::awt::FontDescriptor createFontDescriptorFromPropertySet(const css::uno::Reference< css::beans::XMultiPropertySet > &xMultiPropSet)
::cppu::ImplInheritanceHelper< AccessibleBase, css::accessibility::XAccessibleExtendedComponent > AccessibleChartElement_Base
int i
constexpr OUStringLiteral CHART_ACCESSIBLE_TEXT_SERVICE_NAME
unsigned char sal_Bool