Debian Codegraph @

chart2/source/controller/accessibility/AccessibleChartElement.cxx

raw
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
20 #include "AccessibleChartElement.hxx"
21 #include <AccessibleTextHelper.hxx>
22 #include <ChartModel.hxx>
23 #include <ChartController.hxx>
24 #include <ObjectIdentifier.hxx>
25 #include <ObjectNameProvider.hxx>
26
27 #include <com/sun/star/chart2/XTitle.hpp>
28 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
29
30 using namespace ::com::sun::star;
31 using namespace ::com::sun::star::accessibility;
32
33 using ::com::sun::star::uno::UNO_QUERY;
34 using ::com::sun::star::uno::Reference;
35
36 namespace chart
37 {
38
39 AccessibleChartElement::AccessibleChartElement(
40 const AccessibleElementInfo & rAccInfo,
41 bool bMayHaveChildren ) :
42 AccessibleBase(rAccInfo, bMayHaveChildren, false/*bAlwaysTransparent*/),
43 m_bHasText( false )
44 {
45 AddState( AccessibleStateType::TRANSIENT );
46 }
47
48 AccessibleChartElement::~AccessibleChartElement()
49 {
50 OSL_ASSERT(!isAlive());
51 }
52
53 // ________ protected ________
54
55 bool AccessibleChartElement::ImplUpdateChildren()
56 {
57 bool bResult = false;
58 Reference< chart2::XTitle > xTitle(
59 ObjectIdentifier::getObjectPropertySet(
60 GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument ),
61 uno::UNO_QUERY );
62 m_bHasText = xTitle.is();
63
64 if( m_bHasText )
65 {
66 InitTextEdit();
67 bResult = true;
68 }
69 else
70 bResult = AccessibleBase::ImplUpdateChildren();
71
72 return bResult;
73 }
74
75 void AccessibleChartElement::InitTextEdit()
76 {
77 if( ! m_xTextHelper.is())
78 {
79 // get hard reference
80 rtl::Reference< ::chart::ChartController > xChartController( GetInfo().m_xChartController );
81 if( xChartController.is())
82 m_xTextHelper = xChartController->createAccessibleTextContext();
83 }
84
85 if( !m_xTextHelper.is())
86 return;
87
88 m_xTextHelper->initialize(GetInfo().m_aOID.getObjectCID(), this, GetInfo().m_pWindow);
89 }
90
91 // Interfaces
92
93 // ________ AccessibleBase::XAccessibleContext ________
94 Reference< XAccessible > AccessibleChartElement::ImplGetAccessibleChildById( sal_Int64 i ) const
95 {
96 Reference< XAccessible > xResult;
97
98 if( m_bHasText )
99 xResult.set( m_xTextHelper->getAccessibleChild( i ));
100 else
101 xResult.set( AccessibleBase::ImplGetAccessibleChildById( i ));
102
103 return xResult;
104 }
105
106 sal_Int64 AccessibleChartElement::ImplGetAccessibleChildCount() const
107 {
108 if( m_bHasText )
109 {
110 if( m_xTextHelper.is())
111 return m_xTextHelper->getAccessibleChildCount();
112 return 0;
113 }
114
115 return AccessibleBase::ImplGetAccessibleChildCount();
116 }
117
118 // ________ AccessibleChartElement::XAccessibleContext (override) ________
119 OUString SAL_CALL AccessibleChartElement::getAccessibleName()
120 {
121 return ObjectNameProvider::getNameForCID(
122 GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument );
123 }
124
125 // ________ AccessibleChartElement::XAccessibleContext (override) ________
126 OUString SAL_CALL AccessibleChartElement::getAccessibleDescription()
127 {
128 return getToolTipText();
129 }
130
131 // ________ AccessibleChartElement::XAccessibleExtendedComponent ________
132
133 OUString SAL_CALL AccessibleChartElement::getToolTipText()
134 {
135 ensureAlive();
136
137 return ObjectNameProvider::getHelpText(
138 GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument );
139 }
140
141 } // namespace chart
142
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */