1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleChartElement.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "AccessibleChartElement.hxx"
35 #include "CharacterProperties.hxx"
36 #include "ObjectIdentifier.hxx"
37 #include "ObjectNameProvider.hxx"
38 #include "servicenames.hxx"
41 #include <com/sun/star/awt/XDevice.hpp>
42 #include <com/sun/star/chart2/XTitle.hpp>
43 #include <com/sun/star/beans/XMultiPropertySet.hpp>
44 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
45 #include <com/sun/star/lang/XInitialization.hpp>
48 #include <vcl/svapp.hxx>
49 #include <rtl/ustrbuf.hxx>
51 // #ifndef _RTL_UUID_H_
52 // #include <rtl/uuid.h>
54 // #ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
55 // #include <cppuhelper/queryinterface.hxx>
57 // #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
58 // #include <toolkit/helper/vclunohelper.hxx>
60 // #ifndef _SV_WINDOW_HXX
61 // #include <vcl/window.hxx>
64 // #ifndef _SVX_ACCESSILE_TEXT_HELPER_HXX_
65 // #include <svx/AccessibleTextHelper.hxx>
68 using namespace ::com::sun::star
;
69 using namespace ::com::sun::star::accessibility
;
71 using ::com::sun::star::uno::UNO_QUERY
;
72 using ::rtl::OUString
;
73 using ::rtl::OUStringBuffer
;
74 using ::com::sun::star::uno::Reference
;
75 using ::com::sun::star::uno::Sequence
;
76 using ::osl::MutexGuard
;
77 using ::osl::ClearableMutexGuard
;
78 using ::osl::ResettableMutexGuard
;
79 using ::com::sun::star::uno::RuntimeException
;
80 using ::com::sun::star::uno::Any
;
85 AccessibleChartElement::AccessibleChartElement(
86 const AccessibleElementInfo
& rAccInfo
,
87 bool bMayHaveChildren
,
88 bool bAlwaysTransparent
/* default: false */ ) :
89 impl::AccessibleChartElement_Base( rAccInfo
, bMayHaveChildren
, bAlwaysTransparent
),
92 AddState( AccessibleStateType::TRANSIENT
);
95 AccessibleChartElement::~AccessibleChartElement()
97 OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) );
100 // ________ protected ________
102 bool AccessibleChartElement::ImplUpdateChildren()
104 bool bResult
= false;
105 Reference
< chart2::XTitle
> xTitle(
106 ObjectIdentifier::getObjectPropertySet(
107 GetInfo().m_aCID
, Reference
< chart2::XChartDocument
>( GetInfo().m_xChartDocument
)),
109 m_bHasText
= xTitle
.is();
117 bResult
= AccessibleBase::ImplUpdateChildren();
122 void AccessibleChartElement::InitTextEdit()
124 if( ! m_xTextHelper
.is())
126 // get hard reference
127 Reference
< view::XSelectionSupplier
> xSelSupp( GetInfo().m_xSelectionSupplier
);
128 // get factory from selection supplier (controller)
129 Reference
< lang::XMultiServiceFactory
> xFact( xSelSupp
, uno::UNO_QUERY
);
133 xFact
->createInstance( CHART_ACCESSIBLE_TEXT_SERVICE_NAME
), uno::UNO_QUERY
);
137 if( m_xTextHelper
.is())
140 Reference
< lang::XInitialization
> xInit( m_xTextHelper
, uno::UNO_QUERY_THROW
);
141 Sequence
< uno::Any
> aArgs( 3 );
142 aArgs
[0] <<= GetInfo().m_aCID
;
143 aArgs
[1] <<= Reference
< XAccessible
>( this );
144 aArgs
[2] <<= Reference
< awt::XWindow
>( GetInfo().m_xWindow
);
145 xInit
->initialize( aArgs
);
147 catch( const uno::Exception
& ex
)
149 ASSERT_EXCEPTION( ex
);
152 // OSL_ASSERT( m_pTextHelper == 0 );
155 // ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
156 // Window* pWindow( VCLUnoHelper::GetWindow( GetInfo().m_xWindow ));
159 // // we need ChartController::m_pDrawViewWrapper here
160 // SdrView * pView = 0;
163 // SdrObject * pTextObj = m_pDrawViewWrapper->getTextEditObject();
166 // SvxEditSource * pEditSource = new SvxEditSource( pTextObj, pView, pWindow );
167 // m_pTextHelper = new ::accessibility::AccessibleTextHelper(
168 // ::std::auto_ptr< SvxEditSource >( pEditSource ));
169 // if( m_pTextHelper )
170 // m_pTextHelper->SetEventSource( this );
177 // ____________________________________
178 // ____________________________________
181 // ____________________________________
182 // ____________________________________
184 // ________ AccessibleBase::XAccessibleContext ________
185 Reference
< XAccessible
> AccessibleChartElement::ImplGetAccessibleChildById( sal_Int32 i
) const
186 throw (lang::IndexOutOfBoundsException
, RuntimeException
)
188 Reference
< XAccessible
> xResult
;
192 xResult
.set( m_xTextHelper
->getAccessibleChild( i
));
194 // ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
195 // if( m_pTextHelper )
196 // xResult.set( m_pTextHelper->GetChild( i ) );
200 xResult
.set( AccessibleBase::ImplGetAccessibleChildById( i
));
205 sal_Int32
AccessibleChartElement::ImplGetAccessibleChildCount() const
206 throw (RuntimeException
)
210 if( m_xTextHelper
.is())
211 return m_xTextHelper
->getAccessibleChildCount();
215 return AccessibleBase::ImplGetAccessibleChildCount();
218 // ________ XServiceInfo ________
219 OUString SAL_CALL
AccessibleChartElement::getImplementationName()
220 throw (RuntimeException
)
222 return OUString( RTL_CONSTASCII_USTRINGPARAM( "AccessibleChartElement" ));
225 // ________ AccessibleChartElement::XAccessibleContext (overloaded) ________
226 OUString SAL_CALL
AccessibleChartElement::getAccessibleName()
227 throw (::com::sun::star::uno::RuntimeException
)
229 return ObjectNameProvider::getNameForCID(
230 GetInfo().m_aCID
, GetInfo().m_xChartDocument
);
233 // ________ AccessibleChartElement::XAccessibleContext (overloaded) ________
234 OUString SAL_CALL
AccessibleChartElement::getAccessibleDescription()
235 throw (::com::sun::star::uno::RuntimeException
)
237 return getToolTipText();
240 // ________ AccessibleChartElement::XAccessibleExtendedComponent ________
241 Reference
< awt::XFont
> SAL_CALL
AccessibleChartElement::getFont()
242 throw (uno::RuntimeException
)
246 Reference
< awt::XFont
> xFont
;
247 // using assignment for broken gcc 3.3
248 Reference
< awt::XDevice
> xDevice
= Reference
< awt::XDevice
>(
249 Reference
< awt::XWindow
>( GetInfo().m_xWindow
), uno::UNO_QUERY
);
253 Reference
< beans::XMultiPropertySet
> xObjProp(
254 ObjectIdentifier::getObjectPropertySet(
255 GetInfo().m_aCID
, Reference
< chart2::XChartDocument
>( GetInfo().m_xChartDocument
)), uno::UNO_QUERY
);
256 awt::FontDescriptor
aDescr(
257 CharacterProperties::createFontDescriptorFromPropertySet( xObjProp
));
258 xFont
= xDevice
->getFont( aDescr
);
264 OUString SAL_CALL
AccessibleChartElement::getTitledBorderText()
265 throw (uno::RuntimeException
)
270 OUString SAL_CALL
AccessibleChartElement::getToolTipText()
271 throw (::com::sun::star::uno::RuntimeException
)
275 return ObjectNameProvider::getHelpText(
276 GetInfo().m_aCID
, Reference
< chart2::XChartDocument
>( GetInfo().m_xChartDocument
));
279 // ________ XAccessibleComponent ________
280 sal_Bool SAL_CALL
AccessibleChartElement::containsPoint( const awt::Point
& aPoint
)
281 throw (uno::RuntimeException
)
283 return AccessibleBase::containsPoint( aPoint
);
286 Reference
< accessibility::XAccessible
> SAL_CALL
AccessibleChartElement::getAccessibleAtPoint( const awt::Point
& aPoint
)
287 throw (uno::RuntimeException
)
289 return AccessibleBase::getAccessibleAtPoint( aPoint
);
292 awt::Rectangle SAL_CALL
AccessibleChartElement::getBounds()
293 throw (uno::RuntimeException
)
295 return AccessibleBase::getBounds();
298 awt::Point SAL_CALL
AccessibleChartElement::getLocation()
299 throw (uno::RuntimeException
)
301 return AccessibleBase::getLocation();
304 awt::Point SAL_CALL
AccessibleChartElement::getLocationOnScreen()
305 throw (uno::RuntimeException
)
307 return AccessibleBase::getLocationOnScreen();
310 awt::Size SAL_CALL
AccessibleChartElement::getSize()
311 throw (uno::RuntimeException
)
313 return AccessibleBase::getSize();
316 void SAL_CALL
AccessibleChartElement::grabFocus()
317 throw (uno::RuntimeException
)
319 return AccessibleBase::grabFocus();
322 sal_Int32 SAL_CALL
AccessibleChartElement::getForeground()
323 throw (uno::RuntimeException
)
325 return AccessibleBase::getForeground();
328 sal_Int32 SAL_CALL
AccessibleChartElement::getBackground()
329 throw (uno::RuntimeException
)
331 return AccessibleBase::getBackground();