1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
),
53 ScAccessibleFilterMenuItem::~ScAccessibleFilterMenuItem()
57 sal_Int32
ScAccessibleFilterMenuItem::getAccessibleChildCount()
58 throw (RuntimeException
, std::exception
)
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
)
76 OUString
ScAccessibleFilterMenuItem::getImplementationName()
77 throw (RuntimeException
, std::exception
)
79 return OUString("ScAccessibleFilterMenuItem");
84 sal_Int32
ScAccessibleFilterMenuItem::getAccessibleActionCount() throw (RuntimeException
, std::exception
)
89 sal_Bool
ScAccessibleFilterMenuItem::doAccessibleAction(sal_Int32
/*nIndex*/)
90 throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
92 mpWindow
->executeMenuItem(mnMenuPos
);
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
);
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
138 void ScAccessibleFilterMenuItem::setEnabled(bool bEnabled
)
140 mbEnabled
= bEnabled
;
143 Rectangle
ScAccessibleFilterMenuItem::GetBoundingBoxOnScreen() const
144 throw (RuntimeException
, std::exception
)
146 if (!mpWindow
->IsVisible())
149 Point aPos
= mpWindow
->OutputToAbsoluteScreenPixel(Point(0,0));
152 mpWindow
->getMenuItemPosSize(mnMenuPos
, aMenuPos
, aMenuSize
);
153 Rectangle
aRect(aPos
+ aMenuPos
, aMenuSize
);
157 Rectangle
ScAccessibleFilterMenuItem::GetBoundingBox() const
158 throw (RuntimeException
, std::exception
)
160 if (!mpWindow
->IsVisible())
165 mpWindow
->getMenuItemPosSize(mnMenuPos
, aMenuPos
, aMenuSize
);
166 Rectangle
aRect(aMenuPos
, aMenuSize
);
170 void ScAccessibleFilterMenuItem::updateStateSet()
172 if (!mxStateSet
.is())
173 mxStateSet
.set(new ScAccessibleStateSet
);
175 ScAccessibleStateSet
* p
= static_cast<ScAccessibleStateSet
*>(
181 p
->insert(FOCUSABLE
);
182 p
->insert(SELECTABLE
);
183 p
->insert(SENSITIVE
);
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */