From 8502b8006fdf03d2bc634f53490200f853474867 Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Fri, 31 May 2013 09:03:08 +0000 Subject: Resolves: #i122271# FOCUSABLE flag at accessibility object sidebar title bars so that bridges create focus events and title bars become visible to AT devices. (cherry picked from commit 6055c2b50b36a0fc1b26c18b030827e3e08a51fc) Conflicts: sfx2/source/sidebar/TitleBar.cxx Change-Id: If863c2c9d5ba19ba627639b294a430869f245abd --- sfx2/Library_sfx.mk | 2 + sfx2/source/sidebar/Accessible.cxx | 63 +++++++++++++++++++++++++++ sfx2/source/sidebar/Accessible.hxx | 70 ++++++++++++++++++++++++++++++ sfx2/source/sidebar/AccessibleTitleBar.cxx | 67 ++++++++++++++++++++++++++++ sfx2/source/sidebar/AccessibleTitleBar.hxx | 49 +++++++++++++++++++++ sfx2/source/sidebar/DeckTitleBar.cxx | 11 +++++ sfx2/source/sidebar/DeckTitleBar.hxx | 1 + sfx2/source/sidebar/PanelTitleBar.cxx | 21 +++++---- sfx2/source/sidebar/PanelTitleBar.hxx | 2 + sfx2/source/sidebar/TitleBar.cxx | 32 +++++++++----- sfx2/source/sidebar/TitleBar.hxx | 5 ++- 11 files changed, 301 insertions(+), 22 deletions(-) create mode 100644 sfx2/source/sidebar/Accessible.cxx create mode 100644 sfx2/source/sidebar/Accessible.hxx create mode 100644 sfx2/source/sidebar/AccessibleTitleBar.cxx create mode 100644 sfx2/source/sidebar/AccessibleTitleBar.hxx (limited to 'sfx2') diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 03775fda52a8..aefe3a2d116d 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -233,6 +233,8 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/sidebar/SidebarController \ sfx2/source/sidebar/SidebarPanelBase \ sfx2/source/sidebar/SidebarToolBox \ + sfx2/source/sidebar/Accessible \ + sfx2/source/sidebar/AccessibleTitleBar \ sfx2/source/sidebar/AsynchronousCall \ sfx2/source/sidebar/CommandInfoProvider \ sfx2/source/sidebar/Context \ diff --git a/sfx2/source/sidebar/Accessible.cxx b/sfx2/source/sidebar/Accessible.cxx new file mode 100644 index 000000000000..13d52aa67275 --- /dev/null +++ b/sfx2/source/sidebar/Accessible.cxx @@ -0,0 +1,63 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "Accessible.hxx" + + +using namespace css; +using namespace cssu; + + +namespace sfx2 { namespace sidebar { + + +Accessible::Accessible ( + const Reference& rxContext) + : AccessibleInterfaceBase(m_aMutex), + mxContext(rxContext) +{ +} + + + + +Accessible::~Accessible (void) +{ +} + + + + +void SAL_CALL Accessible::disposing (void) +{ + Reference xComponent (mxContext, UNO_QUERY); + if (xComponent.is()) + xComponent->dispose(); +} + + + + +Reference SAL_CALL Accessible::getAccessibleContext (void) + throw (cssu::RuntimeException) +{ + return mxContext; +} + + +} } // end of namespace sfx2::sidebar diff --git a/sfx2/source/sidebar/Accessible.hxx b/sfx2/source/sidebar/Accessible.hxx new file mode 100644 index 000000000000..d6b8584b9bb3 --- /dev/null +++ b/sfx2/source/sidebar/Accessible.hxx @@ -0,0 +1,70 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef SFX_SIDEBAR_ACCESSIBLE_HXX +#define SFX_SIDEBAR_ACCESSIBLE_HXX + +#include + +#include +#include + +#include +#include + +namespace css = ::com::sun::star; +namespace cssu = ::com::sun::star::uno; + +namespace +{ + typedef ::cppu::WeakComponentImplHelper1 < + css::accessibility::XAccessible + > AccessibleInterfaceBase; +} + +namespace sfx2 { namespace sidebar { + + +/** Simple implementation of the XAccessible interface. + Its getAccessibleContext() method returns a context object given + to its constructor. +*/ +class Accessible + : private ::boost::noncopyable, + private ::cppu::BaseMutex, + public AccessibleInterfaceBase +{ +public: + Accessible ( + const cssu::Reference& rxContext); + virtual ~Accessible (void); + + virtual void SAL_CALL disposing (void); + + + // XAccessible + virtual cssu::Reference SAL_CALL getAccessibleContext (void) + throw (cssu::RuntimeException); + +private: + cssu::Reference mxContext; +}; + + +} } // end of namespace sfx2::sidebar + +#endif diff --git a/sfx2/source/sidebar/AccessibleTitleBar.cxx b/sfx2/source/sidebar/AccessibleTitleBar.cxx new file mode 100644 index 000000000000..47600f08d5f8 --- /dev/null +++ b/sfx2/source/sidebar/AccessibleTitleBar.cxx @@ -0,0 +1,67 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "AccessibleTitleBar.hxx" +#include "Accessible.hxx" +#include "TitleBar.hxx" + +#include +#include + +using namespace css; +using namespace cssu; + +namespace sfx2 { namespace sidebar { + + +Reference AccessibleTitleBar::Create (TitleBar& rTitleBar) +{ + rTitleBar.GetComponentInterface(sal_True); + VCLXWindow* pWindow = rTitleBar.GetWindowPeer(); + if (pWindow != NULL) + return new Accessible(new AccessibleTitleBar(pWindow)); + else + return NULL; +} + + + + +AccessibleTitleBar::AccessibleTitleBar (VCLXWindow* pWindow) + : VCLXAccessibleComponent(pWindow) +{ +} + + + + +AccessibleTitleBar::~AccessibleTitleBar (void) +{ +} + + + + +void AccessibleTitleBar::FillAccessibleStateSet (utl::AccessibleStateSetHelper& rStateSet) +{ + VCLXAccessibleComponent::FillAccessibleStateSet(rStateSet); + rStateSet.AddState(accessibility::AccessibleStateType::FOCUSABLE); +} + + +} } // end of namespace sfx2::sidebar diff --git a/sfx2/source/sidebar/AccessibleTitleBar.hxx b/sfx2/source/sidebar/AccessibleTitleBar.hxx new file mode 100644 index 000000000000..ffbe8ac9a5ac --- /dev/null +++ b/sfx2/source/sidebar/AccessibleTitleBar.hxx @@ -0,0 +1,49 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef SFX_SIDEBAR_ACCESSIBLE_TITLE_BAR_HXX +#define SFX_SIDEBAR_ACCESSIBLE_TITLE_BAR_HXX + +#include +#include + + +namespace css = ::com::sun::star; +namespace cssu = ::com::sun::star::uno; + +namespace sfx2 { namespace sidebar { + +class TitleBar; + +class AccessibleTitleBar + : public VCLXAccessibleComponent +{ +public: + static cssu::Reference Create (TitleBar& rTitleBar); + +protected: + virtual void FillAccessibleStateSet (utl::AccessibleStateSetHelper& rStateSet); + +private: + AccessibleTitleBar (VCLXWindow* pWindow); + virtual ~AccessibleTitleBar (void); +}; + + +} } // end of namespace sfx2::sidebar + +#endif diff --git a/sfx2/source/sidebar/DeckTitleBar.cxx b/sfx2/source/sidebar/DeckTitleBar.cxx index ed7fd178fa81..7855347b3854 100644 --- a/sfx2/source/sidebar/DeckTitleBar.cxx +++ b/sfx2/source/sidebar/DeckTitleBar.cxx @@ -134,6 +134,17 @@ void DeckTitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex) +cssu::Reference DeckTitleBar::CreateAccessible (void) +{ + const ::rtl::OUString sAccessibleName(msTitle); + SetAccessibleName(sAccessibleName); + SetAccessibleDescription(sAccessibleName); + return TitleBar::CreateAccessible(); +} + + + + void DeckTitleBar::DataChanged (const DataChangedEvent& rEvent) { maToolBox.SetItemImage( diff --git a/sfx2/source/sidebar/DeckTitleBar.hxx b/sfx2/source/sidebar/DeckTitleBar.hxx index aab05648fe93..bc31d9863ccd 100644 --- a/sfx2/source/sidebar/DeckTitleBar.hxx +++ b/sfx2/source/sidebar/DeckTitleBar.hxx @@ -45,6 +45,7 @@ protected: virtual sidebar::Paint GetBackgroundPaint (void); virtual Color GetTextColor (void); virtual void HandleToolBoxItemClick (const sal_uInt16 nItemIndex); + virtual cssu::Reference CreateAccessible (void); private: const sal_uInt16 mnCloserItemIndex; diff --git a/sfx2/source/sidebar/PanelTitleBar.cxx b/sfx2/source/sidebar/PanelTitleBar.cxx index 738593a96f0d..dd1b681f847a 100644 --- a/sfx2/source/sidebar/PanelTitleBar.cxx +++ b/sfx2/source/sidebar/PanelTitleBar.cxx @@ -30,7 +30,6 @@ #include #include - using namespace css; using namespace cssu; @@ -50,16 +49,11 @@ PanelTitleBar::PanelTitleBar ( mpPanel(pPanel), mnMenuItemIndex(1), mxFrame(), - msMoreOptionsCommand() + msMoreOptionsCommand(), + msAccessibleNamePrefix(String(SfxResId(SFX_STR_SIDEBAR_ACCESSIBILITY_PANEL_PREFIX))) { OSL_ASSERT(mpPanel != NULL); - const ::rtl::OUString sAccessibleName( - String(SfxResId(SFX_STR_SIDEBAR_ACCESSIBILITY_PANEL_PREFIX)) - + rsTitle); - SetAccessibleName(sAccessibleName); - SetAccessibleDescription(sAccessibleName); - #ifdef DEBUG SetText(A2S("PanelTitleBar")); #endif @@ -190,6 +184,17 @@ void PanelTitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex) +Reference PanelTitleBar::CreateAccessible (void) +{ + const ::rtl::OUString sAccessibleName(msAccessibleNamePrefix + msTitle); + SetAccessibleName(sAccessibleName); + SetAccessibleDescription(sAccessibleName); + return TitleBar::CreateAccessible(); +} + + + + void PanelTitleBar::MouseButtonDown (const MouseEvent& rMouseEvent) { if (rMouseEvent.IsLeft()) diff --git a/sfx2/source/sidebar/PanelTitleBar.hxx b/sfx2/source/sidebar/PanelTitleBar.hxx index f47f86e8c539..6044e2727615 100644 --- a/sfx2/source/sidebar/PanelTitleBar.hxx +++ b/sfx2/source/sidebar/PanelTitleBar.hxx @@ -52,6 +52,7 @@ protected: virtual sidebar::Paint GetBackgroundPaint (void); virtual Color GetTextColor (void); virtual void HandleToolBoxItemClick (const sal_uInt16 nItemIndex); + virtual cssu::Reference CreateAccessible (void); private: bool mbIsLeftButtonDown; @@ -59,6 +60,7 @@ private: const sal_uInt16 mnMenuItemIndex; cssu::Reference mxFrame; ::rtl::OUString msMoreOptionsCommand; + ::rtl::OUString msAccessibleNamePrefix; }; diff --git a/sfx2/source/sidebar/TitleBar.cxx b/sfx2/source/sidebar/TitleBar.cxx index bab96310ba84..e45a6fb9731c 100644 --- a/sfx2/source/sidebar/TitleBar.cxx +++ b/sfx2/source/sidebar/TitleBar.cxx @@ -18,11 +18,16 @@ #include "TitleBar.hxx" #include "Paint.hxx" +#include "Accessible.hxx" +#include "AccessibleTitleBar.hxx" #include #include #include +#include + + namespace { const static sal_Int32 gnLeftIconSpace (3); @@ -89,8 +94,7 @@ void TitleBar::Paint (const Rectangle& rUpdateArea) PaintDecoration(aTitleBarBox); const Rectangle aTitleBox (GetTitleArea(aTitleBarBox)); PaintTitle(aTitleBox); - if (HasFocus()) - PaintFocus(aTitleBox); + PaintFocus(aTitleBox); } @@ -149,6 +153,15 @@ void TitleBar::HandleToolBoxItemClick (const sal_uInt16 nItemIndex) +cssu::Reference TitleBar::CreateAccessible (void) +{ + SetAccessibleRole(css::accessibility::AccessibleRole::PANEL); + return AccessibleTitleBar::Create(*this); +} + + + + void TitleBar::PaintTitle (const Rectangle& rTitleBox) { Push(PUSH_FONT | PUSH_TEXTCOLOR); @@ -186,7 +199,7 @@ void TitleBar::PaintTitle (const Rectangle& rTitleBox) void TitleBar::PaintFocus (const Rectangle& rFocusBox) { - Push(PUSH_FONT | PUSH_TEXTCOLOR | PUSH_LINECOLOR | PUSH_FILLCOLOR); + Push(PUSH_FONT | PUSH_TEXTCOLOR); Font aFont(GetFont()); aFont.SetWeight(WEIGHT_BOLD); @@ -203,15 +216,10 @@ void TitleBar::PaintFocus (const Rectangle& rFocusBox) aTextBox.Right() + 2, aTextBox.Bottom() + 2); - LineInfo aDottedStyle (LINE_DASH); - aDottedStyle.SetDashCount(0); - aDottedStyle.SetDotCount(1); - aDottedStyle.SetDotLen(1); - aDottedStyle.SetDistance(1); - - SetFillColor(); - SetLineColor(COL_BLACK); - DrawPolyLine(Polygon(aLargerTextBox), aDottedStyle); + if (HasFocus()) + Window::ShowFocus(aLargerTextBox); + else + Window::HideFocus(); Pop(); } diff --git a/sfx2/source/sidebar/TitleBar.hxx b/sfx2/source/sidebar/TitleBar.hxx index 229d3b7edcc1..36c31a6f4676 100644 --- a/sfx2/source/sidebar/TitleBar.hxx +++ b/sfx2/source/sidebar/TitleBar.hxx @@ -20,7 +20,7 @@ #include "Paint.hxx" -#include +#include #include "sfx2/sidebar/SidebarToolBox.hxx" @@ -53,6 +53,7 @@ public: protected: SidebarToolBox maToolBox; + ::rtl::OUString msTitle; virtual Rectangle GetTitleArea (const Rectangle& rTitleBarBox) = 0; virtual void PaintDecoration (const Rectangle& rTitleBarBox) = 0; @@ -60,9 +61,9 @@ protected: virtual sidebar::Paint GetBackgroundPaint (void) = 0; virtual Color GetTextColor (void) = 0; virtual void HandleToolBoxItemClick (const sal_uInt16 nItemIndex); + virtual cssu::Reference CreateAccessible (void); private: - ::rtl::OUString msTitle; Image maIcon; void PaintTitle (const Rectangle& rTitleBox); -- cgit