1b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5b3f79822SAndrew Rist * distributed with this work for additional information 6b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14b3f79822SAndrew Rist * software distributed under the License is distributed on an 15b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17b3f79822SAndrew Rist * specific language governing permissions and limitations 18b3f79822SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20b3f79822SAndrew Rist *************************************************************/ 21b3f79822SAndrew Rist 22b3f79822SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sc.hxx" 26cdf0e10cSrcweir #include "AccessibleDataPilotControl.hxx" 27cdf0e10cSrcweir #include "unoguard.hxx" 28cdf0e10cSrcweir #include "fieldwnd.hxx" 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 31cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 32cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 33cdf0e10cSrcweir 34*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 35*0deba7fbSSteve Yin #include <com/sun/star/accessibility/XAccessibleAction.hpp> 36*0deba7fbSSteve Yin #include <comphelper/accessiblekeybindinghelper.hxx> 37*0deba7fbSSteve Yin #include <com/sun/star/awt/KeyModifier.hpp> 38*0deba7fbSSteve Yin #include <vcl/keycodes.hxx> 39*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 40*0deba7fbSSteve Yin #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX 41cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 42*0deba7fbSSteve Yin #endif 43cdf0e10cSrcweir #include <rtl/uuid.h> 44cdf0e10cSrcweir #include <tools/gen.hxx> 45cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 46cdf0e10cSrcweir #include <tools/debug.hxx> 47cdf0e10cSrcweir 48*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 49*0deba7fbSSteve Yin #include <com/sun/star/accessibility/AccessibleRelationType.hpp> 50*0deba7fbSSteve Yin #include <unotools/accessiblerelationsethelper.hxx> 51*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 52cdf0e10cSrcweir using namespace ::com::sun::star; 53cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 54cdf0e10cSrcweir 55cdf0e10cSrcweir class ScAccessibleDataPilotButton 56cdf0e10cSrcweir : public ScAccessibleContextBase 57*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 58*0deba7fbSSteve Yin , public ::com::sun::star::accessibility::XAccessibleAction 59*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 60cdf0e10cSrcweir { 61cdf0e10cSrcweir public: 62cdf0e10cSrcweir //===== internal ======================================================== 63cdf0e10cSrcweir ScAccessibleDataPilotButton( 64cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 65cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& rxParent, 66cdf0e10cSrcweir ScPivotFieldWindow* pFieldWindow, 67cdf0e10cSrcweir sal_Int32 nIndex); 68cdf0e10cSrcweir 69cdf0e10cSrcweir virtual void Init(); 70cdf0e10cSrcweir 71cdf0e10cSrcweir using ScAccessibleContextBase::disposing; 72cdf0e10cSrcweir virtual void SAL_CALL disposing(); 73cdf0e10cSrcweir 74cdf0e10cSrcweir void SetIndex(sal_Int32 nIndex) { mnIndex = nIndex; } 75cdf0e10cSrcweir void NameChanged(); 76cdf0e10cSrcweir void SetFocused(); 77cdf0e10cSrcweir void ResetFocused(); 78cdf0e10cSrcweir protected: 79cdf0e10cSrcweir virtual ~ScAccessibleDataPilotButton(void); 80cdf0e10cSrcweir public: 81*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 82*0deba7fbSSteve Yin // XAccessibleAction 83*0deba7fbSSteve Yin virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) throw (::com::sun::star::uno::RuntimeException); 84*0deba7fbSSteve Yin virtual sal_Bool SAL_CALL doAccessibleAction ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 85*0deba7fbSSteve Yin virtual ::rtl::OUString SAL_CALL getAccessibleActionDescription ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 86*0deba7fbSSteve Yin virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 87*0deba7fbSSteve Yin ///===== XInterface ===================================================== 88*0deba7fbSSteve Yin virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 89*0deba7fbSSteve Yin ::com::sun::star::uno::Type const & rType ) 90*0deba7fbSSteve Yin throw (::com::sun::star::uno::RuntimeException); 91*0deba7fbSSteve Yin virtual void SAL_CALL acquire() throw (); 92*0deba7fbSSteve Yin virtual void SAL_CALL release() throw (); 93*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 94cdf0e10cSrcweir ///===== XAccessibleComponent ============================================ 95cdf0e10cSrcweir 96cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 97cdf0e10cSrcweir SAL_CALL getAccessibleAtPoint( 98cdf0e10cSrcweir const ::com::sun::star::awt::Point& rPoint ) 99cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 100cdf0e10cSrcweir 101cdf0e10cSrcweir virtual sal_Bool SAL_CALL isVisible( ) 102cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 103cdf0e10cSrcweir 104cdf0e10cSrcweir virtual void SAL_CALL grabFocus( ) 105cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 106cdf0e10cSrcweir 107cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getForeground( ) 108cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 109cdf0e10cSrcweir 110cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getBackground( ) 111cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 112cdf0e10cSrcweir 113cdf0e10cSrcweir ///===== XAccessibleContext ============================================== 114cdf0e10cSrcweir 115cdf0e10cSrcweir /// Return the number of currently visible children. 116cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 117cdf0e10cSrcweir getAccessibleChildCount(void) throw (::com::sun::star::uno::RuntimeException); 118cdf0e10cSrcweir 119cdf0e10cSrcweir /// Return the specified child or NULL if index is invalid. 120cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL 121cdf0e10cSrcweir getAccessibleChild(sal_Int32 nIndex) 122cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException, 123cdf0e10cSrcweir ::com::sun::star::lang::IndexOutOfBoundsException); 124cdf0e10cSrcweir 125cdf0e10cSrcweir /// Return this objects index among the parents children. 126cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 127cdf0e10cSrcweir getAccessibleIndexInParent(void) 128cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 129cdf0e10cSrcweir 130cdf0e10cSrcweir /// Return the set of current states. 131cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 132cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL 133cdf0e10cSrcweir getAccessibleStateSet(void) 134cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 135*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 136*0deba7fbSSteve Yin ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > 137*0deba7fbSSteve Yin SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException); 138*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 139cdf0e10cSrcweir ///===== XServiceInfo ==================================================== 140cdf0e10cSrcweir 141cdf0e10cSrcweir /** Returns an identifier for the implementation of this object. 142cdf0e10cSrcweir */ 143cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 144cdf0e10cSrcweir getImplementationName(void) 145cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 146cdf0e10cSrcweir 147cdf0e10cSrcweir ///===== XTypeProvider =================================================== 148cdf0e10cSrcweir 149cdf0e10cSrcweir /** Returns a implementation id. 150cdf0e10cSrcweir */ 151cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL 152cdf0e10cSrcweir getImplementationId(void) 153cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 154cdf0e10cSrcweir 155cdf0e10cSrcweir protected: 156cdf0e10cSrcweir /// Return this object's description. 157cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 158cdf0e10cSrcweir createAccessibleDescription(void) 159cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 160cdf0e10cSrcweir 161cdf0e10cSrcweir /// Return the object's current name. 162cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 163cdf0e10cSrcweir createAccessibleName(void) 164cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 165cdf0e10cSrcweir 166cdf0e10cSrcweir /// Return the object's current bounding box relative to the desktop. 167cdf0e10cSrcweir virtual Rectangle GetBoundingBoxOnScreen(void) const 168cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 169cdf0e10cSrcweir 170cdf0e10cSrcweir /// Return the object's current bounding box relative to the parent object. 171cdf0e10cSrcweir virtual Rectangle GetBoundingBox(void) const 172cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 173cdf0e10cSrcweir 174cdf0e10cSrcweir private: 175cdf0e10cSrcweir ScPivotFieldWindow* mpFieldWindow; 176cdf0e10cSrcweir sal_Int32 mnIndex; 177cdf0e10cSrcweir }; 178cdf0e10cSrcweir 179cdf0e10cSrcweir //===== internal ======================================================== 180cdf0e10cSrcweir ScAccessibleDataPilotControl::ScAccessibleDataPilotControl( 181cdf0e10cSrcweir const uno::Reference<XAccessible>& rxParent, 182cdf0e10cSrcweir ScPivotFieldWindow* pFieldWindow) 183cdf0e10cSrcweir : 184cdf0e10cSrcweir ScAccessibleContextBase(rxParent, AccessibleRole::GROUP_BOX), 185cdf0e10cSrcweir mpFieldWindow(pFieldWindow) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir if (mpFieldWindow) 188cdf0e10cSrcweir maChildren.resize(mpFieldWindow->GetFieldCount()); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir 191cdf0e10cSrcweir ScAccessibleDataPilotControl::~ScAccessibleDataPilotControl(void) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir if (!IsDefunc() && !rBHelper.bInDispose) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir // increment refcount to prevent double call off dtor 196cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 197cdf0e10cSrcweir // call dispose to inform object wich have a weak reference to this object 198cdf0e10cSrcweir dispose(); 199cdf0e10cSrcweir } 200cdf0e10cSrcweir } 201cdf0e10cSrcweir 202cdf0e10cSrcweir void ScAccessibleDataPilotControl::Init() 203cdf0e10cSrcweir { 204cdf0e10cSrcweir } 205cdf0e10cSrcweir 206cdf0e10cSrcweir void SAL_CALL ScAccessibleDataPilotControl::disposing() 207cdf0e10cSrcweir { 208cdf0e10cSrcweir ScUnoGuard aGuard; 209cdf0e10cSrcweir mpFieldWindow = NULL; 210cdf0e10cSrcweir 211cdf0e10cSrcweir ScAccessibleContextBase::disposing(); 212cdf0e10cSrcweir } 213cdf0e10cSrcweir 214cdf0e10cSrcweir void ScAccessibleDataPilotControl::AddField(sal_Int32 nNewIndex) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir sal_Bool bAdded(sal_False); 217cdf0e10cSrcweir if (static_cast<size_t>(nNewIndex) == maChildren.size()) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir maChildren.push_back(AccessibleWeak()); 220cdf0e10cSrcweir bAdded = sal_True; 221cdf0e10cSrcweir } 222cdf0e10cSrcweir else if (static_cast<size_t>(nNewIndex) < maChildren.size()) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir ::std::vector < AccessibleWeak >::iterator aItr = maChildren.begin() + nNewIndex; 225cdf0e10cSrcweir maChildren.insert(aItr, AccessibleWeak()); 226cdf0e10cSrcweir 227cdf0e10cSrcweir ::std::vector < AccessibleWeak >::iterator aEndItr = maChildren.end(); 228cdf0e10cSrcweir aItr = maChildren.begin() + nNewIndex + 1; 229cdf0e10cSrcweir uno::Reference< XAccessible > xTempAcc; 230cdf0e10cSrcweir sal_Int32 nIndex = nNewIndex + 1; 231cdf0e10cSrcweir while (aItr != aEndItr) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir xTempAcc = aItr->xWeakAcc; 234cdf0e10cSrcweir if (xTempAcc.is() && aItr->pAcc) 235cdf0e10cSrcweir aItr->pAcc->SetIndex(nIndex); 236cdf0e10cSrcweir ++nIndex; 237cdf0e10cSrcweir ++aItr; 238cdf0e10cSrcweir } 239cdf0e10cSrcweir bAdded = sal_True; 240cdf0e10cSrcweir } 241cdf0e10cSrcweir else 242cdf0e10cSrcweir { 243cdf0e10cSrcweir DBG_ERRORFILE("did not recognize a child count change"); 244cdf0e10cSrcweir } 245cdf0e10cSrcweir 246cdf0e10cSrcweir if (bAdded) 247cdf0e10cSrcweir { 248cdf0e10cSrcweir AccessibleEventObject aEvent; 249cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD; 250cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 251cdf0e10cSrcweir aEvent.NewValue <<= getAccessibleChild(nNewIndex); 252cdf0e10cSrcweir 253cdf0e10cSrcweir CommitChange(aEvent); // new child - event 254cdf0e10cSrcweir } 255cdf0e10cSrcweir } 256cdf0e10cSrcweir 257cdf0e10cSrcweir void ScAccessibleDataPilotControl::RemoveField(sal_Int32 nOldIndex) 258cdf0e10cSrcweir { 259cdf0e10cSrcweir sal_Bool bRemoved(sal_False); 260cdf0e10cSrcweir uno::Reference< XAccessible > xTempAcc; 261cdf0e10cSrcweir ScAccessibleDataPilotButton* pField = NULL; 262cdf0e10cSrcweir if (static_cast<size_t>(nOldIndex) < maChildren.size()) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir xTempAcc = getAccessibleChild(nOldIndex); 265cdf0e10cSrcweir pField = maChildren[nOldIndex].pAcc; 266cdf0e10cSrcweir 267cdf0e10cSrcweir ::std::vector < AccessibleWeak >::iterator aItr = maChildren.begin() + nOldIndex; 268cdf0e10cSrcweir aItr = maChildren.erase(aItr); 269cdf0e10cSrcweir 270cdf0e10cSrcweir ::std::vector < AccessibleWeak >::iterator aEndItr = maChildren.end(); 271cdf0e10cSrcweir uno::Reference< XAccessible > xItrAcc; 272cdf0e10cSrcweir while (aItr != aEndItr) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir xItrAcc = aItr->xWeakAcc; 275cdf0e10cSrcweir if (xItrAcc.is() && aItr->pAcc) 276cdf0e10cSrcweir aItr->pAcc->SetIndex(nOldIndex); 277cdf0e10cSrcweir ++nOldIndex; 278cdf0e10cSrcweir ++aItr; 279cdf0e10cSrcweir } 280cdf0e10cSrcweir bRemoved = sal_True; 281cdf0e10cSrcweir } 282cdf0e10cSrcweir else 283cdf0e10cSrcweir { 284cdf0e10cSrcweir DBG_ERRORFILE("did not recognize a child count change"); 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir if (bRemoved) 288cdf0e10cSrcweir { 289cdf0e10cSrcweir AccessibleEventObject aEvent; 290cdf0e10cSrcweir aEvent.EventId = AccessibleEventId::CHILD; 291cdf0e10cSrcweir aEvent.Source = uno::Reference< XAccessibleContext >(this); 292cdf0e10cSrcweir aEvent.NewValue <<= xTempAcc; 293cdf0e10cSrcweir 294cdf0e10cSrcweir CommitChange(aEvent); // gone child - event 295cdf0e10cSrcweir 296cdf0e10cSrcweir if (pField) 297cdf0e10cSrcweir pField->dispose(); 298cdf0e10cSrcweir } 299cdf0e10cSrcweir } 300cdf0e10cSrcweir 301cdf0e10cSrcweir void ScAccessibleDataPilotControl::FieldFocusChange(sal_Int32 nOldIndex, sal_Int32 nNewIndex) 302cdf0e10cSrcweir { 303cdf0e10cSrcweir DBG_ASSERT(static_cast<size_t>(nOldIndex) < maChildren.size() && 304cdf0e10cSrcweir static_cast<size_t>(nNewIndex) < maChildren.size(), "did not recognize a child count change"); 305cdf0e10cSrcweir 306cdf0e10cSrcweir uno::Reference < XAccessible > xTempAcc = maChildren[nOldIndex].xWeakAcc; 307cdf0e10cSrcweir if (xTempAcc.is() && maChildren[nOldIndex].pAcc) 308cdf0e10cSrcweir maChildren[nOldIndex].pAcc->ResetFocused(); 309cdf0e10cSrcweir 310cdf0e10cSrcweir xTempAcc = maChildren[nNewIndex].xWeakAcc; 311cdf0e10cSrcweir if (xTempAcc.is() && maChildren[nNewIndex].pAcc) 312cdf0e10cSrcweir maChildren[nNewIndex].pAcc->SetFocused(); 313cdf0e10cSrcweir } 314cdf0e10cSrcweir 315cdf0e10cSrcweir void ScAccessibleDataPilotControl::FieldNameChange(sal_Int32 nIndex) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir DBG_ASSERT(static_cast<size_t>(nIndex) < maChildren.size(), "did not recognize a child count change"); 318cdf0e10cSrcweir 319cdf0e10cSrcweir uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc; 320cdf0e10cSrcweir if (xTempAcc.is() && maChildren[nIndex].pAcc) 321cdf0e10cSrcweir maChildren[nIndex].pAcc->ChangeName(); 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir void ScAccessibleDataPilotControl::GotFocus() 325cdf0e10cSrcweir { 326cdf0e10cSrcweir if (mpFieldWindow) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir DBG_ASSERT(mpFieldWindow->GetFieldCount() == maChildren.size(), "did not recognize a child count change"); 329cdf0e10cSrcweir 330*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 331*0deba7fbSSteve Yin if(maChildren.size()==0) 332*0deba7fbSSteve Yin return ; 333*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 334cdf0e10cSrcweir sal_Int32 nIndex(mpFieldWindow->GetSelectedIndex()); 335cdf0e10cSrcweir uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc; 336cdf0e10cSrcweir if (xTempAcc.is() && maChildren[nIndex].pAcc) 337cdf0e10cSrcweir maChildren[nIndex].pAcc->SetFocused(); 338cdf0e10cSrcweir } 339cdf0e10cSrcweir } 340cdf0e10cSrcweir 341cdf0e10cSrcweir void ScAccessibleDataPilotControl::LostFocus() 342cdf0e10cSrcweir { 343cdf0e10cSrcweir if (mpFieldWindow) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir DBG_ASSERT(mpFieldWindow->GetFieldCount() == maChildren.size(), "did not recognize a child count change"); 346*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 347*0deba7fbSSteve Yin if(maChildren.size()==0) 348*0deba7fbSSteve Yin return ; 349*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 350cdf0e10cSrcweir sal_Int32 nIndex(mpFieldWindow->GetSelectedIndex()); 351cdf0e10cSrcweir uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc; 352cdf0e10cSrcweir if (xTempAcc.is() && maChildren[nIndex].pAcc) 353cdf0e10cSrcweir maChildren[nIndex].pAcc->ResetFocused(); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir } 356cdf0e10cSrcweir 357cdf0e10cSrcweir ///===== XAccessibleComponent ============================================ 358cdf0e10cSrcweir 359cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleDataPilotControl::getAccessibleAtPoint( 360cdf0e10cSrcweir const awt::Point& rPoint ) 361cdf0e10cSrcweir throw (uno::RuntimeException) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir uno::Reference<XAccessible> xAcc; 364cdf0e10cSrcweir if (containsPoint(rPoint)) 365cdf0e10cSrcweir { 366cdf0e10cSrcweir ScUnoGuard aGuard; 367cdf0e10cSrcweir IsObjectValid(); 368cdf0e10cSrcweir if (mpFieldWindow) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir Point aAbsPoint(VCLPoint(rPoint)); 371cdf0e10cSrcweir Point aControlEdge(GetBoundingBoxOnScreen().TopLeft()); 372cdf0e10cSrcweir Point aRelPoint(aAbsPoint - aControlEdge); 373cdf0e10cSrcweir size_t nChildIndex = mpFieldWindow->GetFieldIndex( aRelPoint ); 374cdf0e10cSrcweir if( nChildIndex != PIVOTFIELD_INVALID ) 375cdf0e10cSrcweir xAcc = getAccessibleChild(static_cast< long >( nChildIndex )); 376cdf0e10cSrcweir } 377cdf0e10cSrcweir } 378cdf0e10cSrcweir return xAcc; 379cdf0e10cSrcweir } 380cdf0e10cSrcweir 381cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleDataPilotControl::isVisible( ) 382cdf0e10cSrcweir throw (uno::RuntimeException) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir return sal_True; 385cdf0e10cSrcweir } 386cdf0e10cSrcweir 387cdf0e10cSrcweir void SAL_CALL ScAccessibleDataPilotControl::grabFocus( ) 388cdf0e10cSrcweir throw (uno::RuntimeException) 389cdf0e10cSrcweir { 390cdf0e10cSrcweir ScUnoGuard aGuard; 391cdf0e10cSrcweir IsObjectValid(); 392cdf0e10cSrcweir if (mpFieldWindow) 393cdf0e10cSrcweir mpFieldWindow->GrabFocus(); 394cdf0e10cSrcweir } 395cdf0e10cSrcweir 396cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getForeground( ) 397cdf0e10cSrcweir throw (uno::RuntimeException) 398cdf0e10cSrcweir { 399cdf0e10cSrcweir ScUnoGuard aGuard; 400cdf0e10cSrcweir IsObjectValid(); 401cdf0e10cSrcweir sal_Int32 nColor(0); 402cdf0e10cSrcweir if (mpFieldWindow) 403cdf0e10cSrcweir { 404cdf0e10cSrcweir nColor = mpFieldWindow->GetSettings().GetStyleSettings().GetWindowTextColor().GetColor(); 405cdf0e10cSrcweir } 406cdf0e10cSrcweir return nColor; 407cdf0e10cSrcweir } 408cdf0e10cSrcweir 409cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getBackground( ) 410cdf0e10cSrcweir throw (uno::RuntimeException) 411cdf0e10cSrcweir { 412cdf0e10cSrcweir ScUnoGuard aGuard; 413cdf0e10cSrcweir IsObjectValid(); 414cdf0e10cSrcweir sal_Int32 nColor(0); 415cdf0e10cSrcweir if (mpFieldWindow) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir const StyleSettings& rStyleSett = mpFieldWindow->GetSettings().GetStyleSettings(); 418cdf0e10cSrcweir nColor = (mpFieldWindow->GetType() == PIVOTFIELDTYPE_SELECT) ? rStyleSett.GetFaceColor().GetColor() : rStyleSett.GetWindowColor().GetColor(); 419cdf0e10cSrcweir } 420cdf0e10cSrcweir return nColor; 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir ///===== XAccessibleContext ============================================== 424cdf0e10cSrcweir 425cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getAccessibleChildCount(void) 426cdf0e10cSrcweir throw (uno::RuntimeException) 427cdf0e10cSrcweir { 428cdf0e10cSrcweir ScUnoGuard aGuard; 429cdf0e10cSrcweir IsObjectValid(); 430cdf0e10cSrcweir if (mpFieldWindow) 431cdf0e10cSrcweir return mpFieldWindow->GetFieldCount(); 432cdf0e10cSrcweir else 433cdf0e10cSrcweir return 0; 434cdf0e10cSrcweir } 435cdf0e10cSrcweir 436cdf0e10cSrcweir uno::Reference< XAccessible> SAL_CALL ScAccessibleDataPilotControl::getAccessibleChild(sal_Int32 nIndex) 437cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir ScUnoGuard aGuard; 440cdf0e10cSrcweir IsObjectValid(); 441cdf0e10cSrcweir uno::Reference<XAccessible> xAcc; 442cdf0e10cSrcweir if (mpFieldWindow) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir if (nIndex < 0 || static_cast< size_t >( nIndex ) >= mpFieldWindow->GetFieldCount()) 445cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 446cdf0e10cSrcweir 447cdf0e10cSrcweir DBG_ASSERT(mpFieldWindow->GetFieldCount() == maChildren.size(), "did not recognize a child count change"); 448cdf0e10cSrcweir 449cdf0e10cSrcweir uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc; 450cdf0e10cSrcweir if (!xTempAcc.is()) 451cdf0e10cSrcweir { 452cdf0e10cSrcweir maChildren[nIndex].pAcc = new ScAccessibleDataPilotButton(this, mpFieldWindow, nIndex); 453cdf0e10cSrcweir xTempAcc = maChildren[nIndex].pAcc; 454cdf0e10cSrcweir maChildren[nIndex].xWeakAcc = xTempAcc; 455cdf0e10cSrcweir } 456cdf0e10cSrcweir 457cdf0e10cSrcweir xAcc = xTempAcc; 458cdf0e10cSrcweir } 459cdf0e10cSrcweir return xAcc; 460cdf0e10cSrcweir } 461cdf0e10cSrcweir 462cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessibleDataPilotControl::getAccessibleStateSet(void) 463cdf0e10cSrcweir throw (uno::RuntimeException) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir ScUnoGuard aGuard; 466cdf0e10cSrcweir IsObjectValid(); 467cdf0e10cSrcweir 468cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); 469cdf0e10cSrcweir 470cdf0e10cSrcweir if (IsDefunc()) 471cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::DEFUNC); 472cdf0e10cSrcweir else 473cdf0e10cSrcweir { 474cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::ENABLED); 475cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::OPAQUE); 476cdf0e10cSrcweir if (isShowing()) 477cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SHOWING); 478cdf0e10cSrcweir if (isVisible()) 479cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::VISIBLE); 480cdf0e10cSrcweir } 481cdf0e10cSrcweir 482cdf0e10cSrcweir return pStateSet; 483cdf0e10cSrcweir } 484cdf0e10cSrcweir 485cdf0e10cSrcweir ///===== XServiceInfo ==================================================== 486cdf0e10cSrcweir 487cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::getImplementationName(void) 488cdf0e10cSrcweir throw (uno::RuntimeException) 489cdf0e10cSrcweir { 490cdf0e10cSrcweir return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleDataPilotControl")); 491cdf0e10cSrcweir } 492cdf0e10cSrcweir 493cdf0e10cSrcweir ///===== XTypeProvider =================================================== 494cdf0e10cSrcweir 495cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL ScAccessibleDataPilotControl::getImplementationId(void) 496cdf0e10cSrcweir throw (uno::RuntimeException) 497cdf0e10cSrcweir { 498cdf0e10cSrcweir ScUnoGuard aGuard; 499cdf0e10cSrcweir IsObjectValid(); 500cdf0e10cSrcweir static uno::Sequence<sal_Int8> aId; 501cdf0e10cSrcweir if (aId.getLength() == 0) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir aId.realloc (16); 504cdf0e10cSrcweir rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True); 505cdf0e10cSrcweir } 506cdf0e10cSrcweir return aId; 507cdf0e10cSrcweir } 508cdf0e10cSrcweir 509cdf0e10cSrcweir //===== internal ======================================================== 510cdf0e10cSrcweir 511cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::createAccessibleDescription(void) 512cdf0e10cSrcweir throw (uno::RuntimeException) 513cdf0e10cSrcweir { 514cdf0e10cSrcweir ScUnoGuard aGuard; 515cdf0e10cSrcweir IsObjectValid(); 516cdf0e10cSrcweir if (mpFieldWindow) 517cdf0e10cSrcweir return mpFieldWindow->GetDescription(); 518cdf0e10cSrcweir 519cdf0e10cSrcweir return rtl::OUString(); 520cdf0e10cSrcweir } 521cdf0e10cSrcweir 522cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::createAccessibleName(void) 523cdf0e10cSrcweir throw (uno::RuntimeException) 524cdf0e10cSrcweir { 525cdf0e10cSrcweir ScUnoGuard aGuard; 526cdf0e10cSrcweir IsObjectValid(); 527cdf0e10cSrcweir if (mpFieldWindow) 528cdf0e10cSrcweir return mpFieldWindow->GetName(); 529cdf0e10cSrcweir 530cdf0e10cSrcweir return rtl::OUString(); 531cdf0e10cSrcweir } 532cdf0e10cSrcweir 533cdf0e10cSrcweir Rectangle ScAccessibleDataPilotControl::GetBoundingBoxOnScreen(void) const 534cdf0e10cSrcweir throw (uno::RuntimeException) 535cdf0e10cSrcweir { 536cdf0e10cSrcweir if (mpFieldWindow) 537cdf0e10cSrcweir return mpFieldWindow->GetWindowExtentsRelative(NULL); 538cdf0e10cSrcweir else 539cdf0e10cSrcweir return Rectangle(); 540cdf0e10cSrcweir } 541cdf0e10cSrcweir 542cdf0e10cSrcweir Rectangle ScAccessibleDataPilotControl::GetBoundingBox(void) const 543cdf0e10cSrcweir throw (uno::RuntimeException) 544cdf0e10cSrcweir { 545cdf0e10cSrcweir if (mpFieldWindow) 546cdf0e10cSrcweir return mpFieldWindow->GetWindowExtentsRelative(mpFieldWindow->GetAccessibleParentWindow()); 547cdf0e10cSrcweir else 548cdf0e10cSrcweir return Rectangle(); 549cdf0e10cSrcweir } 550cdf0e10cSrcweir 551cdf0e10cSrcweir 552cdf0e10cSrcweir //=============================================================================== 553cdf0e10cSrcweir 554cdf0e10cSrcweir ScAccessibleDataPilotButton::ScAccessibleDataPilotButton( 555cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 556cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& rxParent, 557cdf0e10cSrcweir ScPivotFieldWindow* pFieldWindow, 558cdf0e10cSrcweir sal_Int32 nIndex) 559*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 560*0deba7fbSSteve Yin //change role frome PUSH_BUTTON to BUTTON_MENU 561*0deba7fbSSteve Yin //: ScAccessibleContextBase(rxParent, AccessibleRole::PUSH_BUTTON), 562*0deba7fbSSteve Yin : ScAccessibleContextBase(rxParent, AccessibleRole::BUTTON_MENU), 563*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 564cdf0e10cSrcweir mpFieldWindow(pFieldWindow), 565cdf0e10cSrcweir mnIndex(nIndex) 566cdf0e10cSrcweir { 567cdf0e10cSrcweir } 568cdf0e10cSrcweir 569cdf0e10cSrcweir ScAccessibleDataPilotButton::~ScAccessibleDataPilotButton(void) 570cdf0e10cSrcweir { 571cdf0e10cSrcweir if (!IsDefunc() && !rBHelper.bInDispose) 572cdf0e10cSrcweir { 573cdf0e10cSrcweir // increment refcount to prevent double call off dtor 574cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 575cdf0e10cSrcweir // call dispose to inform object wich have a weak reference to this object 576cdf0e10cSrcweir dispose(); 577cdf0e10cSrcweir } 578cdf0e10cSrcweir } 579cdf0e10cSrcweir 580cdf0e10cSrcweir void ScAccessibleDataPilotButton::Init() 581cdf0e10cSrcweir { 582cdf0e10cSrcweir } 583cdf0e10cSrcweir 584cdf0e10cSrcweir void SAL_CALL ScAccessibleDataPilotButton::disposing() 585cdf0e10cSrcweir { 586cdf0e10cSrcweir ScUnoGuard aGuard; 587cdf0e10cSrcweir mpFieldWindow = NULL; 588cdf0e10cSrcweir 589cdf0e10cSrcweir ScAccessibleContextBase::disposing(); 590cdf0e10cSrcweir } 591cdf0e10cSrcweir 592cdf0e10cSrcweir void ScAccessibleDataPilotButton::SetFocused() 593cdf0e10cSrcweir { 594cdf0e10cSrcweir CommitFocusGained(); 595cdf0e10cSrcweir } 596cdf0e10cSrcweir 597cdf0e10cSrcweir void ScAccessibleDataPilotButton::ResetFocused() 598cdf0e10cSrcweir { 599cdf0e10cSrcweir CommitFocusLost(); 600cdf0e10cSrcweir } 601cdf0e10cSrcweir 602cdf0e10cSrcweir ///===== XAccessibleComponent ============================================ 603cdf0e10cSrcweir 604cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleDataPilotButton::getAccessibleAtPoint( 605cdf0e10cSrcweir const ::com::sun::star::awt::Point& /* rPoint */ ) 606cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 607cdf0e10cSrcweir { 608cdf0e10cSrcweir return NULL; 609cdf0e10cSrcweir } 610cdf0e10cSrcweir 611cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleDataPilotButton::isVisible( ) 612cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 613cdf0e10cSrcweir { 614cdf0e10cSrcweir return sal_True; 615cdf0e10cSrcweir } 616cdf0e10cSrcweir 617cdf0e10cSrcweir void SAL_CALL ScAccessibleDataPilotButton::grabFocus( ) 618cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 619cdf0e10cSrcweir { 620cdf0e10cSrcweir ScUnoGuard aGuard; 621cdf0e10cSrcweir IsObjectValid(); 622cdf0e10cSrcweir if (mpFieldWindow) 623cdf0e10cSrcweir { 624cdf0e10cSrcweir mpFieldWindow->GrabFocusAndSelect(getAccessibleIndexInParent()); 625cdf0e10cSrcweir } 626cdf0e10cSrcweir } 627cdf0e10cSrcweir 628cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getForeground( ) 629cdf0e10cSrcweir throw (uno::RuntimeException) 630cdf0e10cSrcweir { 631cdf0e10cSrcweir ScUnoGuard aGuard; 632cdf0e10cSrcweir IsObjectValid(); 633cdf0e10cSrcweir sal_Int32 nColor(0); 634cdf0e10cSrcweir if (mpFieldWindow) 635cdf0e10cSrcweir { 636cdf0e10cSrcweir nColor = mpFieldWindow->GetSettings().GetStyleSettings().GetButtonTextColor().GetColor(); 637cdf0e10cSrcweir } 638cdf0e10cSrcweir return nColor; 639cdf0e10cSrcweir } 640cdf0e10cSrcweir 641cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getBackground( ) 642cdf0e10cSrcweir throw (uno::RuntimeException) 643cdf0e10cSrcweir { 644cdf0e10cSrcweir ScUnoGuard aGuard; 645cdf0e10cSrcweir IsObjectValid(); 646cdf0e10cSrcweir sal_Int32 nColor(0); 647cdf0e10cSrcweir if (mpFieldWindow) 648cdf0e10cSrcweir { 649cdf0e10cSrcweir nColor = mpFieldWindow->GetSettings().GetStyleSettings().GetFaceColor().GetColor(); 650cdf0e10cSrcweir } 651cdf0e10cSrcweir return nColor; 652cdf0e10cSrcweir } 653cdf0e10cSrcweir 654cdf0e10cSrcweir ///===== XAccessibleContext ============================================== 655cdf0e10cSrcweir 656cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getAccessibleChildCount(void) 657cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 658cdf0e10cSrcweir { 659cdf0e10cSrcweir return 0; 660cdf0e10cSrcweir } 661cdf0e10cSrcweir 662cdf0e10cSrcweir uno::Reference< XAccessible> SAL_CALL ScAccessibleDataPilotButton::getAccessibleChild(sal_Int32 /* nIndex */) 663cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException, 664cdf0e10cSrcweir ::com::sun::star::lang::IndexOutOfBoundsException) 665cdf0e10cSrcweir { 666cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 667cdf0e10cSrcweir } 668cdf0e10cSrcweir 669cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getAccessibleIndexInParent(void) 670cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 671cdf0e10cSrcweir { 672cdf0e10cSrcweir ScUnoGuard aGuard; 673cdf0e10cSrcweir IsObjectValid(); 674cdf0e10cSrcweir return mnIndex; 675cdf0e10cSrcweir } 676cdf0e10cSrcweir 677cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessibleDataPilotButton::getAccessibleStateSet(void) 678cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 679cdf0e10cSrcweir { 680cdf0e10cSrcweir ScUnoGuard aGuard; 681cdf0e10cSrcweir IsObjectValid(); 682cdf0e10cSrcweir 683cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); 684cdf0e10cSrcweir 685cdf0e10cSrcweir if (IsDefunc()) 686cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::DEFUNC); 687cdf0e10cSrcweir else 688cdf0e10cSrcweir { 689cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::ENABLED); 690cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::OPAQUE); 691cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::FOCUSABLE); 692cdf0e10cSrcweir if (mpFieldWindow && (sal::static_int_cast<sal_Int32>(mpFieldWindow->GetSelectedIndex()) == mnIndex)) 693cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::FOCUSED); 694cdf0e10cSrcweir if (isShowing()) 695cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SHOWING); 696cdf0e10cSrcweir if (isVisible()) 697cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::VISIBLE); 698cdf0e10cSrcweir } 699cdf0e10cSrcweir 700cdf0e10cSrcweir return pStateSet; 701cdf0e10cSrcweir } 702*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 703*0deba7fbSSteve Yin ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > 704*0deba7fbSSteve Yin SAL_CALL ScAccessibleDataPilotButton::getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException) 705*0deba7fbSSteve Yin { 706*0deba7fbSSteve Yin utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; 707*0deba7fbSSteve Yin uno::Reference< accessibility::XAccessibleRelationSet > xSet = pRelationSetHelper; 708*0deba7fbSSteve Yin if(mxParent.is()) 709*0deba7fbSSteve Yin { 710*0deba7fbSSteve Yin uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1); 711*0deba7fbSSteve Yin aSequence[0] = mxParent; 712*0deba7fbSSteve Yin pRelationSetHelper->AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) ); 713*0deba7fbSSteve Yin } 714cdf0e10cSrcweir 715*0deba7fbSSteve Yin return xSet; 716*0deba7fbSSteve Yin 717*0deba7fbSSteve Yin } 718*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 719cdf0e10cSrcweir ///===== XServiceInfo ==================================================== 720cdf0e10cSrcweir 721cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::getImplementationName(void) 722cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 723cdf0e10cSrcweir { 724cdf0e10cSrcweir return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleDataPilotButton")); 725cdf0e10cSrcweir } 726cdf0e10cSrcweir 727cdf0e10cSrcweir ///===== XTypeProvider =================================================== 728cdf0e10cSrcweir 729cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL ScAccessibleDataPilotButton::getImplementationId(void) 730cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 731cdf0e10cSrcweir { 732cdf0e10cSrcweir ScUnoGuard aGuard; 733cdf0e10cSrcweir IsObjectValid(); 734cdf0e10cSrcweir static uno::Sequence<sal_Int8> aId; 735cdf0e10cSrcweir if (aId.getLength() == 0) 736cdf0e10cSrcweir { 737cdf0e10cSrcweir aId.realloc (16); 738cdf0e10cSrcweir rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True); 739cdf0e10cSrcweir } 740cdf0e10cSrcweir return aId; 741cdf0e10cSrcweir } 742cdf0e10cSrcweir 743cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::createAccessibleDescription(void) 744cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 745cdf0e10cSrcweir { 746*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 747*0deba7fbSSteve Yin if (mpFieldWindow) 748*0deba7fbSSteve Yin return mpFieldWindow->GetHelpText(); 749*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 750cdf0e10cSrcweir return rtl::OUString(); 751cdf0e10cSrcweir } 752cdf0e10cSrcweir 753cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::createAccessibleName(void) 754cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 755cdf0e10cSrcweir { 756cdf0e10cSrcweir ScUnoGuard aGuard; 757cdf0e10cSrcweir IsObjectValid(); 758cdf0e10cSrcweir if (mpFieldWindow) 759cdf0e10cSrcweir return mpFieldWindow->GetFieldText(getAccessibleIndexInParent()); 760cdf0e10cSrcweir 761cdf0e10cSrcweir return rtl::OUString(); 762cdf0e10cSrcweir } 763cdf0e10cSrcweir 764cdf0e10cSrcweir Rectangle ScAccessibleDataPilotButton::GetBoundingBoxOnScreen(void) const 765cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 766cdf0e10cSrcweir { 767cdf0e10cSrcweir Rectangle aRect(GetBoundingBox()); 768cdf0e10cSrcweir 769cdf0e10cSrcweir if (mpFieldWindow) 770cdf0e10cSrcweir { 771cdf0e10cSrcweir Point aParentPos(mpFieldWindow->GetWindowExtentsRelative(NULL).TopLeft()); 772cdf0e10cSrcweir aRect.Move(aParentPos.getX(), aParentPos.getY()); 773cdf0e10cSrcweir } 774cdf0e10cSrcweir 775cdf0e10cSrcweir return aRect; 776cdf0e10cSrcweir } 777cdf0e10cSrcweir 778cdf0e10cSrcweir Rectangle ScAccessibleDataPilotButton::GetBoundingBox(void) const 779cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 780cdf0e10cSrcweir { 781cdf0e10cSrcweir if (mpFieldWindow) 782cdf0e10cSrcweir return Rectangle (mpFieldWindow->GetFieldPosition(const_cast<ScAccessibleDataPilotButton*> (this)->getAccessibleIndexInParent()), mpFieldWindow->GetFieldSize()); 783cdf0e10cSrcweir else 784cdf0e10cSrcweir return Rectangle(); 785cdf0e10cSrcweir } 786*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 787*0deba7fbSSteve Yin // ----------------------------------------------------------------------------- 788*0deba7fbSSteve Yin // XAccessibleAction 789*0deba7fbSSteve Yin // ----------------------------------------------------------------------------- 790*0deba7fbSSteve Yin sal_Int32 ScAccessibleDataPilotButton::getAccessibleActionCount( ) throw (uno::RuntimeException) 791*0deba7fbSSteve Yin { 792*0deba7fbSSteve Yin return 1; 793*0deba7fbSSteve Yin } 794*0deba7fbSSteve Yin // ----------------------------------------------------------------------------- 795*0deba7fbSSteve Yin sal_Bool ScAccessibleDataPilotButton::doAccessibleAction ( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 796*0deba7fbSSteve Yin { 797*0deba7fbSSteve Yin if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) 798*0deba7fbSSteve Yin throw lang::IndexOutOfBoundsException(); 799*0deba7fbSSteve Yin return sal_True; 800*0deba7fbSSteve Yin } 801*0deba7fbSSteve Yin // ----------------------------------------------------------------------------- 802*0deba7fbSSteve Yin ::rtl::OUString ScAccessibleDataPilotButton::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 803*0deba7fbSSteve Yin { 804*0deba7fbSSteve Yin if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) 805*0deba7fbSSteve Yin throw lang::IndexOutOfBoundsException(); 806*0deba7fbSSteve Yin return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "press" ) ); 807*0deba7fbSSteve Yin } 808*0deba7fbSSteve Yin // ----------------------------------------------------------------------------- 809*0deba7fbSSteve Yin ::com::sun::star::uno::Reference< XAccessibleKeyBinding > ScAccessibleDataPilotButton::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 810*0deba7fbSSteve Yin { 811*0deba7fbSSteve Yin if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) 812*0deba7fbSSteve Yin throw lang::IndexOutOfBoundsException(); 813*0deba7fbSSteve Yin comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper = new comphelper::OAccessibleKeyBindingHelper(); 814*0deba7fbSSteve Yin ::com::sun::star::uno::Reference< XAccessibleKeyBinding > xKeyBinding = pKeyBindingHelper; 815*0deba7fbSSteve Yin ScPivotFieldWindow* pWindow = mpFieldWindow; 816*0deba7fbSSteve Yin if ( pWindow ) 817*0deba7fbSSteve Yin { 818*0deba7fbSSteve Yin awt::KeyStroke aKeyStroke; 819*0deba7fbSSteve Yin aKeyStroke.Modifiers = 0; 820*0deba7fbSSteve Yin aKeyStroke.KeyCode = KEY_SPACE; 821*0deba7fbSSteve Yin pKeyBindingHelper->AddKeyBinding( aKeyStroke ); 822*0deba7fbSSteve Yin } 823*0deba7fbSSteve Yin return xKeyBinding; 824*0deba7fbSSteve Yin } 825*0deba7fbSSteve Yin //===== XInterface ===================================================== 826*0deba7fbSSteve Yin uno::Any SAL_CALL ScAccessibleDataPilotButton::queryInterface( uno::Type const & rType ) 827*0deba7fbSSteve Yin throw (::com::sun::star::uno::RuntimeException) 828*0deba7fbSSteve Yin { 829*0deba7fbSSteve Yin uno::Any aAny (ScAccessibleContextBase::queryInterface(rType)); 830*0deba7fbSSteve Yin if(!aAny.hasValue()) 831*0deba7fbSSteve Yin { 832*0deba7fbSSteve Yin aAny = ::cppu::queryInterface (rType, 833*0deba7fbSSteve Yin static_cast<XAccessibleAction*>(this) 834*0deba7fbSSteve Yin ); 835*0deba7fbSSteve Yin } 836*0deba7fbSSteve Yin return aAny; 837*0deba7fbSSteve Yin } 838*0deba7fbSSteve Yin void SAL_CALL ScAccessibleDataPilotButton::acquire() 839*0deba7fbSSteve Yin throw () 840*0deba7fbSSteve Yin { 841*0deba7fbSSteve Yin ScAccessibleContextBase::acquire(); 842*0deba7fbSSteve Yin } 843*0deba7fbSSteve Yin void SAL_CALL ScAccessibleDataPilotButton::release() 844*0deba7fbSSteve Yin throw () 845*0deba7fbSSteve Yin { 846*0deba7fbSSteve Yin ScAccessibleContextBase::release(); 847*0deba7fbSSteve Yin } 848*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 849*0deba7fbSSteve Yin 850