summaryrefslogtreecommitdiff
path: root/sc/source/ui/Accessibility
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-09-03 15:46:08 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-09-04 13:02:56 +0200
commitf2d096099a220e4caa2d532a5230785cbdb91eed (patch)
tree230bcc7ab089d2948c321c6d2df3a089f064bc0b /sc/source/ui/Accessibility
parent12f5c69ead6765dd3711db335763caf2df4e049f (diff)
use less dynamic_cast when broadcasting SfxHint in sc
Change-Id: I25ee079b5b14f82012f868ae6b348fa6982571a6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172853 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
Diffstat (limited to 'sc/source/ui/Accessibility')
-rw-r--r--sc/source/ui/Accessibility/AccessibilityHints.cxx10
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocument.cxx139
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx111
-rw-r--r--sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx3
4 files changed, 129 insertions, 134 deletions
diff --git a/sc/source/ui/Accessibility/AccessibilityHints.cxx b/sc/source/ui/Accessibility/AccessibilityHints.cxx
index 9e0ec879812e..893f45de5111 100644
--- a/sc/source/ui/Accessibility/AccessibilityHints.cxx
+++ b/sc/source/ui/Accessibility/AccessibilityHints.cxx
@@ -33,10 +33,8 @@ ScAccWinFocusGotHint::~ScAccWinFocusGotHint()
// ScAccGridWinFocusLostHint - the current grid window lost its focus (to another application, view or document)
-ScAccGridWinFocusLostHint::ScAccGridWinFocusLostHint(ScSplitPos eOld )
- :
- ScAccWinFocusLostHint(),
- eOldGridWin(eOld)
+ScAccGridWinFocusLostHint:: ScAccGridWinFocusLostHint(ScSplitPos eOld )
+ : SfxHint(SfxHintId::ScAccGridWinFocusLost), eOldGridWin(eOld)
{
}
@@ -47,9 +45,7 @@ ScAccGridWinFocusLostHint::~ScAccGridWinFocusLostHint()
// ScAccGridWinFocusGotHint - the grid window got the focus (from another application, view or document)
ScAccGridWinFocusGotHint::ScAccGridWinFocusGotHint(ScSplitPos eNew )
- :
- ScAccWinFocusGotHint(),
- eNewGridWin(eNew)
+ : SfxHint(SfxHintId::ScAccGridWinFocusGot), eNewGridWin(eNew)
{
}
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index 4ab426a2c36a..38d0665d97c7 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -1424,8 +1424,9 @@ IMPL_LINK( ScAccessibleDocument, WindowChildEventListener, VclWindowEvent&, rEve
void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
- if (auto pFocusLostHint = dynamic_cast<const ScAccGridWinFocusLostHint*>(&rHint) )
+ if (rHint.GetId() == SfxHintId::ScAccGridWinFocusLost )
{
+ auto pFocusLostHint = static_cast<const ScAccGridWinFocusLostHint*>(&rHint);
if (pFocusLostHint->GetOldGridWin() == meSplitPos)
{
if (mxTempAcc.is() && mpTempAccEdit)
@@ -1436,8 +1437,9 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
CommitFocusLost();
}
}
- else if (auto pFocusGotHint = dynamic_cast<const ScAccGridWinFocusGotHint*>(&rHint) )
+ else if (rHint.GetId() == SfxHintId::ScAccGridWinFocusGot)
{
+ auto pFocusGotHint = static_cast<const ScAccGridWinFocusGotHint*>(&rHint);
if (pFocusGotHint->GetNewGridWin() == meSplitPos)
{
uno::Reference<XAccessible> xAccessible;
@@ -1466,11 +1468,10 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
}
}
}
- else
+ else if (rHint.GetId() == SfxHintId::ScAccTableChanged)
{
// only notify if child exist, otherwise it is not necessary
- if ((rHint.GetId() == SfxHintId::ScAccTableChanged) &&
- mpAccessibleSpreadsheet.is())
+ if (mpAccessibleSpreadsheet.is())
{
FreeAccessibleSpreadsheet();
@@ -1486,86 +1487,86 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
if (mpAccessibleSpreadsheet.is())
mpAccessibleSpreadsheet->FireFirstCellFocus();
}
- else if (rHint.GetId() == SfxHintId::ScAccMakeDrawLayer)
- {
- if (mpChildrenShapes)
- mpChildrenShapes->SetDrawBroadcaster();
- }
- else if (rHint.GetId() == SfxHintId::ScAccEnterEditMode) // this event comes only on creating edit field of a cell
+ }
+ else if (rHint.GetId() == SfxHintId::ScAccMakeDrawLayer)
+ {
+ if (mpChildrenShapes)
+ mpChildrenShapes->SetDrawBroadcaster();
+ }
+ else if (rHint.GetId() == SfxHintId::ScAccEnterEditMode) // this event comes only on creating edit field of a cell
+ {
+ if (mpViewShell->GetViewData().GetEditActivePart() == meSplitPos)
{
- if (mpViewShell->GetViewData().GetEditActivePart() == meSplitPos)
+ ScViewData& rViewData = mpViewShell->GetViewData();
+ EditEngine const& rEditEng = rViewData.GetEditView(meSplitPos)->getEditEngine();
+ if (rEditEng.IsUpdateLayout())
{
- ScViewData& rViewData = mpViewShell->GetViewData();
- EditEngine const& rEditEng = rViewData.GetEditView(meSplitPos)->getEditEngine();
- if (rEditEng.IsUpdateLayout())
- {
- mpTempAccEdit = new ScAccessibleEditObject(this, rViewData.GetEditView(meSplitPos),
- mpViewShell->GetWindowByPos(meSplitPos), GetCurrentCellName(),
- ScResId(STR_ACC_EDITLINE_DESCR), ScAccessibleEditObject::CellInEditMode);
- uno::Reference<XAccessible> xAcc = mpTempAccEdit;
+ 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(xAcc, true);
- if (mpAccessibleSpreadsheet.is())
- mpAccessibleSpreadsheet->LostFocus();
- else
- CommitFocusLost();
+ if (mpAccessibleSpreadsheet.is())
+ mpAccessibleSpreadsheet->LostFocus();
+ else
+ CommitFocusLost();
- mpTempAccEdit->GotFocus();
- }
+ mpTempAccEdit->GotFocus();
}
}
- else if (rHint.GetId() == SfxHintId::ScAccLeaveEditMode)
+ }
+ else if (rHint.GetId() == SfxHintId::ScAccLeaveEditMode)
+ {
+ if (mxTempAcc.is())
{
- if (mxTempAcc.is())
+ if (mpTempAccEdit)
{
- if (mpTempAccEdit)
- {
- mpTempAccEdit->LostFocus();
- }
- RemoveChild(mxTempAcc, true);
- if (mpTempAccEdit)
- {
- // tdf#125982 a11y use-after-free of editengine by
- // ScAccessibleEditObjectTextData living past the
- // the editengine of the editview passed in above
- // in ScAccEnterEditMode
- mpTempAccEdit->dispose();
- mpTempAccEdit = nullptr;
- }
- if (mpAccessibleSpreadsheet.is() && mpViewShell && mpViewShell->IsActive())
- mpAccessibleSpreadsheet->GotFocus();
- else if( mpViewShell && mpViewShell->IsActive())
- CommitFocusGained();
+ mpTempAccEdit->LostFocus();
+ }
+ RemoveChild(mxTempAcc, true);
+ if (mpTempAccEdit)
+ {
+ // tdf#125982 a11y use-after-free of editengine by
+ // ScAccessibleEditObjectTextData living past the
+ // the editengine of the editview passed in above
+ // in ScAccEnterEditMode
+ mpTempAccEdit->dispose();
+ mpTempAccEdit = nullptr;
}
+ if (mpAccessibleSpreadsheet.is() && mpViewShell && mpViewShell->IsActive())
+ mpAccessibleSpreadsheet->GotFocus();
+ else if( mpViewShell && mpViewShell->IsActive())
+ CommitFocusGained();
}
- else if ((rHint.GetId() == SfxHintId::ScAccVisAreaChanged) || (rHint.GetId() == SfxHintId::ScAccWindowResized))
- {
- tools::Rectangle aOldVisArea(maVisArea);
- maVisArea = GetVisibleArea_Impl();
+ }
+ else if ((rHint.GetId() == SfxHintId::ScAccVisAreaChanged) || (rHint.GetId() == SfxHintId::ScAccWindowResized))
+ {
+ tools::Rectangle aOldVisArea(maVisArea);
+ maVisArea = GetVisibleArea_Impl();
- if (maVisArea != aOldVisArea)
+ if (maVisArea != aOldVisArea)
+ {
+ if (maVisArea.GetSize() != aOldVisArea.GetSize())
{
- if (maVisArea.GetSize() != aOldVisArea.GetSize())
- {
- AccessibleEventObject aEvent;
- aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED;
- aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
- CommitChange(aEvent);
+ CommitChange(aEvent);
- if (mpAccessibleSpreadsheet.is())
- mpAccessibleSpreadsheet->BoundingBoxChanged();
- if (mpAccessibleSpreadsheet.is() && mpViewShell && mpViewShell->IsActive())
- mpAccessibleSpreadsheet->FireFirstCellFocus();
- }
- else if (mpAccessibleSpreadsheet.is())
- {
- mpAccessibleSpreadsheet->VisAreaChanged();
- }
- if (mpChildrenShapes)
- mpChildrenShapes->VisAreaChanged();
+ if (mpAccessibleSpreadsheet.is())
+ mpAccessibleSpreadsheet->BoundingBoxChanged();
+ if (mpAccessibleSpreadsheet.is() && mpViewShell && mpViewShell->IsActive())
+ mpAccessibleSpreadsheet->FireFirstCellFocus();
}
+ else if (mpAccessibleSpreadsheet.is())
+ {
+ mpAccessibleSpreadsheet->VisAreaChanged();
+ }
+ if (mpChildrenShapes)
+ mpChildrenShapes->VisAreaChanged();
}
}
diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
index cddf1c24237f..bed4ddb69669 100644
--- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
@@ -1193,90 +1193,87 @@ void SAL_CALL ScAccessibleDocumentPagePreview::disposing()
void ScAccessibleDocumentPagePreview::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
- if ( dynamic_cast<const ScAccWinFocusLostHint*>(&rHint) )
+ if ( rHint.GetId() == SfxHintId::ScAccWinFocusLost )
{
CommitFocusLost();
}
- else if ( dynamic_cast<const ScAccGridWinFocusLostHint*>(&rHint) )
+ else if ( rHint.GetId() == SfxHintId::ScAccGridWinFocusLost )
{
CommitFocusLost();
}
- else if ( dynamic_cast<const ScAccWinFocusGotHint*>(&rHint) )
+ else if ( rHint.GetId() == SfxHintId::ScAccWinFocusGot )
{
CommitFocusGained();
}
- else if ( dynamic_cast<const ScAccGridWinFocusGotHint*>(&rHint) )
+ else if ( rHint.GetId() == SfxHintId::ScAccGridWinFocusGot )
{
CommitFocusGained();
}
- else
+ else if (rHint.GetId() == SfxHintId::ScDataChanged)
{
// only notify if child exist, otherwise it is not necessary
- if (rHint.GetId() == SfxHintId::ScDataChanged)
+ if (mpTable.is()) // if there is no table there is nothing to notify, because no one recognizes the change
{
- 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);
- }
-
- mpTable->dispose();
- mpTable.clear();
+ 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);
}
- Size aOutputSize;
- vcl::Window* pSizeWindow = mpViewShell->GetWindow();
- if ( pSizeWindow )
- aOutputSize = pSizeWindow->GetOutputSizePixel();
- tools::Rectangle aVisRect( Point(), aOutputSize );
- GetNotesChildren()->DataChanged(aVisRect);
+ mpTable->dispose();
+ mpTable.clear();
+ }
- GetShapeChildren()->DataChanged();
+ Size aOutputSize;
+ vcl::Window* pSizeWindow = mpViewShell->GetWindow();
+ if ( pSizeWindow )
+ aOutputSize = pSizeWindow->GetOutputSizePixel();
+ tools::Rectangle aVisRect( Point(), aOutputSize );
+ GetNotesChildren()->DataChanged(aVisRect);
- const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
- ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChildren(), GetShapeChildren() );
+ GetShapeChildren()->DataChanged();
- if (aCount.nTables > 0)
- {
- //! order is background shapes, header, table or notes, footer, foreground shapes, controls
- sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
+ const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
+ ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChildren(), GetShapeChildren() );
- mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
- mpTable->Init();
+ if (aCount.nTables > 0)
+ {
+ //! order is background shapes, header, table or notes, footer, foreground shapes, controls
+ sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
- {
- 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);
- }
+ 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);
}
}
- else if (rHint.GetId() == SfxHintId::ScAccVisAreaChanged)
- {
- Size aOutputSize;
- vcl::Window* pSizeWindow = mpViewShell->GetWindow();
- if ( pSizeWindow )
- aOutputSize = pSizeWindow->GetOutputSizePixel();
- tools::Rectangle aVisRect( Point(), aOutputSize );
- GetNotesChildren()->DataChanged(aVisRect);
+ }
+ else if (rHint.GetId() == SfxHintId::ScAccVisAreaChanged)
+ {
+ Size aOutputSize;
+ vcl::Window* pSizeWindow = mpViewShell->GetWindow();
+ if ( pSizeWindow )
+ aOutputSize = pSizeWindow->GetOutputSizePixel();
+ tools::Rectangle aVisRect( Point(), aOutputSize );
+ GetNotesChildren()->DataChanged(aVisRect);
- GetShapeChildren()->VisAreaChanged();
+ GetShapeChildren()->VisAreaChanged();
- AccessibleEventObject aEvent;
- aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
- aEvent.Source = uno::Reference< XAccessibleContext >(this);
- CommitChange(aEvent);
- }
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ CommitChange(aEvent);
}
ScAccessibleDocumentBase::Notify(rBC, rHint);
}
diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
index ae88d761dfed..6b7162718225 100644
--- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
+++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
@@ -411,8 +411,9 @@ void ScAccessibleSpreadsheet::VisAreaChanged()
void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
- if ( auto pRefHint = dynamic_cast<const ScUpdateRefHint*>(&rHint) )
+ if ( rHint.GetId() == SfxHintId::ScUpdateRef )
{
+ auto pRefHint = static_cast<const ScUpdateRefHint*>(&rHint);
if (pRefHint->GetMode() == URM_INSDEL && pRefHint->GetDz() == 0) //test whether table is inserted or deleted
{
if (((pRefHint->GetRange().aStart.Col() == maRange.aStart.Col()) &&