summaryrefslogtreecommitdiff
path: root/svx/source/accessibility/AccessibleControlShape.cxx
diff options
context:
space:
mode:
authorSteve Yin <steve_y@apache.org>2013-11-27 13:03:45 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-11-27 15:38:59 +0000
commit60f11adb950e4f9645cc9ecb0f5af8235cc97366 (patch)
treea4a758c31820e909d266f8b5cd49c651011acae9 /svx/source/accessibility/AccessibleControlShape.cxx
parente022c608fd927bfec20bdec5bee5b600668eeaac (diff)
Integrate branch of IAccessible2
Change-Id: I8327fb4ba2a86d4caa52b875221175b80464842a
Diffstat (limited to 'svx/source/accessibility/AccessibleControlShape.cxx')
-rw-r--r--svx/source/accessibility/AccessibleControlShape.cxx78
1 files changed, 70 insertions, 8 deletions
diff --git a/svx/source/accessibility/AccessibleControlShape.cxx b/svx/source/accessibility/AccessibleControlShape.cxx
index ebbd59954e7d..0c958e468a2b 100644
--- a/svx/source/accessibility/AccessibleControlShape.cxx
+++ b/svx/source/accessibility/AccessibleControlShape.cxx
@@ -21,13 +21,18 @@
#include <svx/AccessibleShapeInfo.hxx>
#include "svx/DescriptionGenerator.hxx"
#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/form/FormComponentType.hpp>
#include <com/sun/star/reflection/ProxyFactory.hpp>
#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/container/XChild.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/types.hxx>
#include <unotools/accessiblestatesethelper.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
#include <svx/svdouno.hxx>
#include "svx/unoapi.hxx"
#include <svx/ShapeTypeHandler.hxx>
@@ -67,6 +72,11 @@ namespace
static OUString s_sLabelPropertyLabel( "Label" );
return s_sLabelPropertyLabel;
}
+ const OUString& lcl_getLabelControlPropertyName( )
+ {
+ static OUString s_sLabelControlPropertyLabel("LabelControl");
+ return s_sLabelControlPropertyLabel;
+ }
// return the property which should be used as AccessibleName
const OUString& lcl_getPreferredAccNameProperty( const Reference< XPropertySetInfo >& _rxPSI )
{
@@ -581,21 +591,52 @@ Reference< XAccessible > SAL_CALL AccessibleControlShape::getAccessibleChild( sa
Reference< XAccessibleRelationSet > SAL_CALL AccessibleControlShape::getAccessibleRelationSet( ) throw (RuntimeException)
{
- // TODO
- return AccessibleShape::getAccessibleRelationSet( );
+ utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
+ ensureControlModelAccess();
+ AccessibleControlShape* pCtlAccShape = GetLabeledByControlShape();
+ if(pCtlAccShape)
+ {
+ Reference < XAccessible > xAcc (pCtlAccShape->getAccessibleContext(), UNO_QUERY);
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > aSequence(1);
+ aSequence[0] = xAcc;
+ if( getAccessibleRole() == AccessibleRole::RADIO_BUTTON )
+ {
+ pRelationSetHelper->AddRelation( AccessibleRelation( AccessibleRelationType::MEMBER_OF, aSequence ) );
+ }
+ else
+ {
+ pRelationSetHelper->AddRelation( AccessibleRelation( AccessibleRelationType::LABELED_BY, aSequence ) );
+ }
+ }
+ Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
+ return xSet;
}
OUString AccessibleControlShape::CreateAccessibleName (void) throw (RuntimeException)
{
ensureControlModelAccess();
- // check if we can obtain the "Name" resp. "Label" property from the model
- const OUString& rAccNameProperty = lcl_getPreferredAccNameProperty( m_xModelPropsMeta );
+ OUString sName;
+ if ( getAccessibleRole() != AccessibleRole::SHAPE
+ && getAccessibleRole() != AccessibleRole::RADIO_BUTTON )
+ {
+ AccessibleControlShape* pCtlAccShape = GetLabeledByControlShape();
+ if(pCtlAccShape)
+ {
+ sName = pCtlAccShape->CreateAccessibleName();
+ }
+ }
- OUString sName( getControlModelStringProperty( rAccNameProperty ) );
- if ( sName.isEmpty() )
- { // no -> use the default
- sName = AccessibleShape::CreateAccessibleName();
+ if (sName.isEmpty())
+ {
+ // check if we can obtain the "Name" resp. "Label" property from the model
+ const OUString& rAccNameProperty = lcl_getPreferredAccNameProperty( m_xModelPropsMeta );
+ sName = getControlModelStringProperty( rAccNameProperty );
+ if ( !sName.getLength() )
+ { // no -> use the default
+ sName = AccessibleShape::CreateAccessibleName();
+ }
}
// now that somebody first asked us for our name, ensure that we are listening to name changes on the model
@@ -853,4 +894,25 @@ void SAL_CALL AccessibleControlShape::elementReplaced( const ::com::sun::star::c
// not interested in
}
+AccessibleControlShape* SAL_CALL AccessibleControlShape::GetLabeledByControlShape( )
+{
+ if(m_xControlModel.is())
+ {
+ const OUString& rAccLabelControlProperty = lcl_getLabelControlPropertyName();
+ Any sCtlLabelBy;
+ // get the "label by" property value of the control
+ if (::comphelper::hasProperty(rAccLabelControlProperty, m_xControlModel))
+ {
+ m_xControlModel->getPropertyValue( rAccLabelControlProperty ) >>= sCtlLabelBy;
+ if( sCtlLabelBy.hasValue() )
+ {
+ Reference< XPropertySet > xAsSet (sCtlLabelBy, UNO_QUERY);
+ AccessibleControlShape* pCtlAccShape = mpParent->GetAccControlShapeFromModel(xAsSet.get());
+ return pCtlAccShape;
+ }
+ }
+ }
+ return NULL;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */