merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / Accessibility / AccessibleFilterMenuItem.cxx
blob7216819db12b20d4ef88945dfe5ab394dae54a36
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleDataPilotControl.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_sc.hxx"
34 #include "AccessibleGlobal.hxx"
35 #include "AccessibleFilterMenuItem.hxx"
36 #include "dpcontrol.hxx"
38 #include <com/sun/star/accessibility/XAccessible.hpp>
39 #include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
40 #include <com/sun/star/accessibility/AccessibleRole.hpp>
41 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
42 #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
43 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
44 #include <com/sun/star/accessibility/TextSegment.hpp>
46 using namespace ::com::sun::star;
47 using namespace ::com::sun::star::accessibility;
48 using namespace ::com::sun::star::accessibility::AccessibleStateType;
50 using ::com::sun::star::uno::Any;
51 using ::com::sun::star::uno::Reference;
52 using ::com::sun::star::uno::Sequence;
53 using ::com::sun::star::uno::UNO_QUERY;
54 using ::com::sun::star::lang::IndexOutOfBoundsException;
55 using ::com::sun::star::uno::RuntimeException;
56 using ::rtl::OUString;
58 ScAccessibleFilterMenuItem::ScAccessibleFilterMenuItem(
59 const Reference<XAccessible>& rxParent, ScMenuFloatingWindow* pWin, const OUString& rName, size_t nMenuPos) :
60 ScAccessibleContextBase(rxParent, AccessibleRole::MENU_ITEM),
61 mpWindow(pWin),
62 maName(rName),
63 mnMenuPos(nMenuPos),
64 mbEnabled(true)
66 SetName(rName);
69 ScAccessibleFilterMenuItem::~ScAccessibleFilterMenuItem()
73 sal_Int32 ScAccessibleFilterMenuItem::getAccessibleChildCount()
74 throw (RuntimeException)
76 return 0;
79 Reference<XAccessible> ScAccessibleFilterMenuItem::getAccessibleChild(sal_Int32 /*nIndex*/)
80 throw (RuntimeException, IndexOutOfBoundsException)
82 throw IndexOutOfBoundsException();
83 return Reference<XAccessible>();
86 Reference<XAccessibleStateSet> ScAccessibleFilterMenuItem::getAccessibleStateSet()
87 throw (RuntimeException)
89 updateStateSet();
90 return mxStateSet;
93 OUString ScAccessibleFilterMenuItem::getImplementationName()
94 throw (RuntimeException)
96 return OUString::createFromAscii("ScAccessibleFilterMenuItem");
99 // XAccessibleAction
101 sal_Int32 ScAccessibleFilterMenuItem::getAccessibleActionCount() throw (RuntimeException)
103 return 1;
106 sal_Bool ScAccessibleFilterMenuItem::doAccessibleAction(sal_Int32 /*nIndex*/)
107 throw (IndexOutOfBoundsException, RuntimeException)
109 mpWindow->executeMenuItem(mnMenuPos);
110 return true;
113 OUString ScAccessibleFilterMenuItem::getAccessibleActionDescription(sal_Int32 /*nIndex*/)
114 throw (IndexOutOfBoundsException, RuntimeException)
116 return OUString::createFromAscii("click");
119 Reference<XAccessibleKeyBinding> ScAccessibleFilterMenuItem::getAccessibleActionKeyBinding(
120 sal_Int32 /*nIndex*/) throw (IndexOutOfBoundsException, RuntimeException)
122 return Reference<XAccessibleKeyBinding>();
125 Any SAL_CALL ScAccessibleFilterMenuItem::queryInterface( uno::Type const & rType )
126 throw (RuntimeException)
128 Any any = ScAccessibleContextBase::queryInterface(rType);
129 if (any.hasValue())
130 return any;
132 return ScAccessibleFilterMenuItem_BASE::queryInterface(rType);
135 void SAL_CALL ScAccessibleFilterMenuItem::acquire() throw ()
137 ScAccessibleContextBase::acquire();
140 void SAL_CALL ScAccessibleFilterMenuItem::release() throw ()
142 ScAccessibleContextBase::release();
145 bool ScAccessibleFilterMenuItem::isSelected() const
147 return mpWindow->isMenuItemSelected(mnMenuPos);
150 bool ScAccessibleFilterMenuItem::isFocused() const
152 return isSelected();
155 void ScAccessibleFilterMenuItem::setEnabled(bool bEnabled)
157 mbEnabled = bEnabled;
160 Rectangle ScAccessibleFilterMenuItem::GetBoundingBoxOnScreen() const
161 throw (RuntimeException)
163 if (!mpWindow->IsVisible())
164 return Rectangle();
166 Point aPos = mpWindow->OutputToAbsoluteScreenPixel(Point(0,0));
167 Point aMenuPos;
168 Size aMenuSize;
169 mpWindow->getMenuItemPosSize(mnMenuPos, aMenuPos, aMenuSize);
170 Rectangle aRect(aPos + aMenuPos, aMenuSize);
171 return aRect;
174 Rectangle ScAccessibleFilterMenuItem::GetBoundingBox() const
175 throw (RuntimeException)
177 if (!mpWindow->IsVisible())
178 return Rectangle();
180 Point aMenuPos;
181 Size aMenuSize;
182 mpWindow->getMenuItemPosSize(mnMenuPos, aMenuPos, aMenuSize);
183 Rectangle aRect(aMenuPos, aMenuSize);
184 return aRect;
187 void ScAccessibleFilterMenuItem::updateStateSet()
189 if (!mxStateSet.is())
190 mxStateSet.set(new ScAccessibleStateSet);
192 ScAccessibleStateSet* p = static_cast<ScAccessibleStateSet*>(
193 mxStateSet.get());
195 p->clear();
197 p->insert(ENABLED);
198 p->insert(FOCUSABLE);
199 p->insert(SELECTABLE);
200 p->insert(SENSITIVE);
201 p->insert(OPAQUE);
203 if (isFocused())
204 p->insert(FOCUSED);
206 if (isSelected())
207 p->insert(SELECTED);