Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "AccessibleGlobal.hxx"
31 : : #include "AccessibleFilterMenuItem.hxx"
32 : : #include "checklistmenu.hxx"
33 : :
34 : : #include <com/sun/star/accessibility/XAccessible.hpp>
35 : : #include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
36 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
37 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
38 : : #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
39 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
40 : : #include <com/sun/star/accessibility/TextSegment.hpp>
41 : :
42 : : using namespace ::com::sun::star;
43 : : using namespace ::com::sun::star::accessibility;
44 : : using namespace ::com::sun::star::accessibility::AccessibleStateType;
45 : :
46 : : using ::com::sun::star::uno::Any;
47 : : using ::com::sun::star::uno::Reference;
48 : : using ::com::sun::star::uno::Sequence;
49 : : using ::com::sun::star::uno::UNO_QUERY;
50 : : using ::com::sun::star::lang::IndexOutOfBoundsException;
51 : : using ::com::sun::star::uno::RuntimeException;
52 : : using ::rtl::OUString;
53 : :
54 : 0 : ScAccessibleFilterMenuItem::ScAccessibleFilterMenuItem(
55 : : const Reference<XAccessible>& rxParent, ScMenuFloatingWindow* pWin, const OUString& rName, size_t nMenuPos) :
56 : : ScAccessibleContextBase(rxParent, AccessibleRole::MENU_ITEM),
57 : : mpWindow(pWin),
58 : : maName(rName),
59 : : mnMenuPos(nMenuPos),
60 : 0 : mbEnabled(true)
61 : : {
62 : 0 : SetName(rName);
63 : 0 : }
64 : :
65 : 0 : ScAccessibleFilterMenuItem::~ScAccessibleFilterMenuItem()
66 : : {
67 [ # # ]: 0 : }
68 : :
69 : 0 : sal_Int32 ScAccessibleFilterMenuItem::getAccessibleChildCount()
70 : : throw (RuntimeException)
71 : : {
72 : 0 : return 0;
73 : : }
74 : :
75 : 0 : Reference<XAccessible> ScAccessibleFilterMenuItem::getAccessibleChild(sal_Int32 /*nIndex*/)
76 : : throw (RuntimeException, IndexOutOfBoundsException)
77 : : {
78 [ # # ]: 0 : throw IndexOutOfBoundsException();
79 : : }
80 : :
81 : 0 : Reference<XAccessibleStateSet> ScAccessibleFilterMenuItem::getAccessibleStateSet()
82 : : throw (RuntimeException)
83 : : {
84 : 0 : updateStateSet();
85 : 0 : return mxStateSet;
86 : : }
87 : :
88 : 0 : OUString ScAccessibleFilterMenuItem::getImplementationName()
89 : : throw (RuntimeException)
90 : : {
91 : 0 : return OUString(RTL_CONSTASCII_USTRINGPARAM("ScAccessibleFilterMenuItem"));
92 : : }
93 : :
94 : : // XAccessibleAction
95 : :
96 : 0 : sal_Int32 ScAccessibleFilterMenuItem::getAccessibleActionCount() throw (RuntimeException)
97 : : {
98 : 0 : return 1;
99 : : }
100 : :
101 : 0 : sal_Bool ScAccessibleFilterMenuItem::doAccessibleAction(sal_Int32 /*nIndex*/)
102 : : throw (IndexOutOfBoundsException, RuntimeException)
103 : : {
104 : 0 : mpWindow->executeMenuItem(mnMenuPos);
105 : 0 : return true;
106 : : }
107 : :
108 : 0 : OUString ScAccessibleFilterMenuItem::getAccessibleActionDescription(sal_Int32 /*nIndex*/)
109 : : throw (IndexOutOfBoundsException, RuntimeException)
110 : : {
111 : 0 : return OUString(RTL_CONSTASCII_USTRINGPARAM("click"));
112 : : }
113 : :
114 : 0 : Reference<XAccessibleKeyBinding> ScAccessibleFilterMenuItem::getAccessibleActionKeyBinding(
115 : : sal_Int32 /*nIndex*/) throw (IndexOutOfBoundsException, RuntimeException)
116 : : {
117 : 0 : return Reference<XAccessibleKeyBinding>();
118 : : }
119 : :
120 : 0 : Any SAL_CALL ScAccessibleFilterMenuItem::queryInterface( uno::Type const & rType )
121 : : throw (RuntimeException)
122 : : {
123 [ # # ]: 0 : Any any = ScAccessibleContextBase::queryInterface(rType);
124 [ # # ]: 0 : if (any.hasValue())
125 : 0 : return any;
126 : :
127 [ # # ]: 0 : return ScAccessibleFilterMenuItem_BASE::queryInterface(rType);
128 : : }
129 : :
130 : 0 : void SAL_CALL ScAccessibleFilterMenuItem::acquire() throw ()
131 : : {
132 : 0 : ScAccessibleContextBase::acquire();
133 : 0 : }
134 : :
135 : 0 : void SAL_CALL ScAccessibleFilterMenuItem::release() throw ()
136 : : {
137 : 0 : ScAccessibleContextBase::release();
138 : 0 : }
139 : :
140 : 0 : bool ScAccessibleFilterMenuItem::isSelected() const
141 : : {
142 : 0 : return mpWindow->isMenuItemSelected(mnMenuPos);
143 : : }
144 : :
145 : 0 : bool ScAccessibleFilterMenuItem::isFocused() const
146 : : {
147 : 0 : return isSelected();
148 : : }
149 : :
150 : 0 : void ScAccessibleFilterMenuItem::setEnabled(bool bEnabled)
151 : : {
152 : 0 : mbEnabled = bEnabled;
153 : 0 : }
154 : :
155 : 0 : Rectangle ScAccessibleFilterMenuItem::GetBoundingBoxOnScreen() const
156 : : throw (RuntimeException)
157 : : {
158 [ # # ][ # # ]: 0 : if (!mpWindow->IsVisible())
159 [ # # ]: 0 : return Rectangle();
160 : :
161 [ # # ]: 0 : Point aPos = mpWindow->OutputToAbsoluteScreenPixel(Point(0,0));
162 : 0 : Point aMenuPos;
163 : 0 : Size aMenuSize;
164 [ # # ]: 0 : mpWindow->getMenuItemPosSize(mnMenuPos, aMenuPos, aMenuSize);
165 [ # # ]: 0 : Rectangle aRect(aPos + aMenuPos, aMenuSize);
166 : 0 : return aRect;
167 : : }
168 : :
169 : 0 : Rectangle ScAccessibleFilterMenuItem::GetBoundingBox() const
170 : : throw (RuntimeException)
171 : : {
172 [ # # ][ # # ]: 0 : if (!mpWindow->IsVisible())
173 [ # # ]: 0 : return Rectangle();
174 : :
175 : 0 : Point aMenuPos;
176 : 0 : Size aMenuSize;
177 [ # # ]: 0 : mpWindow->getMenuItemPosSize(mnMenuPos, aMenuPos, aMenuSize);
178 [ # # ]: 0 : Rectangle aRect(aMenuPos, aMenuSize);
179 : 0 : return aRect;
180 : : }
181 : :
182 : 0 : void ScAccessibleFilterMenuItem::updateStateSet()
183 : : {
184 [ # # ]: 0 : if (!mxStateSet.is())
185 [ # # ][ # # ]: 0 : mxStateSet.set(new ScAccessibleStateSet);
186 : :
187 : : ScAccessibleStateSet* p = static_cast<ScAccessibleStateSet*>(
188 [ # # ]: 0 : mxStateSet.get());
189 : :
190 : 0 : p->clear();
191 : :
192 : 0 : p->insert(ENABLED);
193 : 0 : p->insert(FOCUSABLE);
194 : 0 : p->insert(SELECTABLE);
195 : 0 : p->insert(SENSITIVE);
196 : 0 : p->insert(OPAQUE);
197 : :
198 [ # # ]: 0 : if (isFocused())
199 : 0 : p->insert(FOCUSED);
200 : :
201 [ # # ]: 0 : if (isSelected())
202 : 0 : p->insert(SELECTED);
203 : 0 : }
204 : :
205 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|