diff options
author | Steve Yin <steve_y@apache.org> | 2013-11-25 16:15:58 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-11-25 16:52:36 +0000 |
commit | b755fb8c0f6b1282f62c12f378c0a5ecac64d490 (patch) | |
tree | 4e6df42c862fe4eafef3f52267797e811bac59e0 /svtools | |
parent | 74bf915fb48c660bd1e3a04bec6c3a20c754b6af (diff) |
Integrate branch of IAccessible2
Change-Id: I3b5936bb92bb258f9e9e76402dd2b55f29aa686a
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/AllLangResTarget_svt.mk | 1 | ||||
-rw-r--r-- | svtools/Library_svt.mk | 3 | ||||
-rw-r--r-- | svtools/source/brwbox/brwbox3.cxx | 20 | ||||
-rw-r--r-- | svtools/source/brwbox/editbrowsebox.cxx | 2 | ||||
-rw-r--r-- | svtools/source/contnr/imivctl1.cxx | 1 | ||||
-rw-r--r-- | svtools/source/contnr/svimpbox.cxx | 14 | ||||
-rw-r--r-- | svtools/source/contnr/svtabbx.cxx | 6 | ||||
-rw-r--r-- | svtools/source/contnr/treelistbox.cxx | 126 | ||||
-rw-r--r-- | svtools/source/contnr/viewdataentry.cxx | 7 | ||||
-rw-r--r-- | svtools/source/control/accessibleruler.cxx | 482 | ||||
-rw-r--r-- | svtools/source/control/headbar.cxx | 23 | ||||
-rw-r--r-- | svtools/source/control/ruler.cxx | 37 | ||||
-rw-r--r-- | svtools/source/control/ruler.src | 28 | ||||
-rw-r--r-- | svtools/source/control/valueacc.cxx | 44 | ||||
-rw-r--r-- | svtools/source/control/valueimp.hxx | 1 | ||||
-rw-r--r-- | svtools/source/control/valueset.cxx | 13 | ||||
-rw-r--r-- | svtools/source/control/vclxaccessibleheaderbar.cxx | 163 | ||||
-rw-r--r-- | svtools/source/control/vclxaccessibleheaderbaritem.cxx | 370 | ||||
-rw-r--r-- | svtools/source/misc/embedhlp.cxx | 101 |
19 files changed, 1426 insertions, 16 deletions
diff --git a/svtools/AllLangResTarget_svt.mk b/svtools/AllLangResTarget_svt.mk index 3e3b7fb7d747..c9fd27cfc77e 100644 --- a/svtools/AllLangResTarget_svt.mk +++ b/svtools/AllLangResTarget_svt.mk @@ -41,6 +41,7 @@ $(eval $(call gb_SrsTarget_add_files,svt/res,\ svtools/source/control/ctrlbox.src \ svtools/source/control/ctrltool.src \ svtools/source/control/filectrl.src \ + svtools/source/control/ruler.src \ svtools/source/dialogs/addresstemplate.src \ svtools/source/dialogs/filedlg2.src \ svtools/source/dialogs/formats.src \ diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 11706c60969f..eb1ba8cad406 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -104,6 +104,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/contnr/treelistbox \ svtools/source/contnr/treelistentry \ svtools/source/contnr/viewdataentry \ + svtools/source/control/accessibleruler \ svtools/source/control/asynclink \ svtools/source/control/calendar \ svtools/source/control/collatorres \ @@ -129,6 +130,8 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/control/urlcontrol \ svtools/source/control/valueacc \ svtools/source/control/valueset \ + svtools/source/control/vclxaccessibleheaderbar \ + svtools/source/control/vclxaccessibleheaderbaritem \ svtools/source/dialogs/addresstemplate \ svtools/source/dialogs/colrdlg \ svtools/source/dialogs/insdlg \ diff --git a/svtools/source/brwbox/brwbox3.cxx b/svtools/source/brwbox/brwbox3.cxx index 064a4b818908..54ec2a248429 100644 --- a/svtools/source/brwbox/brwbox3.cxx +++ b/svtools/source/brwbox/brwbox3.cxx @@ -208,7 +208,7 @@ sal_Bool BrowseBox::ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point // Object data and state ------------------------------------------------------ -OUString BrowseBox::GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 ) const +OUString BrowseBox::GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition) const { OUString aRetText; switch( eObjType ) @@ -226,7 +226,16 @@ OUString BrowseBox::GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType e aRetText = "ColumnHeaderBar"; break; case ::svt::BBTYPE_TABLECELL: - aRetText = "TableCell"; + if( ColCount() !=0 && GetRowCount()!=0) + { + + sal_Int32 columnId = _nPosition % ColCount() +1; + aRetText = OUString( GetColumnDescription( sal_Int16( columnId ) ) ); + sal_Int32 rowId = _nPosition / GetRowCount() + 1; + aRetText += OUString::number(rowId); + } + else + aRetText = "TableCell"; #if OSL_DEBUG_LEVEL > 1 aRetText += " ["; aRetText += OUString::number(sal_Int32(GetCurRow())); @@ -236,7 +245,10 @@ OUString BrowseBox::GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType e #endif break; case ::svt::BBTYPE_ROWHEADERCELL: - aRetText = "RowHeaderCell"; + { + sal_Int32 rowId = _nPosition + 1; + aRetText = OUString::number( rowId ); + } #if OSL_DEBUG_LEVEL > 1 aRetText += " ["; aRetText += OUString::number(sal_Int32(GetCurRow())); @@ -246,7 +258,7 @@ OUString BrowseBox::GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType e #endif break; case ::svt::BBTYPE_COLUMNHEADERCELL: - aRetText = "ColumnHeaderCell"; + aRetText = OUString( GetColumnDescription( sal_Int16( _nPosition ) ) ); #if OSL_DEBUG_LEVEL > 1 aRetText += " ["; aRetText += OUString::number(sal_Int32(GetCurRow())); diff --git a/svtools/source/brwbox/editbrowsebox.cxx b/svtools/source/brwbox/editbrowsebox.cxx index 51898127f79f..d4dada733050 100644 --- a/svtools/source/brwbox/editbrowsebox.cxx +++ b/svtools/source/brwbox/editbrowsebox.cxx @@ -1046,7 +1046,7 @@ namespace svt { commitTableEvent( ACTIVE_DESCENDANT_CHANGED, - makeAny( CreateAccessibleCell( nRow, GetColumnPos( nCol ) ) ), + makeAny( CreateAccessibleCell( nRow, GetColumnPos( nCol -1) ) ), Any() ); } diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx index 74d7fe5e0e02..1e96c5561523 100644 --- a/svtools/source/contnr/imivctl1.cxx +++ b/svtools/source/contnr/imivctl1.cxx @@ -1029,6 +1029,7 @@ void SvxIconChoiceCtrl_Impl::SetCursor_Impl( SvxIconChoiceCtrlEntry* pOldCursor, { SelectEntry( pCursor, sal_True, sal_True, sal_False, bPaintSync ); aCurSelectionRect = GetEntryBoundRect( pCursor ); + CallEventListeners( VCLEVENT_LISTBOX_SELECT, pCursor ); } } } diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx index 0099dd22a9c0..361868141ff4 100644 --- a/svtools/source/contnr/svimpbox.cxx +++ b/svtools/source/contnr/svimpbox.cxx @@ -287,6 +287,8 @@ void SvImpLBox::Clear() aScrBarBox.Hide(); aContextBmpWidthVector.clear(); + + CallEventListeners( VCLEVENT_LISTBOX_ITEMREMOVED, NULL ); } // ********************************************************************* @@ -645,6 +647,7 @@ void SvImpLBox::SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect ) if(!bForceNoSelect && bSimpleTravel && !(nFlags & F_DESEL_ALL) && GetUpdateMode()) { pView->Select( pCursor, true ); + CallEventListeners( VCLEVENT_LISTBOX_TREEFOCUS, pCursor ); } // multiple selection: select in cursor move if we're not in // Add mode (Ctrl-F8) @@ -654,10 +657,15 @@ void SvImpLBox::SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect ) !bForceNoSelect ) { pView->Select( pCursor, true ); + CallEventListeners( VCLEVENT_LISTBOX_TREEFOCUS, pCursor ); } else { ShowCursor( true ); + if (bForceNoSelect && GetUpdateMode()) + { + CallEventListeners( VCLEVENT_LISTBOX_TREEFOCUS, pCursor); + } } if( pAnchor ) @@ -1642,6 +1650,8 @@ void SvImpLBox::EntrySelected( SvTreeListEntry* pEntry, bool bSelect ) void SvImpLBox::RemovingEntry( SvTreeListEntry* pEntry ) { + CallEventListeners( VCLEVENT_LISTBOX_ITEMREMOVED , pEntry ); + DestroyAnchor(); if( !pView->IsEntryVisible( pEntry ) ) @@ -2256,7 +2266,7 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt) case KEY_LEFT: { - if ( bIsCellFocusEnabled ) + if ( bIsCellFocusEnabled && pCursor ) { if ( nCurTabPos > FIRST_ENTRY_TAB ) { @@ -2560,7 +2570,7 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt) // is from SvTreeListBox::KeyInput. If we set bKeyUsed to true here, then the key input // is just silenced. However, we want SvLBox::KeyInput to get a chance, to do the QuickSelection // handling. - // (The old code here which intentionally set bKeyUsed to TRUE said this was because of "quick search" + // (The old code here which intentionally set bKeyUsed to sal_True said this was because of "quick search" // handling, but actually there was no quick search handling anymore. We just re-implemented it.) // #i31275# / 2009-06-16 / frank.schoenheit@sun.com bKeyUsed = false; diff --git a/svtools/source/contnr/svtabbx.cxx b/svtools/source/contnr/svtabbx.cxx index 7a091e699ece..de1cd94145ae 100644 --- a/svtools/source/contnr/svtabbx.cxx +++ b/svtools/source/contnr/svtabbx.cxx @@ -1123,6 +1123,8 @@ void SvHeaderTabListBox::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper sal_uInt16 nCurColumn = GetCurrColumn(); if ( IsCellVisible( nCurRow, nCurColumn ) ) _rStateSet.AddState( AccessibleStateType::VISIBLE ); + if ( IsEnabled() ) + _rStateSet.AddState( AccessibleStateType::ENABLED ); _rStateSet.AddState( AccessibleStateType::TRANSIENT ); break; } @@ -1133,6 +1135,8 @@ void SvHeaderTabListBox::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper _rStateSet.AddState( AccessibleStateType::VISIBLE ); _rStateSet.AddState( AccessibleStateType::FOCUSABLE ); _rStateSet.AddState( AccessibleStateType::TRANSIENT ); + if ( IsEnabled() ) + _rStateSet.AddState( AccessibleStateType::ENABLED ); break; } default: @@ -1157,6 +1161,8 @@ void SvHeaderTabListBox::FillAccessibleStateSetForCell( ::utl::AccessibleStateSe _rStateSet.AddState( AccessibleStateType::ACTIVE ); _rStateSet.AddState( AccessibleStateType::SELECTED ); } + if ( IsEnabled() ) + _rStateSet.AddState( AccessibleStateType::ENABLED ); } // ----------------------------------------------------------------------- void SvHeaderTabListBox::GrabTableFocus() diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx index ec2960850fe6..661e109325b4 100644 --- a/svtools/source/contnr/treelistbox.cxx +++ b/svtools/source/contnr/treelistbox.cxx @@ -1504,6 +1504,7 @@ void SvTreeListBox::InitTreeView() nFirstSelTab = 0; nLastSelTab = 0; nFocusWidth = -1; + nAllItemAccRoleType = 0; mnCheckboxItemWidth = 0; Link* pLink = new Link( LINK(this,SvTreeListBox, DefaultCompare) ); @@ -1527,6 +1528,79 @@ void SvTreeListBox::InitTreeView() SetTabs(); } +OUString SvTreeListBox::GetEntryAltText( SvTreeListEntry* ) const +{ + return OUString(); +} + +OUString SvTreeListBox::GetEntryLongDescription( SvTreeListEntry* ) const +{ + return OUString(); +} + +OUString SvTreeListBox::SearchEntryTextWithHeadTitle( SvTreeListEntry* pEntry ) +{ + DBG_CHKTHIS(SvTreeListBox,0); + DBG_ASSERT( pEntry, "SvTreeListBox::SearchEntryText(): no entry" ); + OUString sRet; + + sal_uInt16 nCount = pEntry->ItemCount(); + sal_uInt16 nCur = 0; + sal_uInt16 nHeaderCur = 0; + SvLBoxItem* pItem; + while( nCur < nCount ) + { + // MT: SV_ITEM_ID_EXTENDRLBOXSTRING / GetExtendText() was in use in IA2 cws, but only used in sc: ScSolverOptionsString. Needed? + pItem = pEntry->GetItem( nCur ); + if ( (pItem->GetType() == SV_ITEM_ID_LBOXSTRING ) && + !static_cast<SvLBoxString*>( pItem )->GetText().isEmpty() ) + { + //want the column header + if (!headString.isEmpty()) + { + sal_Int32 nEnd = headString.indexOf('\t'); + if( nEnd == -1 ) + { + if (!sRet.isEmpty()) + { + sRet += ","; + } + if (!headString.isEmpty()) + { + sRet += headString ; + sRet += ":" ; + } + } + else + { + OUString aString=headString.getToken(nHeaderCur, '\t'); + if (!sRet.isEmpty()) + { + sRet += ","; + } + if (!aString.isEmpty()) + { + sRet += aString ; + sRet += ":" ; + } + nHeaderCur++; + } + sRet += static_cast<SvLBoxString*>( pItem )->GetText(); + } + else + { + sRet += static_cast<SvLBoxString*>( pItem )->GetText(); + sRet += ","; + } + //end want to the column header + } + nCur++; + } + + if (!sRet.isEmpty()) + sRet = sRet.copy(0, sRet.getLength() - 1); + return sRet; +} SvTreeListBox::~SvTreeListBox() { @@ -2232,18 +2306,37 @@ void SvTreeListBox::RequestingChildren( SvTreeListEntry* pParent ) void SvTreeListBox::GetFocus() { DBG_CHKTHIS(SvTreeListBox,0); + //If there is no item in the tree, draw focus. + if( !First()) + { + Invalidate(); + } pImp->GetFocus(); Control::GetFocus(); SvTreeListEntry* pEntry = FirstSelected(); + if ( !pEntry ) + { + pEntry = pImp->GetCurrentEntry(); + } + if (pImp->pCursor) + { + if (pEntry != pImp->pCursor) + pEntry = pImp->pCursor; + } if ( pEntry ) - pImp->CallEventListeners( VCLEVENT_LISTBOX_SELECT, pEntry ); + pImp->CallEventListeners( VCLEVENT_LISTBOX_TREEFOCUS, pEntry ); } void SvTreeListBox::LoseFocus() { DBG_CHKTHIS(SvTreeListBox,0); + //If there is no item in the tree, delete visual focus. + if( !First()) + { + Invalidate(); + } pImp->LoseFocus(); Control::LoseFocus(); } @@ -2491,7 +2584,7 @@ sal_Bool SvTreeListBox::Select( SvTreeListEntry* pEntry, sal_Bool bSelect ) if( bSelect ) { SelectHdl(); - pImp->CallEventListeners( VCLEVENT_LISTBOX_SELECT, pEntry ); + CallEventListeners( VCLEVENT_LISTBOX_TREESELECT, pEntry); } else DeselectHdl(); @@ -2628,6 +2721,22 @@ void SvTreeListBox::Paint( const Rectangle& rRect ) if( nTreeFlags & TREEFLAG_RECALCTABS ) SetTabs(); pImp->Paint( rRect ); + //Add visual focus draw + if( !First() ) + { + if( HasFocus() ) + { + long tempHeight = GetTextHeight(); + Rectangle tempRect( + Point(0,0),Size(GetSizePixel().Width(),tempHeight) + ); + ShowFocus(tempRect); + } + + else{ + HideFocus(); + } + } } void SvTreeListBox::MouseButtonDown( const MouseEvent& rMEvt ) @@ -3964,6 +4073,19 @@ void SvTreeListBox::FillAccessibleEntryStateSet( SvTreeListEntry* pEntry, ::utl: rStateSet.AddState( AccessibleStateType::VISIBLE ); if ( IsSelected( pEntry ) ) rStateSet.AddState( AccessibleStateType::SELECTED ); + if ( IsEnabled() ) + { + rStateSet.AddState( AccessibleStateType::ENABLED ); + rStateSet.AddState( AccessibleStateType::FOCUSABLE ); + rStateSet.AddState( AccessibleStateType::SELECTABLE ); + SvViewDataEntry* pViewDataNewCur = 0; + if( pEntry ) + { + pViewDataNewCur= GetViewDataEntry(pEntry); + if(pViewDataNewCur->HasFocus()) + rStateSet.AddState( AccessibleStateType::FOCUSED ); + } + } } Rectangle SvTreeListBox::GetBoundingRect( SvTreeListEntry* pEntry ) diff --git a/svtools/source/contnr/viewdataentry.cxx b/svtools/source/contnr/viewdataentry.cxx index 06ba46349cf2..8719586e869e 100644 --- a/svtools/source/contnr/viewdataentry.cxx +++ b/svtools/source/contnr/viewdataentry.cxx @@ -26,6 +26,7 @@ DBG_NAME(SvViewDataEntry); SvViewDataEntry::SvViewDataEntry() : nVisPos(0), mbSelected(false), + mbObjectSelected(false), mbHighlighted(false), mbExpanded(false), mbFocused(false), @@ -38,6 +39,7 @@ SvViewDataEntry::SvViewDataEntry() : SvViewDataEntry::SvViewDataEntry( const SvViewDataEntry& rData ) : nVisPos(rData.nVisPos), mbSelected(false), + mbObjectSelected(false), mbHighlighted(false), mbExpanded(rData.mbExpanded), mbFocused(false), @@ -96,6 +98,11 @@ void SvViewDataEntry::SetSelected( bool bSelected ) mbHighlighted = bSelected; } +void SvViewDataEntry::SetObjectSelected( bool bSelected ) +{ + mbObjectSelected = bSelected; +} + void SvViewDataEntry::SetHighlighted( bool bHighlighted ) { mbHighlighted = bHighlighted; diff --git a/svtools/source/control/accessibleruler.cxx b/svtools/source/control/accessibleruler.cxx new file mode 100644 index 000000000000..19e41f7f13d9 --- /dev/null +++ b/svtools/source/control/accessibleruler.cxx @@ -0,0 +1,482 @@ +/* + * 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 <svtools/accessibleruler.hxx> +#include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <com/sun/star/accessibility/AccessibleEventId.hpp> +#include <unotools/accessiblestatesethelper.hxx> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/beans/PropertyChangeEvent.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <comphelper/accessibleeventnotifier.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <toolkit/helper/convert.hxx> +#include <vcl/svapp.hxx> +#include <osl/mutex.hxx> +#include <rtl/uuid.h> +#include <tools/debug.hxx> +#include <tools/gen.hxx> + +#include "svtools/ruler.hxx" + +using namespace ::cppu; +using namespace ::osl; +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::accessibility; + +DBG_NAME( SvtRulerAccessible ) + + +//===== internal ============================================================ + +SvtRulerAccessible::SvtRulerAccessible( + const uno::Reference< XAccessible >& rxParent, Ruler& rRepr, const OUString& rName ) : + + SvtRulerAccessible_Base( m_aMutex ), + msName( rName ), + mxParent( rxParent ), + mpRepr( &rRepr ), + mnClientId( 0 ) +{ + DBG_CTOR( SvtRulerAccessible, NULL ); +} + +SvtRulerAccessible::~SvtRulerAccessible() +{ + DBG_DTOR( SvtRulerAccessible, NULL ); + + if( IsAlive() ) + { + osl_incrementInterlockedCount( &m_refCount ); + dispose(); // set mpRepr = NULL & release all childs + } +} + +//===== XAccessible ========================================================= + +uno::Reference< XAccessibleContext > SAL_CALL SvtRulerAccessible::getAccessibleContext( void ) throw( RuntimeException ) +{ + return this; +} + +//===== XAccessibleComponent ================================================ + +sal_Bool SAL_CALL SvtRulerAccessible::containsPoint( const awt::Point& rPoint ) throw( RuntimeException ) +{ + // no guard -> done in getBounds() +// return GetBoundingBox().IsInside( VCLPoint( rPoint ) ); + return Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) ); +} + +uno::Reference< XAccessible > SAL_CALL SvtRulerAccessible::getAccessibleAtPoint( const awt::Point& ) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ThrowExceptionIfNotAlive(); + + uno::Reference< XAccessible > xRet; + + + return xRet; +} + +awt::Rectangle SAL_CALL SvtRulerAccessible::getBounds() throw( RuntimeException ) +{ + // no guard -> done in GetBoundingBox() + return AWTRectangle( GetBoundingBox() ); +} + +awt::Point SAL_CALL SvtRulerAccessible::getLocation() throw( RuntimeException ) +{ + // no guard -> done in GetBoundingBox() + return AWTPoint( GetBoundingBox().TopLeft() ); +} + +awt::Point SAL_CALL SvtRulerAccessible::getLocationOnScreen() throw( RuntimeException ) +{ + // no guard -> done in GetBoundingBoxOnScreen() + return AWTPoint( GetBoundingBoxOnScreen().TopLeft() ); +} + +awt::Size SAL_CALL SvtRulerAccessible::getSize() throw( RuntimeException ) +{ + // no guard -> done in GetBoundingBox() + return AWTSize( GetBoundingBox().GetSize() ); +} + +sal_Bool SAL_CALL SvtRulerAccessible::isShowing() throw( RuntimeException ) +{ + return sal_True; +} + +sal_Bool SAL_CALL SvtRulerAccessible::isVisible() throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ThrowExceptionIfNotAlive(); + + return mpRepr->IsVisible(); +} + +sal_Bool SAL_CALL SvtRulerAccessible::isFocusTraversable() throw( RuntimeException ) +{ + return sal_True; +} + +//===== XAccessibleContext ================================================== + +sal_Int32 SAL_CALL SvtRulerAccessible::getAccessibleChildCount( void ) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + ThrowExceptionIfNotAlive(); + + return 0; +} + +uno::Reference< XAccessible > SAL_CALL SvtRulerAccessible::getAccessibleChild( sal_Int32 ) + throw( RuntimeException, lang::IndexOutOfBoundsException ) +{ + uno::Reference< XAccessible > xChild ; + + return xChild; +} + +uno::Reference< XAccessible > SAL_CALL SvtRulerAccessible::getAccessibleParent( void ) throw( RuntimeException ) +{ + return mxParent; +} + +sal_Int32 SAL_CALL SvtRulerAccessible::getAccessibleIndexInParent( void ) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + // Use a simple but slow solution for now. Optimize later. + + // Iterate over all the parent's children and search for this object. + if( mxParent.is() ) + { + uno::Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() ); + if( xParentContext.is() ) + { + sal_Int32 nChildCount = xParentContext->getAccessibleChildCount(); + for( sal_Int32 i = 0 ; i < nChildCount ; ++i ) + { + uno::Reference< XAccessible > xChild( xParentContext->getAccessibleChild( i ) ); + if( xChild.get() == ( XAccessible* ) this ) + return i; + } + } + } + + // Return -1 to indicate that this object's parent does not know about the + // object. + return -1; +} + +sal_Int16 SAL_CALL SvtRulerAccessible::getAccessibleRole( void ) throw( RuntimeException ) +{ + return AccessibleRole::RULER; +} + +OUString SAL_CALL SvtRulerAccessible::getAccessibleDescription( void ) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + return msDescription; +} + +OUString SAL_CALL SvtRulerAccessible::getAccessibleName( void ) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + return msName; +} + +/** Return empty uno::Reference to indicate that the relation set is not + supported. +*/ +uno::Reference< XAccessibleRelationSet > SAL_CALL SvtRulerAccessible::getAccessibleRelationSet( void ) throw( RuntimeException ) +{ + return uno::Reference< XAccessibleRelationSet >(); +} + + +uno::Reference< XAccessibleStateSet > SAL_CALL SvtRulerAccessible::getAccessibleStateSet( void ) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; + + if( IsAlive() ) + { + pStateSetHelper->AddState( AccessibleStateType::ENABLED ); + + if( isShowing() ) + pStateSetHelper->AddState( AccessibleStateType::SHOWING ); + + if( isVisible() ) + pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); + + + if ( mpRepr ) + { + if ( mpRepr->GetStyle() & WB_HORZ ) + pStateSetHelper->AddState( AccessibleStateType::HORIZONTAL ); + else + pStateSetHelper->AddState( AccessibleStateType::VERTICAL ); + } + if(pStateSetHelper->contains(AccessibleStateType::FOCUSABLE)) + { + pStateSetHelper->RemoveState( AccessibleStateType::FOCUSABLE ); + } + + } + + + return pStateSetHelper; +} + +lang::Locale SAL_CALL SvtRulerAccessible::getLocale( void ) throw( IllegalAccessibleComponentStateException, RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if( mxParent.is() ) + { + uno::Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() ); + if( xParentContext.is() ) + return xParentContext->getLocale(); + } + + // No parent. Therefore throw exception to indicate this cluelessness. + throw IllegalAccessibleComponentStateException(); +} + +void SAL_CALL SvtRulerAccessible::addAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) + throw( RuntimeException ) +{ + if (xListener.is()) + { + ::osl::MutexGuard aGuard( m_aMutex ); + if (!mnClientId) + mnClientId = comphelper::AccessibleEventNotifier::registerClient( ); + comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener ); + } +} + +void SAL_CALL SvtRulerAccessible::removeAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) + throw( RuntimeException ) +{ + if (xListener.is()) + { + ::osl::MutexGuard aGuard( m_aMutex ); + + sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ); + if ( !nListenerCount ) + { + // no listeners anymore + // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), + // and at least to us not firing any events anymore, in case somebody calls + // NotifyAccessibleEvent, again + comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); + mnClientId = 0; + } + } +} + +void SAL_CALL SvtRulerAccessible::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) + throw( RuntimeException ) +{ + if( xListener.is() ) + { + ::osl::MutexGuard aGuard( m_aMutex ); + + ThrowExceptionIfNotAlive(); + + uno::Reference< awt::XWindow > xWindow = VCLUnoHelper::GetInterface( mpRepr ); + if( xWindow.is() ) + xWindow->addFocusListener( xListener ); + } +} + +void SAL_CALL SvtRulerAccessible::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) + throw (RuntimeException) +{ + if( xListener.is() ) + { + ::osl::MutexGuard aGuard( m_aMutex ); + + ThrowExceptionIfNotAlive(); + + uno::Reference< awt::XWindow > xWindow = VCLUnoHelper::GetInterface( mpRepr ); + if( xWindow.is() ) + xWindow->removeFocusListener( xListener ); + } +} + +void SAL_CALL SvtRulerAccessible::grabFocus() throw( RuntimeException ) +{ + SolarMutexGuard aSolarGuard; + ::osl::MutexGuard aGuard( m_aMutex ); + + ThrowExceptionIfNotAlive(); + + mpRepr->GrabFocus(); +} + +Any SAL_CALL SvtRulerAccessible::getAccessibleKeyBinding() throw( RuntimeException ) +{ + // here is no implementation, because here are no KeyBindings for every object + return Any(); +} + +sal_Int32 SvtRulerAccessible::getForeground( ) + throw (::com::sun::star::uno::RuntimeException) +{ + SolarMutexGuard aSolarGuard; + ::osl::MutexGuard aGuard( m_aMutex ); + ThrowExceptionIfNotAlive(); + + return mpRepr->GetControlForeground().GetColor(); +} +sal_Int32 SvtRulerAccessible::getBackground( ) + throw (::com::sun::star::uno::RuntimeException) +{ + SolarMutexGuard aSolarGuard; + ::osl::MutexGuard aGuard( m_aMutex ); + ThrowExceptionIfNotAlive(); + + return mpRepr->GetControlBackground().GetColor(); +} + +//===== XServiceInfo ======================================================== + +OUString SAL_CALL SvtRulerAccessible::getImplementationName( void ) throw( RuntimeException ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.ui.SvtRulerAccessible" ) ); +} + +sal_Bool SAL_CALL SvtRulerAccessible::supportsService( const OUString& sServiceName ) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + // Iterate over all supported service names and return true if on of them + // matches the given name. + Sequence< OUString > aSupportedServices( getSupportedServiceNames() ); + int nLength = aSupportedServices.getLength(); + const OUString* pStr = aSupportedServices.getConstArray(); + + for( int i = nLength ; i ; --i, ++pStr ) + { + if( sServiceName == *pStr ) + return sal_True; + } + + return sal_False; +} + +Sequence< OUString > SAL_CALL SvtRulerAccessible::getSupportedServiceNames( void ) throw( RuntimeException ) +{ + const OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) ); + return Sequence< OUString >( &sServiceName, 1 ); +} + +//===== XTypeProvider ======================================================= + +Sequence< sal_Int8 > SAL_CALL SvtRulerAccessible::getImplementationId( void ) throw( RuntimeException ) +{ + return getUniqueId(); +} + + +//===== internals ======================================================== + +void SvtRulerAccessible::setName( const OUString& rName ) +{ + msName = rName; + +} + +void SvtRulerAccessible::setDescription( const OUString& rDescr ) +{ + + msDescription = rDescr; + +} + + + +void SAL_CALL SvtRulerAccessible::disposing() +{ + if( !rBHelper.bDisposed ) + { + { + ::osl::MutexGuard aGuard( m_aMutex ); + mpRepr = NULL; // object dies with representation + + } + + { + ::osl::MutexGuard aGuard( m_aMutex ); + + // Send a disposing to all listeners. + if ( mnClientId ) + { + comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); + mnClientId = 0; + } + mxParent = uno::Reference< XAccessible >(); + } + } +} + +Rectangle SvtRulerAccessible::GetBoundingBoxOnScreen( void ) throw( RuntimeException ) +{ + SolarMutexGuard aSolarGuard; + ::osl::MutexGuard aGuard( m_aMutex ); + + ThrowExceptionIfNotAlive(); + return Rectangle( mpRepr->GetParent()->OutputToAbsoluteScreenPixel( mpRepr->GetPosPixel() ), mpRepr->GetSizePixel() ); +} + +Rectangle SvtRulerAccessible::GetBoundingBox( void ) throw( RuntimeException ) +{ + SolarMutexGuard aSolarGuard; + ::osl::MutexGuard aGuard( m_aMutex ); + + ThrowExceptionIfNotAlive(); + + return Rectangle( mpRepr->GetPosPixel(), mpRepr->GetSizePixel() ); +} + +Sequence< sal_Int8 > SvtRulerAccessible::getUniqueId( void ) +{ + static OImplementationId* pId = 0; + if( !pId ) + { + MutexGuard aGuard( Mutex::getGlobalMutex() ); + if( !pId) + { + static OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +void SvtRulerAccessible::ThrowExceptionIfNotAlive( void ) throw( lang::DisposedException ) +{ + if( IsNotAlive() ) + throw lang::DisposedException(); +} diff --git a/svtools/source/control/headbar.cxx b/svtools/source/control/headbar.cxx index 2ebec04d7645..cb44b4dd7f24 100644 --- a/svtools/source/control/headbar.cxx +++ b/svtools/source/control/headbar.cxx @@ -18,20 +18,20 @@ */ #include <svtools/headbar.hxx> +#include <svtools/vclxaccessibleheaderbar.hxx> #include <tools/debug.hxx> #include <vcl/svapp.hxx> #include <vcl/help.hxx> #include <vcl/image.hxx> #include <vcl/salnativewidgets.hxx> +#include <com/sun/star/accessibility/AccessibleRole.hpp> #include <com/sun/star/accessibility/XAccessible.hpp> -// ======================================================================= - class ImplHeadItem { public: - sal_uInt16 mnId; + sal_uInt16 mnId; HeaderBarItemBits mnBits; long mnSize; OString maHelpId; @@ -76,6 +76,7 @@ void HeaderBar::ImplInit( WinBits nWinStyle ) mbOutDrag = sal_False; mbItemMode = sal_False; + m_pVCLXHeaderBar = NULL; // StyleBits auswerten if ( nWinStyle & WB_DRAG ) mbDragable = sal_True; @@ -1553,4 +1554,20 @@ void HeaderBar::SetAccessible( ::com::sun::star::uno::Reference< ::com::sun::sta mxAccessible = _xAccessible; } +::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > HeaderBar::GetComponentInterface( sal_Bool bCreate ) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xPeer + (Window::GetComponentInterface(false)); + if ( !xPeer.is() && bCreate ) + { + ::com::sun::star::awt::XWindowPeer* mxPeer = new VCLXHeaderBar(this); + m_pVCLXHeaderBar = (VCLXHeaderBar*)(mxPeer); + SetComponentInterface(mxPeer); + return mxPeer; + } + else + return xPeer; +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx index f6808a22df1e..6b74fdcde375 100644 --- a/svtools/source/control/ruler.cxx +++ b/svtools/source/control/ruler.cxx @@ -24,11 +24,18 @@ #include <vcl/i18nhelp.hxx> #include <svtools/ruler.hxx> +#include <svtools/svtresid.hxx> +#include <svtools/svtools.hrc> #include <boost/scoped_array.hpp> #include <vector> using namespace std; +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::accessibility; #define RULER_OFF 3 #define RULER_TEXTOFF 5 @@ -271,6 +278,7 @@ void Ruler::ImplInit( WinBits nWinBits ) aDefSize.Width() = nDefHeight; SetOutputSizePixel( aDefSize ); SetType(WINDOW_RULER); + pAccContext = NULL; } Ruler::Ruler( Window* pParent, WinBits nWinStyle ) : @@ -290,6 +298,8 @@ Ruler::~Ruler() Application::RemoveUserEvent( mnUpdateEvtId ); delete mpSaveData; delete mpDragData; + if( pAccContext ) + pAccContext->release(); } void Ruler::ImplVDrawLine( long nX1, long nY1, long nX2, long nY2 ) @@ -2793,4 +2803,31 @@ void Ruler::DrawTicks() Paint(Rectangle()); } +uno::Reference< XAccessible > Ruler::CreateAccessible() +{ + Window* pParent = GetAccessibleParentWindow(); + OSL_ENSURE( pParent, "-SvxRuler::CreateAccessible(): No Parent!" ); + uno::Reference< XAccessible > xAccParent = pParent->GetAccessible(); + if( xAccParent.is() ) + { + // MT: Fixed compiler issue because the address from a temporary object was used. + // BUT: Shoudl it really be a Pointer, instead of const&??? + OUString aStr; + if ( mnWinStyle & WB_HORZ ) + { + aStr = SvtResId(STR_SVT_ACC_RULER_HORZ_NAME); + } + else + { + aStr = SvtResId(STR_SVT_ACC_RULER_VERT_NAME); + } + pAccContext = new SvtRulerAccessible( xAccParent, *this, aStr ); + pAccContext->acquire(); + this->SetAccessible(pAccContext); + return pAccContext; + } + else + return uno::Reference< XAccessible >(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/control/ruler.src b/svtools/source/control/ruler.src new file mode 100644 index 000000000000..bcefa3e20115 --- /dev/null +++ b/svtools/source/control/ruler.src @@ -0,0 +1,28 @@ +/* + * 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 "svtools/svtools.hrc" + +String STR_SVT_ACC_RULER_HORZ_NAME +{ + Text[ en-US ] = "Horizontal Ruler"; +}; +String STR_SVT_ACC_RULER_VERT_NAME +{ + Text[ en-US ] = "Vertical Ruler"; +}; + diff --git a/svtools/source/control/valueacc.cxx b/svtools/source/control/valueacc.cxx index 01c60af4cc42..fe91c85d47a8 100644 --- a/svtools/source/control/valueacc.cxx +++ b/svtools/source/control/valueacc.cxx @@ -25,6 +25,9 @@ #include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <com/sun/star/accessibility/AccessibleRole.hpp> #include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/accessibility/AccessibleEventId.hpp> +#include <com/sun/star/accessibility/AccessibleRelationType.hpp> +#include <unotools/accessiblerelationsethelper.hxx> using namespace ::com::sun::star; @@ -290,6 +293,9 @@ OUString SAL_CALL ValueSetAcc::getAccessibleName() Window* pLabel = mpParent->GetAccessibleRelationLabeledBy(); if ( pLabel && pLabel != mpParent ) aRet = OutputDevice::GetNonMnemonicString( pLabel->GetText() ); + + if (aRet.isEmpty()) + aRet = mpParent->GetQuickHelpText(); } return aRet; @@ -301,7 +307,30 @@ uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ValueSetAcc::ge throw (uno::RuntimeException) { ThrowIfDisposed(); - return uno::Reference< accessibility::XAccessibleRelationSet >(); + uno::Reference< accessibility::XAccessibleRelationSet > xRelSet; + Window* pWindow = (Window*)mpParent; + if ( pWindow ) + { + utl::AccessibleRelationSetHelper* pRelationSet = new utl::AccessibleRelationSetHelper; + xRelSet = pRelationSet; + + Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy(); + if ( pLabeledBy && pLabeledBy != pWindow ) + { + uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1); + aSequence[0] = pLabeledBy->GetAccessible(); + pRelationSet->AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABELED_BY, aSequence ) ); + } + + Window* pMemberOf = pWindow->GetAccessibleRelationMemberOf(); + if ( pMemberOf && pMemberOf != pWindow ) + { + uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1); + aSequence[0] = pMemberOf->GetAccessible(); + pRelationSet->AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) ); + } + } + return xRelSet; } // ----------------------------------------------------------------------------- @@ -719,7 +748,7 @@ ValueSetItem* ValueSetAcc::getItem (sal_uInt16 nIndex) const nIndex -= 1; } if (pItem == NULL) - pItem = mpParent->ImplGetVisibleItem (static_cast<sal_uInt16>(nIndex)); + pItem = mpParent->ImplGetItem (static_cast<sal_uInt16>(nIndex)); return pItem; } @@ -886,7 +915,7 @@ sal_Int32 SAL_CALL ValueItemAcc::getAccessibleIndexInParent() // just in case the number of children changes in the mean time. try { - pItem = mpParent->mrParent.ImplGetVisibleItem (i); + pItem = mpParent->mrParent.ImplGetItem(i); } catch (const lang::IndexOutOfBoundsException&) { @@ -903,6 +932,15 @@ sal_Int32 SAL_CALL ValueItemAcc::getAccessibleIndexInParent() } } + //if this valueset contain a none field(common value is default), then we should increase the real index and set the noitem index value equal 0. + if ( mpParent && ( (mpParent->mrParent.GetStyle() & WB_NONEFIELD) != 0 ) ) + { + ValueSetItem* pFirstItem = mpParent->mrParent.ImplGetItem (VALUESET_ITEM_NONEITEM); + if( pFirstItem && pFirstItem ->GetAccessible(mbIsTransientChildrenDisabled).get() == this ) + nIndexInParent = 0; + else + nIndexInParent++; + } return nIndexInParent; } diff --git a/svtools/source/control/valueimp.hxx b/svtools/source/control/valueimp.hxx index 7b98251d31d2..3e2076258a77 100644 --- a/svtools/source/control/valueimp.hxx +++ b/svtools/source/control/valueimp.hxx @@ -55,6 +55,7 @@ struct ValueSetItem Color maColor; OUString maText; void* mpData; + bool mbSelected; ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >* mpxAcc; ValueSetItem( ValueSet& rParent ); diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index dfcad5d4f6e7..a757d2f28e9c 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -1907,6 +1907,19 @@ void ValueSet::SetItemWidth( long nNewItemWidth ) } } +//method to set accessible when the style is user draw. +void ValueSet::InsertItem( sal_uInt16 nItemId, const OUString& rText, size_t nPos ) +{ + DBG_ASSERT( nItemId, "ValueSet::InsertItem(): ItemId == 0" ); + DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND, + "ValueSet::InsertItem(): ItemId already exists" ); + ValueSetItem* pItem = new ValueSetItem( *this ); + pItem->mnId = nItemId; + pItem->meType = VALUESETITEM_USERDRAW; + pItem->maText = rText; + ImplInsertItem( pItem, nPos ); +} + // ----------------------------------------------------------------------- void ValueSet::SetItemHeight( long nNewItemHeight ) diff --git a/svtools/source/control/vclxaccessibleheaderbar.cxx b/svtools/source/control/vclxaccessibleheaderbar.cxx new file mode 100644 index 000000000000..de2b2778fae9 --- /dev/null +++ b/svtools/source/control/vclxaccessibleheaderbar.cxx @@ -0,0 +1,163 @@ +/* + * 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 <svtools/vclxaccessibleheaderbar.hxx> +#include <svtools/vclxaccessibleheaderbaritem.hxx> + +#include <toolkit/awt/vclxwindows.hxx> +#include <svtools/headbar.hxx> +#include <unotools/accessiblestatesethelper.hxx> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/accessibility/AccessibleEventId.hpp> +#include <cppuhelper/typeprovider.hxx> +#include <comphelper/sequence.hxx> +#include <com/sun/star/accessibility/AccessibleRole.hpp> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::accessibility; +using namespace ::comphelper; + +VCLXHeaderBar::VCLXHeaderBar(Window* pHeaderBar) +{ + SetWindow(pHeaderBar); +} + +VCLXHeaderBar::~VCLXHeaderBar() +{ +} + +::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXHeaderBar::CreateAccessibleContext() +{ + return new VCLXAccessibleHeaderBar(this); +} + + +VCLXAccessibleHeaderBar::VCLXAccessibleHeaderBar( VCLXWindow* pVCLWindow ) + :VCLXAccessibleComponent( pVCLWindow ) + ,m_pHeadBar(NULL) +{ + m_pHeadBar = static_cast< HeaderBar* >( GetWindow() ); +} + +// ----------------------------------------------------------------------------- + +VCLXAccessibleHeaderBar::~VCLXAccessibleHeaderBar() +{ +} + +// ----------------------------------------------------------------------------- + +void VCLXAccessibleHeaderBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) +{ + VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent ); +} + +// ----------------------------------------------------------------------------- + +void VCLXAccessibleHeaderBar::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) +{ + VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet ); +} + +// ----------------------------------------------------------------------------- +// XServiceInfo +// ----------------------------------------------------------------------------- + +::rtl::OUString VCLXAccessibleHeaderBar::getImplementationName() throw (RuntimeException) +{ + return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleHeaderBar" ); +} + +// ----------------------------------------------------------------------------- + +Sequence< ::rtl::OUString > VCLXAccessibleHeaderBar::getSupportedServiceNames() throw (RuntimeException) +{ + Sequence< ::rtl::OUString > aNames(1); + aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleHeaderBar" ); + return aNames; +} + +// =======XAccessibleContext======= + +sal_Int32 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleChildCount( ) + throw (::com::sun::star::uno::RuntimeException) +{ + sal_Int32 nCount = 0; + if ( m_pHeadBar ) + nCount = m_pHeadBar->GetItemCount(); + + return nCount; +} +::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL + VCLXAccessibleHeaderBar::getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) +{ + if ( i < 0 || i >= getAccessibleChildCount() ) + throw IndexOutOfBoundsException(); + + Reference< XAccessible > xChild; + // search for the child + if ( static_cast<sal_uInt16>(i) >= m_aAccessibleChildren.size() ) + xChild = CreateChild (i); + else + { + xChild = m_aAccessibleChildren[i]; + if ( !xChild.is() ) + xChild = CreateChild (i); + } + return xChild; +} + +sal_Int16 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException) +{ + return com::sun::star::accessibility::AccessibleRole::LIST; +} + +void SAL_CALL VCLXAccessibleHeaderBar::disposing (void) +{ + ListItems().swap(m_aAccessibleChildren); + VCLXAccessibleComponent::disposing(); +} + +::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > VCLXAccessibleHeaderBar::CreateChild (sal_Int32 i) +{ + Reference<XAccessible> xChild; + + sal_uInt16 nPos = static_cast<sal_uInt16>(i); + if ( nPos >= m_aAccessibleChildren.size() ) + { + m_aAccessibleChildren.resize(nPos + 1); + + // insert into the container + xChild = new VCLXAccessibleHeaderBarItem(m_pHeadBar, i); + m_aAccessibleChildren[nPos] = xChild; + } + else + { + xChild = m_aAccessibleChildren[nPos]; + // check if position is empty and can be used else we have to adjust all entries behind this + if ( !xChild.is() ) + { + xChild = new VCLXAccessibleHeaderBarItem(m_pHeadBar, i); + m_aAccessibleChildren[nPos] = xChild; + } + } + return xChild; +} diff --git a/svtools/source/control/vclxaccessibleheaderbaritem.cxx b/svtools/source/control/vclxaccessibleheaderbaritem.cxx new file mode 100644 index 000000000000..293bba6b79b8 --- /dev/null +++ b/svtools/source/control/vclxaccessibleheaderbaritem.cxx @@ -0,0 +1,370 @@ +/* + * 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 <svtools/vclxaccessibleheaderbaritem.hxx> + +#include <svtools/headbar.hxx> + +#include <com/sun/star/accessibility/AccessibleEventId.hpp> +#include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> + +#include <unotools/accessiblestatesethelper.hxx> +#include <unotools/accessiblerelationsethelper.hxx> +#include <vcl/svapp.hxx> +#include <toolkit/awt/vclxfont.hxx> +#include <toolkit/helper/externallock.hxx> +#include <toolkit/helper/convert.hxx> + +#include <vector> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::accessibility; +using namespace ::comphelper; + +DBG_NAME( VCLXAccessibleHeaderBarItem ) + +// ---------------------------------------------------- +// class AccessibleTabBar +// ---------------------------------------------------- + +VCLXAccessibleHeaderBarItem::VCLXAccessibleHeaderBarItem( HeaderBar* pHeadBar, sal_Int32 _nIndexInParent ) + :AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() ) + ,m_pHeadBar( pHeadBar ) + ,m_nIndexInParent(_nIndexInParent + 1) + +{ + DBG_CTOR( VCLXAccessibleHeaderBarItem, NULL ); + m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() ); +} + +// ----------------------------------------------------------------------------- + +VCLXAccessibleHeaderBarItem::~VCLXAccessibleHeaderBarItem() +{ + delete m_pExternalLock; + m_pExternalLock = NULL; +} + +// ----------------------------------------------------------------------------- + +IMPL_LINK( VCLXAccessibleHeaderBarItem, WindowEventListener, VclSimpleEvent*, pEvent ) +{ + DBG_CHKTHIS( VCLXAccessibleHeaderBarItem, 0 ); + DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "VCLXAccessibleHeaderBarItem::WindowEventListener: unknown window event!" ); + + if ( pEvent && pEvent->ISA( VclWindowEvent ) ) + { + DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow(), "VCLXAccessibleHeaderBarItem::WindowEventListener: no window!" ); + if ( !((VclWindowEvent*)pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent->GetId() == VCLEVENT_OBJECT_DYING ) ) + { + ProcessWindowEvent( *(VclWindowEvent*)pEvent ); + } + } + + return 0; +} + +// ----------------------------------------------------------------------------- + +void VCLXAccessibleHeaderBarItem::ProcessWindowEvent( const VclWindowEvent& ) +{ + Any aOldValue, aNewValue; +} + +// ----------------------------------------------------------------------------- + +void VCLXAccessibleHeaderBarItem::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) +{ + if ( m_pHeadBar ) + { + if ( m_pHeadBar->IsEnabled() ) + rStateSet.AddState( AccessibleStateType::ENABLED ); + + if ( m_pHeadBar->IsVisible() ) + { + rStateSet.AddState( AccessibleStateType::VISIBLE ); + } + rStateSet.AddState( AccessibleStateType::SELECTABLE ); + rStateSet.AddState( AccessibleStateType::RESIZABLE ); + } +} + +// ----------------------------------------------------------------------------- +// OCommonAccessibleComponent +// ----------------------------------------------------------------------------- + +awt::Rectangle VCLXAccessibleHeaderBarItem::implGetBounds() throw (RuntimeException) +{ + awt::Rectangle aBounds; + OExternalLockGuard aGuard( this ); + + ::com::sun::star::awt::Size aSize; + + if ( m_pHeadBar ) + aBounds = AWTRectangle( m_pHeadBar->GetItemRect( sal_uInt16( m_nIndexInParent ) ) ); + + return aBounds; +} + +// ----------------------------------------------------------------------------- +// XInterface +// ----------------------------------------------------------------------------- + +IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleHeaderBarItem, AccessibleExtendedComponentHelper_BASE, VCLXAccessibleHeaderBarItem_BASE ) + +// ----------------------------------------------------------------------------- +// XTypeProvider +// ----------------------------------------------------------------------------- + +IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleHeaderBarItem, AccessibleExtendedComponentHelper_BASE, VCLXAccessibleHeaderBarItem_BASE ) + +// ----------------------------------------------------------------------------- +// XComponent +// ----------------------------------------------------------------------------- + +void VCLXAccessibleHeaderBarItem::disposing() +{ + AccessibleExtendedComponentHelper_BASE::disposing(); +} + +// ----------------------------------------------------------------------------- +// XServiceInfo +// ----------------------------------------------------------------------------- + +OUString VCLXAccessibleHeaderBarItem::getImplementationName() throw (RuntimeException) +{ + return OUString("com.sun.star.comp.svtools.AccessibleHeaderBarItem"); +} + +// ----------------------------------------------------------------------------- + +sal_Bool VCLXAccessibleHeaderBarItem::supportsService( const OUString& rServiceName ) throw (RuntimeException) +{ + Sequence< OUString > aNames( getSupportedServiceNames() ); + const OUString* pNames = aNames.getConstArray(); + const OUString* pEnd = pNames + aNames.getLength(); + for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames ) + ; + + return pNames != pEnd; +} + +// ----------------------------------------------------------------------------- + +Sequence< OUString > VCLXAccessibleHeaderBarItem::getSupportedServiceNames() throw (RuntimeException) +{ + Sequence< OUString > aNames(1); + aNames[0] = OUString( "com.sun.star.awt.AccessibleHeaderBarItem" ); + return aNames; +} + +// ----------------------------------------------------------------------------- +// XAccessible +// ----------------------------------------------------------------------------- + +Reference< XAccessibleContext > VCLXAccessibleHeaderBarItem::getAccessibleContext() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + return this; +} + +// ----------------------------------------------------------------------------- +// XAccessibleContext +// ----------------------------------------------------------------------------- + +sal_Int32 VCLXAccessibleHeaderBarItem::getAccessibleChildCount() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + return 0; +} + +// ----------------------------------------------------------------------------- + +Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + if ( i < 0 || i >= getAccessibleChildCount() ) + throw IndexOutOfBoundsException(); + + return Reference< XAccessible >(); +} + +// ----------------------------------------------------------------------------- + +Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleParent() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + Reference< XAccessible > xParent; + if ( m_pHeadBar ) + { + xParent = m_pHeadBar->GetAccessible(); + } + + return xParent; +} + +// ----------------------------------------------------------------------------- + +sal_Int32 VCLXAccessibleHeaderBarItem::getAccessibleIndexInParent() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + return m_nIndexInParent - 1; +} + +// ----------------------------------------------------------------------------- + +sal_Int16 VCLXAccessibleHeaderBarItem::getAccessibleRole() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + return AccessibleRole::COLUMN_HEADER; +} + +// ----------------------------------------------------------------------------- + +OUString VCLXAccessibleHeaderBarItem::getAccessibleDescription() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + OUString sDescription; + return sDescription; +} + +// ----------------------------------------------------------------------------- + +OUString VCLXAccessibleHeaderBarItem::getAccessibleName() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + OUString sName; + if(m_pHeadBar) + sName = m_pHeadBar->GetItemText( sal_uInt16( m_nIndexInParent ) ); + return sName; +} + +// ----------------------------------------------------------------------------- + +Reference< XAccessibleRelationSet > VCLXAccessibleHeaderBarItem::getAccessibleRelationSet( ) throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; + Reference< XAccessibleRelationSet > xSet = pRelationSetHelper; + return xSet; +} + +// ----------------------------------------------------------------------------- + +Reference< XAccessibleStateSet > VCLXAccessibleHeaderBarItem::getAccessibleStateSet( ) throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; + Reference< XAccessibleStateSet > xSet = pStateSetHelper; + + if ( !rBHelper.bDisposed && !rBHelper.bInDispose ) + { + FillAccessibleStateSet( *pStateSetHelper ); + } + else + { + pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); + } + + return xSet; +} + +// ----------------------------------------------------------------------------- + +com::sun::star::lang::Locale VCLXAccessibleHeaderBarItem::getLocale() throw (IllegalAccessibleComponentStateException, RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + return Application::GetSettings().GetLanguageTag().getLocale(); +} + +// ----------------------------------------------------------------------------- +// XAccessibleComponent +// ----------------------------------------------------------------------------- + +Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + return Reference< XAccessible >(); +} + +// ----------------------------------------------------------------------------- + +sal_Int32 VCLXAccessibleHeaderBarItem::getForeground() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + sal_Int32 nColor = 0; + return nColor; +} + +// ----------------------------------------------------------------------------- + +sal_Int32 VCLXAccessibleHeaderBarItem::getBackground() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + sal_Int32 nColor = 0; + return nColor; +} + +// ----------------------------------------------------------------------------- +// XAccessibleExtendedComponent +// ----------------------------------------------------------------------------- + +Reference< awt::XFont > VCLXAccessibleHeaderBarItem::getFont() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + Reference< awt::XFont > xFont; + return xFont; +} + +// ----------------------------------------------------------------------------- + +OUString VCLXAccessibleHeaderBarItem::getTitledBorderText() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + OUString sText; + return sText; +} + +// ----------------------------------------------------------------------------- + +OUString VCLXAccessibleHeaderBarItem::getToolTipText() throw (RuntimeException) +{ + OExternalLockGuard aGuard( this ); + + OUString sText; + if ( m_pHeadBar ) + sText = m_pHeadBar->GetQuickHelpText(); + + return sText; +} diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx index fb5f3f2e1ccc..918b9415ae9f 100644 --- a/svtools/source/misc/embedhlp.cxx +++ b/svtools/source/misc/embedhlp.cxx @@ -28,7 +28,12 @@ #include <toolkit/helper/vclunohelper.hxx> #include <unotools/ucbstreamhelper.hxx> #include <unotools/streamwrap.hxx> - +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XCoordinateSystem.hpp> +#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> +#include <com/sun/star/chart2/XDiagram.hpp> +#include <com/sun/star/chart2/XChartTypeContainer.hpp> +#include <com/sun/star/chart2/XChartType.hpp> #include <tools/globname.hxx> #include <comphelper/classids.hxx> #include <com/sun/star/util/XModifyListener.hpp> @@ -814,6 +819,100 @@ bool EmbeddedObjectRef::IsChart() const return false; } +// MT: Only used for getting accessible attributes, which are not localized +OUString EmbeddedObjectRef::GetChartType() +{ + OUString Style; + if ( mpImpl->mxObj.is() ) + { + if ( IsChart() ) + { + if ( svt::EmbeddedObjectRef::TryRunningState( mpImpl->mxObj ) ) + { + uno::Reference< chart2::XChartDocument > xChart( mpImpl->mxObj->getComponent(), uno::UNO_QUERY ); + if (xChart.is()) + { + uno::Reference< chart2::XDiagram > xDiagram( xChart->getFirstDiagram()); + if( ! xDiagram.is()) + return OUString(); + uno::Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); + uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); + // IA2 CWS. Unused: int nCoordinateCount = aCooSysSeq.getLength(); + sal_Bool bGetChartType = sal_False; + for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx ) + { + uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW ); + uno::Sequence< uno::Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); + int nDimesionCount = aCooSysSeq[nCooSysIdx]->getDimension(); + if( nDimesionCount == 3 ) + Style += "3D "; + else + Style += "2D "; + for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx ) + { + OUString strChartType = aChartTypes[nCTIdx]->getChartType(); + if (strChartType == "com.sun.star.chart2.AreaChartType") + { + Style += "Areas"; + bGetChartType = sal_True; + } + else if (strChartType == "com.sun.star.chart2.BarChartType") + { + Style += "Bars"; + bGetChartType = sal_True; + } + else if (strChartType == "com.sun.star.chart2.ColumnChartType") + { + uno::Reference< beans::XPropertySet > xProp( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY ); + if( xProp.is()) + { + bool bCurrent = false; + if( xProp->getPropertyValue( OUString("SwapXAndYAxis") ) >>= bCurrent ) + { + if (bCurrent) + Style += "Bars"; + else + Style += "Columns"; + bGetChartType = sal_True; + } + } + } + else if (strChartType == "com.sun.star.chart2.LineChartType") + { + Style += "Lines"; + bGetChartType = sal_True; + } + else if (strChartType == "com.sun.star.chart2.ScatterChartType") + { + Style += "XY Chart"; + bGetChartType = sal_True; + } + else if (strChartType == "com.sun.star.chart2.PieChartType") + { + Style += "Pies"; + bGetChartType = sal_True; + } + else if (strChartType == "com.sun.star.chart2.NetChartType") + { + Style += "Radar"; + bGetChartType = sal_True; + } + else if (strChartType == "com.sun.star.chart2.CandleStickChartType") + { + Style += "Candle Stick Chart"; + bGetChartType = sal_True; + } + if (bGetChartType) + return Style; + } + } + } + } + } + } + return Style; +} + // #i104867# sal_uInt32 EmbeddedObjectRef::getGraphicVersion() const { |