[Libreoffice-commits] core.git: sw/inc sw/qa sw/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jul 13 14:49:23 UTC 2021
sw/inc/swtable.hxx | 3 +++
sw/qa/extras/uiwriter/data/TC-table-rowadd.docx |binary
sw/source/core/doc/DocumentRedlineManager.cxx | 22 +++++-----------------
sw/source/core/table/swtable.cxx | 10 ++++++++++
sw/source/core/unocore/unocrsrhelper.cxx | 16 ++++++++++++++--
5 files changed, 32 insertions(+), 19 deletions(-)
New commits:
commit a483a44ca00f43a64ae51d62b8fbb4129a413f6d
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Tue Jul 13 13:35:15 2021 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Tue Jul 13 16:48:46 2021 +0200
tdf#143215 DOCX import: fix tracked empty row insertion/deletion
Rejecting tracked empty row insertion, or accepting tracked
empty row deletion didn't remove the line from the table.
Regression from commit c4cf85766453982f1aa94a7f2cb22af19ed100be
"sw: fix crash due to redlines on tables on ooo121112-2.docx".
Note: as a workaround for the empty rows, i.e. rows without
text content, add a redline with invisible text ZWJ in the
first cell of the empty row.
Follow-up to commit 03b29d4ddb99337c4d54b241020c95e8b2a66991
"tdf#143278 DOCX: support tracked table (row) insertion",
commit 05366b8e6683363688de8708a3d88cf144c7a2bf
"tdf#60382 sw offapi: add change tracking of table/row deletion"
and commit 896c2199d9f0a28bd405dd2d1068f5e2973cdf06
"tdf#79069 DOCX: support tracked table (row) deletion".
Change-Id: I8616a9d6f4a8d21e88c55d935f14a8c6a73c28ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118839
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 6c98d5bed360..ce1982312f75 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -386,6 +386,9 @@ public:
SwTwips GetTableLineHeight( bool& bLayoutAvailable ) const;
bool hasSoftPageBreak() const;
+
+ // it doesn't contain box content
+ bool IsEmpty() const;
};
/// SwTableBox is one table cell in the document model.
diff --git a/sw/qa/extras/uiwriter/data/TC-table-rowadd.docx b/sw/qa/extras/uiwriter/data/TC-table-rowadd.docx
new file mode 100644
index 000000000000..b654b959054e
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/TC-table-rowadd.docx differ
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 0196ea4d5e30..1a3e0da61041 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -443,24 +443,12 @@ namespace
const SwTableLine* pLine = pBox->GetUpper();
const SvxPrintItem *pHasTextChangesOnlyProp =
pLine->GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT);
- // table row property "HasTextChangesOnly" is set and its value is false
- if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() )
+ // empty table row with property "HasTextChangesOnly" = false
+ if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() &&
+ pLine->IsEmpty() )
{
- bool bEmptyLine = true;
- const SwTableBoxes & rBoxes = pLine->GetTabBoxes();
- for (size_t nBox = 0; nBox < rBoxes.size(); ++nBox)
- {
- if ( !rBoxes[nBox]->IsEmpty() )
- {
- bEmptyLine = false;
- break;
- }
- }
- if ( bEmptyLine )
- {
- SwCursor aCursor( *pPos, nullptr );
- pPos->GetDoc().DeleteRow( aCursor );
- }
+ SwCursor aCursor( *pPos, nullptr );
+ pPos->GetDoc().DeleteRow( aCursor );
}
}
}
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 1da79f960545..c750aa3d75f9 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1545,6 +1545,16 @@ SwTwips SwTableLine::GetTableLineHeight( bool& bLayoutAvailable ) const
return nRet;
}
+bool SwTableLine::IsEmpty() const
+{
+ for (size_t i = 0; i < m_aBoxes.size(); ++i)
+ {
+ if ( !m_aBoxes[i]->IsEmpty() )
+ return false;
+ }
+ return true;
+}
+
SwTableBox::SwTableBox( SwTableBoxFormat* pFormat, sal_uInt16 nLines, SwTableLine *pUp )
: SwClient(nullptr)
, m_aLines()
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index aaa223d02894..a04341135117 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -1411,8 +1411,20 @@ void makeTableRowRedline( SwTableLine& rTableLine,
if ( !pHasTextChangesOnlyProp || pHasTextChangesOnlyProp->GetValue() )
{
SvxPrintItem aSetTracking(RES_PRINT, false);
- SwPosition aPos( *rTableLine.GetTabBoxes()[0]->GetSttNd() );
- SwCursor aCursor( aPos, nullptr );
+ SwNodeIndex aInsPos( *(rTableLine.GetTabBoxes()[0]->GetSttNd()), 1 );
+ // as a workaround for the rows without text content,
+ // add a redline with invisible text ZWJ
+ if ( rTableLine.IsEmpty() )
+ {
+ SwPaM aPaM(aInsPos);
+ pDoc->getIDocumentContentOperations().InsertString( aPaM, u"" );
+ aPaM.SetMark();
+ aPaM.GetMark()->nContent.Assign(aPaM.GetContentNode(), 0);
+ makeRedline(aPaM, RedlineType::TableRowInsert == eType
+ ? u"Insert"
+ : u"Delete", rRedlineProperties);
+ }
+ SwCursor aCursor( SwPosition(aInsPos), nullptr );
pDoc->SetRowNotTracked( aCursor, aSetTracking );
}
More information about the Libreoffice-commits
mailing list