xref: /trunk/main/svx/source/accessibility/AccessibleShape.cxx (revision 9b8096d048072d5e312699b7e51b3b8a9f64fe9a)
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
10cdf0e10cSrcweir  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
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
34*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
35*9b8096d0SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLETEXTTYPE_HPP_
36*9b8096d0SSteve Yin #include <com/sun/star/accessibility/AccessibleTextType.hpp>
37*9b8096d0SSteve Yin #endif
38*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
39cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLE_STATE_TYPE_HPP_
40cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
43cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
44cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp>
45cdf0e10cSrcweir #include <com/sun/star/drawing/XShapeDescriptor.hpp>
46cdf0e10cSrcweir #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
47cdf0e10cSrcweir #include <com/sun/star/drawing/FillStyle.hpp>
48cdf0e10cSrcweir #include <com/sun/star/text/XText.hpp>
49cdf0e10cSrcweir #include <editeng/outlobj.hxx>
50cdf0e10cSrcweir #include <rtl/ref.hxx>
51cdf0e10cSrcweir #include <editeng/unoedsrc.hxx>
52cdf0e10cSrcweir #include <svx/unoshtxt.hxx>
53cdf0e10cSrcweir #include <svx/svdobj.hxx>
54cdf0e10cSrcweir #include <svx/svdmodel.hxx>
55cdf0e10cSrcweir #include "svx/unoapi.hxx"
56cdf0e10cSrcweir #include <com/sun/star/uno/Exception.hpp>
57cdf0e10cSrcweir #include <svx/ShapeTypeHandler.hxx>
58cdf0e10cSrcweir #include <svx/SvxShapeTypes.hxx>
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #ifndef _SVX_ACCESSIBILITY_HRC
61cdf0e10cSrcweir #include "accessibility.hrc"
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir #include "svx/svdstr.hrc"
64cdf0e10cSrcweir #include <svx/dialmgr.hxx>
65cdf0e10cSrcweir #include <vcl/svapp.hxx>
66cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
67cdf0e10cSrcweir #include <svx/svdview.hxx>
68cdf0e10cSrcweir #include "AccessibleEmptyEditSource.hxx"
69*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
70*9b8096d0SSteve Yin #include <svx/svdpage.hxx>
71*9b8096d0SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLERELATIONTYPE_HPP_
72*9b8096d0SSteve Yin #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
73*9b8096d0SSteve Yin #endif
74*9b8096d0SSteve Yin #ifndef _UTL_ACCESSIBLERELATIONSETHELPER_HXX_
75*9b8096d0SSteve Yin #include <unotools/accessiblerelationsethelper.hxx>
76*9b8096d0SSteve Yin #endif
77*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
78cdf0e10cSrcweir using namespace ::com::sun::star;
79cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
80*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
81*9b8096d0SSteve Yin using ::com::sun::star::lang::IndexOutOfBoundsException;
82*9b8096d0SSteve Yin using ::com::sun::star::uno::RuntimeException;
83*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
84cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
85cdf0e10cSrcweir using ::rtl::OUString;
86*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
87*9b8096d0SSteve Yin #include <algorithm>
88cdf0e10cSrcweir 
89*9b8096d0SSteve Yin // #include <Accessiblehyperlink.hxx>
90*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
91cdf0e10cSrcweir namespace accessibility {
92cdf0e10cSrcweir 
93cdf0e10cSrcweir namespace {
94cdf0e10cSrcweir 
95cdf0e10cSrcweir OUString GetOptionalProperty (
96cdf0e10cSrcweir     const Reference<beans::XPropertySet>& rxSet,
97cdf0e10cSrcweir     const OUString& rsPropertyName)
98cdf0e10cSrcweir {
99cdf0e10cSrcweir     OUString sValue;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir     if (rxSet.is())
102cdf0e10cSrcweir     {
103cdf0e10cSrcweir         const Reference<beans::XPropertySetInfo> xInfo (rxSet->getPropertySetInfo());
104cdf0e10cSrcweir         if ( ! xInfo.is() || xInfo->hasPropertyByName(rsPropertyName))
105cdf0e10cSrcweir         {
106cdf0e10cSrcweir             try
107cdf0e10cSrcweir             {
108cdf0e10cSrcweir                 rxSet->getPropertyValue(rsPropertyName) >>= sValue;
109cdf0e10cSrcweir             }
110cdf0e10cSrcweir             catch (beans::UnknownPropertyException&)
111cdf0e10cSrcweir             {
112cdf0e10cSrcweir                 // This exception should only be thrown when the property
113cdf0e10cSrcweir                 // does not exits (of course) and the XPropertySetInfo is
114cdf0e10cSrcweir                 // not available.
115cdf0e10cSrcweir             }
116cdf0e10cSrcweir         }
117cdf0e10cSrcweir     }
118cdf0e10cSrcweir     return sValue;
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir } // end of anonymous namespace
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 
126cdf0e10cSrcweir //=====  internal  ============================================================
127cdf0e10cSrcweir 
128cdf0e10cSrcweir AccessibleShape::AccessibleShape (
129cdf0e10cSrcweir     const AccessibleShapeInfo& rShapeInfo,
130cdf0e10cSrcweir     const AccessibleShapeTreeInfo& rShapeTreeInfo)
131*9b8096d0SSteve Yin     //IAccessibility2 Implementation 2009-----
132*9b8096d0SSteve Yin     : AccessibleContextBase (rShapeInfo.mxParent,AccessibleRole::SHAPE),
133*9b8096d0SSteve Yin     //-----IAccessibility2 Implementation 2009
134cdf0e10cSrcweir       mpChildrenManager(NULL),
135cdf0e10cSrcweir       mxShape (rShapeInfo.mxShape),
136cdf0e10cSrcweir       maShapeTreeInfo (rShapeTreeInfo),
137cdf0e10cSrcweir       mnIndex (rShapeInfo.mnIndex),
138cdf0e10cSrcweir       m_nIndexInParent(-1),
139cdf0e10cSrcweir       mpText (NULL),
140cdf0e10cSrcweir       mpParent (rShapeInfo.mpChildrenManager)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     m_pShape = GetSdrObjectFromXShape(mxShape);
143cdf0e10cSrcweir     UpdateNameAndDescription();
144cdf0e10cSrcweir }
145*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
146*9b8096d0SSteve Yin AccessibleShape::AccessibleShape (
147*9b8096d0SSteve Yin         const ::com::sun::star::uno::Reference<
148*9b8096d0SSteve Yin             ::com::sun::star::drawing::XShape>& rxShape,
149*9b8096d0SSteve Yin         const ::com::sun::star::uno::Reference<
150*9b8096d0SSteve Yin             ::com::sun::star::accessibility::XAccessible>& rxParent,
151*9b8096d0SSteve Yin         const AccessibleShapeTreeInfo& rShapeTreeInfo,
152*9b8096d0SSteve Yin         sal_Int32 nIndex)
153*9b8096d0SSteve Yin     : AccessibleContextBase (rxParent,AccessibleRole::SHAPE),
154*9b8096d0SSteve Yin       mpChildrenManager(NULL),
155*9b8096d0SSteve Yin       mxShape (rxShape),
156*9b8096d0SSteve Yin       maShapeTreeInfo (rShapeTreeInfo),
157*9b8096d0SSteve Yin       mnIndex (nIndex),
158*9b8096d0SSteve Yin       m_nIndexInParent(-1),
159*9b8096d0SSteve Yin       mpText (NULL),
160*9b8096d0SSteve Yin       mpParent (NULL)
161*9b8096d0SSteve Yin {
162*9b8096d0SSteve Yin     m_pShape = GetSdrObjectFromXShape(mxShape);
163*9b8096d0SSteve Yin }
164*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
165cdf0e10cSrcweir AccessibleShape::~AccessibleShape (void)
166cdf0e10cSrcweir {
167cdf0e10cSrcweir     if (mpChildrenManager != NULL)
168cdf0e10cSrcweir         delete mpChildrenManager;
169cdf0e10cSrcweir     if (mpText != NULL)
170cdf0e10cSrcweir         delete mpText;
171cdf0e10cSrcweir     OSL_TRACE ("~AccessibleShape");
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     // Unregistering from the various broadcasters should be unnecessary
174cdf0e10cSrcweir     // since this destructor would not have been called if one of the
175cdf0e10cSrcweir     // broadcasters would still hold a strong reference to this object.
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 
181cdf0e10cSrcweir void AccessibleShape::Init (void)
182cdf0e10cSrcweir {
183cdf0e10cSrcweir     // Update the OPAQUE and SELECTED shape.
184cdf0e10cSrcweir     UpdateStates ();
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     // Create a children manager when this shape has children of its own.
187cdf0e10cSrcweir     Reference<drawing::XShapes> xShapes (mxShape, uno::UNO_QUERY);
188cdf0e10cSrcweir     if (xShapes.is() && xShapes->getCount() > 0)
189cdf0e10cSrcweir         mpChildrenManager = new ChildrenManager (
190cdf0e10cSrcweir             this, xShapes, maShapeTreeInfo, *this);
191cdf0e10cSrcweir     if (mpChildrenManager != NULL)
192cdf0e10cSrcweir         mpChildrenManager->Update();
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     // Register at model as document::XEventListener.
195cdf0e10cSrcweir     if (maShapeTreeInfo.GetModelBroadcaster().is())
196cdf0e10cSrcweir         maShapeTreeInfo.GetModelBroadcaster()->addEventListener (
197cdf0e10cSrcweir             static_cast<document::XEventListener*>(this));
198cdf0e10cSrcweir 
199cdf0e10cSrcweir     // Beware! Here we leave the paths of the UNO API and descend into the
200cdf0e10cSrcweir     // depths of the core.  Necessary for makeing the edit engine
201cdf0e10cSrcweir     // accessible.
202cdf0e10cSrcweir     Reference<text::XText> xText (mxShape, uno::UNO_QUERY);
203cdf0e10cSrcweir     if (xText.is())
204cdf0e10cSrcweir     {
205cdf0e10cSrcweir         SdrView* pView = maShapeTreeInfo.GetSdrView ();
206cdf0e10cSrcweir         const Window* pWindow = maShapeTreeInfo.GetWindow ();
207cdf0e10cSrcweir         if (pView != NULL && pWindow != NULL && mxShape.is())
208cdf0e10cSrcweir         {
209cdf0e10cSrcweir             // #107948# Determine whether shape text is empty
210cdf0e10cSrcweir             SdrObject* pSdrObject = GetSdrObjectFromXShape(mxShape);
211cdf0e10cSrcweir             if( pSdrObject )
212cdf0e10cSrcweir             {
213cdf0e10cSrcweir                 SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, pSdrObject );
214cdf0e10cSrcweir                 OutlinerParaObject* pOutlinerParaObject = NULL;
215cdf0e10cSrcweir 
216cdf0e10cSrcweir                 if( pTextObj )
217cdf0e10cSrcweir                     pOutlinerParaObject = pTextObj->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active
218cdf0e10cSrcweir 
219cdf0e10cSrcweir                 bool bOwnParaObj = pOutlinerParaObject != NULL;
220cdf0e10cSrcweir 
221cdf0e10cSrcweir                 if( !pOutlinerParaObject && pSdrObject )
222cdf0e10cSrcweir                     pOutlinerParaObject = pSdrObject->GetOutlinerParaObject();
223cdf0e10cSrcweir 
224cdf0e10cSrcweir                 // create AccessibleTextHelper to handle this shape's text
225cdf0e10cSrcweir                 if( !pOutlinerParaObject )
226cdf0e10cSrcweir                 {
227cdf0e10cSrcweir                     // empty text -> use proxy edit source to delay creation of EditEngine
228cdf0e10cSrcweir                     ::std::auto_ptr<SvxEditSource> pEditSource( new AccessibleEmptyEditSource ( *pSdrObject, *pView, *pWindow) );
229cdf0e10cSrcweir                     mpText = new AccessibleTextHelper( pEditSource );
230cdf0e10cSrcweir                 }
231cdf0e10cSrcweir                 else
232cdf0e10cSrcweir                 {
233cdf0e10cSrcweir                     // non-empty text -> use full-fledged edit source right away
234cdf0e10cSrcweir                     ::std::auto_ptr<SvxEditSource> pEditSource( new SvxTextEditSource ( *pSdrObject, 0, *pView, *pWindow) );
235cdf0e10cSrcweir                     mpText = new AccessibleTextHelper( pEditSource );
236cdf0e10cSrcweir                 }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir                 if( bOwnParaObj )
239cdf0e10cSrcweir                     delete pOutlinerParaObject;
240cdf0e10cSrcweir 
241cdf0e10cSrcweir                 mpText->SetEventSource(this);
242cdf0e10cSrcweir             }
243cdf0e10cSrcweir         }
244cdf0e10cSrcweir     }
245cdf0e10cSrcweir }
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 
250cdf0e10cSrcweir void AccessibleShape::UpdateStates (void)
251cdf0e10cSrcweir {
252cdf0e10cSrcweir     ::utl::AccessibleStateSetHelper* pStateSet =
253cdf0e10cSrcweir         static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
254cdf0e10cSrcweir     if (pStateSet == NULL)
255cdf0e10cSrcweir         return;
256cdf0e10cSrcweir 
257cdf0e10cSrcweir     // Set the opaque state for certain shape types when their fill style is
258cdf0e10cSrcweir     // solid.
259cdf0e10cSrcweir     bool bShapeIsOpaque = false;
260cdf0e10cSrcweir     switch (ShapeTypeHandler::Instance().GetTypeId (mxShape))
261cdf0e10cSrcweir     {
262cdf0e10cSrcweir         case DRAWING_PAGE:
263cdf0e10cSrcweir         case DRAWING_RECTANGLE:
264cdf0e10cSrcweir         case DRAWING_TEXT:
265cdf0e10cSrcweir         {
266cdf0e10cSrcweir             uno::Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY);
267cdf0e10cSrcweir             if (xSet.is())
268cdf0e10cSrcweir             {
269cdf0e10cSrcweir                 try
270cdf0e10cSrcweir                 {
271cdf0e10cSrcweir                     drawing::FillStyle aFillStyle;
272cdf0e10cSrcweir                     bShapeIsOpaque =  ( xSet->getPropertyValue (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle"))) >>= aFillStyle)
273cdf0e10cSrcweir                                         && aFillStyle == drawing::FillStyle_SOLID;
274cdf0e10cSrcweir                 }
275cdf0e10cSrcweir                 catch (::com::sun::star::beans::UnknownPropertyException&)
276cdf0e10cSrcweir                 {
277cdf0e10cSrcweir                     // Ignore.
278cdf0e10cSrcweir                 }
279cdf0e10cSrcweir             }
280cdf0e10cSrcweir         }
281cdf0e10cSrcweir     }
282cdf0e10cSrcweir     if (bShapeIsOpaque)
283cdf0e10cSrcweir         pStateSet->AddState (AccessibleStateType::OPAQUE);
284cdf0e10cSrcweir     else
285cdf0e10cSrcweir         pStateSet->RemoveState (AccessibleStateType::OPAQUE);
286cdf0e10cSrcweir 
287cdf0e10cSrcweir     // Set the selected state.
288cdf0e10cSrcweir     bool bShapeIsSelected = false;
289cdf0e10cSrcweir     // XXX fix_me this has to be done with an extra interface later on
290cdf0e10cSrcweir     if ( m_pShape && maShapeTreeInfo.GetSdrView() )
291cdf0e10cSrcweir     {
292cdf0e10cSrcweir         bShapeIsSelected = maShapeTreeInfo.GetSdrView()->IsObjMarked(m_pShape) == sal_True;
293cdf0e10cSrcweir     }
294cdf0e10cSrcweir 
295cdf0e10cSrcweir     if (bShapeIsSelected)
296cdf0e10cSrcweir         pStateSet->AddState (AccessibleStateType::SELECTED);
297cdf0e10cSrcweir     else
298cdf0e10cSrcweir         pStateSet->RemoveState (AccessibleStateType::SELECTED);
299cdf0e10cSrcweir }
300*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
301*9b8096d0SSteve Yin     ::rtl::OUString AccessibleShape::GetStyle()
302*9b8096d0SSteve Yin     {
303*9b8096d0SSteve Yin         return ShapeTypeHandler::CreateAccessibleBaseName( mxShape );
304*9b8096d0SSteve Yin     }
305cdf0e10cSrcweir 
306*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
307cdf0e10cSrcweir bool AccessibleShape::operator== (const AccessibleShape& rShape)
308cdf0e10cSrcweir {
309cdf0e10cSrcweir     return this==&rShape;
310cdf0e10cSrcweir }
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 
315cdf0e10cSrcweir sal_Bool AccessibleShape::SetState (sal_Int16 aState)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir     sal_Bool bStateHasChanged = sal_False;
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
320cdf0e10cSrcweir     {
321cdf0e10cSrcweir         // Offer FOCUSED state to edit engine and detect whether the state
322cdf0e10cSrcweir         // changes.
323cdf0e10cSrcweir         sal_Bool bIsFocused = mpText->HaveFocus ();
324cdf0e10cSrcweir         mpText->SetFocus (sal_True);
325cdf0e10cSrcweir         bStateHasChanged = (bIsFocused != mpText->HaveFocus ());
326cdf0e10cSrcweir     }
327cdf0e10cSrcweir     else
328cdf0e10cSrcweir         bStateHasChanged = AccessibleContextBase::SetState (aState);
329cdf0e10cSrcweir 
330cdf0e10cSrcweir     return bStateHasChanged;
331cdf0e10cSrcweir }
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 
335cdf0e10cSrcweir 
336cdf0e10cSrcweir sal_Bool AccessibleShape::ResetState (sal_Int16 aState)
337cdf0e10cSrcweir {
338cdf0e10cSrcweir     sal_Bool bStateHasChanged = sal_False;
339cdf0e10cSrcweir 
340cdf0e10cSrcweir     if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
341cdf0e10cSrcweir     {
342cdf0e10cSrcweir         // Try to remove FOCUSED state from the edit engine and detect
343cdf0e10cSrcweir         // whether the state changes.
344cdf0e10cSrcweir         sal_Bool bIsFocused = mpText->HaveFocus ();
345cdf0e10cSrcweir         mpText->SetFocus (sal_False);
346cdf0e10cSrcweir         bStateHasChanged = (bIsFocused != mpText->HaveFocus ());
347cdf0e10cSrcweir     }
348cdf0e10cSrcweir     else
349cdf0e10cSrcweir         bStateHasChanged = AccessibleContextBase::ResetState (aState);
350cdf0e10cSrcweir 
351cdf0e10cSrcweir     return bStateHasChanged;
352cdf0e10cSrcweir }
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 
357cdf0e10cSrcweir sal_Bool AccessibleShape::GetState (sal_Int16 aState)
358cdf0e10cSrcweir {
359cdf0e10cSrcweir     if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
360cdf0e10cSrcweir     {
361cdf0e10cSrcweir         // Just delegate the call to the edit engine.  The state is not
362cdf0e10cSrcweir         // merged into the state set.
363cdf0e10cSrcweir         return mpText->HaveFocus();
364cdf0e10cSrcweir     }
365cdf0e10cSrcweir     else
366cdf0e10cSrcweir         return AccessibleContextBase::GetState (aState);
367cdf0e10cSrcweir }
368*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
369*9b8096d0SSteve Yin // Solution: OverWrite the parent's getAccessibleName method
370*9b8096d0SSteve Yin ::rtl::OUString SAL_CALL AccessibleShape::getAccessibleName (void)
371*9b8096d0SSteve Yin     throw (::com::sun::star::uno::RuntimeException)
372*9b8096d0SSteve Yin {
373*9b8096d0SSteve Yin         ThrowIfDisposed ();
374*9b8096d0SSteve Yin     if( m_pShape && m_pShape->GetTitle().Len() > 0)
375*9b8096d0SSteve Yin         return CreateAccessibleName() + ::rtl::OUString(' ') + m_pShape->GetTitle();
376*9b8096d0SSteve Yin     else
377*9b8096d0SSteve Yin         return CreateAccessibleName();
378*9b8096d0SSteve Yin }
379cdf0e10cSrcweir 
380*9b8096d0SSteve Yin ::rtl::OUString SAL_CALL AccessibleShape::getAccessibleDescription (void)
381*9b8096d0SSteve Yin     throw (::com::sun::star::uno::RuntimeException)
382*9b8096d0SSteve Yin {
383*9b8096d0SSteve Yin         ThrowIfDisposed ();
384*9b8096d0SSteve Yin     if( m_pShape && m_pShape->GetDescription().Len() > 0)
385*9b8096d0SSteve Yin         return  m_pShape->GetDescription() ;
386*9b8096d0SSteve Yin     else
387*9b8096d0SSteve Yin         return OUString( RTL_CONSTASCII_USTRINGPARAM( " " ));
388*9b8096d0SSteve Yin }
389*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
390cdf0e10cSrcweir //=====  XAccessibleContext  ==================================================
391cdf0e10cSrcweir 
392cdf0e10cSrcweir /** The children of this shape come from two sources: The children from
393cdf0e10cSrcweir     group or scene shapes and the paragraphs of text.
394cdf0e10cSrcweir */
395cdf0e10cSrcweir sal_Int32 SAL_CALL
396cdf0e10cSrcweir     AccessibleShape::getAccessibleChildCount ()
397cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
398cdf0e10cSrcweir {
399cdf0e10cSrcweir     ThrowIfDisposed ();
400cdf0e10cSrcweir     sal_Int32 nChildCount = 0;
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     // Add the number of shapes that are children of this shape.
403cdf0e10cSrcweir     if (mpChildrenManager != NULL)
404cdf0e10cSrcweir         nChildCount += mpChildrenManager->GetChildCount ();
405cdf0e10cSrcweir     // Add the number text paragraphs.
406cdf0e10cSrcweir     if (mpText != NULL)
407cdf0e10cSrcweir         nChildCount += mpText->GetChildCount ();
408cdf0e10cSrcweir 
409cdf0e10cSrcweir     return nChildCount;
410cdf0e10cSrcweir }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 
415cdf0e10cSrcweir /** Forward the request to the shape.  Return the requested shape or throw
416cdf0e10cSrcweir     an exception for a wrong index.
417cdf0e10cSrcweir */
418cdf0e10cSrcweir uno::Reference<XAccessible> SAL_CALL
419cdf0e10cSrcweir     AccessibleShape::getAccessibleChild (sal_Int32 nIndex)
420cdf0e10cSrcweir     throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
421cdf0e10cSrcweir {
422cdf0e10cSrcweir     ThrowIfDisposed ();
423cdf0e10cSrcweir 
424cdf0e10cSrcweir     uno::Reference<XAccessible> xChild;
425cdf0e10cSrcweir 
426cdf0e10cSrcweir     // Depending on the index decide whether to delegate this call to the
427cdf0e10cSrcweir     // children manager or the edit engine.
428cdf0e10cSrcweir     if ((mpChildrenManager != NULL)
429cdf0e10cSrcweir         && (nIndex < mpChildrenManager->GetChildCount()))
430cdf0e10cSrcweir     {
431cdf0e10cSrcweir         xChild = mpChildrenManager->GetChild (nIndex);
432cdf0e10cSrcweir     }
433cdf0e10cSrcweir     else if (mpText != NULL)
434cdf0e10cSrcweir     {
435cdf0e10cSrcweir         sal_Int32 nI = nIndex;
436cdf0e10cSrcweir         if (mpChildrenManager != NULL)
437cdf0e10cSrcweir             nI -= mpChildrenManager->GetChildCount();
438cdf0e10cSrcweir         xChild = mpText->GetChild (nI);
439cdf0e10cSrcweir     }
440cdf0e10cSrcweir     else
441cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException (
442cdf0e10cSrcweir             ::rtl::OUString::createFromAscii ("shape has no child with index ")
443cdf0e10cSrcweir             + rtl::OUString::valueOf(nIndex),
444cdf0e10cSrcweir             static_cast<uno::XWeak*>(this));
445cdf0e10cSrcweir 
446cdf0e10cSrcweir     return xChild;
447cdf0e10cSrcweir }
448cdf0e10cSrcweir 
449*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
450*9b8096d0SSteve Yin uno::Reference<XAccessibleRelationSet> SAL_CALL
451*9b8096d0SSteve Yin     AccessibleShape::getAccessibleRelationSet (void)
452*9b8096d0SSteve Yin         throw (::com::sun::star::uno::RuntimeException)
453*9b8096d0SSteve Yin {
454*9b8096d0SSteve Yin     ::osl::MutexGuard aGuard (maMutex);
455*9b8096d0SSteve Yin     ::utl::AccessibleRelationSetHelper* pRelationSet =
456*9b8096d0SSteve Yin         new utl::AccessibleRelationSetHelper;
457*9b8096d0SSteve Yin     SdrObject* pCaptionSdr = const_cast < SdrObject* > ( m_pShape->GetCaptionObj() )  ;
458*9b8096d0SSteve Yin     if(pCaptionSdr!=NULL)
459*9b8096d0SSteve Yin     {
460*9b8096d0SSteve Yin             uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1);
461*9b8096d0SSteve Yin             uno::Reference<drawing::XShape> xCaptionShape ( pCaptionSdr->getUnoShape(),uno::UNO_QUERY);
462*9b8096d0SSteve Yin             if(xCaptionShape.is())
463*9b8096d0SSteve Yin             {
464*9b8096d0SSteve Yin                 aSequence[0] = mpParent->GetAccessibleCaption(xCaptionShape);
465*9b8096d0SSteve Yin                 pRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::DESCRIBED_BY, aSequence ) );
466*9b8096d0SSteve Yin         }
467*9b8096d0SSteve Yin     }
468*9b8096d0SSteve Yin     else
469*9b8096d0SSteve Yin     {
470*9b8096d0SSteve Yin         //this mxshape is the captioned shape, only for sw
471*9b8096d0SSteve Yin         if(mpParent->GetAccessibleCaption(mxShape).get())
472*9b8096d0SSteve Yin         {
473*9b8096d0SSteve Yin             uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1);
474*9b8096d0SSteve Yin             aSequence[0] = mpParent->GetAccessibleCaption(mxShape);
475*9b8096d0SSteve Yin             pRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::DESCRIBED_BY, aSequence ) );
476*9b8096d0SSteve Yin         }
477*9b8096d0SSteve Yin     }
478*9b8096d0SSteve Yin    if (pRelationSet != NULL)
479*9b8096d0SSteve Yin     {
480*9b8096d0SSteve Yin         return uno::Reference<XAccessibleRelationSet> (
481*9b8096d0SSteve Yin             new ::utl::AccessibleRelationSetHelper (*pRelationSet));
482*9b8096d0SSteve Yin     }
483*9b8096d0SSteve Yin     else
484*9b8096d0SSteve Yin         return uno::Reference<XAccessibleRelationSet>(NULL);
485*9b8096d0SSteve Yin     return uno::Reference<XAccessibleRelationSet>();
486*9b8096d0SSteve Yin }
487*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
488cdf0e10cSrcweir 
489cdf0e10cSrcweir /** Return a copy of the state set.
490cdf0e10cSrcweir     Possible states are:
491cdf0e10cSrcweir         ENABLED
492cdf0e10cSrcweir         SHOWING
493cdf0e10cSrcweir         VISIBLE
494cdf0e10cSrcweir */
495cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL
496cdf0e10cSrcweir     AccessibleShape::getAccessibleStateSet (void)
497cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
498cdf0e10cSrcweir {
499cdf0e10cSrcweir     ::osl::MutexGuard aGuard (maMutex);
500cdf0e10cSrcweir     Reference<XAccessibleStateSet> xStateSet;
501cdf0e10cSrcweir 
502cdf0e10cSrcweir     if (rBHelper.bDisposed || mpText == NULL)
503cdf0e10cSrcweir         // Return a minimal state set that only contains the DEFUNC state.
504*9b8096d0SSteve Yin     //IAccessibility2 Implementation 2009-----
505*9b8096d0SSteve Yin     //xStateSet = AccessibleContextBase::getAccessibleStateSet ();
506*9b8096d0SSteve Yin     {
507cdf0e10cSrcweir         xStateSet = AccessibleContextBase::getAccessibleStateSet ();
508*9b8096d0SSteve Yin         ::utl::AccessibleStateSetHelper* pStateSet =
509*9b8096d0SSteve Yin               static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
510*9b8096d0SSteve Yin             ::com::sun::star::uno::Reference<XAccessible> xTempAcc = getAccessibleParent();
511*9b8096d0SSteve Yin             if( xTempAcc.is() )
512*9b8096d0SSteve Yin             {
513*9b8096d0SSteve Yin                 ::com::sun::star::uno::Reference<XAccessibleContext>
514*9b8096d0SSteve Yin                                         xTempAccContext = xTempAcc->getAccessibleContext();
515*9b8096d0SSteve Yin                 if( xTempAccContext.is() )
516*9b8096d0SSteve Yin                 {
517*9b8096d0SSteve Yin                     ::com::sun::star::uno::Reference<XAccessibleStateSet> rState =
518*9b8096d0SSteve Yin                         xTempAccContext->getAccessibleStateSet();
519*9b8096d0SSteve Yin                     if( rState.is() )           {
520*9b8096d0SSteve Yin                         com::sun::star::uno::Sequence<short> pStates = rState->getStates();
521*9b8096d0SSteve Yin                         int count = pStates.getLength();
522*9b8096d0SSteve Yin                         for( int iIndex = 0;iIndex < count;iIndex++ )
523*9b8096d0SSteve Yin                         {
524*9b8096d0SSteve Yin                             if( pStates[iIndex] == AccessibleStateType::EDITABLE )
525*9b8096d0SSteve Yin                             {
526*9b8096d0SSteve Yin                                 pStateSet->AddState (AccessibleStateType::EDITABLE);
527*9b8096d0SSteve Yin                                 pStateSet->AddState (AccessibleStateType::RESIZABLE);
528*9b8096d0SSteve Yin                                 pStateSet->AddState (AccessibleStateType::MOVEABLE);
529*9b8096d0SSteve Yin                                 break;
530*9b8096d0SSteve Yin                             }
531*9b8096d0SSteve Yin                         }
532*9b8096d0SSteve Yin                     }
533*9b8096d0SSteve Yin                 }
534*9b8096d0SSteve Yin             }
535*9b8096d0SSteve Yin             xStateSet = Reference<XAccessibleStateSet>(
536*9b8096d0SSteve Yin                 new ::utl::AccessibleStateSetHelper (*pStateSet));
537*9b8096d0SSteve Yin             //-----IAccessibility2 Implementation 2009
538*9b8096d0SSteve Yin     }else
539cdf0e10cSrcweir     {
540cdf0e10cSrcweir         ::utl::AccessibleStateSetHelper* pStateSet =
541cdf0e10cSrcweir               static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
542cdf0e10cSrcweir 
543cdf0e10cSrcweir         if (pStateSet != NULL)
544cdf0e10cSrcweir         {
545cdf0e10cSrcweir             // Merge current FOCUSED state from edit engine.
546cdf0e10cSrcweir             if (mpText != NULL)
547cdf0e10cSrcweir             {
548cdf0e10cSrcweir                 if (mpText->HaveFocus())
549cdf0e10cSrcweir                     pStateSet->AddState (AccessibleStateType::FOCUSED);
550cdf0e10cSrcweir                 else
551cdf0e10cSrcweir                     pStateSet->RemoveState (AccessibleStateType::FOCUSED);
552cdf0e10cSrcweir             }
553*9b8096d0SSteve Yin             //IAccessibility2 Implementation 2009-----
554*9b8096d0SSteve Yin             //Solution:Just when the document is not read-only,set states EDITABLE,RESIZABLE,MOVEABLE
555*9b8096d0SSteve Yin             ::com::sun::star::uno::Reference<XAccessible> xTempAcc = getAccessibleParent();
556*9b8096d0SSteve Yin             if( xTempAcc.is() )
557*9b8096d0SSteve Yin             {
558*9b8096d0SSteve Yin                 ::com::sun::star::uno::Reference<XAccessibleContext>
559*9b8096d0SSteve Yin                                         xTempAccContext = xTempAcc->getAccessibleContext();
560*9b8096d0SSteve Yin                 if( xTempAccContext.is() )
561*9b8096d0SSteve Yin                 {
562*9b8096d0SSteve Yin                     ::com::sun::star::uno::Reference<XAccessibleStateSet> rState =
563*9b8096d0SSteve Yin                         xTempAccContext->getAccessibleStateSet();
564*9b8096d0SSteve Yin                     if( rState.is() )           {
565*9b8096d0SSteve Yin                         com::sun::star::uno::Sequence<short> pStates = rState->getStates();
566*9b8096d0SSteve Yin                         int count = pStates.getLength();
567*9b8096d0SSteve Yin                         for( int iIndex = 0;iIndex < count;iIndex++ )
568*9b8096d0SSteve Yin                         {
569*9b8096d0SSteve Yin                             if( pStates[iIndex] == AccessibleStateType::EDITABLE )
570*9b8096d0SSteve Yin                             {
571*9b8096d0SSteve Yin                                 pStateSet->AddState (AccessibleStateType::EDITABLE);
572*9b8096d0SSteve Yin                                 pStateSet->AddState (AccessibleStateType::RESIZABLE);
573*9b8096d0SSteve Yin                                 pStateSet->AddState (AccessibleStateType::MOVEABLE);
574*9b8096d0SSteve Yin                                 break;
575*9b8096d0SSteve Yin                             }
576*9b8096d0SSteve Yin                         }
577*9b8096d0SSteve Yin                     }
578*9b8096d0SSteve Yin                 }
579*9b8096d0SSteve Yin             }
580*9b8096d0SSteve Yin             //-----IAccessibility2 Implementation 2009
581cdf0e10cSrcweir             // Create a copy of the state set that may be modified by the
582cdf0e10cSrcweir             // caller without affecting the current state set.
583cdf0e10cSrcweir             xStateSet = Reference<XAccessibleStateSet>(
584cdf0e10cSrcweir                 new ::utl::AccessibleStateSetHelper (*pStateSet));
585cdf0e10cSrcweir         }
586cdf0e10cSrcweir     }
587*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
588*9b8096d0SSteve Yin     UpdateDocumentAllSelState(xStateSet);
589*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
590cdf0e10cSrcweir     return xStateSet;
591cdf0e10cSrcweir }
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 
594cdf0e10cSrcweir 
595cdf0e10cSrcweir 
596cdf0e10cSrcweir //=====  XAccessibleComponent  ================================================
597cdf0e10cSrcweir 
598cdf0e10cSrcweir /** The implementation below is at the moment straightforward.  It iterates
599cdf0e10cSrcweir     over all children (and thereby instances all children which have not
600cdf0e10cSrcweir     been already instatiated) until a child covering the specifed point is
601cdf0e10cSrcweir     found.
602cdf0e10cSrcweir     This leaves room for improvement.  For instance, first iterate only over
603cdf0e10cSrcweir     the already instantiated children and only if no match is found
604cdf0e10cSrcweir     instantiate the remaining ones.
605cdf0e10cSrcweir */
606cdf0e10cSrcweir uno::Reference<XAccessible > SAL_CALL
607cdf0e10cSrcweir     AccessibleShape::getAccessibleAtPoint (
608cdf0e10cSrcweir         const awt::Point& aPoint)
609cdf0e10cSrcweir     throw (uno::RuntimeException)
610cdf0e10cSrcweir {
611cdf0e10cSrcweir     ::osl::MutexGuard aGuard (maMutex);
612cdf0e10cSrcweir 
613cdf0e10cSrcweir     sal_Int32 nChildCount = getAccessibleChildCount ();
614cdf0e10cSrcweir     for (sal_Int32 i=0; i<nChildCount; ++i)
615cdf0e10cSrcweir     {
616cdf0e10cSrcweir         Reference<XAccessible> xChild (getAccessibleChild (i));
617cdf0e10cSrcweir         if (xChild.is())
618cdf0e10cSrcweir         {
619cdf0e10cSrcweir             Reference<XAccessibleComponent> xChildComponent (
620cdf0e10cSrcweir                 xChild->getAccessibleContext(), uno::UNO_QUERY);
621cdf0e10cSrcweir             if (xChildComponent.is())
622cdf0e10cSrcweir             {
623cdf0e10cSrcweir                 awt::Rectangle aBBox (xChildComponent->getBounds());
624cdf0e10cSrcweir                 if ( (aPoint.X >= aBBox.X)
625cdf0e10cSrcweir                     && (aPoint.Y >= aBBox.Y)
626cdf0e10cSrcweir                     && (aPoint.X < aBBox.X+aBBox.Width)
627cdf0e10cSrcweir                     && (aPoint.Y < aBBox.Y+aBBox.Height) )
628cdf0e10cSrcweir                     return xChild;
629cdf0e10cSrcweir             }
630cdf0e10cSrcweir         }
631cdf0e10cSrcweir     }
632cdf0e10cSrcweir 
633cdf0e10cSrcweir     // Have not found a child under the given point.  Returning empty
634cdf0e10cSrcweir     // reference to indicate this.
635cdf0e10cSrcweir     return uno::Reference<XAccessible>();
636cdf0e10cSrcweir }
637cdf0e10cSrcweir 
638cdf0e10cSrcweir 
639cdf0e10cSrcweir 
640cdf0e10cSrcweir 
641cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleShape::getBounds (void)
642cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
643cdf0e10cSrcweir {
644cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
645cdf0e10cSrcweir     ::osl::MutexGuard aGuard (maMutex);
646cdf0e10cSrcweir 
647cdf0e10cSrcweir     ThrowIfDisposed ();
648cdf0e10cSrcweir     awt::Rectangle aBoundingBox;
649cdf0e10cSrcweir     if ( mxShape.is() )
650cdf0e10cSrcweir     {
651cdf0e10cSrcweir 
652cdf0e10cSrcweir         static const OUString sBoundRectName (
653cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM("BoundRect"));
654cdf0e10cSrcweir         static const OUString sAnchorPositionName (
655cdf0e10cSrcweir             RTL_CONSTASCII_USTRINGPARAM("AnchorPosition"));
656cdf0e10cSrcweir 
657cdf0e10cSrcweir         // Get the shape's bounding box in internal coordinates (in 100th of
658cdf0e10cSrcweir         // mm).  Use the property BoundRect.  Only if that is not supported ask
659cdf0e10cSrcweir         // the shape for its position and size directly.
660cdf0e10cSrcweir         Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY);
661cdf0e10cSrcweir         Reference<beans::XPropertySetInfo> xSetInfo;
662cdf0e10cSrcweir         bool bFoundBoundRect = false;
663cdf0e10cSrcweir         if (xSet.is())
664cdf0e10cSrcweir         {
665cdf0e10cSrcweir             xSetInfo = xSet->getPropertySetInfo ();
666cdf0e10cSrcweir             if (xSetInfo.is())
667cdf0e10cSrcweir             {
668cdf0e10cSrcweir                 if (xSetInfo->hasPropertyByName (sBoundRectName))
669cdf0e10cSrcweir                 {
670cdf0e10cSrcweir                     try
671cdf0e10cSrcweir                     {
672cdf0e10cSrcweir                         uno::Any aValue = xSet->getPropertyValue (sBoundRectName);
673cdf0e10cSrcweir                         aValue >>= aBoundingBox;
674cdf0e10cSrcweir                         bFoundBoundRect = true;
675cdf0e10cSrcweir                     }
676cdf0e10cSrcweir                     catch (beans::UnknownPropertyException e)
677cdf0e10cSrcweir                     {
678cdf0e10cSrcweir                         // Handled below (bFoundBoundRect stays false).
679cdf0e10cSrcweir                     }
680cdf0e10cSrcweir                 }
681cdf0e10cSrcweir                 else
682cdf0e10cSrcweir                     OSL_TRACE (" no property BoundRect");
683cdf0e10cSrcweir             }
684cdf0e10cSrcweir         }
685cdf0e10cSrcweir 
686cdf0e10cSrcweir         // Fallback when there is no BoundRect Property.
687cdf0e10cSrcweir         if ( ! bFoundBoundRect )
688cdf0e10cSrcweir         {
689cdf0e10cSrcweir             awt::Point aPosition (mxShape->getPosition());
690cdf0e10cSrcweir             awt::Size aSize (mxShape->getSize());
691cdf0e10cSrcweir             aBoundingBox = awt::Rectangle (
692cdf0e10cSrcweir                 aPosition.X, aPosition.Y,
693cdf0e10cSrcweir                 aSize.Width, aSize.Height);
694cdf0e10cSrcweir 
695cdf0e10cSrcweir             // While BoundRects have absolute positions, the position returned
696cdf0e10cSrcweir             // by XPosition::getPosition is relative.  Get the anchor position
697cdf0e10cSrcweir             // (usually not (0,0) for Writer shapes).
698cdf0e10cSrcweir             if (xSetInfo.is())
699cdf0e10cSrcweir             {
700cdf0e10cSrcweir                 if (xSetInfo->hasPropertyByName (sAnchorPositionName))
701cdf0e10cSrcweir                 {
702cdf0e10cSrcweir                     uno::Any aPos = xSet->getPropertyValue (sAnchorPositionName);
703cdf0e10cSrcweir                     awt::Point aAnchorPosition;
704cdf0e10cSrcweir                     aPos >>= aAnchorPosition;
705cdf0e10cSrcweir                     aBoundingBox.X += aAnchorPosition.X;
706cdf0e10cSrcweir                     aBoundingBox.Y += aAnchorPosition.Y;
707cdf0e10cSrcweir                 }
708cdf0e10cSrcweir             }
709cdf0e10cSrcweir         }
710cdf0e10cSrcweir 
711cdf0e10cSrcweir         // Transform coordinates from internal to pixel.
712cdf0e10cSrcweir         if (maShapeTreeInfo.GetViewForwarder() == NULL)
713cdf0e10cSrcweir             throw uno::RuntimeException (::rtl::OUString (
714cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
715cdf0e10cSrcweir                     "AccessibleShape has no valid view forwarder")),
716cdf0e10cSrcweir                 static_cast<uno::XWeak*>(this));
717cdf0e10cSrcweir         ::Size aPixelSize = maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
718cdf0e10cSrcweir             ::Size (aBoundingBox.Width, aBoundingBox.Height));
719cdf0e10cSrcweir         ::Point aPixelPosition = maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
720cdf0e10cSrcweir             ::Point (aBoundingBox.X, aBoundingBox.Y));
721cdf0e10cSrcweir 
722cdf0e10cSrcweir         // Clip the shape's bounding box with the bounding box of its parent.
723cdf0e10cSrcweir         Reference<XAccessibleComponent> xParentComponent (
724cdf0e10cSrcweir             getAccessibleParent(), uno::UNO_QUERY);
725cdf0e10cSrcweir         if (xParentComponent.is())
726cdf0e10cSrcweir         {
727cdf0e10cSrcweir             // Make the coordinates relative to the parent.
728cdf0e10cSrcweir             awt::Point aParentLocation (xParentComponent->getLocationOnScreen());
729cdf0e10cSrcweir             int x = aPixelPosition.getX() - aParentLocation.X;
730cdf0e10cSrcweir             int y = aPixelPosition.getY() - aParentLocation.Y;
731cdf0e10cSrcweir 
732cdf0e10cSrcweir             /*        //  The following block is a workarround for bug #99889# (property
733cdf0e10cSrcweir             //  BoundRect returnes coordinates relative to document window
734cdf0e10cSrcweir             //  instead of absolute coordinates for shapes in Writer).  Has to
735cdf0e10cSrcweir             //  be removed as soon as bug is fixed.
736cdf0e10cSrcweir 
737cdf0e10cSrcweir             // Use a non-null anchor position as flag that the shape is in a
738cdf0e10cSrcweir             // Writer document.
739cdf0e10cSrcweir             if (xSetInfo.is())
740cdf0e10cSrcweir                 if (xSetInfo->hasPropertyByName (sAnchorPositionName))
741cdf0e10cSrcweir                 {
742cdf0e10cSrcweir                     uno::Any aPos = xSet->getPropertyValue (sAnchorPositionName);
743cdf0e10cSrcweir                     awt::Point aAnchorPosition;
744cdf0e10cSrcweir                     aPos >>= aAnchorPosition;
745cdf0e10cSrcweir                     if (aAnchorPosition.X > 0)
746cdf0e10cSrcweir                     {
747cdf0e10cSrcweir                         x = aPixelPosition.getX();
748cdf0e10cSrcweir                         y = aPixelPosition.getY();
749cdf0e10cSrcweir                     }
750cdf0e10cSrcweir                 }
751cdf0e10cSrcweir             //  End of workarround.
752cdf0e10cSrcweir             */
753cdf0e10cSrcweir             // Clip with parent (with coordinates relative to itself).
754cdf0e10cSrcweir             ::Rectangle aBBox (
755cdf0e10cSrcweir                 x, y, x + aPixelSize.getWidth(), y + aPixelSize.getHeight());
756cdf0e10cSrcweir             awt::Size aParentSize (xParentComponent->getSize());
757cdf0e10cSrcweir             ::Rectangle aParentBBox (0,0, aParentSize.Width, aParentSize.Height);
758cdf0e10cSrcweir             aBBox = aBBox.GetIntersection (aParentBBox);
759cdf0e10cSrcweir             aBoundingBox = awt::Rectangle (
760cdf0e10cSrcweir                 aBBox.getX(),
761cdf0e10cSrcweir                 aBBox.getY(),
762cdf0e10cSrcweir                 aBBox.getWidth(),
763cdf0e10cSrcweir                 aBBox.getHeight());
764cdf0e10cSrcweir         }
765cdf0e10cSrcweir         else
766cdf0e10cSrcweir         {
767cdf0e10cSrcweir             OSL_TRACE ("parent does not support component");
768cdf0e10cSrcweir             aBoundingBox = awt::Rectangle (
769cdf0e10cSrcweir                 aPixelPosition.getX(), aPixelPosition.getY(),
770cdf0e10cSrcweir                 aPixelSize.getWidth(), aPixelSize.getHeight());
771cdf0e10cSrcweir         }
772cdf0e10cSrcweir     }
773cdf0e10cSrcweir 
774cdf0e10cSrcweir     return aBoundingBox;
775cdf0e10cSrcweir }
776cdf0e10cSrcweir 
777cdf0e10cSrcweir 
778cdf0e10cSrcweir 
779cdf0e10cSrcweir 
780cdf0e10cSrcweir awt::Point SAL_CALL AccessibleShape::getLocation (void)
781cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
782cdf0e10cSrcweir {
783cdf0e10cSrcweir     ThrowIfDisposed ();
784cdf0e10cSrcweir     awt::Rectangle aBoundingBox (getBounds());
785cdf0e10cSrcweir     return awt::Point (aBoundingBox.X, aBoundingBox.Y);
786cdf0e10cSrcweir }
787cdf0e10cSrcweir 
788cdf0e10cSrcweir 
789cdf0e10cSrcweir 
790cdf0e10cSrcweir 
791cdf0e10cSrcweir awt::Point SAL_CALL AccessibleShape::getLocationOnScreen (void)
792cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
793cdf0e10cSrcweir {
794cdf0e10cSrcweir     ThrowIfDisposed ();
795cdf0e10cSrcweir 
796cdf0e10cSrcweir     // Get relative position...
797cdf0e10cSrcweir     awt::Point aLocation (getLocation ());
798cdf0e10cSrcweir 
799cdf0e10cSrcweir     // ... and add absolute position of the parent.
800cdf0e10cSrcweir     uno::Reference<XAccessibleComponent> xParentComponent (
801cdf0e10cSrcweir         getAccessibleParent(), uno::UNO_QUERY);
802cdf0e10cSrcweir     if (xParentComponent.is())
803cdf0e10cSrcweir     {
804cdf0e10cSrcweir         awt::Point aParentLocation (xParentComponent->getLocationOnScreen());
805cdf0e10cSrcweir         aLocation.X += aParentLocation.X;
806cdf0e10cSrcweir         aLocation.Y += aParentLocation.Y;
807cdf0e10cSrcweir     }
808cdf0e10cSrcweir     else
809cdf0e10cSrcweir         OSL_TRACE ("getLocation: parent does not support XAccessibleComponent");
810cdf0e10cSrcweir     return aLocation;
811cdf0e10cSrcweir }
812cdf0e10cSrcweir 
813cdf0e10cSrcweir 
814cdf0e10cSrcweir 
815cdf0e10cSrcweir 
816cdf0e10cSrcweir awt::Size SAL_CALL AccessibleShape::getSize (void)
817cdf0e10cSrcweir     throw (uno::RuntimeException)
818cdf0e10cSrcweir {
819cdf0e10cSrcweir     ThrowIfDisposed ();
820cdf0e10cSrcweir     awt::Rectangle aBoundingBox (getBounds());
821cdf0e10cSrcweir     return awt::Size (aBoundingBox.Width, aBoundingBox.Height);
822cdf0e10cSrcweir }
823cdf0e10cSrcweir 
824cdf0e10cSrcweir 
825cdf0e10cSrcweir 
826cdf0e10cSrcweir 
827cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleShape::getForeground (void)
828cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
829cdf0e10cSrcweir {
830cdf0e10cSrcweir     ThrowIfDisposed ();
831cdf0e10cSrcweir     sal_Int32 nColor (0x0ffffffL);
832cdf0e10cSrcweir 
833cdf0e10cSrcweir     try
834cdf0e10cSrcweir     {
835cdf0e10cSrcweir         uno::Reference<beans::XPropertySet> aSet (mxShape, uno::UNO_QUERY);
836cdf0e10cSrcweir         if (aSet.is())
837cdf0e10cSrcweir         {
838cdf0e10cSrcweir             uno::Any aColor;
839cdf0e10cSrcweir             aColor = aSet->getPropertyValue (OUString::createFromAscii ("LineColor"));
840cdf0e10cSrcweir             aColor >>= nColor;
841cdf0e10cSrcweir         }
842cdf0e10cSrcweir     }
843cdf0e10cSrcweir     catch (::com::sun::star::beans::UnknownPropertyException)
844cdf0e10cSrcweir     {
845cdf0e10cSrcweir         // Ignore exception and return default color.
846cdf0e10cSrcweir     }
847cdf0e10cSrcweir     return nColor;
848cdf0e10cSrcweir }
849cdf0e10cSrcweir 
850cdf0e10cSrcweir 
851cdf0e10cSrcweir 
852cdf0e10cSrcweir 
853cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleShape::getBackground (void)
854cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
855cdf0e10cSrcweir {
856cdf0e10cSrcweir     ThrowIfDisposed ();
857cdf0e10cSrcweir     sal_Int32 nColor (0L);
858cdf0e10cSrcweir 
859cdf0e10cSrcweir     try
860cdf0e10cSrcweir     {
861cdf0e10cSrcweir         uno::Reference<beans::XPropertySet> aSet (mxShape, uno::UNO_QUERY);
862cdf0e10cSrcweir         if (aSet.is())
863cdf0e10cSrcweir         {
864cdf0e10cSrcweir             uno::Any aColor;
865cdf0e10cSrcweir             aColor = aSet->getPropertyValue (OUString::createFromAscii ("FillColor"));
866cdf0e10cSrcweir             aColor >>= nColor;
867*9b8096d0SSteve Yin             //IAccessibility2 Implementation 2009-----
868*9b8096d0SSteve Yin             aColor = aSet->getPropertyValue (OUString::createFromAscii ("FillTransparence"));
869*9b8096d0SSteve Yin             short nTrans=0;
870*9b8096d0SSteve Yin             aColor >>= nTrans;
871*9b8096d0SSteve Yin             Color crBk(nColor);
872*9b8096d0SSteve Yin             if (nTrans == 0 )
873*9b8096d0SSteve Yin             {
874*9b8096d0SSteve Yin                 crBk.SetTransparency(0xff);
875*9b8096d0SSteve Yin             }
876*9b8096d0SSteve Yin             else
877*9b8096d0SSteve Yin             {
878*9b8096d0SSteve Yin                 nTrans = short(256 - nTrans / 100. * 256);
879*9b8096d0SSteve Yin                 crBk.SetTransparency(sal_uInt8(nTrans));
880*9b8096d0SSteve Yin             }
881*9b8096d0SSteve Yin             nColor = crBk.GetColor();
882*9b8096d0SSteve Yin             //-----IAccessibility2 Implementation 2009
883cdf0e10cSrcweir         }
884cdf0e10cSrcweir     }
885cdf0e10cSrcweir     catch (::com::sun::star::beans::UnknownPropertyException)
886cdf0e10cSrcweir     {
887cdf0e10cSrcweir         // Ignore exception and return default color.
888cdf0e10cSrcweir     }
889cdf0e10cSrcweir     return nColor;
890cdf0e10cSrcweir }
891cdf0e10cSrcweir 
892cdf0e10cSrcweir 
893cdf0e10cSrcweir 
894cdf0e10cSrcweir 
895cdf0e10cSrcweir //=====  XAccessibleEventBroadcaster  =========================================
896cdf0e10cSrcweir 
897cdf0e10cSrcweir void SAL_CALL AccessibleShape::addEventListener (
898cdf0e10cSrcweir     const Reference<XAccessibleEventListener >& rxListener)
899cdf0e10cSrcweir     throw (uno::RuntimeException)
900cdf0e10cSrcweir {
901cdf0e10cSrcweir     if (rBHelper.bDisposed || rBHelper.bInDispose)
902cdf0e10cSrcweir     {
903cdf0e10cSrcweir         uno::Reference<uno::XInterface> xThis (
904cdf0e10cSrcweir             (lang::XComponent *)this, uno::UNO_QUERY);
905cdf0e10cSrcweir         rxListener->disposing (lang::EventObject (xThis));
906cdf0e10cSrcweir     }
907cdf0e10cSrcweir     else
908cdf0e10cSrcweir     {
909cdf0e10cSrcweir         AccessibleContextBase::addEventListener (rxListener);
910cdf0e10cSrcweir         if (mpText != NULL)
911cdf0e10cSrcweir             mpText->AddEventListener (rxListener);
912cdf0e10cSrcweir     }
913cdf0e10cSrcweir }
914cdf0e10cSrcweir 
915cdf0e10cSrcweir 
916cdf0e10cSrcweir 
917cdf0e10cSrcweir 
918cdf0e10cSrcweir void SAL_CALL AccessibleShape::removeEventListener (
919cdf0e10cSrcweir     const Reference<XAccessibleEventListener >& rxListener)
920cdf0e10cSrcweir     throw (uno::RuntimeException)
921cdf0e10cSrcweir {
922cdf0e10cSrcweir     AccessibleContextBase::removeEventListener (rxListener);
923cdf0e10cSrcweir     if (mpText != NULL)
924cdf0e10cSrcweir         mpText->RemoveEventListener (rxListener);
925cdf0e10cSrcweir }
926cdf0e10cSrcweir 
927cdf0e10cSrcweir 
928cdf0e10cSrcweir 
929cdf0e10cSrcweir 
930cdf0e10cSrcweir //=====  XInterface  ==========================================================
931cdf0e10cSrcweir 
932cdf0e10cSrcweir com::sun::star::uno::Any SAL_CALL
933cdf0e10cSrcweir     AccessibleShape::queryInterface (const com::sun::star::uno::Type & rType)
934cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
935cdf0e10cSrcweir {
936cdf0e10cSrcweir     ::com::sun::star::uno::Any aReturn = AccessibleContextBase::queryInterface (rType);
937cdf0e10cSrcweir     if ( ! aReturn.hasValue())
938cdf0e10cSrcweir         aReturn = ::cppu::queryInterface (rType,
939cdf0e10cSrcweir             static_cast<XAccessibleComponent*>(this),
940cdf0e10cSrcweir             static_cast<XAccessibleExtendedComponent*>(this),
941*9b8096d0SSteve Yin         //IAccessibility2 Implementation 2009-----
942*9b8096d0SSteve Yin             static_cast< ::com::sun::star::accessibility::XAccessibleSelection* >(this),
943*9b8096d0SSteve Yin 
944*9b8096d0SSteve Yin          static_cast< ::com::sun::star::accessibility::XAccessibleExtendedAttributes* >(this),
945*9b8096d0SSteve Yin          //-----IAccessibility2 Implementation 2009
946cdf0e10cSrcweir             static_cast<lang::XEventListener*>(this),
947cdf0e10cSrcweir             static_cast<document::XEventListener*>(this),
948*9b8096d0SSteve Yin             static_cast<lang::XUnoTunnel*>(this),
949*9b8096d0SSteve Yin     //IAccessibility2 Implementation 2009-----
950*9b8096d0SSteve Yin             static_cast<XAccessibleGroupPosition*>(this),
951*9b8096d0SSteve Yin             static_cast<XAccessibleHypertext*>(this)
952*9b8096d0SSteve Yin     //-----IAccessibility2 Implementation 2009
953cdf0e10cSrcweir             );
954cdf0e10cSrcweir     return aReturn;
955cdf0e10cSrcweir }
956cdf0e10cSrcweir 
957cdf0e10cSrcweir 
958cdf0e10cSrcweir 
959cdf0e10cSrcweir 
960cdf0e10cSrcweir void SAL_CALL
961cdf0e10cSrcweir     AccessibleShape::acquire (void)
962cdf0e10cSrcweir     throw ()
963cdf0e10cSrcweir {
964cdf0e10cSrcweir     AccessibleContextBase::acquire ();
965cdf0e10cSrcweir }
966cdf0e10cSrcweir 
967cdf0e10cSrcweir 
968cdf0e10cSrcweir 
969cdf0e10cSrcweir 
970cdf0e10cSrcweir void SAL_CALL
971cdf0e10cSrcweir     AccessibleShape::release (void)
972cdf0e10cSrcweir     throw ()
973cdf0e10cSrcweir {
974cdf0e10cSrcweir     AccessibleContextBase::release ();
975cdf0e10cSrcweir }
976*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
977*9b8096d0SSteve Yin //
978*9b8096d0SSteve Yin //=====  XAccessibleSelection  ============================================
979*9b8096d0SSteve Yin //
980cdf0e10cSrcweir 
981*9b8096d0SSteve Yin //--------------------------------------------------------------------------------
982*9b8096d0SSteve Yin void SAL_CALL AccessibleShape::selectAccessibleChild( sal_Int32 )
983*9b8096d0SSteve Yin throw ( IndexOutOfBoundsException, RuntimeException )
984*9b8096d0SSteve Yin {
985*9b8096d0SSteve Yin }
986cdf0e10cSrcweir 
987*9b8096d0SSteve Yin //----------------------------------------------------------------------------------
988*9b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleShape::isAccessibleChildSelected( sal_Int32 nChildIndex )
989*9b8096d0SSteve Yin throw ( IndexOutOfBoundsException,
990*9b8096d0SSteve Yin        RuntimeException )
991*9b8096d0SSteve Yin {
992*9b8096d0SSteve Yin     uno::Reference<XAccessible> xAcc = getAccessibleChild( nChildIndex );
993*9b8096d0SSteve Yin     uno::Reference<XAccessibleContext> xContext;
994*9b8096d0SSteve Yin     if( xAcc.is() )
995*9b8096d0SSteve Yin     {
996*9b8096d0SSteve Yin         xContext = xAcc->getAccessibleContext();
997*9b8096d0SSteve Yin     }
998cdf0e10cSrcweir 
999*9b8096d0SSteve Yin     if( xContext.is() )
1000*9b8096d0SSteve Yin     {
1001*9b8096d0SSteve Yin         if( xContext->getAccessibleRole() == AccessibleRole::PARAGRAPH )
1002*9b8096d0SSteve Yin         {
1003*9b8096d0SSteve Yin             uno::Reference< ::com::sun::star::accessibility::XAccessibleText >
1004*9b8096d0SSteve Yin                 xText(xAcc, uno::UNO_QUERY);
1005*9b8096d0SSteve Yin             if( xText.is() )
1006*9b8096d0SSteve Yin             {
1007*9b8096d0SSteve Yin                 if( xText->getSelectionStart() >= 0 ) return sal_True;
1008*9b8096d0SSteve Yin             }
1009*9b8096d0SSteve Yin         }
1010*9b8096d0SSteve Yin         else if( xContext->getAccessibleRole() == AccessibleRole::SHAPE )
1011*9b8096d0SSteve Yin         {
1012*9b8096d0SSteve Yin             Reference< XAccessibleStateSet > pRState = xContext->getAccessibleStateSet();
1013*9b8096d0SSteve Yin             if( !pRState.is() )
1014*9b8096d0SSteve Yin                 return sal_False;
1015cdf0e10cSrcweir 
1016*9b8096d0SSteve Yin             uno::Sequence<short> pStates = pRState->getStates();
1017*9b8096d0SSteve Yin             int nCount = pStates.getLength();
1018*9b8096d0SSteve Yin             for( int i = 0; i < nCount; i++ )
1019*9b8096d0SSteve Yin             {
1020*9b8096d0SSteve Yin                 if(pStates[i] == AccessibleStateType::SELECTED)
1021*9b8096d0SSteve Yin                     return sal_True;
1022*9b8096d0SSteve Yin             }
1023*9b8096d0SSteve Yin             return sal_False;
1024*9b8096d0SSteve Yin         }
1025*9b8096d0SSteve Yin     }
1026*9b8096d0SSteve Yin 
1027*9b8096d0SSteve Yin     return sal_False;
1028*9b8096d0SSteve Yin }
1029*9b8096d0SSteve Yin 
1030*9b8096d0SSteve Yin //---------------------------------------------------------------------
1031*9b8096d0SSteve Yin void SAL_CALL AccessibleShape::clearAccessibleSelection(  )
1032*9b8096d0SSteve Yin throw ( RuntimeException )
1033*9b8096d0SSteve Yin {
1034*9b8096d0SSteve Yin }
1035*9b8096d0SSteve Yin 
1036*9b8096d0SSteve Yin //-------------------------------------------------------------------------
1037*9b8096d0SSteve Yin void SAL_CALL AccessibleShape::selectAllAccessibleChildren(  )
1038*9b8096d0SSteve Yin throw ( RuntimeException )
1039*9b8096d0SSteve Yin {
1040*9b8096d0SSteve Yin }
1041*9b8096d0SSteve Yin 
1042*9b8096d0SSteve Yin //----------------------------------------------------------------------------
1043*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getSelectedAccessibleChildCount()
1044*9b8096d0SSteve Yin throw ( RuntimeException )
1045*9b8096d0SSteve Yin {
1046*9b8096d0SSteve Yin     sal_Int32 nCount = 0;
1047*9b8096d0SSteve Yin     sal_Int32 TotalCount = getAccessibleChildCount();
1048*9b8096d0SSteve Yin     for( sal_Int32 i = 0; i < TotalCount; i++ )
1049*9b8096d0SSteve Yin         if( isAccessibleChildSelected(i) ) nCount++;
1050*9b8096d0SSteve Yin 
1051*9b8096d0SSteve Yin     return nCount;
1052*9b8096d0SSteve Yin }
1053*9b8096d0SSteve Yin 
1054*9b8096d0SSteve Yin //--------------------------------------------------------------------------------------
1055*9b8096d0SSteve Yin Reference<XAccessible> SAL_CALL AccessibleShape::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
1056*9b8096d0SSteve Yin throw ( IndexOutOfBoundsException, RuntimeException)
1057*9b8096d0SSteve Yin {
1058*9b8096d0SSteve Yin     if ( nSelectedChildIndex > getSelectedAccessibleChildCount() )
1059*9b8096d0SSteve Yin         throw IndexOutOfBoundsException();
1060*9b8096d0SSteve Yin     sal_Int32 i1, i2;
1061*9b8096d0SSteve Yin     for( i1 = 0, i2 = 0; i1 < getAccessibleChildCount(); i1++ )
1062*9b8096d0SSteve Yin         if( isAccessibleChildSelected(i1) )
1063*9b8096d0SSteve Yin         {
1064*9b8096d0SSteve Yin             if( i2 == nSelectedChildIndex )
1065*9b8096d0SSteve Yin                 return getAccessibleChild( i1 );
1066*9b8096d0SSteve Yin             i2++;
1067*9b8096d0SSteve Yin         }
1068*9b8096d0SSteve Yin     return Reference<XAccessible>();
1069*9b8096d0SSteve Yin }
1070*9b8096d0SSteve Yin 
1071*9b8096d0SSteve Yin //----------------------------------------------------------------------------------
1072*9b8096d0SSteve Yin void SAL_CALL AccessibleShape::deselectAccessibleChild( sal_Int32 )
1073*9b8096d0SSteve Yin                                                             throw ( IndexOutOfBoundsException,
1074*9b8096d0SSteve Yin                                                             RuntimeException )
1075*9b8096d0SSteve Yin {
1076*9b8096d0SSteve Yin 
1077*9b8096d0SSteve Yin }
1078*9b8096d0SSteve Yin 
1079*9b8096d0SSteve Yin //=====  XAccessibleExtendedAttributes  ========================================================
1080*9b8096d0SSteve Yin uno::Any SAL_CALL AccessibleShape::getExtendedAttributes()
1081*9b8096d0SSteve Yin         throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
1082*9b8096d0SSteve Yin {
1083*9b8096d0SSteve Yin     uno::Any strRet;
1084*9b8096d0SSteve Yin     ::rtl::OUString style;
1085*9b8096d0SSteve Yin     if( getAccessibleRole() != AccessibleRole::SHAPE ) return strRet;
1086*9b8096d0SSteve Yin     if( m_pShape )
1087*9b8096d0SSteve Yin     {
1088*9b8096d0SSteve Yin         //style = ::rtl::OUString::createFromAscii("style=");
1089*9b8096d0SSteve Yin         style = ::rtl::OUString::createFromAscii("style:");
1090*9b8096d0SSteve Yin         style += GetStyle();
1091*9b8096d0SSteve Yin     }
1092*9b8096d0SSteve Yin     style += ::rtl::OUString::createFromAscii(";");
1093*9b8096d0SSteve Yin     strRet <<= style;
1094*9b8096d0SSteve Yin     return strRet;
1095*9b8096d0SSteve Yin }
1096*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
1097cdf0e10cSrcweir //=====  XServiceInfo  ========================================================
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir ::rtl::OUString SAL_CALL
1100cdf0e10cSrcweir     AccessibleShape::getImplementationName (void)
1101cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
1102cdf0e10cSrcweir {
1103cdf0e10cSrcweir     return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleShape"));
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir 
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir uno::Sequence<OUString> SAL_CALL
1110cdf0e10cSrcweir     AccessibleShape::getSupportedServiceNames (void)
1111cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
1112cdf0e10cSrcweir {
1113cdf0e10cSrcweir     ThrowIfDisposed ();
1114cdf0e10cSrcweir     // Get list of supported service names from base class...
1115cdf0e10cSrcweir     uno::Sequence<OUString> aServiceNames =
1116cdf0e10cSrcweir         AccessibleContextBase::getSupportedServiceNames();
1117cdf0e10cSrcweir     sal_Int32 nCount (aServiceNames.getLength());
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir     // ...and add additional names.
1120cdf0e10cSrcweir     aServiceNames.realloc (nCount + 1);
1121cdf0e10cSrcweir     static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM(
1122cdf0e10cSrcweir         "com.sun.star.drawing.AccessibleShape"));
1123cdf0e10cSrcweir     aServiceNames[nCount] = sAdditionalServiceName;
1124cdf0e10cSrcweir 
1125cdf0e10cSrcweir     return aServiceNames;
1126cdf0e10cSrcweir }
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir 
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir 
1132cdf0e10cSrcweir //=====  XTypeProvider  ===================================================
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir uno::Sequence<uno::Type> SAL_CALL
1135cdf0e10cSrcweir     AccessibleShape::getTypes (void)
1136cdf0e10cSrcweir     throw (uno::RuntimeException)
1137cdf0e10cSrcweir {
1138cdf0e10cSrcweir     ThrowIfDisposed ();
1139cdf0e10cSrcweir     // Get list of types from the context base implementation, ...
1140cdf0e10cSrcweir     uno::Sequence<uno::Type> aTypeList (AccessibleContextBase::getTypes());
1141cdf0e10cSrcweir     // ... get list of types from component base implementation, ...
1142cdf0e10cSrcweir     uno::Sequence<uno::Type> aComponentTypeList (AccessibleComponentBase::getTypes());
1143cdf0e10cSrcweir     // ... define local types, ...
1144cdf0e10cSrcweir     const uno::Type aLangEventListenerType =
1145cdf0e10cSrcweir         ::getCppuType((const uno::Reference<lang::XEventListener>*)0);
1146cdf0e10cSrcweir     const uno::Type aDocumentEventListenerType =
1147cdf0e10cSrcweir         ::getCppuType((const uno::Reference<document::XEventListener>*)0);
1148cdf0e10cSrcweir     const uno::Type aUnoTunnelType =
1149cdf0e10cSrcweir         ::getCppuType((const uno::Reference<lang::XUnoTunnel>*)0);
1150cdf0e10cSrcweir     //    const uno::Type aStateSetType =
1151cdf0e10cSrcweir     //      ::getCppuType((const uno::Reference<XAccessibleStateSet>*)0);
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir     // ... and merge them all into one list.
1154cdf0e10cSrcweir     sal_Int32   nTypeCount (aTypeList.getLength()),
1155cdf0e10cSrcweir         nComponentTypeCount (aComponentTypeList.getLength());
1156cdf0e10cSrcweir     int         i;
1157cdf0e10cSrcweir 
1158cdf0e10cSrcweir     aTypeList.realloc (nTypeCount + nComponentTypeCount + 3);
1159cdf0e10cSrcweir 
1160cdf0e10cSrcweir     for (i=0; i<nComponentTypeCount; i++)
1161cdf0e10cSrcweir         aTypeList[nTypeCount + i] = aComponentTypeList[i];
1162cdf0e10cSrcweir 
1163cdf0e10cSrcweir     aTypeList[nTypeCount + i++ ] = aLangEventListenerType;
1164cdf0e10cSrcweir     aTypeList[nTypeCount + i++ ] = aDocumentEventListenerType;
1165cdf0e10cSrcweir     aTypeList[nTypeCount + i ] = aUnoTunnelType;
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir     return aTypeList;
1168cdf0e10cSrcweir }
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir 
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir //=====  lang::XEventListener  ================================================
1174cdf0e10cSrcweir 
1175cdf0e10cSrcweir /** Disposing calls are accepted only from the model: Just reset the
1176cdf0e10cSrcweir     reference to the model in the shape tree info.  Otherwise this object
1177cdf0e10cSrcweir     remains functional.
1178cdf0e10cSrcweir */
1179cdf0e10cSrcweir void SAL_CALL
1180cdf0e10cSrcweir     AccessibleShape::disposing (const lang::EventObject& aEvent)
1181cdf0e10cSrcweir     throw (uno::RuntimeException)
1182cdf0e10cSrcweir {
1183cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
1184cdf0e10cSrcweir     ::osl::MutexGuard aGuard (maMutex);
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir     try
1187cdf0e10cSrcweir     {
1188cdf0e10cSrcweir         if (aEvent.Source ==  maShapeTreeInfo.GetModelBroadcaster())
1189cdf0e10cSrcweir         {
1190cdf0e10cSrcweir             // Remove reference to model broadcaster to allow it to pass
1191cdf0e10cSrcweir             // away.
1192cdf0e10cSrcweir             maShapeTreeInfo.SetModelBroadcaster(NULL);
1193cdf0e10cSrcweir         }
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir     }
1196cdf0e10cSrcweir     catch (uno::RuntimeException e)
1197cdf0e10cSrcweir     {
1198cdf0e10cSrcweir         OSL_TRACE ("caught exception while disposing");
1199cdf0e10cSrcweir     }
1200cdf0e10cSrcweir }
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir 
1205cdf0e10cSrcweir //=====  document::XEventListener  ============================================
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir void SAL_CALL
1208cdf0e10cSrcweir     AccessibleShape::notifyEvent (const document::EventObject& rEventObject)
1209cdf0e10cSrcweir     throw (uno::RuntimeException)
1210cdf0e10cSrcweir {
1211cdf0e10cSrcweir     static const OUString sShapeModified (
1212cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("ShapeModified"));
1213cdf0e10cSrcweir 
1214cdf0e10cSrcweir     // First check if the event is for us.
1215cdf0e10cSrcweir     uno::Reference<drawing::XShape> xShape (
1216cdf0e10cSrcweir         rEventObject.Source, uno::UNO_QUERY);
1217cdf0e10cSrcweir     if ( xShape.get() == mxShape.get() )
1218cdf0e10cSrcweir     {
1219cdf0e10cSrcweir         if (rEventObject.EventName.equals (sShapeModified))
1220cdf0e10cSrcweir         {
1221*9b8096d0SSteve Yin             //Need to update text children when receiving ShapeModified hint when exiting edit mode for text box
1222*9b8096d0SSteve Yin             if (mpText)
1223*9b8096d0SSteve Yin                 mpText->UpdateChildren();
1224*9b8096d0SSteve Yin 
1225*9b8096d0SSteve Yin 
1226cdf0e10cSrcweir             // Some property of a shape has been modified.  Send an event
1227cdf0e10cSrcweir             // that indicates a change of the visible data to all listeners.
1228cdf0e10cSrcweir             CommitChange (
1229cdf0e10cSrcweir                 AccessibleEventId::VISIBLE_DATA_CHANGED,
1230cdf0e10cSrcweir                 uno::Any(),
1231cdf0e10cSrcweir                 uno::Any());
1232cdf0e10cSrcweir 
1233cdf0e10cSrcweir             // Name and Description may have changed.  Update the local
1234cdf0e10cSrcweir             // values accordingly.
1235cdf0e10cSrcweir             UpdateNameAndDescription();
1236cdf0e10cSrcweir         }
1237cdf0e10cSrcweir     }
1238cdf0e10cSrcweir }
1239cdf0e10cSrcweir 
1240cdf0e10cSrcweir 
1241cdf0e10cSrcweir 
1242cdf0e10cSrcweir 
1243cdf0e10cSrcweir //=====  lang::XUnoTunnel  ================================================
1244cdf0e10cSrcweir 
1245cdf0e10cSrcweir const uno::Sequence< sal_Int8 >&
1246cdf0e10cSrcweir     AccessibleShape::getUnoTunnelImplementationId()
1247cdf0e10cSrcweir     throw()
1248cdf0e10cSrcweir {
1249cdf0e10cSrcweir     static uno::Sequence< sal_Int8 >* pSeq = 0;
1250cdf0e10cSrcweir 
1251cdf0e10cSrcweir     if( !pSeq )
1252cdf0e10cSrcweir     {
1253cdf0e10cSrcweir         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir         if( !pSeq )
1256cdf0e10cSrcweir         {
1257cdf0e10cSrcweir             static uno::Sequence< sal_Int8 > aSeq( 16 );
1258cdf0e10cSrcweir             rtl_createUuid( (sal_uInt8*) aSeq.getArray(), 0, sal_True );
1259cdf0e10cSrcweir             pSeq = &aSeq;
1260cdf0e10cSrcweir         }
1261cdf0e10cSrcweir     }
1262cdf0e10cSrcweir 
1263cdf0e10cSrcweir     return( *pSeq );
1264cdf0e10cSrcweir }
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir //------------------------------------------------------------------------------
1267cdf0e10cSrcweir AccessibleShape*
1268cdf0e10cSrcweir     AccessibleShape::getImplementation( const uno::Reference< uno::XInterface >& rxIFace )
1269cdf0e10cSrcweir     throw()
1270cdf0e10cSrcweir {
1271cdf0e10cSrcweir     uno::Reference< lang::XUnoTunnel >  xTunnel( rxIFace, uno::UNO_QUERY );
1272cdf0e10cSrcweir     AccessibleShape*                    pReturn = NULL;
1273cdf0e10cSrcweir 
1274cdf0e10cSrcweir     if( xTunnel.is() )
1275cdf0e10cSrcweir         pReturn = reinterpret_cast< AccessibleShape* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) );
1276cdf0e10cSrcweir 
1277cdf0e10cSrcweir     return( pReturn );
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir 
1280cdf0e10cSrcweir //------------------------------------------------------------------------------
1281cdf0e10cSrcweir sal_Int64 SAL_CALL
1282cdf0e10cSrcweir     AccessibleShape::getSomething( const uno::Sequence< sal_Int8 >& rIdentifier )
1283cdf0e10cSrcweir     throw(uno::RuntimeException)
1284cdf0e10cSrcweir {
1285cdf0e10cSrcweir     sal_Int64 nReturn( 0 );
1286cdf0e10cSrcweir 
1287cdf0e10cSrcweir     if( ( rIdentifier.getLength() == 16 ) && ( 0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(), rIdentifier.getConstArray(), 16 ) ) )
1288cdf0e10cSrcweir         nReturn = reinterpret_cast< sal_Int64 >( this );
1289cdf0e10cSrcweir 
1290cdf0e10cSrcweir     return( nReturn );
1291cdf0e10cSrcweir }
1292cdf0e10cSrcweir 
1293cdf0e10cSrcweir //=====  IAccessibleViewForwarderListener  ====================================
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir void AccessibleShape::ViewForwarderChanged (ChangeType aChangeType,
1296cdf0e10cSrcweir         const IAccessibleViewForwarder* pViewForwarder)
1297cdf0e10cSrcweir {
1298cdf0e10cSrcweir     // Inform all listeners that the graphical representation (i.e. size
1299cdf0e10cSrcweir     // and/or position) of the shape has changed.
1300cdf0e10cSrcweir     CommitChange (AccessibleEventId::VISIBLE_DATA_CHANGED,
1301cdf0e10cSrcweir         uno::Any(),
1302cdf0e10cSrcweir         uno::Any());
1303cdf0e10cSrcweir 
1304cdf0e10cSrcweir     // Tell children manager of the modified view forwarder.
1305cdf0e10cSrcweir     if (mpChildrenManager != NULL)
1306cdf0e10cSrcweir         mpChildrenManager->ViewForwarderChanged (aChangeType, pViewForwarder);
1307cdf0e10cSrcweir 
1308cdf0e10cSrcweir     // update our children that our screen position might have changed
1309cdf0e10cSrcweir     if( mpText )
1310cdf0e10cSrcweir         mpText->UpdateChildren();
1311cdf0e10cSrcweir }
1312cdf0e10cSrcweir 
1313cdf0e10cSrcweir 
1314cdf0e10cSrcweir 
1315cdf0e10cSrcweir 
1316cdf0e10cSrcweir //=====  protected internal  ==================================================
1317cdf0e10cSrcweir /// Set this object's name if is different to the current name.
1318cdf0e10cSrcweir ::rtl::OUString
1319cdf0e10cSrcweir     AccessibleShape::CreateAccessibleBaseName (void)
1320cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir     return ShapeTypeHandler::CreateAccessibleBaseName( mxShape );
1323cdf0e10cSrcweir }
1324cdf0e10cSrcweir 
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir ::rtl::OUString
1327cdf0e10cSrcweir     AccessibleShape::CreateAccessibleName (void)
1328cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
1329cdf0e10cSrcweir {
1330*9b8096d0SSteve Yin     //OUString sName (CreateAccessibleBaseName());
1331*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
1332*9b8096d0SSteve Yin     OUString sName;
1333*9b8096d0SSteve Yin     sName = GetFullAccessibleName(this);
1334*9b8096d0SSteve Yin     return sName;
1335*9b8096d0SSteve Yin }
1336cdf0e10cSrcweir 
1337*9b8096d0SSteve Yin ::rtl::OUString
1338*9b8096d0SSteve Yin     AccessibleShape::GetFullAccessibleName (AccessibleShape *shape)
1339*9b8096d0SSteve Yin     throw (::com::sun::star::uno::RuntimeException)
1340*9b8096d0SSteve Yin {
1341*9b8096d0SSteve Yin     OUString sName (shape->CreateAccessibleBaseName());
1342cdf0e10cSrcweir     // Append the shape's index to the name to disambiguate between shapes
1343cdf0e10cSrcweir     // of the same type.  If such an index where not given to the
1344cdf0e10cSrcweir     // constructor then use the z-order instead.  If even that does not exist
1345cdf0e10cSrcweir     // we throw an exception.
1346*9b8096d0SSteve Yin     //long nIndex = mnIndex;
1347*9b8096d0SSteve Yin     //if (nIndex == -1)
1348*9b8096d0SSteve Yin     //{
1349*9b8096d0SSteve Yin     //    try
1350*9b8096d0SSteve Yin     //    {
1351*9b8096d0SSteve Yin     //        uno::Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY);
1352*9b8096d0SSteve Yin     //        if (xSet.is())
1353*9b8096d0SSteve Yin     //        {
1354*9b8096d0SSteve Yin     //            uno::Any aZOrder (xSet->getPropertyValue (::rtl::OUString::createFromAscii ("ZOrder")));
1355*9b8096d0SSteve Yin     //            aZOrder >>= nIndex;
1356cdf0e10cSrcweir 
1357*9b8096d0SSteve Yin     //            // Add one to be not zero based.
1358*9b8096d0SSteve Yin     //            nIndex += 1;
1359*9b8096d0SSteve Yin     //        }
1360*9b8096d0SSteve Yin     //    }
1361*9b8096d0SSteve Yin     //    catch (beans::UnknownPropertyException)
1362*9b8096d0SSteve Yin     //    {
1363*9b8096d0SSteve Yin     //        // We throw our own exception that is a bit more informative.
1364*9b8096d0SSteve Yin     //        throw uno::RuntimeException (::rtl::OUString (
1365*9b8096d0SSteve Yin     //            RTL_CONSTASCII_USTRINGPARAM("AccessibleShape has invalid index and no ZOrder property")),
1366*9b8096d0SSteve Yin     //            static_cast<uno::XWeak*>(this));
1367*9b8096d0SSteve Yin     //    }
1368*9b8096d0SSteve Yin 
1369*9b8096d0SSteve Yin     //}
1370*9b8096d0SSteve Yin 
1371*9b8096d0SSteve Yin     //// Put a space between name and index because of Gnopernicus othewise
1372*9b8096d0SSteve Yin     //// spells the name.
1373*9b8096d0SSteve Yin     //sName += OUString (RTL_CONSTASCII_USTRINGPARAM(" ")) + OUString::valueOf (nIndex);
1374*9b8096d0SSteve Yin 
1375*9b8096d0SSteve Yin     //return sName;
1376*9b8096d0SSteve Yin 
1377*9b8096d0SSteve Yin     XubString nameStr;
1378*9b8096d0SSteve Yin     if(shape->m_pShape)
1379*9b8096d0SSteve Yin         nameStr = shape->m_pShape->GetName();
1380*9b8096d0SSteve Yin     if(nameStr.Len() == 0)
1381*9b8096d0SSteve Yin     {
1382*9b8096d0SSteve Yin         sName +=  OUString( RTL_CONSTASCII_USTRINGPARAM( " " ));
1383*9b8096d0SSteve Yin     }
1384*9b8096d0SSteve Yin     else
1385*9b8096d0SSteve Yin     {
1386*9b8096d0SSteve Yin         sName = nameStr;
1387*9b8096d0SSteve Yin     }
1388*9b8096d0SSteve Yin     /*
1389*9b8096d0SSteve Yin     sal_Int32 nChildCount = shape->getAccessibleChildCount();
1390*9b8096d0SSteve Yin     if(nChildCount > 0)
1391*9b8096d0SSteve Yin       {
1392*9b8096d0SSteve Yin         for (sal_Int32 i=0; i<nChildCount; ++i)
1393*9b8096d0SSteve Yin         {
1394*9b8096d0SSteve Yin             Reference<XAccessible> xChild (shape->getAccessibleChild (i));
1395*9b8096d0SSteve Yin             if (xChild.is())
1396*9b8096d0SSteve Yin             {
1397*9b8096d0SSteve Yin             uno::Reference <XAccessibleContext> xChildContext(xChild->getAccessibleContext());
1398*9b8096d0SSteve Yin             if (xChildContext->getAccessibleRole() == AccessibleRole::PARAGRAPH)
1399*9b8096d0SSteve Yin             {
1400*9b8096d0SSteve Yin                 uno::Reference<XAccessibleText> xText = uno::Reference<XAccessibleText> ( xChild, uno::UNO_QUERY );
1401*9b8096d0SSteve Yin                 sName += OUString( RTL_CONSTASCII_USTRINGPARAM( " " )) + xText->getText();
1402*9b8096d0SSteve Yin             }
1403*9b8096d0SSteve Yin             else if (xChildContext->getAccessibleRole() == AccessibleRole::SHAPE)
1404*9b8096d0SSteve Yin             {
1405*9b8096d0SSteve Yin                 sName += OUString( RTL_CONSTASCII_USTRINGPARAM( " " )) + GetFullAccessibleName(static_cast< AccessibleShape*>( xChild.get()));
1406cdf0e10cSrcweir             }
1407cdf0e10cSrcweir             }
1408*9b8096d0SSteve Yin         }
1409*9b8096d0SSteve Yin       }
1410*9b8096d0SSteve Yin      */
1411*9b8096d0SSteve Yin     //Solution:If the new produced name if not the same with last,notify name changed
1412*9b8096d0SSteve Yin     //         Event
1413*9b8096d0SSteve Yin     if( aAccName != sName && aAccName.getLength() != 0 )
1414cdf0e10cSrcweir     {
1415*9b8096d0SSteve Yin         uno::Any aOldValue, aNewValue;
1416*9b8096d0SSteve Yin         aOldValue <<= aAccName;
1417*9b8096d0SSteve Yin         aNewValue <<= sName;
1418*9b8096d0SSteve Yin         CommitChange(
1419*9b8096d0SSteve Yin             AccessibleEventId::NAME_CHANGED,
1420*9b8096d0SSteve Yin             aNewValue,
1421*9b8096d0SSteve Yin             aOldValue);
1422cdf0e10cSrcweir     }
1423*9b8096d0SSteve Yin     aAccName = sName;
1424cdf0e10cSrcweir     return sName;
1425cdf0e10cSrcweir }
1426*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
1427cdf0e10cSrcweir ::rtl::OUString
1428cdf0e10cSrcweir     AccessibleShape::CreateAccessibleDescription (void)
1429cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
1430cdf0e10cSrcweir {
1431cdf0e10cSrcweir     DescriptionGenerator aDG (mxShape);
1432cdf0e10cSrcweir     aDG.Initialize (CreateAccessibleBaseName());
1433cdf0e10cSrcweir     switch (ShapeTypeHandler::Instance().GetTypeId (mxShape))
1434cdf0e10cSrcweir     {
1435cdf0e10cSrcweir         case DRAWING_3D_CUBE:
1436cdf0e10cSrcweir         case DRAWING_3D_EXTRUDE:
1437cdf0e10cSrcweir         case DRAWING_3D_LATHE:
1438cdf0e10cSrcweir         case DRAWING_3D_SPHERE:
1439cdf0e10cSrcweir             aDG.Add3DProperties ();
1440cdf0e10cSrcweir             break;
1441cdf0e10cSrcweir 
1442cdf0e10cSrcweir         case DRAWING_3D_SCENE:
1443cdf0e10cSrcweir         case DRAWING_GROUP:
1444cdf0e10cSrcweir         case DRAWING_PAGE:
1445cdf0e10cSrcweir             // No further information is appended.
1446cdf0e10cSrcweir             break;
1447cdf0e10cSrcweir 
1448cdf0e10cSrcweir         case DRAWING_CAPTION:
1449cdf0e10cSrcweir         case DRAWING_CLOSED_BEZIER:
1450cdf0e10cSrcweir         case DRAWING_CLOSED_FREEHAND:
1451cdf0e10cSrcweir         case DRAWING_ELLIPSE:
1452cdf0e10cSrcweir         case DRAWING_POLY_POLYGON:
1453cdf0e10cSrcweir         case DRAWING_POLY_POLYGON_PATH:
1454cdf0e10cSrcweir         case DRAWING_RECTANGLE:
1455cdf0e10cSrcweir             aDG.AddLineProperties ();
1456cdf0e10cSrcweir             aDG.AddFillProperties ();
1457cdf0e10cSrcweir             break;
1458cdf0e10cSrcweir 
1459cdf0e10cSrcweir         case DRAWING_CONNECTOR:
1460cdf0e10cSrcweir         case DRAWING_LINE:
1461cdf0e10cSrcweir         case DRAWING_MEASURE:
1462cdf0e10cSrcweir         case DRAWING_OPEN_BEZIER:
1463cdf0e10cSrcweir         case DRAWING_OPEN_FREEHAND:
1464cdf0e10cSrcweir         case DRAWING_POLY_LINE:
1465cdf0e10cSrcweir         case DRAWING_POLY_LINE_PATH:
1466cdf0e10cSrcweir             aDG.AddLineProperties ();
1467cdf0e10cSrcweir             break;
1468cdf0e10cSrcweir 
1469cdf0e10cSrcweir         case DRAWING_CONTROL:
1470cdf0e10cSrcweir             aDG.AddProperty (OUString::createFromAscii ("ControlBackground"),
1471cdf0e10cSrcweir                 DescriptionGenerator::COLOR,
1472cdf0e10cSrcweir                 OUString());
1473cdf0e10cSrcweir             aDG.AddProperty (OUString::createFromAscii ("ControlBorder"),
1474cdf0e10cSrcweir                 DescriptionGenerator::INTEGER,
1475cdf0e10cSrcweir                 OUString());
1476cdf0e10cSrcweir             break;
1477cdf0e10cSrcweir 
1478cdf0e10cSrcweir         case DRAWING_TEXT:
1479cdf0e10cSrcweir             aDG.AddTextProperties ();
1480cdf0e10cSrcweir             break;
1481cdf0e10cSrcweir 
1482cdf0e10cSrcweir         default:
1483cdf0e10cSrcweir             aDG.Initialize (::rtl::OUString (
1484cdf0e10cSrcweir                                 RTL_CONSTASCII_USTRINGPARAM("Unknown accessible shape")));
1485cdf0e10cSrcweir             uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
1486cdf0e10cSrcweir             if (xDescriptor.is())
1487cdf0e10cSrcweir             {
1488cdf0e10cSrcweir                 aDG.AppendString (::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("service name=")));
1489cdf0e10cSrcweir                 aDG.AppendString (xDescriptor->getShapeType());
1490cdf0e10cSrcweir             }
1491cdf0e10cSrcweir     }
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir     return aDG();
1494cdf0e10cSrcweir }
1495cdf0e10cSrcweir 
1496cdf0e10cSrcweir 
1497cdf0e10cSrcweir 
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir uno::Reference< drawing::XShape > AccessibleShape::GetXShape()
1500cdf0e10cSrcweir {
1501cdf0e10cSrcweir     return( mxShape );
1502cdf0e10cSrcweir }
1503cdf0e10cSrcweir 
1504cdf0e10cSrcweir 
1505cdf0e10cSrcweir 
1506cdf0e10cSrcweir // protected
1507cdf0e10cSrcweir void AccessibleShape::disposing (void)
1508cdf0e10cSrcweir {
1509cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
1510cdf0e10cSrcweir     ::osl::MutexGuard aGuard (maMutex);
1511cdf0e10cSrcweir 
1512cdf0e10cSrcweir     // Make sure to send an event that this object looses the focus in the
1513cdf0e10cSrcweir     // case that it has the focus.
1514cdf0e10cSrcweir     ::utl::AccessibleStateSetHelper* pStateSet =
1515cdf0e10cSrcweir           static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
1516cdf0e10cSrcweir     if (pStateSet != NULL)
1517cdf0e10cSrcweir         pStateSet->RemoveState (AccessibleStateType::FOCUSED);
1518cdf0e10cSrcweir 
1519cdf0e10cSrcweir     // Unregister from broadcasters.
1520cdf0e10cSrcweir     Reference<lang::XComponent> xComponent (mxShape, uno::UNO_QUERY);
1521cdf0e10cSrcweir     if (xComponent.is())
1522cdf0e10cSrcweir         xComponent->removeEventListener (this);
1523cdf0e10cSrcweir 
1524cdf0e10cSrcweir     // Unregister from model.
1525cdf0e10cSrcweir     if (maShapeTreeInfo.GetModelBroadcaster().is())
1526cdf0e10cSrcweir         maShapeTreeInfo.GetModelBroadcaster()->removeEventListener (
1527cdf0e10cSrcweir             static_cast<document::XEventListener*>(this));
1528cdf0e10cSrcweir 
1529cdf0e10cSrcweir     // Release the child containers.
1530cdf0e10cSrcweir     if (mpChildrenManager != NULL)
1531cdf0e10cSrcweir     {
1532cdf0e10cSrcweir         delete mpChildrenManager;
1533cdf0e10cSrcweir         mpChildrenManager = NULL;
1534cdf0e10cSrcweir     }
1535cdf0e10cSrcweir     if (mpText != NULL)
1536cdf0e10cSrcweir     {
1537cdf0e10cSrcweir         mpText->Dispose();
1538cdf0e10cSrcweir         delete mpText;
1539cdf0e10cSrcweir         mpText = NULL;
1540cdf0e10cSrcweir     }
1541cdf0e10cSrcweir 
1542cdf0e10cSrcweir     // Cleanup.  Remove references to objects to allow them to be
1543cdf0e10cSrcweir     // destroyed.
1544cdf0e10cSrcweir     mxShape = NULL;
1545cdf0e10cSrcweir     maShapeTreeInfo = AccessibleShapeTreeInfo();
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir     // Call base classes.
1548cdf0e10cSrcweir     AccessibleContextBase::dispose ();
1549cdf0e10cSrcweir }
1550cdf0e10cSrcweir 
1551cdf0e10cSrcweir sal_Int32 SAL_CALL
1552cdf0e10cSrcweir     AccessibleShape::getAccessibleIndexInParent (void)
1553cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
1554cdf0e10cSrcweir {
1555cdf0e10cSrcweir     ThrowIfDisposed ();
1556cdf0e10cSrcweir     //  Use a simple but slow solution for now.  Optimize later.
1557cdf0e10cSrcweir 
1558cdf0e10cSrcweir     sal_Int32 nIndex = m_nIndexInParent;
1559cdf0e10cSrcweir     if ( -1 == nIndex )
1560cdf0e10cSrcweir         nIndex = AccessibleContextBase::getAccessibleIndexInParent();
1561cdf0e10cSrcweir     return nIndex;
1562cdf0e10cSrcweir }
1563cdf0e10cSrcweir 
1564cdf0e10cSrcweir 
1565cdf0e10cSrcweir 
1566cdf0e10cSrcweir 
1567cdf0e10cSrcweir void AccessibleShape::UpdateNameAndDescription (void)
1568cdf0e10cSrcweir {
1569cdf0e10cSrcweir     // Ignore missing title, name, or description.  There are fallbacks for
1570cdf0e10cSrcweir     // them.
1571cdf0e10cSrcweir     try
1572cdf0e10cSrcweir     {
1573cdf0e10cSrcweir         Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY_THROW);
1574cdf0e10cSrcweir         OUString sString;
1575cdf0e10cSrcweir 
1576cdf0e10cSrcweir         // Get the accessible name.
1577cdf0e10cSrcweir         sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Title")));
1578cdf0e10cSrcweir         if (sString.getLength() > 0)
1579cdf0e10cSrcweir         {
1580cdf0e10cSrcweir             SetAccessibleName(sString, AccessibleContextBase::FromShape);
1581cdf0e10cSrcweir         }
1582cdf0e10cSrcweir         else
1583cdf0e10cSrcweir         {
1584cdf0e10cSrcweir             sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Name")));
1585cdf0e10cSrcweir             if (sString.getLength() > 0)
1586cdf0e10cSrcweir                 SetAccessibleName(sString, AccessibleContextBase::FromShape);
1587cdf0e10cSrcweir         }
1588cdf0e10cSrcweir 
1589cdf0e10cSrcweir         // Get the accessible description.
1590cdf0e10cSrcweir         sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Description")));
1591cdf0e10cSrcweir         if (sString.getLength() > 0)
1592cdf0e10cSrcweir             SetAccessibleDescription(sString, AccessibleContextBase::FromShape);
1593cdf0e10cSrcweir     }
1594cdf0e10cSrcweir     catch (uno::RuntimeException&)
1595cdf0e10cSrcweir     {
1596cdf0e10cSrcweir     }
1597cdf0e10cSrcweir }
1598*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
1599*9b8096d0SSteve Yin //  Return this object's role.
1600*9b8096d0SSteve Yin sal_Int16 SAL_CALL AccessibleShape::getAccessibleRole (void)
1601*9b8096d0SSteve Yin         throw (::com::sun::star::uno::RuntimeException)
1602*9b8096d0SSteve Yin {
1603*9b8096d0SSteve Yin     sal_Int16 nAccessibleRole =  AccessibleRole::SHAPE ;
1604*9b8096d0SSteve Yin     switch (ShapeTypeHandler::Instance().GetTypeId (mxShape))
1605*9b8096d0SSteve Yin     {
1606*9b8096d0SSteve Yin         case     DRAWING_GRAPHIC_OBJECT:
1607*9b8096d0SSteve Yin                  nAccessibleRole =  AccessibleRole::GRAPHIC ;               break;
1608*9b8096d0SSteve Yin         case     DRAWING_OLE:
1609*9b8096d0SSteve Yin                  nAccessibleRole =  AccessibleRole::EMBEDDED_OBJECT ;       break;
1610*9b8096d0SSteve Yin 
1611*9b8096d0SSteve Yin         default:
1612*9b8096d0SSteve Yin             nAccessibleRole = AccessibleContextBase::getAccessibleRole();
1613*9b8096d0SSteve Yin             break;
1614*9b8096d0SSteve Yin     }
1615*9b8096d0SSteve Yin 
1616*9b8096d0SSteve Yin     return nAccessibleRole;
1617*9b8096d0SSteve Yin }
1618cdf0e10cSrcweir 
1619cdf0e10cSrcweir 
1620*9b8096d0SSteve Yin void AccessibleShape::UpdateDocumentAllSelState(Reference<XAccessibleStateSet> &xStateSet)
1621*9b8096d0SSteve Yin {
1622*9b8096d0SSteve Yin     if (mpParent && mpParent->IsDocumentSelAll())
1623*9b8096d0SSteve Yin     {
1624*9b8096d0SSteve Yin         ::utl::AccessibleStateSetHelper* pStateSet =
1625*9b8096d0SSteve Yin             static_cast< ::utl::AccessibleStateSetHelper*>(xStateSet.get());
1626*9b8096d0SSteve Yin         pStateSet->AddState (AccessibleStateType::SELECTED);
1627*9b8096d0SSteve Yin 
1628*9b8096d0SSteve Yin         //uno::Any NewValue;
1629*9b8096d0SSteve Yin         //NewValue <<= AccessibleStateType::SELECTED;
1630*9b8096d0SSteve Yin 
1631*9b8096d0SSteve Yin         //CommitChange(AccessibleEventId::STATE_CHANGED,NewValue,uno::Any());
1632*9b8096d0SSteve Yin     }
1633*9b8096d0SSteve Yin }
1634*9b8096d0SSteve Yin 
1635*9b8096d0SSteve Yin //sort the drawing objects from up to down, from left to right
1636*9b8096d0SSteve Yin struct XShapePosCompareHelper
1637*9b8096d0SSteve Yin {
1638*9b8096d0SSteve Yin     bool operator() ( const uno::Reference<drawing::XShape>& xshape1,
1639*9b8096d0SSteve Yin         const uno::Reference<drawing::XShape>& xshape2 ) const
1640*9b8096d0SSteve Yin     {
1641*9b8096d0SSteve Yin         SdrObject* pObj1 = GetSdrObjectFromXShape(xshape1);
1642*9b8096d0SSteve Yin         SdrObject* pObj2 = GetSdrObjectFromXShape(xshape2);
1643*9b8096d0SSteve Yin         if(pObj1 && pObj2)
1644*9b8096d0SSteve Yin             return pObj1->GetOrdNum() < pObj2->GetOrdNum();
1645*9b8096d0SSteve Yin         else
1646*9b8096d0SSteve Yin             return 0;
1647*9b8096d0SSteve Yin     }
1648*9b8096d0SSteve Yin };
1649*9b8096d0SSteve Yin //end of group position
1650*9b8096d0SSteve Yin 
1651*9b8096d0SSteve Yin //=====  XAccessibleGroupPosition  =========================================
1652*9b8096d0SSteve Yin uno::Sequence< sal_Int32 > SAL_CALL
1653*9b8096d0SSteve Yin AccessibleShape::getGroupPosition( const uno::Any& )
1654*9b8096d0SSteve Yin throw (uno::RuntimeException)
1655*9b8096d0SSteve Yin {
1656*9b8096d0SSteve Yin     // we will return the:
1657*9b8096d0SSteve Yin     // [0] group level
1658*9b8096d0SSteve Yin     // [1] similar items counts in the group
1659*9b8096d0SSteve Yin     // [2] the position of the object in the group
1660*9b8096d0SSteve Yin     uno::Sequence< sal_Int32 > aRet( 3 );
1661*9b8096d0SSteve Yin     aRet[0] = 0;
1662*9b8096d0SSteve Yin     aRet[1] = 0;
1663*9b8096d0SSteve Yin     aRet[2] = 0;
1664*9b8096d0SSteve Yin 
1665*9b8096d0SSteve Yin     ::com::sun::star::uno::Reference<XAccessible> xParent = getAccessibleParent();
1666*9b8096d0SSteve Yin     if (!xParent.is())
1667*9b8096d0SSteve Yin     {
1668*9b8096d0SSteve Yin         return aRet;
1669*9b8096d0SSteve Yin     }
1670*9b8096d0SSteve Yin     SdrObject *pObj = GetSdrObjectFromXShape(mxShape);
1671cdf0e10cSrcweir 
1672cdf0e10cSrcweir 
1673*9b8096d0SSteve Yin     if(pObj == NULL )
1674*9b8096d0SSteve Yin     {
1675*9b8096d0SSteve Yin         return aRet;
1676*9b8096d0SSteve Yin     }
1677*9b8096d0SSteve Yin 
1678*9b8096d0SSteve Yin     // Compute object's group level.
1679*9b8096d0SSteve Yin     sal_Int32 nGroupLevel = 0;
1680*9b8096d0SSteve Yin     SdrObject * pUper = pObj->GetUpGroup();
1681*9b8096d0SSteve Yin     while( pUper )
1682*9b8096d0SSteve Yin     {
1683*9b8096d0SSteve Yin         ++nGroupLevel;
1684*9b8096d0SSteve Yin         pUper = pUper->GetUpGroup();
1685*9b8096d0SSteve Yin     }
1686*9b8096d0SSteve Yin 
1687*9b8096d0SSteve Yin     ::com::sun::star::uno::Reference<XAccessibleContext> xParentContext = xParent->getAccessibleContext();
1688*9b8096d0SSteve Yin     if( xParentContext->getAccessibleRole()  == AccessibleRole::DOCUMENT)//Document
1689*9b8096d0SSteve Yin     {
1690*9b8096d0SSteve Yin         Reference< XAccessibleGroupPosition > xGroupPosition( xParent,uno::UNO_QUERY );
1691*9b8096d0SSteve Yin         if ( xGroupPosition.is() )
1692*9b8096d0SSteve Yin         {
1693*9b8096d0SSteve Yin             aRet = xGroupPosition->getGroupPosition( uno::makeAny( getAccessibleContext() ) );
1694*9b8096d0SSteve Yin         }
1695*9b8096d0SSteve Yin         return aRet;
1696*9b8096d0SSteve Yin     }
1697*9b8096d0SSteve Yin     if (xParentContext->getAccessibleRole() != AccessibleRole::SHAPE)
1698*9b8096d0SSteve Yin     {
1699*9b8096d0SSteve Yin         return aRet;
1700*9b8096d0SSteve Yin     }
1701*9b8096d0SSteve Yin 
1702*9b8096d0SSteve Yin     SdrObjList *pGrpList = NULL;
1703*9b8096d0SSteve Yin     if( pObj->GetUpGroup() )
1704*9b8096d0SSteve Yin         pGrpList = pObj->GetUpGroup()->GetSubList();
1705*9b8096d0SSteve Yin     else
1706*9b8096d0SSteve Yin         return aRet;
1707*9b8096d0SSteve Yin 
1708*9b8096d0SSteve Yin     std::vector< uno::Reference<drawing::XShape> > vXShapes;
1709*9b8096d0SSteve Yin     if (pGrpList)
1710*9b8096d0SSteve Yin     {
1711*9b8096d0SSteve Yin         const sal_Int32 nObj = pGrpList->GetObjCount();
1712*9b8096d0SSteve Yin         for(sal_Int32 i = 0 ; i < nObj ; ++i)
1713*9b8096d0SSteve Yin         {
1714*9b8096d0SSteve Yin             SdrObject *pSubObj = pGrpList->GetObj(i);
1715*9b8096d0SSteve Yin             //IAccessibility2 Implementation 2009-----
1716*9b8096d0SSteve Yin             if (pSubObj &&
1717*9b8096d0SSteve Yin                 xParentContext->getAccessibleChild(i)->getAccessibleContext()->getAccessibleRole() != AccessibleRole::GROUP_BOX)
1718*9b8096d0SSteve Yin             //-----IAccessibility2 Implementation 2009
1719*9b8096d0SSteve Yin             {
1720*9b8096d0SSteve Yin                 vXShapes.push_back( GetXShapeForSdrObject(pSubObj) );
1721*9b8096d0SSteve Yin             }
1722*9b8096d0SSteve Yin         }
1723*9b8096d0SSteve Yin     }
1724*9b8096d0SSteve Yin 
1725*9b8096d0SSteve Yin     std::sort( vXShapes.begin(), vXShapes.end(), XShapePosCompareHelper() );
1726*9b8096d0SSteve Yin 
1727*9b8096d0SSteve Yin     //get the the index of the selected object in the group
1728*9b8096d0SSteve Yin     std::vector< uno::Reference<drawing::XShape> >::iterator aIter;
1729*9b8096d0SSteve Yin     //we start counting position from 1
1730*9b8096d0SSteve Yin     sal_Int32 nPos = 1;
1731*9b8096d0SSteve Yin     for ( aIter = vXShapes.begin(); aIter != vXShapes.end(); aIter++, nPos++ )
1732*9b8096d0SSteve Yin     {
1733*9b8096d0SSteve Yin         if ( (*aIter).get() == mxShape.get() )
1734*9b8096d0SSteve Yin         {
1735*9b8096d0SSteve Yin             sal_Int32* pArray = aRet.getArray();
1736*9b8096d0SSteve Yin             pArray[0] = nGroupLevel;
1737*9b8096d0SSteve Yin             pArray[1] = vXShapes.size();
1738*9b8096d0SSteve Yin             pArray[2] = nPos;
1739*9b8096d0SSteve Yin             break;
1740*9b8096d0SSteve Yin         }
1741*9b8096d0SSteve Yin     }
1742*9b8096d0SSteve Yin 
1743*9b8096d0SSteve Yin     return aRet;
1744*9b8096d0SSteve Yin }
1745*9b8096d0SSteve Yin 
1746*9b8096d0SSteve Yin ::rtl::OUString AccessibleShape::getObjectLink( const uno::Any& )
1747*9b8096d0SSteve Yin     throw (uno::RuntimeException)
1748*9b8096d0SSteve Yin {
1749*9b8096d0SSteve Yin     ::rtl::OUString aRet;
1750*9b8096d0SSteve Yin 
1751*9b8096d0SSteve Yin     SdrObject *pObj = GetSdrObjectFromXShape(mxShape);
1752*9b8096d0SSteve Yin     if(pObj == NULL )
1753*9b8096d0SSteve Yin     {
1754*9b8096d0SSteve Yin         return aRet;
1755*9b8096d0SSteve Yin     }
1756*9b8096d0SSteve Yin     if (maShapeTreeInfo.GetDocumentWindow().is())
1757*9b8096d0SSteve Yin     {
1758*9b8096d0SSteve Yin         Reference< XAccessibleGroupPosition > xGroupPosition( maShapeTreeInfo.GetDocumentWindow(), uno::UNO_QUERY );
1759*9b8096d0SSteve Yin         if (xGroupPosition.is())
1760*9b8096d0SSteve Yin         {
1761*9b8096d0SSteve Yin             aRet = xGroupPosition->getObjectLink( uno::makeAny( getAccessibleContext() ) );
1762*9b8096d0SSteve Yin         }
1763*9b8096d0SSteve Yin     }
1764*9b8096d0SSteve Yin     return aRet;
1765*9b8096d0SSteve Yin }
1766*9b8096d0SSteve Yin 
1767*9b8096d0SSteve Yin //=====  XAccesibleHypertext  ==================================================
1768*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getHyperLinkCount()
1769*9b8096d0SSteve Yin     throw (::com::sun::star::uno::RuntimeException)
1770*9b8096d0SSteve Yin {
1771*9b8096d0SSteve Yin     // MT: Introduced with IA2 CWS, but SvxAccessibleHyperlink was redundant to svx::AccessibleHyperlink which we introduced meanwhile.
1772*9b8096d0SSteve Yin     // Code need to be adapted....
1773*9b8096d0SSteve Yin     return 0;
1774*9b8096d0SSteve Yin 
1775*9b8096d0SSteve Yin     /*
1776*9b8096d0SSteve Yin     SvxAccessibleHyperlink* pLink = new SvxAccessibleHyperlink(m_pShape,this);
1777*9b8096d0SSteve Yin     if (pLink->IsValidHyperlink())
1778*9b8096d0SSteve Yin         return 1;
1779*9b8096d0SSteve Yin     else
1780*9b8096d0SSteve Yin         return 0;
1781*9b8096d0SSteve Yin     */
1782*9b8096d0SSteve Yin }
1783*9b8096d0SSteve Yin uno::Reference< XAccessibleHyperlink > SAL_CALL
1784*9b8096d0SSteve Yin     AccessibleShape::getHyperLink( sal_Int32 )
1785*9b8096d0SSteve Yin     throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
1786*9b8096d0SSteve Yin {
1787*9b8096d0SSteve Yin     uno::Reference< XAccessibleHyperlink > xRet;
1788*9b8096d0SSteve Yin     // MT: Introduced with IA2 CWS, but SvxAccessibleHyperlink was redundant to svx::AccessibleHyperlink which we introduced meanwhile.
1789*9b8096d0SSteve Yin     // Code need to be adapted....
1790*9b8096d0SSteve Yin     /*
1791*9b8096d0SSteve Yin     SvxAccessibleHyperlink* pLink = new SvxAccessibleHyperlink(m_pShape,this);
1792*9b8096d0SSteve Yin     if (pLink->IsValidHyperlink())
1793*9b8096d0SSteve Yin         xRet = pLink;
1794*9b8096d0SSteve Yin     if( !xRet.is() )
1795*9b8096d0SSteve Yin         throw ::com::sun::star::lang::IndexOutOfBoundsException();
1796*9b8096d0SSteve Yin     */
1797*9b8096d0SSteve Yin     return xRet;
1798*9b8096d0SSteve Yin }
1799*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getHyperLinkIndex( sal_Int32 )
1800*9b8096d0SSteve Yin throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
1801*9b8096d0SSteve Yin {
1802*9b8096d0SSteve Yin     sal_Int32 nRet = 0;
1803*9b8096d0SSteve Yin     return nRet;
1804*9b8096d0SSteve Yin }
1805*9b8096d0SSteve Yin //=====  XAccesibleText  ==================================================
1806*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getCaretPosition(  ) throw (::com::sun::star::uno::RuntimeException){return 0;}
1807*9b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleShape::setCaretPosition( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return 0;}
1808*9b8096d0SSteve Yin sal_Unicode SAL_CALL AccessibleShape::getCharacter( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return 0;}
1809*9b8096d0SSteve 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)
1810*9b8096d0SSteve Yin {
1811*9b8096d0SSteve Yin     uno::Sequence< ::com::sun::star::beans::PropertyValue > aValues(0);
1812*9b8096d0SSteve Yin     return aValues;
1813*9b8096d0SSteve Yin }
1814*9b8096d0SSteve Yin ::com::sun::star::awt::Rectangle SAL_CALL AccessibleShape::getCharacterBounds( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
1815*9b8096d0SSteve Yin {
1816*9b8096d0SSteve Yin     return com::sun::star::awt::Rectangle(0, 0, 0, 0 );
1817*9b8096d0SSteve Yin }
1818*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getCharacterCount(  ) throw (::com::sun::star::uno::RuntimeException){return 0;}
1819*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getIndexAtPoint( const ::com::sun::star::awt::Point& ) throw (::com::sun::star::uno::RuntimeException){return 0;}
1820*9b8096d0SSteve Yin ::rtl::OUString SAL_CALL AccessibleShape::getSelectedText(  ) throw (::com::sun::star::uno::RuntimeException){return OUString();}
1821*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getSelectionStart(  ) throw (::com::sun::star::uno::RuntimeException){return 0;}
1822*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleShape::getSelectionEnd(  ) throw (::com::sun::star::uno::RuntimeException){return 0;}
1823*9b8096d0SSteve 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;}
1824*9b8096d0SSteve Yin ::rtl::OUString SAL_CALL AccessibleShape::getText(  ) throw (::com::sun::star::uno::RuntimeException){return OUString();}
1825*9b8096d0SSteve Yin ::rtl::OUString SAL_CALL AccessibleShape::getTextRange( sal_Int32, sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException){return OUString();}
1826*9b8096d0SSteve 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)
1827*9b8096d0SSteve Yin {
1828*9b8096d0SSteve Yin     ::com::sun::star::accessibility::TextSegment aResult;
1829*9b8096d0SSteve Yin     return aResult;
1830*9b8096d0SSteve Yin }
1831*9b8096d0SSteve 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)
1832*9b8096d0SSteve Yin {
1833*9b8096d0SSteve Yin     ::com::sun::star::accessibility::TextSegment aResult;
1834*9b8096d0SSteve Yin     return aResult;
1835*9b8096d0SSteve Yin }
1836*9b8096d0SSteve 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)
1837*9b8096d0SSteve Yin {
1838*9b8096d0SSteve Yin     ::com::sun::star::accessibility::TextSegment aResult;
1839*9b8096d0SSteve Yin     return aResult;
1840*9b8096d0SSteve Yin }
1841*9b8096d0SSteve 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;}
1842*9b8096d0SSteve Yin 
1843*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
1844cdf0e10cSrcweir } // end of namespace accessibility
1845