diff options
Diffstat (limited to 'sc/source/ui/Accessibility')
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleCell.cxx | 17 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleCellBase.cxx | 18 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleContextBase.cxx | 258 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleDocument.cxx | 229 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx | 133 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleEditObject.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessiblePageHeader.cxx | 35 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx | 13 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessiblePreviewCell.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessiblePreviewTable.cxx | 98 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx | 254 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleTableBase.cxx | 29 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleText.cxx | 14 |
14 files changed, 362 insertions, 766 deletions
diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx index dd7f189738b9..35288daa99fc 100644 --- a/sc/source/ui/Accessibility/AccessibleCell.cxx +++ b/sc/source/ui/Accessibility/AccessibleCell.cxx @@ -85,20 +85,13 @@ ScAccessibleCell::~ScAccessibleCell() { if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose) { - // increment refcount to prevent double call off dtor + // increment refcount to prevent double call of dtor osl_atomic_increment( &m_refCount ); // call dispose to inform object which have a weak reference to this object dispose(); } } -void ScAccessibleCell::Init() -{ - ScAccessibleCellBase::Init(); - - SetEventSource(this); -} - void SAL_CALL ScAccessibleCell::disposing() { SolarMutexGuard aGuard; @@ -142,7 +135,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleCell::getAccessibleAtPoint( void SAL_CALL ScAccessibleCell::grabFocus( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (getAccessibleParent().is() && mpViewShell) { uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY); @@ -285,7 +278,7 @@ uno::Reference<XAccessibleRelationSet> SAL_CALL ScAccessibleCell::getAccessibleRelationSet() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); rtl::Reference<utl::AccessibleRelationSetHelper> pRelationSet; if (mpAccDoc) pRelationSet = mpAccDoc->GetRelationSet(&maCellAddress); @@ -491,7 +484,7 @@ static OUString ReplaceFourChar(const OUString& oldOUString) .replaceAll(u":", u"\\:"); } -uno::Any SAL_CALL ScAccessibleCell::getExtendedAttributes() +OUString SAL_CALL ScAccessibleCell::getExtendedAttributes() { SolarMutexGuard aGuard; @@ -529,7 +522,7 @@ uno::Any SAL_CALL ScAccessibleCell::getExtendedAttributes() sAttributes += strFor ; } - return uno::Any(sAttributes); + return sAttributes; } // cell has its own ParaIndent property, so when calling character attributes on cell, the ParaIndent should replace the ParaLeftMargin if its value is not zero. diff --git a/sc/source/ui/Accessibility/AccessibleCellBase.cxx b/sc/source/ui/Accessibility/AccessibleCellBase.cxx index ebff91c101e2..8735629c858d 100644 --- a/sc/source/ui/Accessibility/AccessibleCellBase.cxx +++ b/sc/source/ui/Accessibility/AccessibleCellBase.cxx @@ -68,7 +68,7 @@ ScAccessibleCellBase::~ScAccessibleCellBase() bool ScAccessibleCellBase::isVisible() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); // test whether the cell is hidden (column/row - hidden/filtered) bool bVisible(true); if (mpDoc) @@ -87,7 +87,7 @@ bool ScAccessibleCellBase::isVisible() sal_Int32 SAL_CALL ScAccessibleCellBase::getForeground() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); sal_Int32 nColor(0); if (mpDoc) { @@ -126,7 +126,7 @@ sal_Int32 SAL_CALL ScAccessibleCellBase::getForeground() sal_Int32 SAL_CALL ScAccessibleCellBase::getBackground() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); sal_Int32 nColor(0); if (mpDoc) @@ -190,7 +190,7 @@ sal_Int64 ScAccessibleCellBase::getAccessibleIndexInParent() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); return mnIndex; } @@ -214,7 +214,7 @@ uno::Any SAL_CALL ScAccessibleCellBase::getCurrentValue() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); uno::Any aAny; if (mpDoc) { @@ -227,7 +227,7 @@ sal_Bool SAL_CALL ScAccessibleCellBase::setCurrentValue( const uno::Any& aNumber ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); double fValue = 0; bool bResult = false; if((aNumber >>= fValue) && mpDoc && mpDoc->GetDocumentShell()) @@ -294,7 +294,7 @@ bool ScAccessibleCellBase::IsEditable(sal_Int64 nParentStates) OUString ScAccessibleCellBase::GetNote() const { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); OUString sNote; if (mpDoc) { @@ -340,7 +340,7 @@ OUString ScAccessibleCellBase::GetNote() const OUString ScAccessibleCellBase::getShadowAttrs() const { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); table::ShadowFormat aShadowFmt; if (mpDoc) { @@ -420,7 +420,7 @@ OUString ScAccessibleCellBase::getShadowAttrs() const OUString ScAccessibleCellBase::getBorderAttrs() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); table::BorderLine aTopBorder; table::BorderLine aBottomBorder; table::BorderLine aLeftBorder; diff --git a/sc/source/ui/Accessibility/AccessibleContextBase.cxx b/sc/source/ui/Accessibility/AccessibleContextBase.cxx index b121893e2f6c..a0a8c764ce0e 100644 --- a/sc/source/ui/Accessibility/AccessibleContextBase.cxx +++ b/sc/source/ui/Accessibility/AccessibleContextBase.cxx @@ -36,44 +36,11 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; -/** - The listener is an internal class to prevent reference-counting cycles and therefore memory leaks. -*/ -typedef cppu::WeakComponentImplHelper< - css::accessibility::XAccessibleEventListener - > ScAccessibleContextBaseEventListenerWeakImpl; -class ScAccessibleContextBase::ScAccessibleContextBaseEventListener : public cppu::BaseMutex, public ScAccessibleContextBaseEventListenerWeakImpl -{ -public: - ScAccessibleContextBaseEventListener(ScAccessibleContextBase& rBase) - : ScAccessibleContextBaseEventListenerWeakImpl(m_aMutex), mrBase(rBase) {} - - using WeakComponentImplHelperBase::disposing; - - ///===== XAccessibleEventListener ======================================== - - virtual void SAL_CALL disposing( const lang::EventObject& rSource ) override - { - SolarMutexGuard aGuard; - if (rSource.Source == mrBase.mxParent) - dispose(); - } - - virtual void SAL_CALL - notifyEvent( - const css::accessibility::AccessibleEventObject& /*aEvent*/ ) override {} -private: - ScAccessibleContextBase& mrBase; -}; - - ScAccessibleContextBase::ScAccessibleContextBase( uno::Reference<XAccessible> xParent, const sal_Int16 aRole) : - ScAccessibleContextBaseWeakImpl(m_aMutex), mxParent(std::move(xParent)), - mnClientId(0), maRole(aRole) { } @@ -82,7 +49,7 @@ ScAccessibleContextBase::~ScAccessibleContextBase() { if (!IsDefunc() && !rBHelper.bInDispose) { - // increment refcount to prevent double call off dtor + // increment refcount to prevent double call of dtor osl_atomic_increment( &m_refCount ); // call dispose to inform object which have a weak reference to this object dispose(); @@ -94,16 +61,6 @@ void ScAccessibleContextBase::Init() // hold reference to make sure that the destructor is not called uno::Reference< XAccessibleContext > xKeepAlive(this); - if (mxParent.is()) - { - uno::Reference< XAccessibleEventBroadcaster > xBroadcaster (mxParent->getAccessibleContext(), uno::UNO_QUERY); - if (xBroadcaster.is()) - { - if (!mxEventListener) - mxEventListener = new ScAccessibleContextBaseEventListener(*this); - xBroadcaster->addAccessibleEventListener(mxEventListener); - } - } msName = createAccessibleName(); msDescription = createAccessibleDescription(); } @@ -111,25 +68,13 @@ void ScAccessibleContextBase::Init() void SAL_CALL ScAccessibleContextBase::disposing() { SolarMutexGuard aGuard; -// CommitDefunc(); not necessary and should not be send, because it cost a lot of time // hold reference to make sure that the destructor is not called uno::Reference< XAccessibleContext > xKeepAlive(this); - if ( mnClientId ) - { - sal_Int32 nTemClientId(mnClientId); - mnClientId = 0; - comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nTemClientId, *this ); - } + OAccessibleComponentHelper::disposing(); - if (mxParent.is()) - { - uno::Reference< XAccessibleEventBroadcaster > xBroadcaster (mxParent->getAccessibleContext(), uno::UNO_QUERY); - if (xBroadcaster && mxEventListener) - xBroadcaster->removeAccessibleEventListener(mxEventListener); - mxParent = nullptr; - } + mxParent.clear(); } @@ -152,55 +97,26 @@ uno::Reference< XAccessibleContext> SAL_CALL return this; } -//===== XAccessibleComponent ================================================ +// OAccessibleComponentHelper -sal_Bool SAL_CALL ScAccessibleContextBase::containsPoint(const awt::Point& rPoint ) +awt::Rectangle ScAccessibleContextBase::implGetBounds( ) { - SolarMutexGuard aGuard; - IsObjectValid(); - return tools::Rectangle(Point(), GetBoundingBox().GetSize()) - .Contains(vcl::unohelper::ConvertToVCLPoint(rPoint)); -} - -uno::Reference< XAccessible > SAL_CALL ScAccessibleContextBase::getAccessibleAtPoint( - const awt::Point& /* rPoint */ ) -{ - OSL_FAIL("not implemented"); - return uno::Reference<XAccessible>(); -} - -awt::Rectangle SAL_CALL ScAccessibleContextBase::getBounds( ) -{ - SolarMutexGuard aGuard; - IsObjectValid(); return vcl::unohelper::ConvertToAWTRect(GetBoundingBox()); } -awt::Point SAL_CALL ScAccessibleContextBase::getLocation( ) -{ - SolarMutexGuard aGuard; - IsObjectValid(); - return vcl::unohelper::ConvertToAWTPoint(GetBoundingBox().TopLeft()); -} +//===== XAccessibleComponent ================================================ awt::Point SAL_CALL ScAccessibleContextBase::getLocationOnScreen( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); return vcl::unohelper::ConvertToAWTPoint(GetBoundingBoxOnScreen().TopLeft()); } -awt::Size SAL_CALL ScAccessibleContextBase::getSize( ) -{ - SolarMutexGuard aGuard; - IsObjectValid(); - return vcl::unohelper::ConvertToAWTSize(GetBoundingBox().GetSize()); -} - bool ScAccessibleContextBase::isShowing( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); bool bShowing(false); if (mxParent.is()) { @@ -238,55 +154,12 @@ sal_Int32 SAL_CALL ScAccessibleContextBase::getBackground( ) //===== XAccessibleContext ================================================== -sal_Int64 SAL_CALL ScAccessibleContextBase::getAccessibleChildCount() -{ - OSL_FAIL("should be implemented in the abrevated class"); - return 0; -} - -uno::Reference<XAccessible> SAL_CALL - ScAccessibleContextBase::getAccessibleChild(sal_Int64 /* nIndex */) -{ - OSL_FAIL("should be implemented in the abrevated class"); - return uno::Reference<XAccessible>(); -} - uno::Reference<XAccessible> SAL_CALL ScAccessibleContextBase::getAccessibleParent() { return mxParent; } -sal_Int64 SAL_CALL - ScAccessibleContextBase::getAccessibleIndexInParent() -{ - SolarMutexGuard aGuard; - IsObjectValid(); - // Use a simple but slow solution for now. Optimize later. - // Return -1 to indicate that this object's parent does not know about the - // object. - sal_Int64 nIndex(-1); - - // 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_Int64 nChildCount = xParentContext->getAccessibleChildCount(); - for (sal_Int64 i=0; i<nChildCount; ++i) - { - uno::Reference<XAccessible> xChild (xParentContext->getAccessibleChild (i)); - if (xChild.is() && xChild.get() == this) - nIndex = i; - } - } - } - - return nIndex; -} - sal_Int16 SAL_CALL ScAccessibleContextBase::getAccessibleRole() { @@ -297,22 +170,18 @@ OUString SAL_CALL ScAccessibleContextBase::getAccessibleDescription() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (msDescription.isEmpty()) { OUString sDescription(createAccessibleDescription()); if (msDescription != sDescription) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - aEvent.OldValue <<= msDescription; - aEvent.NewValue <<= sDescription; - + const OUString sOldDescription = msDescription; msDescription = sDescription; - CommitChange(aEvent); + CommitChange(AccessibleEventId::DESCRIPTION_CHANGED, uno::Any(sOldDescription), + uno::Any(sDescription)); } } return msDescription; @@ -322,7 +191,7 @@ OUString SAL_CALL ScAccessibleContextBase::getAccessibleName() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (msName.isEmpty()) { OUString sName(createAccessibleName()); @@ -330,15 +199,10 @@ OUString SAL_CALL if (msName != sName) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::NAME_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - aEvent.OldValue <<= msName; - aEvent.NewValue <<= sName; - + const OUString sOldName = msName; msName = sName; - CommitChange(aEvent); + CommitChange(AccessibleEventId::NAME_CHANGED, uno::Any(sOldName), uno::Any(sName)); } } return msName; @@ -359,7 +223,7 @@ lang::Locale SAL_CALL ScAccessibleContextBase::getLocale() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (mxParent.is()) { uno::Reference<XAccessibleContext> xParentContext ( @@ -373,48 +237,6 @@ lang::Locale SAL_CALL throw IllegalAccessibleComponentStateException (); } - //===== XAccessibleEventBroadcaster ===================================== - -void SAL_CALL - ScAccessibleContextBase::addAccessibleEventListener( - const uno::Reference<XAccessibleEventListener>& xListener) -{ - if (xListener.is()) - { - SolarMutexGuard aGuard; - IsObjectValid(); - if (!IsDefunc()) - { - if (!mnClientId) - mnClientId = comphelper::AccessibleEventNotifier::registerClient( ); - comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener ); - } - } -} - -void SAL_CALL - ScAccessibleContextBase::removeAccessibleEventListener( - const uno::Reference<XAccessibleEventListener>& xListener) -{ - if (!xListener.is()) - return; - - SolarMutexGuard aGuard; - if (IsDefunc() || !mnClientId) - return; - - 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; - } -} - // XServiceInfo OUString SAL_CALL ScAccessibleContextBase::getImplementationName() { @@ -438,58 +260,32 @@ uno::Sequence< OUString> SAL_CALL OUString ScAccessibleContextBase::createAccessibleDescription() { - OSL_FAIL("should be implemented in the abrevated class"); + OSL_FAIL("should be implemented in the abbreviated class"); return OUString(); } OUString ScAccessibleContextBase::createAccessibleName() { - OSL_FAIL("should be implemented in the abrevated class"); + OSL_FAIL("should be implemented in the abbreviated class"); return OUString(); } -void ScAccessibleContextBase::CommitChange(const AccessibleEventObject& rEvent) const -{ - if (mnClientId) - comphelper::AccessibleEventNotifier::addEvent( mnClientId, rEvent ); -} - -void ScAccessibleContextBase::CommitFocusGained() const -{ - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::STATE_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(const_cast<ScAccessibleContextBase*>(this)); - aEvent.NewValue <<= AccessibleStateType::FOCUSED; - - CommitChange(aEvent); -} - -void ScAccessibleContextBase::CommitFocusLost() const +void ScAccessibleContextBase::CommitChange(const sal_Int16 nEventId, const css::uno::Any& rOldValue, + const css::uno::Any& rNewValue, sal_Int32 nIndexHint) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::STATE_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(const_cast<ScAccessibleContextBase*>(this)); - aEvent.OldValue <<= AccessibleStateType::FOCUSED; - - CommitChange(aEvent); + NotifyAccessibleEvent(nEventId, rOldValue, rNewValue, nIndexHint); } -AbsoluteScreenPixelRectangle ScAccessibleContextBase::GetBoundingBoxOnScreen() const +void ScAccessibleContextBase::CommitFocusGained() { - OSL_FAIL("not implemented"); - return AbsoluteScreenPixelRectangle(); -} - -tools::Rectangle ScAccessibleContextBase::GetBoundingBox() const -{ - OSL_FAIL("not implemented"); - return tools::Rectangle(); + CommitChange(AccessibleEventId::STATE_CHANGED, uno::Any(), + uno::Any(AccessibleStateType::FOCUSED)); } -void ScAccessibleContextBase::IsObjectValid() const +void ScAccessibleContextBase::CommitFocusLost() { - if (rBHelper.bDisposed || rBHelper.bInDispose) - throw lang::DisposedException(); + CommitChange(AccessibleEventId::STATE_CHANGED, uno::Any(AccessibleStateType::FOCUSED), + uno::Any()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx index 5658ee2a27a9..d1bd67a7686e 100644 --- a/sc/source/ui/Accessibility/AccessibleDocument.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx @@ -220,14 +220,14 @@ public: virtual ::accessibility::AccessibleControlShape* GetAccControlShapeFromModel (css::beans::XPropertySet* pSet) override; - virtual css::uno::Reference< css::accessibility::XAccessible> + virtual ::accessibility::AccessibleShape* GetAccessibleCaption (const css::uno::Reference<css::drawing::XShape>& xShape) override; ///===== Internal ======================================================== void SetDrawBroadcaster(); sal_Int32 GetCount() const; - uno::Reference< XAccessible > Get(const ScAccessibleShapeData* pData) const; - uno::Reference< XAccessible > Get(sal_Int32 nIndex) const; + rtl::Reference<::accessibility::AccessibleShape> Get(const ScAccessibleShapeData* pData) const; + rtl::Reference<::accessibility::AccessibleShape> Get(sal_Int32 nIndex) const; uno::Reference< XAccessible > GetAt(const awt::Point& rPoint) const; // gets the index of the shape starting on 0 (without the index of the table) @@ -241,7 +241,8 @@ public: void DeselectAll(); // deselect also the table void SelectAll(); sal_Int32 GetSelectedCount() const; - uno::Reference< XAccessible > GetSelected(sal_Int32 nSelectedChildIndex, bool bTabSelected) const; + rtl::Reference<::accessibility::AccessibleShape> GetSelected(sal_Int32 nSelectedChildIndex, + bool bTabSelected) const; void Deselect(sal_Int32 nChildIndex); SdrPage* GetDrawPage() const; @@ -429,13 +430,10 @@ bool ScChildrenShapes::ReplaceChild (::accessibility::AccessibleShape* pCurrentC if (it != maShapesMap.end() && it->second->pAccShape.is()) { OSL_ENSURE(it->second->pAccShape == pCurrentChild, "wrong child found"); - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument); - aEvent.OldValue <<= uno::Reference<XAccessible>(pCurrentChild); - aEvent.IndexHint = -1; - - mpAccessibleDocument->CommitChange(aEvent); // child is gone - event + // child is gone - event + mpAccessibleDocument->CommitChange(AccessibleEventId::CHILD, + uno::Any(uno::Reference<XAccessible>(pCurrentChild)), + uno::Any()); pCurrentChild->dispose(); } @@ -447,13 +445,9 @@ bool ScChildrenShapes::ReplaceChild (::accessibility::AccessibleShape* pCurrentC if (it != maShapesMap.end()) { it->second->pAccShape = pReplacement; - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument); - aEvent.NewValue <<= uno::Reference<XAccessible>(pReplacement); - aEvent.IndexHint = -1; - - mpAccessibleDocument->CommitChange(aEvent); // child is new - event + // child is new - event + mpAccessibleDocument->CommitChange(AccessibleEventId::CHILD, uno::Any(), + uno::Any(uno::Reference<XAccessible>(pReplacement))); bResult = true; } } @@ -479,7 +473,7 @@ bool ScChildrenShapes::ReplaceChild (::accessibility::AccessibleShape* pCurrentC return nullptr; } -css::uno::Reference < css::accessibility::XAccessible > +::accessibility::AccessibleShape* ScChildrenShapes::GetAccessibleCaption (const css::uno::Reference < css::drawing::XShape>& xShape) { GetCount(); // populate @@ -487,10 +481,7 @@ ScChildrenShapes::GetAccessibleCaption (const css::uno::Reference < css::drawing if (it == maShapesMap.end()) return nullptr; ScAccessibleShapeData* pShape = it->second; - css::uno::Reference< css::accessibility::XAccessible > xNewChild( pShape->pAccShape ); - if(xNewChild) - return xNewChild; - return nullptr; + return pShape->pAccShape.get(); } sal_Int32 ScChildrenShapes::GetCount() const @@ -509,7 +500,8 @@ sal_Int32 ScChildrenShapes::GetCount() const return maZOrderedShapes.size(); } -uno::Reference< XAccessible > ScChildrenShapes::Get(const ScAccessibleShapeData* pData) const +rtl::Reference<::accessibility::AccessibleShape> +ScChildrenShapes::Get(const ScAccessibleShapeData* pData) const { if (!pData) return nullptr; @@ -533,7 +525,7 @@ uno::Reference< XAccessible > ScChildrenShapes::Get(const ScAccessibleShapeData* return pData->pAccShape; } -uno::Reference< XAccessible > ScChildrenShapes::Get(sal_Int32 nIndex) const +rtl::Reference<::accessibility::AccessibleShape> ScChildrenShapes::Get(sal_Int32 nIndex) const { if (maZOrderedShapes.size() <= 1) GetCount(); // fill list with filtered shapes (no internal shapes) @@ -793,9 +785,10 @@ sal_Int32 ScChildrenShapes::GetSelectedCount() const return aShapes.size(); } -uno::Reference< XAccessible > ScChildrenShapes::GetSelected(sal_Int32 nSelectedChildIndex, bool bTabSelected) const +rtl::Reference<::accessibility::AccessibleShape> +ScChildrenShapes::GetSelected(sal_Int32 nSelectedChildIndex, bool bTabSelected) const { - uno::Reference< XAccessible > xAccessible; + rtl::Reference<::accessibility::AccessibleShape> xAccessible; if (maZOrderedShapes.size() <= 1) GetCount(); // fill list with shapes @@ -1037,30 +1030,25 @@ bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::X if( pMarkedObj == pFocusedObj && pUpObj ) { uno::Reference< drawing::XShape > xUpGroupXShape (pUpObj->getUnoShape(), uno::UNO_QUERY); - uno::Reference < XAccessible > xAccGroupShape = + ::accessibility::AccessibleShape* pAccGroupShape = const_cast<ScChildrenShapes*>(this)->GetAccessibleCaption( xUpGroupXShape ); - if( xAccGroupShape.is() ) + if( pAccGroupShape ) { - ::accessibility::AccessibleShape* pAccGroupShape = - static_cast< ::accessibility::AccessibleShape* >(xAccGroupShape.get()); - if( pAccGroupShape ) + sal_Int64 nCount = pAccGroupShape->getAccessibleChildCount(); + for( sal_Int64 i = 0; i < nCount; i++ ) { - sal_Int64 nCount = pAccGroupShape->getAccessibleChildCount(); - for( sal_Int64 i = 0; i < nCount; i++ ) + uno::Reference<XAccessible> xAccShape = pAccGroupShape->getAccessibleChild(i); + if (xAccShape.is()) { - uno::Reference<XAccessible> xAccShape = pAccGroupShape->getAccessibleChild(i); - if (xAccShape.is()) + ::accessibility::AccessibleShape* pChildAccShape = static_cast< ::accessibility::AccessibleShape* >(xAccShape.get()); + uno::Reference< drawing::XShape > xChildShape = pChildAccShape->GetXShape(); + if (xChildShape == xMarkedXShape) + { + pChildAccShape->SetState(AccessibleStateType::FOCUSED); + } + else { - ::accessibility::AccessibleShape* pChildAccShape = static_cast< ::accessibility::AccessibleShape* >(xAccShape.get()); - uno::Reference< drawing::XShape > xChildShape = pChildAccShape->GetXShape(); - if (xChildShape == xMarkedXShape) - { - pChildAccShape->SetState(AccessibleStateType::FOCUSED); - } - else - { - pChildAccShape->ResetState(AccessibleStateType::FOCUSED); - } + pChildAccShape->ResetState(AccessibleStateType::FOCUSED); } } } @@ -1070,38 +1058,27 @@ bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::X } if (vecSelectedShapeAdd.size() >= 10 ) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; - aEvent.Source = uno::Reference< XAccessible >(mpAccessibleDocument); - mpAccessibleDocument->CommitChange(aEvent); + mpAccessibleDocument->CommitChange(AccessibleEventId::SELECTION_CHANGED_WITHIN, uno::Any(), + uno::Any()); } else { for (const auto& rpShape : vecSelectedShapeAdd) { - AccessibleEventObject aEvent; + sal_Int16 nEventId; if (bHasSelect) - { - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD; - } + nEventId = AccessibleEventId::SELECTION_CHANGED_ADD; else - { - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; - } - aEvent.Source = uno::Reference< XAccessible >(mpAccessibleDocument); - uno::Reference< XAccessible > xChild( rpShape->pAccShape ); - aEvent.NewValue <<= xChild; - mpAccessibleDocument->CommitChange(aEvent); + nEventId = AccessibleEventId::SELECTION_CHANGED; + mpAccessibleDocument->CommitChange( + nEventId, uno::Any(), uno::Any(uno::Reference<XAccessible>(rpShape->pAccShape))); } } for (const auto& rpShape : vecSelectedShapeRemove) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE; - aEvent.Source = uno::Reference< XAccessible >(mpAccessibleDocument); - uno::Reference< XAccessible > xChild( rpShape->pAccShape ); - aEvent.NewValue <<= xChild; - mpAccessibleDocument->CommitChange(aEvent); + mpAccessibleDocument->CommitChange( + AccessibleEventId::SELECTION_CHANGED_REMOVE, uno::Any(), + uno::Any(uno::Reference<XAccessible>(rpShape->pAccShape))); } for(ScAccessibleShapeData*& pShapeData : aShapesList) { @@ -1219,13 +1196,9 @@ void ScChildrenShapes::AddShape(const uno::Reference<drawing::XShape>& xShape, b } if (mpAccessibleDocument && bCommitChange) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument); - aEvent.NewValue <<= Get(pShape); - aEvent.IndexHint = -1; - - mpAccessibleDocument->CommitChange(aEvent); // new child - event + // new child - event + mpAccessibleDocument->CommitChange(AccessibleEventId::CHILD, uno::Any(), + uno::Any(uno::Reference<XAccessible>(Get(pShape)))); } } @@ -1241,19 +1214,16 @@ void ScChildrenShapes::RemoveShape(const uno::Reference<drawing::XShape>& xShape { if (mpAccessibleDocument) { - uno::Reference<XAccessible> xOldAccessible (Get(*aItr)); + rtl::Reference<::accessibility::AccessibleShape> xOldAccessible(Get(*aItr)); delete *aItr; maShapesMap.erase((*aItr)->xShape); maZOrderedShapes.erase(aItr); - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument); - aEvent.OldValue <<= xOldAccessible; - aEvent.IndexHint = -1; - - mpAccessibleDocument->CommitChange(aEvent); // child is gone - event + // child is gone - event + mpAccessibleDocument->CommitChange( + AccessibleEventId::CHILD, uno::Any(uno::Reference<XAccessible>(xOldAccessible)), + uno::Any()); } else { @@ -1365,7 +1335,7 @@ ScAccessibleDocument::~ScAccessibleDocument() { if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose) { - // increment refcount to prevent double call off dtor + // increment refcount to prevent double call of dtor osl_atomic_increment( &m_refCount ); dispose(); } @@ -1443,20 +1413,18 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) auto pFocusGotHint = static_cast<const ScAccGridWinFocusGotHint*>(&rHint); if (pFocusGotHint->GetNewGridWin() == meSplitPos) { - uno::Reference<XAccessible> xAccessible; + rtl::Reference<::accessibility::AccessibleShape> xAccShape; if (mpChildrenShapes) { bool bTabMarked(IsTableSelected()); - xAccessible = mpChildrenShapes->GetSelected(0, bTabMarked); + xAccShape = mpChildrenShapes->GetSelected(0, bTabMarked); } - if( xAccessible.is() ) + if (xAccShape.is()) { uno::Any aNewValue; aNewValue<<=AccessibleStateType::FOCUSED; - static_cast< ::accessibility::AccessibleShape* >(xAccessible.get())-> - CommitChange(AccessibleEventId::STATE_CHANGED, - aNewValue, - uno::Any(), -1 ); + xAccShape->CommitChange(AccessibleEventId::STATE_CHANGED, aNewValue, uno::Any(), + -1); } else { @@ -1480,10 +1448,8 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) // mpChildrenShapes variable. mpChildrenShapes.reset( new ScChildrenShapes( this, mpViewShell, meSplitPos ) ); - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::INVALIDATE_ALL_CHILDREN; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - CommitChange(aEvent); // all children changed + // all children changed + CommitChange(AccessibleEventId::INVALIDATE_ALL_CHILDREN, uno::Any(), uno::Any()); if (mpAccessibleSpreadsheet.is()) mpAccessibleSpreadsheet->GotFocus(); @@ -1505,9 +1471,8 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) mpTempAccEdit = new ScAccessibleEditObject(this, rViewData.GetEditView(meSplitPos), mpViewShell->GetWindowByPos(meSplitPos), GetCurrentCellName(), ScResId(STR_ACC_EDITLINE_DESCR), ScAccessibleEditObject::CellInEditMode); - uno::Reference<XAccessible> xAcc = mpTempAccEdit; - AddChild(xAcc, true); + AddChild(uno::Reference<XAccessible>(mpTempAccEdit), true); if (mpAccessibleSpreadsheet.is()) mpAccessibleSpreadsheet->LostFocus(); @@ -1551,11 +1516,7 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { if (maVisArea.GetSize() != aOldVisArea.GetSize()) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - - CommitChange(aEvent); + CommitChange(AccessibleEventId::BOUNDRECT_CHANGED, uno::Any(), uno::Any()); if (mpAccessibleSpreadsheet.is()) mpAccessibleSpreadsheet->BoundingBoxChanged(); @@ -1592,13 +1553,7 @@ void SAL_CALL ScAccessibleDocument::selectionChanged( const lang::EventObject& / bSelectionChanged = true; if (bSelectionChanged) - { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - - CommitChange(aEvent); - } + CommitChange(AccessibleEventId::SELECTION_CHANGED, uno::Any(), uno::Any()); } //===== XInterface ===================================================== @@ -1630,7 +1585,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleDocument::getAccessibleAtPoin if (containsPoint(rPoint)) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (mpChildrenShapes) xAccessible = mpChildrenShapes->GetAt(rPoint); if(!xAccessible.is()) @@ -1656,7 +1611,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleDocument::getAccessibleAtPoin void SAL_CALL ScAccessibleDocument::grabFocus( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (!getAccessibleParent().is()) return; @@ -1681,7 +1636,7 @@ sal_Int64 SAL_CALL ScAccessibleDocument::getAccessibleChildCount() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); sal_Int64 nCount(1); if (mpChildrenShapes) nCount = mpChildrenShapes->GetCount(); // returns the count of the shapes inclusive the table @@ -1697,7 +1652,7 @@ uno::Reference<XAccessible> SAL_CALL ScAccessibleDocument::getAccessibleChild(sal_Int64 nIndex) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); uno::Reference<XAccessible> xAccessible; if (nIndex >= 0) { @@ -1788,7 +1743,7 @@ void SAL_CALL ScAccessibleDocument::selectAccessibleChild( sal_Int64 nChildIndex ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (!(mpChildrenShapes && mpViewShell)) return; @@ -1817,7 +1772,7 @@ sal_Bool SAL_CALL ScAccessibleDocument::isAccessibleChildSelected( sal_Int64 nChildIndex ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); bool bResult(false); if (mpChildrenShapes) @@ -1849,7 +1804,7 @@ void SAL_CALL ScAccessibleDocument::clearAccessibleSelection( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (mpChildrenShapes) mpChildrenShapes->DeselectAll(); //deselects all (also the table) @@ -1859,7 +1814,7 @@ void SAL_CALL ScAccessibleDocument::selectAllAccessibleChildren( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (mpChildrenShapes) mpChildrenShapes->SelectAll(); @@ -1875,7 +1830,7 @@ sal_Int64 SAL_CALL ScAccessibleDocument::getSelectedAccessibleChildCount( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); sal_Int64 nCount(0); if (mpChildrenShapes) @@ -1894,7 +1849,7 @@ uno::Reference<XAccessible > SAL_CALL ScAccessibleDocument::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); uno::Reference<XAccessible> xAccessible; if (mpChildrenShapes) { @@ -1921,7 +1876,7 @@ void SAL_CALL ScAccessibleDocument::deselectAccessibleChild( sal_Int64 nChildIndex ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (!(mpChildrenShapes && mpViewShell)) return; @@ -1997,14 +1952,14 @@ tools::Rectangle ScAccessibleDocument::GetVisibleArea_Impl() const tools::Rectangle ScAccessibleDocument::GetVisibleArea() const { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); return maVisArea; } Point ScAccessibleDocument::LogicToPixel (const Point& rPoint) const { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); Point aPoint; ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos)); if (pWin) @@ -2018,7 +1973,7 @@ Point ScAccessibleDocument::LogicToPixel (const Point& rPoint) const Size ScAccessibleDocument::LogicToPixel (const Size& rSize) const { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); Size aSize; ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos)); if (pWin) @@ -2046,7 +2001,7 @@ OUString ScAccessibleDocument::createAccessibleName() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); OUString sName = ScResId(STR_ACC_DOC_NAME); sal_Int32 nNumber(sal_Int32(meSplitPos) + 1); sName += OUString::number(nNumber); @@ -2135,12 +2090,8 @@ void ScAccessibleDocument::AddChild(const uno::Reference<XAccessible>& xAcc, boo mxTempAcc = xAcc; if( bFireEvent ) { - AccessibleEventObject aEvent; - aEvent.Source = uno::Reference<XAccessibleContext>(this); - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.NewValue <<= mxTempAcc; - aEvent.IndexHint = getAccessibleChildCount() - 1; - CommitChange( aEvent ); + CommitChange(AccessibleEventId::CHILD, uno::Any(), uno::Any(mxTempAcc), + getAccessibleChildCount() - 1); } } } @@ -2153,14 +2104,7 @@ void ScAccessibleDocument::RemoveChild(const uno::Reference<XAccessible>& xAcc, OSL_ENSURE(xAcc.get() == mxTempAcc.get(), "only the same object should be removed"); if( bFireEvent ) - { - AccessibleEventObject aEvent; - aEvent.Source = uno::Reference<XAccessibleContext>(this); - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.OldValue <<= mxTempAcc; - aEvent.IndexHint = -1; - CommitChange( aEvent ); - } + CommitChange(AccessibleEventId::CHILD, uno::Any(mxTempAcc), uno::Any()); mxTempAcc = nullptr; } @@ -2191,23 +2135,20 @@ ScAddress ScAccessibleDocument::GetCurCellAddress() const return mpViewShell ? mpViewShell->GetViewData().GetCurPos() : ScAddress(); } -uno::Any SAL_CALL ScAccessibleDocument::getExtendedAttributes() +OUString SAL_CALL ScAccessibleDocument::getExtendedAttributes() { SolarMutexGuard g; - uno::Any anyAttribute; - sal_uInt16 sheetIndex; OUString sSheetName; sheetIndex = getVisibleTable(); if(GetDocument()==nullptr) - return anyAttribute; + return OUString(); GetDocument()->GetName(sheetIndex,sSheetName); OUString sValue = "page-name:" + sSheetName + ";page-number:" + OUString::number(sheetIndex+1) + ";total-pages:" + OUString::number(GetDocument()->GetTableCount()) + ";"; - anyAttribute <<= sValue; - return anyAttribute; + return sValue; } sal_Int32 SAL_CALL ScAccessibleDocument::getForeground( ) @@ -2218,7 +2159,7 @@ sal_Int32 SAL_CALL ScAccessibleDocument::getForeground( ) sal_Int32 SAL_CALL ScAccessibleDocument::getBackground( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); return sal_Int32(ScModule::get()->GetColorConfig().GetColorValue(::svtools::DOCCOLOR).nColor); } diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx index 5ba18208d110..5b3248ba079b 100644 --- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx @@ -87,7 +87,7 @@ struct ScAccNote class ScNotesChildren { public: - ScNotesChildren(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview* pAccDoc); + ScNotesChildren(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview& rAccDoc); ~ScNotesChildren(); void Init(const tools::Rectangle& rVisRect, sal_Int32 nOffset); @@ -99,7 +99,7 @@ public: private: ScPreviewShell* mpViewShell; - ScAccessibleDocumentPagePreview* mpAccDoc; + ScAccessibleDocumentPagePreview& mrAccDoc; typedef std::vector<ScAccNote> ScAccNotes; mutable ScAccNotes maNotes; mutable ScAccNotes maMarks; @@ -118,9 +118,9 @@ private: inline ScDocument* GetDocument() const; }; -ScNotesChildren::ScNotesChildren(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview* pAccDoc) +ScNotesChildren::ScNotesChildren(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview& rAccDoc) : mpViewShell(pViewShell), - mpAccDoc(pAccDoc), + mrAccDoc(rAccDoc), mnParagraphs(0), mnOffset(0) { @@ -145,7 +145,7 @@ ScNotesChildren::~ScNotesChildren() ::accessibility::AccessibleTextHelper* ScNotesChildren::CreateTextHelper(const OUString& rString, const tools::Rectangle& rVisRect, const ScAddress& aCellPos, bool bMarkNote, sal_Int32 nChildOffset) const { ::accessibility::AccessibleTextHelper* pTextHelper = new ::accessibility::AccessibleTextHelper(std::make_unique<ScAccessibilityEditSource>(std::make_unique<ScAccessibleNoteTextData>(mpViewShell, rString, aCellPos, bMarkNote))); - pTextHelper->SetEventSource(mpAccDoc); + pTextHelper->SetEventSource(&mrAccDoc); pTextHelper->SetStartIndex(nChildOffset); pTextHelper->SetOffset(rVisRect.TopLeft()); @@ -431,39 +431,23 @@ namespace { struct ScChildGone { - ScAccessibleDocumentPagePreview* mpAccDoc; - explicit ScChildGone(ScAccessibleDocumentPagePreview* pAccDoc) : mpAccDoc(pAccDoc) {} + ScAccessibleDocumentPagePreview& mrAccDoc; + explicit ScChildGone(ScAccessibleDocumentPagePreview& rAccDoc) : mrAccDoc(rAccDoc) {} void operator() (const uno::Reference<XAccessible>& xAccessible) const { - if (mpAccDoc) - { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.Source = uno::Reference< XAccessibleContext >(mpAccDoc); - aEvent.OldValue <<= xAccessible; - aEvent.IndexHint = -1; - - mpAccDoc->CommitChange(aEvent); // gone child - event - } + // gone child - event + mrAccDoc.CommitChange(AccessibleEventId::CHILD, uno::Any(xAccessible), uno::Any()); } }; struct ScChildNew { - ScAccessibleDocumentPagePreview* mpAccDoc; - explicit ScChildNew(ScAccessibleDocumentPagePreview* pAccDoc) : mpAccDoc(pAccDoc) {} + ScAccessibleDocumentPagePreview& mrAccDoc; + explicit ScChildNew(ScAccessibleDocumentPagePreview& rAccDoc) : mrAccDoc(rAccDoc) {} void operator() (const uno::Reference<XAccessible>& xAccessible) const { - if (mpAccDoc) - { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.Source = uno::Reference< XAccessibleContext >(mpAccDoc); - aEvent.NewValue <<= xAccessible; - aEvent.IndexHint = -1; - - mpAccDoc->CommitChange(aEvent); // new child - event - } + // new child - event + mrAccDoc.CommitChange(AccessibleEventId::CHILD, uno::Any(), uno::Any(xAccessible)); } }; @@ -471,7 +455,7 @@ struct ScChildNew void ScNotesChildren::DataChanged(const tools::Rectangle& rVisRect) { - if (!(mpViewShell && mpAccDoc)) + if (!mpViewShell) return; ScXAccVector aNewParas; @@ -487,8 +471,8 @@ void ScNotesChildren::DataChanged(const tools::Rectangle& rVisRect) maNotes = std::move(aNewNotes); } - std::for_each(aOldParas.begin(), aOldParas.end(), ScChildGone(mpAccDoc)); - std::for_each(aNewParas.begin(), aNewParas.end(), ScChildNew(mpAccDoc)); + std::for_each(aOldParas.begin(), aOldParas.end(), ScChildGone(mrAccDoc)); + std::for_each(aNewParas.begin(), aNewParas.end(), ScChildNew(mrAccDoc)); } inline ScDocument* ScNotesChildren::GetDocument() const @@ -721,46 +705,26 @@ void ScShapeChildren::FindChanged(ScShapeChildVec& rOld, ScShapeChildVec& rNew) else if (aNewItr->mxShape.get() < aOldItr->mxShape.get()) { xAcc = GetAccShape(*aNewItr); - AccessibleEventObject aEvent; - aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc); - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.NewValue <<= xAcc; - aEvent.IndexHint = -1; - mpAccDoc->CommitChange(aEvent); + mpAccDoc->CommitChange(AccessibleEventId::CHILD, uno::Any(), uno::Any(xAcc)); ++aNewItr; } else { xAcc = GetAccShape(*aOldItr); - AccessibleEventObject aEvent; - aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc); - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.OldValue <<= xAcc; - aEvent.IndexHint = -1; - mpAccDoc->CommitChange(aEvent); + mpAccDoc->CommitChange(AccessibleEventId::CHILD, uno::Any(xAcc), uno::Any()); ++aOldItr; } } while (aOldItr != aOldEnd) { xAcc = GetAccShape(*aOldItr); - AccessibleEventObject aEvent; - aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc); - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.OldValue <<= xAcc; - aEvent.IndexHint = -1; - mpAccDoc->CommitChange(aEvent); + mpAccDoc->CommitChange(AccessibleEventId::CHILD, uno::Any(xAcc), uno::Any()); ++aOldItr; } while (aNewItr != aNewEnd) { xAcc = GetAccShape(*aNewItr); - AccessibleEventObject aEvent; - aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc); - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.NewValue <<= xAcc; - aEvent.IndexHint = -1; - mpAccDoc->CommitChange(aEvent); + mpAccDoc->CommitChange(AccessibleEventId::CHILD, uno::Any(), uno::Any(xAcc)); ++aNewItr; } } @@ -1161,7 +1125,7 @@ ScAccessibleDocumentPagePreview::~ScAccessibleDocumentPagePreview() { if (!ScAccessibleDocumentBase::IsDefunc() && !rBHelper.bInDispose) { - // increment refcount to prevent double call off dtor + // increment refcount to prevent double call of dtor osl_atomic_increment( &m_refCount ); // call dispose to inform object which have a weak reference to this object dispose(); @@ -1171,9 +1135,21 @@ ScAccessibleDocumentPagePreview::~ScAccessibleDocumentPagePreview() void SAL_CALL ScAccessibleDocumentPagePreview::disposing() { SolarMutexGuard aGuard; - mpTable.clear(); - mpHeader.clear(); - mpFooter.clear(); + if (mpTable.is()) + { + mpTable->dispose(); + mpTable.clear(); + } + if (mpHeader) + { + mpHeader->dispose(); + mpHeader.clear(); + } + if (mpFooter) + { + mpFooter->dispose(); + mpFooter.clear(); + } if (mpViewShell) { @@ -1215,15 +1191,8 @@ void ScAccessibleDocumentPagePreview::Notify( SfxBroadcaster& rBC, const SfxHint // only notify if child exist, otherwise it is not necessary if (mpTable.is()) // if there is no table there is nothing to notify, because no one recognizes the change { - { - uno::Reference<XAccessible> xAcc = mpTable; - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - aEvent.OldValue <<= xAcc; - aEvent.IndexHint = -1; - CommitChange(aEvent); - } + CommitChange(AccessibleEventId::CHILD, uno::Any(uno::Reference<XAccessible>(mpTable)), + uno::Any()); mpTable->dispose(); mpTable.clear(); @@ -1249,15 +1218,8 @@ void ScAccessibleDocumentPagePreview::Notify( SfxBroadcaster& rBC, const SfxHint mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex ); mpTable->Init(); - { - uno::Reference<XAccessible> xAcc = mpTable; - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - aEvent.NewValue <<= xAcc; - aEvent.IndexHint = -1; - CommitChange(aEvent); - } + CommitChange(AccessibleEventId::CHILD, uno::Any(), + uno::Any(uno::Reference<XAccessible>(mpTable))); } } else if (rHint.GetId() == SfxHintId::ScAccVisAreaChanged) @@ -1271,10 +1233,7 @@ void ScAccessibleDocumentPagePreview::Notify( SfxBroadcaster& rBC, const SfxHint GetShapeChildren()->VisAreaChanged(); - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - CommitChange(aEvent); + CommitChange(AccessibleEventId::VISIBLE_DATA_CHANGED, uno::Any(), uno::Any()); } ScAccessibleDocumentBase::Notify(rBC, rHint); } @@ -1287,7 +1246,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleDocumentPagePreview::getAcces if (containsPoint(rPoint)) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if ( mpViewShell ) { @@ -1347,7 +1306,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleDocumentPagePreview::getAcces void SAL_CALL ScAccessibleDocumentPagePreview::grabFocus() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (getAccessibleParent().is()) { uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY); @@ -1364,7 +1323,7 @@ void SAL_CALL ScAccessibleDocumentPagePreview::grabFocus() sal_Int64 SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleChildCount() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); sal_Int64 nRet = 0; if ( mpViewShell ) @@ -1379,7 +1338,7 @@ sal_Int64 SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleChildCount() uno::Reference<XAccessible> SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleChild(sal_Int64 nIndex) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); uno::Reference<XAccessible> xAccessible; if ( mpViewShell ) @@ -1531,7 +1490,7 @@ ScNotesChildren* ScAccessibleDocumentPagePreview::GetNotesChildren() { if (!mpNotesChildren && mpViewShell) { - mpNotesChildren.reset( new ScNotesChildren(mpViewShell, this) ); + mpNotesChildren.reset(new ScNotesChildren(mpViewShell, *this)); const ScPreviewLocationData& rData = mpViewShell->GetLocationData(); ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChildren(), GetShapeChildren() ); diff --git a/sc/source/ui/Accessibility/AccessibleEditObject.cxx b/sc/source/ui/Accessibility/AccessibleEditObject.cxx index d903b9d43218..cccae7991bf8 100644 --- a/sc/source/ui/Accessibility/AccessibleEditObject.cxx +++ b/sc/source/ui/Accessibility/AccessibleEditObject.cxx @@ -109,7 +109,7 @@ ScAccessibleEditObject::~ScAccessibleEditObject() { if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose) { - // increment refcount to prevent double call off dtor + // increment refcount to prevent double call of dtor osl_atomic_increment( &m_refCount ); // call dispose to inform object which have a weak reference to this object dispose(); @@ -173,7 +173,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleEditObject::getAccessibleAtPo if (containsPoint(rPoint)) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); CreateTextHelper(); @@ -248,7 +248,7 @@ sal_Int64 SAL_CALL ScAccessibleEditObject::getAccessibleChildCount() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); CreateTextHelper(); return mpTextHelper->GetChildCount(); } @@ -257,7 +257,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleEditObject::getAccessibleChild(sal_Int64 nIndex) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); CreateTextHelper(); return mpTextHelper->GetChild(nIndex); } diff --git a/sc/source/ui/Accessibility/AccessiblePageHeader.cxx b/sc/source/ui/Accessibility/AccessiblePageHeader.cxx index dab5f2f89b3c..beb373429475 100644 --- a/sc/source/ui/Accessibility/AccessiblePageHeader.cxx +++ b/sc/source/ui/Accessibility/AccessiblePageHeader.cxx @@ -64,7 +64,7 @@ ScAccessiblePageHeader::~ScAccessiblePageHeader() { if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose) { - // increment refcount to prevent double call off dtor + // increment refcount to prevent double call of dtor osl_atomic_increment( &m_refCount ); dispose(); } @@ -107,34 +107,23 @@ void ScAccessiblePageHeader::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { if (aOldAreas[i].is() && aOldAreas[i]->GetEditTextObject()) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - aEvent.OldValue <<= uno::Reference<XAccessible>(aOldAreas[i]); - aEvent.IndexHint = -1; - - CommitChange(aEvent); // child gone - event + // child gone - event + CommitChange(AccessibleEventId::CHILD, + uno::Any(uno::Reference<XAccessible>(aOldAreas[i])), uno::Any()); aOldAreas[i]->dispose(); } if (maAreas[i].is() && maAreas[i]->GetEditTextObject()) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - aEvent.NewValue <<= uno::Reference<XAccessible>(maAreas[i]); - aEvent.IndexHint = -1; - - CommitChange(aEvent); // new child - event + // new child - event + CommitChange(AccessibleEventId::CHILD, uno::Any(), + uno::Any(uno::Reference<XAccessible>(maAreas[i]))); } } } } else if (rHint.GetId() == SfxHintId::ScAccVisAreaChanged) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - CommitChange(aEvent); + CommitChange(AccessibleEventId::VISIBLE_DATA_CHANGED, uno::Any(), uno::Any()); } ScAccessibleContextBase::Notify(rBC, rHint); @@ -149,7 +138,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessiblePageHeader::getAccessibleAtPo if (containsPoint(aPoint)) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); sal_Int64 nCount(getAccessibleChildCount()); // fill the areas @@ -173,7 +162,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessiblePageHeader::getAccessibleAtPo void SAL_CALL ScAccessiblePageHeader::grabFocus() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (getAccessibleParent().is()) { uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY); @@ -187,7 +176,7 @@ void SAL_CALL ScAccessiblePageHeader::grabFocus() sal_Int64 SAL_CALL ScAccessiblePageHeader::getAccessibleChildCount() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if((mnChildCount < 0) && mpViewShell) { @@ -217,7 +206,7 @@ sal_Int64 SAL_CALL ScAccessiblePageHeader::getAccessibleChildCount() uno::Reference< XAccessible > SAL_CALL ScAccessiblePageHeader::getAccessibleChild( sal_Int64 nIndex ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); uno::Reference<XAccessible> xRet; diff --git a/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx b/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx index 4881e2a8ce60..c807a01661dd 100644 --- a/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx +++ b/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx @@ -60,7 +60,7 @@ ScAccessiblePageHeaderArea::~ScAccessiblePageHeaderArea() { if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose) { - // increment refcount to prevent double call off dtor + // increment refcount to prevent double call of dtor osl_atomic_increment( &m_refCount ); dispose(); } @@ -89,10 +89,7 @@ void ScAccessiblePageHeaderArea::Notify( SfxBroadcaster& rBC, const SfxHint& rHi if (mpTextHelper) mpTextHelper->UpdateChildren(); - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - CommitChange(aEvent); + CommitChange(AccessibleEventId::VISIBLE_DATA_CHANGED, uno::Any(), uno::Any()); } ScAccessibleContextBase::Notify(rBC, rHint); } @@ -105,7 +102,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessiblePageHeaderArea::getAccessible if (containsPoint(rPoint)) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if(!mpTextHelper) CreateTextHelper(); @@ -122,7 +119,7 @@ sal_Int64 SAL_CALL ScAccessiblePageHeaderArea::getAccessibleChildCount() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (!mpTextHelper) CreateTextHelper(); return mpTextHelper->GetChildCount(); @@ -132,7 +129,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessiblePageHeaderArea::getAccessibleChild(sal_Int64 nIndex) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (!mpTextHelper) CreateTextHelper(); return mpTextHelper->GetChild(nIndex); diff --git a/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx b/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx index c0aefc808cc8..469ecab7ca85 100644 --- a/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx +++ b/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx @@ -55,7 +55,7 @@ ScAccessiblePreviewCell::~ScAccessiblePreviewCell() { if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose) { - // increment refcount to prevent double call off dtor + // increment refcount to prevent double call of dtor osl_atomic_increment( &m_refCount ); // call dispose to inform object which have a weak reference to this object dispose(); @@ -95,7 +95,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewCell::getAccessibleAtP if (containsPoint(rPoint)) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if(!mpTextHelper) CreateTextHelper(); @@ -109,7 +109,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewCell::getAccessibleAtP void SAL_CALL ScAccessiblePreviewCell::grabFocus() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (getAccessibleParent().is()) { uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY); @@ -123,7 +123,7 @@ void SAL_CALL ScAccessiblePreviewCell::grabFocus() sal_Int64 SAL_CALL ScAccessiblePreviewCell::getAccessibleChildCount() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (!mpTextHelper) CreateTextHelper(); return mpTextHelper->GetChildCount(); @@ -132,7 +132,7 @@ sal_Int64 SAL_CALL ScAccessiblePreviewCell::getAccessibleChildCount() uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewCell::getAccessibleChild(sal_Int64 nIndex) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (!mpTextHelper) CreateTextHelper(); return mpTextHelper->GetChild(nIndex); diff --git a/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx b/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx index 670d45ff0cb9..843e61f611e1 100644 --- a/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx +++ b/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx @@ -131,7 +131,7 @@ void SAL_CALL ScAccessiblePreviewHeaderCell::release() uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::getCurrentValue() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); double fValue(0.0); if (mbColumnHeader) @@ -151,7 +151,7 @@ sal_Bool SAL_CALL ScAccessiblePreviewHeaderCell::setCurrentValue( const uno::Any uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::getMaximumValue() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); double fValue(0.0); ScDocument& rDoc = mpViewShell->GetDocument(); @@ -181,7 +181,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewHeaderCell::getAccessi if (containsPoint(rPoint)) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if(!mxTextHelper) CreateTextHelper(); @@ -195,7 +195,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewHeaderCell::getAccessi void SAL_CALL ScAccessiblePreviewHeaderCell::grabFocus() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (getAccessibleParent().is()) { uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY); @@ -209,7 +209,7 @@ void SAL_CALL ScAccessiblePreviewHeaderCell::grabFocus() sal_Int64 SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleChildCount() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (!mxTextHelper) CreateTextHelper(); return mxTextHelper->GetChildCount(); @@ -218,7 +218,7 @@ sal_Int64 SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleChildCount() uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleChild(sal_Int64 nIndex) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (!mxTextHelper) CreateTextHelper(); return mxTextHelper->GetChild(nIndex); diff --git a/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx b/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx index 5dfc06ca063b..f1c788646736 100644 --- a/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx +++ b/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx @@ -58,7 +58,7 @@ ScAccessiblePreviewTable::~ScAccessiblePreviewTable() { if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose) { - // increment refcount to prevent double call off dtor + // increment refcount to prevent double call of dtor osl_atomic_increment( &m_refCount ); dispose(); } @@ -91,10 +91,7 @@ void ScAccessiblePreviewTable::Notify( SfxBroadcaster& rBC, const SfxHint& rHint } else if (nId == SfxHintId::ScAccVisAreaChanged) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - CommitChange(aEvent); + CommitChange(AccessibleEventId::VISIBLE_DATA_CHANGED, uno::Any(), uno::Any()); } ScAccessibleContextBase::Notify(rBC, rHint); @@ -125,7 +122,7 @@ void SAL_CALL ScAccessiblePreviewTable::release() sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRowCount() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); FillTableInfo(); @@ -138,7 +135,7 @@ sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRowCount() sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnCount() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); FillTableInfo(); @@ -171,7 +168,7 @@ OUString SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnDescription( sal_ sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); FillTableInfo(); @@ -202,7 +199,7 @@ sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRowExtentAt( sal_Int32 sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); FillTableInfo(); @@ -281,7 +278,7 @@ sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleColumnSelected( sal_Int3 uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); FillTableInfo(); @@ -334,7 +331,7 @@ sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleSelected( sal_Int32 nRow { // in the page preview, there is no selection SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); FillTableInfo(); @@ -348,7 +345,7 @@ sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleSelected( sal_Int32 nRow sal_Int64 SAL_CALL ScAccessiblePreviewTable::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); FillTableInfo(); @@ -363,7 +360,7 @@ sal_Int64 SAL_CALL ScAccessiblePreviewTable::getAccessibleIndex( sal_Int32 nRow, sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRow( sal_Int64 nChildIndex ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); FillTableInfo(); @@ -377,7 +374,7 @@ sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRow( sal_Int64 nChildI sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumn( sal_Int64 nChildIndex ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); FillTableInfo(); @@ -392,56 +389,55 @@ sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumn( sal_Int64 nChi uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleAtPoint( const awt::Point& aPoint ) { - uno::Reference<XAccessible> xRet; - if (containsPoint(aPoint)) - { - SolarMutexGuard aGuard; - IsObjectValid(); + if (!containsPoint(aPoint)) + return nullptr; - FillTableInfo(); + SolarMutexGuard aGuard; + ensureAlive(); - if ( mpTableInfo ) - { - SCCOL nCols = mpTableInfo->GetCols(); - SCROW nRows = mpTableInfo->GetRows(); - const ScPreviewColRowInfo* pColInfo = mpTableInfo->GetColInfo(); - const ScPreviewColRowInfo* pRowInfo = mpTableInfo->GetRowInfo(); + FillTableInfo(); - tools::Rectangle aScreenRect(GetBoundingBox()); + if (!mpTableInfo) + return nullptr; - awt::Point aMovedPoint = aPoint; - aMovedPoint.X += aScreenRect.Left(); - aMovedPoint.Y += aScreenRect.Top(); + SCCOL nCols = mpTableInfo->GetCols(); + SCROW nRows = mpTableInfo->GetRows(); + const ScPreviewColRowInfo* pColInfo = mpTableInfo->GetColInfo(); + const ScPreviewColRowInfo* pRowInfo = mpTableInfo->GetRowInfo(); - if ( nCols > 0 && nRows > 0 && aMovedPoint.X >= pColInfo[0].nPixelStart && aMovedPoint.Y >= pRowInfo[0].nPixelStart ) + tools::Rectangle aScreenRect(GetBoundingBox()); + + awt::Point aMovedPoint = aPoint; + aMovedPoint.X += aScreenRect.Left(); + aMovedPoint.Y += aScreenRect.Top(); + + if ( nCols > 0 && nRows > 0 && aMovedPoint.X >= pColInfo[0].nPixelStart && aMovedPoint.Y >= pRowInfo[0].nPixelStart ) + { + SCCOL nColIndex = 0; + while ( nColIndex < nCols && aMovedPoint.X > pColInfo[nColIndex].nPixelEnd ) + ++nColIndex; + SCROW nRowIndex = 0; + while ( nRowIndex < nRows && aMovedPoint.Y > pRowInfo[nRowIndex].nPixelEnd ) + ++nRowIndex; + if ( nColIndex < nCols && nRowIndex < nRows ) + { + try + { + return getAccessibleCellAt( nRowIndex, nColIndex ); + } + catch (uno::Exception&) { - SCCOL nColIndex = 0; - while ( nColIndex < nCols && aMovedPoint.X > pColInfo[nColIndex].nPixelEnd ) - ++nColIndex; - SCROW nRowIndex = 0; - while ( nRowIndex < nRows && aMovedPoint.Y > pRowInfo[nRowIndex].nPixelEnd ) - ++nRowIndex; - if ( nColIndex < nCols && nRowIndex < nRows ) - { - try - { - xRet = getAccessibleCellAt( nRowIndex, nColIndex ); - } - catch (uno::Exception&) - { - } - } } } } - return xRet; + return nullptr; } void SAL_CALL ScAccessiblePreviewTable::grabFocus() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (getAccessibleParent().is()) { uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY); @@ -455,7 +451,7 @@ void SAL_CALL ScAccessiblePreviewTable::grabFocus() sal_Int64 SAL_CALL ScAccessiblePreviewTable::getAccessibleChildCount() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); FillTableInfo(); @@ -468,7 +464,7 @@ sal_Int64 SAL_CALL ScAccessiblePreviewTable::getAccessibleChildCount() uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleChild( sal_Int64 nIndex ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); FillTableInfo(); diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx index 0bad15e85566..b3198242eaf1 100644 --- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx +++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx @@ -329,35 +329,26 @@ void ScAccessibleSpreadsheet::CompleteSelectionChanged(bool bNewState) } mpMarkedRanges.reset(); - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::STATE_CHANGED; + uno::Any aOldValue; + uno::Any aNewValue; if (bNewState) - aEvent.NewValue <<= AccessibleStateType::SELECTED; + aNewValue <<= AccessibleStateType::SELECTED; else - aEvent.OldValue <<= AccessibleStateType::SELECTED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - - CommitChange(aEvent); + aOldValue <<= AccessibleStateType::SELECTED; + CommitChange(AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue); } void ScAccessibleSpreadsheet::LostFocus() { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - aEvent.OldValue <<= uno::Reference<XAccessible>(mpAccCell); - - CommitChange(aEvent); - + CommitChange(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, + uno::Any(uno::Reference<XAccessible>(mpAccCell)), uno::Any()); CommitFocusLost(); } void ScAccessibleSpreadsheet::GotFocus() { CommitFocusGained(); - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); + uno::Reference< XAccessible > xNew; if (IsFormulaMode()) { @@ -384,27 +375,18 @@ void ScAccessibleSpreadsheet::GotFocus() return ; } } - aEvent.NewValue <<= xNew; - CommitChange(aEvent); + CommitChange(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, uno::Any(), uno::Any(xNew)); } void ScAccessibleSpreadsheet::BoundingBoxChanged() { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - - CommitChange(aEvent); + CommitChange(AccessibleEventId::BOUNDRECT_CHANGED, uno::Any(), uno::Any()); } void ScAccessibleSpreadsheet::VisAreaChanged() { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - - CommitChange(aEvent); + CommitChange(AccessibleEventId::VISIBLE_DATA_CHANGED, uno::Any(), uno::Any()); } //===== SfxListener ===================================================== @@ -477,13 +459,8 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint } CommitTableModelChange(nFirstRow, nFirstCol, nLastRow, nLastCol, nId); - - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - aEvent.NewValue <<= uno::Reference<XAccessible>(mpAccCell); - - CommitChange(aEvent); + CommitChange(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, uno::Any(), + uno::Any(uno::Reference<XAccessible>(mpAccCell))); } } } @@ -511,18 +488,16 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint } m_bFormulaLastMode = m_bFormulaMode; - AccessibleEventObject aEvent; - aEvent.Source = uno::Reference< XAccessible >(this); ScAddress aNewCell = rViewData.GetCurPos(); if(aNewCell.Tab() != maActiveCell.Tab()) { - aEvent.EventId = AccessibleEventId::PAGE_CHANGED; auto pAccParent = getAccessibleParent(); ScAccessibleDocument *pAccDoc = static_cast<ScAccessibleDocument*>(pAccParent.get()); if(pAccDoc) { - pAccDoc->CommitChange(aEvent); + pAccDoc->CommitChange(AccessibleEventId::PAGE_CHANGED, uno::Any(), + uno::Any()); } } bool bNewPosCell = (aNewCell != maActiveCell) || mpViewShell->GetForceFocusOnCurCell(); // #i123629# @@ -540,16 +515,14 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint // sal_Bool bNewCellSelected = isAccessibleSelected(aNewCell.Row(), aNewCell.Col()); sal_uInt16 nTab = rViewData.GetTabNo(); const ScRange& aMarkRange = refScMarkData.GetMarkArea(); - aEvent.OldValue.clear(); ScDocument* pDoc= GetDocument(mpViewShell); //Mark All if ( !bNewPosCellFocus && (bNewMarked || bIsMark || bIsMultMark ) && aMarkRange == ScRange( 0,0,nTab, pDoc->MaxCol(),pDoc->MaxRow(),nTab ) ) { - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; - aEvent.NewValue.clear(); - CommitChange(aEvent); + CommitChange(AccessibleEventId::SELECTION_CHANGED_WITHIN, uno::Any(), + uno::Any()); return ; } if (!mpMarkedRanges) @@ -578,11 +551,8 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint !aMarkRange.Contains(m_aLastWithInMarkRange) && aMarkRange.Intersects(m_aLastWithInMarkRange); if( !bSelSmaller ) - { - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; - aEvent.NewValue.clear(); - CommitChange(aEvent); - } + CommitChange(AccessibleEventId::SELECTION_CHANGED_WITHIN, uno::Any(), + uno::Any()); m_aLastWithInMarkRange = aMarkRange; } return ; @@ -597,25 +567,22 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint { CommitFocusCell(aNewCell); } - uno::Reference< XAccessible > xChild ; + rtl::Reference< ScAccessibleCell > xChild ; if (bNewPosCellFocus) { - xChild = mpAccCell.get(); + xChild = mpAccCell; } else { mpAccCell = GetAccessibleCellAt(aNewCell.Row(),aNewCell.Col()); - xChild = mpAccCell.get(); + xChild = mpAccCell; maActiveCell = aNewCell; - aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS; - aEvent.NewValue <<= xChild; - aEvent.OldValue <<= uno::Reference< XAccessible >(); - CommitChange(aEvent); + CommitChange(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS, + uno::Any(), uno::Any(uno::Reference<XAccessible>(xChild))); } - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; - aEvent.NewValue <<= xChild; - CommitChange(aEvent); + CommitChange(AccessibleEventId::SELECTION_CHANGED, uno::Any(), + uno::Any(uno::Reference<XAccessible>(xChild))); OSL_ASSERT(m_mapSelectionSend.count(aNewCell) == 0 ); m_mapSelectionSend.emplace(aNewCell,xChild); @@ -637,24 +604,22 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint std::vector<ScMyAddress> vecNew; if(CalcScRangeListDifferenceMax(mpMarkedRanges.get(), &m_LastMarkedRanges,10,vecNew)) { - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; - aEvent.NewValue.clear(); - CommitChange(aEvent); + CommitChange(AccessibleEventId::SELECTION_CHANGED_WITHIN, uno::Any(), + uno::Any()); } else { for(const auto& rAddr : vecNew) { - uno::Reference< XAccessible > xChild = getAccessibleCellAt(rAddr.Row(),rAddr.Col()); + rtl::Reference< ScAccessibleCell > xChild = GetAccessibleCellAt(rAddr.Row(),rAddr.Col()); if (!(bNewPosCellFocus && rAddr == aNewCell) ) { - aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS; - aEvent.NewValue <<= xChild; - CommitChange(aEvent); + CommitChange( + AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS, + uno::Any(), uno::Any(uno::Reference<XAccessible>(xChild))); } - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD; - aEvent.NewValue <<= xChild; - CommitChange(aEvent); + CommitChange(AccessibleEventId::SELECTION_CHANGED_ADD, uno::Any(), + uno::Any(uno::Reference<XAccessible>(xChild))); m_mapSelectionSend.emplace(rAddr,xChild); } } @@ -685,18 +650,17 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint OUString valStr(pScDoc->GetString(aNewCell.Col(),aNewCell.Row(),aNewCell.Tab())); if(mpAccCell.is() && m_strCurCellValue != valStr) { - AccessibleEventObject aTextChangedEvent; - (void)comphelper::OCommonAccessibleText::implInitTextChangedEvent(m_strCurCellValue, valStr, - aTextChangedEvent.OldValue, - aTextChangedEvent.NewValue); - aTextChangedEvent.EventId = AccessibleEventId::TEXT_CHANGED; - mpAccCell->CommitChange(aTextChangedEvent); + uno::Any aOldValue; + uno::Any aNewValue; + (void)comphelper::OCommonAccessibleText::implInitTextChangedEvent( + m_strCurCellValue, valStr, aOldValue, aNewValue); + mpAccCell->CommitChange(AccessibleEventId::TEXT_CHANGED, aOldValue, + aNewValue); if (pScDoc->HasValueData(maActiveCell)) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::VALUE_CHANGED; - mpAccCell->CommitChange(aEvent); + mpAccCell->CommitChange(AccessibleEventId::VALUE_CHANGED, + uno::Any(), uno::Any()); } m_strCurCellValue = valStr; @@ -705,15 +669,12 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint pScDoc->GetName( maActiveCell.Tab(), tabName ); if( m_strOldTabName != tabName ) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::NAME_CHANGED; OUString sOldName(ScResId(STR_ACC_TABLE_NAME)); sOldName = sOldName.replaceFirst("%1", m_strOldTabName); - aEvent.OldValue <<= sOldName; OUString sNewName(ScResId(STR_ACC_TABLE_NAME)); sNewName = sNewName.replaceFirst("%1", tabName); - aEvent.NewValue <<= sNewName; - CommitChange( aEvent ); + CommitChange(AccessibleEventId::NAME_CHANGED, uno::Any(sOldName), + uno::Any(sNewName)); m_strOldTabName = tabName; } } @@ -745,8 +706,6 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint void ScAccessibleSpreadsheet::RemoveSelection(const ScMarkData &refScMarkData) { - AccessibleEventObject aEvent; - aEvent.Source = uno::Reference< XAccessible >(this); MAP_ADDR_XACC::iterator miRemove = m_mapSelectionSend.begin(); while (miRemove != m_mapSelectionSend.end()) { @@ -756,9 +715,8 @@ void ScAccessibleSpreadsheet::RemoveSelection(const ScMarkData &refScMarkData) ++miRemove; continue; } - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE; - aEvent.NewValue <<= miRemove->second; - CommitChange(aEvent); + CommitChange(AccessibleEventId::SELECTION_CHANGED_REMOVE, uno::Any(), + uno::Any(uno::Reference<XAccessible>(miRemove->second))); miRemove = m_mapSelectionSend.erase(miRemove); } } @@ -786,37 +744,31 @@ void ScAccessibleSpreadsheet::CommitFocusCell(const ScAddress &aNewCell) OUString valStr(pScDoc->GetString(aOldActiveCell.Col(),aOldActiveCell.Row(),aOldActiveCell.Tab())); if(m_strCurCellValue != valStr) { - AccessibleEventObject aTextChangedEvent; - (void)comphelper::OCommonAccessibleText::implInitTextChangedEvent(m_strCurCellValue, valStr, - aTextChangedEvent.OldValue, - aTextChangedEvent.NewValue); - aTextChangedEvent.EventId = AccessibleEventId::TEXT_CHANGED; - mpAccCell->CommitChange(aTextChangedEvent); + uno::Any aOldValue; + uno::Any aNewValue; + (void)comphelper::OCommonAccessibleText::implInitTextChangedEvent( + m_strCurCellValue, valStr, aOldValue, aNewValue); + mpAccCell->CommitChange(AccessibleEventId::TEXT_CHANGED, aOldValue, aNewValue); if (pScDoc->HasValueData(maActiveCell)) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::VALUE_CHANGED; - mpAccCell->CommitChange(aEvent); + mpAccCell->CommitChange(AccessibleEventId::VALUE_CHANGED, uno::Any(), uno::Any()); } m_strCurCellValue = valStr; } } - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; - aEvent.Source = uno::Reference< XAccessible >(this); - aEvent.OldValue <<= uno::Reference<XAccessible>(mpAccCell); + uno::Reference<XAccessible> xOldCell = mpAccCell; mpAccCell.clear(); mpAccCell = GetAccessibleCellAt(aNewCell.Row(), aNewCell.Col()); - aEvent.NewValue <<= uno::Reference<XAccessible>(mpAccCell); maActiveCell = aNewCell; if (pScDoc) { m_strCurCellValue = pScDoc->GetString(maActiveCell.Col(),maActiveCell.Row(),maActiveCell.Tab()); } - CommitChange(aEvent); + CommitChange(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, uno::Any(xOldCell), + uno::Any(uno::Reference<XAccessible>(mpAccCell))); } //===== XAccessibleTable ================================================ @@ -824,7 +776,7 @@ void ScAccessibleSpreadsheet::CommitFocusCell(const ScAddress &aNewCell) uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleSpreadsheet::getAccessibleRowHeaders( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); uno::Reference< XAccessibleTable > xAccessibleTable; if( mpDoc && mbIsSpreadsheet ) { @@ -843,7 +795,7 @@ uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleSpreadsheet::getAccessib uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleSpreadsheet::getAccessibleColumnHeaders( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); uno::Reference< XAccessibleTable > xAccessibleTable; if( mpDoc && mbIsSpreadsheet ) { @@ -862,7 +814,7 @@ uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleSpreadsheet::getAccessib uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleSpreadsheet::getSelectedAccessibleRows( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); uno::Sequence<sal_Int32> aSequence; if (IsFormulaMode()) { @@ -892,7 +844,7 @@ uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleSpreadsheet::getSelectedAccessib uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleSpreadsheet::getSelectedAccessibleColumns( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); uno::Sequence<sal_Int32> aSequence; if (IsFormulaMode() || !mpViewShell) return aSequence; @@ -916,7 +868,7 @@ uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleSpreadsheet::getSelectedAccessib sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleRowSelected( sal_Int32 nRow ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (IsFormulaMode()) { return false; @@ -937,7 +889,7 @@ sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleRowSelected( sal_Int32 nR sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleColumnSelected( sal_Int32 nColumn ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (IsFormulaMode()) { @@ -1003,7 +955,7 @@ rtl::Reference<ScAccessibleCell> ScAccessibleSpreadsheet::GetAccessibleCellAt(sa uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (!IsFormulaMode()) { if (nRow > (maRange.aEnd.Row() - maRange.aStart.Row()) || @@ -1019,7 +971,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleCel sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (IsFormulaMode()) { @@ -1047,7 +999,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleAtP if (containsPoint(rPoint)) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (mpViewShell) { SCCOL nX; @@ -1083,7 +1035,7 @@ sal_Int32 SAL_CALL ScAccessibleSpreadsheet::getForeground( ) sal_Int32 SAL_CALL ScAccessibleSpreadsheet::getBackground( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); return sal_Int32(ScModule::get()->GetColorConfig().GetColorValue(::svtools::DOCCOLOR).nColor); } @@ -1138,7 +1090,7 @@ sal_Int64 SAL_CALL ScAccessibleSpreadsheet::getAccessibleStateSet() void SAL_CALL ScAccessibleSpreadsheet::selectAccessibleChild( sal_Int64 nChildIndex ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount()) throw lang::IndexOutOfBoundsException(); @@ -1155,7 +1107,7 @@ void SAL_CALL ScAccessibleSpreadsheet::clearAccessibleSelection( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (mpViewShell && !IsFormulaMode()) mpViewShell->Unmark(); } @@ -1163,7 +1115,7 @@ void SAL_CALL void SAL_CALL ScAccessibleSpreadsheet::selectAllAccessibleChildren( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (!mpViewShell) return; @@ -1184,7 +1136,7 @@ sal_Int64 SAL_CALL ScAccessibleSpreadsheet::getSelectedAccessibleChildCount( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); sal_Int64 nResult(0); if (mpViewShell) { @@ -1211,7 +1163,7 @@ uno::Reference<XAccessible > SAL_CALL ScAccessibleSpreadsheet::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); uno::Reference < XAccessible > xAccessible; if (IsFormulaMode()) { @@ -1247,7 +1199,7 @@ uno::Reference<XAccessible > SAL_CALL void SAL_CALL ScAccessibleSpreadsheet::deselectAccessibleChild( sal_Int64 nChildIndex ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount()) throw lang::IndexOutOfBoundsException(); @@ -1364,16 +1316,6 @@ uno::Sequence<sal_Int8> SAL_CALL return css::uno::Sequence<sal_Int8>(); } -///===== XAccessibleEventBroadcaster ===================================== - -void SAL_CALL ScAccessibleSpreadsheet::addAccessibleEventListener(const uno::Reference<XAccessibleEventListener>& xListener) -{ - SolarMutexGuard aGuard; - IsObjectValid(); - ScAccessibleTableBase::addAccessibleEventListener(xListener); - -} - //==== internal ========================================================= AbsoluteScreenPixelRectangle ScAccessibleSpreadsheet::GetBoundingBoxOnScreen() const @@ -1541,11 +1483,8 @@ void ScAccessibleSpreadsheet::FireFirstCellFocus() return ; } mbIsFocusSend = true; - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; - aEvent.Source = uno::Reference< XAccessible >(this); - aEvent.NewValue <<= getAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col()); - CommitChange(aEvent); + CommitChange(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, uno::Any(), + uno::Any(getAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col()))); } void ScAccessibleSpreadsheet::NotifyRefMode() @@ -1571,19 +1510,16 @@ void ScAccessibleSpreadsheet::NotifyRefMode() m_nMinY = std::min(nRefStartY,nRefEndY); m_nMaxY = std::max(nRefStartY,nRefEndY); RemoveFormulaSelection(); - AccessibleEventObject aEvent; - aEvent.Source = uno::Reference< XAccessible >(this); - aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; - aEvent.OldValue <<= uno::Reference<XAccessible>(m_pAccFormulaCell); + uno::Reference<XAccessible> xOldFormulaCell = m_pAccFormulaCell; m_pAccFormulaCell = GetAccessibleCellAt(aFormulaAddr.Row(), aFormulaAddr.Col()); - uno::Reference< XAccessible > xNew = m_pAccFormulaCell; - aEvent.NewValue <<= xNew; - CommitChange(aEvent); + rtl::Reference< ScAccessibleCell > xNew = m_pAccFormulaCell; + CommitChange(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, uno::Any(xOldFormulaCell), + uno::Any(uno::Reference<XAccessible>(xNew))); + if (nRefStartX == nRefEndX && nRefStartY == nRefEndY) {//Selection Single - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED; - aEvent.NewValue <<= xNew; - CommitChange(aEvent); + CommitChange(AccessibleEventId::SELECTION_CHANGED, uno::Any(xOldFormulaCell), + uno::Any(uno::Reference<XAccessible>(xNew))); m_mapFormulaSelectionSend.emplace(aFormulaAddr,xNew); m_vecFormulaLastMyAddr.clear(); m_vecFormulaLastMyAddr.emplace_back(aFormulaAddr); @@ -1609,29 +1545,26 @@ void ScAccessibleSpreadsheet::NotifyRefMode() int nNewSize = vecNew.size(); if ( nNewSize > 10 ) { - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN; - aEvent.NewValue.clear(); - CommitChange(aEvent); + CommitChange(AccessibleEventId::SELECTION_CHANGED_WITHIN, uno::Any(), uno::Any()); } else { for(const auto& rAddr : vecNew) { - uno::Reference< XAccessible > xChild; + rtl::Reference< ScAccessibleCell > xChild; if (rAddr == aFormulaAddr) { - xChild = m_pAccFormulaCell.get(); + xChild = m_pAccFormulaCell; } else { - xChild = getAccessibleCellAt(rAddr.Row(),rAddr.Col()); - aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS; - aEvent.NewValue <<= xChild; - CommitChange(aEvent); + xChild = GetAccessibleCellAt(rAddr.Row(),rAddr.Col()); + CommitChange(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS, + uno::Any(xOldFormulaCell), + uno::Any(uno::Reference<XAccessible>(xChild))); } - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD; - aEvent.NewValue <<= xChild; - CommitChange(aEvent); + CommitChange(AccessibleEventId::SELECTION_CHANGED_ADD, uno::Any(), + uno::Any(uno::Reference<XAccessible>(xChild))); m_mapFormulaSelectionSend.emplace(rAddr,xChild); } } @@ -1643,9 +1576,7 @@ void ScAccessibleSpreadsheet::NotifyRefMode() void ScAccessibleSpreadsheet::RemoveFormulaSelection(bool bRemoveAll ) { - AccessibleEventObject aEvent; - aEvent.Source = uno::Reference< XAccessible >(this); - MAP_ADDR_XACC::iterator miRemove = m_mapFormulaSelectionSend.begin(); + auto miRemove = m_mapFormulaSelectionSend.begin(); while (miRemove != m_mapFormulaSelectionSend.end()) { if( !bRemoveAll && IsScAddrFormulaSel(miRemove->first) ) @@ -1653,9 +1584,8 @@ void ScAccessibleSpreadsheet::RemoveFormulaSelection(bool bRemoveAll ) ++miRemove; continue; } - aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE; - aEvent.NewValue <<= miRemove->second; - CommitChange(aEvent); + CommitChange(AccessibleEventId::SELECTION_CHANGED_REMOVE, uno::Any(), + uno::Any(uno::Reference<XAccessible>(miRemove->second))); miRemove = m_mapFormulaSelectionSend.erase(miRemove); } } diff --git a/sc/source/ui/Accessibility/AccessibleTableBase.cxx b/sc/source/ui/Accessibility/AccessibleTableBase.cxx index 993370ccc5a8..6ad24f61a706 100644 --- a/sc/source/ui/Accessibility/AccessibleTableBase.cxx +++ b/sc/source/ui/Accessibility/AccessibleTableBase.cxx @@ -91,14 +91,14 @@ void SAL_CALL ScAccessibleTableBase::release() sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleRowCount( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); return maRange.aEnd.Row() - maRange.aStart.Row() + 1; } sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleColumnCount( ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); return maRange.aEnd.Col() - maRange.aStart.Col() + 1; } @@ -127,7 +127,7 @@ OUString SAL_CALL ScAccessibleTableBase::getAccessibleColumnDescription( sal_Int sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0) || (nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0)) @@ -160,7 +160,7 @@ sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleRowExtentAt( sal_Int32 nR sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0) || (nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0)) @@ -266,7 +266,7 @@ sal_Bool SAL_CALL ScAccessibleTableBase::isAccessibleSelected( sal_Int32 /* nRow sal_Int64 SAL_CALL ScAccessibleTableBase::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (nRow > (maRange.aEnd.Row() - maRange.aStart.Row()) || nRow < 0 || @@ -282,7 +282,7 @@ sal_Int64 SAL_CALL ScAccessibleTableBase::getAccessibleIndex( sal_Int32 nRow, sa sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleRow( sal_Int64 nChildIndex ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (nChildIndex >= getAccessibleChildCount() || nChildIndex < 0) throw lang::IndexOutOfBoundsException(); @@ -293,7 +293,7 @@ sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleRow( sal_Int64 nChildInde sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleColumn( sal_Int64 nChildIndex ) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (nChildIndex >= getAccessibleChildCount() || nChildIndex < 0) throw lang::IndexOutOfBoundsException(); @@ -306,7 +306,7 @@ sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleColumn( sal_Int64 nChildI sal_Int64 SAL_CALL ScAccessibleTableBase::getAccessibleChildCount() { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); // FIXME: representing rows & columns this way is a plain and simple madness. // this needs a radical re-think. @@ -321,7 +321,7 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleTableBase::getAccessibleChild(sal_Int64 nIndex) { SolarMutexGuard aGuard; - IsObjectValid(); + ensureAlive(); if (nIndex >= getAccessibleChildCount() || nIndex < 0) throw lang::IndexOutOfBoundsException(); @@ -355,13 +355,13 @@ OUString ScAccessibleTableBase::createAccessibleName() uno::Reference<XAccessibleRelationSet> SAL_CALL ScAccessibleTableBase::getAccessibleRelationSet() { - OSL_FAIL("should be implemented in the abrevated class"); + OSL_FAIL("should be implemented in the abbreviated class"); return uno::Reference<XAccessibleRelationSet>(); } sal_Int64 SAL_CALL ScAccessibleTableBase::getAccessibleStateSet() { - OSL_FAIL("should be implemented in the abrevated class"); + OSL_FAIL("should be implemented in the abbreviated class"); return 0; } @@ -435,12 +435,7 @@ void ScAccessibleTableBase::CommitTableModelChange(sal_Int32 nStartRow, sal_Int3 aModelChange.LastColumn = nEndCol; aModelChange.Type = nId; - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::TABLE_MODEL_CHANGED; - aEvent.Source = uno::Reference< XAccessibleContext >(this); - aEvent.NewValue <<= aModelChange; - - CommitChange(aEvent); + CommitChange(AccessibleEventId::TABLE_MODEL_CHANGED, uno::Any(), uno::Any(aModelChange)); } sal_Bool SAL_CALL ScAccessibleTableBase::selectRow( sal_Int32 ) diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx index cea5fd635b7a..3df9a2d0bcbb 100644 --- a/sc/source/ui/Accessibility/AccessibleText.cxx +++ b/sc/source/ui/Accessibility/AccessibleText.cxx @@ -1143,15 +1143,15 @@ SvxTextForwarder* ScAccessibleHeaderTextData::GetTextForwarder() pCellAttributeDefault = &pTmp->getDefaultCellAttribute(); } - auto pDefaults = std::make_unique<SfxItemSet>(pHdrEngine->GetEmptyItemSet()); - pCellAttributeDefault->FillEditItemSet(pDefaults.get()); + SfxItemSet aDefaults(pHdrEngine->GetEmptyItemSet()); + pCellAttributeDefault->FillEditItemSet(&aDefaults); // FillEditItemSet adjusts font height to 1/100th mm, // but for header/footer twips is needed, as in the PatternAttr: - pDefaults->Put( pCellAttributeDefault->GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT) ); - pDefaults->Put( pCellAttributeDefault->GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK) ); - pDefaults->Put( pCellAttributeDefault->GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL) ); - pDefaults->Put( SvxAdjustItem( meAdjust, EE_PARA_JUST ) ); - pHdrEngine->SetDefaults(std::move(pDefaults)); + aDefaults.Put( pCellAttributeDefault->GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT) ); + aDefaults.Put( pCellAttributeDefault->GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK) ); + aDefaults.Put( pCellAttributeDefault->GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL) ); + aDefaults.Put( SvxAdjustItem( meAdjust, EE_PARA_JUST ) ); + pHdrEngine->SetDefaults(std::move(aDefaults)); ScHeaderFieldData aData; if (mpViewShell) |