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