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_COMPONENT_HELPER_HXX
25 #define COMPHELPER_ACCESSIBLE_COMPONENT_HELPER_HXX
26 
27 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
28 #include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp>
29 #include <comphelper/accessiblecontexthelper.hxx>
30 #include <cppuhelper/implbase1.hxx>
31 #include <comphelper/uno3.hxx>
32 #include "comphelper/comphelperdllapi.h"
33 
34 //.........................................................................
35 namespace comphelper
36 {
37 //.........................................................................
38 
39 	//=====================================================================
40 	//= OCommonAccessibleComponent
41 	//=====================================================================
42 	/** base class encapsulating common functionality for the helper classes implementing
43 		the XAccessibleComponent respectively XAccessibleExtendendComponent
44 	*/
45 	class COMPHELPER_DLLPUBLIC OCommonAccessibleComponent : public OAccessibleContextHelper
46 	{
47 	protected:
48 		OCommonAccessibleComponent();
49 		/// see the respective base class ctor for an extensive comment on this, please
50 		OCommonAccessibleComponent( IMutex* _pExternalLock );
51 		~OCommonAccessibleComponent();
52 
53 	protected:
54 		/// implements the calculation of the bounding rectangle - still waiting to be overwritten
55 		virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
56 
57 	protected:
58 		/** non-virtual versions of the methods which can be implemented using <method>implGetBounds</method>
59 			note: getLocationOnScreen relies on a valid parent (XAccessibleContext::getParent()->getAccessibleContext()),
60 			     which itself implements XAccessibleComponent
61 		*/
62 		sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
63 		::com::sun::star::awt::Point SAL_CALL getLocation(  ) throw (::com::sun::star::uno::RuntimeException);
64 		::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  ) throw (::com::sun::star::uno::RuntimeException);
65 		::com::sun::star::awt::Size SAL_CALL getSize(  ) throw (::com::sun::star::uno::RuntimeException);
66 		::com::sun::star::awt::Rectangle SAL_CALL getBounds(  ) throw (::com::sun::star::uno::RuntimeException);
67 	};
68 
69 	//=====================================================================
70 	//= OAccessibleComponentHelper
71 	//=====================================================================
72 
73 	struct OAccessibleComponentHelper_Base :
74 		public ::cppu::ImplHelper1< ::com::sun::star::accessibility::XAccessibleComponent >
75 	{};
76 
77 	/** a helper class for implementing an AccessibleContext which at the same time
78 		supports an XAccessibleComponent interface.
79 	*/
80 	class COMPHELPER_DLLPUBLIC OAccessibleComponentHelper
81 			:public OCommonAccessibleComponent
82 			,public OAccessibleComponentHelper_Base
83 	{
84 	protected:
85 		OAccessibleComponentHelper( );
86 		/// see the respective base class ctor for an extensive comment on this, please
87 		OAccessibleComponentHelper( IMutex* _pExternalLock );
88 
89 	public:
90 		// XInterface
91 		DECLARE_XINTERFACE( )
92 		DECLARE_XTYPEPROVIDER( )
93 
94 		// XAccessibleComponent - default implementations
95 		virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
96 		virtual ::com::sun::star::awt::Point SAL_CALL getLocation(  ) throw (::com::sun::star::uno::RuntimeException);
97 		virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  ) throw (::com::sun::star::uno::RuntimeException);
98 		virtual ::com::sun::star::awt::Size SAL_CALL getSize(  ) throw (::com::sun::star::uno::RuntimeException);
99 		virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds(  ) throw (::com::sun::star::uno::RuntimeException);
100 	};
101 
102 	//=====================================================================
103 	//= OAccessibleExtendedComponentHelper
104 	//=====================================================================
105 
106 	typedef	::cppu::ImplHelper1	<	::com::sun::star::accessibility::XAccessibleExtendedComponent
107 								>	OAccessibleExtendedComponentHelper_Base;
108 
109 	/** a helper class for implementing an AccessibleContext which at the same time
110 		supports an XAccessibleExtendedComponent interface.
111 	*/
112 	class COMPHELPER_DLLPUBLIC OAccessibleExtendedComponentHelper
113 			:public OCommonAccessibleComponent
114 			,public OAccessibleExtendedComponentHelper_Base
115 	{
116 	protected:
117 		OAccessibleExtendedComponentHelper( );
118 		/// see the respective base class ctor for an extensive comment on this, please
119 		OAccessibleExtendedComponentHelper( IMutex* _pExternalLock );
120 
121 	public:
122 		// XInterface
123 		DECLARE_XINTERFACE( )
124 		DECLARE_XTYPEPROVIDER( )
125 
126 		// XAccessibleComponent - default implementations
127 		virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
128 		virtual ::com::sun::star::awt::Point SAL_CALL getLocation(  ) throw (::com::sun::star::uno::RuntimeException);
129 		virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  ) throw (::com::sun::star::uno::RuntimeException);
130 		virtual ::com::sun::star::awt::Size SAL_CALL getSize(  ) throw (::com::sun::star::uno::RuntimeException);
131 		virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds(  ) throw (::com::sun::star::uno::RuntimeException);
132 	};
133 
134 //.........................................................................
135 }	// namespace comphelper
136 //.........................................................................
137 
138 #endif // COMPHELPER_ACCESSIBLE_COMPONENT_HELPER_HXX
139 
140 
141