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 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include "AccessibleSpreadsheet.hxx" 29cdf0e10cSrcweir #include "AccessibilityHints.hxx" 30cdf0e10cSrcweir #include "AccessibleCell.hxx" 31cdf0e10cSrcweir #include "AccessibleDocument.hxx" 32cdf0e10cSrcweir #include "tabvwsh.hxx" 33cdf0e10cSrcweir #include "document.hxx" 34cdf0e10cSrcweir #include "unoguard.hxx" 35cdf0e10cSrcweir #include "hints.hxx" 36cdf0e10cSrcweir #include "scmod.hxx" 37cdf0e10cSrcweir 38cdf0e10cSrcweir #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX 39cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEROLE_HPP_ 42cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 43cdf0e10cSrcweir #endif 44cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLESTATETYPE_HPP_ 45cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 46cdf0e10cSrcweir #endif 47cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 48cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp> 49cdf0e10cSrcweir #include <rtl/uuid.h> 50cdf0e10cSrcweir #include <tools/debug.hxx> 51cdf0e10cSrcweir #include <tools/gen.hxx> 52cdf0e10cSrcweir #include <svtools/colorcfg.hxx> 530deba7fbSSteve Yin #include "scresid.hxx" 540deba7fbSSteve Yin #include "sc.hrc" 55cdf0e10cSrcweir #include <algorithm> 56cdf0e10cSrcweir 57cdf0e10cSrcweir using namespace ::com::sun::star; 58cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 59cdf0e10cSrcweir 600deba7fbSSteve Yin bool CompMinCol(const std::pair<sal_uInt16,sal_uInt16> & pc1,const std::pair<sal_uInt16,sal_uInt16> &pc2) 610deba7fbSSteve Yin { 620deba7fbSSteve Yin return pc1.first < pc2.first; 630deba7fbSSteve Yin } 640deba7fbSSteve Yin ScMyAddress ScAccessibleSpreadsheet::CalcScAddressFromRangeList(ScRangeList *pMarkedRanges,sal_Int32 nSelectedChildIndex) 650deba7fbSSteve Yin { 660deba7fbSSteve Yin if (pMarkedRanges->Count() <= 1) 670deba7fbSSteve Yin { 680deba7fbSSteve Yin ScRange* pRange = pMarkedRanges->First(); 690deba7fbSSteve Yin if (pRange) 700deba7fbSSteve Yin { 710deba7fbSSteve Yin // MT IA2: Not used. 720deba7fbSSteve Yin // const int nRowNum = pRange->aEnd.Row() - pRange->aStart.Row() + 1; 730deba7fbSSteve Yin const int nColNum = pRange->aEnd.Col() - pRange->aStart.Col() + 1; 740deba7fbSSteve Yin const int nCurCol = nSelectedChildIndex % nColNum; 750deba7fbSSteve Yin const int nCurRow = (nSelectedChildIndex - nCurCol)/nColNum; 760deba7fbSSteve Yin return ScMyAddress(static_cast<SCCOL>(pRange->aStart.Col() + nCurCol), pRange->aStart.Row() + nCurRow, maActiveCell.Tab()); 770deba7fbSSteve Yin } 780deba7fbSSteve Yin } 790deba7fbSSteve Yin else 800deba7fbSSteve Yin { 810deba7fbSSteve Yin sal_Int32 nMinRow = MAXROW; 820deba7fbSSteve Yin sal_Int32 nMaxRow = 0; 830deba7fbSSteve Yin m_vecTempRange.clear(); 840deba7fbSSteve Yin ScRange* pRange = pMarkedRanges->First(); 850deba7fbSSteve Yin while (pRange) 860deba7fbSSteve Yin { 870deba7fbSSteve Yin if (pRange->aStart.Tab() != pRange->aEnd.Tab()) 880deba7fbSSteve Yin { 890deba7fbSSteve Yin if ((maActiveCell.Tab() >= pRange->aStart.Tab()) || 900deba7fbSSteve Yin maActiveCell.Tab() <= pRange->aEnd.Tab()) 910deba7fbSSteve Yin { 920deba7fbSSteve Yin m_vecTempRange.push_back(pRange); 930deba7fbSSteve Yin nMinRow = std::min(pRange->aStart.Row(),nMinRow); 940deba7fbSSteve Yin nMaxRow = std::max(pRange->aEnd.Row(),nMaxRow); 950deba7fbSSteve Yin } 960deba7fbSSteve Yin else 970deba7fbSSteve Yin DBG_ERROR("Range of wrong table"); 980deba7fbSSteve Yin } 990deba7fbSSteve Yin else if(pRange->aStart.Tab() == maActiveCell.Tab()) 1000deba7fbSSteve Yin { 1010deba7fbSSteve Yin m_vecTempRange.push_back(pRange); 1020deba7fbSSteve Yin nMinRow = std::min(pRange->aStart.Row(),nMinRow); 1030deba7fbSSteve Yin nMaxRow = std::max(pRange->aEnd.Row(),nMaxRow); 1040deba7fbSSteve Yin } 1050deba7fbSSteve Yin else 1060deba7fbSSteve Yin DBG_ERROR("Range of wrong table"); 1070deba7fbSSteve Yin pRange = pMarkedRanges->Next(); 1080deba7fbSSteve Yin } 1090deba7fbSSteve Yin int nCurrentIndex = 0 ; 1100deba7fbSSteve Yin for(sal_Int32 row = nMinRow ; row <= nMaxRow ; ++row) 1110deba7fbSSteve Yin { 1120deba7fbSSteve Yin m_vecTempCol.clear(); 1130deba7fbSSteve Yin { 1140deba7fbSSteve Yin VEC_RANGE::const_iterator vi = m_vecTempRange.begin(); 1150deba7fbSSteve Yin for (; vi < m_vecTempRange.end(); ++vi) 1160deba7fbSSteve Yin { 1170deba7fbSSteve Yin ScRange *p = *vi; 1180deba7fbSSteve Yin if ( row >= p->aStart.Row() && row <= p->aEnd.Row()) 1190deba7fbSSteve Yin { 1200deba7fbSSteve Yin m_vecTempCol.push_back(std::make_pair(p->aStart.Col(),p->aEnd.Col())); 1210deba7fbSSteve Yin } 1220deba7fbSSteve Yin } 1230deba7fbSSteve Yin } 1240deba7fbSSteve Yin std::sort(m_vecTempCol.begin(),m_vecTempCol.end(),CompMinCol); 1250deba7fbSSteve Yin { 1260deba7fbSSteve Yin VEC_COL::const_iterator vic = m_vecTempCol.begin(); 1270deba7fbSSteve Yin for(; vic != m_vecTempCol.end(); ++vic) 1280deba7fbSSteve Yin { 1290deba7fbSSteve Yin const PAIR_COL &pariCol = *vic; 1300deba7fbSSteve Yin sal_uInt16 nCol = pariCol.second - pariCol.first + 1; 1310deba7fbSSteve Yin if (nCol + nCurrentIndex > nSelectedChildIndex) 1320deba7fbSSteve Yin { 1330deba7fbSSteve Yin return ScMyAddress(static_cast<SCCOL>(pariCol.first + nSelectedChildIndex - nCurrentIndex), row, maActiveCell.Tab()); 1340deba7fbSSteve Yin } 1350deba7fbSSteve Yin nCurrentIndex += nCol; 1360deba7fbSSteve Yin } 1370deba7fbSSteve Yin } 1380deba7fbSSteve Yin } 1390deba7fbSSteve Yin } 1400deba7fbSSteve Yin return ScMyAddress(0,0,maActiveCell.Tab()); 1410deba7fbSSteve Yin } 1420deba7fbSSteve Yin sal_Bool ScAccessibleSpreadsheet::CalcScRangeDifferenceMax(ScRange *pSrc,ScRange *pDest,int nMax,VEC_MYADDR &vecRet,int &nSize) 1430deba7fbSSteve Yin { 1440deba7fbSSteve Yin //Src Must be :Src > Dest 1450deba7fbSSteve Yin if (pDest->In(*pSrc)) 1460deba7fbSSteve Yin {//Here is Src In Dest,Src <= Dest 1470deba7fbSSteve Yin return sal_False; 1480deba7fbSSteve Yin } 1490deba7fbSSteve Yin if (!pDest->Intersects(*pSrc)) 1500deba7fbSSteve Yin { 1510deba7fbSSteve Yin int nCellCount = sal_uInt32(pDest->aEnd.Col() - pDest->aStart.Col() + 1) 1520deba7fbSSteve Yin * sal_uInt32(pDest->aEnd.Row() - pDest->aStart.Row() + 1) 1530deba7fbSSteve Yin * sal_uInt32(pDest->aEnd.Tab() - pDest->aStart.Tab() + 1); 1540deba7fbSSteve Yin if (nCellCount + nSize > nMax) 1550deba7fbSSteve Yin { 1560deba7fbSSteve Yin return sal_True; 1570deba7fbSSteve Yin } 1580deba7fbSSteve Yin else if(nCellCount > 0) 1590deba7fbSSteve Yin { 1600deba7fbSSteve Yin nCellCount +=nSize; 1610deba7fbSSteve Yin for (sal_Int32 row = pDest->aStart.Row(); row <= pDest->aEnd.Row();++row) 1620deba7fbSSteve Yin { 1630deba7fbSSteve Yin for (sal_uInt16 col = pDest->aStart.Col(); col <= pDest->aEnd.Col();++col) 1640deba7fbSSteve Yin { 1650deba7fbSSteve Yin vecRet.push_back(ScMyAddress(col,row,pDest->aStart.Tab())); 1660deba7fbSSteve Yin } 1670deba7fbSSteve Yin } 1680deba7fbSSteve Yin } 1690deba7fbSSteve Yin return sal_False; 1700deba7fbSSteve Yin } 1710deba7fbSSteve Yin sal_Int32 nMinRow = pSrc->aStart.Row(); 1720deba7fbSSteve Yin sal_Int32 nMaxRow = pSrc->aEnd.Row(); 1730deba7fbSSteve Yin for (; nMinRow <= nMaxRow ; ++nMinRow,--nMaxRow) 1740deba7fbSSteve Yin { 1750deba7fbSSteve Yin for (sal_uInt16 col = pSrc->aStart.Col(); col <= pSrc->aEnd.Col();++col) 1760deba7fbSSteve Yin { 1770deba7fbSSteve Yin if (nSize > nMax) 1780deba7fbSSteve Yin { 1790deba7fbSSteve Yin return sal_True; 1800deba7fbSSteve Yin } 1810deba7fbSSteve Yin ScMyAddress cell(col,nMinRow,pSrc->aStart.Tab()); 1820deba7fbSSteve Yin if(!pDest->In(cell)) 1830deba7fbSSteve Yin {//In Src ,Not In Dest 1840deba7fbSSteve Yin vecRet.push_back(cell); 1850deba7fbSSteve Yin ++nSize; 1860deba7fbSSteve Yin } 1870deba7fbSSteve Yin } 1880deba7fbSSteve Yin if (nMinRow != nMaxRow) 1890deba7fbSSteve Yin { 1900deba7fbSSteve Yin for (sal_uInt16 col = pSrc->aStart.Col(); col <= pSrc->aEnd.Col();++col) 1910deba7fbSSteve Yin { 1920deba7fbSSteve Yin if (nSize > nMax) 1930deba7fbSSteve Yin { 1940deba7fbSSteve Yin return sal_True; 1950deba7fbSSteve Yin } 1960deba7fbSSteve Yin ScMyAddress cell(col,nMaxRow,pSrc->aStart.Tab()); 1970deba7fbSSteve Yin if(!pDest->In(cell)) 1980deba7fbSSteve Yin {//In Src ,Not In Dest 1990deba7fbSSteve Yin vecRet.push_back(cell); 2000deba7fbSSteve Yin ++nSize; 2010deba7fbSSteve Yin } 2020deba7fbSSteve Yin } 2030deba7fbSSteve Yin } 2040deba7fbSSteve Yin } 2050deba7fbSSteve Yin return sal_False; 2060deba7fbSSteve Yin } 2070deba7fbSSteve Yin //In Src , Not in Dest 2080deba7fbSSteve Yin sal_Bool ScAccessibleSpreadsheet::CalcScRangeListDifferenceMax(ScRangeList *pSrc,ScRangeList *pDest,int nMax,VEC_MYADDR &vecRet) 2090deba7fbSSteve Yin { 2100deba7fbSSteve Yin if (pSrc == NULL || pDest == NULL) 2110deba7fbSSteve Yin { 2120deba7fbSSteve Yin return sal_False; 2130deba7fbSSteve Yin } 2140deba7fbSSteve Yin int nSize =0; 2150deba7fbSSteve Yin if (pDest->GetCellCount() == 0)//if the Dest Rang List is empty 2160deba7fbSSteve Yin { 2170deba7fbSSteve Yin if (pSrc->GetCellCount() > sal_uInt32(nMax))//if the Src Cell count is greater then nMax 2180deba7fbSSteve Yin { 2190deba7fbSSteve Yin return sal_True; 2200deba7fbSSteve Yin } 2210deba7fbSSteve Yin //now the cell count is less then nMax 2220deba7fbSSteve Yin vecRet.reserve(10); 2230deba7fbSSteve Yin ScRange* pRange = pSrc->First(); 2240deba7fbSSteve Yin while (pRange) 2250deba7fbSSteve Yin { 2260deba7fbSSteve Yin for (sal_Int32 row = pRange->aStart.Row(); row <= pRange->aEnd.Row();++row) 2270deba7fbSSteve Yin { 2280deba7fbSSteve Yin for (sal_uInt16 col = pRange->aStart.Col(); col <= pRange->aEnd.Col();++col) 2290deba7fbSSteve Yin { 2300deba7fbSSteve Yin vecRet.push_back(ScMyAddress(col,row,pRange->aStart.Tab())); 2310deba7fbSSteve Yin } 2320deba7fbSSteve Yin } 2330deba7fbSSteve Yin pRange = pSrc->Next(); 2340deba7fbSSteve Yin } 2350deba7fbSSteve Yin return sal_False; 2360deba7fbSSteve Yin } 2370deba7fbSSteve Yin //the Dest Rang List is not empty 2380deba7fbSSteve Yin vecRet.reserve(10); 2390deba7fbSSteve Yin ScRange* pRange = pSrc->First(); 2400deba7fbSSteve Yin while (pRange) 2410deba7fbSSteve Yin { 2420deba7fbSSteve Yin ScRange* pRangeDest = pDest->First(); 2430deba7fbSSteve Yin while (pRangeDest) 2440deba7fbSSteve Yin { 2450deba7fbSSteve Yin if (CalcScRangeDifferenceMax(pRange,pRangeDest,nMax,vecRet,nSize)) 2460deba7fbSSteve Yin { 2470deba7fbSSteve Yin return sal_True; 2480deba7fbSSteve Yin } 2490deba7fbSSteve Yin pRangeDest = pDest->Next(); 2500deba7fbSSteve Yin } 2510deba7fbSSteve Yin pRange = pSrc->Next(); 2520deba7fbSSteve Yin } 2530deba7fbSSteve Yin return sal_False; 2540deba7fbSSteve Yin } 255cdf0e10cSrcweir //===== internal ============================================================ 256cdf0e10cSrcweir 257cdf0e10cSrcweir ScAccessibleSpreadsheet::ScAccessibleSpreadsheet( 258cdf0e10cSrcweir ScAccessibleDocument* pAccDoc, 259cdf0e10cSrcweir ScTabViewShell* pViewShell, 260cdf0e10cSrcweir SCTAB nTab, 261cdf0e10cSrcweir ScSplitPos eSplitPos) 262cdf0e10cSrcweir : 263cdf0e10cSrcweir ScAccessibleTableBase (pAccDoc, GetDocument(pViewShell), 264cdf0e10cSrcweir ScRange(ScAddress(0, 0, nTab),ScAddress(MAXCOL, MAXROW, nTab))), 2650deba7fbSSteve Yin mbIsSpreadsheet( sal_True ), 2660deba7fbSSteve Yin m_bFormulaMode(sal_False), 2670deba7fbSSteve Yin m_bFormulaLastMode(sal_False), 2680deba7fbSSteve Yin m_pAccFormulaCell(NULL), 2690deba7fbSSteve Yin m_nMinX(0),m_nMaxX(0),m_nMinY(0),m_nMaxY(0) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir ConstructScAccessibleSpreadsheet( pAccDoc, pViewShell, nTab, eSplitPos ); 272cdf0e10cSrcweir } 273cdf0e10cSrcweir 274cdf0e10cSrcweir ScAccessibleSpreadsheet::ScAccessibleSpreadsheet( 275cdf0e10cSrcweir ScAccessibleSpreadsheet& rParent, const ScRange& rRange ) : 276cdf0e10cSrcweir ScAccessibleTableBase( rParent.mpAccDoc, rParent.mpDoc, rRange), 277cdf0e10cSrcweir mbIsSpreadsheet( sal_False ) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir ConstructScAccessibleSpreadsheet( rParent.mpAccDoc, rParent.mpViewShell, rParent.mnTab, rParent.meSplitPos ); 280cdf0e10cSrcweir } 281cdf0e10cSrcweir 282cdf0e10cSrcweir ScAccessibleSpreadsheet::~ScAccessibleSpreadsheet() 283cdf0e10cSrcweir { 284cdf0e10cSrcweir if (mpMarkedRanges) 285cdf0e10cSrcweir delete mpMarkedRanges; 286cdf0e10cSrcweir if (mpViewShell) 287cdf0e10cSrcweir mpViewShell->RemoveAccessibilityObject(*this); 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir void ScAccessibleSpreadsheet::ConstructScAccessibleSpreadsheet( 291cdf0e10cSrcweir ScAccessibleDocument* pAccDoc, 292cdf0e10cSrcweir ScTabViewShell* pViewShell, 293cdf0e10cSrcweir SCTAB nTab, 294cdf0e10cSrcweir ScSplitPos eSplitPos) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir mpViewShell = pViewShell; 297cdf0e10cSrcweir mpMarkedRanges = 0; 298cdf0e10cSrcweir mpSortedMarkedCells = 0; 299cdf0e10cSrcweir mpAccDoc = pAccDoc; 300cdf0e10cSrcweir mpAccCell = 0; 301cdf0e10cSrcweir meSplitPos = eSplitPos; 302cdf0e10cSrcweir mnTab = nTab; 303cdf0e10cSrcweir mbHasSelection = sal_False; 304cdf0e10cSrcweir mbDelIns = sal_False; 305cdf0e10cSrcweir mbIsFocusSend = sal_False; 306cdf0e10cSrcweir maVisCells = GetVisCells(GetVisArea(mpViewShell, meSplitPos)); 307cdf0e10cSrcweir if (mpViewShell) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir mpViewShell->AddAccessibilityObject(*this); 310cdf0e10cSrcweir 311cdf0e10cSrcweir const ScViewData& rViewData = *mpViewShell->GetViewData(); 312cdf0e10cSrcweir const ScMarkData& rMarkData = rViewData.GetMarkData(); 313cdf0e10cSrcweir maActiveCell = rViewData.GetCurPos(); 314cdf0e10cSrcweir mbHasSelection = rMarkData.GetTableSelect(maActiveCell.Tab()) && 315cdf0e10cSrcweir (rMarkData.IsMarked() || rMarkData.IsMultiMarked()); 316cdf0e10cSrcweir mpAccCell = GetAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col()); 317cdf0e10cSrcweir mpAccCell->acquire(); 318cdf0e10cSrcweir mpAccCell->Init(); 3190deba7fbSSteve Yin ScDocument* pScDoc= GetDocument(mpViewShell); 3200deba7fbSSteve Yin if (pScDoc) 3210deba7fbSSteve Yin { 3220deba7fbSSteve Yin pScDoc->GetName( maActiveCell.Tab(), m_strOldTabName ); 3230deba7fbSSteve Yin } 324cdf0e10cSrcweir } 325cdf0e10cSrcweir } 326cdf0e10cSrcweir 327cdf0e10cSrcweir void SAL_CALL ScAccessibleSpreadsheet::disposing() 328cdf0e10cSrcweir { 329cdf0e10cSrcweir ScUnoGuard aGuard; 330cdf0e10cSrcweir if (mpViewShell) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir mpViewShell->RemoveAccessibilityObject(*this); 333cdf0e10cSrcweir mpViewShell = NULL; 334cdf0e10cSrcweir } 335cdf0e10cSrcweir if (mpAccCell) 336cdf0e10cSrcweir { 337cdf0e10cSrcweir mpAccCell->release(); 338cdf0e10cSrcweir mpAccCell = NULL; 339cdf0e10cSrcweir } 340cdf0e10cSrcweir 341cdf0e10cSrcweir ScAccessibleTableBase::disposing(); 342cdf0e10cSrcweir } 343cdf0e10cSrcweir 344cdf0e10cSrcweir void ScAccessibleSpreadsheet::CompleteSelectionChanged(sal_Bool bNewState) 345cdf0e10cSrcweir { 3460deba7fbSSteve Yin if (IsFormulaMode()) 3470deba7fbSSteve Yin { 3480deba7fbSSteve Yin return ; 3490deba7fbSSteve Yin } 350cdf0e10cSrcweir if (mpMarkedRanges) 351cdf0e10cSrcweir DELETEZ(mpMarkedRanges); 352cdf0e10cSrcweir mbHasSelection = bNewState; 353cdf0e10cSrcweir 354cdf0e10cSrcweir AccessibleEventObject aEvent; 355cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::STATE_CHANGED; 356cdf0e10cSrcweir if (bNewState) 357cdf0e10cSrcweir aEvent.NewValue = uno::makeAny(AccessibleStateType::SELECTED); 358cdf0e10cSrcweir else 359cdf0e10cSrcweir aEvent.OldValue = uno::makeAny(AccessibleStateType::SELECTED); 360cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 361cdf0e10cSrcweir 362cdf0e10cSrcweir CommitChange(aEvent); 363cdf0e10cSrcweir } 364cdf0e10cSrcweir 365cdf0e10cSrcweir void ScAccessibleSpreadsheet::LostFocus() 366cdf0e10cSrcweir { 367cdf0e10cSrcweir AccessibleEventObject aEvent; 368cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; 369cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 370cdf0e10cSrcweir uno::Reference< XAccessible > xOld = mpAccCell; 371cdf0e10cSrcweir aEvent.OldValue <<= xOld; 372cdf0e10cSrcweir 373cdf0e10cSrcweir CommitChange(aEvent); 374cdf0e10cSrcweir 375cdf0e10cSrcweir CommitFocusLost(); 376cdf0e10cSrcweir } 377cdf0e10cSrcweir 378cdf0e10cSrcweir void ScAccessibleSpreadsheet::GotFocus() 379cdf0e10cSrcweir { 380cdf0e10cSrcweir AccessibleEventObject aEvent; 381cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; 382cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 3830deba7fbSSteve Yin uno::Reference< XAccessible > xNew; 3840deba7fbSSteve Yin if (IsFormulaMode()) 3850deba7fbSSteve Yin { 3860deba7fbSSteve Yin if (!m_pAccFormulaCell || !m_bFormulaLastMode) 3870deba7fbSSteve Yin { 3880deba7fbSSteve Yin ScAddress aFormulaAddr; 3890deba7fbSSteve Yin if(!GetFormulaCurrentFocusCell(aFormulaAddr)) 3900deba7fbSSteve Yin { 3910deba7fbSSteve Yin return; 3920deba7fbSSteve Yin } 3930deba7fbSSteve Yin m_pAccFormulaCell = GetAccessibleCellAt(aFormulaAddr.Row(),aFormulaAddr.Col()); 3940deba7fbSSteve Yin 3950deba7fbSSteve Yin m_pAccFormulaCell->acquire(); 3960deba7fbSSteve Yin m_pAccFormulaCell->Init(); 3970deba7fbSSteve Yin 3980deba7fbSSteve Yin 3990deba7fbSSteve Yin } 4000deba7fbSSteve Yin xNew = m_pAccFormulaCell; 4010deba7fbSSteve Yin } 4020deba7fbSSteve Yin else 4030deba7fbSSteve Yin { 4040deba7fbSSteve Yin if(mpAccCell->GetCellAddress() == maActiveCell) 4050deba7fbSSteve Yin { 4060deba7fbSSteve Yin xNew = mpAccCell; 4070deba7fbSSteve Yin } 4080deba7fbSSteve Yin else 4090deba7fbSSteve Yin { 4100deba7fbSSteve Yin CommitFocusCell(maActiveCell); 4110deba7fbSSteve Yin return ; 4120deba7fbSSteve Yin } 4130deba7fbSSteve Yin } 414cdf0e10cSrcweir aEvent.NewValue <<= xNew; 415cdf0e10cSrcweir 416cdf0e10cSrcweir CommitChange(aEvent); 417cdf0e10cSrcweir } 418cdf0e10cSrcweir 419cdf0e10cSrcweir void ScAccessibleSpreadsheet::BoundingBoxChanged() 420cdf0e10cSrcweir { 421cdf0e10cSrcweir AccessibleEventObject aEvent; 422cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED; 423cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 424cdf0e10cSrcweir 425cdf0e10cSrcweir CommitChange(aEvent); 426cdf0e10cSrcweir } 427cdf0e10cSrcweir 428cdf0e10cSrcweir void ScAccessibleSpreadsheet::VisAreaChanged() 429cdf0e10cSrcweir { 430cdf0e10cSrcweir AccessibleEventObject aEvent; 431cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED; 432cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 433cdf0e10cSrcweir 434cdf0e10cSrcweir CommitChange(aEvent); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir //===== SfxListener ===================================================== 438cdf0e10cSrcweir 439cdf0e10cSrcweir void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir if (rHint.ISA( SfxSimpleHint ) ) 442cdf0e10cSrcweir { 443cdf0e10cSrcweir const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint; 444cdf0e10cSrcweir if ((rRef.GetId() == SC_HINT_ACC_CURSORCHANGED)) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir if (mpViewShell) 447cdf0e10cSrcweir { 4480deba7fbSSteve Yin ScViewData *pViewData = mpViewShell->GetViewData(); 4490deba7fbSSteve Yin 4500deba7fbSSteve Yin m_bFormulaMode = pViewData->IsRefMode() || SC_MOD()->IsFormulaMode(); 4510deba7fbSSteve Yin if ( m_bFormulaMode ) 452cdf0e10cSrcweir { 4530deba7fbSSteve Yin NotifyRefMode(); 4540deba7fbSSteve Yin m_bFormulaLastMode = true; 4550deba7fbSSteve Yin return ; 4560deba7fbSSteve Yin } 4570deba7fbSSteve Yin if (m_bFormulaLastMode) 4580deba7fbSSteve Yin {//Last Notify Mode Is Formula Mode. 4590deba7fbSSteve Yin m_vecFormulaLastMyAddr.clear(); 4600deba7fbSSteve Yin RemoveFormulaSelection(sal_True); 4610deba7fbSSteve Yin if(m_pAccFormulaCell) 4620deba7fbSSteve Yin { 4630deba7fbSSteve Yin m_pAccFormulaCell->release(); 4640deba7fbSSteve Yin m_pAccFormulaCell =NULL; 4650deba7fbSSteve Yin } 4660deba7fbSSteve Yin //Remove All Selection 4670deba7fbSSteve Yin } 4680deba7fbSSteve Yin m_bFormulaLastMode = m_bFormulaMode; 4690deba7fbSSteve Yin 470cdf0e10cSrcweir AccessibleEventObject aEvent; 4710deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(this); 4720deba7fbSSteve Yin ScAddress aNewCell = pViewData->GetCurPos(); 4730deba7fbSSteve Yin if(aNewCell.Tab() != maActiveCell.Tab()) 4740deba7fbSSteve Yin { 4750deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::PAGE_CHANGED; 4760deba7fbSSteve Yin ScAccessibleDocument *pAccDoc = 4770deba7fbSSteve Yin static_cast<ScAccessibleDocument*>(getAccessibleParent().get()); 4780deba7fbSSteve Yin if(pAccDoc) 4790deba7fbSSteve Yin { 4800deba7fbSSteve Yin pAccDoc->CommitChange(aEvent); 4810deba7fbSSteve Yin } 4820deba7fbSSteve Yin } 483*4b4244d8SSteve Yin sal_Bool bNewPosCell = (aNewCell != maActiveCell) || mpViewShell->GetForceFocusOnCurCell(); // i123629 4840deba7fbSSteve Yin sal_Bool bNewPosCellFocus=sal_False; 4850deba7fbSSteve Yin if ( bNewPosCell && IsFocused() && aNewCell.Tab() == maActiveCell.Tab() ) 4860deba7fbSSteve Yin {//single Focus 4870deba7fbSSteve Yin bNewPosCellFocus=sal_True; 4880deba7fbSSteve Yin } 4890deba7fbSSteve Yin ScMarkData &refScMarkData = pViewData->GetMarkData(); 4900deba7fbSSteve Yin // MT IA2: Not used 4910deba7fbSSteve Yin // int nSelCount = refScMarkData.GetSelectCount(); 4920deba7fbSSteve Yin sal_Bool bIsMark =refScMarkData.IsMarked(); 4930deba7fbSSteve Yin sal_Bool bIsMultMark = refScMarkData.IsMultiMarked(); 4940deba7fbSSteve Yin sal_Bool bNewMarked = refScMarkData.GetTableSelect(aNewCell.Tab()) && ( bIsMark || bIsMultMark ); 4950deba7fbSSteve Yin // sal_Bool bNewCellSelected = isAccessibleSelected(aNewCell.Row(), aNewCell.Col()); 4960deba7fbSSteve Yin sal_uInt16 nTab = pViewData->GetTabNo(); 4970deba7fbSSteve Yin ScRange aMarkRange; 4980deba7fbSSteve Yin refScMarkData.GetMarkArea(aMarkRange); 4990deba7fbSSteve Yin aEvent.OldValue <<= ::com::sun::star::uno::Any(); 5000deba7fbSSteve Yin //Mark All 5010deba7fbSSteve Yin if ( !bNewPosCellFocus && 5020deba7fbSSteve Yin (bNewMarked || bIsMark || bIsMultMark ) && 5030deba7fbSSteve Yin aMarkRange == ScRange( 0,0,nTab, MAXCOL,MAXROW,nTab ) ) 5040deba7fbSSteve Yin { 5050deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; 5060deba7fbSSteve Yin aEvent.NewValue <<= ::com::sun::star::uno::Any(); 5070deba7fbSSteve Yin CommitChange(aEvent); 5080deba7fbSSteve Yin return ; 5090deba7fbSSteve Yin } 5100deba7fbSSteve Yin if (!mpMarkedRanges) 5110deba7fbSSteve Yin { 5120deba7fbSSteve Yin mpMarkedRanges = new ScRangeList(); 5130deba7fbSSteve Yin } 5140deba7fbSSteve Yin refScMarkData.FillRangeListWithMarks(mpMarkedRanges, sal_True); 515cdf0e10cSrcweir 5160deba7fbSSteve Yin //For Whole Col Row 5170deba7fbSSteve Yin sal_Bool bWholeRow = ::labs(aMarkRange.aStart.Row() - aMarkRange.aEnd.Row()) == MAXROW ; 5180deba7fbSSteve Yin sal_Bool bWholeCol = ::abs(aMarkRange.aStart.Col() - aMarkRange.aEnd.Col()) == MAXCOL ; 5190deba7fbSSteve Yin if ((bNewMarked || bIsMark || bIsMultMark ) && (bWholeCol || bWholeRow)) 5200deba7fbSSteve Yin { 5210deba7fbSSteve Yin if ( aMarkRange != m_aLastWithInMarkRange ) 5220deba7fbSSteve Yin { 5230deba7fbSSteve Yin RemoveSelection(refScMarkData); 5240deba7fbSSteve Yin if(bNewPosCell) 5250deba7fbSSteve Yin { 5260deba7fbSSteve Yin CommitFocusCell(aNewCell); 5270deba7fbSSteve Yin } 5280deba7fbSSteve Yin sal_Bool bLastIsWholeColRow = 5290deba7fbSSteve Yin ::labs(m_aLastWithInMarkRange.aStart.Row() - m_aLastWithInMarkRange.aEnd.Row()) == MAXROW && bWholeRow || 5300deba7fbSSteve Yin ::abs(m_aLastWithInMarkRange.aStart.Col() - m_aLastWithInMarkRange.aEnd.Col()) == MAXCOL && bWholeCol ; 5310deba7fbSSteve Yin sal_Bool bSelSmaller= 5320deba7fbSSteve Yin bLastIsWholeColRow && 5330deba7fbSSteve Yin !aMarkRange.In(m_aLastWithInMarkRange) && 5340deba7fbSSteve Yin aMarkRange.Intersects(m_aLastWithInMarkRange); 5350deba7fbSSteve Yin if( !bSelSmaller ) 5360deba7fbSSteve Yin { 5370deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; 5380deba7fbSSteve Yin aEvent.NewValue <<= ::com::sun::star::uno::Any(); 539cdf0e10cSrcweir CommitChange(aEvent); 540cdf0e10cSrcweir } 5410deba7fbSSteve Yin m_aLastWithInMarkRange = aMarkRange; 5420deba7fbSSteve Yin } 5430deba7fbSSteve Yin return ; 5440deba7fbSSteve Yin } 5450deba7fbSSteve Yin m_aLastWithInMarkRange = aMarkRange; 5460deba7fbSSteve Yin int nNewMarkCount = mpMarkedRanges->GetCellCount(); 5470deba7fbSSteve Yin sal_Bool bSendSingle= (0 == nNewMarkCount) && bNewPosCell; 5480deba7fbSSteve Yin if (bSendSingle) 5490deba7fbSSteve Yin { 5500deba7fbSSteve Yin RemoveSelection(refScMarkData); 5510deba7fbSSteve Yin if(bNewPosCellFocus) 5520deba7fbSSteve Yin { 5530deba7fbSSteve Yin CommitFocusCell(aNewCell); 5540deba7fbSSteve Yin } 5550deba7fbSSteve Yin uno::Reference< XAccessible > xChild ; 5560deba7fbSSteve Yin if (bNewPosCellFocus) 5570deba7fbSSteve Yin { 5580deba7fbSSteve Yin xChild = mpAccCell; 5590deba7fbSSteve Yin } 5600deba7fbSSteve Yin else 5610deba7fbSSteve Yin { 5620deba7fbSSteve Yin xChild = getAccessibleCellAt(aNewCell.Row(),aNewCell.Col()); 563cdf0e10cSrcweir 564cdf0e10cSrcweir maActiveCell = aNewCell; 5650deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS; 5660deba7fbSSteve Yin aEvent.NewValue <<= xChild; 5670deba7fbSSteve Yin aEvent.OldValue <<= uno::Reference< XAccessible >(); 568cdf0e10cSrcweir CommitChange(aEvent); 569cdf0e10cSrcweir } 5700deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; 5710deba7fbSSteve Yin aEvent.NewValue <<= xChild; 5720deba7fbSSteve Yin CommitChange(aEvent); 5730deba7fbSSteve Yin OSL_ASSERT(m_mapSelectionSend.count(aNewCell) == 0 ); 5740deba7fbSSteve Yin m_mapSelectionSend.insert(MAP_ADDR_XACC::value_type(aNewCell,xChild)); 5750deba7fbSSteve Yin 5760deba7fbSSteve Yin } 5770deba7fbSSteve Yin else 5780deba7fbSSteve Yin { 5790deba7fbSSteve Yin ScRange aDelRange; 5800deba7fbSSteve Yin sal_Bool bIsDel = pViewData->GetDelMark( aDelRange ); 5810deba7fbSSteve Yin if ( (!bIsDel || (bIsDel && aMarkRange != aDelRange)) && 5820deba7fbSSteve Yin bNewMarked && 5830deba7fbSSteve Yin nNewMarkCount > 0 && 5840deba7fbSSteve Yin !IsSameMarkCell() ) 5850deba7fbSSteve Yin { 5860deba7fbSSteve Yin RemoveSelection(refScMarkData); 5870deba7fbSSteve Yin if(bNewPosCellFocus) 5880deba7fbSSteve Yin { 5890deba7fbSSteve Yin CommitFocusCell(aNewCell); 5900deba7fbSSteve Yin } 5910deba7fbSSteve Yin VEC_MYADDR vecNew; 5920deba7fbSSteve Yin if(CalcScRangeListDifferenceMax(mpMarkedRanges,&m_LastMarkedRanges,10,vecNew)) 5930deba7fbSSteve Yin { 5940deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; 5950deba7fbSSteve Yin aEvent.NewValue <<= ::com::sun::star::uno::Any(); 5960deba7fbSSteve Yin CommitChange(aEvent); 5970deba7fbSSteve Yin } 5980deba7fbSSteve Yin else 5990deba7fbSSteve Yin { 6000deba7fbSSteve Yin VEC_MYADDR::iterator viAddr = vecNew.begin(); 6010deba7fbSSteve Yin for(; viAddr < vecNew.end() ; ++viAddr ) 6020deba7fbSSteve Yin { 6030deba7fbSSteve Yin uno::Reference< XAccessible > xChild = getAccessibleCellAt(viAddr->Row(),viAddr->Col()); 6040deba7fbSSteve Yin if (!(bNewPosCellFocus && *viAddr == aNewCell) ) 6050deba7fbSSteve Yin { 6060deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS; 6070deba7fbSSteve Yin aEvent.NewValue <<= xChild; 6080deba7fbSSteve Yin CommitChange(aEvent); 6090deba7fbSSteve Yin } 6100deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD; 6110deba7fbSSteve Yin aEvent.NewValue <<= xChild; 6120deba7fbSSteve Yin CommitChange(aEvent); 6130deba7fbSSteve Yin m_mapSelectionSend.insert(MAP_ADDR_XACC::value_type(*viAddr,xChild)); 6140deba7fbSSteve Yin } 6150deba7fbSSteve Yin } 6160deba7fbSSteve Yin } 6170deba7fbSSteve Yin } 6180deba7fbSSteve Yin if (bNewPosCellFocus && maActiveCell != aNewCell) 6190deba7fbSSteve Yin { 6200deba7fbSSteve Yin CommitFocusCell(aNewCell); 6210deba7fbSSteve Yin } 6220deba7fbSSteve Yin m_LastMarkedRanges = *mpMarkedRanges; 623cdf0e10cSrcweir } 624cdf0e10cSrcweir } 625cdf0e10cSrcweir else if ((rRef.GetId() == SC_HINT_DATACHANGED)) 626cdf0e10cSrcweir { 627cdf0e10cSrcweir if (!mbDelIns) 628cdf0e10cSrcweir CommitTableModelChange(maRange.aStart.Row(), maRange.aStart.Col(), maRange.aEnd.Row(), maRange.aEnd.Col(), AccessibleTableModelChangeType::UPDATE); 629cdf0e10cSrcweir else 630cdf0e10cSrcweir mbDelIns = sal_False; 6310deba7fbSSteve Yin ScViewData *pViewData = mpViewShell->GetViewData(); 6320deba7fbSSteve Yin ScAddress aNewCell = pViewData->GetCurPos(); 6330deba7fbSSteve Yin if( maActiveCell == aNewCell) 6340deba7fbSSteve Yin { 6350deba7fbSSteve Yin ScDocument* pScDoc= GetDocument(mpViewShell); 6360deba7fbSSteve Yin if (pScDoc) 6370deba7fbSSteve Yin { 6380deba7fbSSteve Yin String valStr; 6390deba7fbSSteve Yin pScDoc->GetString(aNewCell.Col(),aNewCell.Row(),aNewCell.Tab(), valStr); 6400deba7fbSSteve Yin if(m_strCurCellValue != valStr) 6410deba7fbSSteve Yin { 6420deba7fbSSteve Yin AccessibleEventObject aEvent; 6430deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::VALUE_CHANGED; 6440deba7fbSSteve Yin mpAccCell->CommitChange(aEvent); 6450deba7fbSSteve Yin m_strCurCellValue=valStr; 646cdf0e10cSrcweir } 6470deba7fbSSteve Yin String tabName; 6480deba7fbSSteve Yin pScDoc->GetName( maActiveCell.Tab(), tabName ); 6490deba7fbSSteve Yin if( m_strOldTabName != tabName ) 6500deba7fbSSteve Yin { 6510deba7fbSSteve Yin AccessibleEventObject aEvent; 6520deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::NAME_CHANGED; 6530deba7fbSSteve Yin String sOldName(ScResId(STR_ACC_TABLE_NAME)); 6540deba7fbSSteve Yin sOldName.SearchAndReplaceAscii("%1", m_strOldTabName); 6550deba7fbSSteve Yin aEvent.OldValue <<= ::rtl::OUString( sOldName ); 6560deba7fbSSteve Yin String sNewName(ScResId(STR_ACC_TABLE_NAME)); 6570deba7fbSSteve Yin sNewName.SearchAndReplaceAscii("%1", tabName); 6580deba7fbSSteve Yin aEvent.NewValue <<= ::rtl::OUString( sNewName ); 6590deba7fbSSteve Yin CommitChange( aEvent ); 6600deba7fbSSteve Yin m_strOldTabName = tabName; 6610deba7fbSSteve Yin } 6620deba7fbSSteve Yin } 6630deba7fbSSteve Yin } 6640deba7fbSSteve Yin } 665cdf0e10cSrcweir // no longer needed, because the document calls the VisAreaChanged method 666cdf0e10cSrcweir /* else if (rRef.GetId() == SC_HINT_ACC_VISAREACHANGED) 667cdf0e10cSrcweir { 668cdf0e10cSrcweir AccessibleEventObject aEvent; 669cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED; 670cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 671cdf0e10cSrcweir 672cdf0e10cSrcweir CommitChange(aEvent);*/ 673cdf0e10cSrcweir // commented out, because to use a ModelChangeEvent is not the right way 674cdf0e10cSrcweir // at the moment there is no way, but the Java/Gnome Api should be extended sometime 675cdf0e10cSrcweir /* if (mpViewShell) 676cdf0e10cSrcweir { 677cdf0e10cSrcweir Rectangle aNewVisCells(GetVisCells(GetVisArea(mpViewShell, meSplitPos))); 678cdf0e10cSrcweir 679cdf0e10cSrcweir Rectangle aNewPos(aNewVisCells); 680cdf0e10cSrcweir 681cdf0e10cSrcweir if (aNewVisCells.IsOver(maVisCells)) 682cdf0e10cSrcweir aNewPos.Union(maVisCells); 683cdf0e10cSrcweir else 684cdf0e10cSrcweir CommitTableModelChange(maVisCells.Top(), maVisCells.Left(), maVisCells.Bottom(), maVisCells.Right(), AccessibleTableModelChangeType::UPDATE); 685cdf0e10cSrcweir 686cdf0e10cSrcweir maVisCells = aNewVisCells; 687cdf0e10cSrcweir 688cdf0e10cSrcweir CommitTableModelChange(aNewPos.Top(), aNewPos.Left(), aNewPos.Bottom(), aNewPos.Right(), AccessibleTableModelChangeType::UPDATE); 689cdf0e10cSrcweir } 690cdf0e10cSrcweir }*/ 691cdf0e10cSrcweir // no longer needed, because the document calls the BoundingBoxChanged method 692cdf0e10cSrcweir /* else if (rRef.GetId() == SC_HINT_ACC_WINDOWRESIZED) 693cdf0e10cSrcweir { 694cdf0e10cSrcweir AccessibleEventObject aEvent; 695cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED; 696cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 697cdf0e10cSrcweir 698cdf0e10cSrcweir CommitChange(aEvent); 699cdf0e10cSrcweir }*/ 700cdf0e10cSrcweir } 701cdf0e10cSrcweir else if (rHint.ISA( ScUpdateRefHint )) 702cdf0e10cSrcweir { 703cdf0e10cSrcweir const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint; 704cdf0e10cSrcweir if (rRef.GetMode() == URM_INSDEL && rRef.GetDz() == 0) //#107250# test whether table is inserted or deleted 705cdf0e10cSrcweir { 706cdf0e10cSrcweir if (((rRef.GetRange().aStart.Col() == maRange.aStart.Col()) && 707cdf0e10cSrcweir (rRef.GetRange().aEnd.Col() == maRange.aEnd.Col())) || 708cdf0e10cSrcweir ((rRef.GetRange().aStart.Row() == maRange.aStart.Row()) && 709cdf0e10cSrcweir (rRef.GetRange().aEnd.Row() == maRange.aEnd.Row()))) 710cdf0e10cSrcweir { 711cdf0e10cSrcweir // ignore next SC_HINT_DATACHANGED notification 712cdf0e10cSrcweir mbDelIns = sal_True; 713cdf0e10cSrcweir 714cdf0e10cSrcweir sal_Int16 nId(0); 715cdf0e10cSrcweir SCsCOL nX(rRef.GetDx()); 716cdf0e10cSrcweir SCsROW nY(rRef.GetDy()); 717cdf0e10cSrcweir ScRange aRange(rRef.GetRange()); 718cdf0e10cSrcweir if ((nX < 0) || (nY < 0)) 719cdf0e10cSrcweir { 720cdf0e10cSrcweir DBG_ASSERT(!((nX < 0) && (nY < 0)), "should not be possible to remove row and column at the same time"); 721cdf0e10cSrcweir nId = AccessibleTableModelChangeType::DELETE; 722cdf0e10cSrcweir if (nX < 0) 723cdf0e10cSrcweir { 724cdf0e10cSrcweir nX = -nX; 725cdf0e10cSrcweir nY = aRange.aEnd.Row() - aRange.aStart.Row(); 726cdf0e10cSrcweir } 727cdf0e10cSrcweir else 728cdf0e10cSrcweir { 729cdf0e10cSrcweir nY = -nY; 730cdf0e10cSrcweir nX = aRange.aEnd.Col() - aRange.aStart.Col(); 731cdf0e10cSrcweir } 732cdf0e10cSrcweir } 733cdf0e10cSrcweir else if ((nX > 0) || (nY > 0)) 734cdf0e10cSrcweir { 735cdf0e10cSrcweir DBG_ASSERT(!((nX > 0) && (nY > 0)), "should not be possible to add row and column at the same time"); 736cdf0e10cSrcweir nId = AccessibleTableModelChangeType::INSERT; 737cdf0e10cSrcweir if (nX < 0) 738cdf0e10cSrcweir nY = aRange.aEnd.Row() - aRange.aStart.Row(); 739cdf0e10cSrcweir else 740cdf0e10cSrcweir nX = aRange.aEnd.Col() - aRange.aStart.Col(); 741cdf0e10cSrcweir } 742cdf0e10cSrcweir else 743cdf0e10cSrcweir { 744cdf0e10cSrcweir DBG_ERROR("is it a deletion or a insertion?"); 745cdf0e10cSrcweir } 746cdf0e10cSrcweir 747cdf0e10cSrcweir CommitTableModelChange(rRef.GetRange().aStart.Row(), 748cdf0e10cSrcweir rRef.GetRange().aStart.Col(), 749cdf0e10cSrcweir rRef.GetRange().aStart.Row() + nY, 750cdf0e10cSrcweir rRef.GetRange().aStart.Col() + nX, nId); 751cdf0e10cSrcweir 752cdf0e10cSrcweir AccessibleEventObject aEvent; 753cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; 754cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 755cdf0e10cSrcweir uno::Reference< XAccessible > xNew = mpAccCell; 756cdf0e10cSrcweir aEvent.NewValue <<= xNew; 757cdf0e10cSrcweir 758cdf0e10cSrcweir CommitChange(aEvent); 759cdf0e10cSrcweir } 760cdf0e10cSrcweir } 761cdf0e10cSrcweir } 762cdf0e10cSrcweir 763cdf0e10cSrcweir ScAccessibleTableBase::Notify(rBC, rHint); 764cdf0e10cSrcweir } 7650deba7fbSSteve Yin void ScAccessibleSpreadsheet::RemoveSelection(ScMarkData &refScMarkData) 7660deba7fbSSteve Yin { 7670deba7fbSSteve Yin AccessibleEventObject aEvent; 7680deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(this); 7690deba7fbSSteve Yin aEvent.OldValue <<= ::com::sun::star::uno::Any(); 7700deba7fbSSteve Yin MAP_ADDR_XACC::iterator miRemove = m_mapSelectionSend.begin(); 7710deba7fbSSteve Yin for(; miRemove != m_mapSelectionSend.end() ;) 7720deba7fbSSteve Yin { 7730deba7fbSSteve Yin if (refScMarkData.IsCellMarked(miRemove->first.Col(),miRemove->first.Row(),sal_True) || 7740deba7fbSSteve Yin refScMarkData.IsCellMarked(miRemove->first.Col(),miRemove->first.Row(),sal_False) ) 7750deba7fbSSteve Yin { 7760deba7fbSSteve Yin ++miRemove; 7770deba7fbSSteve Yin continue; 7780deba7fbSSteve Yin } 7790deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE; 7800deba7fbSSteve Yin aEvent.NewValue <<= miRemove->second; 7810deba7fbSSteve Yin CommitChange(aEvent); 7820deba7fbSSteve Yin MAP_ADDR_XACC::iterator miNext = miRemove; 7830deba7fbSSteve Yin ++miNext; 7840deba7fbSSteve Yin m_mapSelectionSend.erase(miRemove); 7850deba7fbSSteve Yin miRemove = miNext; 7860deba7fbSSteve Yin } 7870deba7fbSSteve Yin } 7880deba7fbSSteve Yin void ScAccessibleSpreadsheet::CommitFocusCell(const ScAddress &aNewCell) 7890deba7fbSSteve Yin { 7900deba7fbSSteve Yin OSL_ASSERT(!IsFormulaMode()); 7910deba7fbSSteve Yin if(IsFormulaMode()) 7920deba7fbSSteve Yin { 7930deba7fbSSteve Yin return ; 7940deba7fbSSteve Yin } 7950deba7fbSSteve Yin AccessibleEventObject aEvent; 7960deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; 7970deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(this); 7980deba7fbSSteve Yin uno::Reference< XAccessible > xOld = mpAccCell; 7990deba7fbSSteve Yin mpAccCell->release(); 8000deba7fbSSteve Yin mpAccCell=NULL; 8010deba7fbSSteve Yin aEvent.OldValue <<= xOld; 8020deba7fbSSteve Yin mpAccCell = GetAccessibleCellAt(aNewCell.Row(), aNewCell.Col()); 8030deba7fbSSteve Yin mpAccCell->acquire(); 8040deba7fbSSteve Yin mpAccCell->Init(); 8050deba7fbSSteve Yin uno::Reference< XAccessible > xNew = mpAccCell; 8060deba7fbSSteve Yin aEvent.NewValue <<= xNew; 8070deba7fbSSteve Yin maActiveCell = aNewCell; 8080deba7fbSSteve Yin ScDocument* pScDoc= GetDocument(mpViewShell); 8090deba7fbSSteve Yin if (pScDoc) 8100deba7fbSSteve Yin { 8110deba7fbSSteve Yin pScDoc->GetString(maActiveCell.Col(),maActiveCell.Row(),maActiveCell.Tab(), m_strCurCellValue); 8120deba7fbSSteve Yin } 8130deba7fbSSteve Yin CommitChange(aEvent); 8140deba7fbSSteve Yin } 8150deba7fbSSteve Yin sal_Bool ScAccessibleSpreadsheet::IsSameMarkCell() 8160deba7fbSSteve Yin { 8170deba7fbSSteve Yin return m_LastMarkedRanges == *mpMarkedRanges; 8180deba7fbSSteve Yin } 819cdf0e10cSrcweir //===== XAccessibleTable ================================================ 820cdf0e10cSrcweir 821cdf0e10cSrcweir uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleSpreadsheet::getAccessibleRowHeaders( ) 822cdf0e10cSrcweir throw (uno::RuntimeException) 823cdf0e10cSrcweir { 824cdf0e10cSrcweir ScUnoGuard aGuard; 825cdf0e10cSrcweir IsObjectValid(); 826cdf0e10cSrcweir uno::Reference< XAccessibleTable > xAccessibleTable; 827cdf0e10cSrcweir if( mpDoc && mbIsSpreadsheet ) 828cdf0e10cSrcweir { 829cdf0e10cSrcweir if( const ScRange* pRowRange = mpDoc->GetRepeatRowRange( mnTab ) ) 830cdf0e10cSrcweir { 831cdf0e10cSrcweir SCROW nStart = pRowRange->aStart.Row(); 832cdf0e10cSrcweir SCROW nEnd = pRowRange->aEnd.Row(); 833cdf0e10cSrcweir if( (0 <= nStart) && (nStart <= nEnd) && (nEnd <= MAXROW) ) 834cdf0e10cSrcweir xAccessibleTable.set( new ScAccessibleSpreadsheet( *this, ScRange( 0, nStart, mnTab, MAXCOL, nEnd, mnTab ) ) ); 835cdf0e10cSrcweir } 836cdf0e10cSrcweir } 837cdf0e10cSrcweir return xAccessibleTable; 838cdf0e10cSrcweir } 839cdf0e10cSrcweir 840cdf0e10cSrcweir uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleSpreadsheet::getAccessibleColumnHeaders( ) 841cdf0e10cSrcweir throw (uno::RuntimeException) 842cdf0e10cSrcweir { 843cdf0e10cSrcweir ScUnoGuard aGuard; 844cdf0e10cSrcweir IsObjectValid(); 845cdf0e10cSrcweir uno::Reference< XAccessibleTable > xAccessibleTable; 846cdf0e10cSrcweir if( mpDoc && mbIsSpreadsheet ) 847cdf0e10cSrcweir { 848cdf0e10cSrcweir if( const ScRange* pColRange = mpDoc->GetRepeatColRange( mnTab ) ) 849cdf0e10cSrcweir { 850cdf0e10cSrcweir SCCOL nStart = pColRange->aStart.Col(); 851cdf0e10cSrcweir SCCOL nEnd = pColRange->aEnd.Col(); 852cdf0e10cSrcweir if( (0 <= nStart) && (nStart <= nEnd) && (nEnd <= MAXCOL) ) 853cdf0e10cSrcweir xAccessibleTable.set( new ScAccessibleSpreadsheet( *this, ScRange( nStart, 0, mnTab, nEnd, MAXROW, mnTab ) ) ); 854cdf0e10cSrcweir } 855cdf0e10cSrcweir } 856cdf0e10cSrcweir return xAccessibleTable; 857cdf0e10cSrcweir } 858cdf0e10cSrcweir 859cdf0e10cSrcweir uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleSpreadsheet::getSelectedAccessibleRows( ) 860cdf0e10cSrcweir throw (uno::RuntimeException) 861cdf0e10cSrcweir { 862cdf0e10cSrcweir ScUnoGuard aGuard; 863cdf0e10cSrcweir IsObjectValid(); 864cdf0e10cSrcweir uno::Sequence<sal_Int32> aSequence; 8650deba7fbSSteve Yin if (IsFormulaMode()) 8660deba7fbSSteve Yin { 8670deba7fbSSteve Yin return aSequence; 8680deba7fbSSteve Yin } 869cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData()) 870cdf0e10cSrcweir { 871cdf0e10cSrcweir aSequence.realloc(maRange.aEnd.Row() - maRange.aStart.Row() + 1); 872cdf0e10cSrcweir const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData(); 873cdf0e10cSrcweir sal_Int32* pSequence = aSequence.getArray(); 874cdf0e10cSrcweir sal_Int32 nCount(0); 875cdf0e10cSrcweir for (SCROW i = maRange.aStart.Row(); i <= maRange.aEnd.Row(); ++i) 876cdf0e10cSrcweir { 877cdf0e10cSrcweir if (rMarkdata.IsRowMarked(i)) 878cdf0e10cSrcweir { 879cdf0e10cSrcweir pSequence[nCount] = i; 880cdf0e10cSrcweir ++nCount; 881cdf0e10cSrcweir } 882cdf0e10cSrcweir } 883cdf0e10cSrcweir aSequence.realloc(nCount); 884cdf0e10cSrcweir } 885cdf0e10cSrcweir else 886cdf0e10cSrcweir aSequence.realloc(0); 887cdf0e10cSrcweir return aSequence; 888cdf0e10cSrcweir } 889cdf0e10cSrcweir 890cdf0e10cSrcweir uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleSpreadsheet::getSelectedAccessibleColumns( ) 891cdf0e10cSrcweir throw (uno::RuntimeException) 892cdf0e10cSrcweir { 893cdf0e10cSrcweir ScUnoGuard aGuard; 894cdf0e10cSrcweir IsObjectValid(); 895cdf0e10cSrcweir uno::Sequence<sal_Int32> aSequence; 8960deba7fbSSteve Yin if (IsFormulaMode()) 8970deba7fbSSteve Yin { 8980deba7fbSSteve Yin return aSequence; 8990deba7fbSSteve Yin } 900cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData()) 901cdf0e10cSrcweir { 902cdf0e10cSrcweir aSequence.realloc(maRange.aEnd.Col() - maRange.aStart.Col() + 1); 903cdf0e10cSrcweir const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData(); 904cdf0e10cSrcweir sal_Int32* pSequence = aSequence.getArray(); 905cdf0e10cSrcweir sal_Int32 nCount(0); 906cdf0e10cSrcweir for (SCCOL i = maRange.aStart.Col(); i <= maRange.aEnd.Col(); ++i) 907cdf0e10cSrcweir { 908cdf0e10cSrcweir if (rMarkdata.IsColumnMarked(i)) 909cdf0e10cSrcweir { 910cdf0e10cSrcweir pSequence[nCount] = i; 911cdf0e10cSrcweir ++nCount; 912cdf0e10cSrcweir } 913cdf0e10cSrcweir } 914cdf0e10cSrcweir aSequence.realloc(nCount); 915cdf0e10cSrcweir } 916cdf0e10cSrcweir else 917cdf0e10cSrcweir aSequence.realloc(0); 918cdf0e10cSrcweir return aSequence; 919cdf0e10cSrcweir } 920cdf0e10cSrcweir 921cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleRowSelected( sal_Int32 nRow ) 922cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException) 923cdf0e10cSrcweir { 924cdf0e10cSrcweir ScUnoGuard aGuard; 925cdf0e10cSrcweir IsObjectValid(); 9260deba7fbSSteve Yin if (IsFormulaMode()) 9270deba7fbSSteve Yin { 9280deba7fbSSteve Yin return sal_False; 9290deba7fbSSteve Yin } 930cdf0e10cSrcweir 931cdf0e10cSrcweir if ((nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0)) 932cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 933cdf0e10cSrcweir 934cdf0e10cSrcweir sal_Bool bResult(sal_False); 935cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData()) 936cdf0e10cSrcweir { 937cdf0e10cSrcweir const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData(); 938cdf0e10cSrcweir bResult = rMarkdata.IsRowMarked((SCROW)nRow); 939cdf0e10cSrcweir } 940cdf0e10cSrcweir return bResult; 941cdf0e10cSrcweir } 942cdf0e10cSrcweir 943cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleColumnSelected( sal_Int32 nColumn ) 944cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException) 945cdf0e10cSrcweir { 946cdf0e10cSrcweir ScUnoGuard aGuard; 947cdf0e10cSrcweir IsObjectValid(); 948cdf0e10cSrcweir 9490deba7fbSSteve Yin if (IsFormulaMode()) 9500deba7fbSSteve Yin { 9510deba7fbSSteve Yin return sal_False; 9520deba7fbSSteve Yin } 953cdf0e10cSrcweir if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0)) 954cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 955cdf0e10cSrcweir 956cdf0e10cSrcweir sal_Bool bResult(sal_False); 957cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData()) 958cdf0e10cSrcweir { 959cdf0e10cSrcweir const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData(); 960cdf0e10cSrcweir bResult = rMarkdata.IsColumnMarked((SCCOL)nColumn); 961cdf0e10cSrcweir } 962cdf0e10cSrcweir return bResult; 963cdf0e10cSrcweir } 964cdf0e10cSrcweir 965cdf0e10cSrcweir ScAccessibleCell* ScAccessibleSpreadsheet::GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn) 966cdf0e10cSrcweir { 967cdf0e10cSrcweir ScAccessibleCell* pAccessibleCell = NULL; 9680deba7fbSSteve Yin if (IsFormulaMode()) 9690deba7fbSSteve Yin { 9700deba7fbSSteve Yin ScAddress aCellAddress(static_cast<SCCOL>(nColumn), nRow, mpViewShell->GetViewData()->GetTabNo()); 9710deba7fbSSteve Yin if ((aCellAddress == m_aFormulaActiveCell) && m_pAccFormulaCell) 9720deba7fbSSteve Yin { 9730deba7fbSSteve Yin pAccessibleCell = m_pAccFormulaCell; 9740deba7fbSSteve Yin } 9750deba7fbSSteve Yin else 9760deba7fbSSteve Yin pAccessibleCell = new ScAccessibleCell(this, mpViewShell, aCellAddress, GetAccessibleIndexFormula(nRow, nColumn), meSplitPos, mpAccDoc); 9770deba7fbSSteve Yin } 9780deba7fbSSteve Yin else 9790deba7fbSSteve Yin { 980cdf0e10cSrcweir ScAddress aCellAddress(static_cast<SCCOL>(maRange.aStart.Col() + nColumn), 981cdf0e10cSrcweir static_cast<SCROW>(maRange.aStart.Row() + nRow), maRange.aStart.Tab()); 982cdf0e10cSrcweir if ((aCellAddress == maActiveCell) && mpAccCell) 983cdf0e10cSrcweir { 984cdf0e10cSrcweir pAccessibleCell = mpAccCell; 985cdf0e10cSrcweir } 986cdf0e10cSrcweir else 987cdf0e10cSrcweir pAccessibleCell = new ScAccessibleCell(this, mpViewShell, aCellAddress, getAccessibleIndex(nRow, nColumn), meSplitPos, mpAccDoc); 9880deba7fbSSteve Yin } 989cdf0e10cSrcweir 990cdf0e10cSrcweir return pAccessibleCell; 991cdf0e10cSrcweir } 992cdf0e10cSrcweir 993cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) 994cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException) 995cdf0e10cSrcweir { 996cdf0e10cSrcweir ScUnoGuard aGuard; 997cdf0e10cSrcweir IsObjectValid(); 9980deba7fbSSteve Yin if (!IsFormulaMode()) 9990deba7fbSSteve Yin { 1000cdf0e10cSrcweir if (nRow > (maRange.aEnd.Row() - maRange.aStart.Row()) || 1001cdf0e10cSrcweir nRow < 0 || 1002cdf0e10cSrcweir nColumn > (maRange.aEnd.Col() - maRange.aStart.Col()) || 1003cdf0e10cSrcweir nColumn < 0) 1004cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 10050deba7fbSSteve Yin } 1006cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible; 1007cdf0e10cSrcweir ScAccessibleCell* pAccessibleCell = GetAccessibleCellAt(nRow, nColumn); 1008cdf0e10cSrcweir xAccessible = pAccessibleCell; 1009cdf0e10cSrcweir pAccessibleCell->Init(); 1010cdf0e10cSrcweir return xAccessible; 1011cdf0e10cSrcweir } 1012cdf0e10cSrcweir 1013cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) 1014cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException) 1015cdf0e10cSrcweir { 1016cdf0e10cSrcweir ScUnoGuard aGuard; 1017cdf0e10cSrcweir IsObjectValid(); 1018cdf0e10cSrcweir 10190deba7fbSSteve Yin if (IsFormulaMode()) 10200deba7fbSSteve Yin { 10210deba7fbSSteve Yin ScAddress addr(static_cast<SCCOL>(nColumn), nRow, 0); 10220deba7fbSSteve Yin return IsScAddrFormulaSel(addr); 10230deba7fbSSteve Yin } 1024cdf0e10cSrcweir if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0) || 1025cdf0e10cSrcweir (nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0)) 1026cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1027cdf0e10cSrcweir 1028cdf0e10cSrcweir sal_Bool bResult(sal_False); 1029cdf0e10cSrcweir if (mpViewShell) 1030cdf0e10cSrcweir { 1031cdf0e10cSrcweir const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData(); 1032cdf0e10cSrcweir bResult = rMarkdata.IsCellMarked(static_cast<SCCOL>(nColumn), static_cast<SCROW>(nRow)); 1033cdf0e10cSrcweir } 1034cdf0e10cSrcweir return bResult; 1035cdf0e10cSrcweir } 1036cdf0e10cSrcweir 1037cdf0e10cSrcweir //===== XAccessibleComponent ============================================ 1038cdf0e10cSrcweir 1039cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleAtPoint( 1040cdf0e10cSrcweir const awt::Point& rPoint ) 1041cdf0e10cSrcweir throw (uno::RuntimeException) 1042cdf0e10cSrcweir { 1043cdf0e10cSrcweir uno::Reference< XAccessible > xAccessible; 1044cdf0e10cSrcweir if (containsPoint(rPoint)) 1045cdf0e10cSrcweir { 1046cdf0e10cSrcweir ScUnoGuard aGuard; 1047cdf0e10cSrcweir IsObjectValid(); 1048cdf0e10cSrcweir if (mpViewShell) 1049cdf0e10cSrcweir { 1050cdf0e10cSrcweir SCsCOL nX; 1051cdf0e10cSrcweir SCsROW nY; 1052cdf0e10cSrcweir mpViewShell->GetViewData()->GetPosFromPixel( rPoint.X, rPoint.Y, meSplitPos, nX, nY); 10530deba7fbSSteve Yin try{ 1054cdf0e10cSrcweir xAccessible = getAccessibleCellAt(nY, nX); 1055cdf0e10cSrcweir } 10560deba7fbSSteve Yin catch( ::com::sun::star::lang::IndexOutOfBoundsException e) 10570deba7fbSSteve Yin { 10580deba7fbSSteve Yin return NULL; 10590deba7fbSSteve Yin } 10600deba7fbSSteve Yin } 1061cdf0e10cSrcweir } 1062cdf0e10cSrcweir return xAccessible; 1063cdf0e10cSrcweir } 1064cdf0e10cSrcweir 1065cdf0e10cSrcweir void SAL_CALL ScAccessibleSpreadsheet::grabFocus( ) 1066cdf0e10cSrcweir throw (uno::RuntimeException) 1067cdf0e10cSrcweir { 1068cdf0e10cSrcweir if (getAccessibleParent().is()) 1069cdf0e10cSrcweir { 1070cdf0e10cSrcweir uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY); 1071cdf0e10cSrcweir if (xAccessibleComponent.is()) 1072cdf0e10cSrcweir xAccessibleComponent->grabFocus(); 1073cdf0e10cSrcweir } 1074cdf0e10cSrcweir } 1075cdf0e10cSrcweir 1076cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleSpreadsheet::getForeground( ) 1077cdf0e10cSrcweir throw (uno::RuntimeException) 1078cdf0e10cSrcweir { 1079cdf0e10cSrcweir return COL_BLACK; 1080cdf0e10cSrcweir } 1081cdf0e10cSrcweir 1082cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleSpreadsheet::getBackground( ) 1083cdf0e10cSrcweir throw (uno::RuntimeException) 1084cdf0e10cSrcweir { 1085cdf0e10cSrcweir ScUnoGuard aGuard; 1086cdf0e10cSrcweir IsObjectValid(); 1087cdf0e10cSrcweir return SC_MOD()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor; 1088cdf0e10cSrcweir } 1089cdf0e10cSrcweir 1090cdf0e10cSrcweir //===== XAccessibleContext ============================================== 1091cdf0e10cSrcweir 1092cdf0e10cSrcweir uno::Reference<XAccessibleRelationSet> SAL_CALL ScAccessibleSpreadsheet::getAccessibleRelationSet(void) 1093cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 1094cdf0e10cSrcweir { 1095cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pRelationSet = NULL; 1096cdf0e10cSrcweir if(mpAccDoc) 1097cdf0e10cSrcweir pRelationSet = mpAccDoc->GetRelationSet(NULL); 1098cdf0e10cSrcweir if (!pRelationSet) 1099cdf0e10cSrcweir pRelationSet = new utl::AccessibleRelationSetHelper(); 1100cdf0e10cSrcweir return pRelationSet; 1101cdf0e10cSrcweir } 1102cdf0e10cSrcweir 1103cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL 1104cdf0e10cSrcweir ScAccessibleSpreadsheet::getAccessibleStateSet(void) 1105cdf0e10cSrcweir throw (uno::RuntimeException) 1106cdf0e10cSrcweir { 1107cdf0e10cSrcweir ScUnoGuard aGuard; 1108cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> xParentStates; 1109cdf0e10cSrcweir if (getAccessibleParent().is()) 1110cdf0e10cSrcweir { 1111cdf0e10cSrcweir uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); 1112cdf0e10cSrcweir xParentStates = xParentContext->getAccessibleStateSet(); 1113cdf0e10cSrcweir } 1114cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); 1115cdf0e10cSrcweir if (IsDefunc(xParentStates)) 1116cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::DEFUNC); 1117cdf0e10cSrcweir else 1118cdf0e10cSrcweir { 1119cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::MANAGES_DESCENDANTS); 1120cdf0e10cSrcweir if (IsEditable(xParentStates)) 1121cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::EDITABLE); 1122cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::ENABLED); 1123cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::FOCUSABLE); 1124cdf0e10cSrcweir if (IsFocused()) 1125cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::FOCUSED); 1126cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::MULTI_SELECTABLE); 1127cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::OPAQUE); 1128cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SELECTABLE); 1129cdf0e10cSrcweir if (IsCompleteSheetSelected()) 1130cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SELECTED); 1131cdf0e10cSrcweir if (isShowing()) 1132cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SHOWING); 1133cdf0e10cSrcweir if (isVisible()) 1134cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::VISIBLE); 1135cdf0e10cSrcweir } 1136cdf0e10cSrcweir return pStateSet; 1137cdf0e10cSrcweir } 1138cdf0e10cSrcweir 1139cdf0e10cSrcweir ///===== XAccessibleSelection =========================================== 1140cdf0e10cSrcweir 1141cdf0e10cSrcweir void SAL_CALL 1142cdf0e10cSrcweir ScAccessibleSpreadsheet::selectAccessibleChild( sal_Int32 nChildIndex ) 1143cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1144cdf0e10cSrcweir { 1145cdf0e10cSrcweir ScUnoGuard aGuard; 1146cdf0e10cSrcweir IsObjectValid(); 1147cdf0e10cSrcweir if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount()) 1148cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1149cdf0e10cSrcweir 1150cdf0e10cSrcweir if (mpViewShell) 1151cdf0e10cSrcweir { 1152cdf0e10cSrcweir sal_Int32 nCol(getAccessibleColumn(nChildIndex)); 1153cdf0e10cSrcweir sal_Int32 nRow(getAccessibleRow(nChildIndex)); 1154cdf0e10cSrcweir 1155cdf0e10cSrcweir SelectCell(nRow, nCol, sal_False); 1156cdf0e10cSrcweir } 1157cdf0e10cSrcweir } 1158cdf0e10cSrcweir 1159cdf0e10cSrcweir void SAL_CALL 1160cdf0e10cSrcweir ScAccessibleSpreadsheet::clearAccessibleSelection( ) 1161cdf0e10cSrcweir throw (uno::RuntimeException) 1162cdf0e10cSrcweir { 1163cdf0e10cSrcweir ScUnoGuard aGuard; 1164cdf0e10cSrcweir IsObjectValid(); 1165cdf0e10cSrcweir if (mpViewShell) 1166cdf0e10cSrcweir { 11670deba7fbSSteve Yin if (!IsFormulaMode()) 1168cdf0e10cSrcweir mpViewShell->Unmark(); 1169cdf0e10cSrcweir } 1170cdf0e10cSrcweir } 1171cdf0e10cSrcweir 1172cdf0e10cSrcweir void SAL_CALL 1173cdf0e10cSrcweir ScAccessibleSpreadsheet::selectAllAccessibleChildren( ) 1174cdf0e10cSrcweir throw (uno::RuntimeException) 1175cdf0e10cSrcweir { 1176cdf0e10cSrcweir ScUnoGuard aGuard; 1177cdf0e10cSrcweir IsObjectValid(); 1178cdf0e10cSrcweir if (mpViewShell) 1179cdf0e10cSrcweir { 11800deba7fbSSteve Yin if (IsFormulaMode()) 11810deba7fbSSteve Yin { 11820deba7fbSSteve Yin ScViewData *pViewData = mpViewShell->GetViewData(); 11830deba7fbSSteve Yin mpViewShell->InitRefMode( 0, 0, pViewData->GetTabNo(), SC_REFTYPE_REF ); 11840deba7fbSSteve Yin pViewData->SetRefStart(0,0,pViewData->GetTabNo()); 11850deba7fbSSteve Yin pViewData->SetRefStart(MAXCOL,MAXROW,pViewData->GetTabNo()); 11860deba7fbSSteve Yin mpViewShell->UpdateRef(MAXCOL, MAXROW, pViewData->GetTabNo()); 11870deba7fbSSteve Yin } 11880deba7fbSSteve Yin else 1189cdf0e10cSrcweir mpViewShell->SelectAll(); 1190cdf0e10cSrcweir } 1191cdf0e10cSrcweir } 1192cdf0e10cSrcweir 1193cdf0e10cSrcweir sal_Int32 SAL_CALL 1194cdf0e10cSrcweir ScAccessibleSpreadsheet::getSelectedAccessibleChildCount( ) 1195cdf0e10cSrcweir throw (uno::RuntimeException) 1196cdf0e10cSrcweir { 1197cdf0e10cSrcweir ScUnoGuard aGuard; 1198cdf0e10cSrcweir IsObjectValid(); 1199cdf0e10cSrcweir sal_Int32 nResult(0); 1200cdf0e10cSrcweir if (mpViewShell) 1201cdf0e10cSrcweir { 12020deba7fbSSteve Yin if (IsFormulaMode()) 12030deba7fbSSteve Yin { 12040deba7fbSSteve Yin nResult = GetRowAll() * GetColAll() ; 12050deba7fbSSteve Yin } 12060deba7fbSSteve Yin else 12070deba7fbSSteve Yin { 1208cdf0e10cSrcweir if (!mpMarkedRanges) 1209cdf0e10cSrcweir { 1210cdf0e10cSrcweir mpMarkedRanges = new ScRangeList(); 1211cdf0e10cSrcweir ScMarkData aMarkData(mpViewShell->GetViewData()->GetMarkData()); 12120deba7fbSSteve Yin //aMarkData.MarkToMulti(); 1213cdf0e10cSrcweir aMarkData.FillRangeListWithMarks(mpMarkedRanges, sal_False); 1214cdf0e10cSrcweir } 1215cdf0e10cSrcweir // is possible, because there shouldn't be overlapped ranges in it 1216cdf0e10cSrcweir if (mpMarkedRanges) 1217cdf0e10cSrcweir nResult = mpMarkedRanges->GetCellCount(); 1218cdf0e10cSrcweir } 12190deba7fbSSteve Yin } 1220cdf0e10cSrcweir return nResult; 1221cdf0e10cSrcweir } 1222cdf0e10cSrcweir 1223cdf0e10cSrcweir uno::Reference<XAccessible > SAL_CALL 1224cdf0e10cSrcweir ScAccessibleSpreadsheet::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) 1225cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1226cdf0e10cSrcweir { 1227cdf0e10cSrcweir ScUnoGuard aGuard; 1228cdf0e10cSrcweir IsObjectValid(); 1229cdf0e10cSrcweir uno::Reference < XAccessible > xAccessible; 12300deba7fbSSteve Yin if (IsFormulaMode()) 12310deba7fbSSteve Yin { 12320deba7fbSSteve Yin if(CheckChildIndex(nSelectedChildIndex)) 12330deba7fbSSteve Yin { 12340deba7fbSSteve Yin ScAddress addr = GetChildIndexAddress(nSelectedChildIndex); 12350deba7fbSSteve Yin xAccessible = getAccessibleCellAt(addr.Row(), addr.Col()); 12360deba7fbSSteve Yin } 12370deba7fbSSteve Yin return xAccessible; 12380deba7fbSSteve Yin } 1239cdf0e10cSrcweir if (mpViewShell) 1240cdf0e10cSrcweir { 1241cdf0e10cSrcweir if (!mpMarkedRanges) 1242cdf0e10cSrcweir { 1243cdf0e10cSrcweir mpMarkedRanges = new ScRangeList(); 1244cdf0e10cSrcweir mpViewShell->GetViewData()->GetMarkData().FillRangeListWithMarks(mpMarkedRanges, sal_False); 1245cdf0e10cSrcweir } 1246cdf0e10cSrcweir if (mpMarkedRanges) 1247cdf0e10cSrcweir { 12480deba7fbSSteve Yin //if (!mpSortedMarkedCells) 12490deba7fbSSteve Yin // CreateSortedMarkedCells(); 12500deba7fbSSteve Yin //if (mpSortedMarkedCells) 12510deba7fbSSteve Yin //{ 12520deba7fbSSteve Yin // if ((nSelectedChildIndex < 0) || 12530deba7fbSSteve Yin // (mpSortedMarkedCells->size() <= static_cast<sal_uInt32>(nSelectedChildIndex))) 12540deba7fbSSteve Yin // throw lang::IndexOutOfBoundsException(); 12550deba7fbSSteve Yin // else 12560deba7fbSSteve Yin // xAccessible = getAccessibleCellAt((*mpSortedMarkedCells)[nSelectedChildIndex].Row(), (*mpSortedMarkedCells)[nSelectedChildIndex].Col()); 1257cdf0e10cSrcweir if ((nSelectedChildIndex < 0) || 12580deba7fbSSteve Yin (mpMarkedRanges->GetCellCount() <= static_cast<sal_uInt32>(nSelectedChildIndex))) 12590deba7fbSSteve Yin { 1260cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1261cdf0e10cSrcweir } 12620deba7fbSSteve Yin ScMyAddress addr = CalcScAddressFromRangeList(mpMarkedRanges,nSelectedChildIndex); 12630deba7fbSSteve Yin if( m_mapSelectionSend.find(addr) != m_mapSelectionSend.end() ) 12640deba7fbSSteve Yin xAccessible = m_mapSelectionSend[addr]; 12650deba7fbSSteve Yin else 12660deba7fbSSteve Yin xAccessible = getAccessibleCellAt(addr.Row(), addr.Col()); 1267cdf0e10cSrcweir } 1268cdf0e10cSrcweir } 1269cdf0e10cSrcweir return xAccessible; 1270cdf0e10cSrcweir } 1271cdf0e10cSrcweir 1272cdf0e10cSrcweir void SAL_CALL 1273cdf0e10cSrcweir ScAccessibleSpreadsheet::deselectAccessibleChild( sal_Int32 nChildIndex ) 1274cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1275cdf0e10cSrcweir { 1276cdf0e10cSrcweir ScUnoGuard aGuard; 1277cdf0e10cSrcweir IsObjectValid(); 1278cdf0e10cSrcweir 1279cdf0e10cSrcweir if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount()) 1280cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1281cdf0e10cSrcweir 1282cdf0e10cSrcweir if (mpViewShell) 1283cdf0e10cSrcweir { 1284cdf0e10cSrcweir sal_Int32 nCol(getAccessibleColumn(nChildIndex)); 1285cdf0e10cSrcweir sal_Int32 nRow(getAccessibleRow(nChildIndex)); 1286cdf0e10cSrcweir 12870deba7fbSSteve Yin if (IsFormulaMode()) 12880deba7fbSSteve Yin { 12890deba7fbSSteve Yin if(IsScAddrFormulaSel( 12900deba7fbSSteve Yin ScAddress(static_cast<SCCOL>(nCol), nRow,mpViewShell->GetViewData()->GetTabNo())) 12910deba7fbSSteve Yin ) 12920deba7fbSSteve Yin { 12930deba7fbSSteve Yin SelectCell(nRow, nCol, sal_True); 12940deba7fbSSteve Yin } 12950deba7fbSSteve Yin return ; 12960deba7fbSSteve Yin } 1297cdf0e10cSrcweir if (mpViewShell->GetViewData()->GetMarkData().IsCellMarked(static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow))) 1298cdf0e10cSrcweir SelectCell(nRow, nCol, sal_True); 1299cdf0e10cSrcweir } 1300cdf0e10cSrcweir } 1301cdf0e10cSrcweir 1302cdf0e10cSrcweir void ScAccessibleSpreadsheet::SelectCell(sal_Int32 nRow, sal_Int32 nCol, sal_Bool bDeselect) 1303cdf0e10cSrcweir { 13040deba7fbSSteve Yin if (IsFormulaMode()) 13050deba7fbSSteve Yin { 13060deba7fbSSteve Yin if (bDeselect) 13070deba7fbSSteve Yin {//?? 13080deba7fbSSteve Yin return ; 13090deba7fbSSteve Yin } 13100deba7fbSSteve Yin else 13110deba7fbSSteve Yin { 13120deba7fbSSteve Yin ScViewData *pViewData = mpViewShell->GetViewData(); 13130deba7fbSSteve Yin 13140deba7fbSSteve Yin mpViewShell->InitRefMode( static_cast<SCCOL>(nCol), nRow, pViewData->GetTabNo(), SC_REFTYPE_REF ); 13150deba7fbSSteve Yin mpViewShell->UpdateRef(static_cast<SCCOL>(nCol), nRow, pViewData->GetTabNo()); 13160deba7fbSSteve Yin } 13170deba7fbSSteve Yin return ; 13180deba7fbSSteve Yin } 1319cdf0e10cSrcweir mpViewShell->SetTabNo( maRange.aStart.Tab() ); 1320cdf0e10cSrcweir 1321cdf0e10cSrcweir mpViewShell->DoneBlockMode( sal_True ); // continue selecting 1322cdf0e10cSrcweir mpViewShell->InitBlockMode( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), maRange.aStart.Tab(), bDeselect, sal_False, sal_False ); 1323cdf0e10cSrcweir 1324cdf0e10cSrcweir mpViewShell->SelectionChanged(); 1325cdf0e10cSrcweir } 1326cdf0e10cSrcweir 1327cdf0e10cSrcweir //===== XServiceInfo ==================================================== 1328cdf0e10cSrcweir 1329cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleSpreadsheet::getImplementationName(void) 1330cdf0e10cSrcweir throw (uno::RuntimeException) 1331cdf0e10cSrcweir { 1332cdf0e10cSrcweir return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleSpreadsheet")); 1333cdf0e10cSrcweir } 1334cdf0e10cSrcweir 1335cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> SAL_CALL 1336cdf0e10cSrcweir ScAccessibleSpreadsheet::getSupportedServiceNames (void) 1337cdf0e10cSrcweir throw (uno::RuntimeException) 1338cdf0e10cSrcweir { 1339cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleTableBase::getSupportedServiceNames(); 1340cdf0e10cSrcweir sal_Int32 nOldSize(aSequence.getLength()); 1341cdf0e10cSrcweir aSequence.realloc(nOldSize + 1); 1342cdf0e10cSrcweir ::rtl::OUString* pNames = aSequence.getArray(); 1343cdf0e10cSrcweir 1344cdf0e10cSrcweir pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.AccessibleSpreadsheet")); 1345cdf0e10cSrcweir 1346cdf0e10cSrcweir return aSequence; 1347cdf0e10cSrcweir } 1348cdf0e10cSrcweir 1349cdf0e10cSrcweir //===== XTypeProvider ======================================================= 1350cdf0e10cSrcweir 1351cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL 1352cdf0e10cSrcweir ScAccessibleSpreadsheet::getImplementationId(void) 1353cdf0e10cSrcweir throw (uno::RuntimeException) 1354cdf0e10cSrcweir { 1355cdf0e10cSrcweir ScUnoGuard aGuard; 1356cdf0e10cSrcweir IsObjectValid(); 1357cdf0e10cSrcweir static uno::Sequence<sal_Int8> aId; 1358cdf0e10cSrcweir if (aId.getLength() == 0) 1359cdf0e10cSrcweir { 1360cdf0e10cSrcweir aId.realloc (16); 1361cdf0e10cSrcweir rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True); 1362cdf0e10cSrcweir } 1363cdf0e10cSrcweir return aId; 1364cdf0e10cSrcweir } 1365cdf0e10cSrcweir 1366cdf0e10cSrcweir ///===== XAccessibleEventBroadcaster ===================================== 1367cdf0e10cSrcweir 1368cdf0e10cSrcweir void SAL_CALL ScAccessibleSpreadsheet::addEventListener(const uno::Reference<XAccessibleEventListener>& xListener) 1369cdf0e10cSrcweir throw (uno::RuntimeException) 1370cdf0e10cSrcweir { 1371cdf0e10cSrcweir ScUnoGuard aGuard; 1372cdf0e10cSrcweir IsObjectValid(); 1373cdf0e10cSrcweir ScAccessibleTableBase::addEventListener(xListener); 1374cdf0e10cSrcweir } 1375cdf0e10cSrcweir 1376cdf0e10cSrcweir //==== internal ========================================================= 1377cdf0e10cSrcweir 1378cdf0e10cSrcweir Rectangle ScAccessibleSpreadsheet::GetBoundingBoxOnScreen() const 1379cdf0e10cSrcweir throw (uno::RuntimeException) 1380cdf0e10cSrcweir { 1381cdf0e10cSrcweir Rectangle aRect; 1382cdf0e10cSrcweir if (mpViewShell) 1383cdf0e10cSrcweir { 1384cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos); 1385cdf0e10cSrcweir if (pWindow) 1386cdf0e10cSrcweir aRect = pWindow->GetWindowExtentsRelative(NULL); 1387cdf0e10cSrcweir } 1388cdf0e10cSrcweir return aRect; 1389cdf0e10cSrcweir } 1390cdf0e10cSrcweir 1391cdf0e10cSrcweir Rectangle ScAccessibleSpreadsheet::GetBoundingBox() const 1392cdf0e10cSrcweir throw (uno::RuntimeException) 1393cdf0e10cSrcweir { 1394cdf0e10cSrcweir Rectangle aRect; 1395cdf0e10cSrcweir if (mpViewShell) 1396cdf0e10cSrcweir { 1397cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos); 1398cdf0e10cSrcweir if (pWindow) 1399cdf0e10cSrcweir //#101986#; extends to the same window, because the parent is the document and it has the same window 1400cdf0e10cSrcweir aRect = pWindow->GetWindowExtentsRelative(pWindow); 1401cdf0e10cSrcweir } 1402cdf0e10cSrcweir return aRect; 1403cdf0e10cSrcweir } 1404cdf0e10cSrcweir 1405cdf0e10cSrcweir sal_Bool ScAccessibleSpreadsheet::IsDefunc( 1406cdf0e10cSrcweir const uno::Reference<XAccessibleStateSet>& rxParentStates) 1407cdf0e10cSrcweir { 1408cdf0e10cSrcweir return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() || 1409cdf0e10cSrcweir (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC)); 1410cdf0e10cSrcweir } 1411cdf0e10cSrcweir 1412cdf0e10cSrcweir sal_Bool ScAccessibleSpreadsheet::IsEditable( 1413cdf0e10cSrcweir const uno::Reference<XAccessibleStateSet>& /* rxParentStates */) 1414cdf0e10cSrcweir { 14150deba7fbSSteve Yin if (IsFormulaMode()) 14160deba7fbSSteve Yin { 14170deba7fbSSteve Yin return sal_False; 14180deba7fbSSteve Yin } 1419cdf0e10cSrcweir sal_Bool bProtected(sal_False); 1420cdf0e10cSrcweir if (mpDoc && mpDoc->IsTabProtected(maRange.aStart.Tab())) 1421cdf0e10cSrcweir bProtected = sal_True; 1422cdf0e10cSrcweir return !bProtected; 1423cdf0e10cSrcweir } 1424cdf0e10cSrcweir 1425cdf0e10cSrcweir sal_Bool ScAccessibleSpreadsheet::IsFocused() 1426cdf0e10cSrcweir { 1427cdf0e10cSrcweir sal_Bool bFocused(sal_False); 1428cdf0e10cSrcweir if (mpViewShell) 1429cdf0e10cSrcweir { 1430cdf0e10cSrcweir if (mpViewShell->GetViewData()->GetActivePart() == meSplitPos) 1431cdf0e10cSrcweir bFocused = mpViewShell->GetActiveWin()->HasFocus(); 1432cdf0e10cSrcweir } 1433cdf0e10cSrcweir return bFocused; 1434cdf0e10cSrcweir } 1435cdf0e10cSrcweir 1436cdf0e10cSrcweir sal_Bool ScAccessibleSpreadsheet::IsCompleteSheetSelected() 1437cdf0e10cSrcweir { 14380deba7fbSSteve Yin if (IsFormulaMode()) 14390deba7fbSSteve Yin { 14400deba7fbSSteve Yin return sal_False; 14410deba7fbSSteve Yin } 1442cdf0e10cSrcweir sal_Bool bResult(sal_False); 1443cdf0e10cSrcweir if(mpViewShell) 1444cdf0e10cSrcweir { 1445cdf0e10cSrcweir //#103800#; use a copy of MarkData 1446cdf0e10cSrcweir ScMarkData aMarkData(mpViewShell->GetViewData()->GetMarkData()); 1447cdf0e10cSrcweir aMarkData.MarkToMulti(); 1448cdf0e10cSrcweir if (aMarkData.IsAllMarked(maRange)) 1449cdf0e10cSrcweir bResult = sal_True; 1450cdf0e10cSrcweir } 1451cdf0e10cSrcweir return bResult; 1452cdf0e10cSrcweir } 1453cdf0e10cSrcweir 1454cdf0e10cSrcweir ScDocument* ScAccessibleSpreadsheet::GetDocument(ScTabViewShell* pViewShell) 1455cdf0e10cSrcweir { 1456cdf0e10cSrcweir ScDocument* pDoc = NULL; 1457cdf0e10cSrcweir if (pViewShell) 1458cdf0e10cSrcweir pDoc = pViewShell->GetViewData()->GetDocument(); 1459cdf0e10cSrcweir return pDoc; 1460cdf0e10cSrcweir } 1461cdf0e10cSrcweir 1462cdf0e10cSrcweir Rectangle ScAccessibleSpreadsheet::GetVisArea(ScTabViewShell* pViewShell, ScSplitPos eSplitPos) 1463cdf0e10cSrcweir { 1464cdf0e10cSrcweir Rectangle aVisArea; 1465cdf0e10cSrcweir if (pViewShell) 1466cdf0e10cSrcweir { 1467cdf0e10cSrcweir Window* pWindow = pViewShell->GetWindowByPos(eSplitPos); 1468cdf0e10cSrcweir if (pWindow) 1469cdf0e10cSrcweir { 1470cdf0e10cSrcweir aVisArea.SetPos(pViewShell->GetViewData()->GetPixPos(eSplitPos)); 1471cdf0e10cSrcweir aVisArea.SetSize(pWindow->GetSizePixel()); 1472cdf0e10cSrcweir } 1473cdf0e10cSrcweir } 1474cdf0e10cSrcweir return aVisArea; 1475cdf0e10cSrcweir } 1476cdf0e10cSrcweir 1477cdf0e10cSrcweir Rectangle ScAccessibleSpreadsheet::GetVisCells(const Rectangle& rVisArea) 1478cdf0e10cSrcweir { 1479cdf0e10cSrcweir if (mpViewShell) 1480cdf0e10cSrcweir { 1481cdf0e10cSrcweir SCsCOL nStartX, nEndX; 1482cdf0e10cSrcweir SCsROW nStartY, nEndY; 1483cdf0e10cSrcweir 1484cdf0e10cSrcweir mpViewShell->GetViewData()->GetPosFromPixel( 1, 1, meSplitPos, nStartX, nStartY); 1485cdf0e10cSrcweir mpViewShell->GetViewData()->GetPosFromPixel( rVisArea.GetWidth(), rVisArea.GetHeight(), meSplitPos, nEndX, nEndY); 1486cdf0e10cSrcweir 1487cdf0e10cSrcweir return Rectangle(nStartX, nStartY, nEndX, nEndY); 1488cdf0e10cSrcweir } 1489cdf0e10cSrcweir else 1490cdf0e10cSrcweir return Rectangle(); 1491cdf0e10cSrcweir } 14920deba7fbSSteve Yin sal_Bool SAL_CALL ScAccessibleSpreadsheet::selectRow( sal_Int32 row ) 1493*4b4244d8SSteve Yin throw (lang::IndexOutOfBoundsException, uno::RuntimeException, ucb::CommandFailedException, ucb::ContentCreationException) 14940deba7fbSSteve Yin { 14950deba7fbSSteve Yin if (IsFormulaMode()) 14960deba7fbSSteve Yin { 14970deba7fbSSteve Yin return sal_False; 14980deba7fbSSteve Yin } 14990deba7fbSSteve Yin 15000deba7fbSSteve Yin mpViewShell->SetTabNo( maRange.aStart.Tab() ); 15010deba7fbSSteve Yin mpViewShell->DoneBlockMode( sal_True ); // continue selecting 15020deba7fbSSteve Yin mpViewShell->InitBlockMode( 0, row, maRange.aStart.Tab(), sal_False, sal_False, sal_True ); 15030deba7fbSSteve Yin mpViewShell->MarkCursor( MAXCOL, row, maRange.aStart.Tab(), sal_False, sal_True ); 15040deba7fbSSteve Yin mpViewShell->SelectionChanged(); 15050deba7fbSSteve Yin return sal_True; 15060deba7fbSSteve Yin } 15070deba7fbSSteve Yin 15080deba7fbSSteve Yin sal_Bool SAL_CALL ScAccessibleSpreadsheet::selectColumn( sal_Int32 column ) 1509*4b4244d8SSteve Yin throw (lang::IndexOutOfBoundsException, uno::RuntimeException, ucb::CommandFailedException, ucb::ContentCreationException) 15100deba7fbSSteve Yin { 15110deba7fbSSteve Yin if (IsFormulaMode()) 15120deba7fbSSteve Yin { 15130deba7fbSSteve Yin return sal_False; 15140deba7fbSSteve Yin } 15150deba7fbSSteve Yin 15160deba7fbSSteve Yin mpViewShell->SetTabNo( maRange.aStart.Tab() ); 15170deba7fbSSteve Yin mpViewShell->DoneBlockMode( sal_True ); // continue selecting 15180deba7fbSSteve Yin mpViewShell->InitBlockMode( static_cast<SCCOL>(column), 0, maRange.aStart.Tab(), sal_False, sal_True, sal_False ); 15190deba7fbSSteve Yin mpViewShell->MarkCursor( static_cast<SCCOL>(column), MAXROW, maRange.aStart.Tab(), sal_True, sal_False ); 15200deba7fbSSteve Yin mpViewShell->SelectionChanged(); 15210deba7fbSSteve Yin return sal_True; 15220deba7fbSSteve Yin } 15230deba7fbSSteve Yin 15240deba7fbSSteve Yin sal_Bool SAL_CALL ScAccessibleSpreadsheet::unselectRow( sal_Int32 row ) 1525*4b4244d8SSteve Yin throw (lang::IndexOutOfBoundsException, uno::RuntimeException, ucb::CommandFailedException, ucb::ContentCreationException) 15260deba7fbSSteve Yin { 15270deba7fbSSteve Yin if (IsFormulaMode()) 15280deba7fbSSteve Yin { 15290deba7fbSSteve Yin return sal_False; 15300deba7fbSSteve Yin } 15310deba7fbSSteve Yin 15320deba7fbSSteve Yin mpViewShell->SetTabNo( maRange.aStart.Tab() ); 15330deba7fbSSteve Yin mpViewShell->DoneBlockMode( sal_True ); // continue selecting 15340deba7fbSSteve Yin mpViewShell->InitBlockMode( 0, row, maRange.aStart.Tab(), sal_False, sal_False, sal_True, sal_True ); 15350deba7fbSSteve Yin mpViewShell->MarkCursor( MAXCOL, row, maRange.aStart.Tab(), sal_False, sal_True ); 15360deba7fbSSteve Yin mpViewShell->SelectionChanged(); 15370deba7fbSSteve Yin mpViewShell->DoneBlockMode( sal_True ); 15380deba7fbSSteve Yin return sal_True; 15390deba7fbSSteve Yin } 15400deba7fbSSteve Yin 15410deba7fbSSteve Yin sal_Bool SAL_CALL ScAccessibleSpreadsheet::unselectColumn( sal_Int32 column ) 1542*4b4244d8SSteve Yin throw (lang::IndexOutOfBoundsException, uno::RuntimeException, ucb::CommandFailedException, ucb::ContentCreationException) 15430deba7fbSSteve Yin { 15440deba7fbSSteve Yin if (IsFormulaMode()) 15450deba7fbSSteve Yin { 15460deba7fbSSteve Yin return sal_False; 15470deba7fbSSteve Yin } 15480deba7fbSSteve Yin 15490deba7fbSSteve Yin mpViewShell->SetTabNo( maRange.aStart.Tab() ); 15500deba7fbSSteve Yin mpViewShell->DoneBlockMode( sal_True ); // continue selecting 15510deba7fbSSteve Yin mpViewShell->InitBlockMode( static_cast<SCCOL>(column), 0, maRange.aStart.Tab(), sal_False, sal_True, sal_False, sal_True ); 15520deba7fbSSteve Yin mpViewShell->MarkCursor( static_cast<SCCOL>(column), MAXROW, maRange.aStart.Tab(), sal_True, sal_False ); 15530deba7fbSSteve Yin mpViewShell->SelectionChanged(); 15540deba7fbSSteve Yin mpViewShell->DoneBlockMode( sal_True ); 15550deba7fbSSteve Yin return sal_True; 15560deba7fbSSteve Yin } 15570deba7fbSSteve Yin 15580deba7fbSSteve Yin void ScAccessibleSpreadsheet::FireFirstCellFocus() 15590deba7fbSSteve Yin { 15600deba7fbSSteve Yin if (IsFormulaMode()) 15610deba7fbSSteve Yin { 15620deba7fbSSteve Yin return ; 15630deba7fbSSteve Yin } 15640deba7fbSSteve Yin if (mbIsFocusSend) 15650deba7fbSSteve Yin { 15660deba7fbSSteve Yin return ; 15670deba7fbSSteve Yin } 15680deba7fbSSteve Yin mbIsFocusSend = sal_True; 15690deba7fbSSteve Yin AccessibleEventObject aEvent; 15700deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; 15710deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(this); 15720deba7fbSSteve Yin aEvent.NewValue <<= getAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col()); 15730deba7fbSSteve Yin CommitChange(aEvent); 15740deba7fbSSteve Yin } 15750deba7fbSSteve Yin void ScAccessibleSpreadsheet::NotifyRefMode() 15760deba7fbSSteve Yin { 15770deba7fbSSteve Yin ScViewData *pViewData = mpViewShell->GetViewData(); 15780deba7fbSSteve Yin sal_uInt16 nRefStartX =pViewData->GetRefStartX(); 15790deba7fbSSteve Yin sal_Int32 nRefStartY=pViewData->GetRefStartY(); 15800deba7fbSSteve Yin sal_uInt16 nRefEndX=pViewData->GetRefEndX(); 15810deba7fbSSteve Yin sal_Int32 nRefEndY=pViewData->GetRefEndY(); 15820deba7fbSSteve Yin ScAddress aFormulaAddr; 15830deba7fbSSteve Yin if(!GetFormulaCurrentFocusCell(aFormulaAddr)) 15840deba7fbSSteve Yin { 15850deba7fbSSteve Yin return ; 15860deba7fbSSteve Yin } 15870deba7fbSSteve Yin if (m_aFormulaActiveCell != aFormulaAddr) 15880deba7fbSSteve Yin {//New Focus 15890deba7fbSSteve Yin m_nMinX =std::min(nRefStartX,nRefEndX); 15900deba7fbSSteve Yin m_nMaxX =std::max(nRefStartX,nRefEndX); 15910deba7fbSSteve Yin m_nMinY = std::min(nRefStartY,nRefEndY); 15920deba7fbSSteve Yin m_nMaxY = std::max(nRefStartY,nRefEndY); 15930deba7fbSSteve Yin RemoveFormulaSelection(); 15940deba7fbSSteve Yin AccessibleEventObject aEvent; 15950deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(this); 15960deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; 15970deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(this); 15980deba7fbSSteve Yin uno::Reference< XAccessible > xOld = m_pAccFormulaCell; 15990deba7fbSSteve Yin aEvent.OldValue <<= xOld; 16000deba7fbSSteve Yin m_pAccFormulaCell = GetAccessibleCellAt(aFormulaAddr.Row(), aFormulaAddr.Col()); 16010deba7fbSSteve Yin m_pAccFormulaCell->acquire(); 16020deba7fbSSteve Yin m_pAccFormulaCell->Init(); 16030deba7fbSSteve Yin uno::Reference< XAccessible > xNew = m_pAccFormulaCell; 16040deba7fbSSteve Yin aEvent.NewValue <<= xNew; 16050deba7fbSSteve Yin CommitChange(aEvent); 16060deba7fbSSteve Yin if (nRefStartX == nRefEndX && nRefStartY == nRefEndY) 16070deba7fbSSteve Yin {//Selection Single 16080deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; 16090deba7fbSSteve Yin aEvent.NewValue <<= xNew; 16100deba7fbSSteve Yin CommitChange(aEvent); 16110deba7fbSSteve Yin m_mapFormulaSelectionSend.insert(MAP_ADDR_XACC::value_type(aFormulaAddr,xNew)); 16120deba7fbSSteve Yin m_vecFormulaLastMyAddr.clear(); 16130deba7fbSSteve Yin m_vecFormulaLastMyAddr.push_back(aFormulaAddr); 16140deba7fbSSteve Yin } 16150deba7fbSSteve Yin else 16160deba7fbSSteve Yin { 16170deba7fbSSteve Yin VEC_MYADDR vecCurSel; 16180deba7fbSSteve Yin int nCurSize = (m_nMaxX - m_nMinX +1)*(m_nMaxY - m_nMinY +1) ; 16190deba7fbSSteve Yin vecCurSel.reserve(nCurSize); 16200deba7fbSSteve Yin for (sal_uInt16 x = m_nMinX ; x <= m_nMaxX ; ++x) 16210deba7fbSSteve Yin { 16220deba7fbSSteve Yin for (sal_Int32 y = m_nMinY ; y <= m_nMaxY ; ++y) 16230deba7fbSSteve Yin { 16240deba7fbSSteve Yin ScMyAddress aAddr(x,y,0); 16250deba7fbSSteve Yin vecCurSel.push_back(aAddr); 16260deba7fbSSteve Yin } 16270deba7fbSSteve Yin } 16280deba7fbSSteve Yin std::sort(vecCurSel.begin(), vecCurSel.end()); 16290deba7fbSSteve Yin VEC_MYADDR vecNew; 16300deba7fbSSteve Yin std::set_difference(vecCurSel.begin(),vecCurSel.end(), 16310deba7fbSSteve Yin m_vecFormulaLastMyAddr.begin(),m_vecFormulaLastMyAddr.end(), 16320deba7fbSSteve Yin std::back_insert_iterator<VEC_MYADDR>(vecNew)); 16330deba7fbSSteve Yin int nNewSize = vecNew.size(); 16340deba7fbSSteve Yin if ( nNewSize > 10 ) 16350deba7fbSSteve Yin { 16360deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; 16370deba7fbSSteve Yin aEvent.NewValue <<= ::com::sun::star::uno::Any(); 16380deba7fbSSteve Yin CommitChange(aEvent); 16390deba7fbSSteve Yin } 16400deba7fbSSteve Yin else 16410deba7fbSSteve Yin { 16420deba7fbSSteve Yin VEC_MYADDR::iterator viAddr = vecNew.begin(); 16430deba7fbSSteve Yin for(; viAddr != vecNew.end() ; ++viAddr ) 16440deba7fbSSteve Yin { 16450deba7fbSSteve Yin uno::Reference< XAccessible > xChild; 16460deba7fbSSteve Yin if (*viAddr == aFormulaAddr) 16470deba7fbSSteve Yin { 16480deba7fbSSteve Yin xChild = m_pAccFormulaCell; 16490deba7fbSSteve Yin } 16500deba7fbSSteve Yin else 16510deba7fbSSteve Yin { 16520deba7fbSSteve Yin xChild = getAccessibleCellAt(viAddr->Row(),viAddr->Col()); 16530deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS; 16540deba7fbSSteve Yin aEvent.NewValue <<= xChild; 16550deba7fbSSteve Yin CommitChange(aEvent); 16560deba7fbSSteve Yin } 16570deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD; 16580deba7fbSSteve Yin aEvent.NewValue <<= xChild; 16590deba7fbSSteve Yin CommitChange(aEvent); 16600deba7fbSSteve Yin m_mapFormulaSelectionSend.insert(MAP_ADDR_XACC::value_type(*viAddr,xChild)); 16610deba7fbSSteve Yin } 16620deba7fbSSteve Yin } 16630deba7fbSSteve Yin m_vecFormulaLastMyAddr.swap(vecCurSel); 16640deba7fbSSteve Yin } 16650deba7fbSSteve Yin } 16660deba7fbSSteve Yin m_aFormulaActiveCell = aFormulaAddr; 16670deba7fbSSteve Yin } 16680deba7fbSSteve Yin void ScAccessibleSpreadsheet::RemoveFormulaSelection(sal_Bool bRemoveAll ) 16690deba7fbSSteve Yin { 16700deba7fbSSteve Yin AccessibleEventObject aEvent; 16710deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(this); 16720deba7fbSSteve Yin aEvent.OldValue <<= ::com::sun::star::uno::Any(); 16730deba7fbSSteve Yin MAP_ADDR_XACC::iterator miRemove = m_mapFormulaSelectionSend.begin(); 16740deba7fbSSteve Yin for(; miRemove != m_mapFormulaSelectionSend.end() ;) 16750deba7fbSSteve Yin { 16760deba7fbSSteve Yin if( !bRemoveAll && IsScAddrFormulaSel(miRemove->first) ) 16770deba7fbSSteve Yin { 16780deba7fbSSteve Yin ++miRemove; 16790deba7fbSSteve Yin continue; 16800deba7fbSSteve Yin } 16810deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE; 16820deba7fbSSteve Yin aEvent.NewValue <<= miRemove->second; 16830deba7fbSSteve Yin CommitChange(aEvent); 16840deba7fbSSteve Yin MAP_ADDR_XACC::iterator miNext = miRemove; 16850deba7fbSSteve Yin ++miNext; 16860deba7fbSSteve Yin m_mapFormulaSelectionSend.erase(miRemove); 16870deba7fbSSteve Yin miRemove = miNext; 16880deba7fbSSteve Yin } 16890deba7fbSSteve Yin } 16900deba7fbSSteve Yin sal_Bool ScAccessibleSpreadsheet::IsScAddrFormulaSel(const ScAddress &addr) const 16910deba7fbSSteve Yin { 16920deba7fbSSteve Yin if( addr.Col() >= m_nMinX && addr.Col() <= m_nMaxX && 16930deba7fbSSteve Yin addr.Row() >= m_nMinY && addr.Row() <= m_nMaxY && 16940deba7fbSSteve Yin addr.Tab() == mpViewShell->GetViewData()->GetTabNo() ) 16950deba7fbSSteve Yin { 16960deba7fbSSteve Yin return sal_True; 16970deba7fbSSteve Yin } 16980deba7fbSSteve Yin return sal_False; 16990deba7fbSSteve Yin } 17000deba7fbSSteve Yin sal_Bool ScAccessibleSpreadsheet::CheckChildIndex(sal_Int32 nIndex) const 17010deba7fbSSteve Yin { 17020deba7fbSSteve Yin sal_Int32 nMaxIndex = (m_nMaxX - m_nMinX +1)*(m_nMaxY - m_nMinY +1) -1 ; 17030deba7fbSSteve Yin return nIndex <= nMaxIndex && nIndex >= 0 ; 17040deba7fbSSteve Yin } 17050deba7fbSSteve Yin ScAddress ScAccessibleSpreadsheet::GetChildIndexAddress(sal_Int32 nIndex) const 17060deba7fbSSteve Yin { 17070deba7fbSSteve Yin sal_Int32 nRowAll = GetRowAll(); 17080deba7fbSSteve Yin sal_uInt16 nColAll = GetColAll(); 17090deba7fbSSteve Yin if (nIndex < 0 || nIndex >= nRowAll * nColAll ) 17100deba7fbSSteve Yin { 17110deba7fbSSteve Yin return ScAddress(); 17120deba7fbSSteve Yin } 17130deba7fbSSteve Yin return ScAddress( 17140deba7fbSSteve Yin static_cast<SCCOL>((nIndex - nIndex % nRowAll) / nRowAll + + m_nMinX), 17150deba7fbSSteve Yin nIndex % nRowAll + m_nMinY, 17160deba7fbSSteve Yin mpViewShell->GetViewData()->GetTabNo() 17170deba7fbSSteve Yin ); 17180deba7fbSSteve Yin } 17190deba7fbSSteve Yin sal_Int32 ScAccessibleSpreadsheet::GetAccessibleIndexFormula( sal_Int32 nRow, sal_Int32 nColumn ) 17200deba7fbSSteve Yin { 17210deba7fbSSteve Yin sal_uInt16 nColRelative = sal_uInt16(nColumn) - GetColAll(); 17220deba7fbSSteve Yin sal_Int32 nRowRelative = nRow - GetRowAll(); 17230deba7fbSSteve Yin if (nRow < 0 || nColumn < 0 || nRowRelative >= GetRowAll() || nColRelative >= GetColAll() ) 17240deba7fbSSteve Yin { 17250deba7fbSSteve Yin return -1; 17260deba7fbSSteve Yin } 17270deba7fbSSteve Yin return GetRowAll() * nRowRelative + nColRelative; 17280deba7fbSSteve Yin } 17290deba7fbSSteve Yin sal_Bool ScAccessibleSpreadsheet::IsFormulaMode() 17300deba7fbSSteve Yin { 17310deba7fbSSteve Yin ScViewData *pViewData = mpViewShell->GetViewData(); 17320deba7fbSSteve Yin m_bFormulaMode = pViewData->IsRefMode() || SC_MOD()->IsFormulaMode(); 17330deba7fbSSteve Yin return m_bFormulaMode ; 17340deba7fbSSteve Yin } 17350deba7fbSSteve Yin sal_Bool ScAccessibleSpreadsheet::GetFormulaCurrentFocusCell(ScAddress &addr) 17360deba7fbSSteve Yin { 17370deba7fbSSteve Yin ScViewData *pViewData = mpViewShell->GetViewData(); 17380deba7fbSSteve Yin sal_uInt16 nRefX=0; 17390deba7fbSSteve Yin sal_Int32 nRefY=0; 17400deba7fbSSteve Yin if(m_bFormulaLastMode) 17410deba7fbSSteve Yin { 17420deba7fbSSteve Yin nRefX=pViewData->GetRefEndX(); 17430deba7fbSSteve Yin nRefY=pViewData->GetRefEndY(); 17440deba7fbSSteve Yin } 17450deba7fbSSteve Yin else 17460deba7fbSSteve Yin { 17470deba7fbSSteve Yin nRefX=pViewData->GetRefStartX(); 17480deba7fbSSteve Yin nRefY=pViewData->GetRefStartY(); 17490deba7fbSSteve Yin } 17500deba7fbSSteve Yin if( /* Always true: nRefX >= 0 && */ nRefX <= MAXCOL && nRefY >= 0 && nRefY <= MAXROW) 17510deba7fbSSteve Yin { 17520deba7fbSSteve Yin addr = ScAddress(nRefX,nRefY,pViewData->GetTabNo()); 17530deba7fbSSteve Yin return sal_True; 17540deba7fbSSteve Yin } 17550deba7fbSSteve Yin return sal_False; 17560deba7fbSSteve Yin } 17570deba7fbSSteve Yin uno::Reference < XAccessible > ScAccessibleSpreadsheet::GetActiveCell() 17580deba7fbSSteve Yin { 17590deba7fbSSteve Yin if( m_mapSelectionSend.find( maActiveCell ) != m_mapSelectionSend.end() ) 17600deba7fbSSteve Yin return m_mapSelectionSend[maActiveCell]; 17610deba7fbSSteve Yin else 17620deba7fbSSteve Yin return getAccessibleCellAt(maActiveCell.Row(), maActiveCell .Col()); 17630deba7fbSSteve Yin } 1764