summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorKai Ahrens <ka@openoffice.org>2002-02-25 09:52:14 +0000
committerKai Ahrens <ka@openoffice.org>2002-02-25 09:52:14 +0000
commitc0c254badb4e1c5ee5f18adf944c86e04a4e7251 (patch)
treee690dfd676624dfcfc36cd1988835ce03594cce8 /svtools
parent1e4b27e5b1980808404833cbbbed658d35582b33 (diff)
#97745#: accessibility for ValueSet
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/makefile.mk8
-rw-r--r--svtools/source/control/valueacc.cxx961
-rw-r--r--svtools/source/control/valueimp.hxx210
-rw-r--r--svtools/source/control/valueset.cxx231
4 files changed, 1325 insertions, 85 deletions
diff --git a/svtools/source/control/makefile.mk b/svtools/source/control/makefile.mk
index 8d2c5f04ca1e..a76c87cd254c 100644
--- a/svtools/source/control/makefile.mk
+++ b/svtools/source/control/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.6 $
+# $Revision: 1.7 $
#
-# last change: $Author: dr $ $Date: 2001-11-19 13:22:39 $
+# last change: $Author: ka $ $Date: 2002-02-25 10:52:14 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -83,7 +83,8 @@ SRCFILES= ctrltool.src \
.ENDIF
EXCEPTIONSFILES=\
- $(SLO)$/filectrl2.obj
+ $(SLO)$/filectrl2.obj \
+ $(SLO)$/valueacc.obj
SLOFILES= $(EXCEPTIONSFILES) \
$(SLO)$/wizardheader.obj \
@@ -92,6 +93,7 @@ SLOFILES= $(EXCEPTIONSFILES) \
$(SLO)$/stdctrl.obj \
$(SLO)$/stdmenu.obj \
$(SLO)$/valueset.obj \
+ $(SLO)$/valueacc.obj \
$(SLO)$/tabbar.obj \
$(SLO)$/headbar.obj \
$(SLO)$/prgsbar.obj \
diff --git a/svtools/source/control/valueacc.cxx b/svtools/source/control/valueacc.cxx
new file mode 100644
index 000000000000..06e2ada7135b
--- /dev/null
+++ b/svtools/source/control/valueacc.cxx
@@ -0,0 +1,961 @@
+/*************************************************************************
+ *
+ * $RCSfile: valueacc.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: ka $ $Date: 2002-02-25 10:47:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#define _SV_VALUESET_CXX
+#define private public
+
+#include "valueset.hxx"
+#include "valueimp.hxx"
+
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
+#include <drafts/com/sun/star/accessibility/AccessibleRole.hpp>
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::drafts::com::sun::star;
+
+// ----------------
+// - ValueSetItem -
+// ----------------
+
+ValueSetItem::ValueSetItem( ValueSet& rParent ) :
+ mrParent( rParent ),
+ mnId( 0 ),
+ mnBits( 0 ),
+ mpData( NULL ),
+ mpxAcc( NULL )
+{
+}
+
+// -----------------------------------------------------------------------
+
+ValueSetItem::~ValueSetItem()
+{
+ if( mpxAcc )
+ {
+ static_cast< ValueItemAcc* >( mpxAcc->get() )->ParentDestroyed();
+ delete mpxAcc;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessible > ValueSetItem::GetAccessible()
+{
+ if( !mpxAcc )
+ mpxAcc = new uno::Reference< accessibility::XAccessible >( new ValueItemAcc( this ) );
+
+ return *mpxAcc;
+}
+
+// -----------------------------------------------------------------------
+
+void ValueSetItem::ClearAccessible()
+{
+ if( mpxAcc )
+ delete mpxAcc, mpxAcc = NULL;
+}
+
+
+// ------------
+// - Valueset -
+// ------------
+
+uno::Reference< accessibility::XAccessible > ValueSet::CreateAccessible()
+{
+ return this;
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessibleContext > SAL_CALL ValueSet::getAccessibleContext()
+ throw (uno::RuntimeException)
+{
+ return this;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ValueSet::getAccessibleChildCount()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ return( ImplGetVisibleItemCount() );
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessible > SAL_CALL ValueSet::getAccessibleChild( sal_Int32 i )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ uno::Reference< accessibility::XAccessible > xRet;
+ ValueSetItem* pItem = ImplGetVisibleItem( static_cast< USHORT >( i ) );
+
+ if( pItem )
+ xRet = pItem->GetAccessible();
+ else
+ throw lang::IndexOutOfBoundsException();
+
+ return xRet;
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessible > SAL_CALL ValueSet::getAccessibleParent()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ Window* pParent = GetParent();
+ uno::Reference< accessibility::XAccessible > xRet;
+
+ if( pParent )
+ xRet = pParent->GetAccessible();
+
+ return xRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ValueSet::getAccessibleIndexInParent()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ Window* pParent = GetParent();
+ sal_Int32 nRet = 0;
+
+ if( pParent )
+ {
+ sal_Bool bFound = sal_False;
+
+ for( USHORT i = 0, nCount = pParent->GetChildCount(); ( i < nCount ) && !bFound; i++ )
+ {
+ if( pParent->GetChild( i ) == this )
+ {
+ nRet = i;
+ bFound = sal_True;
+ }
+ }
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL ValueSet::getAccessibleRole()
+ throw (uno::RuntimeException)
+{
+ return accessibility::AccessibleRole::UNKNOWN;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL ValueSet::getAccessibleDescription()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ return GetText();
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL ValueSet::getAccessibleName()
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "ValueSet" );
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ValueSet::getAccessibleRelationSet()
+ throw (uno::RuntimeException)
+{
+ // !!!
+ return uno::Reference< accessibility::XAccessibleRelationSet >();
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ValueSet::getAccessibleStateSet()
+ throw (uno::RuntimeException)
+{
+ // !!!
+ return uno::Reference< accessibility::XAccessibleStateSet >();
+}
+
+// -----------------------------------------------------------------------------
+
+lang::Locale SAL_CALL ValueSet::getLocale()
+ throw (accessibility::IllegalAccessibleComponentStateException, uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ const ::rtl::OUString aEmptyStr;
+ uno::Reference< accessibility::XAccessible > xParent( getAccessibleParent() );
+ lang::Locale aRet( aEmptyStr, aEmptyStr, aEmptyStr );
+
+ if( xParent.is() )
+ {
+ uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
+
+ if( xParentContext.is() )
+ aRet = xParentContext->getLocale ();
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ValueSet::addEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+
+ if( rxListener.is() )
+ {
+ ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter = mxEventListeners.begin();
+ sal_Bool bFound = sal_False;
+
+ while( !bFound && ( aIter != mxEventListeners.end() ) )
+ {
+ if( *aIter++ == rxListener )
+ bFound = sal_True;
+ }
+
+ if (!bFound)
+ mxEventListeners.push_back( rxListener );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ValueSet::removeEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+
+ if( rxListener.is() )
+ {
+ ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter = mxEventListeners.begin();
+ sal_Bool bFound = sal_False;
+
+ while( !bFound && ( aIter != mxEventListeners.end() ) )
+ {
+ if( *aIter == rxListener )
+ {
+ mxEventListeners.erase( aIter );
+ bFound = sal_True;
+ }
+ else
+ aIter++;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ValueSet::contains( const awt::Point& aPoint )
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ const Rectangle aOutRect( Point(), GetOutputSizePixel() );
+
+ return aOutRect.IsInside( Point( aPoint.X, aPoint.Y ) );
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessible > SAL_CALL ValueSet::getAccessibleAt( const awt::Point& aPoint )
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ const USHORT nItemId = GetItemId( Point( aPoint.X, aPoint.Y ) );
+ uno::Reference< accessibility::XAccessible > xRet;
+
+ if( VALUESET_ITEM_NOTFOUND != nItemId )
+ {
+ const USHORT nItemPos = GetItemPos( nItemId );
+
+ if( VALUESET_ITEM_NONEITEM != nItemPos )
+ {
+ ValueSetItem* pItem = mpItemList->GetObject( nItemPos );
+
+ if( ( pItem->meType != VALUESETITEM_SPACE ) && !pItem->maRect.IsEmpty() )
+ xRet = pItem->GetAccessible();
+ }
+ }
+
+ return xRet;
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Rectangle SAL_CALL ValueSet::getBounds()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ const Point aOutPos( GetPosPixel() );
+ const Size aOutSize( GetOutputSizePixel() );
+ awt::Rectangle aRet;
+
+ aRet.X = aOutPos.X();
+ aRet.Y = aOutPos.Y();
+ aRet.Width = aOutSize.Width();
+ aRet.Height = aOutSize.Height();
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Point SAL_CALL ValueSet::getLocation()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ const Point aOutPos( GetPosPixel() );
+ awt::Point aRet;
+
+ aRet.X = aOutPos.X();
+ aRet.Y = aOutPos.Y();
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Point SAL_CALL ValueSet::getLocationOnScreen()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ const Point aScreenPos( OutputToAbsoluteScreenPixel( Point() ) );
+ awt::Point aRet;
+
+ aRet.X = aScreenPos.X();
+ aRet.Y = aScreenPos.Y();
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Size SAL_CALL ValueSet::getSize()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ const Size aOutSize( GetOutputSizePixel() );
+ awt::Size aRet;
+
+ aRet.Width = aOutSize.Width();
+ aRet.Height = aOutSize.Height();
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ValueSet::isShowing()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ return IsVisible();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ValueSet::isVisible()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ return IsVisible();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ValueSet::isFocusTraversable()
+ throw (uno::RuntimeException)
+{
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ValueSet::addFocusListener( const uno::Reference< awt::XFocusListener >& rxListener )
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+
+ if( rxListener.is() )
+ {
+ ::std::vector< uno::Reference< awt::XFocusListener > >::const_iterator aIter = mxFocusListeners.begin();
+ sal_Bool bFound = sal_False;
+
+ while( !bFound && ( aIter != mxFocusListeners.end() ) )
+ {
+ if( *aIter++ == rxListener )
+ bFound = sal_True;
+ }
+
+ if (!bFound)
+ mxFocusListeners.push_back( rxListener );
+ }
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ValueSet::removeFocusListener( const uno::Reference< awt::XFocusListener >& rxListener )
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+
+ if( rxListener.is() )
+ {
+ ::std::vector< uno::Reference< awt::XFocusListener > >::iterator aIter = mxFocusListeners.begin();
+ sal_Bool bFound = sal_False;
+
+ while( !bFound && ( aIter != mxFocusListeners.end() ) )
+ {
+ if( *aIter == rxListener )
+ {
+ mxFocusListeners.erase( aIter );
+ bFound = sal_True;
+ }
+ else
+ aIter++;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ValueSet::grabFocus()
+ throw (uno::RuntimeException)
+{
+ GrabFocus();
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Any SAL_CALL ValueSet::getAccessibleKeyBinding()
+ throw (uno::RuntimeException)
+{
+ return uno::Any();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ValueSet::selectAccessibleChild( sal_Int32 nChildIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ ValueSetItem* pItem = ImplGetVisibleItem( static_cast< USHORT >( nChildIndex ) );
+
+ if( pItem )
+ SelectItem( pItem->mnId );
+ else
+ throw lang::IndexOutOfBoundsException();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ValueSet::isAccessibleChildSelected( sal_Int32 nChildIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ ValueSetItem* pItem = ImplGetVisibleItem( static_cast< USHORT >( nChildIndex ) );
+ sal_Bool bRet = sal_False;
+
+ if( pItem )
+ bRet = IsItemSelected( pItem->mnId );
+ else
+ throw lang::IndexOutOfBoundsException();
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ValueSet::clearAccessibleSelection()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ SetNoSelection();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ValueSet::selectAllAccessible()
+ throw (uno::RuntimeException)
+{
+ // unsupported due to single selection only
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ValueSet::getSelectedAccessibleChildCount()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ sal_Int32 nRet = 0;
+
+ for( USHORT i = 0, nCount = ImplGetVisibleItemCount(); i < nCount; i++ )
+ {
+ ValueSetItem* pItem = ImplGetVisibleItem( i );
+
+ if( pItem && IsItemSelected( pItem->mnId ) )
+ ++nRet;
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessible > SAL_CALL ValueSet::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ uno::Reference< accessibility::XAccessible > xRet;
+
+ for( USHORT i = 0, nCount = ImplGetVisibleItemCount(), nSel = 0; ( i < nCount ) && !xRet.is(); i++ )
+ {
+ ValueSetItem* pItem = ImplGetVisibleItem( i );
+
+ if( pItem && IsItemSelected( pItem->mnId ) && ( nSelectedChildIndex == static_cast< sal_Int32 >( nSel++ ) ) )
+ xRet = pItem->GetAccessible();
+ }
+
+ return xRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ValueSet::deselectSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ sal_Bool bDone = sal_False;
+
+ for( USHORT i = 0, nCount = ImplGetVisibleItemCount(), nSel = 0; ( i < nCount ) && !bDone; i++ )
+ {
+ ValueSetItem* pItem = ImplGetVisibleItem( i );
+
+ if( pItem && IsItemSelected( pItem->mnId ) && ( nSelectedChildIndex == static_cast< sal_Int32 >( nSel++ ) ) )
+ {
+ SetNoSelection();
+ bDone = sal_True;
+ }
+ }
+}
+
+// ----------------
+// - ValueItemAcc -
+// ----------------
+
+ValueItemAcc::ValueItemAcc( ValueSetItem* pParent ) :
+ mpParent( pParent )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+ValueItemAcc::~ValueItemAcc()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void ValueItemAcc::ParentDestroyed()
+{
+ const ::vos::OGuard aGuard( maMutex );
+ mpParent = NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessibleContext > SAL_CALL ValueItemAcc::getAccessibleContext()
+ throw (uno::RuntimeException)
+{
+ return this;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ValueItemAcc::getAccessibleChildCount()
+ throw (uno::RuntimeException)
+{
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleChild( sal_Int32 i )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ throw lang::IndexOutOfBoundsException();
+ return uno::Reference< accessibility::XAccessible >();
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleParent()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ uno::Reference< accessibility::XAccessible > xRet;
+
+ if( mpParent )
+ xRet = mpParent->mrParent.GetAccessible();
+
+ return xRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ValueItemAcc::getAccessibleIndexInParent()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ sal_Int32 nRet = 0;
+
+ if( mpParent )
+ {
+ sal_Bool bDone = sal_False;
+
+ for( USHORT i = 0, nCount = mpParent->mrParent.ImplGetVisibleItemCount(); ( i < nCount ) && !bDone; i++ )
+ {
+ ValueSetItem* pItem = mpParent->mrParent.ImplGetVisibleItem( i );
+
+ if( pItem && ( pItem->GetAccessible().get() == this ) )
+ {
+ nRet = i;
+ bDone = sal_True;
+ }
+ }
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL ValueItemAcc::getAccessibleRole()
+ throw (uno::RuntimeException)
+{
+ return accessibility::AccessibleRole::UNKNOWN;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL ValueItemAcc::getAccessibleDescription()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ ::rtl::OUString aRet;
+
+ if( mpParent )
+ aRet = mpParent->maText;
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL ValueItemAcc::getAccessibleName()
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii( "ValueSetItem" );
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ValueItemAcc::getAccessibleRelationSet()
+ throw (uno::RuntimeException)
+{
+ // !!!
+ return uno::Reference< accessibility::XAccessibleRelationSet >();
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ValueItemAcc::getAccessibleStateSet()
+ throw (uno::RuntimeException)
+{
+ // !!!
+ return uno::Reference< accessibility::XAccessibleStateSet >();
+}
+
+// -----------------------------------------------------------------------------
+
+lang::Locale SAL_CALL ValueItemAcc::getLocale()
+ throw (accessibility::IllegalAccessibleComponentStateException, uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ const ::rtl::OUString aEmptyStr;
+ uno::Reference< accessibility::XAccessible > xParent( getAccessibleParent() );
+ lang::Locale aRet( aEmptyStr, aEmptyStr, aEmptyStr );
+
+ if( xParent.is() )
+ {
+ uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
+
+ if( xParentContext.is() )
+ aRet = xParentContext->getLocale();
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ValueItemAcc::addEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+
+ if( rxListener.is() )
+ {
+ ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter = mxEventListeners.begin();
+ sal_Bool bFound = sal_False;
+
+ while( !bFound && ( aIter != mxEventListeners.end() ) )
+ {
+ if( *aIter++ == rxListener )
+ bFound = sal_True;
+ }
+
+ if (!bFound)
+ mxEventListeners.push_back( rxListener );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ValueItemAcc::removeEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+
+ if( rxListener.is() )
+ {
+ ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter = mxEventListeners.begin();
+ sal_Bool bFound = sal_False;
+
+ while( !bFound && ( aIter != mxEventListeners.end() ) )
+ {
+ if( *aIter == rxListener )
+ {
+ mxEventListeners.erase( aIter );
+ bFound = sal_True;
+ }
+ else
+ aIter++;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ValueItemAcc::contains( const awt::Point& aPoint )
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ sal_Bool bRet = sal_False;
+
+ if( mpParent )
+ bRet = Rectangle( Point(), mpParent->maRect.GetSize() ).IsInside( Point( aPoint.X, aPoint.Y ) );
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleAt( const awt::Point& aPoint )
+ throw (uno::RuntimeException)
+{
+ return( uno::Reference< accessibility::XAccessible >() );
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Rectangle SAL_CALL ValueItemAcc::getBounds()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ awt::Rectangle aRet;
+
+ if( mpParent )
+ {
+ aRet.X = mpParent->maRect.Left();
+ aRet.Y = mpParent->maRect.Top();
+ aRet.Width = mpParent->maRect.GetWidth();
+ aRet.Height = mpParent->maRect.GetHeight();
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Point SAL_CALL ValueItemAcc::getLocation()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ awt::Point aRet;
+
+ if( mpParent )
+ {
+ aRet.X = mpParent->maRect.Left();
+ aRet.Y = mpParent->maRect.Top();
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Point SAL_CALL ValueItemAcc::getLocationOnScreen()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ awt::Point aRet;
+
+ if( mpParent )
+ {
+ const Point aScreenPos( mpParent->mrParent.OutputToAbsoluteScreenPixel( mpParent->maRect.TopLeft() ) );
+
+ aRet.X = aScreenPos.X();
+ aRet.Y = aScreenPos.Y();
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+awt::Size SAL_CALL ValueItemAcc::getSize()
+ throw (uno::RuntimeException)
+{
+ const ::vos::OGuard aGuard( maMutex );
+ awt::Size aRet;
+
+ if( mpParent )
+ {
+ aRet.Width = mpParent->maRect.GetWidth();
+ aRet.Height = mpParent->maRect.GetHeight();
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ValueItemAcc::isShowing()
+ throw (uno::RuntimeException)
+{
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ValueItemAcc::isVisible()
+ throw (uno::RuntimeException)
+{
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ValueItemAcc::isFocusTraversable()
+ throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ValueItemAcc::addFocusListener( const uno::Reference< awt::XFocusListener >& rxListener )
+ throw (uno::RuntimeException)
+{
+ // nothing to do
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL ValueItemAcc::removeFocusListener( const uno::Reference< awt::XFocusListener >& rxListener )
+ throw (uno::RuntimeException)
+{
+ // nothing to do
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ValueItemAcc::grabFocus()
+ throw (uno::RuntimeException)
+{
+ // nothing to do
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Any SAL_CALL ValueItemAcc::getAccessibleKeyBinding()
+ throw (uno::RuntimeException)
+{
+ return uno::Any();
+}
diff --git a/svtools/source/control/valueimp.hxx b/svtools/source/control/valueimp.hxx
new file mode 100644
index 000000000000..3265d45b3fe9
--- /dev/null
+++ b/svtools/source/control/valueimp.hxx
@@ -0,0 +1,210 @@
+/*************************************************************************
+ *
+ * $RCSfile: valueimp.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: ka $ $Date: 2002-02-25 10:47:50 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (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.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _LIST_HXX
+#include <tools/list.hxx>
+#endif
+#ifndef _IMAGE_HXX
+#include <vcl/image.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE4_HXX_
+#include <cppuhelper/implbase4.hxx>
+#endif
+
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLE_HPP_
+#include <drafts/com/sun/star/accessibility/XAccessible.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLECONTEXT_HPP_
+#include <drafts/com/sun/star/accessibility/XAccessibleContext.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLECOMPONENT_HPP_
+#include <drafts/com/sun/star/accessibility/XAccessibleComponent.hpp>
+#endif
+
+#include <vector>
+
+// -----------
+// - Defines -
+// -----------
+
+#define ITEM_OFFSET 4
+#define ITEM_OFFSET_DOUBLE 6
+#define NAME_LINE_OFF_X 2
+#define NAME_LINE_OFF_Y 2
+#define NAME_LINE_HEIGHT 2
+#define NAME_OFFSET 2
+#define SCRBAR_OFFSET 1
+#define VALUESET_ITEM_NONEITEM 0xFFFE
+#define VALUESET_SCROLL_OFFSET 4
+
+
+// ----------------
+// - ValueItemAcc -
+// ----------------
+
+struct ValueSetItem;
+
+class ValueItemAcc : public ::cppu::WeakImplHelper4< ::drafts::com::sun::star::accessibility::XAccessible,
+ ::drafts::com::sun::star::accessibility::XAccessibleEventBroadcaster,
+ ::drafts::com::sun::star::accessibility::XAccessibleContext,
+ ::drafts::com::sun::star::accessibility::XAccessibleComponent >
+{
+private:
+
+ ::vos::OMutex maMutex;
+ ValueSetItem* mpParent;
+ ::std::vector< ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessibleEventListener > > mxEventListeners;
+
+public:
+
+ ValueItemAcc( ValueSetItem* pParent );
+ ~ValueItemAcc();
+
+ void ParentDestroyed();
+
+public:
+
+ // XAccessible
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleEventBroadcaster
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleContext
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::drafts::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleComponent
+ virtual sal_Bool SAL_CALL contains( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAt( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isShowing( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isVisible( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isFocusTraversable( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException);
+};
+
+// --------------------
+// - ValueSetItemType -
+// --------------------
+
+enum ValueSetItemType
+{
+ VALUESETITEM_NONE,
+ VALUESETITEM_IMAGE,
+ VALUESETITEM_COLOR,
+ VALUESETITEM_USERDRAW,
+ VALUESETITEM_SPACE
+};
+
+// ----------------
+// - ValueSetItem -
+// ----------------
+
+struct ValueSetItem
+{
+private:
+
+ ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessible >* mpxAcc;
+
+
+ ValueSetItem();
+ ValueSetItem( const ValueSetItem& rItem );
+
+ ValueSetItem& operator=( const ValueSetItem& );
+
+public:
+
+ ValueSet& mrParent;
+ USHORT mnId;
+ USHORT mnBits;
+ ValueSetItemType meType;
+ Image maImage;
+ Color maColor;
+ XubString maText;
+ void* mpData;
+ Rectangle maRect;
+
+ ValueSetItem( ValueSet& rParent );
+ ~ValueSetItem();
+
+ ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessible > GetAccessible();
+ void ClearAccessible();
+};
+
+// -----------------------------------------------------------------------------
+
+DECLARE_LIST( ValueItemList, ValueSetItem* );
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index d946bb487bec..24964759116a 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: valueset.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: pl $ $Date: 2001-09-04 17:01:36 $
+ * last change: $Author: ka $ $Date: 2002-02-25 10:52:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,14 +65,10 @@
#ifndef _DEBUG_HXX
#include <tools/debug.hxx>
#endif
-
#ifndef _SV_DECOVIEW_HXX
#include <vcl/decoview.hxx>
#endif
#include <vcl/svapp.hxx>
-#ifndef _IMAGE_HXX
-#include <vcl/image.hxx>
-#endif
#ifndef _SCRBAR_HXX
#include <vcl/scrbar.hxx>
#endif
@@ -80,59 +76,22 @@
#include <vcl/help.hxx>
#endif
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTOBJECT_HPP_
+#include <drafts/com/sun/star/accessibility/AccessibleEventObject.hpp>
+#endif
+#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
+#include <drafts/com/sun/star/accessibility/AccessibleEventId.hpp>
+#endif
+
#define _SV_VALUESET_CXX
#define private public
-#include <valueset.hxx>
-
-// =======================================================================
-
-#define ITEM_OFFSET 4
-#define ITEM_OFFSET_DOUBLE 6
-#define NAME_LINE_OFF_X 2
-#define NAME_LINE_OFF_Y 2
-#define NAME_LINE_HEIGHT 2
-#define NAME_OFFSET 2
-#define SCRBAR_OFFSET 1
-#define VALUESET_ITEM_NONEITEM 0xFFFE
-
-#define VALUESET_SCROLL_OFFSET 4
-
-enum ValueSetItemType { VALUESETITEM_NONE, VALUESETITEM_IMAGE,
- VALUESETITEM_COLOR, VALUESETITEM_USERDRAW,
- VALUESETITEM_SPACE };
-
-struct ValueSetItem
-{
- USHORT mnId;
- USHORT mnBits;
- ValueSetItemType meType;
- Image maImage;
- Color maColor;
- XubString maText;
- void* mpData;
- Rectangle maRect;
-
- ValueSetItem();
- ~ValueSetItem();
-};
-
-DECLARE_LIST( ValueItemList, ValueSetItem* );
-// =======================================================================
-
-ValueSetItem::ValueSetItem()
-{
- mnBits = 0;
- mpData = NULL;
-}
-
-// -----------------------------------------------------------------------
-
-ValueSetItem::~ValueSetItem()
-{
-}
+#include <valueset.hxx>
+#include "valueimp.hxx"
-// =======================================================================
+// ------------
+// - ValueSet -
+// ------------
void ValueSet::ImplInit( WinBits nWinStyle )
{
@@ -200,13 +159,28 @@ ValueSet::~ValueSet()
if ( mpNoneItem )
delete mpNoneItem;
- ValueSetItem* pItem = mpItemList->First();
- while ( pItem )
+ ImplDeleteItems();
+ delete mpItemList;
+}
+
+// -----------------------------------------------------------------------
+
+void ValueSet::ImplDeleteItems()
+{
+ for( ValueSetItem* pItem = mpItemList->First(); pItem; pItem = mpItemList->Next() )
{
+ if( !pItem->maRect.IsEmpty() && ImplHasAccessibleListeners() )
+ {
+ ::com::sun::star::uno::Any aOldAny, aNewAny;
+
+ aOldAny <<= pItem->GetAccessible();
+ ImplFireAccessibleEvent( ::drafts::com::sun::star::accessibility::AccessibleEventId::ACCESSIBLE_CHILD_EVENT, aOldAny, aNewAny );
+ }
+
delete pItem;
- pItem = mpItemList->Next();
}
- delete mpItemList;
+
+ mpItemList->Clear();
}
// -----------------------------------------------------------------------
@@ -608,7 +582,7 @@ void ValueSet::Format()
if ( nStyle & WB_NONEFIELD )
{
if ( !mpNoneItem )
- mpNoneItem = new ValueSetItem;
+ mpNoneItem = new ValueSetItem( *this );
mpNoneItem->mnId = 0;
mpNoneItem->meType = VALUESETITEM_NONE;
@@ -625,6 +599,7 @@ void ValueSet::Format()
// draw items
ULONG nFirstItem = mnFirstLine * mnCols;
ULONG nLastItem = nFirstItem + (mnVisLines * mnCols);
+
if ( !mbFullMode )
{
// If want also draw parts of items in the last line,
@@ -635,15 +610,26 @@ void ValueSet::Format()
}
for ( ULONG i = 0; i < nItemCount; i++ )
{
- ValueSetItem* pItem = mpItemList->GetObject( i );
+ ValueSetItem* pItem = mpItemList->GetObject( i );
+ BOOL bFireEvent = FALSE;
if ( (i >= nFirstItem) && (i < nLastItem) )
{
+ const BOOL bWasEmpty = pItem->maRect.IsEmpty();
+
pItem->maRect.Left() = x;
pItem->maRect.Top() = y;
pItem->maRect.Right() = pItem->maRect.Left()+nItemWidth-1;
pItem->maRect.Bottom() = pItem->maRect.Top()+nItemHeight-1;
+ if( bWasEmpty && ImplHasAccessibleListeners() )
+ {
+ ::com::sun::star::uno::Any aOldAny, aNewAny;
+
+ aNewAny <<= pItem->GetAccessible();
+ ImplFireAccessibleEvent( ::drafts::com::sun::star::accessibility::AccessibleEventId::ACCESSIBLE_CHILD_EVENT, aOldAny, aNewAny );
+ }
+
ImplFormatItem( pItem );
if ( !((i+1) % mnCols) )
@@ -655,7 +641,17 @@ void ValueSet::Format()
x += nItemWidth+nSpace;
}
else
+ {
+ if( !pItem->maRect.IsEmpty() && ImplHasAccessibleListeners() )
+ {
+ ::com::sun::star::uno::Any aOldAny, aNewAny;
+
+ aOldAny <<= pItem->GetAccessible();
+ ImplFireAccessibleEvent( ::drafts::com::sun::star::accessibility::AccessibleEventId::ACCESSIBLE_CHILD_EVENT, aOldAny, aNewAny );
+ }
+
pItem->maRect.SetEmpty();
+ }
}
// ScrollBar anordnen, Werte setzen und anzeigen
@@ -1164,6 +1160,69 @@ ValueSetItem* ValueSet::ImplGetFirstItem()
// -----------------------------------------------------------------------
+USHORT ValueSet::ImplGetVisibleItemCount() const
+{
+ USHORT nRet = 0;
+
+ for( sal_Int32 n = 0, nItemCount = mpItemList->Count(); n < nItemCount; n++ )
+ {
+ ValueSetItem* pItem = mpItemList->GetObject( n );
+
+ if( pItem->meType != VALUESETITEM_SPACE && !pItem->maRect.IsEmpty() )
+ nRet++;
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+ValueSetItem* ValueSet::ImplGetVisibleItem( USHORT nVisiblePos )
+{
+ ValueSetItem* pRet = NULL;
+ USHORT nFoundPos = 0;
+
+ for( sal_Int32 n = 0, nItemCount = mpItemList->Count(); ( n < nItemCount ) && !pRet; n++ )
+ {
+ ValueSetItem* pItem = mpItemList->GetObject( n );
+
+ if( ( pItem->meType != VALUESETITEM_SPACE ) && !pItem->maRect.IsEmpty() && ( nVisiblePos == nFoundPos++ ) )
+ pRet = pItem;
+ }
+
+ return pRet;
+}
+
+// -----------------------------------------------------------------------
+
+void ValueSet::ImplFireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue )
+{
+ if( nEventId )
+ {
+ ::std::vector< ::com::sun::star::uno::Reference< ::drafts::com::sun::star::accessibility::XAccessibleEventListener > >::const_iterator aIter = mxEventListeners.begin();
+
+ while( aIter != mxEventListeners.end() )
+ {
+ ::drafts::com::sun::star::accessibility::AccessibleEventObject aEvtObject;
+
+ aEvtObject.EventId = nEventId;
+ aEvtObject.NewValue = rNewValue;
+ aEvtObject.OldValue = rOldValue;
+
+ (*aIter++)->notifyEvent( aEvtObject );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+BOOL ValueSet::ImplHasAccessibleListeners() const
+{
+ return( mxEventListeners.size() > 0 );
+}
+
+// -----------------------------------------------------------------------
+
IMPL_LINK( ValueSet,ImplScrollHdl, ScrollBar*, pScrollBar )
{
USHORT nNewFirstLine = (USHORT)pScrollBar->GetThumbPos();
@@ -1660,7 +1719,7 @@ void ValueSet::InsertItem( USHORT nItemId, const Image& rImage, USHORT nPos )
DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
"ValueSet::InsertItem(): ItemId already exists" );
- ValueSetItem* pItem = new ValueSetItem;
+ ValueSetItem* pItem = new ValueSetItem( *this );
pItem->mnId = nItemId;
pItem->meType = VALUESETITEM_IMAGE;
pItem->maImage = rImage;
@@ -1679,7 +1738,7 @@ void ValueSet::InsertItem( USHORT nItemId, const Color& rColor, USHORT nPos )
DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
"ValueSet::InsertItem(): ItemId already exists" );
- ValueSetItem* pItem = new ValueSetItem;
+ ValueSetItem* pItem = new ValueSetItem( *this );
pItem->mnId = nItemId;
pItem->meType = VALUESETITEM_COLOR;
pItem->maColor = rColor;
@@ -1699,7 +1758,7 @@ void ValueSet::InsertItem( USHORT nItemId, const Image& rImage,
DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
"ValueSet::InsertItem(): ItemId already exists" );
- ValueSetItem* pItem = new ValueSetItem;
+ ValueSetItem* pItem = new ValueSetItem( *this );
pItem->mnId = nItemId;
pItem->meType = VALUESETITEM_IMAGE;
pItem->maImage = rImage;
@@ -1720,7 +1779,7 @@ void ValueSet::InsertItem( USHORT nItemId, const Color& rColor,
DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
"ValueSet::InsertItem(): ItemId already exists" );
- ValueSetItem* pItem = new ValueSetItem;
+ ValueSetItem* pItem = new ValueSetItem( *this );
pItem->mnId = nItemId;
pItem->meType = VALUESETITEM_COLOR;
pItem->maColor = rColor;
@@ -1740,7 +1799,7 @@ void ValueSet::InsertItem( USHORT nItemId, USHORT nPos )
DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
"ValueSet::InsertItem(): ItemId already exists" );
- ValueSetItem* pItem = new ValueSetItem;
+ ValueSetItem* pItem = new ValueSetItem( *this );
pItem->mnId = nItemId;
pItem->meType = VALUESETITEM_USERDRAW;
mpItemList->Insert( pItem, (ULONG)nPos );
@@ -1758,7 +1817,7 @@ void ValueSet::InsertSpace( USHORT nItemId, USHORT nPos )
DBG_ASSERT( GetItemPos( nItemId ) == VALUESET_ITEM_NOTFOUND,
"ValueSet::InsertSpace(): ItemId already exists" );
- ValueSetItem* pItem = new ValueSetItem;
+ ValueSetItem* pItem = new ValueSetItem( *this );
pItem->mnId = nItemId;
pItem->meType = VALUESETITEM_SPACE;
mpItemList->Insert( pItem, (ULONG)nPos );
@@ -1798,17 +1857,24 @@ void ValueSet::RemoveItem( USHORT nItemId )
void ValueSet::CopyItems( const ValueSet& rValueSet )
{
- ValueSetItem* pItem = mpItemList->First();
- while ( pItem )
- {
- delete pItem;
- pItem = mpItemList->Next();
- }
+ ImplDeleteItems();
- pItem = rValueSet.mpItemList->First();
+ ValueSetItem* pItem = rValueSet.mpItemList->First();
while ( pItem )
{
- mpItemList->Insert( new ValueSetItem( *pItem ) );
+ ValueSetItem* pNewItem = new ValueSetItem( *this );
+
+ pNewItem->mnId = pItem->mnId;
+ pNewItem->mnBits = pItem->mnBits;
+ pNewItem->meType = pItem->meType;
+ pNewItem->maImage = pItem->maImage;
+ pNewItem->maColor = pItem->maColor;
+ pNewItem->maText = pItem->maText;
+ pNewItem->mpData = pItem->mpData;
+ pNewItem->maRect = pItem->maRect;
+ pNewItem->mpxAcc = NULL;
+
+ mpItemList->Insert( pNewItem );
pItem = rValueSet.mpItemList->Next();
}
@@ -1829,13 +1895,7 @@ void ValueSet::CopyItems( const ValueSet& rValueSet )
void ValueSet::Clear()
{
- ValueSetItem* pItem = mpItemList->First();
- while ( pItem )
- {
- delete pItem;
- pItem = mpItemList->Next();
- }
- mpItemList->Clear();
+ ImplDeleteItems();
// Variablen zuruecksetzen
mnFirstLine = 0;
@@ -2040,6 +2100,13 @@ void ValueSet::SelectItem( USHORT nItemId )
ImplDrawSelect();
}
}
+
+ if( ImplHasAccessibleListeners() )
+ {
+ // notify listeners
+ ::com::sun::star::uno::Any aOldAny, aNewAny;
+ ImplFireAccessibleEvent( ::drafts::com::sun::star::accessibility::AccessibleEventId::ACCESSIBLE_SELECTION_EVENT, aOldAny, aNewAny );
+ }
}
}