LCOV - code coverage report
Current view: top level - sc/source/ui/inc - AccessibleSpreadsheet.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 2 9 22.2 %
Date: 2014-11-03 Functions: 2 8 25.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             : #ifndef INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLESPREADSHEET_HXX
      21             : #define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLESPREADSHEET_HXX
      22             : 
      23             : #include <sal/config.h>
      24             : 
      25             : #include <rtl/ref.hxx>
      26             : 
      27             : #include "AccessibleTableBase.hxx"
      28             : #include "viewdata.hxx"
      29             : 
      30             : #include <vector>
      31             : 
      32             : #include "rangelst.hxx"
      33             : #include <map>
      34             : 
      35           2 : class ScMyAddress : public ScAddress
      36             : {
      37             : public:
      38             :     ScMyAddress() : ScAddress() {}
      39           0 :     ScMyAddress(SCCOL nColP, SCROW nRowP, SCTAB nTabP) : ScAddress(nColP, nRowP, nTabP) {}
      40           2 :     ScMyAddress(const ScAddress& rAddress) : ScAddress(rAddress) {}
      41             : 
      42           0 :     bool operator< ( const ScMyAddress& rAddress ) const
      43             :     {
      44           0 :         if( Row() != rAddress.Row() )
      45           0 :             return (Row() < rAddress.Row());
      46             :         else
      47           0 :             return (Col() < rAddress.Col());
      48             :     }
      49             : };
      50             : 
      51             : class ScTabViewShell;
      52             : class ScAccessibleDocument;
      53             : class ScAccessibleCell;
      54             : class ScRangeList;
      55             : 
      56             : /** @descr
      57             :         This base class provides an implementation of the
      58             :         <code>AccessibleTable</code> service.
      59             : */
      60             : class ScAccessibleSpreadsheet
      61             :     :   public  ScAccessibleTableBase
      62             : {
      63             : public:
      64             :     //=====  internal  ========================================================
      65             :     ScAccessibleSpreadsheet(
      66             :         ScAccessibleDocument* pAccDoc,
      67             :         ScTabViewShell* pViewShell,
      68             :         SCTAB   nTab,
      69             :         ScSplitPos eSplitPos);
      70             : protected:
      71             :     ScAccessibleSpreadsheet(
      72             :         ScAccessibleSpreadsheet& rParent,
      73             :         const ScRange& rRange );
      74             : 
      75             :     virtual ~ScAccessibleSpreadsheet();
      76             : 
      77             :     void ConstructScAccessibleSpreadsheet(
      78             :         ScAccessibleDocument* pAccDoc,
      79             :         ScTabViewShell* pViewShell,
      80             :         SCTAB nTab,
      81             :         ScSplitPos eSplitPos);
      82             : 
      83             :     using ScAccessibleTableBase::IsDefunc;
      84             : 
      85             : public:
      86             :     using ScAccessibleTableBase::disposing;
      87             : 
      88             :      virtual void SAL_CALL disposing() SAL_OVERRIDE;
      89             : 
      90             :     void CompleteSelectionChanged(bool bNewState);
      91             : 
      92             :     virtual void LostFocus();
      93             :     virtual void GotFocus();
      94             : 
      95             :     void BoundingBoxChanged();
      96             :     void VisAreaChanged();
      97             : 
      98             : private:
      99             :     ///=====  SfxListener  =====================================================
     100             :     virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
     101             : 
     102             :     ///=====  XAccessibleTable  ================================================
     103             : 
     104             :     /// Returns the row headers as an AccessibleTable.
     105             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
     106             :                 getAccessibleRowHeaders(  )
     107             :                     throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     108             : 
     109             :     /// Returns the column headers as an AccessibleTable.
     110             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
     111             :                 getAccessibleColumnHeaders(  )
     112             :                     throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     113             : 
     114             :     /// Returns the selected rows in a table.
     115             :     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
     116             :                 getSelectedAccessibleRows(  )
     117             :                     throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     118             : 
     119             :     /// Returns the selected columns in a table.
     120             :     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
     121             :                 getSelectedAccessibleColumns(  )
     122             :                     throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     123             : 
     124             :     /// Returns a boolean value indicating whether the specified row is selected.
     125             :     virtual sal_Bool SAL_CALL
     126             :                 isAccessibleRowSelected( sal_Int32 nRow )
     127             :                     throw (::com::sun::star::uno::RuntimeException,
     128             :                     ::com::sun::star::lang::IndexOutOfBoundsException, std::exception) SAL_OVERRIDE;
     129             : 
     130             :     /// Returns a boolean value indicating whether the specified column is selected.
     131             :     virtual sal_Bool SAL_CALL
     132             :                 isAccessibleColumnSelected( sal_Int32 nColumn )
     133             :                     throw (::com::sun::star::uno::RuntimeException,
     134             :                     ::com::sun::star::lang::IndexOutOfBoundsException, std::exception) SAL_OVERRIDE;
     135             : 
     136             :     /// Returns the Accessible at a specified row and column in the table.
     137             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
     138             :                 getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
     139             :                     throw (::com::sun::star::uno::RuntimeException,
     140             :                             ::com::sun::star::lang::IndexOutOfBoundsException, std::exception) SAL_OVERRIDE;
     141             : 
     142             :     rtl::Reference<ScAccessibleCell> GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn);
     143             : 
     144             :     /// Returns a boolean value indicating whether the accessible at a specified row and column is selected.
     145             :     virtual sal_Bool SAL_CALL
     146             :                 isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
     147             :                     throw (::com::sun::star::uno::RuntimeException,
     148             :                     ::com::sun::star::lang::IndexOutOfBoundsException, std::exception) SAL_OVERRIDE;
     149             : 
     150             :     ///=====  XAccessibleComponent  ============================================
     151             : 
     152             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     153             :         SAL_CALL getAccessibleAtPoint(
     154             :         const ::com::sun::star::awt::Point& rPoint )
     155             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     156             : 
     157             :     virtual void SAL_CALL grabFocus(  )
     158             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     159             : 
     160             :     virtual sal_Int32 SAL_CALL getForeground(  )
     161             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     162             : 
     163             :     virtual sal_Int32 SAL_CALL getBackground(  )
     164             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     165             : 
     166             :     ///=====  XAccessibleContext  ==============================================
     167             : 
     168             :     /// Return NULL to indicate that an empty relation set.
     169             :     virtual ::com::sun::star::uno::Reference<
     170             :             ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
     171             :         getAccessibleRelationSet(void)
     172             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     173             : 
     174             :     /// Return the set of current states.
     175             :     virtual ::com::sun::star::uno::Reference<
     176             :             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
     177             :         getAccessibleStateSet(void)
     178             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     179             : 
     180             :     ///=====  XAccessibleSelection  ===========================================
     181             : 
     182             :     virtual void SAL_CALL
     183             :         selectAccessibleChild( sal_Int32 nChildIndex )
     184             :         throw (::com::sun::star::lang::IndexOutOfBoundsException,
     185             :                ::com::sun::star::uno::RuntimeException,
     186             :                std::exception) SAL_OVERRIDE;
     187             : 
     188             :     virtual void SAL_CALL
     189             :         clearAccessibleSelection(  )
     190             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     191             : 
     192             :     virtual void SAL_CALL
     193             :         selectAllAccessibleChildren(  )
     194             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     195             : 
     196             :     virtual sal_Int32 SAL_CALL
     197             :         getSelectedAccessibleChildCount(  )
     198             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     199             : 
     200             :     virtual ::com::sun::star::uno::Reference<
     201             :         ::com::sun::star::accessibility::XAccessible > SAL_CALL
     202             :         getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
     203             :         throw (::com::sun::star::lang::IndexOutOfBoundsException,
     204             :         ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     205             : 
     206             :     virtual void SAL_CALL
     207             :         deselectAccessibleChild( sal_Int32 nChildIndex )
     208             :         throw (::com::sun::star::lang::IndexOutOfBoundsException,
     209             :                ::com::sun::star::uno::RuntimeException,
     210             :                std::exception) SAL_OVERRIDE;
     211             : 
     212             :     ///=====  XServiceInfo  ====================================================
     213             : 
     214             :     /** Returns an identifier for the implementation of this object.
     215             :     */
     216             :     virtual OUString SAL_CALL
     217             :         getImplementationName(void)
     218             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     219             : 
     220             :     /** Returns a list of all supported services.
     221             :     */
     222             :     virtual ::com::sun::star::uno::Sequence< OUString> SAL_CALL
     223             :         getSupportedServiceNames(void)
     224             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     225             : 
     226             :     ///=====  XTypeProvider  ===================================================
     227             : 
     228             :     /** Returns a implementation id.
     229             :     */
     230             :     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
     231             :         getImplementationId(void)
     232             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     233             : 
     234             :     ///=====  XAccessibleEventBroadcaster  =====================================
     235             : 
     236             :     /** Add listener that is informed of future changes of name,
     237             :           description and so on events.
     238             :     */
     239             :     virtual void SAL_CALL
     240             :         addAccessibleEventListener(
     241             :             const ::com::sun::star::uno::Reference<
     242             :                 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
     243             :         throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     244             :     //=====  XAccessibleTableSelection  ============================================
     245             :     virtual sal_Bool SAL_CALL selectRow( sal_Int32 row )
     246             :         throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException,
     247             :                std::exception) SAL_OVERRIDE;
     248             :     virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column )
     249             :         throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException,
     250             :                std::exception) SAL_OVERRIDE;
     251             :     virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row )
     252             :         throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException,
     253             :                std::exception) SAL_OVERRIDE;
     254             :     virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column )
     255             :         throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException,
     256             :                std::exception) SAL_OVERRIDE;
     257             : 
     258             : protected:
     259             :     /// Return the object's current bounding box relative to the desktop.
     260             :     virtual Rectangle GetBoundingBoxOnScreen(void) const
     261             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     262             : 
     263             :     /// Return the object's current bounding box relative to the parent object.
     264             :     virtual Rectangle GetBoundingBox(void) const
     265             :         throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     266             : private:
     267             :     ScTabViewShell* mpViewShell;
     268             :     ScRangeList*    mpMarkedRanges;
     269             :     std::vector<ScMyAddress>* mpSortedMarkedCells;
     270             :     ScAccessibleDocument* mpAccDoc;
     271             :     rtl::Reference<ScAccessibleCell> mpAccCell;
     272             :     Rectangle       maVisCells;
     273             :     ScSplitPos      meSplitPos;
     274             :     ScAddress       maActiveCell;
     275             :     SCTAB           mnTab;
     276             :     bool            mbIsSpreadsheet;
     277             :     bool            mbHasSelection;
     278             :     bool            mbDelIns;
     279             :     bool            mbIsFocusSend;
     280             : 
     281             :     bool IsDefunc(
     282             :         const com::sun::star::uno::Reference<
     283             :         ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
     284             :     bool IsEditable(
     285             :         const com::sun::star::uno::Reference<
     286             :         ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
     287             :     bool IsFocused();
     288             :     bool IsCompleteSheetSelected();
     289             : 
     290             :     void SelectCell(sal_Int32 nRow, sal_Int32 nCol, bool bDeselect);
     291             :     void CreateSortedMarkedCells();
     292             :     void AddMarkedRange(const ScRange& rRange);
     293             : 
     294             :     ScDocument* GetDocument(ScTabViewShell* pViewShell);
     295             :     Rectangle   GetVisArea(ScTabViewShell* pViewShell, ScSplitPos eSplitPos);
     296             :     Rectangle   GetVisCells(const Rectangle& rVisArea);
     297             :     typedef std::vector<ScMyAddress> VEC_MYADDR;
     298             : 
     299             :     typedef std::map<ScMyAddress,com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > >
     300             :         MAP_ADDR_XACC;
     301             :     MAP_ADDR_XACC m_mapSelectionSend;
     302             :     void RemoveSelection(ScMarkData &refScMarkData);
     303             :     bool IsSameMarkCell();
     304             :     void CommitFocusCell(const ScAddress &aNewCell);
     305             : public:
     306             :     void FireFirstCellFocus();
     307             : private:
     308             :     bool          m_bFormulaMode;
     309             :     bool          m_bFormulaLastMode;
     310             :     ScAddress     m_aFormulaActiveCell;
     311             :     MAP_ADDR_XACC m_mapFormulaSelectionSend;
     312             :     VEC_MYADDR    m_vecFormulaLastMyAddr;
     313             :     rtl::Reference<ScAccessibleCell> m_pAccFormulaCell;
     314             :     sal_uInt16    m_nMinX;
     315             :     sal_uInt16    m_nMaxX;
     316             :     sal_Int32     m_nMinY;
     317             :     sal_Int32     m_nMaxY;
     318             : 
     319           0 :     sal_Int32 GetRowAll() const { return m_nMaxY - m_nMinY + 1 ; }
     320           0 :     sal_uInt16  GetColAll() const { return m_nMaxX - m_nMinX + 1; }
     321             :     void NotifyRefMode();
     322             :     void RemoveFormulaSelection(bool bRemoveAll = false);
     323             :     bool CheckChildIndex(sal_Int32) const;
     324             :     ScAddress GetChildIndexAddress(sal_Int32) const;
     325             :     sal_Int32 GetAccessibleIndexFormula( sal_Int32 nRow, sal_Int32 nColumn );
     326             :     bool GetFormulaCurrentFocusCell(ScAddress &addr);
     327             : public:
     328             :     ScRange       m_aLastWithInMarkRange;
     329             :     OUString      m_strCurCellValue;
     330             :     ScRangeList   m_LastMarkedRanges;
     331             :     typedef std::vector<ScRange*> VEC_RANGE;
     332             :     VEC_RANGE     m_vecTempRange;
     333             :     typedef std::pair<sal_uInt16,sal_uInt16> PAIR_COL;
     334             :     typedef std::vector<PAIR_COL> VEC_COL;
     335             :     VEC_COL       m_vecTempCol;
     336             :     OUString      m_strOldTabName;
     337             : 
     338             :     ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > GetActiveCell();
     339             :     bool IsScAddrFormulaSel (const ScAddress &addr) const;
     340             :     bool IsFormulaMode();
     341             :     ScMyAddress CalcScAddressFromRangeList(ScRangeList *pMarkedRanges,sal_Int32 nSelectedChildIndex);
     342             :     bool CalcScRangeDifferenceMax(ScRange *pSrc,ScRange *pDest,int nMax,VEC_MYADDR &vecRet,int &nSize);
     343             :     bool CalcScRangeListDifferenceMax(ScRangeList *pSrc,ScRangeList *pDest,int nMax,VEC_MYADDR &vecRet);
     344             : };
     345             : 
     346             : #endif
     347             : 
     348             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10