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