diff options
author | Kai Ahrens <ka@openoffice.org> | 2002-05-06 08:59:53 +0000 |
---|---|---|
committer | Kai Ahrens <ka@openoffice.org> | 2002-05-06 08:59:53 +0000 |
commit | b4b249da7f4b49b1ed1481aa69ae8e9cdb4a4030 (patch) | |
tree | ce6c5fc2165339e33a0240ea599f4fb447b2feca | |
parent | a42dd813f13251aa2aa6a8e4da00181fe432cc5a (diff) |
#95585#: added AccessibleSelection helper
-rw-r--r-- | comphelper/inc/comphelper/accessibleselectionhelper.hxx | 177 | ||||
-rw-r--r-- | comphelper/source/misc/accessibleselectionhelper.cxx | 225 | ||||
-rw-r--r-- | comphelper/source/misc/makefile.mk | 5 |
3 files changed, 405 insertions, 2 deletions
diff --git a/comphelper/inc/comphelper/accessibleselectionhelper.hxx b/comphelper/inc/comphelper/accessibleselectionhelper.hxx new file mode 100644 index 000000000000..c046af6378ac --- /dev/null +++ b/comphelper/inc/comphelper/accessibleselectionhelper.hxx @@ -0,0 +1,177 @@ +/************************************************************************* + * + * $RCSfile: accessibleselectionhelper.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: ka $ $Date: 2002-05-06 09:58:52 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef COMPHELPER_ACCESSIBLE_SELECTION_HELPER_HXX +#define COMPHELPER_ACCESSIBLE_SELECTION_HELPER_HXX + +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif +#ifndef COMPHELPER_ACCESSIBLE_CONTEXT_HELPER_HXX +#include <comphelper/accessiblecomponenthelper.hxx> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif + +#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLESELECTION_HPP_ +#include <drafts/com/sun/star/accessibility/XAccessibleSelection.hpp> +#endif + +#define ACCESSIBLE_SELECTION_CHILD_ALL ((sal_Int32)-1) +#define ACCESSIBLE_SELECTION_CHILD_SELF ((sal_Int32)-2) + +//......................................................................... +namespace comphelper +{ +//......................................................................... + + //===================================================================== + //= OCommonAccessibleSelection + //===================================================================== + /** base class encapsulating common functionality for the helper classes implementing + the XAccessibleSelection + */ + class OCommonAccessibleSelection + { + protected: + + OCommonAccessibleSelection(); + + protected: + + // access to context - still waiting to be overwritten + virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessibleContext > + implGetAccessibleContext() + throw ( ::com::sun::star::uno::RuntimeException ) = 0; + + // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) + virtual sal_Bool + implIsSelected( sal_Int32 nAccessibleChildIndex ) + throw (::com::sun::star::uno::RuntimeException) = 0; + + // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) + virtual void + implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) = 0; + + protected: + + /** non-virtual versions of the methods which can be implemented using <method>implIsSelected</method> and <method>implSelect</method> + */ + void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + void SAL_CALL clearAccessibleSelection( ) throw (::com::sun::star::uno::RuntimeException); + void SAL_CALL selectAllAccessible( ) throw (::com::sun::star::uno::RuntimeException); + sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + void SAL_CALL deselectSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + + //===================================================================== + //= OAccessibleSelectionHelper + //===================================================================== + + typedef ::cppu::ImplHelper1< ::drafts::com::sun::star::accessibility::XAccessibleSelection > OAccessibleSelectionHelper_Base; + + /** a helper class for implementing an AccessibleSelection which at the same time + supports an XAccessibleSelection interface. + */ + class OAccessibleSelectionHelper : public OAccessibleComponentHelper, + public OCommonAccessibleSelection, + public OAccessibleSelectionHelper_Base + { + protected: + + OAccessibleSelectionHelper( ); + + // return ourself here by default + virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessibleContext > implGetAccessibleContext() throw ( ::com::sun::star::uno::RuntimeException ); + + public: + + // XInterface + DECLARE_XINTERFACE( ) + DECLARE_XTYPEPROVIDER( ) + + // XAccessibleSelection - default implementations + virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL clearAccessibleSelection( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL selectAllAccessible( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deselectSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + }; + +//......................................................................... +} // namespace comphelper +//......................................................................... + +#endif // COMPHELPER_ACCESSIBLE_SELECTION_HELPER_HXX + +/************************************************************************* + * history: + * $Log: not supported by cvs2svn $ + ************************************************************************/ diff --git a/comphelper/source/misc/accessibleselectionhelper.cxx b/comphelper/source/misc/accessibleselectionhelper.cxx new file mode 100644 index 000000000000..7c10a80459dc --- /dev/null +++ b/comphelper/source/misc/accessibleselectionhelper.cxx @@ -0,0 +1,225 @@ +/************************************************************************* + * + * $RCSfile: accessibleselectionhelper.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: ka $ $Date: 2002-05-06 09:59:53 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef COMPHELPER_ACCESSIBLE_SELECTION_HELPER_HXX +#include <comphelper/accessibleselectionhelper.hxx> +#endif + +//......................................................................... +namespace comphelper +{ +//......................................................................... + + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::awt; + using namespace ::com::sun::star::lang; + using namespace ::drafts::com::sun::star::accessibility; + + //===================================================================== + //= OCommonAccessibleSelection + //===================================================================== + //--------------------------------------------------------------------- + OCommonAccessibleSelection::OCommonAccessibleSelection( ) + { + } + + //-------------------------------------------------------------------- + void SAL_CALL OCommonAccessibleSelection::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + implSelect( nChildIndex, sal_True ); + } + + //-------------------------------------------------------------------- + sal_Bool SAL_CALL OCommonAccessibleSelection::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + return( implIsSelected( nChildIndex ) ); + } + + //-------------------------------------------------------------------- + void SAL_CALL OCommonAccessibleSelection::clearAccessibleSelection( ) throw (RuntimeException) + { + implSelect( ACCESSIBLE_SELECTION_CHILD_ALL, sal_False ); + } + + //-------------------------------------------------------------------- + void SAL_CALL OCommonAccessibleSelection::selectAllAccessible( ) throw (RuntimeException) + { + implSelect( ACCESSIBLE_SELECTION_CHILD_ALL, sal_True ); + } + + //-------------------------------------------------------------------- + sal_Int32 SAL_CALL OCommonAccessibleSelection::getSelectedAccessibleChildCount( ) throw (RuntimeException) + { + sal_Int32 nRet = 0; + Reference< XAccessibleContext > xParentContext( implGetAccessibleContext() ); + + OSL_ENSURE( xParentContext.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" ); + + if( xParentContext.is() ) + { + for( sal_Int32 i = 0, nChildCount = xParentContext->getAccessibleChildCount(); i < nChildCount; i++ ) + if( implIsSelected( i ) ) + ++nRet; + } + + return( nRet ); + } + + //-------------------------------------------------------------------- + Reference< XAccessible > SAL_CALL OCommonAccessibleSelection::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + Reference< XAccessible > xRet; + Reference< XAccessibleContext > xParentContext( implGetAccessibleContext() ); + + OSL_ENSURE( xParentContext.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" ); + + if( xParentContext.is() ) + { + for( sal_Int32 i = 0, nChildCount = xParentContext->getAccessibleChildCount(), nPos = 0; ( i < nChildCount ) && !xRet.is(); i++ ) + if( implIsSelected( i ) && ( nPos++ == nSelectedChildIndex ) ) + xRet = xParentContext->getAccessibleChild( i ); + } + + return( xRet ); + } + + //-------------------------------------------------------------------- + void SAL_CALL OCommonAccessibleSelection::deselectSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + implSelect( nSelectedChildIndex, sal_False ); + } + + //===================================================================== + //= OAccessibleSelectionHelper + //===================================================================== + //--------------------------------------------------------------------- + OAccessibleSelectionHelper::OAccessibleSelectionHelper( ) + { + } + + //-------------------------------------------------------------------- + IMPLEMENT_FORWARD_XINTERFACE2( OAccessibleSelectionHelper, OAccessibleComponentHelper, OAccessibleSelectionHelper_Base ) + IMPLEMENT_FORWARD_XTYPEPROVIDER2( OAccessibleSelectionHelper, OAccessibleComponentHelper, OAccessibleSelectionHelper_Base ) + // (order matters: the first is the class name, the second is the class doing the ref counting) + + //-------------------------------------------------------------------- + Reference< XAccessibleContext > OAccessibleSelectionHelper::implGetAccessibleContext() throw ( RuntimeException ) + { + return( this ); + } + + //-------------------------------------------------------------------- + void SAL_CALL OAccessibleSelectionHelper::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + OContextEntryGuard aGuard( this ); + OCommonAccessibleSelection::selectAccessibleChild( nChildIndex ); + } + + //-------------------------------------------------------------------- + sal_Bool SAL_CALL OAccessibleSelectionHelper::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + OContextEntryGuard aGuard( this ); + return( OCommonAccessibleSelection::isAccessibleChildSelected( nChildIndex ) ); + } + + //-------------------------------------------------------------------- + void SAL_CALL OAccessibleSelectionHelper::clearAccessibleSelection( ) throw (RuntimeException) + { + OContextEntryGuard aGuard( this ); + OCommonAccessibleSelection::clearAccessibleSelection(); + } + + //-------------------------------------------------------------------- + void SAL_CALL OAccessibleSelectionHelper::selectAllAccessible( ) throw (RuntimeException) + { + OContextEntryGuard aGuard( this ); + OCommonAccessibleSelection::selectAllAccessible(); + } + + //-------------------------------------------------------------------- + sal_Int32 SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) throw (RuntimeException) + { + OContextEntryGuard aGuard( this ); + return( OCommonAccessibleSelection::getSelectedAccessibleChildCount() ); + } + + //-------------------------------------------------------------------- + Reference< XAccessible > SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + OContextEntryGuard aGuard( this ); + return( OCommonAccessibleSelection::getSelectedAccessibleChild( nSelectedChildIndex ) ); + } + + //-------------------------------------------------------------------- + void SAL_CALL OAccessibleSelectionHelper::deselectSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + OContextEntryGuard aGuard( this ); + OCommonAccessibleSelection::deselectSelectedAccessibleChild( nSelectedChildIndex ); + } + +//......................................................................... +} // namespace comphelper +//......................................................................... + +/************************************************************************* + * history: + * $Log: not supported by cvs2svn $ + ************************************************************************/ diff --git a/comphelper/source/misc/makefile.mk b/comphelper/source/misc/makefile.mk index 20f37490cf9b..9327ee1f818e 100644 --- a/comphelper/source/misc/makefile.mk +++ b/comphelper/source/misc/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.8 $ +# $Revision: 1.9 $ # -# last change: $Author: fs $ $Date: 2002-04-23 11:11:06 $ +# last change: $Author: ka $ $Date: 2002-05-06 09:59:53 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -75,6 +75,7 @@ ENABLE_EXCEPTIONS=TRUE SLOFILES= \ $(SLO)$/accessiblecomponenthelper.obj \ $(SLO)$/accessiblecontexthelper.obj \ + $(SLO)$/accessibleselectionhelper.obj \ $(SLO)$/accimplaccess.obj \ $(SLO)$/interaction.obj \ $(SLO)$/types.obj \ |