[Libreoffice-commits] core.git: accessibility/source include/vcl vcl/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 2 07:37:56 UTC 2020


 accessibility/source/standard/vclxaccessibletabpage.cxx |   18 ++++----
 include/vcl/tabctrl.hxx                                 |    6 ++
 vcl/source/control/tabctrl.cxx                          |   34 ++++++++++++++++
 vcl/source/window/builder.cxx                           |   26 +++++++++++-
 4 files changed, 73 insertions(+), 11 deletions(-)

New commits:
commit 7541fac2c0d5341f4d362779594ae236f05ff9a6
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Aug 31 19:17:39 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Sep 2 09:37:08 2020 +0200

    tdf#136331 implement applying atk properties to tab pages
    
    Change-Id: I2ee57dbdb3d743fe1dd3d505a3aa2f479ffa62b1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101765
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/accessibility/source/standard/vclxaccessibletabpage.cxx b/accessibility/source/standard/vclxaccessibletabpage.cxx
index fb0936f2f360..ab981634a7db 100644
--- a/accessibility/source/standard/vclxaccessibletabpage.cxx
+++ b/accessibility/source/standard/vclxaccessibletabpage.cxx
@@ -339,34 +339,34 @@ sal_Int32 VCLXAccessibleTabPage::getAccessibleIndexInParent(  )
     return nIndexInParent;
 }
 
-
-sal_Int16 VCLXAccessibleTabPage::getAccessibleRole(  )
+sal_Int16 VCLXAccessibleTabPage::getAccessibleRole()
 {
     OExternalLockGuard aGuard( this );
 
     return AccessibleRole::PAGE_TAB;
 }
 
-
-OUString VCLXAccessibleTabPage::getAccessibleDescription(    )
+OUString VCLXAccessibleTabPage::getAccessibleDescription()
 {
     OExternalLockGuard aGuard( this );
 
     OUString sDescription;
     if ( m_pTabControl )
-        sDescription = m_pTabControl->GetHelpText( m_nPageId );
+        sDescription = m_pTabControl->GetAccessibleDescription( m_nPageId );
 
     return sDescription;
 }
 
-
-OUString VCLXAccessibleTabPage::getAccessibleName(  )
+OUString VCLXAccessibleTabPage::getAccessibleName()
 {
     OExternalLockGuard aGuard( this );
 
-    return GetPageText();
-}
+    OUString sName;
+    if ( m_pTabControl )
+        sName = m_pTabControl->GetAccessibleName( m_nPageId );
 
+    return sName;
+}
 
 Reference< XAccessibleRelationSet > VCLXAccessibleTabPage::getAccessibleRelationSet(  )
 {
diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx
index 4fe386da3d15..edfa86cf37f0 100644
--- a/include/vcl/tabctrl.hxx
+++ b/include/vcl/tabctrl.hxx
@@ -152,6 +152,12 @@ public:
     void                SetPageName( sal_uInt16 nPageId, const OString& rName ) const;
     OString             GetPageName( sal_uInt16 nPageId ) const;
 
+    void SetAccessibleName( sal_uInt16 nItemId, const OUString& rStr );
+    OUString GetAccessibleName( sal_uInt16 nItemId ) const;
+
+    void SetAccessibleDescription( sal_uInt16 nItemId, const OUString& rStr );
+    OUString GetAccessibleDescription( sal_uInt16 nItemId ) const;
+
     void                SetPageImage( sal_uInt16 nPageId, const Image& rImage );
 
     using Control::SetHelpId;
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index b5275f6cb539..c3c894cb451d 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -53,6 +53,8 @@ public:
     OUString            maText;
     OUString            maFormatText;
     OUString            maHelpText;
+    OUString            maAccessibleName;
+    OUString            maAccessibleDescription;
     OString             maTabName;
     tools::Rectangle    maRect;
     sal_uInt16          mnLine;
@@ -1948,6 +1950,38 @@ const OUString& TabControl::GetHelpText( sal_uInt16 nPageId ) const
     return pItem->maHelpText;
 }
 
+void TabControl::SetAccessibleName(sal_uInt16 nPageId, const OUString& rName)
+{
+    ImplTabItem* pItem = ImplGetItem( nPageId );
+    assert( pItem );
+    pItem->maAccessibleName = rName;
+}
+
+OUString TabControl::GetAccessibleName( sal_uInt16 nPageId ) const
+{
+    ImplTabItem* pItem = ImplGetItem( nPageId );
+    assert( pItem );
+    if (!pItem->maAccessibleName.isEmpty())
+        return pItem->maAccessibleName;
+    return OutputDevice::GetNonMnemonicString(pItem->maText);
+}
+
+void TabControl::SetAccessibleDescription(sal_uInt16 nPageId, const OUString& rDesc)
+{
+    ImplTabItem* pItem = ImplGetItem( nPageId );
+    assert( pItem );
+    pItem->maAccessibleDescription = rDesc;
+}
+
+OUString TabControl::GetAccessibleDescription( sal_uInt16 nPageId ) const
+{
+    ImplTabItem* pItem = ImplGetItem( nPageId );
+    assert( pItem );
+    if (!pItem->maAccessibleDescription.isEmpty())
+        return pItem->maAccessibleDescription;
+    return pItem->maHelpText;
+}
+
 void TabControl::SetPageName( sal_uInt16 nPageId, const OString& rName ) const
 {
     ImplTabItem* pItem = ImplGetItem( nPageId );
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index d3f9febb7208..03f686f0a664 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -2599,10 +2599,14 @@ VclPtr<vcl::Window> VclBuilder::insertObject(vcl::Window *pParent, const OString
 
 void VclBuilder::handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &reader)
 {
+    TabControl *pTabControl = pParent && pParent->GetType() == WindowType::TABCONTROL ?
+        static_cast<TabControl*>(pParent) : nullptr;
+
     std::vector<OString> sIDs;
 
     int nLevel = 1;
     stringmap aProperties;
+    stringmap aAtkProperties;
     std::vector<vcl::EnumContext::Context> context;
 
     while(true)
@@ -2643,6 +2647,12 @@ void VclBuilder::handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &read
             }
             else if (name == "property")
                 collectProperty(reader, aProperties);
+            else if (pTabControl && name == "child")
+            {
+                // just to collect the atk properties (if any) for the label
+                handleChild(nullptr, &aAtkProperties, reader);
+                --nLevel;
+            }
         }
 
         if (res == xmlreader::XmlReader::Result::End)
@@ -2658,8 +2668,6 @@ void VclBuilder::handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &read
     if (!pParent)
         return;
 
-    TabControl *pTabControl = pParent->GetType() == WindowType::TABCONTROL ?
-        static_cast<TabControl*>(pParent) : nullptr;
     VerticalTabControl *pVerticalTabControl = pParent->GetType() == WindowType::VERTICALTABCONTROL ?
         static_cast<VerticalTabControl*>(pParent) : nullptr;
     assert(pTabControl || pVerticalTabControl);
@@ -2676,6 +2684,20 @@ void VclBuilder::handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &read
                 TabPage* pPage = pTabControl->GetTabPage(nPageId);
                 pPage->SetContext(context);
             }
+
+            for (auto const& prop : aAtkProperties)
+            {
+                const OString &rKey = prop.first;
+                const OUString &rValue = prop.second;
+
+                if (rKey == "AtkObject::accessible-name")
+                    pTabControl->SetAccessibleName(nPageId, rValue);
+                else if (rKey == "AtkObject::accessible-description")
+                    pTabControl->SetAccessibleDescription(nPageId, rValue);
+                else
+                    SAL_INFO("vcl.builder", "unhandled atk property: " << rKey);
+            }
+
         }
         else
         {


More information about the Libreoffice-commits mailing list