summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-12-12 15:58:17 +0100
committerMichael Stahl <Michael.Stahl@cib.de>2018-12-13 14:52:54 +0100
commit90b55ebf380c29413a30db699f0f574951b1cb6f (patch)
treed2329bfdae200df865f279e9c1e9ae4ab06c49ee /sw/source
parent6b47deed575c3372f336158f518e795144f46ad8 (diff)
sw_redlinehide_4b: SwCursorShell::GotoRefMark() check visibility too
As seen in ooo50225-1.sxw. Change-Id: I9f0bc0838cbf216b9a73e3ce6bc06b4340064077
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/crsr/crstrvl.cxx2
-rw-r--r--sw/source/core/fields/reffld.cxx53
2 files changed, 48 insertions, 7 deletions
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index e7e8373d0549..9ce04fccb566 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1234,7 +1234,7 @@ bool SwCursorShell::GotoRefMark( const OUString& rRefMark, sal_uInt16 nSubType,
sal_Int32 nPos = -1;
SwTextNode* pTextNd = SwGetRefFieldType::FindAnchor( GetDoc(), rRefMark,
- nSubType, nSeqNo, &nPos );
+ nSubType, nSeqNo, &nPos, nullptr, GetLayout());
if( pTextNd && pTextNd->GetNodes().IsDocNodes() )
{
m_pCurrentCursor->GetPoint()->nNode = *pTextNd;
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index 40793345af65..a9e47360dc89 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -1104,19 +1104,49 @@ void SwGetRefFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew
NotifyClients( pOld, pNew );
}
+static bool
+IsRefMarkHidden(SwRootFrame const& rLayout, SwTextRefMark const& rRefMark)
+{
+ if (!rLayout.IsHideRedlines())
+ {
+ return false;
+ }
+ SwTextNode const& rNode(rRefMark.GetTextNode());
+ SwTextFrame const*const pFrame(static_cast<SwTextFrame const*>(
+ rNode.getLayoutFrame(&rLayout)));
+ if (!pFrame)
+ {
+ return true;
+ }
+ sal_Int32 const*const pEnd(const_cast<SwTextRefMark&>(rRefMark).GetEnd());
+ if (pEnd)
+ {
+ return pFrame->MapModelToView(&rNode, rRefMark.GetStart())
+ == pFrame->MapModelToView(&rNode, *pEnd);
+ }
+ else
+ {
+ return pFrame->MapModelToView(&rNode, rRefMark.GetStart())
+ == pFrame->MapModelToView(&rNode, rRefMark.GetStart() + 1);
+ }
+}
+
SwTextNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const OUString& rRefMark,
sal_uInt16 nSubType, sal_uInt16 nSeqNo,
- sal_Int32* pStt, sal_Int32* pEnd )
+ sal_Int32* pStt, sal_Int32* pEnd,
+ SwRootFrame const*const pLayout)
{
OSL_ENSURE( pStt, "Why did no one check the StartPos?" );
+ IDocumentRedlineAccess & rIDRA(pDoc->getIDocumentRedlineAccess());
SwTextNode* pTextNd = nullptr;
switch( nSubType )
{
case REF_SETREFATTR:
{
const SwFormatRefMark *pRef = pDoc->GetRefMark( rRefMark );
- if( pRef && pRef->GetTextRefMark() )
+ SwTextRefMark const*const pRefMark(pRef ? pRef->GetTextRefMark() : nullptr);
+ if (pRefMark && (!pLayout || !IsRefMarkHidden(*pLayout, *pRefMark)))
{
pTextNd = const_cast<SwTextNode*>(&pRef->GetTextRefMark()->GetTextNode());
*pStt = pRef->GetTextRefMark()->GetStart();
@@ -1135,10 +1165,12 @@ SwTextNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const OUString& rRefMark
SwIterator<SwFormatField,SwFieldType> aIter( *pFieldType );
for( SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next() )
{
- if( pFormatField->GetTextField() && nSeqNo ==
- static_cast<SwSetExpField*>(pFormatField->GetField())->GetSeqNumber() )
+ SwTextField *const pTextField(pFormatField->GetTextField());
+ if (pTextField && nSeqNo ==
+ static_cast<SwSetExpField*>(pFormatField->GetField())->GetSeqNumber()
+ && (!pLayout || !pLayout->IsHideRedlines()
+ || !sw::IsFieldDeletedInModel(rIDRA, *pTextField)))
{
- SwTextField* pTextField = pFormatField->GetTextField();
pTextNd = pTextField->GetpTextNode();
*pStt = pTextField->GetStart();
if( pEnd )
@@ -1153,7 +1185,9 @@ SwTextNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const OUString& rRefMark
case REF_BOOKMARK:
{
IDocumentMarkAccess::const_iterator_t ppMark = pDoc->getIDocumentMarkAccess()->findMark(rRefMark);
- if(ppMark != pDoc->getIDocumentMarkAccess()->getAllMarksEnd())
+ if (ppMark != pDoc->getIDocumentMarkAccess()->getAllMarksEnd()
+ && (!pLayout || !pLayout->IsHideRedlines()
+ || !sw::IsMarkHidden(*pLayout, **ppMark)))
{
const ::sw::mark::IMark* pBkmk = ppMark->get();
const SwPosition* pPos = &pBkmk->GetMarkStart();
@@ -1191,6 +1225,13 @@ SwTextNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const OUString& rRefMark
for( auto pFootnoteIdx : pDoc->GetFootnoteIdxs() )
if( nSeqNo == pFootnoteIdx->GetSeqRefNo() )
{
+ if (pLayout && pLayout->IsHideRedlines()
+ && sw::IsFootnoteDeleted(rIDRA, *pFootnoteIdx))
+ {
+ return nullptr;
+ }
+ // otherwise: the position at the start of the footnote
+ // will be mapped to something visible at least...
SwNodeIndex* pIdx = pFootnoteIdx->GetStartNode();
if( pIdx )
{