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 .
21 #include "AccessibleGlobal.hxx"
22 #include "AccessibleFilterMenuItem.hxx"
23 #include "checklistmenu.hxx"
25 #include <com/sun/star/accessibility/XAccessible.hpp>
26 #include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
27 #include <com/sun/star/accessibility/AccessibleRole.hpp>
28 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
29 #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
30 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
31 #include <com/sun/star/accessibility/TextSegment.hpp>
33 using namespace ::com::sun::star
;
34 using namespace ::com::sun::star::accessibility
;
35 using namespace ::com::sun::star::accessibility::AccessibleStateType
;
37 using ::com::sun::star::uno::Any
;
38 using ::com::sun::star::uno::Reference
;
39 using ::com::sun::star::uno::Sequence
;
40 using ::com::sun::star::uno::UNO_QUERY
;
41 using ::com::sun::star::lang::IndexOutOfBoundsException
;
42 using ::com::sun::star::uno::RuntimeException
;
44 ScAccessibleFilterMenuItem::ScAccessibleFilterMenuItem(
45 const Reference
<XAccessible
>& rxParent
, ScMenuFloatingWindow
* pWin
, const OUString
& rName
, size_t nMenuPos
) :
46 ScAccessibleContextBase(rxParent
, AccessibleRole::MENU_ITEM
),
55 ScAccessibleFilterMenuItem::~ScAccessibleFilterMenuItem()
59 sal_Int32
ScAccessibleFilterMenuItem::getAccessibleChildCount()
60 throw (RuntimeException
, std::exception
)
65 Reference
<XAccessible
> ScAccessibleFilterMenuItem::getAccessibleChild(sal_Int32
/*nIndex*/)
66 throw (RuntimeException
, IndexOutOfBoundsException
, std::exception
)
68 throw IndexOutOfBoundsException();
71 Reference
<XAccessibleStateSet
> ScAccessibleFilterMenuItem::getAccessibleStateSet()
72 throw (RuntimeException
, std::exception
)
78 OUString
ScAccessibleFilterMenuItem::getImplementationName()
79 throw (RuntimeException
, std::exception
)
81 return OUString("ScAccessibleFilterMenuItem");
86 sal_Int32
ScAccessibleFilterMenuItem::getAccessibleActionCount() throw (RuntimeException
, std::exception
)
91 sal_Bool
ScAccessibleFilterMenuItem::doAccessibleAction(sal_Int32
/*nIndex*/)
92 throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
94 mpWindow
->executeMenuItem(mnMenuPos
);
98 OUString
ScAccessibleFilterMenuItem::getAccessibleActionDescription(sal_Int32
/*nIndex*/)
99 throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
101 return OUString("click");
104 Reference
<XAccessibleKeyBinding
> ScAccessibleFilterMenuItem::getAccessibleActionKeyBinding(
105 sal_Int32
/*nIndex*/) throw (IndexOutOfBoundsException
, RuntimeException
, std::exception
)
107 return Reference
<XAccessibleKeyBinding
>();
110 Any SAL_CALL
ScAccessibleFilterMenuItem::queryInterface( uno::Type
const & rType
)
111 throw (RuntimeException
, std::exception
)
113 Any any
= ScAccessibleContextBase::queryInterface(rType
);
117 return ScAccessibleFilterMenuItem_BASE::queryInterface(rType
);
120 void SAL_CALL
ScAccessibleFilterMenuItem::acquire() throw ()
122 ScAccessibleContextBase::acquire();
125 void SAL_CALL
ScAccessibleFilterMenuItem::release() throw ()
127 ScAccessibleContextBase::release();
130 bool ScAccessibleFilterMenuItem::isSelected() const
132 return mpWindow
->isMenuItemSelected(mnMenuPos
);
135 bool ScAccessibleFilterMenuItem::isFocused() const
140 void ScAccessibleFilterMenuItem::setEnabled(bool bEnabled
)
142 mbEnabled
= bEnabled
;
145 Rectangle
ScAccessibleFilterMenuItem::GetBoundingBoxOnScreen() const
146 throw (RuntimeException
, std::exception
)
148 if (!mpWindow
->IsVisible())
151 Point aPos
= mpWindow
->OutputToAbsoluteScreenPixel(Point(0,0));
154 mpWindow
->getMenuItemPosSize(mnMenuPos
, aMenuPos
, aMenuSize
);
155 Rectangle
aRect(aPos
+ aMenuPos
, aMenuSize
);
159 Rectangle
ScAccessibleFilterMenuItem::GetBoundingBox() const
160 throw (RuntimeException
, std::exception
)
162 if (!mpWindow
->IsVisible())
167 mpWindow
->getMenuItemPosSize(mnMenuPos
, aMenuPos
, aMenuSize
);
168 Rectangle
aRect(aMenuPos
, aMenuSize
);
172 void ScAccessibleFilterMenuItem::updateStateSet()
174 if (!mxStateSet
.is())
175 mxStateSet
.set(new ScAccessibleStateSet
);
177 ScAccessibleStateSet
* p
= static_cast<ScAccessibleStateSet
*>(
183 p
->insert(FOCUSABLE
);
184 p
->insert(SELECTABLE
);
185 p
->insert(SENSITIVE
);
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */