1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sc.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include "AccessibleCell.hxx" 33*cdf0e10cSrcweir #include "scitems.hxx" 34*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include "AccessibleText.hxx" 38*cdf0e10cSrcweir #include "AccessibleDocument.hxx" 39*cdf0e10cSrcweir #include "tabvwsh.hxx" 40*cdf0e10cSrcweir #include "document.hxx" 41*cdf0e10cSrcweir #include "attrib.hxx" 42*cdf0e10cSrcweir #include "miscuno.hxx" 43*cdf0e10cSrcweir #include "unoguard.hxx" 44*cdf0e10cSrcweir #include "editsrc.hxx" 45*cdf0e10cSrcweir #include "dociter.hxx" 46*cdf0e10cSrcweir #include "cell.hxx" 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX 49*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 50*cdf0e10cSrcweir #endif 51*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEROLE_HPP_ 52*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 53*cdf0e10cSrcweir #endif 54*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLESTATETYPE_HPP_ 55*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 56*cdf0e10cSrcweir #endif 57*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRelationType.hpp> 58*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleTable.hpp> 59*cdf0e10cSrcweir #include <rtl/uuid.h> 60*cdf0e10cSrcweir #include <tools/debug.hxx> 61*cdf0e10cSrcweir #include <editeng/brshitem.hxx> 62*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 63*cdf0e10cSrcweir #include <float.h> 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir using namespace ::com::sun::star; 66*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir //===== internal ============================================================ 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir ScAccessibleCell::ScAccessibleCell( 71*cdf0e10cSrcweir const uno::Reference<XAccessible>& rxParent, 72*cdf0e10cSrcweir ScTabViewShell* pViewShell, 73*cdf0e10cSrcweir ScAddress& rCellAddress, 74*cdf0e10cSrcweir sal_Int32 nIndex, 75*cdf0e10cSrcweir ScSplitPos eSplitPos, 76*cdf0e10cSrcweir ScAccessibleDocument* pAccDoc) 77*cdf0e10cSrcweir : 78*cdf0e10cSrcweir ScAccessibleCellBase(rxParent, GetDocument(pViewShell), rCellAddress, nIndex), 79*cdf0e10cSrcweir ::accessibility::AccessibleStaticTextBase(CreateEditSource(pViewShell, rCellAddress, eSplitPos)), 80*cdf0e10cSrcweir mpViewShell(pViewShell), 81*cdf0e10cSrcweir mpAccDoc(pAccDoc), 82*cdf0e10cSrcweir meSplitPos(eSplitPos) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir if (pViewShell) 85*cdf0e10cSrcweir pViewShell->AddAccessibilityObject(*this); 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir ScAccessibleCell::~ScAccessibleCell() 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir // increment refcount to prevent double call off dtor 93*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 94*cdf0e10cSrcweir // call dispose to inform object wich have a weak reference to this object 95*cdf0e10cSrcweir dispose(); 96*cdf0e10cSrcweir } 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir void ScAccessibleCell::Init() 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir ScAccessibleCellBase::Init(); 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir SetEventSource(this); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir void SAL_CALL ScAccessibleCell::disposing() 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir ScUnoGuard aGuard; 109*cdf0e10cSrcweir // #100593# dispose in AccessibleStaticTextBase 110*cdf0e10cSrcweir Dispose(); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir if (mpViewShell) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir mpViewShell->RemoveAccessibilityObject(*this); 115*cdf0e10cSrcweir mpViewShell = NULL; 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir mpAccDoc = NULL; 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir ScAccessibleCellBase::disposing(); 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir //===== XInterface ===================================================== 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( ScAccessibleCell, ScAccessibleCellBase, AccessibleStaticTextBase ) 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir //===== XTypeProvider =================================================== 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( ScAccessibleCell, ScAccessibleCellBase, AccessibleStaticTextBase ) 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir //===== XAccessibleComponent ============================================ 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleCell::getAccessibleAtPoint( 133*cdf0e10cSrcweir const awt::Point& rPoint ) 134*cdf0e10cSrcweir throw (uno::RuntimeException) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir return AccessibleStaticTextBase::getAccessibleAtPoint(rPoint); 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir void SAL_CALL ScAccessibleCell::grabFocus( ) 140*cdf0e10cSrcweir throw (uno::RuntimeException) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir ScUnoGuard aGuard; 143*cdf0e10cSrcweir IsObjectValid(); 144*cdf0e10cSrcweir if (getAccessibleParent().is() && mpViewShell) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY); 147*cdf0e10cSrcweir if (xAccessibleComponent.is()) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir xAccessibleComponent->grabFocus(); 150*cdf0e10cSrcweir mpViewShell->SetCursor(maCellAddress.Col(), maCellAddress.Row()); 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir Rectangle ScAccessibleCell::GetBoundingBoxOnScreen(void) const 156*cdf0e10cSrcweir throw (uno::RuntimeException) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir Rectangle aCellRect(GetBoundingBox()); 159*cdf0e10cSrcweir if (mpViewShell) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos); 162*cdf0e10cSrcweir if (pWindow) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir Rectangle aRect = pWindow->GetWindowExtentsRelative(NULL); 165*cdf0e10cSrcweir aCellRect.setX(aCellRect.getX() + aRect.getX()); 166*cdf0e10cSrcweir aCellRect.setY(aCellRect.getY() + aRect.getY()); 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir return aCellRect; 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir Rectangle ScAccessibleCell::GetBoundingBox(void) const 173*cdf0e10cSrcweir throw (uno::RuntimeException) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir Rectangle aCellRect; 176*cdf0e10cSrcweir if (mpViewShell) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir long nSizeX, nSizeY; 179*cdf0e10cSrcweir mpViewShell->GetViewData()->GetMergeSizePixel( 180*cdf0e10cSrcweir maCellAddress.Col(), maCellAddress.Row(), nSizeX, nSizeY); 181*cdf0e10cSrcweir aCellRect.SetSize(Size(nSizeX, nSizeY)); 182*cdf0e10cSrcweir aCellRect.SetPos(mpViewShell->GetViewData()->GetScrPos(maCellAddress.Col(), maCellAddress.Row(), meSplitPos, sal_True)); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos); 185*cdf0e10cSrcweir if (pWindow) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir Rectangle aRect(pWindow->GetWindowExtentsRelative(pWindow->GetAccessibleParentWindow())); 188*cdf0e10cSrcweir aRect.Move(-aRect.Left(), -aRect.Top()); 189*cdf0e10cSrcweir aCellRect = aRect.Intersection(aCellRect); 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir /* #i19430# Gnopernicus reads text partly if it sticks out of the cell 193*cdf0e10cSrcweir boundaries. This leads to wrong results in cases where the cell 194*cdf0e10cSrcweir text is rotated, because rotation is not taken into account when 195*cdf0e10cSrcweir calculating the visible part of the text. In these cases we will 196*cdf0e10cSrcweir simply expand the cell size to the width of the unrotated text. */ 197*cdf0e10cSrcweir if (mpDoc) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir const SfxInt32Item* pItem = static_cast< const SfxInt32Item* >( 200*cdf0e10cSrcweir mpDoc->GetAttr( maCellAddress.Col(), maCellAddress.Row(), maCellAddress.Tab(), ATTR_ROTATE_VALUE ) ); 201*cdf0e10cSrcweir if( pItem && (pItem->GetValue() != 0) ) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir Rectangle aParaRect = GetParagraphBoundingBox(); 204*cdf0e10cSrcweir if( !aParaRect.IsEmpty() && (aCellRect.GetWidth() < aParaRect.GetWidth()) ) 205*cdf0e10cSrcweir aCellRect.SetSize( Size( aParaRect.GetWidth(), aCellRect.GetHeight() ) ); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir if (aCellRect.IsEmpty()) 210*cdf0e10cSrcweir aCellRect.SetPos(Point(-1, -1)); 211*cdf0e10cSrcweir return aCellRect; 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir //===== XAccessibleContext ============================================== 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir sal_Int32 SAL_CALL 217*cdf0e10cSrcweir ScAccessibleCell::getAccessibleChildCount(void) 218*cdf0e10cSrcweir throw (uno::RuntimeException) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir return AccessibleStaticTextBase::getAccessibleChildCount(); 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL 224*cdf0e10cSrcweir ScAccessibleCell::getAccessibleChild(sal_Int32 nIndex) 225*cdf0e10cSrcweir throw (uno::RuntimeException, 226*cdf0e10cSrcweir lang::IndexOutOfBoundsException) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir return AccessibleStaticTextBase::getAccessibleChild(nIndex); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL 232*cdf0e10cSrcweir ScAccessibleCell::getAccessibleStateSet(void) 233*cdf0e10cSrcweir throw (uno::RuntimeException) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir ScUnoGuard aGuard; 236*cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> xParentStates; 237*cdf0e10cSrcweir if (getAccessibleParent().is()) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); 240*cdf0e10cSrcweir xParentStates = xParentContext->getAccessibleStateSet(); 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); 243*cdf0e10cSrcweir if (IsDefunc(xParentStates)) 244*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::DEFUNC); 245*cdf0e10cSrcweir else 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir if (IsEditable(xParentStates)) 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::EDITABLE); 250*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::RESIZABLE); 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::ENABLED); 253*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::MULTI_LINE); 254*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::MULTI_SELECTABLE); 255*cdf0e10cSrcweir if (IsOpaque(xParentStates)) 256*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::OPAQUE); 257*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SELECTABLE); 258*cdf0e10cSrcweir if (IsSelected()) 259*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SELECTED); 260*cdf0e10cSrcweir if (isShowing()) 261*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SHOWING); 262*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::TRANSIENT); 263*cdf0e10cSrcweir if (isVisible()) 264*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::VISIBLE); 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir return pStateSet; 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir uno::Reference<XAccessibleRelationSet> SAL_CALL 270*cdf0e10cSrcweir ScAccessibleCell::getAccessibleRelationSet(void) 271*cdf0e10cSrcweir throw (uno::RuntimeException) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir ScUnoGuard aGuard; 274*cdf0e10cSrcweir IsObjectValid(); 275*cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pRelationSet = NULL; 276*cdf0e10cSrcweir if (mpAccDoc) 277*cdf0e10cSrcweir pRelationSet = mpAccDoc->GetRelationSet(&maCellAddress); 278*cdf0e10cSrcweir if (!pRelationSet) 279*cdf0e10cSrcweir pRelationSet = new utl::AccessibleRelationSetHelper(); 280*cdf0e10cSrcweir FillDependends(pRelationSet); 281*cdf0e10cSrcweir FillPrecedents(pRelationSet); 282*cdf0e10cSrcweir return pRelationSet; 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir //===== XServiceInfo ==================================================== 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleCell::getImplementationName(void) 288*cdf0e10cSrcweir throw (uno::RuntimeException) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleCell")); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> SAL_CALL 294*cdf0e10cSrcweir ScAccessibleCell::getSupportedServiceNames(void) 295*cdf0e10cSrcweir throw (uno::RuntimeException) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames(); 298*cdf0e10cSrcweir sal_Int32 nOldSize(aSequence.getLength()); 299*cdf0e10cSrcweir aSequence.realloc(nOldSize + 1); 300*cdf0e10cSrcweir ::rtl::OUString* pNames = aSequence.getArray(); 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.AccessibleCell")); 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir return aSequence; 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir //==== internal ========================================================= 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir sal_Bool ScAccessibleCell::IsDefunc( 310*cdf0e10cSrcweir const uno::Reference<XAccessibleStateSet>& rxParentStates) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir return ScAccessibleContextBase::IsDefunc() || (mpDoc == NULL) || (mpViewShell == NULL) || !getAccessibleParent().is() || 313*cdf0e10cSrcweir (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC)); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir sal_Bool ScAccessibleCell::IsEditable( 317*cdf0e10cSrcweir const uno::Reference<XAccessibleStateSet>& rxParentStates) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir sal_Bool bEditable(sal_True); 320*cdf0e10cSrcweir if (rxParentStates.is() && !rxParentStates->contains(AccessibleStateType::EDITABLE) && 321*cdf0e10cSrcweir mpDoc) 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir // here I have to test whether the protection of the table should influence this cell. 324*cdf0e10cSrcweir const ScProtectionAttr* pItem = (const ScProtectionAttr*)mpDoc->GetAttr( 325*cdf0e10cSrcweir maCellAddress.Col(), maCellAddress.Row(), 326*cdf0e10cSrcweir maCellAddress.Tab(), ATTR_PROTECTION); 327*cdf0e10cSrcweir if (pItem) 328*cdf0e10cSrcweir bEditable = !pItem->GetProtection(); 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir return bEditable; 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir sal_Bool ScAccessibleCell::IsOpaque( 334*cdf0e10cSrcweir const uno::Reference<XAccessibleStateSet>& /* rxParentStates */) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir // test whether there is a background color 337*cdf0e10cSrcweir sal_Bool bOpaque(sal_True); 338*cdf0e10cSrcweir if (mpDoc) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir const SvxBrushItem* pItem = (const SvxBrushItem*)mpDoc->GetAttr( 341*cdf0e10cSrcweir maCellAddress.Col(), maCellAddress.Row(), 342*cdf0e10cSrcweir maCellAddress.Tab(), ATTR_BACKGROUND); 343*cdf0e10cSrcweir if (pItem) 344*cdf0e10cSrcweir bOpaque = pItem->GetColor() != COL_TRANSPARENT; 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir return bOpaque; 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir sal_Bool ScAccessibleCell::IsSelected() 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir sal_Bool bResult(sal_False); 352*cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData()) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData(); 355*cdf0e10cSrcweir bResult = rMarkdata.IsCellMarked(maCellAddress.Col(), maCellAddress.Row()); 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir return bResult; 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir ScDocument* ScAccessibleCell::GetDocument(ScTabViewShell* pViewShell) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir ScDocument* pDoc = NULL; 363*cdf0e10cSrcweir if (pViewShell && pViewShell->GetViewData()) 364*cdf0e10cSrcweir pDoc = pViewShell->GetViewData()->GetDocument(); 365*cdf0e10cSrcweir return pDoc; 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir ::std::auto_ptr< SvxEditSource > ScAccessibleCell::CreateEditSource(ScTabViewShell* pViewShell, ScAddress aCell, ScSplitPos eSplitPos) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir ::std::auto_ptr < ScAccessibleTextData > pAccessibleCellTextData 371*cdf0e10cSrcweir ( new ScAccessibleCellTextData( pViewShell, aCell, eSplitPos, this ) ); 372*cdf0e10cSrcweir ::std::auto_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(pAccessibleCellTextData)); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir return pEditSource; 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir void ScAccessibleCell::FillDependends(utl::AccessibleRelationSetHelper* pRelationSet) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir if (mpDoc) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir ScCellIterator aCellIter( mpDoc, 0,0, maCellAddress.Tab(), MAXCOL,MAXROW, maCellAddress.Tab() ); 382*cdf0e10cSrcweir ScBaseCell* pCell = aCellIter.GetFirst(); 383*cdf0e10cSrcweir while (pCell) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir if (pCell->GetCellType() == CELLTYPE_FORMULA) 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir sal_Bool bFound(sal_False); 388*cdf0e10cSrcweir ScDetectiveRefIter aIter( (ScFormulaCell*) pCell ); 389*cdf0e10cSrcweir ScRange aRef; 390*cdf0e10cSrcweir while ( !bFound && aIter.GetNextRef( aRef ) ) 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir if (aRef.In(maCellAddress)) 393*cdf0e10cSrcweir bFound = sal_True; 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir if (bFound) 396*cdf0e10cSrcweir AddRelation(ScAddress(aCellIter.GetCol(), aCellIter.GetRow(), aCellIter.GetTab()), AccessibleRelationType::CONTROLLER_FOR, pRelationSet); 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir pCell = aCellIter.GetNext(); 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir void ScAccessibleCell::FillPrecedents(utl::AccessibleRelationSetHelper* pRelationSet) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir if (mpDoc) 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir ScBaseCell* pBaseCell = mpDoc->GetCell(maCellAddress); 408*cdf0e10cSrcweir if (pBaseCell && (pBaseCell->GetCellType() == CELLTYPE_FORMULA)) 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir ScFormulaCell* pFCell = (ScFormulaCell*) pBaseCell; 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir ScDetectiveRefIter aIter( pFCell ); 413*cdf0e10cSrcweir ScRange aRef; 414*cdf0e10cSrcweir while ( aIter.GetNextRef( aRef ) ) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir AddRelation( aRef, AccessibleRelationType::CONTROLLED_BY, pRelationSet); 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir void ScAccessibleCell::AddRelation(const ScAddress& rCell, 423*cdf0e10cSrcweir const sal_uInt16 aRelationType, 424*cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pRelationSet) 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir AddRelation(ScRange(rCell, rCell), aRelationType, pRelationSet); 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir void ScAccessibleCell::AddRelation(const ScRange& rRange, 430*cdf0e10cSrcweir const sal_uInt16 aRelationType, 431*cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pRelationSet) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir uno::Reference < XAccessibleTable > xTable ( getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY ); 434*cdf0e10cSrcweir if (xTable.is()) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir sal_uInt32 nCount(static_cast<sal_uInt32>(rRange.aEnd.Col() - 437*cdf0e10cSrcweir rRange.aStart.Col() + 1) * (rRange.aEnd.Row() - 438*cdf0e10cSrcweir rRange.aStart.Row() + 1)); 439*cdf0e10cSrcweir uno::Sequence < uno::Reference < uno::XInterface > > aTargetSet( nCount ); 440*cdf0e10cSrcweir uno::Reference < uno::XInterface >* pTargetSet = aTargetSet.getArray(); 441*cdf0e10cSrcweir if (pTargetSet) 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir sal_uInt32 nPos(0); 444*cdf0e10cSrcweir for (sal_uInt32 nRow = rRange.aStart.Row(); nRow <= sal::static_int_cast<sal_uInt32>(rRange.aEnd.Row()); ++nRow) 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir for (sal_uInt32 nCol = rRange.aStart.Col(); nCol <= sal::static_int_cast<sal_uInt32>(rRange.aEnd.Col()); ++nCol) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir pTargetSet[nPos] = xTable->getAccessibleCellAt(nRow, nCol); 449*cdf0e10cSrcweir ++nPos; 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir DBG_ASSERT(nCount == nPos, "something wents wrong"); 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir AccessibleRelation aRelation; 455*cdf0e10cSrcweir aRelation.RelationType = aRelationType; 456*cdf0e10cSrcweir aRelation.TargetSet = aTargetSet; 457*cdf0e10cSrcweir pRelationSet->AddRelation(aRelation); 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir } 460