summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2019-06-18 19:10:21 +0200
committerLászló Németh <nemeth@numbertext.org>2019-06-24 09:37:11 +0200
commitb69c518df68ce673b28d589da6626bd3d860f309 (patch)
treee9f5dd0e79dadc358787ffb259c6925595bee5e3
parent3d4b1c0eee7a3055e67df6b0b342ea25b0f5bf55 (diff)
tdf#54819 keep style & numbering at tracked deletion
and direct paragraph formattings after wholly deleted paragraphs. Clean-up and extension of the previous workaround, now with Undo. See commit 22639148ae5400bac98f32a75d7431b857c80195 "change tracking: keep paragraph style after full deletion" and commit 23c159d948af360baecfe243e1321987760916d7 "change tracking: don't copy page break". (Note: the first fixed the numbering, the second reverted it accidentally.) Change-Id: Ic97af3b171490b011523d1bae11f75aaf4baab54 Reviewed-on: https://gerrit.libreoffice.org/74299 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sw/qa/extras/uiwriter/data2/tdf54819b.odtbin0 -> 17538 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx86
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx9
-rw-r--r--sw/source/core/doc/DocumentRedlineManager.cxx35
4 files changed, 129 insertions, 1 deletions
diff --git a/sw/qa/extras/uiwriter/data2/tdf54819b.odt b/sw/qa/extras/uiwriter/data2/tdf54819b.odt
new file mode 100644
index 000000000000..0fb7a6f95b2e
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data2/tdf54819b.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 4da4123e3322..e00bf02c579c 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -282,6 +282,92 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf54819)
getProperty<OUString>(getParagraph(1), "ParaStyleName"));
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf54819_keep_numbering_with_Undo)
+{
+ load(DATA_DIRECTORY, "tdf54819b.odt");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ // heading
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
+ getProperty<OUString>(getParagraph(2), "ParaStyleName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Outline"),
+ getProperty<OUString>(getParagraph(2), "NumberingStyleName"));
+
+ // next paragraph: bulleted list item
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"),
+ getProperty<OUString>(getParagraph(3), "ParaStyleName"));
+ OUString sNumName = getProperty<OUString>(getParagraph(3), "NumberingStyleName");
+ CPPUNIT_ASSERT_MESSAGE("Missing numbering style", !sNumName.isEmpty());
+ CPPUNIT_ASSERT_MESSAGE("Not a bulleted list item", sNumName != "Outline");
+
+ //turn on red-lining and show changes
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+ pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete
+ | RedlineFlags::ShowInsert);
+ pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On);
+ CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+ pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+ CPPUNIT_ASSERT_MESSAGE("redlines shouldn't be visible",
+ !IDocumentRedlineAccess::IsShowChanges(
+ pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+ // remove heading with paragraph break
+ SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+
+ pWrtShell->Down(/*bSelect=*/false);
+ pWrtShell->Down(/*bSelect=*/false);
+ pWrtShell->Down(/*bSelect=*/false);
+ pWrtShell->Down(/*bSelect=*/false);
+ pWrtShell->Down(/*bSelect=*/false);
+ pWrtShell->EndPara(/*bSelect=*/true);
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false);
+ rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell);
+ pTransfer->Cut();
+
+ // solved problem: changing paragraph style after deletion
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"),
+ getProperty<OUString>(getParagraph(2), "ParaStyleName"));
+
+ sNumName = getProperty<OUString>(getParagraph(2), "NumberingStyleName");
+ // solved problem: lost numbering
+ CPPUNIT_ASSERT_MESSAGE("Missing numbering style", !sNumName.isEmpty());
+ CPPUNIT_ASSERT_MESSAGE("Not a bulleted list item", sNumName != "Outline");
+
+ // accept deletion, remaining (now second) paragraph: still bulleted list item
+ IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess());
+ rIDRA.AcceptAllRedline(true);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"),
+ getProperty<OUString>(getParagraph(2), "ParaStyleName"));
+ sNumName = getProperty<OUString>(getParagraph(2), "NumberingStyleName");
+ CPPUNIT_ASSERT_MESSAGE("Missing numbering style", !sNumName.isEmpty());
+ CPPUNIT_ASSERT_MESSAGE("Not a bulleted list item", sNumName != "Outline");
+
+ // solved problem: Undo with the workaround
+ sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
+ rUndoManager.Undo();
+ rUndoManager.Undo();
+
+ // heading
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
+ getProperty<OUString>(getParagraph(2), "ParaStyleName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Outline"),
+ getProperty<OUString>(getParagraph(2), "NumberingStyleName"));
+
+ // next paragraph: bulleted list item
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Standard"),
+ getProperty<OUString>(getParagraph(3), "ParaStyleName"));
+ sNumName = getProperty<OUString>(getParagraph(3), "NumberingStyleName");
+ CPPUNIT_ASSERT_MESSAGE("Missing numbering style", !sNumName.isEmpty());
+ CPPUNIT_ASSERT_MESSAGE("Not a bulleted list item", sNumName != "Outline");
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf109376_redline)
{
SwDoc* pDoc = createDoc();
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index a49fcd7f3a63..a4e0e677597a 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -3715,6 +3715,11 @@ bool DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl( SwPaM & rPa
return false;
}
+ // tdf#54819 current redlining needs also modification of paragraph style and
+ // attributes added to the same grouped Undo
+ if (m_rDoc.GetIDocumentUndoRedo().DoesGroupUndo())
+ m_rDoc.GetIDocumentUndoRedo().StartUndo(SwUndoId::DELETE, nullptr);
+
auto & rDMA(*m_rDoc.getIDocumentMarkAccess());
std::vector<std::unique_ptr<SwUndo>> MarkUndos;
for (auto iter = rDMA.getAnnotationMarksBegin();
@@ -3815,6 +3820,10 @@ bool DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl( SwPaM & rPa
}
m_rDoc.getIDocumentRedlineAccess().SetRedlineFlags( eOld );
}
+
+ if (m_rDoc.GetIDocumentUndoRedo().DoesGroupUndo())
+ m_rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::DELETE, nullptr);
+
return true;
}
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 5142be7c8d85..e327ff55de1d 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -40,6 +40,7 @@
#include <editsh.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
+#include <svl/intitem.hxx>
#include <sal/log.hxx>
using namespace com::sun::star;
@@ -1933,7 +1934,39 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
SwTextNode* pDelNode = pStt->nNode.GetNode().GetTextNode();
SwTextNode* pTextNode = pEnd->nNode.GetNode().GetTextNode();
if (pDelNode != nullptr && pTextNode != nullptr && pDelNode != pTextNode)
- pDelNode->ChgFormatColl( pTextNode->GetTextColl() );
+ {
+ const SwPaM aPam(*pDelNode);
+ // using Undo, apply paragraph style
+ m_rDoc.SetTextFormatColl(aPam, pTextNode->GetTextColl());
+
+ // using Undo, remove direct paragraph formatting of the first deleted paragraph,
+ // and apply direct paragraph formatting of the next remaining paragraph
+ SfxItemSet aTmp(
+ m_rDoc.GetAttrPool(),
+ svl::Items<
+ RES_PARATR_LINESPACING, RES_PARATR_OUTLINELEVEL,
+ RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1>{});
+
+ SfxItemSet aTmp2(
+ m_rDoc.GetAttrPool(),
+ svl::Items<
+ RES_PARATR_LINESPACING, RES_PARATR_OUTLINELEVEL,
+ RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1>{});
+
+ pDelNode->GetParaAttr(aTmp, 0, 0);
+ pTextNode->GetParaAttr(aTmp2, 0, 0);
+
+ for( sal_uInt16 nItem = 0; nItem < aTmp.TotalCount(); ++nItem)
+ {
+ sal_uInt16 nWhich = aTmp.GetWhichByPos(nItem);
+ if( SfxItemState::SET == aTmp.GetItemState( nWhich, false ) &&
+ SfxItemState::SET != aTmp2.GetItemState( nWhich, false ) )
+ aTmp2.Put( aTmp.GetPool()->GetDefaultItem(nWhich), nWhich );
+ }
+
+ if (aTmp2.Count())
+ m_rDoc.getIDocumentContentOperations().InsertItemSet(aPam, aTmp2);
+ }
}
else
{