1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file
5f6e50924SAndrew Rist * distributed with this work for additional information
6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at
10f6e50924SAndrew Rist *
11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist *
13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist * software distributed under the License is distributed on an
15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the
17f6e50924SAndrew Rist * specific language governing permissions and limitations
18f6e50924SAndrew Rist * under the License.
19f6e50924SAndrew Rist *
20f6e50924SAndrew Rist *************************************************************/
21f6e50924SAndrew Rist
22f6e50924SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir #include <svx/AccessibleShape.hxx>
27cdf0e10cSrcweir #include "svx/DescriptionGenerator.hxx"
28cdf0e10cSrcweir #include <svx/AccessibleShapeInfo.hxx>
29cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp>
30cdf0e10cSrcweir #include <rtl/uuid.h>
31cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLE_ROLE_HPP_
32cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
33cdf0e10cSrcweir #endif
349b8096d0SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLETEXTTYPE_HPP_
359b8096d0SSteve Yin #include <com/sun/star/accessibility/AccessibleTextType.hpp>
369b8096d0SSteve Yin #endif
37cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLE_STATE_TYPE_HPP_
38cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
41cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
42cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp>
43cdf0e10cSrcweir #include <com/sun/star/drawing/XShapeDescriptor.hpp>
44cdf0e10cSrcweir #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
45cdf0e10cSrcweir #include <com/sun/star/drawing/FillStyle.hpp>
46cdf0e10cSrcweir #include <com/sun/star/text/XText.hpp>
47cdf0e10cSrcweir #include <editeng/outlobj.hxx>
48cdf0e10cSrcweir #include <rtl/ref.hxx>
49cdf0e10cSrcweir #include <editeng/unoedsrc.hxx>
50cdf0e10cSrcweir #include <svx/unoshtxt.hxx>
51cdf0e10cSrcweir #include <svx/svdobj.hxx>
52cdf0e10cSrcweir #include <svx/svdmodel.hxx>
53cdf0e10cSrcweir #include "svx/unoapi.hxx"
54cdf0e10cSrcweir #include <com/sun/star/uno/Exception.hpp>
55cdf0e10cSrcweir #include <svx/ShapeTypeHandler.hxx>
56cdf0e10cSrcweir #include <svx/SvxShapeTypes.hxx>
57cdf0e10cSrcweir
58cdf0e10cSrcweir #ifndef _SVX_ACCESSIBILITY_HRC
59cdf0e10cSrcweir #include "accessibility.hrc"
60cdf0e10cSrcweir #endif
61cdf0e10cSrcweir #include "svx/svdstr.hrc"
62cdf0e10cSrcweir #include <svx/dialmgr.hxx>
63cdf0e10cSrcweir #include <vcl/svapp.hxx>
64cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
65cdf0e10cSrcweir #include <svx/svdview.hxx>
66cdf0e10cSrcweir #include "AccessibleEmptyEditSource.hxx"
679b8096d0SSteve Yin #include <svx/svdpage.hxx>
689b8096d0SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLERELATIONTYPE_HPP_
699b8096d0SSteve Yin #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
709b8096d0SSteve Yin #endif
719b8096d0SSteve Yin #ifndef _UTL_ACCESSIBLERELATIONSETHELPER_HXX_
729b8096d0SSteve Yin #include <unotools/accessiblerelationsethelper.hxx>
739b8096d0SSteve Yin #endif
74cdf0e10cSrcweir using namespace ::com::sun::star;
75cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
769b8096d0SSteve Yin using ::com::sun::star::lang::IndexOutOfBoundsException;
779b8096d0SSteve Yin using ::com::sun::star::uno::RuntimeException;
78cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
79cdf0e10cSrcweir using ::rtl::OUString;
809b8096d0SSteve Yin #include <algorithm>
81cdf0e10cSrcweir
829b8096d0SSteve Yin // #include <Accessiblehyperlink.hxx>
83cdf0e10cSrcweir namespace accessibility {
84cdf0e10cSrcweir
85cdf0e10cSrcweir namespace {
86cdf0e10cSrcweir
GetOptionalProperty(const Reference<beans::XPropertySet> & rxSet,const OUString & rsPropertyName)87cdf0e10cSrcweir OUString GetOptionalProperty (
88cdf0e10cSrcweir const Reference<beans::XPropertySet>& rxSet,
89cdf0e10cSrcweir const OUString& rsPropertyName)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir OUString sValue;
92cdf0e10cSrcweir
93cdf0e10cSrcweir if (rxSet.is())
94cdf0e10cSrcweir {
95cdf0e10cSrcweir const Reference<beans::XPropertySetInfo> xInfo (rxSet->getPropertySetInfo());
96cdf0e10cSrcweir if ( ! xInfo.is() || xInfo->hasPropertyByName(rsPropertyName))
97cdf0e10cSrcweir {
98cdf0e10cSrcweir try
99cdf0e10cSrcweir {
100cdf0e10cSrcweir rxSet->getPropertyValue(rsPropertyName) >>= sValue;
101cdf0e10cSrcweir }
102cdf0e10cSrcweir catch (beans::UnknownPropertyException&)
103cdf0e10cSrcweir {
104cdf0e10cSrcweir // This exception should only be thrown when the property
105cdf0e10cSrcweir // does not exits (of course) and the XPropertySetInfo is
106cdf0e10cSrcweir // not available.
107cdf0e10cSrcweir }
108cdf0e10cSrcweir }
109cdf0e10cSrcweir }
110cdf0e10cSrcweir return sValue;
111cdf0e10cSrcweir }
112cdf0e10cSrcweir
113cdf0e10cSrcweir } // end of anonymous namespace
114cdf0e10cSrcweir
115cdf0e10cSrcweir
116cdf0e10cSrcweir
117cdf0e10cSrcweir
118cdf0e10cSrcweir //===== internal ============================================================
119cdf0e10cSrcweir
AccessibleShape(const AccessibleShapeInfo & rShapeInfo,const AccessibleShapeTreeInfo & rShapeTreeInfo)120cdf0e10cSrcweir AccessibleShape::AccessibleShape (
121cdf0e10cSrcweir const AccessibleShapeInfo& rShapeInfo,
122cdf0e10cSrcweir const AccessibleShapeTreeInfo& rShapeTreeInfo)
1239b8096d0SSteve Yin : AccessibleContextBase (rShapeInfo.mxParent,AccessibleRole::SHAPE),
124cdf0e10cSrcweir mpChildrenManager(NULL),
125cdf0e10cSrcweir mxShape (rShapeInfo.mxShape),
126cdf0e10cSrcweir maShapeTreeInfo (rShapeTreeInfo),
127cdf0e10cSrcweir mnIndex (rShapeInfo.mnIndex),
128cdf0e10cSrcweir m_nIndexInParent(-1),
129cdf0e10cSrcweir mpText (NULL),
130cdf0e10cSrcweir mpParent (rShapeInfo.mpChildrenManager)
131cdf0e10cSrcweir {
132cdf0e10cSrcweir m_pShape = GetSdrObjectFromXShape(mxShape);
133cdf0e10cSrcweir UpdateNameAndDescription();
134cdf0e10cSrcweir }
AccessibleShape(const::com::sun::star::uno::Reference<::com::sun::star::drawing::XShape> & rxShape,const::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> & rxParent,const AccessibleShapeTreeInfo & rShapeTreeInfo,sal_Int32 nIndex)1359b8096d0SSteve Yin AccessibleShape::AccessibleShape (
1369b8096d0SSteve Yin const ::com::sun::star::uno::Reference<
1379b8096d0SSteve Yin ::com::sun::star::drawing::XShape>& rxShape,
1389b8096d0SSteve Yin const ::com::sun::star::uno::Reference<
1399b8096d0SSteve Yin ::com::sun::star::accessibility::XAccessible>& rxParent,
1409b8096d0SSteve Yin const AccessibleShapeTreeInfo& rShapeTreeInfo,
1419b8096d0SSteve Yin sal_Int32 nIndex)
1429b8096d0SSteve Yin : AccessibleContextBase (rxParent,AccessibleRole::SHAPE),
1439b8096d0SSteve Yin mpChildrenManager(NULL),
1449b8096d0SSteve Yin mxShape (rxShape),
1459b8096d0SSteve Yin maShapeTreeInfo (rShapeTreeInfo),
1469b8096d0SSteve Yin mnIndex (nIndex),
1479b8096d0SSteve Yin m_nIndexInParent(-1),
1489b8096d0SSteve Yin mpText (NULL),
1499b8096d0SSteve Yin mpParent (NULL)
1509b8096d0SSteve Yin {
1519b8096d0SSteve Yin m_pShape = GetSdrObjectFromXShape(mxShape);
1529b8096d0SSteve Yin }
~AccessibleShape(void)153cdf0e10cSrcweir AccessibleShape::~AccessibleShape (void)
154cdf0e10cSrcweir {
155cdf0e10cSrcweir if (mpChildrenManager != NULL)
156cdf0e10cSrcweir delete mpChildrenManager;
157cdf0e10cSrcweir if (mpText != NULL)
158cdf0e10cSrcweir delete mpText;
159cdf0e10cSrcweir OSL_TRACE ("~AccessibleShape");
160cdf0e10cSrcweir
161cdf0e10cSrcweir // Unregistering from the various broadcasters should be unnecessary
162cdf0e10cSrcweir // since this destructor would not have been called if one of the
163cdf0e10cSrcweir // broadcasters would still hold a strong reference to this object.
164cdf0e10cSrcweir }
165cdf0e10cSrcweir
166cdf0e10cSrcweir
167cdf0e10cSrcweir
168cdf0e10cSrcweir
Init(void)169cdf0e10cSrcweir void AccessibleShape::Init (void)
170cdf0e10cSrcweir {
171cdf0e10cSrcweir // Update the OPAQUE and SELECTED shape.
172cdf0e10cSrcweir UpdateStates ();
173cdf0e10cSrcweir
174cdf0e10cSrcweir // Create a children manager when this shape has children of its own.
175cdf0e10cSrcweir Reference<drawing::XShapes> xShapes (mxShape, uno::UNO_QUERY);
176cdf0e10cSrcweir if (xShapes.is() && xShapes->getCount() > 0)
177cdf0e10cSrcweir mpChildrenManager = new ChildrenManager (
178cdf0e10cSrcweir this, xShapes, maShapeTreeInfo, *this);
179cdf0e10cSrcweir if (mpChildrenManager != NULL)
180cdf0e10cSrcweir mpChildrenManager->Update();
181cdf0e10cSrcweir
182cdf0e10cSrcweir // Register at model as document::XEventListener.
183cdf0e10cSrcweir if (maShapeTreeInfo.GetModelBroadcaster().is())
184cdf0e10cSrcweir maShapeTreeInfo.GetModelBroadcaster()->addEventListener (
185cdf0e10cSrcweir static_cast<document::XEventListener*>(this));
186cdf0e10cSrcweir
187cdf0e10cSrcweir // Beware! Here we leave the paths of the UNO API and descend into the
188cdf0e10cSrcweir // depths of the core. Necessary for makeing the edit engine
189cdf0e10cSrcweir // accessible.
190cdf0e10cSrcweir Reference<text::XText> xText (mxShape, uno::UNO_QUERY);
191cdf0e10cSrcweir if (xText.is())
192cdf0e10cSrcweir {
193cdf0e10cSrcweir SdrView* pView = maShapeTreeInfo.GetSdrView ();
194cdf0e10cSrcweir const Window* pWindow = maShapeTreeInfo.GetWindow ();
195cdf0e10cSrcweir if (pView != NULL && pWindow != NULL && mxShape.is())
196cdf0e10cSrcweir {
197cdf0e10cSrcweir // #107948# Determine whether shape text is empty
198cdf0e10cSrcweir SdrObject* pSdrObject = GetSdrObjectFromXShape(mxShape);
199cdf0e10cSrcweir if( pSdrObject )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, pSdrObject );
202cdf0e10cSrcweir OutlinerParaObject* pOutlinerParaObject = NULL;
203cdf0e10cSrcweir
204cdf0e10cSrcweir if( pTextObj )
205cdf0e10cSrcweir pOutlinerParaObject = pTextObj->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active
206cdf0e10cSrcweir
207cdf0e10cSrcweir bool bOwnParaObj = pOutlinerParaObject != NULL;
208cdf0e10cSrcweir
209cdf0e10cSrcweir if( !pOutlinerParaObject && pSdrObject )
210cdf0e10cSrcweir pOutlinerParaObject = pSdrObject->GetOutlinerParaObject();
211cdf0e10cSrcweir
212cdf0e10cSrcweir // create AccessibleTextHelper to handle this shape's text
213cdf0e10cSrcweir if( !pOutlinerParaObject )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir // empty text -> use proxy edit source to delay creation of EditEngine
216cdf0e10cSrcweir ::std::auto_ptr<SvxEditSource> pEditSource( new AccessibleEmptyEditSource ( *pSdrObject, *pView, *pWindow) );
217cdf0e10cSrcweir mpText = new AccessibleTextHelper( pEditSource );
218cdf0e10cSrcweir }
219cdf0e10cSrcweir else
220cdf0e10cSrcweir {
221cdf0e10cSrcweir // non-empty text -> use full-fledged edit source right away
222cdf0e10cSrcweir ::std::auto_ptr<SvxEditSource> pEditSource( new SvxTextEditSource ( *pSdrObject, 0, *pView, *pWindow) );
223cdf0e10cSrcweir mpText = new AccessibleTextHelper( pEditSource );
224cdf0e10cSrcweir }
225cdf0e10cSrcweir
226cdf0e10cSrcweir if( bOwnParaObj )
227cdf0e10cSrcweir delete pOutlinerParaObject;
228cdf0e10cSrcweir
229cdf0e10cSrcweir mpText->SetEventSource(this);
230cdf0e10cSrcweir }
231cdf0e10cSrcweir }
232cdf0e10cSrcweir }
233cdf0e10cSrcweir }
234cdf0e10cSrcweir
235cdf0e10cSrcweir
236cdf0e10cSrcweir
237cdf0e10cSrcweir
UpdateStates(void)238cdf0e10cSrcweir void AccessibleShape::UpdateStates (void)
239cdf0e10cSrcweir {
240cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet =
241cdf0e10cSrcweir static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
242cdf0e10cSrcweir if (pStateSet == NULL)
243cdf0e10cSrcweir return;
244cdf0e10cSrcweir
245cdf0e10cSrcweir // Set the opaque state for certain shape types when their fill style is
246cdf0e10cSrcweir // solid.
247cdf0e10cSrcweir bool bShapeIsOpaque = false;
248cdf0e10cSrcweir switch (ShapeTypeHandler::Instance().GetTypeId (mxShape))
249cdf0e10cSrcweir {
250cdf0e10cSrcweir case DRAWING_PAGE:
251cdf0e10cSrcweir case DRAWING_RECTANGLE:
252cdf0e10cSrcweir case DRAWING_TEXT:
253cdf0e10cSrcweir {
254cdf0e10cSrcweir uno::Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY);
255cdf0e10cSrcweir if (xSet.is())
256cdf0e10cSrcweir {
257cdf0e10cSrcweir try
258cdf0e10cSrcweir {
259cdf0e10cSrcweir drawing::FillStyle aFillStyle;
260cdf0e10cSrcweir bShapeIsOpaque = ( xSet->getPropertyValue (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle"))) >>= aFillStyle)
261cdf0e10cSrcweir && aFillStyle == drawing::FillStyle_SOLID;
262cdf0e10cSrcweir }
263cdf0e10cSrcweir catch (::com::sun::star::beans::UnknownPropertyException&)
264cdf0e10cSrcweir {
265cdf0e10cSrcweir // Ignore.
266cdf0e10cSrcweir }
267cdf0e10cSrcweir }
268cdf0e10cSrcweir }
269cdf0e10cSrcweir }
270cdf0e10cSrcweir if (bShapeIsOpaque)
271cdf0e10cSrcweir pStateSet->AddState (AccessibleStateType::OPAQUE);
272cdf0e10cSrcweir else
273cdf0e10cSrcweir pStateSet->RemoveState (AccessibleStateType::OPAQUE);
274cdf0e10cSrcweir
275cdf0e10cSrcweir // Set the selected state.
276cdf0e10cSrcweir bool bShapeIsSelected = false;
277cdf0e10cSrcweir // XXX fix_me this has to be done with an extra interface later on
278cdf0e10cSrcweir if ( m_pShape && maShapeTreeInfo.GetSdrView() )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir bShapeIsSelected = maShapeTreeInfo.GetSdrView()->IsObjMarked(m_pShape) == sal_True;
281cdf0e10cSrcweir }
282cdf0e10cSrcweir
283cdf0e10cSrcweir if (bShapeIsSelected)
284cdf0e10cSrcweir pStateSet->AddState (AccessibleStateType::SELECTED);
285cdf0e10cSrcweir else
286cdf0e10cSrcweir pStateSet->RemoveState (AccessibleStateType::SELECTED);
287cdf0e10cSrcweir }
GetStyle()2889b8096d0SSteve Yin ::rtl::OUString AccessibleShape::GetStyle()
2899b8096d0SSteve Yin {
2909b8096d0SSteve Yin return ShapeTypeHandler::CreateAccessibleBaseName( mxShape );
2919b8096d0SSteve Yin }
292cdf0e10cSrcweir
operator ==(const AccessibleShape & rShape)293cdf0e10cSrcweir bool AccessibleShape::operator== (const AccessibleShape& rShape)
294cdf0e10cSrcweir {
295cdf0e10cSrcweir return this==&rShape;
296cdf0e10cSrcweir }
297cdf0e10cSrcweir
298cdf0e10cSrcweir
299cdf0e10cSrcweir
300cdf0e10cSrcweir
SetState(sal_Int16 aState)301cdf0e10cSrcweir sal_Bool AccessibleShape::SetState (sal_Int16 aState)
302cdf0e10cSrcweir {
303cdf0e10cSrcweir sal_Bool bStateHasChanged = sal_False;
304cdf0e10cSrcweir
305cdf0e10cSrcweir if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
306cdf0e10cSrcweir {
307cdf0e10cSrcweir // Offer FOCUSED state to edit engine and detect whether the state
308cdf0e10cSrcweir // changes.
309cdf0e10cSrcweir sal_Bool bIsFocused = mpText->HaveFocus ();
310cdf0e10cSrcweir mpText->SetFocus (sal_True);
311cdf0e10cSrcweir bStateHasChanged = (bIsFocused != mpText->HaveFocus ());
312cdf0e10cSrcweir }
313cdf0e10cSrcweir else
314cdf0e10cSrcweir bStateHasChanged = AccessibleContextBase::SetState (aState);
315cdf0e10cSrcweir
316cdf0e10cSrcweir return bStateHasChanged;
317cdf0e10cSrcweir }
318cdf0e10cSrcweir
319cdf0e10cSrcweir
320cdf0e10cSrcweir
321cdf0e10cSrcweir
ResetState(sal_Int16 aState)322cdf0e10cSrcweir sal_Bool AccessibleShape::ResetState (sal_Int16 aState)
323cdf0e10cSrcweir {
324cdf0e10cSrcweir sal_Bool bStateHasChanged = sal_False;
325cdf0e10cSrcweir
326cdf0e10cSrcweir if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
327cdf0e10cSrcweir {
328cdf0e10cSrcweir // Try to remove FOCUSED state from the edit engine and detect
329cdf0e10cSrcweir // whether the state changes.
330cdf0e10cSrcweir sal_Bool bIsFocused = mpText->HaveFocus ();
331cdf0e10cSrcweir mpText->SetFocus (sal_False);
332cdf0e10cSrcweir bStateHasChanged = (bIsFocused != mpText->HaveFocus ());
333cdf0e10cSrcweir }
334cdf0e10cSrcweir else
335cdf0e10cSrcweir bStateHasChanged = AccessibleContextBase::ResetState (aState);
336cdf0e10cSrcweir
337cdf0e10cSrcweir return bStateHasChanged;
338cdf0e10cSrcweir }
339cdf0e10cSrcweir
340cdf0e10cSrcweir
341cdf0e10cSrcweir
342cdf0e10cSrcweir
GetState(sal_Int16 aState)343cdf0e10cSrcweir sal_Bool AccessibleShape::GetState (sal_Int16 aState)
344cdf0e10cSrcweir {
345cdf0e10cSrcweir if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir // Just delegate the call to the edit engine. The state is not
348cdf0e10cSrcweir // merged into the state set.
349cdf0e10cSrcweir return mpText->HaveFocus();
350cdf0e10cSrcweir }
351cdf0e10cSrcweir else
352cdf0e10cSrcweir return AccessibleContextBase::GetState (aState);
353cdf0e10cSrcweir }
3549b8096d0SSteve Yin // Solution: OverWrite the parent's getAccessibleName method
getAccessibleName(void)3559b8096d0SSteve Yin ::rtl::OUString SAL_CALL AccessibleShape::getAccessibleName (void)
3569b8096d0SSteve Yin throw (::com::sun::star::uno::RuntimeException)
3579b8096d0SSteve Yin {
3589b8096d0SSteve Yin ThrowIfDisposed ();
3599b8096d0SSteve Yin if( m_pShape && m_pShape->GetTitle().Len() > 0)
3609b8096d0SSteve Yin return CreateAccessibleName() + ::rtl::OUString(' ') + m_pShape->GetTitle();
3619b8096d0SSteve Yin else
3629b8096d0SSteve Yin return CreateAccessibleName();
3639b8096d0SSteve Yin }
364cdf0e10cSrcweir
getAccessibleDescription(void)3659b8096d0SSteve Yin ::rtl::OUString SAL_CALL AccessibleShape::getAccessibleDescription (void)
3669b8096d0SSteve Yin throw (::com::sun::star::uno::RuntimeException)
3679b8096d0SSteve Yin {
3689b8096d0SSteve Yin ThrowIfDisposed ();
3699b8096d0SSteve Yin if( m_pShape && m_pShape->GetDescription().Len() > 0)
3709b8096d0SSteve Yin return m_pShape->GetDescription() ;
3719b8096d0SSteve Yin else
3729b8096d0SSteve Yin return OUString( RTL_CONSTASCII_USTRINGPARAM( " " ));
3739b8096d0SSteve Yin }
374cdf0e10cSrcweir //===== XAccessibleContext ==================================================
375cdf0e10cSrcweir
376cdf0e10cSrcweir /** The children of this shape come from two sources: The children from
377cdf0e10cSrcweir group or scene shapes and the paragraphs of text.
378cdf0e10cSrcweir */
379cdf0e10cSrcweir sal_Int32 SAL_CALL
getAccessibleChildCount()380cdf0e10cSrcweir AccessibleShape::getAccessibleChildCount ()
381cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
382cdf0e10cSrcweir {
383cdf0e10cSrcweir ThrowIfDisposed ();
384cdf0e10cSrcweir sal_Int32 nChildCount = 0;
385cdf0e10cSrcweir
386cdf0e10cSrcweir // Add the number of shapes that are children of this shape.
387cdf0e10cSrcweir if (mpChildrenManager != NULL)
388cdf0e10cSrcweir nChildCount += mpChildrenManager->GetChildCount ();
389cdf0e10cSrcweir // Add the number text paragraphs.
390cdf0e10cSrcweir if (mpText != NULL)
391cdf0e10cSrcweir nChildCount += mpText->GetChildCount ();
392cdf0e10cSrcweir
393cdf0e10cSrcweir return nChildCount;
394cdf0e10cSrcweir }
395cdf0e10cSrcweir
396cdf0e10cSrcweir
397cdf0e10cSrcweir
398cdf0e10cSrcweir
399cdf0e10cSrcweir /** Forward the request to the shape. Return the requested shape or throw
400cdf0e10cSrcweir an exception for a wrong index.
401cdf0e10cSrcweir */
402cdf0e10cSrcweir uno::Reference<XAccessible> SAL_CALL
getAccessibleChild(sal_Int32 nIndex)403cdf0e10cSrcweir AccessibleShape::getAccessibleChild (sal_Int32 nIndex)
404cdf0e10cSrcweir throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
405cdf0e10cSrcweir {
406cdf0e10cSrcweir ThrowIfDisposed ();
407cdf0e10cSrcweir
408cdf0e10cSrcweir uno::Reference<XAccessible> xChild;
409cdf0e10cSrcweir
410cdf0e10cSrcweir // Depending on the index decide whether to delegate this call to the
411cdf0e10cSrcweir // children manager or the edit engine.
412cdf0e10cSrcweir if ((mpChildrenManager != NULL)
413cdf0e10cSrcweir && (nIndex < mpChildrenManager->GetChildCount()))
414cdf0e10cSrcweir {
415cdf0e10cSrcweir xChild = mpChildrenManager->GetChild (nIndex);
416cdf0e10cSrcweir }
417cdf0e10cSrcweir else if (mpText != NULL)
418cdf0e10cSrcweir {
419cdf0e10cSrcweir sal_Int32 nI = nIndex;
420cdf0e10cSrcweir if (mpChildrenManager != NULL)
421cdf0e10cSrcweir nI -= mpChildrenManager->GetChildCount();
422cdf0e10cSrcweir xChild = mpText->GetChild (nI);
423cdf0e10cSrcweir }
424cdf0e10cSrcweir else
425cdf0e10cSrcweir throw lang::IndexOutOfBoundsException (
426cdf0e10cSrcweir ::rtl::OUString::createFromAscii ("shape has no child with index ")
427cdf0e10cSrcweir + rtl::OUString::valueOf(nIndex),
428cdf0e10cSrcweir static_cast<uno::XWeak*>(this));
429cdf0e10cSrcweir
430cdf0e10cSrcweir return xChild;
431cdf0e10cSrcweir }
432cdf0e10cSrcweir
4339b8096d0SSteve Yin uno::Reference<XAccessibleRelationSet> SAL_CALL
getAccessibleRelationSet(void)4343dceaf70SArmin Le Grand AccessibleShape::getAccessibleRelationSet (void)
4359b8096d0SSteve Yin throw (::com::sun::star::uno::RuntimeException)
4369b8096d0SSteve Yin {
4373dceaf70SArmin Le Grand ::osl::MutexGuard aGuard (maMutex);
438ec81bebdSSteve Yin ::utl::AccessibleRelationSetHelper* pRelationSet = new utl::AccessibleRelationSetHelper;
4393dceaf70SArmin Le Grand
4403dceaf70SArmin Le Grand //this mxshape is the captioned shape, only for sw
4413dceaf70SArmin Le Grand if (pRelationSet != NULL)
4429b8096d0SSteve Yin {
443ec81bebdSSteve Yin uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1);
444ec81bebdSSteve Yin aSequence[0] = mpParent->GetAccessibleCaption(mxShape);
445ec81bebdSSteve Yin if(aSequence[0].get())
446ec81bebdSSteve Yin {
447ec81bebdSSteve Yin pRelationSet->AddRelation(
448ec81bebdSSteve Yin AccessibleRelation( AccessibleRelationType::DESCRIBED_BY, aSequence ) );
449ec81bebdSSteve Yin }
4509b8096d0SSteve Yin return uno::Reference<XAccessibleRelationSet> (
4519b8096d0SSteve Yin new ::utl::AccessibleRelationSetHelper (*pRelationSet));
4529b8096d0SSteve Yin }
4539b8096d0SSteve Yin else
4543dceaf70SArmin Le Grand {
4559b8096d0SSteve Yin return uno::Reference<XAccessibleRelationSet>(NULL);
4563dceaf70SArmin Le Grand }
4579b8096d0SSteve Yin }
458cdf0e10cSrcweir
459cdf0e10cSrcweir /** Return a copy of the state set.
460cdf0e10cSrcweir Possible states are:
461cdf0e10cSrcweir ENABLED
462cdf0e10cSrcweir SHOWING
463cdf0e10cSrcweir VISIBLE
464cdf0e10cSrcweir */
465cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL
getAccessibleStateSet(void)466cdf0e10cSrcweir AccessibleShape::getAccessibleStateSet (void)
467cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
468cdf0e10cSrcweir {
469cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex);
470cdf0e10cSrcweir Reference<XAccessibleStateSet> xStateSet;
471cdf0e10cSrcweir
472cdf0e10cSrcweir if (rBHelper.bDisposed || mpText == NULL)
473cdf0e10cSrcweir // Return a minimal state set that only contains the DEFUNC state.
4749b8096d0SSteve Yin {
475cdf0e10cSrcweir xStateSet = AccessibleContextBase::getAccessibleStateSet ();
4769b8096d0SSteve Yin ::utl::AccessibleStateSetHelper* pStateSet =
4779b8096d0SSteve Yin static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
4789b8096d0SSteve Yin ::com::sun::star::uno::Reference<XAccessible> xTempAcc = getAccessibleParent();
4799b8096d0SSteve Yin if( xTempAcc.is() )
4809b8096d0SSteve Yin {
4819b8096d0SSteve Yin ::com::sun::star::uno::Reference<XAccessibleContext>
4829b8096d0SSteve Yin xTempAccContext = xTempAcc->getAccessibleContext();
4839b8096d0SSteve Yin if( xTempAccContext.is() )
4849b8096d0SSteve Yin {
4859b8096d0SSteve Yin ::com::sun::star::uno::Reference<XAccessibleStateSet> rState =
4869b8096d0SSteve Yin xTempAccContext->getAccessibleStateSet();
4879b8096d0SSteve Yin if( rState.is() ) {
4889b8096d0SSteve Yin com::sun::star::uno::Sequence<short> pStates = rState->getStates();
4899b8096d0SSteve Yin int count = pStates.getLength();
4909b8096d0SSteve Yin for( int iIndex = 0;iIndex < count;iIndex++ )
4919b8096d0SSteve Yin {
4929b8096d0SSteve Yin if( pStates[iIndex] == AccessibleStateType::EDITABLE )
4939b8096d0SSteve Yin {
4949b8096d0SSteve Yin pStateSet->AddState (AccessibleStateType::EDITABLE);
4959b8096d0SSteve Yin pStateSet->AddState (AccessibleStateType::RESIZABLE);
4969b8096d0SSteve Yin pStateSet->AddState (AccessibleStateType::MOVEABLE);
4979b8096d0SSteve Yin break;
4989b8096d0SSteve Yin }
4999b8096d0SSteve Yin }
5009b8096d0SSteve Yin }
5019b8096d0SSteve Yin }
5029b8096d0SSteve Yin }
5039b8096d0SSteve Yin xStateSet = Reference<XAccessibleStateSet>(
5049b8096d0SSteve Yin new ::utl::AccessibleStateSetHelper (*pStateSet));
5059b8096d0SSteve Yin }else
506cdf0e10cSrcweir {
507cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet =
508cdf0e10cSrcweir static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
509cdf0e10cSrcweir
510cdf0e10cSrcweir if (pStateSet != NULL)
511cdf0e10cSrcweir {
512cdf0e10cSrcweir // Merge current FOCUSED state from edit engine.
513cdf0e10cSrcweir if (mpText != NULL)
514cdf0e10cSrcweir {
515cdf0e10cSrcweir if (mpText->HaveFocus())
516cdf0e10cSrcweir pStateSet->AddState (AccessibleStateType::FOCUSED);
517cdf0e10cSrcweir else
518cdf0e10cSrcweir pStateSet->RemoveState (AccessibleStateType::FOCUSED);
519cdf0e10cSrcweir }
5209b8096d0SSteve Yin //Solution:Just when the document is not read-only,set states EDITABLE,RESIZABLE,MOVEABLE
5219b8096d0SSteve Yin ::com::sun::star::uno::Reference<XAccessible> xTempAcc = getAccessibleParent();
5229b8096d0SSteve Yin if( xTempAcc.is() )
5239b8096d0SSteve Yin {
5249b8096d0SSteve Yin ::com::sun::star::uno::Reference<XAccessibleContext>
5259b8096d0SSteve Yin xTempAccContext = xTempAcc->getAccessibleContext();
5269b8096d0SSteve Yin if( xTempAccContext.is() )
5279b8096d0SSteve Yin {
5289b8096d0SSteve Yin ::com::sun::star::uno::Reference<XAccessibleStateSet> rState =
5299b8096d0SSteve Yin xTempAccContext->getAccessibleStateSet();
5309b8096d0SSteve Yin if( rState.is() ) {
5319b8096d0SSteve Yin com::sun::star::uno::Sequence<short> pStates = rState->getStates();
5329b8096d0SSteve Yin int count = pStates.getLength();
5339b8096d0SSteve Yin for( int iIndex = 0;iIndex < count;iIndex++ )
5349b8096d0SSteve Yin {
5359b8096d0SSteve Yin if( pStates[iIndex] == AccessibleStateType::EDITABLE )
5369b8096d0SSteve Yin {
5379b8096d0SSteve Yin pStateSet->AddState (AccessibleStateType::EDITABLE);
5389b8096d0SSteve Yin pStateSet->AddState (AccessibleStateType::RESIZABLE);
5399b8096d0SSteve Yin pStateSet->AddState (AccessibleStateType::MOVEABLE);
5409b8096d0SSteve Yin break;
5419b8096d0SSteve Yin }
5429b8096d0SSteve Yin }
5439b8096d0SSteve Yin }
5449b8096d0SSteve Yin }
5459b8096d0SSteve Yin }
546cdf0e10cSrcweir // Create a copy of the state set that may be modified by the
547cdf0e10cSrcweir // caller without affecting the current state set.
548cdf0e10cSrcweir xStateSet = Reference<XAccessibleStateSet>(
549cdf0e10cSrcweir new ::utl::AccessibleStateSetHelper (*pStateSet));
550cdf0e10cSrcweir }
551cdf0e10cSrcweir }
5529b8096d0SSteve Yin UpdateDocumentAllSelState(xStateSet);
553cdf0e10cSrcweir return xStateSet;
554cdf0e10cSrcweir }
555cdf0e10cSrcweir
556cdf0e10cSrcweir
557cdf0e10cSrcweir
558cdf0e10cSrcweir
559cdf0e10cSrcweir //===== XAccessibleComponent ================================================
560cdf0e10cSrcweir
561cdf0e10cSrcweir /** The implementation below is at the moment straightforward. It iterates
562cdf0e10cSrcweir over all children (and thereby instances all children which have not
563cdf0e10cSrcweir been already instatiated) until a child covering the specifed point is
564cdf0e10cSrcweir found.
565cdf0e10cSrcweir This leaves room for improvement. For instance, first iterate only over
566cdf0e10cSrcweir the already instantiated children and only if no match is found
567cdf0e10cSrcweir instantiate the remaining ones.
568cdf0e10cSrcweir */
569cdf0e10cSrcweir uno::Reference<XAccessible > SAL_CALL
getAccessibleAtPoint(const awt::Point & aPoint)570cdf0e10cSrcweir AccessibleShape::getAccessibleAtPoint (
571cdf0e10cSrcweir const awt::Point& aPoint)
572cdf0e10cSrcweir throw (uno::RuntimeException)
573cdf0e10cSrcweir {
574cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex);
575cdf0e10cSrcweir
576cdf0e10cSrcweir sal_Int32 nChildCount = getAccessibleChildCount ();
577cdf0e10cSrcweir for (sal_Int32 i=0; i<nChildCount; ++i)
578cdf0e10cSrcweir {
579cdf0e10cSrcweir Reference<XAccessible> xChild (getAccessibleChild (i));
580cdf0e10cSrcweir if (xChild.is())
581cdf0e10cSrcweir {
582cdf0e10cSrcweir Reference<XAccessibleComponent> xChildComponent (
583cdf0e10cSrcweir xChild->getAccessibleContext(), uno::UNO_QUERY);
584cdf0e10cSrcweir if (xChildComponent.is())
585cdf0e10cSrcweir {
586cdf0e10cSrcweir awt::Rectangle aBBox (xChildComponent->getBounds());
587cdf0e10cSrcweir if ( (aPoint.X >= aBBox.X)
588cdf0e10cSrcweir && (aPoint.Y >= aBBox.Y)
589cdf0e10cSrcweir && (aPoint.X < aBBox.X+aBBox.Width)
590cdf0e10cSrcweir && (aPoint.Y < aBBox.Y+aBBox.Height) )
591cdf0e10cSrcweir return xChild;
592cdf0e10cSrcweir }
593cdf0e10cSrcweir }
594cdf0e10cSrcweir }
595cdf0e10cSrcweir
596cdf0e10cSrcweir // Have not found a child under the given point. Returning empty
597cdf0e10cSrcweir // reference to indicate this.
598cdf0e10cSrcweir return uno::Reference<XAccessible>();
599cdf0e10cSrcweir }
600cdf0e10cSrcweir
601cdf0e10cSrcweir
602cdf0e10cSrcweir
603cdf0e10cSrcweir
getBounds(void)604cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleShape::getBounds (void)
605cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
606cdf0e10cSrcweir {
607cdf0e10cSrcweir ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
608cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex);
609cdf0e10cSrcweir
610cdf0e10cSrcweir ThrowIfDisposed ();
611cdf0e10cSrcweir awt::Rectangle aBoundingBox;
612cdf0e10cSrcweir if ( mxShape.is() )
613cdf0e10cSrcweir {
614cdf0e10cSrcweir
615cdf0e10cSrcweir static const OUString sBoundRectName (
616cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("BoundRect"));
617cdf0e10cSrcweir static const OUString sAnchorPositionName (
618cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("AnchorPosition"));
619cdf0e10cSrcweir
620cdf0e10cSrcweir // Get the shape's bounding box in internal coordinates (in 100th of
621cdf0e10cSrcweir // mm). Use the property BoundRect. Only if that is not supported ask
622cdf0e10cSrcweir // the shape for its position and size directly.
623cdf0e10cSrcweir Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY);
624cdf0e10cSrcweir Reference<beans::XPropertySetInfo> xSetInfo;
625cdf0e10cSrcweir bool bFoundBoundRect = false;
626cdf0e10cSrcweir if (xSet.is())
627cdf0e10cSrcweir {
628cdf0e10cSrcweir xSetInfo = xSet->getPropertySetInfo ();
629cdf0e10cSrcweir if (xSetInfo.is())
630cdf0e10cSrcweir {
631cdf0e10cSrcweir if (xSetInfo->hasPropertyByName (sBoundRectName))
632cdf0e10cSrcweir {
633cdf0e10cSrcweir try
634cdf0e10cSrcweir {
635cdf0e10cSrcweir uno::Any aValue = xSet->getPropertyValue (sBoundRectName);
636cdf0e10cSrcweir aValue >>= aBoundingBox;
637cdf0e10cSrcweir bFoundBoundRect = true;
638cdf0e10cSrcweir }
639cdf0e10cSrcweir catch (beans::UnknownPropertyException e)
640cdf0e10cSrcweir {
641cdf0e10cSrcweir // Handled below (bFoundBoundRect stays false).
642cdf0e10cSrcweir }
643cdf0e10cSrcweir }
644cdf0e10cSrcweir else
645cdf0e10cSrcweir OSL_TRACE (" no property BoundRect");
646cdf0e10cSrcweir }
647cdf0e10cSrcweir }
648cdf0e10cSrcweir
649cdf0e10cSrcweir // Fallback when there is no BoundRect Property.
650cdf0e10cSrcweir if ( ! bFoundBoundRect )
651cdf0e10cSrcweir {
652cdf0e10cSrcweir awt::Point aPosition (mxShape->getPosition());
653cdf0e10cSrcweir awt::Size aSize (mxShape->getSize());
654cdf0e10cSrcweir aBoundingBox = awt::Rectangle (
655cdf0e10cSrcweir aPosition.X, aPosition.Y,
656cdf0e10cSrcweir aSize.Width, aSize.Height);
657cdf0e10cSrcweir
658cdf0e10cSrcweir // While BoundRects have absolute positions, the position returned
659cdf0e10cSrcweir // by XPosition::getPosition is relative. Get the anchor position
660cdf0e10cSrcweir // (usually not (0,0) for Writer shapes).
661cdf0e10cSrcweir if (xSetInfo.is())
662cdf0e10cSrcweir {
663cdf0e10cSrcweir if (xSetInfo->hasPropertyByName (sAnchorPositionName))
664cdf0e10cSrcweir {
665cdf0e10cSrcweir uno::Any aPos = xSet->getPropertyValue (sAnchorPositionName);
666cdf0e10cSrcweir awt::Point aAnchorPosition;
667cdf0e10cSrcweir aPos >>= aAnchorPosition;
668cdf0e10cSrcweir aBoundingBox.X += aAnchorPosition.X;
669cdf0e10cSrcweir aBoundingBox.Y += aAnchorPosition.Y;
670cdf0e10cSrcweir }
671cdf0e10cSrcweir }
672cdf0e10cSrcweir }
673cdf0e10cSrcweir
674cdf0e10cSrcweir // Transform coordinates from internal to pixel.
675cdf0e10cSrcweir if (maShapeTreeInfo.GetViewForwarder() == NULL)
676cdf0e10cSrcweir throw uno::RuntimeException (::rtl::OUString (
677cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
678cdf0e10cSrcweir "AccessibleShape has no valid view forwarder")),
679cdf0e10cSrcweir static_cast<uno::XWeak*>(this));
680cdf0e10cSrcweir ::Size aPixelSize = maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
681cdf0e10cSrcweir ::Size (aBoundingBox.Width, aBoundingBox.Height));
682cdf0e10cSrcweir ::Point aPixelPosition = maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
683cdf0e10cSrcweir ::Point (aBoundingBox.X, aBoundingBox.Y));
684cdf0e10cSrcweir
685cdf0e10cSrcweir // Clip the shape's bounding box with the bounding box of its parent.
686cdf0e10cSrcweir Reference<XAccessibleComponent> xParentComponent (
687cdf0e10cSrcweir getAccessibleParent(), uno::UNO_QUERY);
688cdf0e10cSrcweir if (xParentComponent.is())
689cdf0e10cSrcweir {
690cdf0e10cSrcweir // Make the coordinates relative to the parent.
691cdf0e10cSrcweir awt::Point aParentLocation (xParentComponent->getLocationOnScreen());
692cdf0e10cSrcweir int x = aPixelPosition.getX() - aParentLocation.X;
693cdf0e10cSrcweir int y = aPixelPosition.getY() - aParentLocation.Y;
694cdf0e10cSrcweir
695cdf0e10cSrcweir /* // The following block is a workarround for bug #99889# (property
696cdf0e10cSrcweir // BoundRect returnes coordinates relative to document window
697cdf0e10cSrcweir // instead of absolute coordinates for shapes in Writer). Has to
698cdf0e10cSrcweir // be removed as soon as bug is fixed.
699cdf0e10cSrcweir
700cdf0e10cSrcweir // Use a non-null anchor position as flag that the shape is in a
701cdf0e10cSrcweir // Writer document.
702cdf0e10cSrcweir if (xSetInfo.is())
703cdf0e10cSrcweir if (xSetInfo->hasPropertyByName (sAnchorPositionName))
704cdf0e10cSrcweir {
705cdf0e10cSrcweir uno::Any aPos = xSet->getPropertyValue (sAnchorPositionName);
706cdf0e10cSrcweir awt::Point aAnchorPosition;
707cdf0e10cSrcweir aPos >>= aAnchorPosition;
708cdf0e10cSrcweir if (aAnchorPosition.X > 0)
709cdf0e10cSrcweir {
710cdf0e10cSrcweir x = aPixelPosition.getX();
711cdf0e10cSrcweir y = aPixelPosition.getY();
712cdf0e10cSrcweir }
713cdf0e10cSrcweir }
714cdf0e10cSrcweir // End of workarround.
715cdf0e10cSrcweir */
716cdf0e10cSrcweir // Clip with parent (with coordinates relative to itself).
717cdf0e10cSrcweir ::Rectangle aBBox (
718cdf0e10cSrcweir x, y, x + aPixelSize.getWidth(), y + aPixelSize.getHeight());
719cdf0e10cSrcweir awt::Size aParentSize (xParentComponent->getSize());
720cdf0e10cSrcweir ::Rectangle aParentBBox (0,0, aParentSize.Width, aParentSize.Height);
721cdf0e10cSrcweir aBBox = aBBox.GetIntersection (aParentBBox);
722cdf0e10cSrcweir aBoundingBox = awt::Rectangle (
723cdf0e10cSrcweir aBBox.getX(),
724cdf0e10cSrcweir aBBox.getY(),
725cdf0e10cSrcweir aBBox.getWidth(),
726cdf0e10cSrcweir aBBox.getHeight());
727cdf0e10cSrcweir }
728cdf0e10cSrcweir else
729cdf0e10cSrcweir {
730cdf0e10cSrcweir OSL_TRACE ("parent does not support component");
731cdf0e10cSrcweir aBoundingBox = awt::Rectangle (
732cdf0e10cSrcweir aPixelPosition.getX(), aPixelPosition.getY(),
733cdf0e10cSrcweir aPixelSize.getWidth(), aPixelSize.getHeight());
734cdf0e10cSrcweir }
735cdf0e10cSrcweir }
736cdf0e10cSrcweir
737cdf0e10cSrcweir return aBoundingBox;
738cdf0e10cSrcweir }
739cdf0e10cSrcweir
740cdf0e10cSrcweir
741cdf0e10cSrcweir
742cdf0e10cSrcweir
getLocation(void)743cdf0e10cSrcweir awt::Point SAL_CALL AccessibleShape::getLocation (void)
744cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
745cdf0e10cSrcweir {
746cdf0e10cSrcweir ThrowIfDisposed ();
747cdf0e10cSrcweir awt::Rectangle aBoundingBox (getBounds());
748cdf0e10cSrcweir return awt::Point (aBoundingBox.X, aBoundingBox.Y);
749cdf0e10cSrcweir }
750cdf0e10cSrcweir
751cdf0e10cSrcweir
752cdf0e10cSrcweir
753cdf0e10cSrcweir
getLocationOnScreen(void)754cdf0e10cSrcweir awt::Point SAL_CALL AccessibleShape::getLocationOnScreen (void)
755cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
756cdf0e10cSrcweir {
757cdf0e10cSrcweir ThrowIfDisposed ();
758cdf0e10cSrcweir
759cdf0e10cSrcweir // Get relative position...
760cdf0e10cSrcweir awt::Point aLocation (getLocation ());
761cdf0e10cSrcweir
762cdf0e10cSrcweir // ... and add absolute position of the parent.
763cdf0e10cSrcweir uno::Reference<XAccessibleComponent> xParentComponent (
764cdf0e10cSrcweir getAccessibleParent(), uno::UNO_QUERY);
765cdf0e10cSrcweir if (xParentComponent.is())
766cdf0e10cSrcweir {
767cdf0e10cSrcweir awt::Point aParentLocation (xParentComponent->getLocationOnScreen());
768cdf0e10cSrcweir aLocation.X += aParentLocation.X;
769cdf0e10cSrcweir aLocation.Y += aParentLocation.Y;
770cdf0e10cSrcweir }
771cdf0e10cSrcweir else
772cdf0e10cSrcweir OSL_TRACE ("getLocation: parent does not support XAccessibleComponent");
773cdf0e10cSrcweir return aLocation;
774cdf0e10cSrcweir }
775cdf0e10cSrcweir
776cdf0e10cSrcweir
777cdf0e10cSrcweir
778cdf0e10cSrcweir
getSize(void)779cdf0e10cSrcweir awt::Size SAL_CALL AccessibleShape::getSize (void)
780cdf0e10cSrcweir throw (uno::RuntimeException)
781cdf0e10cSrcweir {
782cdf0e10cSrcweir ThrowIfDisposed ();
783cdf0e10cSrcweir awt::Rectangle aBoundingBox (getBounds());
784cdf0e10cSrcweir return awt::Size (aBoundingBox.Width, aBoundingBox.Height);
785cdf0e10cSrcweir }
786cdf0e10cSrcweir
787cdf0e10cSrcweir
788cdf0e10cSrcweir
789cdf0e10cSrcweir
getForeground(void)790cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleShape::getForeground (void)
791cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
792cdf0e10cSrcweir {
793cdf0e10cSrcweir ThrowIfDisposed ();
794cdf0e10cSrcweir sal_Int32 nColor (0x0ffffffL);
795cdf0e10cSrcweir
796cdf0e10cSrcweir try
797cdf0e10cSrcweir {
798cdf0e10cSrcweir uno::Reference<beans::XPropertySet> aSet (mxShape, uno::UNO_QUERY);
799cdf0e10cSrcweir if (aSet.is())
800cdf0e10cSrcweir {
801cdf0e10cSrcweir uno::Any aColor;
802cdf0e10cSrcweir aColor = aSet->getPropertyValue (OUString::createFromAscii ("LineColor"));
803cdf0e10cSrcweir aColor >>= nColor;
804cdf0e10cSrcweir }
805cdf0e10cSrcweir }
806cdf0e10cSrcweir catch (::com::sun::star::beans::UnknownPropertyException)
807cdf0e10cSrcweir {
808cdf0e10cSrcweir // Ignore exception and return default color.
809cdf0e10cSrcweir }
810cdf0e10cSrcweir return nColor;
811cdf0e10cSrcweir }
812cdf0e10cSrcweir
813cdf0e10cSrcweir
814cdf0e10cSrcweir
815cdf0e10cSrcweir
getBackground(void)816cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleShape::getBackground (void)
817cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
818cdf0e10cSrcweir {
819cdf0e10cSrcweir ThrowIfDisposed ();
820cdf0e10cSrcweir sal_Int32 nColor (0L);
821cdf0e10cSrcweir
822cdf0e10cSrcweir try
823cdf0e10cSrcweir {
824cdf0e10cSrcweir uno::Reference<beans::XPropertySet> aSet (mxShape, uno::UNO_QUERY);
825cdf0e10cSrcweir if (aSet.is())
826cdf0e10cSrcweir {
827cdf0e10cSrcweir uno::Any aColor;
828cdf0e10cSrcweir aColor = aSet->getPropertyValue (OUString::createFromAscii ("FillColor"));
829cdf0e10cSrcweir aColor >>= nColor;
8309b8096d0SSteve Yin aColor = aSet->getPropertyValue (OUString::createFromAscii ("FillTransparence"));
8319b8096d0SSteve Yin short nTrans=0;
8329b8096d0SSteve Yin aColor >>= nTrans;
8339b8096d0SSteve Yin Color crBk(nColor);
8349b8096d0SSteve Yin if (nTrans == 0 )
8359b8096d0SSteve Yin {
8369b8096d0SSteve Yin crBk.SetTransparency(0xff);
8379b8096d0SSteve Yin }
8389b8096d0SSteve Yin else
8399b8096d0SSteve Yin {
8409b8096d0SSteve Yin nTrans = short(256 - nTrans / 100. * 256);
8419b8096d0SSteve Yin crBk.SetTransparency(sal_uInt8(nTrans));
8429b8096d0SSteve Yin }
8439b8096d0SSteve Yin nColor = crBk.GetColor();
844cdf0e10cSrcweir }
845cdf0e10cSrcweir }
846cdf0e10cSrcweir catch (::com::sun::star::beans::UnknownPropertyException)
847cdf0e10cSrcweir {
848cdf0e10cSrcweir // Ignore exception and return default color.
849cdf0e10cSrcweir }
850cdf0e10cSrcweir return nColor;
851cdf0e10cSrcweir }
852cdf0e10cSrcweir
853cdf0e10cSrcweir
854cdf0e10cSrcweir
855cdf0e10cSrcweir
856cdf0e10cSrcweir //===== XAccessibleEventBroadcaster =========================================
857cdf0e10cSrcweir
addEventListener(const Reference<XAccessibleEventListener> & rxListener)858cdf0e10cSrcweir void SAL_CALL AccessibleShape::addEventListener (
859cdf0e10cSrcweir const Reference<XAccessibleEventListener >& rxListener)
860cdf0e10cSrcweir throw (uno::RuntimeException)
861cdf0e10cSrcweir {
862cdf0e10cSrcweir if (rBHelper.bDisposed || rBHelper.bInDispose)
863cdf0e10cSrcweir {
864cdf0e10cSrcweir uno::Reference<uno::XInterface> xThis (
865cdf0e10cSrcweir (lang::XComponent *)this, uno::UNO_QUERY);
866cdf0e10cSrcweir rxListener->disposing (lang::EventObject (xThis));
867cdf0e10cSrcweir }
868cdf0e10cSrcweir else
869cdf0e10cSrcweir {
870cdf0e10cSrcweir AccessibleContextBase::addEventListener (rxListener);
871cdf0e10cSrcweir if (mpText != NULL)
872cdf0e10cSrcweir mpText->AddEventListener (rxListener);
873cdf0e10cSrcweir }
874cdf0e10cSrcweir }
875cdf0e10cSrcweir
876cdf0e10cSrcweir
877cdf0e10cSrcweir
878cdf0e10cSrcweir
removeEventListener(const Reference<XAccessibleEventListener> & rxListener)879cdf0e10cSrcweir void SAL_CALL AccessibleShape::removeEventListener (
880cdf0e10cSrcweir const Reference<XAccessibleEventListener >& rxListener)
881cdf0e10cSrcweir throw (uno::RuntimeException)
882cdf0e10cSrcweir {
883cdf0e10cSrcweir AccessibleContextBase::removeEventListener (rxListener);
884cdf0e10cSrcweir if (mpText != NULL)
885cdf0e10cSrcweir mpText->RemoveEventListener (rxListener);
886cdf0e10cSrcweir }
887cdf0e10cSrcweir
888cdf0e10cSrcweir
889cdf0e10cSrcweir
890cdf0e10cSrcweir
891cdf0e10cSrcweir //===== XInterface ==========================================================
892cdf0e10cSrcweir
893cdf0e10cSrcweir com::sun::star::uno::Any SAL_CALL
queryInterface(const com::sun::star::uno::Type & rType)894cdf0e10cSrcweir AccessibleShape::queryInterface (const com::sun::star::uno::Type & rType)
895cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
896cdf0e10cSrcweir {
897cdf0e10cSrcweir ::com::sun::star::uno::Any aReturn = AccessibleContextBase::queryInterface (rType);
898cdf0e10cSrcweir if ( ! aReturn.hasValue())
899cdf0e10cSrcweir aReturn = ::cppu::queryInterface (rType,
900cdf0e10cSrcweir static_cast<XAccessibleComponent*>(this),
901cdf0e10cSrcweir static_cast<XAccessibleExtendedComponent*>(this),
9029b8096d0SSteve Yin static_cast< ::com::sun::star::accessibility::XAccessibleSelection* >(this),
9039b8096d0SSteve Yin
9049b8096d0SSteve Yin static_cast< ::com::sun::star::accessibility::XAccessibleExtendedAttributes* >(this),
905cdf0e10cSrcweir static_cast<lang::XEventListener*>(this),
906cdf0e10cSrcweir static_cast<document::XEventListener*>(this),
9079b8096d0SSteve Yin static_cast<lang::XUnoTunnel*>(this),
9089b8096d0SSteve Yin static_cast<XAccessibleGroupPosition*>(this),
9099b8096d0SSteve Yin static_cast<XAccessibleHypertext*>(this)
910cdf0e10cSrcweir );
911cdf0e10cSrcweir return aReturn;
912cdf0e10cSrcweir }
913cdf0e10cSrcweir
914cdf0e10cSrcweir
915cdf0e10cSrcweir
916cdf0e10cSrcweir
917cdf0e10cSrcweir void SAL_CALL
acquire(void)918cdf0e10cSrcweir AccessibleShape::acquire (void)
919cdf0e10cSrcweir throw ()
920cdf0e10cSrcweir {
921cdf0e10cSrcweir AccessibleContextBase::acquire ();
922cdf0e10cSrcweir }
923cdf0e10cSrcweir
924cdf0e10cSrcweir
925cdf0e10cSrcweir
926cdf0e10cSrcweir
927cdf0e10cSrcweir void SAL_CALL
release(void)928cdf0e10cSrcweir AccessibleShape::release (void)
929cdf0e10cSrcweir throw ()
930cdf0e10cSrcweir {
931cdf0e10cSrcweir AccessibleContextBase::release ();
932cdf0e10cSrcweir }
9339b8096d0SSteve Yin //
9349b8096d0SSteve Yin //===== XAccessibleSelection ============================================
9359b8096d0SSteve Yin //
9369b8096d0SSteve Yin
9379b8096d0SSteve Yin //--------------------------------------------------------------------------------
selectAccessibleChild(sal_Int32)9389b8096d0SSteve Yin void SAL_CALL AccessibleShape::selectAccessibleChild( sal_Int32 )
9399b8096d0SSteve Yin throw ( IndexOutOfBoundsException, RuntimeException )
9409b8096d0SSteve Yin {
9419b8096d0SSteve Yin }
9429b8096d0SSteve Yin
9439b8096d0SSteve Yin //----------------------------------------------------------------------------------
isAccessibleChildSelected(sal_Int32 nChildIndex)9449b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleShape::isAccessibleChildSelected( sal_Int32 nChildIndex )
9459b8096d0SSteve Yin throw ( IndexOutOfBoundsException,
9469b8096d0SSteve Yin RuntimeException )
9479b8096d0SSteve Yin {
9489b8096d0SSteve Yin uno::Reference<XAccessible> xAcc = getAccessibleChild( nChildIndex );
9499b8096d0SSteve Yin uno::Reference<XAccessibleContext> xContext;
9509b8096d0SSteve Yin if( xAcc.is() )
9519b8096d0SSteve Yin {
9529b8096d0SSteve Yin xContext = xAcc->getAccessibleContext();
9539b8096d0SSteve Yin }
9549b8096d0SSteve Yin
9559b8096d0SSteve Yin if( xContext.is() )
9569b8096d0SSteve Yin {
9579b8096d0SSteve Yin if( xContext->getAccessibleRole() == AccessibleRole::PARAGRAPH )
9589b8096d0SSteve Yin {
9599b8096d0SSteve Yin uno::Reference< ::com::sun::star::accessibility::XAccessibleText >
9609b8096d0SSteve Yin xText(xAcc, uno::UNO_QUERY);
9619b8096d0SSteve Yin if( xText.is() )
9629b8096d0SSteve Yin {
9639b8096d0SSteve Yin if( xText->getSelectionStart() >= 0 ) return sal_True;
9649b8096d0SSteve Yin }
9659b8096d0SSteve Yin }
9669b8096d0SSteve Yin else if( xContext->getAccessibleRole() == AccessibleRole::SHAPE )
9679b8096d0SSteve Yin {
9689b8096d0SSteve Yin Reference< XAccessibleStateSet > pRState = xContext->getAccessibleStateSet();
9699b8096d0SSteve Yin if( !pRState.is() )
9709b8096d0SSteve Yin return sal_False;
9719b8096d0SSteve Yin
9729b8096d0SSteve Yin uno::Sequence<short> pStates = pRState->getStates();
9739b8096d0SSteve Yin int nCount = pStates.getLength();
9749b8096d0SSteve Yin for( int i = 0; i < nCount; i++ )
9759b8096d0SSteve Yin {
9769b8096d0SSteve Yin if(pStates[i] == AccessibleStateType::SELECTED)
9779b8096d0SSteve Yin return sal_True;
9789b8096d0SSteve Yin }
9799b8096d0SSteve Yin return sal_False;
9809b8096d0SSteve Yin }
9819b8096d0SSteve Yin }
9829b8096d0SSteve Yin
9839b8096d0SSteve Yin return sal_False;
9849b8096d0SSteve Yin }
9859b8096d0SSteve Yin
9869b8096d0SSteve Yin //---------------------------------------------------------------------
clearAccessibleSelection()9879b8096d0SSteve Yin void SAL_CALL AccessibleShape::clearAccessibleSelection( )
9889b8096d0SSteve Yin throw ( RuntimeException )
9899b8096d0SSteve Yin {
9909b8096d0SSteve Yin }
991cdf0e10cSrcweir
9929b8096d0SSteve Yin //-------------------------------------------------------------------------
selectAllAccessibleChildren()9939b8096d0SSteve Yin void SAL_CALL AccessibleShape::selectAllAccessibleChildren( )
9949b8096d0SSteve Yin throw ( RuntimeException )
9959b8096d0SSteve Yin {
9969b8096d0SSteve Yin }
997cdf0e10cSrcweir
9989b8096d0SSteve Yin //----------------------------------------------------------------------------
getSelectedAccessibleChildCount()9999b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getSelectedAccessibleChildCount()
10009b8096d0SSteve Yin throw ( RuntimeException )
10019b8096d0SSteve Yin {
10029b8096d0SSteve Yin sal_Int32 nCount = 0;
10039b8096d0SSteve Yin sal_Int32 TotalCount = getAccessibleChildCount();
10049b8096d0SSteve Yin for( sal_Int32 i = 0; i < TotalCount; i++ )
10059b8096d0SSteve Yin if( isAccessibleChildSelected(i) ) nCount++;
1006cdf0e10cSrcweir
10079b8096d0SSteve Yin return nCount;
10089b8096d0SSteve Yin }
1009cdf0e10cSrcweir
10109b8096d0SSteve Yin //--------------------------------------------------------------------------------------
getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex)10119b8096d0SSteve Yin Reference<XAccessible> SAL_CALL AccessibleShape::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
10129b8096d0SSteve Yin throw ( IndexOutOfBoundsException, RuntimeException)
10139b8096d0SSteve Yin {
10149b8096d0SSteve Yin if ( nSelectedChildIndex > getSelectedAccessibleChildCount() )
10159b8096d0SSteve Yin throw IndexOutOfBoundsException();
10169b8096d0SSteve Yin sal_Int32 i1, i2;
10179b8096d0SSteve Yin for( i1 = 0, i2 = 0; i1 < getAccessibleChildCount(); i1++ )
10189b8096d0SSteve Yin if( isAccessibleChildSelected(i1) )
10199b8096d0SSteve Yin {
10209b8096d0SSteve Yin if( i2 == nSelectedChildIndex )
10219b8096d0SSteve Yin return getAccessibleChild( i1 );
10229b8096d0SSteve Yin i2++;
10239b8096d0SSteve Yin }
10249b8096d0SSteve Yin return Reference<XAccessible>();
10259b8096d0SSteve Yin }
10269b8096d0SSteve Yin
10279b8096d0SSteve Yin //----------------------------------------------------------------------------------
deselectAccessibleChild(sal_Int32)10289b8096d0SSteve Yin void SAL_CALL AccessibleShape::deselectAccessibleChild( sal_Int32 )
10299b8096d0SSteve Yin throw ( IndexOutOfBoundsException,
10309b8096d0SSteve Yin RuntimeException )
10319b8096d0SSteve Yin {
10329b8096d0SSteve Yin
10339b8096d0SSteve Yin }
10349b8096d0SSteve Yin
10359b8096d0SSteve Yin //===== XAccessibleExtendedAttributes ========================================================
getExtendedAttributes()10369b8096d0SSteve Yin uno::Any SAL_CALL AccessibleShape::getExtendedAttributes()
10379b8096d0SSteve Yin throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
10389b8096d0SSteve Yin {
10399b8096d0SSteve Yin uno::Any strRet;
10409b8096d0SSteve Yin ::rtl::OUString style;
10419b8096d0SSteve Yin if( getAccessibleRole() != AccessibleRole::SHAPE ) return strRet;
10429b8096d0SSteve Yin if( m_pShape )
10439b8096d0SSteve Yin {
10449b8096d0SSteve Yin //style = ::rtl::OUString::createFromAscii("style=");
10459b8096d0SSteve Yin style = ::rtl::OUString::createFromAscii("style:");
10469b8096d0SSteve Yin style += GetStyle();
10479b8096d0SSteve Yin }
10489b8096d0SSteve Yin style += ::rtl::OUString::createFromAscii(";");
10499b8096d0SSteve Yin strRet <<= style;
10509b8096d0SSteve Yin return strRet;
10519b8096d0SSteve Yin }
1052cdf0e10cSrcweir //===== XServiceInfo ========================================================
1053cdf0e10cSrcweir
1054cdf0e10cSrcweir ::rtl::OUString SAL_CALL
getImplementationName(void)1055cdf0e10cSrcweir AccessibleShape::getImplementationName (void)
1056cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
1057cdf0e10cSrcweir {
1058cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleShape"));
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir
1061cdf0e10cSrcweir
1062cdf0e10cSrcweir
1063cdf0e10cSrcweir
1064cdf0e10cSrcweir uno::Sequence<OUString> SAL_CALL
getSupportedServiceNames(void)1065cdf0e10cSrcweir AccessibleShape::getSupportedServiceNames (void)
1066cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir ThrowIfDisposed ();
1069cdf0e10cSrcweir // Get list of supported service names from base class...
1070cdf0e10cSrcweir uno::Sequence<OUString> aServiceNames =
1071cdf0e10cSrcweir AccessibleContextBase::getSupportedServiceNames();
1072cdf0e10cSrcweir sal_Int32 nCount (aServiceNames.getLength());
1073cdf0e10cSrcweir
1074cdf0e10cSrcweir // ...and add additional names.
1075cdf0e10cSrcweir aServiceNames.realloc (nCount + 1);
1076cdf0e10cSrcweir static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM(
1077cdf0e10cSrcweir "com.sun.star.drawing.AccessibleShape"));
1078cdf0e10cSrcweir aServiceNames[nCount] = sAdditionalServiceName;
1079cdf0e10cSrcweir
1080cdf0e10cSrcweir return aServiceNames;
1081cdf0e10cSrcweir }
1082cdf0e10cSrcweir
1083cdf0e10cSrcweir
1084cdf0e10cSrcweir
1085cdf0e10cSrcweir
1086cdf0e10cSrcweir
1087cdf0e10cSrcweir //===== XTypeProvider ===================================================
1088cdf0e10cSrcweir
1089cdf0e10cSrcweir uno::Sequence<uno::Type> SAL_CALL
getTypes(void)1090cdf0e10cSrcweir AccessibleShape::getTypes (void)
1091cdf0e10cSrcweir throw (uno::RuntimeException)
1092cdf0e10cSrcweir {
1093cdf0e10cSrcweir ThrowIfDisposed ();
1094cdf0e10cSrcweir // Get list of types from the context base implementation, ...
1095cdf0e10cSrcweir uno::Sequence<uno::Type> aTypeList (AccessibleContextBase::getTypes());
1096cdf0e10cSrcweir // ... get list of types from component base implementation, ...
1097cdf0e10cSrcweir uno::Sequence<uno::Type> aComponentTypeList (AccessibleComponentBase::getTypes());
1098cdf0e10cSrcweir // ... define local types, ...
1099cdf0e10cSrcweir const uno::Type aLangEventListenerType =
1100cdf0e10cSrcweir ::getCppuType((const uno::Reference<lang::XEventListener>*)0);
1101cdf0e10cSrcweir const uno::Type aDocumentEventListenerType =
1102cdf0e10cSrcweir ::getCppuType((const uno::Reference<document::XEventListener>*)0);
1103cdf0e10cSrcweir const uno::Type aUnoTunnelType =
1104cdf0e10cSrcweir ::getCppuType((const uno::Reference<lang::XUnoTunnel>*)0);
1105cdf0e10cSrcweir // const uno::Type aStateSetType =
1106cdf0e10cSrcweir // ::getCppuType((const uno::Reference<XAccessibleStateSet>*)0);
1107cdf0e10cSrcweir
1108cdf0e10cSrcweir // ... and merge them all into one list.
1109cdf0e10cSrcweir sal_Int32 nTypeCount (aTypeList.getLength()),
1110cdf0e10cSrcweir nComponentTypeCount (aComponentTypeList.getLength());
1111cdf0e10cSrcweir int i;
1112cdf0e10cSrcweir
1113cdf0e10cSrcweir aTypeList.realloc (nTypeCount + nComponentTypeCount + 3);
1114cdf0e10cSrcweir
1115cdf0e10cSrcweir for (i=0; i<nComponentTypeCount; i++)
1116cdf0e10cSrcweir aTypeList[nTypeCount + i] = aComponentTypeList[i];
1117cdf0e10cSrcweir
1118cdf0e10cSrcweir aTypeList[nTypeCount + i++ ] = aLangEventListenerType;
1119cdf0e10cSrcweir aTypeList[nTypeCount + i++ ] = aDocumentEventListenerType;
1120cdf0e10cSrcweir aTypeList[nTypeCount + i ] = aUnoTunnelType;
1121cdf0e10cSrcweir
1122cdf0e10cSrcweir return aTypeList;
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir
1125cdf0e10cSrcweir
1126cdf0e10cSrcweir
1127cdf0e10cSrcweir
1128cdf0e10cSrcweir //===== lang::XEventListener ================================================
1129cdf0e10cSrcweir
1130cdf0e10cSrcweir /** Disposing calls are accepted only from the model: Just reset the
1131cdf0e10cSrcweir reference to the model in the shape tree info. Otherwise this object
1132cdf0e10cSrcweir remains functional.
1133cdf0e10cSrcweir */
1134cdf0e10cSrcweir void SAL_CALL
disposing(const lang::EventObject & aEvent)1135cdf0e10cSrcweir AccessibleShape::disposing (const lang::EventObject& aEvent)
1136cdf0e10cSrcweir throw (uno::RuntimeException)
1137cdf0e10cSrcweir {
1138cdf0e10cSrcweir ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
1139cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex);
1140cdf0e10cSrcweir
1141cdf0e10cSrcweir try
1142cdf0e10cSrcweir {
1143cdf0e10cSrcweir if (aEvent.Source == maShapeTreeInfo.GetModelBroadcaster())
1144cdf0e10cSrcweir {
1145cdf0e10cSrcweir // Remove reference to model broadcaster to allow it to pass
1146cdf0e10cSrcweir // away.
1147cdf0e10cSrcweir maShapeTreeInfo.SetModelBroadcaster(NULL);
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir
1150cdf0e10cSrcweir }
1151cdf0e10cSrcweir catch (uno::RuntimeException e)
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir OSL_TRACE ("caught exception while disposing");
1154cdf0e10cSrcweir }
1155cdf0e10cSrcweir }
1156cdf0e10cSrcweir
1157cdf0e10cSrcweir
1158cdf0e10cSrcweir
1159cdf0e10cSrcweir
1160cdf0e10cSrcweir //===== document::XEventListener ============================================
1161cdf0e10cSrcweir
1162cdf0e10cSrcweir void SAL_CALL
notifyEvent(const document::EventObject & rEventObject)1163cdf0e10cSrcweir AccessibleShape::notifyEvent (const document::EventObject& rEventObject)
1164cdf0e10cSrcweir throw (uno::RuntimeException)
1165cdf0e10cSrcweir {
1166cdf0e10cSrcweir static const OUString sShapeModified (
1167cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("ShapeModified"));
1168cdf0e10cSrcweir
1169cdf0e10cSrcweir // First check if the event is for us.
1170cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape (
1171cdf0e10cSrcweir rEventObject.Source, uno::UNO_QUERY);
1172cdf0e10cSrcweir if ( xShape.get() == mxShape.get() )
1173cdf0e10cSrcweir {
1174cdf0e10cSrcweir if (rEventObject.EventName.equals (sShapeModified))
1175cdf0e10cSrcweir {
11769b8096d0SSteve Yin //Need to update text children when receiving ShapeModified hint when exiting edit mode for text box
11779b8096d0SSteve Yin if (mpText)
11789b8096d0SSteve Yin mpText->UpdateChildren();
11799b8096d0SSteve Yin
11809b8096d0SSteve Yin
1181cdf0e10cSrcweir // Some property of a shape has been modified. Send an event
1182cdf0e10cSrcweir // that indicates a change of the visible data to all listeners.
1183cdf0e10cSrcweir CommitChange (
1184cdf0e10cSrcweir AccessibleEventId::VISIBLE_DATA_CHANGED,
1185cdf0e10cSrcweir uno::Any(),
1186cdf0e10cSrcweir uno::Any());
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir // Name and Description may have changed. Update the local
1189cdf0e10cSrcweir // values accordingly.
1190cdf0e10cSrcweir UpdateNameAndDescription();
1191cdf0e10cSrcweir }
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir }
1194cdf0e10cSrcweir
1195cdf0e10cSrcweir
1196cdf0e10cSrcweir
1197cdf0e10cSrcweir
1198cdf0e10cSrcweir //===== lang::XUnoTunnel ================================================
1199cdf0e10cSrcweir
1200cdf0e10cSrcweir const uno::Sequence< sal_Int8 >&
getUnoTunnelImplementationId()1201cdf0e10cSrcweir AccessibleShape::getUnoTunnelImplementationId()
1202cdf0e10cSrcweir throw()
1203cdf0e10cSrcweir {
1204cdf0e10cSrcweir static uno::Sequence< sal_Int8 >* pSeq = 0;
1205cdf0e10cSrcweir
1206cdf0e10cSrcweir if( !pSeq )
1207cdf0e10cSrcweir {
1208cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
1209cdf0e10cSrcweir
1210cdf0e10cSrcweir if( !pSeq )
1211cdf0e10cSrcweir {
1212cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aSeq( 16 );
1213cdf0e10cSrcweir rtl_createUuid( (sal_uInt8*) aSeq.getArray(), 0, sal_True );
1214cdf0e10cSrcweir pSeq = &aSeq;
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir
1218cdf0e10cSrcweir return( *pSeq );
1219cdf0e10cSrcweir }
1220cdf0e10cSrcweir
1221cdf0e10cSrcweir //------------------------------------------------------------------------------
1222cdf0e10cSrcweir AccessibleShape*
getImplementation(const uno::Reference<uno::XInterface> & rxIFace)1223cdf0e10cSrcweir AccessibleShape::getImplementation( const uno::Reference< uno::XInterface >& rxIFace )
1224cdf0e10cSrcweir throw()
1225cdf0e10cSrcweir {
1226cdf0e10cSrcweir uno::Reference< lang::XUnoTunnel > xTunnel( rxIFace, uno::UNO_QUERY );
1227cdf0e10cSrcweir AccessibleShape* pReturn = NULL;
1228cdf0e10cSrcweir
1229cdf0e10cSrcweir if( xTunnel.is() )
1230cdf0e10cSrcweir pReturn = reinterpret_cast< AccessibleShape* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) );
1231cdf0e10cSrcweir
1232cdf0e10cSrcweir return( pReturn );
1233cdf0e10cSrcweir }
1234cdf0e10cSrcweir
1235cdf0e10cSrcweir //------------------------------------------------------------------------------
1236cdf0e10cSrcweir sal_Int64 SAL_CALL
getSomething(const uno::Sequence<sal_Int8> & rIdentifier)1237cdf0e10cSrcweir AccessibleShape::getSomething( const uno::Sequence< sal_Int8 >& rIdentifier )
1238cdf0e10cSrcweir throw(uno::RuntimeException)
1239cdf0e10cSrcweir {
1240cdf0e10cSrcweir sal_Int64 nReturn( 0 );
1241cdf0e10cSrcweir
1242cdf0e10cSrcweir if( ( rIdentifier.getLength() == 16 ) && ( 0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(), rIdentifier.getConstArray(), 16 ) ) )
1243cdf0e10cSrcweir nReturn = reinterpret_cast< sal_Int64 >( this );
1244cdf0e10cSrcweir
1245cdf0e10cSrcweir return( nReturn );
1246cdf0e10cSrcweir }
1247cdf0e10cSrcweir
1248cdf0e10cSrcweir //===== IAccessibleViewForwarderListener ====================================
1249cdf0e10cSrcweir
ViewForwarderChanged(ChangeType aChangeType,const IAccessibleViewForwarder * pViewForwarder)1250cdf0e10cSrcweir void AccessibleShape::ViewForwarderChanged (ChangeType aChangeType,
1251cdf0e10cSrcweir const IAccessibleViewForwarder* pViewForwarder)
1252cdf0e10cSrcweir {
1253cdf0e10cSrcweir // Inform all listeners that the graphical representation (i.e. size
1254cdf0e10cSrcweir // and/or position) of the shape has changed.
1255cdf0e10cSrcweir CommitChange (AccessibleEventId::VISIBLE_DATA_CHANGED,
1256cdf0e10cSrcweir uno::Any(),
1257cdf0e10cSrcweir uno::Any());
1258cdf0e10cSrcweir
1259cdf0e10cSrcweir // Tell children manager of the modified view forwarder.
1260cdf0e10cSrcweir if (mpChildrenManager != NULL)
1261cdf0e10cSrcweir mpChildrenManager->ViewForwarderChanged (aChangeType, pViewForwarder);
1262cdf0e10cSrcweir
1263cdf0e10cSrcweir // update our children that our screen position might have changed
1264cdf0e10cSrcweir if( mpText )
1265cdf0e10cSrcweir mpText->UpdateChildren();
1266cdf0e10cSrcweir }
1267cdf0e10cSrcweir
1268cdf0e10cSrcweir
1269cdf0e10cSrcweir
1270cdf0e10cSrcweir
1271cdf0e10cSrcweir //===== protected internal ==================================================
1272cdf0e10cSrcweir /// Set this object's name if is different to the current name.
1273cdf0e10cSrcweir ::rtl::OUString
CreateAccessibleBaseName(void)1274cdf0e10cSrcweir AccessibleShape::CreateAccessibleBaseName (void)
1275cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
1276cdf0e10cSrcweir {
1277cdf0e10cSrcweir return ShapeTypeHandler::CreateAccessibleBaseName( mxShape );
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir
1280cdf0e10cSrcweir
1281cdf0e10cSrcweir ::rtl::OUString
CreateAccessibleName(void)1282cdf0e10cSrcweir AccessibleShape::CreateAccessibleName (void)
1283cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
1284cdf0e10cSrcweir {
12859b8096d0SSteve Yin //OUString sName (CreateAccessibleBaseName());
12869b8096d0SSteve Yin OUString sName;
12879b8096d0SSteve Yin sName = GetFullAccessibleName(this);
12889b8096d0SSteve Yin return sName;
12899b8096d0SSteve Yin }
1290cdf0e10cSrcweir
12919b8096d0SSteve Yin ::rtl::OUString
GetFullAccessibleName(AccessibleShape * shape)12929b8096d0SSteve Yin AccessibleShape::GetFullAccessibleName (AccessibleShape *shape)
12939b8096d0SSteve Yin throw (::com::sun::star::uno::RuntimeException)
12949b8096d0SSteve Yin {
12959b8096d0SSteve Yin OUString sName (shape->CreateAccessibleBaseName());
1296cdf0e10cSrcweir // Append the shape's index to the name to disambiguate between shapes
1297cdf0e10cSrcweir // of the same type. If such an index where not given to the
1298cdf0e10cSrcweir // constructor then use the z-order instead. If even that does not exist
1299cdf0e10cSrcweir // we throw an exception.
13009b8096d0SSteve Yin //long nIndex = mnIndex;
13019b8096d0SSteve Yin //if (nIndex == -1)
13029b8096d0SSteve Yin //{
13039b8096d0SSteve Yin // try
13049b8096d0SSteve Yin // {
13059b8096d0SSteve Yin // uno::Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY);
13069b8096d0SSteve Yin // if (xSet.is())
13079b8096d0SSteve Yin // {
13089b8096d0SSteve Yin // uno::Any aZOrder (xSet->getPropertyValue (::rtl::OUString::createFromAscii ("ZOrder")));
13099b8096d0SSteve Yin // aZOrder >>= nIndex;
13109b8096d0SSteve Yin
13119b8096d0SSteve Yin // // Add one to be not zero based.
13129b8096d0SSteve Yin // nIndex += 1;
13139b8096d0SSteve Yin // }
13149b8096d0SSteve Yin // }
13159b8096d0SSteve Yin // catch (beans::UnknownPropertyException)
13169b8096d0SSteve Yin // {
13179b8096d0SSteve Yin // // We throw our own exception that is a bit more informative.
13189b8096d0SSteve Yin // throw uno::RuntimeException (::rtl::OUString (
13199b8096d0SSteve Yin // RTL_CONSTASCII_USTRINGPARAM("AccessibleShape has invalid index and no ZOrder property")),
13209b8096d0SSteve Yin // static_cast<uno::XWeak*>(this));
13219b8096d0SSteve Yin // }
13229b8096d0SSteve Yin
13239b8096d0SSteve Yin //}
13249b8096d0SSteve Yin
1325*796b7e2aSmseidel //// Put a space between name and index because of Gnopernicus otherwise
13269b8096d0SSteve Yin //// spells the name.
13279b8096d0SSteve Yin //sName += OUString (RTL_CONSTASCII_USTRINGPARAM(" ")) + OUString::valueOf (nIndex);
13289b8096d0SSteve Yin
13299b8096d0SSteve Yin //return sName;
13309b8096d0SSteve Yin
13319b8096d0SSteve Yin XubString nameStr;
13329b8096d0SSteve Yin if(shape->m_pShape)
13339b8096d0SSteve Yin nameStr = shape->m_pShape->GetName();
13349b8096d0SSteve Yin if(nameStr.Len() == 0)
13359b8096d0SSteve Yin {
13369b8096d0SSteve Yin sName += OUString( RTL_CONSTASCII_USTRINGPARAM( " " ));
13379b8096d0SSteve Yin }
13389b8096d0SSteve Yin else
13399b8096d0SSteve Yin {
13409b8096d0SSteve Yin sName = nameStr;
13419b8096d0SSteve Yin }
13429b8096d0SSteve Yin /*
13439b8096d0SSteve Yin sal_Int32 nChildCount = shape->getAccessibleChildCount();
13449b8096d0SSteve Yin if(nChildCount > 0)
13459b8096d0SSteve Yin {
13469b8096d0SSteve Yin for (sal_Int32 i=0; i<nChildCount; ++i)
13479b8096d0SSteve Yin {
13489b8096d0SSteve Yin Reference<XAccessible> xChild (shape->getAccessibleChild (i));
13499b8096d0SSteve Yin if (xChild.is())
13509b8096d0SSteve Yin {
13519b8096d0SSteve Yin uno::Reference <XAccessibleContext> xChildContext(xChild->getAccessibleContext());
13529b8096d0SSteve Yin if (xChildContext->getAccessibleRole() == AccessibleRole::PARAGRAPH)
13539b8096d0SSteve Yin {
13549b8096d0SSteve Yin uno::Reference<XAccessibleText> xText = uno::Reference<XAccessibleText> ( xChild, uno::UNO_QUERY );
13559b8096d0SSteve Yin sName += OUString( RTL_CONSTASCII_USTRINGPARAM( " " )) + xText->getText();
13569b8096d0SSteve Yin }
13579b8096d0SSteve Yin else if (xChildContext->getAccessibleRole() == AccessibleRole::SHAPE)
13589b8096d0SSteve Yin {
13599b8096d0SSteve Yin sName += OUString( RTL_CONSTASCII_USTRINGPARAM( " " )) + GetFullAccessibleName(static_cast< AccessibleShape*>( xChild.get()));
13609b8096d0SSteve Yin }
13619b8096d0SSteve Yin }
13629b8096d0SSteve Yin }
13639b8096d0SSteve Yin }
13649b8096d0SSteve Yin */
13659b8096d0SSteve Yin //Solution:If the new produced name if not the same with last,notify name changed
13669b8096d0SSteve Yin // Event
13679b8096d0SSteve Yin if( aAccName != sName && aAccName.getLength() != 0 )
1368cdf0e10cSrcweir {
13699b8096d0SSteve Yin uno::Any aOldValue, aNewValue;
13709b8096d0SSteve Yin aOldValue <<= aAccName;
13719b8096d0SSteve Yin aNewValue <<= sName;
13729b8096d0SSteve Yin CommitChange(
13739b8096d0SSteve Yin AccessibleEventId::NAME_CHANGED,
13749b8096d0SSteve Yin aNewValue,
13759b8096d0SSteve Yin aOldValue);
1376cdf0e10cSrcweir }
13779b8096d0SSteve Yin aAccName = sName;
13789b8096d0SSteve Yin return sName;
1379cdf0e10cSrcweir }
1380cdf0e10cSrcweir ::rtl::OUString
CreateAccessibleDescription(void)1381cdf0e10cSrcweir AccessibleShape::CreateAccessibleDescription (void)
1382cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
1383cdf0e10cSrcweir {
1384cdf0e10cSrcweir DescriptionGenerator aDG (mxShape);
1385cdf0e10cSrcweir aDG.Initialize (CreateAccessibleBaseName());
1386cdf0e10cSrcweir switch (ShapeTypeHandler::Instance().GetTypeId (mxShape))
1387cdf0e10cSrcweir {
1388cdf0e10cSrcweir case DRAWING_3D_CUBE:
1389cdf0e10cSrcweir case DRAWING_3D_EXTRUDE:
1390cdf0e10cSrcweir case DRAWING_3D_LATHE:
1391cdf0e10cSrcweir case DRAWING_3D_SPHERE:
1392cdf0e10cSrcweir aDG.Add3DProperties ();
1393cdf0e10cSrcweir break;
1394cdf0e10cSrcweir
1395cdf0e10cSrcweir case DRAWING_3D_SCENE:
1396cdf0e10cSrcweir case DRAWING_GROUP:
1397cdf0e10cSrcweir case DRAWING_PAGE:
1398cdf0e10cSrcweir // No further information is appended.
1399cdf0e10cSrcweir break;
1400cdf0e10cSrcweir
1401cdf0e10cSrcweir case DRAWING_CAPTION:
1402cdf0e10cSrcweir case DRAWING_CLOSED_BEZIER:
1403cdf0e10cSrcweir case DRAWING_CLOSED_FREEHAND:
1404cdf0e10cSrcweir case DRAWING_ELLIPSE:
1405cdf0e10cSrcweir case DRAWING_POLY_POLYGON:
1406cdf0e10cSrcweir case DRAWING_POLY_POLYGON_PATH:
1407cdf0e10cSrcweir case DRAWING_RECTANGLE:
1408cdf0e10cSrcweir aDG.AddLineProperties ();
1409cdf0e10cSrcweir aDG.AddFillProperties ();
1410cdf0e10cSrcweir break;
1411cdf0e10cSrcweir
1412cdf0e10cSrcweir case DRAWING_CONNECTOR:
1413cdf0e10cSrcweir case DRAWING_LINE:
1414cdf0e10cSrcweir case DRAWING_MEASURE:
1415cdf0e10cSrcweir case DRAWING_OPEN_BEZIER:
1416cdf0e10cSrcweir case DRAWING_OPEN_FREEHAND:
1417cdf0e10cSrcweir case DRAWING_POLY_LINE:
1418cdf0e10cSrcweir case DRAWING_POLY_LINE_PATH:
1419cdf0e10cSrcweir aDG.AddLineProperties ();
1420cdf0e10cSrcweir break;
1421cdf0e10cSrcweir
1422cdf0e10cSrcweir case DRAWING_CONTROL:
1423cdf0e10cSrcweir aDG.AddProperty (OUString::createFromAscii ("ControlBackground"),
1424cdf0e10cSrcweir DescriptionGenerator::COLOR,
1425cdf0e10cSrcweir OUString());
1426cdf0e10cSrcweir aDG.AddProperty (OUString::createFromAscii ("ControlBorder"),
1427cdf0e10cSrcweir DescriptionGenerator::INTEGER,
1428cdf0e10cSrcweir OUString());
1429cdf0e10cSrcweir break;
1430cdf0e10cSrcweir
1431cdf0e10cSrcweir case DRAWING_TEXT:
1432cdf0e10cSrcweir aDG.AddTextProperties ();
1433cdf0e10cSrcweir break;
1434cdf0e10cSrcweir
1435cdf0e10cSrcweir default:
1436cdf0e10cSrcweir aDG.Initialize (::rtl::OUString (
1437cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("Unknown accessible shape")));
1438cdf0e10cSrcweir uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
1439cdf0e10cSrcweir if (xDescriptor.is())
1440cdf0e10cSrcweir {
1441cdf0e10cSrcweir aDG.AppendString (::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("service name=")));
1442cdf0e10cSrcweir aDG.AppendString (xDescriptor->getShapeType());
1443cdf0e10cSrcweir }
1444cdf0e10cSrcweir }
1445cdf0e10cSrcweir
1446cdf0e10cSrcweir return aDG();
1447cdf0e10cSrcweir }
1448cdf0e10cSrcweir
1449cdf0e10cSrcweir
1450cdf0e10cSrcweir
1451cdf0e10cSrcweir
GetXShape()1452cdf0e10cSrcweir uno::Reference< drawing::XShape > AccessibleShape::GetXShape()
1453cdf0e10cSrcweir {
1454cdf0e10cSrcweir return( mxShape );
1455cdf0e10cSrcweir }
1456cdf0e10cSrcweir
1457cdf0e10cSrcweir
1458cdf0e10cSrcweir
1459cdf0e10cSrcweir // protected
disposing(void)1460cdf0e10cSrcweir void AccessibleShape::disposing (void)
1461cdf0e10cSrcweir {
1462cdf0e10cSrcweir ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
1463cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex);
1464cdf0e10cSrcweir
1465cdf0e10cSrcweir // Make sure to send an event that this object looses the focus in the
1466cdf0e10cSrcweir // case that it has the focus.
1467cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet =
1468cdf0e10cSrcweir static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
1469cdf0e10cSrcweir if (pStateSet != NULL)
1470cdf0e10cSrcweir pStateSet->RemoveState (AccessibleStateType::FOCUSED);
1471cdf0e10cSrcweir
1472cdf0e10cSrcweir // Unregister from broadcasters.
1473cdf0e10cSrcweir Reference<lang::XComponent> xComponent (mxShape, uno::UNO_QUERY);
1474cdf0e10cSrcweir if (xComponent.is())
1475cdf0e10cSrcweir xComponent->removeEventListener (this);
1476cdf0e10cSrcweir
1477cdf0e10cSrcweir // Unregister from model.
1478cdf0e10cSrcweir if (maShapeTreeInfo.GetModelBroadcaster().is())
1479cdf0e10cSrcweir maShapeTreeInfo.GetModelBroadcaster()->removeEventListener (
1480cdf0e10cSrcweir static_cast<document::XEventListener*>(this));
1481cdf0e10cSrcweir
1482cdf0e10cSrcweir // Release the child containers.
1483cdf0e10cSrcweir if (mpChildrenManager != NULL)
1484cdf0e10cSrcweir {
1485cdf0e10cSrcweir delete mpChildrenManager;
1486cdf0e10cSrcweir mpChildrenManager = NULL;
1487cdf0e10cSrcweir }
1488cdf0e10cSrcweir if (mpText != NULL)
1489cdf0e10cSrcweir {
1490cdf0e10cSrcweir mpText->Dispose();
1491cdf0e10cSrcweir delete mpText;
1492cdf0e10cSrcweir mpText = NULL;
1493cdf0e10cSrcweir }
1494cdf0e10cSrcweir
1495cdf0e10cSrcweir // Cleanup. Remove references to objects to allow them to be
1496cdf0e10cSrcweir // destroyed.
1497cdf0e10cSrcweir mxShape = NULL;
1498cdf0e10cSrcweir maShapeTreeInfo = AccessibleShapeTreeInfo();
1499cdf0e10cSrcweir
1500cdf0e10cSrcweir // Call base classes.
1501cdf0e10cSrcweir AccessibleContextBase::dispose ();
1502cdf0e10cSrcweir }
1503cdf0e10cSrcweir
1504cdf0e10cSrcweir sal_Int32 SAL_CALL
getAccessibleIndexInParent(void)1505cdf0e10cSrcweir AccessibleShape::getAccessibleIndexInParent (void)
1506cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
1507cdf0e10cSrcweir {
1508cdf0e10cSrcweir ThrowIfDisposed ();
1509cdf0e10cSrcweir // Use a simple but slow solution for now. Optimize later.
1510cdf0e10cSrcweir
1511cdf0e10cSrcweir sal_Int32 nIndex = m_nIndexInParent;
1512cdf0e10cSrcweir if ( -1 == nIndex )
1513cdf0e10cSrcweir nIndex = AccessibleContextBase::getAccessibleIndexInParent();
1514cdf0e10cSrcweir return nIndex;
1515cdf0e10cSrcweir }
1516cdf0e10cSrcweir
1517cdf0e10cSrcweir
1518cdf0e10cSrcweir
1519cdf0e10cSrcweir
UpdateNameAndDescription(void)1520cdf0e10cSrcweir void AccessibleShape::UpdateNameAndDescription (void)
1521cdf0e10cSrcweir {
1522cdf0e10cSrcweir // Ignore missing title, name, or description. There are fallbacks for
1523cdf0e10cSrcweir // them.
1524cdf0e10cSrcweir try
1525cdf0e10cSrcweir {
1526cdf0e10cSrcweir Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY_THROW);
1527cdf0e10cSrcweir OUString sString;
1528cdf0e10cSrcweir
1529cdf0e10cSrcweir // Get the accessible name.
1530cdf0e10cSrcweir sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Title")));
1531cdf0e10cSrcweir if (sString.getLength() > 0)
1532cdf0e10cSrcweir {
1533cdf0e10cSrcweir SetAccessibleName(sString, AccessibleContextBase::FromShape);
1534cdf0e10cSrcweir }
1535cdf0e10cSrcweir else
1536cdf0e10cSrcweir {
1537cdf0e10cSrcweir sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Name")));
1538cdf0e10cSrcweir if (sString.getLength() > 0)
1539cdf0e10cSrcweir SetAccessibleName(sString, AccessibleContextBase::FromShape);
1540cdf0e10cSrcweir }
1541cdf0e10cSrcweir
1542cdf0e10cSrcweir // Get the accessible description.
1543cdf0e10cSrcweir sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Description")));
1544cdf0e10cSrcweir if (sString.getLength() > 0)
1545cdf0e10cSrcweir SetAccessibleDescription(sString, AccessibleContextBase::FromShape);
1546cdf0e10cSrcweir }
1547cdf0e10cSrcweir catch (uno::RuntimeException&)
1548cdf0e10cSrcweir {
1549cdf0e10cSrcweir }
1550cdf0e10cSrcweir }
15519b8096d0SSteve Yin // Return this object's role.
getAccessibleRole(void)15529b8096d0SSteve Yin sal_Int16 SAL_CALL AccessibleShape::getAccessibleRole (void)
15539b8096d0SSteve Yin throw (::com::sun::star::uno::RuntimeException)
15549b8096d0SSteve Yin {
15559b8096d0SSteve Yin sal_Int16 nAccessibleRole = AccessibleRole::SHAPE ;
15569b8096d0SSteve Yin switch (ShapeTypeHandler::Instance().GetTypeId (mxShape))
15579b8096d0SSteve Yin {
15589b8096d0SSteve Yin case DRAWING_GRAPHIC_OBJECT:
15599b8096d0SSteve Yin nAccessibleRole = AccessibleRole::GRAPHIC ; break;
15609b8096d0SSteve Yin case DRAWING_OLE:
15619b8096d0SSteve Yin nAccessibleRole = AccessibleRole::EMBEDDED_OBJECT ; break;
15629b8096d0SSteve Yin
15639b8096d0SSteve Yin default:
15649b8096d0SSteve Yin nAccessibleRole = AccessibleContextBase::getAccessibleRole();
15659b8096d0SSteve Yin break;
15669b8096d0SSteve Yin }
15679b8096d0SSteve Yin
15689b8096d0SSteve Yin return nAccessibleRole;
15699b8096d0SSteve Yin }
15709b8096d0SSteve Yin
1571cdf0e10cSrcweir
UpdateDocumentAllSelState(Reference<XAccessibleStateSet> & xStateSet)15729b8096d0SSteve Yin void AccessibleShape::UpdateDocumentAllSelState(Reference<XAccessibleStateSet> &xStateSet)
15739b8096d0SSteve Yin {
15749b8096d0SSteve Yin if (mpParent && mpParent->IsDocumentSelAll())
15759b8096d0SSteve Yin {
15769b8096d0SSteve Yin ::utl::AccessibleStateSetHelper* pStateSet =
15779b8096d0SSteve Yin static_cast< ::utl::AccessibleStateSetHelper*>(xStateSet.get());
15789b8096d0SSteve Yin pStateSet->AddState (AccessibleStateType::SELECTED);
15799b8096d0SSteve Yin
15809b8096d0SSteve Yin //uno::Any NewValue;
15819b8096d0SSteve Yin //NewValue <<= AccessibleStateType::SELECTED;
15829b8096d0SSteve Yin
15839b8096d0SSteve Yin //CommitChange(AccessibleEventId::STATE_CHANGED,NewValue,uno::Any());
15849b8096d0SSteve Yin }
15859b8096d0SSteve Yin }
1586cdf0e10cSrcweir
15879b8096d0SSteve Yin //sort the drawing objects from up to down, from left to right
15889b8096d0SSteve Yin struct XShapePosCompareHelper
15899b8096d0SSteve Yin {
operator ()accessibility::XShapePosCompareHelper15909b8096d0SSteve Yin bool operator() ( const uno::Reference<drawing::XShape>& xshape1,
15919b8096d0SSteve Yin const uno::Reference<drawing::XShape>& xshape2 ) const
15929b8096d0SSteve Yin {
15939b8096d0SSteve Yin SdrObject* pObj1 = GetSdrObjectFromXShape(xshape1);
15949b8096d0SSteve Yin SdrObject* pObj2 = GetSdrObjectFromXShape(xshape2);
15959b8096d0SSteve Yin if(pObj1 && pObj2)
15969b8096d0SSteve Yin return pObj1->GetOrdNum() < pObj2->GetOrdNum();
15979b8096d0SSteve Yin else
15989b8096d0SSteve Yin return 0;
15999b8096d0SSteve Yin }
16009b8096d0SSteve Yin };
16019b8096d0SSteve Yin //end of group position
1602cdf0e10cSrcweir
16039b8096d0SSteve Yin //===== XAccessibleGroupPosition =========================================
16049b8096d0SSteve Yin uno::Sequence< sal_Int32 > SAL_CALL
getGroupPosition(const uno::Any &)16059b8096d0SSteve Yin AccessibleShape::getGroupPosition( const uno::Any& )
16069b8096d0SSteve Yin throw (uno::RuntimeException)
16079b8096d0SSteve Yin {
16089b8096d0SSteve Yin // we will return the:
16099b8096d0SSteve Yin // [0] group level
16109b8096d0SSteve Yin // [1] similar items counts in the group
16119b8096d0SSteve Yin // [2] the position of the object in the group
16129b8096d0SSteve Yin uno::Sequence< sal_Int32 > aRet( 3 );
16139b8096d0SSteve Yin aRet[0] = 0;
16149b8096d0SSteve Yin aRet[1] = 0;
16159b8096d0SSteve Yin aRet[2] = 0;
16169b8096d0SSteve Yin
16179b8096d0SSteve Yin ::com::sun::star::uno::Reference<XAccessible> xParent = getAccessibleParent();
16189b8096d0SSteve Yin if (!xParent.is())
16199b8096d0SSteve Yin {
16209b8096d0SSteve Yin return aRet;
16219b8096d0SSteve Yin }
16229b8096d0SSteve Yin SdrObject *pObj = GetSdrObjectFromXShape(mxShape);
16239b8096d0SSteve Yin
16249b8096d0SSteve Yin
16259b8096d0SSteve Yin if(pObj == NULL )
16269b8096d0SSteve Yin {
16279b8096d0SSteve Yin return aRet;
16289b8096d0SSteve Yin }
16299b8096d0SSteve Yin
16309b8096d0SSteve Yin // Compute object's group level.
16319b8096d0SSteve Yin sal_Int32 nGroupLevel = 0;
16329b8096d0SSteve Yin SdrObject * pUper = pObj->GetUpGroup();
16339b8096d0SSteve Yin while( pUper )
16349b8096d0SSteve Yin {
16359b8096d0SSteve Yin ++nGroupLevel;
16369b8096d0SSteve Yin pUper = pUper->GetUpGroup();
16379b8096d0SSteve Yin }
16389b8096d0SSteve Yin
16399b8096d0SSteve Yin ::com::sun::star::uno::Reference<XAccessibleContext> xParentContext = xParent->getAccessibleContext();
16409b8096d0SSteve Yin if( xParentContext->getAccessibleRole() == AccessibleRole::DOCUMENT)//Document
16419b8096d0SSteve Yin {
16429b8096d0SSteve Yin Reference< XAccessibleGroupPosition > xGroupPosition( xParent,uno::UNO_QUERY );
16439b8096d0SSteve Yin if ( xGroupPosition.is() )
16449b8096d0SSteve Yin {
16459b8096d0SSteve Yin aRet = xGroupPosition->getGroupPosition( uno::makeAny( getAccessibleContext() ) );
16469b8096d0SSteve Yin }
16479b8096d0SSteve Yin return aRet;
16489b8096d0SSteve Yin }
16499b8096d0SSteve Yin if (xParentContext->getAccessibleRole() != AccessibleRole::SHAPE)
16509b8096d0SSteve Yin {
16519b8096d0SSteve Yin return aRet;
16529b8096d0SSteve Yin }
16539b8096d0SSteve Yin
16549b8096d0SSteve Yin SdrObjList *pGrpList = NULL;
16559b8096d0SSteve Yin if( pObj->GetUpGroup() )
16569b8096d0SSteve Yin pGrpList = pObj->GetUpGroup()->GetSubList();
16579b8096d0SSteve Yin else
16589b8096d0SSteve Yin return aRet;
16599b8096d0SSteve Yin
16609b8096d0SSteve Yin std::vector< uno::Reference<drawing::XShape> > vXShapes;
16619b8096d0SSteve Yin if (pGrpList)
16629b8096d0SSteve Yin {
16639b8096d0SSteve Yin const sal_Int32 nObj = pGrpList->GetObjCount();
16649b8096d0SSteve Yin for(sal_Int32 i = 0 ; i < nObj ; ++i)
16659b8096d0SSteve Yin {
16669b8096d0SSteve Yin SdrObject *pSubObj = pGrpList->GetObj(i);
16679b8096d0SSteve Yin if (pSubObj &&
16689b8096d0SSteve Yin xParentContext->getAccessibleChild(i)->getAccessibleContext()->getAccessibleRole() != AccessibleRole::GROUP_BOX)
16699b8096d0SSteve Yin {
16709b8096d0SSteve Yin vXShapes.push_back( GetXShapeForSdrObject(pSubObj) );
16719b8096d0SSteve Yin }
16729b8096d0SSteve Yin }
16739b8096d0SSteve Yin }
16749b8096d0SSteve Yin
16759b8096d0SSteve Yin std::sort( vXShapes.begin(), vXShapes.end(), XShapePosCompareHelper() );
16769b8096d0SSteve Yin
1677fb0b81f5Smseidel //get the index of the selected object in the group
16789b8096d0SSteve Yin std::vector< uno::Reference<drawing::XShape> >::iterator aIter;
16799b8096d0SSteve Yin //we start counting position from 1
16809b8096d0SSteve Yin sal_Int32 nPos = 1;
16819b8096d0SSteve Yin for ( aIter = vXShapes.begin(); aIter != vXShapes.end(); aIter++, nPos++ )
16829b8096d0SSteve Yin {
16839b8096d0SSteve Yin if ( (*aIter).get() == mxShape.get() )
16849b8096d0SSteve Yin {
16859b8096d0SSteve Yin sal_Int32* pArray = aRet.getArray();
16869b8096d0SSteve Yin pArray[0] = nGroupLevel;
16879b8096d0SSteve Yin pArray[1] = vXShapes.size();
16889b8096d0SSteve Yin pArray[2] = nPos;
16899b8096d0SSteve Yin break;
16909b8096d0SSteve Yin }
16919b8096d0SSteve Yin }
16929b8096d0SSteve Yin
16939b8096d0SSteve Yin return aRet;
16949b8096d0SSteve Yin }
16959b8096d0SSteve Yin
getObjectLink(const uno::Any &)16969b8096d0SSteve Yin ::rtl::OUString AccessibleShape::getObjectLink( const uno::Any& )
16979b8096d0SSteve Yin throw (uno::RuntimeException)
16989b8096d0SSteve Yin {
16999b8096d0SSteve Yin ::rtl::OUString aRet;
17009b8096d0SSteve Yin
17019b8096d0SSteve Yin SdrObject *pObj = GetSdrObjectFromXShape(mxShape);
17029b8096d0SSteve Yin if(pObj == NULL )
17039b8096d0SSteve Yin {
17049b8096d0SSteve Yin return aRet;
17059b8096d0SSteve Yin }
17069b8096d0SSteve Yin if (maShapeTreeInfo.GetDocumentWindow().is())
17079b8096d0SSteve Yin {
17089b8096d0SSteve Yin Reference< XAccessibleGroupPosition > xGroupPosition( maShapeTreeInfo.GetDocumentWindow(), uno::UNO_QUERY );
17099b8096d0SSteve Yin if (xGroupPosition.is())
17109b8096d0SSteve Yin {
17119b8096d0SSteve Yin aRet = xGroupPosition->getObjectLink( uno::makeAny( getAccessibleContext() ) );
17129b8096d0SSteve Yin }
17139b8096d0SSteve Yin }
17149b8096d0SSteve Yin return aRet;
17159b8096d0SSteve Yin }
17169b8096d0SSteve Yin
17179b8096d0SSteve Yin //===== XAccesibleHypertext ==================================================
getHyperLinkCount()17189b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getHyperLinkCount()
17199b8096d0SSteve Yin throw (::com::sun::star::uno::RuntimeException)
17209b8096d0SSteve Yin {
17219b8096d0SSteve Yin // MT: Introduced with IA2 CWS, but SvxAccessibleHyperlink was redundant to svx::AccessibleHyperlink which we introduced meanwhile.
17229b8096d0SSteve Yin // Code need to be adapted....
17239b8096d0SSteve Yin return 0;
17249b8096d0SSteve Yin
17259b8096d0SSteve Yin /*
17269b8096d0SSteve Yin SvxAccessibleHyperlink* pLink = new SvxAccessibleHyperlink(m_pShape,this);
17279b8096d0SSteve Yin if (pLink->IsValidHyperlink())
17289b8096d0SSteve Yin return 1;
17299b8096d0SSteve Yin else
17309b8096d0SSteve Yin return 0;
17319b8096d0SSteve Yin */
17329b8096d0SSteve Yin }
17339b8096d0SSteve Yin uno::Reference< XAccessibleHyperlink > SAL_CALL
getHyperLink(sal_Int32)17349b8096d0SSteve Yin AccessibleShape::getHyperLink( sal_Int32 )
17359b8096d0SSteve Yin throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
17369b8096d0SSteve Yin {
17379b8096d0SSteve Yin uno::Reference< XAccessibleHyperlink > xRet;
17389b8096d0SSteve Yin // MT: Introduced with IA2 CWS, but SvxAccessibleHyperlink was redundant to svx::AccessibleHyperlink which we introduced meanwhile.
17399b8096d0SSteve Yin // Code need to be adapted....
17409b8096d0SSteve Yin /*
17419b8096d0SSteve Yin SvxAccessibleHyperlink* pLink = new SvxAccessibleHyperlink(m_pShape,this);
17429b8096d0SSteve Yin if (pLink->IsValidHyperlink())
17439b8096d0SSteve Yin xRet = pLink;
17449b8096d0SSteve Yin if( !xRet.is() )
17459b8096d0SSteve Yin throw ::com::sun::star::lang::IndexOutOfBoundsException();
17469b8096d0SSteve Yin */
17479b8096d0SSteve Yin return xRet;
17489b8096d0SSteve Yin }
getHyperLinkIndex(sal_Int32)17499b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getHyperLinkIndex( sal_Int32 )
17509b8096d0SSteve Yin throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
17519b8096d0SSteve Yin {
17529b8096d0SSteve Yin sal_Int32 nRet = 0;
17539b8096d0SSteve Yin return nRet;
17549b8096d0SSteve Yin }
17559b8096d0SSteve Yin //===== XAccesibleText ==================================================
getCaretPosition()17569b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException){return 0;}
setCaretPosition(sal_Int32)17579b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleShape::setCaretPosition( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return 0;}
getCharacter(sal_Int32)17589b8096d0SSteve Yin sal_Unicode SAL_CALL AccessibleShape::getCharacter( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return 0;}
getCharacterAttributes(sal_Int32,const::com::sun::star::uno::Sequence<::rtl::OUString> &)17599b8096d0SSteve Yin ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL AccessibleShape::getCharacterAttributes( sal_Int32, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
17609b8096d0SSteve Yin {
17619b8096d0SSteve Yin uno::Sequence< ::com::sun::star::beans::PropertyValue > aValues(0);
17629b8096d0SSteve Yin return aValues;
17639b8096d0SSteve Yin }
getCharacterBounds(sal_Int32)17649b8096d0SSteve Yin ::com::sun::star::awt::Rectangle SAL_CALL AccessibleShape::getCharacterBounds( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
17659b8096d0SSteve Yin {
17669b8096d0SSteve Yin return com::sun::star::awt::Rectangle(0, 0, 0, 0 );
17679b8096d0SSteve Yin }
getCharacterCount()17689b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException){return 0;}
getIndexAtPoint(const::com::sun::star::awt::Point &)17699b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getIndexAtPoint( const ::com::sun::star::awt::Point& ) throw (::com::sun::star::uno::RuntimeException){return 0;}
getSelectedText()17709b8096d0SSteve Yin ::rtl::OUString SAL_CALL AccessibleShape::getSelectedText( ) throw (::com::sun::star::uno::RuntimeException){return OUString();}
getSelectionStart()17719b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException){return 0;}
getSelectionEnd()17729b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException){return 0;}
setSelection(sal_Int32,sal_Int32)17739b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleShape::setSelection( sal_Int32, sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return sal_True;}
getText()17749b8096d0SSteve Yin ::rtl::OUString SAL_CALL AccessibleShape::getText( ) throw (::com::sun::star::uno::RuntimeException){return OUString();}
getTextRange(sal_Int32,sal_Int32)17759b8096d0SSteve Yin ::rtl::OUString SAL_CALL AccessibleShape::getTextRange( sal_Int32, sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return OUString();}
getTextAtIndex(sal_Int32,sal_Int16)17769b8096d0SSteve Yin ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleShape::getTextAtIndex( sal_Int32, sal_Int16 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
17779b8096d0SSteve Yin {
17789b8096d0SSteve Yin ::com::sun::star::accessibility::TextSegment aResult;
17799b8096d0SSteve Yin return aResult;
17809b8096d0SSteve Yin }
getTextBeforeIndex(sal_Int32,sal_Int16)17819b8096d0SSteve Yin ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleShape::getTextBeforeIndex( sal_Int32, sal_Int16 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
17829b8096d0SSteve Yin {
17839b8096d0SSteve Yin ::com::sun::star::accessibility::TextSegment aResult;
17849b8096d0SSteve Yin return aResult;
17859b8096d0SSteve Yin }
getTextBehindIndex(sal_Int32,sal_Int16)17869b8096d0SSteve Yin ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleShape::getTextBehindIndex( sal_Int32, sal_Int16 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
17879b8096d0SSteve Yin {
17889b8096d0SSteve Yin ::com::sun::star::accessibility::TextSegment aResult;
17899b8096d0SSteve Yin return aResult;
17909b8096d0SSteve Yin }
copyText(sal_Int32,sal_Int32)17919b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleShape::copyText( sal_Int32, sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return sal_True;}
1792cdf0e10cSrcweir
1793cdf0e10cSrcweir } // end of namespace accessibility
1794