fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / Accessibility / AccessibleFilterMenuItem.cxx
blobc7d378d7f12802259b5dc9fa6d8653693a844a75
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 #include "AccessibleGlobal.hxx"
21 #include "AccessibleFilterMenuItem.hxx"
22 #include "checklistmenu.hxx"
24 #include <com/sun/star/accessibility/XAccessible.hpp>
25 #include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
26 #include <com/sun/star/accessibility/AccessibleRole.hpp>
27 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
28 #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
29 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
30 #include <com/sun/star/accessibility/TextSegment.hpp>
32 using namespace ::com::sun::star;
33 using namespace ::com::sun::star::accessibility;
34 using namespace ::com::sun::star::accessibility::AccessibleStateType;
36 using ::com::sun::star::uno::Any;
37 using ::com::sun::star::uno::Reference;
38 using ::com::sun::star::uno::Sequence;
39 using ::com::sun::star::uno::UNO_QUERY;
40 using ::com::sun::star::lang::IndexOutOfBoundsException;
41 using ::com::sun::star::uno::RuntimeException;
43 ScAccessibleFilterMenuItem::ScAccessibleFilterMenuItem(
44 const Reference<XAccessible>& rxParent, ScMenuFloatingWindow* pWin, const OUString& rName, size_t nMenuPos) :
45 ScAccessibleContextBase(rxParent, AccessibleRole::MENU_ITEM),
46 mpWindow(pWin),
47 mnMenuPos(nMenuPos),
48 mbEnabled(true)
50 SetName(rName);
53 ScAccessibleFilterMenuItem::~ScAccessibleFilterMenuItem()
57 sal_Int32 ScAccessibleFilterMenuItem::getAccessibleChildCount()
58 throw (RuntimeException, std::exception)
60 return 0;
63 Reference<XAccessible> ScAccessibleFilterMenuItem::getAccessibleChild(sal_Int32 /*nIndex*/)
64 throw (RuntimeException, IndexOutOfBoundsException, std::exception)
66 throw IndexOutOfBoundsException();
69 Reference<XAccessibleStateSet> ScAccessibleFilterMenuItem::getAccessibleStateSet()
70 throw (RuntimeException, std::exception)
72 updateStateSet();
73 return mxStateSet;
76 OUString ScAccessibleFilterMenuItem::getImplementationName()
77 throw (RuntimeException, std::exception)
79 return OUString("ScAccessibleFilterMenuItem");
82 // XAccessibleAction
84 sal_Int32 ScAccessibleFilterMenuItem::getAccessibleActionCount() throw (RuntimeException, std::exception)
86 return 1;
89 sal_Bool ScAccessibleFilterMenuItem::doAccessibleAction(sal_Int32 /*nIndex*/)
90 throw (IndexOutOfBoundsException, RuntimeException, std::exception)
92 mpWindow->executeMenuItem(mnMenuPos);
93 return true;
96 OUString ScAccessibleFilterMenuItem::getAccessibleActionDescription(sal_Int32 /*nIndex*/)
97 throw (IndexOutOfBoundsException, RuntimeException, std::exception)
99 return OUString("click");
102 Reference<XAccessibleKeyBinding> ScAccessibleFilterMenuItem::getAccessibleActionKeyBinding(
103 sal_Int32 /*nIndex*/) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
105 return Reference<XAccessibleKeyBinding>();
108 Any SAL_CALL ScAccessibleFilterMenuItem::queryInterface( uno::Type const & rType )
109 throw (RuntimeException, std::exception)
111 Any any = ScAccessibleContextBase::queryInterface(rType);
112 if (any.hasValue())
113 return any;
115 return ScAccessibleFilterMenuItem_BASE::queryInterface(rType);
118 void SAL_CALL ScAccessibleFilterMenuItem::acquire() throw ()
120 ScAccessibleContextBase::acquire();
123 void SAL_CALL ScAccessibleFilterMenuItem::release() throw ()
125 ScAccessibleContextBase::release();
128 bool ScAccessibleFilterMenuItem::isSelected() const
130 return mpWindow->isMenuItemSelected(mnMenuPos);
133 bool ScAccessibleFilterMenuItem::isFocused() const
135 return isSelected();
138 void ScAccessibleFilterMenuItem::setEnabled(bool bEnabled)
140 mbEnabled = bEnabled;
143 Rectangle ScAccessibleFilterMenuItem::GetBoundingBoxOnScreen() const
144 throw (RuntimeException, std::exception)
146 if (!mpWindow->IsVisible())
147 return Rectangle();
149 Point aPos = mpWindow->OutputToAbsoluteScreenPixel(Point(0,0));
150 Point aMenuPos;
151 Size aMenuSize;
152 mpWindow->getMenuItemPosSize(mnMenuPos, aMenuPos, aMenuSize);
153 Rectangle aRect(aPos + aMenuPos, aMenuSize);
154 return aRect;
157 Rectangle ScAccessibleFilterMenuItem::GetBoundingBox() const
158 throw (RuntimeException, std::exception)
160 if (!mpWindow->IsVisible())
161 return Rectangle();
163 Point aMenuPos;
164 Size aMenuSize;
165 mpWindow->getMenuItemPosSize(mnMenuPos, aMenuPos, aMenuSize);
166 Rectangle aRect(aMenuPos, aMenuSize);
167 return aRect;
170 void ScAccessibleFilterMenuItem::updateStateSet()
172 if (!mxStateSet.is())
173 mxStateSet.set(new ScAccessibleStateSet);
175 ScAccessibleStateSet* p = static_cast<ScAccessibleStateSet*>(
176 mxStateSet.get());
178 p->clear();
180 p->insert(ENABLED);
181 p->insert(FOCUSABLE);
182 p->insert(SELECTABLE);
183 p->insert(SENSITIVE);
184 p->insert(OPAQUE);
186 if (isFocused())
187 p->insert(FOCUSED);
189 if (isSelected())
190 p->insert(SELECTED);
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */