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 10b3f79822SAndrew Rist * 11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12b3f79822SAndrew Rist * 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. 19b3f79822SAndrew Rist * 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> 53*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 54*0deba7fbSSteve Yin #include "scresid.hxx" 55*0deba7fbSSteve Yin #include "sc.hrc" 56*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 57cdf0e10cSrcweir #include <algorithm> 58cdf0e10cSrcweir 59cdf0e10cSrcweir using namespace ::com::sun::star; 60cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 61cdf0e10cSrcweir 62*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 63*0deba7fbSSteve Yin bool CompMinCol(const std::pair<sal_uInt16,sal_uInt16> & pc1,const std::pair<sal_uInt16,sal_uInt16> &pc2) 64*0deba7fbSSteve Yin { 65*0deba7fbSSteve Yin return pc1.first < pc2.first; 66*0deba7fbSSteve Yin } 67*0deba7fbSSteve Yin ScMyAddress ScAccessibleSpreadsheet::CalcScAddressFromRangeList(ScRangeList *pMarkedRanges,sal_Int32 nSelectedChildIndex) 68*0deba7fbSSteve Yin { 69*0deba7fbSSteve Yin if (pMarkedRanges->Count() <= 1) 70*0deba7fbSSteve Yin { 71*0deba7fbSSteve Yin ScRange* pRange = pMarkedRanges->First(); 72*0deba7fbSSteve Yin if (pRange) 73*0deba7fbSSteve Yin { 74*0deba7fbSSteve Yin // MT IA2: Not used. 75*0deba7fbSSteve Yin // const int nRowNum = pRange->aEnd.Row() - pRange->aStart.Row() + 1; 76*0deba7fbSSteve Yin const int nColNum = pRange->aEnd.Col() - pRange->aStart.Col() + 1; 77*0deba7fbSSteve Yin const int nCurCol = nSelectedChildIndex % nColNum; 78*0deba7fbSSteve Yin const int nCurRow = (nSelectedChildIndex - nCurCol)/nColNum; 79*0deba7fbSSteve Yin return ScMyAddress(static_cast<SCCOL>(pRange->aStart.Col() + nCurCol), pRange->aStart.Row() + nCurRow, maActiveCell.Tab()); 80*0deba7fbSSteve Yin } 81*0deba7fbSSteve Yin } 82*0deba7fbSSteve Yin else 83*0deba7fbSSteve Yin { 84*0deba7fbSSteve Yin sal_Int32 nMinRow = MAXROW; 85*0deba7fbSSteve Yin sal_Int32 nMaxRow = 0; 86*0deba7fbSSteve Yin m_vecTempRange.clear(); 87*0deba7fbSSteve Yin ScRange* pRange = pMarkedRanges->First(); 88*0deba7fbSSteve Yin while (pRange) 89*0deba7fbSSteve Yin { 90*0deba7fbSSteve Yin if (pRange->aStart.Tab() != pRange->aEnd.Tab()) 91*0deba7fbSSteve Yin { 92*0deba7fbSSteve Yin if ((maActiveCell.Tab() >= pRange->aStart.Tab()) || 93*0deba7fbSSteve Yin maActiveCell.Tab() <= pRange->aEnd.Tab()) 94*0deba7fbSSteve Yin { 95*0deba7fbSSteve Yin m_vecTempRange.push_back(pRange); 96*0deba7fbSSteve Yin nMinRow = std::min(pRange->aStart.Row(),nMinRow); 97*0deba7fbSSteve Yin nMaxRow = std::max(pRange->aEnd.Row(),nMaxRow); 98*0deba7fbSSteve Yin } 99*0deba7fbSSteve Yin else 100*0deba7fbSSteve Yin DBG_ERROR("Range of wrong table"); 101*0deba7fbSSteve Yin } 102*0deba7fbSSteve Yin else if(pRange->aStart.Tab() == maActiveCell.Tab()) 103*0deba7fbSSteve Yin { 104*0deba7fbSSteve Yin m_vecTempRange.push_back(pRange); 105*0deba7fbSSteve Yin nMinRow = std::min(pRange->aStart.Row(),nMinRow); 106*0deba7fbSSteve Yin nMaxRow = std::max(pRange->aEnd.Row(),nMaxRow); 107*0deba7fbSSteve Yin } 108*0deba7fbSSteve Yin else 109*0deba7fbSSteve Yin DBG_ERROR("Range of wrong table"); 110*0deba7fbSSteve Yin pRange = pMarkedRanges->Next(); 111*0deba7fbSSteve Yin } 112*0deba7fbSSteve Yin int nCurrentIndex = 0 ; 113*0deba7fbSSteve Yin for(sal_Int32 row = nMinRow ; row <= nMaxRow ; ++row) 114*0deba7fbSSteve Yin { 115*0deba7fbSSteve Yin m_vecTempCol.clear(); 116*0deba7fbSSteve Yin { 117*0deba7fbSSteve Yin VEC_RANGE::const_iterator vi = m_vecTempRange.begin(); 118*0deba7fbSSteve Yin for (; vi < m_vecTempRange.end(); ++vi) 119*0deba7fbSSteve Yin { 120*0deba7fbSSteve Yin ScRange *p = *vi; 121*0deba7fbSSteve Yin if ( row >= p->aStart.Row() && row <= p->aEnd.Row()) 122*0deba7fbSSteve Yin { 123*0deba7fbSSteve Yin m_vecTempCol.push_back(std::make_pair(p->aStart.Col(),p->aEnd.Col())); 124*0deba7fbSSteve Yin } 125*0deba7fbSSteve Yin } 126*0deba7fbSSteve Yin } 127*0deba7fbSSteve Yin std::sort(m_vecTempCol.begin(),m_vecTempCol.end(),CompMinCol); 128*0deba7fbSSteve Yin { 129*0deba7fbSSteve Yin VEC_COL::const_iterator vic = m_vecTempCol.begin(); 130*0deba7fbSSteve Yin for(; vic != m_vecTempCol.end(); ++vic) 131*0deba7fbSSteve Yin { 132*0deba7fbSSteve Yin const PAIR_COL &pariCol = *vic; 133*0deba7fbSSteve Yin sal_uInt16 nCol = pariCol.second - pariCol.first + 1; 134*0deba7fbSSteve Yin if (nCol + nCurrentIndex > nSelectedChildIndex) 135*0deba7fbSSteve Yin { 136*0deba7fbSSteve Yin return ScMyAddress(static_cast<SCCOL>(pariCol.first + nSelectedChildIndex - nCurrentIndex), row, maActiveCell.Tab()); 137*0deba7fbSSteve Yin } 138*0deba7fbSSteve Yin nCurrentIndex += nCol; 139*0deba7fbSSteve Yin } 140*0deba7fbSSteve Yin } 141*0deba7fbSSteve Yin } 142*0deba7fbSSteve Yin } 143*0deba7fbSSteve Yin return ScMyAddress(0,0,maActiveCell.Tab()); 144*0deba7fbSSteve Yin } 145*0deba7fbSSteve Yin sal_Bool ScAccessibleSpreadsheet::CalcScRangeDifferenceMax(ScRange *pSrc,ScRange *pDest,int nMax,VEC_MYADDR &vecRet,int &nSize) 146*0deba7fbSSteve Yin { 147*0deba7fbSSteve Yin //Src Must be :Src > Dest 148*0deba7fbSSteve Yin if (pDest->In(*pSrc)) 149*0deba7fbSSteve Yin {//Here is Src In Dest,Src <= Dest 150*0deba7fbSSteve Yin return sal_False; 151*0deba7fbSSteve Yin } 152*0deba7fbSSteve Yin if (!pDest->Intersects(*pSrc)) 153*0deba7fbSSteve Yin { 154*0deba7fbSSteve Yin int nCellCount = sal_uInt32(pDest->aEnd.Col() - pDest->aStart.Col() + 1) 155*0deba7fbSSteve Yin * sal_uInt32(pDest->aEnd.Row() - pDest->aStart.Row() + 1) 156*0deba7fbSSteve Yin * sal_uInt32(pDest->aEnd.Tab() - pDest->aStart.Tab() + 1); 157*0deba7fbSSteve Yin if (nCellCount + nSize > nMax) 158*0deba7fbSSteve Yin { 159*0deba7fbSSteve Yin return sal_True; 160*0deba7fbSSteve Yin } 161*0deba7fbSSteve Yin else if(nCellCount > 0) 162*0deba7fbSSteve Yin { 163*0deba7fbSSteve Yin nCellCount +=nSize; 164*0deba7fbSSteve Yin for (sal_Int32 row = pDest->aStart.Row(); row <= pDest->aEnd.Row();++row) 165*0deba7fbSSteve Yin { 166*0deba7fbSSteve Yin for (sal_uInt16 col = pDest->aStart.Col(); col <= pDest->aEnd.Col();++col) 167*0deba7fbSSteve Yin { 168*0deba7fbSSteve Yin vecRet.push_back(ScMyAddress(col,row,pDest->aStart.Tab())); 169*0deba7fbSSteve Yin } 170*0deba7fbSSteve Yin } 171*0deba7fbSSteve Yin } 172*0deba7fbSSteve Yin return sal_False; 173*0deba7fbSSteve Yin } 174*0deba7fbSSteve Yin sal_Int32 nMinRow = pSrc->aStart.Row(); 175*0deba7fbSSteve Yin sal_Int32 nMaxRow = pSrc->aEnd.Row(); 176*0deba7fbSSteve Yin for (; nMinRow <= nMaxRow ; ++nMinRow,--nMaxRow) 177*0deba7fbSSteve Yin { 178*0deba7fbSSteve Yin for (sal_uInt16 col = pSrc->aStart.Col(); col <= pSrc->aEnd.Col();++col) 179*0deba7fbSSteve Yin { 180*0deba7fbSSteve Yin if (nSize > nMax) 181*0deba7fbSSteve Yin { 182*0deba7fbSSteve Yin return sal_True; 183*0deba7fbSSteve Yin } 184*0deba7fbSSteve Yin ScMyAddress cell(col,nMinRow,pSrc->aStart.Tab()); 185*0deba7fbSSteve Yin if(!pDest->In(cell)) 186*0deba7fbSSteve Yin {//In Src ,Not In Dest 187*0deba7fbSSteve Yin vecRet.push_back(cell); 188*0deba7fbSSteve Yin ++nSize; 189*0deba7fbSSteve Yin } 190*0deba7fbSSteve Yin } 191*0deba7fbSSteve Yin if (nMinRow != nMaxRow) 192*0deba7fbSSteve Yin { 193*0deba7fbSSteve Yin for (sal_uInt16 col = pSrc->aStart.Col(); col <= pSrc->aEnd.Col();++col) 194*0deba7fbSSteve Yin { 195*0deba7fbSSteve Yin if (nSize > nMax) 196*0deba7fbSSteve Yin { 197*0deba7fbSSteve Yin return sal_True; 198*0deba7fbSSteve Yin } 199*0deba7fbSSteve Yin ScMyAddress cell(col,nMaxRow,pSrc->aStart.Tab()); 200*0deba7fbSSteve Yin if(!pDest->In(cell)) 201*0deba7fbSSteve Yin {//In Src ,Not In Dest 202*0deba7fbSSteve Yin vecRet.push_back(cell); 203*0deba7fbSSteve Yin ++nSize; 204*0deba7fbSSteve Yin } 205*0deba7fbSSteve Yin } 206*0deba7fbSSteve Yin } 207*0deba7fbSSteve Yin } 208*0deba7fbSSteve Yin return sal_False; 209*0deba7fbSSteve Yin } 210*0deba7fbSSteve Yin //In Src , Not in Dest 211*0deba7fbSSteve Yin sal_Bool ScAccessibleSpreadsheet::CalcScRangeListDifferenceMax(ScRangeList *pSrc,ScRangeList *pDest,int nMax,VEC_MYADDR &vecRet) 212*0deba7fbSSteve Yin { 213*0deba7fbSSteve Yin if (pSrc == NULL || pDest == NULL) 214*0deba7fbSSteve Yin { 215*0deba7fbSSteve Yin return sal_False; 216*0deba7fbSSteve Yin } 217*0deba7fbSSteve Yin int nSize =0; 218*0deba7fbSSteve Yin if (pDest->GetCellCount() == 0)//if the Dest Rang List is empty 219*0deba7fbSSteve Yin { 220*0deba7fbSSteve Yin if (pSrc->GetCellCount() > sal_uInt32(nMax))//if the Src Cell count is greater then nMax 221*0deba7fbSSteve Yin { 222*0deba7fbSSteve Yin return sal_True; 223*0deba7fbSSteve Yin } 224*0deba7fbSSteve Yin //now the cell count is less then nMax 225*0deba7fbSSteve Yin vecRet.reserve(10); 226*0deba7fbSSteve Yin ScRange* pRange = pSrc->First(); 227*0deba7fbSSteve Yin while (pRange) 228*0deba7fbSSteve Yin { 229*0deba7fbSSteve Yin for (sal_Int32 row = pRange->aStart.Row(); row <= pRange->aEnd.Row();++row) 230*0deba7fbSSteve Yin { 231*0deba7fbSSteve Yin for (sal_uInt16 col = pRange->aStart.Col(); col <= pRange->aEnd.Col();++col) 232*0deba7fbSSteve Yin { 233*0deba7fbSSteve Yin vecRet.push_back(ScMyAddress(col,row,pRange->aStart.Tab())); 234*0deba7fbSSteve Yin } 235*0deba7fbSSteve Yin } 236*0deba7fbSSteve Yin pRange = pSrc->Next(); 237*0deba7fbSSteve Yin } 238*0deba7fbSSteve Yin return sal_False; 239*0deba7fbSSteve Yin } 240*0deba7fbSSteve Yin //the Dest Rang List is not empty 241*0deba7fbSSteve Yin vecRet.reserve(10); 242*0deba7fbSSteve Yin ScRange* pRange = pSrc->First(); 243*0deba7fbSSteve Yin while (pRange) 244*0deba7fbSSteve Yin { 245*0deba7fbSSteve Yin ScRange* pRangeDest = pDest->First(); 246*0deba7fbSSteve Yin while (pRangeDest) 247*0deba7fbSSteve Yin { 248*0deba7fbSSteve Yin if (CalcScRangeDifferenceMax(pRange,pRangeDest,nMax,vecRet,nSize)) 249*0deba7fbSSteve Yin { 250*0deba7fbSSteve Yin return sal_True; 251*0deba7fbSSteve Yin } 252*0deba7fbSSteve Yin pRangeDest = pDest->Next(); 253*0deba7fbSSteve Yin } 254*0deba7fbSSteve Yin pRange = pSrc->Next(); 255*0deba7fbSSteve Yin } 256*0deba7fbSSteve Yin return sal_False; 257*0deba7fbSSteve Yin } 258*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 259cdf0e10cSrcweir //===== internal ============================================================ 260cdf0e10cSrcweir 261cdf0e10cSrcweir ScAccessibleSpreadsheet::ScAccessibleSpreadsheet( 262cdf0e10cSrcweir ScAccessibleDocument* pAccDoc, 263cdf0e10cSrcweir ScTabViewShell* pViewShell, 264cdf0e10cSrcweir SCTAB nTab, 265cdf0e10cSrcweir ScSplitPos eSplitPos) 266cdf0e10cSrcweir : 267cdf0e10cSrcweir ScAccessibleTableBase (pAccDoc, GetDocument(pViewShell), 268cdf0e10cSrcweir ScRange(ScAddress(0, 0, nTab),ScAddress(MAXCOL, MAXROW, nTab))), 269*0deba7fbSSteve Yin mbIsSpreadsheet( sal_True ), 270*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 271*0deba7fbSSteve Yin m_bFormulaMode(sal_False), 272*0deba7fbSSteve Yin m_bFormulaLastMode(sal_False), 273*0deba7fbSSteve Yin m_pAccFormulaCell(NULL), 274*0deba7fbSSteve Yin m_nMinX(0),m_nMaxX(0),m_nMinY(0),m_nMaxY(0) 275*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 276cdf0e10cSrcweir { 277cdf0e10cSrcweir ConstructScAccessibleSpreadsheet( pAccDoc, pViewShell, nTab, eSplitPos ); 278cdf0e10cSrcweir } 279cdf0e10cSrcweir 280cdf0e10cSrcweir ScAccessibleSpreadsheet::ScAccessibleSpreadsheet( 281cdf0e10cSrcweir ScAccessibleSpreadsheet& rParent, const ScRange& rRange ) : 282cdf0e10cSrcweir ScAccessibleTableBase( rParent.mpAccDoc, rParent.mpDoc, rRange), 283cdf0e10cSrcweir mbIsSpreadsheet( sal_False ) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir ConstructScAccessibleSpreadsheet( rParent.mpAccDoc, rParent.mpViewShell, rParent.mnTab, rParent.meSplitPos ); 286cdf0e10cSrcweir } 287cdf0e10cSrcweir 288cdf0e10cSrcweir ScAccessibleSpreadsheet::~ScAccessibleSpreadsheet() 289cdf0e10cSrcweir { 290cdf0e10cSrcweir if (mpMarkedRanges) 291cdf0e10cSrcweir delete mpMarkedRanges; 292*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 293*0deba7fbSSteve Yin //if (mpSortedMarkedCells) 294*0deba7fbSSteve Yin // delete mpSortedMarkedCells; 295*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 296cdf0e10cSrcweir if (mpViewShell) 297cdf0e10cSrcweir mpViewShell->RemoveAccessibilityObject(*this); 298cdf0e10cSrcweir } 299cdf0e10cSrcweir 300cdf0e10cSrcweir void ScAccessibleSpreadsheet::ConstructScAccessibleSpreadsheet( 301cdf0e10cSrcweir ScAccessibleDocument* pAccDoc, 302cdf0e10cSrcweir ScTabViewShell* pViewShell, 303cdf0e10cSrcweir SCTAB nTab, 304cdf0e10cSrcweir ScSplitPos eSplitPos) 305cdf0e10cSrcweir { 306cdf0e10cSrcweir mpViewShell = pViewShell; 307cdf0e10cSrcweir mpMarkedRanges = 0; 308cdf0e10cSrcweir mpSortedMarkedCells = 0; 309cdf0e10cSrcweir mpAccDoc = pAccDoc; 310cdf0e10cSrcweir mpAccCell = 0; 311cdf0e10cSrcweir meSplitPos = eSplitPos; 312cdf0e10cSrcweir mnTab = nTab; 313cdf0e10cSrcweir mbHasSelection = sal_False; 314cdf0e10cSrcweir mbDelIns = sal_False; 315cdf0e10cSrcweir mbIsFocusSend = sal_False; 316cdf0e10cSrcweir maVisCells = GetVisCells(GetVisArea(mpViewShell, meSplitPos)); 317cdf0e10cSrcweir if (mpViewShell) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir mpViewShell->AddAccessibilityObject(*this); 320cdf0e10cSrcweir 321cdf0e10cSrcweir const ScViewData& rViewData = *mpViewShell->GetViewData(); 322cdf0e10cSrcweir const ScMarkData& rMarkData = rViewData.GetMarkData(); 323cdf0e10cSrcweir maActiveCell = rViewData.GetCurPos(); 324cdf0e10cSrcweir mbHasSelection = rMarkData.GetTableSelect(maActiveCell.Tab()) && 325cdf0e10cSrcweir (rMarkData.IsMarked() || rMarkData.IsMultiMarked()); 326cdf0e10cSrcweir mpAccCell = GetAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col()); 327cdf0e10cSrcweir mpAccCell->acquire(); 328cdf0e10cSrcweir mpAccCell->Init(); 329*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 330*0deba7fbSSteve Yin ScDocument* pScDoc= GetDocument(mpViewShell); 331*0deba7fbSSteve Yin if (pScDoc) 332*0deba7fbSSteve Yin { 333*0deba7fbSSteve Yin pScDoc->GetName( maActiveCell.Tab(), m_strOldTabName ); 334*0deba7fbSSteve Yin } 335*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 336*0deba7fbSSteve Yin } 337cdf0e10cSrcweir } 338cdf0e10cSrcweir 339cdf0e10cSrcweir void SAL_CALL ScAccessibleSpreadsheet::disposing() 340cdf0e10cSrcweir { 341cdf0e10cSrcweir ScUnoGuard aGuard; 342cdf0e10cSrcweir if (mpViewShell) 343cdf0e10cSrcweir { 344cdf0e10cSrcweir mpViewShell->RemoveAccessibilityObject(*this); 345cdf0e10cSrcweir mpViewShell = NULL; 346cdf0e10cSrcweir } 347cdf0e10cSrcweir if (mpAccCell) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir mpAccCell->release(); 350cdf0e10cSrcweir mpAccCell = NULL; 351cdf0e10cSrcweir } 352cdf0e10cSrcweir 353cdf0e10cSrcweir ScAccessibleTableBase::disposing(); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir 356cdf0e10cSrcweir void ScAccessibleSpreadsheet::CompleteSelectionChanged(sal_Bool bNewState) 357cdf0e10cSrcweir { 358*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 359*0deba7fbSSteve Yin if (IsFormulaMode()) 360*0deba7fbSSteve Yin { 361*0deba7fbSSteve Yin return ; 362*0deba7fbSSteve Yin } 363*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 364cdf0e10cSrcweir if (mpMarkedRanges) 365cdf0e10cSrcweir DELETEZ(mpMarkedRanges); 366*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 367*0deba7fbSSteve Yin //if (mpSortedMarkedCells) 368*0deba7fbSSteve Yin // DELETEZ(mpSortedMarkedCells); 369*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 370cdf0e10cSrcweir mbHasSelection = bNewState; 371cdf0e10cSrcweir 372cdf0e10cSrcweir AccessibleEventObject aEvent; 373cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::STATE_CHANGED; 374cdf0e10cSrcweir if (bNewState) 375cdf0e10cSrcweir aEvent.NewValue = uno::makeAny(AccessibleStateType::SELECTED); 376cdf0e10cSrcweir else 377cdf0e10cSrcweir aEvent.OldValue = uno::makeAny(AccessibleStateType::SELECTED); 378cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 379cdf0e10cSrcweir 380cdf0e10cSrcweir CommitChange(aEvent); 381cdf0e10cSrcweir } 382cdf0e10cSrcweir 383cdf0e10cSrcweir void ScAccessibleSpreadsheet::LostFocus() 384cdf0e10cSrcweir { 385cdf0e10cSrcweir AccessibleEventObject aEvent; 386cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; 387cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 388cdf0e10cSrcweir uno::Reference< XAccessible > xOld = mpAccCell; 389cdf0e10cSrcweir aEvent.OldValue <<= xOld; 390cdf0e10cSrcweir 391cdf0e10cSrcweir CommitChange(aEvent); 392cdf0e10cSrcweir 393cdf0e10cSrcweir CommitFocusLost(); 394cdf0e10cSrcweir } 395cdf0e10cSrcweir 396cdf0e10cSrcweir void ScAccessibleSpreadsheet::GotFocus() 397cdf0e10cSrcweir { 398*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 399*0deba7fbSSteve Yin //CommitFocusGained(); 400*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 401cdf0e10cSrcweir AccessibleEventObject aEvent; 402cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; 403cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 404*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 405*0deba7fbSSteve Yin //uno::Reference< XAccessible > xNew = mpAccCell; 406*0deba7fbSSteve Yin uno::Reference< XAccessible > xNew; 407*0deba7fbSSteve Yin if (IsFormulaMode()) 408*0deba7fbSSteve Yin { 409*0deba7fbSSteve Yin if (!m_pAccFormulaCell || !m_bFormulaLastMode) 410*0deba7fbSSteve Yin { 411*0deba7fbSSteve Yin ScAddress aFormulaAddr; 412*0deba7fbSSteve Yin if(!GetFormulaCurrentFocusCell(aFormulaAddr)) 413*0deba7fbSSteve Yin { 414*0deba7fbSSteve Yin return; 415*0deba7fbSSteve Yin } 416*0deba7fbSSteve Yin m_pAccFormulaCell = GetAccessibleCellAt(aFormulaAddr.Row(),aFormulaAddr.Col()); 417*0deba7fbSSteve Yin 418*0deba7fbSSteve Yin m_pAccFormulaCell->acquire(); 419*0deba7fbSSteve Yin m_pAccFormulaCell->Init(); 420*0deba7fbSSteve Yin 421*0deba7fbSSteve Yin 422*0deba7fbSSteve Yin } 423*0deba7fbSSteve Yin xNew = m_pAccFormulaCell; 424*0deba7fbSSteve Yin } 425*0deba7fbSSteve Yin else 426*0deba7fbSSteve Yin { 427*0deba7fbSSteve Yin if(mpAccCell->GetCellAddress() == maActiveCell) 428*0deba7fbSSteve Yin { 429*0deba7fbSSteve Yin xNew = mpAccCell; 430*0deba7fbSSteve Yin } 431*0deba7fbSSteve Yin else 432*0deba7fbSSteve Yin { 433*0deba7fbSSteve Yin CommitFocusCell(maActiveCell); 434*0deba7fbSSteve Yin return ; 435*0deba7fbSSteve Yin } 436*0deba7fbSSteve Yin } 437*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 438cdf0e10cSrcweir aEvent.NewValue <<= xNew; 439cdf0e10cSrcweir 440cdf0e10cSrcweir CommitChange(aEvent); 441cdf0e10cSrcweir } 442cdf0e10cSrcweir 443cdf0e10cSrcweir void ScAccessibleSpreadsheet::BoundingBoxChanged() 444cdf0e10cSrcweir { 445cdf0e10cSrcweir AccessibleEventObject aEvent; 446cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED; 447cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 448cdf0e10cSrcweir 449cdf0e10cSrcweir CommitChange(aEvent); 450cdf0e10cSrcweir } 451cdf0e10cSrcweir 452cdf0e10cSrcweir void ScAccessibleSpreadsheet::VisAreaChanged() 453cdf0e10cSrcweir { 454cdf0e10cSrcweir AccessibleEventObject aEvent; 455cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED; 456cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 457cdf0e10cSrcweir 458cdf0e10cSrcweir CommitChange(aEvent); 459cdf0e10cSrcweir } 460cdf0e10cSrcweir 461cdf0e10cSrcweir //===== SfxListener ===================================================== 462cdf0e10cSrcweir 463cdf0e10cSrcweir void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir if (rHint.ISA( SfxSimpleHint ) ) 466cdf0e10cSrcweir { 467cdf0e10cSrcweir const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint; 468cdf0e10cSrcweir // only notify if child exist, otherwise it is not necessary 469*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 470*0deba7fbSSteve Yin //if ((rRef.GetId() == SC_HINT_ACC_CURSORCHANGED)) 471*0deba7fbSSteve Yin //{ 472*0deba7fbSSteve Yin // if (mpViewShell) 473*0deba7fbSSteve Yin // { 474*0deba7fbSSteve Yin // ScAddress aNewCell = mpViewShell->GetViewData()->GetCurPos(); 475*0deba7fbSSteve Yin // sal_Bool bNewMarked(mpViewShell->GetViewData()->GetMarkData().GetTableSelect(aNewCell.Tab()) && 476*0deba7fbSSteve Yin // (mpViewShell->GetViewData()->GetMarkData().IsMarked() || 477*0deba7fbSSteve Yin // mpViewShell->GetViewData()->GetMarkData().IsMultiMarked())); 478*0deba7fbSSteve Yin // sal_Bool bNewCellSelected(isAccessibleSelected(aNewCell.Row(), aNewCell.Col())); 479*0deba7fbSSteve Yin // if ((bNewMarked != mbHasSelection) || 480*0deba7fbSSteve Yin // (!bNewCellSelected && bNewMarked) || 481*0deba7fbSSteve Yin // (bNewCellSelected && mbHasSelection)) 482*0deba7fbSSteve Yin // { 483*0deba7fbSSteve Yin // if (mpMarkedRanges) 484*0deba7fbSSteve Yin // DELETEZ(mpMarkedRanges); 485*0deba7fbSSteve Yin // if (mpSortedMarkedCells) 486*0deba7fbSSteve Yin // DELETEZ(mpSortedMarkedCells); 487*0deba7fbSSteve Yin // AccessibleEventObject aEvent; 488*0deba7fbSSteve Yin // aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; 489*0deba7fbSSteve Yin // aEvent.Source = uno::Reference< XAccessibleContext >(this); 490*0deba7fbSSteve Yin 491*0deba7fbSSteve Yin // mbHasSelection = bNewMarked; 492*0deba7fbSSteve Yin 493*0deba7fbSSteve Yin // CommitChange(aEvent); 494*0deba7fbSSteve Yin // } 495*0deba7fbSSteve Yin 496*0deba7fbSSteve Yin // // active descendant changed event (new cell selected) 497*0deba7fbSSteve Yin // bool bFireActiveDescChanged = (aNewCell != maActiveCell) && 498*0deba7fbSSteve Yin // (aNewCell.Tab() == maActiveCell.Tab()) && IsFocused(); 499*0deba7fbSSteve Yin 500*0deba7fbSSteve Yin // /* Remember old active cell and set new active cell. 501*0deba7fbSSteve Yin // #i82409# always update the class members mpAccCell and 502*0deba7fbSSteve Yin // maActiveCell, even if the sheet is not focused, e.g. when 503*0deba7fbSSteve Yin // using the name box in the toolbar. */ 504*0deba7fbSSteve Yin // uno::Reference< XAccessible > xOld = mpAccCell; 505*0deba7fbSSteve Yin // mpAccCell->release(); 506*0deba7fbSSteve Yin // mpAccCell = GetAccessibleCellAt(aNewCell.Row(), aNewCell.Col()); 507*0deba7fbSSteve Yin // mpAccCell->acquire(); 508*0deba7fbSSteve Yin // mpAccCell->Init(); 509*0deba7fbSSteve Yin // uno::Reference< XAccessible > xNew = mpAccCell; 510*0deba7fbSSteve Yin // maActiveCell = aNewCell; 511*0deba7fbSSteve Yin 512*0deba7fbSSteve Yin // // #i14108# fire event only if sheet is focused 513*0deba7fbSSteve Yin // if( bFireActiveDescChanged ) 514*0deba7fbSSteve Yin // { 515*0deba7fbSSteve Yin // AccessibleEventObject aEvent; 516*0deba7fbSSteve Yin // aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; 517*0deba7fbSSteve Yin // aEvent.Source = uno::Reference< XAccessibleContext >(this); 518*0deba7fbSSteve Yin // aEvent.OldValue <<= xOld; 519*0deba7fbSSteve Yin // aEvent.NewValue <<= xNew; 520*0deba7fbSSteve Yin // CommitChange(aEvent); 521*0deba7fbSSteve Yin // } 522*0deba7fbSSteve Yin // } 523*0deba7fbSSteve Yin //} 524*0deba7fbSSteve Yin //else if ((rRef.GetId() == SC_HINT_DATACHANGED)) 525*0deba7fbSSteve Yin //{ 526*0deba7fbSSteve Yin // if (!mbDelIns) 527*0deba7fbSSteve Yin // CommitTableModelChange(maRange.aStart.Row(), maRange.aStart.Col(), maRange.aEnd.Row(), maRange.aEnd.Col(), AccessibleTableModelChangeType::UPDATE); 528*0deba7fbSSteve Yin // else 529*0deba7fbSSteve Yin // mbDelIns = sal_False; 530*0deba7fbSSteve Yin //} 531cdf0e10cSrcweir if ((rRef.GetId() == SC_HINT_ACC_CURSORCHANGED)) 532cdf0e10cSrcweir { 533cdf0e10cSrcweir if (mpViewShell) 534cdf0e10cSrcweir { 535*0deba7fbSSteve Yin ScViewData *pViewData = mpViewShell->GetViewData(); 536cdf0e10cSrcweir 537*0deba7fbSSteve Yin m_bFormulaMode = pViewData->IsRefMode() || SC_MOD()->IsFormulaMode(); 538*0deba7fbSSteve Yin if ( m_bFormulaMode ) 539*0deba7fbSSteve Yin { 540*0deba7fbSSteve Yin NotifyRefMode(); 541*0deba7fbSSteve Yin m_bFormulaLastMode = true; 542*0deba7fbSSteve Yin return ; 543*0deba7fbSSteve Yin } 544*0deba7fbSSteve Yin if (m_bFormulaLastMode) 545*0deba7fbSSteve Yin {//Last Notify Mode Is Formula Mode. 546*0deba7fbSSteve Yin m_vecFormulaLastMyAddr.clear(); 547*0deba7fbSSteve Yin RemoveFormulaSelection(sal_True); 548*0deba7fbSSteve Yin if(m_pAccFormulaCell) 549*0deba7fbSSteve Yin { 550*0deba7fbSSteve Yin m_pAccFormulaCell->release(); 551*0deba7fbSSteve Yin m_pAccFormulaCell =NULL; 552*0deba7fbSSteve Yin } 553*0deba7fbSSteve Yin //Remove All Selection 554*0deba7fbSSteve Yin } 555*0deba7fbSSteve Yin m_bFormulaLastMode = m_bFormulaMode; 556cdf0e10cSrcweir 557*0deba7fbSSteve Yin AccessibleEventObject aEvent; 558*0deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(this); 559*0deba7fbSSteve Yin ScAddress aNewCell = pViewData->GetCurPos(); 560*0deba7fbSSteve Yin if(aNewCell.Tab() != maActiveCell.Tab()) 561*0deba7fbSSteve Yin { 562*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::PAGE_CHANGED; 563*0deba7fbSSteve Yin ScAccessibleDocument *pAccDoc = 564*0deba7fbSSteve Yin static_cast<ScAccessibleDocument*>(getAccessibleParent().get()); 565*0deba7fbSSteve Yin if(pAccDoc) 566*0deba7fbSSteve Yin { 567*0deba7fbSSteve Yin pAccDoc->CommitChange(aEvent); 568*0deba7fbSSteve Yin } 569*0deba7fbSSteve Yin } 570*0deba7fbSSteve Yin sal_Bool bNewPosCell = (aNewCell != maActiveCell); 571*0deba7fbSSteve Yin sal_Bool bNewPosCellFocus=sal_False; 572*0deba7fbSSteve Yin if ( bNewPosCell && IsFocused() && aNewCell.Tab() == maActiveCell.Tab() ) 573*0deba7fbSSteve Yin {//single Focus 574*0deba7fbSSteve Yin bNewPosCellFocus=sal_True; 575*0deba7fbSSteve Yin } 576*0deba7fbSSteve Yin ScMarkData &refScMarkData = pViewData->GetMarkData(); 577*0deba7fbSSteve Yin // MT IA2: Not used 578*0deba7fbSSteve Yin // int nSelCount = refScMarkData.GetSelectCount(); 579*0deba7fbSSteve Yin sal_Bool bIsMark =refScMarkData.IsMarked(); 580*0deba7fbSSteve Yin sal_Bool bIsMultMark = refScMarkData.IsMultiMarked(); 581*0deba7fbSSteve Yin sal_Bool bNewMarked = refScMarkData.GetTableSelect(aNewCell.Tab()) && ( bIsMark || bIsMultMark ); 582*0deba7fbSSteve Yin // sal_Bool bNewCellSelected = isAccessibleSelected(aNewCell.Row(), aNewCell.Col()); 583*0deba7fbSSteve Yin sal_uInt16 nTab = pViewData->GetTabNo(); 584*0deba7fbSSteve Yin ScRange aMarkRange; 585*0deba7fbSSteve Yin refScMarkData.GetMarkArea(aMarkRange); 586*0deba7fbSSteve Yin aEvent.OldValue <<= ::com::sun::star::uno::Any(); 587*0deba7fbSSteve Yin //Mark All 588*0deba7fbSSteve Yin if ( !bNewPosCellFocus && 589*0deba7fbSSteve Yin (bNewMarked || bIsMark || bIsMultMark ) && 590*0deba7fbSSteve Yin aMarkRange == ScRange( 0,0,nTab, MAXCOL,MAXROW,nTab ) ) 591*0deba7fbSSteve Yin { 592*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; 593*0deba7fbSSteve Yin aEvent.NewValue <<= ::com::sun::star::uno::Any(); 594cdf0e10cSrcweir CommitChange(aEvent); 595*0deba7fbSSteve Yin return ; 596*0deba7fbSSteve Yin } 597*0deba7fbSSteve Yin if (!mpMarkedRanges) 598*0deba7fbSSteve Yin { 599*0deba7fbSSteve Yin mpMarkedRanges = new ScRangeList(); 600*0deba7fbSSteve Yin } 601*0deba7fbSSteve Yin refScMarkData.FillRangeListWithMarks(mpMarkedRanges, sal_True); 602*0deba7fbSSteve Yin 603*0deba7fbSSteve Yin //For Whole Col Row 604*0deba7fbSSteve Yin sal_Bool bWholeRow = ::labs(aMarkRange.aStart.Row() - aMarkRange.aEnd.Row()) == MAXROW ; 605*0deba7fbSSteve Yin sal_Bool bWholeCol = ::abs(aMarkRange.aStart.Col() - aMarkRange.aEnd.Col()) == MAXCOL ; 606*0deba7fbSSteve Yin if ((bNewMarked || bIsMark || bIsMultMark ) && (bWholeCol || bWholeRow)) 607*0deba7fbSSteve Yin { 608*0deba7fbSSteve Yin if ( aMarkRange != m_aLastWithInMarkRange ) 609*0deba7fbSSteve Yin { 610*0deba7fbSSteve Yin RemoveSelection(refScMarkData); 611*0deba7fbSSteve Yin if(bNewPosCell) 612*0deba7fbSSteve Yin { 613*0deba7fbSSteve Yin CommitFocusCell(aNewCell); 614*0deba7fbSSteve Yin } 615*0deba7fbSSteve Yin sal_Bool bLastIsWholeColRow = 616*0deba7fbSSteve Yin ::labs(m_aLastWithInMarkRange.aStart.Row() - m_aLastWithInMarkRange.aEnd.Row()) == MAXROW && bWholeRow || 617*0deba7fbSSteve Yin ::abs(m_aLastWithInMarkRange.aStart.Col() - m_aLastWithInMarkRange.aEnd.Col()) == MAXCOL && bWholeCol ; 618*0deba7fbSSteve Yin sal_Bool bSelSmaller= 619*0deba7fbSSteve Yin bLastIsWholeColRow && 620*0deba7fbSSteve Yin !aMarkRange.In(m_aLastWithInMarkRange) && 621*0deba7fbSSteve Yin aMarkRange.Intersects(m_aLastWithInMarkRange); 622*0deba7fbSSteve Yin if( !bSelSmaller ) 623*0deba7fbSSteve Yin { 624*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; 625*0deba7fbSSteve Yin aEvent.NewValue <<= ::com::sun::star::uno::Any(); 626*0deba7fbSSteve Yin CommitChange(aEvent); 627*0deba7fbSSteve Yin } 628*0deba7fbSSteve Yin m_aLastWithInMarkRange = aMarkRange; 629*0deba7fbSSteve Yin } 630*0deba7fbSSteve Yin return ; 631cdf0e10cSrcweir } 632*0deba7fbSSteve Yin m_aLastWithInMarkRange = aMarkRange; 633*0deba7fbSSteve Yin int nNewMarkCount = mpMarkedRanges->GetCellCount(); 634*0deba7fbSSteve Yin sal_Bool bSendSingle= (0 == nNewMarkCount) && bNewPosCell; 635*0deba7fbSSteve Yin if (bSendSingle) 636*0deba7fbSSteve Yin { 637*0deba7fbSSteve Yin RemoveSelection(refScMarkData); 638*0deba7fbSSteve Yin if(bNewPosCellFocus) 639*0deba7fbSSteve Yin { 640*0deba7fbSSteve Yin CommitFocusCell(aNewCell); 641*0deba7fbSSteve Yin } 642*0deba7fbSSteve Yin uno::Reference< XAccessible > xChild ; 643*0deba7fbSSteve Yin if (bNewPosCellFocus) 644*0deba7fbSSteve Yin { 645*0deba7fbSSteve Yin xChild = mpAccCell; 646*0deba7fbSSteve Yin } 647*0deba7fbSSteve Yin else 648*0deba7fbSSteve Yin { 649*0deba7fbSSteve Yin xChild = getAccessibleCellAt(aNewCell.Row(),aNewCell.Col()); 650*0deba7fbSSteve Yin 651*0deba7fbSSteve Yin maActiveCell = aNewCell; 652*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS; 653*0deba7fbSSteve Yin aEvent.NewValue <<= xChild; 654*0deba7fbSSteve Yin aEvent.OldValue <<= uno::Reference< XAccessible >(); 655*0deba7fbSSteve Yin CommitChange(aEvent); 656*0deba7fbSSteve Yin } 657*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; 658*0deba7fbSSteve Yin aEvent.NewValue <<= xChild; 659cdf0e10cSrcweir CommitChange(aEvent); 660*0deba7fbSSteve Yin OSL_ASSERT(m_mapSelectionSend.count(aNewCell) == 0 ); 661*0deba7fbSSteve Yin m_mapSelectionSend.insert(MAP_ADDR_XACC::value_type(aNewCell,xChild)); 662*0deba7fbSSteve Yin 663*0deba7fbSSteve Yin } 664*0deba7fbSSteve Yin else 665*0deba7fbSSteve Yin { 666*0deba7fbSSteve Yin ScRange aDelRange; 667*0deba7fbSSteve Yin sal_Bool bIsDel = pViewData->GetDelMark( aDelRange ); 668*0deba7fbSSteve Yin if ( (!bIsDel || (bIsDel && aMarkRange != aDelRange)) && 669*0deba7fbSSteve Yin bNewMarked && 670*0deba7fbSSteve Yin nNewMarkCount > 0 && 671*0deba7fbSSteve Yin !IsSameMarkCell() ) 672*0deba7fbSSteve Yin { 673*0deba7fbSSteve Yin RemoveSelection(refScMarkData); 674*0deba7fbSSteve Yin if(bNewPosCellFocus) 675*0deba7fbSSteve Yin { 676*0deba7fbSSteve Yin CommitFocusCell(aNewCell); 677*0deba7fbSSteve Yin } 678*0deba7fbSSteve Yin VEC_MYADDR vecNew; 679*0deba7fbSSteve Yin if(CalcScRangeListDifferenceMax(mpMarkedRanges,&m_LastMarkedRanges,10,vecNew)) 680*0deba7fbSSteve Yin { 681*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; 682*0deba7fbSSteve Yin aEvent.NewValue <<= ::com::sun::star::uno::Any(); 683*0deba7fbSSteve Yin CommitChange(aEvent); 684*0deba7fbSSteve Yin } 685*0deba7fbSSteve Yin else 686*0deba7fbSSteve Yin { 687*0deba7fbSSteve Yin VEC_MYADDR::iterator viAddr = vecNew.begin(); 688*0deba7fbSSteve Yin for(; viAddr < vecNew.end() ; ++viAddr ) 689*0deba7fbSSteve Yin { 690*0deba7fbSSteve Yin uno::Reference< XAccessible > xChild = getAccessibleCellAt(viAddr->Row(),viAddr->Col()); 691*0deba7fbSSteve Yin if (!(bNewPosCellFocus && *viAddr == aNewCell) ) 692*0deba7fbSSteve Yin { 693*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS; 694*0deba7fbSSteve Yin aEvent.NewValue <<= xChild; 695*0deba7fbSSteve Yin CommitChange(aEvent); 696*0deba7fbSSteve Yin } 697*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD; 698*0deba7fbSSteve Yin aEvent.NewValue <<= xChild; 699*0deba7fbSSteve Yin CommitChange(aEvent); 700*0deba7fbSSteve Yin m_mapSelectionSend.insert(MAP_ADDR_XACC::value_type(*viAddr,xChild)); 701*0deba7fbSSteve Yin } 702*0deba7fbSSteve Yin } 703*0deba7fbSSteve Yin } 704*0deba7fbSSteve Yin } 705*0deba7fbSSteve Yin if (bNewPosCellFocus && maActiveCell != aNewCell) 706*0deba7fbSSteve Yin { 707*0deba7fbSSteve Yin CommitFocusCell(aNewCell); 708*0deba7fbSSteve Yin } 709*0deba7fbSSteve Yin m_LastMarkedRanges = *mpMarkedRanges; 710cdf0e10cSrcweir } 711cdf0e10cSrcweir } 712cdf0e10cSrcweir else if ((rRef.GetId() == SC_HINT_DATACHANGED)) 713cdf0e10cSrcweir { 714cdf0e10cSrcweir if (!mbDelIns) 715cdf0e10cSrcweir CommitTableModelChange(maRange.aStart.Row(), maRange.aStart.Col(), maRange.aEnd.Row(), maRange.aEnd.Col(), AccessibleTableModelChangeType::UPDATE); 716cdf0e10cSrcweir else 717cdf0e10cSrcweir mbDelIns = sal_False; 718*0deba7fbSSteve Yin ScViewData *pViewData = mpViewShell->GetViewData(); 719*0deba7fbSSteve Yin ScAddress aNewCell = pViewData->GetCurPos(); 720*0deba7fbSSteve Yin if( maActiveCell == aNewCell) 721*0deba7fbSSteve Yin { 722*0deba7fbSSteve Yin ScDocument* pScDoc= GetDocument(mpViewShell); 723*0deba7fbSSteve Yin if (pScDoc) 724*0deba7fbSSteve Yin { 725*0deba7fbSSteve Yin String valStr; 726*0deba7fbSSteve Yin pScDoc->GetString(aNewCell.Col(),aNewCell.Row(),aNewCell.Tab(), valStr); 727*0deba7fbSSteve Yin if(m_strCurCellValue != valStr) 728*0deba7fbSSteve Yin { 729*0deba7fbSSteve Yin AccessibleEventObject aEvent; 730*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::VALUE_CHANGED; 731*0deba7fbSSteve Yin mpAccCell->CommitChange(aEvent); 732*0deba7fbSSteve Yin m_strCurCellValue=valStr; 733*0deba7fbSSteve Yin } 734*0deba7fbSSteve Yin String tabName; 735*0deba7fbSSteve Yin pScDoc->GetName( maActiveCell.Tab(), tabName ); 736*0deba7fbSSteve Yin if( m_strOldTabName != tabName ) 737*0deba7fbSSteve Yin { 738*0deba7fbSSteve Yin AccessibleEventObject aEvent; 739*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::NAME_CHANGED; 740*0deba7fbSSteve Yin String sOldName(ScResId(STR_ACC_TABLE_NAME)); 741*0deba7fbSSteve Yin sOldName.SearchAndReplaceAscii("%1", m_strOldTabName); 742*0deba7fbSSteve Yin aEvent.OldValue <<= ::rtl::OUString( sOldName ); 743*0deba7fbSSteve Yin String sNewName(ScResId(STR_ACC_TABLE_NAME)); 744*0deba7fbSSteve Yin sNewName.SearchAndReplaceAscii("%1", tabName); 745*0deba7fbSSteve Yin aEvent.NewValue <<= ::rtl::OUString( sNewName ); 746*0deba7fbSSteve Yin CommitChange( aEvent ); 747*0deba7fbSSteve Yin m_strOldTabName = tabName; 748*0deba7fbSSteve Yin } 749*0deba7fbSSteve Yin } 750*0deba7fbSSteve Yin } 751*0deba7fbSSteve Yin } 752*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 753cdf0e10cSrcweir // no longer needed, because the document calls the VisAreaChanged method 754cdf0e10cSrcweir /* else if (rRef.GetId() == SC_HINT_ACC_VISAREACHANGED) 755cdf0e10cSrcweir { 756cdf0e10cSrcweir AccessibleEventObject aEvent; 757cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED; 758cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 759cdf0e10cSrcweir 760cdf0e10cSrcweir CommitChange(aEvent);*/ 761cdf0e10cSrcweir // commented out, because to use a ModelChangeEvent is not the right way 762cdf0e10cSrcweir // at the moment there is no way, but the Java/Gnome Api should be extended sometime 763cdf0e10cSrcweir /* if (mpViewShell) 764cdf0e10cSrcweir { 765cdf0e10cSrcweir Rectangle aNewVisCells(GetVisCells(GetVisArea(mpViewShell, meSplitPos))); 766cdf0e10cSrcweir 767cdf0e10cSrcweir Rectangle aNewPos(aNewVisCells); 768cdf0e10cSrcweir 769cdf0e10cSrcweir if (aNewVisCells.IsOver(maVisCells)) 770cdf0e10cSrcweir aNewPos.Union(maVisCells); 771cdf0e10cSrcweir else 772cdf0e10cSrcweir CommitTableModelChange(maVisCells.Top(), maVisCells.Left(), maVisCells.Bottom(), maVisCells.Right(), AccessibleTableModelChangeType::UPDATE); 773cdf0e10cSrcweir 774cdf0e10cSrcweir maVisCells = aNewVisCells; 775cdf0e10cSrcweir 776cdf0e10cSrcweir CommitTableModelChange(aNewPos.Top(), aNewPos.Left(), aNewPos.Bottom(), aNewPos.Right(), AccessibleTableModelChangeType::UPDATE); 777cdf0e10cSrcweir } 778cdf0e10cSrcweir }*/ 779cdf0e10cSrcweir // no longer needed, because the document calls the BoundingBoxChanged method 780cdf0e10cSrcweir /* else if (rRef.GetId() == SC_HINT_ACC_WINDOWRESIZED) 781cdf0e10cSrcweir { 782cdf0e10cSrcweir AccessibleEventObject aEvent; 783cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED; 784cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 785cdf0e10cSrcweir 786cdf0e10cSrcweir CommitChange(aEvent); 787cdf0e10cSrcweir }*/ 788cdf0e10cSrcweir } 789cdf0e10cSrcweir else if (rHint.ISA( ScUpdateRefHint )) 790cdf0e10cSrcweir { 791cdf0e10cSrcweir const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint; 792cdf0e10cSrcweir if (rRef.GetMode() == URM_INSDEL && rRef.GetDz() == 0) //#107250# test whether table is inserted or deleted 793cdf0e10cSrcweir { 794cdf0e10cSrcweir if (((rRef.GetRange().aStart.Col() == maRange.aStart.Col()) && 795cdf0e10cSrcweir (rRef.GetRange().aEnd.Col() == maRange.aEnd.Col())) || 796cdf0e10cSrcweir ((rRef.GetRange().aStart.Row() == maRange.aStart.Row()) && 797cdf0e10cSrcweir (rRef.GetRange().aEnd.Row() == maRange.aEnd.Row()))) 798cdf0e10cSrcweir { 799cdf0e10cSrcweir // ignore next SC_HINT_DATACHANGED notification 800cdf0e10cSrcweir mbDelIns = sal_True; 801cdf0e10cSrcweir 802cdf0e10cSrcweir sal_Int16 nId(0); 803cdf0e10cSrcweir SCsCOL nX(rRef.GetDx()); 804cdf0e10cSrcweir SCsROW nY(rRef.GetDy()); 805cdf0e10cSrcweir ScRange aRange(rRef.GetRange()); 806cdf0e10cSrcweir if ((nX < 0) || (nY < 0)) 807cdf0e10cSrcweir { 808cdf0e10cSrcweir DBG_ASSERT(!((nX < 0) && (nY < 0)), "should not be possible to remove row and column at the same time"); 809cdf0e10cSrcweir nId = AccessibleTableModelChangeType::DELETE; 810cdf0e10cSrcweir if (nX < 0) 811cdf0e10cSrcweir { 812cdf0e10cSrcweir nX = -nX; 813cdf0e10cSrcweir nY = aRange.aEnd.Row() - aRange.aStart.Row(); 814cdf0e10cSrcweir } 815cdf0e10cSrcweir else 816cdf0e10cSrcweir { 817cdf0e10cSrcweir nY = -nY; 818cdf0e10cSrcweir nX = aRange.aEnd.Col() - aRange.aStart.Col(); 819cdf0e10cSrcweir } 820cdf0e10cSrcweir } 821cdf0e10cSrcweir else if ((nX > 0) || (nY > 0)) 822cdf0e10cSrcweir { 823cdf0e10cSrcweir DBG_ASSERT(!((nX > 0) && (nY > 0)), "should not be possible to add row and column at the same time"); 824cdf0e10cSrcweir nId = AccessibleTableModelChangeType::INSERT; 825cdf0e10cSrcweir if (nX < 0) 826cdf0e10cSrcweir nY = aRange.aEnd.Row() - aRange.aStart.Row(); 827cdf0e10cSrcweir else 828cdf0e10cSrcweir nX = aRange.aEnd.Col() - aRange.aStart.Col(); 829cdf0e10cSrcweir } 830cdf0e10cSrcweir else 831cdf0e10cSrcweir { 832cdf0e10cSrcweir DBG_ERROR("is it a deletion or a insertion?"); 833cdf0e10cSrcweir } 834cdf0e10cSrcweir 835cdf0e10cSrcweir CommitTableModelChange(rRef.GetRange().aStart.Row(), 836cdf0e10cSrcweir rRef.GetRange().aStart.Col(), 837cdf0e10cSrcweir rRef.GetRange().aStart.Row() + nY, 838cdf0e10cSrcweir rRef.GetRange().aStart.Col() + nX, nId); 839cdf0e10cSrcweir 840cdf0e10cSrcweir AccessibleEventObject aEvent; 841cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; 842cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 843cdf0e10cSrcweir uno::Reference< XAccessible > xNew = mpAccCell; 844cdf0e10cSrcweir aEvent.NewValue <<= xNew; 845cdf0e10cSrcweir 846cdf0e10cSrcweir CommitChange(aEvent); 847cdf0e10cSrcweir } 848cdf0e10cSrcweir } 849cdf0e10cSrcweir } 850cdf0e10cSrcweir 851cdf0e10cSrcweir ScAccessibleTableBase::Notify(rBC, rHint); 852cdf0e10cSrcweir } 853*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 854*0deba7fbSSteve Yin void ScAccessibleSpreadsheet::RemoveSelection(ScMarkData &refScMarkData) 855*0deba7fbSSteve Yin { 856*0deba7fbSSteve Yin AccessibleEventObject aEvent; 857*0deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(this); 858*0deba7fbSSteve Yin aEvent.OldValue <<= ::com::sun::star::uno::Any(); 859*0deba7fbSSteve Yin MAP_ADDR_XACC::iterator miRemove = m_mapSelectionSend.begin(); 860*0deba7fbSSteve Yin for(; miRemove != m_mapSelectionSend.end() ;) 861*0deba7fbSSteve Yin { 862*0deba7fbSSteve Yin if (refScMarkData.IsCellMarked(miRemove->first.Col(),miRemove->first.Row(),sal_True) || 863*0deba7fbSSteve Yin refScMarkData.IsCellMarked(miRemove->first.Col(),miRemove->first.Row(),sal_False) ) 864*0deba7fbSSteve Yin { 865*0deba7fbSSteve Yin ++miRemove; 866*0deba7fbSSteve Yin continue; 867*0deba7fbSSteve Yin } 868*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE; 869*0deba7fbSSteve Yin aEvent.NewValue <<= miRemove->second; 870*0deba7fbSSteve Yin CommitChange(aEvent); 871*0deba7fbSSteve Yin MAP_ADDR_XACC::iterator miNext = miRemove; 872*0deba7fbSSteve Yin ++miNext; 873*0deba7fbSSteve Yin m_mapSelectionSend.erase(miRemove); 874*0deba7fbSSteve Yin miRemove = miNext; 875*0deba7fbSSteve Yin } 876*0deba7fbSSteve Yin } 877*0deba7fbSSteve Yin void ScAccessibleSpreadsheet::CommitFocusCell(const ScAddress &aNewCell) 878*0deba7fbSSteve Yin { 879*0deba7fbSSteve Yin OSL_ASSERT(!IsFormulaMode()); 880*0deba7fbSSteve Yin if(IsFormulaMode()) 881*0deba7fbSSteve Yin { 882*0deba7fbSSteve Yin return ; 883*0deba7fbSSteve Yin } 884*0deba7fbSSteve Yin AccessibleEventObject aEvent; 885*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; 886*0deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(this); 887*0deba7fbSSteve Yin uno::Reference< XAccessible > xOld = mpAccCell; 888*0deba7fbSSteve Yin mpAccCell->release(); 889*0deba7fbSSteve Yin mpAccCell=NULL; 890*0deba7fbSSteve Yin aEvent.OldValue <<= xOld; 891*0deba7fbSSteve Yin mpAccCell = GetAccessibleCellAt(aNewCell.Row(), aNewCell.Col()); 892*0deba7fbSSteve Yin mpAccCell->acquire(); 893*0deba7fbSSteve Yin mpAccCell->Init(); 894*0deba7fbSSteve Yin uno::Reference< XAccessible > xNew = mpAccCell; 895*0deba7fbSSteve Yin aEvent.NewValue <<= xNew; 896*0deba7fbSSteve Yin maActiveCell = aNewCell; 897*0deba7fbSSteve Yin ScDocument* pScDoc= GetDocument(mpViewShell); 898*0deba7fbSSteve Yin if (pScDoc) 899*0deba7fbSSteve Yin { 900*0deba7fbSSteve Yin pScDoc->GetString(maActiveCell.Col(),maActiveCell.Row(),maActiveCell.Tab(), m_strCurCellValue); 901*0deba7fbSSteve Yin } 902*0deba7fbSSteve Yin CommitChange(aEvent); 903*0deba7fbSSteve Yin } 904*0deba7fbSSteve Yin sal_Bool ScAccessibleSpreadsheet::IsSameMarkCell() 905*0deba7fbSSteve Yin { 906*0deba7fbSSteve Yin return m_LastMarkedRanges == *mpMarkedRanges; 907*0deba7fbSSteve Yin } 908*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 909cdf0e10cSrcweir //===== XAccessibleTable ================================================ 910cdf0e10cSrcweir 911cdf0e10cSrcweir uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleSpreadsheet::getAccessibleRowHeaders( ) 912cdf0e10cSrcweir throw (uno::RuntimeException) 913cdf0e10cSrcweir { 914cdf0e10cSrcweir ScUnoGuard aGuard; 915cdf0e10cSrcweir IsObjectValid(); 916cdf0e10cSrcweir uno::Reference< XAccessibleTable > xAccessibleTable; 917cdf0e10cSrcweir if( mpDoc && mbIsSpreadsheet ) 918cdf0e10cSrcweir { 919cdf0e10cSrcweir if( const ScRange* pRowRange = mpDoc->GetRepeatRowRange( mnTab ) ) 920cdf0e10cSrcweir { 921cdf0e10cSrcweir SCROW nStart = pRowRange->aStart.Row(); 922cdf0e10cSrcweir SCROW nEnd = pRowRange->aEnd.Row(); 923cdf0e10cSrcweir if( (0 <= nStart) && (nStart <= nEnd) && (nEnd <= MAXROW) ) 924cdf0e10cSrcweir xAccessibleTable.set( new ScAccessibleSpreadsheet( *this, ScRange( 0, nStart, mnTab, MAXCOL, nEnd, mnTab ) ) ); 925cdf0e10cSrcweir } 926cdf0e10cSrcweir } 927cdf0e10cSrcweir return xAccessibleTable; 928cdf0e10cSrcweir } 929cdf0e10cSrcweir 930cdf0e10cSrcweir uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleSpreadsheet::getAccessibleColumnHeaders( ) 931cdf0e10cSrcweir throw (uno::RuntimeException) 932cdf0e10cSrcweir { 933cdf0e10cSrcweir ScUnoGuard aGuard; 934cdf0e10cSrcweir IsObjectValid(); 935cdf0e10cSrcweir uno::Reference< XAccessibleTable > xAccessibleTable; 936cdf0e10cSrcweir if( mpDoc && mbIsSpreadsheet ) 937cdf0e10cSrcweir { 938cdf0e10cSrcweir if( const ScRange* pColRange = mpDoc->GetRepeatColRange( mnTab ) ) 939cdf0e10cSrcweir { 940cdf0e10cSrcweir SCCOL nStart = pColRange->aStart.Col(); 941cdf0e10cSrcweir SCCOL nEnd = pColRange->aEnd.Col(); 942cdf0e10cSrcweir if( (0 <= nStart) && (nStart <= nEnd) && (nEnd <= MAXCOL) ) 943cdf0e10cSrcweir xAccessibleTable.set( new ScAccessibleSpreadsheet( *this, ScRange( nStart, 0, mnTab, nEnd, MAXROW, mnTab ) ) ); 944cdf0e10cSrcweir } 945cdf0e10cSrcweir } 946cdf0e10cSrcweir return xAccessibleTable; 947cdf0e10cSrcweir } 948cdf0e10cSrcweir 949cdf0e10cSrcweir uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleSpreadsheet::getSelectedAccessibleRows( ) 950cdf0e10cSrcweir throw (uno::RuntimeException) 951cdf0e10cSrcweir { 952cdf0e10cSrcweir ScUnoGuard aGuard; 953cdf0e10cSrcweir IsObjectValid(); 954cdf0e10cSrcweir uno::Sequence<sal_Int32> aSequence; 955*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 956*0deba7fbSSteve Yin if (IsFormulaMode()) 957*0deba7fbSSteve Yin { 958*0deba7fbSSteve Yin return aSequence; 959*0deba7fbSSteve Yin } 960*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 961cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData()) 962cdf0e10cSrcweir { 963cdf0e10cSrcweir aSequence.realloc(maRange.aEnd.Row() - maRange.aStart.Row() + 1); 964cdf0e10cSrcweir const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData(); 965cdf0e10cSrcweir sal_Int32* pSequence = aSequence.getArray(); 966cdf0e10cSrcweir sal_Int32 nCount(0); 967cdf0e10cSrcweir for (SCROW i = maRange.aStart.Row(); i <= maRange.aEnd.Row(); ++i) 968cdf0e10cSrcweir { 969cdf0e10cSrcweir if (rMarkdata.IsRowMarked(i)) 970cdf0e10cSrcweir { 971cdf0e10cSrcweir pSequence[nCount] = i; 972cdf0e10cSrcweir ++nCount; 973cdf0e10cSrcweir } 974cdf0e10cSrcweir } 975cdf0e10cSrcweir aSequence.realloc(nCount); 976cdf0e10cSrcweir } 977cdf0e10cSrcweir else 978cdf0e10cSrcweir aSequence.realloc(0); 979cdf0e10cSrcweir return aSequence; 980cdf0e10cSrcweir } 981cdf0e10cSrcweir 982cdf0e10cSrcweir uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleSpreadsheet::getSelectedAccessibleColumns( ) 983cdf0e10cSrcweir throw (uno::RuntimeException) 984cdf0e10cSrcweir { 985cdf0e10cSrcweir ScUnoGuard aGuard; 986cdf0e10cSrcweir IsObjectValid(); 987cdf0e10cSrcweir uno::Sequence<sal_Int32> aSequence; 988*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 989*0deba7fbSSteve Yin if (IsFormulaMode()) 990*0deba7fbSSteve Yin { 991*0deba7fbSSteve Yin return aSequence; 992*0deba7fbSSteve Yin } 993*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 994cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData()) 995cdf0e10cSrcweir { 996cdf0e10cSrcweir aSequence.realloc(maRange.aEnd.Col() - maRange.aStart.Col() + 1); 997cdf0e10cSrcweir const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData(); 998cdf0e10cSrcweir sal_Int32* pSequence = aSequence.getArray(); 999cdf0e10cSrcweir sal_Int32 nCount(0); 1000cdf0e10cSrcweir for (SCCOL i = maRange.aStart.Col(); i <= maRange.aEnd.Col(); ++i) 1001cdf0e10cSrcweir { 1002cdf0e10cSrcweir if (rMarkdata.IsColumnMarked(i)) 1003cdf0e10cSrcweir { 1004cdf0e10cSrcweir pSequence[nCount] = i; 1005cdf0e10cSrcweir ++nCount; 1006cdf0e10cSrcweir } 1007cdf0e10cSrcweir } 1008cdf0e10cSrcweir aSequence.realloc(nCount); 1009cdf0e10cSrcweir } 1010cdf0e10cSrcweir else 1011cdf0e10cSrcweir aSequence.realloc(0); 1012cdf0e10cSrcweir return aSequence; 1013cdf0e10cSrcweir } 1014cdf0e10cSrcweir 1015cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleRowSelected( sal_Int32 nRow ) 1016cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException) 1017cdf0e10cSrcweir { 1018cdf0e10cSrcweir ScUnoGuard aGuard; 1019cdf0e10cSrcweir IsObjectValid(); 1020*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1021*0deba7fbSSteve Yin if (IsFormulaMode()) 1022*0deba7fbSSteve Yin { 1023*0deba7fbSSteve Yin return sal_False; 1024*0deba7fbSSteve Yin } 1025*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1026cdf0e10cSrcweir 1027cdf0e10cSrcweir if ((nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0)) 1028cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1029cdf0e10cSrcweir 1030cdf0e10cSrcweir sal_Bool bResult(sal_False); 1031cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData()) 1032cdf0e10cSrcweir { 1033cdf0e10cSrcweir const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData(); 1034cdf0e10cSrcweir bResult = rMarkdata.IsRowMarked((SCROW)nRow); 1035cdf0e10cSrcweir } 1036cdf0e10cSrcweir return bResult; 1037cdf0e10cSrcweir } 1038cdf0e10cSrcweir 1039cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleColumnSelected( sal_Int32 nColumn ) 1040cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException) 1041cdf0e10cSrcweir { 1042cdf0e10cSrcweir ScUnoGuard aGuard; 1043cdf0e10cSrcweir IsObjectValid(); 1044cdf0e10cSrcweir 1045*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1046*0deba7fbSSteve Yin if (IsFormulaMode()) 1047*0deba7fbSSteve Yin { 1048*0deba7fbSSteve Yin return sal_False; 1049*0deba7fbSSteve Yin } 1050*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1051cdf0e10cSrcweir if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0)) 1052cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1053cdf0e10cSrcweir 1054cdf0e10cSrcweir sal_Bool bResult(sal_False); 1055cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData()) 1056cdf0e10cSrcweir { 1057cdf0e10cSrcweir const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData(); 1058cdf0e10cSrcweir bResult = rMarkdata.IsColumnMarked((SCCOL)nColumn); 1059cdf0e10cSrcweir } 1060cdf0e10cSrcweir return bResult; 1061cdf0e10cSrcweir } 1062cdf0e10cSrcweir 1063cdf0e10cSrcweir ScAccessibleCell* ScAccessibleSpreadsheet::GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn) 1064cdf0e10cSrcweir { 1065cdf0e10cSrcweir ScAccessibleCell* pAccessibleCell = NULL; 1066*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1067*0deba7fbSSteve Yin if (IsFormulaMode()) 1068*0deba7fbSSteve Yin { 1069*0deba7fbSSteve Yin ScAddress aCellAddress(static_cast<SCCOL>(nColumn), nRow, mpViewShell->GetViewData()->GetTabNo()); 1070*0deba7fbSSteve Yin if ((aCellAddress == m_aFormulaActiveCell) && m_pAccFormulaCell) 1071*0deba7fbSSteve Yin { 1072*0deba7fbSSteve Yin pAccessibleCell = m_pAccFormulaCell; 1073*0deba7fbSSteve Yin } 1074*0deba7fbSSteve Yin else 1075*0deba7fbSSteve Yin pAccessibleCell = new ScAccessibleCell(this, mpViewShell, aCellAddress, GetAccessibleIndexFormula(nRow, nColumn), meSplitPos, mpAccDoc); 1076*0deba7fbSSteve Yin } 1077*0deba7fbSSteve Yin else 1078*0deba7fbSSteve Yin { 1079*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1080cdf0e10cSrcweir ScAddress aCellAddress(static_cast<SCCOL>(maRange.aStart.Col() + nColumn), 1081cdf0e10cSrcweir static_cast<SCROW>(maRange.aStart.Row() + nRow), maRange.aStart.Tab()); 1082cdf0e10cSrcweir if ((aCellAddress == maActiveCell) && mpAccCell) 1083cdf0e10cSrcweir { 1084cdf0e10cSrcweir pAccessibleCell = mpAccCell; 1085cdf0e10cSrcweir } 1086cdf0e10cSrcweir else 1087cdf0e10cSrcweir pAccessibleCell = new ScAccessibleCell(this, mpViewShell, aCellAddress, getAccessibleIndex(nRow, nColumn), meSplitPos, mpAccDoc); 1088*0deba7fbSSteve Yin } 1089cdf0e10cSrcweir 1090cdf0e10cSrcweir return pAccessibleCell; 1091cdf0e10cSrcweir } 1092cdf0e10cSrcweir 1093cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) 1094cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException) 1095cdf0e10cSrcweir { 1096cdf0e10cSrcweir ScUnoGuard aGuard; 1097cdf0e10cSrcweir IsObjectValid(); 1098*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1099*0deba7fbSSteve Yin if (!IsFormulaMode()) 1100*0deba7fbSSteve Yin { 1101cdf0e10cSrcweir if (nRow > (maRange.aEnd.Row() - maRange.aStart.Row()) || 1102cdf0e10cSrcweir nRow < 0 || 1103cdf0e10cSrcweir nColumn > (maRange.aEnd.Col() - maRange.aStart.Col()) || 1104cdf0e10cSrcweir nColumn < 0) 1105cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1106*0deba7fbSSteve Yin } 1107*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1108cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible; 1109cdf0e10cSrcweir ScAccessibleCell* pAccessibleCell = GetAccessibleCellAt(nRow, nColumn); 1110cdf0e10cSrcweir xAccessible = pAccessibleCell; 1111cdf0e10cSrcweir pAccessibleCell->Init(); 1112cdf0e10cSrcweir return xAccessible; 1113cdf0e10cSrcweir } 1114cdf0e10cSrcweir 1115cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) 1116cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException) 1117cdf0e10cSrcweir { 1118cdf0e10cSrcweir ScUnoGuard aGuard; 1119cdf0e10cSrcweir IsObjectValid(); 1120cdf0e10cSrcweir 1121*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1122*0deba7fbSSteve Yin if (IsFormulaMode()) 1123*0deba7fbSSteve Yin { 1124*0deba7fbSSteve Yin ScAddress addr(static_cast<SCCOL>(nColumn), nRow, 0); 1125*0deba7fbSSteve Yin return IsScAddrFormulaSel(addr); 1126*0deba7fbSSteve Yin } 1127*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1128cdf0e10cSrcweir if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0) || 1129cdf0e10cSrcweir (nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0)) 1130cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1131cdf0e10cSrcweir 1132cdf0e10cSrcweir sal_Bool bResult(sal_False); 1133cdf0e10cSrcweir if (mpViewShell) 1134cdf0e10cSrcweir { 1135cdf0e10cSrcweir const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData(); 1136cdf0e10cSrcweir bResult = rMarkdata.IsCellMarked(static_cast<SCCOL>(nColumn), static_cast<SCROW>(nRow)); 1137cdf0e10cSrcweir } 1138cdf0e10cSrcweir return bResult; 1139cdf0e10cSrcweir } 1140cdf0e10cSrcweir 1141cdf0e10cSrcweir //===== XAccessibleComponent ============================================ 1142cdf0e10cSrcweir 1143cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleAtPoint( 1144cdf0e10cSrcweir const awt::Point& rPoint ) 1145cdf0e10cSrcweir throw (uno::RuntimeException) 1146cdf0e10cSrcweir { 1147cdf0e10cSrcweir uno::Reference< XAccessible > xAccessible; 1148cdf0e10cSrcweir if (containsPoint(rPoint)) 1149cdf0e10cSrcweir { 1150cdf0e10cSrcweir ScUnoGuard aGuard; 1151cdf0e10cSrcweir IsObjectValid(); 1152cdf0e10cSrcweir if (mpViewShell) 1153cdf0e10cSrcweir { 1154cdf0e10cSrcweir SCsCOL nX; 1155cdf0e10cSrcweir SCsROW nY; 1156cdf0e10cSrcweir mpViewShell->GetViewData()->GetPosFromPixel( rPoint.X, rPoint.Y, meSplitPos, nX, nY); 1157*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1158*0deba7fbSSteve Yin try{ 1159cdf0e10cSrcweir xAccessible = getAccessibleCellAt(nY, nX); 1160*0deba7fbSSteve Yin } 1161*0deba7fbSSteve Yin catch( ::com::sun::star::lang::IndexOutOfBoundsException e) 1162*0deba7fbSSteve Yin { 1163*0deba7fbSSteve Yin return NULL; 1164*0deba7fbSSteve Yin } 1165*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1166cdf0e10cSrcweir } 1167cdf0e10cSrcweir } 1168cdf0e10cSrcweir return xAccessible; 1169cdf0e10cSrcweir } 1170cdf0e10cSrcweir 1171cdf0e10cSrcweir void SAL_CALL ScAccessibleSpreadsheet::grabFocus( ) 1172cdf0e10cSrcweir throw (uno::RuntimeException) 1173cdf0e10cSrcweir { 1174cdf0e10cSrcweir if (getAccessibleParent().is()) 1175cdf0e10cSrcweir { 1176cdf0e10cSrcweir uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY); 1177cdf0e10cSrcweir if (xAccessibleComponent.is()) 1178cdf0e10cSrcweir xAccessibleComponent->grabFocus(); 1179cdf0e10cSrcweir } 1180cdf0e10cSrcweir } 1181cdf0e10cSrcweir 1182cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleSpreadsheet::getForeground( ) 1183cdf0e10cSrcweir throw (uno::RuntimeException) 1184cdf0e10cSrcweir { 1185cdf0e10cSrcweir return COL_BLACK; 1186cdf0e10cSrcweir } 1187cdf0e10cSrcweir 1188cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleSpreadsheet::getBackground( ) 1189cdf0e10cSrcweir throw (uno::RuntimeException) 1190cdf0e10cSrcweir { 1191cdf0e10cSrcweir ScUnoGuard aGuard; 1192cdf0e10cSrcweir IsObjectValid(); 1193cdf0e10cSrcweir return SC_MOD()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor; 1194cdf0e10cSrcweir } 1195cdf0e10cSrcweir 1196cdf0e10cSrcweir //===== XAccessibleContext ============================================== 1197cdf0e10cSrcweir 1198cdf0e10cSrcweir uno::Reference<XAccessibleRelationSet> SAL_CALL ScAccessibleSpreadsheet::getAccessibleRelationSet(void) 1199cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 1200cdf0e10cSrcweir { 1201cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pRelationSet = NULL; 1202cdf0e10cSrcweir if(mpAccDoc) 1203cdf0e10cSrcweir pRelationSet = mpAccDoc->GetRelationSet(NULL); 1204cdf0e10cSrcweir if (!pRelationSet) 1205cdf0e10cSrcweir pRelationSet = new utl::AccessibleRelationSetHelper(); 1206cdf0e10cSrcweir return pRelationSet; 1207cdf0e10cSrcweir } 1208cdf0e10cSrcweir 1209cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL 1210cdf0e10cSrcweir ScAccessibleSpreadsheet::getAccessibleStateSet(void) 1211cdf0e10cSrcweir throw (uno::RuntimeException) 1212cdf0e10cSrcweir { 1213cdf0e10cSrcweir ScUnoGuard aGuard; 1214cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> xParentStates; 1215cdf0e10cSrcweir if (getAccessibleParent().is()) 1216cdf0e10cSrcweir { 1217cdf0e10cSrcweir uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); 1218cdf0e10cSrcweir xParentStates = xParentContext->getAccessibleStateSet(); 1219cdf0e10cSrcweir } 1220cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); 1221cdf0e10cSrcweir if (IsDefunc(xParentStates)) 1222cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::DEFUNC); 1223cdf0e10cSrcweir else 1224cdf0e10cSrcweir { 1225cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::MANAGES_DESCENDANTS); 1226cdf0e10cSrcweir if (IsEditable(xParentStates)) 1227cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::EDITABLE); 1228cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::ENABLED); 1229cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::FOCUSABLE); 1230cdf0e10cSrcweir if (IsFocused()) 1231cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::FOCUSED); 1232cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::MULTI_SELECTABLE); 1233cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::OPAQUE); 1234cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SELECTABLE); 1235cdf0e10cSrcweir if (IsCompleteSheetSelected()) 1236cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SELECTED); 1237cdf0e10cSrcweir if (isShowing()) 1238cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SHOWING); 1239cdf0e10cSrcweir if (isVisible()) 1240cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::VISIBLE); 1241cdf0e10cSrcweir } 1242cdf0e10cSrcweir return pStateSet; 1243cdf0e10cSrcweir } 1244cdf0e10cSrcweir 1245cdf0e10cSrcweir ///===== XAccessibleSelection =========================================== 1246cdf0e10cSrcweir 1247cdf0e10cSrcweir void SAL_CALL 1248cdf0e10cSrcweir ScAccessibleSpreadsheet::selectAccessibleChild( sal_Int32 nChildIndex ) 1249cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1250cdf0e10cSrcweir { 1251cdf0e10cSrcweir ScUnoGuard aGuard; 1252cdf0e10cSrcweir IsObjectValid(); 1253cdf0e10cSrcweir if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount()) 1254cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1255cdf0e10cSrcweir 1256cdf0e10cSrcweir if (mpViewShell) 1257cdf0e10cSrcweir { 1258cdf0e10cSrcweir sal_Int32 nCol(getAccessibleColumn(nChildIndex)); 1259cdf0e10cSrcweir sal_Int32 nRow(getAccessibleRow(nChildIndex)); 1260cdf0e10cSrcweir 1261cdf0e10cSrcweir SelectCell(nRow, nCol, sal_False); 1262cdf0e10cSrcweir } 1263cdf0e10cSrcweir } 1264cdf0e10cSrcweir 1265cdf0e10cSrcweir void SAL_CALL 1266cdf0e10cSrcweir ScAccessibleSpreadsheet::clearAccessibleSelection( ) 1267cdf0e10cSrcweir throw (uno::RuntimeException) 1268cdf0e10cSrcweir { 1269cdf0e10cSrcweir ScUnoGuard aGuard; 1270cdf0e10cSrcweir IsObjectValid(); 1271cdf0e10cSrcweir if (mpViewShell) 1272cdf0e10cSrcweir { 1273*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1274*0deba7fbSSteve Yin if (!IsFormulaMode()) 1275*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1276cdf0e10cSrcweir mpViewShell->Unmark(); 1277cdf0e10cSrcweir } 1278cdf0e10cSrcweir } 1279cdf0e10cSrcweir 1280cdf0e10cSrcweir void SAL_CALL 1281cdf0e10cSrcweir ScAccessibleSpreadsheet::selectAllAccessibleChildren( ) 1282cdf0e10cSrcweir throw (uno::RuntimeException) 1283cdf0e10cSrcweir { 1284cdf0e10cSrcweir ScUnoGuard aGuard; 1285cdf0e10cSrcweir IsObjectValid(); 1286cdf0e10cSrcweir if (mpViewShell) 1287cdf0e10cSrcweir { 1288*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1289*0deba7fbSSteve Yin if (IsFormulaMode()) 1290*0deba7fbSSteve Yin { 1291*0deba7fbSSteve Yin ScViewData *pViewData = mpViewShell->GetViewData(); 1292*0deba7fbSSteve Yin mpViewShell->InitRefMode( 0, 0, pViewData->GetTabNo(), SC_REFTYPE_REF ); 1293*0deba7fbSSteve Yin pViewData->SetRefStart(0,0,pViewData->GetTabNo()); 1294*0deba7fbSSteve Yin pViewData->SetRefStart(MAXCOL,MAXROW,pViewData->GetTabNo()); 1295*0deba7fbSSteve Yin mpViewShell->UpdateRef(MAXCOL, MAXROW, pViewData->GetTabNo()); 1296*0deba7fbSSteve Yin } 1297*0deba7fbSSteve Yin else 1298*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1299cdf0e10cSrcweir mpViewShell->SelectAll(); 1300cdf0e10cSrcweir } 1301cdf0e10cSrcweir } 1302cdf0e10cSrcweir 1303cdf0e10cSrcweir sal_Int32 SAL_CALL 1304cdf0e10cSrcweir ScAccessibleSpreadsheet::getSelectedAccessibleChildCount( ) 1305cdf0e10cSrcweir throw (uno::RuntimeException) 1306cdf0e10cSrcweir { 1307cdf0e10cSrcweir ScUnoGuard aGuard; 1308cdf0e10cSrcweir IsObjectValid(); 1309cdf0e10cSrcweir sal_Int32 nResult(0); 1310cdf0e10cSrcweir if (mpViewShell) 1311cdf0e10cSrcweir { 1312*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1313*0deba7fbSSteve Yin if (IsFormulaMode()) 1314*0deba7fbSSteve Yin { 1315*0deba7fbSSteve Yin nResult = GetRowAll() * GetColAll() ; 1316*0deba7fbSSteve Yin } 1317*0deba7fbSSteve Yin else 1318*0deba7fbSSteve Yin { 1319*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1320cdf0e10cSrcweir if (!mpMarkedRanges) 1321cdf0e10cSrcweir { 1322cdf0e10cSrcweir mpMarkedRanges = new ScRangeList(); 1323cdf0e10cSrcweir ScMarkData aMarkData(mpViewShell->GetViewData()->GetMarkData()); 1324*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1325*0deba7fbSSteve Yin //aMarkData.MarkToMulti(); 1326*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1327cdf0e10cSrcweir aMarkData.FillRangeListWithMarks(mpMarkedRanges, sal_False); 1328cdf0e10cSrcweir } 1329cdf0e10cSrcweir // is possible, because there shouldn't be overlapped ranges in it 1330cdf0e10cSrcweir if (mpMarkedRanges) 1331cdf0e10cSrcweir nResult = mpMarkedRanges->GetCellCount(); 1332*0deba7fbSSteve Yin } 1333cdf0e10cSrcweir } 1334cdf0e10cSrcweir return nResult; 1335cdf0e10cSrcweir } 1336cdf0e10cSrcweir 1337cdf0e10cSrcweir uno::Reference<XAccessible > SAL_CALL 1338cdf0e10cSrcweir ScAccessibleSpreadsheet::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) 1339cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1340cdf0e10cSrcweir { 1341cdf0e10cSrcweir ScUnoGuard aGuard; 1342cdf0e10cSrcweir IsObjectValid(); 1343cdf0e10cSrcweir uno::Reference < XAccessible > xAccessible; 1344*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1345*0deba7fbSSteve Yin if (IsFormulaMode()) 1346*0deba7fbSSteve Yin { 1347*0deba7fbSSteve Yin if(CheckChildIndex(nSelectedChildIndex)) 1348*0deba7fbSSteve Yin { 1349*0deba7fbSSteve Yin ScAddress addr = GetChildIndexAddress(nSelectedChildIndex); 1350*0deba7fbSSteve Yin xAccessible = getAccessibleCellAt(addr.Row(), addr.Col()); 1351*0deba7fbSSteve Yin } 1352*0deba7fbSSteve Yin return xAccessible; 1353*0deba7fbSSteve Yin } 1354*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1355cdf0e10cSrcweir if (mpViewShell) 1356cdf0e10cSrcweir { 1357cdf0e10cSrcweir if (!mpMarkedRanges) 1358cdf0e10cSrcweir { 1359cdf0e10cSrcweir mpMarkedRanges = new ScRangeList(); 1360cdf0e10cSrcweir mpViewShell->GetViewData()->GetMarkData().FillRangeListWithMarks(mpMarkedRanges, sal_False); 1361cdf0e10cSrcweir } 1362cdf0e10cSrcweir if (mpMarkedRanges) 1363cdf0e10cSrcweir { 1364*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1365*0deba7fbSSteve Yin //if (!mpSortedMarkedCells) 1366*0deba7fbSSteve Yin // CreateSortedMarkedCells(); 1367*0deba7fbSSteve Yin //if (mpSortedMarkedCells) 1368*0deba7fbSSteve Yin //{ 1369*0deba7fbSSteve Yin // if ((nSelectedChildIndex < 0) || 1370*0deba7fbSSteve Yin // (mpSortedMarkedCells->size() <= static_cast<sal_uInt32>(nSelectedChildIndex))) 1371*0deba7fbSSteve Yin // throw lang::IndexOutOfBoundsException(); 1372*0deba7fbSSteve Yin // else 1373*0deba7fbSSteve Yin // xAccessible = getAccessibleCellAt((*mpSortedMarkedCells)[nSelectedChildIndex].Row(), (*mpSortedMarkedCells)[nSelectedChildIndex].Col()); 1374*0deba7fbSSteve Yin if ((nSelectedChildIndex < 0) || 1375*0deba7fbSSteve Yin (mpMarkedRanges->GetCellCount() <= static_cast<sal_uInt32>(nSelectedChildIndex))) 1376cdf0e10cSrcweir { 1377*0deba7fbSSteve Yin throw lang::IndexOutOfBoundsException(); 1378cdf0e10cSrcweir } 1379*0deba7fbSSteve Yin ScMyAddress addr = CalcScAddressFromRangeList(mpMarkedRanges,nSelectedChildIndex); 1380*0deba7fbSSteve Yin if( m_mapSelectionSend.find(addr) != m_mapSelectionSend.end() ) 1381*0deba7fbSSteve Yin xAccessible = m_mapSelectionSend[addr]; 1382*0deba7fbSSteve Yin else 1383*0deba7fbSSteve Yin xAccessible = getAccessibleCellAt(addr.Row(), addr.Col()); 1384*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1385cdf0e10cSrcweir } 1386cdf0e10cSrcweir } 1387cdf0e10cSrcweir return xAccessible; 1388cdf0e10cSrcweir } 1389cdf0e10cSrcweir 1390cdf0e10cSrcweir void SAL_CALL 1391cdf0e10cSrcweir ScAccessibleSpreadsheet::deselectAccessibleChild( sal_Int32 nChildIndex ) 1392cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1393cdf0e10cSrcweir { 1394cdf0e10cSrcweir ScUnoGuard aGuard; 1395cdf0e10cSrcweir IsObjectValid(); 1396cdf0e10cSrcweir 1397cdf0e10cSrcweir if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount()) 1398cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1399cdf0e10cSrcweir 1400cdf0e10cSrcweir if (mpViewShell) 1401cdf0e10cSrcweir { 1402cdf0e10cSrcweir sal_Int32 nCol(getAccessibleColumn(nChildIndex)); 1403cdf0e10cSrcweir sal_Int32 nRow(getAccessibleRow(nChildIndex)); 1404cdf0e10cSrcweir 1405*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1406*0deba7fbSSteve Yin if (IsFormulaMode()) 1407*0deba7fbSSteve Yin { 1408*0deba7fbSSteve Yin if(IsScAddrFormulaSel( 1409*0deba7fbSSteve Yin ScAddress(static_cast<SCCOL>(nCol), nRow,mpViewShell->GetViewData()->GetTabNo())) 1410*0deba7fbSSteve Yin ) 1411*0deba7fbSSteve Yin { 1412*0deba7fbSSteve Yin SelectCell(nRow, nCol, sal_True); 1413*0deba7fbSSteve Yin } 1414*0deba7fbSSteve Yin return ; 1415*0deba7fbSSteve Yin } 1416*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1417cdf0e10cSrcweir if (mpViewShell->GetViewData()->GetMarkData().IsCellMarked(static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow))) 1418cdf0e10cSrcweir SelectCell(nRow, nCol, sal_True); 1419cdf0e10cSrcweir } 1420cdf0e10cSrcweir } 1421cdf0e10cSrcweir 1422cdf0e10cSrcweir void ScAccessibleSpreadsheet::SelectCell(sal_Int32 nRow, sal_Int32 nCol, sal_Bool bDeselect) 1423cdf0e10cSrcweir { 1424*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1425*0deba7fbSSteve Yin if (IsFormulaMode()) 1426cdf0e10cSrcweir { 1427*0deba7fbSSteve Yin if (bDeselect) 1428*0deba7fbSSteve Yin {//?? 1429*0deba7fbSSteve Yin return ; 1430cdf0e10cSrcweir } 1431cdf0e10cSrcweir else 1432cdf0e10cSrcweir { 1433*0deba7fbSSteve Yin ScViewData *pViewData = mpViewShell->GetViewData(); 1434*0deba7fbSSteve Yin 1435*0deba7fbSSteve Yin mpViewShell->InitRefMode( static_cast<SCCOL>(nCol), nRow, pViewData->GetTabNo(), SC_REFTYPE_REF ); 1436*0deba7fbSSteve Yin mpViewShell->UpdateRef(static_cast<SCCOL>(nCol), nRow, pViewData->GetTabNo()); 1437cdf0e10cSrcweir } 1438*0deba7fbSSteve Yin return ; 1439cdf0e10cSrcweir } 1440*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1441*0deba7fbSSteve Yin mpViewShell->SetTabNo( maRange.aStart.Tab() ); 1442cdf0e10cSrcweir 1443*0deba7fbSSteve Yin mpViewShell->DoneBlockMode( sal_True ); // continue selecting 1444*0deba7fbSSteve Yin mpViewShell->InitBlockMode( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), maRange.aStart.Tab(), bDeselect, sal_False, sal_False ); 1445*0deba7fbSSteve Yin 1446*0deba7fbSSteve Yin mpViewShell->SelectionChanged(); 1447*0deba7fbSSteve Yin } 1448*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1449*0deba7fbSSteve Yin //void ScAccessibleSpreadsheet::CreateSortedMarkedCells() 1450*0deba7fbSSteve Yin //{ 1451*0deba7fbSSteve Yin // mpSortedMarkedCells = new std::vector<ScMyAddress>(); 1452*0deba7fbSSteve Yin // mpSortedMarkedCells->reserve(mpMarkedRanges->GetCellCount()); 1453*0deba7fbSSteve Yin // ScRange* pRange = mpMarkedRanges->First(); 1454*0deba7fbSSteve Yin // while (pRange) 1455*0deba7fbSSteve Yin // { 1456*0deba7fbSSteve Yin // if (pRange->aStart.Tab() != pRange->aEnd.Tab()) 1457*0deba7fbSSteve Yin // { 1458*0deba7fbSSteve Yin // if ((maActiveCell.Tab() >= pRange->aStart.Tab()) || 1459*0deba7fbSSteve Yin // maActiveCell.Tab() <= pRange->aEnd.Tab()) 1460*0deba7fbSSteve Yin // { 1461*0deba7fbSSteve Yin // ScRange aRange(*pRange); 1462*0deba7fbSSteve Yin // aRange.aStart.SetTab(maActiveCell.Tab()); 1463*0deba7fbSSteve Yin // aRange.aEnd.SetTab(maActiveCell.Tab()); 1464*0deba7fbSSteve Yin // AddMarkedRange(aRange); 1465*0deba7fbSSteve Yin // } 1466*0deba7fbSSteve Yin // else 1467*0deba7fbSSteve Yin // { 1468*0deba7fbSSteve Yin // DBG_ERROR("Range of wrong table"); 1469*0deba7fbSSteve Yin // } 1470*0deba7fbSSteve Yin // } 1471*0deba7fbSSteve Yin // else if(pRange->aStart.Tab() == maActiveCell.Tab()) 1472*0deba7fbSSteve Yin // AddMarkedRange(*pRange); 1473*0deba7fbSSteve Yin // else 1474*0deba7fbSSteve Yin // { 1475*0deba7fbSSteve Yin // DBG_ERROR("Range of wrong table"); 1476*0deba7fbSSteve Yin // } 1477*0deba7fbSSteve Yin // pRange = mpMarkedRanges->Next(); 1478*0deba7fbSSteve Yin // } 1479*0deba7fbSSteve Yin // std::sort(mpSortedMarkedCells->begin(), mpSortedMarkedCells->end()); 1480*0deba7fbSSteve Yin //} 1481*0deba7fbSSteve Yin 1482*0deba7fbSSteve Yin /*void ScAccessibleSpreadsheet::AddMarkedRange(const ScRange& rRange) 1483cdf0e10cSrcweir { 1484cdf0e10cSrcweir for (SCROW nRow = rRange.aStart.Row(); nRow <= rRange.aEnd.Row(); ++nRow) 1485cdf0e10cSrcweir { 1486cdf0e10cSrcweir for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol) 1487cdf0e10cSrcweir { 1488cdf0e10cSrcweir ScMyAddress aCell(nCol, nRow, maActiveCell.Tab()); 1489cdf0e10cSrcweir mpSortedMarkedCells->push_back(aCell); 1490cdf0e10cSrcweir } 1491cdf0e10cSrcweir } 1492*0deba7fbSSteve Yin }*/ 1493*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1494cdf0e10cSrcweir 1495cdf0e10cSrcweir //===== XServiceInfo ==================================================== 1496cdf0e10cSrcweir 1497cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleSpreadsheet::getImplementationName(void) 1498cdf0e10cSrcweir throw (uno::RuntimeException) 1499cdf0e10cSrcweir { 1500cdf0e10cSrcweir return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleSpreadsheet")); 1501cdf0e10cSrcweir } 1502cdf0e10cSrcweir 1503cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> SAL_CALL 1504cdf0e10cSrcweir ScAccessibleSpreadsheet::getSupportedServiceNames (void) 1505cdf0e10cSrcweir throw (uno::RuntimeException) 1506cdf0e10cSrcweir { 1507cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleTableBase::getSupportedServiceNames(); 1508cdf0e10cSrcweir sal_Int32 nOldSize(aSequence.getLength()); 1509cdf0e10cSrcweir aSequence.realloc(nOldSize + 1); 1510cdf0e10cSrcweir ::rtl::OUString* pNames = aSequence.getArray(); 1511cdf0e10cSrcweir 1512cdf0e10cSrcweir pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.AccessibleSpreadsheet")); 1513cdf0e10cSrcweir 1514cdf0e10cSrcweir return aSequence; 1515cdf0e10cSrcweir } 1516cdf0e10cSrcweir 1517cdf0e10cSrcweir //===== XTypeProvider ======================================================= 1518cdf0e10cSrcweir 1519cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL 1520cdf0e10cSrcweir ScAccessibleSpreadsheet::getImplementationId(void) 1521cdf0e10cSrcweir throw (uno::RuntimeException) 1522cdf0e10cSrcweir { 1523cdf0e10cSrcweir ScUnoGuard aGuard; 1524cdf0e10cSrcweir IsObjectValid(); 1525cdf0e10cSrcweir static uno::Sequence<sal_Int8> aId; 1526cdf0e10cSrcweir if (aId.getLength() == 0) 1527cdf0e10cSrcweir { 1528cdf0e10cSrcweir aId.realloc (16); 1529cdf0e10cSrcweir rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True); 1530cdf0e10cSrcweir } 1531cdf0e10cSrcweir return aId; 1532cdf0e10cSrcweir } 1533cdf0e10cSrcweir 1534cdf0e10cSrcweir ///===== XAccessibleEventBroadcaster ===================================== 1535cdf0e10cSrcweir 1536cdf0e10cSrcweir void SAL_CALL ScAccessibleSpreadsheet::addEventListener(const uno::Reference<XAccessibleEventListener>& xListener) 1537cdf0e10cSrcweir throw (uno::RuntimeException) 1538cdf0e10cSrcweir { 1539cdf0e10cSrcweir ScUnoGuard aGuard; 1540cdf0e10cSrcweir IsObjectValid(); 1541cdf0e10cSrcweir ScAccessibleTableBase::addEventListener(xListener); 1542cdf0e10cSrcweir 1543*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1544*0deba7fbSSteve Yin /* if (!mbIsFocusSend) 1545cdf0e10cSrcweir { 1546cdf0e10cSrcweir mbIsFocusSend = sal_True; 1547cdf0e10cSrcweir CommitFocusGained(); 1548cdf0e10cSrcweir 1549cdf0e10cSrcweir AccessibleEventObject aEvent; 1550cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; 1551cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 1552cdf0e10cSrcweir aEvent.NewValue <<= getAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col()); 1553cdf0e10cSrcweir 1554cdf0e10cSrcweir CommitChange(aEvent); 1555cdf0e10cSrcweir } 1556*0deba7fbSSteve Yin */ 1557*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1558cdf0e10cSrcweir } 1559cdf0e10cSrcweir 1560cdf0e10cSrcweir //==== internal ========================================================= 1561cdf0e10cSrcweir 1562cdf0e10cSrcweir Rectangle ScAccessibleSpreadsheet::GetBoundingBoxOnScreen() const 1563cdf0e10cSrcweir throw (uno::RuntimeException) 1564cdf0e10cSrcweir { 1565cdf0e10cSrcweir Rectangle aRect; 1566cdf0e10cSrcweir if (mpViewShell) 1567cdf0e10cSrcweir { 1568cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos); 1569cdf0e10cSrcweir if (pWindow) 1570cdf0e10cSrcweir aRect = pWindow->GetWindowExtentsRelative(NULL); 1571cdf0e10cSrcweir } 1572cdf0e10cSrcweir return aRect; 1573cdf0e10cSrcweir } 1574cdf0e10cSrcweir 1575cdf0e10cSrcweir Rectangle ScAccessibleSpreadsheet::GetBoundingBox() const 1576cdf0e10cSrcweir throw (uno::RuntimeException) 1577cdf0e10cSrcweir { 1578cdf0e10cSrcweir Rectangle aRect; 1579cdf0e10cSrcweir if (mpViewShell) 1580cdf0e10cSrcweir { 1581cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos); 1582cdf0e10cSrcweir if (pWindow) 1583cdf0e10cSrcweir //#101986#; extends to the same window, because the parent is the document and it has the same window 1584cdf0e10cSrcweir aRect = pWindow->GetWindowExtentsRelative(pWindow); 1585cdf0e10cSrcweir } 1586cdf0e10cSrcweir return aRect; 1587cdf0e10cSrcweir } 1588cdf0e10cSrcweir 1589cdf0e10cSrcweir sal_Bool ScAccessibleSpreadsheet::IsDefunc( 1590cdf0e10cSrcweir const uno::Reference<XAccessibleStateSet>& rxParentStates) 1591cdf0e10cSrcweir { 1592cdf0e10cSrcweir return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() || 1593cdf0e10cSrcweir (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC)); 1594cdf0e10cSrcweir } 1595cdf0e10cSrcweir 1596cdf0e10cSrcweir sal_Bool ScAccessibleSpreadsheet::IsEditable( 1597cdf0e10cSrcweir const uno::Reference<XAccessibleStateSet>& /* rxParentStates */) 1598cdf0e10cSrcweir { 1599*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1600*0deba7fbSSteve Yin if (IsFormulaMode()) 1601*0deba7fbSSteve Yin { 1602*0deba7fbSSteve Yin return sal_False; 1603*0deba7fbSSteve Yin } 1604*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1605cdf0e10cSrcweir sal_Bool bProtected(sal_False); 1606cdf0e10cSrcweir if (mpDoc && mpDoc->IsTabProtected(maRange.aStart.Tab())) 1607cdf0e10cSrcweir bProtected = sal_True; 1608cdf0e10cSrcweir return !bProtected; 1609cdf0e10cSrcweir } 1610cdf0e10cSrcweir 1611cdf0e10cSrcweir sal_Bool ScAccessibleSpreadsheet::IsFocused() 1612cdf0e10cSrcweir { 1613cdf0e10cSrcweir sal_Bool bFocused(sal_False); 1614cdf0e10cSrcweir if (mpViewShell) 1615cdf0e10cSrcweir { 1616cdf0e10cSrcweir if (mpViewShell->GetViewData()->GetActivePart() == meSplitPos) 1617cdf0e10cSrcweir bFocused = mpViewShell->GetActiveWin()->HasFocus(); 1618cdf0e10cSrcweir } 1619cdf0e10cSrcweir return bFocused; 1620cdf0e10cSrcweir } 1621cdf0e10cSrcweir 1622cdf0e10cSrcweir sal_Bool ScAccessibleSpreadsheet::IsCompleteSheetSelected() 1623cdf0e10cSrcweir { 1624*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1625*0deba7fbSSteve Yin if (IsFormulaMode()) 1626*0deba7fbSSteve Yin { 1627*0deba7fbSSteve Yin return sal_False; 1628*0deba7fbSSteve Yin } 1629*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1630cdf0e10cSrcweir sal_Bool bResult(sal_False); 1631cdf0e10cSrcweir if(mpViewShell) 1632cdf0e10cSrcweir { 1633cdf0e10cSrcweir //#103800#; use a copy of MarkData 1634cdf0e10cSrcweir ScMarkData aMarkData(mpViewShell->GetViewData()->GetMarkData()); 1635cdf0e10cSrcweir aMarkData.MarkToMulti(); 1636cdf0e10cSrcweir if (aMarkData.IsAllMarked(maRange)) 1637cdf0e10cSrcweir bResult = sal_True; 1638cdf0e10cSrcweir } 1639cdf0e10cSrcweir return bResult; 1640cdf0e10cSrcweir } 1641cdf0e10cSrcweir 1642cdf0e10cSrcweir ScDocument* ScAccessibleSpreadsheet::GetDocument(ScTabViewShell* pViewShell) 1643cdf0e10cSrcweir { 1644cdf0e10cSrcweir ScDocument* pDoc = NULL; 1645cdf0e10cSrcweir if (pViewShell) 1646cdf0e10cSrcweir pDoc = pViewShell->GetViewData()->GetDocument(); 1647cdf0e10cSrcweir return pDoc; 1648cdf0e10cSrcweir } 1649cdf0e10cSrcweir 1650cdf0e10cSrcweir Rectangle ScAccessibleSpreadsheet::GetVisArea(ScTabViewShell* pViewShell, ScSplitPos eSplitPos) 1651cdf0e10cSrcweir { 1652cdf0e10cSrcweir Rectangle aVisArea; 1653cdf0e10cSrcweir if (pViewShell) 1654cdf0e10cSrcweir { 1655cdf0e10cSrcweir Window* pWindow = pViewShell->GetWindowByPos(eSplitPos); 1656cdf0e10cSrcweir if (pWindow) 1657cdf0e10cSrcweir { 1658cdf0e10cSrcweir aVisArea.SetPos(pViewShell->GetViewData()->GetPixPos(eSplitPos)); 1659cdf0e10cSrcweir aVisArea.SetSize(pWindow->GetSizePixel()); 1660cdf0e10cSrcweir } 1661cdf0e10cSrcweir } 1662cdf0e10cSrcweir return aVisArea; 1663cdf0e10cSrcweir } 1664cdf0e10cSrcweir 1665cdf0e10cSrcweir Rectangle ScAccessibleSpreadsheet::GetVisCells(const Rectangle& rVisArea) 1666cdf0e10cSrcweir { 1667cdf0e10cSrcweir if (mpViewShell) 1668cdf0e10cSrcweir { 1669cdf0e10cSrcweir SCsCOL nStartX, nEndX; 1670cdf0e10cSrcweir SCsROW nStartY, nEndY; 1671cdf0e10cSrcweir 1672cdf0e10cSrcweir mpViewShell->GetViewData()->GetPosFromPixel( 1, 1, meSplitPos, nStartX, nStartY); 1673cdf0e10cSrcweir mpViewShell->GetViewData()->GetPosFromPixel( rVisArea.GetWidth(), rVisArea.GetHeight(), meSplitPos, nEndX, nEndY); 1674cdf0e10cSrcweir 1675cdf0e10cSrcweir return Rectangle(nStartX, nStartY, nEndX, nEndY); 1676cdf0e10cSrcweir } 1677cdf0e10cSrcweir else 1678cdf0e10cSrcweir return Rectangle(); 1679cdf0e10cSrcweir } 1680*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 1681*0deba7fbSSteve Yin sal_Bool SAL_CALL ScAccessibleSpreadsheet::selectRow( sal_Int32 row ) 1682*0deba7fbSSteve Yin throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1683*0deba7fbSSteve Yin { 1684*0deba7fbSSteve Yin if (IsFormulaMode()) 1685*0deba7fbSSteve Yin { 1686*0deba7fbSSteve Yin return sal_False; 1687*0deba7fbSSteve Yin } 1688*0deba7fbSSteve Yin 1689*0deba7fbSSteve Yin mpViewShell->SetTabNo( maRange.aStart.Tab() ); 1690*0deba7fbSSteve Yin mpViewShell->DoneBlockMode( sal_True ); // continue selecting 1691*0deba7fbSSteve Yin mpViewShell->InitBlockMode( 0, row, maRange.aStart.Tab(), sal_False, sal_False, sal_True ); 1692*0deba7fbSSteve Yin mpViewShell->MarkCursor( MAXCOL, row, maRange.aStart.Tab(), sal_False, sal_True ); 1693*0deba7fbSSteve Yin mpViewShell->SelectionChanged(); 1694*0deba7fbSSteve Yin return sal_True; 1695*0deba7fbSSteve Yin } 1696*0deba7fbSSteve Yin 1697*0deba7fbSSteve Yin sal_Bool SAL_CALL ScAccessibleSpreadsheet::selectColumn( sal_Int32 column ) 1698*0deba7fbSSteve Yin throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1699*0deba7fbSSteve Yin { 1700*0deba7fbSSteve Yin if (IsFormulaMode()) 1701*0deba7fbSSteve Yin { 1702*0deba7fbSSteve Yin return sal_False; 1703*0deba7fbSSteve Yin } 1704*0deba7fbSSteve Yin 1705*0deba7fbSSteve Yin mpViewShell->SetTabNo( maRange.aStart.Tab() ); 1706*0deba7fbSSteve Yin mpViewShell->DoneBlockMode( sal_True ); // continue selecting 1707*0deba7fbSSteve Yin mpViewShell->InitBlockMode( static_cast<SCCOL>(column), 0, maRange.aStart.Tab(), sal_False, sal_True, sal_False ); 1708*0deba7fbSSteve Yin mpViewShell->MarkCursor( static_cast<SCCOL>(column), MAXROW, maRange.aStart.Tab(), sal_True, sal_False ); 1709*0deba7fbSSteve Yin mpViewShell->SelectionChanged(); 1710*0deba7fbSSteve Yin return sal_True; 1711*0deba7fbSSteve Yin } 1712*0deba7fbSSteve Yin 1713*0deba7fbSSteve Yin sal_Bool SAL_CALL ScAccessibleSpreadsheet::unselectRow( sal_Int32 row ) 1714*0deba7fbSSteve Yin throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1715*0deba7fbSSteve Yin { 1716*0deba7fbSSteve Yin if (IsFormulaMode()) 1717*0deba7fbSSteve Yin { 1718*0deba7fbSSteve Yin return sal_False; 1719*0deba7fbSSteve Yin } 1720*0deba7fbSSteve Yin 1721*0deba7fbSSteve Yin mpViewShell->SetTabNo( maRange.aStart.Tab() ); 1722*0deba7fbSSteve Yin mpViewShell->DoneBlockMode( sal_True ); // continue selecting 1723*0deba7fbSSteve Yin mpViewShell->InitBlockMode( 0, row, maRange.aStart.Tab(), sal_False, sal_False, sal_True, sal_True ); 1724*0deba7fbSSteve Yin mpViewShell->MarkCursor( MAXCOL, row, maRange.aStart.Tab(), sal_False, sal_True ); 1725*0deba7fbSSteve Yin mpViewShell->SelectionChanged(); 1726*0deba7fbSSteve Yin mpViewShell->DoneBlockMode( sal_True ); 1727*0deba7fbSSteve Yin return sal_True; 1728*0deba7fbSSteve Yin } 1729*0deba7fbSSteve Yin 1730*0deba7fbSSteve Yin sal_Bool SAL_CALL ScAccessibleSpreadsheet::unselectColumn( sal_Int32 column ) 1731*0deba7fbSSteve Yin throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1732*0deba7fbSSteve Yin { 1733*0deba7fbSSteve Yin if (IsFormulaMode()) 1734*0deba7fbSSteve Yin { 1735*0deba7fbSSteve Yin return sal_False; 1736*0deba7fbSSteve Yin } 1737*0deba7fbSSteve Yin 1738*0deba7fbSSteve Yin mpViewShell->SetTabNo( maRange.aStart.Tab() ); 1739*0deba7fbSSteve Yin mpViewShell->DoneBlockMode( sal_True ); // continue selecting 1740*0deba7fbSSteve Yin mpViewShell->InitBlockMode( static_cast<SCCOL>(column), 0, maRange.aStart.Tab(), sal_False, sal_True, sal_False, sal_True ); 1741*0deba7fbSSteve Yin mpViewShell->MarkCursor( static_cast<SCCOL>(column), MAXROW, maRange.aStart.Tab(), sal_True, sal_False ); 1742*0deba7fbSSteve Yin mpViewShell->SelectionChanged(); 1743*0deba7fbSSteve Yin mpViewShell->DoneBlockMode( sal_True ); 1744*0deba7fbSSteve Yin return sal_True; 1745*0deba7fbSSteve Yin } 1746*0deba7fbSSteve Yin 1747*0deba7fbSSteve Yin void ScAccessibleSpreadsheet::FireFirstCellFocus() 1748*0deba7fbSSteve Yin { 1749*0deba7fbSSteve Yin if (IsFormulaMode()) 1750*0deba7fbSSteve Yin { 1751*0deba7fbSSteve Yin return ; 1752*0deba7fbSSteve Yin } 1753*0deba7fbSSteve Yin if (mbIsFocusSend) 1754*0deba7fbSSteve Yin { 1755*0deba7fbSSteve Yin return ; 1756*0deba7fbSSteve Yin } 1757*0deba7fbSSteve Yin mbIsFocusSend = sal_True; 1758*0deba7fbSSteve Yin AccessibleEventObject aEvent; 1759*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; 1760*0deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(this); 1761*0deba7fbSSteve Yin aEvent.NewValue <<= getAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col()); 1762*0deba7fbSSteve Yin CommitChange(aEvent); 1763*0deba7fbSSteve Yin } 1764*0deba7fbSSteve Yin void ScAccessibleSpreadsheet::NotifyRefMode() 1765*0deba7fbSSteve Yin { 1766*0deba7fbSSteve Yin ScViewData *pViewData = mpViewShell->GetViewData(); 1767*0deba7fbSSteve Yin sal_uInt16 nRefStartX =pViewData->GetRefStartX(); 1768*0deba7fbSSteve Yin sal_Int32 nRefStartY=pViewData->GetRefStartY(); 1769*0deba7fbSSteve Yin sal_uInt16 nRefEndX=pViewData->GetRefEndX(); 1770*0deba7fbSSteve Yin sal_Int32 nRefEndY=pViewData->GetRefEndY(); 1771*0deba7fbSSteve Yin ScAddress aFormulaAddr; 1772*0deba7fbSSteve Yin if(!GetFormulaCurrentFocusCell(aFormulaAddr)) 1773*0deba7fbSSteve Yin { 1774*0deba7fbSSteve Yin return ; 1775*0deba7fbSSteve Yin } 1776*0deba7fbSSteve Yin if (m_aFormulaActiveCell != aFormulaAddr) 1777*0deba7fbSSteve Yin {//New Focus 1778*0deba7fbSSteve Yin m_nMinX =std::min(nRefStartX,nRefEndX); 1779*0deba7fbSSteve Yin m_nMaxX =std::max(nRefStartX,nRefEndX); 1780*0deba7fbSSteve Yin m_nMinY = std::min(nRefStartY,nRefEndY); 1781*0deba7fbSSteve Yin m_nMaxY = std::max(nRefStartY,nRefEndY); 1782*0deba7fbSSteve Yin RemoveFormulaSelection(); 1783*0deba7fbSSteve Yin AccessibleEventObject aEvent; 1784*0deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(this); 1785*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; 1786*0deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(this); 1787*0deba7fbSSteve Yin uno::Reference< XAccessible > xOld = m_pAccFormulaCell; 1788*0deba7fbSSteve Yin aEvent.OldValue <<= xOld; 1789*0deba7fbSSteve Yin m_pAccFormulaCell = GetAccessibleCellAt(aFormulaAddr.Row(), aFormulaAddr.Col()); 1790*0deba7fbSSteve Yin m_pAccFormulaCell->acquire(); 1791*0deba7fbSSteve Yin m_pAccFormulaCell->Init(); 1792*0deba7fbSSteve Yin uno::Reference< XAccessible > xNew = m_pAccFormulaCell; 1793*0deba7fbSSteve Yin aEvent.NewValue <<= xNew; 1794*0deba7fbSSteve Yin CommitChange(aEvent); 1795*0deba7fbSSteve Yin if (nRefStartX == nRefEndX && nRefStartY == nRefEndY) 1796*0deba7fbSSteve Yin {//Selection Single 1797*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; 1798*0deba7fbSSteve Yin aEvent.NewValue <<= xNew; 1799*0deba7fbSSteve Yin CommitChange(aEvent); 1800*0deba7fbSSteve Yin m_mapFormulaSelectionSend.insert(MAP_ADDR_XACC::value_type(aFormulaAddr,xNew)); 1801*0deba7fbSSteve Yin m_vecFormulaLastMyAddr.clear(); 1802*0deba7fbSSteve Yin m_vecFormulaLastMyAddr.push_back(aFormulaAddr); 1803*0deba7fbSSteve Yin } 1804*0deba7fbSSteve Yin else 1805*0deba7fbSSteve Yin { 1806*0deba7fbSSteve Yin VEC_MYADDR vecCurSel; 1807*0deba7fbSSteve Yin int nCurSize = (m_nMaxX - m_nMinX +1)*(m_nMaxY - m_nMinY +1) ; 1808*0deba7fbSSteve Yin vecCurSel.reserve(nCurSize); 1809*0deba7fbSSteve Yin for (sal_uInt16 x = m_nMinX ; x <= m_nMaxX ; ++x) 1810*0deba7fbSSteve Yin { 1811*0deba7fbSSteve Yin for (sal_Int32 y = m_nMinY ; y <= m_nMaxY ; ++y) 1812*0deba7fbSSteve Yin { 1813*0deba7fbSSteve Yin ScMyAddress aAddr(x,y,0); 1814*0deba7fbSSteve Yin vecCurSel.push_back(aAddr); 1815*0deba7fbSSteve Yin } 1816*0deba7fbSSteve Yin } 1817*0deba7fbSSteve Yin std::sort(vecCurSel.begin(), vecCurSel.end()); 1818*0deba7fbSSteve Yin VEC_MYADDR vecNew; 1819*0deba7fbSSteve Yin std::set_difference(vecCurSel.begin(),vecCurSel.end(), 1820*0deba7fbSSteve Yin m_vecFormulaLastMyAddr.begin(),m_vecFormulaLastMyAddr.end(), 1821*0deba7fbSSteve Yin std::back_insert_iterator<VEC_MYADDR>(vecNew)); 1822*0deba7fbSSteve Yin int nNewSize = vecNew.size(); 1823*0deba7fbSSteve Yin if ( nNewSize > 10 ) 1824*0deba7fbSSteve Yin { 1825*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; 1826*0deba7fbSSteve Yin aEvent.NewValue <<= ::com::sun::star::uno::Any(); 1827*0deba7fbSSteve Yin CommitChange(aEvent); 1828*0deba7fbSSteve Yin } 1829*0deba7fbSSteve Yin else 1830*0deba7fbSSteve Yin { 1831*0deba7fbSSteve Yin VEC_MYADDR::iterator viAddr = vecNew.begin(); 1832*0deba7fbSSteve Yin for(; viAddr != vecNew.end() ; ++viAddr ) 1833*0deba7fbSSteve Yin { 1834*0deba7fbSSteve Yin uno::Reference< XAccessible > xChild; 1835*0deba7fbSSteve Yin if (*viAddr == aFormulaAddr) 1836*0deba7fbSSteve Yin { 1837*0deba7fbSSteve Yin xChild = m_pAccFormulaCell; 1838*0deba7fbSSteve Yin } 1839*0deba7fbSSteve Yin else 1840*0deba7fbSSteve Yin { 1841*0deba7fbSSteve Yin xChild = getAccessibleCellAt(viAddr->Row(),viAddr->Col()); 1842*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS; 1843*0deba7fbSSteve Yin aEvent.NewValue <<= xChild; 1844*0deba7fbSSteve Yin CommitChange(aEvent); 1845*0deba7fbSSteve Yin } 1846*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD; 1847*0deba7fbSSteve Yin aEvent.NewValue <<= xChild; 1848*0deba7fbSSteve Yin CommitChange(aEvent); 1849*0deba7fbSSteve Yin m_mapFormulaSelectionSend.insert(MAP_ADDR_XACC::value_type(*viAddr,xChild)); 1850*0deba7fbSSteve Yin } 1851*0deba7fbSSteve Yin } 1852*0deba7fbSSteve Yin m_vecFormulaLastMyAddr.swap(vecCurSel); 1853*0deba7fbSSteve Yin } 1854*0deba7fbSSteve Yin } 1855*0deba7fbSSteve Yin m_aFormulaActiveCell = aFormulaAddr; 1856*0deba7fbSSteve Yin } 1857*0deba7fbSSteve Yin void ScAccessibleSpreadsheet::RemoveFormulaSelection(sal_Bool bRemoveAll ) 1858*0deba7fbSSteve Yin { 1859*0deba7fbSSteve Yin AccessibleEventObject aEvent; 1860*0deba7fbSSteve Yin aEvent.Source = uno::Reference< XAccessible >(this); 1861*0deba7fbSSteve Yin aEvent.OldValue <<= ::com::sun::star::uno::Any(); 1862*0deba7fbSSteve Yin MAP_ADDR_XACC::iterator miRemove = m_mapFormulaSelectionSend.begin(); 1863*0deba7fbSSteve Yin for(; miRemove != m_mapFormulaSelectionSend.end() ;) 1864*0deba7fbSSteve Yin { 1865*0deba7fbSSteve Yin if( !bRemoveAll && IsScAddrFormulaSel(miRemove->first) ) 1866*0deba7fbSSteve Yin { 1867*0deba7fbSSteve Yin ++miRemove; 1868*0deba7fbSSteve Yin continue; 1869*0deba7fbSSteve Yin } 1870*0deba7fbSSteve Yin aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE; 1871*0deba7fbSSteve Yin aEvent.NewValue <<= miRemove->second; 1872*0deba7fbSSteve Yin CommitChange(aEvent); 1873*0deba7fbSSteve Yin MAP_ADDR_XACC::iterator miNext = miRemove; 1874*0deba7fbSSteve Yin ++miNext; 1875*0deba7fbSSteve Yin m_mapFormulaSelectionSend.erase(miRemove); 1876*0deba7fbSSteve Yin miRemove = miNext; 1877*0deba7fbSSteve Yin } 1878*0deba7fbSSteve Yin } 1879*0deba7fbSSteve Yin sal_Bool ScAccessibleSpreadsheet::IsScAddrFormulaSel(const ScAddress &addr) const 1880*0deba7fbSSteve Yin { 1881*0deba7fbSSteve Yin if( addr.Col() >= m_nMinX && addr.Col() <= m_nMaxX && 1882*0deba7fbSSteve Yin addr.Row() >= m_nMinY && addr.Row() <= m_nMaxY && 1883*0deba7fbSSteve Yin addr.Tab() == mpViewShell->GetViewData()->GetTabNo() ) 1884*0deba7fbSSteve Yin { 1885*0deba7fbSSteve Yin return sal_True; 1886*0deba7fbSSteve Yin } 1887*0deba7fbSSteve Yin return sal_False; 1888*0deba7fbSSteve Yin } 1889*0deba7fbSSteve Yin sal_Bool ScAccessibleSpreadsheet::CheckChildIndex(sal_Int32 nIndex) const 1890*0deba7fbSSteve Yin { 1891*0deba7fbSSteve Yin sal_Int32 nMaxIndex = (m_nMaxX - m_nMinX +1)*(m_nMaxY - m_nMinY +1) -1 ; 1892*0deba7fbSSteve Yin return nIndex <= nMaxIndex && nIndex >= 0 ; 1893*0deba7fbSSteve Yin } 1894*0deba7fbSSteve Yin ScAddress ScAccessibleSpreadsheet::GetChildIndexAddress(sal_Int32 nIndex) const 1895*0deba7fbSSteve Yin { 1896*0deba7fbSSteve Yin sal_Int32 nRowAll = GetRowAll(); 1897*0deba7fbSSteve Yin sal_uInt16 nColAll = GetColAll(); 1898*0deba7fbSSteve Yin if (nIndex < 0 || nIndex >= nRowAll * nColAll ) 1899*0deba7fbSSteve Yin { 1900*0deba7fbSSteve Yin return ScAddress(); 1901*0deba7fbSSteve Yin } 1902*0deba7fbSSteve Yin return ScAddress( 1903*0deba7fbSSteve Yin static_cast<SCCOL>((nIndex - nIndex % nRowAll) / nRowAll + + m_nMinX), 1904*0deba7fbSSteve Yin nIndex % nRowAll + m_nMinY, 1905*0deba7fbSSteve Yin mpViewShell->GetViewData()->GetTabNo() 1906*0deba7fbSSteve Yin ); 1907*0deba7fbSSteve Yin } 1908*0deba7fbSSteve Yin sal_Int32 ScAccessibleSpreadsheet::GetAccessibleIndexFormula( sal_Int32 nRow, sal_Int32 nColumn ) 1909*0deba7fbSSteve Yin { 1910*0deba7fbSSteve Yin sal_uInt16 nColRelative = sal_uInt16(nColumn) - GetColAll(); 1911*0deba7fbSSteve Yin sal_Int32 nRowRelative = nRow - GetRowAll(); 1912*0deba7fbSSteve Yin if (nRow < 0 || nColumn < 0 || nRowRelative >= GetRowAll() || nColRelative >= GetColAll() ) 1913*0deba7fbSSteve Yin { 1914*0deba7fbSSteve Yin return -1; 1915*0deba7fbSSteve Yin } 1916*0deba7fbSSteve Yin return GetRowAll() * nRowRelative + nColRelative; 1917*0deba7fbSSteve Yin } 1918*0deba7fbSSteve Yin sal_Bool ScAccessibleSpreadsheet::IsFormulaMode() 1919*0deba7fbSSteve Yin { 1920*0deba7fbSSteve Yin ScViewData *pViewData = mpViewShell->GetViewData(); 1921*0deba7fbSSteve Yin m_bFormulaMode = pViewData->IsRefMode() || SC_MOD()->IsFormulaMode(); 1922*0deba7fbSSteve Yin return m_bFormulaMode ; 1923*0deba7fbSSteve Yin } 1924*0deba7fbSSteve Yin sal_Bool ScAccessibleSpreadsheet::GetFormulaCurrentFocusCell(ScAddress &addr) 1925*0deba7fbSSteve Yin { 1926*0deba7fbSSteve Yin ScViewData *pViewData = mpViewShell->GetViewData(); 1927*0deba7fbSSteve Yin sal_uInt16 nRefX=0; 1928*0deba7fbSSteve Yin sal_Int32 nRefY=0; 1929*0deba7fbSSteve Yin if(m_bFormulaLastMode) 1930*0deba7fbSSteve Yin { 1931*0deba7fbSSteve Yin nRefX=pViewData->GetRefEndX(); 1932*0deba7fbSSteve Yin nRefY=pViewData->GetRefEndY(); 1933*0deba7fbSSteve Yin } 1934*0deba7fbSSteve Yin else 1935*0deba7fbSSteve Yin { 1936*0deba7fbSSteve Yin nRefX=pViewData->GetRefStartX(); 1937*0deba7fbSSteve Yin nRefY=pViewData->GetRefStartY(); 1938*0deba7fbSSteve Yin } 1939*0deba7fbSSteve Yin if( /* Always true: nRefX >= 0 && */ nRefX <= MAXCOL && nRefY >= 0 && nRefY <= MAXROW) 1940*0deba7fbSSteve Yin { 1941*0deba7fbSSteve Yin addr = ScAddress(nRefX,nRefY,pViewData->GetTabNo()); 1942*0deba7fbSSteve Yin return sal_True; 1943*0deba7fbSSteve Yin } 1944*0deba7fbSSteve Yin return sal_False; 1945*0deba7fbSSteve Yin } 1946*0deba7fbSSteve Yin uno::Reference < XAccessible > ScAccessibleSpreadsheet::GetActiveCell() 1947*0deba7fbSSteve Yin { 1948*0deba7fbSSteve Yin if( m_mapSelectionSend.find( maActiveCell ) != m_mapSelectionSend.end() ) 1949*0deba7fbSSteve Yin return m_mapSelectionSend[maActiveCell]; 1950*0deba7fbSSteve Yin else 1951*0deba7fbSSteve Yin return getAccessibleCellAt(maActiveCell.Row(), maActiveCell .Col()); 1952*0deba7fbSSteve Yin } 1953*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 1954