LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/Accessibility - AccessibleDataPilotControl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 297 0.3 %
Date: 2013-07-09 Functions: 2 51 3.9 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10