LCOV - code coverage report
Current view: top level - svx/source/accessibility - AccessibleShape.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 267 403 66.3 %
Date: 2012-08-25 Functions: 32 41 78.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 247 783 31.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <svx/AccessibleShape.hxx>
      30                 :            : #include "svx/DescriptionGenerator.hxx"
      31                 :            : #include <svx/AccessibleShapeInfo.hxx>
      32                 :            : #include <com/sun/star/view/XSelectionSupplier.hpp>
      33                 :            : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      34                 :            : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      35                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      36                 :            : #include <com/sun/star/container/XChild.hpp>
      37                 :            : #include <com/sun/star/drawing/XShapes.hpp>
      38                 :            : #include <com/sun/star/drawing/XShapeDescriptor.hpp>
      39                 :            : #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
      40                 :            : #include <com/sun/star/drawing/FillStyle.hpp>
      41                 :            : #include <com/sun/star/text/XText.hpp>
      42                 :            : #include <editeng/outlobj.hxx>
      43                 :            : #include <rtl/ref.hxx>
      44                 :            : #include <editeng/unoedsrc.hxx>
      45                 :            : #include <svx/unoshtxt.hxx>
      46                 :            : #include <svx/svdobj.hxx>
      47                 :            : #include <svx/svdmodel.hxx>
      48                 :            : #include "svx/unoapi.hxx"
      49                 :            : #include <com/sun/star/uno/Exception.hpp>
      50                 :            : #include <svx/ShapeTypeHandler.hxx>
      51                 :            : #include <svx/SvxShapeTypes.hxx>
      52                 :            : 
      53                 :            : #include "accessibility.hrc"
      54                 :            : #include "svx/svdstr.hrc"
      55                 :            : #include <svx/dialmgr.hxx>
      56                 :            : #include <vcl/svapp.hxx>
      57                 :            : #include <unotools/accessiblestatesethelper.hxx>
      58                 :            : #include <svx/svdview.hxx>
      59                 :            : #include <comphelper/servicehelper.hxx>
      60                 :            : #include "AccessibleEmptyEditSource.hxx"
      61                 :            : 
      62                 :            : using namespace ::com::sun::star;
      63                 :            : using namespace ::com::sun::star::accessibility;
      64                 :            : using ::com::sun::star::uno::Reference;
      65                 :            : using ::rtl::OUString;
      66                 :            : 
      67                 :            : namespace accessibility {
      68                 :            : 
      69                 :            : namespace {
      70                 :            : 
      71                 :         36 : OUString GetOptionalProperty (
      72                 :            :     const Reference<beans::XPropertySet>& rxSet,
      73                 :            :     const OUString& rsPropertyName)
      74                 :            : {
      75                 :         36 :     OUString sValue;
      76                 :            : 
      77         [ +  - ]:         36 :     if (rxSet.is())
      78                 :            :     {
      79 [ +  - ][ +  - ]:         36 :         const Reference<beans::XPropertySetInfo> xInfo (rxSet->getPropertySetInfo());
      80 [ +  - ][ +  - ]:         36 :         if ( ! xInfo.is() || xInfo->hasPropertyByName(rsPropertyName))
         [ +  - ][ +  - ]
                 [ +  - ]
      81                 :            :         {
      82                 :            :             try
      83                 :            :             {
      84 [ +  - ][ +  - ]:         36 :                 rxSet->getPropertyValue(rsPropertyName) >>= sValue;
      85                 :            :             }
      86         [ #  # ]:          0 :             catch (beans::UnknownPropertyException&)
      87                 :            :             {
      88                 :            :                 // This exception should only be thrown when the property
      89                 :            :                 // does not exits (of course) and the XPropertySetInfo is
      90                 :            :                 // not available.
      91                 :            :             }
      92                 :         36 :         }
      93                 :            :     }
      94         [ #  # ]:         36 :     return sValue;
      95                 :            : }
      96                 :            : 
      97                 :            : } // end of anonymous namespace
      98                 :            : 
      99                 :            : 
     100                 :            : 
     101                 :            : 
     102                 :            : //=====  internal  ============================================================
     103                 :            : 
     104                 :         22 : AccessibleShape::AccessibleShape (
     105                 :            :     const AccessibleShapeInfo& rShapeInfo,
     106                 :            :     const AccessibleShapeTreeInfo& rShapeTreeInfo)
     107                 :            :     : AccessibleContextBase (rShapeInfo.mxParent,AccessibleRole::LIST_ITEM),
     108                 :            :       mpChildrenManager(NULL),
     109                 :            :       mxShape (rShapeInfo.mxShape),
     110                 :            :       maShapeTreeInfo (rShapeTreeInfo),
     111                 :            :       mnIndex (rShapeInfo.mnIndex),
     112                 :            :       m_nIndexInParent(-1),
     113                 :            :       mpText (NULL),
     114 [ +  - ][ +  - ]:         22 :       mpParent (rShapeInfo.mpChildrenManager)
     115                 :            : {
     116                 :         22 :     m_pShape = GetSdrObjectFromXShape(mxShape);
     117         [ +  - ]:         22 :     UpdateNameAndDescription();
     118                 :         22 : }
     119                 :            : 
     120                 :            : 
     121                 :            : 
     122                 :            : 
     123 [ +  - ][ +  - ]:         22 : AccessibleShape::~AccessibleShape (void)
     124                 :            : {
     125         [ -  + ]:         22 :     if (mpChildrenManager != NULL)
     126 [ #  # ][ #  # ]:          0 :         delete mpChildrenManager;
     127         [ -  + ]:         22 :     if (mpText != NULL)
     128 [ #  # ][ #  # ]:          0 :         delete mpText;
     129                 :            :     OSL_TRACE ("~AccessibleShape");
     130                 :            : 
     131                 :            :     // Unregistering from the various broadcasters should be unnecessary
     132                 :            :     // since this destructor would not have been called if one of the
     133                 :            :     // broadcasters would still hold a strong reference to this object.
     134         [ -  + ]:         30 : }
     135                 :            : 
     136                 :            : 
     137                 :            : 
     138                 :            : 
     139                 :         22 : void AccessibleShape::Init (void)
     140                 :            : {
     141                 :            :     // Update the OPAQUE and SELECTED shape.
     142         [ +  - ]:         22 :     UpdateStates ();
     143                 :            : 
     144                 :            :     // Create a children manager when this shape has children of its own.
     145         [ +  - ]:         22 :     Reference<drawing::XShapes> xShapes (mxShape, uno::UNO_QUERY);
     146 [ -  + ][ #  # ]:         22 :     if (xShapes.is() && xShapes->getCount() > 0)
         [ #  # ][ #  # ]
                 [ -  + ]
     147                 :            :         mpChildrenManager = new ChildrenManager (
     148 [ #  # ][ #  # ]:          0 :             this, xShapes, maShapeTreeInfo, *this);
                 [ #  # ]
     149         [ -  + ]:         22 :     if (mpChildrenManager != NULL)
     150         [ #  # ]:          0 :         mpChildrenManager->Update();
     151                 :            : 
     152                 :            :     // Register at model as document::XEventListener.
     153 [ +  - ][ +  - ]:         22 :     if (maShapeTreeInfo.GetModelBroadcaster().is())
     154 [ +  - ][ +  - ]:         44 :         maShapeTreeInfo.GetModelBroadcaster()->addEventListener (
     155 [ +  - ][ +  - ]:         22 :             static_cast<document::XEventListener*>(this));
     156                 :            : 
     157                 :            :     // Beware! Here we leave the paths of the UNO API and descend into the
     158                 :            :     // depths of the core.  Necessary for makeing the edit engine
     159                 :            :     // accessible.
     160         [ +  - ]:         22 :     Reference<text::XText> xText (mxShape, uno::UNO_QUERY);
     161         [ +  + ]:         22 :     if (xText.is())
     162                 :            :     {
     163         [ +  - ]:          8 :         SdrView* pView = maShapeTreeInfo.GetSdrView ();
     164         [ +  - ]:          8 :         const Window* pWindow = maShapeTreeInfo.GetWindow ();
     165 [ +  - ][ +  - ]:          8 :         if (pView != NULL && pWindow != NULL && mxShape.is())
         [ +  - ][ +  - ]
     166                 :            :         {
     167                 :            :             // #107948# Determine whether shape text is empty
     168                 :          8 :             SdrObject* pSdrObject = GetSdrObjectFromXShape(mxShape);
     169         [ +  - ]:          8 :             if( pSdrObject )
     170                 :            :             {
     171 [ +  - ][ +  - ]:          8 :                 SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, pSdrObject );
         [ +  - ][ +  - ]
     172                 :          8 :                 OutlinerParaObject* pOutlinerParaObject = NULL;
     173                 :            : 
     174         [ +  - ]:          8 :                 if( pTextObj )
     175         [ +  - ]:          8 :                     pOutlinerParaObject = pTextObj->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active
     176                 :            : 
     177                 :          8 :                 bool bOwnParaObj = pOutlinerParaObject != NULL;
     178                 :            : 
     179 [ +  - ][ +  - ]:          8 :                 if( !pOutlinerParaObject && pSdrObject )
     180         [ +  - ]:          8 :                     pOutlinerParaObject = pSdrObject->GetOutlinerParaObject();
     181                 :            : 
     182                 :            :                 // create AccessibleTextHelper to handle this shape's text
     183         [ +  - ]:          8 :                 if( !pOutlinerParaObject )
     184                 :            :                 {
     185                 :            :                     // empty text -> use proxy edit source to delay creation of EditEngine
     186                 :            :                     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     187 [ +  - ][ +  - ]:          8 :                     ::std::auto_ptr<SvxEditSource> pEditSource( new AccessibleEmptyEditSource ( *pSdrObject, *pView, *pWindow) );
     188                 :            :                     SAL_WNODEPRECATED_DECLARATIONS_POP
     189 [ +  - ][ +  - ]:          8 :                     mpText = new AccessibleTextHelper( pEditSource );
         [ +  - ][ +  - ]
     190                 :            :                 }
     191                 :            :                 else
     192                 :            :                 {
     193                 :            :                     // non-empty text -> use full-fledged edit source right away
     194                 :            :                     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     195 [ #  # ][ #  # ]:          0 :                     ::std::auto_ptr<SvxEditSource> pEditSource( new SvxTextEditSource ( *pSdrObject, 0, *pView, *pWindow) );
     196                 :            :                     SAL_WNODEPRECATED_DECLARATIONS_POP
     197 [ #  # ][ #  # ]:          0 :                     mpText = new AccessibleTextHelper( pEditSource );
         [ #  # ][ #  # ]
     198                 :            :                 }
     199                 :            : 
     200         [ -  + ]:          8 :                 if( bOwnParaObj )
     201 [ #  # ][ #  # ]:          0 :                     delete pOutlinerParaObject;
     202                 :            : 
     203 [ +  - ][ +  - ]:          8 :                 mpText->SetEventSource(this);
     204                 :            :             }
     205                 :            :         }
     206                 :         22 :     }
     207                 :         22 : }
     208                 :            : 
     209                 :            : 
     210                 :            : 
     211                 :            : 
     212                 :         22 : void AccessibleShape::UpdateStates (void)
     213                 :            : {
     214                 :            :     ::utl::AccessibleStateSetHelper* pStateSet =
     215         [ +  - ]:         22 :         static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
     216         [ -  + ]:         22 :     if (pStateSet == NULL)
     217                 :         22 :         return;
     218                 :            : 
     219                 :            :     // Set the opaque state for certain shape types when their fill style is
     220                 :            :     // solid.
     221                 :         22 :     bool bShapeIsOpaque = false;
     222         [ +  + ]:         22 :     switch (ShapeTypeHandler::Instance().GetTypeId (mxShape))
     223                 :            :     {
     224                 :            :         case DRAWING_PAGE:
     225                 :            :         case DRAWING_RECTANGLE:
     226                 :            :         case DRAWING_TEXT:
     227                 :            :         {
     228         [ +  - ]:          8 :             uno::Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY);
     229         [ +  - ]:          8 :             if (xSet.is())
     230                 :            :             {
     231                 :            :                 try
     232                 :            :                 {
     233                 :            :                     drawing::FillStyle aFillStyle;
     234 [ +  - ][ +  - ]:         16 :                     bShapeIsOpaque =  ( xSet->getPropertyValue (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle"))) >>= aFillStyle)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
           [ #  #  #  #  
                   #  # ]
     235 [ +  - ][ +  - ]:          8 :                                         && aFillStyle == drawing::FillStyle_SOLID;
     236                 :            :                 }
     237         [ #  # ]:          0 :                 catch (::com::sun::star::beans::UnknownPropertyException&)
     238                 :            :                 {
     239                 :            :                     // Ignore.
     240                 :            :                 }
     241                 :          8 :             }
     242                 :            :         }
     243                 :            :     }
     244         [ +  + ]:         22 :     if (bShapeIsOpaque)
     245                 :          8 :         pStateSet->AddState (AccessibleStateType::OPAQUE);
     246                 :            :     else
     247                 :         14 :         pStateSet->RemoveState (AccessibleStateType::OPAQUE);
     248                 :            : 
     249                 :            :     // Set the selected state.
     250                 :         22 :     bool bShapeIsSelected = false;
     251                 :            :     // XXX fix_me this has to be done with an extra interface later on
     252 [ +  + ][ +  - ]:         22 :     if ( m_pShape && maShapeTreeInfo.GetSdrView() )
                 [ +  + ]
     253                 :            :     {
     254                 :          8 :         bShapeIsSelected = maShapeTreeInfo.GetSdrView()->IsObjMarked(m_pShape) == sal_True;
     255                 :            :     }
     256                 :            : 
     257         [ -  + ]:         22 :     if (bShapeIsSelected)
     258                 :          0 :         pStateSet->AddState (AccessibleStateType::SELECTED);
     259                 :            :     else
     260                 :         22 :         pStateSet->RemoveState (AccessibleStateType::SELECTED);
     261                 :            : }
     262                 :            : 
     263                 :            : 
     264                 :            : 
     265                 :            : 
     266                 :          0 : bool AccessibleShape::operator== (const AccessibleShape& rShape)
     267                 :            : {
     268                 :          0 :     return this==&rShape;
     269                 :            : }
     270                 :            : 
     271                 :            : 
     272                 :            : 
     273                 :            : 
     274                 :         38 : sal_Bool AccessibleShape::SetState (sal_Int16 aState)
     275                 :            : {
     276                 :         38 :     sal_Bool bStateHasChanged = sal_False;
     277                 :            : 
     278 [ +  + ][ +  - ]:         38 :     if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
     279                 :            :     {
     280                 :            :         // Offer FOCUSED state to edit engine and detect whether the state
     281                 :            :         // changes.
     282                 :          2 :         sal_Bool bIsFocused = mpText->HaveFocus ();
     283                 :          2 :         mpText->SetFocus (sal_True);
     284                 :          2 :         bStateHasChanged = (bIsFocused != mpText->HaveFocus ());
     285                 :            :     }
     286                 :            :     else
     287                 :         36 :         bStateHasChanged = AccessibleContextBase::SetState (aState);
     288                 :            : 
     289                 :         38 :     return bStateHasChanged;
     290                 :            : }
     291                 :            : 
     292                 :            : 
     293                 :            : 
     294                 :            : 
     295                 :          0 : sal_Bool AccessibleShape::ResetState (sal_Int16 aState)
     296                 :            : {
     297                 :          0 :     sal_Bool bStateHasChanged = sal_False;
     298                 :            : 
     299 [ #  # ][ #  # ]:          0 :     if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
     300                 :            :     {
     301                 :            :         // Try to remove FOCUSED state from the edit engine and detect
     302                 :            :         // whether the state changes.
     303                 :          0 :         sal_Bool bIsFocused = mpText->HaveFocus ();
     304                 :          0 :         mpText->SetFocus (sal_False);
     305                 :          0 :         bStateHasChanged = (bIsFocused != mpText->HaveFocus ());
     306                 :            :     }
     307                 :            :     else
     308                 :          0 :         bStateHasChanged = AccessibleContextBase::ResetState (aState);
     309                 :            : 
     310                 :          0 :     return bStateHasChanged;
     311                 :            : }
     312                 :            : 
     313                 :            : 
     314                 :            : 
     315                 :            : 
     316                 :          2 : sal_Bool AccessibleShape::GetState (sal_Int16 aState)
     317                 :            : {
     318 [ +  - ][ +  - ]:          2 :     if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
     319                 :            :     {
     320                 :            :         // Just delegate the call to the edit engine.  The state is not
     321                 :            :         // merged into the state set.
     322                 :          2 :         return mpText->HaveFocus();
     323                 :            :     }
     324                 :            :     else
     325                 :          2 :         return AccessibleContextBase::GetState (aState);
     326                 :            : }
     327                 :            : 
     328                 :            : 
     329                 :            : 
     330                 :            : 
     331                 :            : //=====  XAccessibleContext  ==================================================
     332                 :            : 
     333                 :            : /** The children of this shape come from two sources: The children from
     334                 :            :     group or scene shapes and the paragraphs of text.
     335                 :            : */
     336                 :            : sal_Int32 SAL_CALL
     337                 :          8 :        AccessibleShape::getAccessibleChildCount ()
     338                 :            :     throw (::com::sun::star::uno::RuntimeException)
     339                 :            : {
     340                 :          8 :     ThrowIfDisposed ();
     341                 :          8 :     sal_Int32 nChildCount = 0;
     342                 :            : 
     343                 :            :     // Add the number of shapes that are children of this shape.
     344         [ -  + ]:          8 :     if (mpChildrenManager != NULL)
     345                 :          0 :         nChildCount += mpChildrenManager->GetChildCount ();
     346                 :            :     // Add the number text paragraphs.
     347         [ +  - ]:          8 :     if (mpText != NULL)
     348                 :          8 :         nChildCount += mpText->GetChildCount ();
     349                 :            : 
     350                 :          8 :     return nChildCount;
     351                 :            : }
     352                 :            : 
     353                 :            : 
     354                 :            : 
     355                 :            : 
     356                 :            : /** Forward the request to the shape.  Return the requested shape or throw
     357                 :            :     an exception for a wrong index.
     358                 :            : */
     359                 :            : uno::Reference<XAccessible> SAL_CALL
     360                 :          0 :     AccessibleShape::getAccessibleChild (sal_Int32 nIndex)
     361                 :            :     throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
     362                 :            : {
     363                 :          0 :     ThrowIfDisposed ();
     364                 :            : 
     365                 :          0 :     uno::Reference<XAccessible> xChild;
     366                 :            : 
     367                 :            :     // Depending on the index decide whether to delegate this call to the
     368                 :            :     // children manager or the edit engine.
     369         [ #  # ]:          0 :     if ((mpChildrenManager != NULL)
           [ #  #  #  # ]
     370                 :          0 :         && (nIndex < mpChildrenManager->GetChildCount()))
     371                 :            :     {
     372 [ #  # ][ #  # ]:          0 :         xChild = mpChildrenManager->GetChild (nIndex);
     373                 :            :     }
     374         [ #  # ]:          0 :     else if (mpText != NULL)
     375                 :            :     {
     376                 :          0 :         sal_Int32 nI = nIndex;
     377         [ #  # ]:          0 :         if (mpChildrenManager != NULL)
     378                 :          0 :             nI -= mpChildrenManager->GetChildCount();
     379 [ #  # ][ #  # ]:          0 :         xChild = mpText->GetChild (nI);
     380                 :            :     }
     381                 :            :     else
     382                 :            :         throw lang::IndexOutOfBoundsException (
     383                 :            :             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("shape has no child with index "))
     384                 :            :             + rtl::OUString::valueOf(nIndex),
     385 [ #  # ][ #  # ]:          0 :             static_cast<uno::XWeak*>(this));
                 [ #  # ]
     386                 :            : 
     387                 :          0 :     return xChild;
     388                 :            : }
     389                 :            : 
     390                 :            : 
     391                 :            : 
     392                 :            : 
     393                 :            : /** Return a copy of the state set.
     394                 :            :     Possible states are:
     395                 :            :         ENABLED
     396                 :            :         SHOWING
     397                 :            :         VISIBLE
     398                 :            : */
     399                 :            : uno::Reference<XAccessibleStateSet> SAL_CALL
     400                 :         10 :     AccessibleShape::getAccessibleStateSet (void)
     401                 :            :     throw (::com::sun::star::uno::RuntimeException)
     402                 :            : {
     403         [ +  - ]:         10 :     ::osl::MutexGuard aGuard (maMutex);
     404                 :         10 :     Reference<XAccessibleStateSet> xStateSet;
     405                 :            : 
     406 [ +  + ][ +  - ]:         10 :     if (rBHelper.bDisposed || mpText == NULL)
     407                 :            :         // Return a minimal state set that only contains the DEFUNC state.
     408 [ +  - ][ +  - ]:          4 :         xStateSet = AccessibleContextBase::getAccessibleStateSet ();
     409                 :            :     else
     410                 :            :     {
     411                 :            :         ::utl::AccessibleStateSetHelper* pStateSet =
     412 [ +  - ][ +  - ]:          6 :               static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
     413                 :            : 
     414         [ +  - ]:          6 :         if (pStateSet != NULL)
     415                 :            :         {
     416                 :            :             // Merge current FOCUSED state from edit engine.
     417         [ +  - ]:          6 :             if (mpText != NULL)
     418                 :            :             {
     419 [ +  - ][ +  + ]:          6 :                 if (mpText->HaveFocus())
     420         [ +  - ]:          2 :                     pStateSet->AddState (AccessibleStateType::FOCUSED);
     421                 :            :                 else
     422         [ +  - ]:          4 :                     pStateSet->RemoveState (AccessibleStateType::FOCUSED);
     423                 :            :             }
     424                 :            : 
     425                 :            :             // Create a copy of the state set that may be modified by the
     426                 :            :             // caller without affecting the current state set.
     427                 :            :             xStateSet = Reference<XAccessibleStateSet>(
     428 [ +  - ][ +  - ]:          6 :                 new ::utl::AccessibleStateSetHelper (*pStateSet));
         [ +  - ][ +  - ]
     429                 :            :         }
     430                 :            :     }
     431                 :            : 
     432         [ +  - ]:         10 :     return xStateSet;
     433                 :            : }
     434                 :            : 
     435                 :            : 
     436                 :            : 
     437                 :            : 
     438                 :            : //=====  XAccessibleComponent  ================================================
     439                 :            : 
     440                 :            : /** The implementation below is at the moment straightforward.  It iterates
     441                 :            :     over all children (and thereby instances all children which have not
     442                 :            :     been already instatiated) until a child covering the specifed point is
     443                 :            :     found.
     444                 :            :     This leaves room for improvement.  For instance, first iterate only over
     445                 :            :     the already instantiated children and only if no match is found
     446                 :            :     instantiate the remaining ones.
     447                 :            : */
     448                 :            : uno::Reference<XAccessible > SAL_CALL
     449                 :          0 :     AccessibleShape::getAccessibleAtPoint (
     450                 :            :         const awt::Point& aPoint)
     451                 :            :     throw (uno::RuntimeException)
     452                 :            : {
     453         [ #  # ]:          0 :     ::osl::MutexGuard aGuard (maMutex);
     454                 :            : 
     455         [ #  # ]:          0 :     sal_Int32 nChildCount = getAccessibleChildCount ();
     456         [ #  # ]:          0 :     for (sal_Int32 i=0; i<nChildCount; ++i)
     457                 :            :     {
     458         [ #  # ]:          0 :         Reference<XAccessible> xChild (getAccessibleChild (i));
     459         [ #  # ]:          0 :         if (xChild.is())
     460                 :            :         {
     461                 :            :             Reference<XAccessibleComponent> xChildComponent (
     462 [ #  # ][ #  # ]:          0 :                 xChild->getAccessibleContext(), uno::UNO_QUERY);
                 [ #  # ]
     463         [ #  # ]:          0 :             if (xChildComponent.is())
     464                 :            :             {
     465 [ #  # ][ #  # ]:          0 :                 awt::Rectangle aBBox (xChildComponent->getBounds());
     466 [ #  # ][ #  # ]:          0 :                 if ( (aPoint.X >= aBBox.X)
         [ #  # ][ #  # ]
     467                 :            :                     && (aPoint.Y >= aBBox.Y)
     468                 :            :                     && (aPoint.X < aBBox.X+aBBox.Width)
     469                 :            :                     && (aPoint.Y < aBBox.Y+aBBox.Height) )
     470                 :          0 :                     return xChild;
     471         [ #  # ]:          0 :             }
     472                 :            :         }
     473         [ #  # ]:          0 :     }
     474                 :            : 
     475                 :            :     // Have not found a child under the given point.  Returning empty
     476                 :            :     // reference to indicate this.
     477         [ #  # ]:          0 :     return uno::Reference<XAccessible>();
     478                 :            : }
     479                 :            : 
     480                 :            : 
     481                 :            : 
     482                 :            : 
     483                 :        464 : awt::Rectangle SAL_CALL AccessibleShape::getBounds (void)
     484                 :            :     throw (::com::sun::star::uno::RuntimeException)
     485                 :            : {
     486         [ +  - ]:        464 :     SolarMutexGuard aSolarGuard;
     487         [ +  - ]:        464 :     ::osl::MutexGuard aGuard (maMutex);
     488                 :            : 
     489         [ +  - ]:        464 :     ThrowIfDisposed ();
     490                 :        464 :     awt::Rectangle aBoundingBox;
     491         [ +  - ]:        464 :     if ( mxShape.is() )
     492                 :            :     {
     493                 :            : 
     494                 :            :         static const OUString sBoundRectName (
     495 [ +  + ][ +  - ]:        464 :             RTL_CONSTASCII_USTRINGPARAM("BoundRect"));
         [ +  - ][ #  # ]
     496                 :            :         static const OUString sAnchorPositionName (
     497 [ +  + ][ +  - ]:        464 :             RTL_CONSTASCII_USTRINGPARAM("AnchorPosition"));
         [ +  - ][ #  # ]
     498                 :            : 
     499                 :            :         // Get the shape's bounding box in internal coordinates (in 100th of
     500                 :            :         // mm).  Use the property BoundRect.  Only if that is not supported ask
     501                 :            :         // the shape for its position and size directly.
     502         [ +  - ]:        464 :         Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY);
     503                 :        464 :         Reference<beans::XPropertySetInfo> xSetInfo;
     504                 :        464 :         bool bFoundBoundRect = false;
     505         [ +  - ]:        464 :         if (xSet.is())
     506                 :            :         {
     507 [ +  - ][ +  - ]:        464 :             xSetInfo = xSet->getPropertySetInfo ();
                 [ +  - ]
     508         [ +  - ]:        464 :             if (xSetInfo.is())
     509                 :            :             {
     510 [ +  - ][ +  - ]:        464 :                 if (xSetInfo->hasPropertyByName (sBoundRectName))
                 [ +  - ]
     511                 :            :                 {
     512                 :            :                     try
     513                 :            :                     {
     514 [ +  - ][ +  - ]:        464 :                         uno::Any aValue = xSet->getPropertyValue (sBoundRectName);
     515         [ +  - ]:        464 :                         aValue >>= aBoundingBox;
     516         [ #  # ]:        464 :                         bFoundBoundRect = true;
     517                 :            :                     }
     518         [ #  # ]:          0 :                     catch (beans::UnknownPropertyException const&)
     519                 :            :                     {
     520                 :            :                         // Handled below (bFoundBoundRect stays false).
     521                 :            :                     }
     522                 :            :                 }
     523                 :            :                 else
     524                 :            :                     OSL_TRACE (" no property BoundRect");
     525                 :            :             }
     526                 :            :         }
     527                 :            : 
     528                 :            :         // Fallback when there is no BoundRect Property.
     529         [ -  + ]:        464 :         if ( ! bFoundBoundRect )
     530                 :            :         {
     531 [ #  # ][ #  # ]:          0 :             awt::Point aPosition (mxShape->getPosition());
     532 [ #  # ][ #  # ]:          0 :             awt::Size aSize (mxShape->getSize());
     533                 :            :             aBoundingBox = awt::Rectangle (
     534                 :            :                 aPosition.X, aPosition.Y,
     535                 :          0 :                 aSize.Width, aSize.Height);
     536                 :            : 
     537                 :            :             // While BoundRects have absolute positions, the position returned
     538                 :            :             // by XPosition::getPosition is relative.  Get the anchor position
     539                 :            :             // (usually not (0,0) for Writer shapes).
     540         [ #  # ]:          0 :             if (xSetInfo.is())
     541                 :            :             {
     542 [ #  # ][ #  # ]:          0 :                 if (xSetInfo->hasPropertyByName (sAnchorPositionName))
                 [ #  # ]
     543                 :            :                 {
     544 [ #  # ][ #  # ]:          0 :                     uno::Any aPos = xSet->getPropertyValue (sAnchorPositionName);
     545                 :          0 :                     awt::Point aAnchorPosition;
     546         [ #  # ]:          0 :                     aPos >>= aAnchorPosition;
     547                 :          0 :                     aBoundingBox.X += aAnchorPosition.X;
     548                 :          0 :                     aBoundingBox.Y += aAnchorPosition.Y;
     549                 :            :                 }
     550                 :            :             }
     551                 :            :         }
     552                 :            : 
     553                 :            :         // Transform coordinates from internal to pixel.
     554 [ +  - ][ -  + ]:        464 :         if (maShapeTreeInfo.GetViewForwarder() == NULL)
     555                 :            :             throw uno::RuntimeException (::rtl::OUString (
     556                 :            :                 RTL_CONSTASCII_USTRINGPARAM(
     557                 :            :                     "AccessibleShape has no valid view forwarder")),
     558 [ #  # ][ #  # ]:          0 :                 static_cast<uno::XWeak*>(this));
                 [ #  # ]
     559         [ +  - ]:        464 :         ::Size aPixelSize = maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
     560         [ +  - ]:        464 :             ::Size (aBoundingBox.Width, aBoundingBox.Height));
     561         [ +  - ]:        464 :         ::Point aPixelPosition = maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
     562         [ +  - ]:        464 :             ::Point (aBoundingBox.X, aBoundingBox.Y));
     563                 :            : 
     564                 :            :         // Clip the shape's bounding box with the bounding box of its parent.
     565                 :            :         Reference<XAccessibleComponent> xParentComponent (
     566 [ +  - ][ +  - ]:        464 :             getAccessibleParent(), uno::UNO_QUERY);
     567         [ +  - ]:        464 :         if (xParentComponent.is())
     568                 :            :         {
     569                 :            :             // Make the coordinates relative to the parent.
     570 [ +  - ][ +  - ]:        464 :             awt::Point aParentLocation (xParentComponent->getLocationOnScreen());
     571                 :        464 :             int x = aPixelPosition.getX() - aParentLocation.X;
     572                 :        464 :             int y = aPixelPosition.getY() - aParentLocation.Y;
     573                 :            : 
     574                 :            :             // Clip with parent (with coordinates relative to itself).
     575                 :            :             ::Rectangle aBBox (
     576         [ +  - ]:        464 :                 x, y, x + aPixelSize.getWidth(), y + aPixelSize.getHeight());
     577 [ +  - ][ +  - ]:        464 :             awt::Size aParentSize (xParentComponent->getSize());
     578         [ +  - ]:        464 :             ::Rectangle aParentBBox (0,0, aParentSize.Width, aParentSize.Height);
     579         [ +  - ]:        464 :             aBBox = aBBox.GetIntersection (aParentBBox);
     580                 :            :             aBoundingBox = awt::Rectangle (
     581                 :        464 :                 aBBox.getX(),
     582                 :        464 :                 aBBox.getY(),
     583                 :        464 :                 aBBox.getWidth(),
     584                 :        928 :                 aBBox.getHeight());
     585                 :            :         }
     586                 :            :         else
     587                 :            :         {
     588                 :            :             OSL_TRACE ("parent does not support component");
     589                 :            :             aBoundingBox = awt::Rectangle (
     590                 :          0 :                 aPixelPosition.getX(), aPixelPosition.getY(),
     591                 :          0 :                 aPixelSize.getWidth(), aPixelSize.getHeight());
     592                 :        464 :         }
     593                 :            :     }
     594                 :            : 
     595 [ +  - ][ +  - ]:        464 :     return aBoundingBox;
     596                 :            : }
     597                 :            : 
     598                 :            : 
     599                 :            : 
     600                 :            : 
     601                 :          4 : awt::Point SAL_CALL AccessibleShape::getLocation (void)
     602                 :            :     throw (::com::sun::star::uno::RuntimeException)
     603                 :            : {
     604         [ +  - ]:          4 :     ThrowIfDisposed ();
     605         [ +  - ]:          4 :     awt::Rectangle aBoundingBox (getBounds());
     606                 :          4 :     return awt::Point (aBoundingBox.X, aBoundingBox.Y);
     607                 :            : }
     608                 :            : 
     609                 :            : 
     610                 :            : 
     611                 :            : 
     612                 :          2 : awt::Point SAL_CALL AccessibleShape::getLocationOnScreen (void)
     613                 :            :     throw (::com::sun::star::uno::RuntimeException)
     614                 :            : {
     615         [ +  - ]:          2 :     ThrowIfDisposed ();
     616                 :            : 
     617                 :            :     // Get relative position...
     618         [ +  - ]:          2 :     awt::Point aLocation (getLocation ());
     619                 :            : 
     620                 :            :     // ... and add absolute position of the parent.
     621                 :            :     uno::Reference<XAccessibleComponent> xParentComponent (
     622 [ +  - ][ +  - ]:          2 :         getAccessibleParent(), uno::UNO_QUERY);
     623         [ +  - ]:          2 :     if (xParentComponent.is())
     624                 :            :     {
     625 [ +  - ][ +  - ]:          2 :         awt::Point aParentLocation (xParentComponent->getLocationOnScreen());
     626                 :          2 :         aLocation.X += aParentLocation.X;
     627                 :          2 :         aLocation.Y += aParentLocation.Y;
     628                 :            :     }
     629                 :            :     else
     630                 :            :         OSL_TRACE ("getLocation: parent does not support XAccessibleComponent");
     631                 :          2 :     return aLocation;
     632                 :            : }
     633                 :            : 
     634                 :            : 
     635                 :            : 
     636                 :            : 
     637                 :        458 : awt::Size SAL_CALL AccessibleShape::getSize (void)
     638                 :            :     throw (uno::RuntimeException)
     639                 :            : {
     640         [ +  - ]:        458 :     ThrowIfDisposed ();
     641         [ +  - ]:        458 :     awt::Rectangle aBoundingBox (getBounds());
     642                 :        458 :     return awt::Size (aBoundingBox.Width, aBoundingBox.Height);
     643                 :            : }
     644                 :            : 
     645                 :            : 
     646                 :            : 
     647                 :            : 
     648                 :          2 : sal_Int32 SAL_CALL AccessibleShape::getForeground (void)
     649                 :            :     throw (::com::sun::star::uno::RuntimeException)
     650                 :            : {
     651         [ +  - ]:          2 :     ThrowIfDisposed ();
     652                 :          2 :     sal_Int32 nColor (0x0ffffffL);
     653                 :            : 
     654                 :            :     try
     655                 :            :     {
     656         [ +  - ]:          2 :         uno::Reference<beans::XPropertySet> aSet (mxShape, uno::UNO_QUERY);
     657         [ +  - ]:          2 :         if (aSet.is())
     658                 :            :         {
     659                 :          2 :             uno::Any aColor;
     660 [ +  - ][ +  - ]:          2 :             aColor = aSet->getPropertyValue (OUString(RTL_CONSTASCII_USTRINGPARAM("LineColor")) );
                 [ +  - ]
     661                 :          2 :             aColor >>= nColor;
     662         [ #  # ]:          2 :         }
     663                 :            :     }
     664         [ #  # ]:          0 :     catch (const ::com::sun::star::beans::UnknownPropertyException &)
     665                 :            :     {
     666                 :            :         // Ignore exception and return default color.
     667                 :            :     }
     668                 :          2 :     return nColor;
     669                 :            : }
     670                 :            : 
     671                 :            : 
     672                 :            : 
     673                 :            : 
     674                 :          2 : sal_Int32 SAL_CALL AccessibleShape::getBackground (void)
     675                 :            :     throw (::com::sun::star::uno::RuntimeException)
     676                 :            : {
     677         [ +  - ]:          2 :     ThrowIfDisposed ();
     678                 :          2 :     sal_Int32 nColor (0L);
     679                 :            : 
     680                 :            :     try
     681                 :            :     {
     682         [ +  - ]:          2 :         uno::Reference<beans::XPropertySet> aSet (mxShape, uno::UNO_QUERY);
     683         [ +  - ]:          2 :         if (aSet.is())
     684                 :            :         {
     685                 :          2 :             uno::Any aColor;
     686 [ +  - ][ +  - ]:          2 :             aColor = aSet->getPropertyValue (OUString(RTL_CONSTASCII_USTRINGPARAM("FillColor")) );
                 [ +  - ]
     687                 :          2 :             aColor >>= nColor;
     688         [ #  # ]:          2 :         }
     689                 :            :     }
     690         [ #  # ]:          0 :     catch (const ::com::sun::star::beans::UnknownPropertyException &)
     691                 :            :     {
     692                 :            :         // Ignore exception and return default color.
     693                 :            :     }
     694                 :          2 :     return nColor;
     695                 :            : }
     696                 :            : 
     697                 :            : 
     698                 :            : 
     699                 :            : 
     700                 :            : //=====  XAccessibleEventBroadcaster  =========================================
     701                 :            : 
     702                 :          2 : void SAL_CALL AccessibleShape::addEventListener (
     703                 :            :     const Reference<XAccessibleEventListener >& rxListener)
     704                 :            :     throw (uno::RuntimeException)
     705                 :            : {
     706 [ +  - ][ -  + ]:          2 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     707                 :            :     {
     708                 :            :         uno::Reference<uno::XInterface> xThis (
     709         [ #  # ]:          0 :             (lang::XComponent *)this, uno::UNO_QUERY);
     710 [ #  # ][ #  # ]:          0 :         rxListener->disposing (lang::EventObject (xThis));
         [ #  # ][ #  # ]
     711                 :            :     }
     712                 :            :     else
     713                 :            :     {
     714                 :          2 :         AccessibleContextBase::addEventListener (rxListener);
     715         [ +  - ]:          2 :         if (mpText != NULL)
     716                 :          2 :             mpText->AddEventListener (rxListener);
     717                 :            :     }
     718                 :          2 : }
     719                 :            : 
     720                 :            : 
     721                 :            : 
     722                 :            : 
     723                 :          2 : void SAL_CALL AccessibleShape::removeEventListener (
     724                 :            :     const Reference<XAccessibleEventListener >& rxListener)
     725                 :            :     throw (uno::RuntimeException)
     726                 :            : {
     727                 :          2 :     AccessibleContextBase::removeEventListener (rxListener);
     728         [ +  - ]:          2 :     if (mpText != NULL)
     729                 :          2 :         mpText->RemoveEventListener (rxListener);
     730                 :          2 : }
     731                 :            : 
     732                 :            : 
     733                 :            : 
     734                 :            : 
     735                 :            : //=====  XInterface  ==========================================================
     736                 :            : 
     737                 :            : com::sun::star::uno::Any SAL_CALL
     738                 :        162 :     AccessibleShape::queryInterface (const com::sun::star::uno::Type & rType)
     739                 :            :     throw (::com::sun::star::uno::RuntimeException)
     740                 :            : {
     741                 :        162 :     ::com::sun::star::uno::Any aReturn = AccessibleContextBase::queryInterface (rType);
     742         [ +  + ]:        162 :     if ( ! aReturn.hasValue())
     743                 :            :         aReturn = ::cppu::queryInterface (rType,
     744                 :            :             static_cast<XAccessibleComponent*>(this),
     745                 :            :             static_cast<XAccessibleExtendedComponent*>(this),
     746                 :            :             static_cast<lang::XEventListener*>(this),
     747                 :            :             static_cast<document::XEventListener*>(this),
     748                 :            :             static_cast<lang::XUnoTunnel*>(this)
     749         [ +  - ]:         64 :             );
     750                 :        162 :     return aReturn;
     751                 :            : }
     752                 :            : 
     753                 :            : 
     754                 :            : 
     755                 :            : 
     756                 :            : void SAL_CALL
     757                 :        730 :     AccessibleShape::acquire (void)
     758                 :            :     throw ()
     759                 :            : {
     760                 :        730 :     AccessibleContextBase::acquire ();
     761                 :        730 : }
     762                 :            : 
     763                 :            : 
     764                 :            : 
     765                 :            : 
     766                 :            : void SAL_CALL
     767                 :        730 :     AccessibleShape::release (void)
     768                 :            :     throw ()
     769                 :            : {
     770                 :        730 :     AccessibleContextBase::release ();
     771                 :        730 : }
     772                 :            : 
     773                 :            : 
     774                 :            : 
     775                 :            : 
     776                 :            : //=====  XServiceInfo  ========================================================
     777                 :            : 
     778                 :            : ::rtl::OUString SAL_CALL
     779                 :          6 :     AccessibleShape::getImplementationName (void)
     780                 :            :     throw (::com::sun::star::uno::RuntimeException)
     781                 :            : {
     782                 :          6 :     return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleShape"));
     783                 :            : }
     784                 :            : 
     785                 :            : 
     786                 :            : 
     787                 :            : 
     788                 :            : uno::Sequence<OUString> SAL_CALL
     789                 :          0 :     AccessibleShape::getSupportedServiceNames (void)
     790                 :            :     throw (::com::sun::star::uno::RuntimeException)
     791                 :            : {
     792                 :          0 :     ThrowIfDisposed ();
     793                 :            :     // Get list of supported service names from base class...
     794                 :            :     uno::Sequence<OUString> aServiceNames =
     795                 :          0 :         AccessibleContextBase::getSupportedServiceNames();
     796                 :          0 :     sal_Int32 nCount (aServiceNames.getLength());
     797                 :            : 
     798                 :            :     // ...and add additional names.
     799         [ #  # ]:          0 :     aServiceNames.realloc (nCount + 1);
     800                 :            :     static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM(
     801 [ #  # ][ #  # ]:          0 :         "com.sun.star.drawing.AccessibleShape"));
         [ #  # ][ #  # ]
     802         [ #  # ]:          0 :     aServiceNames[nCount] = sAdditionalServiceName;
     803                 :            : 
     804                 :          0 :     return aServiceNames;
     805                 :            : }
     806                 :            : 
     807                 :            : 
     808                 :            : 
     809                 :            : 
     810                 :            : 
     811                 :            : //=====  XTypeProvider  ===================================================
     812                 :            : 
     813                 :            : uno::Sequence<uno::Type> SAL_CALL
     814                 :          0 :     AccessibleShape::getTypes (void)
     815                 :            :     throw (uno::RuntimeException)
     816                 :            : {
     817         [ #  # ]:          0 :     ThrowIfDisposed ();
     818                 :            :     // Get list of types from the context base implementation, ...
     819         [ #  # ]:          0 :     uno::Sequence<uno::Type> aTypeList (AccessibleContextBase::getTypes());
     820                 :            :     // ... get list of types from component base implementation, ...
     821         [ #  # ]:          0 :     uno::Sequence<uno::Type> aComponentTypeList (AccessibleComponentBase::getTypes());
     822                 :            :     // ... define local types, ...
     823                 :            :     const uno::Type aLangEventListenerType =
     824         [ #  # ]:          0 :         ::getCppuType((const uno::Reference<lang::XEventListener>*)0);
     825                 :            :     const uno::Type aDocumentEventListenerType =
     826         [ #  # ]:          0 :         ::getCppuType((const uno::Reference<document::XEventListener>*)0);
     827                 :            :     const uno::Type aUnoTunnelType =
     828         [ #  # ]:          0 :         ::getCppuType((const uno::Reference<lang::XUnoTunnel>*)0);
     829                 :            : 
     830                 :            :     // ... and merge them all into one list.
     831                 :          0 :     sal_Int32   nTypeCount (aTypeList.getLength()),
     832                 :          0 :         nComponentTypeCount (aComponentTypeList.getLength());
     833                 :            :     int         i;
     834                 :            : 
     835         [ #  # ]:          0 :     aTypeList.realloc (nTypeCount + nComponentTypeCount + 3);
     836                 :            : 
     837         [ #  # ]:          0 :     for (i=0; i<nComponentTypeCount; i++)
     838 [ #  # ][ #  # ]:          0 :         aTypeList[nTypeCount + i] = aComponentTypeList[i];
     839                 :            : 
     840         [ #  # ]:          0 :     aTypeList[nTypeCount + i++ ] = aLangEventListenerType;
     841         [ #  # ]:          0 :     aTypeList[nTypeCount + i++ ] = aDocumentEventListenerType;
     842         [ #  # ]:          0 :     aTypeList[nTypeCount + i ] = aUnoTunnelType;
     843                 :            : 
     844         [ #  # ]:          0 :     return aTypeList;
     845                 :            : }
     846                 :            : 
     847                 :            : 
     848                 :            : 
     849                 :            : 
     850                 :            : //=====  lang::XEventListener  ================================================
     851                 :            : 
     852                 :            : /** Disposing calls are accepted only from the model: Just reset the
     853                 :            :     reference to the model in the shape tree info.  Otherwise this object
     854                 :            :     remains functional.
     855                 :            : */
     856                 :            : void SAL_CALL
     857                 :          0 :     AccessibleShape::disposing (const lang::EventObject& aEvent)
     858                 :            :     throw (uno::RuntimeException)
     859                 :            : {
     860         [ #  # ]:          0 :     SolarMutexGuard aSolarGuard;
     861         [ #  # ]:          0 :     ::osl::MutexGuard aGuard (maMutex);
     862                 :            : 
     863                 :            :     try
     864                 :            :     {
     865 [ #  # ][ #  # ]:          0 :         if (aEvent.Source ==  maShapeTreeInfo.GetModelBroadcaster())
                 [ #  # ]
     866                 :            :         {
     867                 :            :             // Remove reference to model broadcaster to allow it to pass
     868                 :            :             // away.
     869 [ #  # ][ #  # ]:          0 :             maShapeTreeInfo.SetModelBroadcaster(NULL);
                 [ #  # ]
     870                 :            :         }
     871                 :            : 
     872                 :            :     }
     873         [ #  # ]:          0 :     catch (uno::RuntimeException const&)
     874                 :            :     {
     875                 :            :         OSL_TRACE ("caught exception while disposing");
     876 [ #  # ][ #  # ]:          0 :     }
     877                 :          0 : }
     878                 :            : 
     879                 :            : 
     880                 :            : 
     881                 :            : 
     882                 :            : //=====  document::XEventListener  ============================================
     883                 :            : 
     884                 :            : void SAL_CALL
     885                 :         34 :     AccessibleShape::notifyEvent (const document::EventObject& rEventObject)
     886                 :            :     throw (uno::RuntimeException)
     887                 :            : {
     888                 :            :     static const OUString sShapeModified (
     889 [ +  + ][ +  - ]:         34 :         RTL_CONSTASCII_USTRINGPARAM("ShapeModified"));
         [ +  - ][ #  # ]
     890                 :            : 
     891                 :            :     // First check if the event is for us.
     892                 :            :     uno::Reference<drawing::XShape> xShape (
     893         [ +  - ]:         34 :         rEventObject.Source, uno::UNO_QUERY);
     894 [ +  - ][ +  - ]:         34 :     if ( xShape.get() == mxShape.get() )
                 [ +  + ]
     895                 :            :     {
     896         [ +  + ]:         18 :         if (rEventObject.EventName.equals (sShapeModified))
     897                 :            :         {
     898                 :            :             // Some property of a shape has been modified.  Send an event
     899                 :            :             // that indicates a change of the visible data to all listeners.
     900                 :            :             CommitChange (
     901                 :            :                 AccessibleEventId::VISIBLE_DATA_CHANGED,
     902                 :            :                 uno::Any(),
     903         [ +  - ]:          4 :                 uno::Any());
     904                 :            : 
     905                 :            :             // Name and Description may have changed.  Update the local
     906                 :            :             // values accordingly.
     907         [ +  - ]:          4 :             UpdateNameAndDescription();
     908                 :            :         }
     909                 :         34 :     }
     910                 :         34 : }
     911                 :            : 
     912                 :            : //=====  lang::XUnoTunnel  ================================================
     913                 :            : 
     914                 :            : namespace
     915                 :            : {
     916                 :            :     class theAccessibleShapeImplementationId : public rtl::Static< UnoTunnelIdInit, theAccessibleShapeImplementationId > {};
     917                 :            : }
     918                 :            : 
     919                 :            : const uno::Sequence< sal_Int8 >&
     920                 :          4 :     AccessibleShape::getUnoTunnelImplementationId()
     921                 :            :     throw()
     922                 :            : {
     923                 :          4 :     return theAccessibleShapeImplementationId::get().getSeq();
     924                 :            : }
     925                 :            : 
     926                 :            : //------------------------------------------------------------------------------
     927                 :            : AccessibleShape*
     928                 :          2 :     AccessibleShape::getImplementation( const uno::Reference< uno::XInterface >& rxIFace )
     929                 :            :     throw()
     930                 :            : {
     931         [ +  - ]:          2 :     uno::Reference< lang::XUnoTunnel >  xTunnel( rxIFace, uno::UNO_QUERY );
     932                 :          2 :     AccessibleShape*                    pReturn = NULL;
     933                 :            : 
     934         [ +  - ]:          2 :     if( xTunnel.is() )
     935 [ +  - ][ +  - ]:          2 :         pReturn = reinterpret_cast< AccessibleShape* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) );
     936                 :            : 
     937                 :          2 :     return( pReturn );
     938                 :            : }
     939                 :            : 
     940                 :            : //------------------------------------------------------------------------------
     941                 :            : sal_Int64 SAL_CALL
     942                 :          2 :     AccessibleShape::getSomething( const uno::Sequence< sal_Int8 >& rIdentifier )
     943                 :            :     throw(uno::RuntimeException)
     944                 :            : {
     945                 :          2 :     sal_Int64 nReturn( 0 );
     946                 :            : 
     947 [ +  - ][ +  - ]:          2 :     if( ( rIdentifier.getLength() == 16 ) && ( 0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(), rIdentifier.getConstArray(), 16 ) ) )
                 [ +  - ]
     948                 :          2 :         nReturn = reinterpret_cast< sal_Int64 >( this );
     949                 :            : 
     950                 :          2 :     return( nReturn );
     951                 :            : }
     952                 :            : 
     953                 :            : //=====  IAccessibleViewForwarderListener  ====================================
     954                 :            : 
     955                 :          0 : void AccessibleShape::ViewForwarderChanged (ChangeType aChangeType,
     956                 :            :         const IAccessibleViewForwarder* pViewForwarder)
     957                 :            : {
     958                 :            :     // Inform all listeners that the graphical representation (i.e. size
     959                 :            :     // and/or position) of the shape has changed.
     960                 :            :     CommitChange (AccessibleEventId::VISIBLE_DATA_CHANGED,
     961                 :            :         uno::Any(),
     962         [ #  # ]:          0 :         uno::Any());
     963                 :            : 
     964                 :            :     // Tell children manager of the modified view forwarder.
     965         [ #  # ]:          0 :     if (mpChildrenManager != NULL)
     966                 :          0 :         mpChildrenManager->ViewForwarderChanged (aChangeType, pViewForwarder);
     967                 :            : 
     968                 :            :     // update our children that our screen position might have changed
     969         [ #  # ]:          0 :     if( mpText )
     970                 :          0 :         mpText->UpdateChildren();
     971                 :          0 : }
     972                 :            : 
     973                 :            : 
     974                 :            : 
     975                 :            : 
     976                 :            : //=====  protected internal  ==================================================
     977                 :            : /// Set this object's name if is different to the current name.
     978                 :            : ::rtl::OUString
     979                 :          4 :     AccessibleShape::CreateAccessibleBaseName (void)
     980                 :            :     throw (::com::sun::star::uno::RuntimeException)
     981                 :            : {
     982                 :          4 :     return ShapeTypeHandler::CreateAccessibleBaseName( mxShape );
     983                 :            : }
     984                 :            : 
     985                 :            : 
     986                 :            : ::rtl::OUString
     987                 :          4 :     AccessibleShape::CreateAccessibleName (void)
     988                 :            :     throw (::com::sun::star::uno::RuntimeException)
     989                 :            : {
     990         [ +  - ]:          4 :     OUString sName (CreateAccessibleBaseName());
     991                 :            : 
     992                 :            :     // Append the shape's index to the name to disambiguate between shapes
     993                 :            :     // of the same type.  If such an index where not given to the
     994                 :            :     // constructor then use the z-order instead.  If even that does not exist
     995                 :            :     // we throw an exception.
     996                 :          4 :     long nIndex = mnIndex;
     997         [ -  + ]:          4 :     if (nIndex == -1)
     998                 :            :     {
     999                 :            :         try
    1000                 :            :         {
    1001         [ #  # ]:          0 :             uno::Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY);
    1002         [ #  # ]:          0 :             if (xSet.is())
    1003                 :            :             {
    1004 [ #  # ][ #  # ]:          0 :                 uno::Any aZOrder (xSet->getPropertyValue (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ZOrder")) ));
                 [ #  # ]
    1005                 :          0 :                 aZOrder >>= nIndex;
    1006                 :            : 
    1007                 :            :                 // Add one to be not zero based.
    1008                 :          0 :                 nIndex += 1;
    1009                 :          0 :             }
    1010                 :            :         }
    1011         [ #  # ]:          0 :         catch (const beans::UnknownPropertyException &)
    1012                 :            :         {
    1013                 :            :             // We throw our own exception that is a bit more informative.
    1014                 :            :             throw uno::RuntimeException (::rtl::OUString (
    1015                 :            :                 RTL_CONSTASCII_USTRINGPARAM("AccessibleShape has invalid index and no ZOrder property")),
    1016   [ #  #  #  #  :          0 :                 static_cast<uno::XWeak*>(this));
                   #  # ]
    1017                 :            :         }
    1018                 :            : 
    1019                 :            :     }
    1020                 :            : 
    1021                 :            :     // Put a space between name and index because of Gnopernicus othewise
    1022                 :            :     // spells the name.
    1023         [ +  - ]:          4 :     sName += OUString (RTL_CONSTASCII_USTRINGPARAM(" ")) + OUString::valueOf (nIndex);
    1024                 :            : 
    1025                 :          4 :     return sName;
    1026                 :            : }
    1027                 :            : 
    1028                 :            : 
    1029                 :            : 
    1030                 :            : 
    1031                 :            : ::rtl::OUString
    1032                 :          0 :     AccessibleShape::CreateAccessibleDescription (void)
    1033                 :            :     throw (::com::sun::star::uno::RuntimeException)
    1034                 :            : {
    1035         [ #  # ]:          0 :     DescriptionGenerator aDG (mxShape);
    1036 [ #  # ][ #  # ]:          0 :     aDG.Initialize (CreateAccessibleBaseName());
    1037 [ #  # ][ #  #  :          0 :     switch (ShapeTypeHandler::Instance().GetTypeId (mxShape))
             #  #  #  #  
              # ][ #  # ]
    1038                 :            :     {
    1039                 :            :         case DRAWING_3D_CUBE:
    1040                 :            :         case DRAWING_3D_EXTRUDE:
    1041                 :            :         case DRAWING_3D_LATHE:
    1042                 :            :         case DRAWING_3D_SPHERE:
    1043         [ #  # ]:          0 :             aDG.Add3DProperties ();
    1044                 :            :             break;
    1045                 :            : 
    1046                 :            :         case DRAWING_3D_SCENE:
    1047                 :            :         case DRAWING_GROUP:
    1048                 :            :         case DRAWING_PAGE:
    1049                 :            :             // No further information is appended.
    1050                 :            :             break;
    1051                 :            : 
    1052                 :            :         case DRAWING_CAPTION:
    1053                 :            :         case DRAWING_CLOSED_BEZIER:
    1054                 :            :         case DRAWING_CLOSED_FREEHAND:
    1055                 :            :         case DRAWING_ELLIPSE:
    1056                 :            :         case DRAWING_POLY_POLYGON:
    1057                 :            :         case DRAWING_POLY_POLYGON_PATH:
    1058                 :            :         case DRAWING_RECTANGLE:
    1059         [ #  # ]:          0 :             aDG.AddLineProperties ();
    1060         [ #  # ]:          0 :             aDG.AddFillProperties ();
    1061                 :            :             break;
    1062                 :            : 
    1063                 :            :         case DRAWING_CONNECTOR:
    1064                 :            :         case DRAWING_LINE:
    1065                 :            :         case DRAWING_MEASURE:
    1066                 :            :         case DRAWING_OPEN_BEZIER:
    1067                 :            :         case DRAWING_OPEN_FREEHAND:
    1068                 :            :         case DRAWING_POLY_LINE:
    1069                 :            :         case DRAWING_POLY_LINE_PATH:
    1070         [ #  # ]:          0 :             aDG.AddLineProperties ();
    1071                 :            :             break;
    1072                 :            : 
    1073                 :            :         case DRAWING_CONTROL:
    1074                 :            :             aDG.AddProperty (OUString(RTL_CONSTASCII_USTRINGPARAM("ControlBackground")),
    1075                 :            :                 DescriptionGenerator::COLOR,
    1076 [ #  # ][ #  # ]:          0 :                 OUString());
    1077                 :            :             aDG.AddProperty (OUString(RTL_CONSTASCII_USTRINGPARAM("ControlBorder")),
    1078                 :            :                 DescriptionGenerator::INTEGER,
    1079 [ #  # ][ #  # ]:          0 :                 OUString());
    1080                 :            :             break;
    1081                 :            : 
    1082                 :            :         case DRAWING_TEXT:
    1083         [ #  # ]:          0 :             aDG.AddTextProperties ();
    1084                 :            :             break;
    1085                 :            : 
    1086                 :            :         default:
    1087                 :            :             aDG.Initialize (::rtl::OUString (
    1088 [ #  # ][ #  # ]:          0 :                                 RTL_CONSTASCII_USTRINGPARAM("Unknown accessible shape")));
    1089         [ #  # ]:          0 :             uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
    1090         [ #  # ]:          0 :             if (xDescriptor.is())
    1091                 :            :             {
    1092 [ #  # ][ #  # ]:          0 :                 aDG.AppendString (::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("service name=")));
    1093 [ #  # ][ #  # ]:          0 :                 aDG.AppendString (xDescriptor->getShapeType());
                 [ #  # ]
    1094                 :          0 :             }
    1095                 :            :     }
    1096                 :            : 
    1097 [ #  # ][ #  # ]:          0 :     return aDG();
    1098                 :            : }
    1099                 :            : 
    1100                 :            : 
    1101                 :            : 
    1102                 :            : 
    1103                 :          2 : uno::Reference< drawing::XShape > AccessibleShape::GetXShape()
    1104                 :            : {
    1105                 :          2 :     return( mxShape );
    1106                 :            : }
    1107                 :            : 
    1108                 :            : 
    1109                 :            : 
    1110                 :            : // protected
    1111                 :         22 : void AccessibleShape::disposing (void)
    1112                 :            : {
    1113         [ +  - ]:         22 :     SolarMutexGuard aSolarGuard;
    1114         [ +  - ]:         22 :     ::osl::MutexGuard aGuard (maMutex);
    1115                 :            : 
    1116                 :            :     // Make sure to send an event that this object looses the focus in the
    1117                 :            :     // case that it has the focus.
    1118                 :            :     ::utl::AccessibleStateSetHelper* pStateSet =
    1119 [ +  - ][ +  - ]:         22 :           static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
    1120         [ +  - ]:         22 :     if (pStateSet != NULL)
    1121         [ +  - ]:         22 :         pStateSet->RemoveState (AccessibleStateType::FOCUSED);
    1122                 :            : 
    1123                 :            :     // Unregister from broadcasters.
    1124         [ +  - ]:         22 :     Reference<lang::XComponent> xComponent (mxShape, uno::UNO_QUERY);
    1125         [ +  + ]:         22 :     if (xComponent.is())
    1126 [ +  - ][ +  - ]:          8 :         xComponent->removeEventListener (this);
                 [ +  - ]
    1127                 :            : 
    1128                 :            :     // Unregister from model.
    1129 [ +  - ][ +  - ]:         22 :     if (maShapeTreeInfo.GetModelBroadcaster().is())
    1130 [ +  - ][ +  - ]:         44 :         maShapeTreeInfo.GetModelBroadcaster()->removeEventListener (
    1131 [ +  - ][ +  - ]:         22 :             static_cast<document::XEventListener*>(this));
    1132                 :            : 
    1133                 :            :     // Release the child containers.
    1134         [ -  + ]:         22 :     if (mpChildrenManager != NULL)
    1135                 :            :     {
    1136 [ #  # ][ #  # ]:          0 :         delete mpChildrenManager;
    1137                 :          0 :         mpChildrenManager = NULL;
    1138                 :            :     }
    1139         [ +  + ]:         22 :     if (mpText != NULL)
    1140                 :            :     {
    1141         [ +  - ]:          8 :         mpText->Dispose();
    1142 [ +  - ][ +  - ]:          8 :         delete mpText;
    1143                 :          8 :         mpText = NULL;
    1144                 :            :     }
    1145                 :            : 
    1146                 :            :     // Cleanup.  Remove references to objects to allow them to be
    1147                 :            :     // destroyed.
    1148         [ +  - ]:         22 :     mxShape = NULL;
    1149 [ +  - ][ +  - ]:         22 :     maShapeTreeInfo = AccessibleShapeTreeInfo();
                 [ +  - ]
    1150                 :            : 
    1151                 :            :     // Call base classes.
    1152 [ +  - ][ +  - ]:         22 :     AccessibleContextBase::dispose ();
                 [ +  - ]
    1153                 :         22 : }
    1154                 :            : 
    1155                 :            : sal_Int32 SAL_CALL
    1156                 :          8 :        AccessibleShape::getAccessibleIndexInParent (void)
    1157                 :            :     throw (::com::sun::star::uno::RuntimeException)
    1158                 :            : {
    1159                 :          8 :     ThrowIfDisposed ();
    1160                 :            :     //  Use a simple but slow solution for now.  Optimize later.
    1161                 :            : 
    1162                 :          8 :     sal_Int32 nIndex = m_nIndexInParent;
    1163         [ -  + ]:          8 :     if ( -1 == nIndex )
    1164                 :          0 :         nIndex = AccessibleContextBase::getAccessibleIndexInParent();
    1165                 :          8 :     return nIndex;
    1166                 :            : }
    1167                 :            : 
    1168                 :            : 
    1169                 :            : 
    1170                 :            : 
    1171                 :         26 : void AccessibleShape::UpdateNameAndDescription (void)
    1172                 :            : {
    1173                 :            :     // Ignore missing title, name, or description.  There are fallbacks for
    1174                 :            :     // them.
    1175                 :            :     try
    1176                 :            :     {
    1177         [ +  + ]:         26 :         Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY_THROW);
    1178                 :         12 :         OUString sString;
    1179                 :            : 
    1180                 :            :         // Get the accessible name.
    1181 [ +  - ][ +  - ]:         12 :         sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Title")));
    1182         [ -  + ]:         12 :         if (!sString.isEmpty())
    1183                 :            :         {
    1184         [ #  # ]:          0 :             SetAccessibleName(sString, AccessibleContextBase::FromShape);
    1185                 :            :         }
    1186                 :            :         else
    1187                 :            :         {
    1188 [ +  - ][ +  - ]:         12 :             sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Name")));
    1189         [ -  + ]:         12 :             if (!sString.isEmpty())
    1190         [ #  # ]:          0 :                 SetAccessibleName(sString, AccessibleContextBase::FromShape);
    1191                 :            :         }
    1192                 :            : 
    1193                 :            :         // Get the accessible description.
    1194 [ +  - ][ +  - ]:         12 :         sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Description")));
    1195         [ -  + ]:         12 :         if (!sString.isEmpty())
    1196 [ #  # ][ -  + ]:         26 :             SetAccessibleDescription(sString, AccessibleContextBase::FromShape);
    1197                 :            :     }
    1198                 :         14 :     catch (uno::RuntimeException&)
    1199                 :            :     {
    1200                 :            :     }
    1201                 :         26 : }
    1202                 :            : 
    1203                 :            : 
    1204                 :            : 
    1205                 :            : 
    1206                 :            : } // end of namespace accessibility
    1207                 :            : 
    1208                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10