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