LCOV - code coverage report
Current view: top level - sc/source/ui/inc - AccessibleCsvControl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 5 0.0 %
Date: 2012-08-25 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 6 0.0 %

           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                 :            : // ============================================================================
      30                 :            : 
      31                 :            : #ifndef _SC_ACCESSIBLECSVCONTROL_HXX
      32                 :            : #define _SC_ACCESSIBLECSVCONTROL_HXX
      33                 :            : 
      34                 :            : #include <com/sun/star/accessibility/XAccessibleText.hpp>
      35                 :            : #include <com/sun/star/accessibility/XAccessibleTable.hpp>
      36                 :            : #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
      37                 :            : #include <tools/gen.hxx>
      38                 :            : #include <tools/string.hxx>
      39                 :            : #include <rtl/ustrbuf.hxx>
      40                 :            : #include <cppuhelper/implbase1.hxx>
      41                 :            : #include <cppuhelper/implbase2.hxx>
      42                 :            : #include <editeng/AccessibleStaticTextBase.hxx>
      43                 :            : #include <comphelper/uno3.hxx>
      44                 :            : #include "AccessibleContextBase.hxx"
      45                 :            : 
      46                 :            : 
      47                 :            : // ============================================================================
      48                 :            : 
      49                 :            : class ScCsvControl;
      50                 :            : namespace utl { class AccessibleStateSetHelper; }
      51                 :            : 
      52                 :            : /** Accessible base class used for CSV controls. */
      53                 :            : class ScAccessibleCsvControl : public ScAccessibleContextBase
      54                 :            : {
      55                 :            : protected:
      56                 :            :     typedef ::com::sun::star::uno::Reference<
      57                 :            :         ::com::sun::star::accessibility::XAccessible > XAccessibleRef;
      58                 :            :     typedef ::com::sun::star::uno::Reference<
      59                 :            :         ::com::sun::star::accessibility::XAccessibleRelationSet > XAccessibleRelationSetRef;
      60                 :            :     typedef ::com::sun::star::uno::Reference<
      61                 :            :         ::com::sun::star::accessibility::XAccessibleStateSet > XAccessibleStateSetRef;
      62                 :            : 
      63                 :            :     typedef ::com::sun::star::awt::Point        AwtPoint;
      64                 :            :     typedef ::com::sun::star::awt::Size         AwtSize;
      65                 :            :     typedef ::com::sun::star::awt::Rectangle    AwtRectangle;
      66                 :            : 
      67                 :            : private:
      68                 :            :     ScCsvControl*               mpControl;          /// Pointer to the VCL control.
      69                 :            : 
      70                 :            : public:
      71                 :            :     explicit                    ScAccessibleCsvControl(
      72                 :            :                                     const XAccessibleRef& rxParent,
      73                 :            :                                     ScCsvControl& rControl,
      74                 :            :                                     sal_uInt16 nRole );
      75                 :            :     virtual                     ~ScAccessibleCsvControl();
      76                 :            : 
      77                 :            :     using ScAccessibleContextBase::disposing;
      78                 :            :     virtual void SAL_CALL       disposing();
      79                 :            : 
      80                 :            :     // XAccessibleComponent ---------------------------------------------------
      81                 :            : 
      82                 :            :     /** Returns the child at the specified point (cell returns NULL). */
      83                 :            :     virtual XAccessibleRef SAL_CALL getAccessibleAtPoint( const AwtPoint& rPoint )
      84                 :            :         throw( ::com::sun::star::uno::RuntimeException );
      85                 :            : 
      86                 :            :     /** Returns true, if the control is visible. */
      87                 :            :     virtual sal_Bool SAL_CALL isVisible() throw( ::com::sun::star::uno::RuntimeException );
      88                 :            : 
      89                 :            :     /** Sets the focus to this control. */
      90                 :            :     virtual void SAL_CALL grabFocus() throw( ::com::sun::star::uno::RuntimeException );
      91                 :            : 
      92                 :            :     // events -----------------------------------------------------------------
      93                 :            : public:
      94                 :            :     /** Sends a GetFocus or LoseFocus event to all listeners. */
      95                 :            :     virtual void SendFocusEvent( bool bFocused );
      96                 :            :     /** Sends a caret changed event to all listeners. */
      97                 :            :     virtual void SendCaretEvent();
      98                 :            :     /** Sends a visible area changed event to all listeners. */
      99                 :            :     virtual void SendVisibleEvent();
     100                 :            :     /** Sends a selection changed event to all listeners. */
     101                 :            :     virtual void SendSelectionEvent();
     102                 :            :     /** Sends a table model changed event for changed cell contents to all listeners. */
     103                 :            :     virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows );
     104                 :            :     /** Sends a table model changed event for an inserted column to all listeners. */
     105                 :            :     virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
     106                 :            :     /** Sends a table model changed event for a removed column to all listeners. */
     107                 :            :     virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
     108                 :            : 
     109                 :            :     // helpers ----------------------------------------------------------------
     110                 :            : protected:
     111                 :            :     /** Returns this object's current bounding box relative to the desktop. */
     112                 :            :     virtual Rectangle GetBoundingBoxOnScreen() const throw( ::com::sun::star::uno::RuntimeException );
     113                 :            :     /** Returns this object's current bounding box relative to the parent object. */
     114                 :            :     virtual Rectangle GetBoundingBox() const throw( ::com::sun::star::uno::RuntimeException );
     115                 :            : 
     116                 :            :     /** Returns whether the object is alive. Must be called with locked mutex. */
     117 [ #  # ][ #  # ]:          0 :     inline bool implIsAlive() const { return !rBHelper.bDisposed && !rBHelper.bInDispose && mpControl; }
                 [ #  # ]
     118                 :            :     /** Throws an exception, if the object is disposed/disposing or any pointer
     119                 :            :         is missing. Should be used with locked mutex! */
     120                 :            :     void ensureAlive() const throw( ::com::sun::star::lang::DisposedException );
     121                 :            : 
     122                 :            :     /** Returns the VCL control. Assumes a living object. */
     123                 :            :     ScCsvControl& implGetControl() const;
     124                 :            : 
     125                 :            :     /** Returns the first child of rxParentObj, which has the role nRole. */
     126                 :            :     XAccessibleRef implGetChildByRole( const XAccessibleRef& rxParentObj, sal_uInt16 nRole )
     127                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     128                 :            :     /** Creates a StateSetHelper and fills it with DEFUNC, OPAQUE, ENABLED, SHOWING and VISIBLE. */
     129                 :            :     ::utl::AccessibleStateSetHelper* implCreateStateSet();
     130                 :            : 
     131                 :            :     /** Disposes the object. This is a helper called from destructors only. */
     132                 :            :     void implDispose();
     133                 :            : 
     134                 :            :     /** Converts the control-relative position to an absolute screen position. */
     135                 :            :     Point implGetAbsPos( const Point& rPos ) const;
     136                 :            : };
     137                 :            : 
     138                 :            : 
     139                 :            : // ============================================================================
     140                 :            : 
     141                 :            : class ScCsvRuler;
     142                 :            : 
     143                 :            : typedef ::cppu::ImplHelper1<
     144                 :            :         ::com::sun::star::accessibility::XAccessibleText >
     145                 :            :     ScAccessibleCsvRulerImpl;
     146                 :            : 
     147                 :            : /** Accessible class representing the CSV ruler control. */
     148                 :            : class ScAccessibleCsvRuler : public ScAccessibleCsvControl, public ScAccessibleCsvRulerImpl
     149                 :            : {
     150                 :            : protected:
     151                 :            :     typedef ::com::sun::star::uno::Sequence<
     152                 :            :         ::com::sun::star::beans::PropertyValue > PropertyValueSeq;
     153                 :            : 
     154                 :            : private:
     155                 :            :     ::rtl::OUStringBuffer       maBuffer;   /// Contains the text representation of the ruler.
     156                 :            : 
     157                 :            : public:
     158                 :            :     explicit                    ScAccessibleCsvRuler( ScCsvRuler& rRuler );
     159                 :            :     virtual                     ~ScAccessibleCsvRuler();
     160                 :            : 
     161                 :            :     // XAccessibleComponent -----------------------------------------------------
     162                 :            : 
     163                 :            :     virtual sal_Int32 SAL_CALL getForeground(  )
     164                 :            :         throw (::com::sun::star::uno::RuntimeException);
     165                 :            : 
     166                 :            :     virtual sal_Int32 SAL_CALL getBackground(  )
     167                 :            :         throw (::com::sun::star::uno::RuntimeException);
     168                 :            : 
     169                 :            :     // XAccessibleContext -----------------------------------------------------
     170                 :            : 
     171                 :            :     /** Returns the child count (the ruler does not have children). */
     172                 :            :     virtual sal_Int32 SAL_CALL getAccessibleChildCount()
     173                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     174                 :            : 
     175                 :            :     /** Throws an exception (the ruler does not have children). */
     176                 :            :     virtual XAccessibleRef SAL_CALL getAccessibleChild( sal_Int32 nIndex )
     177                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     178                 :            : 
     179                 :            :     /** Returns the relation to the grid control. */
     180                 :            :     virtual XAccessibleRelationSetRef SAL_CALL getAccessibleRelationSet()
     181                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     182                 :            : 
     183                 :            :     /** Returns the current set of states. */
     184                 :            :     virtual XAccessibleStateSetRef SAL_CALL getAccessibleStateSet()
     185                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     186                 :            : 
     187                 :            :     // XAccessibleText --------------------------------------------------------
     188                 :            : 
     189                 :            :     /** Return the position of the caret. */
     190                 :            :     virtual sal_Int32 SAL_CALL getCaretPosition() throw( ::com::sun::star::uno::RuntimeException );
     191                 :            : 
     192                 :            :     /** Sets the position of the caret. */
     193                 :            :     virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex )
     194                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     195                 :            : 
     196                 :            :     /** Returns the specified character. */
     197                 :            :     virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex )
     198                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     199                 :            : 
     200                 :            :     /** Returns the attributes of the specified character. */
     201                 :            :     virtual PropertyValueSeq SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRequestedAttributes )
     202                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     203                 :            : 
     204                 :            :     /** Returns the screen coordinates of the specified character. */
     205                 :            :     virtual AwtRectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex )
     206                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     207                 :            : 
     208                 :            :     /** Returns the count of characters. */
     209                 :            :     virtual sal_Int32 SAL_CALL getCharacterCount() throw( ::com::sun::star::uno::RuntimeException );
     210                 :            : 
     211                 :            :     /** Returns the character index at the specified coordinate (object's coordinate system). */
     212                 :            :     virtual sal_Int32 SAL_CALL getIndexAtPoint( const AwtPoint& rPoint )
     213                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     214                 :            : 
     215                 :            :     /** Returns the selected text (ruler returns empty string). */
     216                 :            :     virtual ::rtl::OUString SAL_CALL getSelectedText() throw( ::com::sun::star::uno::RuntimeException );
     217                 :            : 
     218                 :            :     /** Returns the start index of the selection (ruler returns -1). */
     219                 :            :     virtual sal_Int32 SAL_CALL getSelectionStart() throw( ::com::sun::star::uno::RuntimeException );
     220                 :            : 
     221                 :            :     /** Returns the end index of the selection (ruler returns -1). */
     222                 :            :     virtual sal_Int32 SAL_CALL getSelectionEnd() throw( ::com::sun::star::uno::RuntimeException );
     223                 :            : 
     224                 :            :     /** Selects a part of the text (ruler does nothing). */
     225                 :            :     virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
     226                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     227                 :            : 
     228                 :            :     /** Returns the entire text. */
     229                 :            :     virtual ::rtl::OUString SAL_CALL getText() throw( ::com::sun::star::uno::RuntimeException );
     230                 :            : 
     231                 :            :     /** Returns the specified range [Start,End) of the text. */
     232                 :            :     virtual ::rtl::OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
     233                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     234                 :            : 
     235                 :            :     /** Returns the specified text portion. */
     236                 :            :     virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     237                 :            :     virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     238                 :            :     virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     239                 :            : 
     240                 :            :     /** Copies the specified text range into the clipboard (ruler does nothing). */
     241                 :            :     virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
     242                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     243                 :            : 
     244                 :            :     // XInterface -------------------------------------------------------------
     245                 :            : 
     246                 :            :     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
     247                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     248                 :            : 
     249                 :            :     virtual void SAL_CALL acquire() throw();
     250                 :            : 
     251                 :            :     virtual void SAL_CALL release() throw();
     252                 :            : 
     253                 :            :     // XServiceInfo -----------------------------------------------------------
     254                 :            : 
     255                 :            :     /** Returns an identifier for the implementation of this object. */
     256                 :            :     virtual ::rtl::OUString SAL_CALL getImplementationName()
     257                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     258                 :            : 
     259                 :            :     // XTypeProvider ----------------------------------------------------------
     260                 :            : 
     261                 :            :     /** Returns a sequence with all supported interface types. */
     262                 :            :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
     263                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     264                 :            : 
     265                 :            :     /** Returns an implementation ID. */
     266                 :            :     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
     267                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     268                 :            : 
     269                 :            :     // events -----------------------------------------------------------------
     270                 :            : public:
     271                 :            :     /** Sends a caret changed event to all listeners. */
     272                 :            :     virtual void SendCaretEvent();
     273                 :            : 
     274                 :            :     // helpers ----------------------------------------------------------------
     275                 :            : private:
     276                 :            :     /** Returns this object's name. */
     277                 :            :     virtual ::rtl::OUString SAL_CALL createAccessibleName()
     278                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     279                 :            :     /** Returns this object's description. */
     280                 :            :     virtual ::rtl::OUString SAL_CALL createAccessibleDescription()
     281                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     282                 :            : 
     283                 :            :     /** Throws an exception, if the specified character position is invalid (outside 0..len-1). */
     284                 :            :     void ensureValidIndex( sal_Int32 nIndex ) const
     285                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException );
     286                 :            :     /** Throws an exception, if the specified character position is invalid (outside 0..len). */
     287                 :            :     void ensureValidIndexWithEnd( sal_Int32 nIndex ) const
     288                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException );
     289                 :            :     /** Throws an exception, if the specified character range [Start,End) is invalid.
     290                 :            :         @descr  If Start>End, swaps Start and End before checking. */
     291                 :            :     void ensureValidRange( sal_Int32& rnStartIndex, sal_Int32& rnEndIndex ) const
     292                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException );
     293                 :            : 
     294                 :            :     /** Returns the VCL ruler control. Assumes a living object. */
     295                 :            :     ScCsvRuler& implGetRuler() const;
     296                 :            : 
     297                 :            :     /** Builds the entire string buffer. */
     298                 :            :     void constructStringBuffer() throw( ::com::sun::star::uno::RuntimeException );
     299                 :            :     /** Returns the character count of the text. */
     300                 :            :     sal_Int32 implGetTextLength() const;
     301                 :            : 
     302                 :            :     /** Returns true, if the character at the specified index has a split. */
     303                 :            :     bool implHasSplit( sal_Int32 nApiPos );
     304                 :            : 
     305                 :            :     /** Returns the first character index with equal formatting as at nApiPos. */
     306                 :            :     sal_Int32 implGetFirstEqualFormatted( sal_Int32 nApiPos );
     307                 :            :     /** Returns the last character index with equal formatting as at nApiPos. */
     308                 :            :     sal_Int32 implGetLastEqualFormatted( sal_Int32 nApiPos );
     309                 :            : };
     310                 :            : 
     311                 :            : 
     312                 :            : // ============================================================================
     313                 :            : 
     314                 :            : class ScCsvGrid;
     315                 :            : 
     316                 :            : typedef ::cppu::ImplHelper2<
     317                 :            :         ::com::sun::star::accessibility::XAccessibleTable,
     318                 :            :         ::com::sun::star::accessibility::XAccessibleSelection >
     319                 :            :     ScAccessibleCsvGridImpl;
     320                 :            : 
     321                 :            : /** Accessible class representing the CSV grid control. */
     322                 :            : class ScAccessibleCsvGrid : public ScAccessibleCsvControl, public ScAccessibleCsvGridImpl
     323                 :            : {
     324                 :            : protected:
     325                 :            :     typedef ::com::sun::star::uno::Reference<
     326                 :            :         ::com::sun::star::accessibility::XAccessibleTable > XAccessibleTableRef;
     327                 :            : 
     328                 :            : public:
     329                 :            :     explicit                    ScAccessibleCsvGrid( ScCsvGrid& rGrid );
     330                 :            :     virtual                     ~ScAccessibleCsvGrid();
     331                 :            : 
     332                 :            :     // XAccessibleComponent ---------------------------------------------------
     333                 :            : 
     334                 :            :     /** Returns the cell at the specified point. */
     335                 :            :     virtual XAccessibleRef SAL_CALL getAccessibleAtPoint( const AwtPoint& rPoint )
     336                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     337                 :            : 
     338                 :            :     virtual sal_Int32 SAL_CALL getForeground(  )
     339                 :            :         throw (::com::sun::star::uno::RuntimeException);
     340                 :            : 
     341                 :            :     virtual sal_Int32 SAL_CALL getBackground(  )
     342                 :            :         throw (::com::sun::star::uno::RuntimeException);
     343                 :            : 
     344                 :            :     // XAccessibleContext -----------------------------------------------------
     345                 :            : 
     346                 :            :     /** Returns the child count (count of cells in the table). */
     347                 :            :     virtual sal_Int32 SAL_CALL getAccessibleChildCount()
     348                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     349                 :            : 
     350                 :            :     /** Returns the specified child cell. */
     351                 :            :     virtual XAccessibleRef SAL_CALL getAccessibleChild( sal_Int32 nIndex )
     352                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     353                 :            : 
     354                 :            :     /** Returns the relation to the ruler control. */
     355                 :            :     virtual XAccessibleRelationSetRef SAL_CALL getAccessibleRelationSet()
     356                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     357                 :            : 
     358                 :            :     /** Returns the current set of states. */
     359                 :            :     virtual XAccessibleStateSetRef SAL_CALL getAccessibleStateSet()
     360                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     361                 :            : 
     362                 :            :     // XAccessibleTable -------------------------------------------------------
     363                 :            : 
     364                 :            :     /** Returns the number of rows in the table. */
     365                 :            :     virtual sal_Int32 SAL_CALL getAccessibleRowCount()
     366                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     367                 :            : 
     368                 :            :     /** Returns the number of columns in the table. */
     369                 :            :     virtual sal_Int32 SAL_CALL getAccessibleColumnCount()
     370                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     371                 :            : 
     372                 :            :     /** Returns the description of the specified row in the table. */
     373                 :            :     virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow )
     374                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     375                 :            : 
     376                 :            :     /** Returns the description text of the specified column in the table. */
     377                 :            :     virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn )
     378                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     379                 :            : 
     380                 :            :     /** Returns the number of rows occupied at a specified row and column.
     381                 :            :         @descr  Returns always 1 (Merged cells not supported). */
     382                 :            :     virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
     383                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     384                 :            : 
     385                 :            :     /** Returns the number of rows occupied at a specified row and column.
     386                 :            :         @descr  Returns always 1 (Merged cells not supported). */
     387                 :            :     virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
     388                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     389                 :            : 
     390                 :            :     /** Returns the row headers as an AccessibleTable. */
     391                 :            :     virtual XAccessibleTableRef SAL_CALL getAccessibleRowHeaders()
     392                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     393                 :            : 
     394                 :            :     /** Returns the column headers as an AccessibleTable. */
     395                 :            :     virtual XAccessibleTableRef SAL_CALL getAccessibleColumnHeaders()
     396                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     397                 :            : 
     398                 :            :     /** Returns the selected rows as a sequence. */
     399                 :            :     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows()
     400                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     401                 :            : 
     402                 :            :     /** Returns the selected columns as a sequence. */
     403                 :            :     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns()
     404                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     405                 :            : 
     406                 :            :     /** Returns true, if the specified row is selected. */
     407                 :            :     virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow )
     408                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     409                 :            : 
     410                 :            :     /** Returns true, if the specified column is selected. */
     411                 :            :     virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn )
     412                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     413                 :            : 
     414                 :            :     /** Returns the accessible cell object at the specified position. */
     415                 :            :     virtual XAccessibleRef SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
     416                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     417                 :            : 
     418                 :            :     /** Returns the caption object of the table. */
     419                 :            :     virtual XAccessibleRef SAL_CALL getAccessibleCaption()
     420                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     421                 :            : 
     422                 :            :     /** Returns the summary description object of the table. */
     423                 :            :     virtual XAccessibleRef SAL_CALL getAccessibleSummary()
     424                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     425                 :            : 
     426                 :            :     /** Returns true, if the cell at a specified position is selected. */
     427                 :            :     virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
     428                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     429                 :            : 
     430                 :            :     /** Returns the child index of the cell at the specified position. */
     431                 :            :     virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
     432                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     433                 :            : 
     434                 :            :     /** Returns the row index of the specified child. */
     435                 :            :     virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex )
     436                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     437                 :            : 
     438                 :            :     /** Returns the column index of the specified child. */
     439                 :            :     virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex )
     440                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     441                 :            : 
     442                 :            :     // XAccessibleSelection ---------------------------------------------------
     443                 :            : 
     444                 :            :     /** Selects the specified child (selects the entire column or the entire table). */
     445                 :            :     virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex )
     446                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     447                 :            : 
     448                 :            :     /** Returns true, if the specified child is selected. */
     449                 :            :     virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex )
     450                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     451                 :            : 
     452                 :            :     /** Deselects all cells. */
     453                 :            :     virtual void SAL_CALL clearAccessibleSelection()
     454                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     455                 :            : 
     456                 :            :     /** Selects all cells. */
     457                 :            :     virtual void SAL_CALL selectAllAccessibleChildren()
     458                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     459                 :            : 
     460                 :            :     /** Returns the count of selected children. */
     461                 :            :     virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount()
     462                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     463                 :            : 
     464                 :            :     /** Returns the child with the specified index in all selected children. */
     465                 :            :     virtual XAccessibleRef SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
     466                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     467                 :            : 
     468                 :            :     /** Deselects the child with the specified index in all selected children. */
     469                 :            :     virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex )
     470                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     471                 :            : 
     472                 :            :     // XInterface -------------------------------------------------------------
     473                 :            : 
     474                 :            :     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
     475                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     476                 :            : 
     477                 :            :     virtual void SAL_CALL acquire() throw();
     478                 :            : 
     479                 :            :     virtual void SAL_CALL release() throw();
     480                 :            : 
     481                 :            :     // XServiceInfo -----------------------------------------------------------
     482                 :            : 
     483                 :            :     /** Returns an identifier for the implementation of this object. */
     484                 :            :     virtual ::rtl::OUString SAL_CALL getImplementationName()
     485                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     486                 :            : 
     487                 :            :     // XTypeProvider ----------------------------------------------------------
     488                 :            : 
     489                 :            :     /** Returns a sequence with all supported interface types. */
     490                 :            :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
     491                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     492                 :            : 
     493                 :            :     /** Returns an implementation ID. */
     494                 :            :     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
     495                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     496                 :            : 
     497                 :            :     // events -----------------------------------------------------------------
     498                 :            : public:
     499                 :            :     /** Sends a GetFocus or LoseFocus event to all listeners. */
     500                 :            :     virtual void SendFocusEvent( bool bFocused );
     501                 :            :     /** Sends a table model changed event for changed cell contents to all listeners. */
     502                 :            :     virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows );
     503                 :            :     /** Sends a table model changed event for an inserted column to all listeners. */
     504                 :            :     virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
     505                 :            :     /** Sends a table model changed event for a removed column to all listeners. */
     506                 :            :     virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
     507                 :            : 
     508                 :            :     // helpers ----------------------------------------------------------------
     509                 :            : private:
     510                 :            :     /** Returns this object's name. */
     511                 :            :     virtual ::rtl::OUString SAL_CALL createAccessibleName()
     512                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     513                 :            :     /** Returns this object's description. */
     514                 :            :     virtual ::rtl::OUString SAL_CALL createAccessibleDescription()
     515                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     516                 :            : 
     517                 :            :     /** Throws an exception, if nIndex is not a valid child index. */
     518                 :            :     void ensureValidIndex( sal_Int32 nIndex ) const
     519                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException );
     520                 :            :     /** Throws an exception, if the specified position is invalid. */
     521                 :            :     void ensureValidPosition( sal_Int32 nRow, sal_Int32 nColumn ) const
     522                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException );
     523                 :            : 
     524                 :            :     /** Returns the VCL grid control. Assumes a living object. */
     525                 :            :     ScCsvGrid& implGetGrid() const;
     526                 :            : 
     527                 :            :     /** Returns true, if the specified column (including header) is selected. */
     528                 :            :     bool implIsColumnSelected( sal_Int32 nColumn ) const;
     529                 :            :     /** Selects the specified column (including header). */
     530                 :            :     void implSelectColumn( sal_Int32 nColumn, bool bSelect );
     531                 :            : 
     532                 :            :     /** Returns the count of visible rows in the table (including header). */
     533                 :            :     sal_Int32 implGetRowCount() const;
     534                 :            :     /** Returns the total column count in the table (including header). */
     535                 :            :     sal_Int32 implGetColumnCount() const;
     536                 :            :     /** Returns the count of selected columns in the table. */
     537                 :            :     sal_Int32 implGetSelColumnCount() const;
     538                 :            :     /** Returns the total cell count in the table (including header). */
     539                 :          0 :     inline sal_Int32 implGetCellCount() const { return implGetRowCount() * implGetColumnCount(); }
     540                 :            : 
     541                 :            :     /** Returns the row index from cell index (including header). */
     542                 :          0 :     inline sal_Int32 implGetRow( sal_Int32 nIndex ) const { return nIndex / implGetColumnCount(); }
     543                 :            :     /** Returns the column index from cell index (including header). */
     544                 :          0 :     inline sal_Int32 implGetColumn( sal_Int32 nIndex ) const { return nIndex % implGetColumnCount(); }
     545                 :            :     /** Returns the absolute column index of the nSelColumn-th selected column. */
     546                 :            :     sal_Int32 implGetSelColumn( sal_Int32 nSelColumn ) const;
     547                 :            :     /** Returns the child index from cell position (including header). */
     548                 :          0 :     inline sal_Int32 implGetIndex( sal_Int32 nRow, sal_Int32 nColumn ) const { return nRow * implGetColumnCount() + nColumn; }
     549                 :            : 
     550                 :            :     /** Returns the contents of the specified cell (including header). Indexes must be valid. */
     551                 :            :     String implGetCellText( sal_Int32 nRow, sal_Int32 nColumn ) const;
     552                 :            :     /** Creates a new accessible object of the specified cell. Indexes must be valid. */
     553                 :            :     ScAccessibleCsvControl* implCreateCellObj( sal_Int32 nRow, sal_Int32 nColumn ) const;
     554                 :            : };
     555                 :            : 
     556                 :            : 
     557                 :            : // ============================================================================
     558                 :            : 
     559                 :            : /** Accessible class representing a cell of the CSV grid control. */
     560                 :            : class ScAccessibleCsvCell : public ScAccessibleCsvControl, public accessibility::AccessibleStaticTextBase
     561                 :            : {
     562                 :            : protected:
     563                 :            :     typedef ::com::sun::star::uno::Sequence<
     564                 :            :         ::com::sun::star::beans::PropertyValue >    PropertyValueSeq;
     565                 :            :     typedef ::std::auto_ptr< SvxEditSource >        SvxEditSourcePtr;
     566                 :            : 
     567                 :            : private:
     568                 :            :     String                      maCellText; /// The text contents of this cell.
     569                 :            :     sal_Int32                   mnLine;     /// The grid line index (core index).
     570                 :            :     sal_uInt32                  mnColumn;   /// The grid column index (core index).
     571                 :            :     sal_Int32                   mnIndex;    /// The index of the cell in the table.
     572                 :            : 
     573                 :            : public:
     574                 :            :     explicit                    ScAccessibleCsvCell(
     575                 :            :                                     ScCsvGrid& rGrid,
     576                 :            :                                     const String& rCellText,
     577                 :            :                                     sal_Int32 nRow, sal_Int32 nColumn );
     578                 :            :     virtual                     ~ScAccessibleCsvCell();
     579                 :            : 
     580                 :            :     using ScAccessibleCsvControl::disposing;
     581                 :            :     virtual void SAL_CALL       disposing();
     582                 :            : 
     583                 :            :     // XAccessibleComponent ---------------------------------------------------
     584                 :            : 
     585                 :            :     /** Sets the focus to the column of this cell. */
     586                 :            :     virtual void SAL_CALL grabFocus() throw( ::com::sun::star::uno::RuntimeException );
     587                 :            : 
     588                 :            :     virtual sal_Int32 SAL_CALL getForeground(  )
     589                 :            :         throw (::com::sun::star::uno::RuntimeException);
     590                 :            : 
     591                 :            :     virtual sal_Int32 SAL_CALL getBackground(  )
     592                 :            :         throw (::com::sun::star::uno::RuntimeException);
     593                 :            : 
     594                 :            :     // XAccessibleContext -----------------------------------------------------
     595                 :            : 
     596                 :            :     /** Returns the child count. */
     597                 :            :     virtual sal_Int32 SAL_CALL getAccessibleChildCount()
     598                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     599                 :            : 
     600                 :            :     /** Returns the specified child. */
     601                 :            :     virtual XAccessibleRef SAL_CALL getAccessibleChild( sal_Int32 nIndex )
     602                 :            :         throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
     603                 :            : 
     604                 :            :     /** Returns the index of this cell in the table. */
     605                 :            :     virtual sal_Int32 SAL_CALL getAccessibleIndexInParent()
     606                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     607                 :            : 
     608                 :            :     /** Returns the relation to the ruler control. */
     609                 :            :     virtual XAccessibleRelationSetRef SAL_CALL getAccessibleRelationSet()
     610                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     611                 :            : 
     612                 :            :     /** Returns the current set of states. */
     613                 :            :     virtual XAccessibleStateSetRef SAL_CALL getAccessibleStateSet()
     614                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     615                 :            : 
     616                 :            :     // XInterface -------------------------------------------------------------
     617                 :            : 
     618                 :            :     DECLARE_XINTERFACE()
     619                 :            : 
     620                 :            :     // XTypeProvider ----------------------------------------------------------
     621                 :            : 
     622                 :            :     DECLARE_XTYPEPROVIDER()
     623                 :            : 
     624                 :            :     // XServiceInfo -----------------------------------------------------------
     625                 :            : 
     626                 :            :     /** Returns an identifier for the implementation of this object. */
     627                 :            :     virtual ::rtl::OUString SAL_CALL getImplementationName()
     628                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     629                 :            : 
     630                 :            :     // helpers ----------------------------------------------------------------
     631                 :            : protected:
     632                 :            :     /** Returns this object's current bounding box relative to the desktop. */
     633                 :            :     virtual Rectangle GetBoundingBoxOnScreen() const throw( ::com::sun::star::uno::RuntimeException );
     634                 :            :     /** Returns this object's current bounding box relative to the parent object. */
     635                 :            :     virtual Rectangle GetBoundingBox() const throw( ::com::sun::star::uno::RuntimeException );
     636                 :            : 
     637                 :            : private:
     638                 :            :     /** Returns this object's name. */
     639                 :            :     virtual ::rtl::OUString SAL_CALL createAccessibleName()
     640                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     641                 :            :     /** Returns this object's description. */
     642                 :            :     virtual ::rtl::OUString SAL_CALL createAccessibleDescription()
     643                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     644                 :            : 
     645                 :            :     /** Returns the VCL grid control. Assumes a living object. */
     646                 :            :     ScCsvGrid& implGetGrid() const;
     647                 :            :     /** Returns the pixel position of the cell (rel. to parent), regardless of visibility. */
     648                 :            :     Point implGetRealPos() const;
     649                 :            :     /** Returns the width of the character count */
     650                 :            :     sal_uInt32 implCalcPixelWidth(sal_uInt32 nChars) const;
     651                 :            :     /** Returns the pixel size of the cell, regardless of visibility. */
     652                 :            :     Size implGetRealSize() const;
     653                 :            :     /** Returns the bounding box of the cell relative in the table. */
     654                 :            :     Rectangle implGetBoundingBox() const;
     655                 :            : 
     656                 :            :     /** Creates the edit source the text helper needs. */
     657                 :            :     ::std::auto_ptr< SvxEditSource > implCreateEditSource();
     658                 :            : };
     659                 :            : 
     660                 :            : 
     661                 :            : // ============================================================================
     662                 :            : 
     663                 :            : #endif
     664                 :            : 
     665                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10