AccessibleControlShape.cxx (f6e50924) AccessibleControlShape.cxx (9b8096d0)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 30 unchanged lines hidden (view full) ---

39#include <svx/ShapeTypeHandler.hxx>
40#include <svx/SvxShapeTypes.hxx>
41#include <toolkit/helper/vclunohelper.hxx>
42#include <comphelper/accessiblewrapper.hxx>
43#include <svx/svdview.hxx>
44#include <svx/svdpagv.hxx>
45#include "svx/svdstr.hrc"
46#include <algorithm>
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 30 unchanged lines hidden (view full) ---

39#include <svx/ShapeTypeHandler.hxx>
40#include <svx/SvxShapeTypes.hxx>
41#include <toolkit/helper/vclunohelper.hxx>
42#include <comphelper/accessiblewrapper.hxx>
43#include <svx/svdview.hxx>
44#include <svx/svdpagv.hxx>
45#include "svx/svdstr.hrc"
46#include <algorithm>
47
47//IAccessibility2 Implementation 2009-----
48#ifndef _COMPHELPER_PROPERTY_HXX_
49#include <comphelper/property.hxx>
50#endif
51#ifndef _COMPHELPER_TYPES_HXX_
52#include <comphelper/types.hxx>
53#endif
54#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
55#include <com/sun/star/container/XChild.hpp>
56#endif
57#ifndef _UTL_ACCESSIBLERELATIONSETHELPER_HXX_
58#include <unotools/accessiblerelationsethelper.hxx>
59#endif
60#ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLERELATIONTYPE_HPP_
61#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
62#endif
63//-----IAccessibility2 Implementation 2009
48using namespace ::comphelper;
49using namespace ::accessibility;
50using namespace ::com::sun::star::accessibility;
51using namespace ::com::sun::star::uno;
52using namespace ::com::sun::star::awt;
53using namespace ::com::sun::star::beans;
54using namespace ::com::sun::star::util;
55using namespace ::com::sun::star::lang;

--- 17 unchanged lines hidden (view full) ---

73 return s_sDescPropertyDesc;
74 }
75 //................................................................
76 const ::rtl::OUString& lcl_getLabelPropertyName( )
77 {
78 static ::rtl::OUString s_sLabelPropertyLabel( RTL_CONSTASCII_USTRINGPARAM( "Label" ) );
79 return s_sLabelPropertyLabel;
80 }
64using namespace ::comphelper;
65using namespace ::accessibility;
66using namespace ::com::sun::star::accessibility;
67using namespace ::com::sun::star::uno;
68using namespace ::com::sun::star::awt;
69using namespace ::com::sun::star::beans;
70using namespace ::com::sun::star::util;
71using namespace ::com::sun::star::lang;

--- 17 unchanged lines hidden (view full) ---

89 return s_sDescPropertyDesc;
90 }
91 //................................................................
92 const ::rtl::OUString& lcl_getLabelPropertyName( )
93 {
94 static ::rtl::OUString s_sLabelPropertyLabel( RTL_CONSTASCII_USTRINGPARAM( "Label" ) );
95 return s_sLabelPropertyLabel;
96 }
97 //IAccessibility2 Implementation 2009-----
81 //................................................................
98 //................................................................
99 const ::rtl::OUString& lcl_getLabelControlPropertyName( )
100 {
101 static ::rtl::OUString s_sLabelControlPropertyLabel( RTL_CONSTASCII_USTRINGPARAM( "LabelControl" ) );
102 return s_sLabelControlPropertyLabel;
103 }
104 //-----IAccessibility2 Implementation 2009
105 //................................................................
82 // return the property which should be used as AccessibleName
83 const ::rtl::OUString& lcl_getPreferredAccNameProperty( const Reference< XPropertySetInfo >& _rxPSI )
84 {
85 if ( _rxPSI.is() && _rxPSI->hasPropertyByName( lcl_getLabelPropertyName() ) )
86 return lcl_getLabelPropertyName();
87 else
88 return lcl_getNamePropertyName();
89 }

--- 541 unchanged lines hidden (view full) ---

631#endif
632 return xChild;
633}
634
635//--------------------------------------------------------------------
636Reference< XAccessibleRelationSet > SAL_CALL AccessibleControlShape::getAccessibleRelationSet( ) throw (RuntimeException)
637{
638 // TODO
106 // return the property which should be used as AccessibleName
107 const ::rtl::OUString& lcl_getPreferredAccNameProperty( const Reference< XPropertySetInfo >& _rxPSI )
108 {
109 if ( _rxPSI.is() && _rxPSI->hasPropertyByName( lcl_getLabelPropertyName() ) )
110 return lcl_getLabelPropertyName();
111 else
112 return lcl_getNamePropertyName();
113 }

--- 541 unchanged lines hidden (view full) ---

655#endif
656 return xChild;
657}
658
659//--------------------------------------------------------------------
660Reference< XAccessibleRelationSet > SAL_CALL AccessibleControlShape::getAccessibleRelationSet( ) throw (RuntimeException)
661{
662 // TODO
639 return AccessibleShape::getAccessibleRelationSet( );
663 // return AccessibleShape::getAccessibleRelationSet( );
664 //IAccessibility2 Implementation 2009-----
665 utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
666 ensureControlModelAccess();
667 AccessibleControlShape* pCtlAccShape = GetLabeledByControlShape();
668 if(pCtlAccShape)
669 {
670 Reference < XAccessible > xAcc (pCtlAccShape->getAccessibleContext(), UNO_QUERY);
671
672 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > aSequence(1);
673 aSequence[0] = xAcc;
674 if( getAccessibleRole() == AccessibleRole::RADIO_BUTTON )
675 {
676 pRelationSetHelper->AddRelation( AccessibleRelation( AccessibleRelationType::MEMBER_OF, aSequence ) );
677 }
678 else
679 {
680 pRelationSetHelper->AddRelation( AccessibleRelation( AccessibleRelationType::LABELED_BY, aSequence ) );
681 }
682 }
683 Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
684 return xSet;
685 //-----IAccessibility2 Implementation 2009
640}
641
642//--------------------------------------------------------------------
643::rtl::OUString AccessibleControlShape::CreateAccessibleName (void) throw (RuntimeException)
644{
645 ensureControlModelAccess();
686}
687
688//--------------------------------------------------------------------
689::rtl::OUString AccessibleControlShape::CreateAccessibleName (void) throw (RuntimeException)
690{
691 ensureControlModelAccess();
646
647 // check if we can obtain the "Name" resp. "Label" property from the model
648 const ::rtl::OUString& rAccNameProperty = lcl_getPreferredAccNameProperty( m_xModelPropsMeta );
649
650 ::rtl::OUString sName( getControlModelStringProperty( rAccNameProperty ) );
651 if ( !sName.getLength() )
652 { // no -> use the default
653 sName = AccessibleShape::CreateAccessibleName();
692 //IAccessibility2 Implementation 2009-----
693 ::rtl::OUString sName;
694 if ( getAccessibleRole() != AccessibleRole::SHAPE
695 && getAccessibleRole() != AccessibleRole::RADIO_BUTTON )
696 {
697 AccessibleControlShape* pCtlAccShape = GetLabeledByControlShape();
698 if(pCtlAccShape)
699 {
700 sName = pCtlAccShape->CreateAccessibleName();
701 }
654 }
702 }
655
703 if(sName.getLength() == 0)
704 {
705 // check if we can obtain the "Name" resp. "Label" property from the model
706 const ::rtl::OUString& rAccNameProperty = lcl_getPreferredAccNameProperty( m_xModelPropsMeta );
707 sName = getControlModelStringProperty( rAccNameProperty );
708 if ( !sName.getLength() )
709 { // no -> use the default
710 sName = AccessibleShape::CreateAccessibleName();
711 }
712 }
713 //-----IAccessibility2 Implementation 2009
656 // now that somebody first asked us for our name, ensure that we are listening to name changes on the model
657 m_bListeningForName = ensureListeningState( m_bListeningForName, sal_True, lcl_getPreferredAccNameProperty( m_xModelPropsMeta ) );
658
659 return sName;
660}
661
662//--------------------------------------------------------------------
663void SAL_CALL AccessibleControlShape::disposing (void)

--- 245 unchanged lines hidden (view full) ---

909{
910 // not interested in
911}
912
913void SAL_CALL AccessibleControlShape::elementReplaced( const ::com::sun::star::container::ContainerEvent& ) throw (::com::sun::star::uno::RuntimeException)
914{
915 // not interested in
916}
714 // now that somebody first asked us for our name, ensure that we are listening to name changes on the model
715 m_bListeningForName = ensureListeningState( m_bListeningForName, sal_True, lcl_getPreferredAccNameProperty( m_xModelPropsMeta ) );
716
717 return sName;
718}
719
720//--------------------------------------------------------------------
721void SAL_CALL AccessibleControlShape::disposing (void)

--- 245 unchanged lines hidden (view full) ---

967{
968 // not interested in
969}
970
971void SAL_CALL AccessibleControlShape::elementReplaced( const ::com::sun::star::container::ContainerEvent& ) throw (::com::sun::star::uno::RuntimeException)
972{
973 // not interested in
974}
975//IAccessibility2 Implementation 2009-----
976AccessibleControlShape* SAL_CALL AccessibleControlShape::GetLabeledByControlShape( )
977{
978 if(m_xControlModel.is())
979 {
980 const ::rtl::OUString& rAccLabelControlProperty = lcl_getLabelControlPropertyName();
981 Any sCtlLabelBy;
982 // get the "label by" property value of the control
983 if (::comphelper::hasProperty(rAccLabelControlProperty, m_xControlModel))
984 {
985 m_xControlModel->getPropertyValue( rAccLabelControlProperty ) >>= sCtlLabelBy;
986 if( sCtlLabelBy.hasValue() )
987 {
988 Reference< XPropertySet > xAsSet (sCtlLabelBy, UNO_QUERY);
989 AccessibleControlShape* pCtlAccShape = mpParent->GetAccControlShapeFromModel(xAsSet.get());
990 return pCtlAccShape;
991 }
992 }
993 }
994 return NULL;
995}
996//-----IAccessibility2 Implementation 2009