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 
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 
69 AccessibleCell::~AccessibleCell (void)
70 {
71 	DBG_ASSERT( mpText == 0, "svx::AccessibleCell::~AccessibleCell(), not disposed!?" );
72 }
73 
74 // --------------------------------------------------------------------
75 
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 
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 
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 
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 
159 bool AccessibleCell::operator== (const AccessibleCell& rAccessibleCell)
160 {
161 	return this == &rAccessibleCell;
162 }
163 
164 //-----------------------------------------------------------------------------
165 // XInterface
166 //-----------------------------------------------------------------------------
167 
168 Any SAL_CALL AccessibleCell::queryInterface( const Type& aType ) throw (RuntimeException)
169 {
170 	return AccessibleCellBase::queryInterface( aType );
171 }
172 
173 //-----------------------------------------------------------------------------
174 
175 void SAL_CALL AccessibleCell::acquire(  ) throw ()
176 {
177 	AccessibleCellBase::acquire();
178 }
179 
180 //-----------------------------------------------------------------------------
181 
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 */
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 */
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 */
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 			//Sym2_6167, IAccessibility2 Implementation 2009-----
255 			//Solution:Just when the parent table is not read-only,set states EDITABLE,RESIZABLE,MOVEABLE
256 		    ::com::sun::star::uno::Reference<XAccessible> xTempAcc = getAccessibleParent();
257 		    if( xTempAcc.is() )
258 		    {
259 		    	::com::sun::star::uno::Reference<XAccessibleContext>
260 		    							xTempAccContext = xTempAcc->getAccessibleContext();
261 		    	if( xTempAccContext.is() )
262 		    	{
263 		    		::com::sun::star::uno::Reference<XAccessibleStateSet> rState =
264 		    			xTempAccContext->getAccessibleStateSet();
265 		    		if( rState.is() )    		{
266 						com::sun::star::uno::Sequence<short> pStates = rState->getStates();
267 						int count = pStates.getLength();
268 						for( int iIndex = 0;iIndex < count;iIndex++ )
269 						{
270 							if( pStates[iIndex] == AccessibleStateType::EDITABLE )
271 							{
272 								pStateSet->AddState (AccessibleStateType::EDITABLE);
273 							    pStateSet->AddState (AccessibleStateType::RESIZABLE);
274 							    pStateSet->AddState (AccessibleStateType::MOVEABLE);
275 								break;
276 							}
277 						}
278 					}
279 				}
280 		    }
281 			//-----IAccessibility2 Implementation 2009
282             // Create a copy of the state set that may be modified by the
283             // caller without affecting the current state set.
284             xStateSet = Reference<XAccessibleStateSet>(new ::utl::AccessibleStateSetHelper (*pStateSet));
285         }
286     }
287 
288     return xStateSet;
289 }
290 
291 // --------------------------------------------------------------------
292 // XAccessibleComponent
293 // --------------------------------------------------------------------
294 
295 sal_Bool SAL_CALL AccessibleCell::containsPoint( const ::com::sun::star::awt::Point& aPoint) throw (::com::sun::star::uno::RuntimeException)
296 {
297 	return AccessibleComponentBase::containsPoint( aPoint );
298 }
299 
300 /** The implementation below is at the moment straightforward.  It iterates
301     over all children (and thereby instances all children which have not
302     been already instatiated) until a child covering the specifed point is
303     found.
304     This leaves room for improvement.  For instance, first iterate only over
305     the already instantiated children and only if no match is found
306     instantiate the remaining ones.
307 */
308 Reference<XAccessible > SAL_CALL  AccessibleCell::getAccessibleAtPoint ( const ::com::sun::star::awt::Point& aPoint) throw(RuntimeException)
309 {
310     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
311     ::osl::MutexGuard aGuard (maMutex);
312 
313     sal_Int32 nChildCount = getAccessibleChildCount ();
314     for (sal_Int32 i=0; i<nChildCount; ++i)
315     {
316         Reference<XAccessible> xChild (getAccessibleChild (i));
317         if (xChild.is())
318         {
319             Reference<XAccessibleComponent> xChildComponent (xChild->getAccessibleContext(), uno::UNO_QUERY);
320             if (xChildComponent.is())
321             {
322                 awt::Rectangle aBBox (xChildComponent->getBounds());
323                 if ( (aPoint.X >= aBBox.X)
324                     && (aPoint.Y >= aBBox.Y)
325                     && (aPoint.X < aBBox.X+aBBox.Width)
326                     && (aPoint.Y < aBBox.Y+aBBox.Height) )
327                     return xChild;
328             }
329         }
330     }
331 
332     // Have not found a child under the given point.  Returning empty
333     // reference to indicate this.
334     return uno::Reference<XAccessible>();
335 }
336 
337 // --------------------------------------------------------------------
338 
339 ::com::sun::star::awt::Rectangle SAL_CALL AccessibleCell::getBounds(void) throw(RuntimeException)
340 {
341     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
342     ::osl::MutexGuard aGuard (maMutex);
343 
344     ThrowIfDisposed ();
345 	::com::sun::star::awt::Rectangle aBoundingBox;
346 	if( mxCell.is() )
347 	{
348 		// Get the cell's bounding box in internal coordinates (in 100th of mm)
349 		const ::Rectangle aCellRect( mxCell->getCellRect() );
350 
351 		// Transform coordinates from internal to pixel.
352 		if (maShapeTreeInfo.GetViewForwarder() == NULL)
353 			throw uno::RuntimeException (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleCell has no valid view forwarder")),static_cast<uno::XWeak*>(this));
354 
355 		::Size aPixelSize( maShapeTreeInfo.GetViewForwarder()->LogicToPixel(::Size(aCellRect.GetWidth(), aCellRect.GetHeight())) );
356 		::Point aPixelPosition( maShapeTreeInfo.GetViewForwarder()->LogicToPixel( aCellRect.TopLeft() ));
357 
358 		// Clip the shape's bounding box with the bounding box of its parent.
359 		Reference<XAccessibleComponent> xParentComponent ( getAccessibleParent(), uno::UNO_QUERY);
360 		if (xParentComponent.is())
361 		{
362 			// Make the coordinates relative to the parent.
363 			awt::Point aParentLocation (xParentComponent->getLocationOnScreen());
364 			int x = aPixelPosition.getX() - aParentLocation.X;
365 			int y = aPixelPosition.getY() - aParentLocation.Y;
366 
367 			// Clip with parent (with coordinates relative to itself).
368 			::Rectangle aBBox ( x, y, x + aPixelSize.getWidth(), y + aPixelSize.getHeight());
369 			awt::Size aParentSize (xParentComponent->getSize());
370 			::Rectangle aParentBBox (0,0, aParentSize.Width, aParentSize.Height);
371 			aBBox = aBBox.GetIntersection (aParentBBox);
372 			aBoundingBox = awt::Rectangle (	aBBox.getX(), aBBox.getY(), aBBox.getWidth(), aBBox.getHeight());
373 		}
374 		else
375 		{
376 			OSL_TRACE ("parent does not support component");
377 			aBoundingBox = awt::Rectangle (aPixelPosition.getX(), aPixelPosition.getY(),aPixelSize.getWidth(), aPixelSize.getHeight());
378 		}
379 	}
380 
381     return aBoundingBox;
382 }
383 
384 // --------------------------------------------------------------------
385 
386 ::com::sun::star::awt::Point SAL_CALL AccessibleCell::getLocation(void) throw (RuntimeException)
387 {
388     ThrowIfDisposed ();
389 	::com::sun::star::awt::Rectangle aBoundingBox(getBounds());
390     return ::com::sun::star::awt::Point(aBoundingBox.X, aBoundingBox.Y);
391 }
392 
393 // --------------------------------------------------------------------
394 
395 ::com::sun::star::awt::Point SAL_CALL AccessibleCell::getLocationOnScreen(void) throw(RuntimeException)
396 {
397     ThrowIfDisposed ();
398 
399     // Get relative position...
400     ::com::sun::star::awt::Point aLocation(getLocation ());
401 
402     // ... and add absolute position of the parent.
403     Reference<XAccessibleComponent> xParentComponent( getAccessibleParent(), uno::UNO_QUERY);
404     if(xParentComponent.is())
405     {
406         ::com::sun::star::awt::Point aParentLocation(xParentComponent->getLocationOnScreen());
407         aLocation.X += aParentLocation.X;
408         aLocation.Y += aParentLocation.Y;
409     }
410     else
411 	{
412         OSL_TRACE ("getLocation: parent does not support XAccessibleComponent");
413 	}
414 
415 	return aLocation;
416 }
417 
418 // --------------------------------------------------------------------
419 
420 awt::Size SAL_CALL AccessibleCell::getSize (void) throw (RuntimeException)
421 {
422     ThrowIfDisposed ();
423     awt::Rectangle aBoundingBox (getBounds());
424     return awt::Size (aBoundingBox.Width, aBoundingBox.Height);
425 }
426 
427 // --------------------------------------------------------------------
428 
429 void SAL_CALL AccessibleCell::addFocusListener ( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener) throw (::com::sun::star::uno::RuntimeException)
430 {
431 	AccessibleComponentBase::addFocusListener( xListener );
432 }
433 
434 // --------------------------------------------------------------------
435 
436 void SAL_CALL AccessibleCell::removeFocusListener (const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
437 {
438 	AccessibleComponentBase::removeFocusListener( xListener );
439 }
440 
441 // --------------------------------------------------------------------
442 
443 void SAL_CALL AccessibleCell::grabFocus (void) throw (::com::sun::star::uno::RuntimeException)
444 {
445 	AccessibleComponentBase::grabFocus();
446 }
447 
448 // --------------------------------------------------------------------
449 
450 sal_Int32 SAL_CALL AccessibleCell::getForeground(void) throw (RuntimeException)
451 {
452     ThrowIfDisposed ();
453     sal_Int32 nColor (0x0ffffffL);
454 
455 	// todo
456     return nColor;
457 }
458 
459 // --------------------------------------------------------------------
460 
461 sal_Int32 SAL_CALL AccessibleCell::getBackground (void) throw (RuntimeException)
462 {
463     ThrowIfDisposed ();
464     sal_Int32 nColor (0L);
465 
466 	// todo
467     return nColor;
468 }
469 
470 // --------------------------------------------------------------------
471 // XAccessibleExtendedComponent
472 // --------------------------------------------------------------------
473 
474 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL AccessibleCell::getFont (void) throw (::com::sun::star::uno::RuntimeException)
475 {
476 //todo
477 	return AccessibleComponentBase::getFont();
478 }
479 
480 // --------------------------------------------------------------------
481 
482 ::rtl::OUString SAL_CALL AccessibleCell::getTitledBorderText (void) throw (::com::sun::star::uno::RuntimeException)
483 {
484 	return AccessibleComponentBase::getTitledBorderText();
485 }
486 
487 // --------------------------------------------------------------------
488 
489 ::rtl::OUString SAL_CALL AccessibleCell::getToolTipText (void) throw (::com::sun::star::uno::RuntimeException)
490 {
491 	return AccessibleComponentBase::getToolTipText();
492 }
493 
494 // --------------------------------------------------------------------
495 // XAccessibleEventBroadcaster
496 // --------------------------------------------------------------------
497 
498 void SAL_CALL AccessibleCell::addEventListener( const Reference<XAccessibleEventListener >& rxListener)  throw (RuntimeException)
499 {
500     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
501     ::osl::MutexGuard aGuard (maMutex);
502 	if (rBHelper.bDisposed || rBHelper.bInDispose)
503 	{
504 		Reference<XInterface> xSource( static_cast<XComponent *>(this) );
505 		lang::EventObject aEventObj(xSource);
506 		rxListener->disposing(aEventObj);
507 	}
508     else
509     {
510         AccessibleContextBase::addEventListener (rxListener);
511         if (mpText != NULL)
512             mpText->AddEventListener (rxListener);
513     }
514 }
515 
516 // --------------------------------------------------------------------
517 
518 void SAL_CALL AccessibleCell::removeEventListener( const Reference<XAccessibleEventListener >& rxListener) throw (RuntimeException)
519 {
520     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
521     AccessibleContextBase::removeEventListener(rxListener);
522     if (mpText != NULL)
523         mpText->RemoveEventListener (rxListener);
524 }
525 
526 // --------------------------------------------------------------------
527 // XServiceInfo
528 // --------------------------------------------------------------------
529 
530 OUString SAL_CALL AccessibleCell::getImplementationName(void) throw (RuntimeException)
531 {
532 	return OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleCell"));
533 }
534 
535 // --------------------------------------------------------------------
536 
537 Sequence<OUString> SAL_CALL AccessibleCell::getSupportedServiceNames(void) throw (RuntimeException)
538 {
539     ThrowIfDisposed ();
540 
541 	// Get list of supported service names from base class...
542     uno::Sequence<OUString> aServiceNames = AccessibleContextBase::getSupportedServiceNames();
543     sal_Int32 nCount (aServiceNames.getLength());
544 
545     // ...and add additional names.
546     aServiceNames.realloc (nCount + 1);
547     static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.AccessibleCell"));
548     aServiceNames[nCount] = sAdditionalServiceName;
549 
550     return aServiceNames;
551 }
552 
553 // --------------------------------------------------------------------
554 // IAccessibleViewForwarderListener
555 // --------------------------------------------------------------------
556 
557 void AccessibleCell::ViewForwarderChanged (ChangeType /*aChangeType*/, const IAccessibleViewForwarder* /*pViewForwarder*/)
558 {
559     // Inform all listeners that the graphical representation (i.e. size
560     // and/or position) of the shape has changed.
561     CommitChange(AccessibleEventId::VISIBLE_DATA_CHANGED, Any(), Any());
562 
563     // update our children that our screen position might have changed
564     if( mpText )
565         mpText->UpdateChildren();
566 }
567 
568 // --------------------------------------------------------------------
569 // protected
570 // --------------------------------------------------------------------
571 
572 void AccessibleCell::disposing (void)
573 {
574     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
575     ::osl::MutexGuard aGuard (maMutex);
576 
577     // Make sure to send an event that this object looses the focus in the
578     // case that it has the focus.
579     ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
580     if (pStateSet != NULL)
581         pStateSet->RemoveState(AccessibleStateType::FOCUSED);
582 
583     if (mpText != NULL)
584     {
585         mpText->Dispose();
586         delete mpText;
587         mpText = NULL;
588     }
589 
590     // Cleanup.  Remove references to objects to allow them to be
591     // destroyed.
592     mxCell.clear();
593     maShapeTreeInfo = AccessibleShapeTreeInfo();
594 
595     // Call base classes.
596     AccessibleContextBase::dispose ();
597 }
598 
599 sal_Int32 SAL_CALL AccessibleCell::getAccessibleIndexInParent (void) throw (RuntimeException)
600 {
601     ThrowIfDisposed ();
602     return mnIndexInParent;
603 }
604 
605 // SD table ACC----, added by Steve Yin
606 sdr::table::CellRef AccessibleCell::getCellRef()
607 {
608 	return mxCell;
609 }
610 ::rtl::OUString AccessibleCell::getCellName( sal_Int32 nCol, sal_Int32 nRow )
611 {
612     rtl::OUStringBuffer aBuf;
613 
614     if (nCol < 26*26)
615     {
616         if (nCol < 26)
617             aBuf.append( static_cast<sal_Unicode>( 'A' +
618                         static_cast<sal_uInt16>(nCol)));
619         else
620         {
621             aBuf.append( static_cast<sal_Unicode>( 'A' +
622                         (static_cast<sal_uInt16>(nCol) / 26) - 1));
623             aBuf.append( static_cast<sal_Unicode>( 'A' +
624                         (static_cast<sal_uInt16>(nCol) % 26)));
625         }
626     }
627     else
628     {
629         String aStr;
630         while (nCol >= 26)
631         {
632             sal_Int32 nC = nCol % 26;
633             aStr += static_cast<sal_Unicode>( 'A' +
634                     static_cast<sal_uInt16>(nC));
635             nCol = nCol - nC;
636             nCol = nCol / 26 - 1;
637         }
638         aStr += static_cast<sal_Unicode>( 'A' +
639                 static_cast<sal_uInt16>(nCol));
640         aStr.Reverse();
641         aBuf.append( aStr);
642     }
643     aBuf.append( OUString::valueOf(nRow+1) );
644     return aBuf.makeStringAndClear();
645 }
646 ::rtl::OUString SAL_CALL AccessibleCell::getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException)
647 {
648     ThrowIfDisposed ();
649     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
650 
651     if( pAccTable )
652 	try
653     {
654         sal_Int32 nRow = 0, nCol = 0;
655         pAccTable->getColumnAndRow(mnIndexInParent, nCol, nRow);
656         return getCellName( nCol, nRow );
657     }
658     catch( Exception& )
659     {
660     }
661 
662     return AccessibleCellBase::getAccessibleName();
663 }
664 void AccessibleCell::UpdateChildren()
665 {
666 	if (mpText)
667 		mpText->UpdateChildren();
668 }
669 // ----SD table ACC
670 
671 /* MT: Above getAccessibleName was introduced with IA2 CWS, while below was introduce in 3.3 meanwhile. Check which one is correct
672 If this is correct, we also don't need 	sdr::table::CellRef getCellRef(), UpdateChildren(), getCellName( sal_Int32 nCol, sal_Int32 nRow ) above
673 
674 ::rtl::OUString SAL_CALL AccessibleCell::getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException)
675 {
676     ThrowIfDisposed ();
677     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
678 
679     if( mxCell.is() )
680         return mxCell->getName();
681 
682     return AccessibleCellBase::getAccessibleName();
683 }
684 */
685 
686 } // end of namespace accessibility
687