Kaydet (Commit) 9933690d authored tarafından Michael Stahl's avatar Michael Stahl

sw_redlinehide_3: stop SwAccessibleParagraph listening at SwTextNode

The SwAccessibleParagraph is a client of SwTextNode, just so that it can
dispose its mpParaChangeTrackInfo on any and all editing operations.

This won't work with merged paragraphs, but on the other hand it's not
necessary with merged paragraphs because the
initChangeTrackTextMarkupLists() does nothing if IsHideRedlines().

However there is the problem that the node and the frame might become
mis-matched if the frame is "moved around", so to avoid problems due to
that, listen on the SwTextFrame instead of the node, and have the
SwTextFrame relay any events it gets.

Though the frame is only SwClient, this is now possible thanks to
the SfxBroadcaster on the SwFrame class, so convert to SfxListener;
also the Accessible lifetime is tied to SwTextFrame anyway.

In UnHideRedlines(), send a dummy event too so that toggling Show/Hide
disposes the mpParaChangeTrackInfo too, which previously happened
as a side effect of moving the redlines around in the nodes-array.

Change-Id: I4e5a7107cb55d408266ee42463f9fa2a4a8b721b
üst a12bb53c
...@@ -533,8 +533,7 @@ void SwAccessibleParagraph::InvalidateFocus_() ...@@ -533,8 +533,7 @@ void SwAccessibleParagraph::InvalidateFocus_()
SwAccessibleParagraph::SwAccessibleParagraph( SwAccessibleParagraph::SwAccessibleParagraph(
std::shared_ptr<SwAccessibleMap> const& pInitMap, std::shared_ptr<SwAccessibleMap> const& pInitMap,
const SwTextFrame& rTextFrame ) const SwTextFrame& rTextFrame )
: SwClient( const_cast<SwTextNode*>(rTextFrame.GetTextNode()) ) // #i108125# : SwAccessibleContext( pInitMap, AccessibleRole::PARAGRAPH, &rTextFrame )
, SwAccessibleContext( pInitMap, AccessibleRole::PARAGRAPH, &rTextFrame )
, m_sDesc() , m_sDesc()
, m_nOldCaretPos( -1 ) , m_nOldCaretPos( -1 )
, m_bIsHeading( false ) , m_bIsHeading( false )
...@@ -544,6 +543,7 @@ SwAccessibleParagraph::SwAccessibleParagraph( ...@@ -544,6 +543,7 @@ SwAccessibleParagraph::SwAccessibleParagraph(
, mpParaChangeTrackInfo( new SwParaChangeTrackingInfo( rTextFrame ) ) // #i108125# , mpParaChangeTrackInfo( new SwParaChangeTrackingInfo( rTextFrame ) ) // #i108125#
, m_bLastHasSelection(false) //To add TEXT_SELECTION_CHANGED event , m_bLastHasSelection(false) //To add TEXT_SELECTION_CHANGED event
{ {
StartListening(const_cast<SwTextFrame&>(rTextFrame));
m_bIsHeading = IsHeading(); m_bIsHeading = IsHeading();
//Get the real heading level, Heading1 ~ Heading10 //Get the real heading level, Heading1 ~ Heading10
m_nHeadingLevel = GetRealHeadingLevel(); m_nHeadingLevel = GetRealHeadingLevel();
...@@ -3517,11 +3517,9 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getNumberOfLineWithCaret() ...@@ -3517,11 +3517,9 @@ sal_Int32 SAL_CALL SwAccessibleParagraph::getNumberOfLineWithCaret()
} }
// #i108125# // #i108125#
void SwAccessibleParagraph::Modify( const SfxPoolItem* pOld, const SfxPoolItem* /*pNew*/ ) void SwAccessibleParagraph::Notify(SfxBroadcaster&, const SfxHint&)
{ {
mpParaChangeTrackInfo->reset(); mpParaChangeTrackInfo->reset();
CheckRegistration( pOld );
} }
bool SwAccessibleParagraph::GetSelectionAtIndex( bool SwAccessibleParagraph::GetSelectionAtIndex(
......
...@@ -53,7 +53,7 @@ typedef std::unordered_map< OUString, ...@@ -53,7 +53,7 @@ typedef std::unordered_map< OUString,
css::beans::PropertyValue > tAccParaPropValMap; css::beans::PropertyValue > tAccParaPropValMap;
class SwAccessibleParagraph : class SwAccessibleParagraph :
public SwClient, // #i108125# public SfxListener,
public SwAccessibleContext, public SwAccessibleContext,
public css::accessibility::XAccessibleEditableText, public css::accessibility::XAccessibleEditableText,
public css::accessibility::XAccessibleSelection, public css::accessibility::XAccessibleSelection,
...@@ -225,7 +225,7 @@ protected: ...@@ -225,7 +225,7 @@ protected:
sal_Int32 nPos, sal_Int32 nPos,
sal_Int16 aTextType ); sal_Int16 aTextType );
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew) override; virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
public: public:
......
...@@ -4340,6 +4340,7 @@ static void UnHideRedlines(SwRootFrame & rLayout, ...@@ -4340,6 +4340,7 @@ static void UnHideRedlines(SwRootFrame & rLayout,
pFrame->SetMergedPara(nullptr); pFrame->SetMergedPara(nullptr);
} }
} }
pFrame->Broadcast(SfxHint()); // notify SwAccessibleParagraph
} }
} }
if (!rNode.IsCreateFrameWhenHidingRedlines()) if (!rNode.IsCreateFrameWhenHidingRedlines())
......
...@@ -1823,6 +1823,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) ...@@ -1823,6 +1823,8 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
} }
} }
Broadcast(SfxHint()); // notify SwAccessibleParagraph
// while locked ignore all modifications // while locked ignore all modifications
if( IsLocked() ) if( IsLocked() )
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment