LCOV - code coverage report
Current view: top level - sc/source/ui/Accessibility - AccessiblePageHeaderArea.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 127 0.0 %
Date: 2014-04-14 Functions: 0 19 0.0 %
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 <tools/gen.hxx>
      21             : #include "AccessiblePageHeaderArea.hxx"
      22             : #include "AccessibleText.hxx"
      23             : #include "AccessibilityHints.hxx"
      24             : #include "editsrc.hxx"
      25             : #include "prevwsh.hxx"
      26             : #include "prevloc.hxx"
      27             : #include "scresid.hxx"
      28             : #include "sc.hrc"
      29             : 
      30             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      31             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      32             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      33             : #include <editeng/editobj.hxx>
      34             : #include <svx/AccessibleTextHelper.hxx>
      35             : #include <comphelper/servicehelper.hxx>
      36             : #include <unotools/accessiblestatesethelper.hxx>
      37             : #include <rtl/ustrbuf.hxx>
      38             : #include <toolkit/helper/convert.hxx>
      39             : #include <vcl/svapp.hxx>
      40             : 
      41             : using namespace ::com::sun::star;
      42             : using namespace ::com::sun::star::accessibility;
      43             : 
      44             :     //=====  internal  ========================================================
      45             : 
      46           0 : ScAccessiblePageHeaderArea::ScAccessiblePageHeaderArea(
      47             :         const uno::Reference<XAccessible>& rxParent,
      48             :         ScPreviewShell* pViewShell,
      49             :         const EditTextObject* pEditObj,
      50             :         bool bHeader,
      51             :         SvxAdjust eAdjust)
      52             :         : ScAccessibleContextBase(rxParent, AccessibleRole::TEXT),
      53           0 :         mpEditObj(pEditObj->Clone()),
      54             :         mpTextHelper(NULL),
      55             :         mpViewShell(pViewShell),
      56             :         mbHeader(bHeader),
      57           0 :         meAdjust(eAdjust)
      58             : {
      59           0 :     if (mpViewShell)
      60           0 :         mpViewShell->AddAccessibilityObject(*this);
      61           0 : }
      62             : 
      63           0 : ScAccessiblePageHeaderArea::~ScAccessiblePageHeaderArea(void)
      64             : {
      65           0 :     if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose)
      66             :     {
      67             :         // increment refcount to prevent double call off dtor
      68           0 :         osl_atomic_increment( &m_refCount );
      69           0 :         dispose();
      70             :     }
      71           0 : }
      72             : 
      73           0 : void SAL_CALL ScAccessiblePageHeaderArea::disposing()
      74             : {
      75           0 :     SolarMutexGuard aGuard;
      76           0 :     if (mpViewShell)
      77             :     {
      78           0 :         mpViewShell->RemoveAccessibilityObject(*this);
      79           0 :         mpViewShell = NULL;
      80             :     }
      81           0 :     if (mpTextHelper)
      82           0 :         DELETEZ(mpTextHelper);
      83           0 :     if (mpEditObj)
      84           0 :         DELETEZ(mpEditObj);
      85             : 
      86           0 :     ScAccessibleContextBase::disposing();
      87           0 : }
      88             : 
      89             : //=====  SfxListener  =====================================================
      90             : 
      91           0 : void ScAccessiblePageHeaderArea::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
      92             : {
      93           0 :     if (rHint.ISA( SfxSimpleHint ) )
      94             :     {
      95           0 :         const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
      96             :         // only notify if child exist, otherwise it is not necessary
      97           0 :         if (rRef.GetId() == SC_HINT_ACC_VISAREACHANGED)
      98             :         {
      99           0 :             if (mpTextHelper)
     100           0 :                 mpTextHelper->UpdateChildren();
     101             : 
     102           0 :             AccessibleEventObject aEvent;
     103           0 :             aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
     104           0 :             aEvent.Source = uno::Reference< XAccessibleContext >(this);
     105           0 :             CommitChange(aEvent);
     106             :         }
     107             :     }
     108           0 :     ScAccessibleContextBase::Notify(rBC, rHint);
     109           0 : }
     110             :     //=====  XAccessibleComponent  ============================================
     111             : 
     112           0 : uno::Reference< XAccessible > SAL_CALL ScAccessiblePageHeaderArea::getAccessibleAtPoint(
     113             :         const awt::Point& rPoint )
     114             :         throw (uno::RuntimeException, std::exception)
     115             : {
     116           0 :     uno::Reference<XAccessible> xRet;
     117           0 :     if (containsPoint(rPoint))
     118             :     {
     119           0 :          SolarMutexGuard aGuard;
     120           0 :         IsObjectValid();
     121             : 
     122           0 :         if(!mpTextHelper)
     123           0 :             CreateTextHelper();
     124             : 
     125           0 :         xRet = mpTextHelper->GetAt(rPoint);
     126             :     }
     127             : 
     128           0 :     return xRet;
     129             : }
     130             : 
     131             :     //=====  XAccessibleContext  ==============================================
     132             : 
     133             : sal_Int32 SAL_CALL
     134           0 :     ScAccessiblePageHeaderArea::getAccessibleChildCount(void)
     135             :                     throw (uno::RuntimeException, std::exception)
     136             : {
     137           0 :     SolarMutexGuard aGuard;
     138           0 :     IsObjectValid();
     139           0 :     if (!mpTextHelper)
     140           0 :         CreateTextHelper();
     141           0 :     return mpTextHelper->GetChildCount();
     142             : }
     143             : 
     144             : uno::Reference< XAccessible > SAL_CALL
     145           0 :     ScAccessiblePageHeaderArea::getAccessibleChild(sal_Int32 nIndex)
     146             :         throw (uno::RuntimeException,
     147             :         lang::IndexOutOfBoundsException, std::exception)
     148             : {
     149           0 :     SolarMutexGuard aGuard;
     150           0 :     IsObjectValid();
     151           0 :     if (!mpTextHelper)
     152           0 :         CreateTextHelper();
     153           0 :     return mpTextHelper->GetChild(nIndex);
     154             : }
     155             : 
     156             : uno::Reference<XAccessibleStateSet> SAL_CALL
     157           0 :     ScAccessiblePageHeaderArea::getAccessibleStateSet(void)
     158             :     throw (uno::RuntimeException, std::exception)
     159             : {
     160           0 :     SolarMutexGuard aGuard;
     161           0 :     uno::Reference<XAccessibleStateSet> xParentStates;
     162           0 :     if (getAccessibleParent().is())
     163             :     {
     164           0 :         uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
     165           0 :         xParentStates = xParentContext->getAccessibleStateSet();
     166             :     }
     167           0 :     utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
     168           0 :     if (IsDefunc())
     169           0 :         pStateSet->AddState(AccessibleStateType::DEFUNC);
     170             :     else
     171             :     {
     172           0 :         pStateSet->AddState(AccessibleStateType::ENABLED);
     173           0 :         pStateSet->AddState(AccessibleStateType::MULTI_LINE);
     174           0 :         if (isShowing())
     175           0 :             pStateSet->AddState(AccessibleStateType::SHOWING);
     176           0 :         if (isVisible())
     177           0 :             pStateSet->AddState(AccessibleStateType::VISIBLE);
     178             :     }
     179           0 :     return pStateSet;
     180             : }
     181             : 
     182             : //=====  XServiceInfo  ========================================================
     183             : 
     184             : OUString SAL_CALL
     185           0 :        ScAccessiblePageHeaderArea::getImplementationName(void)
     186             :     throw (uno::RuntimeException, std::exception)
     187             : {
     188           0 :     return OUString("ScAccessiblePageHeaderArea");
     189             : }
     190             : 
     191             : uno::Sequence< OUString> SAL_CALL
     192           0 :        ScAccessiblePageHeaderArea::getSupportedServiceNames(void)
     193             :     throw (uno::RuntimeException, std::exception)
     194             : {
     195           0 :     uno::Sequence< OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
     196           0 :     sal_Int32 nOldSize(aSequence.getLength());
     197           0 :     aSequence.realloc(nOldSize + 1);
     198             : 
     199           0 :     aSequence[nOldSize] = "com.sun.star.sheet.AccessiblePageHeaderFooterAreasView";
     200             : 
     201           0 :     return aSequence;
     202             : }
     203             : 
     204             : //=====  XTypeProvider  =======================================================
     205             : 
     206             : uno::Sequence<sal_Int8> SAL_CALL
     207           0 :     ScAccessiblePageHeaderArea::getImplementationId(void)
     208             :     throw (uno::RuntimeException, std::exception)
     209             : {
     210           0 :     return css::uno::Sequence<sal_Int8>();
     211             : }
     212             : 
     213             : //===== internal ==============================================================
     214           0 : OUString SAL_CALL ScAccessiblePageHeaderArea::createAccessibleDescription(void)
     215             :     throw(uno::RuntimeException)
     216             : {
     217           0 :     OUString sDesc;
     218           0 :     switch (meAdjust)
     219             :     {
     220             :     case SVX_ADJUST_LEFT :
     221           0 :         sDesc = OUString(ScResId(STR_ACC_LEFTAREA_DESCR));
     222           0 :         break;
     223             :     case SVX_ADJUST_RIGHT:
     224           0 :         sDesc = OUString(ScResId(STR_ACC_RIGHTAREA_DESCR));
     225           0 :         break;
     226             :     case SVX_ADJUST_CENTER:
     227           0 :         sDesc = OUString(ScResId(STR_ACC_CENTERAREA_DESCR));
     228           0 :         break;
     229             :     default:
     230             :         OSL_FAIL("wrong adjustment found");
     231             :     }
     232             : 
     233           0 :     return sDesc;
     234             : }
     235             : 
     236           0 : OUString SAL_CALL ScAccessiblePageHeaderArea::createAccessibleName(void)
     237             :     throw (uno::RuntimeException, std::exception)
     238             : {
     239           0 :     OUString sName;
     240           0 :     switch (meAdjust)
     241             :     {
     242             :     case SVX_ADJUST_LEFT :
     243           0 :         sName = OUString(ScResId(STR_ACC_LEFTAREA_NAME));
     244           0 :         break;
     245             :     case SVX_ADJUST_RIGHT:
     246           0 :         sName = OUString(ScResId(STR_ACC_RIGHTAREA_NAME));
     247           0 :         break;
     248             :     case SVX_ADJUST_CENTER:
     249           0 :         sName = OUString(ScResId(STR_ACC_CENTERAREA_NAME));
     250           0 :         break;
     251             :     default:
     252             :         OSL_FAIL("wrong adjustment found");
     253             :     }
     254             : 
     255           0 :     return sName;
     256             : }
     257             : 
     258           0 : Rectangle ScAccessiblePageHeaderArea::GetBoundingBoxOnScreen(void) const
     259             :     throw(::com::sun::star::uno::RuntimeException, std::exception)
     260             : {
     261           0 :     Rectangle aRect;
     262           0 :     if (mxParent.is())
     263             :     {
     264           0 :         uno::Reference<XAccessibleContext> xContext = mxParent->getAccessibleContext();
     265           0 :         uno::Reference<XAccessibleComponent> xComp(xContext, uno::UNO_QUERY);
     266           0 :         if (xComp.is())
     267             :         {
     268             :             // has the same size and position on screen like the parent
     269           0 :             aRect = Rectangle(VCLPoint(xComp->getLocationOnScreen()), VCLRectangle(xComp->getBounds()).GetSize());
     270           0 :         }
     271             :     }
     272           0 :     return aRect;
     273             : }
     274             : 
     275           0 : Rectangle ScAccessiblePageHeaderArea::GetBoundingBox(void) const
     276             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     277             : {
     278           0 :     Rectangle aRect;
     279           0 :     if (mxParent.is())
     280             :     {
     281           0 :         uno::Reference<XAccessibleContext> xContext = mxParent->getAccessibleContext();
     282           0 :         uno::Reference<XAccessibleComponent> xComp(xContext, uno::UNO_QUERY);
     283           0 :         if (xComp.is())
     284             :         {
     285             :             // has the same size and position on screen like the parent and so the pos is (0, 0)
     286           0 :             Rectangle aNewRect(Point(0, 0), VCLRectangle(xComp->getBounds()).GetSize());
     287           0 :             aRect = aNewRect;
     288           0 :         }
     289             :     }
     290             : 
     291           0 :     return aRect;
     292             : }
     293             : 
     294           0 : void ScAccessiblePageHeaderArea::CreateTextHelper()
     295             : {
     296           0 :     if (!mpTextHelper)
     297             :     {
     298             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
     299             :         ::std::auto_ptr < ScAccessibleTextData > pAccessibleHeaderTextData
     300           0 :             (new ScAccessibleHeaderTextData(mpViewShell, mpEditObj, mbHeader, meAdjust));
     301           0 :         ::std::auto_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(pAccessibleHeaderTextData));
     302             :         SAL_WNODEPRECATED_DECLARATIONS_POP
     303             : 
     304           0 :         mpTextHelper = new ::accessibility::AccessibleTextHelper(pEditSource );
     305           0 :         mpTextHelper->SetEventSource(this);
     306             :     }
     307           0 : }
     308             : 
     309             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10