sw/inc/accmap.hxx | 8 - sw/inc/swurl.hxx | 2 sw/source/core/access/acccell.cxx | 12 +- sw/source/core/access/acccontext.cxx | 81 +++++++---------- sw/source/core/access/acccontext.hxx | 4 sw/source/core/access/accdoc.cxx | 14 +- sw/source/core/access/accfootnote.cxx | 4 sw/source/core/access/accframebase.cxx | 11 -- sw/source/core/access/accfrmobj.cxx | 2 sw/source/core/access/accfrmobjmap.cxx | 4 sw/source/core/access/accmap.cxx | 128 +++++++++++++-------------- sw/source/core/access/accpara.cxx | 12 +- sw/source/core/access/accselectionhelper.cxx | 6 - sw/source/core/view/viewimp.cxx | 2 sw/source/uibase/wrtsh/wrtsh2.cxx | 5 - 15 files changed, 139 insertions(+), 156 deletions(-)
New commits: commit f7922602e0a7445ff0f45bcfe2c6454e4074bbe9 Author: Michael Weghorn <[email protected]> AuthorDate: Tue Apr 15 17:49:21 2025 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Apr 15 22:58:13 2025 +0200 sw a11y: Return ref in SwAccessibleContext::GetShell Return a ref instad of a pointer in SwAccessibleContext::GetShell and also switch the SwViewShell param for LoadURL to a reference. This also allows to drop the // The shell could be 0 also!!!!! comment in that method. Change-Id: I9a817fb33f79a10f1baccb8c6264dafd9677731a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184231 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/sw/inc/swurl.hxx b/sw/inc/swurl.hxx index 6051a6da32df..22d6efbf5833 100644 --- a/sw/inc/swurl.hxx +++ b/sw/inc/swurl.hxx @@ -35,7 +35,7 @@ namespace o3tl { bool LoadURL( SwWrtShell& rSh, const OUString& rName, LoadUrlFlags nFilter, const OUString& rTargetFrameName ); -bool LoadURL( SwViewShell* rSh, const OUString& rName, +bool LoadURL( SwViewShell& rSh, const OUString& rName, LoadUrlFlags nFilter, const OUString& rTargetFrameName ); #endif diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx index d8b0f3ee69d4..a2f729a9fa95 100644 --- a/sw/source/core/access/acccontext.cxx +++ b/sw/source/core/access/acccontext.cxx @@ -123,7 +123,7 @@ void SwAccessibleContext::ChildrenScrolled( const SwFrame *pFrame, { const SwAccessibleChild& rLower = *aIter; const SwRect aBox( rLower.GetBox( *(GetMap()) ) ); - if( rLower.IsAccessible( GetShell()->IsPreview() ) ) + if (rLower.IsAccessible(GetShell().IsPreview())) { Action eAction = Action::NONE; if( aBox.Overlaps( rNewVisArea ) ) @@ -347,7 +347,7 @@ void SwAccessibleContext::InvalidateChildrenStates( const SwFrame* _pFrame, if( pLower ) { ::rtl::Reference< SwAccessibleContext > xAccImpl; - if( rLower.IsAccessible( GetShell()->IsPreview() ) ) + if (rLower.IsAccessible(GetShell().IsPreview())) xAccImpl = GetMap()->GetContextImpl( pLower, false ); if( xAccImpl.is() ) xAccImpl->InvalidateStates( _nStates ); @@ -884,8 +884,8 @@ awt::Rectangle SwAccessibleContext::getBoundsImpl(bool bRelative) if( GetFrame()->IsPageFrame() && static_cast < const SwPageFrame * >( GetFrame() )->IsEmptyPage() ) { - OSL_ENSURE( GetShell()->IsPreview(), "empty page accessible?" ); - if( GetShell()->IsPreview() ) + OSL_ENSURE(GetShell().IsPreview(), "empty page accessible?"); + if (GetShell().IsPreview()) { // adjust method call <GetMap()->GetPreviewPageSize()> sal_uInt16 nPageNum = diff --git a/sw/source/core/access/acccontext.hxx b/sw/source/core/access/acccontext.hxx index 8fa1e857bd0c..814a4e6d8a8b 100644 --- a/sw/source/core/access/acccontext.hxx +++ b/sw/source/core/access/acccontext.hxx @@ -111,13 +111,13 @@ protected: const SwAccessibleMap *GetMap() const { return m_pMap; } /** convenience method to get the SwViewShell through accessibility map */ - SwViewShell* GetShell() + SwViewShell& GetShell() { - return &GetMap()->GetShell(); + return GetMap()->GetShell(); } - const SwViewShell* GetShell() const + const SwViewShell& GetShell() const { - return &GetMap()->GetShell(); + return GetMap()->GetShell(); } /** convenience method to get SwCursorShell through accessibility map diff --git a/sw/source/core/access/accdoc.cxx b/sw/source/core/access/accdoc.cxx index acb83c0f3c11..219c854fd2f6 100644 --- a/sw/source/core/access/accdoc.cxx +++ b/sw/source/core/access/accdoc.cxx @@ -191,7 +191,7 @@ OUString SAL_CALL SwAccessibleDocumentBase::getAccessibleName() SolarMutexGuard g; OUString sAccName = GetResource( STR_ACCESS_DOC_WORDPROCESSING ); - SwDoc *pDoc = GetMap() ? GetShell()->GetDoc() : nullptr; + SwDoc* pDoc = GetMap() ? GetShell().GetDoc() : nullptr; if ( pDoc ) { OUString sFileName = pDoc->getDocAccTitle(); @@ -471,7 +471,7 @@ uno::Any SAL_CALL SwAccessibleDocument::getExtendedAttributes() SolarMutexGuard g; uno::Any anyAttribute; - SwDoc *pDoc = GetMap() ? GetShell()->GetDoc() : nullptr; + SwDoc* pDoc = GetMap() ? GetShell().GetDoc() : nullptr; if (!pDoc) return anyAttribute; diff --git a/sw/source/core/access/accfootnote.cxx b/sw/source/core/access/accfootnote.cxx index 70e5c64a58bd..5ca1ae94815a 100644 --- a/sw/source/core/access/accfootnote.cxx +++ b/sw/source/core/access/accfootnote.cxx @@ -49,7 +49,7 @@ SwAccessibleFootnote::SwAccessibleFootnote( static_cast< const SwFootnoteFrame *>( GetFrame() )->GetAttr(); if( pTextFootnote ) { - const SwDoc *pDoc = GetShell()->GetDoc(); + const SwDoc* pDoc = GetShell().GetDoc(); sArg = pTextFootnote->GetFootnote().GetViewNumStr(*pDoc, pFootnoteFrame->getRootFrame()); } diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx index 8d4e886fb989..3a1d0985a586 100644 --- a/sw/source/uibase/wrtsh/wrtsh2.cxx +++ b/sw/source/uibase/wrtsh/wrtsh2.cxx @@ -625,11 +625,10 @@ bool LoadURL( SwWrtShell& rVSh, const OUString& rURL, LoadUrlFlags nFilter, return ::LoadURL(rVSh.GetView(), rURL, nFilter, rTargetFrameName); } -bool LoadURL( SwViewShell* pVSh, const OUString& rURL, LoadUrlFlags nFilter, +bool LoadURL( SwViewShell& rVSh, const OUString& rURL, LoadUrlFlags nFilter, const OUString& rTargetFrameName ) { - // The shell could be 0 also!!!!! - if (auto pSh = dynamic_cast<SwWrtShell*>(pVSh)) + if (auto pSh = dynamic_cast<SwWrtShell*>(&rVSh)) return ::LoadURL(*pSh, rURL, nFilter, rTargetFrameName); return false; } commit 3477b770d4add125be81b64c0f7051b655fe6016 Author: Michael Weghorn <[email protected]> AuthorDate: Tue Apr 15 17:19:33 2025 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Apr 15 22:58:07 2025 +0200 sw a11y: Use ref for SwAccessibleMap's SwViewShell After Change-Id: Iccb2549bfaef37d14f3f7a4b9c691c583b189bb3 Author: Michael Weghorn <[email protected]> Date: Tue Apr 15 15:31:55 2025 +0200 sw: Let SwViewShellImp hold/return ref instead of pointer to its SwViewShell , it is clear that the SwViewShell passed in the SwAccessibleMap ctor is always non-null. Switch to a reference for the corresponding class member and getter as well. This makes clear that it's always non-null and allows to drop a few null checks/assert/`OSL_ENSURE`s. Change-Id: Id4219064bdde476a331e343c8d6dea4a5af5b23d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184230 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/sw/inc/accmap.hxx b/sw/inc/accmap.hxx index 886899c08faf..5c7e5be9d241 100644 --- a/sw/inc/accmap.hxx +++ b/sw/inc/accmap.hxx @@ -102,7 +102,7 @@ class SwAccessibleMap final : public ::accessibility::IAccessibleViewForwarder, // #i27301 data structure to keep information about // accessible paragraph, which have a selection. std::unique_ptr<SwAccessibleSelectedParas_Impl> mpSelectedParas; - SwViewShell *mpVSh; + SwViewShell& m_rViewShell; /// for page preview: store preview data, VisArea, and mapping of /// preview-to-display coordinates std::unique_ptr<SwAccPreviewData> mpPreview; @@ -141,7 +141,7 @@ class SwAccessibleMap final : public ::accessibility::IAccessibleViewForwarder, public: - SwAccessibleMap( SwViewShell *pSh ); + SwAccessibleMap(SwViewShell& rViewShell); virtual ~SwAccessibleMap() override; css::uno::Reference<css::accessibility::XAccessible> GetDocumentView(); @@ -168,9 +168,9 @@ public: SwAccessibleContext *pParentImpl, bool bCreate = true ); - SwViewShell* GetShell() const + SwViewShell& GetShell() const { - return mpVSh; + return m_rViewShell; } static bool IsInSameLevel(const SdrObject* pObj, const SwFEShell* pFESh); void AddShapeContext(const SdrObject *pObj, diff --git a/sw/source/core/access/acccell.cxx b/sw/source/core/access/acccell.cxx index fb955b104a3f..7483cfb897b6 100644 --- a/sw/source/core/access/acccell.cxx +++ b/sw/source/core/access/acccell.cxx @@ -53,9 +53,8 @@ bool SwAccessibleCell::IsSelected() bool bRet = false; assert(GetMap()); - const SwViewShell *pVSh = GetMap()->GetShell(); - assert(pVSh); - if( auto pCSh = dynamic_cast<const SwCursorShell*>(pVSh) ) + const SwViewShell& rVSh = GetMap()->GetShell(); + if( auto pCSh = dynamic_cast<const SwCursorShell*>(&rVSh) ) { if( pCSh->IsTableMode() ) { @@ -76,9 +75,8 @@ void SwAccessibleCell::GetStates( sal_Int64& rStateSet ) SwAccessibleContext::GetStates( rStateSet ); // SELECTABLE - const SwViewShell *pVSh = GetMap()->GetShell(); - assert(pVSh); - if( dynamic_cast<const SwCursorShell*>( pVSh) != nullptr ) + const SwViewShell& rVSh = GetMap()->GetShell(); + if( dynamic_cast<const SwCursorShell*>(&rVSh) != nullptr ) rStateSet |= AccessibleStateType::SELECTABLE; //Add resizable state to table cell. rStateSet |= AccessibleStateType::RESIZABLE; @@ -157,7 +155,7 @@ bool SwAccessibleCell::InvalidateChildrenCursorPos( const SwFrame *pFrame ) const SwFrame *pLower = rLower.GetSwFrame(); if( pLower ) { - if( rLower.IsAccessible( GetMap()->GetShell()->IsPreview() ) ) + if (rLower.IsAccessible(GetMap()->GetShell().IsPreview())) { ::rtl::Reference< SwAccessibleContext > xAccImpl( GetMap()->GetContextImpl( pLower, false ) ); diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx index 4239fe1b41ab..d8b0f3ee69d4 100644 --- a/sw/source/core/access/acccontext.cxx +++ b/sw/source/core/access/acccontext.cxx @@ -55,9 +55,9 @@ void SwAccessibleContext::InitStates() { m_isShowingState = GetMap() && IsShowing( *(GetMap()) ); - SwViewShell *pVSh = GetMap()->GetShell(); - m_isEditableState = pVSh && IsEditable(*pVSh); - m_isOpaqueState = pVSh && IsOpaque(*pVSh); + SwViewShell& rVSh = GetMap()->GetShell(); + m_isEditableState = IsEditable(rVSh); + m_isOpaqueState = IsOpaque(rVSh); m_isDefuncState = false; } @@ -81,11 +81,7 @@ vcl::Window *SwAccessibleContext::GetWindow() if( GetMap() ) { - const SwViewShell *pVSh = GetMap()->GetShell(); - OSL_ENSURE( pVSh, "no view shell" ); - if( pVSh ) - pWin = pVSh->GetWin(); - + pWin = GetMap()->GetShell().GetWin(); OSL_ENSURE( pWin, "no window" ); } @@ -95,7 +91,7 @@ vcl::Window *SwAccessibleContext::GetWindow() // get SwViewShell from accessibility map, and cast to cursor shell SwCursorShell* SwAccessibleContext::GetCursorShell() { - SwViewShell* pViewShell = GetMap() ? GetMap()->GetShell() : nullptr; + SwViewShell* pViewShell = GetMap() ? &GetMap()->GetShell() : nullptr; OSL_ENSURE( pViewShell, "no view shell" ); return dynamic_cast<SwCursorShell*>( pViewShell); } @@ -103,7 +99,7 @@ SwCursorShell* SwAccessibleContext::GetCursorShell() const SwCursorShell* SwAccessibleContext::GetCursorShell() const { // just like non-const GetCursorShell - const SwViewShell* pViewShell = GetMap() ? GetMap()->GetShell() : nullptr; + const SwViewShell* pViewShell = GetMap() ? &GetMap()->GetShell() : nullptr; OSL_ENSURE( pViewShell, "no view shell" ); return dynamic_cast<const SwCursorShell*>( pViewShell); } @@ -526,7 +522,7 @@ SwAccessibleContext::SwAccessibleContext(std::shared_ptr<SwAccessibleMap> const& sal_Int16 const nRole, const SwFrame *pF ) : SwAccessibleFrame( pMap->GetVisArea(), pF, - pMap->GetShell()->IsPreview() ) + pMap->GetShell().IsPreview() ) , m_pMap(pMap.get()) , m_wMap(pMap) , m_nClientId(0) @@ -1285,37 +1281,34 @@ void SwAccessibleContext::InvalidateStates( AccessibleStates _nStates ) if( !GetMap() ) return; - SwViewShell *pVSh = GetMap()->GetShell(); - if( pVSh ) + SwViewShell& rVSh = GetMap()->GetShell(); + if( _nStates & AccessibleStates::EDITABLE ) { - if( _nStates & AccessibleStates::EDITABLE ) + bool bIsOldEditableState; + bool bIsNewEditableState = IsEditable(rVSh); { - bool bIsOldEditableState; - bool bIsNewEditableState = IsEditable(*pVSh); - { - std::scoped_lock aGuard( m_Mutex ); - bIsOldEditableState = m_isEditableState; - m_isEditableState = bIsNewEditableState; - } - - if( bIsOldEditableState != bIsNewEditableState ) - FireStateChangedEvent( AccessibleStateType::EDITABLE, - bIsNewEditableState ); + std::scoped_lock aGuard( m_Mutex ); + bIsOldEditableState = m_isEditableState; + m_isEditableState = bIsNewEditableState; } - if( _nStates & AccessibleStates::OPAQUE ) - { - bool bIsOldOpaqueState; - bool bIsNewOpaqueState = IsOpaque(*pVSh); - { - std::scoped_lock aGuard( m_Mutex ); - bIsOldOpaqueState = m_isOpaqueState; - m_isOpaqueState = bIsNewOpaqueState; - } - if( bIsOldOpaqueState != bIsNewOpaqueState ) - FireStateChangedEvent( AccessibleStateType::OPAQUE, - bIsNewOpaqueState ); + if( bIsOldEditableState != bIsNewEditableState ) + FireStateChangedEvent( AccessibleStateType::EDITABLE, + bIsNewEditableState ); + } + if( _nStates & AccessibleStates::OPAQUE ) + { + bool bIsOldOpaqueState; + bool bIsNewOpaqueState = IsOpaque(rVSh); + { + std::scoped_lock aGuard( m_Mutex ); + bIsOldOpaqueState = m_isOpaqueState; + m_isOpaqueState = bIsNewOpaqueState; } + + if( bIsOldOpaqueState != bIsNewOpaqueState ) + FireStateChangedEvent( AccessibleStateType::OPAQUE, + bIsNewOpaqueState ); } InvalidateChildrenStates( GetFrame(), _nStates ); @@ -1430,7 +1423,7 @@ bool SwAccessibleContext::HasAdditionalAccessibleChildren() if ( GetFrame()->IsTextFrame() ) { - SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr(); + SwPostItMgr* pPostItMgr = GetMap()->GetShell().GetPostItMgr(); if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() ) { bRet = pPostItMgr->HasFrameConnectedSidebarWins( *(GetFrame()) ); @@ -1447,7 +1440,7 @@ vcl::Window* SwAccessibleContext::GetAdditionalAccessibleChild( const sal_Int32 if ( GetFrame()->IsTextFrame() ) { - SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr(); + SwPostItMgr* pPostItMgr = GetMap()->GetShell().GetPostItMgr(); if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() ) { pAdditionalAccessibleChild = @@ -1463,7 +1456,7 @@ void SwAccessibleContext::GetAdditionalAccessibleChildren( std::vector< vcl::Win { if ( GetFrame()->IsTextFrame() ) { - SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr(); + SwPostItMgr* pPostItMgr = GetMap()->GetShell().GetPostItMgr(); if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() ) { pPostItMgr->GetAllSidebarWinForFrame( *(GetFrame()), pChildren ); diff --git a/sw/source/core/access/acccontext.hxx b/sw/source/core/access/acccontext.hxx index 7eda05bd1e8a..8fa1e857bd0c 100644 --- a/sw/source/core/access/acccontext.hxx +++ b/sw/source/core/access/acccontext.hxx @@ -113,11 +113,11 @@ protected: /** convenience method to get the SwViewShell through accessibility map */ SwViewShell* GetShell() { - return GetMap()->GetShell(); + return &GetMap()->GetShell(); } const SwViewShell* GetShell() const { - return GetMap()->GetShell(); + return &GetMap()->GetShell(); } /** convenience method to get SwCursorShell through accessibility map diff --git a/sw/source/core/access/accdoc.cxx b/sw/source/core/access/accdoc.cxx index aced77c5f8a5..acb83c0f3c11 100644 --- a/sw/source/core/access/accdoc.cxx +++ b/sw/source/core/access/accdoc.cxx @@ -65,8 +65,8 @@ using lang::IndexOutOfBoundsException; SwAccessibleDocumentBase::SwAccessibleDocumentBase( std::shared_ptr<SwAccessibleMap> const& pMap) : SwAccessibleContext(pMap, AccessibleRole::DOCUMENT_TEXT, - pMap->GetShell()->GetLayout()) - , mxParent(pMap->GetShell()->GetWin()->GetAccessibleParent()) + pMap->GetShell().GetLayout()) + , mxParent(pMap->GetShell().GetWin()->GetAccessibleParent()) , mpChildWin(nullptr) { } @@ -342,7 +342,7 @@ SwAccessibleDocument::SwAccessibleDocument( , maSelectionHelper(*this) { SetName(pInitMap->GetDocName()); - vcl::Window *pWin = pInitMap->GetShell()->GetWin(); + vcl::Window* pWin = pInitMap->GetShell().GetWin(); if( pWin ) { pWin->AddChildEventListener( LINK( this, SwAccessibleDocument, WindowChildEventListener )); @@ -359,7 +359,7 @@ SwAccessibleDocument::SwAccessibleDocument( SwAccessibleDocument::~SwAccessibleDocument() { - vcl::Window *pWin = GetMap() ? GetMap()->GetShell()->GetWin() : nullptr; + vcl::Window* pWin = GetMap() ? GetMap()->GetShell().GetWin() : nullptr; if( pWin ) pWin->RemoveChildEventListener( LINK( this, SwAccessibleDocument, WindowChildEventListener )); } @@ -368,7 +368,7 @@ void SwAccessibleDocument::Dispose(bool bRecursive, bool bCanSkipInvisible) { OSL_ENSURE( GetFrame() && GetMap(), "already disposed" ); - vcl::Window *pWin = GetMap() ? GetMap()->GetShell()->GetWin() : nullptr; + vcl::Window *pWin = GetMap() ? GetMap()->GetShell().GetWin() : nullptr; if( pWin ) pWin->RemoveChildEventListener( LINK( this, SwAccessibleDocument, WindowChildEventListener )); SwAccessibleContext::Dispose(bRecursive, bCanSkipInvisible); diff --git a/sw/source/core/access/accfootnote.cxx b/sw/source/core/access/accfootnote.cxx index b23768be822d..70e5c64a58bd 100644 --- a/sw/source/core/access/accfootnote.cxx +++ b/sw/source/core/access/accfootnote.cxx @@ -75,7 +75,7 @@ OUString SAL_CALL SwAccessibleFootnote::getAccessibleDescription() static_cast< const SwFootnoteFrame *>( GetFrame() )->GetAttr(); if( pTextFootnote ) { - const SwDoc *pDoc = GetMap()->GetShell()->GetDoc(); + const SwDoc* pDoc = GetMap()->GetShell().GetDoc(); sArg = pTextFootnote->GetFootnote().GetViewNumStr(*pDoc, GetFrame()->getRootFrame()); } diff --git a/sw/source/core/access/accframebase.cxx b/sw/source/core/access/accframebase.cxx index c5517d57b606..535d621387e6 100644 --- a/sw/source/core/access/accframebase.cxx +++ b/sw/source/core/access/accframebase.cxx @@ -44,9 +44,8 @@ bool SwAccessibleFrameBase::IsSelected() bool bRet = false; assert(GetMap()); - const SwViewShell *pVSh = GetMap()->GetShell(); - assert(pVSh); - if( auto pFESh = dynamic_cast<const SwFEShell*>(pVSh) ) + const SwViewShell& rVSh = GetMap()->GetShell(); + if (auto pFESh = dynamic_cast<const SwFEShell*>(&rVSh)) { const SwFrame *pFlyFrame = pFESh->GetSelectedFlyFrame(); if( pFlyFrame == GetFrame() ) @@ -60,10 +59,8 @@ void SwAccessibleFrameBase::GetStates( sal_Int64& rStateSet ) { SwAccessibleContext::GetStates( rStateSet ); - const SwViewShell *pVSh = GetMap()->GetShell(); - assert(pVSh); - - if (dynamic_cast<const SwFEShell*>(pVSh)) + const SwViewShell& rVSh = GetMap()->GetShell(); + if (dynamic_cast<const SwFEShell*>(&rVSh)) { // SELECTABLE rStateSet |= AccessibleStateType::SELECTABLE; diff --git a/sw/source/core/access/accfrmobj.cxx b/sw/source/core/access/accfrmobj.cxx index 004ca4ab94e0..24382681ed38 100644 --- a/sw/source/core/access/accfrmobj.cxx +++ b/sw/source/core/access/accfrmobj.cxx @@ -254,7 +254,7 @@ SwRect SwAccessibleChild::GetBox( const SwAccessibleMap& rAccMap ) const } else if ( mpWindow ) { - vcl::Window *pWin = rAccMap.GetShell()->GetWin(); + vcl::Window* pWin = rAccMap.GetShell().GetWin(); if (pWin) { aBox = SwRect( pWin->PixelToLogic( diff --git a/sw/source/core/access/accfrmobjmap.cxx b/sw/source/core/access/accfrmobjmap.cxx index 5da8dad1ad2b..210f44ada1f7 100644 --- a/sw/source/core/access/accfrmobjmap.cxx +++ b/sw/source/core/access/accfrmobjmap.cxx @@ -35,8 +35,8 @@ using namespace sw::access; SwAccessibleChildMap::SwAccessibleChildMap( const SwRect& rVisArea, const SwFrame& rFrame, SwAccessibleMap& rAccMap ) - : mnHellId( rAccMap.GetShell()->GetDoc()->getIDocumentDrawModelAccess().GetHellId() ) - , mnControlsId( rAccMap.GetShell()->GetDoc()->getIDocumentDrawModelAccess().GetControlsId() ) + : mnHellId(rAccMap.GetShell().GetDoc()->getIDocumentDrawModelAccess().GetHellId()) + , mnControlsId(rAccMap.GetShell().GetDoc()->getIDocumentDrawModelAccess().GetControlsId()) { const bool bVisibleChildrenOnly = SwAccessibleChild( &rFrame ).IsVisibleChildrenOnly(); diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index 9d6de6ca9fc0..b787ec7a22d5 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -272,12 +272,12 @@ public: explicit SwAccessibleShapeMap_Impl( SwAccessibleMap const *pMap ) { - maInfo.SetSdrView( pMap->GetShell()->GetDrawView() ); - maInfo.SetWindow( pMap->GetShell()->GetWin() ); + maInfo.SetSdrView(pMap->GetShell().GetDrawView()); + maInfo.SetWindow(pMap->GetShell().GetWin()); maInfo.SetViewForwarder( pMap ); uno::Reference < document::XShapeEventBroadcaster > xModelBroadcaster = new SwDrawModellListener_Impl( - pMap->GetShell()->getIDocumentDrawModelAccess().GetOrCreateDrawModel() ); + pMap->GetShell().getIDocumentDrawModelAccess().GetOrCreateDrawModel()); maInfo.SetModelBroadcaster( xModelBroadcaster ); } @@ -1087,7 +1087,7 @@ void SwAccessibleMap::InvalidateCursorPosition(const rtl::Reference<SwAccessible { assert(rxAcc.is()); assert(rxAcc->GetFrame()); - if( GetShell()->ActionPend() ) + if (GetShell().ActionPend()) { SwAccessibleEvent_Impl aEvent(SwAccessibleEvent_Impl::CARET_OR_STATES, rxAcc.get(), SwAccessibleChild(rxAcc->GetFrame()), @@ -1108,7 +1108,7 @@ void SwAccessibleMap::InvalidateCursorPosition(const rtl::Reference<SwAccessible void SwAccessibleMap::InvalidateShapeSelection() { - if( GetShell()->ActionPend() ) + if (GetShell().ActionPend()) { SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::SHAPE_SELECTION ); @@ -1133,8 +1133,8 @@ void SwAccessibleMap::InvalidateShapeInParaSelection() SwAccessibleObjShape_Impl *pSelShape = nullptr; size_t nShapes = 0; - const SwViewShell *pVSh = GetShell(); - const SwFEShell *pFESh = dynamic_cast<const SwFEShell*>(pVSh); + const SwViewShell& rVSh = GetShell(); + const SwFEShell *pFESh = dynamic_cast<const SwFEShell*>(&rVSh); SwPaM* pCursor = pFESh ? pFESh->GetCursor( false /* ??? */ ) : nullptr; //const size_t nSelShapes = pFESh ? pFESh->IsObjSelected() : 0; @@ -1194,7 +1194,7 @@ void SwAccessibleMap::InvalidateShapeInParaSelection() if( pCursor != nullptr ) { const SwTextNode* pNode = pAnchorNode->GetTextNode(); - SwTextFrame const*const pFrame(static_cast<SwTextFrame*>(pNode->getLayoutFrame(pVSh->GetLayout()))); + SwTextFrame const*const pFrame(static_cast<SwTextFrame*>(pNode->getLayoutFrame(rVSh.GetLayout()))); SwNodeOffset nFirstNode(pFrame->GetTextNodeFirst()->GetIndex()); SwNodeOffset nLastNode; if (sw::MergedPara const*const pMerged = pFrame->GetMergedPara()) @@ -1464,8 +1464,8 @@ void SwAccessibleMap::DoInvalidateShapeSelection(bool bInvalidateFocusMode /*=fa SwAccessibleObjShape_Impl *pSelShape = nullptr; size_t nShapes = 0; - const SwViewShell *pVSh = GetShell(); - const SwFEShell *pFESh = dynamic_cast<const SwFEShell*>(pVSh); + const SwViewShell& rVSh = GetShell(); + const SwFEShell *pFESh = dynamic_cast<const SwFEShell*>(&rVSh); const size_t nSelShapes = pFESh ? pFESh->GetSelectedObjCount() : 0; //when InvalidateFocus Call this function ,and the current selected shape count is not 1 , @@ -1483,7 +1483,7 @@ void SwAccessibleMap::DoInvalidateShapeSelection(bool bInvalidateFocusMode /*=fa std::vector<::rtl::Reference<::accessibility::AccessibleShape>> vecxShapeAdd; std::vector<::rtl::Reference<::accessibility::AccessibleShape>> vecxShapeRemove; - vcl::Window *pWin = GetShell()->GetWin(); + vcl::Window* pWin = GetShell().GetWin(); bool bFocused = pWin && pWin->HasFocus(); SwAccessibleObjShape_Impl *pShape = pShapes.get(); int nShapeCount = nShapes; @@ -1609,12 +1609,12 @@ void SwAccessibleMap::DoInvalidateShapeSelection(bool bInvalidateFocusMode /*=fa } } -SwAccessibleMap::SwAccessibleMap( SwViewShell *pSh ) : - mpVSh( pSh ), +SwAccessibleMap::SwAccessibleMap(SwViewShell& rViewShell) : + m_rViewShell(rViewShell), mbShapeSelected( false ), maDocName(SwAccessibleContext::GetResource(STR_ACCESS_DOC_NAME)) { - pSh->GetLayout()->AddAccessibleShell(); + rViewShell.GetLayout()->AddAccessibleShell(); } SwAccessibleMap::~SwAccessibleMap() @@ -1624,7 +1624,7 @@ SwAccessibleMap::~SwAccessibleMap() rtl::Reference < SwAccessibleContext > xAcc; if( mpFrameMap ) { - const SwRootFrame *pRootFrame = GetShell()->GetLayout(); + const SwRootFrame* pRootFrame = GetShell().GetLayout(); SwAccessibleContextMap_Impl::iterator aIter = mpFrameMap->find( pRootFrame ); if( aIter != mpFrameMap->end() ) xAcc = (*aIter).second; @@ -1670,7 +1670,7 @@ SwAccessibleMap::~SwAccessibleMap() mpEventMap.reset(); mpEvents.reset(); } - mpVSh->GetLayout()->RemoveAccessibleShell(); + m_rViewShell.GetLayout()->RemoveAccessibleShell(); } rtl::Reference<SwAccessibleContext> SwAccessibleMap::GetDocumentView_( @@ -1694,7 +1694,7 @@ rtl::Reference<SwAccessibleContext> SwAccessibleMap::GetDocumentView_( mpFrameMap->mbLocked = true; #endif - const SwRootFrame *pRootFrame = GetShell()->GetLayout(); + const SwRootFrame* pRootFrame = GetShell().GetLayout(); SwAccessibleContextMap_Impl::iterator aIter = mpFrameMap->find( pRootFrame ); if( aIter != mpFrameMap->end() ) xAcc = (*aIter).second; @@ -1825,7 +1825,7 @@ rtl::Reference<SwAccessibleContext> SwAccessibleMap::GetContextImpl(const SwFram static_cast< const SwTabFrame *>( pFrame ) ); break; case SwFrameType::Page: - OSL_ENSURE( GetShell()->IsPreview(), + OSL_ENSURE(GetShell().IsPreview(), "accessible page frames only in PagePreview" ); pAcc = new SwAccessiblePage(shared_from_this(), pFrame); break; @@ -2113,7 +2113,7 @@ void SwAccessibleMap::A11yDispose( const SwFrame *pFrame, OSL_ENSURE( !aFrameOrObj.GetSwFrame() || aFrameOrObj.GetSwFrame()->IsAccessibleFrame(), "non accessible frame should be disposed" ); - if (!(aFrameOrObj.IsAccessible(GetShell()->IsPreview()) + if (!(aFrameOrObj.IsAccessible(GetShell().IsPreview()) // fdo#87199 dispose the darn thing if it ever was accessible || Contains(pFrame))) return; @@ -2136,7 +2136,7 @@ void SwAccessibleMap::A11yDispose( const SwFrame *pFrame, // If there is none, look if the parent is accessible. const SwFrame *pParent = SwAccessibleFrame::GetParent( aFrameOrObj, - GetShell()->IsPreview()); + GetShell().IsPreview()); if( pParent ) { @@ -2155,7 +2155,7 @@ void SwAccessibleMap::A11yDispose( const SwFrame *pFrame, xShapeAccImpl = aIter->second; } } - if( pObj && GetShell()->ActionPend() && + if (pObj && GetShell().ActionPend() && (xParentAccImpl.is() || xShapeAccImpl.is()) ) { // Keep a reference to the XShape to avoid that it @@ -2221,7 +2221,7 @@ void SwAccessibleMap::InvalidatePosOrSize( const SwFrame *pFrame, DBG_TESTSOLARMUTEX(); SwAccessibleChild aFrameOrObj( pFrame, pObj, pWindow ); - if( !aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) ) + if (!aFrameOrObj.IsAccessible(GetShell().IsPreview())) return; ::rtl::Reference< SwAccessibleContext > xAccImpl; @@ -2246,7 +2246,7 @@ void SwAccessibleMap::InvalidatePosOrSize( const SwFrame *pFrame, // If not, there is nothing to do. pParent = SwAccessibleFrame::GetParent( aFrameOrObj, - GetShell()->IsPreview()); + GetShell().IsPreview()); if( pParent ) { @@ -2260,7 +2260,7 @@ void SwAccessibleMap::InvalidatePosOrSize( const SwFrame *pFrame, if( xAccImpl.is() ) { - if( GetShell()->ActionPend() ) + if (GetShell().ActionPend()) { SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::POS_CHANGED, xAccImpl.get(), @@ -2278,7 +2278,7 @@ void SwAccessibleMap::InvalidatePosOrSize( const SwFrame *pFrame, } else if( xParentAccImpl.is() ) { - if( GetShell()->ActionPend() ) + if (GetShell().ActionPend()) { assert(pParent); // tdf#99722 faster not to buffer events that won't be sent @@ -2327,7 +2327,7 @@ so run here: save the parent's SwFrame not the accessible object parent, } if( bIsValidFrame || bIsTextParent ) { - if( GetShell()->ActionPend() ) + if (GetShell().ActionPend()) { SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CHILD_POS_CHANGED, @@ -2347,7 +2347,7 @@ void SwAccessibleMap::InvalidateContent( const SwFrame *pFrame ) DBG_TESTSOLARMUTEX(); SwAccessibleChild aFrameOrObj( pFrame ); - if( !aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) ) + if (!aFrameOrObj.IsAccessible(GetShell().IsPreview())) return; if (!mpFrameMap) @@ -2362,7 +2362,7 @@ void SwAccessibleMap::InvalidateContent( const SwFrame *pFrame ) if( !xAcc.is() ) return; - if( GetShell()->ActionPend() ) + if (GetShell().ActionPend()) { SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::INVALID_CONTENT, xAcc.get(), @@ -2381,7 +2381,7 @@ void SwAccessibleMap::InvalidateAttr( const SwTextFrame& rTextFrame ) DBG_TESTSOLARMUTEX(); SwAccessibleChild aFrameOrObj( &rTextFrame ); - if( !aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) ) + if (!aFrameOrObj.IsAccessible(GetShell().IsPreview())) return; if (!mpFrameMap) @@ -2396,7 +2396,7 @@ void SwAccessibleMap::InvalidateAttr( const SwTextFrame& rTextFrame ) if( !xAcc.is() ) return; - if( GetShell()->ActionPend() ) + if (GetShell().ActionPend()) { SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::INVALID_ATTR, xAcc.get(), std::move(aFrameOrObj) ); @@ -2416,15 +2416,15 @@ void SwAccessibleMap::InvalidateCursorPosition( const SwFrame *pFrame ) SwAccessibleChild aFrameOrObj( pFrame ); bool bShapeSelected = false; - const SwViewShell *pVSh = GetShell(); - if( auto pCSh = dynamic_cast<const SwCursorShell*>(pVSh) ) + const SwViewShell& rVSh = GetShell(); + if( auto pCSh = dynamic_cast<const SwCursorShell*>(&rVSh) ) { if( pCSh->IsTableMode() ) { while( aFrameOrObj.GetSwFrame() && !aFrameOrObj.GetSwFrame()->IsCellFrame() ) aFrameOrObj = aFrameOrObj.GetSwFrame()->GetUpper(); } - else if( auto pFESh = dynamic_cast<const SwFEShell*>(pVSh) ) + else if( auto pFESh = dynamic_cast<const SwFEShell*>(&rVSh) ) { const SwFrame *pFlyFrame = pFESh->GetSelectedFlyFrame(); if( pFlyFrame ) @@ -2441,7 +2441,7 @@ void SwAccessibleMap::InvalidateCursorPosition( const SwFrame *pFrame ) } } - OSL_ENSURE( bShapeSelected || aFrameOrObj.IsAccessible(GetShell()->IsPreview()), + OSL_ENSURE(bShapeSelected || aFrameOrObj.IsAccessible(GetShell().IsPreview()), "frame is not accessible" ); rtl::Reference < SwAccessibleContext > xOldAcc; @@ -2510,7 +2510,7 @@ void SwAccessibleMap::InvalidateCursorPosition( const SwFrame *pFrame ) } else if (bShapeSelected) { - const SwFEShell *pFESh = static_cast< const SwFEShell * >( pVSh ); + const SwFEShell* pFESh = static_cast<const SwFEShell*>(&rVSh); const SdrMarkList *pMarkList = pFESh->GetMarkList(); if (pMarkList != nullptr && pMarkList->GetMarkCount() == 1) { @@ -2524,7 +2524,7 @@ void SwAccessibleMap::InvalidateCursorPosition( const SwFrame *pFrame ) } if (pObj != nullptr) { - const SwFrame *pParent = SwAccessibleFrame::GetParent( SwAccessibleChild(pObj), GetShell()->IsPreview() ); + const SwFrame *pParent = SwAccessibleFrame::GetParent(SwAccessibleChild(pObj), GetShell().IsPreview()); if( pParent ) { ::rtl::Reference< SwAccessibleContext > xParentAccImpl = GetContextImpl(pParent,false); @@ -2536,7 +2536,7 @@ void SwAccessibleMap::InvalidateCursorPosition( const SwFrame *pFrame ) //The Table should not add in acc.because the "pParent" is not add to acc . uno::Reference< XAccessible> xAccParentTab = GetContext(pTabFrame);//Should Create. - const SwFrame *pParentRoot = SwAccessibleFrame::GetParent( SwAccessibleChild(pTabFrame), GetShell()->IsPreview() ); + const SwFrame *pParentRoot = SwAccessibleFrame::GetParent(SwAccessibleChild(pTabFrame), GetShell().IsPreview()); if (pParentRoot) { ::rtl::Reference< SwAccessibleContext > xParentAccImplRoot = GetContextImpl(pParentRoot,false); @@ -2556,7 +2556,7 @@ void SwAccessibleMap::InvalidateCursorPosition( const SwFrame *pFrame ) //directly create this acc para . xParentAccImpl = GetContextImpl(pParent);//Should Create. - const SwFrame *pParentRoot = SwAccessibleFrame::GetParent( SwAccessibleChild(pParent), GetShell()->IsPreview() ); + const SwFrame *pParentRoot = SwAccessibleFrame::GetParent(SwAccessibleChild(pParent), GetShell().IsPreview()); ::rtl::Reference< SwAccessibleContext > xParentAccImplRoot = GetContextImpl(pParentRoot,false); if(xParentAccImplRoot.is()) @@ -2619,7 +2619,7 @@ void SwAccessibleMap::InvalidateFocus() { DBG_TESTSOLARMUTEX(); - if(GetShell()->IsPreview()) + if (GetShell().IsPreview()) { rtl::Reference<SwAccessibleContext> xDocView = GetDocumentView_(true); assert(xDocView.is()); @@ -2649,13 +2649,13 @@ void SwAccessibleMap::InvalidateEditableStates( const SwFrame* _pFrame ) // Start with the frame or the first upper that is accessible SwAccessibleChild aFrameOrObj( _pFrame ); while( aFrameOrObj.GetSwFrame() && - !aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) ) + !aFrameOrObj.IsAccessible(GetShell().IsPreview())) aFrameOrObj = aFrameOrObj.GetSwFrame()->GetUpper(); if( !aFrameOrObj.GetSwFrame() ) - aFrameOrObj = GetShell()->GetLayout(); + aFrameOrObj = GetShell().GetLayout(); rtl::Reference<SwAccessibleContext> xAccImpl = GetContextImpl(aFrameOrObj.GetSwFrame()); - if( GetShell()->ActionPend() ) + if (GetShell().ActionPend()) { SwAccessibleEvent_Impl aEvent(SwAccessibleEvent_Impl::CARET_OR_STATES, xAccImpl.get(), SwAccessibleChild(xAccImpl->GetFrame()), @@ -2676,7 +2676,7 @@ void SwAccessibleMap::InvalidateRelationSet_( const SwFrame* pFrame, // first, see if this frame is accessible, and if so, get the respective SwAccessibleChild aFrameOrObj( pFrame ); - if( !aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) ) + if (!aFrameOrObj.IsAccessible(GetShell().IsPreview())) return; if (!mpFrameMap) @@ -2694,7 +2694,7 @@ void SwAccessibleMap::InvalidateRelationSet_( const SwFrame* pFrame, if( !xAcc.is() ) return; - if( GetShell()->ActionPend() ) + if (GetShell().ActionPend()) { SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES, xAcc.get(), SwAccessibleChild(pFrame), @@ -2733,7 +2733,7 @@ void SwAccessibleMap::InvalidateParaTextSelection( const SwTextFrame& _rTextFram // first, see if this frame is accessible, and if so, get the respective SwAccessibleChild aFrameOrObj( &_rTextFrame ); - if( !aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) ) + if (!aFrameOrObj.IsAccessible(GetShell().IsPreview())) return; if (!mpFrameMap) @@ -2751,7 +2751,7 @@ void SwAccessibleMap::InvalidateParaTextSelection( const SwTextFrame& _rTextFram if( !xAcc.is() ) return; - if( GetShell()->ActionPend() ) + if (GetShell().ActionPend()) { SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES, @@ -2775,7 +2775,7 @@ sal_Int32 SwAccessibleMap::GetChildIndex( const SwFrame& rParentFrame, sal_Int32 nIndex( -1 ); SwAccessibleChild aFrameOrObj( &rParentFrame ); - if( aFrameOrObj.IsAccessible( GetShell()->IsPreview() ) ) + if (aFrameOrObj.IsAccessible(GetShell().IsPreview())) { rtl::Reference < SwAccessibleContext > xAcc; @@ -2803,7 +2803,7 @@ void SwAccessibleMap::UpdatePreview( const std::vector<std::unique_ptr<PreviewPa const Size& _rPreviewWinSize ) { DBG_TESTSOLARMUTEX(); - assert(GetShell()->IsPreview() && "no preview?"); + assert(GetShell().IsPreview() && "no preview?"); assert(mpPreview != nullptr && "no preview data?"); mpPreview->Update( *this, _rPreviewPages, _rScale, _pSelectedPageFrame, _rPreviewWinSize ); @@ -2812,7 +2812,7 @@ void SwAccessibleMap::UpdatePreview( const std::vector<std::unique_ptr<PreviewPa // accessibility tree; this will also send appropriate scroll // events SwAccessibleContext* pDoc = - GetContextImpl( GetShell()->GetLayout() ).get(); + GetContextImpl(GetShell().GetLayout()).get(); static_cast<SwAccessibleDocumentBase*>( pDoc )->SetVisArea(); rtl::Reference < SwAccessibleContext > xOldAcc = mxCursorContext; @@ -2836,10 +2836,10 @@ void SwAccessibleMap::UpdatePreview( const std::vector<std::unique_ptr<PreviewPa void SwAccessibleMap::InvalidatePreviewSelection( sal_uInt16 nSelPage ) { DBG_TESTSOLARMUTEX(); - assert(GetShell()->IsPreview()); + assert(GetShell().IsPreview()); assert(mpPreview != nullptr); - mpPreview->InvalidateSelection( GetShell()->GetLayout()->GetPageByPageNum( nSelPage ) ); + mpPreview->InvalidateSelection(GetShell().GetLayout()->GetPageByPageNum(nSelPage)); rtl::Reference < SwAccessibleContext > xOldAcc = mxCursorContext; rtl::Reference < SwAccessibleContext > xAcc; @@ -2897,7 +2897,7 @@ tools::Rectangle SwAccessibleMap::GetVisibleArea() const Point SwAccessibleMap::LogicToPixel( const Point& rPoint ) const { Point aPoint = o3tl::toTwips( rPoint, o3tl::Length::mm100 ); - if (const vcl::Window* pWin = GetShell()->GetWin()) + if (const vcl::Window* pWin = GetShell().GetWin()) { const MapMode aMapMode = GetMapMode(aPoint); aPoint = pWin->LogicToPixel( aPoint, aMapMode ); @@ -2910,7 +2910,7 @@ Point SwAccessibleMap::LogicToPixel( const Point& rPoint ) const Size SwAccessibleMap::LogicToPixel( const Size& rSize ) const { Size aSize( o3tl::toTwips( rSize, o3tl::Length::mm100 ) ); - if (const OutputDevice* pWin = GetShell()->GetWin()->GetOutDev()) + if (const OutputDevice* pWin = GetShell().GetWin()->GetOutDev()) { const MapMode aMapMode = GetMapMode(Point(0, 0)); aSize = pWin->LogicToPixel( aSize, aMapMode ); @@ -3019,7 +3019,7 @@ XAccessible* Point SwAccessibleMap::PixelToCore( const Point& rPoint ) const { Point aPoint; - if (const OutputDevice* pWin = GetShell()->GetWin()->GetOutDev()) + if (const OutputDevice* pWin = GetShell().GetWin()->GetOutDev()) { const MapMode aMapMode = GetMapMode(rPoint); aPoint = pWin->PixelToLogic( rPoint, aMapMode ); @@ -3063,7 +3063,7 @@ static void lcl_CorrectRectangle(tools::Rectangle & rRect, tools::Rectangle SwAccessibleMap::CoreToPixel( const SwRect& rRect ) const { tools::Rectangle aRect; - if (const OutputDevice* pWin = GetShell()->GetWin()->GetOutDev()) + if (const OutputDevice* pWin = GetShell().GetWin()->GetOutDev()) { const MapMode aMapMode = GetMapMode(rRect.TopLeft()); aRect = pWin->LogicToPixel( rRect.SVRect(), aMapMode ); @@ -3085,8 +3085,8 @@ tools::Rectangle SwAccessibleMap::CoreToPixel( const SwRect& rRect ) const */ MapMode SwAccessibleMap::GetMapMode(const Point& _rPoint) const { - MapMode aMapMode = GetShell()->GetWin()->GetMapMode(); - if( GetShell()->IsPreview() ) + MapMode aMapMode = GetShell().GetWin()->GetMapMode(); + if ( GetShell().IsPreview()) { assert(mpPreview != nullptr); mpPreview->AdjustMapMode( aMapMode, _rPoint ); @@ -3096,9 +3096,9 @@ MapMode SwAccessibleMap::GetMapMode(const Point& _rPoint) const Size SwAccessibleMap::GetPreviewPageSize(sal_uInt16 const nPreviewPageNum) const { - assert(mpVSh->IsPreview()); + assert(m_rViewShell.IsPreview()); assert(mpPreview != nullptr); - return mpVSh->PagePreviewLayout()->GetPreviewPageSizeByPageNum(nPreviewPageNum); + return m_rViewShell.PagePreviewLayout()->GetPreviewPageSizeByPageNum(nPreviewPageNum); } /** method to build up a new data structure of the accessible paragraphs, @@ -3116,7 +3116,7 @@ std::unique_ptr<SwAccessibleSelectedParas_Impl> SwAccessibleMap::BuildSelectedPa // get cursor as an instance of its base class <SwPaM> SwPaM* pCursor( nullptr ); { - SwCursorShell* pCursorShell = dynamic_cast<SwCursorShell*>(GetShell()); + SwCursorShell* pCursorShell = dynamic_cast<SwCursorShell*>(&GetShell()); if ( pCursorShell ) { SwFEShell* pFEShell = dynamic_cast<SwFEShell*>(pCursorShell); @@ -3284,16 +3284,16 @@ void SwAccessibleMap::InvalidateTextSelectionOfAllParas() const SwRect& SwAccessibleMap::GetVisArea() const { - assert(!GetShell()->IsPreview() || (mpPreview != nullptr)); + assert(!GetShell().IsPreview() || (mpPreview != nullptr)); - return GetShell()->IsPreview() + return GetShell().IsPreview() ? mpPreview->GetVisArea() - : GetShell()->VisArea(); + : GetShell().VisArea(); } bool SwAccessibleMap::IsDocumentSelAll() { - return GetShell()->GetDoc()->IsPrepareSelAll(); + return GetShell().GetDoc()->IsPrepareSelAll(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index f7d6c8371f26..5f8032ae359f 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -431,7 +431,7 @@ void SwAccessibleParagraph::UpdatePortionData() OSL_ENSURE( pFrame->IsTextFrame(), "The text frame has mutated!" ); // build new portion data m_pPortionData.reset( new SwAccessiblePortionData( - pFrame, GetMap()->GetShell()->GetViewOptions()) ); + pFrame, GetMap()->GetShell().GetViewOptions()) ); pFrame->VisitPortions( *m_pPortionData ); } OSL_ENSURE( m_pPortionData != nullptr, "UpdatePortionData() failed" ); @@ -446,10 +446,9 @@ void SwAccessibleParagraph::ClearPortionData() void SwAccessibleParagraph::ExecuteAtViewShell( sal_uInt16 nSlot ) { OSL_ENSURE( GetMap() != nullptr, "no map?" ); - SwViewShell* pViewShell = GetMap()->GetShell(); + SwViewShell& rViewShell = GetMap()->GetShell(); - assert(pViewShell != nullptr && "View shell expected!"); - SfxViewShell* pSfxShell = pViewShell->GetSfxViewShell(); + SfxViewShell* pSfxShell = rViewShell.GetSfxViewShell(); OSL_ENSURE( pSfxShell != nullptr, "SfxViewShell shell expected!" ); if( !pSfxShell ) @@ -2428,10 +2427,9 @@ sal_Bool SwAccessibleParagraph::scrollSubstringTo( sal_Int32 nStartIndex, } const SwRect aRect(startPoint, endPoint); - SwViewShell* pViewShell = GetMap()->GetShell(); - OSL_ENSURE( pViewShell != nullptr, "View shell expected!" ); + SwViewShell& rViewShell = GetMap()->GetShell(); - ScrollMDI(pViewShell, aRect, USHRT_MAX, USHRT_MAX); + ScrollMDI(&rViewShell, aRect, USHRT_MAX, USHRT_MAX); return true; } diff --git a/sw/source/core/access/accselectionhelper.cxx b/sw/source/core/access/accselectionhelper.cxx index 0a77c606970d..7a83065126b1 100644 --- a/sw/source/core/access/accselectionhelper.cxx +++ b/sw/source/core/access/accselectionhelper.cxx @@ -53,11 +53,9 @@ SwAccessibleSelectionHelper::SwAccessibleSelectionHelper( SwFEShell* SwAccessibleSelectionHelper::GetFEShell() { OSL_ENSURE( m_rContext.GetMap() != nullptr, "no map?" ); - SwViewShell* pViewShell = m_rContext.GetMap()->GetShell(); - OSL_ENSURE( pViewShell != nullptr, - "No view shell? Then what are you looking at?" ); + SwViewShell& rViewShell = m_rContext.GetMap()->GetShell(); - SwFEShell* pFEShell = dynamic_cast<SwFEShell*>( pViewShell ); + SwFEShell* pFEShell = dynamic_cast<SwFEShell*>(&rViewShell); return pFEShell; } diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx index cd5d9178f39d..bed6ad867587 100644 --- a/sw/source/core/view/viewimp.cxx +++ b/sw/source/core/view/viewimp.cxx @@ -516,7 +516,7 @@ void SwViewShellImp::InvalidateAccessiblePreviewSelection( sal_uInt16 nSelPage ) SwAccessibleMap *SwViewShellImp::CreateAccessibleMap() { assert(!m_pAccessibleMap); - m_pAccessibleMap = std::make_shared<SwAccessibleMap>(&GetShell()); + m_pAccessibleMap = std::make_shared<SwAccessibleMap>(GetShell()); return m_pAccessibleMap.get(); }
