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

Generated by: LCOV version 1.10