summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei@openoffice.org>2009-08-25 15:36:57 +0000
committerKohei Yoshida <kohei@openoffice.org>2009-08-25 15:36:57 +0000
commitfddbd3634adb04995106aff39334c1ddf55013bc (patch)
tree353099156e1a2b2213efc59d07e7e769030cd23d
parent6f8305a93490ec9868510b62f522c7545ef73a5b (diff)
Reorganized accessible menu implementation so that the toplevel window is treated as menu. It's cleaner and less complicated this way.
-rw-r--r--sc/inc/AccessibleFilterMenu.hxx10
-rw-r--r--sc/inc/AccessibleFilterMenuItem.hxx9
-rw-r--r--sc/inc/AccessibleFilterTopWindow.hxx5
-rw-r--r--sc/source/ui/Accessibility/AccessibleFilterMenu.cxx52
-rw-r--r--sc/source/ui/Accessibility/AccessibleFilterMenuItem.cxx27
-rw-r--r--sc/source/ui/Accessibility/AccessibleFilterTopWindow.cxx28
-rw-r--r--sc/source/ui/cctrl/dpcontrol.cxx9
-rw-r--r--sc/source/ui/inc/dpcontrol.hxx3
8 files changed, 122 insertions, 21 deletions
diff --git a/sc/inc/AccessibleFilterMenu.hxx b/sc/inc/AccessibleFilterMenu.hxx
index f295950f1c82..54194a2d4acf 100644
--- a/sc/inc/AccessibleFilterMenu.hxx
+++ b/sc/inc/AccessibleFilterMenu.hxx
@@ -161,6 +161,16 @@ public:
void setMenuPos(size_t nMenuPos);
void setEnabled(bool bEnabled);
+protected:
+
+ sal_Int32 getMenuItemCount() const;
+
+ virtual Rectangle GetBoundingBoxOnScreen() const
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual Rectangle GetBoundingBox() const
+ throw (::com::sun::star::uno::RuntimeException);
+
private:
bool isSelected() const;
bool isFocused() const;
diff --git a/sc/inc/AccessibleFilterMenuItem.hxx b/sc/inc/AccessibleFilterMenuItem.hxx
index 10d471f4b245..f5ad0fd5d74b 100644
--- a/sc/inc/AccessibleFilterMenuItem.hxx
+++ b/sc/inc/AccessibleFilterMenuItem.hxx
@@ -97,9 +97,16 @@ public:
// Non-UNO Methods
-
void setEnabled(bool bEnabled);
+protected:
+
+ virtual Rectangle GetBoundingBoxOnScreen() const
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual Rectangle GetBoundingBox() const
+ throw (::com::sun::star::uno::RuntimeException);
+
private:
bool isSelected() const;
bool isFocused() const;
diff --git a/sc/inc/AccessibleFilterTopWindow.hxx b/sc/inc/AccessibleFilterTopWindow.hxx
index 801d84d0c5fb..e901949286a1 100644
--- a/sc/inc/AccessibleFilterTopWindow.hxx
+++ b/sc/inc/AccessibleFilterTopWindow.hxx
@@ -31,13 +31,14 @@
#ifndef SC_ACCESSIBLEFILTERTOPWINDOW_HXX
#define SC_ACCESSIBLEFILTERTOPWINDOW_HXX
-#include "AccessibleContextBase.hxx"
+//#include "AccessibleContextBase.hxx"
+#include "AccessibleFilterMenu.hxx"
#include "cppuhelper/implbase1.hxx"
class ScDPFieldPopupWindow;
class ScDocument;
-class ScAccessibleFilterTopWindow : public ScAccessibleContextBase
+class ScAccessibleFilterTopWindow : public ScAccessibleFilterMenu
{
public:
ScAccessibleFilterTopWindow(
diff --git a/sc/source/ui/Accessibility/AccessibleFilterMenu.cxx b/sc/source/ui/Accessibility/AccessibleFilterMenu.cxx
index 5e576128ba87..14824b920c85 100644
--- a/sc/source/ui/Accessibility/AccessibleFilterMenu.cxx
+++ b/sc/source/ui/Accessibility/AccessibleFilterMenu.cxx
@@ -155,7 +155,7 @@ OUString ScAccessibleFilterMenu::getAccessibleName() throw (RuntimeException)
sal_Int32 ScAccessibleFilterMenu::getAccessibleChildCount()
throw (RuntimeException)
{
- return maMenuItems.size();
+ return getMenuItemCount();
}
Reference<XAccessible> ScAccessibleFilterMenu::getAccessibleChild(sal_Int32 nIndex)
@@ -284,6 +284,51 @@ Sequence<sal_Int8> ScAccessibleFilterMenu::getImplementationId()
return aId;
}
+Rectangle ScAccessibleFilterMenu::GetBoundingBoxOnScreen() const
+ throw (RuntimeException)
+{
+ if (mnMenuPos == ScMenuFloatingWindow::MENU_NOT_SELECTED)
+ return Rectangle();
+
+ // Menu object's bounding box is the bounding box of the menu item that
+ // launches the menu, which belongs to the parent window.
+ ScMenuFloatingWindow* pParentWin = mpWindow->getParentMenuWindow();
+ if (!pParentWin)
+ return Rectangle();
+
+ if (!pParentWin->IsVisible())
+ return Rectangle();
+
+ Point aPos = pParentWin->OutputToAbsoluteScreenPixel(Point(0,0));
+ Point aMenuPos;
+ Size aMenuSize;
+ pParentWin->getMenuItemPosSize(mnMenuPos, aMenuPos, aMenuSize);
+ Rectangle aRect(aPos + aMenuPos, aMenuSize);
+ return aRect;
+}
+
+Rectangle ScAccessibleFilterMenu::GetBoundingBox() const
+ throw (RuntimeException)
+{
+ if (mnMenuPos == ScMenuFloatingWindow::MENU_NOT_SELECTED)
+ return Rectangle();
+
+ // Menu object's bounding box is the bounding box of the menu item that
+ // launches the menu, which belongs to the parent window.
+ ScMenuFloatingWindow* pParentWin = mpWindow->getParentMenuWindow();
+ if (!pParentWin)
+ return Rectangle();
+
+ if (!pParentWin->IsVisible())
+ return Rectangle();
+
+ Point aMenuPos;
+ Size aMenuSize;
+ pParentWin->getMenuItemPosSize(mnMenuPos, aMenuPos, aMenuSize);
+ Rectangle aRect(aMenuPos, aMenuSize);
+ return aRect;
+}
+
void ScAccessibleFilterMenu::appendMenuItem(const OUString& rName, bool bEnabled, size_t nMenuPos)
{
// Check weather this menu item is a sub menu or a regular menu item.
@@ -317,6 +362,11 @@ void ScAccessibleFilterMenu::setEnabled(bool bEnabled)
mbEnabled = bEnabled;
}
+sal_Int32 ScAccessibleFilterMenu::getMenuItemCount() const
+{
+ return maMenuItems.size();
+}
+
bool ScAccessibleFilterMenu::isSelected() const
{
// Check to see if any of the child menu items is selected.
diff --git a/sc/source/ui/Accessibility/AccessibleFilterMenuItem.cxx b/sc/source/ui/Accessibility/AccessibleFilterMenuItem.cxx
index 1918a1c01e35..0ab5fa270688 100644
--- a/sc/source/ui/Accessibility/AccessibleFilterMenuItem.cxx
+++ b/sc/source/ui/Accessibility/AccessibleFilterMenuItem.cxx
@@ -157,6 +157,33 @@ void ScAccessibleFilterMenuItem::setEnabled(bool bEnabled)
mbEnabled = bEnabled;
}
+Rectangle ScAccessibleFilterMenuItem::GetBoundingBoxOnScreen() const
+ throw (RuntimeException)
+{
+ if (!mpWindow->IsVisible())
+ return Rectangle();
+
+ Point aPos = mpWindow->OutputToAbsoluteScreenPixel(Point(0,0));
+ Point aMenuPos;
+ Size aMenuSize;
+ mpWindow->getMenuItemPosSize(mnMenuPos, aMenuPos, aMenuSize);
+ Rectangle aRect(aPos + aMenuPos, aMenuSize);
+ return aRect;
+}
+
+Rectangle ScAccessibleFilterMenuItem::GetBoundingBox() const
+ throw (RuntimeException)
+{
+ if (!mpWindow->IsVisible())
+ return Rectangle();
+
+ Point aMenuPos;
+ Size aMenuSize;
+ mpWindow->getMenuItemPosSize(mnMenuPos, aMenuPos, aMenuSize);
+ Rectangle aRect(aMenuPos, aMenuSize);
+ return aRect;
+}
+
void ScAccessibleFilterMenuItem::updateStateSet()
{
if (!mxStateSet.is())
diff --git a/sc/source/ui/Accessibility/AccessibleFilterTopWindow.cxx b/sc/source/ui/Accessibility/AccessibleFilterTopWindow.cxx
index 02fafd87e138..832cb37dd096 100644
--- a/sc/source/ui/Accessibility/AccessibleFilterTopWindow.cxx
+++ b/sc/source/ui/Accessibility/AccessibleFilterTopWindow.cxx
@@ -46,47 +46,49 @@ using ::rtl::OUString;
ScAccessibleFilterTopWindow::ScAccessibleFilterTopWindow(
const Reference<XAccessible>& rxParent, ScDPFieldPopupWindow* pWin, const OUString& rName, ScDocument* pDoc) :
- ScAccessibleContextBase(rxParent, AccessibleRole::PANEL),
+ ScAccessibleFilterMenu(rxParent, pWin, rName, ScMenuFloatingWindow::MENU_NOT_SELECTED, pDoc),
mpWindow(pWin),
mpDoc(pDoc)
{
- fprintf(stdout, "ScAccessibleFilterTopWindow::ScAccessibleFilterTopWindow: ctor (%p)\n", this);
SetName(rName);
}
ScAccessibleFilterTopWindow::~ScAccessibleFilterTopWindow()
{
- fprintf(stdout, "ScAccessibleFilterTopWindow::~ScAccessibleFilterTopWindow: dtor (%p)\n", this);
}
// XAccessibleContext
sal_Int32 ScAccessibleFilterTopWindow::getAccessibleChildCount() throw (RuntimeException)
{
- return 7;
+ sal_Int32 nMenuCount = getMenuItemCount();
+ return nMenuCount + 6;
}
Reference<XAccessible> ScAccessibleFilterTopWindow::getAccessibleChild(
sal_Int32 nIndex) throw (RuntimeException, IndexOutOfBoundsException)
{
- if (nIndex >= 7)
+ if (nIndex >= getAccessibleChildCount())
throw IndexOutOfBoundsException();
+ sal_Int32 nMenuCount = getMenuItemCount();
+ if (nIndex < nMenuCount)
+ return ScAccessibleFilterMenu::getAccessibleChild(nIndex);
+
+ nIndex -= nMenuCount;
switch (nIndex)
{
case 0:
- return getAccessibleChildMenu();
- case 1:
return mxAccListBox;
- case 2:
+ case 1:
return mxAccToggleAll;
- case 3:
+ case 2:
return mxAccSingleOnBtn;
- case 4:
+ case 3:
return mxAccSingleOffBtn;
- case 5:
+ case 4:
return mxAccOkBtn;
- case 6:
+ case 5:
return mxAccCancelBtn;
default:
;
@@ -103,7 +105,7 @@ OUString ScAccessibleFilterTopWindow::getImplementationName() throw (RuntimeExce
Reference<XAccessible> ScAccessibleFilterTopWindow::getAccessibleChildMenu()
{
if (!mxAccMenu.is())
- mxAccMenu.set(new ScAccessibleFilterMenu(this, mpWindow, getAccessibleName(), 999, mpDoc));
+ mxAccMenu.set(new ScAccessibleFilterMenu(this, mpWindow, getAccessibleName(), ScMenuFloatingWindow::MENU_NOT_SELECTED, mpDoc));
return mxAccMenu;
}
diff --git a/sc/source/ui/cctrl/dpcontrol.cxx b/sc/source/ui/cctrl/dpcontrol.cxx
index ca3d5d3d93ae..c46a83e4f8b8 100644
--- a/sc/source/ui/cctrl/dpcontrol.cxx
+++ b/sc/source/ui/cctrl/dpcontrol.cxx
@@ -830,6 +830,11 @@ void ScMenuFloatingWindow::getMenuItemPosSize(size_t nPos, Point& rPos, Size& rS
rSize = aSize1;
}
+ScMenuFloatingWindow* ScMenuFloatingWindow::getParentMenuWindow() const
+{
+ return mpParentMenu;
+}
+
size_t ScMenuFloatingWindow::getEnclosingMenuItem(const Point& rPos) const
{
size_t n = maMenuItems.size();
@@ -1212,9 +1217,7 @@ Reference<XAccessible> ScDPFieldPopupWindow::CreateAccessible()
mxAccessible.set(new ScAccessibleFilterTopWindow(
GetAccessibleParentWindow()->GetAccessible(), this, getName(), getDoc()));
ScAccessibleFilterTopWindow* pAccTop = static_cast<ScAccessibleFilterTopWindow*>(mxAccessible.get());
- Reference<XAccessible> xAccMenu = pAccTop->getAccessibleChildMenu();
- ScAccessibleFilterMenu* pAccMenu = static_cast<ScAccessibleFilterMenu*>(xAccMenu.get());
- fillMenuItemsToAccessible(pAccMenu);
+ fillMenuItemsToAccessible(pAccTop);
pAccTop->setAccessibleChild(
maChecks.CreateAccessible(), ScAccessibleFilterTopWindow::LISTBOX);
diff --git a/sc/source/ui/inc/dpcontrol.hxx b/sc/source/ui/inc/dpcontrol.hxx
index dbbbcb55ed49..77fae133ce81 100644
--- a/sc/source/ui/inc/dpcontrol.hxx
+++ b/sc/source/ui/inc/dpcontrol.hxx
@@ -140,6 +140,8 @@ public:
const ::rtl::OUString& getName() const;
void executeMenuItem(size_t nPos);
+ void getMenuItemPosSize(size_t nPos, Point& rPos, Size& rSize) const;
+ ScMenuFloatingWindow* getParentMenuWindow() const;
protected:
@@ -167,7 +169,6 @@ private:
void resizeToFitMenuItems();
void highlightMenuItem(size_t nPos, bool bSelected);
- void getMenuItemPosSize(size_t nPos, Point& rPos, Size& rSize) const;
size_t getEnclosingMenuItem(const Point& rPos) const;
size_t getSubMenuPos(ScMenuFloatingWindow* pSubMenu);