summaryrefslogtreecommitdiff
path: root/sw/source/core/layout
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-12-06 12:32:20 +0100
committerMichael Stahl <Michael.Stahl@cib.de>2018-12-06 19:04:15 +0100
commita696e85ca462b157033855e24db3f4ce912ebb7a (patch)
tree210ce906c341d6ad1c6aa856a2210e487a894788 /sw/source/core/layout
parent4f37f275015ee0c433efc09d8615d997f91d8a92 (diff)
sw_redlinehide_4b: fix some problems with pathological table redlines
As seen in ooo95711-1.odt, the ODF import may create a redline that starts on a SwTableNode - though i haven't been able to figure out how such an odd creature might arise from UI actions. Try to fix the obvious places so we don't crash easily; there might be more trouble elsewhere though with code that assumes that a redline starts on a SwTextNode. Change-Id: I8431c1416ac4503ff0209a946398656f1c28366d
Diffstat (limited to 'sw/source/core/layout')
-rw-r--r--sw/source/core/layout/frmtool.cxx26
-rw-r--r--sw/source/core/layout/wsfrm.cxx18
2 files changed, 44 insertions, 0 deletions
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index f1c11bb23103..dda68bc72473 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -59,6 +59,7 @@
#include <laycache.hxx>
#include <rootfrm.hxx>
#include <paratr.hxx>
+#include <redline.hxx>
#include <sortedobjs.hxx>
#include <objectformatter.hxx>
#include <calbck.hxx>
@@ -1446,6 +1447,31 @@ void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc,
else if ( pNd->IsTableNode() )
{ //Should we have encountered a table?
SwTableNode *pTableNode = static_cast<SwTableNode*>(pNd);
+ if (pLayout->IsHideRedlines())
+ {
+ // in the problematic case, there can be only 1 redline...
+ SwPosition const tmp(*pNd);
+ SwRangeRedline const*const pRedline(
+ pDoc->getIDocumentRedlineAccess().GetRedline(tmp, nullptr));
+ // pathology: redline that starts on a TableNode; cannot
+ // be created in UI but by import filters...
+ if (pRedline
+ && pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE
+ && &pRedline->Start()->nNode.GetNode() == pNd)
+ {
+ SAL_WARN("sw.pageframe", "skipping table frame creation on bizarre redline");
+ while (true)
+ {
+ pTableNode->GetNodes()[nIndex]->SetRedlineMergeFlag(SwNode::Merge::Hidden);
+ if (nIndex == pTableNode->EndOfSectionIndex())
+ {
+ break;
+ }
+ ++nIndex;
+ }
+ continue;
+ }
+ }
if (pLayout->IsHideRedlines() && !pNd->IsCreateFrameWhenHidingRedlines())
{
assert(pNd->GetRedlineMergeFlag() == SwNode::Merge::Hidden);
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index aa2cd56249f6..9cebf22c8229 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -4349,6 +4349,24 @@ static void UnHideRedlines(SwRootFrame & rLayout,
rTextNode.NumRuleChgd();
}
}
+ else if (rNode.IsTableNode() && rLayout.IsHideRedlines())
+ {
+ SwPosition const tmp(rNode);
+ SwRangeRedline const*const pRedline(
+ rLayout.GetFormat()->GetDoc()->getIDocumentRedlineAccess().GetRedline(tmp, nullptr));
+ // pathology: redline that starts on a TableNode; cannot
+ // be created in UI but by import filters...
+ if (pRedline
+ && pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE
+ && &pRedline->Start()->nNode.GetNode() == &rNode)
+ {
+ for (sal_uLong j = rNode.GetIndex(); j <= rNode.EndOfSectionIndex(); ++j)
+ {
+ rNode.GetNodes()[j]->SetRedlineMergeFlag(SwNode::Merge::Hidden);
+ }
+ rNode.GetTableNode()->DelFrames(&rLayout);
+ }
+ }
if (!rNode.IsCreateFrameWhenHidingRedlines())
{
if (rLayout.IsHideRedlines())