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 #include "AccessibleDataPilotControl.hxx" 31*cdf0e10cSrcweir #include "unoguard.hxx" 32*cdf0e10cSrcweir #include "fieldwnd.hxx" 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 39*cdf0e10cSrcweir #include <rtl/uuid.h> 40*cdf0e10cSrcweir #include <tools/gen.hxx> 41*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 42*cdf0e10cSrcweir #include <tools/debug.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir using namespace ::com::sun::star; 45*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir class ScAccessibleDataPilotButton 48*cdf0e10cSrcweir : public ScAccessibleContextBase 49*cdf0e10cSrcweir { 50*cdf0e10cSrcweir public: 51*cdf0e10cSrcweir //===== internal ======================================================== 52*cdf0e10cSrcweir ScAccessibleDataPilotButton( 53*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 54*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& rxParent, 55*cdf0e10cSrcweir ScPivotFieldWindow* pFieldWindow, 56*cdf0e10cSrcweir sal_Int32 nIndex); 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir virtual void Init(); 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir using ScAccessibleContextBase::disposing; 61*cdf0e10cSrcweir virtual void SAL_CALL disposing(); 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir void SetIndex(sal_Int32 nIndex) { mnIndex = nIndex; } 64*cdf0e10cSrcweir void NameChanged(); 65*cdf0e10cSrcweir void SetFocused(); 66*cdf0e10cSrcweir void ResetFocused(); 67*cdf0e10cSrcweir protected: 68*cdf0e10cSrcweir virtual ~ScAccessibleDataPilotButton(void); 69*cdf0e10cSrcweir public: 70*cdf0e10cSrcweir ///===== XAccessibleComponent ============================================ 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 73*cdf0e10cSrcweir SAL_CALL getAccessibleAtPoint( 74*cdf0e10cSrcweir const ::com::sun::star::awt::Point& rPoint ) 75*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir virtual sal_Bool SAL_CALL isVisible( ) 78*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir virtual void SAL_CALL grabFocus( ) 81*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getForeground( ) 84*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getBackground( ) 87*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir ///===== XAccessibleContext ============================================== 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir /// Return the number of currently visible children. 92*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 93*cdf0e10cSrcweir getAccessibleChildCount(void) throw (::com::sun::star::uno::RuntimeException); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir /// Return the specified child or NULL if index is invalid. 96*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL 97*cdf0e10cSrcweir getAccessibleChild(sal_Int32 nIndex) 98*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException, 99*cdf0e10cSrcweir ::com::sun::star::lang::IndexOutOfBoundsException); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir /// Return this objects index among the parents children. 102*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 103*cdf0e10cSrcweir getAccessibleIndexInParent(void) 104*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir /// Return the set of current states. 107*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 108*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL 109*cdf0e10cSrcweir getAccessibleStateSet(void) 110*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir ///===== XServiceInfo ==================================================== 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir /** Returns an identifier for the implementation of this object. 115*cdf0e10cSrcweir */ 116*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 117*cdf0e10cSrcweir getImplementationName(void) 118*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir ///===== XTypeProvider =================================================== 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir /** Returns a implementation id. 123*cdf0e10cSrcweir */ 124*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL 125*cdf0e10cSrcweir getImplementationId(void) 126*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir protected: 129*cdf0e10cSrcweir /// Return this object's description. 130*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 131*cdf0e10cSrcweir createAccessibleDescription(void) 132*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir /// Return the object's current name. 135*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 136*cdf0e10cSrcweir createAccessibleName(void) 137*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir /// Return the object's current bounding box relative to the desktop. 140*cdf0e10cSrcweir virtual Rectangle GetBoundingBoxOnScreen(void) const 141*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir /// Return the object's current bounding box relative to the parent object. 144*cdf0e10cSrcweir virtual Rectangle GetBoundingBox(void) const 145*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir private: 148*cdf0e10cSrcweir ScPivotFieldWindow* mpFieldWindow; 149*cdf0e10cSrcweir sal_Int32 mnIndex; 150*cdf0e10cSrcweir }; 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir //===== internal ======================================================== 153*cdf0e10cSrcweir ScAccessibleDataPilotControl::ScAccessibleDataPilotControl( 154*cdf0e10cSrcweir const uno::Reference<XAccessible>& rxParent, 155*cdf0e10cSrcweir ScPivotFieldWindow* pFieldWindow) 156*cdf0e10cSrcweir : 157*cdf0e10cSrcweir ScAccessibleContextBase(rxParent, AccessibleRole::GROUP_BOX), 158*cdf0e10cSrcweir mpFieldWindow(pFieldWindow) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir if (mpFieldWindow) 161*cdf0e10cSrcweir maChildren.resize(mpFieldWindow->GetFieldCount()); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir ScAccessibleDataPilotControl::~ScAccessibleDataPilotControl(void) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir if (!IsDefunc() && !rBHelper.bInDispose) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir // increment refcount to prevent double call off dtor 169*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 170*cdf0e10cSrcweir // call dispose to inform object wich have a weak reference to this object 171*cdf0e10cSrcweir dispose(); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir void ScAccessibleDataPilotControl::Init() 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir void SAL_CALL ScAccessibleDataPilotControl::disposing() 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir ScUnoGuard aGuard; 182*cdf0e10cSrcweir mpFieldWindow = NULL; 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir ScAccessibleContextBase::disposing(); 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir void ScAccessibleDataPilotControl::AddField(sal_Int32 nNewIndex) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir sal_Bool bAdded(sal_False); 190*cdf0e10cSrcweir if (static_cast<size_t>(nNewIndex) == maChildren.size()) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir maChildren.push_back(AccessibleWeak()); 193*cdf0e10cSrcweir bAdded = sal_True; 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir else if (static_cast<size_t>(nNewIndex) < maChildren.size()) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir ::std::vector < AccessibleWeak >::iterator aItr = maChildren.begin() + nNewIndex; 198*cdf0e10cSrcweir maChildren.insert(aItr, AccessibleWeak()); 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir ::std::vector < AccessibleWeak >::iterator aEndItr = maChildren.end(); 201*cdf0e10cSrcweir aItr = maChildren.begin() + nNewIndex + 1; 202*cdf0e10cSrcweir uno::Reference< XAccessible > xTempAcc; 203*cdf0e10cSrcweir sal_Int32 nIndex = nNewIndex + 1; 204*cdf0e10cSrcweir while (aItr != aEndItr) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir xTempAcc = aItr->xWeakAcc; 207*cdf0e10cSrcweir if (xTempAcc.is() && aItr->pAcc) 208*cdf0e10cSrcweir aItr->pAcc->SetIndex(nIndex); 209*cdf0e10cSrcweir ++nIndex; 210*cdf0e10cSrcweir ++aItr; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir bAdded = sal_True; 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir else 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir DBG_ERRORFILE("did not recognize a child count change"); 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir if (bAdded) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir AccessibleEventObject aEvent; 222*cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD; 223*cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 224*cdf0e10cSrcweir aEvent.NewValue <<= getAccessibleChild(nNewIndex); 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir CommitChange(aEvent); // new child - event 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir void ScAccessibleDataPilotControl::RemoveField(sal_Int32 nOldIndex) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir sal_Bool bRemoved(sal_False); 233*cdf0e10cSrcweir uno::Reference< XAccessible > xTempAcc; 234*cdf0e10cSrcweir ScAccessibleDataPilotButton* pField = NULL; 235*cdf0e10cSrcweir if (static_cast<size_t>(nOldIndex) < maChildren.size()) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir xTempAcc = getAccessibleChild(nOldIndex); 238*cdf0e10cSrcweir pField = maChildren[nOldIndex].pAcc; 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir ::std::vector < AccessibleWeak >::iterator aItr = maChildren.begin() + nOldIndex; 241*cdf0e10cSrcweir aItr = maChildren.erase(aItr); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir ::std::vector < AccessibleWeak >::iterator aEndItr = maChildren.end(); 244*cdf0e10cSrcweir uno::Reference< XAccessible > xItrAcc; 245*cdf0e10cSrcweir while (aItr != aEndItr) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir xItrAcc = aItr->xWeakAcc; 248*cdf0e10cSrcweir if (xItrAcc.is() && aItr->pAcc) 249*cdf0e10cSrcweir aItr->pAcc->SetIndex(nOldIndex); 250*cdf0e10cSrcweir ++nOldIndex; 251*cdf0e10cSrcweir ++aItr; 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir bRemoved = sal_True; 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir else 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir DBG_ERRORFILE("did not recognize a child count change"); 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir if (bRemoved) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir AccessibleEventObject aEvent; 263*cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD; 264*cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 265*cdf0e10cSrcweir aEvent.NewValue <<= xTempAcc; 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir CommitChange(aEvent); // gone child - event 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir if (pField) 270*cdf0e10cSrcweir pField->dispose(); 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir void ScAccessibleDataPilotControl::FieldFocusChange(sal_Int32 nOldIndex, sal_Int32 nNewIndex) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir DBG_ASSERT(static_cast<size_t>(nOldIndex) < maChildren.size() && 277*cdf0e10cSrcweir static_cast<size_t>(nNewIndex) < maChildren.size(), "did not recognize a child count change"); 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir uno::Reference < XAccessible > xTempAcc = maChildren[nOldIndex].xWeakAcc; 280*cdf0e10cSrcweir if (xTempAcc.is() && maChildren[nOldIndex].pAcc) 281*cdf0e10cSrcweir maChildren[nOldIndex].pAcc->ResetFocused(); 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir xTempAcc = maChildren[nNewIndex].xWeakAcc; 284*cdf0e10cSrcweir if (xTempAcc.is() && maChildren[nNewIndex].pAcc) 285*cdf0e10cSrcweir maChildren[nNewIndex].pAcc->SetFocused(); 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir void ScAccessibleDataPilotControl::FieldNameChange(sal_Int32 nIndex) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir DBG_ASSERT(static_cast<size_t>(nIndex) < maChildren.size(), "did not recognize a child count change"); 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc; 293*cdf0e10cSrcweir if (xTempAcc.is() && maChildren[nIndex].pAcc) 294*cdf0e10cSrcweir maChildren[nIndex].pAcc->ChangeName(); 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir void ScAccessibleDataPilotControl::GotFocus() 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir if (mpFieldWindow) 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir DBG_ASSERT(mpFieldWindow->GetFieldCount() == maChildren.size(), "did not recognize a child count change"); 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir sal_Int32 nIndex(mpFieldWindow->GetSelectedIndex()); 304*cdf0e10cSrcweir uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc; 305*cdf0e10cSrcweir if (xTempAcc.is() && maChildren[nIndex].pAcc) 306*cdf0e10cSrcweir maChildren[nIndex].pAcc->SetFocused(); 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir void ScAccessibleDataPilotControl::LostFocus() 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir if (mpFieldWindow) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir DBG_ASSERT(mpFieldWindow->GetFieldCount() == maChildren.size(), "did not recognize a child count change"); 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir sal_Int32 nIndex(mpFieldWindow->GetSelectedIndex()); 317*cdf0e10cSrcweir uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc; 318*cdf0e10cSrcweir if (xTempAcc.is() && maChildren[nIndex].pAcc) 319*cdf0e10cSrcweir maChildren[nIndex].pAcc->ResetFocused(); 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir ///===== XAccessibleComponent ============================================ 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleDataPilotControl::getAccessibleAtPoint( 326*cdf0e10cSrcweir const awt::Point& rPoint ) 327*cdf0e10cSrcweir throw (uno::RuntimeException) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir uno::Reference<XAccessible> xAcc; 330*cdf0e10cSrcweir if (containsPoint(rPoint)) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir ScUnoGuard aGuard; 333*cdf0e10cSrcweir IsObjectValid(); 334*cdf0e10cSrcweir if (mpFieldWindow) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir Point aAbsPoint(VCLPoint(rPoint)); 337*cdf0e10cSrcweir Point aControlEdge(GetBoundingBoxOnScreen().TopLeft()); 338*cdf0e10cSrcweir Point aRelPoint(aAbsPoint - aControlEdge); 339*cdf0e10cSrcweir size_t nChildIndex = mpFieldWindow->GetFieldIndex( aRelPoint ); 340*cdf0e10cSrcweir if( nChildIndex != PIVOTFIELD_INVALID ) 341*cdf0e10cSrcweir xAcc = getAccessibleChild(static_cast< long >( nChildIndex )); 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir return xAcc; 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleDataPilotControl::isVisible( ) 348*cdf0e10cSrcweir throw (uno::RuntimeException) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir return sal_True; 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir void SAL_CALL ScAccessibleDataPilotControl::grabFocus( ) 354*cdf0e10cSrcweir throw (uno::RuntimeException) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir ScUnoGuard aGuard; 357*cdf0e10cSrcweir IsObjectValid(); 358*cdf0e10cSrcweir if (mpFieldWindow) 359*cdf0e10cSrcweir mpFieldWindow->GrabFocus(); 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getForeground( ) 363*cdf0e10cSrcweir throw (uno::RuntimeException) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir ScUnoGuard aGuard; 366*cdf0e10cSrcweir IsObjectValid(); 367*cdf0e10cSrcweir sal_Int32 nColor(0); 368*cdf0e10cSrcweir if (mpFieldWindow) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir nColor = mpFieldWindow->GetSettings().GetStyleSettings().GetWindowTextColor().GetColor(); 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir return nColor; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getBackground( ) 376*cdf0e10cSrcweir throw (uno::RuntimeException) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir ScUnoGuard aGuard; 379*cdf0e10cSrcweir IsObjectValid(); 380*cdf0e10cSrcweir sal_Int32 nColor(0); 381*cdf0e10cSrcweir if (mpFieldWindow) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir const StyleSettings& rStyleSett = mpFieldWindow->GetSettings().GetStyleSettings(); 384*cdf0e10cSrcweir nColor = (mpFieldWindow->GetType() == PIVOTFIELDTYPE_SELECT) ? rStyleSett.GetFaceColor().GetColor() : rStyleSett.GetWindowColor().GetColor(); 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir return nColor; 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir ///===== XAccessibleContext ============================================== 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getAccessibleChildCount(void) 392*cdf0e10cSrcweir throw (uno::RuntimeException) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir ScUnoGuard aGuard; 395*cdf0e10cSrcweir IsObjectValid(); 396*cdf0e10cSrcweir if (mpFieldWindow) 397*cdf0e10cSrcweir return mpFieldWindow->GetFieldCount(); 398*cdf0e10cSrcweir else 399*cdf0e10cSrcweir return 0; 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir uno::Reference< XAccessible> SAL_CALL ScAccessibleDataPilotControl::getAccessibleChild(sal_Int32 nIndex) 403*cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir ScUnoGuard aGuard; 406*cdf0e10cSrcweir IsObjectValid(); 407*cdf0e10cSrcweir uno::Reference<XAccessible> xAcc; 408*cdf0e10cSrcweir if (mpFieldWindow) 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir if (nIndex < 0 || static_cast< size_t >( nIndex ) >= mpFieldWindow->GetFieldCount()) 411*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir DBG_ASSERT(mpFieldWindow->GetFieldCount() == maChildren.size(), "did not recognize a child count change"); 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc; 416*cdf0e10cSrcweir if (!xTempAcc.is()) 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir maChildren[nIndex].pAcc = new ScAccessibleDataPilotButton(this, mpFieldWindow, nIndex); 419*cdf0e10cSrcweir xTempAcc = maChildren[nIndex].pAcc; 420*cdf0e10cSrcweir maChildren[nIndex].xWeakAcc = xTempAcc; 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir xAcc = xTempAcc; 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir return xAcc; 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessibleDataPilotControl::getAccessibleStateSet(void) 429*cdf0e10cSrcweir throw (uno::RuntimeException) 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir ScUnoGuard aGuard; 432*cdf0e10cSrcweir IsObjectValid(); 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir if (IsDefunc()) 437*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::DEFUNC); 438*cdf0e10cSrcweir else 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::ENABLED); 441*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::OPAQUE); 442*cdf0e10cSrcweir if (isShowing()) 443*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SHOWING); 444*cdf0e10cSrcweir if (isVisible()) 445*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::VISIBLE); 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir return pStateSet; 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir ///===== XServiceInfo ==================================================== 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::getImplementationName(void) 454*cdf0e10cSrcweir throw (uno::RuntimeException) 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleDataPilotControl")); 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir ///===== XTypeProvider =================================================== 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL ScAccessibleDataPilotControl::getImplementationId(void) 462*cdf0e10cSrcweir throw (uno::RuntimeException) 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir ScUnoGuard aGuard; 465*cdf0e10cSrcweir IsObjectValid(); 466*cdf0e10cSrcweir static uno::Sequence<sal_Int8> aId; 467*cdf0e10cSrcweir if (aId.getLength() == 0) 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir aId.realloc (16); 470*cdf0e10cSrcweir rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True); 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir return aId; 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir //===== internal ======================================================== 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::createAccessibleDescription(void) 478*cdf0e10cSrcweir throw (uno::RuntimeException) 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir ScUnoGuard aGuard; 481*cdf0e10cSrcweir IsObjectValid(); 482*cdf0e10cSrcweir if (mpFieldWindow) 483*cdf0e10cSrcweir return mpFieldWindow->GetDescription(); 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir return rtl::OUString(); 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::createAccessibleName(void) 489*cdf0e10cSrcweir throw (uno::RuntimeException) 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir ScUnoGuard aGuard; 492*cdf0e10cSrcweir IsObjectValid(); 493*cdf0e10cSrcweir if (mpFieldWindow) 494*cdf0e10cSrcweir return mpFieldWindow->GetName(); 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir return rtl::OUString(); 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir Rectangle ScAccessibleDataPilotControl::GetBoundingBoxOnScreen(void) const 500*cdf0e10cSrcweir throw (uno::RuntimeException) 501*cdf0e10cSrcweir { 502*cdf0e10cSrcweir if (mpFieldWindow) 503*cdf0e10cSrcweir return mpFieldWindow->GetWindowExtentsRelative(NULL); 504*cdf0e10cSrcweir else 505*cdf0e10cSrcweir return Rectangle(); 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir Rectangle ScAccessibleDataPilotControl::GetBoundingBox(void) const 509*cdf0e10cSrcweir throw (uno::RuntimeException) 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir if (mpFieldWindow) 512*cdf0e10cSrcweir return mpFieldWindow->GetWindowExtentsRelative(mpFieldWindow->GetAccessibleParentWindow()); 513*cdf0e10cSrcweir else 514*cdf0e10cSrcweir return Rectangle(); 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir //=============================================================================== 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir ScAccessibleDataPilotButton::ScAccessibleDataPilotButton( 521*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 522*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& rxParent, 523*cdf0e10cSrcweir ScPivotFieldWindow* pFieldWindow, 524*cdf0e10cSrcweir sal_Int32 nIndex) 525*cdf0e10cSrcweir : ScAccessibleContextBase(rxParent, AccessibleRole::PUSH_BUTTON), 526*cdf0e10cSrcweir mpFieldWindow(pFieldWindow), 527*cdf0e10cSrcweir mnIndex(nIndex) 528*cdf0e10cSrcweir { 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir ScAccessibleDataPilotButton::~ScAccessibleDataPilotButton(void) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir if (!IsDefunc() && !rBHelper.bInDispose) 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir // increment refcount to prevent double call off dtor 536*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 537*cdf0e10cSrcweir // call dispose to inform object wich have a weak reference to this object 538*cdf0e10cSrcweir dispose(); 539*cdf0e10cSrcweir } 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir void ScAccessibleDataPilotButton::Init() 543*cdf0e10cSrcweir { 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir void SAL_CALL ScAccessibleDataPilotButton::disposing() 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir ScUnoGuard aGuard; 549*cdf0e10cSrcweir mpFieldWindow = NULL; 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir ScAccessibleContextBase::disposing(); 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir void ScAccessibleDataPilotButton::SetFocused() 555*cdf0e10cSrcweir { 556*cdf0e10cSrcweir CommitFocusGained(); 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir void ScAccessibleDataPilotButton::ResetFocused() 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir CommitFocusLost(); 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir ///===== XAccessibleComponent ============================================ 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleDataPilotButton::getAccessibleAtPoint( 567*cdf0e10cSrcweir const ::com::sun::star::awt::Point& /* rPoint */ ) 568*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir return NULL; 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleDataPilotButton::isVisible( ) 574*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir return sal_True; 577*cdf0e10cSrcweir } 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir void SAL_CALL ScAccessibleDataPilotButton::grabFocus( ) 580*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir ScUnoGuard aGuard; 583*cdf0e10cSrcweir IsObjectValid(); 584*cdf0e10cSrcweir if (mpFieldWindow) 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir mpFieldWindow->GrabFocusAndSelect(getAccessibleIndexInParent()); 587*cdf0e10cSrcweir } 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getForeground( ) 591*cdf0e10cSrcweir throw (uno::RuntimeException) 592*cdf0e10cSrcweir { 593*cdf0e10cSrcweir ScUnoGuard aGuard; 594*cdf0e10cSrcweir IsObjectValid(); 595*cdf0e10cSrcweir sal_Int32 nColor(0); 596*cdf0e10cSrcweir if (mpFieldWindow) 597*cdf0e10cSrcweir { 598*cdf0e10cSrcweir nColor = mpFieldWindow->GetSettings().GetStyleSettings().GetButtonTextColor().GetColor(); 599*cdf0e10cSrcweir } 600*cdf0e10cSrcweir return nColor; 601*cdf0e10cSrcweir } 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getBackground( ) 604*cdf0e10cSrcweir throw (uno::RuntimeException) 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir ScUnoGuard aGuard; 607*cdf0e10cSrcweir IsObjectValid(); 608*cdf0e10cSrcweir sal_Int32 nColor(0); 609*cdf0e10cSrcweir if (mpFieldWindow) 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir nColor = mpFieldWindow->GetSettings().GetStyleSettings().GetFaceColor().GetColor(); 612*cdf0e10cSrcweir } 613*cdf0e10cSrcweir return nColor; 614*cdf0e10cSrcweir } 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir ///===== XAccessibleContext ============================================== 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getAccessibleChildCount(void) 619*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 620*cdf0e10cSrcweir { 621*cdf0e10cSrcweir return 0; 622*cdf0e10cSrcweir } 623*cdf0e10cSrcweir 624*cdf0e10cSrcweir uno::Reference< XAccessible> SAL_CALL ScAccessibleDataPilotButton::getAccessibleChild(sal_Int32 /* nIndex */) 625*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException, 626*cdf0e10cSrcweir ::com::sun::star::lang::IndexOutOfBoundsException) 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getAccessibleIndexInParent(void) 632*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 633*cdf0e10cSrcweir { 634*cdf0e10cSrcweir ScUnoGuard aGuard; 635*cdf0e10cSrcweir IsObjectValid(); 636*cdf0e10cSrcweir return mnIndex; 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessibleDataPilotButton::getAccessibleStateSet(void) 640*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir ScUnoGuard aGuard; 643*cdf0e10cSrcweir IsObjectValid(); 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir if (IsDefunc()) 648*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::DEFUNC); 649*cdf0e10cSrcweir else 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::ENABLED); 652*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::OPAQUE); 653*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::FOCUSABLE); 654*cdf0e10cSrcweir if (mpFieldWindow && (sal::static_int_cast<sal_Int32>(mpFieldWindow->GetSelectedIndex()) == mnIndex)) 655*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::FOCUSED); 656*cdf0e10cSrcweir if (isShowing()) 657*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SHOWING); 658*cdf0e10cSrcweir if (isVisible()) 659*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::VISIBLE); 660*cdf0e10cSrcweir } 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir return pStateSet; 663*cdf0e10cSrcweir } 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir ///===== XServiceInfo ==================================================== 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::getImplementationName(void) 668*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 669*cdf0e10cSrcweir { 670*cdf0e10cSrcweir return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleDataPilotButton")); 671*cdf0e10cSrcweir } 672*cdf0e10cSrcweir 673*cdf0e10cSrcweir ///===== XTypeProvider =================================================== 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL ScAccessibleDataPilotButton::getImplementationId(void) 676*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir ScUnoGuard aGuard; 679*cdf0e10cSrcweir IsObjectValid(); 680*cdf0e10cSrcweir static uno::Sequence<sal_Int8> aId; 681*cdf0e10cSrcweir if (aId.getLength() == 0) 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir aId.realloc (16); 684*cdf0e10cSrcweir rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True); 685*cdf0e10cSrcweir } 686*cdf0e10cSrcweir return aId; 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::createAccessibleDescription(void) 690*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 691*cdf0e10cSrcweir { 692*cdf0e10cSrcweir return rtl::OUString(); 693*cdf0e10cSrcweir } 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::createAccessibleName(void) 696*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 697*cdf0e10cSrcweir { 698*cdf0e10cSrcweir ScUnoGuard aGuard; 699*cdf0e10cSrcweir IsObjectValid(); 700*cdf0e10cSrcweir if (mpFieldWindow) 701*cdf0e10cSrcweir return mpFieldWindow->GetFieldText(getAccessibleIndexInParent()); 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir return rtl::OUString(); 704*cdf0e10cSrcweir } 705*cdf0e10cSrcweir 706*cdf0e10cSrcweir Rectangle ScAccessibleDataPilotButton::GetBoundingBoxOnScreen(void) const 707*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 708*cdf0e10cSrcweir { 709*cdf0e10cSrcweir Rectangle aRect(GetBoundingBox()); 710*cdf0e10cSrcweir 711*cdf0e10cSrcweir if (mpFieldWindow) 712*cdf0e10cSrcweir { 713*cdf0e10cSrcweir Point aParentPos(mpFieldWindow->GetWindowExtentsRelative(NULL).TopLeft()); 714*cdf0e10cSrcweir aRect.Move(aParentPos.getX(), aParentPos.getY()); 715*cdf0e10cSrcweir } 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir return aRect; 718*cdf0e10cSrcweir } 719*cdf0e10cSrcweir 720*cdf0e10cSrcweir Rectangle ScAccessibleDataPilotButton::GetBoundingBox(void) const 721*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir if (mpFieldWindow) 724*cdf0e10cSrcweir return Rectangle (mpFieldWindow->GetFieldPosition(const_cast<ScAccessibleDataPilotButton*> (this)->getAccessibleIndexInParent()), mpFieldWindow->GetFieldSize()); 725*cdf0e10cSrcweir else 726*cdf0e10cSrcweir return Rectangle(); 727*cdf0e10cSrcweir } 728