Avoid potential negative array index access to cached text.
[LibreOffice.git] / chart2 / source / controller / accessibility / AccessibleChartShape.cxx
blob771698a84010c14512e6d528af8f079b84c3bb01
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 "AccessibleChartShape.hxx"
22 #include <com/sun/star/awt/XWindow.hpp>
23 #include <toolkit/helper/vclunohelper.hxx>
24 #include <svx/ShapeTypeHandler.hxx>
25 #include <svx/AccessibleShape.hxx>
26 #include <svx/AccessibleShapeInfo.hxx>
28 using namespace ::com::sun::star;
29 using namespace ::com::sun::star::accessibility;
31 using ::com::sun::star::uno::Reference;
33 namespace chart
36 AccessibleChartShape::AccessibleChartShape(
37 const AccessibleElementInfo& rAccInfo )
38 :impl::AccessibleChartShape_Base( rAccInfo, true/*bMayHaveChildren*/, false/*bAlwaysTransparent*/ )
40 if ( !rAccInfo.m_aOID.isAdditionalShape() )
41 return;
43 Reference< drawing::XShape > xShape( rAccInfo.m_aOID.getAdditionalShape() );
44 Reference< XAccessible > xParent;
45 if ( rAccInfo.m_pParent )
47 xParent.set( rAccInfo.m_pParent );
49 ::accessibility::AccessibleShapeInfo aShapeInfo( xShape, xParent );
51 m_aShapeTreeInfo.SetSdrView( rAccInfo.m_pSdrView );
52 m_aShapeTreeInfo.SetController( nullptr );
53 m_aShapeTreeInfo.SetWindow( VCLUnoHelper::GetWindow( rAccInfo.m_xWindow ) );
54 m_aShapeTreeInfo.SetViewForwarder( rAccInfo.m_pViewForwarder );
56 ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance();
57 m_pAccShape = rShapeHandler.CreateAccessibleObject( aShapeInfo, m_aShapeTreeInfo );
58 if ( m_pAccShape.is() )
60 m_pAccShape->Init();
64 AccessibleChartShape::~AccessibleChartShape()
66 OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) );
68 if ( m_pAccShape.is() )
70 m_pAccShape->dispose();
74 // ________ XServiceInfo ________
75 OUString AccessibleChartShape::getImplementationName()
77 return "AccessibleChartShape";
80 // ________ XAccessibleContext ________
81 sal_Int64 AccessibleChartShape::getAccessibleChildCount()
83 sal_Int64 nCount(0);
84 if ( m_pAccShape.is() )
86 nCount = m_pAccShape->getAccessibleChildCount();
88 return nCount;
91 Reference< XAccessible > AccessibleChartShape::getAccessibleChild( sal_Int64 i )
93 Reference< XAccessible > xChild;
94 if ( m_pAccShape.is() )
96 xChild = m_pAccShape->getAccessibleChild( i );
98 return xChild;
101 sal_Int16 AccessibleChartShape::getAccessibleRole()
103 sal_Int16 nRole(0);
104 if ( m_pAccShape.is() )
106 nRole = m_pAccShape->getAccessibleRole();
108 return nRole;
111 OUString AccessibleChartShape::getAccessibleDescription()
113 OUString aDescription;
114 if ( m_pAccShape.is() )
116 aDescription = m_pAccShape->getAccessibleDescription();
118 return aDescription;
121 OUString AccessibleChartShape::getAccessibleName()
123 OUString aName;
124 if ( m_pAccShape.is() )
126 aName = m_pAccShape->getAccessibleName();
128 return aName;
131 // ________ XAccessibleComponent ________
132 sal_Bool AccessibleChartShape::containsPoint( const awt::Point& aPoint )
134 bool bReturn = false;
135 if ( m_pAccShape.is() )
137 bReturn = m_pAccShape->containsPoint( aPoint );
139 return bReturn;
142 Reference< XAccessible > AccessibleChartShape::getAccessibleAtPoint( const awt::Point& aPoint )
144 Reference< XAccessible > xResult;
145 if ( m_pAccShape.is() )
147 xResult.set( m_pAccShape->getAccessibleAtPoint( aPoint ) );
149 return xResult;
152 awt::Rectangle AccessibleChartShape::getBounds()
154 awt::Rectangle aBounds;
155 if ( m_pAccShape.is() )
157 aBounds = m_pAccShape->getBounds();
159 return aBounds;
162 awt::Point AccessibleChartShape::getLocation()
164 awt::Point aLocation;
165 if ( m_pAccShape.is() )
167 aLocation = m_pAccShape->getLocation();
169 return aLocation;
172 awt::Point AccessibleChartShape::getLocationOnScreen()
174 awt::Point aLocation;
175 if ( m_pAccShape.is() )
177 aLocation = m_pAccShape->getLocationOnScreen();
179 return aLocation;
182 awt::Size AccessibleChartShape::getSize()
184 awt::Size aSize;
185 if ( m_pAccShape.is() )
187 aSize = m_pAccShape->getSize();
189 return aSize;
192 void AccessibleChartShape::grabFocus()
194 return AccessibleBase::grabFocus();
197 sal_Int32 AccessibleChartShape::getForeground()
199 sal_Int32 nColor(0);
200 if ( m_pAccShape.is() )
202 nColor = m_pAccShape->getForeground();
204 return nColor;
207 sal_Int32 AccessibleChartShape::getBackground()
209 sal_Int32 nColor(0);
210 if ( m_pAccShape.is() )
212 nColor = m_pAccShape->getBackground();
214 return nColor;
217 // ________ XAccessibleExtendedComponent ________
218 Reference< awt::XFont > AccessibleChartShape::getFont()
220 Reference< awt::XFont > xFont;
221 if ( m_pAccShape.is() )
223 xFont.set( m_pAccShape->getFont() );
225 return xFont;
228 OUString AccessibleChartShape::getTitledBorderText()
230 OUString aText;
231 if ( m_pAccShape.is() )
233 aText = m_pAccShape->getTitledBorderText();
235 return aText;
238 OUString AccessibleChartShape::getToolTipText()
240 OUString aText;
241 if ( m_pAccShape.is() )
243 aText = m_pAccShape->getToolTipText();
245 return aText;
248 } // namespace chart
250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */