sw/qa/extras/uiwriter/data2/tdf54819.fodt     |    9 ++++++
 sw/qa/extras/uiwriter/uiwriter2.cxx           |   36 ++++++++++++++++++++++++++
 sw/source/core/doc/DocumentRedlineManager.cxx |   13 +++++++++
 3 files changed, 58 insertions(+)

New commits:
commit 22639148ae5400bac98f32a75d7431b857c80195
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Tue Aug 28 18:23:17 2018 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Wed Sep 5 07:41:09 2018 +0200

    tdf#54819 change tracking: keep paragraph style after full deletion
    
    of the previous paragraph(s), as in editing without change tracking.
    
    This is a workaround for the regression introduced by #i100466#.
    
    NOTE: We change the style of the first removed paragraph to restore
    normal editing function during change tracking, too. Manual fix
    of the spoiled paragraph does the same style changes in the
    previously deleted paragraphs, so this commit doesn't introduce
    any new oddity.
    
    Change-Id: I9565e600ec86adc95246ff899d58de79f3c3a996
    Reviewed-on: https://gerrit.libreoffice.org/59820
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/qa/extras/uiwriter/data2/tdf54819.fodt 
b/sw/qa/extras/uiwriter/data2/tdf54819.fodt
new file mode 100644
index 000000000000..f9a8e9d0b698
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data2/tdf54819.fodt
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
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:config="urn:oas
 is:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
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:rpt="http://openoffice.org/2005/report"; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:formx="urn:openoffice:names:
 experimental:ooxml-odf-interop:xmlns:form:1.0" 
xmlns:css3t="http://www.w3.org/TR/css3-text/"; office:version="1.2" 
office:mimetype="application/vnd.oasis.opendocument.text">
+  <office:body>
+    <office:text>
+      <text:h>Lorem ipsum</text:h>
+      <text:p>dolor sit amet.</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 239700294b71..0a789a73b87d 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -11,6 +11,7 @@
 #include <com/sun/star/awt/FontSlant.hpp>
 #include <swdtflvr.hxx>
 #include <wrtsh.hxx>
+#include <redline.hxx>
 
 namespace
 {
@@ -22,9 +23,11 @@ class SwUiWriterTest2 : public SwModelTestBase
 {
 public:
     void testTdf101534();
+    void testTdf54819();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest2);
     CPPUNIT_TEST(testTdf101534);
+    CPPUNIT_TEST(testTdf54819);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -55,6 +58,39 @@ void SwUiWriterTest2::testTdf101534()
     CPPUNIT_ASSERT(aSet.HasItem(RES_LR_SPACE));
 }
 
+void SwUiWriterTest2::testTdf54819()
+{
+    load(DATA_DIRECTORY, "tdf54819.fodt");
+
+    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+
+    CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
+                         getProperty<OUString>(getParagraph(1), 
"ParaStyleName"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Standard"),
+                         getProperty<OUString>(getParagraph(2), 
"ParaStyleName"));
+
+    //turn on red-lining and hide changes
+    SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+    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 first paragraph with paragraph break
+    SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+    pWrtShell->EndPara(/*bSelect=*/true);
+    pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, 
/*bBasicCall=*/false);
+    rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell);
+    pTransfer->Cut();
+
+    // remaining paragraph keeps its original style
+    CPPUNIT_ASSERT_EQUAL(OUString("Standard"),
+                         getProperty<OUString>(getParagraph(1), 
"ParaStyleName"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index a47b75629940..6838e7fc8dcd 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -1680,7 +1680,20 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* 
pNewRedl, bool const bCall
                 pNewRedl = nullptr;
             }
             else
+            {
+                if (pStt->nContent == 0)
+                {
+                    // tdf#54819 to keep the style of the paragraph
+                    // after the fully deleted paragraphs (normal behaviour
+                    // of editing without change tracking), we copy its style
+                    // to the first removed paragraph.
+                    SwTextNode* pDelNode = pStt->nNode.GetNode().GetTextNode();
+                    SwTextNode* pTextNode = 
pEnd->nNode.GetNode().GetTextNode();
+                    if (pDelNode != nullptr && pTextNode != nullptr && 
pDelNode != pTextNode)
+                        pTextNode->CopyCollFormat( *pDelNode );
+                }
                 mpRedlineTable->Insert( pNewRedl );
+            }
         }
 
         if( bCompress )
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to