1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sc.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include "AccessibleDocument.hxx" 33*cdf0e10cSrcweir #include "AccessibleSpreadsheet.hxx" 34*cdf0e10cSrcweir #include "tabvwsh.hxx" 35*cdf0e10cSrcweir #include "AccessibilityHints.hxx" 36*cdf0e10cSrcweir #include "document.hxx" 37*cdf0e10cSrcweir #include "drwlayer.hxx" 38*cdf0e10cSrcweir #include "unoguard.hxx" 39*cdf0e10cSrcweir #include "shapeuno.hxx" 40*cdf0e10cSrcweir #include "DrawModelBroadcaster.hxx" 41*cdf0e10cSrcweir #include "drawview.hxx" 42*cdf0e10cSrcweir #include "gridwin.hxx" 43*cdf0e10cSrcweir #include "AccessibleEditObject.hxx" 44*cdf0e10cSrcweir #include "scresid.hxx" 45*cdf0e10cSrcweir #ifndef SC_SC_HRC 46*cdf0e10cSrcweir #include "sc.hrc" 47*cdf0e10cSrcweir #endif 48*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 49*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLESTATETYPE_HPP_ 50*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 51*cdf0e10cSrcweir #endif 52*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLERELATIONTYPE_HPP_ 53*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRelationType.hpp> 54*cdf0e10cSrcweir #endif 55*cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp> 56*cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp> 57*cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp> 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX 60*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 61*cdf0e10cSrcweir #endif 62*cdf0e10cSrcweir #include <tools/debug.hxx> 63*cdf0e10cSrcweir #include <tools/gen.hxx> 64*cdf0e10cSrcweir #include <svx/svdpage.hxx> 65*cdf0e10cSrcweir #include <svx/svdobj.hxx> 66*cdf0e10cSrcweir #include <svx/ShapeTypeHandler.hxx> 67*cdf0e10cSrcweir #include <svx/AccessibleShape.hxx> 68*cdf0e10cSrcweir #include <svx/AccessibleShapeTreeInfo.hxx> 69*cdf0e10cSrcweir #include <svx/AccessibleShapeInfo.hxx> 70*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 71*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 72*cdf0e10cSrcweir #include <svx/unoshcol.hxx> 73*cdf0e10cSrcweir #include <svx/unoshape.hxx> 74*cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx> 75*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir #include <list> 78*cdf0e10cSrcweir #include <algorithm> 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir using namespace ::com::sun::star; 81*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 82*cdf0e10cSrcweir using ::std::for_each; 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir //===== internal ======================================================== 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir struct ScAccessibleShapeData 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir ScAccessibleShapeData() : pAccShape(NULL), pRelationCell(NULL), bSelected(sal_False), bSelectable(sal_True) {} 89*cdf0e10cSrcweir ~ScAccessibleShapeData(); 90*cdf0e10cSrcweir mutable ::accessibility::AccessibleShape* pAccShape; 91*cdf0e10cSrcweir mutable ScAddress* pRelationCell; // if it is NULL this shape is anchored on the table 92*cdf0e10cSrcweir // SdrObject* pShape; 93*cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape; 94*cdf0e10cSrcweir mutable sal_Bool bSelected; 95*cdf0e10cSrcweir sal_Bool bSelectable; 96*cdf0e10cSrcweir }; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir ScAccessibleShapeData::~ScAccessibleShapeData() 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir if (pAccShape) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir pAccShape->dispose(); 103*cdf0e10cSrcweir pAccShape->release(); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir struct ScShapeDataLess 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir rtl::OUString msLayerId; 110*cdf0e10cSrcweir rtl::OUString msZOrder; 111*cdf0e10cSrcweir ScShapeDataLess() 112*cdf0e10cSrcweir : msLayerId(RTL_CONSTASCII_USTRINGPARAM( "LayerID" )), 113*cdf0e10cSrcweir msZOrder(RTL_CONSTASCII_USTRINGPARAM( "ZOrder" )) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir void ConvertLayerId(sal_Int16& rLayerID) const // changes the number of the LayerId so it the accessibility order 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir switch (rLayerID) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir case SC_LAYER_FRONT: 121*cdf0e10cSrcweir rLayerID = 1; 122*cdf0e10cSrcweir break; 123*cdf0e10cSrcweir case SC_LAYER_BACK: 124*cdf0e10cSrcweir rLayerID = 0; 125*cdf0e10cSrcweir break; 126*cdf0e10cSrcweir case SC_LAYER_INTERN: 127*cdf0e10cSrcweir rLayerID = 2; 128*cdf0e10cSrcweir break; 129*cdf0e10cSrcweir case SC_LAYER_CONTROLS: 130*cdf0e10cSrcweir rLayerID = 3; 131*cdf0e10cSrcweir break; 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir sal_Bool LessThanSheet(const ScAccessibleShapeData* pData) const 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir sal_Bool bResult(sal_False); 137*cdf0e10cSrcweir uno::Reference< beans::XPropertySet> xProps(pData->xShape, uno::UNO_QUERY); 138*cdf0e10cSrcweir if (xProps.is()) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir uno::Any aPropAny = xProps->getPropertyValue(msLayerId); 141*cdf0e10cSrcweir sal_Int16 nLayerID = 0; 142*cdf0e10cSrcweir if( (aPropAny >>= nLayerID) ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir if (nLayerID == SC_LAYER_BACK) 145*cdf0e10cSrcweir bResult = sal_True; 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir return bResult; 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir sal_Bool operator()(const ScAccessibleShapeData* pData1, const ScAccessibleShapeData* pData2) const 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir sal_Bool bResult(sal_False); 153*cdf0e10cSrcweir if (pData1 && pData2) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir uno::Reference< beans::XPropertySet> xProps1(pData1->xShape, uno::UNO_QUERY); 156*cdf0e10cSrcweir uno::Reference< beans::XPropertySet> xProps2(pData2->xShape, uno::UNO_QUERY); 157*cdf0e10cSrcweir if (xProps1.is() && xProps2.is()) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir uno::Any aPropAny1 = xProps1->getPropertyValue(msLayerId); 160*cdf0e10cSrcweir uno::Any aPropAny2 = xProps2->getPropertyValue(msLayerId); 161*cdf0e10cSrcweir sal_Int16 nLayerID1(0); 162*cdf0e10cSrcweir sal_Int16 nLayerID2(0); 163*cdf0e10cSrcweir if( (aPropAny1 >>= nLayerID1) && (aPropAny2 >>= nLayerID2) ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir if (nLayerID1 == nLayerID2) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir uno::Any aAny1 = xProps1->getPropertyValue(msZOrder); 168*cdf0e10cSrcweir sal_Int32 nZOrder1 = 0; 169*cdf0e10cSrcweir uno::Any aAny2 = xProps2->getPropertyValue(msZOrder); 170*cdf0e10cSrcweir sal_Int32 nZOrder2 = 0; 171*cdf0e10cSrcweir if ( (aAny1 >>= nZOrder1) && (aAny2 >>= nZOrder2) ) 172*cdf0e10cSrcweir bResult = (nZOrder1 < nZOrder2); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir else 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir ConvertLayerId(nLayerID1); 177*cdf0e10cSrcweir ConvertLayerId(nLayerID2); 178*cdf0e10cSrcweir bResult = (nLayerID1 < nLayerID2); 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir else if (pData1 && !pData2) 184*cdf0e10cSrcweir bResult = LessThanSheet(pData1); 185*cdf0e10cSrcweir else if (!pData1 && pData2) 186*cdf0e10cSrcweir bResult = !LessThanSheet(pData2); 187*cdf0e10cSrcweir else 188*cdf0e10cSrcweir bResult = sal_False; 189*cdf0e10cSrcweir return bResult; 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir }; 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir struct DeselectShape 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir void operator() (const ScAccessibleShapeData* pAccShapeData) const 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir if (pAccShapeData) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir pAccShapeData->bSelected = sal_False; 200*cdf0e10cSrcweir if (pAccShapeData->pAccShape) 201*cdf0e10cSrcweir pAccShapeData->pAccShape->ResetState(AccessibleStateType::SELECTED); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir }; 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir struct SelectShape 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir uno::Reference < drawing::XShapes > xShapes; 209*cdf0e10cSrcweir SelectShape(uno::Reference<drawing::XShapes>& xTemp) : xShapes(xTemp) {} 210*cdf0e10cSrcweir void operator() (const ScAccessibleShapeData* pAccShapeData) const 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir if (pAccShapeData && pAccShapeData->bSelectable) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir pAccShapeData->bSelected = sal_True; 215*cdf0e10cSrcweir if (pAccShapeData->pAccShape) 216*cdf0e10cSrcweir pAccShapeData->pAccShape->SetState(AccessibleStateType::SELECTED); 217*cdf0e10cSrcweir if (xShapes.is()) 218*cdf0e10cSrcweir xShapes->add(pAccShapeData->xShape); 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir }; 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir struct Destroy 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir void operator() (ScAccessibleShapeData* pData) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir if (pData) 228*cdf0e10cSrcweir DELETEZ(pData); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir }; 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir class ScChildrenShapes : public SfxListener, 233*cdf0e10cSrcweir public ::accessibility::IAccessibleParent 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir public: 236*cdf0e10cSrcweir ScChildrenShapes(ScAccessibleDocument* pAccessibleDocument, ScTabViewShell* pViewShell, ScSplitPos eSplitPos); 237*cdf0e10cSrcweir ~ScChildrenShapes(); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir ///===== SfxListener ===================================================== 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir ///===== IAccessibleParent =============================================== 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir virtual sal_Bool ReplaceChild ( 246*cdf0e10cSrcweir ::accessibility::AccessibleShape* pCurrentChild, 247*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape, 248*cdf0e10cSrcweir const long _nIndex, 249*cdf0e10cSrcweir const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo 250*cdf0e10cSrcweir ) throw (::com::sun::star::uno::RuntimeException); 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir ///===== Internal ======================================================== 253*cdf0e10cSrcweir void SetDrawBroadcaster(); 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir sal_Int32 GetCount() const; 256*cdf0e10cSrcweir uno::Reference< XAccessible > Get(const ScAccessibleShapeData* pData) const; 257*cdf0e10cSrcweir uno::Reference< XAccessible > Get(sal_Int32 nIndex) const; 258*cdf0e10cSrcweir uno::Reference< XAccessible > GetAt(const awt::Point& rPoint) const; 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir // gets the index of the shape starting on 0 (without the index of the table) 261*cdf0e10cSrcweir // returns the selected shape 262*cdf0e10cSrcweir sal_Bool IsSelected(sal_Int32 nIndex, 263*cdf0e10cSrcweir com::sun::star::uno::Reference<com::sun::star::drawing::XShape>& rShape) const; 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir sal_Bool SelectionChanged(); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir void Select(sal_Int32 nIndex); 268*cdf0e10cSrcweir void DeselectAll(); // deselect also the table 269*cdf0e10cSrcweir void SelectAll(); 270*cdf0e10cSrcweir sal_Int32 GetSelectedCount() const; 271*cdf0e10cSrcweir uno::Reference< XAccessible > GetSelected(sal_Int32 nSelectedChildIndex, sal_Bool bTabSelected) const; 272*cdf0e10cSrcweir void Deselect(sal_Int32 nChildIndex); 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir SdrPage* GetDrawPage() const; 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir utl::AccessibleRelationSetHelper* GetRelationSet(const ScAddress* pAddress) const; 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir void VisAreaChanged() const; 279*cdf0e10cSrcweir private: 280*cdf0e10cSrcweir typedef std::vector<ScAccessibleShapeData*> SortedShapes; 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir mutable SortedShapes maZOrderedShapes; // a null pointer represents the sheet in the correct order 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir mutable ::accessibility::AccessibleShapeTreeInfo maShapeTreeInfo; 285*cdf0e10cSrcweir mutable com::sun::star::uno::Reference<com::sun::star::view::XSelectionSupplier> xSelectionSupplier; 286*cdf0e10cSrcweir mutable sal_uInt32 mnSdrObjCount; 287*cdf0e10cSrcweir mutable sal_uInt32 mnShapesSelected; 288*cdf0e10cSrcweir ScTabViewShell* mpViewShell; 289*cdf0e10cSrcweir ScAccessibleDocument* mpAccessibleDocument; 290*cdf0e10cSrcweir ScSplitPos meSplitPos; 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir void FillShapes(std::vector < uno::Reference < drawing::XShape > >& rShapes) const; 293*cdf0e10cSrcweir sal_Bool FindSelectedShapesChanges(const com::sun::star::uno::Reference<com::sun::star::drawing::XShapes>& xShapes, sal_Bool bCommitChange) const; 294*cdf0e10cSrcweir void FillSelectionSupplier() const; 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir ScAddress* GetAnchor(const uno::Reference<drawing::XShape>& xShape) const; 297*cdf0e10cSrcweir uno::Reference<XAccessibleRelationSet> GetRelationSet(const ScAccessibleShapeData* pData) const; 298*cdf0e10cSrcweir void CheckWhetherAnchorChanged(const uno::Reference<drawing::XShape>& xShape) const; 299*cdf0e10cSrcweir void SetAnchor(const uno::Reference<drawing::XShape>& xShape, ScAccessibleShapeData* pData) const; 300*cdf0e10cSrcweir void AddShape(const uno::Reference<drawing::XShape>& xShape, sal_Bool bCommitChange) const; 301*cdf0e10cSrcweir void RemoveShape(const uno::Reference<drawing::XShape>& xShape) const; 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir sal_Bool FindShape(const uno::Reference<drawing::XShape>& xShape, SortedShapes::iterator& rItr) const; 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir sal_Int8 Compare(const ScAccessibleShapeData* pData1, 306*cdf0e10cSrcweir const ScAccessibleShapeData* pData2) const; 307*cdf0e10cSrcweir }; 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir ScChildrenShapes::ScChildrenShapes(ScAccessibleDocument* pAccessibleDocument, ScTabViewShell* pViewShell, ScSplitPos eSplitPos) 310*cdf0e10cSrcweir : 311*cdf0e10cSrcweir mnShapesSelected(0), 312*cdf0e10cSrcweir mpViewShell(pViewShell), 313*cdf0e10cSrcweir mpAccessibleDocument(pAccessibleDocument), 314*cdf0e10cSrcweir meSplitPos(eSplitPos) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir FillSelectionSupplier(); 317*cdf0e10cSrcweir maZOrderedShapes.push_back(NULL); // add an element which represents the table 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir GetCount(); // fill list with filtered shapes (no internal shapes) 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir if (mnShapesSelected) 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir //set flag on every selected shape 324*cdf0e10cSrcweir if (!xSelectionSupplier.is()) 325*cdf0e10cSrcweir throw uno::RuntimeException(); 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir uno::Reference<drawing::XShapes> xShapes(xSelectionSupplier->getSelection(), uno::UNO_QUERY); 328*cdf0e10cSrcweir if (xShapes.is()) 329*cdf0e10cSrcweir FindSelectedShapesChanges(xShapes, sal_False); 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir if (pViewShell) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir SfxBroadcaster* pDrawBC = pViewShell->GetViewData()->GetDocument()->GetDrawBroadcaster(); 334*cdf0e10cSrcweir if (pDrawBC) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir StartListening(*pDrawBC); 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir maShapeTreeInfo.SetModelBroadcaster( new ScDrawModelBroadcaster(pViewShell->GetViewData()->GetDocument()->GetDrawLayer()) ); 339*cdf0e10cSrcweir maShapeTreeInfo.SetSdrView(pViewShell->GetViewData()->GetScDrawView()); 340*cdf0e10cSrcweir maShapeTreeInfo.SetController(NULL); 341*cdf0e10cSrcweir maShapeTreeInfo.SetWindow(pViewShell->GetWindowByPos(meSplitPos)); 342*cdf0e10cSrcweir maShapeTreeInfo.SetViewForwarder(mpAccessibleDocument); 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir ScChildrenShapes::~ScChildrenShapes() 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), Destroy()); 350*cdf0e10cSrcweir if (mpViewShell) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir SfxBroadcaster* pDrawBC = mpViewShell->GetViewData()->GetDocument()->GetDrawBroadcaster(); 353*cdf0e10cSrcweir if (pDrawBC) 354*cdf0e10cSrcweir EndListening(*pDrawBC); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir void ScChildrenShapes::SetDrawBroadcaster() 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir if (mpViewShell) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir SfxBroadcaster* pDrawBC = mpViewShell->GetViewData()->GetDocument()->GetDrawBroadcaster(); 363*cdf0e10cSrcweir if (pDrawBC) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir StartListening(*pDrawBC, sal_True); 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir maShapeTreeInfo.SetModelBroadcaster( new ScDrawModelBroadcaster(mpViewShell->GetViewData()->GetDocument()->GetDrawLayer()) ); 368*cdf0e10cSrcweir maShapeTreeInfo.SetSdrView(mpViewShell->GetViewData()->GetScDrawView()); 369*cdf0e10cSrcweir maShapeTreeInfo.SetController(NULL); 370*cdf0e10cSrcweir maShapeTreeInfo.SetWindow(mpViewShell->GetWindowByPos(meSplitPos)); 371*cdf0e10cSrcweir maShapeTreeInfo.SetViewForwarder(mpAccessibleDocument); 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir void ScChildrenShapes::Notify(SfxBroadcaster&, const SfxHint& rHint) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir if ( rHint.ISA( SdrHint ) ) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ); 381*cdf0e10cSrcweir if (pSdrHint) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir SdrObject* pObj = const_cast<SdrObject*>(pSdrHint->GetObject()); 384*cdf0e10cSrcweir if (pObj && /*(pObj->GetLayer() != SC_LAYER_INTERN) && */(pObj->GetPage() == GetDrawPage()) && 385*cdf0e10cSrcweir (pObj->GetPage() == pObj->GetObjList()) ) //#108480# only do something if the object lies direct on the page 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir switch (pSdrHint->GetKind()) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir case HINT_OBJCHG : // Objekt geaendert 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY); 392*cdf0e10cSrcweir if (xShape.is()) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir ScShapeDataLess aLess; 395*cdf0e10cSrcweir std::sort(maZOrderedShapes.begin(), maZOrderedShapes.end(), aLess); // sort, because the z index or layer could be changed 396*cdf0e10cSrcweir CheckWhetherAnchorChanged(xShape); 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir break; 400*cdf0e10cSrcweir case HINT_OBJINSERTED : // Neues Zeichenobjekt eingefuegt 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY); 403*cdf0e10cSrcweir if (xShape.is()) 404*cdf0e10cSrcweir AddShape(xShape, sal_True); 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir break; 407*cdf0e10cSrcweir case HINT_OBJREMOVED : // Zeichenobjekt aus Liste entfernt 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY); 410*cdf0e10cSrcweir if (xShape.is()) 411*cdf0e10cSrcweir RemoveShape(xShape); 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir break; 414*cdf0e10cSrcweir default : 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir // other events are not interesting 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir break; 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir } 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir sal_Bool ScChildrenShapes::ReplaceChild (::accessibility::AccessibleShape* pCurrentChild, 426*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape, 427*cdf0e10cSrcweir const long _nIndex, const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo) 428*cdf0e10cSrcweir throw (uno::RuntimeException) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir // create the new child 431*cdf0e10cSrcweir ::accessibility::AccessibleShape* pReplacement = ::accessibility::ShapeTypeHandler::Instance().CreateAccessibleObject ( 432*cdf0e10cSrcweir ::accessibility::AccessibleShapeInfo ( _rxShape, pCurrentChild->getAccessibleParent(), this, _nIndex ), 433*cdf0e10cSrcweir _rShapeTreeInfo 434*cdf0e10cSrcweir ); 435*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xNewChild( pReplacement ); // keep this alive (do this before calling Init!) 436*cdf0e10cSrcweir if ( pReplacement ) 437*cdf0e10cSrcweir pReplacement->Init(); 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir sal_Bool bResult(sal_False); 440*cdf0e10cSrcweir if (pCurrentChild && pReplacement) 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir DBG_ASSERT(pCurrentChild->GetXShape().get() == pReplacement->GetXShape().get(), "XShape changes and should be inserted sorted"); 443*cdf0e10cSrcweir SortedShapes::iterator aItr; 444*cdf0e10cSrcweir FindShape(pCurrentChild->GetXShape(), aItr); 445*cdf0e10cSrcweir if (aItr != maZOrderedShapes.end() && (*aItr)) 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir if ((*aItr)->pAccShape) 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir DBG_ASSERT((*aItr)->pAccShape == pCurrentChild, "wrong child found"); 450*cdf0e10cSrcweir AccessibleEventObject aEvent; 451*cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD; 452*cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument); 453*cdf0e10cSrcweir aEvent.OldValue <<= uno::makeAny(uno::Reference<XAccessible>(pCurrentChild)); 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir mpAccessibleDocument->CommitChange(aEvent); // child is gone - event 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir pCurrentChild->dispose(); 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir (*aItr)->pAccShape = pReplacement; 460*cdf0e10cSrcweir AccessibleEventObject aEvent; 461*cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD; 462*cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument); 463*cdf0e10cSrcweir aEvent.NewValue <<= uno::makeAny(uno::Reference<XAccessible>(pReplacement)); 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir mpAccessibleDocument->CommitChange(aEvent); // child is new - event 466*cdf0e10cSrcweir bResult = sal_True; 467*cdf0e10cSrcweir } 468*cdf0e10cSrcweir } 469*cdf0e10cSrcweir return bResult; 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir sal_Int32 ScChildrenShapes::GetCount() const 473*cdf0e10cSrcweir { 474*cdf0e10cSrcweir SdrPage* pDrawPage = GetDrawPage(); 475*cdf0e10cSrcweir if (pDrawPage && (maZOrderedShapes.size() == 1)) // the table is always in 476*cdf0e10cSrcweir { 477*cdf0e10cSrcweir mnSdrObjCount = pDrawPage->GetObjCount(); 478*cdf0e10cSrcweir maZOrderedShapes.reserve(mnSdrObjCount + 1); // the table is always in 479*cdf0e10cSrcweir for (sal_uInt32 i = 0; i < mnSdrObjCount; ++i) 480*cdf0e10cSrcweir { 481*cdf0e10cSrcweir SdrObject* pObj = pDrawPage->GetObj(i); 482*cdf0e10cSrcweir if (pObj/* && (pObj->GetLayer() != SC_LAYER_INTERN)*/) 483*cdf0e10cSrcweir { 484*cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape (pObj->getUnoShape(), uno::UNO_QUERY); 485*cdf0e10cSrcweir AddShape(xShape, sal_False); //inserts in the correct order 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir } 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir return maZOrderedShapes.size(); 490*cdf0e10cSrcweir } 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir uno::Reference< XAccessible > ScChildrenShapes::Get(const ScAccessibleShapeData* pData) const 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir if (!pData) 495*cdf0e10cSrcweir return NULL; 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir if (!pData->pAccShape) 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance(); 500*cdf0e10cSrcweir ::accessibility::AccessibleShapeInfo aShapeInfo(pData->xShape, mpAccessibleDocument, const_cast<ScChildrenShapes*>(this)); 501*cdf0e10cSrcweir pData->pAccShape = rShapeHandler.CreateAccessibleObject( 502*cdf0e10cSrcweir aShapeInfo, maShapeTreeInfo); 503*cdf0e10cSrcweir if (pData->pAccShape) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir pData->pAccShape->acquire(); 506*cdf0e10cSrcweir pData->pAccShape->Init(); 507*cdf0e10cSrcweir if (pData->bSelected) 508*cdf0e10cSrcweir pData->pAccShape->SetState(AccessibleStateType::SELECTED); 509*cdf0e10cSrcweir if (!pData->bSelectable) 510*cdf0e10cSrcweir pData->pAccShape->ResetState(AccessibleStateType::SELECTABLE); 511*cdf0e10cSrcweir pData->pAccShape->SetRelationSet(GetRelationSet(pData)); 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir } 514*cdf0e10cSrcweir return pData->pAccShape; 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir uno::Reference< XAccessible > ScChildrenShapes::Get(sal_Int32 nIndex) const 518*cdf0e10cSrcweir { 519*cdf0e10cSrcweir if (maZOrderedShapes.size() <= 1) 520*cdf0e10cSrcweir GetCount(); // fill list with filtered shapes (no internal shapes) 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir if (static_cast<sal_uInt32>(nIndex) >= maZOrderedShapes.size()) 523*cdf0e10cSrcweir return NULL; 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir return Get(maZOrderedShapes[nIndex]); 526*cdf0e10cSrcweir } 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir uno::Reference< XAccessible > ScChildrenShapes::GetAt(const awt::Point& rPoint) const 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible; 531*cdf0e10cSrcweir if(mpViewShell) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir sal_Int32 i(maZOrderedShapes.size() - 1); 534*cdf0e10cSrcweir sal_Bool bFound(sal_False); 535*cdf0e10cSrcweir while (!bFound && i >= 0) 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir ScAccessibleShapeData* pShape = maZOrderedShapes[i]; 538*cdf0e10cSrcweir if (pShape) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir if (!pShape->pAccShape) 541*cdf0e10cSrcweir Get(pShape); 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir if (pShape->pAccShape) 544*cdf0e10cSrcweir { 545*cdf0e10cSrcweir Point aPoint(VCLPoint(rPoint)); 546*cdf0e10cSrcweir aPoint -= VCLRectangle(pShape->pAccShape->getBounds()).TopLeft(); 547*cdf0e10cSrcweir if (pShape->pAccShape->containsPoint(AWTPoint(aPoint))) 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir xAccessible = pShape->pAccShape; 550*cdf0e10cSrcweir bFound = sal_True; 551*cdf0e10cSrcweir } 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir else 554*cdf0e10cSrcweir { 555*cdf0e10cSrcweir DBG_ERRORFILE("I should have an accessible shape now!"); 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir else 559*cdf0e10cSrcweir bFound = sal_True; // this is the sheet and it lies before the rest of the shapes which are background shapes 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir --i; 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir return xAccessible; 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir sal_Bool ScChildrenShapes::IsSelected(sal_Int32 nIndex, 568*cdf0e10cSrcweir uno::Reference<drawing::XShape>& rShape) const 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir sal_Bool bResult (sal_False); 571*cdf0e10cSrcweir if (maZOrderedShapes.size() <= 1) 572*cdf0e10cSrcweir GetCount(); // fill list with filtered shapes (no internal shapes) 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir if (!xSelectionSupplier.is()) 575*cdf0e10cSrcweir throw uno::RuntimeException(); 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir if (!maZOrderedShapes[nIndex]) 578*cdf0e10cSrcweir return sal_False; 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir bResult = maZOrderedShapes[nIndex]->bSelected; 581*cdf0e10cSrcweir rShape = maZOrderedShapes[nIndex]->xShape; 582*cdf0e10cSrcweir 583*cdf0e10cSrcweir #ifdef DBG_UTIL // test whether it is truly selected by a slower method 584*cdf0e10cSrcweir uno::Reference< drawing::XShape > xReturnShape; 585*cdf0e10cSrcweir sal_Bool bDebugResult(sal_False); 586*cdf0e10cSrcweir uno::Reference<container::XIndexAccess> xIndexAccess; 587*cdf0e10cSrcweir xSelectionSupplier->getSelection() >>= xIndexAccess; 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir if (xIndexAccess.is()) 590*cdf0e10cSrcweir { 591*cdf0e10cSrcweir sal_Int32 nCount(xIndexAccess->getCount()); 592*cdf0e10cSrcweir if (nCount) 593*cdf0e10cSrcweir { 594*cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape; 595*cdf0e10cSrcweir uno::Reference< drawing::XShape > xIndexShape = maZOrderedShapes[nIndex]->xShape; 596*cdf0e10cSrcweir sal_Int32 i(0); 597*cdf0e10cSrcweir while (!bDebugResult && (i < nCount)) 598*cdf0e10cSrcweir { 599*cdf0e10cSrcweir xIndexAccess->getByIndex(i) >>= xShape; 600*cdf0e10cSrcweir if (xShape.is() && (xIndexShape.get() == xShape.get())) 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir bDebugResult = sal_True; 603*cdf0e10cSrcweir xReturnShape = xShape; 604*cdf0e10cSrcweir } 605*cdf0e10cSrcweir else 606*cdf0e10cSrcweir ++i; 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir } 610*cdf0e10cSrcweir DBG_ASSERT((bResult == bDebugResult) && ((bResult && (rShape.get() == xReturnShape.get())) || !bResult), "found the wrong shape or result"); 611*cdf0e10cSrcweir #endif 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir return bResult; 614*cdf0e10cSrcweir } 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir sal_Bool ScChildrenShapes::SelectionChanged() 617*cdf0e10cSrcweir { 618*cdf0e10cSrcweir sal_Bool bResult(sal_False); 619*cdf0e10cSrcweir if (!xSelectionSupplier.is()) 620*cdf0e10cSrcweir throw uno::RuntimeException(); 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir uno::Reference<drawing::XShapes> xShapes(xSelectionSupplier->getSelection(), uno::UNO_QUERY); 623*cdf0e10cSrcweir 624*cdf0e10cSrcweir bResult = FindSelectedShapesChanges(xShapes, sal_True); 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir return bResult; 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir 629*cdf0e10cSrcweir void ScChildrenShapes::Select(sal_Int32 nIndex) 630*cdf0e10cSrcweir { 631*cdf0e10cSrcweir if (maZOrderedShapes.size() <= 1) 632*cdf0e10cSrcweir GetCount(); // fill list with filtered shapes (no internal shapes) 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir if (!xSelectionSupplier.is()) 635*cdf0e10cSrcweir throw uno::RuntimeException(); 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir if (!maZOrderedShapes[nIndex]) 638*cdf0e10cSrcweir return; 639*cdf0e10cSrcweir 640*cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape; 641*cdf0e10cSrcweir if (!IsSelected(nIndex, xShape) && maZOrderedShapes[nIndex]->bSelectable) 642*cdf0e10cSrcweir { 643*cdf0e10cSrcweir uno::Reference<drawing::XShapes> xShapes; 644*cdf0e10cSrcweir xSelectionSupplier->getSelection() >>= xShapes; 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir if (!xShapes.is()) 647*cdf0e10cSrcweir xShapes = new SvxShapeCollection(); 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir xShapes->add(maZOrderedShapes[nIndex]->xShape); 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir try 652*cdf0e10cSrcweir { 653*cdf0e10cSrcweir xSelectionSupplier->select(uno::makeAny(xShapes)); 654*cdf0e10cSrcweir maZOrderedShapes[nIndex]->bSelected = sal_True; 655*cdf0e10cSrcweir if (maZOrderedShapes[nIndex]->pAccShape) 656*cdf0e10cSrcweir maZOrderedShapes[nIndex]->pAccShape->SetState(AccessibleStateType::SELECTED); 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir catch (lang::IllegalArgumentException&) 659*cdf0e10cSrcweir { 660*cdf0e10cSrcweir } 661*cdf0e10cSrcweir } 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir void ScChildrenShapes::DeselectAll() 665*cdf0e10cSrcweir { 666*cdf0e10cSrcweir if (!xSelectionSupplier.is()) 667*cdf0e10cSrcweir throw uno::RuntimeException(); 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir sal_Bool bSomethingSelected(sal_True); 670*cdf0e10cSrcweir try 671*cdf0e10cSrcweir { 672*cdf0e10cSrcweir xSelectionSupplier->select(uno::Any()); //deselects all 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir catch (lang::IllegalArgumentException&) 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir DBG_ERRORFILE("nothing selected before"); 677*cdf0e10cSrcweir bSomethingSelected = sal_False; 678*cdf0e10cSrcweir } 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir if (bSomethingSelected) 681*cdf0e10cSrcweir std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), DeselectShape()); 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir void ScChildrenShapes::SelectAll() 685*cdf0e10cSrcweir { 686*cdf0e10cSrcweir if (!xSelectionSupplier.is()) 687*cdf0e10cSrcweir throw uno::RuntimeException(); 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir if (maZOrderedShapes.size() <= 1) 690*cdf0e10cSrcweir GetCount(); // fill list with filtered shapes (no internal shapes) 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir if (maZOrderedShapes.size() > 1) 693*cdf0e10cSrcweir { 694*cdf0e10cSrcweir uno::Reference<drawing::XShapes> xShapes; 695*cdf0e10cSrcweir xShapes = new SvxShapeCollection(); 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir try 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), SelectShape(xShapes)); 700*cdf0e10cSrcweir xSelectionSupplier->select(uno::makeAny(xShapes)); 701*cdf0e10cSrcweir } 702*cdf0e10cSrcweir catch (lang::IllegalArgumentException&) 703*cdf0e10cSrcweir { 704*cdf0e10cSrcweir SelectionChanged(); // find all selected shapes and set the flags 705*cdf0e10cSrcweir } 706*cdf0e10cSrcweir } 707*cdf0e10cSrcweir } 708*cdf0e10cSrcweir 709*cdf0e10cSrcweir void ScChildrenShapes::FillShapes(std::vector < uno::Reference < drawing::XShape > >& rShapes) const 710*cdf0e10cSrcweir { 711*cdf0e10cSrcweir uno::Reference<container::XIndexAccess> xIndexAccess; 712*cdf0e10cSrcweir xSelectionSupplier->getSelection() >>= xIndexAccess; 713*cdf0e10cSrcweir 714*cdf0e10cSrcweir if (xIndexAccess.is()) 715*cdf0e10cSrcweir { 716*cdf0e10cSrcweir sal_uInt32 nCount(xIndexAccess->getCount()); 717*cdf0e10cSrcweir for (sal_uInt32 i = 0; i < nCount; ++i) 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape; 720*cdf0e10cSrcweir xIndexAccess->getByIndex(i) >>= xShape; 721*cdf0e10cSrcweir if (xShape.is()) 722*cdf0e10cSrcweir rShapes.push_back(xShape); 723*cdf0e10cSrcweir } 724*cdf0e10cSrcweir } 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir 727*cdf0e10cSrcweir sal_Int32 ScChildrenShapes::GetSelectedCount() const 728*cdf0e10cSrcweir { 729*cdf0e10cSrcweir if (!xSelectionSupplier.is()) 730*cdf0e10cSrcweir throw uno::RuntimeException(); 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir std::vector < uno::Reference < drawing::XShape > > aShapes; 733*cdf0e10cSrcweir FillShapes(aShapes); 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir return aShapes.size(); 736*cdf0e10cSrcweir } 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir uno::Reference< XAccessible > ScChildrenShapes::GetSelected(sal_Int32 nSelectedChildIndex, sal_Bool bTabSelected) const 739*cdf0e10cSrcweir { 740*cdf0e10cSrcweir uno::Reference< XAccessible > xAccessible; 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir if (maZOrderedShapes.size() <= 1) 743*cdf0e10cSrcweir GetCount(); // fill list with shapes 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir if (!bTabSelected) 746*cdf0e10cSrcweir { 747*cdf0e10cSrcweir std::vector < uno::Reference < drawing::XShape > > aShapes; 748*cdf0e10cSrcweir FillShapes(aShapes); 749*cdf0e10cSrcweir 750*cdf0e10cSrcweir SortedShapes::iterator aItr; 751*cdf0e10cSrcweir if (FindShape(aShapes[nSelectedChildIndex], aItr)) 752*cdf0e10cSrcweir xAccessible = Get(aItr - maZOrderedShapes.begin()); 753*cdf0e10cSrcweir } 754*cdf0e10cSrcweir else 755*cdf0e10cSrcweir { 756*cdf0e10cSrcweir SortedShapes::iterator aItr = maZOrderedShapes.begin(); 757*cdf0e10cSrcweir SortedShapes::iterator aEndItr = maZOrderedShapes.end(); 758*cdf0e10cSrcweir sal_Bool bFound(sal_False); 759*cdf0e10cSrcweir while(!bFound && aItr != aEndItr) 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir if (*aItr) 762*cdf0e10cSrcweir { 763*cdf0e10cSrcweir if ((*aItr)->bSelected) 764*cdf0e10cSrcweir { 765*cdf0e10cSrcweir if (nSelectedChildIndex == 0) 766*cdf0e10cSrcweir bFound = sal_True; 767*cdf0e10cSrcweir else 768*cdf0e10cSrcweir --nSelectedChildIndex; 769*cdf0e10cSrcweir } 770*cdf0e10cSrcweir } 771*cdf0e10cSrcweir else 772*cdf0e10cSrcweir { 773*cdf0e10cSrcweir if (nSelectedChildIndex == 0) 774*cdf0e10cSrcweir bFound = sal_True; 775*cdf0e10cSrcweir else 776*cdf0e10cSrcweir --nSelectedChildIndex; 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir if (!bFound) 779*cdf0e10cSrcweir ++aItr; 780*cdf0e10cSrcweir } 781*cdf0e10cSrcweir if (bFound && *aItr) 782*cdf0e10cSrcweir xAccessible = (*aItr)->pAccShape; 783*cdf0e10cSrcweir } 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir return xAccessible; 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir 788*cdf0e10cSrcweir void ScChildrenShapes::Deselect(sal_Int32 nChildIndex) 789*cdf0e10cSrcweir { 790*cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape; 791*cdf0e10cSrcweir if (IsSelected(nChildIndex, xShape)) // returns false if it is the sheet 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir if (xShape.is()) 794*cdf0e10cSrcweir { 795*cdf0e10cSrcweir uno::Reference<drawing::XShapes> xShapes; 796*cdf0e10cSrcweir xSelectionSupplier->getSelection() >>= xShapes; 797*cdf0e10cSrcweir if (xShapes.is()) 798*cdf0e10cSrcweir xShapes->remove(xShape); 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir try 801*cdf0e10cSrcweir { 802*cdf0e10cSrcweir xSelectionSupplier->select(uno::makeAny(xShapes)); 803*cdf0e10cSrcweir } 804*cdf0e10cSrcweir catch (lang::IllegalArgumentException&) 805*cdf0e10cSrcweir { 806*cdf0e10cSrcweir DBG_ERRORFILE("something not selectable"); 807*cdf0e10cSrcweir } 808*cdf0e10cSrcweir 809*cdf0e10cSrcweir maZOrderedShapes[nChildIndex]->bSelected = sal_False; 810*cdf0e10cSrcweir if (maZOrderedShapes[nChildIndex]->pAccShape) 811*cdf0e10cSrcweir maZOrderedShapes[nChildIndex]->pAccShape->ResetState(AccessibleStateType::SELECTED); 812*cdf0e10cSrcweir } 813*cdf0e10cSrcweir } 814*cdf0e10cSrcweir } 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir SdrPage* ScChildrenShapes::GetDrawPage() const 818*cdf0e10cSrcweir { 819*cdf0e10cSrcweir SCTAB nTab(mpAccessibleDocument->getVisibleTable()); 820*cdf0e10cSrcweir SdrPage* pDrawPage = NULL; 821*cdf0e10cSrcweir if (mpViewShell) 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir ScDocument* pDoc = mpViewShell->GetViewData()->GetDocument(); 824*cdf0e10cSrcweir if (pDoc && pDoc->GetDrawLayer()) 825*cdf0e10cSrcweir { 826*cdf0e10cSrcweir ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); 827*cdf0e10cSrcweir if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab)) 828*cdf0e10cSrcweir pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(static_cast<sal_Int16>(nTab))); 829*cdf0e10cSrcweir } 830*cdf0e10cSrcweir } 831*cdf0e10cSrcweir return pDrawPage; 832*cdf0e10cSrcweir } 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir struct SetRelation 835*cdf0e10cSrcweir { 836*cdf0e10cSrcweir const ScChildrenShapes* mpChildrenShapes; 837*cdf0e10cSrcweir mutable utl::AccessibleRelationSetHelper* mpRelationSet; 838*cdf0e10cSrcweir const ScAddress* mpAddress; 839*cdf0e10cSrcweir SetRelation(const ScChildrenShapes* pChildrenShapes, const ScAddress* pAddress) 840*cdf0e10cSrcweir : 841*cdf0e10cSrcweir mpChildrenShapes(pChildrenShapes), 842*cdf0e10cSrcweir mpRelationSet(NULL), 843*cdf0e10cSrcweir mpAddress(pAddress) 844*cdf0e10cSrcweir { 845*cdf0e10cSrcweir } 846*cdf0e10cSrcweir void operator() (const ScAccessibleShapeData* pAccShapeData) const 847*cdf0e10cSrcweir { 848*cdf0e10cSrcweir if (pAccShapeData && 849*cdf0e10cSrcweir ((!pAccShapeData->pRelationCell && !mpAddress) || 850*cdf0e10cSrcweir (pAccShapeData->pRelationCell && mpAddress && (*(pAccShapeData->pRelationCell) == *mpAddress)))) 851*cdf0e10cSrcweir { 852*cdf0e10cSrcweir if (!mpRelationSet) 853*cdf0e10cSrcweir mpRelationSet = new utl::AccessibleRelationSetHelper(); 854*cdf0e10cSrcweir 855*cdf0e10cSrcweir AccessibleRelation aRelation; 856*cdf0e10cSrcweir aRelation.TargetSet.realloc(1); 857*cdf0e10cSrcweir aRelation.TargetSet[0] = mpChildrenShapes->Get(pAccShapeData); 858*cdf0e10cSrcweir aRelation.RelationType = AccessibleRelationType::CONTROLLER_FOR; 859*cdf0e10cSrcweir 860*cdf0e10cSrcweir mpRelationSet->AddRelation(aRelation); 861*cdf0e10cSrcweir } 862*cdf0e10cSrcweir } 863*cdf0e10cSrcweir }; 864*cdf0e10cSrcweir 865*cdf0e10cSrcweir utl::AccessibleRelationSetHelper* ScChildrenShapes::GetRelationSet(const ScAddress* pAddress) const 866*cdf0e10cSrcweir { 867*cdf0e10cSrcweir SetRelation aSetRelation(this, pAddress); 868*cdf0e10cSrcweir ::std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), aSetRelation); 869*cdf0e10cSrcweir return aSetRelation.mpRelationSet; 870*cdf0e10cSrcweir } 871*cdf0e10cSrcweir 872*cdf0e10cSrcweir sal_Bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::XShapes>& xShapes, sal_Bool /* bCommitChange */) const 873*cdf0e10cSrcweir { 874*cdf0e10cSrcweir sal_Bool bResult(sal_False); 875*cdf0e10cSrcweir SortedShapes aShapesList; 876*cdf0e10cSrcweir uno::Reference<container::XIndexAccess> xIndexAcc(xShapes, uno::UNO_QUERY); 877*cdf0e10cSrcweir if (xIndexAcc.is()) 878*cdf0e10cSrcweir { 879*cdf0e10cSrcweir mnShapesSelected = xIndexAcc->getCount(); 880*cdf0e10cSrcweir for (sal_uInt32 i = 0; i < mnShapesSelected; ++i) 881*cdf0e10cSrcweir { 882*cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape; 883*cdf0e10cSrcweir xIndexAcc->getByIndex(i) >>= xShape; 884*cdf0e10cSrcweir if (xShape.is()) 885*cdf0e10cSrcweir { 886*cdf0e10cSrcweir ScAccessibleShapeData* pShapeData = new ScAccessibleShapeData(); 887*cdf0e10cSrcweir pShapeData->xShape = xShape; 888*cdf0e10cSrcweir aShapesList.push_back(pShapeData); 889*cdf0e10cSrcweir } 890*cdf0e10cSrcweir } 891*cdf0e10cSrcweir } 892*cdf0e10cSrcweir else 893*cdf0e10cSrcweir mnShapesSelected = 0; 894*cdf0e10cSrcweir ScShapeDataLess aLess; 895*cdf0e10cSrcweir std::sort(aShapesList.begin(), aShapesList.end(), aLess); 896*cdf0e10cSrcweir 897*cdf0e10cSrcweir SortedShapes::iterator aXShapesItr(aShapesList.begin()); 898*cdf0e10cSrcweir SortedShapes::const_iterator aXShapesEndItr(aShapesList.end()); 899*cdf0e10cSrcweir SortedShapes::iterator aDataItr(maZOrderedShapes.begin()); 900*cdf0e10cSrcweir SortedShapes::const_iterator aDataEndItr(maZOrderedShapes.end()); 901*cdf0e10cSrcweir SortedShapes::const_iterator aFocusedItr = aDataEndItr; 902*cdf0e10cSrcweir while((aDataItr != aDataEndItr)) 903*cdf0e10cSrcweir { 904*cdf0e10cSrcweir if (*aDataItr) // is it realy a shape or only the sheet 905*cdf0e10cSrcweir { 906*cdf0e10cSrcweir sal_Int8 nComp(0); 907*cdf0e10cSrcweir if (aXShapesItr == aXShapesEndItr) 908*cdf0e10cSrcweir nComp = -1; // simulate that the Shape is lower, so the selction state will be removed 909*cdf0e10cSrcweir else 910*cdf0e10cSrcweir nComp = Compare(*aDataItr, *aXShapesItr); 911*cdf0e10cSrcweir if (nComp == 0) 912*cdf0e10cSrcweir { 913*cdf0e10cSrcweir if (!(*aDataItr)->bSelected) 914*cdf0e10cSrcweir { 915*cdf0e10cSrcweir (*aDataItr)->bSelected = sal_True; 916*cdf0e10cSrcweir if ((*aDataItr)->pAccShape) 917*cdf0e10cSrcweir { 918*cdf0e10cSrcweir (*aDataItr)->pAccShape->SetState(AccessibleStateType::SELECTED); 919*cdf0e10cSrcweir (*aDataItr)->pAccShape->ResetState(AccessibleStateType::FOCUSED); 920*cdf0e10cSrcweir bResult = sal_True; 921*cdf0e10cSrcweir } 922*cdf0e10cSrcweir aFocusedItr = aDataItr; 923*cdf0e10cSrcweir } 924*cdf0e10cSrcweir ++aDataItr; 925*cdf0e10cSrcweir ++aXShapesItr; 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir else if (nComp < 0) 928*cdf0e10cSrcweir { 929*cdf0e10cSrcweir if ((*aDataItr)->bSelected) 930*cdf0e10cSrcweir { 931*cdf0e10cSrcweir (*aDataItr)->bSelected = sal_False; 932*cdf0e10cSrcweir if ((*aDataItr)->pAccShape) 933*cdf0e10cSrcweir { 934*cdf0e10cSrcweir (*aDataItr)->pAccShape->ResetState(AccessibleStateType::SELECTED); 935*cdf0e10cSrcweir (*aDataItr)->pAccShape->ResetState(AccessibleStateType::FOCUSED); 936*cdf0e10cSrcweir bResult = sal_True; 937*cdf0e10cSrcweir } 938*cdf0e10cSrcweir } 939*cdf0e10cSrcweir ++aDataItr; 940*cdf0e10cSrcweir } 941*cdf0e10cSrcweir else 942*cdf0e10cSrcweir { 943*cdf0e10cSrcweir DBG_ERRORFILE("here is a selected shape which is not in the childlist"); 944*cdf0e10cSrcweir ++aXShapesItr; 945*cdf0e10cSrcweir --mnShapesSelected; 946*cdf0e10cSrcweir } 947*cdf0e10cSrcweir } 948*cdf0e10cSrcweir else 949*cdf0e10cSrcweir ++aDataItr; 950*cdf0e10cSrcweir } 951*cdf0e10cSrcweir if ((aFocusedItr != aDataEndItr) && (*aFocusedItr)->pAccShape && (mnShapesSelected == 1)) 952*cdf0e10cSrcweir (*aFocusedItr)->pAccShape->SetState(AccessibleStateType::FOCUSED); 953*cdf0e10cSrcweir 954*cdf0e10cSrcweir std::for_each(aShapesList.begin(), aShapesList.end(), Destroy()); 955*cdf0e10cSrcweir 956*cdf0e10cSrcweir return bResult; 957*cdf0e10cSrcweir } 958*cdf0e10cSrcweir 959*cdf0e10cSrcweir void ScChildrenShapes::FillSelectionSupplier() const 960*cdf0e10cSrcweir { 961*cdf0e10cSrcweir if (!xSelectionSupplier.is() && mpViewShell) 962*cdf0e10cSrcweir { 963*cdf0e10cSrcweir SfxViewFrame* pViewFrame = mpViewShell->GetViewFrame(); 964*cdf0e10cSrcweir if (pViewFrame) 965*cdf0e10cSrcweir { 966*cdf0e10cSrcweir xSelectionSupplier = uno::Reference<view::XSelectionSupplier>(pViewFrame->GetFrame().GetController(), uno::UNO_QUERY); 967*cdf0e10cSrcweir if (xSelectionSupplier.is()) 968*cdf0e10cSrcweir { 969*cdf0e10cSrcweir if (mpAccessibleDocument) 970*cdf0e10cSrcweir xSelectionSupplier->addSelectionChangeListener(mpAccessibleDocument); 971*cdf0e10cSrcweir uno::Reference<drawing::XShapes> xShapes (xSelectionSupplier->getSelection(), uno::UNO_QUERY); 972*cdf0e10cSrcweir if (xShapes.is()) 973*cdf0e10cSrcweir mnShapesSelected = xShapes->getCount(); 974*cdf0e10cSrcweir } 975*cdf0e10cSrcweir } 976*cdf0e10cSrcweir } 977*cdf0e10cSrcweir } 978*cdf0e10cSrcweir 979*cdf0e10cSrcweir ScAddress* ScChildrenShapes::GetAnchor(const uno::Reference<drawing::XShape>& xShape) const 980*cdf0e10cSrcweir { 981*cdf0e10cSrcweir ScAddress* pAddress = NULL; 982*cdf0e10cSrcweir if (mpViewShell) 983*cdf0e10cSrcweir { 984*cdf0e10cSrcweir SvxShape* pShapeImp = SvxShape::getImplementation(xShape); 985*cdf0e10cSrcweir uno::Reference<beans::XPropertySet> xShapeProp(xShape, uno::UNO_QUERY); 986*cdf0e10cSrcweir if (pShapeImp && xShapeProp.is()) 987*cdf0e10cSrcweir { 988*cdf0e10cSrcweir SdrObject *pSdrObj = pShapeImp->GetSdrObject(); 989*cdf0e10cSrcweir if (pSdrObj) 990*cdf0e10cSrcweir { 991*cdf0e10cSrcweir if (ScDrawLayer::GetAnchor(pSdrObj) == SCA_CELL) 992*cdf0e10cSrcweir { 993*cdf0e10cSrcweir ScDocument* pDoc = mpViewShell->GetViewData()->GetDocument(); 994*cdf0e10cSrcweir if (pDoc) 995*cdf0e10cSrcweir { 996*cdf0e10cSrcweir rtl::OUString sCaptionShape(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape")); 997*cdf0e10cSrcweir awt::Point aPoint(xShape->getPosition()); 998*cdf0e10cSrcweir awt::Size aSize(xShape->getSize()); 999*cdf0e10cSrcweir rtl::OUString sType(xShape->getShapeType()); 1000*cdf0e10cSrcweir Rectangle aRectangle(aPoint.X, aPoint.Y, aPoint.X + aSize.Width, aPoint.Y + aSize.Height); 1001*cdf0e10cSrcweir if ( sType.equals(sCaptionShape) ) 1002*cdf0e10cSrcweir { 1003*cdf0e10cSrcweir awt::Point aRelativeCaptionPoint; 1004*cdf0e10cSrcweir rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" )); 1005*cdf0e10cSrcweir xShapeProp->getPropertyValue( sCaptionPoint ) >>= aRelativeCaptionPoint; 1006*cdf0e10cSrcweir Point aCoreRelativeCaptionPoint(aRelativeCaptionPoint.X, aRelativeCaptionPoint.Y); 1007*cdf0e10cSrcweir Point aCoreAbsoluteCaptionPoint(aPoint.X, aPoint.Y); 1008*cdf0e10cSrcweir aCoreAbsoluteCaptionPoint += aCoreRelativeCaptionPoint; 1009*cdf0e10cSrcweir aRectangle.Union(Rectangle(aCoreAbsoluteCaptionPoint, aCoreAbsoluteCaptionPoint)); 1010*cdf0e10cSrcweir } 1011*cdf0e10cSrcweir ScRange aRange = pDoc->GetRange(mpAccessibleDocument->getVisibleTable(), aRectangle); 1012*cdf0e10cSrcweir pAddress = new ScAddress(aRange.aStart); 1013*cdf0e10cSrcweir } 1014*cdf0e10cSrcweir } 1015*cdf0e10cSrcweir // else 1016*cdf0e10cSrcweir // do nothing, because it is always a NULL Pointer 1017*cdf0e10cSrcweir } 1018*cdf0e10cSrcweir } 1019*cdf0e10cSrcweir } 1020*cdf0e10cSrcweir 1021*cdf0e10cSrcweir return pAddress; 1022*cdf0e10cSrcweir } 1023*cdf0e10cSrcweir 1024*cdf0e10cSrcweir uno::Reference<XAccessibleRelationSet> ScChildrenShapes::GetRelationSet(const ScAccessibleShapeData* pData) const 1025*cdf0e10cSrcweir { 1026*cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pRelationSet = new utl::AccessibleRelationSetHelper(); 1027*cdf0e10cSrcweir 1028*cdf0e10cSrcweir if(pData && pRelationSet && mpAccessibleDocument) 1029*cdf0e10cSrcweir { 1030*cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible = mpAccessibleDocument->GetAccessibleSpreadsheet(); // should be the current table 1031*cdf0e10cSrcweir if (pData->pRelationCell && xAccessible.is()) 1032*cdf0e10cSrcweir { 1033*cdf0e10cSrcweir uno::Reference<XAccessibleTable> xAccTable (xAccessible->getAccessibleContext(), uno::UNO_QUERY); 1034*cdf0e10cSrcweir if (xAccTable.is()) 1035*cdf0e10cSrcweir xAccessible = xAccTable->getAccessibleCellAt(pData->pRelationCell->Row(), pData->pRelationCell->Col()); 1036*cdf0e10cSrcweir } 1037*cdf0e10cSrcweir AccessibleRelation aRelation; 1038*cdf0e10cSrcweir aRelation.TargetSet.realloc(1); 1039*cdf0e10cSrcweir aRelation.TargetSet[0] = xAccessible; 1040*cdf0e10cSrcweir aRelation.RelationType = AccessibleRelationType::CONTROLLED_BY; 1041*cdf0e10cSrcweir pRelationSet->AddRelation(aRelation); 1042*cdf0e10cSrcweir } 1043*cdf0e10cSrcweir 1044*cdf0e10cSrcweir return pRelationSet; 1045*cdf0e10cSrcweir } 1046*cdf0e10cSrcweir 1047*cdf0e10cSrcweir void ScChildrenShapes::CheckWhetherAnchorChanged(const uno::Reference<drawing::XShape>& xShape) const 1048*cdf0e10cSrcweir { 1049*cdf0e10cSrcweir SortedShapes::iterator aItr; 1050*cdf0e10cSrcweir if (FindShape(xShape, aItr)) 1051*cdf0e10cSrcweir SetAnchor(xShape, *aItr); 1052*cdf0e10cSrcweir } 1053*cdf0e10cSrcweir 1054*cdf0e10cSrcweir void ScChildrenShapes::SetAnchor(const uno::Reference<drawing::XShape>& xShape, ScAccessibleShapeData* pData) const 1055*cdf0e10cSrcweir { 1056*cdf0e10cSrcweir if (pData) 1057*cdf0e10cSrcweir { 1058*cdf0e10cSrcweir ScAddress* pAddress = GetAnchor(xShape); 1059*cdf0e10cSrcweir if ((pAddress && pData->pRelationCell && (*pAddress != *(pData->pRelationCell))) || 1060*cdf0e10cSrcweir (!pAddress && pData->pRelationCell) || (pAddress && !pData->pRelationCell)) 1061*cdf0e10cSrcweir { 1062*cdf0e10cSrcweir if (pData->pRelationCell) 1063*cdf0e10cSrcweir delete pData->pRelationCell; 1064*cdf0e10cSrcweir pData->pRelationCell = pAddress; 1065*cdf0e10cSrcweir if (pData->pAccShape) 1066*cdf0e10cSrcweir pData->pAccShape->SetRelationSet(GetRelationSet(pData)); 1067*cdf0e10cSrcweir } 1068*cdf0e10cSrcweir } 1069*cdf0e10cSrcweir } 1070*cdf0e10cSrcweir 1071*cdf0e10cSrcweir void ScChildrenShapes::AddShape(const uno::Reference<drawing::XShape>& xShape, sal_Bool bCommitChange) const 1072*cdf0e10cSrcweir { 1073*cdf0e10cSrcweir SortedShapes::iterator aFindItr; 1074*cdf0e10cSrcweir if (!FindShape(xShape, aFindItr)) 1075*cdf0e10cSrcweir { 1076*cdf0e10cSrcweir ScAccessibleShapeData* pShape = new ScAccessibleShapeData(); 1077*cdf0e10cSrcweir pShape->xShape = xShape; 1078*cdf0e10cSrcweir SortedShapes::iterator aNewItr = maZOrderedShapes.insert(aFindItr, pShape); 1079*cdf0e10cSrcweir SetAnchor(xShape, pShape); 1080*cdf0e10cSrcweir 1081*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xShapeProp(xShape, uno::UNO_QUERY); 1082*cdf0e10cSrcweir if (xShapeProp.is()) 1083*cdf0e10cSrcweir { 1084*cdf0e10cSrcweir uno::Any aPropAny = xShapeProp->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "LayerID" ))); 1085*cdf0e10cSrcweir sal_Int16 nLayerID = 0; 1086*cdf0e10cSrcweir if( aPropAny >>= nLayerID ) 1087*cdf0e10cSrcweir { 1088*cdf0e10cSrcweir if( (nLayerID == SC_LAYER_INTERN) || (nLayerID == SC_LAYER_HIDDEN) ) 1089*cdf0e10cSrcweir pShape->bSelectable = sal_False; 1090*cdf0e10cSrcweir else 1091*cdf0e10cSrcweir pShape->bSelectable = sal_True; 1092*cdf0e10cSrcweir } 1093*cdf0e10cSrcweir } 1094*cdf0e10cSrcweir 1095*cdf0e10cSrcweir 1096*cdf0e10cSrcweir if (!xSelectionSupplier.is()) 1097*cdf0e10cSrcweir throw uno::RuntimeException(); 1098*cdf0e10cSrcweir 1099*cdf0e10cSrcweir uno::Reference<container::XEnumerationAccess> xEnumAcc(xSelectionSupplier->getSelection(), uno::UNO_QUERY); 1100*cdf0e10cSrcweir if (xEnumAcc.is()) 1101*cdf0e10cSrcweir { 1102*cdf0e10cSrcweir uno::Reference<container::XEnumeration> xEnum = xEnumAcc->createEnumeration(); 1103*cdf0e10cSrcweir if (xEnum.is()) 1104*cdf0e10cSrcweir { 1105*cdf0e10cSrcweir uno::Reference<drawing::XShape> xSelectedShape; 1106*cdf0e10cSrcweir sal_Bool bFound(sal_False); 1107*cdf0e10cSrcweir while (!bFound && xEnum->hasMoreElements()) 1108*cdf0e10cSrcweir { 1109*cdf0e10cSrcweir xEnum->nextElement() >>= xSelectedShape; 1110*cdf0e10cSrcweir if (xShape.is() && (xShape.get() == xSelectedShape.get())) 1111*cdf0e10cSrcweir { 1112*cdf0e10cSrcweir pShape->bSelected = sal_True; 1113*cdf0e10cSrcweir bFound = sal_True; 1114*cdf0e10cSrcweir } 1115*cdf0e10cSrcweir } 1116*cdf0e10cSrcweir } 1117*cdf0e10cSrcweir } 1118*cdf0e10cSrcweir if (mpAccessibleDocument && bCommitChange) 1119*cdf0e10cSrcweir { 1120*cdf0e10cSrcweir AccessibleEventObject aEvent; 1121*cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD; 1122*cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument); 1123*cdf0e10cSrcweir aEvent.NewValue <<= Get(aNewItr - maZOrderedShapes.begin()); 1124*cdf0e10cSrcweir 1125*cdf0e10cSrcweir mpAccessibleDocument->CommitChange(aEvent); // new child - event 1126*cdf0e10cSrcweir } 1127*cdf0e10cSrcweir } 1128*cdf0e10cSrcweir else 1129*cdf0e10cSrcweir { 1130*cdf0e10cSrcweir DBG_ERRORFILE("shape is always in the list"); 1131*cdf0e10cSrcweir } 1132*cdf0e10cSrcweir } 1133*cdf0e10cSrcweir 1134*cdf0e10cSrcweir void ScChildrenShapes::RemoveShape(const uno::Reference<drawing::XShape>& xShape) const 1135*cdf0e10cSrcweir { 1136*cdf0e10cSrcweir SortedShapes::iterator aItr; 1137*cdf0e10cSrcweir if (FindShape(xShape, aItr)) 1138*cdf0e10cSrcweir { 1139*cdf0e10cSrcweir if (mpAccessibleDocument) 1140*cdf0e10cSrcweir { 1141*cdf0e10cSrcweir uno::Reference<XAccessible> xOldAccessible (Get(aItr - maZOrderedShapes.begin())); 1142*cdf0e10cSrcweir 1143*cdf0e10cSrcweir delete *aItr; 1144*cdf0e10cSrcweir maZOrderedShapes.erase(aItr); 1145*cdf0e10cSrcweir 1146*cdf0e10cSrcweir AccessibleEventObject aEvent; 1147*cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD; 1148*cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument); 1149*cdf0e10cSrcweir aEvent.OldValue <<= uno::makeAny(xOldAccessible); 1150*cdf0e10cSrcweir 1151*cdf0e10cSrcweir mpAccessibleDocument->CommitChange(aEvent); // child is gone - event 1152*cdf0e10cSrcweir } 1153*cdf0e10cSrcweir else 1154*cdf0e10cSrcweir { 1155*cdf0e10cSrcweir delete *aItr; 1156*cdf0e10cSrcweir maZOrderedShapes.erase(aItr); 1157*cdf0e10cSrcweir } 1158*cdf0e10cSrcweir } 1159*cdf0e10cSrcweir else 1160*cdf0e10cSrcweir { 1161*cdf0e10cSrcweir DBG_ERRORFILE("shape was not in internal list"); 1162*cdf0e10cSrcweir } 1163*cdf0e10cSrcweir } 1164*cdf0e10cSrcweir 1165*cdf0e10cSrcweir sal_Bool ScChildrenShapes::FindShape(const uno::Reference<drawing::XShape>& xShape, ScChildrenShapes::SortedShapes::iterator& rItr) const 1166*cdf0e10cSrcweir { 1167*cdf0e10cSrcweir sal_Bool bResult(sal_False); 1168*cdf0e10cSrcweir ScAccessibleShapeData aShape; 1169*cdf0e10cSrcweir aShape.xShape = xShape; 1170*cdf0e10cSrcweir ScShapeDataLess aLess; 1171*cdf0e10cSrcweir rItr = std::lower_bound(maZOrderedShapes.begin(), maZOrderedShapes.end(), &aShape, aLess); 1172*cdf0e10cSrcweir if ((rItr != maZOrderedShapes.end()) && (*rItr != NULL) && ((*rItr)->xShape.get() == xShape.get())) 1173*cdf0e10cSrcweir bResult = sal_True; // if the shape is found 1174*cdf0e10cSrcweir 1175*cdf0e10cSrcweir #ifdef DBG_UTIL // test whether it finds truly the correct shape (perhaps it is not really sorted) 1176*cdf0e10cSrcweir SortedShapes::iterator aDebugItr = maZOrderedShapes.begin(); 1177*cdf0e10cSrcweir SortedShapes::iterator aEndItr = maZOrderedShapes.end(); 1178*cdf0e10cSrcweir sal_Bool bFound(sal_False); 1179*cdf0e10cSrcweir while (!bFound && aDebugItr != aEndItr) 1180*cdf0e10cSrcweir { 1181*cdf0e10cSrcweir if (*aDebugItr && ((*aDebugItr)->xShape.get() == xShape.get())) 1182*cdf0e10cSrcweir bFound = sal_True; 1183*cdf0e10cSrcweir else 1184*cdf0e10cSrcweir ++aDebugItr; 1185*cdf0e10cSrcweir } 1186*cdf0e10cSrcweir sal_Bool bResult2 = (aDebugItr != maZOrderedShapes.end()); 1187*cdf0e10cSrcweir DBG_ASSERT((bResult == bResult2) && ((bResult && (rItr == aDebugItr)) || !bResult), "wrong Shape found"); 1188*cdf0e10cSrcweir #endif 1189*cdf0e10cSrcweir return bResult; 1190*cdf0e10cSrcweir } 1191*cdf0e10cSrcweir 1192*cdf0e10cSrcweir sal_Int8 ScChildrenShapes::Compare(const ScAccessibleShapeData* pData1, 1193*cdf0e10cSrcweir const ScAccessibleShapeData* pData2) const 1194*cdf0e10cSrcweir { 1195*cdf0e10cSrcweir ScShapeDataLess aLess; 1196*cdf0e10cSrcweir 1197*cdf0e10cSrcweir sal_Bool bResult1(aLess(pData1, pData2)); 1198*cdf0e10cSrcweir sal_Bool bResult2(aLess(pData2, pData1)); 1199*cdf0e10cSrcweir 1200*cdf0e10cSrcweir sal_Int8 nResult(0); 1201*cdf0e10cSrcweir if (!bResult1 && bResult2) 1202*cdf0e10cSrcweir nResult = 1; 1203*cdf0e10cSrcweir else if (bResult1 && !bResult2) 1204*cdf0e10cSrcweir nResult = -1; 1205*cdf0e10cSrcweir 1206*cdf0e10cSrcweir return nResult; 1207*cdf0e10cSrcweir } 1208*cdf0e10cSrcweir 1209*cdf0e10cSrcweir struct ScVisAreaChanged 1210*cdf0e10cSrcweir { 1211*cdf0e10cSrcweir ScAccessibleDocument* mpAccDoc; 1212*cdf0e10cSrcweir ScVisAreaChanged(ScAccessibleDocument* pAccDoc) : mpAccDoc(pAccDoc) {} 1213*cdf0e10cSrcweir void operator() (const ScAccessibleShapeData* pAccShapeData) const 1214*cdf0e10cSrcweir { 1215*cdf0e10cSrcweir if (pAccShapeData && pAccShapeData->pAccShape) 1216*cdf0e10cSrcweir { 1217*cdf0e10cSrcweir pAccShapeData->pAccShape->ViewForwarderChanged(::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA, mpAccDoc); 1218*cdf0e10cSrcweir } 1219*cdf0e10cSrcweir } 1220*cdf0e10cSrcweir }; 1221*cdf0e10cSrcweir 1222*cdf0e10cSrcweir void ScChildrenShapes::VisAreaChanged() const 1223*cdf0e10cSrcweir { 1224*cdf0e10cSrcweir ScVisAreaChanged aVisAreaChanged(mpAccessibleDocument); 1225*cdf0e10cSrcweir std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), aVisAreaChanged); 1226*cdf0e10cSrcweir } 1227*cdf0e10cSrcweir 1228*cdf0e10cSrcweir // ============================================================================ 1229*cdf0e10cSrcweir 1230*cdf0e10cSrcweir ScAccessibleDocument::ScAccessibleDocument( 1231*cdf0e10cSrcweir const uno::Reference<XAccessible>& rxParent, 1232*cdf0e10cSrcweir ScTabViewShell* pViewShell, 1233*cdf0e10cSrcweir ScSplitPos eSplitPos) 1234*cdf0e10cSrcweir : ScAccessibleDocumentBase(rxParent), 1235*cdf0e10cSrcweir mpViewShell(pViewShell), 1236*cdf0e10cSrcweir meSplitPos(eSplitPos), 1237*cdf0e10cSrcweir mpAccessibleSpreadsheet(NULL), 1238*cdf0e10cSrcweir mpChildrenShapes(NULL), 1239*cdf0e10cSrcweir mpTempAccEdit(NULL), 1240*cdf0e10cSrcweir mbCompleteSheetSelected(sal_False) 1241*cdf0e10cSrcweir { 1242*cdf0e10cSrcweir if (pViewShell) 1243*cdf0e10cSrcweir { 1244*cdf0e10cSrcweir pViewShell->AddAccessibilityObject(*this); 1245*cdf0e10cSrcweir Window *pWin = pViewShell->GetWindowByPos(eSplitPos); 1246*cdf0e10cSrcweir if( pWin ) 1247*cdf0e10cSrcweir { 1248*cdf0e10cSrcweir pWin->AddChildEventListener( LINK( this, ScAccessibleDocument, WindowChildEventListener )); 1249*cdf0e10cSrcweir sal_uInt16 nCount = pWin->GetChildCount(); 1250*cdf0e10cSrcweir for( sal_uInt16 i=0; i < nCount; ++i ) 1251*cdf0e10cSrcweir { 1252*cdf0e10cSrcweir Window *pChildWin = pWin->GetChild( i ); 1253*cdf0e10cSrcweir if( pChildWin && 1254*cdf0e10cSrcweir AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() ) 1255*cdf0e10cSrcweir AddChild( pChildWin->GetAccessible(), sal_False ); 1256*cdf0e10cSrcweir } 1257*cdf0e10cSrcweir } 1258*cdf0e10cSrcweir if (pViewShell->GetViewData()->HasEditView( eSplitPos )) 1259*cdf0e10cSrcweir { 1260*cdf0e10cSrcweir uno::Reference<XAccessible> xAcc = new ScAccessibleEditObject(this, pViewShell->GetViewData()->GetEditView(eSplitPos), 1261*cdf0e10cSrcweir pViewShell->GetWindowByPos(eSplitPos), GetCurrentCellName(), GetCurrentCellDescription(), 1262*cdf0e10cSrcweir CellInEditMode); 1263*cdf0e10cSrcweir AddChild(xAcc, sal_False); 1264*cdf0e10cSrcweir } 1265*cdf0e10cSrcweir } 1266*cdf0e10cSrcweir maVisArea = GetVisibleArea_Impl(); 1267*cdf0e10cSrcweir } 1268*cdf0e10cSrcweir 1269*cdf0e10cSrcweir void ScAccessibleDocument::Init() 1270*cdf0e10cSrcweir { 1271*cdf0e10cSrcweir if(!mpChildrenShapes) 1272*cdf0e10cSrcweir mpChildrenShapes = new ScChildrenShapes(this, mpViewShell, meSplitPos); 1273*cdf0e10cSrcweir } 1274*cdf0e10cSrcweir 1275*cdf0e10cSrcweir ScAccessibleDocument::~ScAccessibleDocument(void) 1276*cdf0e10cSrcweir { 1277*cdf0e10cSrcweir if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose) 1278*cdf0e10cSrcweir { 1279*cdf0e10cSrcweir // increment refcount to prevent double call off dtor 1280*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 1281*cdf0e10cSrcweir dispose(); 1282*cdf0e10cSrcweir } 1283*cdf0e10cSrcweir } 1284*cdf0e10cSrcweir 1285*cdf0e10cSrcweir void SAL_CALL ScAccessibleDocument::disposing() 1286*cdf0e10cSrcweir { 1287*cdf0e10cSrcweir ScUnoGuard aGuard; 1288*cdf0e10cSrcweir FreeAccessibleSpreadsheet(); 1289*cdf0e10cSrcweir if (mpViewShell) 1290*cdf0e10cSrcweir { 1291*cdf0e10cSrcweir Window *pWin = mpViewShell->GetWindowByPos(meSplitPos); 1292*cdf0e10cSrcweir if( pWin ) 1293*cdf0e10cSrcweir pWin->RemoveChildEventListener( LINK( this, ScAccessibleDocument, WindowChildEventListener )); 1294*cdf0e10cSrcweir 1295*cdf0e10cSrcweir mpViewShell->RemoveAccessibilityObject(*this); 1296*cdf0e10cSrcweir mpViewShell = NULL; 1297*cdf0e10cSrcweir } 1298*cdf0e10cSrcweir if (mpChildrenShapes) 1299*cdf0e10cSrcweir DELETEZ(mpChildrenShapes); 1300*cdf0e10cSrcweir 1301*cdf0e10cSrcweir ScAccessibleDocumentBase::disposing(); 1302*cdf0e10cSrcweir } 1303*cdf0e10cSrcweir 1304*cdf0e10cSrcweir void SAL_CALL ScAccessibleDocument::disposing( const lang::EventObject& /* Source */ ) 1305*cdf0e10cSrcweir throw (uno::RuntimeException) 1306*cdf0e10cSrcweir { 1307*cdf0e10cSrcweir disposing(); 1308*cdf0e10cSrcweir } 1309*cdf0e10cSrcweir 1310*cdf0e10cSrcweir //===== SfxListener ===================================================== 1311*cdf0e10cSrcweir 1312*cdf0e10cSrcweir IMPL_LINK( ScAccessibleDocument, WindowChildEventListener, VclSimpleEvent*, pEvent ) 1313*cdf0e10cSrcweir { 1314*cdf0e10cSrcweir DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" ); 1315*cdf0e10cSrcweir if ( pEvent && pEvent->ISA( VclWindowEvent ) ) 1316*cdf0e10cSrcweir { 1317*cdf0e10cSrcweir VclWindowEvent *pVclEvent = static_cast< VclWindowEvent * >( pEvent ); 1318*cdf0e10cSrcweir DBG_ASSERT( pVclEvent->GetWindow(), "Window???" ); 1319*cdf0e10cSrcweir switch ( pVclEvent->GetId() ) 1320*cdf0e10cSrcweir { 1321*cdf0e10cSrcweir case VCLEVENT_WINDOW_SHOW: // send create on show for direct accessible children 1322*cdf0e10cSrcweir { 1323*cdf0e10cSrcweir Window* pChildWin = static_cast < Window * >( pVclEvent->GetData() ); 1324*cdf0e10cSrcweir if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() ) 1325*cdf0e10cSrcweir { 1326*cdf0e10cSrcweir AddChild( pChildWin->GetAccessible(), sal_True ); 1327*cdf0e10cSrcweir } 1328*cdf0e10cSrcweir } 1329*cdf0e10cSrcweir break; 1330*cdf0e10cSrcweir case VCLEVENT_WINDOW_HIDE: // send destroy on hide for direct accessible children 1331*cdf0e10cSrcweir { 1332*cdf0e10cSrcweir Window* pChildWin = static_cast < Window * >( pVclEvent->GetData() ); 1333*cdf0e10cSrcweir if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() ) 1334*cdf0e10cSrcweir { 1335*cdf0e10cSrcweir RemoveChild( pChildWin->GetAccessible(), sal_True ); 1336*cdf0e10cSrcweir } 1337*cdf0e10cSrcweir } 1338*cdf0e10cSrcweir break; 1339*cdf0e10cSrcweir } 1340*cdf0e10cSrcweir } 1341*cdf0e10cSrcweir return 0; 1342*cdf0e10cSrcweir } 1343*cdf0e10cSrcweir 1344*cdf0e10cSrcweir void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 1345*cdf0e10cSrcweir { 1346*cdf0e10cSrcweir if (rHint.ISA( ScAccGridWinFocusLostHint ) ) 1347*cdf0e10cSrcweir { 1348*cdf0e10cSrcweir const ScAccGridWinFocusLostHint& rRef = (const ScAccGridWinFocusLostHint&)rHint; 1349*cdf0e10cSrcweir if (rRef.GetOldGridWin() == meSplitPos) 1350*cdf0e10cSrcweir { 1351*cdf0e10cSrcweir if (mxTempAcc.is() && mpTempAccEdit) 1352*cdf0e10cSrcweir mpTempAccEdit->LostFocus(); 1353*cdf0e10cSrcweir else if (mpAccessibleSpreadsheet) 1354*cdf0e10cSrcweir mpAccessibleSpreadsheet->LostFocus(); 1355*cdf0e10cSrcweir else 1356*cdf0e10cSrcweir CommitFocusLost(); 1357*cdf0e10cSrcweir } 1358*cdf0e10cSrcweir } 1359*cdf0e10cSrcweir else if (rHint.ISA( ScAccGridWinFocusGotHint ) ) 1360*cdf0e10cSrcweir { 1361*cdf0e10cSrcweir const ScAccGridWinFocusGotHint& rRef = (const ScAccGridWinFocusGotHint&)rHint; 1362*cdf0e10cSrcweir if (rRef.GetNewGridWin() == meSplitPos) 1363*cdf0e10cSrcweir { 1364*cdf0e10cSrcweir if (mxTempAcc.is() && mpTempAccEdit) 1365*cdf0e10cSrcweir mpTempAccEdit->GotFocus(); 1366*cdf0e10cSrcweir else if (mpAccessibleSpreadsheet) 1367*cdf0e10cSrcweir mpAccessibleSpreadsheet->GotFocus(); 1368*cdf0e10cSrcweir else 1369*cdf0e10cSrcweir CommitFocusGained(); 1370*cdf0e10cSrcweir } 1371*cdf0e10cSrcweir } 1372*cdf0e10cSrcweir else if (rHint.ISA( SfxSimpleHint )) 1373*cdf0e10cSrcweir { 1374*cdf0e10cSrcweir const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint; 1375*cdf0e10cSrcweir // only notify if child exist, otherwise it is not necessary 1376*cdf0e10cSrcweir if ((rRef.GetId() == SC_HINT_ACC_TABLECHANGED) && 1377*cdf0e10cSrcweir mpAccessibleSpreadsheet) 1378*cdf0e10cSrcweir { 1379*cdf0e10cSrcweir FreeAccessibleSpreadsheet(); 1380*cdf0e10cSrcweir if (mpChildrenShapes) 1381*cdf0e10cSrcweir DELETEZ(mpChildrenShapes); 1382*cdf0e10cSrcweir 1383*cdf0e10cSrcweir // #124567# Accessibility: Shapes / form controls after reload not accessible 1384*cdf0e10cSrcweir if ( !mpChildrenShapes ) 1385*cdf0e10cSrcweir { 1386*cdf0e10cSrcweir mpChildrenShapes = new ScChildrenShapes( this, mpViewShell, meSplitPos ); 1387*cdf0e10cSrcweir } 1388*cdf0e10cSrcweir 1389*cdf0e10cSrcweir AccessibleEventObject aEvent; 1390*cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::INVALIDATE_ALL_CHILDREN; 1391*cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 1392*cdf0e10cSrcweir CommitChange(aEvent); // all childs changed 1393*cdf0e10cSrcweir } 1394*cdf0e10cSrcweir else if (rRef.GetId() == SC_HINT_ACC_MAKEDRAWLAYER) 1395*cdf0e10cSrcweir { 1396*cdf0e10cSrcweir if (mpChildrenShapes) 1397*cdf0e10cSrcweir mpChildrenShapes->SetDrawBroadcaster(); 1398*cdf0e10cSrcweir } 1399*cdf0e10cSrcweir else if ((rRef.GetId() == SC_HINT_ACC_ENTEREDITMODE)) // this event comes only on creating edit field of a cell 1400*cdf0e10cSrcweir { 1401*cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData()->HasEditView(meSplitPos)) 1402*cdf0e10cSrcweir { 1403*cdf0e10cSrcweir mpTempAccEdit = new ScAccessibleEditObject(this, mpViewShell->GetViewData()->GetEditView(meSplitPos), 1404*cdf0e10cSrcweir mpViewShell->GetWindowByPos(meSplitPos), GetCurrentCellName(), 1405*cdf0e10cSrcweir rtl::OUString(String(ScResId(STR_ACC_EDITLINE_DESCR))), CellInEditMode); 1406*cdf0e10cSrcweir uno::Reference<XAccessible> xAcc = mpTempAccEdit; 1407*cdf0e10cSrcweir 1408*cdf0e10cSrcweir AddChild(xAcc, sal_True); 1409*cdf0e10cSrcweir 1410*cdf0e10cSrcweir if (mpAccessibleSpreadsheet) 1411*cdf0e10cSrcweir mpAccessibleSpreadsheet->LostFocus(); 1412*cdf0e10cSrcweir else 1413*cdf0e10cSrcweir CommitFocusLost(); 1414*cdf0e10cSrcweir 1415*cdf0e10cSrcweir mpTempAccEdit->GotFocus(); 1416*cdf0e10cSrcweir } 1417*cdf0e10cSrcweir } 1418*cdf0e10cSrcweir else if (rRef.GetId() == SC_HINT_ACC_LEAVEEDITMODE) 1419*cdf0e10cSrcweir { 1420*cdf0e10cSrcweir if (mxTempAcc.is()) 1421*cdf0e10cSrcweir { 1422*cdf0e10cSrcweir if (mpTempAccEdit) 1423*cdf0e10cSrcweir mpTempAccEdit->LostFocus(); 1424*cdf0e10cSrcweir 1425*cdf0e10cSrcweir mpTempAccEdit = NULL; 1426*cdf0e10cSrcweir RemoveChild(mxTempAcc, sal_True); 1427*cdf0e10cSrcweir 1428*cdf0e10cSrcweir if (mpAccessibleSpreadsheet) 1429*cdf0e10cSrcweir mpAccessibleSpreadsheet->GotFocus(); 1430*cdf0e10cSrcweir else 1431*cdf0e10cSrcweir CommitFocusGained(); 1432*cdf0e10cSrcweir } 1433*cdf0e10cSrcweir } 1434*cdf0e10cSrcweir else if ((rRef.GetId() == SC_HINT_ACC_VISAREACHANGED) || (rRef.GetId() == SC_HINT_ACC_WINDOWRESIZED)) 1435*cdf0e10cSrcweir { 1436*cdf0e10cSrcweir Rectangle aOldVisArea(maVisArea); 1437*cdf0e10cSrcweir maVisArea = GetVisibleArea_Impl(); 1438*cdf0e10cSrcweir 1439*cdf0e10cSrcweir if (maVisArea != aOldVisArea) 1440*cdf0e10cSrcweir { 1441*cdf0e10cSrcweir if (maVisArea.GetSize() != aOldVisArea.GetSize()) 1442*cdf0e10cSrcweir { 1443*cdf0e10cSrcweir AccessibleEventObject aEvent; 1444*cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED; 1445*cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 1446*cdf0e10cSrcweir 1447*cdf0e10cSrcweir CommitChange(aEvent); 1448*cdf0e10cSrcweir 1449*cdf0e10cSrcweir if (mpAccessibleSpreadsheet) 1450*cdf0e10cSrcweir mpAccessibleSpreadsheet->BoundingBoxChanged(); 1451*cdf0e10cSrcweir } 1452*cdf0e10cSrcweir else if (mpAccessibleSpreadsheet) 1453*cdf0e10cSrcweir { 1454*cdf0e10cSrcweir mpAccessibleSpreadsheet->VisAreaChanged(); 1455*cdf0e10cSrcweir } 1456*cdf0e10cSrcweir if (mpChildrenShapes) 1457*cdf0e10cSrcweir mpChildrenShapes->VisAreaChanged(); 1458*cdf0e10cSrcweir } 1459*cdf0e10cSrcweir } 1460*cdf0e10cSrcweir } 1461*cdf0e10cSrcweir 1462*cdf0e10cSrcweir ScAccessibleDocumentBase::Notify(rBC, rHint); 1463*cdf0e10cSrcweir } 1464*cdf0e10cSrcweir 1465*cdf0e10cSrcweir void SAL_CALL ScAccessibleDocument::selectionChanged( const lang::EventObject& /* aEvent */ ) 1466*cdf0e10cSrcweir throw (uno::RuntimeException) 1467*cdf0e10cSrcweir { 1468*cdf0e10cSrcweir sal_Bool bSelectionChanged(sal_False); 1469*cdf0e10cSrcweir if (mpAccessibleSpreadsheet) 1470*cdf0e10cSrcweir { 1471*cdf0e10cSrcweir sal_Bool bOldSelected(mbCompleteSheetSelected); 1472*cdf0e10cSrcweir mbCompleteSheetSelected = IsTableSelected(); 1473*cdf0e10cSrcweir if (bOldSelected != mbCompleteSheetSelected) 1474*cdf0e10cSrcweir { 1475*cdf0e10cSrcweir mpAccessibleSpreadsheet->CompleteSelectionChanged(mbCompleteSheetSelected); 1476*cdf0e10cSrcweir bSelectionChanged = sal_True; 1477*cdf0e10cSrcweir } 1478*cdf0e10cSrcweir } 1479*cdf0e10cSrcweir 1480*cdf0e10cSrcweir if (mpChildrenShapes && mpChildrenShapes->SelectionChanged()) 1481*cdf0e10cSrcweir bSelectionChanged = sal_True; 1482*cdf0e10cSrcweir 1483*cdf0e10cSrcweir if (bSelectionChanged) 1484*cdf0e10cSrcweir { 1485*cdf0e10cSrcweir AccessibleEventObject aEvent; 1486*cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; 1487*cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 1488*cdf0e10cSrcweir 1489*cdf0e10cSrcweir CommitChange(aEvent); 1490*cdf0e10cSrcweir } 1491*cdf0e10cSrcweir } 1492*cdf0e10cSrcweir 1493*cdf0e10cSrcweir //===== XInterface ===================================================== 1494*cdf0e10cSrcweir 1495*cdf0e10cSrcweir uno::Any SAL_CALL ScAccessibleDocument::queryInterface( uno::Type const & rType ) 1496*cdf0e10cSrcweir throw (uno::RuntimeException) 1497*cdf0e10cSrcweir { 1498*cdf0e10cSrcweir uno::Any aAny (ScAccessibleDocumentImpl::queryInterface(rType)); 1499*cdf0e10cSrcweir return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType); 1500*cdf0e10cSrcweir } 1501*cdf0e10cSrcweir 1502*cdf0e10cSrcweir void SAL_CALL ScAccessibleDocument::acquire() 1503*cdf0e10cSrcweir throw () 1504*cdf0e10cSrcweir { 1505*cdf0e10cSrcweir ScAccessibleContextBase::acquire(); 1506*cdf0e10cSrcweir } 1507*cdf0e10cSrcweir 1508*cdf0e10cSrcweir void SAL_CALL ScAccessibleDocument::release() 1509*cdf0e10cSrcweir throw () 1510*cdf0e10cSrcweir { 1511*cdf0e10cSrcweir ScAccessibleContextBase::release(); 1512*cdf0e10cSrcweir } 1513*cdf0e10cSrcweir 1514*cdf0e10cSrcweir //===== XAccessibleComponent ============================================ 1515*cdf0e10cSrcweir 1516*cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleDocument::getAccessibleAtPoint( 1517*cdf0e10cSrcweir const awt::Point& rPoint ) 1518*cdf0e10cSrcweir throw (uno::RuntimeException) 1519*cdf0e10cSrcweir { 1520*cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible = NULL; 1521*cdf0e10cSrcweir if (containsPoint(rPoint)) 1522*cdf0e10cSrcweir { 1523*cdf0e10cSrcweir ScUnoGuard aGuard; 1524*cdf0e10cSrcweir IsObjectValid(); 1525*cdf0e10cSrcweir if (mpChildrenShapes) 1526*cdf0e10cSrcweir xAccessible = mpChildrenShapes->GetAt(rPoint); 1527*cdf0e10cSrcweir if(!xAccessible.is()) 1528*cdf0e10cSrcweir { 1529*cdf0e10cSrcweir if (mxTempAcc.is()) 1530*cdf0e10cSrcweir { 1531*cdf0e10cSrcweir uno::Reference< XAccessibleContext > xCont(mxTempAcc->getAccessibleContext()); 1532*cdf0e10cSrcweir uno::Reference< XAccessibleComponent > xComp(xCont, uno::UNO_QUERY); 1533*cdf0e10cSrcweir if (xComp.is()) 1534*cdf0e10cSrcweir { 1535*cdf0e10cSrcweir Rectangle aBound(VCLRectangle(xComp->getBounds())); 1536*cdf0e10cSrcweir if (aBound.IsInside(VCLPoint(rPoint))) 1537*cdf0e10cSrcweir xAccessible = mxTempAcc; 1538*cdf0e10cSrcweir } 1539*cdf0e10cSrcweir } 1540*cdf0e10cSrcweir if (!xAccessible.is()) 1541*cdf0e10cSrcweir xAccessible = GetAccessibleSpreadsheet(); 1542*cdf0e10cSrcweir } 1543*cdf0e10cSrcweir } 1544*cdf0e10cSrcweir return xAccessible; 1545*cdf0e10cSrcweir } 1546*cdf0e10cSrcweir 1547*cdf0e10cSrcweir void SAL_CALL ScAccessibleDocument::grabFocus( ) 1548*cdf0e10cSrcweir throw (uno::RuntimeException) 1549*cdf0e10cSrcweir { 1550*cdf0e10cSrcweir ScUnoGuard aGuard; 1551*cdf0e10cSrcweir IsObjectValid(); 1552*cdf0e10cSrcweir if (getAccessibleParent().is()) 1553*cdf0e10cSrcweir { 1554*cdf0e10cSrcweir uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY); 1555*cdf0e10cSrcweir if (xAccessibleComponent.is()) 1556*cdf0e10cSrcweir { 1557*cdf0e10cSrcweir xAccessibleComponent->grabFocus(); 1558*cdf0e10cSrcweir // grab only focus if it does not have the focus and it is not hidden 1559*cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData() && 1560*cdf0e10cSrcweir (mpViewShell->GetViewData()->GetActivePart() != meSplitPos) && 1561*cdf0e10cSrcweir mpViewShell->GetWindowByPos(meSplitPos)->IsVisible()) 1562*cdf0e10cSrcweir { 1563*cdf0e10cSrcweir mpViewShell->ActivatePart(meSplitPos); 1564*cdf0e10cSrcweir } 1565*cdf0e10cSrcweir } 1566*cdf0e10cSrcweir } 1567*cdf0e10cSrcweir } 1568*cdf0e10cSrcweir 1569*cdf0e10cSrcweir //===== XAccessibleContext ============================================== 1570*cdf0e10cSrcweir 1571*cdf0e10cSrcweir /// Return the number of currently visible children. 1572*cdf0e10cSrcweir sal_Int32 SAL_CALL 1573*cdf0e10cSrcweir ScAccessibleDocument::getAccessibleChildCount(void) 1574*cdf0e10cSrcweir throw (uno::RuntimeException) 1575*cdf0e10cSrcweir { 1576*cdf0e10cSrcweir ScUnoGuard aGuard; 1577*cdf0e10cSrcweir IsObjectValid(); 1578*cdf0e10cSrcweir sal_Int32 nCount(1); 1579*cdf0e10cSrcweir if (mpChildrenShapes) 1580*cdf0e10cSrcweir nCount = mpChildrenShapes->GetCount(); // returns the count of the shapes inclusive the table 1581*cdf0e10cSrcweir 1582*cdf0e10cSrcweir if (mxTempAcc.is()) 1583*cdf0e10cSrcweir ++nCount; 1584*cdf0e10cSrcweir 1585*cdf0e10cSrcweir return nCount; 1586*cdf0e10cSrcweir } 1587*cdf0e10cSrcweir 1588*cdf0e10cSrcweir /// Return the specified child or NULL if index is invalid. 1589*cdf0e10cSrcweir uno::Reference<XAccessible> SAL_CALL 1590*cdf0e10cSrcweir ScAccessibleDocument::getAccessibleChild(sal_Int32 nIndex) 1591*cdf0e10cSrcweir throw (uno::RuntimeException, 1592*cdf0e10cSrcweir lang::IndexOutOfBoundsException) 1593*cdf0e10cSrcweir { 1594*cdf0e10cSrcweir ScUnoGuard aGuard; 1595*cdf0e10cSrcweir IsObjectValid(); 1596*cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible; 1597*cdf0e10cSrcweir if (nIndex >= 0) 1598*cdf0e10cSrcweir { 1599*cdf0e10cSrcweir sal_Int32 nCount(1); 1600*cdf0e10cSrcweir if (mpChildrenShapes) 1601*cdf0e10cSrcweir { 1602*cdf0e10cSrcweir xAccessible = mpChildrenShapes->Get(nIndex); // returns NULL if it is the table or out of range 1603*cdf0e10cSrcweir nCount = mpChildrenShapes->GetCount(); //there is always a table 1604*cdf0e10cSrcweir } 1605*cdf0e10cSrcweir if (!xAccessible.is()) 1606*cdf0e10cSrcweir { 1607*cdf0e10cSrcweir if (nIndex < nCount) 1608*cdf0e10cSrcweir xAccessible = GetAccessibleSpreadsheet(); 1609*cdf0e10cSrcweir else if (nIndex == nCount && mxTempAcc.is()) 1610*cdf0e10cSrcweir xAccessible = mxTempAcc; 1611*cdf0e10cSrcweir } 1612*cdf0e10cSrcweir } 1613*cdf0e10cSrcweir 1614*cdf0e10cSrcweir if (!xAccessible.is()) 1615*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1616*cdf0e10cSrcweir 1617*cdf0e10cSrcweir return xAccessible; 1618*cdf0e10cSrcweir } 1619*cdf0e10cSrcweir 1620*cdf0e10cSrcweir /// Return the set of current states. 1621*cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL 1622*cdf0e10cSrcweir ScAccessibleDocument::getAccessibleStateSet(void) 1623*cdf0e10cSrcweir throw (uno::RuntimeException) 1624*cdf0e10cSrcweir { 1625*cdf0e10cSrcweir ScUnoGuard aGuard; 1626*cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> xParentStates; 1627*cdf0e10cSrcweir if (getAccessibleParent().is()) 1628*cdf0e10cSrcweir { 1629*cdf0e10cSrcweir uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); 1630*cdf0e10cSrcweir xParentStates = xParentContext->getAccessibleStateSet(); 1631*cdf0e10cSrcweir } 1632*cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); 1633*cdf0e10cSrcweir if (IsDefunc(xParentStates)) 1634*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::DEFUNC); 1635*cdf0e10cSrcweir else 1636*cdf0e10cSrcweir { 1637*cdf0e10cSrcweir if (IsEditable(xParentStates)) 1638*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::EDITABLE); 1639*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::ENABLED); 1640*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::OPAQUE); 1641*cdf0e10cSrcweir if (isShowing()) 1642*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SHOWING); 1643*cdf0e10cSrcweir if (isVisible()) 1644*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::VISIBLE); 1645*cdf0e10cSrcweir } 1646*cdf0e10cSrcweir return pStateSet; 1647*cdf0e10cSrcweir } 1648*cdf0e10cSrcweir 1649*cdf0e10cSrcweir ///===== XAccessibleSelection =========================================== 1650*cdf0e10cSrcweir 1651*cdf0e10cSrcweir void SAL_CALL 1652*cdf0e10cSrcweir ScAccessibleDocument::selectAccessibleChild( sal_Int32 nChildIndex ) 1653*cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1654*cdf0e10cSrcweir { 1655*cdf0e10cSrcweir ScUnoGuard aGuard; 1656*cdf0e10cSrcweir IsObjectValid(); 1657*cdf0e10cSrcweir 1658*cdf0e10cSrcweir if (mpChildrenShapes) 1659*cdf0e10cSrcweir { 1660*cdf0e10cSrcweir sal_Int32 nCount(mpChildrenShapes->GetCount()); //all shapes and the table 1661*cdf0e10cSrcweir if (mxTempAcc.is()) 1662*cdf0e10cSrcweir ++nCount; 1663*cdf0e10cSrcweir if (nChildIndex < 0 || nChildIndex >= nCount) 1664*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1665*cdf0e10cSrcweir 1666*cdf0e10cSrcweir uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex); 1667*cdf0e10cSrcweir if (xAccessible.is()) 1668*cdf0e10cSrcweir { 1669*cdf0e10cSrcweir sal_Bool bWasTableSelected(IsTableSelected()); 1670*cdf0e10cSrcweir 1671*cdf0e10cSrcweir if (mpChildrenShapes) 1672*cdf0e10cSrcweir mpChildrenShapes->Select(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is to high 1673*cdf0e10cSrcweir 1674*cdf0e10cSrcweir if (bWasTableSelected) 1675*cdf0e10cSrcweir mpViewShell->SelectAll(); 1676*cdf0e10cSrcweir } 1677*cdf0e10cSrcweir else 1678*cdf0e10cSrcweir { 1679*cdf0e10cSrcweir if (mpViewShell) 1680*cdf0e10cSrcweir mpViewShell->SelectAll(); 1681*cdf0e10cSrcweir } 1682*cdf0e10cSrcweir } 1683*cdf0e10cSrcweir } 1684*cdf0e10cSrcweir 1685*cdf0e10cSrcweir sal_Bool SAL_CALL 1686*cdf0e10cSrcweir ScAccessibleDocument::isAccessibleChildSelected( sal_Int32 nChildIndex ) 1687*cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1688*cdf0e10cSrcweir { 1689*cdf0e10cSrcweir ScUnoGuard aGuard; 1690*cdf0e10cSrcweir IsObjectValid(); 1691*cdf0e10cSrcweir sal_Bool bResult(sal_False); 1692*cdf0e10cSrcweir 1693*cdf0e10cSrcweir if (mpChildrenShapes) 1694*cdf0e10cSrcweir { 1695*cdf0e10cSrcweir sal_Int32 nCount(mpChildrenShapes->GetCount()); //all shapes and the table 1696*cdf0e10cSrcweir if (mxTempAcc.is()) 1697*cdf0e10cSrcweir ++nCount; 1698*cdf0e10cSrcweir if (nChildIndex < 0 || nChildIndex >= nCount) 1699*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1700*cdf0e10cSrcweir 1701*cdf0e10cSrcweir uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex); 1702*cdf0e10cSrcweir if (xAccessible.is()) 1703*cdf0e10cSrcweir { 1704*cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape; 1705*cdf0e10cSrcweir bResult = mpChildrenShapes->IsSelected(nChildIndex, xShape); // throws no lang::IndexOutOfBoundsException if Index is to high 1706*cdf0e10cSrcweir } 1707*cdf0e10cSrcweir else 1708*cdf0e10cSrcweir { 1709*cdf0e10cSrcweir if (mxTempAcc.is() && nChildIndex == nCount) 1710*cdf0e10cSrcweir bResult = sal_True; 1711*cdf0e10cSrcweir else 1712*cdf0e10cSrcweir bResult = IsTableSelected(); 1713*cdf0e10cSrcweir } 1714*cdf0e10cSrcweir } 1715*cdf0e10cSrcweir return bResult; 1716*cdf0e10cSrcweir } 1717*cdf0e10cSrcweir 1718*cdf0e10cSrcweir void SAL_CALL 1719*cdf0e10cSrcweir ScAccessibleDocument::clearAccessibleSelection( ) 1720*cdf0e10cSrcweir throw (uno::RuntimeException) 1721*cdf0e10cSrcweir { 1722*cdf0e10cSrcweir ScUnoGuard aGuard; 1723*cdf0e10cSrcweir IsObjectValid(); 1724*cdf0e10cSrcweir 1725*cdf0e10cSrcweir if (mpChildrenShapes) 1726*cdf0e10cSrcweir mpChildrenShapes->DeselectAll(); //deselects all (also the table) 1727*cdf0e10cSrcweir } 1728*cdf0e10cSrcweir 1729*cdf0e10cSrcweir void SAL_CALL 1730*cdf0e10cSrcweir ScAccessibleDocument::selectAllAccessibleChildren( ) 1731*cdf0e10cSrcweir throw (uno::RuntimeException) 1732*cdf0e10cSrcweir { 1733*cdf0e10cSrcweir ScUnoGuard aGuard; 1734*cdf0e10cSrcweir IsObjectValid(); 1735*cdf0e10cSrcweir 1736*cdf0e10cSrcweir if (mpChildrenShapes) 1737*cdf0e10cSrcweir mpChildrenShapes->SelectAll(); 1738*cdf0e10cSrcweir 1739*cdf0e10cSrcweir // select table after shapes, because while selecting shapes the table will be deselected 1740*cdf0e10cSrcweir if (mpViewShell) 1741*cdf0e10cSrcweir { 1742*cdf0e10cSrcweir mpViewShell->SelectAll(); 1743*cdf0e10cSrcweir } 1744*cdf0e10cSrcweir } 1745*cdf0e10cSrcweir 1746*cdf0e10cSrcweir sal_Int32 SAL_CALL 1747*cdf0e10cSrcweir ScAccessibleDocument::getSelectedAccessibleChildCount( ) 1748*cdf0e10cSrcweir throw (uno::RuntimeException) 1749*cdf0e10cSrcweir { 1750*cdf0e10cSrcweir ScUnoGuard aGuard; 1751*cdf0e10cSrcweir IsObjectValid(); 1752*cdf0e10cSrcweir sal_Int32 nCount(0); 1753*cdf0e10cSrcweir 1754*cdf0e10cSrcweir if (mpChildrenShapes) 1755*cdf0e10cSrcweir nCount = mpChildrenShapes->GetSelectedCount(); 1756*cdf0e10cSrcweir 1757*cdf0e10cSrcweir if (IsTableSelected()) 1758*cdf0e10cSrcweir ++nCount; 1759*cdf0e10cSrcweir 1760*cdf0e10cSrcweir if (mxTempAcc.is()) 1761*cdf0e10cSrcweir ++nCount; 1762*cdf0e10cSrcweir 1763*cdf0e10cSrcweir return nCount; 1764*cdf0e10cSrcweir } 1765*cdf0e10cSrcweir 1766*cdf0e10cSrcweir uno::Reference<XAccessible > SAL_CALL 1767*cdf0e10cSrcweir ScAccessibleDocument::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) 1768*cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1769*cdf0e10cSrcweir { 1770*cdf0e10cSrcweir ScUnoGuard aGuard; 1771*cdf0e10cSrcweir IsObjectValid(); 1772*cdf0e10cSrcweir uno::Reference<XAccessible> xAccessible; 1773*cdf0e10cSrcweir if (mpChildrenShapes) 1774*cdf0e10cSrcweir { 1775*cdf0e10cSrcweir sal_Int32 nCount(getSelectedAccessibleChildCount()); //all shapes and the table 1776*cdf0e10cSrcweir if (nSelectedChildIndex < 0 || nSelectedChildIndex >= nCount) 1777*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1778*cdf0e10cSrcweir 1779*cdf0e10cSrcweir sal_Bool bTabMarked(IsTableSelected()); 1780*cdf0e10cSrcweir 1781*cdf0e10cSrcweir if (mpChildrenShapes) 1782*cdf0e10cSrcweir xAccessible = mpChildrenShapes->GetSelected(nSelectedChildIndex, bTabMarked); // throws no lang::IndexOutOfBoundsException if Index is to high 1783*cdf0e10cSrcweir if (mxTempAcc.is() && nSelectedChildIndex == nCount - 1) 1784*cdf0e10cSrcweir xAccessible = mxTempAcc; 1785*cdf0e10cSrcweir else if (bTabMarked) 1786*cdf0e10cSrcweir xAccessible = GetAccessibleSpreadsheet(); 1787*cdf0e10cSrcweir } 1788*cdf0e10cSrcweir 1789*cdf0e10cSrcweir DBG_ASSERT(xAccessible.is(), "here should always be an accessible object or a exception throwed"); 1790*cdf0e10cSrcweir 1791*cdf0e10cSrcweir return xAccessible; 1792*cdf0e10cSrcweir } 1793*cdf0e10cSrcweir 1794*cdf0e10cSrcweir void SAL_CALL 1795*cdf0e10cSrcweir ScAccessibleDocument::deselectAccessibleChild( sal_Int32 nChildIndex ) 1796*cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1797*cdf0e10cSrcweir { 1798*cdf0e10cSrcweir ScUnoGuard aGuard; 1799*cdf0e10cSrcweir IsObjectValid(); 1800*cdf0e10cSrcweir 1801*cdf0e10cSrcweir if (mpChildrenShapes) 1802*cdf0e10cSrcweir { 1803*cdf0e10cSrcweir sal_Int32 nCount(mpChildrenShapes->GetCount()); //all shapes and the table 1804*cdf0e10cSrcweir if (mxTempAcc.is()) 1805*cdf0e10cSrcweir ++nCount; 1806*cdf0e10cSrcweir if (nChildIndex < 0 || nChildIndex >= nCount) 1807*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 1808*cdf0e10cSrcweir 1809*cdf0e10cSrcweir sal_Bool bTabMarked(IsTableSelected()); 1810*cdf0e10cSrcweir 1811*cdf0e10cSrcweir uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex); 1812*cdf0e10cSrcweir if (xAccessible.is()) 1813*cdf0e10cSrcweir { 1814*cdf0e10cSrcweir if (mpChildrenShapes) 1815*cdf0e10cSrcweir mpChildrenShapes->Deselect(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is to high 1816*cdf0e10cSrcweir 1817*cdf0e10cSrcweir if (bTabMarked) 1818*cdf0e10cSrcweir mpViewShell->SelectAll(); // select the table again 1819*cdf0e10cSrcweir } 1820*cdf0e10cSrcweir else if (bTabMarked) 1821*cdf0e10cSrcweir mpViewShell->Unmark(); 1822*cdf0e10cSrcweir } 1823*cdf0e10cSrcweir } 1824*cdf0e10cSrcweir 1825*cdf0e10cSrcweir //===== XServiceInfo ==================================================== 1826*cdf0e10cSrcweir 1827*cdf0e10cSrcweir ::rtl::OUString SAL_CALL 1828*cdf0e10cSrcweir ScAccessibleDocument::getImplementationName(void) 1829*cdf0e10cSrcweir throw (uno::RuntimeException) 1830*cdf0e10cSrcweir { 1831*cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleDocument")); 1832*cdf0e10cSrcweir } 1833*cdf0e10cSrcweir 1834*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> SAL_CALL 1835*cdf0e10cSrcweir ScAccessibleDocument::getSupportedServiceNames(void) 1836*cdf0e10cSrcweir throw (uno::RuntimeException) 1837*cdf0e10cSrcweir { 1838*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames(); 1839*cdf0e10cSrcweir sal_Int32 nOldSize(aSequence.getLength()); 1840*cdf0e10cSrcweir aSequence.realloc(nOldSize + 1); 1841*cdf0e10cSrcweir ::rtl::OUString* pNames = aSequence.getArray(); 1842*cdf0e10cSrcweir 1843*cdf0e10cSrcweir pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.AccessibleSpreadsheetDocumentView")); 1844*cdf0e10cSrcweir 1845*cdf0e10cSrcweir return aSequence; 1846*cdf0e10cSrcweir } 1847*cdf0e10cSrcweir 1848*cdf0e10cSrcweir //===== XTypeProvider ======================================================= 1849*cdf0e10cSrcweir 1850*cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL ScAccessibleDocument::getTypes() 1851*cdf0e10cSrcweir throw (uno::RuntimeException) 1852*cdf0e10cSrcweir { 1853*cdf0e10cSrcweir return comphelper::concatSequences(ScAccessibleDocumentImpl::getTypes(), ScAccessibleContextBase::getTypes()); 1854*cdf0e10cSrcweir } 1855*cdf0e10cSrcweir 1856*cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL 1857*cdf0e10cSrcweir ScAccessibleDocument::getImplementationId(void) 1858*cdf0e10cSrcweir throw (uno::RuntimeException) 1859*cdf0e10cSrcweir { 1860*cdf0e10cSrcweir ScUnoGuard aGuard; 1861*cdf0e10cSrcweir IsObjectValid(); 1862*cdf0e10cSrcweir static uno::Sequence<sal_Int8> aId; 1863*cdf0e10cSrcweir if (aId.getLength() == 0) 1864*cdf0e10cSrcweir { 1865*cdf0e10cSrcweir aId.realloc (16); 1866*cdf0e10cSrcweir rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True); 1867*cdf0e10cSrcweir } 1868*cdf0e10cSrcweir return aId; 1869*cdf0e10cSrcweir } 1870*cdf0e10cSrcweir 1871*cdf0e10cSrcweir ///===== IAccessibleViewForwarder ======================================== 1872*cdf0e10cSrcweir 1873*cdf0e10cSrcweir sal_Bool ScAccessibleDocument::IsValid (void) const 1874*cdf0e10cSrcweir { 1875*cdf0e10cSrcweir ScUnoGuard aGuard; 1876*cdf0e10cSrcweir IsObjectValid(); 1877*cdf0e10cSrcweir return (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose); 1878*cdf0e10cSrcweir } 1879*cdf0e10cSrcweir 1880*cdf0e10cSrcweir Rectangle ScAccessibleDocument::GetVisibleArea_Impl() const 1881*cdf0e10cSrcweir { 1882*cdf0e10cSrcweir Rectangle aVisRect(GetBoundingBox()); 1883*cdf0e10cSrcweir 1884*cdf0e10cSrcweir Point aPoint(mpViewShell->GetViewData()->GetPixPos(meSplitPos)); // returns a negative Point 1885*cdf0e10cSrcweir aPoint.setX(-aPoint.getX()); 1886*cdf0e10cSrcweir aPoint.setY(-aPoint.getY()); 1887*cdf0e10cSrcweir aVisRect.SetPos(aPoint); 1888*cdf0e10cSrcweir 1889*cdf0e10cSrcweir ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos)); 1890*cdf0e10cSrcweir if (pWin) 1891*cdf0e10cSrcweir aVisRect = pWin->PixelToLogic(aVisRect, pWin->GetDrawMapMode()); 1892*cdf0e10cSrcweir 1893*cdf0e10cSrcweir return aVisRect; 1894*cdf0e10cSrcweir } 1895*cdf0e10cSrcweir 1896*cdf0e10cSrcweir Rectangle ScAccessibleDocument::GetVisibleArea() const 1897*cdf0e10cSrcweir { 1898*cdf0e10cSrcweir ScUnoGuard aGuard; 1899*cdf0e10cSrcweir IsObjectValid(); 1900*cdf0e10cSrcweir return maVisArea; 1901*cdf0e10cSrcweir } 1902*cdf0e10cSrcweir 1903*cdf0e10cSrcweir Point ScAccessibleDocument::LogicToPixel (const Point& rPoint) const 1904*cdf0e10cSrcweir { 1905*cdf0e10cSrcweir ScUnoGuard aGuard; 1906*cdf0e10cSrcweir IsObjectValid(); 1907*cdf0e10cSrcweir Point aPoint; 1908*cdf0e10cSrcweir ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos)); 1909*cdf0e10cSrcweir if (pWin) 1910*cdf0e10cSrcweir { 1911*cdf0e10cSrcweir aPoint = pWin->LogicToPixel(rPoint, pWin->GetDrawMapMode()); 1912*cdf0e10cSrcweir aPoint += pWin->GetWindowExtentsRelative(NULL).TopLeft(); 1913*cdf0e10cSrcweir } 1914*cdf0e10cSrcweir return aPoint; 1915*cdf0e10cSrcweir } 1916*cdf0e10cSrcweir 1917*cdf0e10cSrcweir Size ScAccessibleDocument::LogicToPixel (const Size& rSize) const 1918*cdf0e10cSrcweir { 1919*cdf0e10cSrcweir ScUnoGuard aGuard; 1920*cdf0e10cSrcweir IsObjectValid(); 1921*cdf0e10cSrcweir Size aSize; 1922*cdf0e10cSrcweir ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos)); 1923*cdf0e10cSrcweir if (pWin) 1924*cdf0e10cSrcweir aSize = pWin->LogicToPixel(rSize, pWin->GetDrawMapMode()); 1925*cdf0e10cSrcweir return aSize; 1926*cdf0e10cSrcweir } 1927*cdf0e10cSrcweir 1928*cdf0e10cSrcweir Point ScAccessibleDocument::PixelToLogic (const Point& rPoint) const 1929*cdf0e10cSrcweir { 1930*cdf0e10cSrcweir ScUnoGuard aGuard; 1931*cdf0e10cSrcweir IsObjectValid(); 1932*cdf0e10cSrcweir Point aPoint; 1933*cdf0e10cSrcweir ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos)); 1934*cdf0e10cSrcweir if (pWin) 1935*cdf0e10cSrcweir { 1936*cdf0e10cSrcweir aPoint -= pWin->GetWindowExtentsRelative(NULL).TopLeft(); 1937*cdf0e10cSrcweir aPoint = pWin->PixelToLogic(rPoint, pWin->GetDrawMapMode()); 1938*cdf0e10cSrcweir } 1939*cdf0e10cSrcweir return aPoint; 1940*cdf0e10cSrcweir } 1941*cdf0e10cSrcweir 1942*cdf0e10cSrcweir Size ScAccessibleDocument::PixelToLogic (const Size& rSize) const 1943*cdf0e10cSrcweir { 1944*cdf0e10cSrcweir ScUnoGuard aGuard; 1945*cdf0e10cSrcweir IsObjectValid(); 1946*cdf0e10cSrcweir Size aSize; 1947*cdf0e10cSrcweir ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos)); 1948*cdf0e10cSrcweir if (pWin) 1949*cdf0e10cSrcweir aSize = pWin->PixelToLogic(rSize, pWin->GetDrawMapMode()); 1950*cdf0e10cSrcweir return aSize; 1951*cdf0e10cSrcweir } 1952*cdf0e10cSrcweir 1953*cdf0e10cSrcweir //===== internal ======================================================== 1954*cdf0e10cSrcweir 1955*cdf0e10cSrcweir utl::AccessibleRelationSetHelper* ScAccessibleDocument::GetRelationSet(const ScAddress* pAddress) const 1956*cdf0e10cSrcweir { 1957*cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pRelationSet = NULL; 1958*cdf0e10cSrcweir if (mpChildrenShapes) 1959*cdf0e10cSrcweir pRelationSet = mpChildrenShapes->GetRelationSet(pAddress); 1960*cdf0e10cSrcweir return pRelationSet; 1961*cdf0e10cSrcweir } 1962*cdf0e10cSrcweir 1963*cdf0e10cSrcweir ::rtl::OUString SAL_CALL 1964*cdf0e10cSrcweir ScAccessibleDocument::createAccessibleDescription(void) 1965*cdf0e10cSrcweir throw (uno::RuntimeException) 1966*cdf0e10cSrcweir { 1967*cdf0e10cSrcweir rtl::OUString sDescription = String(ScResId(STR_ACC_DOC_DESCR)); 1968*cdf0e10cSrcweir return sDescription; 1969*cdf0e10cSrcweir } 1970*cdf0e10cSrcweir 1971*cdf0e10cSrcweir ::rtl::OUString SAL_CALL 1972*cdf0e10cSrcweir ScAccessibleDocument::createAccessibleName(void) 1973*cdf0e10cSrcweir throw (uno::RuntimeException) 1974*cdf0e10cSrcweir { 1975*cdf0e10cSrcweir ScUnoGuard aGuard; 1976*cdf0e10cSrcweir IsObjectValid(); 1977*cdf0e10cSrcweir rtl::OUString sName = String(ScResId(STR_ACC_DOC_NAME)); 1978*cdf0e10cSrcweir sal_Int32 nNumber(sal_Int32(meSplitPos) + 1); 1979*cdf0e10cSrcweir sName += rtl::OUString::valueOf(nNumber); 1980*cdf0e10cSrcweir return sName; 1981*cdf0e10cSrcweir } 1982*cdf0e10cSrcweir 1983*cdf0e10cSrcweir Rectangle ScAccessibleDocument::GetBoundingBoxOnScreen() const 1984*cdf0e10cSrcweir throw (uno::RuntimeException) 1985*cdf0e10cSrcweir { 1986*cdf0e10cSrcweir Rectangle aRect; 1987*cdf0e10cSrcweir if (mpViewShell) 1988*cdf0e10cSrcweir { 1989*cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos); 1990*cdf0e10cSrcweir if (pWindow) 1991*cdf0e10cSrcweir aRect = pWindow->GetWindowExtentsRelative(NULL); 1992*cdf0e10cSrcweir } 1993*cdf0e10cSrcweir return aRect; 1994*cdf0e10cSrcweir } 1995*cdf0e10cSrcweir 1996*cdf0e10cSrcweir Rectangle ScAccessibleDocument::GetBoundingBox() const 1997*cdf0e10cSrcweir throw (uno::RuntimeException) 1998*cdf0e10cSrcweir { 1999*cdf0e10cSrcweir Rectangle aRect; 2000*cdf0e10cSrcweir if (mpViewShell) 2001*cdf0e10cSrcweir { 2002*cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos); 2003*cdf0e10cSrcweir if (pWindow) 2004*cdf0e10cSrcweir aRect = pWindow->GetWindowExtentsRelative(pWindow->GetAccessibleParentWindow()); 2005*cdf0e10cSrcweir } 2006*cdf0e10cSrcweir return aRect; 2007*cdf0e10cSrcweir } 2008*cdf0e10cSrcweir 2009*cdf0e10cSrcweir SCTAB ScAccessibleDocument::getVisibleTable() const 2010*cdf0e10cSrcweir { 2011*cdf0e10cSrcweir SCTAB nVisibleTable(0); 2012*cdf0e10cSrcweir if (mpViewShell && mpViewShell->GetViewData()) 2013*cdf0e10cSrcweir nVisibleTable = mpViewShell->GetViewData()->GetTabNo(); 2014*cdf0e10cSrcweir return nVisibleTable; 2015*cdf0e10cSrcweir } 2016*cdf0e10cSrcweir 2017*cdf0e10cSrcweir uno::Reference < XAccessible > 2018*cdf0e10cSrcweir ScAccessibleDocument::GetAccessibleSpreadsheet() 2019*cdf0e10cSrcweir { 2020*cdf0e10cSrcweir if (!mpAccessibleSpreadsheet && mpViewShell) 2021*cdf0e10cSrcweir { 2022*cdf0e10cSrcweir mpAccessibleSpreadsheet = new ScAccessibleSpreadsheet(this, mpViewShell, getVisibleTable(), meSplitPos); 2023*cdf0e10cSrcweir mpAccessibleSpreadsheet->acquire(); 2024*cdf0e10cSrcweir mpAccessibleSpreadsheet->Init(); 2025*cdf0e10cSrcweir mbCompleteSheetSelected = IsTableSelected(); 2026*cdf0e10cSrcweir } 2027*cdf0e10cSrcweir return mpAccessibleSpreadsheet; 2028*cdf0e10cSrcweir } 2029*cdf0e10cSrcweir 2030*cdf0e10cSrcweir void ScAccessibleDocument::FreeAccessibleSpreadsheet() 2031*cdf0e10cSrcweir { 2032*cdf0e10cSrcweir if (mpAccessibleSpreadsheet) 2033*cdf0e10cSrcweir { 2034*cdf0e10cSrcweir mpAccessibleSpreadsheet->dispose(); 2035*cdf0e10cSrcweir mpAccessibleSpreadsheet->release(); 2036*cdf0e10cSrcweir mpAccessibleSpreadsheet = NULL; 2037*cdf0e10cSrcweir } 2038*cdf0e10cSrcweir } 2039*cdf0e10cSrcweir 2040*cdf0e10cSrcweir sal_Bool ScAccessibleDocument::IsTableSelected() const 2041*cdf0e10cSrcweir { 2042*cdf0e10cSrcweir sal_Bool bResult (sal_False); 2043*cdf0e10cSrcweir if(mpViewShell) 2044*cdf0e10cSrcweir { 2045*cdf0e10cSrcweir SCTAB nTab(getVisibleTable()); 2046*cdf0e10cSrcweir //#103800#; use a copy of MarkData 2047*cdf0e10cSrcweir ScMarkData aMarkData(mpViewShell->GetViewData()->GetMarkData()); 2048*cdf0e10cSrcweir aMarkData.MarkToMulti(); 2049*cdf0e10cSrcweir if (aMarkData.IsAllMarked(ScRange(ScAddress(0, 0, nTab),ScAddress(MAXCOL, MAXROW, nTab)))) 2050*cdf0e10cSrcweir bResult = sal_True; 2051*cdf0e10cSrcweir } 2052*cdf0e10cSrcweir return bResult; 2053*cdf0e10cSrcweir } 2054*cdf0e10cSrcweir 2055*cdf0e10cSrcweir sal_Bool ScAccessibleDocument::IsDefunc( 2056*cdf0e10cSrcweir const uno::Reference<XAccessibleStateSet>& rxParentStates) 2057*cdf0e10cSrcweir { 2058*cdf0e10cSrcweir return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() || 2059*cdf0e10cSrcweir (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC)); 2060*cdf0e10cSrcweir } 2061*cdf0e10cSrcweir 2062*cdf0e10cSrcweir sal_Bool ScAccessibleDocument::IsEditable( 2063*cdf0e10cSrcweir const uno::Reference<XAccessibleStateSet>& /* rxParentStates */) 2064*cdf0e10cSrcweir { 2065*cdf0e10cSrcweir // what is with document protection or readonly documents? 2066*cdf0e10cSrcweir return sal_True; 2067*cdf0e10cSrcweir } 2068*cdf0e10cSrcweir 2069*cdf0e10cSrcweir void ScAccessibleDocument::AddChild(const uno::Reference<XAccessible>& xAcc, sal_Bool bFireEvent) 2070*cdf0e10cSrcweir { 2071*cdf0e10cSrcweir DBG_ASSERT(!mxTempAcc.is(), "this object should be removed before"); 2072*cdf0e10cSrcweir if (xAcc.is()) 2073*cdf0e10cSrcweir { 2074*cdf0e10cSrcweir mxTempAcc = xAcc; 2075*cdf0e10cSrcweir if( bFireEvent ) 2076*cdf0e10cSrcweir { 2077*cdf0e10cSrcweir AccessibleEventObject aEvent; 2078*cdf0e10cSrcweir aEvent.Source = uno::Reference<XAccessibleContext>(this); 2079*cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD; 2080*cdf0e10cSrcweir aEvent.NewValue <<= mxTempAcc; 2081*cdf0e10cSrcweir CommitChange( aEvent ); 2082*cdf0e10cSrcweir } 2083*cdf0e10cSrcweir } 2084*cdf0e10cSrcweir } 2085*cdf0e10cSrcweir 2086*cdf0e10cSrcweir void ScAccessibleDocument::RemoveChild(const uno::Reference<XAccessible>& xAcc, sal_Bool bFireEvent) 2087*cdf0e10cSrcweir { 2088*cdf0e10cSrcweir DBG_ASSERT(mxTempAcc.is(), "this object should be added before"); 2089*cdf0e10cSrcweir if (xAcc.is()) 2090*cdf0e10cSrcweir { 2091*cdf0e10cSrcweir DBG_ASSERT(xAcc.get() == mxTempAcc.get(), "only the same object should be removed"); 2092*cdf0e10cSrcweir if( bFireEvent ) 2093*cdf0e10cSrcweir { 2094*cdf0e10cSrcweir AccessibleEventObject aEvent; 2095*cdf0e10cSrcweir aEvent.Source = uno::Reference<XAccessibleContext>(this); 2096*cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD; 2097*cdf0e10cSrcweir aEvent.OldValue <<= mxTempAcc; 2098*cdf0e10cSrcweir CommitChange( aEvent ); 2099*cdf0e10cSrcweir } 2100*cdf0e10cSrcweir mxTempAcc = NULL; 2101*cdf0e10cSrcweir } 2102*cdf0e10cSrcweir } 2103*cdf0e10cSrcweir 2104*cdf0e10cSrcweir rtl::OUString ScAccessibleDocument::GetCurrentCellName() const 2105*cdf0e10cSrcweir { 2106*cdf0e10cSrcweir String sName( ScResId(STR_ACC_CELL_NAME) ); 2107*cdf0e10cSrcweir if (mpViewShell) 2108*cdf0e10cSrcweir { 2109*cdf0e10cSrcweir String sAddress; 2110*cdf0e10cSrcweir // Document not needed, because only the cell address, but not the tablename is needed 2111*cdf0e10cSrcweir mpViewShell->GetViewData()->GetCurPos().Format( sAddress, SCA_VALID, NULL ); 2112*cdf0e10cSrcweir sName.SearchAndReplaceAscii("%1", sAddress); 2113*cdf0e10cSrcweir } 2114*cdf0e10cSrcweir return rtl::OUString(sName); 2115*cdf0e10cSrcweir } 2116*cdf0e10cSrcweir 2117*cdf0e10cSrcweir rtl::OUString ScAccessibleDocument::GetCurrentCellDescription() const 2118*cdf0e10cSrcweir { 2119*cdf0e10cSrcweir return rtl::OUString(); 2120*cdf0e10cSrcweir } 2121