xref: /trunk/main/comphelper/inc/comphelper/accessiblecomponenthelper.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef COMPHELPER_ACCESSIBLE_COMPONENT_HELPER_HXX
29 #define COMPHELPER_ACCESSIBLE_COMPONENT_HELPER_HXX
30 
31 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
32 #include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp>
33 #include <comphelper/accessiblecontexthelper.hxx>
34 #include <cppuhelper/implbase1.hxx>
35 #include <comphelper/uno3.hxx>
36 #include "comphelper/comphelperdllapi.h"
37 
38 //.........................................................................
39 namespace comphelper
40 {
41 //.........................................................................
42 
43     //=====================================================================
44     //= OCommonAccessibleComponent
45     //=====================================================================
46     /** base class encapsulating common functionality for the helper classes implementing
47         the XAccessibleComponent respectively XAccessibleExtendendComponent
48     */
49     class COMPHELPER_DLLPUBLIC OCommonAccessibleComponent : public OAccessibleContextHelper
50     {
51     protected:
52         OCommonAccessibleComponent();
53         /// see the respective base class ctor for an extensive comment on this, please
54         OCommonAccessibleComponent( IMutex* _pExternalLock );
55         ~OCommonAccessibleComponent();
56 
57     protected:
58         /// implements the calculation of the bounding rectangle - still waiting to be overwritten
59         virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
60 
61     protected:
62         /** non-virtual versions of the methods which can be implemented using <method>implGetBounds</method>
63             note: getLocationOnScreen relies on a valid parent (XAccessibleContext::getParent()->getAccessibleContext()),
64                  which itself implements XAccessibleComponent
65         */
66         sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
67         ::com::sun::star::awt::Point SAL_CALL getLocation(  ) throw (::com::sun::star::uno::RuntimeException);
68         ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  ) throw (::com::sun::star::uno::RuntimeException);
69         ::com::sun::star::awt::Size SAL_CALL getSize(  ) throw (::com::sun::star::uno::RuntimeException);
70         ::com::sun::star::awt::Rectangle SAL_CALL getBounds(  ) throw (::com::sun::star::uno::RuntimeException);
71     };
72 
73     //=====================================================================
74     //= OAccessibleComponentHelper
75     //=====================================================================
76 
77     struct OAccessibleComponentHelper_Base :
78         public ::cppu::ImplHelper1< ::com::sun::star::accessibility::XAccessibleComponent >
79     {};
80 
81     /** a helper class for implementing an AccessibleContext which at the same time
82         supports an XAccessibleComponent interface.
83     */
84     class COMPHELPER_DLLPUBLIC OAccessibleComponentHelper
85             :public OCommonAccessibleComponent
86             ,public OAccessibleComponentHelper_Base
87     {
88     protected:
89         OAccessibleComponentHelper( );
90         /// see the respective base class ctor for an extensive comment on this, please
91         OAccessibleComponentHelper( IMutex* _pExternalLock );
92 
93     public:
94         // XInterface
95         DECLARE_XINTERFACE( )
96         DECLARE_XTYPEPROVIDER( )
97 
98         // XAccessibleComponent - default implementations
99         virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
100         virtual ::com::sun::star::awt::Point SAL_CALL getLocation(  ) throw (::com::sun::star::uno::RuntimeException);
101         virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  ) throw (::com::sun::star::uno::RuntimeException);
102         virtual ::com::sun::star::awt::Size SAL_CALL getSize(  ) throw (::com::sun::star::uno::RuntimeException);
103         virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds(  ) throw (::com::sun::star::uno::RuntimeException);
104     };
105 
106     //=====================================================================
107     //= OAccessibleExtendedComponentHelper
108     //=====================================================================
109 
110     typedef ::cppu::ImplHelper1 <   ::com::sun::star::accessibility::XAccessibleExtendedComponent
111                                 >   OAccessibleExtendedComponentHelper_Base;
112 
113     /** a helper class for implementing an AccessibleContext which at the same time
114         supports an XAccessibleExtendedComponent interface.
115     */
116     class COMPHELPER_DLLPUBLIC OAccessibleExtendedComponentHelper
117             :public OCommonAccessibleComponent
118             ,public OAccessibleExtendedComponentHelper_Base
119     {
120     protected:
121         OAccessibleExtendedComponentHelper( );
122         /// see the respective base class ctor for an extensive comment on this, please
123         OAccessibleExtendedComponentHelper( IMutex* _pExternalLock );
124 
125     public:
126         // XInterface
127         DECLARE_XINTERFACE( )
128         DECLARE_XTYPEPROVIDER( )
129 
130         // XAccessibleComponent - default implementations
131         virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
132         virtual ::com::sun::star::awt::Point SAL_CALL getLocation(  ) throw (::com::sun::star::uno::RuntimeException);
133         virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  ) throw (::com::sun::star::uno::RuntimeException);
134         virtual ::com::sun::star::awt::Size SAL_CALL getSize(  ) throw (::com::sun::star::uno::RuntimeException);
135         virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds(  ) throw (::com::sun::star::uno::RuntimeException);
136     };
137 
138 //.........................................................................
139 }   // namespace comphelper
140 //.........................................................................
141 
142 #endif // COMPHELPER_ACCESSIBLE_COMPONENT_HELPER_HXX
143 
144 
145