sw/inc/node.hxx | 2 sw/inc/undobj.hxx | 6 sw/qa/extras/uiwriter/data/tdf132160.odt |binary sw/qa/extras/uiwriter/data/tdf132911.odt |binary sw/qa/extras/uiwriter/data/tdf133967.odt |binary sw/qa/extras/uiwriter/data/tdf133982.docx |binary sw/qa/extras/uiwriter/data/tdf133990.odt |binary sw/qa/extras/uiwriter/data/tdf134021.docx |binary sw/qa/extras/uiwriter/data/tdf134250.fodt | 86 ++ sw/qa/extras/uiwriter/data/tdf134252.fodt | 95 ++ sw/qa/extras/uiwriter/data/tdf134436.fodt | 83 ++ sw/qa/extras/uiwriter/data/tdf134931.odt |binary sw/qa/extras/uiwriter/data/tdf135056.odt |binary sw/qa/extras/uiwriter/data/tdf136453.fodt | 66 + sw/qa/extras/uiwriter/data2/try2.fodt | 66 + sw/qa/extras/uiwriter/uiwriter.cxx | 655 ++++++++++++++++ sw/qa/extras/uiwriter/uiwriter2.cxx | 97 ++ sw/qa/uitest/writer_tests/data/tdf135018.odt |binary sw/qa/uitest/writer_tests/trackedChanges.py | 36 sw/source/core/doc/DocumentContentOperationsManager.cxx | 43 - sw/source/core/doc/DocumentRedlineManager.cxx | 268 ++++-- sw/source/core/docnode/ndsect.cxx | 8 sw/source/core/docnode/nodes.cxx | 13 sw/source/core/edit/eddel.cxx | 12 sw/source/core/edit/edglss.cxx | 7 sw/source/core/layout/colfrm.cxx | 3 sw/source/core/layout/frmtool.cxx | 9 sw/source/core/layout/tabfrm.cxx | 1 sw/source/core/layout/trvlfrm.cxx | 61 - sw/source/core/text/redlnitr.cxx | 2 sw/source/core/text/txtfrm.cxx | 6 sw/source/core/txtnode/ndtxt.cxx | 31 sw/source/core/undo/unattr.cxx | 5 sw/source/core/undo/undel.cxx | 38 sw/source/core/undo/untblk.cxx | 38 sw/source/uibase/wrtsh/wrtsh1.cxx | 4 36 files changed, 1551 insertions(+), 190 deletions(-)
New commits: commit 3270dbc15af87f9b8bdc62bba832ec2a5420d431 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Sep 1 17:30:44 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 16:45:03 2020 +0100 tdf#135018: sw: Add UItest Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101883 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit b6ab2330d97672936edc56de8d6f5b6f772908ff) Change-Id: Ia88e28b1569ea69df81d905cb76a6791a887ef3f diff --git a/sw/qa/uitest/writer_tests/data/tdf135018.odt b/sw/qa/uitest/writer_tests/data/tdf135018.odt new file mode 100644 index 000000000000..2dc9e2a4da0d Binary files /dev/null and b/sw/qa/uitest/writer_tests/data/tdf135018.odt differ diff --git a/sw/qa/uitest/writer_tests/trackedChanges.py b/sw/qa/uitest/writer_tests/trackedChanges.py index 5bc8fecf7b03..274d65d99294 100644 --- a/sw/qa/uitest/writer_tests/trackedChanges.py +++ b/sw/qa/uitest/writer_tests/trackedChanges.py @@ -7,9 +7,13 @@ from uitest.framework import UITestCase from uitest.debug import sleep +from uitest.path import get_srcdir_url import time from uitest.uihelper.common import get_state_as_dict, type_text +def get_url_for_data_file(file_name): + return get_srcdir_url() + "/sw/qa/uitest/writer_tests/data/" + file_name + class trackedchanges(UITestCase): def test_tdf91270(self): @@ -151,4 +155,36 @@ class trackedchanges(UITestCase): self.assertEqual(document.Text.String[0:30], "Test LibreOffice Test2 Test4") self.ui_test.close_doc() + + def test_tdf135018(self): + self.ui_test.load_file(get_url_for_data_file("tdf135018.odt")) + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + document = self.ui_test.get_component() + + #self.assertEqual(5, document.CurrentController.PageCount) + + self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges") + xTrackDlg = self.xUITest.getTopFocusWindow() + changesList = xTrackDlg.getChild("changes") + self.assertEqual(147, len(changesList.getChildren())) + + # Without the fix in place, it would have crashed here + xAccBtn = xTrackDlg.getChild("acceptall") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(0, len(changesList.getChildren())) + + xUndoBtn = xTrackDlg.getChild("undo") + xUndoBtn.executeAction("CLICK", tuple()) + + self.assertEqual(147, len(changesList.getChildren())) + + xcloseBtn = xTrackDlg.getChild("close") + xcloseBtn.executeAction("CLICK", tuple()) + + #self.assertEqual(18, document.CurrentController.PageCount) + + self.ui_test.close_doc() + # vim: set shiftwidth=4 softtabstop=4 expandtab: commit 24fd8762f60659c7f13c7fc48f9a731ea016e029 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Mon Oct 12 17:43:28 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 16:24:28 2020 +0100 sw_redlinehide: fix crash in SwTextNode::SplitContentNode() Bug happens in the "top" branch of SplitContentNode(). SwTextNode::CutImpl() sends several hints to the SwTextFrame so that it invalidates itself; a SwInsText and a SwDelText most prominently. The SwInsText won't have an effect because the target node doesn't have text frames yet, but the SwDelText should be sufficient to update the text frames' MergedPara and invalidate the text frames. The MergedPara is re-created by SwTextFrame::RegisterToNode() anyway, but that *doesn't* invalidate the SwTextFrame. Then an additional SwDelText is sent, which will *not* invalidate the SwTextFrame, because its MergedPara is up-to-date so nothing gets deleted by the hint. It's unclear why the LockModify() is done here, since CVS initial import, perhaps it's some premature optimization; try to remove the manual sending of SwDelText and just let CutImpl() do it. Also remove an odd assert in UpdateMergedParaForMove() that i don't understand the reason for now. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104219 Tested-by: Michael Stahl <michael.st...@cib.de> Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit fefc0dfdcedbd0ef9d32c32be356f8086e756b33) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104252 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 6600403ad3f743c16eb4aef33627e7dbce3b153d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104291 (cherry picked from commit 3ee77ed55e9d1da8d0746e8c06ecf82ed429521e) Change-Id: Iba7196556f614356dba4def74f039a88f392eb0f diff --git a/sw/qa/extras/uiwriter/data2/try2.fodt b/sw/qa/extras/uiwriter/data2/try2.fodt new file mode 100644 index 000000000000..624a75a85ea9 --- /dev/null +++ b/sw/qa/extras/uiwriter/data2/try2.fodt @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rpt="http://openoffice.org/2005/report" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:d r3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:font-face-decls> + <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Lohit Devanagari" svg:font-family="'Lohit Devanagari'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Source Han Serif CN" svg:font-family="'Source Han Serif CN'" style:font-family-generic="system" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Serif CN" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/> + </style:default-style> + <style:default-style style:family="paragraph"> + <style:paragraph-properties fo:orphans="2" fo:widows="2" fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/> + <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Serif CN" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/> + </style:default-style> + <style:default-style style:family="table"> + <style:table-properties table:border-model="collapsing"/> + </style:default-style> + <style:default-style style:family="table-row"> + <style:table-row-properties fo:keep-together="auto"/> + </style:default-style> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + </office:styles> + <office:automatic-styles> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + <text:tracked-changes text:track-changes="false"> + <text:changed-region xml:id="ct110725936" text:id="ct110725936"> + <text:deletion> + <office:change-info> + <dc:creator>Unknown Author</dc:creator> + <dc:date>2020-10-12T19:26:19</dc:date> + </office:change-info> + </text:deletion> + </text:changed-region> + <text:changed-region xml:id="ct110726576" text:id="ct110726576"> + <text:deletion> + <office:change-info> + <dc:creator>Unknown Author</dc:creator> + <dc:date>2020-10-12T19:26:26</dc:date> + </office:change-info> + </text:deletion> + </text:changed-region> + </text:tracked-changes> + <text:p text:style-name="Standard">A<text:change-start text:change-id="ct110725936"/></text:p> + <text:p text:style-name="Standard"><text:change-end text:change-id="ct110725936"/>xxxxxxxxxxxxxxxxxx<text:change-start text:change-id="ct110726576"/>x</text:p> + <text:p text:style-name="Standard">y<text:change-end text:change-id="ct110726576"/>y</text:p> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 5b90d1346179..86bba13162d2 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -32,6 +32,7 @@ public: void testRedlineInHiddenSection(); void testTdf101534(); void testTdf131684(); + void testRedlineSplitContentNode(); void testTdf132236(); void testTdf109376_redline(); void testTdf109376(); @@ -41,6 +42,7 @@ public: CPPUNIT_TEST(testRedlineInHiddenSection); CPPUNIT_TEST(testTdf101534); CPPUNIT_TEST(testTdf131684); + CPPUNIT_TEST(testRedlineSplitContentNode); CPPUNIT_TEST(testTdf132236); CPPUNIT_TEST(testTdf109376_redline); CPPUNIT_TEST(testTdf109376); @@ -241,6 +243,48 @@ void SwUiWriterTest2::testRedlineInHiddenSection() CPPUNIT_ASSERT(pNode->GetNodes()[pNode->GetIndex() + 4]->IsEndNode()); } +void SwUiWriterTest2::testRedlineSplitContentNode() +{ + load(DATA_DIRECTORY, "try2.fodt"); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + SwWrtShell* const pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + + SwViewOption aViewOptions(*pWrtShell->GetViewOptions()); + // these are required so that IsBlank() is true + aViewOptions.SetBlank(true); + aViewOptions.SetViewMetaChars(true); + pWrtShell->ApplyViewOptions(aViewOptions); + + // enable redlining + lcl_dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + // hide + lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + + SwDocShell* const pDocShell = pTextDoc->GetDocShell(); + SwDoc* const pDoc = pDocShell->GetDoc(); + CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + CPPUNIT_ASSERT_MESSAGE( + "redlines should be visible", + IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); + + sw::UndoManager& rUndoManager = pDoc->GetUndoManager(); + + pWrtShell->CalcLayout(); + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 18, /*bBasicCall=*/false); + pWrtShell->SplitNode(true); + rUndoManager.Undo(); + // crashed + pWrtShell->SplitNode(true); + rUndoManager.Undo(); + rUndoManager.Redo(); + rUndoManager.Undo(); + rUndoManager.Redo(); + rUndoManager.Undo(); + pWrtShell->SplitNode(true); + rUndoManager.Undo(); +} + void SwUiWriterTest2::testTdf132236() { load(DATA_DIRECTORY, "tdf132236.odt"); diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 50f5c0cb5a3b..ea75eba6d012 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -1855,7 +1855,6 @@ void UpdateMergedParaForMove(sw::MergedPara & rMerged, } if (nLastEnd != rNode.Len()) // without nLen, string yet to be removed { - assert(rNode.Len() == 0 || nLastEnd < nSourceEnd); if (nLastEnd < nSourceEnd) { deleted.emplace_back(std::max(nLastEnd, nSourceStart), nSourceEnd); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index b6bb8b593ca9..6e4ec1a53320 100755 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -457,9 +457,7 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos, { // optimization for SplitNode: If a split is at the end of a node then // move the frames from the current to the new one and create new ones - // for the current one. As a result, no need for recreating the layout. - - LockModify(); // disable notifications + // for the current one. // If fly frames are moved, they don't need to destroy their layout // frames. Set a flag that is checked in SwTextFlyCnt::SetAnchor. @@ -567,28 +565,6 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos, SetInCache( false ); } - UnlockModify(); // enable notify again - - // If there is an accessible layout we must call modify even - // with length zero, because we have to notify about the changed - // text node. - const SwRootFrame *pRootFrame; - if ( (nTextLen != nSplitPos) || - ( (pRootFrame = pNode->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout()) != nullptr && - pRootFrame->IsAnyShellAccessible() ) ) - { - // tell the frames that something was "deleted" at the end - if( 1 == nTextLen - nSplitPos ) - { - SwDelChr aHint( nSplitPos ); - pNode->NotifyClients( nullptr, &aHint ); - } - else - { - SwDelText aHint( nSplitPos, nTextLen - nSplitPos ); - pNode->NotifyClients( nullptr, &aHint ); - } - } if ( HasHints() ) { MoveTextAttr_To_AttrSet(); commit 5e585b1852e46f0625565ef1ef9f129349581b0e Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Wed Oct 28 15:55:42 2020 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 16:23:48 2020 +0100 Revert "tdf#135001 sw_redlinehide: fix IsShown() for AT_PARA flys" This reverts commit 4018dba80e1fe37b24582e803d360998e1a73b2c. The code there changed substantially in 6.3, and this fix doesn't actually fix the bug in 6.1 branch. Change-Id: I441c47844afeafd084f7e0126bf89d74288e16d4 diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 3404dc9e3054..c77d55c12f9f 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1045,16 +1045,10 @@ static bool IsShown(sal_uLong const nIndex, { return false; } - if (rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA + if (pIter && rAnch.GetAnchorId() != RndStdIds::FLY_AT_PARA // sw_redlinehide: we want to hide AT_CHAR, but currently can't // because Delete and Accept Redline don't delete them! - || rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR) - { - return pIter == nullptr // not merged - || pIter != pEnd // at least one char visible in node - || rAnchor.nNode.GetNode().GetRedlineMergeFlag() != SwNode::Merge::Hidden; - } - if (pIter) + && rAnch.GetAnchorId() != RndStdIds::FLY_AT_CHAR) { // note: frames are not sorted by anchor position. assert(pEnd); commit 4018dba80e1fe37b24582e803d360998e1a73b2c Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Fri Aug 28 22:05:06 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 15:55:31 2020 +0100 tdf#135001 sw_redlinehide: fix IsShown() for AT_PARA flys There is one merged text frame from node 102 to node 328 with no extents, and of course a shape anchored at node 271 should not be visible at all. This crashes because the shape was removed from the layout during CheckParaRedlineMerge() but then moved to the visible heaven layer again via sw::AddRemoveFlysAnchoredToFrameStartingAtNode() and the layer determines if it's visible as far as Sdr* is concerned; it lacks a connection to a SwFrame though. warn:legacy.osl:3547848:3547848:sw/source/core/layout/paintfrm.cxx:3861: <SwFlyFrame::IsPaint(..)> - paint of drawing object without anchor frame!? (regression from 6aaae44da382f4bc3eafc287b4a21734b740cf21) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101584 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit 586750da40c5b332d2442ef24ae121795e88e903) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101673 Reviewed-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 56db540f6b97cb7616e68308355e7930d3d64539) Change-Id: Ia20449b3a7d251f0c049eb979c88df1e80cd7d5f diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index c77d55c12f9f..3404dc9e3054 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1045,10 +1045,16 @@ static bool IsShown(sal_uLong const nIndex, { return false; } - if (pIter && rAnch.GetAnchorId() != RndStdIds::FLY_AT_PARA + if (rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA // sw_redlinehide: we want to hide AT_CHAR, but currently can't // because Delete and Accept Redline don't delete them! - && rAnch.GetAnchorId() != RndStdIds::FLY_AT_CHAR) + || rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR) + { + return pIter == nullptr // not merged + || pIter != pEnd // at least one char visible in node + || rAnchor.nNode.GetNode().GetRedlineMergeFlag() != SwNode::Merge::Hidden; + } + if (pIter) { // note: frames are not sorted by anchor position. assert(pEnd); commit c5f36ad58f0e63a9298e6e318d3c7488ba131743 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Tue Aug 25 17:30:16 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 14:58:58 2020 +0100 tdf#135018 sw_redlinehide: fix accept delete redline at start of body There is no predecessor text node. (regression from 34b32f56e7f76639ee3a31cfc230a3340acf635a) Change-Id: I5f6a1a7a1a35a2a6e600166dc1afcf6c4bf9d389 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101337 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit a64511dc929a91926ade0c132b310214fdb1bdea) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101354 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> (cherry picked from commit 4d2f2c7ca37e618e0ac64fd22e5315ecccc8df5b) diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 5ca09ba95fd4..b6bb8b593ca9 100755 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -881,7 +881,10 @@ void CheckResetRedlineMergeFlag(SwTextNode & rNode, Recreate const eRecreateMerg if (eRecreateMerged != sw::Recreate::No) { SwTextNode * pMergeNode(&rNode); - if (eRecreateMerged == sw::Recreate::Predecessor) + if (eRecreateMerged == sw::Recreate::Predecessor + // tdf#135018 check that there is a predecessor node, i.e. rNode + // isn't the first node after the body start node + && rNode.GetNodes()[rNode.GetIndex() - 1]->StartOfSectionIndex() != 0) { for (sal_uLong i = rNode.GetIndex() - 1; ; --i) { commit 56f7c9973a96fdab67c7f95fd1ce15d2398abfe4 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Tue Aug 25 14:44:39 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 14:53:01 2020 +0100 (related: tdf#132160) sw: fix lcl_RejectRedline if end is on table node This happens on Undo: sw/source/core/undo/undobj.cxx:1394: void SwRedlineSaveData::RedlineToDoc(const SwPaM&): Assertion `result != IDocumentRedlineAccess::AppendResult::IGNORED' failed. Because the SwRedlineSaveData was created in SwUndoDelete ctor from this: (rr) p *pRedl $18 = (SwRangeRedline) { <SwPaM> = SwPaM = { point = SwPosition (node 13457, offset 0), mark = SwPosition (node 13455, offset 0) }, (rr) p pRedl->GetPoint()->nNode.GetNode().GetNodes()[13457] $19 = (SwTableNode *) 0x80bdbe0 DelFullPara() will delete the end node, see "m_rDoc.GetNodes().Delete( aRg.aStart, nNodeDiff+1 );" or equivalent in SwUndoDelete. So if the end is on a start node, set it back to the previous node, because deleting just a start node is a bad idea. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101334 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit e2fe4fde592564d35099ad1e2659ad682dfb77f5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101352 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> (cherry picked from commit d0ebd31df55d6bec2a0a7f84978712e49b90b993) Change-Id: Ib7c35c103ce05ede39e66505fa47fa70bfece018 diff --git a/sw/qa/extras/uiwriter/data/tdf132160.odt b/sw/qa/extras/uiwriter/data/tdf132160.odt new file mode 100644 index 000000000000..8a8ae7b8b1cb Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf132160.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 90cfa8d7e944..e380090223c2 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -257,6 +257,7 @@ public: void testDocModState(); void testTdf135056(); void testTdf94804(); + void testTdf132160(); void testTdf34957(); void testTdf89954(); void testTdf89720(); @@ -470,6 +471,7 @@ public: CPPUNIT_TEST(testDocModState); CPPUNIT_TEST(testTdf135056); CPPUNIT_TEST(testTdf94804); + CPPUNIT_TEST(testTdf132160); CPPUNIT_TEST(testTdf34957); CPPUNIT_TEST(testTdf89954); CPPUNIT_TEST(testTdf89720); @@ -4226,6 +4228,7 @@ void SwUiWriterTest::testTdf127635() } #endif + //IdleTask class to add a low priority Idle task class IdleTask { @@ -4313,6 +4316,24 @@ void SwUiWriterTest::testTdf135056() CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pWrtShell->GetTOXCount()); } +void SwUiWriterTest::testTdf132160() +{ + load(DATA_DIRECTORY, "tdf132160.odt"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + // this would crash due to delete redline starting with ToX + lcl_dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {}); + + // this would crash due to insert redline ending on table node + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + + lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); +} + void SwUiWriterTest::testTdf94804() { //create new writer document diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 8818a7bac565..f97d43a1e3af 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -607,6 +607,11 @@ namespace { aPam.GetBound().nContent.Assign( nullptr, 0 ); aPam.GetBound( false ).nContent.Assign( nullptr, 0 ); + if (aPam.End()->nNode.GetNode().IsStartNode()) + { // end node will be deleted too! see nNodeDiff+1 + --aPam.End()->nNode; + } + assert(!aPam.End()->nNode.GetNode().IsStartNode()); rDoc.getIDocumentContentOperations().DelFullPara( aPam ); } else commit 63630c3bad2daa0ebbd18dae683649fc46e80a88 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Tue Apr 16 19:00:50 2019 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 14:50:49 2020 +0100 tdf#109376 sw: fix redline SwUndoDelete with end pos on SwTableNode crash ... that happens when you accept a delete redline (or reject an insert redline) with such end pos. The problem is that first a DeleteRange() will move the anchor position onto the table node (because check in SwUndoSaveContent::DelContentIndex() is surprisingly asymmetric and so the fly not deleted by the previous bugfix), then DelFullPara() creates a second SwUndoDelete then deleting the fly crashes because its anchors was moved. The code in lcl_AcceptRedline() / lcl_RejectRedline() doesn't make much sense (but always was like this), if we just call DeleteFullPara() once instead, the problem is avoided, and we don't even have to worry about why DelContentIndex() is so asymmetric (is "selection direction" really a meaningful concept?). Reportedly this started to crash with commit e07feb9457f2ffb373ae69b73dda290140e4005f, previously it was just wrong. Reviewed-on: https://gerrit.libreoffice.org/70836 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit f83e22f535c1c9482c5d3f566d5d0283355dd98f) Change-Id: Ib3d4b31e0255a6f4e7b49b40f204dec168ea3006 diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 237405f1e6fb..5b90d1346179 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -33,6 +33,7 @@ public: void testTdf101534(); void testTdf131684(); void testTdf132236(); + void testTdf109376_redline(); void testTdf109376(); CPPUNIT_TEST_SUITE(SwUiWriterTest2); @@ -41,6 +42,7 @@ public: CPPUNIT_TEST(testTdf101534); CPPUNIT_TEST(testTdf131684); CPPUNIT_TEST(testTdf132236); + CPPUNIT_TEST(testTdf109376_redline); CPPUNIT_TEST(testTdf109376); CPPUNIT_TEST_SUITE_END(); @@ -263,6 +265,57 @@ void SwUiWriterTest2::testTdf132236() assertXPath(pXmlDoc, "/root/page[1]/body/txt", 1); } +void SwUiWriterTest2::testTdf109376_redline() +{ + SwDoc* pDoc = createDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + // need 2 paragraphs to get to the bMoveNds case + pWrtShell->Insert("foo"); + pWrtShell->SplitNode(); + pWrtShell->Insert("bar"); + pWrtShell->SplitNode(); + pWrtShell->StartOfSection(false); + + // add AT_PARA fly at 1st to be deleted node + SwFormatAnchor anchor(RndStdIds::FLY_AT_PARA); + anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint()); + SfxItemSet flySet(pDoc->GetAttrPool(), + svl::Items<RES_FRM_SIZE, RES_FRM_SIZE, RES_ANCHOR, RES_ANCHOR>{}); + flySet.Put(anchor); + SwFormatFrameSize size(ATT_MIN_SIZE, 1000, 1000); + flySet.Put(size); // set a size, else we get 1 char per line... + SwFrameFormat const* pFly = pWrtShell->NewFlyFrame(flySet, /*bAnchValid=*/true); + CPPUNIT_ASSERT(pFly != nullptr); + + pWrtShell->SttEndDoc(false); + SwInsertTableOptions tableOpt(SwInsertTableFlags::DefaultBorder, 0); + const SwTable& rTable = pWrtShell->InsertTable(tableOpt, 1, 1); + + pWrtShell->StartOfSection(false); + SwPaM pam(*pWrtShell->GetCursor()->GetPoint()); + pam.SetMark(); + pam.GetPoint()->nNode = *rTable.GetTableNode(); + pam.GetPoint()->nContent.Assign(nullptr, 0); + pam.Exchange(); // same selection direction as in doc compare... + + IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess()); + rIDRA.SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowInsert | RedlineFlags::ShowDelete); + rIDRA.AppendRedline(new SwRangeRedline(nsRedlineType_t::REDLINE_DELETE, pam), true); + // this used to assert/crash with m_pAnchoredFlys mismatch because the + // fly was not deleted but its anchor was moved to the SwTableNode + rIDRA.AcceptAllRedline(true); + + CPPUNIT_ASSERT_EQUAL(size_t(0), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); + sw::UndoManager& rUndoManager = pDoc->GetUndoManager(); + rUndoManager.Undo(); + CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); + rUndoManager.Redo(); + CPPUNIT_ASSERT_EQUAL(size_t(0), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); + rUndoManager.Undo(); + CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); +} + void SwUiWriterTest2::testTdf109376() { SwDoc* pDoc = createDoc(); diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 48d5646e6f84..8818a7bac565 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -491,17 +491,15 @@ namespace if( pCSttNd && pCEndNd ) rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam ); - else - { - rDoc.getIDocumentContentOperations().DeleteRange( aPam ); - - if( pCSttNd && !pCEndNd ) + else if (pCSttNd && !pCEndNd) { aPam.GetBound().nContent.Assign( nullptr, 0 ); aPam.GetBound( false ).nContent.Assign( nullptr, 0 ); - aPam.DeleteMark(); rDoc.getIDocumentContentOperations().DelFullPara( aPam ); } + else + { + rDoc.getIDocumentContentOperations().DeleteRange(aPam); } rDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld ); } @@ -605,17 +603,15 @@ namespace if( pCSttNd && pCEndNd ) rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam ); - else - { - rDoc.getIDocumentContentOperations().DeleteRange( aPam ); - - if( pCSttNd && !pCEndNd ) + else if (pCSttNd && !pCEndNd) { aPam.GetBound().nContent.Assign( nullptr, 0 ); aPam.GetBound( false ).nContent.Assign( nullptr, 0 ); - aPam.DeleteMark(); rDoc.getIDocumentContentOperations().DelFullPara( aPam ); } + else + { + rDoc.getIDocumentContentOperations().DeleteRange(aPam); } rDoc.getIDocumentRedlineAccess().SetRedlineFlags_intern( eOld ); } commit 1bb7fd58e59a1a7309470c3c3fe6139011ff8e0f Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Mon Aug 24 19:29:14 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 14:34:36 2020 +0100 tdf#132160 sw_redlinehide: more pathological redline problems This is similar to 63dba5203e8bc7fc390943cb8208ae904f18e3bb except here the redline starts with a section (in particular an entire alphabetical index); this one is at node 13489 to node 14206. There's another fun one, starts with a table but has a text node following it, at node 8222 to 8231; this case also wasn't handled correctly at least in one direction. Fix that by continuing iteration of text-nodes once table/section at the start are handled. (regression from d258fc29560baa5ecae03ebc2740e11420643e27) Change-Id: I3f75ad473881f01be80d2c3804b9ac209f430bdf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101287 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit 0bbc397dc5b4440144627330c2b6ee479bdcf074) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101350 Reviewed-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 1a3c4545db30e222ef8456ccdbf51d07a18adbca) diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 1932098fd25c..48d5646e6f84 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -144,24 +144,38 @@ void UpdateFramesForAddDeleteRedline(SwDoc & rDoc, SwPaM const& rPam) // no need to call UpdateFootnoteNums for FTNNUM_PAGE: // the AppendFootnote/RemoveFootnote will do it by itself! rDoc.GetFootnoteIdxs().UpdateFootnote(rPam.Start()->nNode); - SwTextNode *const pStartNode(rPam.Start()->nNode.GetNode().GetTextNode()); - if (!pStartNode) + SwPosition currentStart(*rPam.Start()); + SwTextNode * pStartNode(rPam.Start()->nNode.GetNode().GetTextNode()); + while (!pStartNode) { - SwTableNode *const pTableNode(rPam.Start()->nNode.GetNode().GetTableNode()); - assert(pTableNode); // known pathology - for (sal_uLong j = pTableNode->GetIndex(); j <= pTableNode->EndOfSectionIndex(); ++j) + SwStartNode *const pTableOrSectionNode( + currentStart.nNode.GetNode().IsTableNode() + ? static_cast<SwStartNode*>(currentStart.nNode.GetNode().GetTableNode()) + : static_cast<SwStartNode*>(currentStart.nNode.GetNode().GetSectionNode())); + assert(pTableOrSectionNode); // known pathology + for (sal_uLong j = pTableOrSectionNode->GetIndex(); j <= pTableOrSectionNode->EndOfSectionIndex(); ++j) { - pTableNode->GetNodes()[j]->SetRedlineMergeFlag(SwNode::Merge::Hidden); + pTableOrSectionNode->GetNodes()[j]->SetRedlineMergeFlag(SwNode::Merge::Hidden); } for (SwRootFrame const*const pLayout : rDoc.GetAllLayouts()) { if (pLayout->IsHideRedlines()) { - pTableNode->DelFrames(pLayout); + if (pTableOrSectionNode->IsTableNode()) + { + static_cast<SwTableNode*>(pTableOrSectionNode)->DelFrames(pLayout); + } + else + { + static_cast<SwSectionNode*>(pTableOrSectionNode)->DelFrames(pLayout); + } } } + currentStart.nNode = pTableOrSectionNode->EndOfSectionIndex() + 1; + currentStart.nContent.Assign(currentStart.nNode.GetNode().GetContentNode(), 0); + pStartNode = currentStart.nNode.GetNode().GetTextNode(); } - else + if (currentStart < *rPam.End()) { SwTextNode * pNode(pStartNode); do @@ -225,24 +239,32 @@ void UpdateFramesForRemoveDeleteRedline(SwDoc & rDoc, SwPaM const& rPam) { bool isAppendObjsCalled(false); rDoc.GetFootnoteIdxs().UpdateFootnote(rPam.Start()->nNode); - SwTextNode *const pStartNode(rPam.Start()->nNode.GetNode().GetTextNode()); - if (!pStartNode) + SwPosition currentStart(*rPam.Start()); + SwTextNode * pStartNode(rPam.Start()->nNode.GetNode().GetTextNode()); + while (!pStartNode) { - SwTableNode const*const pTableNode(rPam.Start()->nNode.GetNode().GetTableNode()); - assert(pTableNode); // known pathology - for (sal_uLong j = pTableNode->GetIndex(); j <= pTableNode->EndOfSectionIndex(); ++j) + SwStartNode const*const pTableOrSectionNode( + currentStart.nNode.GetNode().IsTableNode() + ? static_cast<SwStartNode*>(currentStart.nNode.GetNode().GetTableNode()) + : static_cast<SwStartNode*>(currentStart.nNode.GetNode().GetSectionNode())); + assert(pTableOrSectionNode); // known pathology + for (sal_uLong j = pTableOrSectionNode->GetIndex(); j <= pTableOrSectionNode->EndOfSectionIndex(); ++j) { - pTableNode->GetNodes()[j]->SetRedlineMergeFlag(SwNode::Merge::None); + pTableOrSectionNode->GetNodes()[j]->SetRedlineMergeFlag(SwNode::Merge::None); } if (rDoc.getIDocumentLayoutAccess().GetCurrentLayout()->IsHideRedlines()) { // note: this will also create frames for all currently hidden flys // because it calls AppendAllObjs - ::MakeFrames(&rDoc, rPam.Start()->nNode, rPam.End()->nNode); + SwNodeIndex const end(*pTableOrSectionNode->EndOfSectionNode()); + ::MakeFrames(&rDoc, currentStart.nNode, end); isAppendObjsCalled = true; } + currentStart.nNode = pTableOrSectionNode->EndOfSectionIndex() + 1; + currentStart.nContent.Assign(currentStart.nNode.GetNode().GetContentNode(), 0); + pStartNode = currentStart.nNode.GetNode().GetTextNode(); } - else + if (currentStart < *rPam.End()) { SwTextNode * pNode(pStartNode); do commit d676059ee2d44bd4d911dd222124fc36ebaee760 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Wed Sep 2 18:35:54 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 13:39:46 2020 +0100 tdf#135056: sw_uiwriter: Add unittest Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101950 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit bc46ff73d6f79d850253f9e1896643eb73238ebb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104826 Tested-by: Michael Stahl <michael.st...@cib.de> Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit c64995d1e550b49a226d8f170b2e5533a59bb987) Change-Id: I933537a44b9493adc89516bccb189003cf4f132f diff --git a/sw/qa/extras/uiwriter/data/tdf135056.odt b/sw/qa/extras/uiwriter/data/tdf135056.odt new file mode 100644 index 000000000000..bd94317d07d4 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf135056.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index aa3be88b2a2f..90cfa8d7e944 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -255,6 +255,7 @@ public: void testDde(); #endif void testDocModState(); + void testTdf135056(); void testTdf94804(); void testTdf34957(); void testTdf89954(); @@ -467,6 +468,7 @@ public: CPPUNIT_TEST(testDde); #endif CPPUNIT_TEST(testDocModState); + CPPUNIT_TEST(testTdf135056); CPPUNIT_TEST(testTdf94804); CPPUNIT_TEST(testTdf34957); CPPUNIT_TEST(testTdf89954); @@ -4286,6 +4288,31 @@ void SwUiWriterTest::testDocModState() CPPUNIT_ASSERT(!(pShell->IsModified())); } +void SwUiWriterTest::testTdf135056() +{ + load(DATA_DIRECTORY, "tdf135056.odt"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pWrtShell->GetTOXCount()); + + const SwTOXBase* pTOX = pWrtShell->GetTOX(0); + CPPUNIT_ASSERT(pTOX); + + //Without the fix in place, it would have hung here + pWrtShell->DeleteTOX(*pTOX, true); + + CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), pWrtShell->GetTOXCount()); + + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pWrtShell->GetTOXCount()); +} + void SwUiWriterTest::testTdf94804() { //create new writer document commit 17ebd66b726772688fbef7252707527c2ec46f76 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Jul 28 18:34:48 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 13:39:46 2020 +0100 tdf#132911: sw_uiwriter: Add unittest Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99641 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit a206054ac048702d48077eea6f3d464c3d241ab3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104824 Tested-by: Michael Stahl <michael.st...@cib.de> Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit b2faa46071ff4a00672b0699e524e7ae66915fc0) Change-Id: I0ad6697d8dce814f20ea5f98e9c8f4b9c68f278d diff --git a/sw/qa/extras/uiwriter/data/tdf132911.odt b/sw/qa/extras/uiwriter/data/tdf132911.odt new file mode 100644 index 000000000000..3c311f3ed36b Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf132911.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 8308cdaeb6e4..aa3be88b2a2f 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -287,6 +287,7 @@ public: void testTdf135260(); void testRedlineParam(); void testRedlineViewAuthor(); + void testTdf132911(); void testTdf91292(); void testTdf78727(); void testRedlineTimestamp(); @@ -498,6 +499,7 @@ public: CPPUNIT_TEST(testTdf135260); CPPUNIT_TEST(testRedlineParam); CPPUNIT_TEST(testRedlineViewAuthor); + CPPUNIT_TEST(testTdf132911); CPPUNIT_TEST(testTdf91292); CPPUNIT_TEST(testTdf78727); CPPUNIT_TEST(testRedlineTimestamp); @@ -5478,6 +5480,80 @@ void SwUiWriterTest::testRedlineViewAuthor() pDocShell->SetView(pView); } +void SwUiWriterTest::testTdf132911() +{ + load(DATA_DIRECTORY, "tdf132911.odt"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + auto getShapes = [&]() -> int + { + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage(); + return xDraws->getCount(); + }; + + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + lcl_dispatchCommand(mxComponent, ".uno:Cut", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(0, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + + // Without the fix in place, it would have crashed here + lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(8, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(0, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(8, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(4, getShapes()); + + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(0, getShapes()); + + //FIXME: tdf#135247 + //lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + //Scheduler::ProcessEventsToIdle(); + //CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + //CPPUNIT_ASSERT_EQUAL(4, getShapes()); +} + void SwUiWriterTest::testTdf91292() { createDoc("tdf91292_paraBackground.docx"); commit 844155051de97fcbcff805e43b546c1c2bf3433d Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Sep 29 13:20:21 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 13:39:46 2020 +0100 tdf#133358: sw_uiwriter: Add unittest Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103608 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit 416cb76758719b88a4cdefe8c9d16131c35cfdf5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104747 Tested-by: Michael Stahl <michael.st...@cib.de> Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit a780fd334a3a6d9a5a300f1b0ba0e067b500dcad) Change-Id: I148052d7038824b43ec0c473d4bcbcb64e2f92b0 diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index a2c5b4963ddf..8308cdaeb6e4 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -359,6 +359,7 @@ public: void testTdf133982(); void testTdf117225(); void testTdf91801(); + void testTdf133358(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -569,6 +570,7 @@ public: CPPUNIT_TEST(testTdf133982); CPPUNIT_TEST(testTdf117225); CPPUNIT_TEST(testTdf91801); + CPPUNIT_TEST(testTdf133358); CPPUNIT_TEST_SUITE_END(); private: @@ -6884,6 +6886,38 @@ void SwUiWriterTest::testTdf91801() CPPUNIT_ASSERT_EQUAL(555.0, xCell->getValue()); } +void SwUiWriterTest::testTdf133358() +{ + mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + SwWrtShell* pWrtSh = pTextDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtSh); + + pWrtSh->Insert("Test"); + + CPPUNIT_ASSERT_EQUAL(OUString("Test"), getParagraph(1)->getString()); + + uno::Reference<beans::XPropertyState> xParagraph(getParagraph(1), uno::UNO_QUERY); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xParagraph, "ParaLeftMargin")); + + lcl_dispatchCommand(mxComponent, ".uno:IncrementIndent", {}); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(1251), getProperty<sal_Int32>(xParagraph, "ParaLeftMargin")); + + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xParagraph, "ParaLeftMargin")); + + // Without the fix in place, this test would have crashed here + lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(1251), getProperty<sal_Int32>(xParagraph, "ParaLeftMargin")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); commit 3cf8afdbdfa1686d74c20632ae757a97445cdfce Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri Jul 31 16:47:56 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 13:39:46 2020 +0100 tdf#134931: sw_uiwriter: Add unittest Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99878 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit 99284a22f3cda8518cd2207128928c2e455c89ee) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104825 Tested-by: Michael Stahl <michael.st...@cib.de> Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit 49307ae2cef2d2d43fee92f99809d2bf192343de) Change-Id: I737296f1a0646065288be2cb0be3ef7f939fb536 diff --git a/sw/qa/extras/uiwriter/data/tdf134931.odt b/sw/qa/extras/uiwriter/data/tdf134931.odt new file mode 100644 index 000000000000..bfd1ccf2e561 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf134931.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 31b7a41277b9..a2c5b4963ddf 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -260,6 +260,7 @@ public: void testTdf89954(); void testTdf89720(); void testTdf88986(); + void testTdf134931(); void testTdf87922(); #if HAVE_MORE_FONTS void testTdf77014(); @@ -469,6 +470,7 @@ public: CPPUNIT_TEST(testTdf89954); CPPUNIT_TEST(testTdf89720); CPPUNIT_TEST(testTdf88986); + CPPUNIT_TEST(testTdf134931); CPPUNIT_TEST(testTdf87922); #if HAVE_MORE_FONTS CPPUNIT_TEST(testTdf77014); @@ -4444,6 +4446,41 @@ void SwUiWriterTest::testTdf88986() CPPUNIT_ASSERT(aSet.HasItem(SID_COLOR_TABLE)); } +void SwUiWriterTest::testTdf134931() +{ + load(DATA_DIRECTORY, "tdf134931.odt"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(1, getPages()); + + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + lcl_dispatchCommand(mxComponent, ".uno:Copy", {}); + Scheduler::ProcessEventsToIdle(); + + lcl_dispatchCommand(mxComponent, ".uno:GoDown", {}); + + for (sal_Int32 i = 0; i < 10; ++i) + { + lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + } + + CPPUNIT_ASSERT_EQUAL(sal_Int32(11), xIndexAccess->getCount()); + + // Without the fix in place, this test would have failed with: + // - Expected: 4 + // - Actual : 1 + // Because the tables are pasted but not displayed + + CPPUNIT_ASSERT_EQUAL(4, getPages()); +} + void SwUiWriterTest::testTdf87922() { // Create an SwDrawTextInfo. commit 669140f713f80175273aad9e932a3f6fd5251d07 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri Jun 19 12:46:30 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 13:39:46 2020 +0100 tdf#133990: sw: Add unittest Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96714 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit 8e4c79472644452431381733a5e4b21f98fcdcf3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104823 Tested-by: Michael Stahl <michael.st...@cib.de> Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit 61d83ce8d29aa6dc1039df8e7f8c5afdbf42a266) Change-Id: I3b5d1a2a2396fba9d350350ac4d04f7f97401ebe diff --git a/sw/qa/extras/uiwriter/data/tdf133990.odt b/sw/qa/extras/uiwriter/data/tdf133990.odt new file mode 100644 index 000000000000..8eaca8161701 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf133990.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 61295481490e..31b7a41277b9 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -300,6 +300,7 @@ public: #if HAVE_MORE_FONTS void testTdf35021_tabOverMarginDemo(); #endif + void testTdf133990(); void testTdf106701_tabOverMarginAutotab(); void testTdf104492(); void testTdf107025(); @@ -508,6 +509,7 @@ public: #if HAVE_MORE_FONTS CPPUNIT_TEST(testTdf35021_tabOverMarginDemo); #endif + CPPUNIT_TEST(testTdf133990); CPPUNIT_TEST(testTdf106701_tabOverMarginAutotab); CPPUNIT_TEST(testTdf104492); CPPUNIT_TEST(testTdf107025); @@ -5671,6 +5673,33 @@ void SwUiWriterTest::testTdf35021_tabOverMarginDemo() } #endif +void SwUiWriterTest::testTdf133990() +{ + load(DATA_DIRECTORY, "tdf133990.odt"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(1, getPages()); + + //Use selectAll 3 times in a row + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + + lcl_dispatchCommand(mxComponent, ".uno:Delete", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); + + //Without the fix in place, it would have crashed here + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(1, getPages()); +} + void SwUiWriterTest::testTdf106701_tabOverMarginAutotab() { createDoc("tdf106701_tabOverMarginAutotab.doc"); commit 8c2a195bf8eec523e1206152e69ebbc9d37e9476 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Jun 30 11:42:08 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 13:39:45 2020 +0100 tdf#134021: sw: Add unittest Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97481 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit 189086209113a20a36ad43d19e53af6678ff772c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104822 Tested-by: Michael Stahl <michael.st...@cib.de> Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit f359a10b2eff013cc0c7dc25e9ce12b94bd6be43) Change-Id: I789adaf699a857e28416132d253c04128def5984 diff --git a/sw/qa/extras/uiwriter/data/tdf134021.docx b/sw/qa/extras/uiwriter/data/tdf134021.docx new file mode 100644 index 000000000000..cda11fbdf3ef Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf134021.docx differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index c1a2558bafd6..61295481490e 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -318,6 +318,7 @@ public: void testCreateDocxAnnotation(); void testTdf107976(); void testTdf108524(); + void testTdf134021(); #if HAVE_MORE_FONTS void testTableInSection(); void testTableInNestedSection(); @@ -525,6 +526,7 @@ public: CPPUNIT_TEST(testCreateDocxAnnotation); CPPUNIT_TEST(testTdf107976); CPPUNIT_TEST(testTdf108524); + CPPUNIT_TEST(testTdf134021); #if HAVE_MORE_FONTS CPPUNIT_TEST(testTableInSection); CPPUNIT_TEST(testTableInNestedSection); @@ -6103,6 +6105,34 @@ void SwUiWriterTest::testTdf108524() assertXPath(pXmlDoc, "/root/page[2]/body/tab/row/cell/section", 1); } +void SwUiWriterTest::testTdf134021() +{ + load(DATA_DIRECTORY, "tdf134021.docx"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(12, getPages()); + + lcl_dispatchCommand(mxComponent, ".uno:JumpToNextTable", {}); + + lcl_dispatchCommand(mxComponent, ".uno:DeleteTable", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(1, getPages()); + + // Without the fix in place, it would have crashed here + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(12, getPages()); +} + void SwUiWriterTest::testLinesInSectionInTable() { // This is similar to testTdf108524(), but the page boundary now is not in commit e6fba37976a28052317332bb2d5c5c372ec8d8ed Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Thu Oct 15 23:44:04 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 13:39:45 2020 +0100 tdf#135260: sw_uiwriter: Add unittest Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104391 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit c143ad222a3c4c8d86699e1b3f20d3a5262da1e2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104746 Tested-by: Michael Stahl <michael.st...@cib.de> Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit bebdc5e923c9e5dcb9d2f8d32244a9eeb925b31f) Change-Id: Iec50c3129097e99ae57543601d40c5a380db678f diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 2ce1c79b3779..c1a2558bafd6 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -283,6 +283,7 @@ public: void testTableStyleUndo(); void testRedlineCopyPaste(); void testTdf134436(); + void testTdf135260(); void testRedlineParam(); void testRedlineViewAuthor(); void testTdf91292(); @@ -489,6 +490,7 @@ public: CPPUNIT_TEST(testTableStyleUndo); CPPUNIT_TEST(testRedlineCopyPaste); CPPUNIT_TEST(testTdf134436); + CPPUNIT_TEST(testTdf135260); CPPUNIT_TEST(testRedlineParam); CPPUNIT_TEST(testRedlineViewAuthor); CPPUNIT_TEST(testTdf91292); @@ -5308,6 +5310,32 @@ void SwUiWriterTest::testTdf134436() CPPUNIT_ASSERT_EQUAL(OUString(""), pWrtShell->GetCursor()->GetText()); } +void SwUiWriterTest::testTdf135260() +{ + SwDoc* pDoc = createDoc(); + SwDocShell* pDocShell = pDoc->GetDocShell(); + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + pWrtShell->Insert("test"); + + // Turn on track changes + uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY); + xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true)); + + for(int i = 0; i < 4; i++) { + pWrtShell->DelLeft(); + } + + SwEditShell* const pEditShell(pDoc->GetEditShell()); + // accept all redlines + while(pEditShell->GetRedlineCount()) + pEditShell->AcceptRedline(0); + + // Without the fix in place, this test would have failed with + // - Expected: + // - Actual : tes + CPPUNIT_ASSERT_EQUAL(OUString(""), getParagraph(1)->getString()); +} + void SwUiWriterTest::testRedlineParam() { // Create a document with minimal content. commit add4aeb4e39bc9f593e6787313976ebdcd356395 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri Oct 16 18:32:32 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 13:39:45 2020 +0100 tdf#127635: sw_uiwriter: Add unittest Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104444 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit 254c26f1c69e2eb23f66a79349b0ea78a5d467d3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104745 Tested-by: Michael Stahl <michael.st...@cib.de> Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit c207a70dc1d42250b80d9bf63723fee11c9b0c2b) Change-Id: Ib25d5723057b79f49876df816bff5971ee3fa7c3 diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 92a73959cee9..2ce1c79b3779 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -251,6 +251,7 @@ public: void testShapeAnchorUndo(); #if HAVE_FEATURE_UI void testTdf134250(); + void testTdf127635(); void testDde(); #endif void testDocModState(); @@ -456,6 +457,7 @@ public: CPPUNIT_TEST(testShapeAnchorUndo); #if HAVE_FEATURE_UI CPPUNIT_TEST(testTdf134250); + CPPUNIT_TEST(testTdf127635); CPPUNIT_TEST(testDde); #endif CPPUNIT_TEST(testDocModState); @@ -4166,6 +4168,49 @@ void SwUiWriterTest::testDde() CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty<OUString>(xField, "TextPortionType")); CPPUNIT_ASSERT(xField->getString().endsWith("asdf")); } + +void SwUiWriterTest::testTdf127635() +{ + SwDoc* pDoc = createDoc(); + + SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + CPPUNIT_ASSERT(pXTextDocument); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, ' ', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'b', 0); + Scheduler::ProcessEventsToIdle(); + + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); + + //Select 'a' + pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false); + + // enable redlining + lcl_dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + // hide + lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + + CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines()); + + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, ' ', 0); + pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'd', 0); + Scheduler::ProcessEventsToIdle(); + + SwEditShell* const pEditShell(pDoc->GetEditShell()); + // accept all redlines + while(pEditShell->GetRedlineCount()) + pEditShell->AcceptRedline(0); + + // Without the fix in place, this test would have failed with + // - Expected: C d b + // - Actual : Cd b + CPPUNIT_ASSERT_EQUAL(OUString("C d b"), getParagraph(1)->getString()); +} + #endif //IdleTask class to add a low priority Idle task class IdleTask commit 30b35f047a91732886ac3479663fc5a4069bc4ea Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Thu Jun 18 11:08:38 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 13:39:45 2020 +0100 tdf#133982: sw: Add unittest Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96592 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit 9197a52c1bd79bbdc0756724c74fd2a679b9f626) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104744 Tested-by: Michael Stahl <michael.st...@cib.de> Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit 95554417cad0a6597d9f633f87081ab3d2d03c11) Change-Id: I1a9b0a1150f8e3e1832aaa15a09049622bd83afc diff --git a/sw/qa/extras/uiwriter/data/tdf133982.docx b/sw/qa/extras/uiwriter/data/tdf133982.docx new file mode 100644 index 000000000000..d2e8573d15ac Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf133982.docx differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index fff1d471dc99..92a73959cee9 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -351,6 +351,7 @@ public: void testTdf116403(); void testHtmlCopyImages(); void testTdf116789(); + void testTdf133982(); void testTdf117225(); void testTdf91801(); @@ -555,6 +556,7 @@ public: CPPUNIT_TEST(testTdf116403); CPPUNIT_TEST(testHtmlCopyImages); CPPUNIT_TEST(testTdf116789); + CPPUNIT_TEST(testTdf133982); CPPUNIT_TEST(testTdf117225); CPPUNIT_TEST(testTdf91801); CPPUNIT_TEST_SUITE_END(); @@ -6655,6 +6657,31 @@ void SwUiWriterTest::testTdf116789() CPPUNIT_ASSERT_EQUAL(xText1, xText2); } +void SwUiWriterTest::testTdf133982() +{ + load(DATA_DIRECTORY, "tdf133982.docx"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); + + //Use selectAll 3 times in a row + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + + //Without the fix in place, it would have crashed here + lcl_dispatchCommand(mxComponent, ".uno:Cut", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); + + lcl_dispatchCommand(mxComponent, ".uno:Paste", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); +} + void SwUiWriterTest::testTdf117225() { // Test that saving a document with an embedded object does not leak commit 87578f6022f277617072c588ad8ce6384dc25425 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Thu Jul 30 01:28:14 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 13:39:45 2020 +0100 tdf#133967: sw_uiwriter: Add unittest Change-Id: I7ec43fd7109e883b0ae560cc8832e449a09fddb0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99758 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit a6e02f6337f038a445b858bb91bf14d1a14768e4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99735 Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99791 (cherry picked from commit a6753768fe914fb110bc4e4def4699b8e54b7e49) diff --git a/sw/qa/extras/uiwriter/data/tdf133967.odt b/sw/qa/extras/uiwriter/data/tdf133967.odt new file mode 100644 index 000000000000..18ed5bfb7844 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf133967.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 65ccd4fcd39a..fff1d471dc99 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -222,6 +222,7 @@ public: void testSearchWithTransliterate(); void testTdf73660(); void testNewDocModifiedState(); + void testTdf133967(); void testTdf132187(); void testTdf77342(); void testTdf63553(); @@ -425,6 +426,7 @@ public: CPPUNIT_TEST(testSearchWithTransliterate); CPPUNIT_TEST(testTdf73660); CPPUNIT_TEST(testNewDocModifiedState); + CPPUNIT_TEST(testTdf133967); CPPUNIT_TEST(testTdf132187); CPPUNIT_TEST(testTdf77342); CPPUNIT_TEST(testTdf63553); @@ -4273,6 +4275,34 @@ void SwUiWriterTest::testUnicodeNotationToggle() CPPUNIT_ASSERT_EQUAL( sDocString, sOriginalDocString ); } +void SwUiWriterTest::testTdf133967() +{ + load(DATA_DIRECTORY, "tdf133967.odt"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + CPPUNIT_ASSERT_EQUAL(6, getPages()); + + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + + lcl_dispatchCommand(mxComponent, ".uno:Cut", {}); + Scheduler::ProcessEventsToIdle(); + + for (sal_Int32 i = 0; i < 10; ++i) + { + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + Scheduler::ProcessEventsToIdle(); + } + + // Without the fix in place, this test would have failed with: + //- Expected: 1 + //- Actual : 45 + CPPUNIT_ASSERT_EQUAL(1, getPages()); +} + void SwUiWriterTest::testTdf132187() { load(DATA_DIRECTORY, "tdf132187.odt"); commit 6b49259c54bd8588c5f6372bd3c230cbc292f41a Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Tue Oct 27 16:33:30 2020 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 13:39:45 2020 +0100 tdf#136453 sw_redlinehide: SwUndoDelete: only create extra frames... ... at the start if the section nodes were at the start. m_bBackSp and m_bJoinNext can't both be true. (regression from 740f1796504f66408b692225a9676c9ee3d63722) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104891 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit c4967928475f2be20ac2d79e3fa84ac435a7e560) Change-Id: I999ed3809ca8f527bc3e754b229df02da4576825 diff --git a/sw/qa/extras/uiwriter/data/tdf136453.fodt b/sw/qa/extras/uiwriter/data/tdf136453.fodt new file mode 100644 index 000000000000..2234957e1db8 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf136453.fodt @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rpt="http://openoffice.org/2005/report" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:d r3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:font-face-decls> + <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Lohit Devanagari" svg:font-family="'Lohit Devanagari'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Source Han Serif CN" svg:font-family="'Source Han Serif CN'" style:font-family-generic="system" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Serif CN" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/> + </style:default-style> + <style:default-style style:family="paragraph"> + <style:paragraph-properties fo:orphans="2" fo:widows="2" fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Serif CN" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false"/> + </style:default-style> + <style:default-style style:family="table"> + <style:table-properties table:border-model="collapsing"/> + </style:default-style> + <style:default-style style:family="table-row"> + <style:table-row-properties fo:keep-together="auto"/> + </style:default-style> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + <text:notes-configuration text:note-class="footnote" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/> + <text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/> + <text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/> + </office:styles> + <office:automatic-styles> + <style:style style:name="Sect1" style:family="section"> + <style:section-properties fo:background-color="#81d41a" style:editable="false"> + <style:columns fo:column-count="1" fo:column-gap="0cm"/> + <style:background-image/> + </style:section-properties> + </style:style> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + <text:sequence-decls> + <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> + <text:sequence-decl text:display-outline-level="0" text:name="Table"/> + <text:sequence-decl text:display-outline-level="0" text:name="Text"/> + <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> + <text:sequence-decl text:display-outline-level="0" text:name="Figure"/> + </text:sequence-decls> + <text:p text:style-name="Standard"/> + <text:p text:style-name="Standard">foo</text:p> + <text:p text:style-name="Standard">bar</text:p> + <text:section text:style-name="Sect1" text:name="Section1"> + <text:p text:style-name="Standard">baz</text:p> + </text:section> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index a306869a26b2..65ccd4fcd39a 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -169,6 +169,7 @@ public: void testDOTMAutoText(); void testDOCXAutoTextGallery(); void testWatermarkDOCX(); + void testTdf136453(); void testTdf134252(); void testWatermarkPosition(); void testTdf67238(); @@ -371,6 +372,7 @@ public: CPPUNIT_TEST(testDOTMAutoText); CPPUNIT_TEST(testDOCXAutoTextGallery); CPPUNIT_TEST(testWatermarkDOCX); + CPPUNIT_TEST(testTdf136453); CPPUNIT_TEST(testTdf134252); CPPUNIT_TEST(testWatermarkPosition); CPPUNIT_TEST(testTdf67238); @@ -1082,6 +1084,57 @@ void SwUiWriterTest::testWatermarkDOCX() CPPUNIT_ASSERT_EQUAL(sal_Int16(50), pWatermark->GetTransparency()); } +void SwUiWriterTest::testTdf136453() +{ + load(DATA_DIRECTORY, "tdf136453.fodt"); + + SwXTextDocument *const pTextDoc(dynamic_cast<SwXTextDocument*>(mxComponent.get())); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* const pDoc(pTextDoc->GetDocShell()->GetDoc()); + SwWrtShell *const pWrtShell(pDoc->GetDocShell()->GetWrtShell()); + + sal_uLong const nNodes(pDoc->GetNodes().Count()); + + pWrtShell->SttEndDoc(false); + pWrtShell->SetMark(); + pWrtShell->Up(true, 1); + pWrtShell->SttPara(true); + pWrtShell->Delete(); + + // one paragraph deleted, section is gone + CPPUNIT_ASSERT_EQUAL(nNodes - 3, pDoc->GetNodes().Count()); + + pWrtShell->Undo(); + + CPPUNIT_ASSERT_EQUAL(nNodes, pDoc->GetNodes().Count()); + + // check that every node has 1 frame + xmlDocPtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 3); + assertXPath(pXmlDoc, "/root/page[1]/body/section", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/section/txt", 1); + + pWrtShell->Redo(); + + // one paragraph deleted, section is gone + CPPUNIT_ASSERT_EQUAL(nNodes - 3, pDoc->GetNodes().Count()); + + discardDumpedLayout(); + pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 3); + assertXPath(pXmlDoc, "/root/page[1]/body/section", 0); + + pWrtShell->Undo(); + + CPPUNIT_ASSERT_EQUAL(nNodes, pDoc->GetNodes().Count()); + + discardDumpedLayout(); + pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 3); + assertXPath(pXmlDoc, "/root/page[1]/body/section", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/section/txt", 1); +} + void SwUiWriterTest::testWatermarkPosition() { // tdf#108494 Watermark inserted in the document with page break was outside the first page diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 03c6daa5dd48..54fdcdcf305b 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -1111,7 +1111,8 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) // create frames after SetSaveData has recreated redlines if (0 != m_nNode) { - if (m_nReplaceDummy != 0) + // tdf#136453 only if section nodes at the start + if (m_bBackSp && m_nReplaceDummy != 0) { // tdf#134252 *first* create outer section frames // note: text node m_nSttNode currently has frame with an upper; commit 391bd552b1c61f26ad2c544b29b14e477a9c2605 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Wed Jul 29 19:02:46 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Wed Oct 28 13:39:45 2020 +0100 tdf#134252 sw_redlinehide: fix SwUndoDelete for table before end of section In this funny case, the SwPaM starts inside a section, and ends in the first text node following the end of the section, which happens to be in a different section (but that doesn't matter)... this is because IsSelOvr() moves the end of the selection resulting in the 3rd SelAll off of the table end node (as the section ends with a table), but then it's on the section end node and moves forward again. SwUndoDelete::UndoImpl() must first create the outer section frames, skip over the start text node which has frames handled by RecreateStartTextFrames() and then create the frames following the start text node, where the end node of the outer section now finds its expected outer section frame. This relies on the code from 55576842ec72a748d0bad123d41fa03c89fc136d to move the existing text frame below the new section frame(s). (regression from 6c7245e789f973cf6dad03f7008ab3f9d12d350c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99723 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit 740f1796504f66408b692225a9676c9ee3d63722) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99742 Reviewed-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 4ee6aa2a6602ad7c7bc4e3ce1d5d857b2110f804) Change-Id: I9f39b09e603e75ef813d5c855d828ec9bd5fdd95 diff --git a/sw/qa/extras/uiwriter/data/tdf134252.fodt b/sw/qa/extras/uiwriter/data/tdf134252.fodt new file mode 100644 index 000000000000..6e19ac847dd8 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf134252.fodt @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:officeooo="http://openoffice.org/2009/office" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rpt="http://openoffice.org/2005/report" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns :config:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="ur n:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:font-face-decls> + <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Lohit Devanagari" svg:font-family="'Lohit Devanagari'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Source Han Serif CN" svg:font-family="'Source Han Serif CN'" style:font-family-generic="system" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Serif CN" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/> + </style:default-style> + <style:default-style style:family="paragraph"> + <style:paragraph-properties fo:orphans="2" fo:widows="2" fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Serif CN" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false"/> + </style:default-style> + <style:default-style style:family="table"> + <style:table-properties table:border-model="collapsing"/> + </style:default-style> + <style:default-style style:family="table-row"> + <style:table-row-properties fo:keep-together="auto"/> + </style:default-style> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + <text:notes-configuration text:note-class="footnote" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/> + <text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/> + <text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/> + </office:styles> + <office:automatic-styles> + <style:style style:name="Table1" style:family="table"> + <style:table-properties style:width="17cm" table:align="margins"/> + </style:style> + <style:style style:name="Table1.A" style:family="table-column"> + <style:table-column-properties style:column-width="17cm" style:rel-column-width="65535*"/> + </style:style> + <style:style style:name="Table1.A1" style:family="table-cell"> + <style:table-cell-properties fo:padding="0.097cm" fo:border="0.05pt solid #000000"/> + </style:style> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard"> + <style:text-properties officeooo:rsid="00078615" officeooo:paragraph-rsid="00078615"/> + </style:style> + <style:style style:name="P3" style:family="paragraph" style:parent-style-name="Table_20_Contents"> + <style:text-properties officeooo:rsid="00095b34" officeooo:paragraph-rsid="00095b34"/> + </style:style> + <style:style style:name="Sect1" style:family="section"> + <style:section-properties fo:background-color="#81d41a" style:editable="false"> + <style:columns fo:column-count="1" fo:column-gap="0cm"/> + <style:background-image/> + </style:section-properties> + </style:style> + <style:style style:name="Sect2" style:family="section"> + <style:section-properties style:editable="false"> + <style:columns fo:column-count="1" fo:column-gap="0cm"/> + </style:section-properties> + </style:style> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + <text:sequence-decls> + <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> + <text:sequence-decl text:display-outline-level="0" text:name="Table"/> + <text:sequence-decl text:display-outline-level="0" text:name="Text"/> + <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> + <text:sequence-decl text:display-outline-level="0" text:name="Figure"/> + </text:sequence-decls> + <text:section text:style-name="Sect1" text:name="Section1"> + <text:p text:style-name="P1">bar</text:p> + <table:table table:name="Table1" table:style-name="Table1"> + <table:table-column table:style-name="Table1.A"/> + <table:table-row> + <table:table-cell table:style-name="Table1.A1" office:value-type="string"> + <text:p text:style-name="P3">baz</text:p> + </table:table-cell> + </table:table-row> + </table:table> + </text:section> + <text:section text:style-name="Sect2" text:name="Section2"> + <text:p text:style-name="P1">foo</text:p> + </text:section> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 18c57ab42374..a306869a26b2 100755 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -169,6 +169,7 @@ public: void testDOTMAutoText(); void testDOCXAutoTextGallery(); void testWatermarkDOCX(); + void testTdf134252(); void testWatermarkPosition(); void testTdf67238(); void testFdo75110(); @@ -370,6 +371,7 @@ public: CPPUNIT_TEST(testDOTMAutoText); CPPUNIT_TEST(testDOCXAutoTextGallery); CPPUNIT_TEST(testWatermarkDOCX); + CPPUNIT_TEST(testTdf134252); CPPUNIT_TEST(testWatermarkPosition); CPPUNIT_TEST(testTdf67238); CPPUNIT_TEST(testFdo75110); @@ -4596,6 +4598,65 @@ void SwUiWriterTest::testTdf96515() CPPUNIT_ASSERT_EQUAL(1, getPages()); } +void SwUiWriterTest::testTdf134252() +{ + load(DATA_DIRECTORY, "tdf134252.fodt"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xCursor(xTextViewCursorSupplier->getViewCursor()); + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); + uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); + + // select all with section + lcl_dispatchCommand(mxComponent, ".uno:SelectAll", {}); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xSections->getCount()); + CPPUNIT_ASSERT_EQUAL(OUString("bar" SAL_NEWLINE_STRING "baz" SAL_NEWLINE_STRING), xCursor->getString()); + + lcl_dispatchCommand(mxComponent, ".uno:Delete", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount()); + CPPUNIT_ASSERT_EQUAL(OUString(""), xCursor->getString()); + + // this would crash + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xSections->getCount()); + CPPUNIT_ASSERT_EQUAL(OUString("bar" SAL_NEWLINE_STRING "baz" SAL_NEWLINE_STRING), xCursor->getString()); + + lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount()); + CPPUNIT_ASSERT_EQUAL(OUString(""), xCursor->getString()); + + lcl_dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xSections->getCount()); + CPPUNIT_ASSERT_EQUAL(OUString("bar" SAL_NEWLINE_STRING "baz" SAL_NEWLINE_STRING), xCursor->getString()); + + lcl_dispatchCommand(mxComponent, ".uno:Redo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xTables->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xSections->getCount()); + CPPUNIT_ASSERT_EQUAL(OUString(""), xCursor->getString()); +} + void SwUiWriterTest::testTdf96943() { // Enable hide whitespace mode. diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 7c1f3e7872dd..03c6daa5dd48 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -1111,6 +1111,15 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) // create frames after SetSaveData has recreated redlines if (0 != m_nNode) { + if (m_nReplaceDummy != 0) + { + // tdf#134252 *first* create outer section frames + // note: text node m_nSttNode currently has frame with an upper; + // there's a hack in InsertCnt_() to move it below new section frame + SwNodeIndex const start(rDoc.GetNodes(), nSttNode - m_nReplaceDummy); + SwNodeIndex const end(rDoc.GetNodes(), nSttNode); // exclude m_nSttNode + ::MakeFrames(&rDoc, start, end); + } // tdf#121031 if the start node is a text node, it already has a frame; // if it's a table, it does not // tdf#109376 exception: end on non-text-node -> start node was inserted commit 5c3773909ac7494b1c6feae340eaa82c2f28a894 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Tue Oct 27 13:25:42 2020 +0100 ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits