summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-05-29 14:09:08 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2018-06-08 21:51:33 +0200
commit0356b46e3a37017134fdcf4b7300d1496de44573 (patch)
tree73f708d64ce944f678f17181422fa92b52ae7089 /sw/source/core
parentf579109b9253a70751920e75af9000deafc23cb1 (diff)
sw_redlinehide: use WriterMultiListener to connect SwTextFrame
... with multiple SwTextNodes in CheckParaRedlineMerge() Change-Id: I57402ca7d2210fc30015b9a7e2e05216e0b8a8eb
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/inc/txtfrm.hxx40
-rw-r--r--sw/source/core/layout/ssfrm.cxx5
-rw-r--r--sw/source/core/text/redlnitr.cxx12
-rw-r--r--sw/source/core/text/txtfrm.cxx1
4 files changed, 37 insertions, 21 deletions
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index eebbf7a65541..77b244042551 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -88,23 +88,7 @@ struct Extent
}
};
-struct MergedPara
-{
- std::vector<Extent> const extents;
- /// note: cannot be const currently to avoid UB because SwTextGuess::Guess
- /// const_casts it and modifies it
- OUString mergedText;
- /// most paragraph properties are taken from the first non-empty node
- SwTextNode const*const pParaPropsNode;
- /// except break attributes, those are taken from the first node
- SwTextNode *const pFirstNode;
- MergedPara(std::vector<Extent>&& rExtents, OUString const& rText, SwTextNode const*const pProps, SwTextNode *const pFirst)
- : extents(std::move(rExtents)), mergedText(rText), pParaPropsNode(pProps), pFirstNode(pFirst)
- {
- assert(pParaPropsNode);
- assert(pFirstNode);
- }
-};
+struct MergedPara;
std::pair<SwTextNode*, sal_Int32> MapViewToModel(MergedPara const&, TextFrameIndex nIndex);
TextFrameIndex MapModelToView(MergedPara const&, SwTextNode const* pNode, sal_Int32 nIndex);
@@ -917,7 +901,27 @@ public:
namespace sw {
-struct MergedPara;
+struct MergedPara
+{
+ sw::WriterMultiListener listener;
+ std::vector<Extent> const extents;
+ /// note: cannot be const currently to avoid UB because SwTextGuess::Guess
+ /// const_casts it and modifies it
+ OUString mergedText;
+ /// most paragraph properties are taken from the first non-empty node
+ SwTextNode const*const pParaPropsNode;
+ /// except break attributes, those are taken from the first node
+ SwTextNode *const pFirstNode;
+ MergedPara(SwTextFrame & rFrame, std::vector<Extent>&& rExtents,
+ OUString const& rText,
+ SwTextNode const*const pProps, SwTextNode *const pFirst)
+ : listener(rFrame), extents(std::move(rExtents)), mergedText(rText)
+ , pParaPropsNode(pProps), pFirstNode(pFirst)
+ {
+ assert(pParaPropsNode);
+ assert(pFirstNode);
+ }
+};
/// iterate SwTextAttr in potentially merged text frame
class MergedAttrIterBase
diff --git a/sw/source/core/layout/ssfrm.cxx b/sw/source/core/layout/ssfrm.cxx
index a0b035ebaee7..b2fd7113c0b4 100644
--- a/sw/source/core/layout/ssfrm.cxx
+++ b/sw/source/core/layout/ssfrm.cxx
@@ -438,7 +438,10 @@ void SwTextFrame::RegisterToNode(SwTextNode & rNode)
{
assert(&rNode != GetRegisteredIn());
m_pMergedPara = sw::CheckParaRedlineMerge(*this, rNode);
- rNode.Add( this );
+ if (!m_pMergedPara)
+ {
+ rNode.Add(this);
+ }
}
void SwLayoutFrame::DestroyImpl()
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 44fa965d8387..0640001dddb0 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -55,6 +55,7 @@ CheckParaRedlineMerge(SwTextFrame & rFrame, SwTextNode & rTextNode)
return nullptr;
}
bool bHaveRedlines(false);
+ std::vector<SwTextNode *> nodes{ &rTextNode };
std::vector<sw::Extent> extents;
OUStringBuffer mergedText;
SwTextNode const* pParaPropsNode(nullptr);
@@ -92,6 +93,7 @@ CheckParaRedlineMerge(SwTextFrame & rFrame, SwTextNode & rTextNode)
}
pNode = pEnd->nNode.GetNode().GetTextNode();
assert(pNode);
+ nodes.push_back(pNode);
pNode->SetRedlineMergeFlag(SwNode::Merge::NonFirst);
}
nLastEnd = pEnd->nContent.GetIndex();
@@ -115,8 +117,14 @@ CheckParaRedlineMerge(SwTextFrame & rFrame, SwTextNode & rTextNode)
assert(!mergedText.isEmpty());
pParaPropsNode = extents.begin()->pNode; // para props from first node that isn't empty
}
- return o3tl::make_unique<sw::MergedPara>(std::move(extents),
- mergedText.makeStringAndClear(), pParaPropsNode, &rTextNode);
+ auto pRet(o3tl::make_unique<sw::MergedPara>(rFrame, std::move(extents),
+ mergedText.makeStringAndClear(), pParaPropsNode, &rTextNode));
+ for (SwTextNode * pTmp : nodes)
+ {
+ pRet->listener.StartListening(pTmp);
+ }
+ rFrame.EndListeningAll();
+ return pRet;
}
} // namespace sw
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index b1d27f0360e2..8e5a7f221a9e 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -581,6 +581,7 @@ SwTextFrame::SwTextFrame(SwTextNode * const pNode, SwFrame* pSib )
, mnFootnoteLine( 0 )
, mnHeightOfLastLine( 0 )
, mnAdditionalFirstLineOffset( 0 )
+ // note: this may change this->pRegisteredIn to m_pMergedPara->listeners
, m_pMergedPara(CheckParaRedlineMerge(*this, *pNode)) // ensure it is inited
, mnOffset( 0 )
, mnCacheIndex( USHRT_MAX )