1b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5b3f79822SAndrew Rist * distributed with this work for additional information 6b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14b3f79822SAndrew Rist * software distributed under the License is distributed on an 15b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17b3f79822SAndrew Rist * specific language governing permissions and limitations 18b3f79822SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20b3f79822SAndrew Rist *************************************************************/ 21b3f79822SAndrew Rist 22b3f79822SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sc.hxx" 26cdf0e10cSrcweir #include "AccessibleEditObject.hxx" 27cdf0e10cSrcweir #include "scitems.hxx" 28cdf0e10cSrcweir #include <editeng/eeitem.hxx> 29cdf0e10cSrcweir #include "unoguard.hxx" 30cdf0e10cSrcweir #include "AccessibleText.hxx" 31cdf0e10cSrcweir #include "editsrc.hxx" 32cdf0e10cSrcweir #include "scmod.hxx" 33cdf0e10cSrcweir #include "inputhdl.hxx" 34cdf0e10cSrcweir 35cdf0e10cSrcweir #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX 36cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEROLE_HPP_ 39cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLESTATETYPE_HPP_ 42cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 43cdf0e10cSrcweir #endif 44cdf0e10cSrcweir #include <rtl/uuid.h> 45cdf0e10cSrcweir #include <tools/debug.hxx> 46cdf0e10cSrcweir #include <svx/AccessibleTextHelper.hxx> 47*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 48*0deba7fbSSteve Yin #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> 49*0deba7fbSSteve Yin #include <com/sun/star/sheet/XSpreadsheet.hpp> 50cdf0e10cSrcweir #include <editeng/editview.hxx> 51cdf0e10cSrcweir #include <editeng/editeng.hxx> 52cdf0e10cSrcweir #include <svx/svdmodel.hxx> 53*0deba7fbSSteve Yin #include <sfx2/objsh.hxx> 54cdf0e10cSrcweir 55*0deba7fbSSteve Yin #include "unonames.hxx" 56*0deba7fbSSteve Yin #include "document.hxx" 57*0deba7fbSSteve Yin #include "AccessibleDocument.hxx" 58*0deba7fbSSteve Yin #include <com/sun/star/accessibility/AccessibleRelationType.hpp> 59*0deba7fbSSteve Yin #include <unotools/accessiblerelationsethelper.hxx> 60*0deba7fbSSteve Yin #include <com/sun/star/accessibility/XAccessibleText.hpp> 61*0deba7fbSSteve Yin using ::com::sun::star::lang::IndexOutOfBoundsException; 62*0deba7fbSSteve Yin using ::com::sun::star::uno::RuntimeException; 63*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 64cdf0e10cSrcweir using namespace ::com::sun::star; 65cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 66cdf0e10cSrcweir 67cdf0e10cSrcweir //===== internal ============================================================ 68cdf0e10cSrcweir 69cdf0e10cSrcweir ScAccessibleEditObject::ScAccessibleEditObject( 70cdf0e10cSrcweir const uno::Reference<XAccessible>& rxParent, 71cdf0e10cSrcweir EditView* pEditView, Window* pWin, const rtl::OUString& rName, 72cdf0e10cSrcweir const rtl::OUString& rDescription, EditObjectType eObjectType) 73cdf0e10cSrcweir : 74cdf0e10cSrcweir ScAccessibleContextBase(rxParent, AccessibleRole::TEXT_FRAME), 75cdf0e10cSrcweir mpTextHelper(NULL), 76cdf0e10cSrcweir mpEditView(pEditView), 77cdf0e10cSrcweir mpWindow(pWin), 78cdf0e10cSrcweir meObjectType(eObjectType), 79cdf0e10cSrcweir mbHasFocus(sal_False) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir CreateTextHelper(); 82cdf0e10cSrcweir SetName(rName); 83cdf0e10cSrcweir SetDescription(rDescription); 84*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 85*0deba7fbSSteve Yin if( meObjectType == CellInEditMode) 86*0deba7fbSSteve Yin { 87*0deba7fbSSteve Yin const ScAccessibleDocument *pAccDoc = const_cast<ScAccessibleDocument*>(static_cast<ScAccessibleDocument*>(rxParent.get())) ; 88*0deba7fbSSteve Yin if (pAccDoc) 89*0deba7fbSSteve Yin { 90*0deba7fbSSteve Yin m_pScDoc = pAccDoc->GetDocument(); 91*0deba7fbSSteve Yin m_curCellAddress =pAccDoc->GetCurCellAddress(); 92*0deba7fbSSteve Yin } 93*0deba7fbSSteve Yin else 94*0deba7fbSSteve Yin { 95*0deba7fbSSteve Yin m_pScDoc=NULL; 96*0deba7fbSSteve Yin } 97*0deba7fbSSteve Yin } 98*0deba7fbSSteve Yin else 99*0deba7fbSSteve Yin m_pScDoc=NULL; 100*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 101cdf0e10cSrcweir } 102cdf0e10cSrcweir 103cdf0e10cSrcweir ScAccessibleEditObject::~ScAccessibleEditObject() 104cdf0e10cSrcweir { 105cdf0e10cSrcweir if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir // increment refcount to prevent double call off dtor 108cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 109cdf0e10cSrcweir // call dispose to inform object wich have a weak reference to this object 110cdf0e10cSrcweir dispose(); 111cdf0e10cSrcweir } 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir void SAL_CALL ScAccessibleEditObject::disposing() 115cdf0e10cSrcweir { 116cdf0e10cSrcweir ScUnoGuard aGuard; 117cdf0e10cSrcweir if (mpTextHelper) 118cdf0e10cSrcweir DELETEZ(mpTextHelper); 119cdf0e10cSrcweir 120cdf0e10cSrcweir ScAccessibleContextBase::disposing(); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir void ScAccessibleEditObject::LostFocus() 124cdf0e10cSrcweir { 125cdf0e10cSrcweir mbHasFocus = sal_False; 126cdf0e10cSrcweir if (mpTextHelper) 127cdf0e10cSrcweir mpTextHelper->SetFocus(sal_False); 128cdf0e10cSrcweir CommitFocusLost(); 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir void ScAccessibleEditObject::GotFocus() 132cdf0e10cSrcweir { 133cdf0e10cSrcweir mbHasFocus = sal_True; 134cdf0e10cSrcweir CommitFocusGained(); 135cdf0e10cSrcweir if (mpTextHelper) 136cdf0e10cSrcweir mpTextHelper->SetFocus(sal_True); 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 140*0deba7fbSSteve Yin //===== XInterface ========================================================== 141*0deba7fbSSteve Yin 142*0deba7fbSSteve Yin com::sun::star::uno::Any SAL_CALL 143*0deba7fbSSteve Yin ScAccessibleEditObject::queryInterface (const com::sun::star::uno::Type & rType) 144*0deba7fbSSteve Yin throw (::com::sun::star::uno::RuntimeException) 145*0deba7fbSSteve Yin { 146*0deba7fbSSteve Yin ::com::sun::star::uno::Any aReturn = ScAccessibleContextBase::queryInterface (rType); 147*0deba7fbSSteve Yin if ( ! aReturn.hasValue()) 148*0deba7fbSSteve Yin aReturn = ::cppu::queryInterface (rType, 149*0deba7fbSSteve Yin static_cast< ::com::sun::star::accessibility::XAccessibleSelection* >(this) 150*0deba7fbSSteve Yin ); 151*0deba7fbSSteve Yin return aReturn; 152*0deba7fbSSteve Yin } 153*0deba7fbSSteve Yin void SAL_CALL 154*0deba7fbSSteve Yin ScAccessibleEditObject::acquire (void) 155*0deba7fbSSteve Yin throw () 156*0deba7fbSSteve Yin { 157*0deba7fbSSteve Yin ScAccessibleContextBase::acquire (); 158*0deba7fbSSteve Yin } 159*0deba7fbSSteve Yin void SAL_CALL 160*0deba7fbSSteve Yin ScAccessibleEditObject::release (void) 161*0deba7fbSSteve Yin throw () 162*0deba7fbSSteve Yin { 163*0deba7fbSSteve Yin ScAccessibleContextBase::release (); 164*0deba7fbSSteve Yin } 165*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 166cdf0e10cSrcweir //===== XAccessibleComponent ============================================ 167cdf0e10cSrcweir 168cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleEditObject::getAccessibleAtPoint( 169cdf0e10cSrcweir const awt::Point& rPoint ) 170cdf0e10cSrcweir throw (uno::RuntimeException) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir uno::Reference<XAccessible> xRet; 173cdf0e10cSrcweir if (containsPoint(rPoint)) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir ScUnoGuard aGuard; 176cdf0e10cSrcweir IsObjectValid(); 177cdf0e10cSrcweir 178cdf0e10cSrcweir if(!mpTextHelper) 179cdf0e10cSrcweir CreateTextHelper(); 180cdf0e10cSrcweir 181cdf0e10cSrcweir xRet = mpTextHelper->GetAt(rPoint); 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir return xRet; 185cdf0e10cSrcweir } 186cdf0e10cSrcweir 187cdf0e10cSrcweir Rectangle ScAccessibleEditObject::GetBoundingBoxOnScreen(void) const 188cdf0e10cSrcweir throw (uno::RuntimeException) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir Rectangle aScreenBounds; 191cdf0e10cSrcweir 192cdf0e10cSrcweir if ( mpWindow ) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir if ( meObjectType == CellInEditMode ) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir if ( mpEditView && mpEditView->GetEditEngine() ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir MapMode aMapMode( mpEditView->GetEditEngine()->GetRefMapMode() ); 199cdf0e10cSrcweir aScreenBounds = mpWindow->LogicToPixel( mpEditView->GetOutputArea(), aMapMode ); 200cdf0e10cSrcweir Point aCellLoc = aScreenBounds.TopLeft(); 201cdf0e10cSrcweir Rectangle aWindowRect = mpWindow->GetWindowExtentsRelative( NULL ); 202cdf0e10cSrcweir Point aWindowLoc = aWindowRect.TopLeft(); 203cdf0e10cSrcweir Point aPos( aCellLoc.getX() + aWindowLoc.getX(), aCellLoc.getY() + aWindowLoc.getY() ); 204cdf0e10cSrcweir aScreenBounds.SetPos( aPos ); 205cdf0e10cSrcweir } 206cdf0e10cSrcweir } 207cdf0e10cSrcweir else 208cdf0e10cSrcweir { 209cdf0e10cSrcweir aScreenBounds = mpWindow->GetWindowExtentsRelative( NULL ); 210cdf0e10cSrcweir } 211cdf0e10cSrcweir } 212cdf0e10cSrcweir 213cdf0e10cSrcweir return aScreenBounds; 214cdf0e10cSrcweir } 215cdf0e10cSrcweir 216cdf0e10cSrcweir Rectangle ScAccessibleEditObject::GetBoundingBox(void) const 217cdf0e10cSrcweir throw (uno::RuntimeException) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir Rectangle aBounds( GetBoundingBoxOnScreen() ); 220cdf0e10cSrcweir 221cdf0e10cSrcweir if ( mpWindow ) 222cdf0e10cSrcweir { 223cdf0e10cSrcweir uno::Reference< XAccessible > xThis( mpWindow->GetAccessible() ); 224cdf0e10cSrcweir if ( xThis.is() ) 225cdf0e10cSrcweir { 226cdf0e10cSrcweir uno::Reference< XAccessibleContext > xContext( xThis->getAccessibleContext() ); 227cdf0e10cSrcweir if ( xContext.is() ) 228cdf0e10cSrcweir { 229cdf0e10cSrcweir uno::Reference< XAccessible > xParent( xContext->getAccessibleParent() ); 230cdf0e10cSrcweir if ( xParent.is() ) 231cdf0e10cSrcweir { 232cdf0e10cSrcweir uno::Reference< XAccessibleComponent > xParentComponent( xParent->getAccessibleContext(), uno::UNO_QUERY ); 233cdf0e10cSrcweir if ( xParentComponent.is() ) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir Point aScreenLoc = aBounds.TopLeft(); 236cdf0e10cSrcweir awt::Point aParentScreenLoc = xParentComponent->getLocationOnScreen(); 237cdf0e10cSrcweir Point aPos( aScreenLoc.getX() - aParentScreenLoc.X, aScreenLoc.getY() - aParentScreenLoc.Y ); 238cdf0e10cSrcweir aBounds.SetPos( aPos ); 239cdf0e10cSrcweir } 240cdf0e10cSrcweir } 241cdf0e10cSrcweir } 242cdf0e10cSrcweir } 243cdf0e10cSrcweir } 244cdf0e10cSrcweir 245cdf0e10cSrcweir return aBounds; 246cdf0e10cSrcweir } 247cdf0e10cSrcweir 248cdf0e10cSrcweir //===== XAccessibleContext ============================================== 249cdf0e10cSrcweir 250cdf0e10cSrcweir sal_Int32 SAL_CALL 251cdf0e10cSrcweir ScAccessibleEditObject::getAccessibleChildCount(void) 252cdf0e10cSrcweir throw (uno::RuntimeException) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir ScUnoGuard aGuard; 255cdf0e10cSrcweir IsObjectValid(); 256cdf0e10cSrcweir if (!mpTextHelper) 257cdf0e10cSrcweir CreateTextHelper(); 258cdf0e10cSrcweir return mpTextHelper->GetChildCount(); 259cdf0e10cSrcweir } 260cdf0e10cSrcweir 261cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL 262cdf0e10cSrcweir ScAccessibleEditObject::getAccessibleChild(sal_Int32 nIndex) 263cdf0e10cSrcweir throw (uno::RuntimeException, 264cdf0e10cSrcweir lang::IndexOutOfBoundsException) 265cdf0e10cSrcweir { 266cdf0e10cSrcweir ScUnoGuard aGuard; 267cdf0e10cSrcweir IsObjectValid(); 268cdf0e10cSrcweir if (!mpTextHelper) 269cdf0e10cSrcweir CreateTextHelper(); 270cdf0e10cSrcweir return mpTextHelper->GetChild(nIndex); 271cdf0e10cSrcweir } 272cdf0e10cSrcweir 273cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL 274cdf0e10cSrcweir ScAccessibleEditObject::getAccessibleStateSet(void) 275cdf0e10cSrcweir throw (uno::RuntimeException) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir ScUnoGuard aGuard; 278cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> xParentStates; 279cdf0e10cSrcweir if (getAccessibleParent().is()) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); 282cdf0e10cSrcweir xParentStates = xParentContext->getAccessibleStateSet(); 283cdf0e10cSrcweir } 284cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); 285cdf0e10cSrcweir if (IsDefunc(xParentStates)) 286cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::DEFUNC); 287cdf0e10cSrcweir else 288cdf0e10cSrcweir { 289cdf0e10cSrcweir // all states are const, because this object exists only in one state 290cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::EDITABLE); 291cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::ENABLED); 292cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SENSITIVE); 293cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::MULTI_LINE); 294cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::MULTI_SELECTABLE); 295cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SHOWING); 296cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::VISIBLE); 297cdf0e10cSrcweir } 298cdf0e10cSrcweir return pStateSet; 299cdf0e10cSrcweir } 300cdf0e10cSrcweir 301cdf0e10cSrcweir ::rtl::OUString SAL_CALL 302cdf0e10cSrcweir ScAccessibleEditObject::createAccessibleDescription(void) 303cdf0e10cSrcweir throw (uno::RuntimeException) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir // DBG_ERRORFILE("Should never be called, because is set in the constructor.") 306cdf0e10cSrcweir return rtl::OUString(); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir 309cdf0e10cSrcweir ::rtl::OUString SAL_CALL 310cdf0e10cSrcweir ScAccessibleEditObject::createAccessibleName(void) 311cdf0e10cSrcweir throw (uno::RuntimeException) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir DBG_ERRORFILE("Should never be called, because is set in the constructor."); 314cdf0e10cSrcweir return rtl::OUString(); 315cdf0e10cSrcweir } 316cdf0e10cSrcweir 317cdf0e10cSrcweir ///===== XAccessibleEventBroadcaster ===================================== 318cdf0e10cSrcweir 319cdf0e10cSrcweir void SAL_CALL 320cdf0e10cSrcweir ScAccessibleEditObject::addEventListener(const uno::Reference<XAccessibleEventListener>& xListener) 321cdf0e10cSrcweir throw (uno::RuntimeException) 322cdf0e10cSrcweir { 323cdf0e10cSrcweir if (!mpTextHelper) 324cdf0e10cSrcweir CreateTextHelper(); 325cdf0e10cSrcweir 326cdf0e10cSrcweir mpTextHelper->AddEventListener(xListener); 327cdf0e10cSrcweir 328cdf0e10cSrcweir ScAccessibleContextBase::addEventListener(xListener); 329cdf0e10cSrcweir } 330cdf0e10cSrcweir 331cdf0e10cSrcweir void SAL_CALL 332cdf0e10cSrcweir ScAccessibleEditObject::removeEventListener(const uno::Reference<XAccessibleEventListener>& xListener) 333cdf0e10cSrcweir throw (uno::RuntimeException) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir if (!mpTextHelper) 336cdf0e10cSrcweir CreateTextHelper(); 337cdf0e10cSrcweir 338cdf0e10cSrcweir mpTextHelper->RemoveEventListener(xListener); 339cdf0e10cSrcweir 340cdf0e10cSrcweir ScAccessibleContextBase::removeEventListener(xListener); 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir //===== XServiceInfo ==================================================== 344cdf0e10cSrcweir 345cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleEditObject::getImplementationName(void) 346cdf0e10cSrcweir throw (uno::RuntimeException) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleEditObject")); 349cdf0e10cSrcweir } 350cdf0e10cSrcweir 351cdf0e10cSrcweir //===== XTypeProvider ======================================================= 352cdf0e10cSrcweir 353cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL 354cdf0e10cSrcweir ScAccessibleEditObject::getImplementationId(void) 355cdf0e10cSrcweir throw (uno::RuntimeException) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir ScUnoGuard aGuard; 358cdf0e10cSrcweir IsObjectValid(); 359cdf0e10cSrcweir static uno::Sequence<sal_Int8> aId; 360cdf0e10cSrcweir if (aId.getLength() == 0) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir aId.realloc (16); 363cdf0e10cSrcweir rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True); 364cdf0e10cSrcweir } 365cdf0e10cSrcweir return aId; 366cdf0e10cSrcweir } 367cdf0e10cSrcweir 368cdf0e10cSrcweir //==== internal ========================================================= 369cdf0e10cSrcweir 370cdf0e10cSrcweir sal_Bool ScAccessibleEditObject::IsDefunc( 371cdf0e10cSrcweir const uno::Reference<XAccessibleStateSet>& rxParentStates) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir return ScAccessibleContextBase::IsDefunc() || !getAccessibleParent().is() || 374cdf0e10cSrcweir (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC)); 375cdf0e10cSrcweir } 376cdf0e10cSrcweir 377cdf0e10cSrcweir void ScAccessibleEditObject::CreateTextHelper() 378cdf0e10cSrcweir { 379cdf0e10cSrcweir if (!mpTextHelper) 380cdf0e10cSrcweir { 381cdf0e10cSrcweir ::std::auto_ptr < ScAccessibleTextData > pAccessibleTextData; 382cdf0e10cSrcweir if (meObjectType == CellInEditMode || meObjectType == EditControl) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir pAccessibleTextData.reset 385cdf0e10cSrcweir (new ScAccessibleEditObjectTextData(mpEditView, mpWindow)); 386cdf0e10cSrcweir } 387cdf0e10cSrcweir else 388cdf0e10cSrcweir { 389cdf0e10cSrcweir pAccessibleTextData.reset 390cdf0e10cSrcweir (new ScAccessibleEditLineTextData(NULL, mpWindow)); 391cdf0e10cSrcweir } 392cdf0e10cSrcweir 393cdf0e10cSrcweir ::std::auto_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(pAccessibleTextData)); 394cdf0e10cSrcweir mpTextHelper = new ::accessibility::AccessibleTextHelper(pEditSource ); 395cdf0e10cSrcweir mpTextHelper->SetEventSource(this); 396cdf0e10cSrcweir mpTextHelper->SetFocus(mbHasFocus); 397cdf0e10cSrcweir 398cdf0e10cSrcweir // #i54814# activate cell in edit mode 399cdf0e10cSrcweir if( meObjectType == CellInEditMode ) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir // do not activate cell object, if top edit line is active 402cdf0e10cSrcweir const ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(); 403cdf0e10cSrcweir if( pInputHdl && !pInputHdl->IsTopMode() ) 404cdf0e10cSrcweir { 405cdf0e10cSrcweir SdrHint aHint( HINT_BEGEDIT ); 406cdf0e10cSrcweir mpTextHelper->GetEditSource().GetBroadcaster().Broadcast( aHint ); 407cdf0e10cSrcweir } 408cdf0e10cSrcweir } 409cdf0e10cSrcweir } 410cdf0e10cSrcweir } 411*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 412*0deba7fbSSteve Yin sal_Int32 SAL_CALL ScAccessibleEditObject::getForeground( ) 413*0deba7fbSSteve Yin throw (::com::sun::star::uno::RuntimeException) 414*0deba7fbSSteve Yin { 415*0deba7fbSSteve Yin return GetFgBgColor(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CCOLOR))); 416*0deba7fbSSteve Yin } 417*0deba7fbSSteve Yin 418*0deba7fbSSteve Yin sal_Int32 SAL_CALL ScAccessibleEditObject::getBackground( ) 419*0deba7fbSSteve Yin throw (::com::sun::star::uno::RuntimeException) 420*0deba7fbSSteve Yin { 421*0deba7fbSSteve Yin return GetFgBgColor(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLBACK))); 422*0deba7fbSSteve Yin } 423*0deba7fbSSteve Yin sal_Int32 ScAccessibleEditObject::GetFgBgColor( const rtl::OUString &strPropColor) 424*0deba7fbSSteve Yin { 425*0deba7fbSSteve Yin ScUnoGuard aGuard; 426*0deba7fbSSteve Yin sal_Int32 nColor(0); 427*0deba7fbSSteve Yin if (m_pScDoc) 428*0deba7fbSSteve Yin { 429*0deba7fbSSteve Yin SfxObjectShell* pObjSh = m_pScDoc->GetDocumentShell(); 430*0deba7fbSSteve Yin if ( pObjSh ) 431*0deba7fbSSteve Yin { 432*0deba7fbSSteve Yin uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( pObjSh->GetModel(), uno::UNO_QUERY ); 433*0deba7fbSSteve Yin if ( xSpreadDoc.is() ) 434*0deba7fbSSteve Yin { 435*0deba7fbSSteve Yin uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets(); 436*0deba7fbSSteve Yin uno::Reference<container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY ); 437*0deba7fbSSteve Yin if ( xIndex.is() ) 438*0deba7fbSSteve Yin { 439*0deba7fbSSteve Yin uno::Any aTable = xIndex->getByIndex(m_curCellAddress.Tab()); 440*0deba7fbSSteve Yin uno::Reference<sheet::XSpreadsheet> xTable; 441*0deba7fbSSteve Yin if (aTable>>=xTable) 442*0deba7fbSSteve Yin { 443*0deba7fbSSteve Yin uno::Reference<table::XCell> xCell = xTable->getCellByPosition(m_curCellAddress.Col(), m_curCellAddress.Row()); 444*0deba7fbSSteve Yin if (xCell.is()) 445*0deba7fbSSteve Yin { 446*0deba7fbSSteve Yin uno::Reference<beans::XPropertySet> xCellProps(xCell, uno::UNO_QUERY); 447*0deba7fbSSteve Yin if (xCellProps.is()) 448*0deba7fbSSteve Yin { 449*0deba7fbSSteve Yin uno::Any aAny = xCellProps->getPropertyValue(strPropColor); 450*0deba7fbSSteve Yin aAny >>= nColor; 451*0deba7fbSSteve Yin } 452*0deba7fbSSteve Yin } 453*0deba7fbSSteve Yin } 454*0deba7fbSSteve Yin } 455*0deba7fbSSteve Yin } 456*0deba7fbSSteve Yin } 457*0deba7fbSSteve Yin } 458*0deba7fbSSteve Yin return nColor; 459*0deba7fbSSteve Yin } 460*0deba7fbSSteve Yin //===== XAccessibleSelection ============================================ 461*0deba7fbSSteve Yin //-------------------------------------------------------------------------------- 462*0deba7fbSSteve Yin void SAL_CALL ScAccessibleEditObject::selectAccessibleChild( sal_Int32 ) 463*0deba7fbSSteve Yin throw ( IndexOutOfBoundsException, RuntimeException ) 464*0deba7fbSSteve Yin { 465*0deba7fbSSteve Yin } 466*0deba7fbSSteve Yin //---------------------------------------------------------------------------------- 467*0deba7fbSSteve Yin sal_Bool SAL_CALL ScAccessibleEditObject::isAccessibleChildSelected( sal_Int32 nChildIndex ) 468*0deba7fbSSteve Yin throw ( IndexOutOfBoundsException, 469*0deba7fbSSteve Yin RuntimeException ) 470*0deba7fbSSteve Yin { 471*0deba7fbSSteve Yin uno::Reference<XAccessible> xAcc = getAccessibleChild( nChildIndex ); 472*0deba7fbSSteve Yin uno::Reference<XAccessibleContext> xContext; 473*0deba7fbSSteve Yin if( xAcc.is() ) 474*0deba7fbSSteve Yin xContext = xAcc->getAccessibleContext(); 475*0deba7fbSSteve Yin if( xContext.is() ) 476*0deba7fbSSteve Yin { 477*0deba7fbSSteve Yin if( xContext->getAccessibleRole() == AccessibleRole::PARAGRAPH ) 478*0deba7fbSSteve Yin { 479*0deba7fbSSteve Yin uno::Reference< ::com::sun::star::accessibility::XAccessibleText > 480*0deba7fbSSteve Yin xText(xAcc, uno::UNO_QUERY); 481*0deba7fbSSteve Yin if( xText.is() ) 482*0deba7fbSSteve Yin { 483*0deba7fbSSteve Yin if( xText->getSelectionStart() >= 0 ) return sal_True; 484*0deba7fbSSteve Yin } 485*0deba7fbSSteve Yin } 486*0deba7fbSSteve Yin } 487*0deba7fbSSteve Yin return sal_False; 488*0deba7fbSSteve Yin } 489*0deba7fbSSteve Yin //--------------------------------------------------------------------- 490*0deba7fbSSteve Yin void SAL_CALL ScAccessibleEditObject::clearAccessibleSelection( ) 491*0deba7fbSSteve Yin throw ( RuntimeException ) 492*0deba7fbSSteve Yin { 493*0deba7fbSSteve Yin } 494*0deba7fbSSteve Yin //------------------------------------------------------------------------- 495*0deba7fbSSteve Yin void SAL_CALL ScAccessibleEditObject::selectAllAccessibleChildren( ) 496*0deba7fbSSteve Yin throw ( RuntimeException ) 497*0deba7fbSSteve Yin { 498*0deba7fbSSteve Yin } 499*0deba7fbSSteve Yin //---------------------------------------------------------------------------- 500*0deba7fbSSteve Yin sal_Int32 SAL_CALL ScAccessibleEditObject::getSelectedAccessibleChildCount() 501*0deba7fbSSteve Yin throw ( RuntimeException ) 502*0deba7fbSSteve Yin { 503*0deba7fbSSteve Yin sal_Int32 nCount = 0; 504*0deba7fbSSteve Yin sal_Int32 TotalCount = getAccessibleChildCount(); 505*0deba7fbSSteve Yin for( sal_Int32 i = 0; i < TotalCount; i++ ) 506*0deba7fbSSteve Yin if( isAccessibleChildSelected(i) ) nCount++; 507*0deba7fbSSteve Yin return nCount; 508*0deba7fbSSteve Yin } 509*0deba7fbSSteve Yin //-------------------------------------------------------------------------------------- 510*0deba7fbSSteve Yin uno::Reference<XAccessible> SAL_CALL ScAccessibleEditObject::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) 511*0deba7fbSSteve Yin throw ( IndexOutOfBoundsException, RuntimeException) 512*0deba7fbSSteve Yin { 513*0deba7fbSSteve Yin if ( nSelectedChildIndex > getSelectedAccessibleChildCount() ) 514*0deba7fbSSteve Yin throw IndexOutOfBoundsException(); 515*0deba7fbSSteve Yin sal_Int32 i1, i2; 516*0deba7fbSSteve Yin for( i1 = 0, i2 = 0; i1 < getAccessibleChildCount(); i1++ ) 517*0deba7fbSSteve Yin if( isAccessibleChildSelected(i1) ) 518*0deba7fbSSteve Yin { 519*0deba7fbSSteve Yin if( i2 == nSelectedChildIndex ) 520*0deba7fbSSteve Yin return getAccessibleChild( i1 ); 521*0deba7fbSSteve Yin i2++; 522*0deba7fbSSteve Yin } 523*0deba7fbSSteve Yin return uno::Reference<XAccessible>(); 524*0deba7fbSSteve Yin } 525*0deba7fbSSteve Yin //---------------------------------------------------------------------------------- 526*0deba7fbSSteve Yin void SAL_CALL ScAccessibleEditObject::deselectAccessibleChild( 527*0deba7fbSSteve Yin sal_Int32 ) 528*0deba7fbSSteve Yin throw ( IndexOutOfBoundsException, 529*0deba7fbSSteve Yin RuntimeException ) 530*0deba7fbSSteve Yin { 531*0deba7fbSSteve Yin } 532*0deba7fbSSteve Yin uno::Reference< XAccessibleRelationSet > ScAccessibleEditObject::getAccessibleRelationSet( ) 533*0deba7fbSSteve Yin throw (uno::RuntimeException) 534*0deba7fbSSteve Yin { 535*0deba7fbSSteve Yin ScUnoGuard aGuard; 536*0deba7fbSSteve Yin Window* pWindow = mpWindow; 537*0deba7fbSSteve Yin utl::AccessibleRelationSetHelper* rRelationSet = new utl::AccessibleRelationSetHelper; 538*0deba7fbSSteve Yin uno::Reference< XAccessibleRelationSet > rSet = rRelationSet; 539*0deba7fbSSteve Yin if ( pWindow ) 540*0deba7fbSSteve Yin { 541*0deba7fbSSteve Yin Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy(); 542*0deba7fbSSteve Yin if ( pLabeledBy && pLabeledBy != pWindow ) 543*0deba7fbSSteve Yin { 544*0deba7fbSSteve Yin uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1); 545*0deba7fbSSteve Yin aSequence[0] = pLabeledBy->GetAccessible(); 546*0deba7fbSSteve Yin rRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::LABELED_BY, aSequence ) ); 547*0deba7fbSSteve Yin } 548*0deba7fbSSteve Yin Window* pMemberOf = pWindow->GetAccessibleRelationMemberOf(); 549*0deba7fbSSteve Yin if ( pMemberOf && pMemberOf != pWindow ) 550*0deba7fbSSteve Yin { 551*0deba7fbSSteve Yin uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1); 552*0deba7fbSSteve Yin aSequence[0] = pMemberOf->GetAccessible(); 553*0deba7fbSSteve Yin rRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::MEMBER_OF, aSequence ) ); 554*0deba7fbSSteve Yin } 555*0deba7fbSSteve Yin return rSet; 556*0deba7fbSSteve Yin } 557*0deba7fbSSteve Yin return uno::Reference< XAccessibleRelationSet >(); 558*0deba7fbSSteve Yin } 559*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 560cdf0e10cSrcweir 561