diff options
author | RĂ¼diger Timm <rt@openoffice.org> | 2008-07-07 13:31:23 +0000 |
---|---|---|
committer | RĂ¼diger Timm <rt@openoffice.org> | 2008-07-07 13:31:23 +0000 |
commit | db692190dcf8733ada51ec6b7d12adb687ef9455 (patch) | |
tree | 5f0c4f0701af682780982168e0e25c148a637516 /svx/source/accessibility | |
parent | b2421712a78c42d8942eece1ba3962f4ea6d7241 (diff) |
INTEGRATION: CWS impressa11y (1.50.106); FILE MERGED
2008/05/29 12:23:24 af 1.50.106.6: RESYNC: (1.51-1.53); FILE MERGED
2008/01/22 11:59:11 af 1.50.106.5: RESYNC: (1.50-1.51); FILE MERGED
2007/04/25 11:45:58 af 1.50.106.4: #130728# Fixed the handling of optional properties.
2007/04/20 11:54:57 af 1.50.106.3: #129239# Fixed minor compile problems.
2007/01/16 12:55:40 af 1.50.106.2: #129239# Changed role from SHAPE to LIST_ITEM.
2007/01/11 16:37:39 af 1.50.106.1: #i73244# Added UpdateNameAndDescription() method.
Diffstat (limited to 'svx/source/accessibility')
-rwxr-xr-x | svx/source/accessibility/AccessibleShape.cxx | 108 |
1 files changed, 79 insertions, 29 deletions
diff --git a/svx/source/accessibility/AccessibleShape.cxx b/svx/source/accessibility/AccessibleShape.cxx index 0d2394fb3c..be29ed6786 100755 --- a/svx/source/accessibility/AccessibleShape.cxx +++ b/svx/source/accessibility/AccessibleShape.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: AccessibleShape.cxx,v $ - * $Revision: 1.53 $ + * $Revision: 1.54 $ * * This file is part of OpenOffice.org. * @@ -48,6 +48,7 @@ #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/text/XText.hpp> +#include <rtl/ref.hxx> #include <svx/unoedsrc.hxx> #include <svx/unoshtxt.hxx> #include <svx/svdobj.hxx> @@ -67,19 +68,52 @@ #include <svx/svdview.hxx> #include "AccessibleEmptyEditSource.hxx" -using ::rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; using ::com::sun::star::uno::Reference; +using ::rtl::OUString; namespace accessibility { +namespace { + +OUString GetOptionalProperty ( + const Reference<beans::XPropertySet>& rxSet, + const OUString& rsPropertyName) +{ + OUString sValue; + + if (rxSet.is()) + { + const Reference<beans::XPropertySetInfo> xInfo (rxSet->getPropertySetInfo()); + if ( ! xInfo.is() || xInfo->hasPropertyByName(rsPropertyName)) + { + try + { + rxSet->getPropertyValue(rsPropertyName) >>= sValue; + } + catch (beans::UnknownPropertyException&) + { + // This exception should only be thrown when the property + // does not exits (of course) and the XPropertySetInfo is + // not available. + } + } + } + return sValue; +} + +} // end of anonymous namespace + + + + //===== internal ============================================================ AccessibleShape::AccessibleShape ( const AccessibleShapeInfo& rShapeInfo, const AccessibleShapeTreeInfo& rShapeTreeInfo) - : AccessibleContextBase (rShapeInfo.mxParent,AccessibleRole::SHAPE), + : AccessibleContextBase (rShapeInfo.mxParent,AccessibleRole::LIST_ITEM), mpChildrenManager(NULL), mxShape (rShapeInfo.mxShape), maShapeTreeInfo (rShapeTreeInfo), @@ -89,6 +123,7 @@ AccessibleShape::AccessibleShape ( mpParent (rShapeInfo.mpChildrenManager) { m_pShape = GetSdrObjectFromXShape(mxShape); + UpdateNameAndDescription(); } @@ -219,32 +254,6 @@ void AccessibleShape::UpdateStates (void) bShapeIsSelected = maShapeTreeInfo.GetSdrView()->IsObjMarked(m_pShape) == TRUE; } - -// Reference<view::XSelectionSupplier> xSelectionSupplier ( maShapeTreeInfo.GetController(), uno::UNO_QUERY); -// if ( xSelectionSupplier.is() ) -// { -// uno::Any aSelection(xSelectionSupplier->getSelection()); -// Reference<drawing::XShape> xSelectedShape; -// aSelection >>= xSelectedShape; -// if ( xSelectedShape.is() && xSelectedShape.get() == mxShape.get() ) -// bShapeIsSelected = true; -// else -// { -// Reference<container::XIndexAccess> xSelectedShapes; -// aSelection >>= xSelectedShapes; -// if ( xSelectedShapes.is() ) -// { -// for (sal_Int32 i=0,nCount=xSelectedShapes->getCount(); -// i<nCount && !bShapeIsSelected; ++i) -// { -// xSelectedShapes->getByIndex(i) >>= xSelectedShape; -// bShapeIsSelected = xSelectedShape.get() == mxShape.get(); -// } -// } -// } -// } - - if (bShapeIsSelected) pStateSet->AddState (AccessibleStateType::SELECTED); else @@ -261,6 +270,7 @@ bool AccessibleShape::operator== (const AccessibleShape& rShape) + sal_Bool AccessibleShape::SetState (sal_Int16 aState) { sal_Bool bStateHasChanged = sal_False; @@ -912,6 +922,10 @@ void SAL_CALL AccessibleEventId::VISIBLE_DATA_CHANGED, uno::Any(), uno::Any()); + + // Name and Description may have changed. Update the local + // values accordingly. + UpdateNameAndDescription(); } } } @@ -1186,4 +1200,40 @@ sal_Int32 SAL_CALL + +void AccessibleShape::UpdateNameAndDescription (void) +{ + // Ignore missing title, name, or description. There are fallbacks for + // them. + try + { + Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY_THROW); + OUString sString; + + // Get the accessible name. + sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Title"))); + if (sString.getLength() > 0) + { + SetAccessibleName(sString, AccessibleContextBase::FromShape); + } + else + { + sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Name"))); + if (sString.getLength() > 0) + SetAccessibleName(sString, AccessibleContextBase::FromShape); + } + + // Get the accessible description. + sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Description"))); + if (sString.getLength() > 0) + SetAccessibleDescription(sString, AccessibleContextBase::FromShape); + } + catch (uno::RuntimeException&) + { + } +} + + + + } // end of namespace accessibility |