LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/control - valueimp.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 7 0.0 %
Date: 2012-12-27 Functions: 0 4 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 <osl/mutex.hxx>
      21             : #include <tools/color.hxx>
      22             : #include <tools/string.hxx>
      23             : #include <vcl/image.hxx>
      24             : #include <cppuhelper/implbase5.hxx>
      25             : #include <cppuhelper/compbase6.hxx>
      26             : #include <comphelper/broadcasthelper.hxx>
      27             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      28             : #include <com/sun/star/accessibility/XAccessible.hpp>
      29             : #include <com/sun/star/accessibility/XAccessibleContext.hpp>
      30             : #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
      31             : #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
      32             : #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
      33             : #include <com/sun/star/lang/DisposedException.hpp>
      34             : 
      35             : #include <vector>
      36             : 
      37             : // -----------
      38             : // - Defines -
      39             : // -----------
      40             : 
      41             : #define VALUESET_ITEM_NONEITEM      0xFFFE
      42             : 
      43             : // --------------------
      44             : // - ValueSetItemType -
      45             : // --------------------
      46             : 
      47             : enum ValueSetItemType
      48             : {
      49             :     VALUESETITEM_NONE,
      50             :     VALUESETITEM_IMAGE,
      51             :     VALUESETITEM_COLOR,
      52             :     VALUESETITEM_USERDRAW
      53             : };
      54             : 
      55             : // ----------------
      56             : // - ValueSetItem -
      57             : // ----------------
      58             : 
      59             : class ValueSet;
      60             : 
      61             : struct ValueSetItem
      62             : {
      63             :     ValueSet&           mrParent;
      64             :     sal_uInt16          mnId;
      65             :     sal_uInt8           meType;
      66             :     bool                mbVisible;
      67             :     Image               maImage;
      68             :     Color               maColor;
      69             :     XubString           maText;
      70             :     void*               mpData;
      71             :     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >* mpxAcc;
      72             : 
      73             :     ValueSetItem( ValueSet& rParent );
      74             :     ~ValueSetItem();
      75             : 
      76             :     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
      77             :                         GetAccessible( bool bIsTransientChildrenDisabled );
      78             : };
      79             : 
      80             : // ---------------
      81             : // - ValueSetAcc -
      82             : // ---------------
      83             : 
      84             : typedef ::cppu::PartialWeakComponentImplHelper6<
      85             :     ::com::sun::star::accessibility::XAccessible,
      86             :     ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
      87             :     ::com::sun::star::accessibility::XAccessibleContext,
      88             :     ::com::sun::star::accessibility::XAccessibleComponent,
      89             :     ::com::sun::star::accessibility::XAccessibleSelection,
      90             :     ::com::sun::star::lang::XUnoTunnel >
      91             :     ValueSetAccComponentBase;
      92             : 
      93             : class ValueSetAcc :
      94             :     public ::comphelper::OBaseMutex,
      95             :     public ValueSetAccComponentBase
      96             : {
      97             : public:
      98             : 
      99             :     ValueSetAcc( ValueSet* pParent, bool bIsTransientChildrenDisabled );
     100             :     ~ValueSetAcc();
     101             : 
     102             :     void                FireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue );
     103           0 :     sal_Bool                HasAccessibleListeners() const { return( mxEventListeners.size() > 0 ); }
     104             : 
     105             :     static ValueSetAcc* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw();
     106             : 
     107             : public:
     108             : 
     109             :     /** Called by the corresponding ValueSet when it gets the focus.
     110             :         Stores the new focus state and broadcasts a state change event.
     111             :     */
     112             :     void GetFocus (void);
     113             : 
     114             :     /** Called by the corresponding ValueSet when it loses the focus.
     115             :         Stores the new focus state and broadcasts a state change event.
     116             :     */
     117             :     void LoseFocus (void);
     118             : 
     119             :     // XComponent
     120           0 :     virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException)
     121           0 :         { WeakComponentImplHelperBase::dispose(); }
     122           0 :     virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
     123           0 :         { WeakComponentImplHelperBase::addEventListener(xListener); }
     124           0 :     virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException)
     125           0 :         { WeakComponentImplHelperBase::removeEventListener(xListener); }
     126             : 
     127             :     // XAccessible
     128             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException);
     129             : 
     130             :     // XAccessibleEventBroadcaster
     131             :     virtual void SAL_CALL addAccessibleEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
     132             :     virtual void SAL_CALL removeAccessibleEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
     133             : 
     134             :     // XAccessibleContext
     135             :     virtual sal_Int32 SAL_CALL getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
     136             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
     137             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent(  ) throw (::com::sun::star::uno::RuntimeException);
     138             :     virtual sal_Int32 SAL_CALL getAccessibleIndexInParent(  ) throw (::com::sun::star::uno::RuntimeException);
     139             :     virtual sal_Int16 SAL_CALL getAccessibleRole(  ) throw (::com::sun::star::uno::RuntimeException);
     140             :     virtual ::rtl::OUString SAL_CALL getAccessibleDescription(  ) throw (::com::sun::star::uno::RuntimeException);
     141             :     virtual ::rtl::OUString SAL_CALL getAccessibleName(  ) throw (::com::sun::star::uno::RuntimeException);
     142             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) throw (::com::sun::star::uno::RuntimeException);
     143             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) throw (::com::sun::star::uno::RuntimeException);
     144             :     virtual ::com::sun::star::lang::Locale SAL_CALL getLocale(  ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
     145             : 
     146             :     // XAccessibleComponent
     147             :     virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
     148             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
     149             :     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds(  ) throw (::com::sun::star::uno::RuntimeException);
     150             :     virtual ::com::sun::star::awt::Point SAL_CALL getLocation(  ) throw (::com::sun::star::uno::RuntimeException);
     151             :     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  ) throw (::com::sun::star::uno::RuntimeException);
     152             :     virtual ::com::sun::star::awt::Size SAL_CALL getSize(  ) throw (::com::sun::star::uno::RuntimeException);
     153             :     virtual void SAL_CALL grabFocus(  ) throw (::com::sun::star::uno::RuntimeException);
     154             :     virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding(  ) throw (::com::sun::star::uno::RuntimeException);
     155             :     virtual sal_Int32 SAL_CALL getForeground(  ) throw (::com::sun::star::uno::RuntimeException);
     156             :     virtual sal_Int32 SAL_CALL getBackground(  ) throw (::com::sun::star::uno::RuntimeException);
     157             : 
     158             :     // XAccessibleSelection
     159             :     virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
     160             :     virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
     161             :     virtual void SAL_CALL clearAccessibleSelection(  ) throw (::com::sun::star::uno::RuntimeException);
     162             :     virtual void SAL_CALL selectAllAccessibleChildren(  ) throw (::com::sun::star::uno::RuntimeException);
     163             :     virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
     164             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
     165             :     virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
     166             : 
     167             :     // XUnoTunnel
     168             :     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException );
     169             : 
     170             : private:
     171             :     ::std::vector< ::com::sun::star::uno::Reference<
     172             :         ::com::sun::star::accessibility::XAccessibleEventListener > >   mxEventListeners;
     173             :     ValueSet*                                                           mpParent;
     174             :     bool                                                                mbIsTransientChildrenDisabled;
     175             :     /// The current FOCUSED state.
     176             :     bool mbIsFocused;
     177             : 
     178             :     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
     179             : 
     180             :     /** Tell all listeners that the object is dying.  This callback is
     181             :         usually called from the WeakComponentImplHelper class.
     182             :     */
     183             :     virtual void SAL_CALL disposing (void);
     184             : 
     185             :     /** Return the number of items.  This takes the None-Item into account.
     186             :     */
     187             :     sal_uInt16 getItemCount (void) const;
     188             : 
     189             :     /** Return the item associated with the given index.  The None-Item is
     190             :         taken into account which, when present, is taken to be the first
     191             :         (with index 0) item.
     192             :         @param nIndex
     193             :             Index of the item to return.  The index 0 denotes the None-Item
     194             :             when present.
     195             :         @return
     196             :             Returns NULL when the given index is out of range.
     197             :     */
     198             :     ValueSetItem* getItem (sal_uInt16 nIndex) const;
     199             : 
     200             :     /** Check whether or not the object has been disposed (or is in the
     201             :         state of beeing disposed).  If that is the case then
     202             :         DisposedException is thrown to inform the (indirect) caller of the
     203             :         foul deed.
     204             :     */
     205             :     void ThrowIfDisposed (void)
     206             :         throw (::com::sun::star::lang::DisposedException);
     207             : 
     208             :     /** Check whether the value set has a 'none' field, i.e. a field (button)
     209             :         that deselects any items (selects none of them).
     210             :         @return
     211             :             Returns <true/> if there is a 'none' field and <false/> it it is
     212             :             missing.
     213             :     */
     214             :     bool HasNoneField (void) const;
     215             : };
     216             : 
     217             : // ----------------
     218             : // - ValueItemAcc -
     219             : // ----------------
     220             : 
     221             : class ValueItemAcc : public ::cppu::WeakImplHelper5< ::com::sun::star::accessibility::XAccessible,
     222             :                                                      ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
     223             :                                                      ::com::sun::star::accessibility::XAccessibleContext,
     224             :                                                      ::com::sun::star::accessibility::XAccessibleComponent,
     225             :                                                      ::com::sun::star::lang::XUnoTunnel >
     226             : {
     227             : private:
     228             : 
     229             :     ::std::vector< ::com::sun::star::uno::Reference<
     230             :         ::com::sun::star::accessibility::XAccessibleEventListener > >   mxEventListeners;
     231             :     ::osl::Mutex                                                        maMutex;
     232             :     ValueSetItem*                                                       mpParent;
     233             :     bool                                                                mbIsTransientChildrenDisabled;
     234             : 
     235             :     static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
     236             : 
     237             : public:
     238             : 
     239             :     ValueItemAcc( ValueSetItem* pParent, bool bIsTransientChildrenDisabled );
     240             :     ~ValueItemAcc();
     241             : 
     242             :     void    ParentDestroyed();
     243             : 
     244             :     void    FireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue );
     245             :     sal_Bool    HasAccessibleListeners() const { return( mxEventListeners.size() > 0 ); }
     246             : 
     247             :     static ValueItemAcc* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw();
     248             : 
     249             : public:
     250             : 
     251             :     // XAccessible
     252             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException);
     253             : 
     254             :     // XAccessibleEventBroadcaster
     255             :     virtual void SAL_CALL addAccessibleEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
     256             :     virtual void SAL_CALL removeAccessibleEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
     257             : 
     258             :     // XAccessibleContext
     259             :     virtual sal_Int32 SAL_CALL getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
     260             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
     261             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent(  ) throw (::com::sun::star::uno::RuntimeException);
     262             :     virtual sal_Int32 SAL_CALL getAccessibleIndexInParent(  ) throw (::com::sun::star::uno::RuntimeException);
     263             :     virtual sal_Int16 SAL_CALL getAccessibleRole(  ) throw (::com::sun::star::uno::RuntimeException);
     264             :     virtual ::rtl::OUString SAL_CALL getAccessibleDescription(  ) throw (::com::sun::star::uno::RuntimeException);
     265             :     virtual ::rtl::OUString SAL_CALL getAccessibleName(  ) throw (::com::sun::star::uno::RuntimeException);
     266             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) throw (::com::sun::star::uno::RuntimeException);
     267             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) throw (::com::sun::star::uno::RuntimeException);
     268             :     virtual ::com::sun::star::lang::Locale SAL_CALL getLocale(  ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
     269             : 
     270             :     // XAccessibleComponent
     271             :     virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
     272             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
     273             :     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds(  ) throw (::com::sun::star::uno::RuntimeException);
     274             :     virtual ::com::sun::star::awt::Point SAL_CALL getLocation(  ) throw (::com::sun::star::uno::RuntimeException);
     275             :     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  ) throw (::com::sun::star::uno::RuntimeException);
     276             :     virtual ::com::sun::star::awt::Size SAL_CALL getSize(  ) throw (::com::sun::star::uno::RuntimeException);
     277             :     virtual void SAL_CALL grabFocus(  ) throw (::com::sun::star::uno::RuntimeException);
     278             :     virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding(  ) throw (::com::sun::star::uno::RuntimeException);
     279             :     virtual sal_Int32 SAL_CALL getForeground(  ) throw (::com::sun::star::uno::RuntimeException);
     280             :     virtual sal_Int32 SAL_CALL getBackground(  ) throw (::com::sun::star::uno::RuntimeException);
     281             : 
     282             :     // XUnoTunnel
     283             :     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException );
     284             : };
     285             : 
     286             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10