1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "AccessibleChartElement.hxx"
#include <CharacterProperties.hxx>
#include <ObjectIdentifier.hxx>
#include <ObjectNameProvider.hxx>
#include <servicenames.hxx>
#include <com/sun/star/awt/XDevice.hpp>
#include <com/sun/star/chart2/XTitle.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <tools/diagnose_ex.h>
using namespace ::com::sun::star;
using namespace ::com::sun::star::accessibility;
using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
namespace chart
{
AccessibleChartElement::AccessibleChartElement(
const AccessibleElementInfo & rAccInfo,
bool bMayHaveChildren ) :
impl::AccessibleChartElement_Base( rAccInfo, bMayHaveChildren, false/*bAlwaysTransparent*/ ),
m_bHasText( false )
{
AddState( AccessibleStateType::TRANSIENT );
}
AccessibleChartElement::~AccessibleChartElement()
{
OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) );
}
// ________ protected ________
bool AccessibleChartElement::ImplUpdateChildren()
{
bool bResult = false;
Reference< chart2::XTitle > xTitle(
ObjectIdentifier::getObjectPropertySet(
GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )),
uno::UNO_QUERY );
m_bHasText = xTitle.is();
if( m_bHasText )
{
InitTextEdit();
bResult = true;
}
else
bResult = AccessibleBase::ImplUpdateChildren();
return bResult;
}
void AccessibleChartElement::InitTextEdit()
{
if( ! m_xTextHelper.is())
{
// get hard reference
Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier );
// get factory from selection supplier (controller)
Reference< lang::XMultiServiceFactory > xFact( xSelSupp, uno::UNO_QUERY );
if( xFact.is())
{
m_xTextHelper.set(
xFact->createInstance( CHART_ACCESSIBLE_TEXT_SERVICE_NAME ), uno::UNO_QUERY );
}
}
if( !m_xTextHelper.is())
return;
try
{
Reference< lang::XInitialization > xInit( m_xTextHelper, uno::UNO_QUERY_THROW );
Sequence< uno::Any > aArgs( 3 );
aArgs[0] <<= GetInfo().m_aOID.getObjectCID();
aArgs[1] <<= Reference< XAccessible >( this );
aArgs[2] <<= Reference< awt::XWindow >( GetInfo().m_xWindow );
xInit->initialize( aArgs );
}
catch( const uno::Exception & )
{
DBG_UNHANDLED_EXCEPTION("chart2");
}
}
// Interfaces
// ________ AccessibleBase::XAccessibleContext ________
Reference< XAccessible > AccessibleChartElement::ImplGetAccessibleChildById( sal_Int32 i ) const
{
Reference< XAccessible > xResult;
if( m_bHasText )
xResult.set( m_xTextHelper->getAccessibleChild( i ));
else
xResult.set( AccessibleBase::ImplGetAccessibleChildById( i ));
return xResult;
}
sal_Int32 AccessibleChartElement::ImplGetAccessibleChildCount() const
{
if( m_bHasText )
{
if( m_xTextHelper.is())
return m_xTextHelper->getAccessibleChildCount();
return 0;
}
return AccessibleBase::ImplGetAccessibleChildCount();
}
// ________ XServiceInfo ________
OUString SAL_CALL AccessibleChartElement::getImplementationName()
{
return "AccessibleChartElement";
}
// ________ AccessibleChartElement::XAccessibleContext (override) ________
OUString SAL_CALL AccessibleChartElement::getAccessibleName()
{
return ObjectNameProvider::getNameForCID(
GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument );
}
// ________ AccessibleChartElement::XAccessibleContext (override) ________
OUString SAL_CALL AccessibleChartElement::getAccessibleDescription()
{
return getToolTipText();
}
// ________ AccessibleChartElement::XAccessibleExtendedComponent ________
Reference< awt::XFont > SAL_CALL AccessibleChartElement::getFont()
{
CheckDisposeState();
Reference< awt::XFont > xFont;
Reference< awt::XDevice > xDevice( Reference< awt::XWindow >( GetInfo().m_xWindow ), uno::UNO_QUERY );
if( xDevice.is())
{
Reference< beans::XMultiPropertySet > xObjProp(
ObjectIdentifier::getObjectPropertySet(
GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )), uno::UNO_QUERY );
awt::FontDescriptor aDescr(
CharacterProperties::createFontDescriptorFromPropertySet( xObjProp ));
xFont = xDevice->getFont( aDescr );
}
return xFont;
}
OUString SAL_CALL AccessibleChartElement::getTitledBorderText()
{
return OUString();
}
OUString SAL_CALL AccessibleChartElement::getToolTipText()
{
CheckDisposeState();
return ObjectNameProvider::getHelpText(
GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument ));
}
// ________ XAccessibleComponent ________
sal_Bool SAL_CALL AccessibleChartElement::containsPoint( const awt::Point& aPoint )
{
return AccessibleBase::containsPoint( aPoint );
}
Reference< XAccessible > SAL_CALL AccessibleChartElement::getAccessibleAtPoint( const awt::Point& aPoint )
{
return AccessibleBase::getAccessibleAtPoint( aPoint );
}
awt::Rectangle SAL_CALL AccessibleChartElement::getBounds()
{
return AccessibleBase::getBounds();
}
awt::Point SAL_CALL AccessibleChartElement::getLocation()
{
return AccessibleBase::getLocation();
}
awt::Point SAL_CALL AccessibleChartElement::getLocationOnScreen()
{
return AccessibleBase::getLocationOnScreen();
}
awt::Size SAL_CALL AccessibleChartElement::getSize()
{
return AccessibleBase::getSize();
}
void SAL_CALL AccessibleChartElement::grabFocus()
{
return AccessibleBase::grabFocus();
}
sal_Int32 SAL_CALL AccessibleChartElement::getForeground()
{
return AccessibleBase::getForeground();
}
sal_Int32 SAL_CALL AccessibleChartElement::getBackground()
{
return AccessibleBase::getBackground();
}
} // namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|