fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / controller / accessibility / AccessibleChartElement.cxx
blobb92b64cd6bbafc34b58d577318687d20d9001341
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 "AccessibleChartElement.hxx"
21 #include "CharacterProperties.hxx"
22 #include "ObjectIdentifier.hxx"
23 #include "ObjectNameProvider.hxx"
24 #include "servicenames.hxx"
25 #include "macros.hxx"
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>
33 #include <vcl/svapp.hxx>
34 #include <rtl/ustrbuf.hxx>
36 using namespace ::com::sun::star;
37 using namespace ::com::sun::star::accessibility;
39 using ::com::sun::star::uno::UNO_QUERY;
40 using ::com::sun::star::uno::Reference;
41 using ::com::sun::star::uno::Sequence;
42 using ::osl::MutexGuard;
43 using ::osl::ClearableMutexGuard;
44 using ::osl::ResettableMutexGuard;
45 using ::com::sun::star::uno::RuntimeException;
46 using ::com::sun::star::uno::Any;
48 namespace chart
51 AccessibleChartElement::AccessibleChartElement(
52 const AccessibleElementInfo & rAccInfo,
53 bool bMayHaveChildren,
54 bool bAlwaysTransparent /* default: false */ ) :
55 impl::AccessibleChartElement_Base( rAccInfo, bMayHaveChildren, bAlwaysTransparent ),
56 m_bHasText( false )
58 AddState( AccessibleStateType::TRANSIENT );
61 AccessibleChartElement::~AccessibleChartElement()
63 OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) );
66 // ________ protected ________
68 bool AccessibleChartElement::ImplUpdateChildren()
70 bool bResult = false;
71 Reference< chart2::XTitle > xTitle(
72 ObjectIdentifier::getObjectPropertySet(
73 GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )),
74 uno::UNO_QUERY );
75 m_bHasText = xTitle.is();
77 if( m_bHasText )
79 InitTextEdit();
80 bResult = true;
82 else
83 bResult = AccessibleBase::ImplUpdateChildren();
85 return bResult;
88 void AccessibleChartElement::InitTextEdit()
90 if( ! m_xTextHelper.is())
92 // get hard reference
93 Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier );
94 // get factory from selection supplier (controller)
95 Reference< lang::XMultiServiceFactory > xFact( xSelSupp, uno::UNO_QUERY );
96 if( xFact.is())
98 m_xTextHelper.set(
99 xFact->createInstance( CHART_ACCESSIBLE_TEXT_SERVICE_NAME ), uno::UNO_QUERY );
103 if( m_xTextHelper.is())
106 Reference< lang::XInitialization > xInit( m_xTextHelper, uno::UNO_QUERY_THROW );
107 Sequence< uno::Any > aArgs( 3 );
108 aArgs[0] <<= GetInfo().m_aOID.getObjectCID();
109 aArgs[1] <<= Reference< XAccessible >( this );
110 aArgs[2] <<= Reference< awt::XWindow >( GetInfo().m_xWindow );
111 xInit->initialize( aArgs );
113 catch( const uno::Exception & ex )
115 ASSERT_EXCEPTION( ex );
119 // Interfaces
121 // ________ AccessibleBase::XAccessibleContext ________
122 Reference< XAccessible > AccessibleChartElement::ImplGetAccessibleChildById( sal_Int32 i ) const
123 throw (lang::IndexOutOfBoundsException, RuntimeException)
125 Reference< XAccessible > xResult;
127 if( m_bHasText )
128 xResult.set( m_xTextHelper->getAccessibleChild( i ));
129 else
130 xResult.set( AccessibleBase::ImplGetAccessibleChildById( i ));
132 return xResult;
135 sal_Int32 AccessibleChartElement::ImplGetAccessibleChildCount() const
136 throw (RuntimeException)
138 if( m_bHasText )
140 if( m_xTextHelper.is())
141 return m_xTextHelper->getAccessibleChildCount();
142 return 0;
145 return AccessibleBase::ImplGetAccessibleChildCount();
148 // ________ XServiceInfo ________
149 OUString SAL_CALL AccessibleChartElement::getImplementationName()
150 throw (RuntimeException, std::exception)
152 return OUString( "AccessibleChartElement" );
155 // ________ AccessibleChartElement::XAccessibleContext (override) ________
156 OUString SAL_CALL AccessibleChartElement::getAccessibleName()
157 throw (::com::sun::star::uno::RuntimeException, std::exception)
159 return ObjectNameProvider::getNameForCID(
160 GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument );
163 // ________ AccessibleChartElement::XAccessibleContext (override) ________
164 OUString SAL_CALL AccessibleChartElement::getAccessibleDescription()
165 throw (::com::sun::star::uno::RuntimeException, std::exception)
167 return getToolTipText();
170 // ________ AccessibleChartElement::XAccessibleExtendedComponent ________
171 Reference< awt::XFont > SAL_CALL AccessibleChartElement::getFont()
172 throw (uno::RuntimeException, std::exception)
174 CheckDisposeState();
176 Reference< awt::XFont > xFont;
177 // using assignment for broken gcc 3.3
178 Reference< awt::XDevice > xDevice = Reference< awt::XDevice >(
179 Reference< awt::XWindow >( GetInfo().m_xWindow ), uno::UNO_QUERY );
181 if( xDevice.is())
183 Reference< beans::XMultiPropertySet > xObjProp(
184 ObjectIdentifier::getObjectPropertySet(
185 GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )), uno::UNO_QUERY );
186 awt::FontDescriptor aDescr(
187 CharacterProperties::createFontDescriptorFromPropertySet( xObjProp ));
188 xFont = xDevice->getFont( aDescr );
191 return xFont;
194 OUString SAL_CALL AccessibleChartElement::getTitledBorderText()
195 throw (uno::RuntimeException, std::exception)
197 return OUString();
200 OUString SAL_CALL AccessibleChartElement::getToolTipText()
201 throw (::com::sun::star::uno::RuntimeException, std::exception)
203 CheckDisposeState();
205 return ObjectNameProvider::getHelpText(
206 GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument ));
209 // ________ XAccessibleComponent ________
210 sal_Bool SAL_CALL AccessibleChartElement::containsPoint( const awt::Point& aPoint )
211 throw (uno::RuntimeException, std::exception)
213 return AccessibleBase::containsPoint( aPoint );
216 Reference< XAccessible > SAL_CALL AccessibleChartElement::getAccessibleAtPoint( const awt::Point& aPoint )
217 throw (uno::RuntimeException, std::exception)
219 return AccessibleBase::getAccessibleAtPoint( aPoint );
222 awt::Rectangle SAL_CALL AccessibleChartElement::getBounds()
223 throw (uno::RuntimeException, std::exception)
225 return AccessibleBase::getBounds();
228 awt::Point SAL_CALL AccessibleChartElement::getLocation()
229 throw (uno::RuntimeException, std::exception)
231 return AccessibleBase::getLocation();
234 awt::Point SAL_CALL AccessibleChartElement::getLocationOnScreen()
235 throw (uno::RuntimeException, std::exception)
237 return AccessibleBase::getLocationOnScreen();
240 awt::Size SAL_CALL AccessibleChartElement::getSize()
241 throw (uno::RuntimeException, std::exception)
243 return AccessibleBase::getSize();
246 void SAL_CALL AccessibleChartElement::grabFocus()
247 throw (uno::RuntimeException, std::exception)
249 return AccessibleBase::grabFocus();
252 sal_Int32 SAL_CALL AccessibleChartElement::getForeground()
253 throw (uno::RuntimeException, std::exception)
255 return AccessibleBase::getForeground();
258 sal_Int32 SAL_CALL AccessibleChartElement::getBackground()
259 throw (uno::RuntimeException, std::exception)
261 return AccessibleBase::getBackground();
264 } // namespace chart
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */