1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef COMPHELPER_ACCESSIBLE_SELECTION_HELPER_HXX
25 #define COMPHELPER_ACCESSIBLE_SELECTION_HELPER_HXX
26 
27 #include <comphelper/uno3.hxx>
28 #ifndef COMPHELPER_ACCESSIBLE_CONTEXT_HELPER_HXX
29 #include <comphelper/accessiblecomponenthelper.hxx>
30 #endif
31 #include <cppuhelper/implbase1.hxx>
32 #include <comphelper/uno3.hxx>
33 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
34 #include "comphelper/comphelperdllapi.h"
35 
36 #define ACCESSIBLE_SELECTION_CHILD_ALL  ((sal_Int32)-1)
37 #define ACCESSIBLE_SELECTION_CHILD_SELF ((sal_Int32)-2)
38 
39 //.........................................................................
40 namespace comphelper
41 {
42 //.........................................................................
43 
44 	//=====================================================================
45 	//= OCommonAccessibleSelection
46 	//=====================================================================
47 	/** base class encapsulating common functionality for the helper classes implementing
48 		the XAccessibleSelection
49 	*/
50 	class COMPHELPER_DLLPUBLIC OCommonAccessibleSelection
51 	{
52 	protected:
53 
54         OCommonAccessibleSelection();
55 
56 	protected:
57 
58 		// access to context - still waiting to be overwritten
59         virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
60             implGetAccessibleContext()
61             throw ( ::com::sun::star::uno::RuntimeException ) = 0;
62 
63         // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
64 	    virtual sal_Bool
65             implIsSelected( sal_Int32 nAccessibleChildIndex )
66             throw (::com::sun::star::uno::RuntimeException) = 0;
67 
68 	    // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
69         virtual void
70             implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect )
71             throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) = 0;
72 
73 	protected:
74 
75         /** non-virtual versions of the methods which can be implemented using <method>implIsSelected</method> and <method>implSelect</method>
76 	    */
77 	    void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
78 	    sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
79 	    void SAL_CALL clearAccessibleSelection(  ) throw (::com::sun::star::uno::RuntimeException);
80 	    void SAL_CALL selectAllAccessibleChildren(  ) throw (::com::sun::star::uno::RuntimeException);
81 	    sal_Int32 SAL_CALL getSelectedAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
82 	    ::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);
83 	    void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
84     };
85 
86 	//=====================================================================
87 	//= OAccessibleSelectionHelper
88 	//=====================================================================
89 
90 	typedef	::cppu::ImplHelper1< ::com::sun::star::accessibility::XAccessibleSelection > OAccessibleSelectionHelper_Base;
91 
92 	/** a helper class for implementing an AccessibleSelection which at the same time
93 		supports an XAccessibleSelection interface.
94 	*/
95 	class COMPHELPER_DLLPUBLIC OAccessibleSelectionHelper : public OAccessibleComponentHelper,
96                                        public OCommonAccessibleSelection,
97 			                           public OAccessibleSelectionHelper_Base
98 	{
99 	protected:
100 
101         OAccessibleSelectionHelper( );
102 
103 		/// see the respective base class ctor for an extensive comment on this, please
104 		OAccessibleSelectionHelper( IMutex* _pExternalLock );
105 
106 		// return ourself here by default
107         virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > implGetAccessibleContext() throw ( ::com::sun::star::uno::RuntimeException );
108 
109 	public:
110 
111         // XInterface
112 		DECLARE_XINTERFACE( )
113 		DECLARE_XTYPEPROVIDER( )
114 
115 		// XAccessibleSelection - default implementations
116 	    virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
117 	    virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
118 	    virtual void SAL_CALL clearAccessibleSelection(  ) throw (::com::sun::star::uno::RuntimeException);
119 	    virtual void SAL_CALL selectAllAccessibleChildren(  ) throw (::com::sun::star::uno::RuntimeException);
120 	    virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
121 	    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);
122 	    virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
123 	};
124 
125 //.........................................................................
126 }	// namespace comphelper
127 //.........................................................................
128 
129 #endif // COMPHELPER_ACCESSIBLE_SELECTION_HELPER_HXX
130 
131