diff options
Diffstat (limited to 'sw/source/core/access/acccell.cxx')
-rw-r--r-- | sw/source/core/access/acccell.cxx | 232 |
1 files changed, 227 insertions, 5 deletions
diff --git a/sw/source/core/access/acccell.cxx b/sw/source/core/access/acccell.cxx index c70a5146e3b0..28a8bc1e2065 100644 --- a/sw/source/core/access/acccell.cxx +++ b/sw/source/core/access/acccell.cxx @@ -50,6 +50,14 @@ #include <limits.h> +//IAccessibility2 Implementation 2009----- +#include <ndtxt.hxx> +#include <editeng/brshitem.hxx> +#include <swatrset.hxx> +#include <frmatr.hxx> +#include "acctable.hxx" +//-----IAccessibility2 Implementation 2009 + using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; using ::rtl::OUString; @@ -91,6 +99,10 @@ void SwAccessibleCell::GetStates( ::utl::AccessibleStateSetHelper& rStateSet ) DBG_ASSERT( pVSh, "no shell?" ); if( dynamic_cast< const SwCrsrShell* >(pVSh) ) rStateSet.AddState( AccessibleStateType::SELECTABLE ); + //IAccessibility2 Implementation 2009----- + //Solution:Add resizable state to table cell. + rStateSet.AddState( AccessibleStateType::RESIZABLE ); + //-----IAccessibility2 Implementation 2009 // SELECTED if( IsSelected() ) @@ -105,6 +117,7 @@ void SwAccessibleCell::GetStates( ::utl::AccessibleStateSetHelper& rStateSet ) SwAccessibleCell::SwAccessibleCell( SwAccessibleMap *pInitMap, const SwCellFrm *pCellFrm ) : SwAccessibleContext( pInitMap, AccessibleRole::TABLE_CELL, pCellFrm ) + , aSelectionHelper( *this ) , bIsSelected( sal_False ) { vos::OGuard aGuard(Application::GetSolarMutex()); @@ -112,6 +125,13 @@ SwAccessibleCell::SwAccessibleCell( SwAccessibleMap *pInitMap, SetName( sBoxName ); bIsSelected = IsSelected(); + + //IAccessibility2 Implementation 2009----- + //Need not assign the pointer of accessible table object to m_pAccTable, + //for it already done in SwAccessibleCell::GetTable(); Former codes: + //m_pAccTable= GetTable(); + GetTable(); + //-----IAccessibility2 Implementation 2009 } sal_Bool SwAccessibleCell::_InvalidateMyCursorPos() @@ -132,9 +152,16 @@ sal_Bool SwAccessibleCell::_InvalidateMyCursorPos() } sal_Bool bChanged = bOld != bNew; + //IAccessibility2 Implementation 2009----- if( bChanged ) + { FireStateChangedEvent( AccessibleStateType::SELECTED, bNew ); - + if (m_pAccTable) + { + m_pAccTable->AddSelectionCell(this,bNew); + } + } + //-----IAccessibility2 Implementation 2009 return bChanged; } @@ -158,8 +185,10 @@ sal_Bool SwAccessibleCell::_InvalidateChildrenCursorPos( const SwFrm *pFrm ) { ASSERT( xAccImpl->GetFrm()->IsCellFrm(), "table child is not a cell frame" ) - bChanged |= static_cast< SwAccessibleCell *>( + //IAccessibility2 Implementation 2009----- + bChanged = static_cast< SwAccessibleCell *>( xAccImpl.getBodyPtr() )->_InvalidateMyCursorPos(); + //-----IAccessibility2 Implementation 2009 } else bChanged = sal_True; // If the context is not know we @@ -180,6 +209,22 @@ sal_Bool SwAccessibleCell::_InvalidateChildrenCursorPos( const SwFrm *pFrm ) void SwAccessibleCell::_InvalidateCursorPos() { + //IAccessibility2 Implementation 2009----- + if (IsSelected()) + { + const SwAccessibleChild aChild( GetChild( *(GetMap()), 0 ) ); + if( aChild.IsValid() && aChild.GetSwFrm() ) + { + ::vos::ORef < SwAccessibleContext > xChildImpl( GetMap()->GetContextImpl( aChild.GetSwFrm()) ); + if(xChildImpl.isValid()) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::STATE_CHANGED; + aEvent.NewValue<<=AccessibleStateType::FOCUSED; + xChildImpl->FireAccessibleEvent( aEvent ); + } + } + } const SwFrm *pParent = GetParent( SwAccessibleChild(GetFrm()), IsInPagePreview() ); ASSERT( pParent->IsTabFrm(), "parent is not a tab frame" ); @@ -189,6 +234,8 @@ void SwAccessibleCell::_InvalidateCursorPos() while( pTabFrm ) { + _InvalidateChildrenCursorPos( pTabFrm ); +/* sal_Bool bChanged = _InvalidateChildrenCursorPos( pTabFrm ); if( bChanged ) { @@ -201,9 +248,14 @@ void SwAccessibleCell::_InvalidateCursorPos() xAccImpl->FireAccessibleEvent( aEvent ); } } - +*/ pTabFrm = pTabFrm->GetFollow(); } + if (m_pAccTable) + { + m_pAccTable->FireSelectionEvent(); + } + //-----IAccessibility2 Implementation 2009 } sal_Bool SwAccessibleCell::HasCursor() @@ -274,6 +326,21 @@ void SwAccessibleCell::InvalidatePosOrSize( const SwRect& rOldBox ) uno::Any SwAccessibleCell::queryInterface( const uno::Type& rType ) throw( uno::RuntimeException ) { + //IAccessibility2 Implementation 2009----- + if (rType == ::getCppuType((const uno::Reference<XAccessibleExtendedAttributes>*)0)) + { + uno::Any aR; + aR <<= uno::Reference<XAccessibleExtendedAttributes>(this); + return aR; + } + + if (rType == ::getCppuType((const uno::Reference<XAccessibleSelection>*)0)) + { + uno::Any aR; + aR <<= uno::Reference<XAccessibleSelection>(this); + return aR; + } + //-----IAccessibility2 Implementation 2009 if ( rType == ::getCppuType( static_cast< uno::Reference< XAccessibleValue > * >( 0 ) ) ) { uno::Reference<XAccessibleValue> xValue = this; @@ -327,7 +394,8 @@ SwFrmFmt* SwAccessibleCell::GetTblBoxFormat() const return pCellFrm->GetTabBox()->GetFrmFmt(); } - +//IAccessibility2 Implementation 2009----- +//Implement TableCell currentValue uno::Any SwAccessibleCell::getCurrentValue( ) throw( uno::RuntimeException ) { @@ -335,9 +403,33 @@ uno::Any SwAccessibleCell::getCurrentValue( ) CHECK_FOR_DEFUNC( XAccessibleValue ); uno::Any aAny; - aAny <<= GetTblBoxFormat()->GetTblBoxValue().GetValue(); + + const SwCellFrm* pCellFrm = static_cast<const SwCellFrm*>( GetFrm() ); + const SwStartNode *pSttNd = pCellFrm->GetTabBox()->GetSttNd(); + if( pSttNd ) + { + ::rtl::OUString strRet; + SwNodeIndex aCntntIdx( *pSttNd, 0 ); + SwCntntNode* pCNd=NULL; + for(int nIndex = 0 ; + 0 != ( pCNd = pSttNd->GetNodes().GoNext( &aCntntIdx ) ) && + aCntntIdx.GetIndex() < pSttNd->EndOfSectionIndex(); + ++nIndex ) + { + if(pCNd && pCNd->IsTxtNode()) + { + if (0 != nIndex) + { + strRet += ::rtl::OUString::createFromAscii(" "); + } + strRet +=((SwTxtNode*)pCNd)->GetTxt(); + } + } + aAny <<= strRet; + } return aAny; } +//-----IAccessibility2 Implementation 2009 sal_Bool SwAccessibleCell::setCurrentValue( const uno::Any& aNumber ) throw( uno::RuntimeException ) @@ -370,3 +462,133 @@ uno::Any SwAccessibleCell::getMinimumValue( ) aAny <<= -DBL_MAX; return aAny; } + +//IAccessibility2 Implementation 2009----- +::rtl::OUString ReplaceOneChar(::rtl::OUString oldOUString, ::rtl::OUString replacedChar, ::rtl::OUString replaceStr) +{ + int iReplace = -1; + iReplace = oldOUString.lastIndexOf(replacedChar); + if (iReplace > -1) + { + for(;iReplace>-1;) + { + oldOUString = oldOUString.replaceAt(iReplace,1, replaceStr); + iReplace=oldOUString.lastIndexOf(replacedChar,iReplace); + } + } + return oldOUString; +} +::rtl::OUString ReplaceFourChar(::rtl::OUString oldOUString) +{ + oldOUString = ReplaceOneChar(oldOUString,OUString::createFromAscii("\\"),OUString::createFromAscii("\\\\")); + oldOUString = ReplaceOneChar(oldOUString,::rtl::OUString::createFromAscii(";"),::rtl::OUString::createFromAscii("\\;")); + oldOUString = ReplaceOneChar(oldOUString,::rtl::OUString::createFromAscii("="),::rtl::OUString::createFromAscii("\\=")); + oldOUString = ReplaceOneChar(oldOUString,::rtl::OUString::createFromAscii(","),::rtl::OUString::createFromAscii("\\,")); + oldOUString = ReplaceOneChar(oldOUString,::rtl::OUString::createFromAscii(":"),::rtl::OUString::createFromAscii("\\:")); + return oldOUString; +} + +::com::sun::star::uno::Any SAL_CALL SwAccessibleCell::getExtendedAttributes() + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Any strRet; + SwFrmFmt *pFrmFmt = GetTblBoxFormat(); + DBG_ASSERT(pFrmFmt,"Must be Valid"); + + const SwTblBoxFormula& tbl_formula = pFrmFmt->GetTblBoxFormula(); + + ::rtl::OUString strFormula = ReplaceFourChar(tbl_formula.GetFormula()); + ::rtl::OUString strFor = ::rtl::OUString::createFromAscii("Formula:"); + strFor += strFormula; + strFor += ::rtl::OUString::createFromAscii(";") ; + strRet <<= strFor; + + return strRet; +} + +sal_Int32 SAL_CALL SwAccessibleCell::getBackground() + throw (::com::sun::star::uno::RuntimeException) +{ + const SvxBrushItem &rBack = GetFrm()->GetAttrSet()->GetBackground(); + sal_uInt32 crBack = rBack.GetColor().GetColor(); + + if (COL_AUTO == crBack) + { + uno::Reference<XAccessible> xAccDoc = getAccessibleParent(); + if (xAccDoc.is()) + { + uno::Reference<XAccessibleComponent> xCompoentDoc(xAccDoc, uno::UNO_QUERY); + if (xCompoentDoc.is()) + { + crBack = (sal_uInt32)xCompoentDoc->getBackground(); + } + } + } + return crBack; +} + +//===== XAccessibleSelection ============================================ +void SwAccessibleCell::selectAccessibleChild( + sal_Int32 nChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + aSelectionHelper.selectAccessibleChild(nChildIndex); +} + +sal_Bool SwAccessibleCell::isAccessibleChildSelected( + sal_Int32 nChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + return aSelectionHelper.isAccessibleChildSelected(nChildIndex); +} + +void SwAccessibleCell::clearAccessibleSelection( ) + throw ( uno::RuntimeException ) +{ + aSelectionHelper.clearAccessibleSelection(); +} + +void SwAccessibleCell::selectAllAccessibleChildren( ) + throw ( uno::RuntimeException ) +{ + aSelectionHelper.selectAllAccessibleChildren(); +} + +sal_Int32 SwAccessibleCell::getSelectedAccessibleChildCount( ) + throw ( uno::RuntimeException ) +{ + return aSelectionHelper.getSelectedAccessibleChildCount(); +} + +uno::Reference<XAccessible> SwAccessibleCell::getSelectedAccessibleChild( + sal_Int32 nSelectedChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException) +{ + return aSelectionHelper.getSelectedAccessibleChild(nSelectedChildIndex); +} + +void SwAccessibleCell::deselectAccessibleChild( + sal_Int32 nSelectedChildIndex ) + throw ( lang::IndexOutOfBoundsException, uno::RuntimeException ) +{ + aSelectionHelper.deselectAccessibleChild(nSelectedChildIndex); +} + +SwAccessibleTable *SwAccessibleCell::GetTable() +{ + if (!m_pAccTable) + { + if (!xTableReference.is()) + { + xTableReference = getAccessibleParent(); + #ifdef OSL_DEBUG_LEVEL + uno::Reference<XAccessibleContext> xContextTable(xTableReference, uno::UNO_QUERY); + OSL_ASSERT(xContextTable.is() && xContextTable->getAccessibleRole() == AccessibleRole::TABLE); + #endif + //SwAccessibleTable aTable = *(static_cast<SwAccessibleTable *>(xTable.get())); + } + m_pAccTable = static_cast<SwAccessibleTable *>(xTableReference.get()); + } + return m_pAccTable; +} +//-----IAccessibility2 Implementation 2009 |