tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / inc / AccessibleEditObject.hxx
blob159fa2eeb77e8ca37a5ad18acff9dc2757b255b7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include "AccessibleContextBase.hxx"
24 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
25 #include <address.hxx>
26 #include <vcl/vclptr.hxx>
27 #include <vcl/customweld.hxx>
29 #include <memory>
31 namespace accessibility
33 class AccessibleTextHelper;
35 class EditView;
36 class ScTextWnd;
37 namespace vcl { class Window; }
39 /** @descr
40 This base class provides an implementation of the
41 <code>AccessibleCell</code> service.
43 class ScAccessibleEditObject
44 : public ScAccessibleContextBase,
45 public css::accessibility::XAccessibleSelection
47 public:
48 enum EditObjectType
50 CellInEditMode,
51 EditLine,
52 EditControl
55 ScAccessibleEditObject(
56 const css::uno::Reference<css::accessibility::XAccessible>& rxParent,
57 EditView* pEditView, vcl::Window* pWin, const OUString& rName,
58 const OUString& rDescription, EditObjectType eObjectType);
60 void InitAcc(
61 const css::uno::Reference<css::accessibility::XAccessible>& rxParent,
62 EditView* pEditView, const OUString& rName, const OUString& rDescription);
64 protected:
65 virtual ~ScAccessibleEditObject() override;
67 ScAccessibleEditObject(EditObjectType eObjectType);
69 using ScAccessibleContextBase::IsDefunc;
71 public:
72 using ScAccessibleContextBase::disposing;
74 virtual void SAL_CALL disposing() override;
76 void LostFocus();
78 void GotFocus();
79 ///===== XInterface =====================================================
81 virtual css::uno::Any SAL_CALL queryInterface(
82 css::uno::Type const & rType ) override;
84 virtual void SAL_CALL acquire() noexcept override;
86 virtual void SAL_CALL release() noexcept override;
87 ///===== XAccessibleComponent ============================================
89 virtual css::uno::Reference< css::accessibility::XAccessible >
90 SAL_CALL getAccessibleAtPoint(
91 const css::awt::Point& rPoint ) override;
93 virtual OutputDevice* GetOutputDeviceForView();
95 protected:
96 /// Return the object's current bounding box relative to the desktop.
97 virtual AbsoluteScreenPixelRectangle GetBoundingBoxOnScreen() const override;
99 /// Return the object's current bounding box relative to the parent object.
100 virtual tools::Rectangle GetBoundingBox() const override;
102 public:
103 ///===== XAccessibleContext ==============================================
105 /// Return the number of currently visible children.
106 /// override to calculate this on demand
107 virtual sal_Int64 SAL_CALL
108 getAccessibleChildCount() override;
110 /// Return the specified child or NULL if index is invalid.
111 /// override to calculate this on demand
112 virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
113 getAccessibleChild(sal_Int64 nIndex) override;
115 /// Return the set of current states.
116 virtual sal_Int64 SAL_CALL getAccessibleStateSet() override;
118 //===== XAccessibleSelection ============================================
120 virtual void SAL_CALL selectAccessibleChild(
121 sal_Int64 nChildIndex ) override;
122 virtual sal_Bool SAL_CALL isAccessibleChildSelected(
123 sal_Int64 nChildIndex ) override;
124 virtual void SAL_CALL clearAccessibleSelection( ) override;
125 virtual void SAL_CALL selectAllAccessibleChildren( ) override;
126 virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount( ) override;
127 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(
128 sal_Int64 nSelectedChildIndex ) override;
129 virtual void SAL_CALL deselectAccessibleChild(
130 sal_Int64 nSelectedChildIndex ) override;
131 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
132 protected:
133 /// Return this object's description.
134 virtual OUString
135 createAccessibleDescription() override;
137 /// Return the object's current name.
138 virtual OUString
139 createAccessibleName() override;
141 public:
142 ///===== XAccessibleEventBroadcaster =====================================
144 /** Add listener that is informed of future changes of name,
145 description and so on events.
147 virtual void SAL_CALL
148 addAccessibleEventListener(
149 const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override;
151 // Remove an existing event listener.
152 virtual void SAL_CALL
153 removeAccessibleEventListener(
154 const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override;
156 ///===== XServiceInfo ====================================================
158 /** Returns an identifier for the implementation of this object.
160 virtual OUString SAL_CALL
161 getImplementationName() override;
163 ///===== XTypeProvider ===================================================
165 /** Returns an implementation id.
167 virtual css::uno::Sequence<sal_Int8> SAL_CALL
168 getImplementationId() override;
170 private:
171 std::unique_ptr<accessibility::AccessibleTextHelper> mpTextHelper;
172 EditView* mpEditView;
173 VclPtr<vcl::Window> mpWindow;
174 protected:
175 ScTextWnd* mpTextWnd;
176 private:
177 EditObjectType meObjectType;
178 bool mbHasFocus;
180 bool IsDefunc(sal_Int64 nParentStates);
182 void CreateTextHelper();
183 ScDocument *m_pScDoc;
184 ScAddress m_curCellAddress;
186 ///===== XAccessibleComponent ============================================
187 virtual sal_Int32 SAL_CALL getForeground( ) override;
189 virtual sal_Int32 SAL_CALL getBackground( ) override;
191 sal_Int32 GetFgBgColor( const OUString &strPropColor) ;
194 class ScAccessibleEditControlObject : public ScAccessibleEditObject
196 private:
197 weld::CustomWidgetController* m_pController;
199 protected:
200 /// Return the object's current bounding box relative to the desktop.
201 virtual AbsoluteScreenPixelRectangle GetBoundingBoxOnScreen() const override;
203 /// Return the object's current bounding box relative to the parent object.
204 virtual tools::Rectangle GetBoundingBox() const override;
206 public:
207 ScAccessibleEditControlObject(weld::CustomWidgetController* pController, EditObjectType eObjectType)
208 : ScAccessibleEditObject(eObjectType)
209 , m_pController(pController)
213 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
215 // for mapping positions/sizes within the TextView to a11y
216 virtual OutputDevice* GetOutputDeviceForView() override;
218 using ScAccessibleContextBase::disposing;
219 virtual void SAL_CALL disposing() override;
222 class ScAccessibleEditLineObject : public ScAccessibleEditControlObject
224 public:
225 ScAccessibleEditLineObject(ScTextWnd* pTextWnd);
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */