1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #include <accessiblecell.hxx>
28 
29 #include "svx/DescriptionGenerator.hxx"
30 
31 #include <com/sun/star/accessibility/AccessibleRole.hpp>
32 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
33 
34 #include <vcl/svapp.hxx>
35 
36 #include <unotools/accessiblestatesethelper.hxx>
37 
38 #include <editeng/outlobj.hxx>
39 #include <svx/unoshtxt.hxx>
40 #include <svx/svdotext.hxx>
41 
42 using ::rtl::OUString;
43 using namespace ::sdr::table;
44 using namespace ::com::sun::star;
45 using namespace ::com::sun::star::uno;
46 using namespace	::com::sun::star::accessibility;
47 using namespace ::com::sun::star::lang;
48 using namespace ::com::sun::star::container;
49 
50 namespace accessibility {
51 
52 // --------------------------------------------------------------------
53 // AccessibleCell
54 // --------------------------------------------------------------------
55 
AccessibleCell(const::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> & rxParent,const sdr::table::CellRef & rCell,sal_Int32 nIndex,const AccessibleShapeTreeInfo & rShapeTreeInfo)56 AccessibleCell::AccessibleCell( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent, const sdr::table::CellRef& rCell, sal_Int32 nIndex, const AccessibleShapeTreeInfo& rShapeTreeInfo )
57 : AccessibleCellBase( rxParent, AccessibleRole::TABLE_CELL )
58 , maShapeTreeInfo( rShapeTreeInfo )
59 , mnIndexInParent( nIndex )
60 , mpText( NULL )
61 , mxCell( rCell )
62 {
63 	//Init the pAccTable var
64 	pAccTable = dynamic_cast <AccessibleTableShape *> (rxParent.get());
65 }
66 
67 // --------------------------------------------------------------------
68 
~AccessibleCell(void)69 AccessibleCell::~AccessibleCell (void)
70 {
71 	DBG_ASSERT( mpText == 0, "svx::AccessibleCell::~AccessibleCell(), not disposed!?" );
72 }
73 
74 // --------------------------------------------------------------------
75 
Init(void)76 void AccessibleCell::Init (void)
77 {
78 	SdrView* pView = maShapeTreeInfo.GetSdrView();
79 	const Window* pWindow = maShapeTreeInfo.GetWindow ();
80 	if( (pView != NULL) && (pWindow != NULL) && mxCell.is())
81 	{
82         OutlinerParaObject* pOutlinerParaObject = mxCell->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active
83 
84         bool bOwnParaObject = pOutlinerParaObject != 0;
85 
86 		if( !pOutlinerParaObject )
87 			pOutlinerParaObject = mxCell->GetOutlinerParaObject();
88 
89 		// create AccessibleTextHelper to handle this shape's text
90         if( pOutlinerParaObject )
91         {
92             // non-empty text -> use full-fledged edit source right away
93             ::std::auto_ptr<SvxEditSource> pEditSource( new SvxTextEditSource( mxCell->GetObject(), mxCell.get(), *pView, *pWindow) );
94             mpText = new AccessibleTextHelper( pEditSource );
95 			mpText->SetEventSource(this);
96         }
97 
98         if( bOwnParaObject)
99             delete pOutlinerParaObject;
100     }
101 }
102 
103 // --------------------------------------------------------------------
104 
SetState(sal_Int16 aState)105 sal_Bool AccessibleCell::SetState (sal_Int16 aState)
106 {
107     sal_Bool bStateHasChanged = sal_False;
108 
109     if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
110     {
111         // Offer FOCUSED state to edit engine and detect whether the state
112         // changes.
113         sal_Bool bIsFocused = mpText->HaveFocus ();
114         mpText->SetFocus (sal_True);
115         bStateHasChanged = (bIsFocused != mpText->HaveFocus ());
116     }
117     else
118         bStateHasChanged = AccessibleContextBase::SetState (aState);
119 
120     return bStateHasChanged;
121 }
122 
123 // --------------------------------------------------------------------
124 
ResetState(sal_Int16 aState)125 sal_Bool AccessibleCell::ResetState (sal_Int16 aState)
126 {
127     sal_Bool bStateHasChanged = sal_False;
128 
129     if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
130     {
131         // Try to remove FOCUSED state from the edit engine and detect
132         // whether the state changes.
133         sal_Bool bIsFocused = mpText->HaveFocus ();
134         mpText->SetFocus (sal_False);
135         bStateHasChanged = (bIsFocused != mpText->HaveFocus ());
136     }
137     else
138         bStateHasChanged = AccessibleContextBase::ResetState (aState);
139 
140     return bStateHasChanged;
141 }
142 
143 // --------------------------------------------------------------------
144 
GetState(sal_Int16 aState)145 sal_Bool AccessibleCell::GetState (sal_Int16 aState)
146 {
147     if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
148     {
149         // Just delegate the call to the edit engine.  The state is not
150         // merged into the state set.
151         return mpText->HaveFocus();
152     }
153     else
154         return AccessibleContextBase::GetState (aState);
155 }
156 
157 //-----------------------------------------------------------------------------
158 
operator ==(const AccessibleCell & rAccessibleCell)159 bool AccessibleCell::operator== (const AccessibleCell& rAccessibleCell)
160 {
161 	return this == &rAccessibleCell;
162 }
163 
164 //-----------------------------------------------------------------------------
165 // XInterface
166 //-----------------------------------------------------------------------------
167 
queryInterface(const Type & aType)168 Any SAL_CALL AccessibleCell::queryInterface( const Type& aType ) throw (RuntimeException)
169 {
170 	return AccessibleCellBase::queryInterface( aType );
171 }
172 
173 //-----------------------------------------------------------------------------
174 
acquire()175 void SAL_CALL AccessibleCell::acquire(  ) throw ()
176 {
177 	AccessibleCellBase::acquire();
178 }
179 
180 //-----------------------------------------------------------------------------
181 
release()182 void SAL_CALL AccessibleCell::release(  ) throw ()
183 {
184 	AccessibleCellBase::release();
185 }
186 
187 // --------------------------------------------------------------------
188 // XAccessibleContext
189 // --------------------------------------------------------------------
190 
191 /** The children of this cell come from the paragraphs of text.
192 */
getAccessibleChildCount()193 sal_Int32 SAL_CALL AccessibleCell::getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException)
194 {
195     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
196     ThrowIfDisposed ();
197 	return mpText != NULL ? mpText->GetChildCount () : 0;
198 }
199 
200 // --------------------------------------------------------------------
201 
202 /** Forward the request to the shape.  Return the requested shape or throw
203     an exception for a wrong index.
204 */
getAccessibleChild(sal_Int32 nIndex)205 Reference<XAccessible> SAL_CALL AccessibleCell::getAccessibleChild (sal_Int32 nIndex) throw (IndexOutOfBoundsException, RuntimeException)
206 {
207     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
208     ThrowIfDisposed ();
209 
210 	// todo: does GetChild throw IndexOutOfBoundsException?
211 	return mpText->GetChild (nIndex);
212 }
213 
214 // --------------------------------------------------------------------
215 
216 /**	Return a copy of the state set.
217     Possible states are:
218 		ENABLED
219 		SHOWING
220 		VISIBLE
221 */
getAccessibleStateSet(void)222 Reference<XAccessibleStateSet> SAL_CALL AccessibleCell::getAccessibleStateSet (void) throw (RuntimeException)
223 {
224     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
225     ::osl::MutexGuard aGuard (maMutex);
226     Reference<XAccessibleStateSet> xStateSet;
227 
228 	if (rBHelper.bDisposed || mpText == NULL)
229 	{
230         // Return a minimal state set that only contains the DEFUNC state.
231         xStateSet = AccessibleContextBase::getAccessibleStateSet ();
232 	}
233     else
234     {
235         ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
236 
237         if(pStateSet)
238         {
239             // Merge current FOCUSED state from edit engine.
240             if (mpText != NULL)
241 			{
242 				if (mpText->HaveFocus())
243                     pStateSet->AddState (AccessibleStateType::FOCUSED);
244                 else
245                     pStateSet->RemoveState (AccessibleStateType::FOCUSED);
246 			}
247 			// Set the invisible state for merged cell
248 			if (mxCell.is() && mxCell->isMerged())
249 				pStateSet->RemoveState(AccessibleStateType::VISIBLE);
250 			else
251 				pStateSet->AddState(AccessibleStateType::VISIBLE);
252 
253 
254 			//Solution:Just when the parent table is not read-only,set states EDITABLE,RESIZABLE,MOVEABLE
255 		    ::com::sun::star::uno::Reference<XAccessible> xTempAcc = getAccessibleParent();
256 		    if( xTempAcc.is() )
257 		    {
258 		    	::com::sun::star::uno::Reference<XAccessibleContext>
259 		    							xTempAccContext = xTempAcc->getAccessibleContext();
260 		    	if( xTempAccContext.is() )
261 		    	{
262 		    		::com::sun::star::uno::Reference<XAccessibleStateSet> rState =
263 		    			xTempAccContext->getAccessibleStateSet();
264 		    		if( rState.is() )    		{
265 						com::sun::star::uno::Sequence<short> pStates = rState->getStates();
266 						int count = pStates.getLength();
267 						for( int iIndex = 0;iIndex < count;iIndex++ )
268 						{
269 							if( pStates[iIndex] == AccessibleStateType::EDITABLE )
270 							{
271 								pStateSet->AddState (AccessibleStateType::EDITABLE);
272 							    pStateSet->AddState (AccessibleStateType::RESIZABLE);
273 							    pStateSet->AddState (AccessibleStateType::MOVEABLE);
274 								break;
275 							}
276 						}
277 					}
278 				}
279 		    }
280             // Create a copy of the state set that may be modified by the
281             // caller without affecting the current state set.
282             xStateSet = Reference<XAccessibleStateSet>(new ::utl::AccessibleStateSetHelper (*pStateSet));
283         }
284     }
285 
286     return xStateSet;
287 }
288 
289 // --------------------------------------------------------------------
290 // XAccessibleComponent
291 // --------------------------------------------------------------------
292 
containsPoint(const::com::sun::star::awt::Point & aPoint)293 sal_Bool SAL_CALL AccessibleCell::containsPoint( const ::com::sun::star::awt::Point& aPoint) throw (::com::sun::star::uno::RuntimeException)
294 {
295 	return AccessibleComponentBase::containsPoint( aPoint );
296 }
297 
298 /** The implementation below is at the moment straightforward.  It iterates
299     over all children (and thereby instances all children which have not
300     been already instatiated) until a child covering the specifed point is
301     found.
302     This leaves room for improvement.  For instance, first iterate only over
303     the already instantiated children and only if no match is found
304     instantiate the remaining ones.
305 */
getAccessibleAtPoint(const::com::sun::star::awt::Point & aPoint)306 Reference<XAccessible > SAL_CALL  AccessibleCell::getAccessibleAtPoint ( const ::com::sun::star::awt::Point& aPoint) throw(RuntimeException)
307 {
308     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
309     ::osl::MutexGuard aGuard (maMutex);
310 
311     sal_Int32 nChildCount = getAccessibleChildCount ();
312     for (sal_Int32 i=0; i<nChildCount; ++i)
313     {
314         Reference<XAccessible> xChild (getAccessibleChild (i));
315         if (xChild.is())
316         {
317             Reference<XAccessibleComponent> xChildComponent (xChild->getAccessibleContext(), uno::UNO_QUERY);
318             if (xChildComponent.is())
319             {
320                 awt::Rectangle aBBox (xChildComponent->getBounds());
321                 if ( (aPoint.X >= aBBox.X)
322                     && (aPoint.Y >= aBBox.Y)
323                     && (aPoint.X < aBBox.X+aBBox.Width)
324                     && (aPoint.Y < aBBox.Y+aBBox.Height) )
325                     return xChild;
326             }
327         }
328     }
329 
330     // Have not found a child under the given point.  Returning empty
331     // reference to indicate this.
332     return uno::Reference<XAccessible>();
333 }
334 
335 // --------------------------------------------------------------------
336 
getBounds(void)337 ::com::sun::star::awt::Rectangle SAL_CALL AccessibleCell::getBounds(void) throw(RuntimeException)
338 {
339     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
340     ::osl::MutexGuard aGuard (maMutex);
341 
342     ThrowIfDisposed ();
343 	::com::sun::star::awt::Rectangle aBoundingBox;
344 	if( mxCell.is() )
345 	{
346 		// Get the cell's bounding box in internal coordinates (in 100th of mm)
347 		const ::Rectangle aCellRect( mxCell->getCellRect() );
348 
349 		// Transform coordinates from internal to pixel.
350 		if (maShapeTreeInfo.GetViewForwarder() == NULL)
351 			throw uno::RuntimeException (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleCell has no valid view forwarder")),static_cast<uno::XWeak*>(this));
352 
353 		::Size aPixelSize( maShapeTreeInfo.GetViewForwarder()->LogicToPixel(::Size(aCellRect.GetWidth(), aCellRect.GetHeight())) );
354 		::Point aPixelPosition( maShapeTreeInfo.GetViewForwarder()->LogicToPixel( aCellRect.TopLeft() ));
355 
356 		// Clip the shape's bounding box with the bounding box of its parent.
357 		Reference<XAccessibleComponent> xParentComponent ( getAccessibleParent(), uno::UNO_QUERY);
358 		if (xParentComponent.is())
359 		{
360 			// Make the coordinates relative to the parent.
361 			awt::Point aParentLocation (xParentComponent->getLocationOnScreen());
362 			int x = aPixelPosition.getX() - aParentLocation.X;
363 			int y = aPixelPosition.getY() - aParentLocation.Y;
364 
365 			// Clip with parent (with coordinates relative to itself).
366 			::Rectangle aBBox ( x, y, x + aPixelSize.getWidth(), y + aPixelSize.getHeight());
367 			awt::Size aParentSize (xParentComponent->getSize());
368 			::Rectangle aParentBBox (0,0, aParentSize.Width, aParentSize.Height);
369 			aBBox = aBBox.GetIntersection (aParentBBox);
370 			aBoundingBox = awt::Rectangle (	aBBox.getX(), aBBox.getY(), aBBox.getWidth(), aBBox.getHeight());
371 		}
372 		else
373 		{
374 			OSL_TRACE ("parent does not support component");
375 			aBoundingBox = awt::Rectangle (aPixelPosition.getX(), aPixelPosition.getY(),aPixelSize.getWidth(), aPixelSize.getHeight());
376 		}
377 	}
378 
379     return aBoundingBox;
380 }
381 
382 // --------------------------------------------------------------------
383 
getLocation(void)384 ::com::sun::star::awt::Point SAL_CALL AccessibleCell::getLocation(void) throw (RuntimeException)
385 {
386     ThrowIfDisposed ();
387 	::com::sun::star::awt::Rectangle aBoundingBox(getBounds());
388     return ::com::sun::star::awt::Point(aBoundingBox.X, aBoundingBox.Y);
389 }
390 
391 // --------------------------------------------------------------------
392 
getLocationOnScreen(void)393 ::com::sun::star::awt::Point SAL_CALL AccessibleCell::getLocationOnScreen(void) throw(RuntimeException)
394 {
395     ThrowIfDisposed ();
396 
397     // Get relative position...
398     ::com::sun::star::awt::Point aLocation(getLocation ());
399 
400     // ... and add absolute position of the parent.
401     Reference<XAccessibleComponent> xParentComponent( getAccessibleParent(), uno::UNO_QUERY);
402     if(xParentComponent.is())
403     {
404         ::com::sun::star::awt::Point aParentLocation(xParentComponent->getLocationOnScreen());
405         aLocation.X += aParentLocation.X;
406         aLocation.Y += aParentLocation.Y;
407     }
408     else
409 	{
410         OSL_TRACE ("getLocation: parent does not support XAccessibleComponent");
411 	}
412 
413 	return aLocation;
414 }
415 
416 // --------------------------------------------------------------------
417 
getSize(void)418 awt::Size SAL_CALL AccessibleCell::getSize (void) throw (RuntimeException)
419 {
420     ThrowIfDisposed ();
421     awt::Rectangle aBoundingBox (getBounds());
422     return awt::Size (aBoundingBox.Width, aBoundingBox.Height);
423 }
424 
425 // --------------------------------------------------------------------
426 
addFocusListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XFocusListener> & xListener)427 void SAL_CALL AccessibleCell::addFocusListener ( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener) throw (::com::sun::star::uno::RuntimeException)
428 {
429 	AccessibleComponentBase::addFocusListener( xListener );
430 }
431 
432 // --------------------------------------------------------------------
433 
removeFocusListener(const::com::sun::star::uno::Reference<::com::sun::star::awt::XFocusListener> & xListener)434 void SAL_CALL AccessibleCell::removeFocusListener (const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
435 {
436 	AccessibleComponentBase::removeFocusListener( xListener );
437 }
438 
439 // --------------------------------------------------------------------
440 
grabFocus(void)441 void SAL_CALL AccessibleCell::grabFocus (void) throw (::com::sun::star::uno::RuntimeException)
442 {
443 	AccessibleComponentBase::grabFocus();
444 }
445 
446 // --------------------------------------------------------------------
447 
getForeground(void)448 sal_Int32 SAL_CALL AccessibleCell::getForeground(void) throw (RuntimeException)
449 {
450     ThrowIfDisposed ();
451     sal_Int32 nColor (0x0ffffffL);
452 
453 	// todo
454     return nColor;
455 }
456 
457 // --------------------------------------------------------------------
458 
getBackground(void)459 sal_Int32 SAL_CALL AccessibleCell::getBackground (void) throw (RuntimeException)
460 {
461     ThrowIfDisposed ();
462     sal_Int32 nColor (0L);
463 
464 	// todo
465     return nColor;
466 }
467 
468 // --------------------------------------------------------------------
469 // XAccessibleExtendedComponent
470 // --------------------------------------------------------------------
471 
getFont(void)472 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL AccessibleCell::getFont (void) throw (::com::sun::star::uno::RuntimeException)
473 {
474 //todo
475 	return AccessibleComponentBase::getFont();
476 }
477 
478 // --------------------------------------------------------------------
479 
getTitledBorderText(void)480 ::rtl::OUString SAL_CALL AccessibleCell::getTitledBorderText (void) throw (::com::sun::star::uno::RuntimeException)
481 {
482 	return AccessibleComponentBase::getTitledBorderText();
483 }
484 
485 // --------------------------------------------------------------------
486 
getToolTipText(void)487 ::rtl::OUString SAL_CALL AccessibleCell::getToolTipText (void) throw (::com::sun::star::uno::RuntimeException)
488 {
489 	return AccessibleComponentBase::getToolTipText();
490 }
491 
492 // --------------------------------------------------------------------
493 // XAccessibleEventBroadcaster
494 // --------------------------------------------------------------------
495 
addEventListener(const Reference<XAccessibleEventListener> & rxListener)496 void SAL_CALL AccessibleCell::addEventListener( const Reference<XAccessibleEventListener >& rxListener)  throw (RuntimeException)
497 {
498     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
499     ::osl::MutexGuard aGuard (maMutex);
500 	if (rBHelper.bDisposed || rBHelper.bInDispose)
501 	{
502 		Reference<XInterface> xSource( static_cast<XComponent *>(this) );
503 		lang::EventObject aEventObj(xSource);
504 		rxListener->disposing(aEventObj);
505 	}
506     else
507     {
508         AccessibleContextBase::addEventListener (rxListener);
509         if (mpText != NULL)
510             mpText->AddEventListener (rxListener);
511     }
512 }
513 
514 // --------------------------------------------------------------------
515 
removeEventListener(const Reference<XAccessibleEventListener> & rxListener)516 void SAL_CALL AccessibleCell::removeEventListener( const Reference<XAccessibleEventListener >& rxListener) throw (RuntimeException)
517 {
518     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
519     AccessibleContextBase::removeEventListener(rxListener);
520     if (mpText != NULL)
521         mpText->RemoveEventListener (rxListener);
522 }
523 
524 // --------------------------------------------------------------------
525 // XServiceInfo
526 // --------------------------------------------------------------------
527 
getImplementationName(void)528 OUString SAL_CALL AccessibleCell::getImplementationName(void) throw (RuntimeException)
529 {
530 	return OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleCell"));
531 }
532 
533 // --------------------------------------------------------------------
534 
getSupportedServiceNames(void)535 Sequence<OUString> SAL_CALL AccessibleCell::getSupportedServiceNames(void) throw (RuntimeException)
536 {
537     ThrowIfDisposed ();
538 
539 	// Get list of supported service names from base class...
540     uno::Sequence<OUString> aServiceNames = AccessibleContextBase::getSupportedServiceNames();
541     sal_Int32 nCount (aServiceNames.getLength());
542 
543     // ...and add additional names.
544     aServiceNames.realloc (nCount + 1);
545     static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.AccessibleCell"));
546     aServiceNames[nCount] = sAdditionalServiceName;
547 
548     return aServiceNames;
549 }
550 
551 // --------------------------------------------------------------------
552 // IAccessibleViewForwarderListener
553 // --------------------------------------------------------------------
554 
ViewForwarderChanged(ChangeType,const IAccessibleViewForwarder *)555 void AccessibleCell::ViewForwarderChanged (ChangeType /*aChangeType*/, const IAccessibleViewForwarder* /*pViewForwarder*/)
556 {
557     // Inform all listeners that the graphical representation (i.e. size
558     // and/or position) of the shape has changed.
559     CommitChange(AccessibleEventId::VISIBLE_DATA_CHANGED, Any(), Any());
560 
561     // update our children that our screen position might have changed
562     if( mpText )
563         mpText->UpdateChildren();
564 }
565 
566 // --------------------------------------------------------------------
567 // protected
568 // --------------------------------------------------------------------
569 
disposing(void)570 void AccessibleCell::disposing (void)
571 {
572     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
573     ::osl::MutexGuard aGuard (maMutex);
574 
575     // Make sure to send an event that this object looses the focus in the
576     // case that it has the focus.
577     ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
578     if (pStateSet != NULL)
579         pStateSet->RemoveState(AccessibleStateType::FOCUSED);
580 
581     if (mpText != NULL)
582     {
583         mpText->Dispose();
584         delete mpText;
585         mpText = NULL;
586     }
587 
588     // Cleanup.  Remove references to objects to allow them to be
589     // destroyed.
590     mxCell.clear();
591     maShapeTreeInfo = AccessibleShapeTreeInfo();
592 
593     // Call base classes.
594     AccessibleContextBase::dispose ();
595 }
596 
getAccessibleIndexInParent(void)597 sal_Int32 SAL_CALL AccessibleCell::getAccessibleIndexInParent (void) throw (RuntimeException)
598 {
599     ThrowIfDisposed ();
600     return mnIndexInParent;
601 }
602 
getCellRef()603 sdr::table::CellRef AccessibleCell::getCellRef()
604 {
605 	return mxCell;
606 }
getCellName(sal_Int32 nCol,sal_Int32 nRow)607 ::rtl::OUString AccessibleCell::getCellName( sal_Int32 nCol, sal_Int32 nRow )
608 {
609     rtl::OUStringBuffer aBuf;
610 
611     if (nCol < 26*26)
612     {
613         if (nCol < 26)
614             aBuf.append( static_cast<sal_Unicode>( 'A' +
615                         static_cast<sal_uInt16>(nCol)));
616         else
617         {
618             aBuf.append( static_cast<sal_Unicode>( 'A' +
619                         (static_cast<sal_uInt16>(nCol) / 26) - 1));
620             aBuf.append( static_cast<sal_Unicode>( 'A' +
621                         (static_cast<sal_uInt16>(nCol) % 26)));
622         }
623     }
624     else
625     {
626         String aStr;
627         while (nCol >= 26)
628         {
629             sal_Int32 nC = nCol % 26;
630             aStr += static_cast<sal_Unicode>( 'A' +
631                     static_cast<sal_uInt16>(nC));
632             nCol = nCol - nC;
633             nCol = nCol / 26 - 1;
634         }
635         aStr += static_cast<sal_Unicode>( 'A' +
636                 static_cast<sal_uInt16>(nCol));
637         aStr.Reverse();
638         aBuf.append( aStr);
639     }
640     aBuf.append( OUString::valueOf(nRow+1) );
641     return aBuf.makeStringAndClear();
642 }
getAccessibleName(void)643 ::rtl::OUString SAL_CALL AccessibleCell::getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException)
644 {
645     ThrowIfDisposed ();
646     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
647 
648     if( pAccTable )
649 	try
650     {
651         sal_Int32 nRow = 0, nCol = 0;
652         pAccTable->getColumnAndRow(mnIndexInParent, nCol, nRow);
653         return getCellName( nCol, nRow );
654     }
655     catch( Exception& )
656     {
657     }
658 
659     return AccessibleCellBase::getAccessibleName();
660 }
UpdateChildren()661 void AccessibleCell::UpdateChildren()
662 {
663 	if (mpText)
664 		mpText->UpdateChildren();
665 }
666 
667 /* MT: Above getAccessibleName was introduced with IA2 CWS, while below was introduce in 3.3 meanwhile. Check which one is correct
668 If this is correct, we also don't need 	sdr::table::CellRef getCellRef(), UpdateChildren(), getCellName( sal_Int32 nCol, sal_Int32 nRow ) above
669 
670 ::rtl::OUString SAL_CALL AccessibleCell::getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException)
671 {
672     ThrowIfDisposed ();
673     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
674 
675     if( mxCell.is() )
676         return mxCell->getName();
677 
678     return AccessibleCellBase::getAccessibleName();
679 }
680 */
681 
682 } // end of namespace accessibility
683